]> arthur.barton.de Git - netatalk.git/blobdiff - etc/papd/queries.c
changed all LOG messages using logtype_default to use logtype_papd
[netatalk.git] / etc / papd / queries.c
index 44e8019d77a5bd0148cc580c4da7529ff955ae1f..a1ef26066a6f81a84435fbdedbb04f88eb1fb443 100644 (file)
@@ -1,14 +1,18 @@
 /*
+ * $Id: queries.c,v 1.15 2002-09-29 23:29:14 sibaz Exp $
+ *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
 
 #include <string.h>
-#include <sys/syslog.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <atalk/logger.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #ifdef KRB
 #ifdef SOLARIS
 #include <kerberos/krb.h>
-#else
+#else /* SOLARIS */
 #include <krb.h>
-#endif
-#endif KRB
+#endif /* SOLARIS */
+#endif /* KRB */
 
 #include "file.h"
 #include "comment.h"
 #include "printer.h"
 #include "ppd.h"
+#include "lp.h"
 #include "uam_auth.h"
 
-cq_default( in, out )
+int cq_default( struct papfile *, struct papfile * );
+int cq_k4login( struct papfile *, struct papfile * );
+int cq_uameth( struct papfile *, struct papfile * );
+
+int gq_balance( struct papfile * );
+int gq_pagecost( struct papfile * );
+int gq_true( struct papfile * );
+int gq_rbispoolerid( struct papfile * );
+int gq_rbiuamlist( struct papfile * );
+
+int cq_query( struct papfile *, struct papfile * );
+void cq_font_answer( char *, char *, struct papfile * );
+int cq_font( struct papfile *, struct papfile * );
+int cq_feature( struct papfile *, struct papfile * );
+int cq_printer( struct papfile *, struct papfile * );
+int cq_rmjob( struct papfile *, struct papfile * );
+int cq_listq( struct papfile *, struct papfile * );
+int cq_rbilogin( struct papfile *, struct papfile * );
+
+
+
+int cq_default( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *stop, *p;
@@ -85,7 +111,7 @@ char *LoginFailed = "LoginFailed\n";
 
 #define h2b(x) (isdigit((x))?(x)-'0':(isupper((x))?(x)-'A':(x)-'a')+10)
 
-cq_k4login( in, out )
+int cq_k4login( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *p;
@@ -119,13 +145,13 @@ cq_k4login( in, out )
 
     if (( rc = krb_rd_req( &tkt, "LaserWriter", printer->p_name,
            0, &ad, "" )) != RD_AP_OK ) {
-       syslog( LOG_ERR, "cq_k4login: %s", krb_err_txt[ rc ] );
+       LOG(log_error, logtype_papd, "cq_k4login: %s", krb_err_txt[ rc ] );
        append( out, LoginFailed, strlen( LoginFailed ));
        compop();
        CONSUME( in, linelength + crlflength );
        return( CH_DONE );
     }
-    syslog( LOG_INFO, "cq_k4login: %s.%s@%s", ad.pname, ad.pinst,
+    LOG(log_info, logtype_papd, "cq_k4login: %s.%s@%s", ad.pname, ad.pinst,
            ad.prealm );
     lp_person( ad.pname );
     lp_host( ad.prealm );
@@ -138,7 +164,7 @@ cq_k4login( in, out )
 
 char   *uameth = "UMICHKerberosIV\n*\n";
 
-cq_uameth( in, out )
+int cq_uameth( in, out )
     struct papfile     *in, *out;
 {
     char               *start;
@@ -157,7 +183,7 @@ cq_uameth( in, out )
        if ( comgetflags() == 0 ) {     /* start */
            if (( printer->p_flags & P_KRB ) == 0 ) {   /* no kerberos */
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_uameth: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_uameth: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -174,9 +200,9 @@ cq_uameth( in, out )
        CONSUME( in, linelength + crlflength );
     }
 }
-#endif KRB
+#endif /* KRB */
 
-gq_true( out )
+int gq_true( out )
     struct papfile     *out;
 {
     if ( printer->p_flags & P_SPOOLED ) {
@@ -187,7 +213,7 @@ gq_true( out )
     }
 }
 
-gq_pagecost( out )
+int gq_pagecost( out )
     struct papfile     *out;
 {
     char               cost[ 60 ];
@@ -199,7 +225,7 @@ gq_pagecost( out )
     } else if ( printer->p_flags & P_ACCOUNT ) {
 #ifdef ABS_PRINT
        lp_pagecost();
-#endif ABS_PRINT
+#endif /* ABS_PRINT */
        sprintf( cost, "%d", printer->p_pagecost );
        append( out, cost, strlen( cost ));
     } else {
@@ -210,7 +236,7 @@ gq_pagecost( out )
 }
 
 #ifdef ABS_PRINT
-gq_balance( out )
+int gq_balance( out )
     struct papfile     *out;
 {
     char               balance[ 60 ];
@@ -222,16 +248,16 @@ gq_balance( out )
     append( out, balance, strlen( balance ));
     return( 0 );
 }
-#endif ABS_PRINT
+#endif /* ABS_PRINT */
 
 
 /*
  * Handler for RBISpoolerID
  */
 
-static const char *spoolerid = "(PAPD Spooler) 2.1 (2.1.4 pre-release)\n";
+static const char *spoolerid = "(PAPD Spooler) " VERSION "\n";
 
-gq_rbispoolerid( out )
+int gq_rbispoolerid( out )
     struct papfile     *out;
 {
     append( out, spoolerid, strlen( spoolerid ));
@@ -246,7 +272,7 @@ gq_rbispoolerid( out )
 
 static const char *nouams = "*\n";
 
-gq_rbiuamlist( out )
+int gq_rbiuamlist( out )
     struct papfile      *out;
 {
     char uamnames[128] = "\0";
@@ -273,15 +299,16 @@ struct genquery {
     { "UMICHCostPerPage", gq_pagecost },
 #ifdef notdef
     { "UMICHUserBalance", gq_balance },
-#endif 
+#endif /* notdef */
     { "RBISpoolerID",  gq_rbispoolerid },
     { "RBIUAMListQuery", gq_rbiuamlist },
+    { "ADOIsBinaryOK?", gq_true },
     { "UMICHListQueue", gq_true },
     { "UMICHDeleteJob", gq_true },
     { NULL },
 };
 
-cq_query( in, out )
+int cq_query( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *stop, *p, *q;
@@ -331,7 +358,7 @@ cq_query( in, out )
            if ( gq->gq_name == NULL || gq->gq_handler == NULL ||
                    (gq->gq_handler)( out ) < 0 ) {
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_feature: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_feature: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -348,7 +375,7 @@ cq_query( in, out )
     }
 }
 
-cq_font_answer( start, stop, out )
+void cq_font_answer( start, stop, out )
     char               *start, *stop;
     struct papfile     *out;
 {
@@ -385,7 +412,7 @@ cq_font_answer( start, stop, out )
     return;
 }
 
-cq_font( in, out )
+int cq_font( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *stop, *p;
@@ -442,7 +469,7 @@ cq_font( in, out )
     }
 }
 
-cq_feature( in, out )
+int cq_feature( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *stop, *p;
@@ -477,7 +504,7 @@ cq_feature( in, out )
 
            if (( pfe = ppd_feature( p, stop - p )) == NULL ) {
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_feature: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_feature: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -500,7 +527,7 @@ cq_feature( in, out )
 static const char      *psver = "*PSVersion\n";
 static const char      *prod = "*Product\n";
 
-cq_printer( in, out )
+int cq_printer( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *p;
@@ -522,7 +549,7 @@ cq_printer( in, out )
 
            if (( pdpsver = ppd_feature( psver, strlen( psver ))) == NULL ) {
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_printer: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_printer: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -534,9 +561,9 @@ cq_printer( in, out )
                }
            }
            if ( *p == '\0' ) {
-               syslog( LOG_ERR, "cq_printer: can't parse PSVersion!" );
+               LOG(log_error, logtype_papd, "cq_printer: can't parse PSVersion!" );
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_printer: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_printer: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -544,7 +571,7 @@ cq_printer( in, out )
 
            if (( pdprod = ppd_feature( prod, strlen( prod ))) == NULL ) {
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_printer: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_printer: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -576,7 +603,7 @@ cq_printer( in, out )
 static const char      *rmjobfailed = "Failed\n";
 static const char      *rmjobok = "Ok\n";
 
-cq_rmjob( in, out )
+int cq_rmjob( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *stop, *p;
@@ -617,7 +644,7 @@ cq_rmjob( in, out )
     return( CH_DONE );
 }
 
-cq_listq( in, out )
+int cq_listq( in, out )
     struct papfile     *in, *out;
 {
     char               *start;
@@ -632,7 +659,7 @@ cq_listq( in, out )
     }
 
     if ( lp_queue( out )) {
-       syslog( LOG_ERR, "cq_listq: lp_queue failed" );
+       LOG(log_error, logtype_papd, "cq_listq: lp_queue failed" );
     }
 
     compop();
@@ -650,10 +677,10 @@ static const char *rbiloginok = "0\r";
 static const char *rbiloginbad = "-1\r";
 static const char *rbiloginerrstr = "%%[Error: SecurityError; \
 SecurityViolation: Unknown user, incorrect password or log on is \
-disabled ]%%\r%%Flushing: rest of job (to end-of-file) will be \
+disabled ]%%\r%%[Flushing: rest of job (to end-of-file) will be \
 ignored ]%%\r";
 
-cq_rbilogin( in, out )
+int cq_rbilogin( in, out )
     struct papfile      *in, *out;
 {
     char               *start, *stop, *p, *begin;
@@ -685,7 +712,7 @@ cq_rbilogin( in, out )
 
            if ((papd_uam = auth_uamfind(UAM_SERVER_PRINTAUTH,
                                uamtype, strlen(uamtype))) == NULL) {
-               syslog(LOG_INFO, "Could not find uam: %s", uamtype);
+               LOG(log_info, logtype_papd, "Could not find uam: %s", uamtype);
                append(out, rbiloginbad, strlen(rbiloginbad));
                append(out, rbiloginerrstr, strlen(rbiloginerrstr));
            } else {
@@ -717,7 +744,7 @@ struct papd_comment queries[] = {
 #ifdef KRB
     { "%%Login: UMICHKerberosIV", 0,                   cq_k4login,     0 },
     { "%%?BeginUAMethodsQuery",        "%%?EndUAMethodsQuery:", cq_uameth, C_FULL },
-#endif KRB
+#endif /* KRB */
     { "%UMICHListQueue", 0,                            cq_listq, C_FULL },
     { "%UMICHDeleteJob", 0,                            cq_rmjob,       0 },
     { "%%?BeginQuery: RBILogin ", "%%?EndQuery",       cq_rbilogin,    0 },