46a47 > papi_status_t status = PAPI_OK; 47a49 > papi_attribute_t **unmapped = NULL; 53,54d54 < char *class = NULL; < char *job_name = NULL; 62,64c62,63 < int lowerPage = 0; < int upperPage = 0; < papi_status_t getResult = 0; --- > int lower = 0; > int upper = 0; 66a66,72 > char *mapped_keys[] = { "copies", "document-format", "form", > "job-class", "job-hold-until", "job-host", "job-name", > "job-originating-user-name", "job-printer", > "job-sheets", "lp-charset", "lp-modes", "number-up", > "orienttation-requested", "page-ranges", "pr-filter", > "pr-indent", "pr-title", "pr-width", "priority", > "requesting-user-name", NULL }; 68,69d73 < char banner = 0; < 73,74c77,79 < papiAttributeListGetString(attributes, NULL, "job-printer", < &r->destination); --- > /* replace the current destination */ > papiAttributeListGetLPString(attributes, > "job-printer", &r->destination); 75a81 > /* set the copies. We need at least 1 */ 81a88,91 > /* > * set the priority. PAPI/IPP uses 1-100, lpsched use 0-39, so we > * have to convert it. > */ 89d98 < 93,102c102,103 < /* < * 'media' size should be processed both in the lpsched filter and < * the foomatic filter (if present) so that we ensure the result of < * other options like 'page-ranges' are consistent. < */ < /* < * TODO - I thing we should really have this but I can't get it to filter < * so its commented out for now (paulcun) < * papiAttributeListGetString(attributes, NULL, "media", &r->form); < */ --- > /* set the requested form to print on */ > papiAttributeListGetLPString(attributes, "form", &r->form); 103a105 > /* set the page range */ 105c107 < papiAttributeListGetString(attributes, NULL, "page-ranges", &r->pages); --- > papiAttributeListGetLPString(attributes, "page-ranges", &r->pages); 107,117c109,114 < getResult = < papiAttributeListGetRange(attributes, &iterator, < "page-ranges", &lowerPage, &upperPage); < while (getResult == PAPI_OK) { < if (r->pages == NULL) { < snprintf(buf, sizeof (buf), < "%d-%d", lowerPage, upperPage); < r->pages = (char *)strdup(buf); < } < else < { --- > for (status = papiAttributeListGetRange(attributes, &iterator, > "page-ranges", &lower, &upper); > status == PAPI_OK; > status = papiAttributeListGetRange(attributes, &iterator, > "page-ranges", &lower, &upper)) { > if (r->pages != NULL) { 119c116 < r->pages, lowerPage, upperPage); --- > r->pages, lower, upper); 121,129c118,120 < r->pages = (char *)strdup(buf); < } < /* < * get the next value; note the attribute 'name' is set to < * NULL to do this. < */ < getResult = < papiAttributeListGetRange(attributes, &iterator, < "page-ranges", &lowerPage, &upperPage); --- > } else > snprintf(buf, sizeof (buf), "%d-%d", lower, upper); > r->pages = (char *)strdup(buf); 133c124,127 < --- > /* > * set the document format, converting to old format names as > * as needed. > */ 138a133 > 167a163 > /* set any held state */ 181c177,178 < papiAttributeListGetString(attributes, NULL, "lp-charset", &r->charset); --- > /* set lp charset/printwheel */ > papiAttributeListGetLPString(attributes, "lp-charset", &r->charset); 211,215c208,210 < papiAttributeListGetBoolean(attributes, NULL, "job-sheets", &banner); < papiAttributeListGetString(attributes, NULL, "job-class", &class); < papiAttributeListGetString(attributes, NULL, "job-name", &job_name); < < { --- > s = NULL; > papiAttributeListGetString(attributes, NULL, "job-sheets", &s); > if ((s != NULL) && (strcasecmp(s, "none") == 0)) { 216a212,217 > char *class = NULL; > char *job_name = NULL; > > papiAttributeListGetLPString(attributes, "job-class", &class); > papiAttributeListGetLPString(attributes, "job-name", &job_name); > 227,228c228 < } < if (banner == 0) /* burst page is disabled via lp "option" */ --- > } else /* burst page is disabled via lp "option" */ 231,247d230 < /* add "lp -o" options */ < attr = papiAttributeListFind(attributes, "lp-options"); < if ((attr != NULL) && (attr->type == PAPI_STRING) && < (attr->values != NULL)) { < int i; < < for (i = 0; attr->values[i] != NULL; i++) < appendlist(&options, attr->values[i]->string); < } < < if (options != NULL) { < if (r->options != NULL) < free(r->options); < r->options = sprintlist(options); < freelist(options); < } < 263,301c246,254 < case 3: < { < /* 3 = portrait */ < appendlist(&modes, "portrait"); < break; < } < < case 4: < { < /* 4 = landscape */ < appendlist(&modes, "landscape"); < break; < } < < case 5: < { < /* < * 5 = reverse-landscape - not supported in < * lpsched so just use 'landscape' for now < */ < appendlist(&modes, "landscape"); < break; < } < < case 6: < { < /* < * 6 = reverse-portrait not supported in < * lpsched so just use 'portrait' for now < */ < appendlist(&modes, "portrait"); < break; < } < < default: < { < appendlist(&modes, "portrait"); < break; < } --- > case 4: /* landscape */ > case 5: /* reverse-landscape, use landscape instead */ > appendlist(&modes, "landscape"); > break; > case 3: /* portrait */ > case 6: /* reverse-portrait, use portrait instead */ > default: > appendlist(&modes, "portrait"); > break; 321a275,297 > /* add any unconsumed attributes to the "options" list */ > split_and_copy_attributes(mapped_keys, attributes, NULL, &unmapped); > if (unmapped != NULL) { /* convert them to lp options */ > char *buf = malloc(1024); > ssize_t size = 1024; > > while (papiAttributeListToString(unmapped, ", ", buf, size) > != PAPI_OK) { > size += 1024; > buf = realloc(buf, size); > } > appendlist(&options, buf); > free(buf); > papiAttributeListFree(unmapped); > } > > if (options != NULL) { > if (r->options != NULL) > free(r->options); > r->options = sprintlist(options); > freelist(options); > } > 391,392c367,368 < addLPString(&j->attributes, PAPI_ATTR_REPLACE, "printer-name", < r->destination); --- > papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, > "printer-name", r->destination); 394,397d369 < /* file_list */ < addLPStrings(&j->attributes, PAPI_ATTR_REPLACE, < "lpsched-files", r->file_list); < 399c371,372 < addLPString(&j->attributes, PAPI_ATTR_REPLACE, "media", r->form); --- > papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, > "form", r->form); 401,407d373 < /* actions */ < papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, < "lpsched-actions", r->actions); < < /* alert */ < addLPString(&j->attributes, PAPI_ATTR_REPLACE, "lp-alert", r->alert); < 409,410c375,376 < addLPString(&j->attributes, PAPI_ATTR_REPLACE, < "lp-options", r->options); --- > papiAttributeListFromString(&j->attributes, PAPI_ATTR_APPEND, > r->options); 432c398,399 < addLPString(&j->attributes, PAPI_ATTR_REPLACE, "page-ranges", r->pages); --- > papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, > "page-ranges", r->pages); 435,436c402,403 < addLPString(&j->attributes, PAPI_ATTR_REPLACE, "lp-charset", < r->charset); --- > papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, > "lp-charset", r->charset); 439c406,407 < addLPString(&j->attributes, PAPI_ATTR_REPLACE, "lp-modes", r->modes); --- > papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, > "lp-modes", r->modes); 442c410,411 < addLPString(&j->attributes, PAPI_ATTR_REPLACE, "job-name", r->title); --- > papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, > "job-name", r->title); 447c416 < addLPString(&j->attributes, PAPI_ATTR_REPLACE, --- > papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, 451,452d419 < papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, < "lpsched-outcome", r->outcome); 455,458d421 < /* version */ < papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, < "lpsched-version", r->version); < 479c442 < addLPString(&job->attributes, PAPI_ATTR_REPLACE, --- > papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE, 489c452,453 < snprintf(buf, sizeof (buf), "lpsched://%s/%d", destination, atoi(p)); --- > snprintf(buf, sizeof (buf), "lpsched://localhost/printers/%s/%d", > destination, atoi(p)); 492c456,457 < snprintf(buf, sizeof (buf), "lpsched://%s", destination); --- > snprintf(buf, sizeof (buf), "lpsched://localhost/printers/%s", > destination); 501c466,467 < addLPString(&job->attributes, PAPI_ATTR_REPLACE, "media", form); --- > papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE, > "form", form); 507c473 < addLPString(&job->attributes, PAPI_ATTR_REPLACE, --- > papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE, 509c475 < addLPString(&job->attributes, PAPI_ATTR_REPLACE, --- > papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE, 515c481 < addLPString(&job->attributes, PAPI_ATTR_REPLACE, --- > papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE, 517c483 < addLPString(&job->attributes, PAPI_ATTR_EXCL, --- > papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_EXCL, 519c485 < addLPString(&job->attributes, PAPI_ATTR_EXCL, --- > papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_EXCL,