improved error messages
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 28 May 1983 02:36:07 +0000 (18:36 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 28 May 1983 02:36:07 +0000 (18:36 -0800)
SCCS-vsn: usr.sbin/lpr/common_source/common.c 4.4
SCCS-vsn: usr.sbin/lpr/common_source/startdaemon.c 4.4

usr/src/usr.sbin/lpr/common_source/common.c
usr/src/usr.sbin/lpr/common_source/startdaemon.c

index 939c108..52f8baa 100644 (file)
@@ -1,4 +1,4 @@
-/*     common.c        4.3     83/05/18        */
+/*     common.c        4.4     83/05/27        */
 /*
  * Routines and data common to all the line printer functions.
  */
 /*
  * Routines and data common to all the line printer functions.
  */
@@ -239,17 +239,3 @@ fatal(msg, a1, a2, a3)
        putchar('\n');
        exit(1);
 }
        putchar('\n');
        exit(1);
 }
-
-fatalerror(msg)
-       char *msg;
-{
-       extern int sys_nerr;
-       extern char *sys_errlist[];
-
-       printf("%s: ", name);
-       if (*msg)
-               printf("%s: ", msg);
-       fputs(errno < sys_nerr ? sys_errlist[errno] : "Unknown error" , stdout);
-       putchar('\n');
-       exit(1);
-}
index 8cb9a28..77e93fa 100644 (file)
@@ -1,4 +1,4 @@
-/*     startdaemon.c   4.3     83/05/18        */
+/*     startdaemon.c   4.4     83/05/27        */
 /*
  * Tell the printer daemon that there are new files in the spool directory.
  */
 /*
  * Tell the printer daemon that there are new files in the spool directory.
  */
@@ -11,11 +11,14 @@ startdaemon()
        char buf[BUFSIZ];
 
        rem = getport(host);
        char buf[BUFSIZ];
 
        rem = getport(host);
-       if (rem < 0)
+       if (rem < 0) {
+               perr();
                return(0);
                return(0);
+       }
        (void) sprintf(buf, "\1%s\n", printer);
        i = strlen(buf);
        if (write(rem, buf, i) != i) {
        (void) sprintf(buf, "\1%s\n", printer);
        i = strlen(buf);
        if (write(rem, buf, i) != i) {
+               perr();
                (void) close(rem);
                return(0);
        }
                (void) close(rem);
                return(0);
        }
@@ -23,6 +26,19 @@ startdaemon()
                (void) fwrite(buf, 1, i, stdout);
                err++;
        }
                (void) fwrite(buf, 1, i, stdout);
                err++;
        }
+       if (i < 0)
+               perr();
        (void) close(rem);
        return(i == 0 && err == 0);
 }
        (void) close(rem);
        return(i == 0 && err == 0);
 }
+
+static
+perr()
+{
+       extern int sys_nerr;
+       extern char *sys_errlist[];
+
+       printf("%s: ", name);
+       fputs(errno < sys_nerr ? sys_errlist[errno] : "Unknown error" , stdout);
+       putchar('\n');
+}