1 #include "PrintJobPlugin.h"
2 #include <stdio.h>
3 
4 
5 /* none of these setup, cleanup, preprocess, postprocess,
6    *etc. commands make any sense on Unix.  Well, I suppose such a
7    *thing could* be implemented, but it would all have to be done by
8    *hand */
ioPrintSetup(PrintingLogicPtr * printJob)9 int ioPrintSetup(PrintingLogicPtr  *printJob)
10 {
11   *printJob= (PrintingLogicPtr) 1234;  /* I would like to put NULL here, but NULL is considered an error.... */
12   return 0;
13 }
14 
ioPrintPreProcessing(PrintingLogicPtr printJob,int numberOfPages)15 int ioPrintPreProcessing(PrintingLogicPtr printJob,int numberOfPages)
16 {
17   return 0;
18 }
19 
ioPrintPostProcessing(PrintingLogicPtr printJob)20 int ioPrintPostProcessing(PrintingLogicPtr printJob)
21 {
22   return 0;
23 }
24 
ioPrintCleanup(PrintingLogicPtr * printJob)25 int ioPrintCleanup(PrintingLogicPtr *printJob)
26 {
27   return 0;
28 }
29 
ioInitPrintJob(void)30 int ioInitPrintJob(void)
31 {
32   return 1;  /* it would be nice to have a standard on which functions
33                 return 0 for success and which functions return
34                 non-zero... */
35 }
36 
ioShutdownPrintJob(void)37 int ioShutdownPrintJob(void)
38 {
39   return 1;
40 }
41 
ioPagePreProcessing(PrintingLogicPtr printJob)42 int ioPagePreProcessing(PrintingLogicPtr printJob)
43 {
44   return 0;
45 }
46 
ioPagePostProcessing(PrintingLogicPtr printJob)47 int ioPagePostProcessing(PrintingLogicPtr printJob)
48 {
49   return 0;
50 }
51 
52 
53 
54 
55 /* ioGetFirstPageNumber and ioGetLastPageNumber --
56    Since the above operations aren't actually performed, there are no
57    page numbers, or any other info, to be returned from the plugin.
58    These functions just return page 1.  */
59 
ioPrintGetFirstPageNumber(PrintingLogicPtr printJob)60 int ioPrintGetFirstPageNumber(PrintingLogicPtr printJob)
61 {
62   return 1;
63 }
64 
65 
ioPrintGetLastPageNumber(PrintingLogicPtr printJob)66 int ioPrintGetLastPageNumber(PrintingLogicPtr printJob)
67 {
68   return 1;
69 }
70 
71 
72 /* ioPrint -- theoretically this should be where the printing happens,
73    but that means recording each portion of the print job.  It should
74    be fixed up at some point to do so; users should be able, for
75    example, to cancel a print job.  Then again, for the common
76    application of printing out the current desktop, it doesn't matter */
ioPrint(PrintingLogicPtr printJob)77 int ioPrint(PrintingLogicPtr printJob)
78 {
79   return 0;
80 }
81 
82 
83 
84 /* ioPagePostscript -- print out a posstcript file.  This just popen's lpr */
85 /* XXX the exact print command should probably be configurable */
ioPagePostscript(PrintingLogicPtr printJob,char * postscript,int postscriptLength)86 int ioPagePostscript(PrintingLogicPtr printJob,char *postscript,int postscriptLength)
87 {
88   FILE *lprOutput;
89   size_t written;
90 
91   lprOutput=popen("lpr", "w");
92   if(lprOutput == NULL) {
93     perror("lpr");
94     return 1;
95   }
96 
97   written = fwrite(postscript, postscriptLength, 1, lprOutput);
98   if(written < 1) {
99     perror("fwrite");
100     pclose(lprOutput);
101     return 1;
102   }
103 
104   pclose(lprOutput);
105   return 0;
106 }
107 
108 
109 /* ioPageForm -- print out a form */
ioPageForm(PrintingLogicPtr printJob,char * aBitMap,int h,int w,int d,float sh,float sw,int oh,int ow)110 int ioPageForm(PrintingLogicPtr printJob, char *aBitMap,int h,int w,int d,float sh,float sw,int oh,int ow)
111 {
112   /* just call the original primitive for form-printing */
113   return ioFormPrint((int)aBitMap, w, h, d, sw, sh, 1);
114 }
115