]> arthur.barton.de Git - netatalk.git/blobdiff - etc/psf/psf.c
replaced all #include <sys/syslog.h> with #include <syslog.h>
[netatalk.git] / etc / psf / psf.c
index c0ce07bf764f24ad8bf2e5bfa031981315ef8909..d70c2e79e78d08f766bded82c74df8b7d902c976 100644 (file)
@@ -1,9 +1,9 @@
 /*
+ * $Id: psf.c,v 1.7 2002-01-03 17:49:39 sibaz Exp $
+ *
  * Copyright (c) 1990,1995 Regents of The University of Michigan.
  * All Rights Reserved. See COPYRIGHT.
- */
-
-/*
+ *
  * PostScript Filter, psf.
  *
  * Handles both PostScript files and text files.  Files with the
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
 
 #define FUCKED
 
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif /* HAVE_UNISTD_H */
 #include <sys/time.h>
+
+/* POSIX.1 sys/wait.h check */
 #include <sys/types.h>
+#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif /* HAVE_SYS_WAIT_H */
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif /* ! WEXITSTATUS */
+#ifndef WIFEXITED
+#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif /* ! WIFEXITED */
+
 #include <sys/file.h>
-#include <sys/syslog.h>
+#include <syslog.h>
 #include <atalk/paths.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <signal.h>
+#include <errno.h>
 
 /* Forward Declarations */
 int pexecv(char *path, char *argv[]);
@@ -84,7 +98,7 @@ int main( ac, av )
     int                        c, rc, children = 0;
 #ifdef FUCKED
     int                        psafileno, multiconn = 0, waitidle = 0, waitidle2 = 0;
-#endif FUCKED
+#endif /* FUCKED */
     int                        status;
     extern char                *optarg;
     extern int         optind, opterr;
@@ -97,9 +111,9 @@ int main( ac, av )
     }
 #ifdef ultrix
     openlog( prog, LOG_PID );
-#else ultrix
+#else /* ultrix */
     openlog( prog, LOG_PID, LOG_LPR );
-#endif ultrix
+#endif /* ultrix */
 
     while (( c = getopt( ac, av, "P:C:D:F:L:J:x:y:n:h:w:l:i:c" )) != EOF ) {
        switch ( c ) {
@@ -120,7 +134,7 @@ int main( ac, av )
            if ( width == 0 ) {
                width = 80;
            }
-#endif ZEROWIDTH
+#endif /* ZEROWIDTH */
            break;
 
        case 'l' :
@@ -147,7 +161,7 @@ int main( ac, av )
        default :
            syslog( LOG_ERR, "bad option: %c", c );
            exit( 2 );
-#endif notdef
+#endif /* notdef */
        }
     }
     if ( ac - optind > 1 ) {
@@ -164,13 +178,13 @@ int main( ac, av )
     if ( index( prog, 'm' )) {
        multiconn++;
     }
-#endif FUCKED
+#endif /* FUCKED */
 
     syslog( LOG_INFO, "starting for %s", name ? name : "?" );
 
 restart:
     if (( inlen = read( 0, inbuf, sizeof( inbuf ))) < 0 ) {
-       syslog( LOG_ERR, "read: %m" );
+       syslog( LOG_ERR, "read: %s", strerror(errno) );
        exit( 1 );
     }
     if ( inlen == 0 ) {        /* nothing to be done */
@@ -188,7 +202,7 @@ restart:
        psaargv[ 2 ] = name;
        psaargv[ 3 ] = host;
        if (( c = pexecv( psapath, psaargv )) < 0 ) {
-           syslog( LOG_ERR, "%s: %m", psapath );
+           syslog( LOG_ERR, "%s: %s", psapath, strerror(errno) );
            exit( 2 );
        }
        children++;
@@ -237,7 +251,7 @@ restart:
                papargv[ 5 ] = _PATH_PAGECOUNT;
                papargv[ 6 ] = 0;
            }
-#endif FUCKED
+#endif /* FUCKED */
        } else {
            papargv[ 2 ] = "-c";
            papargv[ 3 ] = "-E";
@@ -245,7 +259,7 @@ restart:
        }
 
        if (( c = pexecv( pappath, papargv )) < 0 ) {
-           syslog( LOG_ERR, "%s: %m", pappath );
+           syslog( LOG_ERR, "%s: %s", pappath, strerror(errno) );
            exit( 2 );
        }
        children++;
