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.

94 lines
2.4 KiB

  1. //+-------------------------------------------------------------------------
  2. // Microsoft Windows
  3. //
  4. // Copyright (C) Microsoft Corporation, 1995 - 1999
  5. //
  6. // File: pkistr.cpp
  7. //
  8. // Contents: PKI String Functions
  9. //
  10. // Functions: Pki_wcsicmp
  11. // Pki_wcsnicmp
  12. // Pki_stricmp
  13. // Pki_strnicmp
  14. //
  15. // History: 21-May-99 philh created
  16. //--------------------------------------------------------------------------
  17. #include "global.hxx"
  18. #include <dbgdef.h>
  19. #define NO_LOCALE MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
  20. //+-------------------------------------------------------------------------
  21. // CompareString is called with the following locale:
  22. // MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
  23. //--------------------------------------------------------------------------
  24. int __cdecl Pki_wcsicmp(const wchar_t *pwsz1, const wchar_t *pwsz2)
  25. {
  26. return CompareStringU(
  27. NO_LOCALE,
  28. NORM_IGNORECASE,
  29. pwsz1,
  30. -1,
  31. pwsz2,
  32. -1) - CSTR_EQUAL;
  33. }
  34. int __cdecl Pki_wcsnicmp(const wchar_t *pwsz1, const wchar_t *pwsz2,
  35. size_t cch)
  36. {
  37. const wchar_t *pwsz;
  38. size_t cch1;
  39. size_t cch2;
  40. for (cch1 = 0, pwsz = pwsz1; cch1 < cch && L'\0' != *pwsz; cch1++, pwsz++)
  41. ;
  42. for (cch2 = 0, pwsz = pwsz2; cch2 < cch && L'\0' != *pwsz; cch2++, pwsz++)
  43. ;
  44. return CompareStringU(
  45. NO_LOCALE,
  46. NORM_IGNORECASE,
  47. pwsz1,
  48. (int) cch1,
  49. pwsz2,
  50. (int) cch2) - CSTR_EQUAL;
  51. }
  52. int __cdecl Pki_stricmp(const char *psz1, const char *psz2)
  53. {
  54. return CompareStringA(
  55. NO_LOCALE,
  56. NORM_IGNORECASE,
  57. psz1,
  58. -1,
  59. psz2,
  60. -1) - CSTR_EQUAL;
  61. }
  62. int __cdecl Pki_strnicmp(const char *psz1, const char *psz2,
  63. size_t cch)
  64. {
  65. const char *psz;
  66. size_t cch1;
  67. size_t cch2;
  68. for (cch1 = 0, psz = psz1; cch1 < cch && '\0' != *psz; cch1++, psz++)
  69. ;
  70. for (cch2 = 0, psz = psz2; cch2 < cch && '\0' != *psz; cch2++, psz++)
  71. ;
  72. return CompareStringA(
  73. NO_LOCALE,
  74. NORM_IGNORECASE,
  75. psz1,
  76. (int) cch1,
  77. psz2,
  78. (int) cch2) - CSTR_EQUAL;
  79. }