/* GETCMD.H A library for managing a command processing queue. 'getcmd' puts words on a queue. 'iscmd' and others process the words. See GETCMD.C for more details. */ void getcmd (char *prompt, char *retword); /* 'prompt' - string issued if command queue is empty. 'retword' - word or string returned from commmand queue Maintains a queue (fifo stack) of tokens. The front token is returned as 'retword'. If the queue is empty, prints the 'prompt', and uses getword to get 'retword' from standard input. */ int iscmd(char *entered, char *cmd); /* 'entered' - a token accepted from the getcmd queue. 'cmd' - the string against which 'entered' is checked. Returns 1 if 'input' is the same as 'cmd', else returns 0. Will accept abbreviations. See the comments with iscmd for details on abbreviations. */ void flushcmd(char *warning, char *about, int flag); /* 'warning' - optional string for printing 'about' - second optional string for printing 'flag' - if 0, don't print warnings. Removes everything on the command queue and prints a 'warning' 'about' something. */ int getint(char *prompt, int *retnum); /* 'prompt' - string printed if the command queue is empty. 'retnum' - number returned from the command queue. Use this to prompt for an integer. Function value is 1 if a number has been entered, 0 if user has entered an 'exit'. In the latter case retnum is undefined. */ int getdouble(char *prompt, double *retnum); /* 'prompt' - string printed if the command queue is empty. 'retnum' - number returned from the command queue. Use this to prompt for a real number. Function value is 1 if a number has been entered, 0 if user has entered an 'exit'. In the latter case retnum is undefined. */ int morecmd(void); /* Returns the number of commands that remain to be processed. */ int getifint(int *retnum); /* 'retnum' - number to be returned from the command queue, if there was an integer. Use this to get an optional integer. Function value is 1 if an integer was at the front of the queue, else 0. Example of use. Compare the two streams: 'set value do next job' 'set value 10 do next job' getifint would be used after 'value' is accepted to set a value to 10 if the second stream is entered, or do nothing if the first stream is entered. User could supply a default integer if the returned function value was 0. */ void pushcmd(char *cmd); /* 'cmd' - a command to be returned to the queue. Puts 'cmd' at the front of the queue. Used for filling the command stack from the program, and for returning commands to the queue that should be used during the next invocation of getcmd. */ void showcmd(char *strn); /* 'strn' - something to be printed. Use this for debugging purposes. It reports the commands that remain to be processed, the value of the command pointer and the queue top pointer. */ int getword(char *token); /* 'token' - word or string returned from standard input. Used by getcmd. */ int getifcmd(char *cmd, char *queuword); /* 'cmd' - string to be returned from the command queue, if it is there 'cmdstr' - returned string. Tests the command queue to see if the next command is 'cmd'. If it is, it is removed from the queue and returned in 'cmdstr', and the function value is 1. If it is not, 'cmdstr' is undefined, and function value is 0. Example of use: 'set trace' and 'set no trace'. getifcmd would be used to detect if the word after 'set' was 'no', with no effect on the word 'trace'. 'cmd' may be abbreviated. See the comments in routine iscmd for how abbreviation is handled. */