]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/lib_head.c
wwww porting~
[16.git] / src / lib / lib_head.c
index 0f080bcaae4c227258b3c080513cbb9db08545ed..4ca25c9cbc48fe153f5311d45462810c542fb440 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #include "src/lib/lib_head.h"
-\r
+
 /* local function */\r
 void wait(clock_t wait);
 void* AllocateLargestFreeBlock(size_t* Size);
@@ -128,3 +128,38 @@ filesize(FILE *fp)
        fseek(fp, save_pos, SEEK_SET);\r
        return(size_of_file);\r
 }
+
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//      US_CheckParm() - checks to see if a string matches one of a set of\r
+//              strings. The check is case insensitive. The routine returns the\r
+//              index of the string that matched, or -1 if no matches were found\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+int\r
+US_CheckParm(char *parm,char **strings)\r
+{\r
+       char    cp,cs,\r
+                       *p,*s;\r
+       int             i;\r
+\r
+       while (!isalpha(*parm)) // Skip non-alphas\r
+               parm++;\r
+\r
+       for (i = 0;*strings && **strings;i++)\r
+       {\r
+               for (s = *strings++,p = parm,cs = cp = 0;cs == cp;)\r
+               {\r
+                       cs = *s++;\r
+                       if (!cs)\r
+                               return(i);\r
+                       cp = *p++;\r
+\r
+                       if (isupper(cs))\r
+                               cs = tolower(cs);\r
+                       if (isupper(cp))\r
+                               cp = tolower(cp);\r
+               }\r
+       }\r
+       return(-1);\r
+}