/* DOSPASTE.C 1/28/86 - 2/18/86 MDF */ /* dp_kbint() updated for extended funcs 2006-03-04 BALJ */ /* * Copyright 1999, Caldera Thin Clients, Inc. * This software is licenced under the GNU Public License. * Please see LICENSE.TXT for further information. */ #include #include #include #define CR '\015' #define LF '\012' #define RDBUFFSZ 512 #define PBUFFSZ 2000 EXTERN WORD DOS_ERR; EXTERN WORD dos_open(); EXTERN WORD dos_read(); EXTERN VOID dos_close(); EXTERN LONG dos_alloc(); EXTERN VOID dos_free(); EXTERN VOID take_kbd(); /* in stealkbd.a86 */ EXTERN VOID rest_kbd(); EXTERN WORD parse_tbl(); /* in tblparse.c */ MLOCAL WORD next_key; MLOCAL WORD dp_savch; /* first char after margin */ MLOCAL WORD dp_infile; MLOCAL WORD dp_marg; MLOCAL WORD* dp_chpt; MLOCAL WORD dp_chnum; MLOCAL WORD dp_atend; MLOCAL LONG dp_rdbuf; MLOCAL WORD dp_rdlen; /* Table of scan codes ordered by ASCII value of characters. */ /* Values come from diagram on page 1-76 of PC-DOS 2.02 Tech. */ /* Reference. */ MLOCAL UBYTE scancodes[] = { /* 0-9 */ 0, 30, 48, 46, 32, 18, 8, 34, 14, 15, /* 10 */ 36, 37, 38, 28, 49, 24, 25, 16, 19, 31, /* 20 */ 20, 22, 47, 17, 45, 21, 44, 1, 43, 27, /* 30 */ 0, 0, 57, 2, 40, 4, 5, 6, 8, 40, /* 40 */ 10, 11, 55, 13, 51, 12, 52, 53, 11, 2, /* 50 */ 3, 4, 5, 6, 7, 8, 9, 10, 39, 39, /* 60 */ 51, 13, 52, 53, 3, 30, 48, 46, 32, 18, /* 70 */ 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, /* 80 */ 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, /* 90 */ 44, 26, 43, 27, 7, 12, 41, 30, 48, 46, /* 100 */ 32, 18, 8, 34, 35, 23, 36, 37, 38, 50, /* 110 */ 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, /* 120 */ 45, 21, 44, 26, 43, 27, 41, 14 }; MLOCAL FILTABLE dp_filtbl; MLOCAL FILTABLE dp_deftbl = { {0}, {0}, {0x1C0D}, /* RETURN key */ {0}, 0x3920, /* space bar */ 0, 0 }; /* Filter Table Keywords, etc. */ #define NKWRDS 7 #define PBKEY 0 #define PSKEY 1 #define PLKEY 2 #define PEKEY 3 #define PFKEY 4 #define CMKEY 5 #define PMKEY 6 BYTE *keywords[NKWRDS] = { "PB=", "PS=", "PL=", "PE=", "PF=", "CM=", "PM=" }; /************************************************************************/ /* */ /* dp_schar() -- returns scan code/ASCII character pair in word */ /* */ /* Looks up scan code based on ASCII value and puts scan code */ /* into high byte, character into low byte. */ /* */ /************************************************************************/ WORD dp_schar(ch) BYTE ch; { WORD code; code = scancodes[ch & 0x7F] << 8; /* mask out high bit */ return(code + ch); } /************************************************************************/ /* */ /* dp_isskip() -- returns true if character should be ignored */ /* */ /* */ /************************************************************************/ WORD dp_isskip(wch) WORD wch; { WORD i; for (i=0; i= 'a') && (ch <= 'z') ) return(ch - 32); else return(ch); } WORD is_digit(ch) BYTE ch; { return((ch>='0') && (ch<='9')); } WORD is_xdigit(ch) BYTE ch; { ch = toupper(ch); return(is_digit(ch) || ((ch>='A') && (ch<='F'))); } WORD dp_dconv(ch) BYTE ch; { return(is_digit(ch)?(ch - '0'):(toupper(ch)-'A'+10)); } /************************************************************************/ /* */ /* dp_atoi() -- convert ASCII to integer */ /* */ /* */ /************************************************************************/ WORD dp_atoi(st_ad, len, base) LONG st_ad; WORD len; { WORD i; WORD total; total = 0; for (i=0; i