Exemple #1
0
static papi_status_t
psm_modifyAttrsFile(papi_attribute_t **attrs, char *file)

{
	papi_status_t result = PAPI_OK;
	papi_attribute_t **newAttrs = NULL;
	struct stat   tmpBuf;
	FILE *fd = NULL;

	if ((attrs != NULL) && (*attrs != NULL) && (file != NULL)) {

		/*
		 * check file exist before try to modify it, if it doesn't
		 * exist assume there is an error
		 */
		if (stat(file, &tmpBuf) == 0) {
			/*
			 * if file is currently empty just write the given
			 * attributes to the file otherwise exact the attributes
			 * from the file and modify them accordingly before
			 * writing them back to the file
			 */
			if (tmpBuf.st_size == 0) {
				newAttrs = (papi_attribute_t **)attrs;

				fd = fopen(file, "w");
				if (fd != NULL) {
					papiAttributeListPrint(fd,
							newAttrs, "");
					fclose(fd);
				} else {
					result = PAPI_NOT_POSSIBLE;
				}
			} else {
				result =
				    psm_modifyAttrsList(file, attrs, &newAttrs);

				fd = fopen(file, "w");
				if (fd != NULL) {
					papiAttributeListPrint(fd,
								newAttrs, "");
					fclose(fd);
				} else {
					result = PAPI_NOT_POSSIBLE;
				}

				papiAttributeListFree(newAttrs);
			}
		} else {
			result = PAPI_NOT_POSSIBLE;
		}
	}

	return (result);
} /* psm_modifyAttrsFile */
Exemple #2
0
static int
service_query(char *name, int (*report)(char *, papi_attribute_t **, int),
		papi_encryption_t encryption, int verbose)
{
	int result = 0;
	papi_status_t status;
	papi_service_t svc = NULL;
	papi_attribute_t **attrs = NULL;

	status = papiServiceCreate(&svc, name, NULL, NULL, cli_auth_callback,
					encryption, NULL);
	if (status != PAPI_OK) {
		papiServiceDestroy(svc);
		return (-1);
	}

	attrs = papiServiceGetAttributeList(svc);
	if (attrs != NULL) {
		result = report(name, attrs, verbose);

		if (verbose > 1) {
			printf("\n");
			papiAttributeListPrint(stdout, attrs, "\t");
			printf("\n");
		}
	}

	papiServiceDestroy(svc);

	return (result);
}
Exemple #3
0
papi_status_t
ipp_process_request(papi_attribute_t **request, papi_attribute_t ***response,
	ipp_reader_t iread, void *fd)
{
	papi_status_t result = PAPI_OK;

	ipp_initialize_response(request, response);

#ifdef DEBUG
	fprintf(stderr, "REQUEST:");
	papiAttributeListPrint(stderr, request, " %d  ", getpid());
	fprintf(stderr, "\n");
#endif

	/* verify that the request is "well-formed" */
	if ((result = ipp_validate_request(request, response)) == PAPI_OK) {
		papi_service_t svc = NULL;
		ipp_handler_t *handler;

		result = print_service_connect(&svc, request, response);
		handler = ipp_operation_handler(request, response);

		/* process the request */
		if ((result == PAPI_OK) && (handler != NULL))
			result = (handler)(svc, request, response, iread, fd);
#ifdef DEBUG
		fprintf(stderr, "RESULT: %s\n", papiStatusString(result));
#endif
		papiServiceDestroy(svc);
	}

	(void) papiAttributeListAddInteger(response, PAPI_ATTR_EXCL,
				"status-code", result);
	massage_response(request, *response);

#ifdef DEBUG
	fprintf(stderr, "RESPONSE:");
	papiAttributeListPrint(stderr, *response, " %d  ", getpid());
	fprintf(stderr, "\n");
#endif

	return (result);
}
Exemple #4
0
static papi_status_t
psm_copy_attrsToFile(papi_attribute_t **attrs, char *file)

