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.

96 lines
2.0 KiB

  1. /*
  2. * http.cpp
  3. *
  4. * These routines are exported to privately support the
  5. * debugger's http source lookup cababilities.
  6. */
  7. #include "pch.h"
  8. #include "store.hpp"
  9. BOOL
  10. httpOpenFileHandle(
  11. IN LPCSTR srv,
  12. IN LPCSTR path,
  13. IN DWORD options,
  14. OUT HANDLE *hsite,
  15. OUT HANDLE *hfile
  16. )
  17. {
  18. CHAR file[MAX_PATH + 1];
  19. CHAR srvsite[MAX_PATH + 1];
  20. CHAR trgfile[MAX_PATH + 1];
  21. DWORD type;
  22. StoreHTTP *store;
  23. if (strstr(path, "dll.c"))
  24. dprint("%s\n", path);
  25. if (srv && *srv) {
  26. CopyStrArray(srvsite, srv);
  27. if (strstr(path, srvsite) == path)
  28. CopyStrArray(file, path + strlen(srvsite) + 1);
  29. else
  30. CopyStrArray(file, path);
  31. ConvertBackslashes(file);
  32. type = GetStoreType(srvsite);
  33. } else {
  34. type = ParsePath(path, srvsite, file, NULL, false);
  35. }
  36. if (type != stHTTP && type != stHTTPS) {
  37. SetLastError(ERROR_INVALID_PARAMETER);
  38. return false;
  39. }
  40. store = (StoreHTTP *)FindStore(srvsite);
  41. if (!store) {
  42. store = (StoreHTTP *)AddStore(srvsite);
  43. if (!store)
  44. return false;
  45. }
  46. if (!store->init())
  47. return false;
  48. if (!store->open(NULL, file))
  49. return false;
  50. *hsite = store->hsite();
  51. *hfile = store->hfile();
  52. return true;
  53. }
  54. BOOL
  55. httpQueryDataAvailable(
  56. IN HINTERNET hFile,
  57. OUT LPDWORD lpdwNumberOfBytesAvailable OPTIONAL,
  58. IN DWORD dwFlags,
  59. IN DWORD_PTR dwContext
  60. )
  61. {
  62. return InternetQueryDataAvailable(hFile, lpdwNumberOfBytesAvailable, dwFlags, dwContext);
  63. }
  64. BOOL
  65. httpReadFile(
  66. IN HINTERNET hFile,
  67. IN LPVOID lpBuffer,
  68. IN DWORD dwNumberOfBytesToRead,
  69. OUT LPDWORD lpdwNumberOfBytesRead
  70. )
  71. {
  72. return InternetReadFile(hFile, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead);
  73. }
  74. BOOL
  75. httpCloseHandle(
  76. IN HINTERNET hInternet
  77. )
  78. {
  79. return InternetCloseHandle(hInternet);
  80. }