/*
- * $Id: lp.c,v 1.26 2009-02-04 22:35:45 didg Exp $
+ * $Id: lp.c,v 1.33 2009-10-29 13:38:15 didg Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
int lp_conn_unix();
int lp_disconn_unix( int );
-char hostname[ MAXHOSTNAMELEN ];
+static char hostname[ MAXHOSTNAMELEN ];
extern struct sockaddr_at *sat;
-struct lp {
+static struct lp {
int lp_flags;
FILE *lp_stream;
int lp_seq;
char temp[4];
long int ch;
- q=p=string;
+ q=p=(unsigned char *)string;
while ( *p != '\0' ) {
ch = 0;
if ( *p == '\\' ) {
if (*option != NULL) {
convert_octal(*option, from);
if (from) {
- if ((size_t) -1 != (convert_string_allocate(from, dest, *option, strlen(*option), &translated)) ) {
+ if ((size_t) -1 != (convert_string_allocate(from, dest, *option, -1, &translated)) ) {
free (*option);
*option = translated;
}
if (lp.lp_job) {
#ifdef DEBUG1
- LOG(log_debug, logtype_papd, "job: %s", lp.lp_job );
+ LOG(log_debug9, logtype_papd, "job: %s", lp.lp_job );
#endif
translate(from, dest, &lp.lp_job);
}
if (lp.lp_created_for) {
#ifdef DEBUG1
- LOG(log_debug, logtype_papd, "for: %s", lp.lp_created_for );
+ LOG(log_debug9, logtype_papd, "for: %s", lp.lp_created_for );
#endif
translate(from, dest, &lp.lp_created_for);
}
if (lp.lp_person) {
#ifdef DEBUG1
- LOG(log_debug, logtype_papd, "person: %s", lp.lp_person );
+ LOG(log_debug9, logtype_papd, "person: %s", lp.lp_person );
#endif
translate(from, dest, &lp.lp_person);
}
#define is_var(a, b) (strncmp((a), (b), 2) == 0)
+#if 0
+/* removed, it's not used and a pain to get it right from a security POV */
static size_t quote(char *dest, char *src, const size_t bsize, size_t len)
{
size_t used = 0;
return used;
}
-
static char* pipexlate(char *src)
{
char *p, *q, *dest;
}
return destbuf;
}
+#endif
-
-void lp_person( person )
- char *person;
+void lp_person(char *person)
{
if ( lp.lp_person != NULL ) {
free( lp.lp_person );
}
#ifdef ABS_PRINT
-int lp_pagecost()
+int lp_pagecost(void)
{
char cost[ 22 ];
char balance[ 22 ];
}
#endif /* ABS_PRINT */
-void lp_host( host )
- char *host;
+void lp_host( char *host)
{
if ( lp.lp_host != NULL ) {
free( lp.lp_host );
* This should be added.
*/
-void lp_job( job )
- char *job;
+void lp_job(char *job)
{
if ( lp.lp_job != NULL ) {
free( lp.lp_job );
lp.lp_job = strdup(job);
#ifdef DEBUG
- LOG(log_debug, logtype_papd, "job: %s", lp.lp_job );
+ LOG(log_debug9, logtype_papd, "job: %s", lp.lp_job );
#endif
}
-void lp_for ( lpfor )
- char *lpfor;
+void lp_for (char *lpfor)
{
if ( lp.lp_created_for != NULL ) {
free( lp.lp_created_for );
}
-static int lp_init( out, sat )
- struct papfile *out;
- struct sockaddr_at *sat;
+static int lp_init(struct papfile *out, struct sockaddr_at *sat)
{
int authenticated = 0;
#ifndef HAVE_CUPS
return( 0 );
}
-int lp_open( out, sat )
- struct papfile *out;
- struct sockaddr_at *sat;
+int lp_open(struct papfile *out, struct sockaddr_at *sat)
{
char name[ MAXPATHLEN ];
int fd;
struct passwd *pwent;
#ifdef DEBUG
- LOG (log_debug, logtype_papd, "lp_open");
+ LOG (log_debug9, logtype_papd, "lp_open");
#endif
if ( lp.lp_flags & LP_JOBPENDING ) {
}
lp_setup_comments(CH_UNIX);
- pipe_cmd = pipexlate(printer->p_printer);
+ pipe_cmd = printer->p_printer;
if (!pipe_cmd) {
- LOG(log_error, logtype_papd, "lp_open: can't generate pipe cmd" );
+ LOG(log_error, logtype_papd, "lp_open: no pipe cmd" );
spoolerror( out, NULL );
return( -1 );
}
return( -1 );
}
#ifdef DEBUG
- LOG(log_debug, logtype_papd, "lp_open: opened %s", name );
+ LOG(log_debug9, logtype_papd, "lp_open: opened %s", name );
#endif
}
lp.lp_flags |= LP_OPEN;
return( 0 );
}
-int lp_close()
+int lp_close(void)
{
if (( lp.lp_flags & LP_INIT ) == 0 || ( lp.lp_flags & LP_OPEN ) == 0 ) {
return 0;
-int lp_write(in, buf, len )
- struct papfile *in;
- char *buf;
- size_t len;
+int lp_write(struct papfile *in, char *buf, size_t len)
{
#define BUFSIZE 32768
static char tempbuf[BUFSIZE];
tbuf = tempbuf2;
last_line_translated = 1;
#ifdef DEBUG
- LOG(log_debug, logtype_papd, "lp_write: %s", tbuf );
+ LOG(log_debug9, logtype_papd, "lp_write: %s", tbuf );
#endif
}
else {
* %%EndComment triggers writing to file */
if (( lp.lp_flags & LP_OPEN ) == 0 ) {
#ifdef DEBUG
- LOG(log_debug, logtype_papd, "lp_write: writing to temporary buffer" );
+ LOG(log_debug9, logtype_papd, "lp_write: writing to temporary buffer" );
#endif
if ((bufpos+len) > BUFSIZE) {
LOG(log_error, logtype_papd, "lp_write: temporary buffer too small" );
return( 0 );
}
-int lp_cancel()
+int lp_cancel(void)
{
char name[ MAXPATHLEN ];
char letter;
*
* XXX piped?
*/
-int lp_print()
+int lp_print(void)
{
#ifndef HAVE_CUPS
char buf[ MAXPATHLEN ];
return( close( fd ));
}
-int lp_conn_unix()
+int lp_conn_unix(void)
{
int s;
struct sockaddr_un saun;
return( close( fd ));
}
-int lp_conn_inet()
+int lp_conn_inet(void)
{
int privfd, port = IPPORT_RESERVED - 1;
struct sockaddr_in sin;
return( privfd );
}
-int lp_rmjob( job )
- int job;
+int lp_rmjob( int job)
{
char buf[ 1024 ];
int n, s;
char *tag_size = "size: ";
char *tag_status = "status: ";
-int lp_queue( out )
- struct papfile *out;
+int lp_queue( struct papfile *out)
{
char buf[ 1024 ], *start, *stop, *p, *q;
int linelength, crlflength;