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.

525 lines
14 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. regdata.h
  5. Abstract:
  6. Funtions for dealing with registry data
  7. Environment:
  8. Win32 subsystem, printer drivers (kernel and user mode)
  9. Revision History:
  10. 02/04/97 -davidx-
  11. Use REG_MULTI_SZ instead of REG_BINARY where possible.
  12. 09/25/96 -davidx-
  13. Functions to manipulate MultiSZ string pairs.
  14. 09/25/96 -davidx-
  15. Convert to Hungarian notation.
  16. 08/13/96 -davidx-
  17. New functions and interface.
  18. 07/22/96 -srinivac-
  19. Updated for PSCRIPT5
  20. 06/19/95 -davidx-
  21. Created it.
  22. --*/
  23. #ifndef _REGDATA_H_
  24. #define _REGDATA_H_
  25. //
  26. // Value names for printer data in the registry
  27. //
  28. // values common to pscript and unidrv
  29. #define REGVAL_PRINTER_DATA_SIZE TEXT("PrinterDataSize")
  30. #define REGVAL_PRINTER_DATA TEXT("PrinterData")
  31. #define REGVAL_FONT_SUBST_TABLE TEXT("TTFontSubTable")
  32. #define REGVAL_FORMS_ADDED TEXT("Forms?")
  33. #define REGVAL_PRINTER_INITED TEXT("InitDriverVersion")
  34. #define REGVAL_KEYWORD_NAME TEXT("FeatureKeyword")
  35. #define REGVAL_KEYWORD_SIZE TEXT("FeatureKeywordSize")
  36. #ifdef WINNT_40 // for NT4
  37. #define REGVAL_INIDATA TEXT("IniData4")
  38. #else // for Win2K
  39. #define REGVAL_INIDATA TEXT("IniData5")
  40. #endif // WINNT_40
  41. // pscript specific
  42. #define REGVAL_FREEMEM TEXT("FreeMem")
  43. #define REGVAL_JOBTIMEOUT TEXT("JobTimeOut")
  44. #define REGVAL_PROTOCOL TEXT("Protocol")
  45. // unidrv specific
  46. #define REGVAL_CURRENT_DEVHTINFO TEXT("CurDevHTInfo")
  47. #define REGVAL_FONTCART TEXT("FontCart")
  48. #define REGVAL_PAGE_PROTECTION TEXT("RasddFlags")
  49. #define REGVAL_FONTFILENAME TEXT("ExternalFontFile")
  50. #define REGVAL_CARTRIDGEFILENAME TEXT("ExtFontCartFile")
  51. #define REGVAL_EXEFONTINSTALLER TEXT("FontInstaller")
  52. #define REGVAL_EXTFONTCART TEXT("ExtFontCartNames")
  53. #define REGVAL_PARTIALCLIP TEXT("PartialClip")
  54. // pscript 4.0 compatibility
  55. #define REGVAL_FONT_SUBST_SIZE_PS40 TEXT("TTFontSubTableSize")
  56. #define REGVAL_TRAY_FORM_TABLE_PS40 TEXT("TrayFormTable")
  57. #define REGVAL_TRAY_FORM_SIZE_PS40 TEXT("TrayFormSize")
  58. #define REGVAL_DEPFILES TEXT("DependentFiles")
  59. #define REGVAL_NTFFILENAME TEXT("FontDownloaderNTF")
  60. // rasdd 4.0 compatibility
  61. #define REGVAL_TRAYFORM_TABLE_RASDD TEXT("TrayFormTable")
  62. #define REGVAL_MODELNAME TEXT("Model")
  63. #define REGVAL_RASDD_FREEMEM TEXT("FreeMem")
  64. //
  65. // delimiter for keyword name conversion
  66. //
  67. #define END_OF_FEATURE '\n'
  68. //
  69. // Get a DWORD value from the registry under PrinerDriverData key
  70. //
  71. BOOL
  72. BGetPrinterDataDWord(
  73. IN HANDLE hPrinter,
  74. IN LPCTSTR ptstrRegKey,
  75. OUT PDWORD pdwValue
  76. );
  77. //
  78. // Save a DWORD value to the registry under PrinerDriverData key
  79. //
  80. BOOL
  81. BSetPrinterDataDWord(
  82. IN HANDLE hPrinter,
  83. IN LPCTSTR ptstrRegKey,
  84. IN DWORD dwValue
  85. );
  86. //
  87. // Get a string value from PrinterDriverData registry key
  88. //
  89. PTSTR
  90. PtstrGetPrinterDataString(
  91. IN HANDLE hPrinter,
  92. IN LPCTSTR ptstrRegKey,
  93. OUT PDWORD pdwSize
  94. );
  95. //
  96. // Save a string or multi-sz value under PrinerDriverData registry key
  97. //
  98. BOOL
  99. BSetPrinterDataString(
  100. IN HANDLE hPrinter,
  101. IN LPCTSTR ptstrRegKey,
  102. IN LPCTSTR ptstrValue,
  103. IN DWORD dwType
  104. );
  105. //
  106. // Get a MULTI_SZ value from PrinerDriverData registry key
  107. //
  108. PTSTR
  109. PtstrGetPrinterDataMultiSZPair(
  110. IN HANDLE hPrinter,
  111. IN LPCTSTR ptstrRegKey,
  112. OUT PDWORD pdwSize
  113. );
  114. //
  115. // Save a MULTI_SZ value under PrinerDriverData registry key
  116. //
  117. BOOL
  118. BSetPrinterDataMultiSZPair(
  119. IN HANDLE hPrinter,
  120. IN LPCTSTR ptstrRegKey,
  121. IN LPCTSTR ptstrValue,
  122. IN DWORD dwSize
  123. );
  124. //
  125. // Get binary data from the registry under PrinterDriverData key
  126. //
  127. PVOID
  128. PvGetPrinterDataBinary(
  129. IN HANDLE hPrinter,
  130. IN LPCTSTR ptstrSizeKey,
  131. IN LPCTSTR ptstrDataKey,
  132. OUT PDWORD pdwSize
  133. );
  134. //
  135. // Save binary data to the registry under PrinterDriverData key
  136. //
  137. BOOL
  138. BSetPrinterDataBinary(
  139. IN HANDLE hPrinter,
  140. IN LPCTSTR ptstrSizeKey,
  141. IN LPCTSTR ptstrDataKey,
  142. IN PVOID pvData,
  143. IN DWORD dwSize
  144. );
  145. //
  146. // Functions for working with TrueType font substitution table:
  147. // Retrieve TrueType font substitution table from registry
  148. // Save TrueType font substitution table to registry
  149. // Find out the substituted device font given a TrueType font name
  150. //
  151. // TrueType font substitution table has a very simple structure.
  152. // Each TrueType font name is followed is followed by its
  153. // corresponding device font name. Font names are NUL-terminated
  154. // character strings. The entire table is terminated by a NUL character.
  155. // For example:
  156. //
  157. // "Arial" "Helvetica"
  158. // "Courier" "Courier"
  159. // ...
  160. // ""
  161. //
  162. typedef PTSTR TTSUBST_TABLE;
  163. #define PGetTTSubstTable(hPrinter, pSize) \
  164. PtstrGetPrinterDataMultiSZPair(hPrinter, REGVAL_FONT_SUBST_TABLE, pSize)
  165. #define PtstrSearchTTSubstTable(pTTSubstTable, ptstrTTFontName) \
  166. PtstrSearchStringInMultiSZPair(pTTSubstTable, ptstrTTFontName)
  167. BOOL
  168. BSaveTTSubstTable(
  169. IN HANDLE hPrinter,
  170. IN TTSUBST_TABLE pTTSubstTable,
  171. IN DWORD dwSize
  172. );
  173. //
  174. // Functions for working with form-to-tray assignment table:
  175. // Retrieve form-to-tray assignment table from registry
  176. // Save form-to-tray assignment table to registry
  177. // Search form-to-tray assignment table
  178. //
  179. // The format of form-to-tray assignment table is fairly simple.
  180. // for each table entry:
  181. // tray name (NUL-terminated character string)
  182. // form name (NUL-terminated character string)
  183. // NUL terminator
  184. //
  185. typedef PTSTR FORM_TRAY_TABLE;
  186. FORM_TRAY_TABLE
  187. PGetFormTrayTable(
  188. IN HANDLE hPrinter,
  189. OUT PDWORD pdwSize
  190. );
  191. BOOL
  192. BSaveFormTrayTable(
  193. IN HANDLE hPrinter,
  194. IN FORM_TRAY_TABLE pFormTrayTable,
  195. IN DWORD dwSize
  196. );
  197. //
  198. // These functions are implemented in lib\ps and lib\uni.
  199. //
  200. // If there is no new format form-to-tray table, PGetFormTrayTable will
  201. // call PGetAndConvertOldVersionFormTrayTable to see if any old version
  202. // form-to-tray table exists and can be converted to the new format.
  203. //
  204. // BSaveFormTrayTable calls BSaveAsOldVersionFormTrayTable to save
  205. // a form-tray table in NT 4.0 compatible format.
  206. //
  207. FORM_TRAY_TABLE
  208. PGetAndConvertOldVersionFormTrayTable(
  209. IN HANDLE hPrinter,
  210. OUT PDWORD pdwSize
  211. );
  212. BOOL
  213. BSaveAsOldVersionFormTrayTable(
  214. IN HANDLE hPrinter,
  215. IN FORM_TRAY_TABLE pFormTrayTable,
  216. IN DWORD dwSize
  217. );
  218. //
  219. // Macros for accessing font cartridge registry data
  220. //
  221. #define PtstrGetFontCart(hPrinter, pSize) \
  222. PtstrGetPrinterDataString(hPrinter, REGVAL_FONTCART, pSize)
  223. #define BSaveFontCart(hPrinter, pFontCart) \
  224. BSetPrinterDataString(hPrinter, REGVAL_FONTCART, pFontCart, REG_MULTI_SZ)
  225. //
  226. // Data structure for storing the result of searching form-to-tray assignment table
  227. //
  228. typedef struct _FINDFORMTRAY {
  229. PVOID pvSignature; // signature
  230. PTSTR ptstrTrayName; // tray name
  231. PTSTR ptstrFormName; // form name
  232. PTSTR ptstrNextEntry; // where to start the next search
  233. } FINDFORMTRAY, *PFINDFORMTRAY;
  234. BOOL
  235. BSearchFormTrayTable(
  236. IN FORM_TRAY_TABLE pFormTrayTable,
  237. IN PTSTR ptstrTrayName,
  238. IN PTSTR ptstrFormName,
  239. IN OUT PFINDFORMTRAY pFindData
  240. );
  241. //
  242. // Initialize FINDFORMTRAY structure. This must be called before calling
  243. // BSearchFormTrayTable for the first time.
  244. //
  245. #define RESET_FINDFORMTRAY(pFormTrayTable, pFindData) \
  246. { \
  247. (pFindData)->pvSignature = (pFindData); \
  248. (pFindData)->ptstrNextEntry = (pFormTrayTable); \
  249. }
  250. //
  251. // Printer sticky properties
  252. //
  253. typedef struct _PRINTERDATA {
  254. WORD wDriverVersion; // driver version number
  255. WORD wSize; // size of the structure
  256. DWORD dwFlags; // flags
  257. DWORD dwFreeMem; // amount of free memory
  258. DWORD dwJobTimeout; // job timeout
  259. DWORD dwWaitTimeout; // wait timeout
  260. WORD wMinoutlinePPEM; // min size to download as Type1
  261. WORD wMaxbitmapPPEM; // max size to download as Type3
  262. DWORD dwReserved1[3]; // reserved space
  263. WORD wReserved2; // old 16-bit checksum set to 0
  264. WORD wProtocol; // output protocol
  265. DWORD dwChecksum32; // checksum of printer description file
  266. DWORD dwOptions; // number of printer-sticky features
  267. OPTSELECT aOptions[MAX_PRINTER_OPTIONS]; // installable options
  268. } PRINTERDATA, *PPRINTERDATA;
  269. //
  270. // Constant flags for PRINTERDATA.dwFlags field
  271. //
  272. #define PFLAGS_METRIC 0x0001 // running on metric system
  273. #define PFLAGS_HOST_HALFTONE 0x0002 // use host halftoning
  274. #define PFLAGS_IGNORE_DEVFONT 0x0004 // ignore device fonts
  275. #define PFLAGS_SLOW_FONTSUBST 0x0008 // slow but accurate font subst
  276. #define PFLAGS_NO_HEADERPERJOB 0x0010 // don't download header with job
  277. #define PFLAGS_PAGE_PROTECTION 0x0020 // page protection is turned on
  278. #define PFLAGS_CTRLD_BEFORE 0x0040 // send ^D before each job
  279. #define PFLAGS_CTRLD_AFTER 0x0080 // send ^D after each job
  280. #define PFLAGS_TRUE_GRAY_TEXT 0x0100 // enable TrueGray detection
  281. #define PFLAGS_TRUE_GRAY_GRAPH 0x0200 // enable TrueGray detection
  282. #define PERFORM_TRUE_GRAY_TEXT(pdev) ((pdev)->PrinterData.dwFlags & PFLAGS_TRUE_GRAY_TEXT)
  283. #define PERFORM_TRUE_GRAY_GRAPH(pdev) ((pdev)->PrinterData.dwFlags & PFLAGS_TRUE_GRAY_GRAPH)
  284. #define PFLAGS_ADD_EURO 0x0400 // enable Euro augmentation
  285. #define PFLAGS_EURO_SET 0x0800 // set if PFLAGS_ADD_EURO has been set to it's current value intentionally
  286. // as opposed to just because it wasn't set in an older version
  287. #define PERFORM_ADD_EURO(pdev) (((pdev)->PrinterData.dwFlags & PFLAGS_ADD_EURO) && \
  288. (TARGET_PSLEVEL(pdev) >= 2))
  289. //
  290. // Default Max/Min point sizes in PPEM for switching between Type1 and Type3
  291. //
  292. #define DEFAULT_MINOUTLINEPPEM 100
  293. #define DEFAULT_MAXBITMAPPPEM 600
  294. //
  295. // Functions for accessing printer properties data:
  296. // retrieve printer property data in the registry
  297. // get the default printer property data
  298. // save printer property data to registry
  299. //
  300. BOOL
  301. BGetPrinterProperties(
  302. IN HANDLE hPrinter,
  303. IN PRAWBINARYDATA pRawData,
  304. OUT PPRINTERDATA pPrinterData
  305. );
  306. BOOL
  307. BGetDefaultPrinterProperties(
  308. IN HANDLE hPrinter,
  309. IN PRAWBINARYDATA pRawData,
  310. OUT PPRINTERDATA pPrinterData
  311. );
  312. BOOL
  313. BSavePrinterProperties(
  314. IN HANDLE hPrinter,
  315. IN PRAWBINARYDATA pRawData,
  316. IN PPRINTERDATA pPrinterData,
  317. IN DWORD dwSize
  318. );
  319. BOOL
  320. BConvertPrinterPropertiesData(
  321. IN HANDLE hPrinter,
  322. IN PRAWBINARYDATA pRawData,
  323. OUT PPRINTERDATA pPrinterData,
  324. IN PVOID pvSrcData,
  325. IN DWORD dwSrcSize
  326. );
  327. VOID
  328. VUpdatePrivatePrinterData(
  329. IN HANDLE hPrinter,
  330. IN OUT PPRINTERDATA pPrinterData,
  331. IN DWORD dwMode,
  332. IN PUIINFO pUIInfo,
  333. IN POPTSELECT pCombineOptions
  334. );
  335. #define MODE_READ 0
  336. #define MODE_WRITE 1
  337. //
  338. // NT4 PS driver PRINTERDATA structure
  339. //
  340. typedef struct _PS4_PRINTERDATA {
  341. WORD wDriverVersion; // driver version number
  342. WORD wSize; // size of the structure
  343. DWORD dwFlags; // flags
  344. DWORD dwFreeVm; // amount of VM
  345. DWORD dwJobTimeout; // job timeout
  346. DWORD dwWaitTimeout; // wait timeout
  347. DWORD dwReserved[4]; // reserved space
  348. WORD wChecksum; // PPD file checksum
  349. WORD wOptionCount; // number of options to follow
  350. BYTE options[64]; // installable options
  351. } PS4_PRINTERDATA, *PPS4_PRINTERDATA;
  352. //
  353. // Retrieve device halftone setup information from registry
  354. //
  355. BOOL
  356. BGetDeviceHalftoneSetup(
  357. HANDLE hPrinter,
  358. DEVHTINFO *pDevHTInfo
  359. );
  360. //
  361. // Save device halftone setup information to registry
  362. //
  363. BOOL
  364. BSaveDeviceHalftoneSetup(
  365. HANDLE hPrinter,
  366. DEVHTINFO *pDevHTInfo
  367. );
  368. //
  369. // Figure out printer driver directory from the driver DLL's full pathname
  370. //
  371. PTSTR
  372. PtstrGetDriverDirectory(
  373. IN LPCTSTR ptstrDriverDllPath
  374. );
  375. //
  376. // Search the list of dependent files (in REG_MULTI_SZ format)
  377. // for a file with the specified extension
  378. //
  379. LPCTSTR
  380. PtstrSearchDependentFileWithExtension(
  381. IN LPCTSTR ptstrDependentFiles,
  382. IN LPCTSTR ptstrExtension
  383. );
  384. //
  385. // Verify the input data block is in REG_MULTI_SZ format and
  386. // it consists of multiple string pairs
  387. //
  388. BOOL
  389. BVerifyMultiSZPair(
  390. IN LPCTSTR ptstrData,
  391. IN DWORD dwSize
  392. );
  393. BOOL
  394. BVerifyMultiSZ(
  395. IN LPCTSTR ptstrData,
  396. IN DWORD dwSize
  397. );
  398. DWORD
  399. DwCountStringsInMultiSZ(
  400. IN LPCTSTR ptstrData
  401. );
  402. //
  403. // Search for the specified key in MultiSZ key-value string pairs
  404. //
  405. LPCTSTR
  406. PtstrSearchStringInMultiSZPair(
  407. IN LPCTSTR ptstrMultiSZ,
  408. IN LPCTSTR ptstrKey
  409. );
  410. #endif //!_REGDATA_H_