lpsched-jobs.c (45916cd2fec6e79bca5dee0421bd39e3c2910d1e) lpsched-jobs.c (355b4669e025ff377602b6fc7caaf30dbc218371)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 30 unchanged lines hidden (view full) ---

39#include "printers.h"
40
41#include <papi_impl.h>
42
43papi_status_t
44job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r,
45 papi_attribute_t **attributes)
46{
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 30 unchanged lines hidden (view full) ---

39#include "printers.h"
40
41#include <papi_impl.h>
42
43papi_status_t
44job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r,
45 papi_attribute_t **attributes)
46{
47 papi_status_t status = PAPI_OK;
47 papi_attribute_t *attr;
48 papi_attribute_t *attr;
49 papi_attribute_t **unmapped = NULL;
48 int i;
49 char *s;
50
51 char **options = NULL;
52 char **modes = NULL;
50 int i;
51 char *s;
52
53 char **options = NULL;
54 char **modes = NULL;
53 char *class = NULL;
54 char *job_name = NULL;
55
56 char pr_filter = 0;
57 char *pr_title = NULL;
58 int pr_width = -1;
59 int pr_indent = -1;
60 int numberUp = 0;
61 int orientation = 0;
55
56 char pr_filter = 0;
57 char *pr_title = NULL;
58 int pr_width = -1;
59 int pr_indent = -1;
60 int numberUp = 0;
61 int orientation = 0;
62 int lowerPage = 0;
63 int upperPage = 0;
64 papi_status_t getResult = 0;
62 int lower = 0;
63 int upper = 0;
65 char buf[256];
66 void *iterator = NULL;
64 char buf[256];
65 void *iterator = NULL;
66 char *mapped_keys[] = { "copies", "document-format", "form",
67 "job-class", "job-hold-until", "job-host", "job-name",
68 "job-originating-user-name", "job-printer",
69 "job-sheets", "lp-charset", "lp-modes", "number-up",
70 "orienttation-requested", "page-ranges", "pr-filter",
71 "pr-indent", "pr-title", "pr-width", "priority",
72 "requesting-user-name", NULL };
67
73
68 char banner = 0;
69
70 if (attributes == NULL)
71 return (PAPI_BAD_ARGUMENT);
72
74 if (attributes == NULL)
75 return (PAPI_BAD_ARGUMENT);
76
73 papiAttributeListGetString(attributes, NULL, "job-printer",
74 &r->destination);
77 /* replace the current destination */
78 papiAttributeListGetLPString(attributes,
79 "job-printer", &r->destination);
75
80
81 /* set the copies. We need at least 1 */
76 i = r->copies;
77 papiAttributeListGetInteger(attributes, NULL, "copies", &i);
78 if (i <= 0)
79 i = 1;
80 r->copies = i;
81
82 i = r->copies;
83 papiAttributeListGetInteger(attributes, NULL, "copies", &i);
84 if (i <= 0)
85 i = 1;
86 r->copies = i;
87
88 /*
89 * set the priority. PAPI/IPP uses 1-100, lpsched use 0-39, so we
90 * have to convert it.
91 */
82 if (papiAttributeListGetInteger(attributes, NULL, "priority", &i)
83 == PAPI_OK) {
84 if ((i < 1) || (i > 100))
85 i = 50;
86 i = (i + 1) / 2.5;
87 r->priority = i;
88 }
92 if (papiAttributeListGetInteger(attributes, NULL, "priority", &i)
93 == PAPI_OK) {
94 if ((i < 1) || (i > 100))
95 i = 50;
96 i = (i + 1) / 2.5;
97 r->priority = i;
98 }
89
90 if ((r->priority < 0) || (r->priority > 39))
91 r->priority = 20;
92
99 if ((r->priority < 0) || (r->priority > 39))
100 r->priority = 20;
101
93 /*
94 * 'media' size should be processed both in the lpsched filter and
95 * the foomatic filter (if present) so that we ensure the result of
96 * other options like 'page-ranges' are consistent.
97 */
98/*
99 * TODO - I thing we should really have this but I can't get it to filter
100 * so its commented out for now (paulcun)
101 * papiAttributeListGetString(attributes, NULL, "media", &r->form);
102 */
102 /* set the requested form to print on */
103 papiAttributeListGetLPString(attributes, "form", &r->form);
103
104
105 /* set the page range */
104#ifndef LP_USE_PAPI_ATTR
106#ifndef LP_USE_PAPI_ATTR
105 papiAttributeListGetString(attributes, NULL, "page-ranges", &r->pages);
107 papiAttributeListGetLPString(attributes, "page-ranges", &r->pages);
106#else
108#else
107 getResult =
108 papiAttributeListGetRange(attributes, &iterator,
109 "page-ranges", &lowerPage, &upperPage);
110 while (getResult == PAPI_OK) {
111 if (r->pages == NULL) {
112 snprintf(buf, sizeof (buf),
113 "%d-%d", lowerPage, upperPage);
114 r->pages = (char *)strdup(buf);
115 }
116 else
117 {
109 for (status = papiAttributeListGetRange(attributes, &iterator,
110 "page-ranges", &lower, &upper);
111 status == PAPI_OK;
112 status = papiAttributeListGetRange(attributes, &iterator,
113 "page-ranges", &lower, &upper)) {
114 if (r->pages != NULL) {
118 snprintf(buf, sizeof (buf), "%s,%d-%d",
115 snprintf(buf, sizeof (buf), "%s,%d-%d",
119 r->pages, lowerPage, upperPage);
116 r->pages, lower, upper);
120 free(r->pages);
117 free(r->pages);
121 r->pages = (char *)strdup(buf);
122 }
123 /*
124 * get the next value; note the attribute 'name' is set to
125 * NULL to do this.
126 */
127 getResult =
128 papiAttributeListGetRange(attributes, &iterator,
129 "page-ranges", &lowerPage, &upperPage);
118 } else
119 snprintf(buf, sizeof (buf), "%d-%d", lower, upper);
120 r->pages = (char *)strdup(buf);
130 }
131#endif
132
121 }
122#endif
123
133
124 /*
125 * set the document format, converting to old format names as
126 * as needed.
127 */
134 s = NULL;
135 papiAttributeListGetString(attributes, NULL, "document-format", &s);
136 if (s != NULL)
137 r->input_type = strdup(mime_type_to_lp_type(s));
138
128 s = NULL;
129 papiAttributeListGetString(attributes, NULL, "document-format", &s);
130 if (s != NULL)
131 r->input_type = strdup(mime_type_to_lp_type(s));
132
133
139 /*
140 * If we don't have an owner, set one.
141 */
142 if (r->user == NULL) {
143 uid_t uid = getuid();
144 struct passwd *pw;
145 char *user = "intruder";
146 char *host = NULL;

--- 13 unchanged lines hidden (view full) ---

160 snprintf(buf, sizeof (buf), "%s%s%s", user,
161 (host ? "@" : ""), (host ? host : ""));
162 user = buf;
163 }
164
165 r->user = strdup(user);
166 }
167
134 /*
135 * If we don't have an owner, set one.
136 */
137 if (r->user == NULL) {
138 uid_t uid = getuid();
139 struct passwd *pw;
140 char *user = "intruder";
141 char *host = NULL;

--- 13 unchanged lines hidden (view full) ---

155 snprintf(buf, sizeof (buf), "%s%s%s", user,
156 (host ? "@" : ""), (host ? host : ""));
157 user = buf;
158 }
159
160 r->user = strdup(user);
161 }
162
163 /* set any held state */
168 s = NULL;
169 papiAttributeListGetString(attributes, NULL, "job-hold-until", &s);
170 if (s != NULL) {
171 if (strcmp(s, "immediate") == 0)
172 r->actions |= ACT_IMMEDIATE;
173 else if ((strcmp(s, "resume") == 0) ||
174 (strcmp(s, "no-hold") == 0))
175 r->actions |= ACT_RESUME;
176 else if ((strcmp(s, "hold") == 0) ||
177 (strcmp(s, "indefinite") == 0))
178 r->actions |= ACT_HOLD;
179 }
180
164 s = NULL;
165 papiAttributeListGetString(attributes, NULL, "job-hold-until", &s);
166 if (s != NULL) {
167 if (strcmp(s, "immediate") == 0)
168 r->actions |= ACT_IMMEDIATE;
169 else if ((strcmp(s, "resume") == 0) ||
170 (strcmp(s, "no-hold") == 0))
171 r->actions |= ACT_RESUME;
172 else if ((strcmp(s, "hold") == 0) ||
173 (strcmp(s, "indefinite") == 0))
174 r->actions |= ACT_HOLD;
175 }
176
181 papiAttributeListGetString(attributes, NULL, "lp-charset", &r->charset);
177 /* set lp charset/printwheel */
178 papiAttributeListGetLPString(attributes, "lp-charset", &r->charset);
182
183 /* legacy pr(1) filter related garbage "lpr -p" */
184 papiAttributeListGetBoolean(attributes, NULL, "pr-filter", &pr_filter);
185 papiAttributeListGetString(attributes, NULL, "pr-title", &pr_title);
186 papiAttributeListGetInteger(attributes, NULL, "pr-width", &pr_width);
187 papiAttributeListGetInteger(attributes, NULL, "pr-indent", &pr_indent);
188
189 if (pr_filter != 0) {

--- 13 unchanged lines hidden (view full) ---

203 snprintf(buf, sizeof (buf), "indent=%d", pr_indent);
204 appendlist(&modes, buf);
205 }
206 } else if ((pr_title != NULL) || (pr_width >= 0) || (pr_indent >= 0))
207 detailed_error(svc, gettext(
208 "pr(1) filter options specified without enabling pr(1) filter"));
209
210 /* add burst page information */
179
180 /* legacy pr(1) filter related garbage "lpr -p" */
181 papiAttributeListGetBoolean(attributes, NULL, "pr-filter", &pr_filter);
182 papiAttributeListGetString(attributes, NULL, "pr-title", &pr_title);
183 papiAttributeListGetInteger(attributes, NULL, "pr-width", &pr_width);
184 papiAttributeListGetInteger(attributes, NULL, "pr-indent", &pr_indent);
185
186 if (pr_filter != 0) {

--- 13 unchanged lines hidden (view full) ---

200 snprintf(buf, sizeof (buf), "indent=%d", pr_indent);
201 appendlist(&modes, buf);
202 }
203 } else if ((pr_title != NULL) || (pr_width >= 0) || (pr_indent >= 0))
204 detailed_error(svc, gettext(
205 "pr(1) filter options specified without enabling pr(1) filter"));
206
207 /* add burst page information */
211 papiAttributeListGetBoolean(attributes, NULL, "job-sheets", &banner);
212 papiAttributeListGetString(attributes, NULL, "job-class", &class);
213 papiAttributeListGetString(attributes, NULL, "job-name", &job_name);
214
215 {
208 s = NULL;
209 papiAttributeListGetString(attributes, NULL, "job-sheets", &s);
210 if ((s != NULL) && (strcasecmp(s, "none") == 0)) {
216 char buf[128];
211 char buf[128];
212 char *class = NULL;
213 char *job_name = NULL;
214
215 papiAttributeListGetLPString(attributes, "job-class", &class);
216 papiAttributeListGetLPString(attributes, "job-name", &job_name);
217
217 /* burst page is enabled by default, add the title */
218 snprintf(buf, sizeof (buf), "%s%s%s",
219 (job_name ? job_name : ""),
220 (job_name && class ? "\\n#####\\n#####\\t\\t " : ""),
221 (class ? class : ""));
222 if (buf[0] != '\0') {
223 if (r->title != NULL)
224 free(r->title);
225 r->title = strdup(buf);
226 }
218 /* burst page is enabled by default, add the title */
219 snprintf(buf, sizeof (buf), "%s%s%s",
220 (job_name ? job_name : ""),
221 (job_name && class ? "\\n#####\\n#####\\t\\t " : ""),
222 (class ? class : ""));
223 if (buf[0] != '\0') {
224 if (r->title != NULL)
225 free(r->title);
226 r->title = strdup(buf);
227 }
227 }
228 if (banner == 0) /* burst page is disabled via lp "option" */
228 } else /* burst page is disabled via lp "option" */
229 appendlist(&options, "nobanner");
230
229 appendlist(&options, "nobanner");
230
231 /* add "lp -o" options */
232 attr = papiAttributeListFind(attributes, "lp-options");
233 if ((attr != NULL) && (attr->type == PAPI_STRING) &&
234 (attr->values != NULL)) {
235 int i;
236
237 for (i = 0; attr->values[i] != NULL; i++)
238 appendlist(&options, attr->values[i]->string);
239 }
240
241 if (options != NULL) {
242 if (r->options != NULL)
243 free(r->options);
244 r->options = sprintlist(options);
245 freelist(options);
246 }
247
248 /* Convert attribute "number-up" to mode group=n */
249 papiAttributeListGetInteger(attributes, NULL, "number-up", &numberUp);
250 if ((numberUp >= 2) && ((numberUp % 2) == 0)) {
251 snprintf(buf, sizeof (buf), "group=%d", numberUp);
252 appendlist(&modes, buf);
253 }
254
255 /*
256 * Convert attribute "orientation-requested" to modes
257 * 'landscape', 'portrait', etc.
258 */
259 papiAttributeListGetInteger(attributes, NULL,
260 "orientation-requested", &orientation);
261 if ((orientation >= 3) && (orientation <= 6)) {
262 switch (orientation) {
231 /* Convert attribute "number-up" to mode group=n */
232 papiAttributeListGetInteger(attributes, NULL, "number-up", &numberUp);
233 if ((numberUp >= 2) && ((numberUp % 2) == 0)) {
234 snprintf(buf, sizeof (buf), "group=%d", numberUp);
235 appendlist(&modes, buf);
236 }
237
238 /*
239 * Convert attribute "orientation-requested" to modes
240 * 'landscape', 'portrait', etc.
241 */
242 papiAttributeListGetInteger(attributes, NULL,
243 "orientation-requested", &orientation);
244 if ((orientation >= 3) && (orientation <= 6)) {
245 switch (orientation) {
263 case 3:
264 {
265 /* 3 = portrait */
266 appendlist(&modes, "portrait");
267 break;
268 }
269
270 case 4:
271 {
272 /* 4 = landscape */
273 appendlist(&modes, "landscape");
274 break;
275 }
276
277 case 5:
278 {
279 /*
280 * 5 = reverse-landscape - not supported in
281 * lpsched so just use 'landscape' for now
282 */
283 appendlist(&modes, "landscape");
284 break;
285 }
286
287 case 6:
288 {
289 /*
290 * 6 = reverse-portrait not supported in
291 * lpsched so just use 'portrait' for now
292 */
293 appendlist(&modes, "portrait");
294 break;
295 }
296
297 default:
298 {
299 appendlist(&modes, "portrait");
300 break;
301 }
246 case 4: /* landscape */
247 case 5: /* reverse-landscape, use landscape instead */
248 appendlist(&modes, "landscape");
249 break;
250 case 3: /* portrait */
251 case 6: /* reverse-portrait, use portrait instead */
252 default:
253 appendlist(&modes, "portrait");
254 break;
302 }
303 }
304
305 /* add "lp -y" modes */
306 attr = papiAttributeListFind(attributes, "lp-modes");
307 if ((attr != NULL) && (attr->type == PAPI_STRING) &&
308 (attr->values != NULL)) {
309 int i;

--- 4 unchanged lines hidden (view full) ---

314
315 if (modes != NULL) {
316 if (r->modes == NULL)
317 free(r->modes);
318 r->modes = sprintlist(modes);
319 freelist(modes);
320 }
321
255 }
256 }
257
258 /* add "lp -y" modes */
259 attr = papiAttributeListFind(attributes, "lp-modes");
260 if ((attr != NULL) && (attr->type == PAPI_STRING) &&
261 (attr->values != NULL)) {
262 int i;

--- 4 unchanged lines hidden (view full) ---

267
268 if (modes != NULL) {
269 if (r->modes == NULL)
270 free(r->modes);
271 r->modes = sprintlist(modes);
272 freelist(modes);
273 }
274
275 /* add any unconsumed attributes to the "options" list */
276 split_and_copy_attributes(mapped_keys, attributes, NULL, &unmapped);
277 if (unmapped != NULL) { /* convert them to lp options */
278 char *buf = malloc(1024);
279 ssize_t size = 1024;
280
281 while (papiAttributeListToString(unmapped, ", ", buf, size)
282 != PAPI_OK) {
283 size += 1024;
284 buf = realloc(buf, size);
285 }
286 appendlist(&options, buf);
287 free(buf);
288 papiAttributeListFree(unmapped);
289 }
290
291 if (options != NULL) {
292 if (r->options != NULL)
293 free(r->options);
294 r->options = sprintlist(options);
295 freelist(options);
296 }
297
322 return (PAPI_OK);
323}
324
325/*
326 * Convert REQUEST->outcome (or R_REQUEST_* state) to the equivalent
327 * PAPI attribute representation.
328 */
329static void

--- 53 unchanged lines hidden (view full) ---

383 char *tmp;
384 int i;
385
386 /* copies */
387 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
388 "copies", r->copies);
389
390 /* destination */
298 return (PAPI_OK);
299}
300
301/*
302 * Convert REQUEST->outcome (or R_REQUEST_* state) to the equivalent
303 * PAPI attribute representation.
304 */
305static void

