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.1 KiB

  1. // wild.c
  2. //
  3. // wildcard file matching
  4. //
  5. //
  6. #include <string.h>
  7. #if defined(OS2)
  8. #define INCL_NOCOMMON
  9. #define INCL_DOSPROCESS
  10. #define INCL_DOSSEMAPHORES
  11. #define INCL_DOSFILEMGR
  12. #define INCL_DOSERRORS
  13. #define INCL_DOSMISC
  14. #include <os2.h>
  15. #else
  16. #include <windows.h>
  17. #endif
  18. #include <dos.h>
  19. #include "hungary.h"
  20. #include "bsc.h"
  21. BOOL BSC_API
  22. FWildMatch(LSZ pchPat, LSZ pchText)
  23. // return TRUE if pchText matchs pchPat in the dos wildcard sense
  24. //
  25. // REVIEW for 1.2 file name support
  26. //
  27. {
  28. for (;;) {
  29. switch (*pchPat) {
  30. case '\0':
  31. return *pchText == '\0';
  32. case '.':
  33. pchPat++;
  34. switch (*pchText) {
  35. case '.':
  36. pchText++;
  37. break;
  38. case '\0':
  39. break;
  40. default:
  41. return FALSE;
  42. }
  43. break;
  44. case '*':
  45. pchPat++;
  46. while (*pchText != '\0' && *pchText != '.')
  47. pchText++;
  48. while (*pchPat != '\0' && *pchPat != '.')
  49. pchPat++;
  50. break;
  51. case '?':
  52. pchPat++;
  53. if (*pchText != '\0' && *pchText != '.')
  54. pchText++;
  55. break;
  56. default:
  57. if (*pchText != *pchPat)
  58. return FALSE;
  59. pchPat++;
  60. pchText++;
  61. break;
  62. }
  63. }
  64. }