]> arthur.barton.de Git - netatalk.git/blobdiff - etc/papd/queries.c
Remove bdb env on exit
[netatalk.git] / etc / papd / queries.c
index 658caa02a87f8baf9612aec6d83ff8351cd92f4a..ef1c5a6e8991c0e074408dbac5fd3563397ae101 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: queries.c,v 1.20 2009-02-02 12:46:45 didg Exp $
+ * $Id: queries.c,v 1.22 2009-10-13 22:55:37 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -57,8 +57,7 @@ int cq_rbilogin( struct papfile *, struct papfile * );
 
 
 
-int cq_default( in, out )
-    struct papfile     *in, *out;
+int cq_default( struct papfile *in, struct papfile *out)
 {
     char               *start, *stop, *p;
     int                        linelength, crlflength;
@@ -94,9 +93,11 @@ int cq_default( in, out )
                        break;
                    }
                }
-               p++;
-               while ( *p == ' ' ) {
+               if (p < stop) {
                    p++;
+                   while ( *p == ' ' ) {
+                       p++;
+                    }
                }
 
                append( out, p, stop - p + crlflength );
@@ -116,8 +117,7 @@ char        *LoginFailed = "LoginFailed\n";
 
 #define h2b(x) (isdigit((x))?(x)-'0':(isupper((x))?(x)-'A':(x)-'a')+10)
 
-int cq_k4login( in, out )
-    struct papfile     *in, *out;
+int cq_k4login( struct papfile *in, struct papfile *out)
 {
     char               *start, *p;
     int                        linelength, crlflength;
@@ -145,6 +145,7 @@ int cq_k4login( in, out )
 
     bzero( &tkt, sizeof( tkt ));
     stop = start+linelength;
+    /* FIXME */
     for ( i = 0, t = tkt.dat; p < stop; p += 2, t++, i++ ) {
        *t = ( h2b( (unsigned char)*p ) << 4 ) +
                h2b( (unsigned char)*( p + 1 ));
@@ -172,8 +173,7 @@ int cq_k4login( in, out )
 
 char   *uameth = "UMICHKerberosIV\n*\n";
 
-int cq_uameth( in, out )
-    struct papfile     *in, *out;
+int cq_uameth( struct papfile *in, struct papfile *out)
 {
     char               *start;
     int                        linelength, crlflength;
@@ -213,8 +213,7 @@ int cq_uameth( in, out )
 }
 #endif /* KRB */
 
-int gq_true( out )
-    struct papfile     *out;
+int gq_true( struct papfile *out)
 {
     if ( printer->p_flags & P_SPOOLED ) {
        append( out, "true\n", 5 );
@@ -224,8 +223,7 @@ int gq_true( out )
     }
 }
 
-int gq_pagecost( out )
-    struct papfile     *out;
+int gq_pagecost( struct papfile *out)
 {
     char               cost[ 60 ];
 
@@ -247,8 +245,7 @@ int gq_pagecost( out )
 }
 
 #ifdef ABS_PRINT
-int gq_balance( out )
-    struct papfile     *out;
+int gq_balance( struct papfile *out)
 {
     char               balance[ 60 ];
 
@@ -268,8 +265,7 @@ int gq_balance( out )
 
 static const char *spoolerid = "(PAPD Spooler) 1.0 (" VERSION ")\n";
 
-int gq_rbispoolerid( out )
-    struct papfile     *out;
+int gq_rbispoolerid( struct papfile *out)
 {
     append( out, spoolerid, strlen( spoolerid ));
     return(0);
@@ -283,8 +279,7 @@ int gq_rbispoolerid( out )
 
 static const char *nouams = "*\n";
 
-int gq_rbiuamlist( out )
-    struct papfile      *out;
+int gq_rbiuamlist( struct papfile *out)
 {
     char uamnames[128] = "\0";
 
@@ -319,8 +314,7 @@ struct genquery {
     { NULL, NULL },
 };
 
-int cq_query( in, out )
-    struct papfile     *in, *out;
+int cq_query( struct papfile *in, struct papfile *out)
 {
     char               *start, *stop, *p, *q;
     int                        linelength, crlflength;
@@ -351,7 +345,7 @@ int cq_query( in, out )
                }
            }
 
-           for ( p++; p < stop; p++ ) {
+           if (p < stop) for ( p++; p < stop; p++ ) {
                if ( *p != ' ' && *p != '\t' ) {
                    break;
                }
@@ -364,7 +358,7 @@ int cq_query( in, out )
            }
 
            for ( gq = genqueries; gq->gq_name; gq++ ) {
-               if (( strlen( gq->gq_name ) == q - p ) &&
+               if (( strlen( gq->gq_name ) == (size_t)(q - p) ) &&
                        ( strncmp( gq->gq_name, p, q - p ) == 0 )) {
                    break;
                }
@@ -389,9 +383,7 @@ int cq_query( in, out )
     }
 }
 
-void cq_font_answer( start, stop, out )
-    char               *start, *stop;
-    struct papfile     *out;
+void cq_font_answer( char *start, char *stop, struct papfile *out)
 {
     char               *p, *q, buf[ 256 ];
     struct ppd_font    *pfo;
@@ -428,8 +420,7 @@ void cq_font_answer( start, stop, out )
     return;
 }
 
-int cq_font( in, out )
-    struct papfile     *in, *out;
+int cq_font(struct papfile *in, struct papfile *out)
 {
     char               *start, *stop, *p;
     int                        linelength, crlflength;
@@ -457,7 +448,8 @@ int cq_font( in, out )
                    break;
                }
            }
-           p++;
+           if (p < stop)
+               p++;
 
            cq_font_answer( p, stop, out );
        } else {
@@ -470,7 +462,8 @@ int cq_font( in, out )
                        break;
                    }
                }
-               p++;
+               if (p < stop)
+                   p++;
 
                cq_font_answer( p, stop, out );
            } else {
@@ -488,8 +481,7 @@ int cq_font( in, out )
     }
 }
 
-int cq_feature( in, out )
-    struct papfile     *in, *out;
+int cq_feature( struct papfile *in, struct papfile *out)
 {
     char               *start, *stop, *p;
     int                        linelength, crlflength;
@@ -519,7 +511,8 @@ int cq_feature( in, out )
                    break;
                }
            }
