home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / QPROC.ZIP / PMPRINT.H next >
C/C++ Source or Header  |  1990-10-18  |  11KB  |  323 lines

  1. /*****************************************************************/
  2. /**             Microsoft LAN Manager            **/
  3. /**           Copyright(c) Microsoft Corp., 1985-1990        **/
  4. /*****************************************************************/
  5. /****************************** Module Header ******************************\
  6.  
  7. Module Name: PMPRINT.H
  8.  
  9. Private include file for the sources used to build the PM print queue
  10. processor (PMPRINT.QPR)
  11.  
  12. History:
  13.  20-Apr-89 [davesni]  Created.
  14.  
  15. \***************************************************************************/
  16.  
  17. #define INCL_NOCOMMON
  18. #define INCL_DOS
  19. #define INCL_DOSERRORS
  20. #define INCL_DOSINFOSEG
  21. #define INCL_DOSDEVICES
  22. #define INCL_DOSMONITORS
  23. #define INCL_SPL
  24. #define INCL_SPLERRORS
  25. #define INCL_SPLDOSPRINT
  26. #define INCL_WINHEAP
  27. #define INCL_WINSHELLDATA
  28. #define INCL_WINMESSAGEMGR
  29. #define INCL_WINPOINTERS
  30. #include <os2.h>
  31.  
  32. #define INCL_WINP
  33. #define INCL_SPLP
  34. #define INCL_WINP_FSRS
  35. #include <os2p.h>
  36.  
  37. #include "splerror.h"
  38. #include "splconst.h"
  39.  
  40. #define min(a, b) ((a) < (b) ? (a) : (b))
  41.  
  42. #define NULL_HFILE      (HFILE)0xFFFF
  43. #define HABX   (HAB)-1L             /* Bogus hab for API calls */
  44. typedef ULONG SEM;
  45.  
  46. #define NOASSOC      0
  47. #define ASSOCIATE        1
  48.  
  49. #define SPL_ID_QP_PMPRINT_TITLE         0
  50. #define SPL_ID_QP_DATATYPE_ERROR        1
  51. #define SPL_ID_QP_INVALID_PARAMETER     2
  52. #define SPL_ID_QP_INTERNAL_ERROR        3
  53. #define SPL_ID_QP_MEM_ERROR             4
  54. #define SPL_ID_QP_FILE_NOT_FOUND        5
  55. #define SPL_ID_QP_INVALID_OPERATION     6
  56. #define SPL_ID_QP_OPENDC_ERROR          7
  57. #define SPL_ID_DT_STD                   8
  58. #define SPL_ID_DT_RAW                   9
  59. #define SPL_ID_QPROC_DEFAULT_OPTS       10
  60. #define SPL_ID_INI_QPROC                11
  61. #define SPL_ID_QPROC_NAME               12
  62. #define SPL_ID_INSTALL_MSG              13
  63. #define SPL_ID_INSTALL_CAPTION          14
  64. #define SPL_ID_DEFAULT_SEPARATOR        15
  65.  
  66. #define SPL_MAX_STRING_ID               15
  67. #define SPL_MIN_STRING_ID               0
  68.  
  69. #define QPROC_CAPTION   pszSplStrings[ SPL_ID_QP_PMPRINT_TITLE   ]
  70. #define DT_STD          pszSplStrings[ SPL_ID_DT_STD             ]
  71. #define DT_RAW          pszSplStrings[ SPL_ID_DT_RAW             ]
  72. #define INI_QPROC       pszSplStrings[ SPL_ID_INI_QPROC          ]
  73. #define QPROC_NAME      pszSplStrings[ SPL_ID_QPROC_NAME         ]
  74. #define QPROC_DEFAULT_OPTS pszSplStrings[ SPL_ID_QPROC_DEFAULT_OPTS ]
  75. #define INSTALL_MSG     pszSplStrings[ SPL_ID_INSTALL_MSG        ]
  76. #define INSTALL_CAPTION pszSplStrings[ SPL_ID_INSTALL_CAPTION    ]
  77. #define DEFAULT_SEPARATOR pszSplStrings[ SPL_ID_DEFAULT_SEPARATOR  ]
  78.  
  79.  
  80. typedef void near *NPVOID;
  81. typedef CHAR near *NPCHAR;
  82. typedef DRIVDATA near *NPDRIVDATA;
  83. typedef PSZ far *PPSZ;
  84. #define FARENTRY pascal far
  85.  
  86. #ifndef RC_INVOKED
  87.  
  88. typedef struct _KEYDATA {
  89.     USHORT  cb;
  90.     USHORT  cTokens;
  91.     NPSZ    pTokens[1];
  92. } KEYDATA;
  93. typedef KEYDATA near *PKEYDATA;
  94.  
  95. typedef struct _INIENTRY {
  96.     USHORT      signature;
  97.     USHORT      cb;
  98.     struct _INIENTRY *pNext;
  99.     USHORT      cRef;
  100.     NPSZ        pszName;
  101. } INIENTRY;
  102. typedef INIENTRY *PINIENTRY;
  103.  
  104. typedef struct _INIQPROC {             /* iqp */
  105.     USHORT      signature;
  106.     USHORT      cb;
  107.     struct _INIQPROC near *pNext;
  108.     USHORT      cRef;
  109.     NPSZ        pszName;
  110.     NPSZ        pszOptions;
  111.     NPSZ        pszDLLName;
  112.     USHORT      cDataTypes;
  113.     PSZ near *  ppszDataTypes;  /* points to separatly allocated data */
  114. } INIQPROC;
  115.  
  116. typedef INIQPROC near *PINIQPROC;
  117.  
  118. #define IQP_SIGNATURE    0x5051 /* 'QP' is the signature value */
  119.  
  120. typedef struct _QPPOINT {   /* qpt */
  121.     union {                     /* Expressed as a percentage of page size */
  122.         CHAR chLeft;
  123.         CHAR chWidth;
  124.     } x;
  125.     union {                     /* Expressed as a percentage of page size */
  126.         CHAR chTop;
  127.         CHAR chDepth;
  128.     } y;
  129. } QPPOINT;
  130.  
  131. typedef struct _QPPARMS {   /* qpp */
  132.     USHORT  cCopies;            /* COP=nn                               */
  133.     BOOL    fTransform;         /* FALSE => XFM=0       TRUE => XFM=1   */
  134.     BOOL    fColor;             /* FALSE => COL=M       TRUE => COL=C   */
  135.     BOOL    fMapColors;         /* FALSE => MAP=N       TRUE => MAP=A   */
  136.     BOOL    fLandscape;         /* FALSE => ORI=P       TRUE => ORI=L   */
  137.     BOOL    fArea;              /* FALSE => ARE=C   TRUE => ARE=w,d,l,t */
  138.     QPPOINT ptAreaSize;         /* w,d                                  */
  139.     QPPOINT ptAreaOrigin;       /* l,t                                  */
  140.     BOOL    fFit;               /* FALSE => FIT=S       TRUE => FIT=l,t */
  141.     QPPOINT ptFit;        /* l,t                    */
  142.     USHORT  uCodePage;        /* Code page Number (0 == Not defined)    */
  143. } QPPARMS;
  144. typedef QPPARMS far *PQPPARMS;
  145.  
  146. typedef struct _QPROCINST {     /* qpi */
  147.     USHORT      signature;      /* signature word for validating HSPL */
  148.     USHORT      cb;             /* number of bytes allocated */
  149.     struct _QPROCINST near *pNext;
  150.     PID         uPid;           /* Process that created this QProc inst */
  151.     USHORT      fsStatus;       /* Status bits (see below) */
  152.     SEM         semPaused;
  153.     USHORT      uType;          /* Type of QProc */
  154.     BOOL (PASCAL *pfnPrintFile)(struct _QPROCINST near *pQProc, PSZ pszFileName);
  155.                                 /* -> print file func for this type */
  156.     QPPARMS     qparms;         /* Parsed Queue Processor parameters */
  157.  
  158.     NPSZ        pszFileName;    /* -> file name associated with handle */
  159.     HFILE       hFile;          /* OS/2 file handle for output file */
  160.     ULONG       ulFilePos;      /* current read position in hFile */
  161.     ULONG       cbFile;         /* Total size of file */
  162.     SEL         selBuf;         /* != 0 then selector to allocated buffer */
  163.  
  164.     HDC         hdc;
  165.     HDC         hInfodc;
  166.     HPS         hps;
  167.     HMF         hmf;
  168.     HRGN        region;
  169.     NPSZ        pszPortName;    /* Port Name i.e. "LPT1" */
  170.     NPSZ        pszDriverName;  /* Driver Name i.e. "IBM4201" */
  171.     PDRIVDATA   pDriverData;    /* -> PM Device driver data to use */
  172.     NPSZ        pszDataType;    /* -> data type */
  173.     NPSZ        pszDocument;    /* -> document name */
  174.     NPSZ        pszComment;     /* -> comment string */
  175.     NPSZ        pszQName;       /* -> queue name */
  176.     USHORT      uJobId;         /* Job ID */
  177. } QPROCINST;
  178. typedef QPROCINST near *PQPROCINST;
  179.  
  180. #define QP_SIGNATURE    0x5051  /* 'QP' is the signature value */
  181.  
  182. /* Define flags for fsStatus field */
  183.  
  184. #define QP_ABORTED      0x0001
  185. #define QP_PAUSED       0x0002
  186.  
  187. #define QP_RESERVED     0xFFFC
  188.  
  189. /* Define values for uType field */
  190.  
  191. #define QP_TYPE_STD     0
  192. #define QP_TYPE_RAW     1
  193. #define QP_TYPE_NUM     2
  194.  
  195. /* Filled in at SplLoadProc time with pointers to STRINGTABLE strings */
  196.  
  197. PSZ pszSplStrings[SPL_MAX_STRING_ID+1];
  198. CHAR    szNull[ 0+1 ];
  199.  
  200. FSRSEM semPMPRINT;          /* Fast, Safe RAM Semaphore to serialize access */
  201.                             /* to all of the global data that follows.      */
  202.  
  203. BOOL    bInitDone;          /* TRUE if SplInit has been called */
  204.  
  205. HHEAP   hSplHeap;           /* Local heap for our use */
  206. USHORT  cbSplHeap;          /* HEAPSIZE parameter from PMSPL.DEF */
  207.  
  208. HMODULE hSplModule;         /* module handle of PMSPL.DLL */
  209.  
  210. HHEAP   hheapJob;           /* job heap */
  211. PVOID   pvJobHeap;          /* -> beginning of job heap */
  212.  
  213. PGINFOSEG pGlobalInfo;      /* -> global info segment */
  214. PLINFOSEG pLocalInfo;       /* -> local info segment  */
  215.  
  216. PSZ     pszDLLName;         /* path specified in .ini file */
  217.  
  218. /* Utility functions defined in QPINIT.C  */
  219.  
  220. extern SEL  selGlobalSeg;  /* Pointer to global info segment */
  221. extern USHORT usCodePage;  /* Current Code Page */
  222.  
  223. VOID EXPENTRY SplExitListProc( USHORT uExitType );
  224. BOOL near     SplLoadProc( HMODULE hModule, USHORT cbHeap );
  225. BOOL EXPENTRY SplInit( VOID );
  226.  
  227. /* Queue Processor functions defined in QPAPI.C  */
  228.  
  229. PQPROCINST CreateQProcInst(PDEVOPENSTRUC pQProcData, USHORT uJobId, PSZ pszQName);
  230. PQPROCINST FARENTRY DestroyQProcInst( PQPROCINST pQProc );
  231. PQPROCINST ValidateQProcInst( HPROC hQProc );
  232. BOOL       ParseQProcParms( PSZ pszParms, PQPPARMS pqp );
  233. BOOL       ParseQProcParm( NPSZ pszParm, PQPPARMS pqp );
  234. NPSZ       ParseQProcPercentList(NPSZ pszList, PBYTE pResult, USHORT cListElem);
  235. BOOL       OpenQPInputFile( PQPROCINST pQProc, PSZ pszFileName, BOOL fOpen );
  236. BOOL       CloseQPInputFile( PQPROCINST pQProc );
  237. BOOL       OpenQPOutputDC(PQPROCINST pQProc, USHORT fFlag);
  238. BOOL       CloseQPOutputDC(PQPROCINST pQProc, BOOL fEndDoc);
  239.  
  240. #define hQProcTopQProc( hs ) (PQPROCINST)(USHORT)(hs)
  241.  
  242. PQPROCINST pQProcInstances; /* List of QProc Instances created by SplQpOpen */
  243.  
  244. /* Queue Processor functions defined in QPMSG.C  */
  245.  
  246. USHORT FARENTRY SplQpMessage(PSZ pszPort, USHORT uErrId, USHORT uErrCode);
  247.  
  248.  
  249. /* Queue Processor functions defined in QPSTD.C, QPRAW.C */
  250.  
  251. BOOL PASCAL SplQpStdPrintFile( PQPROCINST pQProc, PSZ pszFileName );
  252. BOOL SetViewMatrix( PQPROCINST pQProc );
  253. LONG ApplyPercentage( USHORT uPercent, USHORT uLower, USHORT uUpper );
  254. BOOL PASCAL SplQpRawPrintFile( PQPROCINST pQProc, PSZ pszFileName );
  255.  
  256.  
  257. /* Utility functions in QPUTIL.C */
  258.  
  259. VOID        FARENTRY EnterSplSem( VOID );
  260. VOID        FARENTRY LeaveSplSem( VOID );
  261. VOID        FARENTRY ExitSplSem( VOID );
  262. NPVOID      FARENTRY AllocSplMem(USHORT cb);
  263. NPVOID      FARENTRY FreeSplMem( NPVOID p, USHORT cb );
  264. NPSZ        FARENTRY AllocSplStr(PSZ pszSrc);
  265. NPSZ        FARENTRY FreeSplStr(NPSZ psz);
  266. NPSZ        FARENTRY ExtractFileName( NPSZ npszFileName, PSZ pszPathSpec,
  267.                                       BOOL bExtToo );
  268. USHORT      FARENTRY AsciiToInt( PSZ psz );
  269. BOOL        FARENTRY StrPrefix( PSZ pStr1, PSZ pStr2, USHORT cb );
  270. PKEYDATA    FARENTRY ParseKeyData( PSZ pKeyData, UCHAR chSep, USHORT cbKeyData );
  271. PSZ         FARENTRY MyItoa(USHORT, PSZ);
  272.  
  273.  
  274. #ifdef DEBUG
  275. #define SplInSem() if (FSRSemCheck(&semPMPRINT)) \
  276. SplPanic("not in semaphore in %Fs line:%d", __FILE__, __LINE__)
  277. #else
  278. #define SplInSem()
  279. #endif
  280.  
  281. #ifdef DEBUG
  282. #define SplOutSem() if (!FSRSemCheck(&semPMPRINT)) \
  283. SplPanic("in semaphore in %Fs line:%d", __FILE__, __LINE__)
  284. #else
  285. #define SplOutSem()
  286. #endif
  287.  
  288. #ifdef LMPRINT
  289.  
  290. #define OKSIG        0
  291. #define RESTARTSIG    1
  292. #define KILLSIG        2
  293. #define SEPERRORSIG    -1
  294. #define PROCERRORSIG    -2
  295. #define DEVERRORSIG    -3
  296.  
  297. #define MAXLINE        256        /* print separator */
  298.  
  299.  
  300. #define LETGOSTRMEM(pdev) EnterSplSem(); FreeSplMem(pdev->d_pszPath, pdev->d_uPathSize); LeaveSplSem()
  301.  
  302.  
  303. typedef struct _device_spl {
  304.     PQPROCINST    d_pQProc;
  305.     PSZ        d_pszSep;    /* name of separator file */
  306.     NPSZ        d_pszPath;    /* path to spool directory */
  307.     USHORT        d_uPathSize;     /* House keeping of size of alloc for path */
  308.     CHAR        d_szUser[UNLEN+1];/* user name */
  309.     ULONG        d_time;       /* Time of printing */
  310.     unsigned int    d_mode;     /* separator mode */
  311.     unsigned int    d_linelen;    /* Line lenegth */
  312.     HFILE        d_handle;
  313.     } DEVICESPL;
  314.  
  315. typedef DEVICESPL far * PDEVICESPL;
  316.  
  317.  
  318. int GetSepInfo(PQPROCINST, PDEVICESPL);
  319. int PrintSep(PDEVICESPL);
  320. #endif
  321.  
  322. #endif
  323.