{
	papi_status_t result = PAPI_OK;

	if ((attrs != NULL) && (*attrs != NULL)) {
		FILE *out = NULL;

		if ((out = fopen(file, "w")) != NULL) {
			papiAttributeListPrint(out, attrs, "");
			fclose(out);
		} else {
			result = PAPI_NOT_POSSIBLE;
		}
	}

	return (result);
} /* psm_copy_attrsToFile */
Exemple #5
0
int
main(int ac, char *av[])
{
	papi_status_t status;
	papi_service_t svc = NULL;
	papi_attribute_t **list = NULL;
	papi_encryption_t encryption = PAPI_ENCRYPT_NEVER;
	papi_job_t job = NULL;
	char prefetch[3];
	int prefetch_len = sizeof (prefetch);
	char *printer = NULL;
	char b = PAPI_TRUE;
	int copy = 0;
	int silent = 0;
	int dump = 0;
	int validate = 0;
	int modify = -1;
	int c;
	uid_t ruid;
	struct passwd *pw;

	(void) setlocale(LC_ALL, "");
	(void) textdomain("SUNW_OST_OSCMD");

	ruid = getuid();
	if ((pw = getpwuid(ruid)) != NULL)
		(void) initgroups(pw->pw_name, pw->pw_gid);
	(void) setuid(ruid);


	while ((c = getopt(ac, av, "DEH:P:S:T:cd:f:i:mn:o:pq:rst:Vwy:")) != EOF)
		switch (c) {
		case 'H':	/* handling */
			if (strcasecmp(optarg, "hold") == 0)
				papiAttributeListAddString(&list,
				    PAPI_ATTR_EXCL,
				    "job-hold-until", "indefinite");
			else if (strcasecmp(optarg, "immediate") == 0)
				papiAttributeListAddString(&list,
				    PAPI_ATTR_EXCL,
				    "job-hold-until", "no-hold");
			else
				papiAttributeListAddString(&list,
				    PAPI_ATTR_EXCL,
				    "job-hold-until", optarg);
			break;
		case 'P': {	/* page list */
			char buf[BUFSIZ];

			snprintf(buf, sizeof (buf), "page-ranges=%s", optarg);
			papiAttributeListFromString(&list,
			    PAPI_ATTR_EXCL, buf);
			}
			break;
		case 'S':	/* charset */
			papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
			    "lp-charset", optarg);
			break;
		case 'T':	/* type */
			papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
			    "document-format",
			    lp_type_to_mime_type(optarg));
			break;
		case 'D':	/* dump */
			dump = 1;
			break;
		case 'c':	/* copy */
			copy = 1;
			break;
		case 'd':	/* destination */
			printer = optarg;
			break;
		case 'f':	/* form */
			papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
			    "form", optarg);
			break;
		case 'i':	/* modify job */
			if ((get_printer_id(optarg, &printer, &modify) < 0) ||
			    (modify < 0)) {
				fprintf(stderr,
				    gettext("invalid request id: %s\n"),
				    optarg);
				exit(1);
			}
			break;
		case 'm':	/* mail when complete */
			papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL,
			    "rfc-1179-mail", 1);
			break;
		case 'n':	/* copies */
			papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL,
			    "copies", atoi(optarg));
			break;
		case 'o':	/* lp "options" */
			papiAttributeListFromString(&list,
			    PAPI_ATTR_REPLACE, optarg);
			break;
		case 'p':	/* Solaris - notification */
			papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL,
			    "rfc-1179-mail", 1);
			break;
		case 'q': {	/* priority */
			int i = atoi(optarg);

			i = 100 - (i * 2.5);
			if ((i < 1) || (i > 100)) {
				fprintf(stderr, gettext("UX:lp: "));
				fprintf(stderr, gettext("ERROR: "));
				fprintf(stderr, gettext("Bad priority"
				    " value \"%s\"."), optarg);
				fprintf(stderr, gettext("\n      "));
				fprintf(stderr, gettext("TO FIX"));
				fprintf(stderr, gettext(": "));
				fprintf(stderr, gettext("Use an integer value"
				    " from 0 to 39."));
				fprintf(stderr, gettext("\n"));
				exit(1);
			}
			papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL,
			    "job-priority", i);
			}
			break;
		case 'r':	/* "raw" mode */
			papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
			    "document-format",
			    "application/octet-stream");
			papiAttributeListAddString(&list, PAPI_ATTR_APPEND,
			    "stty", "raw");
			break;
		case 's':	/* suppress message */
			silent = 1;
			break;
		case 't':	/* title */
			papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
			    "job-name", optarg);
			break;
		case 'V':	/* validate */
			validate = 1;
			break;
		case 'w':
			papiAttributeListAddBoolean(&list, PAPI_ATTR_EXCL,
			    "rfc-1179-mail", 1);
			break;
		case 'y':	/* lp "modes" */
			papiAttributeListAddString(&list, PAPI_ATTR_APPEND,
			    "lp-modes", optarg);
			break;
		case 'E':
			encryption = PAPI_ENCRYPT_REQUIRED;
			break;
		default:
			usage(av[0]);
		}

	/* convert "banner", "nobanner" to "job-sheet" */
	if (papiAttributeListGetBoolean(list, NULL, "banner", &b) == PAPI_OK) {
		(void) papiAttributeListDelete(&list, "banner");
		if (b == PAPI_FALSE)
			papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
			    "job-sheets", "none");
	}

	if ((printer == NULL) &&
	    ((printer = getenv("PRINTER")) == NULL) &&
	    ((printer = getenv("LPDEST")) == NULL))
		printer = DEFAULT_DEST;

	if (((optind + 1) == ac) && (strcmp(av[optind], "-") == 0))
		optind = ac;

	if (modify == -1) {
		char *document_format = "text/plain";

		if (optind != ac) {
			/* get the mime type of the file data */
#ifdef MAGIC_MIME
			magic_t ms = NULL;

			if ((ms = magic_open(MAGIC_MIME)) != NULL) {
				document_format = magic_file(ms, av[optind]);
				magic_close(ms);
			}
#else
			if (is_postscript(av[optind]) == 1)
				document_format = "application/postscript";
#endif
		} else {
			if (is_postscript_stream(0, prefetch, &prefetch_len)
			    == 1)
				document_format = "application/postscript";
		}

		papiAttributeListAddInteger(&list, PAPI_ATTR_EXCL, "copies", 1);
		papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
		    "document-format", document_format);
		papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
		    "job-sheets", "standard");
	}

	status = papiServiceCreate(&svc, printer, NULL, NULL, cli_auth_callback,
	    encryption, NULL);
	if (status != PAPI_OK) {
		fprintf(stderr, gettext(
		    "Failed to contact service for %s: %s\n"), printer,
		    verbose_papi_message(svc, status));
		exit(1);
	}

	if (dump != 0) {
		printf("requesting attributes:\n");
		papiAttributeListPrint(stdout, list, "\t");
		printf("\n");
	}

	if (modify != -1)
		status = papiJobModify(svc, printer, modify, list, &job);
	else if (optind == ac)	/* no file list, use stdin */
		status = jobSubmitSTDIN(svc, printer, prefetch, prefetch_len,
		    list, &job);
	else if (validate == 1)	/* validate the request can be processed */
		status = papiJobValidate(svc, printer, list,
		    NULL, &av[optind], &job);
	else if (copy == 0)	/* reference the files in the job, default */
		status = papiJobSubmitByReference(svc, printer, list,
		    NULL, &av[optind], &job);
	else			/* copy the files before return, -c */
		status = papiJobSubmit(svc, printer, list,
		    NULL, &av[optind], &job);

	papiAttributeListFree(list);

	if (status != PAPI_OK) {
		fprintf(stderr, gettext("%s: %s\n"), printer,
		    verbose_papi_message(svc, status));
		papiJobFree(job);
		papiServiceDestroy(svc);
		exit(1);
	}

	if (((silent == 0) || (dump != 0)) &&
	    ((list = papiJobGetAttributeList(job)) != NULL)) {
		int32_t id = -1;

		if (printer == NULL)
			papiAttributeListGetString(list, NULL,
			    "printer-name", &printer);

		papiAttributeListGetInteger(list, NULL,
		    "job-id-requested", &id);
		if (id == -1) {
			papiAttributeListGetInteger(list, NULL, "job-id", &id);
		}

		printf(gettext("request id is %s-%d "), printer, id);
		if (ac != optind)
			printf("(%d file(s))\n", ac - optind);
		else
			printf("(standard input)\n");

		if (dump != 0) {
			printf("job attributes:\n");
			papiAttributeListPrint(stdout, list, "\t");
			printf("\n");
		}
	}

	papiJobFree(job);
	papiServiceDestroy(svc);

	return (0);
}
Exemple #6
0
static int
ipp_handler(request_rec *r)
{
	papi_attribute_t **request = NULL, **response = NULL;
	IPPListenerConfig *config;
	papi_status_t status;
	int ret;

	/* Really, IPP is all POST requests */
	if (r->method_number != M_POST)
		return (DECLINED);

#ifndef APACHE2
	/*
	 * An IPP request must have a MIME type of "application/ipp"
	 * (RFC-2910, Section 4, page 19).  If it doesn't match this
	 * MIME type, we should decline the request and let someone else
	 * try and handle it.
	 */
	if (r->headers_in != NULL) {
		char *mime_type = (char *)ap_table_get(r->headers_in,
							"Content-Type");

		if ((mime_type == NULL) ||
		    (strcasecmp(mime_type, "application/ipp") != 0))
			return (DECLINED);
	}
#endif
	/* CHUNKED_DECHUNK might not work right for IPP? */
	if ((ret = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)) != OK)
		return (ret);

	if (!ap_should_client_block(r))
		return (HTTP_INTERNAL_SERVER_ERROR);

