2 * "$Id: lpstat.c 7921 2008-09-10 15:42:24Z mike $"
4 * "lpstat" command for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2008 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * main() - Parse options and show status information.
18 * check_dest() - Verify that the named destination(s) exists.
19 * match_list() - Match a name from a list of comma or space-separated
21 * show_accepting() - Show acceptance status.
22 * show_classes() - Show printer classes.
23 * show_default() - Show default destination.
24 * show_devices() - Show printer devices.
25 * show_jobs() - Show active print jobs.
26 * show_printers() - Show printers.
27 * show_scheduler() - Show scheduler status.
31 * Include necessary headers...
37 #include <cups/http-private.h>
38 #include <cups/string.h>
39 #include <cups/cups.h>
40 #include <cups/i18n.h>
41 #include <cups/debug.h>
48 static void check_dest(const char *command
, const char *name
,
49 int *num_dests
, cups_dest_t
**dests
);
50 static int match_list(const char *list
, const char *name
);
51 static int show_accepting(const char *printers
, int num_dests
,
53 static int show_classes(const char *dests
);
54 static void show_default(cups_dest_t
*dest
);
55 static int show_devices(const char *printers
, int num_dests
,
57 static int show_jobs(const char *dests
, const char *users
, int long_status
,
58 int ranking
, const char *which
);
59 static int show_printers(const char *printers
, int num_dests
,
60 cups_dest_t
*dests
, int long_status
);
61 static void show_scheduler(void);
65 * 'main()' - Parse options and show status information.
69 main(int argc
, /* I - Number of command-line arguments */
70 char *argv
[]) /* I - Command-line arguments */
72 int i
, /* Looping var */
73 status
; /* Exit status */
74 int num_dests
; /* Number of user destinations */
75 cups_dest_t
*dests
; /* User destinations */
76 int long_status
; /* Long status report? */
77 int ranking
; /* Show job ranking? */
78 const char *which
; /* Which jobs to show? */
79 char op
; /* Last operation on command-line */
85 * Parse command-line options...
93 which
= "not-completed";
96 for (i
= 1; i
< argc
; i
++)
97 if (argv
[i
][0] == '-')
100 case 'D' : /* Show description */
104 case 'E' : /* Encrypt */
106 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
108 _cupsLangPrintf(stderr
,
109 _("%s: Sorry, no encryption support compiled in!\n"),
111 #endif /* HAVE_SSL */
114 case 'H' : /* Show server and port */
115 if (cupsServer()[0] == '/')
116 _cupsLangPrintf(stdout
, "%s\n", cupsServer());
118 _cupsLangPrintf(stdout
, "%s:%d\n", cupsServer(), ippPort());
121 case 'P' : /* Show paper types */
125 case 'R' : /* Show ranking */
129 case 'S' : /* Show charsets */
135 case 'U' : /* Username */
137 cupsSetUser(argv
[i
] + 2);
143 _cupsLangPrintf(stderr
,
144 _("%s: Error - expected username after "
150 cupsSetUser(argv
[i
]);
154 case 'W' : /* Show which jobs? */
163 _cupsLangPrintf(stderr
,
164 _("%s: Error - need \"completed\", "
165 "\"not-completed\", or \"all\" after "
174 if (strcmp(which
, "completed") && strcmp(which
, "not-completed") &&
175 strcmp(which
, "all"))
177 _cupsLangPrintf(stderr
,
178 _("%s: Error - need \"completed\", "
179 "\"not-completed\", or \"all\" after "
186 case 'a' : /* Show acceptance status */
191 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
193 status
|= show_accepting(argv
[i
] + 2, num_dests
, dests
);
195 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
199 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
201 status
|= show_accepting(argv
[i
], num_dests
, dests
);
207 cupsFreeDests(num_dests
, dests
);
208 num_dests
= cupsGetDests(&dests
);
211 status
|= show_accepting(NULL
, num_dests
, dests
);
216 case 'b' : /* Show both the local and remote status */
222 * The local and remote status are separated by a blank line;
223 * since all CUPS jobs are networked, we only output the
224 * second list for now... In the future, we might further
225 * emulate this by listing the remote server's queue, but
226 * for now this is enough to make the SGI printstatus program
230 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
233 status
|= show_jobs(argv
[i
] + 2, NULL
, 3, ranking
, which
);
237 _cupsLangPrintf(stderr
,
238 _("%s: Error - expected destination after "
247 case 'c' : /* Show classes and members */
252 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
254 status
|= show_classes(argv
[i
] + 2);
256 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
260 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
262 status
|= show_classes(argv
[i
]);
265 status
|= show_classes(NULL
);
268 case 'd' : /* Show default destination */
271 if (num_dests
!= 1 || !dests
[0].is_default
)
273 cupsFreeDests(num_dests
, dests
);
275 dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, NULL
, NULL
);
276 num_dests
= dests
? 1 : 0;
282 case 'f' : /* Show forms */
288 case 'h' : /* Connect to host */
290 cupsSetServer(argv
[i
] + 2);
297 _cupsLangPrintf(stderr
,
298 _("%s: Error - expected hostname after "
304 cupsSetServer(argv
[i
]);
308 case 'l' : /* Long status or long job status */
314 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
316 status
|= show_jobs(argv
[i
] + 2, NULL
, 3, ranking
, which
);
323 case 'o' : /* Show jobs by destination */
328 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
330 status
|= show_jobs(argv
[i
] + 2, NULL
, long_status
, ranking
,
333 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
337 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
339 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
342 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
345 case 'p' : /* Show printers */
350 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
352 status
|= show_printers(argv
[i
] + 2, num_dests
, dests
,
355 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
359 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
361 status
|= show_printers(argv
[i
], num_dests
, dests
, long_status
);
367 cupsFreeDests(num_dests
, dests
);
368 num_dests
= cupsGetDests(&dests
);
371 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
375 case 'r' : /* Show scheduler status */
381 case 's' : /* Show summary */
386 cupsFreeDests(num_dests
, dests
);
387 num_dests
= cupsGetDests(&dests
);
390 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
391 status
|= show_classes(NULL
);
392 status
|= show_devices(NULL
, num_dests
, dests
);
395 case 't' : /* Show all info */
400 cupsFreeDests(num_dests
, dests
);
401 num_dests
= cupsGetDests(&dests
);
405 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
406 status
|= show_classes(NULL
);
407 status
|= show_devices(NULL
, num_dests
, dests
);
408 status
|= show_accepting(NULL
, num_dests
, dests
);
409 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
410 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
413 case 'u' : /* Show jobs by user */
417 status
|= show_jobs(NULL
, argv
[i
] + 2, long_status
, ranking
,
419 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
422 status
|= show_jobs(NULL
, argv
[i
], long_status
, ranking
, which
);
425 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
428 case 'v' : /* Show printer devices */
433 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
435 status
|= show_devices(argv
[i
] + 2, num_dests
, dests
);
437 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
441 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
443 status
|= show_devices(argv
[i
], num_dests
, dests
);
449 cupsFreeDests(num_dests
, dests
);
450 num_dests
= cupsGetDests(&dests
);
453 status
|= show_devices(NULL
, num_dests
, dests
);
458 _cupsLangPrintf(stderr
,
459 _("%s: Error - unknown option \'%c\'!\n"),
460 argv
[0], argv
[i
][1]);
465 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
470 status
|= show_jobs(NULL
, cupsUser(), long_status
, ranking
, which
);
477 * 'check_dest()' - Verify that the named destination(s) exists.
481 check_dest(const char *command
, /* I - Command name */
482 const char *name
, /* I - List of printer/class names */
483 int *num_dests
, /* IO - Number of destinations */
484 cups_dest_t
**dests
) /* IO - Destinations */
486 const char *dptr
; /* Pointer into name */
487 char *pptr
, /* Pointer into printer */
488 printer
[1024]; /* Current printer/class name */
492 * Load the destination list as necessary...
498 cupsFreeDests(*num_dests
, *dests
);
500 if (strchr(name
, ','))
501 *num_dests
= cupsGetDests(dests
);
504 strlcpy(printer
, name
, sizeof(printer
));
505 if ((pptr
= strchr(printer
, '/')) != NULL
)
508 if ((*dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, printer
, pptr
)) == NULL
)
510 _cupsLangPrintf(stderr
,
511 _("%s: Invalid destination name in list \"%s\"!\n"),
524 * Scan the name string for printer/class name(s)...
527 for (dptr
= name
; *dptr
;)
530 * Skip leading whitespace and commas...
533 while (isspace(*dptr
& 255) || *dptr
== ',')
540 * Extract a single destination name from the name string...
543 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
;)
545 if ((pptr
- printer
) < (sizeof(printer
) - 1))
549 _cupsLangPrintf(stderr
,
550 _("%s: Invalid destination name in list \"%s\"!\n"),
559 * Check the destination...
562 if (!cupsGetDest(printer
, NULL
, *num_dests
, *dests
))
564 _cupsLangPrintf(stderr
,
565 _("%s: Unknown destination \"%s\"!\n"), command
, printer
);
573 * 'match_list()' - Match a name from a list of comma or space-separated names.
576 static int /* O - 1 on match, 0 on no match */
577 match_list(const char *list
, /* I - List of names */
578 const char *name
) /* I - Name to find */
580 const char *nameptr
; /* Pointer into name */
584 * An empty list always matches...
593 * Skip leading whitespace and commas...
596 while (isspace(*list
& 255) || *list
== ',')
607 *nameptr
&& *list
&& tolower(*nameptr
& 255) == tolower(*list
& 255);
608 nameptr
++, list
++);
610 if (!*nameptr
&& (!*list
|| *list
== ',' || isspace(*list
& 255)))
613 while (*list
&& !isspace(*list
& 255) && *list
!= ',')
622 * 'show_accepting()' - Show acceptance status.
625 static int /* O - 0 on success, 1 on fail */
626 show_accepting(const char *printers
, /* I - Destinations */
627 int num_dests
, /* I - Number of user-defined dests */
628 cups_dest_t
*dests
) /* I - User-defined destinations */
630 int i
; /* Looping var */
631 ipp_t
*request
, /* IPP Request */
632 *response
; /* IPP Response */
633 ipp_attribute_t
*attr
; /* Current attribute */
634 const char *printer
, /* Printer name */
635 *message
; /* Printer device URI */
636 int accepting
; /* Accepting requests? */
637 time_t ptime
; /* Printer state time */
638 struct tm
*pdate
; /* Printer state date & time */
639 char printer_state_time
[255];/* Printer state time */
640 static const char *pattrs
[] = /* Attributes we need for printers... */
643 "printer-state-change-time",
644 "printer-state-message",
645 "printer-is-accepting-jobs"
649 DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers
));
651 if (printers
!= NULL
&& !strcmp(printers
, "all"))
655 * Build a CUPS_GET_PRINTERS request, which requires the following
659 * attributes-natural-language
660 * requested-attributes
661 * requesting-user-name
664 request
= ippNewRequest(CUPS_GET_PRINTERS
);
666 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
667 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
670 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
674 * Do the request and get back a response...
677 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
679 DEBUG_puts("show_accepting: request succeeded...");
681 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
683 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
689 * Loop through the printers returned in the list and display
693 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
696 * Skip leading attributes until we hit a printer...
699 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
706 * Pull the needed attributes from this printer...
714 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
716 if (!strcmp(attr
->name
, "printer-name") &&
717 attr
->value_tag
== IPP_TAG_NAME
)
718 printer
= attr
->values
[0].string
.text
;
719 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
720 attr
->value_tag
== IPP_TAG_INTEGER
)
721 ptime
= (time_t)attr
->values
[0].integer
;
722 else if (!strcmp(attr
->name
, "printer-state-message") &&
723 attr
->value_tag
== IPP_TAG_TEXT
)
724 message
= attr
->values
[0].string
.text
;
725 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
726 attr
->value_tag
== IPP_TAG_BOOLEAN
)
727 accepting
= attr
->values
[0].boolean
;
733 * See if we have everything needed...
745 * Display the printer entry if needed...
748 if (match_list(printers
, printer
))
750 pdate
= localtime(&ptime
);
751 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
754 _cupsLangPrintf(stdout
, _("%s accepting requests since %s\n"),
755 printer
, printer_state_time
);
757 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -\n"
759 printer
, printer_state_time
,
760 (message
== NULL
|| !*message
) ?
761 "reason unknown" : message
);
763 for (i
= 0; i
< num_dests
; i
++)
764 if (!strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
767 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s\n"),
768 printer
, dests
[i
].instance
, printer_state_time
);
770 _cupsLangPrintf(stdout
, _("%s/%s not accepting requests since "
772 printer
, dests
[i
].instance
, printer_state_time
,
773 (message
== NULL
|| !*message
) ?
774 "reason unknown" : message
);
786 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
795 * 'show_classes()' - Show printer classes.
798 static int /* O - 0 on success, 1 on fail */
799 show_classes(const char *dests
) /* I - Destinations */
801 int i
; /* Looping var */
802 ipp_t
*request
, /* IPP Request */
803 *response
, /* IPP Response */
804 *response2
; /* IPP response from remote server */
805 http_t
*http2
; /* Remote server */
806 ipp_attribute_t
*attr
; /* Current attribute */
807 const char *printer
, /* Printer class name */
808 *printer_uri
; /* Printer class URI */
809 ipp_attribute_t
*members
; /* Printer members */
810 char method
[HTTP_MAX_URI
], /* Request method */
811 username
[HTTP_MAX_URI
], /* Username:password */
812 server
[HTTP_MAX_URI
], /* Server name */
813 resource
[HTTP_MAX_URI
]; /* Resource name */
814 int port
; /* Port number */
815 static const char *cattrs
[] = /* Attributes we need for classes... */
818 "printer-uri-supported",
823 DEBUG_printf(("show_classes(dests=\"%s\")\n", dests
));
825 if (dests
!= NULL
&& !strcmp(dests
, "all"))
829 * Build a CUPS_GET_CLASSES request, which requires the following
833 * attributes-natural-language
834 * requested-attributes
835 * requesting-user-name
838 request
= ippNewRequest(CUPS_GET_CLASSES
);
840 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
841 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
844 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
848 * Do the request and get back a response...
851 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
853 DEBUG_puts("show_classes: request succeeded...");
855 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
857 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
863 * Loop through the printers returned in the list and display
867 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
870 * Skip leading attributes until we hit a job...
873 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
880 * Pull the needed attributes from this job...
887 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
889 if (!strcmp(attr
->name
, "printer-name") &&
890 attr
->value_tag
== IPP_TAG_NAME
)
891 printer
= attr
->values
[0].string
.text
;
893 if (!strcmp(attr
->name
, "printer-uri-supported") &&
894 attr
->value_tag
== IPP_TAG_URI
)
895 printer_uri
= attr
->values
[0].string
.text
;
897 if (!strcmp(attr
->name
, "member-names") &&
898 attr
->value_tag
== IPP_TAG_NAME
)
905 * If this is a remote class, grab the class info from the
910 if (members
== NULL
&& printer_uri
!= NULL
)
912 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
913 username
, sizeof(username
), server
, sizeof(server
),
914 &port
, resource
, sizeof(resource
));
916 if (!strcasecmp(server
, cupsServer()))
917 http2
= CUPS_HTTP_DEFAULT
;
919 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
922 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
923 * following attributes:
926 * attributes-natural-language
928 * requested-attributes
931 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
933 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
934 "printer-uri", NULL
, printer_uri
);
936 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
937 "requested-attributes",
938 sizeof(cattrs
) / sizeof(cattrs
[0]),
941 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
942 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
949 * See if we have everything needed...
955 ippDelete(response2
);
964 * Display the printer entry if needed...
967 if (match_list(dests
, printer
))
969 _cupsLangPrintf(stdout
, _("members of class %s:\n"), printer
);
973 for (i
= 0; i
< members
->num_values
; i
++)
974 _cupsLangPrintf(stdout
, "\t%s\n",
975 members
->values
[i
].string
.text
);
978 _cupsLangPuts(stdout
, "\tunknown\n");
982 ippDelete(response2
);
992 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1001 * 'show_default()' - Show default destination.
1005 show_default(cups_dest_t
*dest
) /* I - Default destination */
1007 const char *printer
, /* Printer name */
1008 *val
; /* Environment variable name */
1014 _cupsLangPrintf(stdout
, _("system default destination: %s/%s\n"),
1015 dest
->name
, dest
->instance
);
1017 _cupsLangPrintf(stdout
, _("system default destination: %s\n"),
1024 if ((printer
= getenv("LPDEST")) == NULL
)
1026 if ((printer
= getenv("PRINTER")) != NULL
)
1028 if (!strcmp(printer
, "lp"))
1038 _cupsLangPrintf(stdout
,
1039 _("lpstat: error - %s environment variable names "
1040 "non-existent destination \"%s\"!\n"),
1043 _cupsLangPuts(stdout
, _("no system default destination\n"));
1049 * 'show_devices()' - Show printer devices.
1052 static int /* O - 0 on success, 1 on fail */
1053 show_devices(const char *printers
, /* I - Destinations */
1054 int num_dests
, /* I - Number of user-defined dests */
1055 cups_dest_t
*dests
) /* I - User-defined destinations */
1057 int i
; /* Looping var */
1058 ipp_t
*request
, /* IPP Request */
1059 *response
; /* IPP Response */
1060 ipp_attribute_t
*attr
; /* Current attribute */
1061 const char *printer
, /* Printer name */
1062 *uri
, /* Printer URI */
1063 *device
; /* Printer device URI */
1064 static const char *pattrs
[] = /* Attributes we need for printers... */
1067 "printer-uri-supported",
1072 DEBUG_printf(("show_devices(printers=\"%s\")\n", printers
));
1074 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1078 * Build a CUPS_GET_PRINTERS request, which requires the following
1081 * attributes-charset
1082 * attributes-natural-language
1083 * requested-attributes
1084 * requesting-user-name
1087 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1089 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1090 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1093 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1097 * Do the request and get back a response...
1100 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1102 DEBUG_puts("show_devices: request succeeded...");
1104 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1106 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1107 ippDelete(response
);
1112 * Loop through the printers returned in the list and display
1116 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1119 * Skip leading attributes until we hit a job...
1122 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1129 * Pull the needed attributes from this job...
1136 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1138 if (!strcmp(attr
->name
, "printer-name") &&
1139 attr
->value_tag
== IPP_TAG_NAME
)
1140 printer
= attr
->values
[0].string
.text
;
1142 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1143 attr
->value_tag
== IPP_TAG_URI
)
1144 uri
= attr
->values
[0].string
.text
;
1146 if (!strcmp(attr
->name
, "device-uri") &&
1147 attr
->value_tag
== IPP_TAG_URI
)
1148 device
= attr
->values
[0].string
.text
;
1154 * See if we have everything needed...
1157 if (printer
== NULL
)
1166 * Display the printer entry if needed...
1169 if (match_list(printers
, printer
))
1171 #ifdef __osf__ /* Compaq/Digital like to do it their own way... */
1172 char scheme
[HTTP_MAX_URI
], /* Components of printer URI */
1173 username
[HTTP_MAX_URI
],
1174 hostname
[HTTP_MAX_URI
],
1175 resource
[HTTP_MAX_URI
];
1181 httpSeparateURI(HTTP_URI_CODING_ALL
, uri
, scheme
, sizeof(scheme
),
1182 username
, sizeof(username
), hostname
,
1183 sizeof(hostname
), &port
, resource
, sizeof(resource
));
1184 _cupsLangPrintf(stdout
,
1185 _("Output for printer %s is sent to remote "
1186 "printer %s on %s\n"),
1187 printer
, strrchr(resource
, '/') + 1, hostname
);
1189 else if (!strncmp(device
, "file:", 5))
1190 _cupsLangPrintf(stdout
,
1191 _("Output for printer %s is sent to %s\n"),
1192 printer
, device
+ 5);
1194 _cupsLangPrintf(stdout
,
1195 _("Output for printer %s is sent to %s\n"),
1198 for (i
= 0; i
< num_dests
; i
++)
1199 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1202 _cupsLangPrintf(stdout
,
1203 _("Output for printer %s/%s is sent to "
1204 "remote printer %s on %s\n"),
1205 printer
, dests
[i
].instance
,
1206 strrchr(resource
, '/') + 1, hostname
);
1207 else if (!strncmp(device
, "file:", 5))
1208 _cupsLangPrintf(stdout
,
1209 _("Output for printer %s/%s is sent to %s\n"),
1210 printer
, dests
[i
].instance
, device
+ 5);
1212 _cupsLangPrintf(stdout
,
1213 _("Output for printer %s/%s is sent to %s\n"),
1214 printer
, dests
[i
].instance
, device
);
1218 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1220 else if (!strncmp(device
, "file:", 5))
1221 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1222 printer
, device
+ 5);
1224 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1227 for (i
= 0; i
< num_dests
; i
++)
1228 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1231 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1232 printer
, dests
[i
].instance
, uri
);
1233 else if (!strncmp(device
, "file:", 5))
1234 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1235 printer
, dests
[i
].instance
, device
+ 5);
1237 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1238 printer
, dests
[i
].instance
, device
);
1240 #endif /* __osf__ */
1247 ippDelete(response
);
1251 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1260 * 'show_jobs()' - Show active print jobs.
1263 static int /* O - 0 on success, 1 on fail */
1264 show_jobs(const char *dests
, /* I - Destinations */
1265 const char *users
, /* I - Users */
1266 int long_status
, /* I - Show long status? */
1267 int ranking
, /* I - Show job ranking? */
1268 const char *which
) /* I - Show which jobs? */
1270 int i
; /* Looping var */
1271 ipp_t
*request
, /* IPP Request */
1272 *response
; /* IPP Response */
1273 ipp_attribute_t
*attr
, /* Current attribute */
1274 *reasons
; /* Job state reasons attribute */
1275 const char *dest
, /* Pointer into job-printer-uri */
1276 *username
, /* Pointer to job-originating-user-name */
1277 *title
; /* Pointer to job-name */
1278 int rank
, /* Rank in queue */
1280 size
; /* job-k-octets */
1281 time_t jobtime
; /* time-at-creation */
1282 struct tm
*jobdate
; /* Date & time */
1283 char temp
[255], /* Temporary buffer */
1284 date
[255]; /* Date buffer */
1285 static const char *jattrs
[] = /* Attributes we need for jobs... */
1292 "job-originating-user-name",
1297 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1298 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1301 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1305 * Build a IPP_GET_JOBS request, which requires the following
1308 * attributes-charset
1309 * attributes-natural-language
1311 * requested-attributes
1312 * requesting-user-name
1316 request
= ippNewRequest(IPP_GET_JOBS
);
1318 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1319 NULL
, "ipp://localhost/");
1321 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1322 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1325 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1328 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1332 * Do the request and get back a response...
1335 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1338 * Loop through the job list and display them...
1341 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1343 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1344 ippDelete(response
);
1350 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1353 * Skip leading attributes until we hit a job...
1356 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1363 * Pull the needed attributes from this job...
1374 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1376 if (!strcmp(attr
->name
, "job-id") &&
1377 attr
->value_tag
== IPP_TAG_INTEGER
)
1378 jobid
= attr
->values
[0].integer
;
1380 if (!strcmp(attr
->name
, "job-k-octets") &&
1381 attr
->value_tag
== IPP_TAG_INTEGER
)
1382 size
= attr
->values
[0].integer
;
1384 if (!strcmp(attr
->name
, "time-at-creation") &&
1385 attr
->value_tag
== IPP_TAG_INTEGER
)
1386 jobtime
= attr
->values
[0].integer
;
1388 if (!strcmp(attr
->name
, "job-printer-uri") &&
1389 attr
->value_tag
== IPP_TAG_URI
)
1390 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1393 if (!strcmp(attr
->name
, "job-originating-user-name") &&
1394 attr
->value_tag
== IPP_TAG_NAME
)
1395 username
= attr
->values
[0].string
.text
;
1397 if (!strcmp(attr
->name
, "job-name") &&
1398 attr
->value_tag
== IPP_TAG_NAME
)
1399 title
= attr
->values
[0].string
.text
;
1401 if (!strcmp(attr
->name
, "job-state-reasons") &&
1402 attr
->value_tag
== IPP_TAG_KEYWORD
)
1409 * See if we have everything needed...
1412 if (dest
== NULL
|| jobid
== 0)
1421 * Display the job...
1426 if (match_list(dests
, dest
) || match_list(users
, username
))
1428 jobdate
= localtime(&jobtime
);
1429 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1431 if (long_status
== 3)
1434 * Show the consolidated output format for the SGI tools...
1437 if (!strftime(date
, sizeof(date
), "%b %d %H:%M", jobdate
))
1438 strcpy(date
, "Unknown");
1440 _cupsLangPrintf(stdout
, "%s;%s;%d;%s;%s\n",
1441 temp
, username
? username
: "unknown",
1442 size
, title
? title
: "unknown", date
);
1446 if (!strftime(date
, sizeof(date
), "%c", jobdate
))
1447 strcpy(date
, "Unknown");
1450 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s\n",
1451 rank
, temp
, username
? username
: "unknown",
1452 1024.0 * size
, date
);
1454 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s\n",
1455 temp
, username
? username
: "unknown",
1456 1024.0 * size
, date
);
1461 _cupsLangPuts(stdout
, _("\tAlerts:"));
1462 for (i
= 0; i
< reasons
->num_values
; i
++)
1463 _cupsLangPrintf(stdout
, " %s",
1464 reasons
->values
[i
].string
.text
);
1465 _cupsLangPuts(stdout
, "\n");
1467 _cupsLangPrintf(stdout
, _("\tqueued for %s\n"), dest
);
1476 ippDelete(response
);
1480 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1489 * 'show_printers()' - Show printers.
1492 static int /* O - 0 on success, 1 on fail */
1493 show_printers(const char *printers
, /* I - Destinations */
1494 int num_dests
, /* I - Number of user-defined dests */
1495 cups_dest_t
*dests
, /* I - User-defined destinations */
1496 int long_status
) /* I - Show long status? */
1498 int i
, j
; /* Looping vars */
1499 ipp_t
*request
, /* IPP Request */
1500 *response
, /* IPP Response */
1501 *jobs
; /* IPP Get Jobs response */
1502 ipp_attribute_t
*attr
, /* Current attribute */
1503 *jobattr
, /* Job ID attribute */
1504 *reasons
; /* Job state reasons attribute */
1505 const char *printer
, /* Printer name */
1506 *message
, /* Printer state message */
1507 *description
, /* Description of printer */
1508 *location
, /* Location of printer */
1509 *make_model
, /* Make and model of printer */
1510 *uri
; /* URI of printer */
1511 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1512 *denied
; /* requestint-user-name-denied */
1513 ipp_pstate_t pstate
; /* Printer state */
1514 cups_ptype_t ptype
; /* Printer type */
1515 time_t ptime
; /* Printer state time */
1516 struct tm
*pdate
; /* Printer state date & time */
1517 int jobid
; /* Job ID of current job */
1518 char printer_uri
[HTTP_MAX_URI
],
1520 printer_state_time
[255];/* Printer state time */
1521 const char *root
; /* Server root directory... */
1522 static const char *pattrs
[] = /* Attributes we need for printers... */
1526 "printer-state-message",
1527 "printer-state-reasons",
1528 "printer-state-change-time",
1532 "printer-make-and-model",
1533 "printer-uri-supported",
1534 "requesting-user-name-allowed",
1535 "requesting-user-name-denied"
1537 static const char *jattrs
[] = /* Attributes we need for jobs... */
1543 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1544 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1546 if ((root
= getenv("CUPS_SERVERROOT")) == NULL
)
1547 root
= CUPS_SERVERROOT
;
1549 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1553 * Build a CUPS_GET_PRINTERS request, which requires the following
1556 * attributes-charset
1557 * attributes-natural-language
1558 * requested-attributes
1559 * requesting-user-name
1562 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1564 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1565 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1568 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1572 * Do the request and get back a response...
1575 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1577 DEBUG_puts("show_printers: request succeeded...");
1579 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1581 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1582 ippDelete(response
);
1587 * Loop through the printers returned in the list and display
1591 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1594 * Skip leading attributes until we hit a job...
1597 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1604 * Pull the needed attributes from this job...
1609 ptype
= CUPS_PRINTER_LOCAL
;
1610 pstate
= IPP_PRINTER_IDLE
;
1621 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1623 if (!strcmp(attr
->name
, "printer-name") &&
1624 attr
->value_tag
== IPP_TAG_NAME
)
1625 printer
= attr
->values
[0].string
.text
;
1626 else if (!strcmp(attr
->name
, "printer-state") &&
1627 attr
->value_tag
== IPP_TAG_ENUM
)
1628 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1629 else if (!strcmp(attr
->name
, "printer-type") &&
1630 attr
->value_tag
== IPP_TAG_ENUM
)
1631 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1632 else if (!strcmp(attr
->name
, "printer-state-message") &&
1633 attr
->value_tag
== IPP_TAG_TEXT
)
1634 message
= attr
->values
[0].string
.text
;
1635 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1636 attr
->value_tag
== IPP_TAG_INTEGER
)
1637 ptime
= (time_t)attr
->values
[0].integer
;
1638 else if (!strcmp(attr
->name
, "printer-info") &&
1639 attr
->value_tag
== IPP_TAG_TEXT
)
1640 description
= attr
->values
[0].string
.text
;
1641 else if (!strcmp(attr
->name
, "printer-location") &&
1642 attr
->value_tag
== IPP_TAG_TEXT
)
1643 location
= attr
->values
[0].string
.text
;
1644 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1645 attr
->value_tag
== IPP_TAG_TEXT
)
1646 make_model
= attr
->values
[0].string
.text
;
1647 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1648 attr
->value_tag
== IPP_TAG_URI
)
1649 uri
= attr
->values
[0].string
.text
;
1650 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1651 attr
->value_tag
== IPP_TAG_KEYWORD
)
1653 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1654 attr
->value_tag
== IPP_TAG_NAME
)
1656 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1657 attr
->value_tag
== IPP_TAG_NAME
)
1664 * See if we have everything needed...
1667 if (printer
== NULL
)
1676 * Display the printer entry if needed...
1679 if (match_list(printers
, printer
))
1682 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1683 * current job for the printer.
1686 if (pstate
== IPP_PRINTER_PROCESSING
)
1689 * Build an IPP_GET_JOBS request, which requires the following
1692 * attributes-charset
1693 * attributes-natural-language
1696 * requested-attributes
1699 request
= ippNewRequest(IPP_GET_JOBS
);
1701 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1702 request
->request
.op
.request_id
= 1;
1704 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1705 "requested-attributes",
1706 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1708 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1709 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1710 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1711 "printer-uri", NULL
, printer_uri
);
1713 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1716 * Get the current active job on this queue...
1719 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1722 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1726 if (jobstate
== IPP_JOB_PROCESSING
)
1732 if (!strcmp(jobattr
->name
, "job-id") &&
1733 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1734 jobid
= jobattr
->values
[0].integer
;
1735 else if (!strcmp(jobattr
->name
, "job-state") &&
1736 jobattr
->value_tag
== IPP_TAG_ENUM
)
1737 jobstate
= jobattr
->values
[0].integer
;
1740 if (jobstate
!= IPP_JOB_PROCESSING
)
1751 pdate
= localtime(&ptime
);
1752 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
1756 case IPP_PRINTER_IDLE
:
1757 _cupsLangPrintf(stdout
,
1758 _("printer %s is idle. enabled since %s\n"),
1759 printer
, printer_state_time
);
1761 case IPP_PRINTER_PROCESSING
:
1762 _cupsLangPrintf(stdout
,
1763 _("printer %s now printing %s-%d. "
1764 "enabled since %s\n"),
1765 printer
, printer
, jobid
, printer_state_time
);
1767 case IPP_PRINTER_STOPPED
:
1768 _cupsLangPrintf(stdout
,
1769 _("printer %s disabled since %s -\n"),
1770 printer
, printer_state_time
);
1774 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1776 if (!message
|| !*message
)
1777 _cupsLangPuts(stdout
, _("\treason unknown\n"));
1779 _cupsLangPrintf(stdout
, "\t%s\n", message
);
1782 if (long_status
> 1)
1783 _cupsLangPuts(stdout
,
1784 _("\tForm mounted:\n"
1785 "\tContent types: any\n"
1786 "\tPrinter types: unknown\n"));
1790 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
1791 description
? description
: "");
1795 _cupsLangPuts(stdout
, _("\tAlerts:"));
1796 for (j
= 0; j
< reasons
->num_values
; j
++)
1797 _cupsLangPrintf(stdout
, " %s",
1798 reasons
->values
[j
].string
.text
);
1799 _cupsLangPuts(stdout
, "\n");
1802 if (long_status
> 1)
1804 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
1805 location
? location
: "");
1807 if (ptype
& CUPS_PRINTER_REMOTE
)
1809 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
1811 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1812 !strstr(make_model
, "Raw Printer") && uri
)
1813 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
1818 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
1820 if (make_model
&& strstr(make_model
, "System V Printer"))
1821 _cupsLangPrintf(stdout
,
1822 _("\tInterface: %s/interfaces/%s\n"),
1824 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1825 _cupsLangPrintf(stdout
,
1826 _("\tInterface: %s/ppd/%s.ppd\n"), root
, printer
);
1828 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
1829 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
1830 /* TODO update to use printer-error-policy */
1833 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1834 for (j
= 0; j
< allowed
->num_values
; j
++)
1835 _cupsLangPrintf(stdout
, "\t\t%s\n",
1836 allowed
->values
[j
].string
.text
);
1840 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
1841 for (j
= 0; j
< denied
->num_values
; j
++)
1842 _cupsLangPrintf(stdout
, "\t\t%s\n",
1843 denied
->values
[j
].string
.text
);
1847 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1848 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
1850 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
1851 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1852 _cupsLangPuts(stdout
, _("\tBanner required\n"));
1853 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
1854 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1855 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
1856 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
1857 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
1860 for (i
= 0; i
< num_dests
; i
++)
1861 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1865 case IPP_PRINTER_IDLE
:
1866 _cupsLangPrintf(stdout
,
1867 _("printer %s/%s is idle. "
1868 "enabled since %s\n"),
1869 printer
, dests
[i
].instance
,
1870 printer_state_time
);
1872 case IPP_PRINTER_PROCESSING
:
1873 _cupsLangPrintf(stdout
,
1874 _("printer %s/%s now printing %s-%d. "
1875 "enabled since %s\n"),
1876 printer
, dests
[i
].instance
, printer
, jobid
,
1877 printer_state_time
);
1879 case IPP_PRINTER_STOPPED
:
1880 _cupsLangPrintf(stdout
,
1881 _("printer %s/%s disabled since %s -\n"),
1882 printer
, dests
[i
].instance
,
1883 printer_state_time
);
1887 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1889 if (!message
|| !*message
)
1890 _cupsLangPuts(stdout
, _("\treason unknown\n"));
1892 _cupsLangPrintf(stdout
, "\t%s\n", message
);
1895 if (long_status
> 1)
1896 _cupsLangPuts(stdout
,
1897 _("\tForm mounted:\n"
1898 "\tContent types: any\n"
1899 "\tPrinter types: unknown\n"));
1903 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
1904 description
? description
: "");
1908 _cupsLangPuts(stdout
, _("\tAlerts:"));
1909 for (j
= 0; j
< reasons
->num_values
; j
++)
1910 _cupsLangPrintf(stdout
, " %s",
1911 reasons
->values
[j
].string
.text
);
1912 _cupsLangPuts(stdout
, "\n");
1915 if (long_status
> 1)
1917 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
1918 location
? location
: "");
1920 if (ptype
& CUPS_PRINTER_REMOTE
)
1922 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
1924 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1925 !strstr(make_model
, "Raw Printer") && uri
)
1926 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
1931 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
1933 if (make_model
&& strstr(make_model
, "System V Printer"))
1934 _cupsLangPrintf(stdout
,
1935 _("\tInterface: %s/interfaces/%s\n"),
1937 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1938 _cupsLangPrintf(stdout
,
1939 _("\tInterface: %s/ppd/%s.ppd\n"), root
, printer
);
1941 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
1942 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
1943 /* TODO update to use printer-error-policy */
1946 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1947 for (j
= 0; j
< allowed
->num_values
; j
++)
1948 _cupsLangPrintf(stdout
, "\t\t%s\n",
1949 allowed
->values
[j
].string
.text
);
1953 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
1954 for (j
= 0; j
< denied
->num_values
; j
++)
1955 _cupsLangPrintf(stdout
, "\t\t%s\n",
1956 denied
->values
[j
].string
.text
);
1960 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1961 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
1963 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
1964 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1965 _cupsLangPuts(stdout
, _("\tBanner required\n"));
1966 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
1967 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1968 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
1969 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
1970 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
1979 ippDelete(response
);
1983 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1992 * 'show_scheduler()' - Show scheduler status.
1996 show_scheduler(void)
1998 http_t
*http
; /* Connection to server */
2001 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
2002 cupsEncryption())) != NULL
)
2004 _cupsLangPuts(stdout
, _("scheduler is running\n"));
2008 _cupsLangPuts(stdout
, _("scheduler is not running\n"));
2013 * End of "$Id: lpstat.c 7921 2008-09-10 15:42:24Z mike $".