diff options
author | sonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM> | 2009-01-13 01:34:36 -0800 |
---|---|---|
committer | sonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM> | 2009-01-13 01:34:36 -0800 |
commit | f7c8cd012c28272538f8d60411ba60f8d136dfa7 (patch) | |
tree | 4aa2c39f3c1414f33f264f1faf420305716b9cf6 /usr/src/cmd/print/bsd-sysv-commands | |
parent | cf73e6ab4b17d3ab02ba5c9cfec155e4d6d8ff22 (diff) | |
download | illumos-joyent-f7c8cd012c28272538f8d60411ba60f8d136dfa7.tar.gz |
6759910 lpstat doesn't display (-D) Description
Diffstat (limited to 'usr/src/cmd/print/bsd-sysv-commands')
-rw-r--r-- | usr/src/cmd/print/bsd-sysv-commands/lpstat.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c index cd69b4efed..0f644fdc44 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c +++ b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * */ @@ -157,6 +157,43 @@ get_device_uri(papi_service_t svc, char *name) return (result); } +static void +print_description(papi_attribute_t **list, char *printer_name) +{ + char *str = ""; + + (void) papiAttributeListGetString(list, NULL, + "printer-info", &str); + + /* + * If no printer-info is read then + * by default the printer-info is <printer-name>@<server> + */ + if (str[0] == '\0') { + char *uri = NULL; + uri_t *u = NULL; + + (void) papiAttributeListGetString(list, NULL, + "printer-uri-supported", &uri); + + if ((uri != NULL) && (uri_from_string(uri, &u) == 0)) { + char *nodename = localhostname(); + + if ((u->host == NULL) || + (strcasecmp(u->host, "localhost") == 0) || + (strcasecmp(u->host, nodename) == 0)) + printf(gettext("\tDescription:\n")); + else + printf(gettext("\tDescription: %s@%s\n"), + printer_name, u->host); + + uri_free(u); + } else + printf(gettext("\tDescription:\n")); + } else + printf(gettext("\tDescription: %s\n"), str); +} + static char *report_device_keys[] = { "printer-name", "printer-uri-supported", NULL }; /* ARGSUSED2 */ @@ -391,10 +428,8 @@ report_printer(papi_service_t svc, char *name, papi_printer_t printer, printf(", %s", str); printf("\n"); - str = ""; - (void) papiAttributeListGetString(attrs, NULL, - "printer-info", &str); - printf(gettext("\tDescription: %s\n"), str); + /* Display the printer description */ + print_description(attrs, name); str = ""; iter = NULL; @@ -523,12 +558,10 @@ report_printer(papi_service_t svc, char *name, papi_printer_t printer, 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) + } else if (description == 1) + /* Display printer description */ + print_description(attrs, name); + else if (verbose > 1) papiAttributeListPrint(stdout, attrs, "\t"); if (verbose > 0) |