home *** CD-ROM | disk | FTP | other *** search
- Parse
- =====
-
- This program is not in the public domain, but it may be freely copied
- and distributed for no charge providing this header is included.
- The code may be modified as required, but any modifications must be
- documented so that the person responsible can be identified. If someone
- else breaks this code, I don't want to be blamed for code that does not
- work! The code may not be sold commercially without prior permission from
- the author, although it may be given away free with commercial products,
- providing it is made clear that this program is free and that the source
- code is provided with the program.
-
- ****************************************************************************
-
- Description:
- ============
-
- parse() is a simple command line keyword parser which will accept upper
- or lower case commands and abbreviations.
-
- Comment lines may be indicated using a !.
-
- The keyword structure array and returned string array are defined thus:
- KeyWd keywords[NCOMM];
- char *strparam[MAXSTRPARAM];
-
- The returned float parameters are defined thus:
- float floatparam[MAXFLOATPARAM];
-
- Space for the returned strings must be allocated thus:
- strparam[n] = (char *)malloc(MAXSTRLEN * sizeof(char));
- and repeated for each parameter.
-
- The keyword list with type and numbers of returned parameters is
- constructed using the MAKEKEY macro:
- MAKEKEY(keywords[0],"RANGE",NUMBER,2);
- MAKEKEY(keywords[1],"STRING",STRING,1);
-
- Here, the keywords must be defined in upper case.
-
-
- An example is contained in the source file and may be compiled by
- #define'ing DEMO
-
- **************************************************************************
- Usage:
- ======
-
- MAKEKEY(keywd,text,type,nparam)
- -------------------------------
- Output: KeyWd keywd The completed KeyWd structure
- Input: char *text The text for the keyword (must be
- upper case).
- int type Does the keyword expect string or
- numeric parameters (STRING or NUMBER)
- int nparam The number of parameters expected.
-
- MAKEKEY() is a macro to fill in a KeyWd structure
-
-
- parse(comline,nkeys,keywords,floatparam,strparam)
- -------------------------------------------------
- Input: char *comline A command line string to parse
- int nkeys Number of keywords
- KeyWd *keywords Array of keyword structures
- Output: float *floatparam Array of returned strings
- char **strparam Array of pointers to returned strings
- Returns: int Index of found command or error flag
- ****************************************************************************
-
-