SCCS-vsn: usr.sbin/lpr/common_source/lp.local.h 1.5
SCCS-vsn: usr.sbin/lpr/lpr/lpr.c 4.7
*/
#define DEFLP "lp"
#define DEFLOCK "lock"
*/
#define DEFLP "lp"
#define DEFLOCK "lock"
+#define DEFSTAT "status"
#define DEFSPOOL "/usr/spool/lpd"
#define DEFDAEMON "/usr/lib/lpd"
#define DEFLOGF "/dev/console"
#define DEFSPOOL "/usr/spool/lpd"
#define DEFDAEMON "/usr/lib/lpd"
#define DEFLOGF "/dev/console"
#define DEFBINDIR "/usr/ucb"
#define DEFMX 1000
#define DEFFF "\f"
#define DEFBINDIR "/usr/ucb"
#define DEFMX 1000
#define DEFFF "\f"
/*
* Some utilities used by lpd
/*
* Some utilities used by lpd
char lpr_id[] = "~|^`lpr.c:\t4.2\t1 May 1981\n";
char lpr_id[] = "~|^`lpr.c:\t4.2\t1 May 1981\n";
-/* lpr.c 4.6 83/01/05 */
+/* lpr.c 4.7 83/01/07 */
/*
* lpr -- off line print
* also known as print
/*
* lpr -- off line print
* also known as print
if (argc == 1)
copy(0, " ");
else while (--argc) {
if (argc == 1)
copy(0, " ");
else while (--argc) {
- if (test(arg = *++argv))
+ if ((i = test(arg = *++argv)) < 0)
continue; /* file unreasonable */
continue; /* file unreasonable */
- if (lflag && linked(arg)) {
+ if (i && lflag && linked(arg)) {
if (prflag)
card('T', title ? title : arg);
for (i = 0;i < ncopies; i++)
if (prflag)
card('T', title ? title : arg);
for (i = 0;i < ncopies; i++)
card('N', arg);
dfname[inchar]++;
nact++;
card('N', arg);
dfname[inchar]++;
nact++;
if ((f = open(arg, 0)) < 0) {
printf("%s: cannot open %s\n", name, arg);
continue;
if ((f = open(arg, 0)) < 0) {
printf("%s: cannot open %s\n", name, arg);
continue;
/*
* Test to see if this is a printable file.
/*
* Test to see if this is a printable file.
- * Return -1 if it is not, else 0
+ * Return -1 if it is not, 1 if it's publically readable, else 0
*/
test(file)
char *file;
*/
test(file)
char *file;
+ if (statb.st_mode & 04)
+ return(1);
int n;
char buf[BUFSIZ], *mktemp();
int n;
char buf[BUFSIZ], *mktemp();
(void) sprintf(buf, "%s/.seq", SD);
(void) sprintf(buf, "%s/.seq", SD);
- if ((fd = open(buf, 2)) < 0) {
- n = umask(0);
- fd = creat(buf, FILMOD);
- (void) umask(n);
- if (fd < 0) {
- printf("%s: cannot create %s\n", name, buf);
- exit(1);
- }
- n = 1;
- }
- else {
- if (flock(fd, FEXLOCK)) {
+ if ((fp = fopen(buf, "r+")) == NULL) {
+ printf("%s: cannot create %s\n", name, buf);
+ exit(1);
+ } else {
+ setbuf(fp, buf);
+ if (flock(fileno(fp), FEXLOCK)) {
printf("%s: cannot lock %s\n", name, buf);
exit(1);
}
printf("%s: cannot lock %s\n", name, buf);
exit(1);
}
- if (read(fd, (char *)&n, sizeof(n)) != sizeof(n))
- n = 1;
+ n = 0;
+ while ((c = getc(fp)) >= '0' && c <= '9')
+ n = n * 10 + (c - '0');
}
len = strlen(SD) + strlen(host) + 8;
tfname = mktemp("tf", n, len);
}
len = strlen(SD) + strlen(host) + 8;
tfname = mktemp("tf", n, len);
dfname = mktemp("df", n, len);
inchar = strlen(SD) + 3;
n = (n + 1) % 1000;
dfname = mktemp("df", n, len);
inchar = strlen(SD) + 3;
n = (n + 1) % 1000;
- (void) lseek(fd, 0L, 0);
- (void) write(fd, &n, sizeof(n));
- (void) close(fd);
+ (void) fseek(fp, 0L, 0);
+ fprintf(fp, "%d\n", n);
+ (void) fclose(fp);