papi_status_t hold_release_job(papi_service_t handle, char *printer, int32_t job_id, int flag) { papi_status_t status; service_t *svc = handle; REQUEST *r = NULL; char *file; char *dest; if ((svc == NULL) || (printer == NULL) || (job_id < 0)) return (PAPI_BAD_ARGUMENT); if ((status = authorized(svc, job_id)) != PAPI_OK) return (status); dest = printer_name_from_uri_id(printer, job_id); status = lpsched_start_change(svc, dest, job_id, &file); if (status != PAPI_OK) return (status); if ((r = getrequest(file)) != NULL) { r->actions &= ~ACT_RESUME; switch (flag) { case 0: r->actions |= ACT_HOLD; break; case 1: r->actions |= ACT_RESUME; break; case 2: r->actions |= ACT_IMMEDIATE; break; } if (putrequest(file, r) < 0) { detailed_error(svc, gettext("failed to write job: %s: %s"), file, strerror(errno)); freerequest(r); return (PAPI_DEVICE_ERROR); } freerequest(r); } else { detailed_error(svc, gettext("failed to read job: %s: %s"), file, strerror(errno)); return (PAPI_DEVICE_ERROR); } status = lpsched_end_change(svc, dest, job_id); return (status); }
/* * interface for passing a peer's connection to gather sensitivity labeling * from for Trusted Solaris. */ papi_status_t papiServiceSetPeer(papi_service_t handle, int peerfd) { papi_status_t result = PAPI_OK; service_t *svc = handle; if (svc == NULL) return (PAPI_BAD_ARGUMENT); if (is_system_labeled()) { short status; if ((snd_msg(svc, S_PASS_PEER_CONNECTION) < 0) || (ioctl(svc->md->writefd, I_SENDFD, peerfd) < 0) || (rcv_msg(svc, R_PASS_PEER_CONNECTION, &status) < 0)) status = MTRANSMITERR; if (status != MOK) { detailed_error(svc, gettext("failed to send peer connection: %s"), lpsched_status_string(status)); result = lpsched_status_to_papi_status(status); } } return (result); }
papi_status_t papiJobQuery(papi_service_t handle, char *printer, int32_t job_id, char **requested_attrs, papi_job_t *job) { service_t *svc = handle; job_t *j; char *dest; char req_id[32]; short rc; char *form = NULL, *request_id = NULL, *charset = NULL, *user = NULL, *slabel = NULL, *file = NULL; time_t date = 0; size_t size = 0; short rank = 0, state = 0; if ((handle == NULL) || (printer == NULL) || (job_id < 0)) return (PAPI_BAD_ARGUMENT); dest = printer_name_from_uri_id(printer, job_id); snprintf(req_id, sizeof (req_id), "%s-%d", dest, job_id); free(dest); rc = snd_msg(svc, S_INQUIRE_REQUEST_RANK, 0, "", "", req_id, "", ""); if (rc < 0) return (PAPI_SERVICE_UNAVAILABLE); if (rcv_msg(svc, R_INQUIRE_REQUEST_RANK, &rc, &request_id, &user, &slabel, &size, &date, &state, &dest, &form, &charset, &rank, &file) < 0) { detailed_error(svc, gettext("failed to read response from scheduler")); return (PAPI_DEVICE_ERROR); } if ((request_id == NULL) || (request_id[0] == NULL)) return (PAPI_NOT_FOUND); if ((*job = j = calloc(1, sizeof (*j))) == NULL) return (PAPI_TEMPORARY_ERROR); snprintf(req_id, sizeof (req_id), "%d-0", job_id); lpsched_read_job_configuration(svc, j, req_id); job_status_to_attributes(j, request_id, user, slabel, size, date, state, dest, form, charset, rank, file); return (PAPI_OK); }
papi_status_t papiJobCommit(papi_service_t handle, char *printer, int32_t id) { papi_status_t status = PAPI_OK; service_t *svc = handle; REQUEST *r = NULL; char *metadata_file; char *dest; if ((svc == NULL) || (printer == NULL)) return (PAPI_BAD_ARGUMENT); dest = printer_name_from_uri_id(printer, id); /* tell the scheduler that we want to change the job */ status = lpsched_start_change(svc, dest, id, &metadata_file); if (status != PAPI_OK) return (status); if ((r = getrequest(metadata_file)) != NULL) { r->actions &= ~ACT_RESUME; r->actions |= ACT_RESUME; dellist(&r->file_list, DUMMY_FILE); if (putrequest(metadata_file, r) < 0) { detailed_error(svc, gettext("failed to write job: %s: %s"), metadata_file, strerror(errno)); freerequest(r); return (PAPI_DEVICE_ERROR); } } else { detailed_error(svc, gettext("failed to read job: %s: %s"), metadata_file, strerror(errno)); return (PAPI_DEVICE_ERROR); } status = lpsched_end_change(svc, dest, id); freerequest(r); return (status); }
papi_status_t papiPrinterPurgeJobs(papi_service_t handle, char *name, papi_job_t **jobs) { service_t *svc = handle; papi_status_t result = PAPI_OK_SUBST; short more; long status; char *dest; char *req_id; if ((handle == NULL) || (name == NULL)) return (PAPI_BAD_ARGUMENT); dest = printer_name_from_uri_id(name, -1); more = snd_msg(svc, S_CANCEL, dest, "", ""); free(dest); if (more < 0) return (PAPI_SERVICE_UNAVAILABLE); do { if (rcv_msg(svc, R_CANCEL, &more, &status, &req_id) < 0) return (PAPI_SERVICE_UNAVAILABLE); switch (status) { case MOK: papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, "canceled-jobs", req_id); break; case M2LATE: case MUNKNOWN: case MNOINFO: papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, "cancel-failed", req_id); result = PAPI_DEVICE_ERROR; break; case MNOPERM: papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, "cancel-failed", req_id); result = PAPI_NOT_AUTHORIZED; break; default: detailed_error(svc, gettext("cancel failed, bad status (%d)\n"), status); return (PAPI_DEVICE_ERROR); } } while (more == MOKMORE); return (result); }
/* * This puts the class information in only. It could create a hybrid * printer object to return, but that is problematic at best. */ papi_status_t lpsched_class_configuration_to_attributes(service_t *svc, printer_t *p, char *dest) { CLASS *tmp; if ((svc == NULL) || (p == NULL)) return (PAPI_BAD_ARGUMENT); /* get the configuration DB data */ if ((tmp = getclass(dest)) == NULL) { detailed_error(svc, gettext("unable to read configuration data")); return (PAPI_DEVICE_ERROR); } /* name */ papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "printer-name", tmp->name); if (tmp->name != NULL) { char uri[BUFSIZ]; snprintf(uri, sizeof (uri), "lpsched://localhost/printers/%s", tmp->name); papiAttributeListAddString(&p->attributes, PAPI_ATTR_REPLACE, "printer-uri-supported", uri); } if (tmp->members != NULL) { char **members = tmp->members; int i; for (i = 0; members[i] != NULL; i++) papiAttributeListAddString(&p->attributes, PAPI_ATTR_APPEND, "member-names", members[i]); } freeclass(tmp); return (PAPI_OK); }
papi_status_t papiServiceCreate(papi_service_t *handle, char *service_name, char *user_name, char *password, int (*authCB)(papi_service_t svc, void *app_data), papi_encryption_t encryption, void *app_data) { service_t *svc = NULL; char *path = Lp_FIFO; if (handle == NULL) return (PAPI_BAD_ARGUMENT); if ((*handle = svc = calloc(1, sizeof (*svc))) == NULL) return (PAPI_TEMPORARY_ERROR); svc->md = mconnect(path, 0, 0); if (svc->md == NULL) { detailed_error(svc, gettext("can't connect to spooler for %s: %s"), (service_name ? service_name : ""), strerror(errno)); return (PAPI_SERVICE_UNAVAILABLE); } svc->msgbuf_size = MSGMAX; if ((svc->msgbuf = calloc(1, svc->msgbuf_size)) == NULL) return (PAPI_TEMPORARY_ERROR); if (service_name != NULL) papiAttributeListAddString(&svc->attributes, PAPI_ATTR_EXCL, "service-name", service_name); (void) papiServiceSetUserName(svc, user_name); (void) papiServiceSetPassword(svc, password); (void) papiServiceSetAuthCB(svc, authCB); (void) papiServiceSetAppData(svc, app_data); (void) papiServiceSetEncryption(svc, encryption); return (PAPI_OK); }
papi_status_t papiJobStreamOpen(papi_service_t handle, char *printer, papi_attribute_t **job_attributes, papi_job_ticket_t *job_ticket, papi_stream_t *stream) { papi_status_t status; service_t *svc = handle; job_stream_t *s = NULL; char *request_id = NULL; char lpfile[BUFSIZ]; if ((svc == NULL) || (printer == NULL) || (stream == NULL)) return (PAPI_BAD_ARGUMENT); if (job_ticket != NULL) return (PAPI_OPERATION_NOT_SUPPORTED); if ((*stream = s = calloc(1, sizeof (*s))) == NULL) return (PAPI_TEMPORARY_ERROR); /* 1 for data, 1 for the meta-data (-0) */ status = lpsched_alloc_files(svc, 2, &request_id); if (status != PAPI_OK) return (status); s->request = create_request(svc, (char *)printer, (papi_attribute_t **)job_attributes); snprintf(lpfile, sizeof (lpfile), "/var/spool/lp/temp/%s-1", request_id); s->fd = open(lpfile, O_WRONLY); addlist(&(s->request->file_list), lpfile); #ifdef LP_USE_PAPI_ATTR /* * store the job attributes in the PAPI job attribute file that was * created by lpsched_alloc_files(), the attributes will then pass * through lpsched and be given to the slow-filters and the printer's * interface script to process them */ snprintf(lpfile, sizeof (lpfile), "%s%s-%s", "/var/spool/lp/temp/", request_id, LP_PAPIATTRNAME); status = psm_copy_attrsToFile(job_attributes, lpfile); if (status != PAPI_OK) { detailed_error(svc, "unable to copy attributes to file: %s: %s", lpfile, strerror(errno)); close(s->fd); free(s); return (PAPI_DEVICE_ERROR); } #endif /* store the meta-data file */ snprintf(lpfile, sizeof (lpfile), "%s-0", request_id); s->meta_data_file = strdup(lpfile); if (putrequest(lpfile, s->request) < 0) { detailed_error(svc, gettext("unable to save request: %s: %s"), lpfile, strerror(errno)); s->request = NULL; return (PAPI_DEVICE_ERROR); } return (PAPI_OK); }
papi_status_t papiJobSubmitByReference(papi_service_t handle, char *printer, papi_attribute_t **job_attributes, papi_job_ticket_t *job_ticket, char **files, papi_job_t *job) { service_t *svc = handle; struct stat statbuf; job_t *j; int file_no; short status; char *request_id = NULL; REQUEST *request; char *c; char *tmp = NULL; char lpfile[BUFSIZ]; char **file_list = NULL; if ((svc == NULL) || (printer == NULL) || (files == NULL) || (job == NULL)) return (PAPI_BAD_ARGUMENT); if (job_ticket != NULL) return (PAPI_OPERATION_NOT_SUPPORTED); if (files != NULL) for (file_no = 0; files[file_no] != NULL; file_no++) { if (access(files[file_no], R_OK) < 0) { detailed_error(svc, gettext("Cannot access file: %s: %s"), files[file_no], strerror(errno)); return (PAPI_DOCUMENT_ACCESS_ERROR); } if (stat(files[file_no], &statbuf) < 0) { detailed_error(svc, gettext("Cannot access file: %s: %s"), files[file_no], strerror(errno)); return (PAPI_DOCUMENT_ACCESS_ERROR); } if (statbuf.st_size == 0) { detailed_error(svc, gettext("Zero byte (empty) file: %s"), files[file_no]); return (PAPI_BAD_ARGUMENT); } if (files[file_no][0] != '/') { char path[MAXPATHLEN]; if (getcwd(path, sizeof (path)) == NULL) { detailed_error(svc, gettext( "getcwd for file: %s: %s"), files[file_no], strerror(errno)); return (PAPI_DOCUMENT_ACCESS_ERROR); } strlcat(path, "/", sizeof (path)); if (strlcat(path, files[file_no], sizeof (path)) >= sizeof (path)) { detailed_error(svc, gettext( "pathname too long: %s"), files[file_no]); return (PAPI_DOCUMENT_ACCESS_ERROR); } addlist(&file_list, path); } else addlist(&file_list, (char *)files[file_no]); } if ((*job = j = calloc(1, sizeof (*j))) == NULL) return (PAPI_TEMPORARY_ERROR); /* 1 for the control file (-0) */ status = lpsched_alloc_files(svc, 1, &request_id); if (status != PAPI_OK) return (status); request = create_request(svc, (char *)printer, (papi_attribute_t **)job_attributes); request->file_list = file_list; #ifdef LP_USE_PAPI_ATTR /* * store the job attributes in the PAPI job attribute file that was * created by lpsched_alloc_files(), the attributes will then pass * through lpsched and be given to the slow-filters and the printer's * interface script to process them */ snprintf(lpfile, sizeof (lpfile), "%s%s-%s", "/var/spool/lp/temp/", request_id, LP_PAPIATTRNAME); status = psm_copy_attrsToFile(job_attributes, lpfile); if (status != PAPI_OK) { detailed_error(svc, "unable to copy attributes to file: %s: %s", lpfile, strerror(errno)); return (PAPI_DEVICE_ERROR); } #endif /* store the meta-data file */ snprintf(lpfile, sizeof (lpfile), "%s-0", request_id); if (putrequest(lpfile, request) < 0) { detailed_error(svc, gettext("unable to save request: %s: %s"), lpfile, strerror(errno)); freerequest(request); return (PAPI_DEVICE_ERROR); } status = lpsched_commit_job(svc, lpfile, &tmp); if (status != PAPI_OK) { unlink(lpfile); freerequest(request); return (status); } lpsched_request_to_job_attributes(request, j); freerequest(request); if ((c = strrchr(tmp, '-')) != NULL) c++; papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, "job-id", atoi(c)); papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE, "job-uri", tmp); return (PAPI_OK); }
papi_status_t papiJobStreamAdd(papi_service_t handle, char *printer, int32_t id, papi_stream_t *stream) { papi_status_t status; service_t *svc = handle; job_stream_t *s = NULL; char *metadata_file = NULL; char *dest; char path[MAXPATHLEN]; /* allocate space for the stream */ if ((*stream = s = calloc(1, sizeof (*s))) == NULL) return (PAPI_TEMPORARY_ERROR); dest = printer_name_from_uri_id(printer, id); /* create/open data file (only root or lp can really do this */ snprintf(path, sizeof (path), "/var/spool/lp/temp/%d-XXXXXX", id); if ((s->fd = mkstemp(path)) < 0) { detailed_error(svc, gettext("unable to create sink (%s): %s"), path, strerror(errno)); free(s); return (PAPI_NOT_AUTHORIZED); } /* add data file to job */ status = lpsched_start_change(svc, dest, id, &metadata_file); if (status != PAPI_OK) { close(s->fd); free(s); unlink(path); return (status); } if ((s->request = getrequest(metadata_file)) == NULL) { detailed_error(svc, gettext("unable to load request: %s: %s"), metadata_file, strerror(errno)); close(s->fd); free(s); unlink(path); return (PAPI_NOT_POSSIBLE); } addlist(&(s->request->file_list), path); if (putrequest(metadata_file, s->request) < 0) { detailed_error(svc, gettext("unable to save request: %s: %s"), metadata_file, strerror(errno)); close(s->fd); free(s); unlink(path); return (PAPI_NOT_POSSIBLE); } status = lpsched_end_change(svc, dest, id); if (status != PAPI_OK) return (status); return (PAPI_OK); }
papi_status_t papiJobCreate(papi_service_t handle, char *printer, papi_attribute_t **job_attributes, papi_job_ticket_t *job_ticket, papi_job_t *job) { papi_status_t status; service_t *svc = handle; job_t *j = NULL; REQUEST *request; char *request_id = NULL; char *c; char *tmp = NULL; char metadata_file[MAXPATHLEN]; if ((svc == NULL) || (printer == NULL) || (job == NULL)) return (PAPI_BAD_ARGUMENT); if (job_ticket != NULL) return (PAPI_JOB_TICKET_NOT_SUPPORTED); if ((*job = j = calloc(1, sizeof (*j))) == NULL) return (PAPI_TEMPORARY_ERROR); /* 1 for the control file (-0) */ status = lpsched_alloc_files(svc, 1, &request_id); if (status != PAPI_OK) return (status); /* convert the attributes to an lpsched REQUEST structure */ request = create_request(svc, (char *)printer, (papi_attribute_t **)job_attributes); if (request == NULL) return (PAPI_TEMPORARY_ERROR); addlist(&request->file_list, DUMMY_FILE); /* add a dummy file */ request->actions |= ACT_HOLD; /* hold the job */ #ifdef LP_USE_PAPI_ATTR /* * store the job attributes in the PAPI job attribute file that was * created by lpsched_alloc_files(), the attributes will then pass * through lpsched and be given to the slow-filters and the printer's * interface script to process them */ snprintf(metadata_file, sizeof (metadata_file), "%s%s-%s", "/var/spool/lp/temp/", request_id, LP_PAPIATTRNAME); status = psm_copy_attrsToFile(job_attributes, metadata_file); if (status != PAPI_OK) { detailed_error(svc, "unable to copy attributes to file: %s: %s", metadata_file, strerror(errno)); free(request_id); return (PAPI_DEVICE_ERROR); } #endif /* store the REQUEST on disk */ snprintf(metadata_file, sizeof (metadata_file), "%s-0", request_id); free(request_id); if (putrequest(metadata_file, request) < 0) { detailed_error(svc, gettext("unable to save request: %s: %s"), metadata_file, strerror(errno)); return (PAPI_DEVICE_ERROR); } status = lpsched_commit_job(svc, metadata_file, &tmp); if (status != PAPI_OK) { unlink(metadata_file); return (status); } lpsched_request_to_job_attributes(request, j); if ((c = strrchr(tmp, '-')) != NULL) c++; papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, "job-id", atoi(c)); papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE, "job-uri", tmp); return (PAPI_OK); }
papi_status_t papiJobModify(papi_service_t handle, char *printer, int32_t job_id, papi_attribute_t **attributes, papi_job_t *job) { papi_status_t status; job_t *j = NULL; service_t *svc = handle; char *file = NULL; char *dest; REQUEST *r = NULL; char lpfile[BUFSIZ]; if ((svc == NULL) || (printer == NULL) || (job_id < 0) || (attributes == NULL)) return (PAPI_BAD_ARGUMENT); if ((*job = j = calloc(1, sizeof (*j))) == NULL) return (PAPI_TEMPORARY_ERROR); dest = printer_name_from_uri_id(printer, job_id); status = lpsched_start_change(svc, dest, job_id, &file); if (status != PAPI_OK) return (status); if ((r = getrequest(file)) != NULL) { job_attributes_to_lpsched_request(handle, r, (papi_attribute_t **)attributes); #ifdef LP_USE_PAPI_ATTR /* * store the job attributes in the PAPI job attribute file * that was created by the origonal job request. We need to * modify the attributes in the file as per the new attributes */ snprintf(lpfile, sizeof (lpfile), "%s%d-%s", "/var/spool/lp/temp/", job_id, LP_PAPIATTRNAME); status = psm_modifyAttrsFile(attributes, lpfile); if (status != PAPI_OK) { detailed_error(svc, "unable to modify the attributes file: %s: %s", lpfile, strerror(errno)); return (PAPI_DEVICE_ERROR); } #endif if (putrequest(file, r) < 0) { detailed_error(svc, gettext("failed to write job: %s: %s"), file, strerror(errno)); freerequest(r); return (PAPI_DEVICE_ERROR); } } else { detailed_error(svc, gettext("failed to read job: %s: %s"), file, strerror(errno)); return (PAPI_DEVICE_ERROR); } status = lpsched_end_change(svc, dest, job_id); lpsched_request_to_job_attributes(r, j); papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, "job-id", job_id); freerequest(r); return (status); }
papi_status_t papiJobSubmit(papi_service_t handle, char *printer, papi_attribute_t **job_attributes, papi_job_ticket_t *job_ticket, char **files, papi_job_t *job) { papi_status_t status; service_t *svc = handle; job_t *j; int file_no; char *request_id = NULL; REQUEST *request; int i; char *c; char *tmp = NULL; char lpfile[BUFSIZ]; if ((svc == NULL) || (printer == NULL) || (files == NULL) || (job == NULL)) return (PAPI_BAD_ARGUMENT); if (job_ticket != NULL) return (PAPI_OPERATION_NOT_SUPPORTED); if (files != NULL) for (file_no = 0; files[file_no] != NULL; file_no++) if (access(files[file_no], R_OK) < 0) { detailed_error(svc, gettext("Cannot access file: %s: %s"), files[file_no], strerror(errno)); return (PAPI_BAD_ARGUMENT); } if ((*job = j = calloc(1, sizeof (*j))) == NULL) return (PAPI_TEMPORARY_ERROR); /* file_no + 1 for the control file (-0) */ status = lpsched_alloc_files(svc, file_no + 1, &request_id); if (status != PAPI_OK) return (status); request = create_request(svc, (char *)printer, (papi_attribute_t **)job_attributes); for (i = 0; files[i] != NULL; i++) { papi_status_t status; snprintf(lpfile, sizeof (lpfile), "%s%s-%d", "/var/spool/lp/temp/", request_id, i+1); status = copy_file(files[i], lpfile); if (status != PAPI_OK) { detailed_error(svc, gettext("unable to copy: %s -> %s: %s"), files[i], lpfile, strerror(errno)); freerequest(request); return (PAPI_DEVICE_ERROR); } addlist(&(request->file_list), lpfile); } #ifdef LP_USE_PAPI_ATTR /* * store the job attributes in the PAPI job attribute file that was * created by lpsched_alloc_files(), the attributes will then pass * through lpsched and be given to the slow-filters and the printer's * interface script to process them */ snprintf(lpfile, sizeof (lpfile), "%s%s-%s", "/var/spool/lp/temp/", request_id, LP_PAPIATTRNAME); status = psm_copy_attrsToFile(job_attributes, lpfile); if (status != PAPI_OK) { detailed_error(svc, "unable to copy attributes to file: %s: %s", lpfile, strerror(errno)); return (PAPI_DEVICE_ERROR); } #endif /* store the meta-data file */ snprintf(lpfile, sizeof (lpfile), "%s-0", request_id); if (putrequest(lpfile, request) < 0) { detailed_error(svc, gettext("unable to save request: %s: %s"), lpfile, strerror(errno)); freerequest(request); return (PAPI_DEVICE_ERROR); } status = lpsched_commit_job(svc, lpfile, &tmp); if (status != PAPI_OK) { unlink(lpfile); freerequest(request); return (status); } lpsched_request_to_job_attributes(request, j); freerequest(request); if ((c = strrchr(tmp, '-')) != NULL) c++; papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, "job-id", atoi(c)); papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE, "job-uri", tmp); return (PAPI_OK); }
papi_status_t lpsched_printer_configuration_to_attributes(service_t *svc, printer_t *p, char *dest) { PRINTER *tmp; char buf[BUFSIZ+1]; struct utsname sysname; char **allowed = NULL, **denied = NULL; if ((svc == NULL) || (p == NULL) || (dest == NULL)) return (PAPI_BAD_ARGUMENT); /* get the configuration DB data */ if ((tmp = getprinter(dest)) == NULL) { detailed_error(svc, gettext("unable to read configuration data")); return (PAPI_DEVICE_ERROR); } /* name */ papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "printer-name", tmp->name); if (tmp->name != NULL) { char uri[BUFSIZ]; snprintf(uri, sizeof (uri), "lpsched://localhost/printers/%s", tmp->name); papiAttributeListAddString(&p->attributes, PAPI_ATTR_REPLACE, "printer-uri-supported", uri); } /* banner */ if ((tmp->banner & BAN_OPTIONAL) == BAN_OPTIONAL) papiAttributeListAddString(&p->attributes, PAPI_ATTR_APPEND, "job-sheets-supported", "optional"); else if (tmp->banner & BAN_NEVER) papiAttributeListAddString(&p->attributes, PAPI_ATTR_APPEND, "job-sheets-supported", "none"); else if (tmp->banner & BAN_ALWAYS) papiAttributeListAddString(&p->attributes, PAPI_ATTR_APPEND, "job-sheets-supported", "standard"); /* input_types */ if (tmp->input_types != NULL) { int i; for (i = 0; tmp->input_types[i] != NULL; i++) papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_APPEND, "document-format-supported", lp_type_to_mime_type(tmp->input_types[i])); } /* description */ papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "printer-info", tmp->description); /* add lpsched specific attributes */ papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "device-uri", tmp->device); papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-dial-info", tmp->dial_info); papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-fault-recovery", tmp->fault_rec); papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-interface-script", tmp->interface); papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-data-rate", tmp->speed); papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-stty", tmp->stty); papiAttributeListAddBoolean(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-login-term", tmp->login); papiAttributeListAddBoolean(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-daisy", tmp->daisy); papiAttributeListAddLPStrings(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-charsets", tmp->char_sets); #ifdef CAN_DO_MODULES papiAttributeListAddLPStrings(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-modules", tmp->modules); #endif /* CAN_DO_MODULES */ papiAttributeListAddLPStrings(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-options", tmp->options); papiAttributeListAddLPStrings(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-printer-type", tmp->printer_types); if (tmp->fault_alert.shcmd != NULL) { papiAttributeListAddLPString(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-fault-alert-command", tmp->fault_alert.shcmd); papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-fault-alert-threshold", tmp->fault_alert.Q); papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-fault-alert-interval", tmp->fault_alert.W); } papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-cpi-value", tmp->cpi.val); papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-cpi-unit", tmp->cpi.sc); papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-lpi-value", tmp->lpi.val); papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-lpi-unit", tmp->lpi.sc); papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-plen-value", tmp->plen.val); papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-plen-unit", tmp->plen.sc); papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-pwid-value", tmp->pwid.val); papiAttributeListAddInteger(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-pwid-unit", tmp->pwid.sc); /* allow/deny list */ load_userprinter_access(dest, &allowed, &denied); papiAttributeListAddLPStrings(&p->attributes, PAPI_ATTR_REPLACE, "requesting-user-name-allowed", allowed); papiAttributeListAddLPStrings(&p->attributes, PAPI_ATTR_REPLACE, "requesting-user-name-denied", denied); #ifdef LP_USE_PAPI_ATTR if (tmp->ppd != NULL) { int fd; struct stat sbuf; /* construct the two URIs for the printer's PPD file */ if (uname(&sysname) < 0) { /* failed to get systen name */ sysname.nodename[0] = 0; } snprintf(buf, sizeof (buf), "file://%s%s/ppd/%s.ppd", sysname.nodename, ETCDIR, tmp->name); papiAttributeListAddString(&p->attributes, PAPI_ATTR_REPLACE, "ppd-file-uri", buf); snprintf(buf, sizeof (buf), "file://%s%s", sysname.nodename, tmp->ppd); papiAttributeListAddString(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-printer-configure-ppd-uri", buf); papiAttributeListAddString(&p->attributes, PAPI_ATTR_REPLACE, "lpsched-ppd-source-path", tmp->ppd); snprintf(buf, sizeof (buf), "%s/ppd/%s.ppd", ETCDIR, tmp->name); /* * We don't return error on any of the error conditions, we just * silently return without adding the attribute. */ PPDFileToAttributesList(&p->attributes, buf); } #endif freeprinter(tmp); return (PAPI_OK); }