home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / utility / strnicmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  1.8 KB  |  85 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: strnicmp.c,v 1.5 1996/10/24 15:51:38 aros Exp $
  4.     $Log: strnicmp.c,v $
  5.     Revision 1.5  1996/10/24 15:51:38  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/09/13 17:33:30  digulla
  9.     Use the ToLower function instead of the macro
  10.  
  11.     Revision 1.3  1996/08/13 14:10:31  digulla
  12.     Replaced AROS_LA by AROS_LHA
  13.  
  14.     Revision 1.2  1996/08/01 17:41:42  digulla
  15.     Added standard header for all files
  16.  
  17.     Desc:
  18.     Lang: english
  19. */
  20. #include <exec/types.h>
  21. #include <aros/libcall.h>
  22. #include "utility_intern.h"
  23.  
  24. /*****************************************************************************
  25.  
  26.     NAME */
  27.     #include <clib/utility_protos.h>
  28.  
  29.     AROS_LH3(LONG, Strnicmp,
  30.  
  31. /*  SYNOPSIS */
  32.     AROS_LHA(STRPTR, string1, A0),
  33.     AROS_LHA(STRPTR, string2, A1),
  34.     AROS_LHA(LONG,   length,  D0),
  35.  
  36. /*  LOCATION */
  37.     struct UtilityBase *, UtilityBase, 28, Utility)
  38.  
  39. /*  FUNCTION
  40.     Compares two strings treating lower and upper case characters
  41.     as identical up to a given maximum number of characters.
  42.  
  43.     INPUTS
  44.     string1, string2 - The strings to compare.
  45.     length         - maximum number of characters to compare.
  46.  
  47.     RESULT
  48.     <0  if string1 <  string2
  49.     ==0 if string1 == string2
  50.     >0  if string1 >  string2
  51.  
  52.     NOTES
  53.  
  54.     EXAMPLE
  55.  
  56.     BUGS
  57.  
  58.     SEE ALSO
  59.  
  60.     INTERNALS
  61.  
  62.     HISTORY
  63.  
  64. *****************************************************************************/
  65. {
  66.     AROS_LIBFUNC_INIT
  67.     UBYTE c1, c2;
  68.  
  69.     /* 0 characters are always identical */
  70.     if(!length)
  71.     return 0;
  72.  
  73.     /* Loop as long as the strings are identical and valid. */
  74.     do
  75.     {
  76.     /* Get characters, convert them to lower case. */
  77.     c1=ToLower (*string1++);
  78.     c2=ToLower (*string2++);
  79.     }while(c1==c2&&c1&&--length);
  80.  
  81.     /* Get result. */
  82.     return (LONG)c1-(LONG)c2;
  83.     AROS_LIBFUNC_EXIT
  84. } /* Strnicmp */
  85.