/* librock/text/ssmonth.c librock_CHISEL _summary String scan for a month name. Copyright (c) 2001-2002, Forrest J. Cavalier III, doing business as Mib Software, Saylorsburg Pennsylvania USA Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef librock_NOTLIBROCK /**************************************************************/ /* ABOUT THIS FILE: GUIDE TO QUICK REUSE WITHOUT REWORK This file uses many preprocessor conditional blocks and features to publish http://www.mibsoftware.com/librock/ You can disable those features with little or no editing, and reuse this file: 1. At compile time, enable this conditional block by defining the preprocessor symbol librock_NOTLIBROCK, either with a compiler command line parameter, or as a #define in a source file which then #includes this source file. 2. Define any preprocessor symbols in this block (if any) appropriately for your machine and compilation environment. 3. Copy and use the declarations from this block in your source files as appropriate. This file is originally from the librock library, which is Free (libre), free (no cost), rock-stable API, and works on gcc/MSVC/Windows/Linux/BSD/more. Get originals, updates, license certificates, more, at http://www.mibsoftware.com/librock/ (Change log appears at end of this file.) */ #ifdef librock_NOTLIBROCK /**************************************************************/ /* ABOUT THIS FILE: GUIDE TO QUICK REUSE WITHOUT REWORK This file uses many preprocessor conditional blocks and features to publish http://www.mibsoftware.com/librock/ You can disable those features with little or no editing, and reuse this file: 1. At compile time, enable this conditional block by defining the preprocessor symbol librock_NOTLIBROCK, either with a compiler command line parameter, or as a #define in a source file which then #includes this source file. 2. Define any preprocessor symbols in this block (if any) appropriately for your machine and compilation environment. 3. Copy and use the declarations from this block in your source files as appropriate. This file is originally from the librock library, which is Free (libre), free (no cost), rock-stable API, and works on gcc/MSVC/Windows/Linux/BSD/more. Get originals, updates, license certificates, more, at http://www.mibsoftware.com/librock/ (Change log appears at end of this file.) */ #define librock_ISOLATED #define librock_PTR #define librock_CONST const #define librock_PRIVATE /**************************************************************/ #endif #define librock_ISOLATED #define librock_PTR #define librock_CONST const #ifndef librock_strncasecmp #ifdef _MSC_VER #define librock_strncasecmp strnicmp #else #define librock_strncasecmp strncasecmp #endif #endif #include /**************************************************************/ #endif #ifndef librock_ISOLATED /**************************************************************/ #define librock_IMPLEMENT_ssmonth #include #include #include /**************************************************************/ #endif #ifdef librock_IMPL_LIDESC #ifndef librock_NOIMPL_LIDESC_ssmonth /**************************************************************/ #include /* librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45 */ void *librock_LIDESC_ssmonth[] = { "\n" __FILE__ librock_LIDESC_librock "\n", 0 }; /**************************************************************/ #endif #endif #ifndef librock_WRAP /**************************************************************/ #define librock_body_ssmonth librock_ssmonth /**************************************************************/ #endif /**************************************************************/ librock_PRIVATE char librock_PTR *months[] = { "january","february","march","april","may","june", "july","august","september","october","november","december" }; #ifndef librock_NOIMPL_ssmonth #define librock_FNTYPE_ssmonth fni_s_I /**************************************************************/ int librock_body_ssmonth(const char librock_PTR *sptr,int librock_PTR *piMonth) { /* Will take 3 letter abbreviations or full month name */ /* Copyright 1998-2001, Forrest J. Cavalier III d-b-a Mib Software Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block. License, originals, details: http://www.mibsoftware.com/librock/ */ #ifdef librock_MANUAL_ssmonth /* librock_ssmonth - Recognize 3 letter month abbreviations, or full month name, case insensitive. */ /**/ #include int librock_ssmonth( const char *sptr, int *piMonth ); /* Returns the number of characters matched. Stores a month 1-12 at *piMonth if matched. Typical use is */ #ifdef librock_TYPICAL_USE_ssmonth const char *ptr = "January 12, 2001"; int iMonth; if (librock_ssmonth(ptr,&iMonth)) { printf("Month: %d\n",iMonth); } #endif /* strlen() librock_strncasecmp() */ /* Copyright 1998-2002 Forrest J. Cavalier III, http://www.mibsoftware.com Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block. License text in librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45 */ #endif /* MANUAL */ /*-------------------------------------------*/ int ind; for(ind = 0;ind < 12;ind++) { if (!librock_strncasecmp(sptr,months[ind],3)) { if (piMonth) { *piMonth = ind+1; } if (!librock_strncasecmp(sptr,months[ind],strlen(months[ind]))) { return strlen(months[ind]); } return 3; } } return 0; } /* ssmonth */ /**************************************************************/ #endif /* NOIMP section */ /* $Log: ssmonth.c,v $ Revision 1.6 2002/08/01 20:37:07 forrest@mibsoftware.com rights=#1 Updated TYPICAL_USE section. Added NOTLIBROCK section. Moved CVS log to end. Changed LIDESC MD5 to HC. Revision 1.5 2002/04/09 03:39:35 forrest@mibsoftware.com rights=#1 Added FNTYPEs. Updated LICENSE in manual pages. Revision 1.4 2002/02/08 12:47:56 forrest@mibsoftware.com rights=#1 Adjust comments Revision 1.3 2002/02/08 12:45:55 forrest@mibsoftware.com rights=#1 TABS to spaces, standardized chg log Revision 1.2 2002/01/30 16:08:06 forrest@mibsoftware.com rights=#1 Renamed some .h files Revision 1.1 2002/01/29 13:52:56 forrest@mibsoftware.com rights=#1 Initial rights#1 Copyright (c) Forrest J Cavalier III d-b-a Mib Software rights#1 License text in librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45 */