Source code of Windows XP (NT5)
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.

55 lines
1.0 KiB

  1. /***************************** Module Header ****************************\
  2. * Copyright (c) 1990-1999 Microsoft Corporation
  3. *
  4. * Module Name: util.c
  5. *
  6. * Extended functions for opening files on environment paths.
  7. *
  8. * Created: 01-May-90
  9. *
  10. * History:
  11. * 01-May-90 created by SMeans
  12. *
  13. \************************************************************************/
  14. #include <stdio.h>
  15. #include <string.h>
  16. FILE *pfopen(const char *path, char *search, const char *type)
  17. {
  18. char szTmp[256];
  19. char *pszEnd;
  20. char c;
  21. FILE *fp;
  22. if (!(pszEnd = search)) {
  23. return fopen(path, type);
  24. }
  25. c = *search;
  26. while (c) {
  27. while (*pszEnd && *pszEnd != ';') {
  28. pszEnd++;
  29. }
  30. c = *pszEnd;
  31. *pszEnd = '\0';
  32. strcpy(szTmp, search);
  33. *pszEnd = c;
  34. if (szTmp[strlen(szTmp) - 1] != '\\') {
  35. strcat(szTmp, "\\");
  36. }
  37. strcat(szTmp, path);
  38. if (fp = fopen(szTmp, type)) {
  39. return fp;
  40. }
  41. search = ++pszEnd;
  42. }
  43. return (FILE *)NULL;
  44. }