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.

180 lines
4.1 KiB

  1. /*
  2. * store.hpp
  3. */
  4. enum {
  5. stHTTP = 0,
  6. stHTTPS,
  7. stUNC,
  8. stError
  9. };
  10. typedef BOOL (*COPYPROC)(DWORD, LPCSTR, LPCSTR, DWORD);
  11. typedef struct _SRVTYPEINFO {
  12. LPCSTR tag;
  13. COPYPROC copyproc;
  14. int taglen;
  15. } SRVTYPEINFO, *PSRVTYPEINFO;
  16. #define SF_DISABLED 0X1
  17. #define SF_INTERNET_DISABLED 0x2
  18. typedef int (*DBGPRINT)(LPSTR, ...);
  19. extern DBGPRINT gdprint;
  20. #define dprint (gdprint)&&gdprint
  21. typedef int (*DBGEPRINT)(LPSTR, ...);
  22. extern DBGEPRINT geprint;
  23. #define eprint (geprint)&&geprint
  24. typedef int (*QUERYCANCEL)();
  25. extern QUERYCANCEL gquerycancel;
  26. __inline BOOL querycancel()
  27. {
  28. if (!gquerycancel)
  29. return false;
  30. return gquerycancel();
  31. }
  32. class Store
  33. {
  34. public:
  35. Store()
  36. {
  37. *m_name = 0;
  38. m_type = 0;
  39. m_flags = 0;
  40. }
  41. DWORD assign(PCSTR name);
  42. char *target();
  43. void setsize(LONGLONG size);
  44. void setbytes(LONGLONG bytes);
  45. virtual BOOL init();
  46. virtual BOOL open(PCSTR rpath, PCSTR file);
  47. virtual BOOL get(PCSTR trg);
  48. virtual VOID close();
  49. virtual BOOL copy(PCSTR rpath, PCSTR file, PCSTR trg);
  50. virtual BOOL ping();
  51. virtual BOOL progress();
  52. protected:
  53. DWORD m_type; // type of site
  54. char m_name[MAX_PATH + 1]; // name of site
  55. DWORD m_flags; // options
  56. char m_rpath[MAX_PATH + 1]; // relative path from node
  57. char m_file[MAX_PATH + 1]; // name of file
  58. char m_spath[MAX_PATH + 1]; // source file path
  59. char m_tpath[MAX_PATH + 1]; // fully qualified target file path
  60. char m_epath[MAX_PATH + 1]; // save last existing node of a path being created
  61. LONGLONG m_size; // size of file
  62. LONGLONG m_bytes; // amount of bytes copied
  63. DWORD m_tic; // last tic count for timing counters
  64. public:
  65. char *name() {return m_name;}
  66. };
  67. class StoreUNC : public Store
  68. {
  69. public:
  70. virtual BOOL init() {return true;}
  71. virtual BOOL get(PCSTR trg);
  72. virtual BOOL copy(PCSTR rpath, PCSTR file, PCSTR trg);
  73. virtual BOOL ping();
  74. };
  75. class StoreInet : public Store
  76. {
  77. public:
  78. StoreInet()
  79. {
  80. *m_name = 0;
  81. m_type = 0;
  82. m_flags = 0;
  83. m_hsite = 0;
  84. }
  85. ~StoreInet()
  86. {
  87. if (m_hsite)
  88. InternetCloseHandle(m_hsite);
  89. }
  90. virtual BOOL init();
  91. virtual BOOL open(PCSTR rpath, PCSTR file);
  92. virtual BOOL copy(PCSTR rpath, PCSTR file, PCSTR trg);
  93. virtual BOOL ping();
  94. protected:
  95. HINTERNET m_hsite;
  96. INTERNET_PORT m_port;
  97. DWORD m_iflags;
  98. DWORD m_service;
  99. DWORD m_context;
  100. char m_site[MAX_PATH + 1];
  101. char m_srpath[MAX_PATH + 1];
  102. };
  103. class StoreHTTP : public StoreInet
  104. {
  105. public:
  106. ~StoreHTTP()
  107. {
  108. if (m_file)
  109. InternetCloseHandle(m_hfile);
  110. if (m_hsite)
  111. InternetCloseHandle(m_hsite);
  112. }
  113. virtual BOOL init();
  114. virtual BOOL open(PCSTR rpath, PCSTR file);
  115. virtual VOID close();
  116. virtual BOOL get(PCSTR trg);
  117. virtual BOOL progress();
  118. HINTERNET hsite() {return m_hsite;}
  119. HINTERNET hfile() {return m_hfile;}
  120. protected:
  121. HINTERNET m_hfile;
  122. DWORD request();
  123. DWORD prompt(HINTERNET hreq, DWORD err);
  124. DWORD fileinfo();
  125. };
  126. // these manage the list of store objects
  127. Store *GetStore(PCSTR name);
  128. Store *FindStore(PCSTR name);
  129. Store *AddStore(PCSTR name);
  130. // utility functions
  131. #ifdef __cplusplus
  132. extern "C" {
  133. #endif
  134. void SetParentWindow(HWND hwnd);
  135. void setproxy(char *proxy);
  136. void setdstore(char *proxy);
  137. void SetStoreOptions(UINT_PTR opts);
  138. void setdprint(DBGPRINT fndprint);
  139. DWORD GetStoreType(LPCSTR sz);
  140. BOOL ReadFilePtr(LPSTR path, DWORD size);
  141. BOOL UncompressFile(LPCSTR Source, LPCSTR Target);
  142. BOOL ParsePath(LPCSTR ipath, LPSTR site, LPSTR path, LPSTR file, BOOL striptype);
  143. #ifdef __cplusplus
  144. };
  145. #endif