summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/lp/lib/papi/lpsched-msgs.c63
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/accept.c27
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/disable.c10
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/enable.c25
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/reject.c26
5 files changed, 91 insertions, 60 deletions
diff --git a/usr/src/cmd/lp/lib/papi/lpsched-msgs.c b/usr/src/cmd/lp/lib/papi/lpsched-msgs.c
index b7646151b0..2d64912d08 100644
--- a/usr/src/cmd/lp/lib/papi/lpsched-msgs.c
+++ b/usr/src/cmd/lp/lib/papi/lpsched-msgs.c
@@ -20,11 +20,10 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
@@ -64,18 +63,19 @@ snd_msg(service_t *svc, int type, ...)
va_end(ap);
if (rc < 0) {
detailed_error(svc,
- gettext("unable to build message for scheduler: %s"),
- strerror(errno));
+ gettext("unable to build message for scheduler: %s"),
+ strerror(errno));
return (rc);
}
/* write the message */
- while (((rc = mwrite(svc->md, svc->msgbuf)) < 0) && (errno == EINTR));
+ while (((rc = mwrite(svc->md, svc->msgbuf)) < 0) && (errno == EINTR)) {
+ }
if (rc < 0)
detailed_error(svc,
- gettext("unable to send message to scheduler: %s"),
- strerror(errno));
+ gettext("unable to send message to scheduler: %s"),
+ strerror(errno));
return (rc);
}
@@ -92,12 +92,13 @@ rcv_msg(service_t *svc, int type, ...)
/* read the message */
while (((rc = mread(svc->md, svc->msgbuf, svc->msgbuf_size)) < 0) &&
- (errno == EINTR));
+ (errno == EINTR)) {
+ }
if (rc < 0)
detailed_error(svc,
- gettext("unable to read message from scheduler: %s"),
- strerror(errno));
+ gettext("unable to read message from scheduler: %s"),
+ strerror(errno));
else {
va_list ap;
@@ -108,7 +109,7 @@ rcv_msg(service_t *svc, int type, ...)
if (rc < 0)
detailed_error(svc,
gettext("unable to parse message from scheduler: %s"),
- strerror(errno));
+ strerror(errno));
}
return (rc);
@@ -182,7 +183,7 @@ lpsched_status_string(short status)
static char result[16];
snprintf(result, sizeof (result), gettext("status: %d"),
- status);
+ status);
return (result);
}
}
@@ -204,7 +205,7 @@ lpsched_alloc_files(papi_service_t svc, int number, char **prefix)
if (status != MOK) {
detailed_error(svc,
gettext("failed to allocate %d file(s) for request: %s"),
- number, lpsched_status_string(status));
+ number, lpsched_status_string(status));
result = lpsched_status_to_papi_status(status);
}
@@ -258,8 +259,8 @@ lpsched_start_change(papi_service_t svc, char *printer, int32_t job_id,
if (status != MOK) {
detailed_error(svc,
gettext("failed to initiate change for job (%s-%d): %s"),
- printer,
- job_id, lpsched_status_string(status));
+ printer,
+ job_id, lpsched_status_string(status));
result = lpsched_status_to_papi_status(status);
}
@@ -289,7 +290,7 @@ lpsched_end_change(papi_service_t svc, char *printer, int32_t job_id)
if (status != MOK) {
detailed_error(svc,
gettext("failed to commit change for job (%s-%d): %s"), printer,
- job_id, lpsched_status_string(status));
+ job_id, lpsched_status_string(status));
result = lpsched_status_to_papi_status(status);
}
@@ -300,7 +301,7 @@ papi_status_t
lpsched_accept_printer(papi_service_t svc, char *printer)
{
papi_status_t result = PAPI_OK;
- short status;
+ short status = MOK;
char *req_id;
char *dest;
@@ -315,9 +316,9 @@ lpsched_accept_printer(papi_service_t svc, char *printer)
if ((status != MOK) && (status != MERRDEST)) {
detailed_error(svc, "%s: %s", printer,
- lpsched_status_string(status));
- result = lpsched_status_to_papi_status(status);
+ lpsched_status_string(status));
}
+ result = lpsched_status_to_papi_status(status);
return (result);
}
@@ -326,7 +327,7 @@ papi_status_t
lpsched_reject_printer(papi_service_t svc, char *printer, char *message)
{
papi_status_t result = PAPI_OK;
- short status;
+ short status = MOK;
char *req_id;
char *dest;
@@ -344,9 +345,9 @@ lpsched_reject_printer(papi_service_t svc, char *printer, char *message)
if ((status != MOK) && (status != MERRDEST)) {
detailed_error(svc, "%s: %s", printer,
- lpsched_status_string(status));
- result = lpsched_status_to_papi_status(status);
+ lpsched_status_string(status));
}
+ result = lpsched_status_to_papi_status(status);
return (result);
}
@@ -355,7 +356,7 @@ papi_status_t
lpsched_enable_printer(papi_service_t svc, char *printer)
{
papi_status_t result = PAPI_OK;
- short status;
+ short status = MOK;
char *req_id;
char *dest;
@@ -370,9 +371,9 @@ lpsched_enable_printer(papi_service_t svc, char *printer)
if ((status != MOK) && (status != MERRDEST)) {
detailed_error(svc, "%s: %s", printer,
- lpsched_status_string(status));
- result = lpsched_status_to_papi_status(status);
+ lpsched_status_string(status));
}
+ result = lpsched_status_to_papi_status(status);
return (result);
}
@@ -381,7 +382,7 @@ papi_status_t
lpsched_disable_printer(papi_service_t svc, char *printer, char *message)
{
papi_status_t result = PAPI_OK;
- short status;
+ short status = MOK;
char *req_id;
char *dest;
@@ -399,9 +400,9 @@ lpsched_disable_printer(papi_service_t svc, char *printer, char *message)
if ((status != MOK) && (status != MERRDEST)) {
detailed_error(svc, "%s: %s", printer,
- lpsched_status_string(status));
- result = lpsched_status_to_papi_status(status);
+ lpsched_status_string(status));
}
+ result = lpsched_status_to_papi_status(status);
return (result);
}
@@ -463,7 +464,7 @@ remove_from_class(papi_service_t handle, char *dest, CLASS *cls)
if (cls->members != NULL) {
if (putclass(cls->name, cls) == 0)
(void) lpsched_load_unload_dest(handle,
- cls->name, S_LOAD_CLASS);
+ cls->name, S_LOAD_CLASS);
} else
(void) lpsched_remove_class(handle, cls->name);
}
@@ -516,10 +517,10 @@ lpsched_add_modify_class(papi_service_t handle, char *dest,
* members. Anything else will be ignored.
*/
for (result = papiAttributeListGetString(attributes, &iter,
- "member-names", &member);
+ "member-names", &member);
result == PAPI_OK;
result = papiAttributeListGetString(attributes, &iter,
- NULL, &member))
+ NULL, &member))
addlist(&members, member);
if (members != NULL) {
diff --git a/usr/src/cmd/print/bsd-sysv-commands/accept.c b/usr/src/cmd/print/bsd-sysv-commands/accept.c
index c20f9344de..903d7728ba 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/accept.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/accept.c
@@ -20,15 +20,13 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: accept.c 146 2006-03-24 00:26:54Z njacobs $ */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -49,8 +47,8 @@ usage(char *program)
name++;
fprintf(stdout,
- gettext("Usage: %s destination ...\n"),
- name);
+ gettext("Usage: %s destination ...\n"),
+ name);
exit(1);
}
@@ -82,18 +80,27 @@ main(int ac, char *av[])
char *printer = av[c];
status = papiServiceCreate(&svc, printer, NULL, NULL,
- cli_auth_callback, encryption, 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));
+ "Failed to contact service for %s: %s\n"),
+ printer, verbose_papi_message(svc, status));
exit_status = 1;
}
status = papiPrinterResume(svc, printer);
- if (status != PAPI_OK) {
+ if (status == PAPI_OK) {
+ printf(gettext(
+ "Destination \"%s\" now accepting requests\n"),
+ printer);
+ } else if (status == PAPI_NOT_ACCEPTING) {
+ fprintf(stderr, gettext(
+ "Destination \"%s\" was already "
+ "accepting requests.\n"), printer);
+ exit_status = 1;
+ } else {
fprintf(stderr, gettext("accept: %s: %s\n"), printer,
- verbose_papi_message(svc, status));
+ verbose_papi_message(svc, status));
exit_status = 1;
}
diff --git a/usr/src/cmd/print/bsd-sysv-commands/disable.c b/usr/src/cmd/print/bsd-sysv-commands/disable.c
index d57abe5728..95f6dbd230 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/disable.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/disable.c
@@ -132,7 +132,15 @@ main(int ac, char *av[])
}
status = papiPrinterDisable(svc, printer, reason);
- if (status != PAPI_OK) {
+ if (status == PAPI_OK) {
+ printf(gettext("printer \"%s\" now disabled\n"),
+ printer);
+ } else if (status == PAPI_NOT_ACCEPTING) {
+ fprintf(stderr, gettext(
+ "Destination \"%s\" was already disabled.\n"),
+ printer);
+ exit_status = 1;
+ } else {
fprintf(stderr, gettext("disable: %s: %s\n"), printer,
verbose_papi_message(svc, status));
exit_status = 1;
diff --git a/usr/src/cmd/print/bsd-sysv-commands/enable.c b/usr/src/cmd/print/bsd-sysv-commands/enable.c
index 1bf7a0ccce..f67ace102c 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/enable.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/enable.c
@@ -20,14 +20,13 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: enable.c 146 2006-03-24 00:26:54Z njacobs $ */
-#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
@@ -49,8 +48,8 @@ usage(char *program)
name++;
fprintf(stdout,
- gettext("Usage: %s destination ...\n"),
- name);
+ gettext("Usage: %s destination ...\n"),
+ name);
exit(1);
}
@@ -82,18 +81,26 @@ main(int ac, char *av[])
char *printer = av[c];
status = papiServiceCreate(&svc, printer, NULL, NULL,
- cli_auth_callback, encryption, 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));
+ "Failed to contact service for %s: %s\n"),
+ printer, verbose_papi_message(svc, status));
exit_status = 1;
}
status = papiPrinterEnable(svc, printer);
- if (status != PAPI_OK) {
+ if (status == PAPI_OK) {
+ printf(gettext("printer \"%s\" now enabled\n"),
+ printer);
+ } else if (status == PAPI_NOT_ACCEPTING) {
+ fprintf(stderr, gettext(
+ "Destination \"%s\" was already enabled.\n"),
+ printer);
+ exit_status = 1;
+ } else {
fprintf(stderr, gettext("enable: %s: %s\n"), printer,
- verbose_papi_message(svc, status));
+ verbose_papi_message(svc, status));
exit_status = 1;
}
diff --git a/usr/src/cmd/print/bsd-sysv-commands/reject.c b/usr/src/cmd/print/bsd-sysv-commands/reject.c
index 58eb2829d0..777172f2fa 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/reject.c
+++ b/usr/src/cmd/print/bsd-sysv-commands/reject.c
@@ -20,14 +20,13 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: reject.c 146 2006-03-24 00:26:54Z njacobs $ */
-#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
@@ -49,8 +48,8 @@ usage(char *program)
name++;
fprintf(stdout,
- gettext("Usage: %s destination ...\n"),
- name);
+ gettext("Usage: %s destination ...\n"),
+ name);
exit(1);
}
@@ -86,18 +85,27 @@ main(int ac, char *av[])
char *printer = av[optind++];
status = papiServiceCreate(&svc, printer, NULL, NULL,
- cli_auth_callback, encryption, 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));
+ "Failed to contact service for %s: %s\n"),
+ printer, verbose_papi_message(svc, status));
exit_status = 1;
}
status = papiPrinterPause(svc, printer, reason);
- if (status != PAPI_OK) {
+ if (status == PAPI_OK) {
+ printf(gettext(
+ "Destination \"%s\" will no longer "
+ "accept requests\n"), printer);
+ } else if (status == PAPI_NOT_ACCEPTING) {
+ fprintf(stderr, gettext(
+ "Destination \"%s\" was already not "
+ "accepting requests.\n"), printer);
+ exit_status = 1;
+ } else {
fprintf(stderr, gettext("reject: %s: %s\n"), printer,
- verbose_papi_message(svc, status));
+ verbose_papi_message(svc, status));
exit_status = 1;
}