4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/types.h>
44 extern int optind
, opterr
, optopt
;
45 extern char *getenv(const char *);
51 (void) fprintf(stderr
,
52 gettext("Usage: %s [-k key] [list|(printer) ...]\n"),
58 display_kvp(char *key
, char *value
)
64 (void) printf("\n\t%s=%s", key
, value
);
66 (void) printf(gettext("\n\t%s - undefined"), key
);
73 display_value(ns_printer_t
*printer
, char *name
, char **keys
)
77 if (printer
!= NULL
) {
79 (void) printf("%s:", name
);
81 while (*keys
!= NULL
) {
82 char *string
= ns_get_value_string(*keys
,
84 rc
+= display_kvp(*keys
, string
);
88 ns_kvp_t
**list
= printer
->attributes
;
90 for (list
= printer
->attributes
;
91 (list
!= NULL
&& *list
!= NULL
); list
++) {
93 if (((*list
)->key
[0] == '\t') ||
94 ((*list
)->key
[0] == ' '))
97 string
= ns_get_value_string((*list
)->key
,
99 rc
+= display_kvp((*list
)->key
, string
);
104 (void) printf(gettext("%s: Not Found\n"), name
);
111 * main() calls the appropriate routine to parse the command line arguments
112 * and then calls the local remove routine, followed by the remote remove
113 * routine to remove jobs.
116 main(int ac
, char *av
[])
124 (void) setlocale(LC_ALL
, "");
126 #if !defined(TEXT_DOMAIN)
127 #define TEXT_DOMAIN "SYS_TEST"
129 (void) textdomain(TEXT_DOMAIN
);
131 if ((program
= strrchr(av
[0], '/')) == NULL
)
136 openlog(program
, LOG_PID
, LOG_LPR
);
137 while ((c
= getopt(ac
, av
, "k:t:n:")) != EOF
)
141 keys
= (char **)list_append((void **)keys
,
154 ns
= normalize_ns_name(ns
);
156 while (optind
< ac
) {
157 char *name
= av
[optind
++];
159 if (strcmp(name
, "list") == 0) {
160 ns_printer_t
**printers
= ns_printer_get_list(ns
);
162 while (printers
!= NULL
&& *printers
!= NULL
) {
163 exit_code
+= display_value(*printers
,
164 (*printers
)->name
, keys
);
168 exit_code
= display_value(ns_printer_get_name(name
, ns
),