"Fossies" - the Fresh Open Source Software Archive

Member "libspf2-1.2.10/src/libreplace/strncasecmp.c" (28 Jan 2012, 512 Bytes) of package /linux/privat/libspf2-1.2.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "strncasecmp.c" see the Fossies "Dox" file reference documentation.

    1 #ifdef HAVE_CONFIG_H
    2 #include "config.h"
    3 #endif
    4 
    5 // #ifndef HAVE_STRNCASECMP
    6 
    7 #include <string.h>
    8 #include <ctype.h>
    9 
   10 int
   11 strncasecmp(const char *s1, const char *s2, size_t n)
   12 {
   13     if (n == 0)
   14         return 0;
   15 
   16     while ((n-- != 0)
   17         && (tolower(*(unsigned char *) s1) ==
   18             tolower(*(unsigned char *) s2))) {
   19         if (n == 0 || *s1 == '\0' || *s2 == '\0')
   20             return 0;
   21         s1++;
   22         s2++;
   23     }
   24 
   25     return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
   26 }
   27 
   28 // #endif                          /* HAVE_STRNCASECMP */