/* parse.c - Parser for Report tool. This module is part of report.exe Language = Microsoft C version 4.0 This source is distributed freely and may be copied and redistributed with the following provisos: You may not sell it, nor may you charge for making copies beyond the actual cost of mailing and media. Written by Skip Hansen WB6YMH and Harold Price NK6K. Feedback is desired. RCP/M (213) 541-2503 300/1200/2400 baud or via packet WB6YMH @ WB6YMH-2 or NK6K @ NK6K Modification history: 8/10/87 NK6K: Initial release. ver 1.0 10/18/87 NK6K: First general release. ver 1.1 Notes: This was a quick grab from something else that was laying around, and has several hooks for things which aren't actually here. On the other hand, it does the job. To add new commands, add the text to parse.h and a new case in doit() below. */ #include "parse.h" #include #include #include #define promptlen 4; int ars,point,ppoint,i,tc; unsigned int pnum; int old_more; char token[129]; char buf[128]; int ctype; int ltype; int first_com_g; int tflag,ok,eh; #define true 1 #define false 0 int point; enum ttypes { notoken, alftoken, numtoken, qmarktoken, /* ? */ cmarktoken, /* ; */ qtmarktoken, /* " */ errtoken} typtoken; char oplist[] = " ?;\""; FILE *fin, *fout, *fopen(); int in_open = 0; int out_open = 0; /* global defs */ char sel_call[11]; int sel_flag=0; char sel_types[0]="CDFIT"; unsigned long recnum; int sp_skip(i) int i; { int looping; looping = true; point = i; while (looping) { if (point >=ars) looping = false; else if(buf[point]==' ') point++; else looping = false; } return(point=ars) { looping=false; point++; /* skip past ' */ } else if (buf[point+1]=='"') { /* put a ' into the token */ tc++; if (tc<127) token[tc] = c; point+=2; /* skip past both ' */ } else { looping=false; point++; /* skip past closing ' */ } } else { tc++; if (tc<127) token[tc] = c; point++; if (point>=ars) { looping = false; typtoken=errtoken; /* no trailing ' */ } } } /* while looping */ } /* end if qtmark */ else if (looping) { /* alphanumeric token */ typtoken=alftoken; while (looping) { c = buf[point]; if ((isalnum(c)) || (c=='_') || (c=='.') || (c=='-') || (c=='/')||(c=='\\')) { tc++; if (tc<127) token[tc] = c; point++; if (point>=ars) looping = false; } else if (NULL==strchr(oplist,c)) { looping = false; typtoken=errtoken; } else looping = false; } } token[tc+1]='\0'; /* now characterize it */ if (typtoken==alftoken) { /* alphanumeric, check for numeric */ typtoken = numtoken; for (i=0;i