2 * Copyright (c) 1995 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
9 #include <sys/syslog.h>
10 #include <sys/types.h>
11 #include <sys/param.h>
13 #include <netatalk/at.h>
14 #include <atalk/atp.h>
19 struct ppd_font *ppd_fonts = NULL;
21 struct ppd_feature ppd_features[] = {
22 { "*LanguageLevel", 0 },
29 { "*ColorDevice", 0 },
31 { "*TTRasterizer", 0 },
52 read_ppd( printer->p_ppdfile, 0 );
60 static char buf[ 1024 ];
61 static struct ppdent ppdent;
64 ppdent.pe_main = ppdent.pe_option = ppdent.pe_translation =
65 ppdent.pe_value = NULL;
67 while (( p = fgets( buf, sizeof( buf ), stream )) != NULL ) {
68 if ( *p != '*' ) { /* main key word */
71 if ( p[ strlen( p ) - 1 ] != '\n' ) {
72 syslog( LOG_ERR, "getppdent: line too long" );
77 while ( *p != ' ' && *p != '\t' && *p != ':' && *p != '\n' ) {
80 if ( *( q + 1 ) == '%' || *( q + 1 ) == '?' ) { /* comments & queries */
86 ppdent.pe_option = ppdent.pe_translation = ppdent.pe_value = NULL;
90 if ( *p != ':' ) { /* option key word */
93 while ( *p == ' ' || *p == '\t' ) {
98 while ( *p != ':' && *p != '/' && *p != '\n' ) {
106 ppdent.pe_option = q;
107 if ( *p == '/' ) { /* translation string */
110 while ( *p != ':' && *p != '\n' ) {
117 ppdent.pe_translation = q;
119 ppdent.pe_translation = NULL;
124 while ( *p == ' ' || *p == '\t' ) {
133 while ( *p != '"' && *p != '\n' ) {
144 while ( *p != '\n' ) {
156 read_ppd( file, fcnt )
162 struct ppd_feature *pfe;
163 struct ppd_font *pfo;
166 syslog( LOG_ERR, "read_ppd: %s: Too many files!", file );
170 if (( ppdfile = fopen( file, "r" )) == NULL ) {
171 syslog( LOG_ERR, "read_ppd %s: %m", file );
175 while (( pe = getppdent( ppdfile )) != NULL ) {
177 if ( strcmp( pe->pe_main, "*Include" ) == 0 ) {
178 read_ppd( pe->pe_value, fcnt + 1 );
183 if ( strcmp( pe->pe_main, "*Font" ) == 0 ) {
184 for ( pfo = ppd_fonts; pfo; pfo = pfo->pd_next ) {
185 if ( strcmp( pfo->pd_font, pe->pe_option ) == 0 ) {
193 if (( pfo = (struct ppd_font *)malloc( sizeof( struct ppd_font )))
195 syslog( LOG_ERR, "malloc: %m" );
199 (char *)malloc( strlen( pe->pe_option ) + 1 )) == NULL ) {
200 syslog( LOG_ERR, "malloc: %m" );
203 strcpy( pfo->pd_font, pe->pe_option );
204 pfo->pd_next = ppd_fonts;
211 for ( pfe = ppd_features; pfe->pd_name; pfe++ ) {
212 if ( strcmp( pe->pe_main, pfe->pd_name ) == 0 ) {
216 if ( pfe->pd_name && pfe->pd_value == NULL ) {
217 if (( pfe->pd_value =
218 (char *)malloc( strlen( pe->pe_value ) + 1 )) == NULL ) {
219 syslog( LOG_ERR, "malloc: %m" );
223 strcpy( pfe->pd_value, pe->pe_value );
236 struct ppd_font *pfo;
239 if ( ! ppd_inited ) {
244 for ( pfo = ppd_fonts; pfo; pfo = pfo->pd_next ) {
245 if ( strcmp( pfo->pd_font, font ) == 0 ) {
253 ppd_feature( feature, len )
257 struct ppd_feature *pfe;
262 if ( ! ppd_inited ) {
267 for ( end = feature + len, p = feature, q = main;
268 p <= end && *p != '\n' && *p != '\r'; p++, q++ ) {
276 for ( pfe = ppd_features; pfe->pd_name; pfe++ ) {
277 if ( strcmp( pfe->pd_name, main ) == 0 && pfe->pd_value ) {