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.

278 lines
7.6 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <tchar.h>
  6. #include <assert.h>
  7. #define IGNORE_IF_SPLIT 130
  8. #define ERROR_IF_SPLIT 131
  9. #define ERROR_IF_NOT_SPLIT 132
  10. #define TRANSACTION_ADD 201
  11. #define TRANSACTION_DEL 202
  12. #define DONT_STORE_FILES 203
  13. #define STORE_FILE 204
  14. #define STORE_PTR 205
  15. #define TRANSACTION_QUERY 220
  16. #define DEL 210
  17. #define ADD_STORE 206
  18. #define ADD_DONT_STORE 207
  19. #define ADD_STORE_FROM_FILE 208
  20. #define QUERY 221
  21. #define MAX_VERSION 20
  22. #define MAX_PRODUCT 120
  23. #define MAX_COMMENT 346
  24. #define MAX_ID 10
  25. #define MAX_DATE 8
  26. #define MAX_TIME 8
  27. #define MAX_UNUSED 0
  28. // Define some constants for lengths in the transaction record
  29. // in order to define the maximum length of the record that will
  30. // be written to the master file.
  31. #define TRANS_NUM_COMMAS 8
  32. #define TRANS_EOL 1
  33. #define TRANS_ADD_DEL 3
  34. #define TRANS_FILE_PTR 4
  35. // Define some constants for determining what happened when an NT
  36. // file was stored
  37. #define FILE_STORED 1
  38. #define FILE_SKIPPED 2
  39. #define FILE_ERRORED 3
  40. // Define some flag values for determing whether or not to add the file
  41. // pointer to refs.ptr and file.ptr.
  42. #define ADD_ENTIRE_ENTRY 1
  43. #define SKIP_ENTIRE_ENTRY 2
  44. #define ADD_ONLY_REFSPTR 4
  45. #define DELETE_REFSPTR 8
  46. typedef struct _TRANSACTION {
  47. LPTSTR szId; // Id for this transaction
  48. // This always refers to the transaction file that
  49. // is being deleted or added
  50. LPTSTR szDelId; // Id for a delete transaction
  51. // This is just appended to the master file, there is
  52. // no file created for it.
  53. DWORD TransState; // State of this transaction
  54. DWORD FileOrPtr; // Are we storing files or pointers?
  55. LPTSTR szProduct; // Name of the product being added
  56. LPTSTR szVersion; // Version of the product
  57. LPTSTR szComment; // Description
  58. LPTSTR szTransFileName; // Full Path and name of the Transaction file
  59. LPTSTR szTime;
  60. LPTSTR szDate;
  61. LPTSTR szUnused;
  62. } TRANSACTION, *PTRANSACTION;
  63. /* ++
  64. Description of the fields in COM_ARGS
  65. szSrcDir Directory where source files exist
  66. szFileName File name(s) to store in the symbols server.
  67. This may contain wild card characters
  68. Recurse Recurse into subdirectories
  69. szRootDir Root Directory of the symbols server
  70. szSymbolsDir Symbols Directory under the root of the symbols server
  71. szSrcPath Path to the files. If this is not NULL,
  72. then store a pointer to the files instead of
  73. the files. Typically, this is the same as szSrcDir.
  74. The difference is that szSrcPath is the path that
  75. the debugger will use to find the symbol file.
  76. Thus, it needs to be a network share, whereas szSrcDir
  77. can be a local path.
  78. szId Reference string for this transaction. This must be
  79. unique for each transaction.
  80. szAdminDir Admin directory under the root of the symbols server
  81. szProduct Name of the product
  82. szVersion Version of the product
  83. szComment Text description ... optional
  84. szMasterFileName The full path and name of the master file. This contains
  85. the master transaction record for each transaction.
  86. szServerFileName The full path and name of the file that contains a list of
  87. all the transactions that are currently stored in the server.
  88. szTransFileName The full path and name of the file that contains a list of
  89. all the files added by this transaction. This only gets
  90. initialized during GetCommandLineArgs if symstore is only
  91. supposed to store the transaction file and not store any
  92. files on the symbol server.
  93. szShareName This is used with the /x option. It is a prefix of
  94. szFileName. It is the part of szFileName that may
  95. change later when the files are added to the server.
  96. TransState Is this TRANSACTION_ADD or TRANSACTION_DEL
  97. StoreFlags Possible values: STORE or DONT_STORE
  98. AppendStoreFile When storing to a file instead of adding the files to the
  99. symbol server, open the file with append.
  100. -- */
  101. typedef struct _COMMAND_ARGS {
  102. LPTSTR szSrcDir;
  103. LPTSTR szFileName;
  104. BOOL StorePtrs;
  105. BOOL Recurse;
  106. LPTSTR szRootDir;
  107. LPTSTR szSymbolsDir;
  108. LPTSTR szSrcPath;
  109. LPTSTR szId;
  110. LPTSTR szAdminDir;
  111. LPTSTR szProduct;
  112. LPTSTR szVersion;
  113. LPTSTR szComment;
  114. LPTSTR szUnused;
  115. LPTSTR szMasterFileName;
  116. LPTSTR szServerFileName;
  117. LPTSTR szTransFileName;
  118. LPTSTR szShareName;
  119. DWORD ShareNameLength;
  120. DWORD TransState;
  121. DWORD StoreFlags;
  122. BOOL AppendStoreFile;
  123. FILE *pStoreFromFile;
  124. BOOL AppendIDToFile;
  125. BOOL VerboseOutput;
  126. DWORD Filter;
  127. BOOL CorruptBinaries;
  128. } COM_ARGS, *PCOM_ARGS;
  129. typedef struct _FILE_COUNTS {
  130. DWORD NumPassedFiles;
  131. DWORD NumIgnoredFiles;
  132. DWORD NumFailedFiles;
  133. } FILE_COUNTS, *PFILE_COUNTS;
  134. BOOL
  135. StoreDbg(
  136. LPTSTR szDestDir,
  137. LPTSTR szFileName,
  138. LPTSTR szPtrFileName,
  139. USHORT *rc_flag
  140. );
  141. BOOL
  142. StorePdb(
  143. LPTSTR szDestDir,
  144. LPTSTR szFileName,
  145. LPTSTR szPtrFileName, // If this is NULL, then the file is stored.
  146. // If this is not NULL, then a pointer to
  147. // the file is stored.
  148. USHORT *rc_flag
  149. );
  150. BOOL
  151. DeleteAllFilesInDirectory(
  152. LPTSTR szDir
  153. );
  154. ULONG GetMaxLineOfRefsPtrFile(
  155. VOID
  156. );
  157. DECLSPEC_NORETURN
  158. VOID
  159. MallocFailed(
  160. VOID
  161. );
  162. typedef struct _LIST_ELEM {
  163. CHAR FName[_MAX_PATH];
  164. CHAR Path[_MAX_PATH];
  165. } LIST_ELEM, *P_LIST_ELEM;
  166. typedef struct _LIST {
  167. LIST_ELEM *List; // Pointers to the file names
  168. DWORD dNumFiles;
  169. } LIST, *P_LIST;
  170. P_LIST
  171. GetList(
  172. LPTSTR szFileName
  173. );
  174. BOOL
  175. InList(
  176. LPTSTR szFileName,
  177. P_LIST pExcludeList
  178. );
  179. BOOL
  180. StoreNtFile(
  181. LPTSTR szDestDir,
  182. LPTSTR szFileName,
  183. LPTSTR szPtrFileName,
  184. USHORT *rc
  185. );
  186. DWORD
  187. StoreFromFile(
  188. FILE *pStoreFromFile,
  189. LPTSTR szDestDir,
  190. PFILE_COUNTS pFileCounts
  191. );
  192. BOOL
  193. MyCopyFile(
  194. LPCTSTR lpExistingFileName,
  195. LPCTSTR lpNewFileName
  196. );
  197. _TCHAR *
  198. _tcsistr(
  199. _TCHAR *s1,
  200. _TCHAR *s2
  201. );
  202. void
  203. MyEnsureTrailingChar(
  204. char *sz,
  205. char c
  206. );
  207. void
  208. MyEnsureTrailingBackslash(
  209. char *sz
  210. );
  211. void
  212. MyEnsureTrailingSlash(
  213. char *sz
  214. );
  215. void
  216. MyEnsureTrailingCR(
  217. char *sz
  218. );
  219. // returns TRUE if Filename matches the regexp /.*~\d+\..{0,3}/
  220. BOOL DoesThisLookLikeAShortFilenameHack(char *Filename);
  221. // from sharedutils.c
  222. DWORD PrivateGetFullPathName(LPCTSTR lpFilename, DWORD nBufferLength, LPTSTR lpBuffer, LPTSTR *lpFilePart);
  223. extern HANDLE hTransFile;
  224. extern DWORD StoreFlags;
  225. extern PCOM_ARGS pArgs;
  226. extern PTRANSACTION pTrans;
  227. extern LONG lMaxTrans; // Maximum number of characters in a transaction record
  228. extern BOOL PubPriPriority;
  229. BOOL FileExists(IN LPCSTR FileName,
  230. OUT PWIN32_FIND_DATA FindData);