--- 53 unchanged lines hidden (view full) ---

359 char *tmp;
360 int i;
361
362 /* copies */
363 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
364 "copies", r->copies);
365
366 /* destination */
391 addLPString(&j->attributes, PAPI_ATTR_REPLACE, "printer-name",
392 r->destination);
367 papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE,
368 "printer-name", r->destination);
393
369
394 /* file_list */
395 addLPStrings(&j->attributes, PAPI_ATTR_REPLACE,
396 "lpsched-files", r->file_list);
397
398 /* form */
370 /* form */
399 addLPString(&j->attributes, PAPI_ATTR_REPLACE, "media", r->form);
371 papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE,
372 "form", r->form);
400
373
401 /* actions */
402 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
403 "lpsched-actions", r->actions);
404
405 /* alert */
406 addLPString(&j->attributes, PAPI_ATTR_REPLACE, "lp-alert", r->alert);
407
408 /* options */
374 /* options */
409 addLPString(&j->attributes, PAPI_ATTR_REPLACE,
410 "lp-options", r->options);
375 papiAttributeListFromString(&j->attributes, PAPI_ATTR_APPEND,
376 r->options);
411
412 tmp = (((r->options != NULL) && (strstr(r->options, "nobanner")
413 != NULL)) ? "none" : "standard");
414 papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE,
415 "job-sheets", tmp);
416
417 tmp = (((r->options != NULL) && (strstr(r->options, "duplex")
418 != NULL)) ? "two-sized" : "one-sided");

