home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
prog
/
c
/
parse.lha
/
parse.autodoc
< prev
next >
Wrap
Text File
|
1992-08-11
|
3KB
|
119 lines
TABLE OF CONTENTS
parse/parse
parse/parse_cleanup
parse/parse parse/parse
NAME
parse - parse command line to fetch options
SYNOPSYS
number = parse( descrip, argc, argv, rapport )
char char * int char** struct rapport *
FUNCTION
This function take the common C descriptors of the command line
and parse it until it runs out of options or find a syntax error
(according to OSF conventions relatives to options parsing).
Its results are stored in a convenient structure.
Does performs memory allocation, so parse_cleanup() may have to
be called after (see further on).
INPUTS
descrip : characters stringsdescribing the options. It is a sequence
of letter followed by either a space (0x20) if the option
has no argument or by a semicolon if the option has an
argument.
argc : the argc directly got from main()
argv : the argv directly got from main()
report : pointer to an existent struct rapport (not initialized)
RESULTS
-1 : there was either a lack of memory or a syntax error. In any
case, parse_cleanup() has not to be called.
The error code and the eventual guilty letter are indicated
in the struct rapport transmitted to.
any other : everything is OK and the number is that of options
presently recognized by the program. parse_cleanup() *must*
be called later.
The option and theirs contents are indicated in the structure
rapport. The number of remaining arguments and a vector of
them (pointing on the first one) are also in that structure.
EXCEPTIONS
EXAMPLE
void main (int argc, char *argv[])
{
struct rapport report;
char nopt;
nopt = parse("h o;v r ", argc, argv, &report);
if (nopt < 0) {
fprintf(stderr, ParseErrMess, report.lettre);
fputc('\n', stderr);
exit(10);
}
if (report.options[0] && report.narg == 0) {
puts("fubar version 0.01a");
exit(0);
}
/.../
parse_cleanup();
exit(0);
}
SEE ALSO
parse_cleanup
BUGS
AUTHOR
Jean-Pierre Rivière
Last modified on 01 Aug 92
parse/parse_cleanup parse/parse_cleanup
NAME
parse_cleanup - release memory after a successfull call to parse
SYNOPSYS
result = parse( void )
char
FUNCTION
This function frees the resources allocated by parse.
Call it only if a previous call to parse was successful.
INPUTS
RESULTS
1 : the resources have been freed.
0 : error - you were not right to call the function (no harm was
done yet)
EXCEPTIONS
EXAMPLE
SEE ALSO
parse_cleanup
BUGS
AUTHOR
Jean-Pierre Rivière
Last modified on 01 Aug 92