]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/lib_head.c
wwww
[16.git] / src / lib / lib_head.c
index 0053446f965d4a2accf812e15c89a37b0c75e3f6..4ca25c9cbc48fe153f5311d45462810c542fb440 100644 (file)
@@ -1,5 +1,27 @@
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
+ *
+ * This file is part of Project 16.
+ *
+ * Project 16 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Project 16 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
 #include "src/lib/lib_head.h"
-\r
+
 /* local function */\r
 void wait(clock_t wait);
 void* AllocateLargestFreeBlock(size_t* Size);
@@ -106,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
+}