fixed `fc' and `fs' when 0177777 is needed.
[unix-history] / usr / src / usr.sbin / lpr / lpd / recvjob.c
index fcb1c01..1b957f7 100644 (file)
@@ -1,4 +1,4 @@
-/*     recvjob.c       4.2     83/05/16        */
+/*     recvjob.c       4.5     83/06/17        */
 /*
  * Receive printer jobs from the network, queue them and
  * start the printer daemon.
 /*
  * Receive printer jobs from the network, queue them and
  * start the printer daemon.
@@ -6,8 +6,8 @@
 
 #include "lp.h"
 
 
 #include "lp.h"
 
-char    tfname[40];            /* tmp copy of cf before linking */
-char    *dfname;               /* data files */
+static char    tfname[40];     /* tmp copy of cf before linking */
+static char    *dfname;                /* data files */
 
 recvjob()
 {
 
 recvjob()
 {
@@ -30,7 +30,7 @@ recvjob()
                LO = DEFLOCK;
 
        (void) close(2);
                LO = DEFLOCK;
 
        (void) close(2);
-       (void) open(LF, FWRONLY|FAPPEND, 0);
+       (void) open(LF, O_WRONLY|O_APPEND);
        if (chdir(SD) < 0)
                fatal("cannot chdir to %s", SD);
        if (stat(LO, &stb) == 0 && (stb.st_mode & 010)) {
        if (chdir(SD) < 0)
                fatal("cannot chdir to %s", SD);
        if (stat(LO, &stb) == 0 && (stb.st_mode & 010)) {
@@ -50,6 +50,7 @@ char  *sp = "";
  * Read printer jobs sent by lpd and copy them to the spooling directory.
  * Return the number of jobs successfully transfered.
  */
  * Read printer jobs sent by lpd and copy them to the spooling directory.
  * Return the number of jobs successfully transfered.
  */
+static
 readjob(printer)
        char *printer;
 {
 readjob(printer)
        char *printer;
 {
@@ -112,6 +113,7 @@ readjob(printer)
 /*
  * Read files send by lpd and copy them to the spooling directory.
  */
 /*
  * Read files send by lpd and copy them to the spooling directory.
  */
+static
 readfile(file, size)
        char *file;
        int size;
 readfile(file, size)
        char *file;
        int size;
@@ -121,7 +123,7 @@ readfile(file, size)
        register int i, j, amt;
        int fd, err;
 
        register int i, j, amt;
        int fd, err;
 
-       fd = open(file, FWRONLY|FCREATE, FILMOD);
+       fd = open(file, O_WRONLY|O_CREAT, FILMOD);
        if (fd < 0)
                fatal("cannot create %s", file);
        ack();
        if (fd < 0)
                fatal("cannot create %s", file);
        ack();
@@ -141,8 +143,10 @@ readfile(file, size)
                amt = BUFSIZ;
                if (i + amt > size)
                        amt = size - i;
                amt = BUFSIZ;
                if (i + amt > size)
                        amt = size - i;
-               if (err == 0 && write(fd, buf, amt) != amt)
+               if (write(fd, buf, amt) != amt) {
                        err++;
                        err++;
+                       break;
+               }
        }
        (void) close(fd);
        if (err)
        }
        (void) close(fd);
        if (err)