| 121 | */ |
| 122 | |
| 123 | static int /* O - Exit status */ |
| 124 | auto_configure(ppd_file_t *ppd, /* I - PPD file */ |
| 125 | const char *user) /* I - Printing user */ |
| 126 | { |
| 127 | int status = 0; /* Exit status */ |
| 128 | ppd_option_t *option; /* Current option in PPD */ |
| 129 | ppd_attr_t *attr; /* Query command attribute */ |
| 130 | const char *valptr; /* Pointer into attribute value */ |
| 131 | char buffer[1024], /* String buffer */ |
| 132 | *bufptr; /* Pointer into buffer */ |
| 133 | ssize_t bytes; /* Number of bytes read */ |
| 134 | int datalen; /* Side-channel data length */ |
| 135 | |
| 136 | |
| 137 | /* |
| 138 | * See if the backend supports bidirectional I/O... |
| 139 | */ |
| 140 | |
| 141 | datalen = 1; |
| 142 | if (cupsSideChannelDoRequest(CUPS_SC_CMD_GET_BIDI, buffer, &datalen, |
| 143 | 30.0) != CUPS_SC_STATUS_OK || |
| 144 | buffer[0] != CUPS_SC_BIDI_SUPPORTED) |
| 145 | { |
| 146 | fputs("DEBUG: Unable to auto-configure PostScript Printer - no " |
| 147 | "bidirectional I/O available!\n", stderr); |
| 148 | return (1); |
| 149 | } |
| 150 | |
| 151 | /* |
| 152 | * Put the printer in PostScript mode... |
| 153 | */ |
| 154 | |
| 155 | begin_ps(ppd, user); |
| 156 | |
| 157 | /* |
| 158 | * (STR #4028) |
| 159 | * |
| 160 | * As a lot of PPDs contain bad PostScript query code, we need to prevent one |
| 161 | * bad query sequence from affecting all auto-configuration. The following |
| 162 | * error handler allows us to log PostScript errors to cupsd. |
| 163 | */ |
| 164 | |
| 165 | puts("/cups_handleerror {\n" |
| 166 | " $error /newerror false put\n" |
| 167 | " (:PostScript error in \") print cups_query_keyword print (\": ) " |
| 168 | "print\n" |
| 169 | " $error /errorname get 128 string cvs print\n" |
| 170 | " (; offending command:) print $error /command get 128 string cvs " |
| 171 | "print (\n) print flush\n" |
| 172 | "} bind def\n" |
| 173 | "errordict /timeout {} put\n" |
| 174 | "/cups_query_keyword (?Unknown) def\n"); |
| 175 | fflush(stdout); |
| 176 | |
| 177 | /* |
| 178 | * Wait for the printer to become connected... |
| 179 | */ |
| 180 |
no test coverage detected