@@ -258,7 +272,7 @@ restart:
      */
     if ( strstr( prog, "rev" ) != NULL ) {
        if (( c = pexecv( revpath, revargv )) < 0 ) {
-           syslog( LOG_ERR, "%s: %m", revpath );
+           syslog( LOG_ERR, "%s: %s", revpath, strerror(errno) );
            exit( 2 );
        }
        syslog( LOG_INFO, "sending to rev[%d]", c );
@@ -272,7 +286,7 @@ restart:
     if ( *prog != 'i' && *prog != 'o' && *( prog + 1 ) == 'f' ) {
        filtargv[ 0 ] = filtargv[ 1 ] = prog;
        if (( c = pexecv( _PATH_PSFILTER, filtargv )) < 0 ) {
-           syslog( LOG_ERR, "%s: %m", _PATH_PSFILTER );
+           syslog( LOG_ERR, "%s: %s", _PATH_PSFILTER, strerror(errno) );
            exit( 2 );
        }
        syslog( LOG_INFO, "external filter[%d]", c );
@@ -310,26 +324,26 @@ restart:
        }
 
        if (( c = pexecv( pappath, papargv )) < 0 ) {
-           syslog( LOG_ERR, "%s: %m", pappath );
+           syslog( LOG_ERR, "%s: %s", pappath, strerror(errno) );
            exit( 2 );
        }
        children++;
        syslog( LOG_INFO, "pagecount with pap[%d]", c );
     }
-#endif FUCKED
+#endif /* FUCKED */
 
     if ( children ) {
        close( 1 );
     }
     while ( children ) {
        if (( c = wait3( &status, 0, 0 )) < 0 ) {
-           syslog( LOG_ERR, "wait3: %m" );
+           syslog( LOG_ERR, "wait3: %s", strerror(errno) );
            exit( 1 );
        }
        if ( WIFEXITED( status )) {
 #ifndef WEXITSTATUS
 #define WEXITSTATUS(x) ((x).w_status)
-#endif WEXITSTATUS
+#endif /* WEXITSTATUS */
            if ( WEXITSTATUS( status ) != 0 ) {
                syslog( LOG_ERR, "%d died with %d", c, WEXITSTATUS( status ));
                exit( WEXITSTATUS( status ));
@@ -382,7 +396,7 @@ notdone:
                    break;
                }
                if ( write( 1, "\031", 1 ) != 1 ) {
-                   syslog( LOG_ERR, "write: %m" );
+                   syslog( LOG_ERR, "write: %s", strerror(errno) );
                    return( 1 );
                }
                ctl = 0;
@@ -395,7 +409,7 @@ notdone:
        } else {
            if ( ctl == 1 ) {
                if ( write( 1, "\031", 1 ) != 1 ) {
-                   syslog( LOG_ERR, "write: %m" );
+                   syslog( LOG_ERR, "write: %s", strerror(errno) );
                    return( 1 );
                }
            }
@@ -410,7 +424,7 @@ notdone:
 
        inlen -= ctl;
        if (( inlen > 0 ) && ( write( 1, inbuf, inlen ) != inlen )) {
-           syslog( LOG_ERR, "write: %m" );
+           syslog( LOG_ERR, "write: %s", strerror(errno) );
            return( 1 );
        }
        if ( ctl == 2 ) {
@@ -431,13 +445,13 @@ notdone:
     }
 
     if ( inlen < 0 ) {
-       syslog( LOG_ERR, "read: %m" );
+       syslog( LOG_ERR, "read: %s", strerror(errno) );
        return( 1 );
     }
 
     if ( ctl == 1 ) {
        if ( write( 1, "\031", 1 ) != 1 ) {
-           syslog( LOG_ERR, "write: %m" );
+           syslog( LOG_ERR, "write: %s", strerror(errno) );
            return( 1 );
        }
     } else if ( ctl == 2 ) {
@@ -507,7 +521,7 @@ int textps()
                    /* output postscript prologue: */
                    if ( write( 1, pspro, sizeof( pspro ) - 1 ) !=
                            sizeof( pspro ) - 1 ) {
-                       syslog( LOG_ERR, "write prologue: %m" );
+                       syslog( LOG_ERR, "write prologue: %s", strerror(errno) );
                        return( 1 );
                    }
                    if ( name && host ) {
@@ -632,7 +646,7 @@ int textps()
        }
     } while (( inlen = read( 0, inbuf, sizeof( inbuf ))) > 0 );
     if ( inlen < 0 ) {
-       syslog( LOG_ERR, "read: %m" );
+       syslog( LOG_ERR, "read: %s", strerror(errno) );
        return( 1 );
     }
     rc = 0;