cmds.c (98268) | cmds.c (98278) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 29 unchanged lines hidden (view full) --- 38 The Regents of the University of California. All rights reserved.\n"; 39#endif /* not lint */ 40 41#ifndef lint 42/* 43static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/28/95"; 44*/ 45static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 29 unchanged lines hidden (view full) --- 38 The Regents of the University of California. All rights reserved.\n"; 39#endif /* not lint */ 40 41#ifndef lint 42/* 43static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/28/95"; 44*/ 45static const char rcsid[] = |
46 "$FreeBSD: head/usr.sbin/lpr/lpc/cmds.c 98268 2002-06-15 23:31:27Z gad $"; | 46 "$FreeBSD: head/usr.sbin/lpr/lpc/cmds.c 98278 2002-06-16 01:43:29Z gad $"; |
47#endif /* not lint */ 48 49/* 50 * lpc -- line printer control program -- commands: 51 */ 52 53#include <sys/param.h> 54#include <sys/time.h> --- 58 unchanged lines hidden (view full) --- 113generic(void (*specificrtn)(struct printer *_pp), int cmdopts, 114 void (*initrtn)(int _argc, char *_argv[]), int argc, char *argv[]) 115{ 116 int cmdstatus, more, targc; 117 struct printer myprinter, *pp; 118 char **margv, **targv; 119 120 if (argc == 1) { | 47#endif /* not lint */ 48 49/* 50 * lpc -- line printer control program -- commands: 51 */ 52 53#include <sys/param.h> 54#include <sys/time.h> --- 58 unchanged lines hidden (view full) --- 113generic(void (*specificrtn)(struct printer *_pp), int cmdopts, 114 void (*initrtn)(int _argc, char *_argv[]), int argc, char *argv[]) 115{ 116 int cmdstatus, more, targc; 117 struct printer myprinter, *pp; 118 char **margv, **targv; 119 120 if (argc == 1) { |
121 /* 122 * Usage needs a special case for 'down': The user must 123 * either include `-msg', or only the first parameter 124 * that they give will be processed as a printer name. 125 */ |
|
121 printf("usage: %s {all | printer ...}", argv[0]); | 126 printf("usage: %s {all | printer ...}", argv[0]); |
122 if (cmdopts & LPC_MSGOPT) | 127 if (strcmp(argv[0], "down") == 0) { 128 printf(" -msg [<text> ...]\n"); 129 printf(" or: down {all | printer} [<text> ...]"); 130 } else if (cmdopts & LPC_MSGOPT) |
123 printf(" [-msg <text> ...]"); 124 printf("\n"); 125 return; 126 } 127 128 /* The first argument is the command name. */ 129 generic_cmdname = *argv++; 130 argc--; --- 1012 unchanged lines hidden (view full) --- 1143 } 1144 cp1[-1] = '\n'; 1145 *cp1 = '\0'; 1146 (void) write(fd, buf, strlen(buf)); 1147 (void) close(fd); 1148} 1149 1150/* | 131 printf(" [-msg <text> ...]"); 132 printf("\n"); 133 return; 134 } 135 136 /* The first argument is the command name. */ 137 generic_cmdname = *argv++; 138 argc--; --- 1012 unchanged lines hidden (view full) --- 1151 } 1152 cp1[-1] = '\n'; 1153 *cp1 = '\0'; 1154 (void) write(fd, buf, strlen(buf)); 1155 (void) close(fd); 1156} 1157 1158/* |
1159 * Disable queuing and printing and put a message into the status file 1160 * (reason for being down). If the user specified `-msg', then use 1161 * everything after that as the message for the status file. If the 1162 * user did NOT specify `-msg', then the command should take the first 1163 * parameter as the printer name, and all remaining parameters as the 1164 * message for the status file. (This is to be compatible with the 1165 * original definition of 'down', which was implemented long before 1166 * `-msg' was around). 1167 */ 1168void 1169down_gi(int argc, char *argv[]) 1170{ 1171 1172 /* If `-msg' was specified, then this routine has nothing to do. */ 1173 if (generic_msg != NULL) 1174 return; 1175 1176 /* 1177 * If the user only gave one parameter, then use a default msg. 1178 * (if argc == 1 at this point, then *argv == name of printer). 1179 */ 1180 if (argc == 1) { 1181 generic_msg = strdup("printing disabled\n"); 1182 return; 1183 } 1184 1185 /* 1186 * The user specified multiple parameters, and did not specify 1187 * `-msg'. Build a message from all the parameters after the 1188 * first one (and nullify those parameters so generic-processing 1189 * will not process them as printer-queue names). 1190 */ 1191 argc--; 1192 argv++; 1193 generic_msg = args2line(argc, argv); 1194 for (; argc > 0; argc--, argv++) 1195 *argv = generic_nullarg; /* "erase" it */ 1196} 1197 1198void 1199down_q(struct printer *pp) 1200{ 1201 int setres; 1202 char lf[MAXPATHLEN]; 1203 1204 lock_file_name(pp, lf, sizeof lf); 1205 printf("%s:\n", pp->printer); 1206 1207 setres = set_qstate(SQS_DISABLEQ+SQS_STOPP, lf); 1208 if (setres >= 0) 1209 upstat(pp, generic_msg, 1); 1210} 1211 1212/* |
|
1151 * Exit lpc 1152 */ 1153void 1154quit(int argc __unused, char *argv[] __unused) 1155{ 1156 exit(0); 1157} 1158 --- 446 unchanged lines hidden --- | 1213 * Exit lpc 1214 */ 1215void 1216quit(int argc __unused, char *argv[] __unused) 1217{ 1218 exit(0); 1219} 1220 --- 446 unchanged lines hidden --- |