--- 5 unchanged lines hidden (view full) ---

424 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
425 "orientation-requested", i);
426
427 /* priority (map 0-39 to 1-100) */
428 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
429 "job-priority", (int)((r->priority + 1) * 2.5));
430
431 /* pages */
377
378 tmp = (((r->options != NULL) && (strstr(r->options, "nobanner")
379 != NULL)) ? "none" : "standard");
380 papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE,
381 "job-sheets", tmp);
382
383 tmp = (((r->options != NULL) && (strstr(r->options, "duplex")
384 != NULL)) ? "two-sized" : "one-sided");

--- 5 unchanged lines hidden (view full) ---

390 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
391 "orientation-requested", i);
392
393 /* priority (map 0-39 to 1-100) */
394 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
395 "job-priority", (int)((r->priority + 1) * 2.5));
396
397 /* pages */
432 addLPString(&j->attributes, PAPI_ATTR_REPLACE, "page-ranges", r->pages);
398 papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE,
399 "page-ranges", r->pages);
433
434 /* charset */
400
401 /* charset */
435 addLPString(&j->attributes, PAPI_ATTR_REPLACE, "lp-charset",
436 r->charset);
402 papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE,
403 "lp-charset", r->charset);
437
438 /* modes */
404
405 /* modes */
439 addLPString(&j->attributes, PAPI_ATTR_REPLACE, "lp-modes", r->modes);
406 papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE,
407 "lp-modes", r->modes);
440
441 /* title */
408
409 /* title */
442 addLPString(&j->attributes, PAPI_ATTR_REPLACE, "job-name", r->title);
410 papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE,
411 "job-name", r->title);
443
444 /* input_type */
445
446 /* user */
412
413 /* input_type */
414
415 /* user */
447 addLPString(&j->attributes, PAPI_ATTR_REPLACE,
416 papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE,
448 "job-originating-user-name", r->user);
449
450 /* outcome */
417 "job-originating-user-name", r->user);
418
419 /* outcome */
451 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
452 "lpsched-outcome", r->outcome);
453 lpsched_request_outcome_to_attributes(&j->attributes, r->outcome);
454
420 lpsched_request_outcome_to_attributes(&j->attributes, r->outcome);
421
455 /* version */
456 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
457 "lpsched-version", r->version);
458
459 /* constants, (should be derived from options) */
460 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
461 "number-up", 1);
462
463 papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE,
464 "multiple-document-handling",
465 "seperate-documents-collated-copies");
466}

