Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.5 KiB

  1. /***
  2. *strstri.cpp - search for one string inside another
  3. *
  4. * Modified from strstr.c in the CRT source code
  5. *
  6. *******************************************************************************/
  7. #include "stdafx.h"
  8. //#include <cruntime.h>
  9. //#include <string.h>
  10. /***
  11. *char *strstri(string1, string2) - case-insensitive search for string2 in string1
  12. *
  13. *Purpose:
  14. * finds the first occurrence of string2 in string1
  15. *
  16. *Entry:
  17. * char *string1 - string to search in
  18. * char *string2 - string to search for
  19. *
  20. *Exit:
  21. * returns a pointer to the first occurrence of string2 in
  22. * string1, or NULL if string2 does not occur in string1
  23. *
  24. *Uses:
  25. *
  26. *Exceptions:
  27. *
  28. *******************************************************************************/
  29. char * __cdecl strstri (
  30. const char * str1,
  31. const char * str2
  32. )
  33. {
  34. char *cp = (char *) str1;
  35. char *s1, *s2;
  36. if ( !*str2 )
  37. return((char *)str1);
  38. while (*cp)
  39. {
  40. s1 = cp;
  41. s2 = (char *) str2;
  42. while ( *s1 && *s2 )
  43. {
  44. #ifdef WIN32
  45. LPTSTR ch1 = CharUpper((LPTSTR)(*s1));
  46. LPTSTR ch2 = CharUpper((LPTSTR)(*s2));
  47. #else
  48. LPSTR ch1 = AnsiUpper((LPSTR)(*s1));
  49. LPSTR ch2 = AnsiUpper((LPSTR)(*s2));
  50. #endif
  51. if (ch1 != ch2)
  52. break;
  53. s1++;
  54. s2++;
  55. }
  56. if (*s2 == '\0')
  57. return(cp);
  58. cp++;
  59. }
  60. return(NULL);
  61. }