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 struct comment *comment;
21 if ( comment = compeek()) {
22 switch( (*comment->c_handler)( infile, outfile )) {
34 switch ( markline( &start, &stop, infile )) {
37 outfile->pf_state |= PF_EOF;
45 if ( infile->pf_state & PF_BOT ) {
46 if (( comment = commatch( start, stop, magics )) != NULL ) {
48 continue; /* top of for (;;) */
50 infile->pf_state &= ~PF_BOT;
52 /* set up spool file */
53 if ( lp_open( outfile ) < 0 ) {
54 syslog( LOG_ERR, "lp_open failed" );
55 spoolerror( outfile, "Ignoring job." );
61 lp_write( start, stop - start + 1 );
62 consumetomark( start, stop, infile );
68 struct papfile *in, *out;
70 struct comment *comment;
74 switch ( markline( &start, &stop, in )) {
77 out->pf_state |= PF_EOF;
85 if ( in->pf_state & PF_BOT ) {
86 in->pf_state &= ~PF_BOT;
88 if (( comment = commatch( start, stop, queries )) != NULL ) {
94 consumetomark( start, stop, in );
99 struct papfile *in, *out;
102 struct comment *comment = compeek();
105 switch ( markline( &start, &stop, in )) {
108 out->pf_state |= PF_EOF;
116 if ( in->pf_state & PF_BOT ) {
117 in->pf_state &= ~PF_BOT;
118 if ( lp_open( out ) < 0 ) {
119 syslog( LOG_ERR, "lp_open failed" );
120 spoolerror( out, "Ignoring job." );
123 if (( comment = commatch( start, stop, headers )) != NULL ) {
130 lp_write( start, stop - start + 1 );
131 consumetomark( start, stop, in );
135 char *Query = "Query";
137 cm_psswitch( in, out )
138 struct papfile *in, *out;
140 char *start, *stop, *p;
141 struct comment *comment = compeek();
143 switch ( markline( &start, &stop, in )) {
146 out->pf_state |= PF_EOF;
154 for ( p = start; p < stop; p++ ) {
155 if ( *p == ' ' || *p == '\t' ) {
159 for ( ; p < stop; p++ ) {
160 if ( *p != ' ' && *p != '\t' ) {
165 if ( stop - p >= strlen( Query ) &&
166 strncmp( p, Query, strlen( Query )) == 0 ) {
167 if ( comswitch( magics, cm_psquery ) < 0 ) {
168 syslog( LOG_ERR, "cm_psswitch: can't find psquery!" );
172 if ( comswitch( magics, cm_psadobe ) < 0 ) {
173 syslog( LOG_ERR, "cm_psswitch: can't find psadobe!" );
180 struct comment magics[] = {
181 { "%!PS-Adobe-3.0 Query", 0, cm_psquery, C_FULL },
182 { "%!PS-Adobe-3.0", 0, cm_psadobe, C_FULL },
183 { "%!PS-Adobe-", 0, cm_psswitch, 0 },