diff options
author | sonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM> | 2009-03-23 23:26:09 -0700 |
---|---|---|
committer | sonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM> | 2009-03-23 23:26:09 -0700 |
commit | 3d09a4fec6be19a6f09e277d5d5d17942bb4abf4 (patch) | |
tree | e494bd339b4d362c20d064d041407385b34066e0 /usr/src/cmd/print/bsd-sysv-commands/lpstat.c | |
parent | 546a399722fe82dc300c308a8fb86a11d2ca3ba3 (diff) | |
download | illumos-gate-3d09a4fec6be19a6f09e277d5d5d17942bb4abf4.tar.gz |
6789790 'lpstat -o' doesnot display the host-info along with the owner of the request with ipp service
Diffstat (limited to 'usr/src/cmd/print/bsd-sysv-commands/lpstat.c')
-rw-r--r-- | usr/src/cmd/print/bsd-sysv-commands/lpstat.c | 74 |
1 files changed, 70 insertions, 4 deletions
diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c index ecf5d0b54f..4ba932cc91 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c +++ b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c @@ -700,6 +700,8 @@ report_job(papi_job_t job, int show_rank, int verbose) char *destination = "unknown"; int32_t id = -1; + static int check = 0; + static char *uri = NULL; (void) papiAttributeListGetString(attrs, NULL, "job-originating-user-name", &user); @@ -710,11 +712,75 @@ report_job(papi_job_t job, int show_rank, int verbose) (void) papiAttributeListGetString(attrs, NULL, "job-originating-host-name", &host); - if (host) - snprintf(User, sizeof (User), "%s@%s", user, host); - else - snprintf(User, sizeof (User), "%s", user); + if (check == 0) { + /* + * Read the attribute "job-printer-uri" + * just once + */ + (void) papiAttributeListGetString(attrs, NULL, + "job-printer-uri", &uri); + check = 1; + } + + if (host) { + /* Check if it is local printer or remote printer */ + uri_t *u = NULL; + + 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)) { + if (strcasecmp(host, nodename) == 0) { + /* + * Request submitted locally + * for the local queue. + * Hostname will not be displayed + */ + snprintf(User, sizeof (User), "%s", + user); + } + else + snprintf(User, sizeof (User), "%s@%s", + user, host); + } else if (uri != NULL) { + /* + * It's a remote printer. + * In case of remote printers hostname is + * always displayed. + */ + snprintf(User, sizeof (User), "%s@%s", + user, host); + } + uri_free(u); + } else { + /* + * If attribute "job-printer-uri" + * cannot be read + * by default append the hostname + */ + snprintf(User, sizeof (User), "%s@%s", user, host); + } + } else { + /* + * When print server is s10u4 and ipp service is used + * "job-originating-hostname" attribute is not set + * So get the host information from the uri + */ + uri_t *u = NULL; + if ((uri != NULL) && (uri_from_string(uri, &u) == 0)) { + if ((u != NULL) && (u->host != NULL)) + snprintf(User, sizeof (User), "%s@%s", + user, u->host); + else + snprintf(User, sizeof (User), "%s", user); + + uri_free(u); + } else + snprintf(User, sizeof (User), "%s", user); + } (void) papiAttributeListGetInteger(attrs, NULL, "job-k-octets", &size); size *= 1024; /* for the approximate byte size */ (void) papiAttributeListGetInteger(attrs, NULL, "job-octets", &size); |