Changes.
This commit is contained in:
parent
262ecfed9f
commit
b87296ceaa
1 changed files with 26 additions and 33 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
|
#define NOPLAN9DEFINES
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
@ -13,27 +14,9 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
|
||||||
#undef ctime
|
#define LP unsharp("#9/bin/lp")
|
||||||
#undef wait
|
|
||||||
|
|
||||||
/* for Plan 9 */
|
|
||||||
#ifdef PLAN9
|
|
||||||
#define LP "/bin/lp"
|
|
||||||
#define TMPDIR "/var/tmp"
|
#define TMPDIR "/var/tmp"
|
||||||
#define LPDAEMONLOG unsharp("#9/lp/log/lpdaemonl")
|
#define LPDAEMONLOG unsharp("#9/lp/log/lpdaemonl")
|
||||||
#endif
|
|
||||||
/* for Tenth Edition systems */
|
|
||||||
#ifdef V10
|
|
||||||
#define LP "/usr/bin/lp"
|
|
||||||
#define TMPDIR "/tmp"
|
|
||||||
#define LPDAEMONLOG "/tmp/lpdaemonl"
|
|
||||||
#endif
|
|
||||||
/* for System V or BSD systems */
|
|
||||||
#if defined(SYSV) || defined(BSD)
|
|
||||||
#define LP "/v/bin/lp"
|
|
||||||
#define TMPDIR "/tmp"
|
|
||||||
#define LPDAEMONLOG "/tmp/lpdaemonl"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ARGSIZ 4096
|
#define ARGSIZ 4096
|
||||||
#define NAMELEN 30
|
#define NAMELEN 30
|
||||||
|
|
@ -116,7 +99,7 @@ forklp(int inputfd)
|
||||||
}
|
}
|
||||||
*--cp = '\n';
|
*--cp = '\n';
|
||||||
*++cp = '\0';
|
*++cp = '\0';
|
||||||
error(logent);
|
error((char *)logent);
|
||||||
switch((cpid=fork())){
|
switch((cpid=fork())){
|
||||||
case -1:
|
case -1:
|
||||||
error("fork error\n");
|
error("fork error\n");
|
||||||
|
|
@ -126,18 +109,24 @@ forklp(int inputfd)
|
||||||
dup2(inputfd, 0);
|
dup2(inputfd, 0);
|
||||||
dup2(1, 2);
|
dup2(1, 2);
|
||||||
lseek(0, 0L, 0);
|
lseek(0, 0L, 0);
|
||||||
execvp(LP, (char**)argvals);
|
execvp(LP, (char **)argvals);
|
||||||
error("exec failed\n");
|
error("exec failed\n");
|
||||||
exit(3);
|
exit(3);
|
||||||
default:
|
default:
|
||||||
while(wait((int *)0) != cpid);
|
while((i=wait((int *)0)) != cpid){
|
||||||
|
if(i == -1 && errno == ECHILD)
|
||||||
|
break;
|
||||||
|
printf("%d %d\n", i, errno);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
error("wait got %d\n", cpid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
tempfile(void)
|
tempfile(void)
|
||||||
{
|
{
|
||||||
int tindx = 0;
|
static int tindx = 0;
|
||||||
char tmpf[sizeof(TMPDIR)+64];
|
char tmpf[sizeof(TMPDIR)+64];
|
||||||
int crtfd, tmpfd;
|
int crtfd, tmpfd;
|
||||||
|
|
||||||
|
|
@ -153,7 +142,7 @@ tempfile(void)
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
close(crtfd);
|
close(crtfd);
|
||||||
unlink(tmpf); /* comment out for debugging */
|
/* unlink(tmpf); /* comment out for debugging */
|
||||||
return(tmpfd);
|
return(tmpfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,7 +239,7 @@ getfiles(void)
|
||||||
case '\1': /* cleanup - data sent was bad (whatever that means) */
|
case '\1': /* cleanup - data sent was bad (whatever that means) */
|
||||||
break;
|
break;
|
||||||
case '\2': /* read control file */
|
case '\2': /* read control file */
|
||||||
bsize = atoi(ap);
|
bsize = atoi((const char *)ap);
|
||||||
cntrlfd = tempfile();
|
cntrlfd = tempfile();
|
||||||
if (readfile(cntrlfd, bsize) < 0) {
|
if (readfile(cntrlfd, bsize) < 0) {
|
||||||
close(cntrlfd);
|
close(cntrlfd);
|
||||||
|
|
@ -259,7 +248,7 @@ getfiles(void)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\3': /* read data file */
|
case '\3': /* read data file */
|
||||||
bsize = atoi(ap);
|
bsize = atoi((const char *)ap);
|
||||||
datafd[filecnt] = tempfile();
|
datafd[filecnt] = tempfile();
|
||||||
if (readfile(datafd[filecnt], bsize) < 0) {
|
if (readfile(datafd[filecnt], bsize) < 0) {
|
||||||
close(datafd[filecnt]);
|
close(datafd[filecnt]);
|
||||||
|
|
@ -326,17 +315,21 @@ alarmhandler(int sig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char **argv)
|
nop(int sig)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
unsigned char *ap, *bp, *cp, *savbufpnt;
|
unsigned char *ap, *bp, *cp, *savbufpnt;
|
||||||
int i, blen, rv, saveflg, savargcnt;
|
int i, blen, rv, saveflg, savargcnt;
|
||||||
struct jobinfo *jinfop;
|
struct jobinfo *jinfop;
|
||||||
|
|
||||||
USED(argc);
|
signal(SIGHUP, SIG_IGN); /* SIGHUP not in lcc */
|
||||||
USED(argv);
|
signal(SIGALRM, alarmhandler); /* SIGALRM not in lcc */
|
||||||
|
signal(SIGCHLD, nop); /* so that wait will get us something */
|
||||||
signal(SIGHUP, SIG_IGN);
|
|
||||||
signal(SIGALRM, alarmhandler);
|
|
||||||
cp = argvstr;
|
cp = argvstr;
|
||||||
/* setup argv[0] for exec */
|
/* setup argv[0] for exec */
|
||||||
argvals[argcnt++] = cp;
|
argvals[argcnt++] = cp;
|
||||||
|
|
@ -447,7 +440,7 @@ main(int argc, char **argv)
|
||||||
} while (*bp!='\n' && *bp!='\0');
|
} while (*bp!='\n' && *bp!='\0');
|
||||||
if (readline(0) < 0) exit(7);
|
if (readline(0) < 0) exit(7);
|
||||||
datafd[0] = tempfile();
|
datafd[0] = tempfile();
|
||||||
if(readfile(datafd[0], atoi((char *)lnbuf)) < 0) {
|
if(readfile(datafd[0], atoi((const char *)lnbuf)) < 0) {
|
||||||
error("readfile failed\n");
|
error("readfile failed\n");
|
||||||
exit(8);
|
exit(8);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue