/********************************************************* * * args.c * * The implementation of the UNIX command line argument * processing package. See args.h for a description of * the assumptions that this package makes. * ********************************************************/ #include "args.h" #include /* for isalpha and isdigit */ #include /* for strlen, strncpy and strcmp */ #include /* * The get_flag procedure extracts a legal flag from the * character string that is passed to it. The flag is returned * as get_flag's value. * * Pre-conditions: * The input string s contains a valid flag and is NULL terminated * * Post-conditions: * Returns the flag that is the prefix of s, the flag ends at * the first non-alphabetic character. * * Note: the return value is malloc'ed and must be freed by the * calling procedure. */ static char* get_flag(char s[]) { int i; int len; char* result; len = strlen(s); for(i=1; i