X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Flib_head.c;h=4ca25c9cbc48fe153f5311d45462810c542fb440;hb=5ab89616163e37b41b208796e3455b891bda44dc;hp=0053446f965d4a2accf812e15c89a37b0c75e3f6;hpb=8b92f32b6e6a8ab7be52ced02208cc789364a014;p=16.git diff --git a/src/lib/lib_head.c b/src/lib/lib_head.c index 0053446f..4ca25c9c 100644 --- a/src/lib/lib_head.c +++ b/src/lib/lib_head.c @@ -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 , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + #include "src/lib/lib_head.h" - + /* local function */ void wait(clock_t wait); void* AllocateLargestFreeBlock(size_t* Size); @@ -106,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); +}