| Line |  | 
|---|
| 1 | /* $Id: stricmp.c,v 1.2 1999-10-14 01:19:21 bird Exp $ | 
|---|
| 2 | * | 
|---|
| 3 | * stricmp - Case insensitive string compare. | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright (c) 1999 knut st. osmundsen | 
|---|
| 6 | * | 
|---|
| 7 | */ | 
|---|
| 8 |  | 
|---|
| 9 | /******************************************************************************* | 
|---|
| 10 | *   Defined Constants                                                          * | 
|---|
| 11 | *******************************************************************************/ | 
|---|
| 12 | #define upcase(ch)   \ | 
|---|
| 13 | (ch >= 'a' && ch <= 'z' ? ch - ('a' - 'A') : ch) | 
|---|
| 14 |  | 
|---|
| 15 |  | 
|---|
| 16 | /******************************************************************************* | 
|---|
| 17 | *   Header Files                                                               * | 
|---|
| 18 | *******************************************************************************/ | 
|---|
| 19 | #include <string.h> | 
|---|
| 20 | #pragma info(nogen, noext, nouni) | 
|---|
| 21 |  | 
|---|
| 22 | /** | 
|---|
| 23 | * stricmp - case insensitive string compare. | 
|---|
| 24 | * Not i subsys library. | 
|---|
| 25 | * @param   psz1   String 1 | 
|---|
| 26 | * @param   psz2   String 2 | 
|---|
| 27 | * @return  0 if equal | 
|---|
| 28 | *          != 0 if not equal | 
|---|
| 29 | */ | 
|---|
| 30 | int stricmp(const char *psz1, const char *psz2) | 
|---|
| 31 | { | 
|---|
| 32 | int iRet; | 
|---|
| 33 |  | 
|---|
| 34 | while ((iRet = upcase(*psz1) - upcase(*psz2)) == 0 && *psz1 != '\0') | 
|---|
| 35 | psz1++, psz2++; | 
|---|
| 36 |  | 
|---|
| 37 | return iRet; | 
|---|
| 38 | } | 
|---|
| 39 |  | 
|---|
| 40 |  | 
|---|
| 41 |  | 
|---|
| 42 | /** | 
|---|
| 43 | * strnicmp - case insensitive string compare for up to cch chars of the strings. | 
|---|
| 44 | * Not i subsys library. | 
|---|
| 45 | * @param   psz1   String 1 | 
|---|
| 46 | * @param   psz2   String 2 | 
|---|
| 47 | * @return  0 if equal | 
|---|
| 48 | *          != 0 if not equal | 
|---|
| 49 | */ | 
|---|
| 50 | int strnicmp(const char *psz1, const char *psz2, size_t cch) | 
|---|
| 51 | { | 
|---|
| 52 | int iRet; | 
|---|
| 53 |  | 
|---|
| 54 | while (cch > 0 && (iRet = upcase(*psz1) - upcase(*psz2)) == 0 && *psz1 != '\0') | 
|---|
| 55 | psz1++, psz2++, cch--; | 
|---|
| 56 |  | 
|---|
| 57 | return iRet; | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.