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.

60 lines
2.1 KiB

  1. //////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // string.c
  4. //
  5. // This file contains most commonly used string operation. ALl the setup project should link here
  6. // or add the common utility here to avoid duplicating code everywhere or using CRT runtime.
  7. //
  8. // Created 4\15\997 inateeg
  9. //
  10. ///////////////////////////////////////////////////////////////////////////////////////////////////
  11. #include <windows.h>
  12. #include "sdsutils.h"
  13. //=================================================================================================
  14. //
  15. // copied from \\trango\slmadd\src\shell\shlwapi\strings.c
  16. //
  17. // ChrCmp - Case sensitive character comparison for DBCS
  18. // Assumes w1, wMatch are characters to be compared
  19. // Return FALSE if they match, TRUE if no match
  20. //
  21. //=================================================================================================
  22. BOOL ChrCmpA_inline(WORD w1, WORD wMatch)
  23. {
  24. /* Most of the time this won't match, so test it first for speed.
  25. */
  26. if (LOBYTE(w1) == LOBYTE(wMatch))
  27. {
  28. if (IsDBCSLeadByte(LOBYTE(w1)))
  29. {
  30. return(w1 != wMatch);
  31. }
  32. return FALSE;
  33. }
  34. return TRUE;
  35. }
  36. //=================================================================================================
  37. //
  38. // copied from \\trango\slmadd\src\shell\shlwapi\strings.c
  39. //
  40. // StrChr - Find first occurrence of character in string
  41. // Assumes lpStart points to start of null terminated string
  42. // wMatch is the character to match
  43. // returns ptr to the first occurrence of ch in str, NULL if not found.
  44. //
  45. //=================================================================================================
  46. LPSTR FAR ANSIStrChr(LPCSTR lpStart, WORD wMatch)
  47. {
  48. for ( ; *lpStart; lpStart = CharNext(lpStart))
  49. {
  50. // (ChrCmp returns FALSE when characters match)
  51. if (!ChrCmpA_inline(*(UNALIGNED WORD FAR *)lpStart, wMatch))
  52. return((LPSTR)lpStart);
  53. }
  54. return (NULL);
  55. }