]> arthur.barton.de Git - netatalk.git/commitdiff
prototyping to allow the compiler to do some real argument checking
authorsamnoble <samnoble>
Thu, 24 May 2001 21:23:50 +0000 (21:23 +0000)
committersamnoble <samnoble>
Thu, 24 May 2001 21:23:50 +0000 (21:23 +0000)
turned up a number of problems which are now fixed (due to the addition
of prototypes for functions in papd)... in particular papd will no longer
dump core in alphalinux when it tries to unregister all its nbp services.

19 files changed:
etc/papd/auth.c
etc/papd/comment.c
etc/papd/comment.h
etc/papd/file.c
etc/papd/file.h
etc/papd/headers.c
etc/papd/lp.c
etc/papd/lp.h [new file with mode: 0644]
etc/papd/magics.c
etc/papd/main.c
etc/papd/ppd.c
etc/papd/ppd.h
etc/papd/printcap.c
etc/papd/printcap.h [new file with mode: 0644]
etc/papd/queries.c
etc/papd/session.c
etc/papd/session.h [new file with mode: 0644]
etc/papd/uam.c
etc/papd/uam_auth.h

index 9776693ed7f9f115bf470c8ac1c7bf51eca9949f..a30a48b5212d92ca62edb1d93dbf0367f603cef8 100644 (file)
@@ -118,6 +118,7 @@ int auth_load(const char *path, const char *list)
     }
     p = strtok(NULL, ",");
   }
+  return 0;
 }
 
 /* get rid of all of the uams */
index 71b6d58f68a856bafc1172dcb5978e983094ae0a..d4122107c081bed4ed5671b2e09a9ca9493bcdda 100644 (file)
@@ -19,7 +19,7 @@ struct comstate       *comstate;
 
 char   *comcont = "%%+";
 
-compop()
+void compop( void )
 {
     struct comstate    *cs;
 
@@ -28,7 +28,7 @@ compop()
     free( cs );
 }
 
-compush( comment )
+void compush( comment )
     struct papd_comment        *comment;
 {
     struct comstate    *cs;
@@ -45,7 +45,7 @@ compush( comment )
     comstate = cs;
 }
 
-comswitch( comments, handler )
+int comswitch( comments, handler )
     struct papd_comment        *comments;
     int                        (*handler)();
 {
@@ -65,7 +65,7 @@ comswitch( comments, handler )
     return( 0 );
 }
 
