X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Flib_head.c;h=4ca25c9cbc48fe153f5311d45462810c542fb440;hb=a423e762973f70f457b66845696d58aa597291ed;hp=0f080bcaae4c227258b3c080513cbb9db08545ed;hpb=d9e8696a3a67052729b1b783f0f3f1b0d20d9e9a;p=16.git diff --git a/src/lib/lib_head.c b/src/lib/lib_head.c index 0f080bca..4ca25c9c 100644 --- a/src/lib/lib_head.c +++ b/src/lib/lib_head.c @@ -21,7 +21,7 @@ */ #include "src/lib/lib_head.h" - + /* local function */ void wait(clock_t wait); void* AllocateLargestFreeBlock(size_t* Size); @@ -128,3 +128,38 @@ filesize(FILE *fp) fseek(fp, save_pos, SEEK_SET); return(size_of_file); } + +/////////////////////////////////////////////////////////////////////////// +// +// US_CheckParm() - checks to see if a string matches one of a set of +// strings. The check is case insensitive. The routine returns the +// index of the string that matched, or -1 if no matches were found +// +/////////////////////////////////////////////////////////////////////////// +int +US_CheckParm(char *parm,char **strings) +{ + char cp,cs, + *p,*s; + int i; + + while (!isalpha(*parm)) // Skip non-alphas + parm++; + + for (i = 0;*strings && **strings;i++) + { + for (s = *strings++,p = parm,cs = cp = 0;cs == cp;) + { + cs = *s++; + if (!cs) + return(i); + cp = *p++; + + if (isupper(cs)) + cs = tolower(cs); + if (isupper(cp)) + cp = tolower(cp); + } + } + return(-1); +}