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.

182 lines
5.4 KiB

  1. /*************************************************************************
  2. * Microsoft Windows NT *
  3. * *
  4. * Copyright(c) Microsoft Corp., 1994 *
  5. * *
  6. * Revision History: *
  7. * *
  8. * Jan. 22,94 Koti Created *
  9. * *
  10. * Description: *
  11. * *
  12. * This file contains defines and structure definitions needed for LPD *
  13. * *
  14. *************************************************************************/
  15. #include <nt.h>
  16. #include <ntrtl.h>
  17. #include <nturtl.h>
  18. #include <windef.h>
  19. #include <winbase.h>
  20. #include <winsock2.h>
  21. #include <ws2tcpip.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <winspool.h>
  25. #include <ntlsapi.h>
  26. #include <time.h>
  27. #include "lpdstruc.h"
  28. #include "lpdextrn.h"
  29. #include "debug.h"
  30. #include "lpdmsg.h"
  31. #include "trace.h"
  32. #if DBG
  33. #define LocalAlloc(flag, Size) DbgAllocMem( pscConn, flag, Size, __LINE__, __FILE__ );
  34. #define LocalReAlloc(Buffer, Size, flag) DbgReAllocMem(pscConn, Buffer, Size, flag, __LINE__, __FILE__ );
  35. #define LocalFree(Buffer) DbgFreeMem(Buffer);
  36. PVOID DbgAllocMem( PSOCKCONN pscConn, DWORD flag, DWORD ReqSize, DWORD dwLine, char *szFile );
  37. VOID DbgFreeMem( PVOID pBufferToFree );
  38. PVOID DbgReAllocMem( PSOCKCONN pscConn, PVOID pPartBuf, DWORD ReqSize, DWORD flag, DWORD dwLine, char *szFile );
  39. #endif
  40. #define WCS_LEN(dwAnsiLen) ( sizeof( WCHAR ) * ( dwAnsiLen ))
  41. #define LPD_FLD_OWNER 12
  42. #define LPD_FLD_STATUS 10
  43. #define LPD_FLD_JOBNAME 20
  44. #define LPD_FLD_JOBID 6
  45. #define LPD_FLD_SIZE 10
  46. #define LPD_FLD_PAGES 7
  47. #define LPD_FLD_PRIORITY 7
  48. #define LPD_LINE_SIZE ( LPD_FLD_OWNER + LPD_FLD_STATUS \
  49. + LPD_FLD_JOBNAME + LPD_FLD_JOBID + LPD_FLD_SIZE \
  50. + LPD_FLD_PAGES + LPD_FLD_PRIORITY \
  51. + sizeof( LPD_NEWLINE ) )
  52. // this string also defined in lprmon.h in ....lprmon\monitor: the two strings must
  53. // be identical!
  54. #define LPD_JOB_PREFIX "job=lpd"
  55. // we tell spooler "give me status of these many jobs"
  56. #define LPD_MAXJOBS_ENUM 500
  57. // guess for LPD init time: 10 seconds
  58. #define LPD_WAIT_HINT 10000
  59. #define WINSOCK_VER_MAJOR 1
  60. #define WINSOCK_VER_MINOR 1
  61. #define LPD_PORT 515
  62. // max no. bytes we try to get at one time via recv
  63. #define LPD_BIGBUFSIZE 32000
  64. // most commands are 50 or 60 bytes or so long, so 5000 should be plenty!
  65. #define LPD_MAX_COMMAND_LEN 5000
  66. #define LPD_MAX_USERS 50
  67. #define LPD_MAX_QUEUE_LENGTH 100
  68. // just to have an upper limit: control file bigger than 10MB deserves to be rejected!
  69. #define LPD_MAX_CONTROL_FILE_LEN 10000000
  70. //
  71. // stuff for .mc messages
  72. // you may have to change hese definitions if you add messages
  73. //
  74. #define LPD_FIRST_STRING LPD_LOGO
  75. #define LPD_LAST_STRING LPD_DEFAULT_DOC_NAME
  76. #define LPD_CSTRINGS (LPD_LAST_STRING - LPD_FIRST_STRING + 1)
  77. #define GETSTRING( dwID ) (g_ppszStrings[ dwID - LPD_FIRST_STRING ])
  78. // Linefeed character that terminates every command
  79. #define LF ('\n')
  80. #define LPD_ACK 0
  81. #define LPD_NAK 1
  82. #define LPD_CONTROLFILE 1
  83. #define LPD_DATAFILE 2
  84. // the print formats
  85. #define LPD_PF_RAW_DATA 1
  86. #define LPD_PF_TEXT_DATA 2
  87. #define LPD_SHORT 1
  88. #define LPD_LONG 2
  89. #define IS_WHITE_SPACE( ch ) ( (ch == ' ') || (ch == '\t') || (ch == '\r') )
  90. #define IS_LINEFEED_CHAR( ch ) ( ch == LF )
  91. #define IS_NULL_CHAR( ch ) ( ch == '\0' )
  92. // LPD Command codes
  93. #define LPDC_RESUME_PRINTING 1
  94. #define LPDC_RECEIVE_JOB 2
  95. #define LPDC_SEND_SHORTQ 3
  96. #define LPDC_SEND_LONGQ 4
  97. #define LPDC_REMOVE_JOBS 5
  98. // LPD Job Subcommands
  99. #define LPDCS_ABORT_JOB 1
  100. #define LPDCS_RECV_CFILE 2
  101. #define LPDCS_RECV_DFILE 3
  102. // LPD States (most correspond to command codes)
  103. #define LPDS_INIT 0
  104. #define LPDS_RESUME_PRINTING 1
  105. #define LPDS_RECEIVE_JOB 2
  106. #define LPDS_SEND_SHORTQ 3
  107. #define LPDS_SEND_LONGQ 4
  108. #define LPDS_REMOVE_JOBS 5
  109. #define LPDS_ALL_WENT_WELL 10
  110. // LPD States corresponding to the subcommands
  111. #define LPDSS_ABORTING_JOB 21
  112. #define LPDSS_RECVD_CFILENAME 22
  113. #define LPDSS_RECVD_CFILE 23
  114. #define LPDSS_RECVD_DFILENAME 24
  115. #define LPDSS_SPOOLING 25
  116. // LPD Error codes
  117. #define LPDERR_BASE (20000)
  118. #define LPDERR_NOBUFS (LPDERR_BASE + 1)
  119. #define LPDERR_NORESPONSE (LPDERR_BASE + 2)
  120. #define LPDERR_BADFORMAT (LPDERR_BASE + 3)
  121. #define LPDERR_NOPRINTER (LPDERR_BASE + 4)
  122. #define LPDERR_JOBABORTED (LPDERR_BASE + 5)
  123. #define LPDERR_GODKNOWS (LPDERR_BASE + 6)
  124. #define CONNECTION_CLOSED 3
  125. // Recv timeout is 60 seconds, so we don't keep worker threads
  126. // tied to dead or dud clients. --- MohsinA, 01-May-97.
  127. #define RECV_TIMEOUT 60