home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / utility / strnicmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  2.0 KB  |  91 lines

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