--- 4 unchanged lines hidden (view full) ---

471void
472job_status_to_attributes(job_t *job, char *req_id, char *user, char *slabel,
473 size_t size, time_t date, short state, char *destination,
474 char *form, char *charset, short rank, char *file)
475{
476 char buf[BUFSIZ];
477 char *p;
478
422 /* constants, (should be derived from options) */
423 papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE,
424 "number-up", 1);
425
426 papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE,
427 "multiple-document-handling",
428 "seperate-documents-collated-copies");
429}

--- 4 unchanged lines hidden (view full) ---

434void
435job_status_to_attributes(job_t *job, char *req_id, char *user, char *slabel,
436 size_t size, time_t date, short state, char *destination,
437 char *form, char *charset, short rank, char *file)
438{
439 char buf[BUFSIZ];
440 char *p;
441
479 addLPString(&job->attributes, PAPI_ATTR_REPLACE,
442 papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE,
480 "job-originating-user-name", user);
481 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
482 "job-k-octets", size/1024);
483 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
484 "job-octets", size);
485 if ((p = strrchr(req_id, '-')) != NULL) {
486 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
487 "job-id", atoi(++p));
488 }
443 "job-originating-user-name", user);
444 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
445 "job-k-octets", size/1024);
446 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
447 "job-octets", size);
448 if ((p = strrchr(req_id, '-')) != NULL) {
449 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
450 "job-id", atoi(++p));
451 }
489 snprintf(buf, sizeof (buf), "lpsched://%s/%d", destination, atoi(p));
452 snprintf(buf, sizeof (buf), "lpsched://localhost/printers/%s/%d",
453 destination, atoi(p));
490 papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE,
491 "job-uri", buf);
454 papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE,
455 "job-uri", buf);
492 snprintf(buf, sizeof (buf), "lpsched://%s", destination);
456 snprintf(buf, sizeof (buf), "lpsched://localhost/printers/%s",
457 destination);
493 papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE,
494 "job-printer-uri", buf);
495 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
496 "job-printer-up-time", time(NULL));
497 papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE,
498 "output-device-assigned", destination);
499 papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE,
500 "printer-name", destination);
458 papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE,
459 "job-printer-uri", buf);
460 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
461 "job-printer-up-time", time(NULL));
462 papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE,
463 "output-device-assigned", destination);
464 papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE,
465 "printer-name", destination);
501 addLPString(&job->attributes, PAPI_ATTR_REPLACE, "media", form);
466 papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE,
467 "form", form);
502
503 lpsched_request_outcome_to_attributes(&job->attributes, state);
504
505 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
506 "time-at-creation", date);
468
469 lpsched_request_outcome_to_attributes(&job->attributes, state);
470
471 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
472 "time-at-creation", date);
507 addLPString(&job->attributes, PAPI_ATTR_REPLACE,
473 papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE,
508 "lpsched-request-id", req_id);
474 "lpsched-request-id", req_id);
509 addLPString(&job->attributes, PAPI_ATTR_REPLACE,
475 papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE,
510 "lp-charset", charset);
511 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
512 "lpsched-job-state", state);
513 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
514 "number-of-intervening-jobs", rank - 1);
476 "lp-charset", charset);
477 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
478 "lpsched-job-state", state);
479 papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE,
480 "number-of-intervening-jobs", rank - 1);
515 addLPString(&job->attributes, PAPI_ATTR_REPLACE,
481 papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE,
516 "lpsched-file", file);
482 "lpsched-file", file);
517 addLPString(&job->attributes, PAPI_ATTR_EXCL,
483 papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_EXCL,
518 "job-name", file);
484 "job-name", file);
519 addLPString(&job->attributes, PAPI_ATTR_EXCL,
485 papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_EXCL,
520 "tsol-sensitivity-label", slabel);
521}
522
523void
524lpsched_read_job_configuration(service_t *svc, job_t *j, char *file)
525{
526 REQUEST *r;
527
528 if ((r = getrequest(file)) == NULL) {
529 detailed_error(svc, gettext("unable to read job data: %s"),
530 file);
531 return;
532 }
533
534 lpsched_request_to_job_attributes(r, j);
535}
486 "tsol-sensitivity-label", slabel);
487}
488
489void
490lpsched_read_job_configuration(service_t *svc, job_t *j, char *file)
491{
492 REQUEST *r;
493
494 if ((r = getrequest(file)) == NULL) {
495 detailed_error(svc, gettext("unable to read job data: %s"),
496 file);
497 return;
498 }
499
500 lpsched_request_to_job_attributes(r, j);
501}