2 * Copyright (c) 1990,1994 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
6 #include <sys/syslog.h>
15 struct papfile *infile, *outfile;
18 int linelength, crlflength;
19 struct comment *comment;
22 if ( comment = compeek()) {
23 switch( (*comment->c_handler)( infile, outfile )) {
35 switch ( markline( infile, &start, &linelength, &crlflength )) {
38 outfile->pf_state |= PF_EOF;
46 if ( infile->pf_state & PF_BOT ) {
47 if (( comment = commatch( start, start+linelength, magics )) != NULL ) {
49 continue; /* top of for (;;) */
51 infile->pf_state &= ~PF_BOT;
53 /* set up spool file */
54 if ( lp_open( outfile ) < 0 ) {
55 syslog( LOG_ERR, "lp_open failed" );
56 spoolerror( outfile, "Ignoring job." );
61 lp_write( start, linelength + crlflength );
62 CONSUME( infile, linelength + crlflength );
68 struct papfile *in, *out;
70 struct comment *comment;
72 int linelength, crlflength;
75 switch ( markline( in, &start, &linelength, &crlflength )) {
78 out->pf_state |= PF_EOF;
86 if ( in->pf_state & PF_BOT ) {
87 in->pf_state &= ~PF_BOT;
89 if (( comment = commatch( start, start+linelength, queries )) != NULL ) {
95 CONSUME( in, linelength + crlflength );
100 struct papfile *in, *out;
103 int linelength, crlflength;
104 struct comment *comment = compeek();
107 switch ( markline( in, &start, &linelength, &crlflength )) {
110 out->pf_state |= PF_EOF;
118 if ( in->pf_state & PF_BOT ) {
119 in->pf_state &= ~PF_BOT;
120 if ( lp_open( out ) < 0 ) {
121 syslog( LOG_ERR, "lp_open failed" );
122 spoolerror( out, "Ignoring job." );
125 if (( comment = commatch( start, start + linelength, headers )) != NULL ) {
131 lp_write( start, linelength + crlflength );
132 CONSUME( in, linelength + crlflength );
136 char *Query = "Query";
138 cm_psswitch( in, out )
139 struct papfile *in, *out;
141 char *start, *stop, *p;
142 int linelength, crlflength;
143 struct comment *comment = compeek();
145 switch ( markline( in, &start, &linelength, &crlflength )) {
148 out->pf_state |= PF_EOF;
156 stop = start + linelength;
157 for ( p = start; p < stop; p++ ) {
158 if ( *p == ' ' || *p == '\t' ) {
162 for ( ; p < stop; p++ ) {
163 if ( *p != ' ' && *p != '\t' ) {
168 if ( stop - p >= strlen( Query ) &&
169 strncmp( p, Query, strlen( Query )) == 0 ) {
170 if ( comswitch( magics, cm_psquery ) < 0 ) {
171 syslog( LOG_ERR, "cm_psswitch: can't find psquery!" );
175 if ( comswitch( magics, cm_psadobe ) < 0 ) {
176 syslog( LOG_ERR, "cm_psswitch: can't find psadobe!" );
183 struct comment magics[] = {
184 { "%!PS-Adobe-3.0 Query", 0, cm_psquery, C_FULL },
185 { "%!PS-Adobe-3.0", 0, cm_psadobe, C_FULL },
186 { "%!PS-Adobe-", 0, cm_psswitch, 0 },