#ifndef APACHE2
	ap_soft_timeout("ipp_module: read/reply request ", r);
#endif
	/* read the IPP request off the network */
	status = ipp_read_message(read_data, r, &request, IPP_TYPE_REQUEST);

	if (status != PAPI_OK)
		_log_rerror(APLOG_MARK, APLOG_ERR, r,
			"read failed: %s\n", papiStatusString(status));
#ifdef DEBUG
	papiAttributeListPrint(stderr, request, "request (%d)  ", getpid());
#endif

	(void) papiAttributeListAddString(&request, PAPI_ATTR_EXCL,
		"originating-host", (char *)
#ifdef APACHE2
		ap_get_remote_host
			(r->connection, r->per_dir_config, REMOTE_NAME, NULL));
#else
		ap_get_remote_host
			(r->connection, r->per_dir_config, REMOTE_NAME));
#endif

	(void) papiAttributeListAddInteger(&request, PAPI_ATTR_EXCL,
				"uri-port", ap_get_server_port(r));
	if (r->headers_in != NULL) {
		char *host = (char *)ap_table_get(r->headers_in, "Host");

		if ((host == NULL) || (host[0] == '\0'))
			host = (char *)ap_get_server_name(r);

		(void) papiAttributeListAddString(&request, PAPI_ATTR_EXCL,
				"uri-host", host);
	}
	(void) papiAttributeListAddString(&request, PAPI_ATTR_EXCL,
				"uri-path", r->uri);

	config = ap_get_module_config(r->per_dir_config, &ipp_module);
	if (config != NULL) {
		(void) papiAttributeListAddInteger(&request, PAPI_ATTR_EXCL,
				"conformance", config->conformance);
		(void) papiAttributeListAddCollection(&request, PAPI_ATTR_EXCL,
				"operations", config->operations);
		if (config->default_user != NULL)
			(void) papiAttributeListAddString(&request,
						PAPI_ATTR_EXCL, "default-user",
						config->default_user);
		if (config->default_svc != NULL)
			(void) papiAttributeListAddString(&request,
					PAPI_ATTR_EXCL, "default-service",
					config->default_svc);
	}

	/*
	 * For Trusted Solaris, pass the fd number of the socket connection
	 * to the backend so the it can be forwarded to the backend print
	 * service to retrieve the sensativity label off of a multi-level
	 * port.
	 */
	(void) papiAttributeListAddInteger(&request, PAPI_ATTR_EXCL,
			"peer-socket", ap_bfileno(r->connection->client, B_RD));

	/* process the request */
	status = ipp_process_request(request, &response, read_data, r);
	if (status != PAPI_OK) {
		errno = 0;
		_log_rerror(APLOG_MARK, APLOG_ERR, r,
			"request failed: %s\n", papiStatusString(status));
		discard_data(r);
	}
