]> arthur.barton.de Git - netatalk.git/blobdiff - etc/papd/ppd.c
CVS id tags, define fixes, code beautification
[netatalk.git] / etc / papd / ppd.c
index 783719feaf4eaecc1ef6d103a02532875cbc83e0..c0a4e59bc63cd9620595b31279304ab9cead52bb 100644 (file)
@@ -1,8 +1,14 @@
 /*
+ * $Id: ppd.c,v 1.6 2001-06-25 20:13:45 rufustfirefly Exp $
+ *
  * Copyright (c) 1995 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -39,45 +45,21 @@ struct ppdent {
     char       *pe_value;
 };
 
-#ifdef notdef
-main( ac, av )
-    int                ac;
-    char       **av;
-{
-    struct ppd_feature *pfe;
-    struct ppd_font    *pfo;
-
-    if ( ac != 2 ) {
-       fprintf( stderr, "Usage:\t%s ppdfile\n", av[ 0 ] );
-       exit( 1 );
-    }
-
-    read_ppd( av[ 1 ], 0 );
-    for ( pfo = ppd_fonts; pfo; pfo = pfo->pd_next ) {
-       printf( "Font: %s\n", pfo->pd_font );
-    }
-    for ( pfe = ppd_features; pfe->pd_name; pfe++ ) {
-       printf( "Feature: %s %s\n", pfe->pd_name, pfe->pd_value );
-    }
-
-    exit( 0 );
-}
-#endif notdef
-
+#ifndef SHOWPPD
 int ppd_inited = 0;
 
-ppd_init()
+int ppd_init()
 {
     if ( ppd_inited ) {
        return( -1 );
     }
     ppd_inited++;
 
-    read_ppd( printer->p_ppdfile, 0 );
+    return read_ppd( printer->p_ppdfile, 0 );
 }
+#endif /* SHOWPPD */
 
-    struct ppdent *
-getppdent( stream )
+struct ppdent *getppdent( stream )
     FILE       *stream;
 {
     static char                        buf[ 1024 ];
@@ -97,10 +79,10 @@ getppdent( stream )
        }
 
        q = p;
-       while ( *p != ' ' && *p != '\t' && *p != ':' && *p != '\n' ) {
+       while ( (*p != ' ') && (*p != '\t') && (*p != ':') && (*p != '\n') ) {
            p++;
        }
-       if ( *( q + 1 ) == '%' || *( q + 1 ) == '?' ) { /* comments & queries */
+       if ( (*( q + 1 ) == '%') || (*( q + 1 ) == '?') ) {     /* comments & queries */
            continue;
        }
        ppdent.pe_main = q;
@@ -113,12 +95,12 @@ getppdent( stream )
        if ( *p != ':' ) {      /* option key word */
            *p++ = '\0';
 
-           while ( *p == ' ' || *p == '\t' ) {
+           while ( (*p == ' ') || (*p == '\t') ) {
                p++;
            }
 
            q = p;
-           while ( *p != ':' && *p != '/' && *p != '\n' ) {
+           while ( (*p != ':') && (*p != '/') && (*p != '\n') ) {
                p++;
            }
 
@@ -144,39 +126,25 @@ getppdent( stream )
        }
        *p++ = '\0';
 
-       while ( *p == ' ' || *p == '\t' ) {
+       while ( (*p == ' ') || (*p == '\t') ) {
            p++;
        }
 
        /* value */
-       if ( *p == '"' ) {
+       q = p;
+       while ( *p != '\n' ) {
            p++;
-           q = p;
-
-           while ( *p != '"' && *p != '\n' ) {
-               p++;
-           }
-
-           if ( *p == '\n' ) {
-               continue;
-           }
-           *p = '\0';
-           ppdent.pe_value = q;
-       } else {
-           q = p;
-           while ( *p != '\n' ) {
-               p++;
-           }
-           *p = '\0';
-           ppdent.pe_value = q;
        }
+       *p = '\0';
+       ppdent.pe_value = q;
+
        return( &ppdent );
     }
 
     return( NULL );
 }
 
-read_ppd( file, fcnt )
+int read_ppd( file, fcnt )
     char       *file;
     int                fcnt;
 {
@@ -236,7 +204,7 @@ read_ppd( file, fcnt )
                break;
            }
        }
-       if ( pfe->pd_name && pfe->pd_value == NULL ) {
+       if ( pfe->pd_name && (pfe->pd_value == NULL) ) {
            if (( pfe->pd_value =
                    (char *)malloc( strlen( pe->pe_value ) + 1 )) == NULL ) {
                syslog( LOG_ERR, "malloc: %m" );
@@ -252,15 +220,16 @@ read_ppd( file, fcnt )
     return( 0 );
 }
 
-    struct ppd_font *
-ppd_font( font )
+struct ppd_font *ppd_font( font )
     char       *font;
 {
     struct ppd_font    *pfo;
 
+#ifndef SHOWPPD
     if ( ! ppd_inited ) {
        ppd_init();
     }
+#endif /* SHOWPPD */
 
     for ( pfo = ppd_fonts; pfo; pfo = pfo->pd_next ) {
        if ( strcmp( pfo->pd_font, font ) == 0 ) {
@@ -270,21 +239,23 @@ ppd_font( font )
     return( NULL );
 }
 
-    struct ppd_feature *
-ppd_feature( feature, len )
-    char       *feature;
+struct ppd_feature *ppd_feature( feature, len )
+    const char *feature;
     int                len;
 {
     struct ppd_feature *pfe;
-    char               main[ 256 ];
-    char               *end, *p, *q;
+    char               ppd_feature_main[ 256 ];
+    const char         *end, *p;
+    char               *q;
 
+#ifndef SHOWPPD
     if ( ! ppd_inited ) {
        ppd_init();
     }
+#endif /* SHOWPPD */
 
-    for ( end = feature + len, p = feature, q = main;
-           p <= end && *p != '\n' && *p != '\r'; p++, q++ ) {
+    for ( end = feature + len, p = feature, q = ppd_feature_main;
+           (p <= end) && (*p != '\n') && (*p != '\r'); p++, q++ ) {
        *q = *p;
     }
     if ( p > end ) {
@@ -293,7 +264,7 @@ ppd_feature( feature, len )
     *q = '\0';
 
     for ( pfe = ppd_features; pfe->pd_name; pfe++ ) {
-       if ( strcmp( pfe->pd_name, main ) == 0 && pfe->pd_value ) {
+       if ( (strcmp( pfe->pd_name, ppd_feature_main ) == 0) && pfe->pd_value ) {
            return( pfe );
        }
     }