/*
- * $Id: pap.c,v 1.9 2002-11-25 01:33:02 jmarcus Exp $
+ * $Id: pap.c,v 1.14 2009-10-16 01:10:59 didg Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#include <sys/uio.h>
#include <netatalk/endian.h>
#include <netatalk/at.h>
+#include <errno.h>
#include <atalk/atp.h>
#include <atalk/pap.h>
#include <atalk/nbp.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
-#include <errno.h>
#define FUCKED
#define _PATH_PAPRC ".paprc"
-char *nbpfailure = "AppleTalk printer offline";
/* Forward Declarations */
-void updatestatus(char *s, int len);
-int send_file(int fd, ATP atp, int lastfile);
+static void updatestatus(char *s, int len);
+static int send_file(int fd, ATP atp, int lastfile);
-void usage( path )
- char *path;
+static void usage(char *path)
{
char *p;
exit( 2 );
}
-char *
-paprc()
+static char *
+paprc(void)
{
static char s[ 32 + 1 + 32 + 1 + 32 ];
char *name = NULL;
return( name );
}
-char *printer = NULL;
-char *status = NULL;
-int noeof = 0;
-int waitforprinter = 0;
+static char *printer = NULL;
+static char *status = NULL;
+static int noeof = 0;
+static int waitforprinter = 0;
-unsigned char connid, quantum, oquantum = PAP_MAXQUANTUM;
-struct sockaddr_at sat;
+static unsigned char connid, quantum, oquantum = PAP_MAXQUANTUM;
+static struct sockaddr_at sat;
-char cbuf[ 8 ];
-struct nbpnve nn;
-ATP satp;
+static char cbuf[ 8 ];
+static struct nbpnve nn;
+static ATP satp;
-char fbuf[ PAP_MAXQUANTUM ][ 4 + PAP_MAXDATA ];
-struct iovec rfiov[ PAP_MAXQUANTUM ] = {
+static char fbuf[ PAP_MAXQUANTUM ][ 4 + PAP_MAXDATA ];
+static struct iovec rfiov[ PAP_MAXQUANTUM ] = {
{ fbuf[ 0 ] + 4, 0 },
{ fbuf[ 1 ] + 4, 0 },
{ fbuf[ 2 ] + 4, 0 },
{ fbuf[ 6 ] + 4, 0 },
{ fbuf[ 7 ] + 4, 0 },
};
-struct iovec sniov[ PAP_MAXQUANTUM ] = {
+
+static struct iovec sniov[ PAP_MAXQUANTUM ] = {
{ fbuf[ 0 ], 0 },
{ fbuf[ 1 ], 0 },
{ fbuf[ 2 ], 0 },
{ fbuf[ 7 ], 0 },
};
-char nbuf[ PAP_MAXQUANTUM ][ 4 + PAP_MAXDATA ];
-struct iovec rniov[ PAP_MAXQUANTUM ] = {
+static char nbuf[ PAP_MAXQUANTUM ][ 4 + PAP_MAXDATA ];
+static struct iovec rniov[ PAP_MAXQUANTUM ] = {
{ nbuf[ 0 ], 0 },
{ nbuf[ 1 ], 0 },
{ nbuf[ 2 ], 0 },
{ nbuf[ 6 ], 0 },
{ nbuf[ 7 ], 0 },
};
-struct iovec sfiov[ PAP_MAXQUANTUM ] = {
+
+static struct iovec sfiov[ PAP_MAXQUANTUM ] = {
{ nbuf[ 0 ] + 4, 0 },
{ nbuf[ 1 ] + 4, 0 },
{ nbuf[ 2 ] + 4, 0 },
{ nbuf[ 7 ] + 4, 0 },
};
-int debug;
+static int debug;
-int main( ac, av )
- int ac;
- char **av;
+int main( int ac, char **av)
{
ATP atp;
struct atp_block atpb;
cbuf[ 2 ] = cbuf[ 3 ] = 0;
cbuf[ 4 ] = atp_sockaddr( atp )->sat_port;
cbuf[ 5 ] = oquantum; /* flow quantum */
- if ( gettimeofday( &stv, 0 ) < 0 ) {
+ if ( gettimeofday( &stv, NULL ) < 0 ) {
perror( "gettimeofday" );
exit( 2 );
}
if ( cuts ) {
waiting = 0xffff;
} else {
- if ( gettimeofday( &tv, 0 ) < 0 ) {
+ if ( gettimeofday( &tv, NULL ) < 0 ) {
perror( "gettimeofday" );
exit( 2 );
}
exit( 0 );
}
-int data = 0;
-unsigned char port;
-u_int16_t seq = 0, rseq = 1;
+static int data = 0;
+static unsigned char port;
+static u_int16_t seq = 0;
-int send_file( fd, atp, lastfile )
- int fd;
- ATP atp;
- int lastfile;
+static int send_file( int fd, ATP atp, int lastfile)
{
struct timeval stv, tv;
struct sockaddr_at ssat;
int cc, i;
unsigned short netseq;
- if ( gettimeofday( &stv, 0 ) < 0 ) {
+ if ( gettimeofday( &stv, NULL ) < 0 ) {
perror( "gettimeofday" );
exit( 2 );
}
if(debug){ printf( "READ %d >\n", seq ), fflush( stdout );}
for (;;) {
- if ( gettimeofday( &tv, 0 ) < 0 ) {
+ if ( gettimeofday( &tv, NULL ) < 0 ) {
perror( "gettimeofday" );
exit( 2 );
}
}
FD_SET( atp_fileno( atp ), &fds );
- if (( cc = select( FD_SETSIZE, &fds, 0, 0, &tv )) < 0 ) {
+ if (( cc = select( FD_SETSIZE, &fds, NULL, NULL, &tv )) < 0 ) {
perror( "select" );
exit( 2 );
}
}
}
-void updatestatus( s, len )
- char *s;
- int len;
+static void updatestatus(char *s, int len)
{
int fd = -1;
struct iovec iov[ 3 ];