2 * Copyright (c) 1995 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
13 #include <sys/syslog.h>
14 #include <sys/types.h>
15 #include <sys/param.h>
17 #include <netatalk/at.h>
18 #include <atalk/atp.h>
23 struct ppd_font *ppd_fonts = NULL;
25 struct ppd_feature ppd_features[] = {
26 { "*LanguageLevel", 0 },
33 { "*ColorDevice", 0 },
35 { "*TTRasterizer", 0 },
56 read_ppd( printer->p_ppdfile, 0 );
64 static char buf[ 1024 ];
65 static struct ppdent ppdent;
68 ppdent.pe_main = ppdent.pe_option = ppdent.pe_translation =
69 ppdent.pe_value = NULL;
71 while (( p = fgets( buf, sizeof( buf ), stream )) != NULL ) {
72 if ( *p != '*' ) { /* main key word */
75 if ( p[ strlen( p ) - 1 ] != '\n' ) {
76 syslog( LOG_ERR, "getppdent: line too long" );
81 while ( *p != ' ' && *p != '\t' && *p != ':' && *p != '\n' ) {
84 if ( *( q + 1 ) == '%' || *( q + 1 ) == '?' ) { /* comments & queries */
90 ppdent.pe_option = ppdent.pe_translation = ppdent.pe_value = NULL;
94 if ( *p != ':' ) { /* option key word */
97 while ( *p == ' ' || *p == '\t' ) {
102 while ( *p != ':' && *p != '/' && *p != '\n' ) {
110 ppdent.pe_option = q;
111 if ( *p == '/' ) { /* translation string */
114 while ( *p != ':' && *p != '\n' ) {
121 ppdent.pe_translation = q;
123 ppdent.pe_translation = NULL;
128 while ( *p == ' ' || *p == '\t' ) {
134 while ( *p != '\n' ) {
146 read_ppd( file, fcnt )
152 struct ppd_feature *pfe;
153 struct ppd_font *pfo;
156 syslog( LOG_ERR, "read_ppd: %s: Too many files!", file );
160 if (( ppdfile = fopen( file, "r" )) == NULL ) {
161 syslog( LOG_ERR, "read_ppd %s: %m", file );
165 while (( pe = getppdent( ppdfile )) != NULL ) {
167 if ( strcmp( pe->pe_main, "*Include" ) == 0 ) {
168 read_ppd( pe->pe_value, fcnt + 1 );
173 if ( strcmp( pe->pe_main, "*Font" ) == 0 ) {
174 for ( pfo = ppd_fonts; pfo; pfo = pfo->pd_next ) {
175 if ( strcmp( pfo->pd_font, pe->pe_option ) == 0 ) {
183 if (( pfo = (struct ppd_font *)malloc( sizeof( struct ppd_font )))
185 syslog( LOG_ERR, "malloc: %m" );
189 (char *)malloc( strlen( pe->pe_option ) + 1 )) == NULL ) {
190 syslog( LOG_ERR, "malloc: %m" );
193 strcpy( pfo->pd_font, pe->pe_option );
194 pfo->pd_next = ppd_fonts;
201 for ( pfe = ppd_features; pfe->pd_name; pfe++ ) {
202 if ( strcmp( pe->pe_main, pfe->pd_name ) == 0 ) {
206 if ( pfe->pd_name && pfe->pd_value == NULL ) {
207 if (( pfe->pd_value =
208 (char *)malloc( strlen( pe->pe_value ) + 1 )) == NULL ) {
209 syslog( LOG_ERR, "malloc: %m" );
213 strcpy( pfe->pd_value, pe->pe_value );
226 struct ppd_font *pfo;
229 if ( ! ppd_inited ) {
234 for ( pfo = ppd_fonts; pfo; pfo = pfo->pd_next ) {
235 if ( strcmp( pfo->pd_font, font ) == 0 ) {
243 ppd_feature( feature, len )
247 struct ppd_feature *pfe;
252 if ( ! ppd_inited ) {
257 for ( end = feature + len, p = feature, q = main;
258 p <= end && *p != '\n' && *p != '\r'; p++, q++ ) {
266 for ( pfe = ppd_features; pfe->pd_name; pfe++ ) {
267 if ( strcmp( pfe->pd_name, main ) == 0 && pfe->pd_value ) {