/*
- * $Id: psf.c,v 1.7 2002-01-03 17:49:39 sibaz Exp $
+ * $Id: psf.c,v 1.11 2009-10-14 01:38:28 didg Exp $
*
* Copyright (c) 1990,1995 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
int copyio();
int textps();
-char psapath[] = _PATH_PSA;
-char *psaargv[] = { "psa", 0, 0, 0, 0 };
+static char psapath[] = _PATH_PSA;
+static char *psaargv[] = { "psa", 0, 0, 0, 0 };
/*
* If we're not doing accounting, we just call pap as below.
* arg 4. The second time, we call it with "-c" in arg 2, pagecount.ps
* in arg 3, and 0 in arg 4.
*/
-char pappath[] = _PATH_PAP;
-char *papargv[] = { "pap", "-sstatus", 0, 0, 0, 0, 0, 0 };
+static char pappath[] = _PATH_PAP;
+static char *papargv[] = { "pap", "-sstatus", 0, 0, 0, 0, 0, 0 };
-char revpath[] = _PATH_PSORDER;
-char *revargv[] = { "psorder", "-d", 0 };
+static char revpath[] = _PATH_PSORDER;
+static char *revargv[] = { "psorder", "-d", 0 };
-char *filtargv[] = { 0, 0, 0 };
+static char *filtargv[] = { 0, 0, 0 };
-char inbuf[ 1024 * 8 ];
-int inlen;
+static char inbuf[ 1024 * 8 ];
+static int inlen;
-FILE *acctfile = NULL;
-int literal;
-int width = 80, length = 66, indent = 0;
-char *prog, *name, *host;
+static FILE *acctfile = NULL;
+static int literal;
+static int width = 80, length = 66, indent = 0;
+static char *prog, *name, *host;
-struct papersize {
+static struct papersize {
int width;
int length;
float win;
{ 80, 70, 8.27, 11.69 }, /* A4 */
};
-int main( ac, av )
- int ac;
- char **av;
+int main( int ac, char **av)
{
int c, rc, children = 0;
#ifdef FUCKED
- int psafileno, multiconn = 0, waitidle = 0, waitidle2 = 0;
+ int psafileno = 0, multiconn = 0, waitidle = 0, waitidle2 = 0;
#endif /* FUCKED */
int status;
extern char *optarg;
exit( rc );
}
-int copyio()
+int copyio(void)
{
/* implement the FSM needed to do the suspend. Note that
* the last characters will be \031\001 so don't worry
return( 0 );
}
-char *font = "Courier";
-int point = 11;
+static char *font = "Courier";
+static int point = 11;
-char pspro[] = "\
+static char pspro[] = "\
/GSV save def % global VM\n\
/SP {\n\
/SV save def % save vmstate\n\
/EP { SV restore showpage } bind def\n\
%%EndProlog\n";
-int textps()
+int textps(void)
{
struct papersize papersize;
- int state = 0, line = 0, col = 0, npages = 0, rc, i;
+ int state = 0, line = 0, col = 0, npages = 0, rc;
+ unsigned int i;
char *p, *end;
#define elements(x) (sizeof(x)/sizeof((x)[0]))
state |= ST_PAGE;
}
if ( state & ST_CONTROL && *p != '\001' ) {
+ /* It is a very bad thing to toss a job because it contains
+ * unprintable characters. Instead, we will convert them to
+ * question marks. This is adapted from a solution described
+ * by Werner Eugster <eugster@giub.unibe.ch> on his ApplePrint
+ * webpage (http://www.giub.unibe.ch/~eugster/appleprint.html).
+ *
+ * Note that this is rather ugly code. The same change is
+ * applied identically at two different locations in this file.
+ * It would be better someday to combine the two.
+ */
if ( !literal ) {
- fprintf( stderr, "unprintable character (0x%x)!\n",
- (unsigned char)031 );
- return( 2 ); /* Toss job */
+ fprintf( stderr,
+ "unprintable character (0x%x) converted to ?!\n",
+ (unsigned char)*p );
+ putchar( '?' ); /* Replace unprintable char with a question mark. */
+ } else {
+ printf( "\\%o", (unsigned char)031 );
}
- printf( "\\%o", (unsigned char)031 );
state &= ~ST_CONTROL;
col++;
}
}
if ( !isascii( *p ) || !isprint( *p )) {
if ( !literal ) {
- fprintf( stderr, "unprintable character (0x%x)!\n",
- (unsigned char)*p );
- return( 2 ); /* Toss job */
+ fprintf( stderr,
+ "unprintable character (0x%x) converted to ?!\n",
+ (unsigned char)*p );
+ putchar( '?' ); /* Replace unprintable char with a question mark. */
+ } else {
+ printf( "\\%o", (unsigned char)*p );
}
- printf( "\\%o", (unsigned char)*p );
} else {
putchar( *p );
}
* Manipulates file descriptors 0, 1, and 2, such that the new child
* is reading from the parent's output.
*/
-int pexecv( path, argv )
- char *path, *argv[];
+int pexecv( char *path, char *argv[])
{
int fd[ 2 ], c;