date and time created 83/04/29 11:30:46 by ralph
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 30 Apr 1983 02:30:46 +0000 (18:30 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 30 Apr 1983 02:30:46 +0000 (18:30 -0800)
SCCS-vsn: usr.sbin/lpr/common_source/startdaemon.c 4.1

usr/src/usr.sbin/lpr/common_source/startdaemon.c [new file with mode: 0644]

diff --git a/usr/src/usr.sbin/lpr/common_source/startdaemon.c b/usr/src/usr.sbin/lpr/common_source/startdaemon.c
new file mode 100644 (file)
index 0000000..df76220
--- /dev/null
@@ -0,0 +1,28 @@
+/*     startdaemon.c   4.1     83/04/29        */
+/*
+ * Tell the printer daemon that there are new files in the spool directory.
+ */
+
+#include "lp.h"
+
+startdaemon()
+{
+       register int rem, i, err = 0;
+       char buf[BUFSIZ];
+
+       rem = getport();
+       if (rem < 0)
+               return(0);
+       (void) sprintf(buf, "\1%s\n", printer);
+       i = strlen(buf);
+       if (write(rem, buf, i) != i) {
+               (void) close(rem);
+               return(0);
+       }
+       while ((i = read(rem, buf, sizeof(buf))) > 0) {
+               (void) fwrite(buf, 1, i, stdout);
+               err++;
+       }
+       (void) close(rem);
+       return(i == 0 && err == 0);
+}