-           p++;
+           if (p < stop)
+               p++;
            while ( *p == ' ' ) {
                p++;
            }
@@ -549,8 +542,7 @@ int cq_feature( in, out )
 static const char      *psver = "*PSVersion\n";
 static const char      *prod = "*Product\n";
 
-int cq_printer( in, out )
-    struct papfile     *in, *out;
+int cq_printer(struct papfile *in, struct papfile *out)
 {
     char               *start, *p;
     int                        linelength, crlflength;
@@ -630,8 +622,7 @@ int cq_printer( in, out )
 static const char      *rmjobfailed = "Failed\n";
 static const char      *rmjobok = "Ok\n";
 
-int cq_rmjob( in, out )
-    struct papfile     *in, *out;
+int cq_rmjob( struct papfile *in, struct papfile *out)
 {
     char               *start, *stop, *p;
     int                        linelength, crlflength;
@@ -674,8 +665,7 @@ int cq_rmjob( in, out )
     return( CH_DONE );
 }
 
-int cq_listq( in, out )
-    struct papfile     *in, *out;
+int cq_listq( struct papfile *in, struct papfile *out)
 {
     char               *start;
     int                        linelength, crlflength;
@@ -714,8 +704,7 @@ SecurityViolation: Unknown user, incorrect password or log on is \
 disabled ]%%\r%%[Flushing: rest of job (to end-of-file) will be \
 ignored ]%%\r";
 
-int cq_rbilogin( in, out )
-    struct papfile      *in, *out;
+int cq_rbilogin( struct papfile *in, struct papfile *out)
 {
     char               *start, *stop, *p, *begin;
     int                        linelength, crlflength;