-comcmp( start, stop, str, how )
+int comcmp( start, stop, str, how )
     char       *start, *stop, *str;
     int                how;
 {
@@ -74,11 +74,11 @@ comcmp( start, stop, str, how )
     len = stop - start;
     cc = strlen( str );
     if ( how & C_FULL ) {
-       if ( cc == len & strncmp( str, start, cc ) == 0 ) {
+       if ( (cc == len) && (strncmp( str, start, cc ) == 0) ) {
            return( 0 );
        }
     } else {
-       if ( cc <= len && strncmp( str, start, cc ) == 0 ) {
+       if ( (cc <= len) && (strncmp( str, start, cc ) == 0) ) {
            return( 0 );
        }
     }
@@ -86,8 +86,7 @@ comcmp( start, stop, str, how )
     return( 1 );
 }
 
-    struct papd_comment *
-commatch( start, stop, comments )
+struct papd_comment *commatch( start, stop, comments )
     char               *start, *stop;
     struct papd_comment        comments[];
 {
@@ -105,8 +104,7 @@ commatch( start, stop, comments )
     }
 }
 
-    char *
-comtoken( start, stop, pos, delim )
+char *comtoken( start, stop, pos, delim )
     char       *start, *stop, *pos, *delim;
 {
     if ( pos < start || pos > stop ) {
index 482846caac353db6e8278e46eac8598d2e6ba219..f068011e9a4f5ad1f3357cd07c19a71316055ed0 100644 (file)
@@ -3,6 +3,9 @@
  * All Rights Reserved.  See COPYRIGHT.
  */
 
+#ifndef PAPD_COMMENT_H
+#define PAPD_COMMENT_H 1
+
 struct papd_comment {
     char               *c_begin;
     char               *c_end;
@@ -46,3 +49,12 @@ extern char                  *comcont;
  * Magic "number" subtypes.
  */
 #define CM_NOPRINT     (1<<16)                         /* or print */
+
+void compop __P(( void ));
+void compush __P(( struct papd_comment * ));
+int comswitch __P(( struct papd_comment *, int (*)() ));
+int comcmp __P(( char *, char *, char *, int ));
+struct papd_comment *commatch __P(( char *, char *, struct papd_comment * ));
+char *comtoken __P(( char *, char *, char *, char * ));
+
+#endif /* PAPD_COMMENT_H */
index 50a6986168ad6a57177b29138d0efb7776644dd6..76e4961a41b3b1b92692d2781535bd81a1b82fd2 100644 (file)
@@ -15,7 +15,7 @@
 
 #include "file.h"
 
-markline( pf, start, linelength, crlflength )
+int markline( pf, start, linelength, crlflength )
     char               **start;
     int                        *linelength, *crlflength;
     struct papfile     *pf;
@@ -55,7 +55,7 @@ markline( pf, start, linelength, crlflength )
     return *linelength;
 }
 
-morespace( pf, data, len )
+void morespace( pf, data, len )
     struct papfile     *pf;
     char               *data;
     int                        len;
@@ -90,22 +90,22 @@ morespace( pf, data, len )
 }
 
 
-append(pf, data, len)
+void append(pf, data, len)
     struct papfile     *pf;
-    char               *data;
+    const char         *data;
     int                        len;
 {
     if ((pf->pf_data + pf->pf_datalen + len) >
        (pf->pf_buf + pf->pf_bufsize)) {
                morespace(pf, data, len);
     } else {
-       bcopy(data, pf->pf_data + pf->pf_datalen, len);
+       memcpy(pf->pf_data + pf->pf_datalen, data, len);
        pf->pf_datalen += len;
     }
 }
 
 
-spoolerror( out, str )
+void spoolerror( out, str )
     struct papfile     *out;
     char               *str;
 {
index f33800d2495b319628d167ddf873db2d118e1842..b7f4aeb025eb4a0840be1f634e94dcdbd3f6e694 100644 (file)
@@ -3,6 +3,9 @@
  * All Rights Reserved.  See COPYRIGHT.
  */
 
+#ifndef PAPD_FILE_H
+#define PAPD_FILE_H 1
+
 struct papfile {
     int                        pf_state;
     struct state       *pf_xstate;
@@ -25,3 +28,10 @@ struct papfile {
                            }
 
 #define PF_MORESPACE   1024
+
+int markline __P(( struct papfile *, char **, int *, int * ));
+void morespace __P(( struct papfile *, char *, int ));
+void append __P(( struct papfile *, const char *, int ));
+void spoolerror __P(( struct papfile *, char * ));
+
+#endif /* PAPD_FILE_H */
index 51ef0b1beb6b7af25d73df68b9a29727a738f2bc..c9a66bf6b01d76dc5fa3a6c8bb11ec785e018a5f 100644 (file)
 
 #include "file.h"
 #include "comment.h"
+#include "lp.h"
 
-ch_title( in, out )
+int ch_title( struct papfile *, struct papfile * );
+
+int ch_title( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *stop, *p, *q, c;
index b90a45a5ec2eb998e66c580c360238441243900a..5a08554113719cc3eb572c3d51175be6637a0c78 100644 (file)
@@ -48,6 +48,9 @@
 #include <sys/time.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
+#include <ctype.h>
+#include <unistd.h>
+
 #if defined( sun ) && defined( __svr4__ )
 #include </usr/ucbinclude/sys/file.h>
 #else sun __svr4__
 
 #include "printer.h"
 #include "file.h"
+#include "lp.h"
+
+/* These functions aren't used outside of lp.c */
+int lp_conn_inet();
+int lp_disconn_inet( int );
+int lp_conn_unix();
+int lp_disconn_unix( int );
 
 char   hostname[ MAXHOSTNAMELEN ];
 
 extern struct sockaddr_at *sat;
 
-/* initialize printing interface */
-int    lp_init();
-/* cancel current job */
-int    lp_cancel();
-/* print current job */
-int    lp_print();
-
-/* open a file for spooling */
-int    lp_open();
-/* open a buffer to the current open file */
-int    lp_write();
-/* close current spooling file */
-int    lp_close();
-
 struct lp {
     int                        lp_flags;
     FILE               *lp_stream;
@@ -107,7 +103,7 @@ struct lp {
 #define LP_CONNECT     (1<<3)
 #define LP_QUEUE       (1<<4)
 
-lp_person( person )
+void lp_person( person )
     char       *person;
 {
     if ( lp.lp_person != NULL ) {
@@ -121,7 +117,7 @@ lp_person( person )
 }
 
 #ifdef ABS_PRINT
-lp_pagecost()
+int lp_pagecost()
 {
     char       cost[ 22 ];
     char       balance[ 22 ];
@@ -138,7 +134,7 @@ lp_pagecost()
 }
 #endif ABS_PRINT
 
-lp_host( host )
+void lp_host( host )
     char       *host;
 {
     if ( lp.lp_host != NULL ) {
@@ -151,7 +147,7 @@ lp_host( host )
     strcpy( lp.lp_host, host );
 }
 
-lp_job( job )
+void lp_job( job )
     char       *job;
 {
     char       *p, *q;
@@ -173,7 +169,7 @@ lp_job( job )
     *q = '\0';
 }
 
-lp_init( out, sat )
+int lp_init( out, sat )
     struct papfile     *out;
     struct sockaddr_at *sat;
 {
@@ -315,7 +311,7 @@ lp_init( out, sat )
     return( 0 );
 }
 
-lp_open( out, sat )
+int lp_open( out, sat )
     struct papfile     *out;
     struct sockaddr_at *sat;
 {
@@ -387,18 +383,18 @@ lp_open( out, sat )
     return( 0 );
 }
 
-lp_close()
+int lp_close()
 {
     if (( lp.lp_flags & LP_INIT ) == 0 || ( lp.lp_flags & LP_OPEN ) == 0 ) {
-       return;
+       return 0;
     }
     fclose( lp.lp_stream );
     lp.lp_stream = NULL;
     lp.lp_flags &= ~LP_OPEN;
-    return;
+    return 0;
 }
 
-lp_write( buf, len )
+int lp_write( buf, len )
     char       *buf;
     int                len;
 {
@@ -413,13 +409,13 @@ lp_write( buf, len )
     return( 0 );
 }
 
-lp_cancel()
+int lp_cancel()
 {
     char       name[ MAXPATHLEN ];
     char       letter;
 
     if (( lp.lp_flags & LP_INIT ) == 0 || lp.lp_letter == 'A' ) {
-       return;
+       return 0;
     }
 
     if ( lp.lp_flags & LP_OPEN ) {
@@ -433,7 +429,7 @@ lp_cancel()
        }
     }
 
-    return;
+    return 0;
 }
 
 /*
@@ -442,7 +438,7 @@ lp_cancel()
  *
  * XXX piped?
  */
-lp_print()
+int lp_print()
 {
     char               buf[ MAXPATHLEN ];
     char               tfname[ MAXPATHLEN ];
@@ -452,7 +448,7 @@ lp_print()
     FILE               *cfile;
 
     if (( lp.lp_flags & LP_INIT ) == 0 || lp.lp_letter == 'A' ) {
-       return;
+       return 0;
     }
     lp_close();
 
@@ -460,11 +456,11 @@ lp_print()
        sprintf( tfname, "tfA%03d%s", lp.lp_seq, hostname );
        if (( fd = open( tfname, O_WRONLY|O_EXCL|O_CREAT, 0660 )) < 0 ) {
            syslog( LOG_ERR, "lp_print %s: %m", tfname );
-           return;
+           return 0;
        }
        if (( cfile = fdopen( fd, "w" )) == NULL ) {
            syslog( LOG_ERR, "lp_print %s: %m", tfname );
-           return;
+           return 0;
        }
        fprintf( cfile, "H%s\n", hostname );    /* XXX lp_host? */
 
@@ -506,43 +502,43 @@ lp_print()
        if ( link( tfname, cfname ) < 0 ) {
            syslog( LOG_ERR, "lp_print can't link %s to %s: %m", cfname,
                    tfname );
-           return;
+           return 0;
        }
        unlink( tfname );
 
        if (( s = lp_conn_unix()) < 0 ) {
            syslog( LOG_ERR, "lp_print: lp_conn_unix: %m" );
-           return;
+           return 0;
        }
 
        sprintf( buf, "\1%s\n", printer->p_printer );
        n = strlen( buf );
        if ( write( s, buf, n ) != n ) {
            syslog( LOG_ERR, "lp_print write: %m" );
-           return;
+           return 0;
        }
        if ( read( s, buf, 1 ) != 1 ) {
            syslog( LOG_ERR, "lp_print read: %m" );
-           return;
+           return 0;
        }
 
        lp_disconn_unix( s );
 
        if ( buf[ 0 ] != '\0' ) {
            syslog( LOG_ERR, "lp_print lpd said %c: %m", buf[ 0 ] );
-           return;
+           return 0;
        }
     }
     syslog( LOG_INFO, "lp_print queued" );
-    return;
+    return 0;
 }
 
-lp_disconn_unix( fd )
+int lp_disconn_unix( fd )
 {
     return( close( fd ));
 }
 
-lp_conn_unix()
+int lp_conn_unix()
 {
     int                        s;
     struct sockaddr_un saun;
@@ -564,12 +560,12 @@ lp_conn_unix()
     return( s );
 }
 
-lp_disconn_inet( fd )
+int lp_disconn_inet( int fd )
 {
     return( close( fd ));
 }
 
-lp_conn_inet()
+int lp_conn_inet()
 {
     int                        privfd, port = IPPORT_RESERVED - 1;
     struct sockaddr_in sin;
@@ -613,7 +609,7 @@ lp_conn_inet()
     return( privfd );
 }
 
-lp_rmjob( job )
+int lp_rmjob( job )
     int                job;
 {
     char       buf[ 1024 ];
@@ -653,7 +649,7 @@ char        *tag_files = "files: ";
 char   *tag_size = "size: ";
 char   *tag_status = "status: ";
 
-lp_queue( out )
+int lp_queue( out )
     struct papfile     *out;
 {
     char                       buf[ 1024 ], *start, *stop, *p, *q;
diff --git a/etc/papd/lp.h b/etc/papd/lp.h
new file mode 100644 (file)
index 0000000..4cc0514
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef PAPD_LP_H
+#define PAPD_LP_H 1
+
+#include <sys/socket.h>
+#include "file.h"
+
+void lp_person __P(( char * ));
+int lp_pagecost __P(( void ));
+void lp_host __P(( char * ));
+void lp_job __P(( char * ));
+int lp_rmjob __P(( int ));
+int lp_queue __P(( struct papfile * ));
+
+/* initialize printing interface */
+int lp_init __P(( struct papfile *, struct sockaddr_at * ));
+/* cancel current job */
+int lp_cancel __P(( void ));
+/* print current job */
+int lp_print __P(( void ));
+/* open a file for spooling */
+int lp_open __P(( struct papfile *, struct sockaddr_at * ));
+/* open a buffer to the current open file */
+int lp_write __P(( char *, int ));
+/* close current spooling file */
+int lp_close __P(( void ));
+
+#endif /* PAPD_LP_H */
index c3209d5741ad21b326e6f2bc343ee08ce3c79fbc..59fac7c291ba8b7994a142990e0d7bbeae0507ec 100644 (file)
 #include <sys/param.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include "file.h"
 #include "comment.h"
+#include "lp.h"
 
-ps( infile, outfile, sat )
+int ps( infile, outfile, sat )
     struct papfile     *infile, *outfile;
     struct sockaddr_at *sat;
 {
@@ -24,7 +26,7 @@ ps( infile, outfile, sat )
     struct papd_comment                *comment;
 
     for (;;) {
-       if ( comment = compeek()) {
+       if ( (comment = compeek()) ) {
            switch( (*comment->c_handler)( infile, outfile, sat )) {
            case CH_DONE :
                continue;
@@ -69,7 +71,7 @@ ps( infile, outfile, sat )
     }
 }
 
-cm_psquery( in, out, sat )
+int cm_psquery( in, out, sat )
     struct papfile     *in, *out;
     struct sockaddr_at *sat;
 {
@@ -102,13 +104,13 @@ cm_psquery( in, out, sat )
     }
 }
 
-cm_psadobe( in, out, sat )
+int cm_psadobe( in, out, sat )
     struct papfile     *in, *out;
     struct sockaddr_at *sat;
 {
     char               *start;
     int                        linelength, crlflength;
-    struct comment     *comment = compeek();
+    struct papd_comment        *comment = compeek();
 
     for (;;) {
        switch ( markline( in, &start, &linelength, &crlflength )) {
@@ -142,7 +144,7 @@ cm_psadobe( in, out, sat )
 
 char   *Query = "Query";
 
-cm_psswitch( in, out, sat )
+int cm_psswitch( in, out, sat )
     struct papfile     *in, *out;
     struct sockaddr_at *sat;
 {
index 751284370a077b7a7f895bb3b42afd72e9865ee3..9e84eb9dcab619daa6aacf003ac90adf42d2ae37 100644 (file)
 #include <atalk/pap.h>
 #include <atalk/paths.h>
 #include <atalk/util.h>
+#include <atalk/nbp.h>
 
 #include "printer.h"
+#include "printcap.h"
+#include "session.h"
+#include "uam_auth.h"
 
 #define _PATH_PAPDPPDFILE      ".ppd"
 
@@ -58,6 +62,12 @@ static char      *pidfile = _PATH_PAPDLOCK;
 char           *uamlist;
 char           *uampath = _PATH_PAPDUAMPATH;
 
+/* Prototypes for locally used functions */
+int getstatus( struct printer *pr, char *buf );
+int rprintcap( struct printer *pr );
+void getprinters( char *cf );
+
+
 /* this only needs to be used by the server process */
 static void papd_exit(const int i)
 {
@@ -73,10 +83,13 @@ die( n )
     int                        n;
 {
     struct printer     *pr;
+    struct at_addr     addr;
+
+    memset(&addr, 0, sizeof(addr));
 
     for ( pr = printers; pr; pr = pr->p_next ) {
        if ( pr->p_flags & P_REGISTERED ) {
-           if ( nbp_unrgstr( pr->p_name, pr->p_type, pr->p_zone ) < 0 ) {
+           if ( nbp_unrgstr( pr->p_name, pr->p_type, pr->p_zone, &addr ) < 0 ) {
                syslog( LOG_ERR, "can't unregister %s:%s@%s\n", pr->p_name,
                        pr->p_type, pr->p_zone );
                papd_exit( n + 1 );
@@ -118,7 +131,7 @@ reap()
 
 char           rbuf[ 255 + 1 + 8 ];
 
-main( ac, av )
+int main( ac, av )
     int                ac;
     char       **av;
 {
@@ -453,13 +466,14 @@ main( ac, av )
            }
        }
     }
+    return 0;
 }
 
 /*
  * We assume buf is big enough for 255 bytes of data and a length byte.
  */
-    int
-getstatus( pr, buf )
+
+int getstatus( pr, buf )
     struct printer     *pr;
     char               *buf;
 {
@@ -492,7 +506,7 @@ getstatus( pr, buf )
 char   *pgetstr();
 char   *getpname();
 
-getprinters( cf )
+void getprinters( cf )
     char       *cf;
 {
     char               buf[ 1024 ], area[ 1024 ], *a, *p, *name, *type, *zone;
@@ -602,7 +616,7 @@ getprinters( cf )
            pr->p_flags |= P_AUTH_CAP;
        } else { pr->p_authprintdir = NULL; }
 
-       if ( pgetflag( "sp", &a ) == 1 ) {
+       if ( pgetflag( "sp" ) == 1 ) {
            pr->p_flags |= P_AUTH;
            pr->p_flags |= P_AUTH_PSSP;
        }
@@ -647,7 +661,7 @@ getprinters( cf )
     }
 }
 
-rprintcap( pr )
+int rprintcap( pr )
     struct printer     *pr;
 {
     char               buf[ 1024 ], area[ 1024 ], *a, *p;
index bd5406afc643b20fba77f575b61a2006ef4785e2..9848211c7591d1daad733f5befb1b6ac076d6ca0 100644 (file)
@@ -46,19 +46,18 @@ struct ppdent {
 #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 ];
@@ -78,10 +77,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;
@@ -94,12 +93,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++;
            }
 
@@ -125,7 +124,7 @@ getppdent( stream )
        }
        *p++ = '\0';
 
-       while ( *p == ' ' || *p == '\t' ) {
+       while ( (*p == ' ') || (*p == '\t') ) {
            p++;
        }
 
@@ -143,7 +142,7 @@ getppdent( stream )
     return( NULL );
 }
 
-read_ppd( file, fcnt )
+int read_ppd( file, fcnt )
     char       *file;
     int                fcnt;
 {
@@ -203,7 +202,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" );
@@ -219,8 +218,7 @@ read_ppd( file, fcnt )
     return( 0 );
 }
 
-    struct ppd_font *
-ppd_font( font )
+struct ppd_font *ppd_font( font )
     char       *font;
 {
     struct ppd_font    *pfo;
@@ -239,14 +237,14 @@ 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 ) {
@@ -254,8 +252,8 @@ ppd_feature( feature, len )
     }
 #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 ) {
@@ -264,7 +262,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 );
        }
     }
index b519533cd09d7279e248a033adcdfe0bc24af968..0d29d35cb4e9fe4129bbc1afcdd5a3759157484f 100644 (file)
@@ -2,6 +2,8 @@
  * Copyright (c) 1995 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
+#ifndef PAPD_PPD_H
+#define PAPD_PPD_H 1
 
 struct ppd_font {
     char               *pd_font;
@@ -13,5 +15,9 @@ struct ppd_feature {
     char       *pd_value;
 };
 
-struct ppd_feature     *ppd_feature();
-struct ppd_font                *ppd_font();
+struct ppd_feature     *ppd_feature __P((const char *, int));
+struct ppd_font                *ppd_font __P((char *));
+int read_ppd __P((char *, int));
+int ppd_init __P(( void ));
+
+#endif /* PAPD_PPD_H */
index a2e0d19ebde91ff8875871b8e7b74c27dd5f0fff..e542cd120e4369ff50356761e33eb66684ea7b90 100644 (file)
@@ -47,8 +47,14 @@ static char sccsid[] = "@(#)printcap.c       5.7 (Berkeley) 3/4/91";
 #include <ctype.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include <atalk/paths.h>
 
+#include "printcap.h"
+
 #ifndef BUFSIZ
 #define        BUFSIZ  1024
 #endif
@@ -98,7 +104,7 @@ char *getenv();
  * Added a "cap" parameter, so we can use these calls for printcap
  * and papd.conf.
  */
-getprent( cap, bp)
+int getprent( cap, bp)
        register char *cap;
        register char *bp;
 {
@@ -140,7 +146,7 @@ getprent( cap, bp)
        }
 }
 
-endprent()
+void endprent()
 {
        if (pfp != NULL)
                fclose(pfp);
@@ -154,7 +160,7 @@ endprent()
  * Added a "cap" parameter, so we can use these calls for printcap
  * and papd.conf.
  */
-tgetent( cap, bp, name)
+int tgetent( cap, bp, name)
        char *cap, *bp, *name;
 {
        register char *cp;
@@ -226,7 +232,7 @@ tgetent( cap, bp, name)
                 */
                if (tnamatch(name)) {
                        close(tf);
-                       return(tnchktc());
+                       return(tnchktc(cap));
                }
        }
 }
@@ -241,7 +247,7 @@ tgetent( cap, bp, name)
  * Added a "cap" parameter, so we can use these calls for printcap
  * and papd.conf.
  */
-tnchktc( cap )
+int tnchktc( cap )
     char *cap;
 {
        register char *p, *q;
@@ -289,7 +295,7 @@ tnchktc( cap )
  * against each such name.  The normal : terminator after the last
  * name (before the first field) stops us.
  */
-tnamatch(np)
+int tnamatch(np)
        char *np;
 {
        register char *Np, *Bp;
@@ -335,7 +341,7 @@ tskip(bp)
  * a # character.  If the option is not found we return -1.
  * Note that we handle octal numbers beginning with 0.
  */
-tgetnum(id)
+int tgetnum(id)
        char *id;
 {
        register int i, base;
@@ -368,7 +374,7 @@ tgetnum(id)
  * of the buffer.  Return 1 if we find the option, or 0 if it is
  * not given.
  */
-tgetflag(id)
+int tgetflag(id)
        char *id;
 {
        register char *bp = tbuf;
diff --git a/etc/papd/printcap.h b/etc/papd/printcap.h
new file mode 100644 (file)
index 0000000..4fb957b
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef PAPD_PRINTCAP_H
+#define PAPD_PRINTCAP_H 1
+
+int getprent __P(( register char *, register char * ));
+int pnchktc __P(( char * ));
+int pgetflag __P(( char * ));
+void endprent __P(( void ));
+int pgetent __P(( char *, char *, char * ));
+int pgetnum __P(( char * ));
+int pnamatch __P(( char * ));
+
+#endif /* PAPD_PRINTCAP_H */
index 44e8019d77a5bd0148cc580c4da7529ff955ae1f..74a4fc97c0c07a46819620d4b85bef1b2932ef6e 100644 (file)
@@ -8,6 +8,8 @@
 #endif
 
 #include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <sys/syslog.h>
 #include <sys/param.h>
 #include <sys/time.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 +109,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;
@@ -138,7 +162,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;
@@ -176,7 +200,7 @@ cq_uameth( in, out )
 }
 #endif KRB
 
-gq_true( out )
+int gq_true( out )
     struct papfile     *out;
 {
     if ( printer->p_flags & P_SPOOLED ) {
@@ -187,7 +211,7 @@ gq_true( out )
     }
 }
 
-gq_pagecost( out )
+int gq_pagecost( out )
     struct papfile     *out;
 {
     char               cost[ 60 ];
@@ -210,7 +234,7 @@ gq_pagecost( out )
 }
 
 #ifdef ABS_PRINT
-gq_balance( out )
+int gq_balance( out )
     struct papfile     *out;
 {
     char               balance[ 60 ];
@@ -231,7 +255,7 @@ gq_balance( out )
 
 static const char *spoolerid = "(PAPD Spooler) 2.1 (2.1.4 pre-release)\n";
 
-gq_rbispoolerid( out )
+int gq_rbispoolerid( out )
     struct papfile     *out;
 {
     append( out, spoolerid, strlen( spoolerid ));
@@ -246,7 +270,7 @@ gq_rbispoolerid( out )
 
 static const char *nouams = "*\n";
 
-gq_rbiuamlist( out )
+int gq_rbiuamlist( out )
     struct papfile      *out;
 {
     char uamnames[128] = "\0";
@@ -281,7 +305,7 @@ struct genquery {
     { NULL },
 };
 
-cq_query( in, out )
+int cq_query( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *stop, *p, *q;
@@ -348,7 +372,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 +409,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 +466,7 @@ cq_font( in, out )
     }
 }
 
-cq_feature( in, out )
+int cq_feature( in, out )
     struct papfile     *in, *out;
 {
     char               *start, *stop, *p;
@@ -500,7 +524,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;
@@ -576,7 +600,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 +641,7 @@ cq_rmjob( in, out )
     return( CH_DONE );
 }
 
-cq_listq( in, out )
+int cq_listq( in, out )
     struct papfile     *in, *out;
 {
     char               *start;
@@ -653,7 +677,7 @@ SecurityViolation: Unknown user, incorrect password or log on is \
 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;
index b142a4c877a205c1acf68b8ccaca2d8e783a44e9..bb1b6178b02d07fd37a004ca640936b7c5d1eca6 100644 (file)
@@ -7,6 +7,7 @@
 #include "config.h"
 #endif
 
+#include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/syslog.h>
@@ -18,6 +19,8 @@
 #include <atalk/pap.h>
 
 #include "file.h"
+#include "lp.h"
+#include "session.h"
 
 extern unsigned char   connid, quantum, oquantum;
 
@@ -48,7 +51,7 @@ struct iovec  iov[ PAP_MAXQUANTUM ] = {
  * Read lines of a file, until the client sends eof, after
  * which we'll send eof also.
  */
-session( atp, sat )
+int session( atp, sat )
     ATP                        atp;
     struct sockaddr_at *sat;
 {
@@ -89,7 +92,7 @@ session( atp, sat )
     atpb.atp_sreqtries = -1;           /* infinite retries */
     if ( atp_sreq( atp, &atpb, oquantum, ATP_XO )) {
        syslog( LOG_ERR, "atp_sreq: %m" );
-       exit( 1 );
+       return( -1 );
     }
 
     for (;;) {
@@ -107,13 +110,13 @@ session( atp, sat )
 
        if (( cc = select( FD_SETSIZE, &fds, 0, 0, &tv )) < 0 ) {
            syslog( LOG_ERR, "select: %m" );
-           exit( 1 );
+           return( -1 );
        }
        if ( cc == 0 ) {
            if ( timeout++ > 2 ) {
                syslog( LOG_ERR, "connection timed out" );
                lp_cancel();
-               exit( 1 );
+               return( -1 );
            }
 
            /*
@@ -129,14 +132,14 @@ session( atp, sat )
            atpb.atp_sreqtries = 1;             /* try once */
            if ( atp_sreq( atp, &atpb, 0, 0 )) {
                syslog( LOG_ERR, "atp_sreq: %m" );
-               exit( 1 );
+               return( -1 );
            }
            continue;
        } else {
            timeout = 0;
        }
 
-       bzero( &ssat, sizeof( struct sockaddr_at ));
+       memset( &ssat, 0, sizeof( struct sockaddr_at ));
        switch( atp_rsel( atp, &ssat, ATP_TRESP | ATP_TREQ )) {
        case ATP_TREQ :
            atpb.atp_saddr = &ssat;
@@ -144,7 +147,7 @@ session( atp, sat )
            atpb.atp_rreqdlen = sizeof( cbuf );
            if ( atp_rreq( atp, &atpb ) < 0 ) {
                syslog( LOG_ERR, "atp_rreq: %m" );
-               exit( 1 );
+               return( -1 );
            }
            /* sanity */
            if ( (unsigned char)cbuf[ 0 ] != connid ) {
@@ -192,7 +195,7 @@ session( atp, sat )
                    syslog( LOG_ERR, "atp_sresp: %m" );
                    exit( 1 );
                }
-               exit( 0 );
+               return( 0 );
                break;
 
            case PAP_TICKLE :
@@ -212,7 +215,7 @@ session( atp, sat )
            atpb.atp_rresiovcnt = oquantum;
            if ( atp_rresp( atp, &atpb ) < 0 ) {
                syslog( LOG_ERR, "atp_rresp: %m" );
-               exit( 1 );
+               return( -1 );
            }
 
            /* sanity */
@@ -234,7 +237,7 @@ session( atp, sat )
            /* move data */
            if ( ps( &infile, &outfile, sat ) < 0 ) {
                syslog( LOG_ERR, "parse: bad return" );
-               exit( 1 );      /* really?  close? */
+               return( -1 );   /* really?  close? */
            }
 
            /*
@@ -244,7 +247,7 @@ session( atp, sat )
            cbuf[ 1 ] = PAP_READ;
            if ( ++seq == 0 ) seq = 1;
            netseq = htons( seq );
-           bcopy( &netseq, &cbuf[ 2 ], sizeof( netseq ));
+           memcpy( &cbuf[ 2 ], &netseq, sizeof( netseq ));
            atpb.atp_saddr = sat;
            atpb.atp_sreqdata = cbuf;
            atpb.atp_sreqdlen = 4;              /* bytes in SendData request */
@@ -252,7 +255,7 @@ session( atp, sat )
            atpb.atp_sreqtries = -1;            /* infinite retries */
            if ( atp_sreq( atp, &atpb, oquantum, ATP_XO )) {
                syslog( LOG_ERR, "atp_sreq: %m" );
-               exit( 1 );
+               return( -1 );
            }
            break;
 
@@ -261,7 +264,7 @@ session( atp, sat )
 
        default :
            syslog( LOG_ERR, "atp_rsel: %m" );
-           exit( 1 );
+           return( -1 );
        }
 
        /* send any data that we have */
@@ -285,7 +288,7 @@ session( atp, sat )
                }
 
                niov[ i ].iov_len = 4 + cc;
-               bcopy( outfile.pf_data, niov[ i ].iov_base + 4, cc );
+               memcpy( niov[ i ].iov_base + 4, outfile.pf_data, cc );
                CONSUME( &outfile, cc );
                if ( outfile.pf_datalen == 0 ) {
                    i++;
@@ -298,7 +301,7 @@ session( atp, sat )
            atpb.atp_sresiovcnt = i;    /* reported by stevebn@pc1.eos.co.uk */
            if ( atp_sresp( atp, &atpb ) < 0 ) {
                syslog( LOG_ERR, "atp_sresp: %m" );
-               exit( 1 );
+               return( -1 );
            }
            readpending = 0;
        }
diff --git a/etc/papd/session.h b/etc/papd/session.h
new file mode 100644 (file)
index 0000000..714a5c3
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef PAPD_SESSION_H
+#define PAPD_SESSION_H 1
+
+#include <atalk/atp.h>
+
+int session( ATP atp, struct sockaddr_at *sat );
+
+#endif /* PAPD_SESSION_H */
index 65b63a3f8405d4f18c6ae2d63337599a1dae3179..c332685e9be810454bf4ebd888417849786d7e12 100644 (file)
@@ -185,8 +185,7 @@ struct passwd *uam_getname(char *name, const int len)
 
   setpwent();
   while ((pwent = getpwent())) {
-    if (user = strchr(pwent->pw_gecos, ','))
-      *user = '\0';
+    if ((user = strchr(pwent->pw_gecos, ','))) *user = '\0';
     user = pwent->pw_gecos;
 
     /* check against both the gecos and the name fields. the user
index bf644fc5d63b6bc12433d38408364e95a9895de4..9e9b7692f637abb47cc861baacc7ffad68002a4b 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <atalk/uam.h>
 
+#include "file.h"
+
 struct uam_mod {
   void *uam_module;
   struct uam_export *uam_fcn;
@@ -63,5 +65,6 @@ int auth_register __P((const int, struct uam_obj *));
 #define auth_unregister(a) uam_detach(a)
 struct uam_obj *auth_uamfind __P((const int, const char *, const int));
 void auth_unload __P((void));
+int getuamnames __P((const int, char *));
 
 #endif /* uam_auth.h */