/*
- * $Id: psf.c,v 1.4 2001-06-25 20:13:45 rufustfirefly Exp $
+ * $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.
#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[]);
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 */
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++;
}
if (( c = pexecv( pappath, papargv )) < 0 ) {
- syslog( LOG_ERR, "%s: %m", pappath );
+ syslog( LOG_ERR, "%s: %s", pappath, strerror(errno) );
exit( 2 );
}
children++;
*/
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 );
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 );
}
if (( c = pexecv( pappath, papargv )) < 0 ) {
- syslog( LOG_ERR, "%s: %m", pappath );
+ syslog( LOG_ERR, "%s: %s", pappath, strerror(errno) );
exit( 2 );
}
children++;
}
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 )) {
break;
}
if ( write( 1, "\031", 1 ) != 1 ) {
- syslog( LOG_ERR, "write: %m" );
+ syslog( LOG_ERR, "write: %s", strerror(errno) );
return( 1 );
}
ctl = 0;
} else {
if ( ctl == 1 ) {
if ( write( 1, "\031", 1 ) != 1 ) {
- syslog( LOG_ERR, "write: %m" );
+ syslog( LOG_ERR, "write: %s", strerror(errno) );
return( 1 );
}
}
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 ) {
}
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 ) {
/* 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 ) {
}
} 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;