Lines Matching +full:idle +full:- +full:touch
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
33 #include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
35 * lpc -- line printer control program -- commands:
62 #define KQT_LFERROR -2
63 #define KQT_KILLFAIL -1
72 static int touch(struct jobqueue *_jq);
82 QSEL_UNKNOWN = -1, /* ... not selected yet */
91 static char *generic_msg; /* if a -msg was specified */
93 static void (*generic_wrapup)(int _last_status); /* perform rtn wrap-up */
106 * either include `-msg', or only the first parameter in generic()
111 printf(" -msg [<text> ...]\n"); in generic()
114 printf(" [-msg <text> ...]"); in generic()
121 argc--; in generic()
141 * Some commands accept a -msg argument, which indicates that in generic()
148 for (; targc > 0; targc--, targv++) { in generic()
149 if (strcmp(*targv, "-msg") == 0) { in generic()
150 argc -= targc; in generic()
151 generic_msg = args2line(targc - 1, targv + 1); in generic()
157 " '-msg'.\n"); in generic()
160 printf(" [-msg <text> ...]\n"); in generic()
174 * correct the arg-count. in generic()
180 for (; targc > 0; targc--, targv++) { in generic()
204 pp->printer); in generic()
215 generic_qselect = QSEL_BYNAME; /* specifically-named ptrs */ in generic()
216 for (; argc > 0; argc--, argv++) { in generic()
245 * Convert an argv-array of character strings into a single string.
258 cend = buf + sizeof(buf) - 1; /* save room for '\0' */ in args2line()
259 while (--argc >= 0) { in args2line()
263 cp1[-1] = ' '; in args2line()
265 cp1[-1] = '\n'; in args2line()
304 * XXX - not sure I understand the reasoning behind this... in kill_qtask()
399 printf("%s:\n", pp->printer); in abort_q()
409 * lpd-process which is listed in that lock file. If the lock in abort_q()
413 * process id of that lpd-process). in abort_q()
448 static int cln_testonly; /* remove-files vs just-print-info */
453 int c = d->d_name[0]; in doselect()
456 d->d_name[1] == 'f') in doselect()
459 if (!strcmp(d->d_name, "core")) in doselect()
463 if (!strncmp(d->d_name, "errs.", 5)) in doselect()
475 * `tf', and then by the sequence letter (which is A-Z, or a-z). This
488 const int a_lt_b = -1, a_gt_b = 1, cat_other = 10; in sortq()
492 fname_a = (*a)->d_name; in sortq()
493 fname_b = (*b)->d_name; in sortq()
497 * legitimate `cf', `df', `rf' & `tf' filenames, and "other" - in in sortq()
503 * file-sequence letter, and start the job number in position 5.] in sortq()
554 * or `tf' files. Compare them by job-number and machine name. in sortq()
621 for (; argc > 0; argc--, argv++) { in clean_gi()
622 if (**argv != '-') in clean_gi()
624 if (strcmp(*argv, "-d") == 0) { in clean_gi()
657 printf("%s:\n", pp->printer); in clean_q()
662 cp = pp->spool_dir; in clean_q()
663 while (lp < &line[sizeof(line) - 1]) { in clean_q()
667 lp[-1] = '/'; in clean_q()
668 linerem = sizeof(line) - (lp - line); in clean_q()
672 nitems = scandir(pp->spool_dir, &queue, doselect, sortq); in clean_q()
676 printf("%s:\n", pp->printer); in clean_q()
684 printf("%s:\n", pp->printer); in clean_q()
687 printf("\t** found a core file in %s !\n", pp->spool_dir); in clean_q()
692 printf("%s:\n", pp->printer); in clean_q()
694 printf("\t** ----- Sorted list of files being checked:\n"); in clean_q()
697 cp = queue[i]->d_name; in clean_q()
700 printf("\t** ----- end of sorted list\n"); in clean_q()
704 cp = queue[i]->d_name; in clean_q()
708 * A control file. Look for matching data-files. in clean_q()
712 * part of cf-filenames match the hostname part in clean_q()
713 * in df-filenames, and that is not necessarily in clean_q()
714 * true (eg: for multi-homed hosts). This needs in clean_q()
719 cp1 = queue[i + 1]->d_name; in clean_q()
744 printf("\t** spooldir = %s\n", pp->spool_dir); in clean_q()
779 * "file" which is really a symlink due to 'lpr -s' processing. In in unlinkf()
780 * that case, we need to check the last-mod time of the symlink, and in unlinkf()
795 /* this debugging-aid probably is not needed any more... */ in unlinkf()
804 * symlink before unlink-ing the file itself in unlinkf()
816 res--; in unlinkf()
839 * lpr command included '-r' ("remove file"). Of course, this in unlinkf()
842 * impossible to determine if '-r' had been specified... in unlinkf()
847 * samba, if they were configured to use 'lpr -r', and if in unlinkf()
866 printf("%s:\n", pp->printer); in enable_q()
881 printf("%s:\n", pp->printer); in disable_q()
888 * (reason for being down). If the user specified `-msg', then use
890 * user did NOT specify `-msg', then the command should take the first
894 * `-msg' was around).
900 /* If `-msg' was specified, then this routine has nothing to do. */ in down_gi()
915 * `-msg'. Build a message from all the parameters after the in down_gi()
916 * first one (and nullify those parameters so generic-processing in down_gi()
917 * will not process them as printer-queue names). in down_gi()
919 argc--; in down_gi()
922 for (; argc > 0; argc--, argv++) in down_gi()
933 printf("%s:\n", pp->printer); in down_q()
959 printf("%s:\n", pp->printer); in restart_q()
964 * XXX - if the kill worked, we should probably sleep for in restart_q()
981 * Set the status message of each queue listed. Requires a "-msg"
989 printf("You must specify '-msg' before the text of the new status message.\n"); in setstatus_gi()
1002 printf("%s:\n", pp->printer); in setstatus_q()
1007 * Warn the user if 'lpq' will not display this new status-message. in setstatus_q()
1018 printf("\t so this -msg will only be shown by 'lpq' if\n"); in setstatus_q()
1033 printf("%s:\n", pp->printer); in start_q()
1059 printf("%s:\n", pp->printer); in status()
1072 if ((dirp = opendir(pp->spool_dir)) == NULL) { in status()
1078 if (*dp->d_name == 'c' && dp->d_name[1] == 'f') in status()
1091 printf("\tprinter idle\n"); in status()
1120 printf("%s:\n", pp->printer); in stop_q()
1148 --argc; in topq()
1164 printf("%s:\n", pp->printer); in topq()
1167 if (chdir(pp->spool_dir) < 0) { in topq()
1168 printf("\tcannot chdir to %s\n", pp->spool_dir); in topq()
1176 mtime = queue[0]->job_time; in topq()
1177 for (i = argc; --i; ) { in topq()
1196 if (changed && stat(pp->lock_file, &stbuf) >= 0) in topq()
1197 (void) chmod(pp->lock_file, stbuf.st_mode | LFM_RESET_QUE); in topq()
1208 touch(struct jobqueue *jq) in touch() function
1213 tvp[0].tv_sec = tvp[1].tv_sec = --mtime; in touch()
1216 ret = utimes(jq->job_cfname, tvp); in touch()
1223 * Returns: negative (-1) if argument name is not in the queue.
1251 jobnum = jobnum * 10 + (*job++ - '0'); in doarg()
1253 for (qq = queue + nitems; --qq >= queue; ) { in doarg()
1255 for (cp = (*qq)->job_cfname+3; isdigit(*cp); ) in doarg()
1256 n = n * 10 + (*cp++ - '0'); in doarg()
1263 if (touch(*qq) == 0) { in doarg()
1264 printf("\tmoved %s\n", (*qq)->job_cfname); in doarg()
1273 for (qq = queue + nitems; --qq >= queue; ) { in doarg()
1275 fp = fopen((*qq)->job_cfname, "r"); in doarg()
1285 if (touch(*qq) == 0) { in doarg()
1286 printf("\tmoved %s\n", (*qq)->job_cfname); in doarg()
1303 printf("%s:\n", pp->printer); in up_q()