#ifdef DEBUG
	fprintf(stderr, "processing result: %s\n", papiStatusString(status));
	papiAttributeListPrint(stderr, response, "response (%d)  ", getpid());
#endif

	/*
	 * If the client is using chunking and we have not yet received the
	 * final "0" sized chunk, we need to discard any data that may
	 * remain in the post request.
	 */
	if ((r->read_chunked != 0) &&
	    (ap_table_get(r->headers_in, "Content-Length") == NULL))
		discard_data(r);

	/* write an IPP response back to the network */
	r->content_type = "application/ipp";

#ifndef	APACHE2
	ap_send_http_header(r);
#endif

	status = ipp_write_message(write_data, r, response);
	if (status != PAPI_OK)
		_log_rerror(APLOG_MARK, APLOG_ERR, r,
			"write failed: %s\n", papiStatusString(status));
#ifdef DEBUG
	fprintf(stderr, "write result: %s\n", papiStatusString(status));
	fflush(stderr);
#endif

	papiAttributeListFree(request);
	papiAttributeListFree(response);

#ifndef APACHE2
	ap_kill_timeout(r);
	if (ap_rflush(r) < 0)
		_log_rerror(APLOG_MARK, APLOG_ERR, r,
			"flush failed, response may not have been sent");
#endif

	return (OK);
}
Exemple #7
0
static int
report_job(papi_job_t job, int show_rank, int verbose)
{
	papi_attribute_t **attrs = papiJobGetAttributeList(job);
	time_t clock = 0;
	char date[24];
	char request[26];
	char *user = "******";
	int32_t size = 0;
	int32_t jstate = 0;

	char *destination = "unknown";
	int32_t id = -1;

	(void) papiAttributeListGetString(attrs, NULL,
				"job-originating-user-name", &user);

	if ((users != NULL) && (match_user(user, users) < 0))
		return (0);

	(void) papiAttributeListGetInteger(attrs, NULL, "job-k-octets", &size);
	size *= 1024;	/* for the approximate byte size */
	(void) papiAttributeListGetInteger(attrs, NULL, "job-octets", &size);

	(void) time(&clock);
	(void) papiAttributeListGetInteger(attrs, NULL,
				"time-at-creation", (int32_t *)&clock);
	(void) strftime(date, sizeof (date), "%b %d %R", localtime(&clock));

	(void) papiAttributeListGetString(attrs, NULL,
				"job-printer-uri", &destination);
	(void) papiAttributeListGetString(attrs, NULL,
				"printer-name", &destination);
	(void) papiAttributeListGetInteger(attrs, NULL,
				"job-id", &id);
	snprintf(request, sizeof (request), "%s-%d", destination, id);

	if (show_rank != 0) {
		int32_t rank = -1;

		(void) papiAttributeListGetInteger(attrs, NULL,
				"number-of-intervening-jobs", &rank);
		rank++;

		printf("%3d %-21s %-14s %7ld %s",
			rank, request, user, size, date);
	} else
		printf("%-23s %-14s %7ld   %s", request, user, size, date);

	(void) papiAttributeListGetInteger(attrs, NULL,
				"job-state", &jstate);
	if (jstate == 0x04)
		printf(gettext(", being held"));
	else if (jstate == 0x07)
		printf(gettext(", cancelled"));
	else if (jstate == 0x09)
		printf(gettext(", complete"));

	if (verbose == 1) {
		(void) papiAttributeListGetString(attrs, NULL,
				"output-device-assigned", &destination);
		printf("\n\t assigned %s", destination);
	} else if (verbose > 1) {
		printf("\n");
		papiAttributeListPrint(stdout, attrs, "\t");
	}

	printf("\n");

	return (0);
}
Exemple #8
0
/* ARGSUSED2 */
static int
report_printer(papi_service_t svc, char *name, papi_printer_t printer,
		int verbose, int description)
{
	papi_status_t status;
	papi_attribute_t **attrs = papiPrinterGetAttributeList(printer);
	time_t curr;
	int32_t pstat = 0;
	char *member = NULL;

	status = papiAttributeListGetString(attrs, NULL,
				"member-names", &member);
	if (status == PAPI_OK)	/* it's a class */
		return (0);

	if (name == NULL) {
		status = papiAttributeListGetString(attrs, NULL,
					"printer-name", &name);
		if (status != PAPI_OK)
			status = papiAttributeListGetString(attrs, NULL,
					"printer-uri-supported", &name);
	}
	if (name == NULL)
		return (-1);

	printf(gettext("printer %s "), name);

	status = papiAttributeListGetInteger(attrs, NULL,
					"printer-state", &pstat);

	switch (pstat) {
	case 0x03:	/* idle */
		printf(gettext("idle. enabled"));
		break;
	case 0x04: {	/* processing */
		char *requested[] = { "job-id", NULL };
		papi_job_t *j = NULL;
		int32_t jobid = 0;

		(void) papiPrinterListJobs(svc, name, requested, 0, 1, &j);
		if ((j != NULL) && (j[0] != NULL))
			jobid = papiJobGetId(j[0]);
		papiJobListFree(j);

		printf(gettext("now printing %s-%d. enabled"), name, jobid);
		}
		break;
	case 0x05:	/* stopped */
		printf(gettext("disabled"));
		break;
	default:
		printf(gettext("unknown state(0x%x)."), pstat);
		break;
	}

	(void) time(&curr);
	(void) papiAttributeListGetDatetime(attrs, NULL,
					"printer-up-time", &curr);
	(void) papiAttributeListGetDatetime(attrs, NULL,
					"printer-state-time", &curr);
	(void) papiAttributeListGetDatetime(attrs, NULL,
					"lpsched-disable-date", &curr);
	printf(gettext(" since %s. available.\n"), nctime(&curr));

	if (pstat == 0x05) {
		char *reason = "unknown reason";

		(void) papiAttributeListGetString(attrs, NULL,
					"printer-state-reasons", &reason);
		(void) papiAttributeListGetString(attrs, NULL,
					"lpsched-disable-reason", &reason);
		printf(gettext("\t%s\n"), reason);
	}

	if (verbose == 1) {
		void *iter;
		char *str;

		str = "";
		(void) papiAttributeListGetString(attrs, NULL,
					"form-ready", &str);
		printf(gettext("\tForm mounted: %s\n"), str);

		str = "";
		iter = NULL;
		(void) papiAttributeListGetString(attrs, &iter,
					"document-format-supported", &str);
		printf(gettext("\tContent types: %s"), str);
		while (papiAttributeListGetString(attrs, &iter, NULL, &str)
				== PAPI_OK)
			printf(", %s", str);
		printf("\n");

		str = "";
		(void) papiAttributeListGetString(attrs, NULL,
					"printer-info", &str);
		printf(gettext("\tDescription: %s\n"), str);

		str = "";
		(void) papiAttributeListGetString(attrs, NULL,
					"lpsched-dial-info", &str);
		printf(gettext("\tConnection: %s\n"),
			((str[0] != '\0') ? gettext("direct") : str));

		str = "";
		(void) papiAttributeListGetString(attrs, NULL,
					"lpsched-interface-script", &str);
		printf(gettext("\tInterface: %s\n"), str);

		str = NULL;
		(void) papiAttributeListGetString(attrs, NULL,
					"ppd-file-uri", &str);
		(void) papiAttributeListGetString(attrs, NULL,
					"lpsched-ppd-source-path", &str);
		if (str != NULL)
			printf(gettext("\tPPD: %s\n"), str);

		str = NULL;
		(void) papiAttributeListGetString(attrs, NULL,
					"lpsched-fault-alert-command", &str);
		if (str != NULL)
			printf(gettext("\tOn fault: %s\n"), str);

		str = "";
		(void) papiAttributeListGetString(attrs, NULL,
					"lpsched-fault-recovery", &str);
		printf(gettext("\tAfter fault: %s\n"),
			((str[0] == '\0') ? gettext("continue") : str));

		str = "(all)";
		iter = NULL;
		(void) papiAttributeListGetString(attrs, &iter,
					"requesting-user-name-allowed", &str);
		printf(gettext("\tUsers allowed:\n\t\t%s\n"),
			((str[0] == '\0') ? gettext("(none)") : str));
		if ((str != NULL) && (str[0] != '\0'))
			while (papiAttributeListGetString(attrs, &iter, NULL,
					&str) == PAPI_OK)
				printf("\t\t%s\n", str);

		str = NULL;
		iter = NULL;
		(void) papiAttributeListGetString(attrs, &iter,
					"requesting-user-name-denied", &str);
		if (str != NULL) {
			printf(gettext("\tUsers denied:\n\t\t%s\n"),
				((str[0] == '\0') ? gettext("(none)") : str));
			if ((str != NULL) && (str[0] != '\0'))
				while (papiAttributeListGetString(attrs, &iter,
						NULL, &str) == PAPI_OK)
					printf("\t\t%s\n", str);
		}

		str = "(none)";
		iter = NULL;
		(void) papiAttributeListGetString(attrs, &iter,
					"form-supported", &str);
		printf(gettext("\tForms allowed:\n\t\t%s\n"),
			((str[0] == '\0') ? gettext("(none)") : str));
		if ((str != NULL) && (str[0] != '\0'))
			while (papiAttributeListGetString(attrs, &iter, NULL,
					&str) == PAPI_OK)
				printf("\t\t%s\n", str);

		str = "";
		iter = NULL;
		(void) papiAttributeListGetString(attrs, &iter,
					"media-supported", &str);
		printf(gettext("\tMedia supported:\n\t\t%s\n"),
			((str[0] == '\0') ? gettext("(none)") : str));
		if ((str != NULL) && (str[0] != '\0'))
			while (papiAttributeListGetString(attrs, &iter, NULL,
					&str) == PAPI_OK)
				printf("\t\t%s\n", str);

		str = "";
		(void) papiAttributeListGetString(attrs, NULL,
					"job-sheets-supported", &str);
		printf(gettext("\tBanner %s\n"),
			(strcasecmp(str, "none") == 0 ?
				gettext("not required") : gettext("required")));

		str = "";
		iter = NULL;
		(void) papiAttributeListGetString(attrs, &iter,
					"lpsched-print-wheels", &str);
		printf(gettext("\tCharacter sets:\n\t\t%s\n"),
			((str[0] == '\0') ? gettext("(none)") : str));
		if ((str != NULL) && (str[0] != '\0'))
			while (papiAttributeListGetString(attrs, &iter, NULL,
					&str) == PAPI_OK)
				printf("\t\t%s\n", str);

		printf(gettext("\tDefault pitch:\n"));
		printf(gettext("\tDefault page size:\n"));
		printf(gettext("\tDefault port setting:\n"));

		str = "";
		iter = NULL;
		(void) papiAttributeListGetString(attrs, &iter,
					"lpsched-options", &str);
		if (str != NULL) {
			printf(gettext("\tOptions: %s"), str);
			while (papiAttributeListGetString(attrs, &iter, NULL,
						&str) == PAPI_OK)
				printf(", %s", str);
			printf("\n");
		}

	} else if (description == 1) {
		char *str = "";
		(void) papiAttributeListGetString(attrs, NULL,
					"printer-description", &str);
		printf(gettext("\tDescription: %s\n"), str);
	} else if (verbose > 1)
		papiAttributeListPrint(stdout, attrs, "\t");

	if (verbose > 0)
		printf("\n");

	return (0);
}