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.

196 lines
3.8 KiB

  1. /********
  2. *
  3. * Copyright (c) 1996 Microsoft Corporation
  4. *
  5. *
  6. * Module Name : spool.h
  7. *
  8. * Abstract :
  9. *
  10. * This module contains the prototypes for the spool.cpp file for
  11. * HTTP Printers Server Extension.
  12. *
  13. ******************/
  14. #ifndef _SPOOL_H
  15. #define _SPOOL_H
  16. // ----------------------------------------------------------------------
  17. //
  18. // GLOBAL EXTERNS
  19. //
  20. // ----------------------------------------------------------------------
  21. // This structure defines the asynchronous-reads when processing large
  22. // jobs. This is used to track state-information during the job.
  23. //
  24. #define SPL_ASYNC_BUF 65535
  25. typedef struct _SPLASYNC {
  26. WORD wReq; // Type of request processing.
  27. HANDLE hPrinter; // Handle to printer.
  28. LPTSTR lpszShare; // Sharename for printer (used in job-response).
  29. HANDLE hIpp; // Handle to an Ipp-Stream-Processor.
  30. LPBYTE lpbBuf; // Buffer which asynchronous reads are kept.
  31. DWORD cbTotal; // Total bytes to read for the job.
  32. DWORD cbRead; // Number of bytes accumulated during reads.
  33. DWORD cbBuf; // Size of our buffer (static size).
  34. LPBYTE lpbRet; // Return-buffer based upon request.
  35. } SPLASYNC, *PSPLASYNC, *LPSPLASYNC;
  36. // ----------------------------------------------------------------------
  37. //
  38. // JOB FUNCTIONS
  39. //
  40. // ----------------------------------------------------------------------
  41. // Structure for linked list we keep open job information in
  42. typedef struct _INIJOB {
  43. DWORD signature;
  44. DWORD cb;
  45. struct _INIJOB *pNext;
  46. struct _INIJOB *pPrevious;
  47. DWORD JobId;
  48. HANDLE hPrinter;
  49. DWORD dwFlags;
  50. DWORD dwStatus;
  51. LS_HANDLE hLicense; // Client Access License Handle
  52. DWORD dwStartTime;
  53. EXTENSION_CONTROL_BLOCK *pECB; // Struct from ISAPI interface
  54. } INIJOB, *PINIJOB;
  55. #define IJ_SIGNATURE 0x494A /* 'IJ' is the signature value */
  56. #define MAX_JOB_MINUTE 15 // The maximum duration for a single job in spooler is 15 minutes
  57. #define JOB_READY 0 // Job is ready for deleting or processing
  58. #define JOB_BUSY 1 // Job is being processed by some thread
  59. DWORD
  60. OpenJob(
  61. IN LPEXTENSION_CONTROL_BLOCK pECB,
  62. IN HANDLE hPrinter,
  63. IN PIPPREQ_PRTJOB pipr,
  64. IN DWORD dwSize,
  65. OUT PINIJOB *ppCopyIniJob = NULL
  66. );
  67. BOOL
  68. WriteJob(
  69. DWORD JobId,
  70. LPBYTE pBuf,
  71. DWORD dwSize,
  72. LPDWORD pWritten
  73. );
  74. BOOL
  75. CloseJob(
  76. DWORD JobId
  77. );
  78. BOOL
  79. DeleteJob(
  80. DWORD JobId
  81. );
  82. VOID
  83. AddJobEntry(
  84. PINIJOB pIniJob
  85. );
  86. VOID
  87. DeleteJobEntry(
  88. PINIJOB pIniJob
  89. );
  90. PINIJOB
  91. FindJob(
  92. DWORD JobId, DWORD dwStatus = JOB_READY
  93. );
  94. BOOL CleanupOldJob(void);
  95. DWORD GetCurrentMinute (void);
  96. // ----------------------------------------------------------------------
  97. //
  98. // Client Access Licensing FUNCTIONS
  99. //
  100. // ----------------------------------------------------------------------
  101. BOOL RequestLicense(
  102. LS_HANDLE *phLicense,
  103. LPEXTENSION_CONTROL_BLOCK pECB
  104. );
  105. void FreeLicense(
  106. LS_HANDLE hLicense
  107. );
  108. // ----------------------------------------------------------------------
  109. //
  110. // Impersonation utilities
  111. //
  112. // ----------------------------------------------------------------------
  113. HANDLE
  114. RevertToPrinterSelf(
  115. VOID
  116. );
  117. BOOL
  118. ImpersonatePrinterClient(
  119. HANDLE hToken
  120. );
  121. // ----------------------------------------------------------------------
  122. //
  123. // HELPER FUNCTIONS
  124. //
  125. // ----------------------------------------------------------------------
  126. #ifdef DEBUG
  127. LPVOID
  128. AllocSplMem(
  129. DWORD cb
  130. );
  131. BOOL
  132. FreeSplMem(
  133. LPVOID pMem,
  134. DWORD cb
  135. );
  136. #else
  137. #define AllocSplMem(a) LocalAlloc(LPTR, a)
  138. #define FreeSplMem(a, b) LocalFree(a)
  139. #endif
  140. LPTSTR
  141. AllocSplStr(
  142. LPCTSTR lpStr
  143. );
  144. BOOL
  145. FreeSplStr(
  146. LPTSTR lpStr
  147. );
  148. #endif