Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/printutils
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (11 years ago)
- Location:
- branches/3.2/mindi-busybox/printutils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/printutils/lpd.c
r2725 r3232 71 71 */ 72 72 73 //usage:#define lpd_trivial_usage 74 //usage: "SPOOLDIR [HELPER [ARGS]]" 75 //usage:#define lpd_full_usage "\n\n" 76 //usage: "SPOOLDIR must contain (symlinks to) device nodes or directories" 77 //usage: "\nwith names matching print queue names. In the first case, jobs are" 78 //usage: "\nsent directly to the device. Otherwise each job is stored in queue" 79 //usage: "\ndirectory and HELPER program is called. Name of file to print" 80 //usage: "\nis passed in $DATAFILE variable." 81 //usage: "\nExample:" 82 //usage: "\n tcpsvd -E 0 515 softlimit -m 999999 lpd /var/spool ./print" 83 73 84 #include "libbb.h" 74 85 … … 92 103 // SECURITY: 93 104 size_t max = 4 * 1024; // more than enough for commands! 94 return xmalloc_reads(STDIN_FILENO, NULL,&max);105 return xmalloc_reads(STDIN_FILENO, &max); 95 106 } 96 107 -
branches/3.2/mindi-busybox/printutils/lpr.c
r2725 r3232 12 12 * See RFC 1179 for protocol description. 13 13 */ 14 15 //usage:#define lpr_trivial_usage 16 //usage: "-P queue[@host[:port]] -U USERNAME -J TITLE -Vmh [FILE]..." 17 /* -C CLASS exists too, not shown. 18 * CLASS is supposed to be printed on banner page, if one is requested */ 19 //usage:#define lpr_full_usage "\n\n" 20 //usage: " -P lp service to connect to (else uses $PRINTER)" 21 //usage: "\n -m Send mail on completion" 22 //usage: "\n -h Print banner page too" 23 //usage: "\n -V Verbose" 24 //usage: 25 //usage:#define lpq_trivial_usage 26 //usage: "[-P queue[@host[:port]]] [-U USERNAME] [-d JOBID]... [-fs]" 27 //usage:#define lpq_full_usage "\n\n" 28 //usage: " -P lp service to connect to (else uses $PRINTER)" 29 //usage: "\n -d Delete jobs" 30 //usage: "\n -f Force any waiting job to be printed" 31 //usage: "\n -s Short display" 32 14 33 #include "libbb.h" 15 34 … … 71 90 int fd; 72 91 92 queue = getenv("PRINTER"); 93 if (!queue) 94 queue = "lp"; 95 73 96 // parse options 74 97 // TODO: set opt_complementary: s,d,f are mutually exclusive … … 80 103 argv += optind; 81 104 82 // if queue is not specified -> use $PRINTER 83 if (!(opts & OPT_P)) 84 queue = getenv("PRINTER"); 85 // if queue is still not specified -> 86 if (!queue) { 87 // ... queue defaults to "lp" 88 // server defaults to "localhost" 89 queue = "lp"; 90 // if queue is specified -> 91 } else { 105 { 92 106 // queue name is to the left of '@' 93 107 char *s = strchr(queue, '@'); … … 168 182 } 169 183 184 st.st_size = 0; /* paranoia: fstat may theoretically fail */ 185 fstat(dfd, &st); 186 187 /* Apparently, some servers are buggy and won't accept 0-sized jobs. 188 * Standard lpr works around it by refusing to send such jobs: 189 */ 190 if (st.st_size == 0) { 191 bb_error_msg("nothing to print"); 192 continue; 193 } 194 170 195 /* "The name ... should start with ASCII "cfA", 171 196 * followed by a three digit job number, followed … … 192 217 , remote_filename 193 218 ); 194 // delete possible "\nX\n" patterns219 // delete possible "\nX\n" (that is, one-char) patterns 195 220 c = controlfile; 196 cflen = (unsigned)strlen(controlfile);197 221 while ((c = strchr(c, '\n')) != NULL) { 198 222 if (c[1] && c[2] == '\n') { 199 /* can't use strcpy, results are undefined */ 200 memmove(c, c+2, cflen - (c-controlfile) - 1); 201 cflen -= 2; 223 overlapping_strcpy(c, c+2); 202 224 } else { 203 225 c++; … … 210 232 /* "Acknowledgement processing must occur as usual 211 233 * after the command is sent." */ 234 cflen = (unsigned)strlen(controlfile); 212 235 fdprintf(fd, "\x2" "%u c%s\n", cflen, remote_filename); 213 236 get_response_or_say_and_die(fd, "sending control file"); … … 223 246 if (opts & LPR_V) 224 247 bb_error_msg("sending data file"); 225 st.st_size = 0; /* paranoia: fstat may theoretically fail */226 fstat(dfd, &st);227 248 fdprintf(fd, "\x3" "%"OFF_FMT"u d%s\n", st.st_size, remote_filename); 228 249 get_response_or_say_and_die(fd, "sending data file");
Note:
See TracChangeset
for help on using the changeset viewer.