2 * "lpstat" command for CUPS.
4 * Copyright 2007-2017 by Apple Inc.
5 * Copyright 1997-2006 by Easy Software Products.
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
11 * Include necessary headers...
14 #include <cups/cups-private.h>
21 static void check_dest(const char *command
, const char *name
,
22 int *num_dests
, cups_dest_t
**dests
);
23 static int match_list(const char *list
, const char *name
);
24 static int show_accepting(const char *printers
, int num_dests
,
26 static int show_classes(const char *dests
);
27 static void show_default(cups_dest_t
*dest
);
28 static int show_devices(const char *printers
, int num_dests
,
30 static int show_jobs(const char *dests
, const char *users
, int long_status
,
31 int ranking
, const char *which
);
32 static int show_printers(const char *printers
, int num_dests
,
33 cups_dest_t
*dests
, int long_status
);
34 static void show_scheduler(void);
38 * 'main()' - Parse options and show status information.
42 main(int argc
, /* I - Number of command-line arguments */
43 char *argv
[]) /* I - Command-line arguments */
45 int i
, /* Looping var */
46 status
; /* Exit status */
47 char *opt
; /* Option pointer */
48 int num_dests
; /* Number of user destinations */
49 cups_dest_t
*dests
; /* User destinations */
50 int long_status
; /* Long status report? */
51 int ranking
; /* Show job ranking? */
52 const char *which
; /* Which jobs to show? */
53 char op
; /* Last operation on command-line */
59 * Parse command-line options...
67 which
= "not-completed";
70 for (i
= 1; i
< argc
; i
++)
72 if (argv
[i
][0] == '-')
74 for (opt
= argv
[i
] + 1; *opt
; opt
++)
78 case 'D' : /* Show description */
82 case 'E' : /* Encrypt */
84 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
86 _cupsLangPrintf(stderr
,
87 _("%s: Sorry, no encryption support."),
92 case 'H' : /* Show server and port */
93 if (cupsServer()[0] == '/')
94 _cupsLangPuts(stdout
, cupsServer());
96 _cupsLangPrintf(stdout
, "%s:%d", cupsServer(), ippPort());
100 case 'P' : /* Show paper types */
104 case 'R' : /* Show ranking */
108 case 'S' : /* Show charsets */
114 case 'U' : /* Username */
117 cupsSetUser(opt
+ 1);
118 opt
+= strlen(opt
) - 1;
125 _cupsLangPrintf(stderr
, _("%s: Error - expected username after \"-U\" option."), argv
[0]);
129 cupsSetUser(argv
[i
]);
133 case 'W' : /* Show which jobs? */
137 opt
+= strlen(opt
) - 1;
145 _cupsLangPrintf(stderr
, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv
[0]);
152 if (strcmp(which
, "completed") && strcmp(which
, "not-completed") && strcmp(which
, "all"))
154 _cupsLangPrintf(stderr
, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv
[0]);
159 case 'a' : /* Show acceptance status */
164 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
166 status
|= show_accepting(opt
+ 1, num_dests
, dests
);
167 opt
+= strlen(opt
) - 1;
169 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
173 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
175 status
|= show_accepting(argv
[i
], num_dests
, dests
);
181 cupsFreeDests(num_dests
, dests
);
182 num_dests
= cupsGetDests(&dests
);
184 if (num_dests
== 0 && (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
|| cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
186 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
191 status
|= show_accepting(NULL
, num_dests
, dests
);
195 case 'c' : /* Show classes and members */
200 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
202 status
|= show_classes(opt
+ 1);
203 opt
+= strlen(opt
) - 1;
205 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
209 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
211 status
|= show_classes(argv
[i
]);
214 status
|= show_classes(NULL
);
217 case 'd' : /* Show default destination */
220 if (num_dests
!= 1 || !dests
[0].is_default
)
222 cupsFreeDests(num_dests
, dests
);
224 dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, NULL
, NULL
);
225 num_dests
= dests
? 1 : 0;
227 if (num_dests
== 0 &&
228 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
229 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
231 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
239 case 'e' : /* List destinations */
241 cups_dest_t
*temp
= NULL
, *dest
;
242 int j
, num_temp
= cupsGetDests(&temp
);
246 for (j
= num_temp
, dest
= temp
; j
> 0; j
--, dest
++)
249 printf("%s/%s", dest
->name
, dest
->instance
);
251 fputs(dest
->name
, stdout
);
255 const char *printer_uri_supported
= cupsGetOption("printer-uri-supported", dest
->num_options
, dest
->options
);
256 const char *printer_is_temporary
= cupsGetOption("printer-is-temporary", dest
->num_options
, dest
->options
);
257 const char *type
= "network";
259 if (printer_is_temporary
&& !strcmp(printer_is_temporary
, "true"))
261 else if (printer_uri_supported
)
264 printf(" %s %s %s\n", type
, printer_uri_supported
? printer_uri_supported
: "none", cupsGetOption("device-uri", dest
->num_options
, dest
->options
));
270 cupsFreeDests(num_temp
, temp
);
274 case 'f' : /* Show forms */
278 opt
+= strlen(opt
) - 1;
288 case 'h' : /* Connect to host */
291 cupsSetServer(opt
+ 1);
292 opt
+= strlen(opt
) - 1;
300 _cupsLangPrintf(stderr
, _("%s: Error - expected hostname after \"-h\" option."), argv
[0]);
304 cupsSetServer(argv
[i
]);
308 case 'l' : /* Long status or long job status */
312 case 'o' : /* Show jobs by destination */
317 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
319 status
|= show_jobs(opt
+ 1, NULL
, long_status
, ranking
, which
);
320 opt
+= strlen(opt
) - 1;
322 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
326 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
328 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
331 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
334 case 'p' : /* Show printers */
339 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
341 status
|= show_printers(opt
+ 1, num_dests
, dests
,
343 opt
+= strlen(opt
) - 1;
345 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
349 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
351 status
|= show_printers(argv
[i
], num_dests
, dests
, long_status
);
357 cupsFreeDests(num_dests
, dests
);
358 num_dests
= cupsGetDests(&dests
);
360 if (num_dests
== 0 &&
361 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
362 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
364 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
369 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
373 case 'r' : /* Show scheduler status */
379 case 's' : /* Show summary */
384 cupsFreeDests(num_dests
, dests
);
385 num_dests
= cupsGetDests(&dests
);
387 if (num_dests
== 0 &&
388 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
389 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
391 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
396 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
397 status
|= show_classes(NULL
);
398 status
|= show_devices(NULL
, num_dests
, dests
);
401 case 't' : /* Show all info */
406 cupsFreeDests(num_dests
, dests
);
407 num_dests
= cupsGetDests(&dests
);
409 if (num_dests
== 0 &&
410 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
411 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
413 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
419 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
420 status
|= show_classes(NULL
);
421 status
|= show_devices(NULL
, num_dests
, dests
);
422 status
|= show_accepting(NULL
, num_dests
, dests
);
423 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
424 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
427 case 'u' : /* Show jobs by user */
432 status
|= show_jobs(NULL
, opt
+ 1, long_status
, ranking
, which
);
433 opt
+= strlen(opt
) - 1;
435 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
438 status
|= show_jobs(NULL
, argv
[i
], long_status
, ranking
, which
);
441 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
444 case 'v' : /* Show printer devices */
449 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
451 status
|= show_devices(opt
+ 1, num_dests
, dests
);
452 opt
+= strlen(opt
) - 1;
454 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
458 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
460 status
|= show_devices(argv
[i
], num_dests
, dests
);
466 cupsFreeDests(num_dests
, dests
);
467 num_dests
= cupsGetDests(&dests
);
469 if (num_dests
== 0 &&
470 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
471 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
473 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
478 status
|= show_devices(NULL
, num_dests
, dests
);
483 _cupsLangPrintf(stderr
, _("%s: Error - unknown option \"%c\"."), argv
[0], argv
[i
][1]);
490 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
496 status
|= show_jobs(NULL
, cupsUser(), long_status
, ranking
, which
);
503 * 'check_dest()' - Verify that the named destination(s) exists.
507 check_dest(const char *command
, /* I - Command name */
508 const char *name
, /* I - List of printer/class names */
509 int *num_dests
, /* IO - Number of destinations */
510 cups_dest_t
**dests
) /* IO - Destinations */
512 const char *dptr
; /* Pointer into name */
513 char *pptr
, /* Pointer into printer */
514 printer
[1024]; /* Current printer/class name */
518 * Load the destination list as necessary...
524 cupsFreeDests(*num_dests
, *dests
);
526 if (strchr(name
, ','))
527 *num_dests
= cupsGetDests(dests
);
530 strlcpy(printer
, name
, sizeof(printer
));
531 if ((pptr
= strchr(printer
, '/')) != NULL
)
534 if ((*dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, printer
, pptr
)) == NULL
)
536 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
537 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
538 _cupsLangPrintf(stderr
,
539 _("%s: Error - add '/version=1.1' to server name."),
542 _cupsLangPrintf(stderr
,
543 _("%s: Invalid destination name in list \"%s\"."),
557 * Scan the name string for printer/class name(s)...
560 for (dptr
= name
; *dptr
;)
563 * Skip leading whitespace and commas...
566 while (isspace(*dptr
& 255) || *dptr
== ',')
573 * Extract a single destination name from the name string...
576 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
;)
578 if ((size_t)(pptr
- printer
) < (sizeof(printer
) - 1))
582 _cupsLangPrintf(stderr
,
583 _("%s: Invalid destination name in list \"%s\"."),
592 * Check the destination...
595 if (!cupsGetDest(printer
, NULL
, *num_dests
, *dests
))
597 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
598 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
599 _cupsLangPrintf(stderr
,
600 _("%s: Error - add '/version=1.1' to server name."),
603 _cupsLangPrintf(stderr
,
604 _("%s: Unknown destination \"%s\"."), command
, printer
);
613 * 'match_list()' - Match a name from a list of comma or space-separated names.
616 static int /* O - 1 on match, 0 on no match */
617 match_list(const char *list
, /* I - List of names */
618 const char *name
) /* I - Name to find */
620 const char *nameptr
; /* Pointer into name */
624 * An empty list always matches...
636 * Skip leading whitespace and commas...
639 while (isspace(*list
& 255) || *list
== ',')
650 *nameptr
&& *list
&& tolower(*nameptr
& 255) == tolower(*list
& 255);
651 nameptr
++, list
++);
653 if (!*nameptr
&& (!*list
|| *list
== ',' || isspace(*list
& 255)))
656 while (*list
&& !isspace(*list
& 255) && *list
!= ',')
665 * 'show_accepting()' - Show acceptance status.
668 static int /* O - 0 on success, 1 on fail */
669 show_accepting(const char *printers
, /* I - Destinations */
670 int num_dests
, /* I - Number of user-defined dests */
671 cups_dest_t
*dests
) /* I - User-defined destinations */
673 int i
; /* Looping var */
674 ipp_t
*request
, /* IPP Request */
675 *response
; /* IPP Response */
676 ipp_attribute_t
*attr
; /* Current attribute */
677 const char *printer
, /* Printer name */
678 *message
; /* Printer device URI */
679 int accepting
; /* Accepting requests? */
680 time_t ptime
; /* Printer state time */
681 char printer_state_time
[255];/* Printer state time */
682 static const char *pattrs
[] = /* Attributes we need for printers... */
685 "printer-state-change-time",
686 "printer-state-message",
687 "printer-is-accepting-jobs"
691 DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers
));
693 if (printers
!= NULL
&& !strcmp(printers
, "all"))
697 * Build a CUPS_GET_PRINTERS request, which requires the following
701 * attributes-natural-language
702 * requested-attributes
703 * requesting-user-name
706 request
= ippNewRequest(CUPS_GET_PRINTERS
);
708 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
709 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
712 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
716 * Do the request and get back a response...
719 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
721 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
722 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
724 _cupsLangPrintf(stderr
,
725 _("%s: Error - add '/version=1.1' to server name."),
730 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
732 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
739 DEBUG_puts("show_accepting: request succeeded...");
742 * Loop through the printers returned in the list and display
746 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
749 * Skip leading attributes until we hit a printer...
752 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
759 * Pull the needed attributes from this printer...
767 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
769 if (!strcmp(attr
->name
, "printer-name") &&
770 attr
->value_tag
== IPP_TAG_NAME
)
771 printer
= attr
->values
[0].string
.text
;
772 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
773 attr
->value_tag
== IPP_TAG_INTEGER
)
774 ptime
= (time_t)attr
->values
[0].integer
;
775 else if (!strcmp(attr
->name
, "printer-state-message") &&
776 attr
->value_tag
== IPP_TAG_TEXT
)
777 message
= attr
->values
[0].string
.text
;
778 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
779 attr
->value_tag
== IPP_TAG_BOOLEAN
)
780 accepting
= attr
->values
[0].boolean
;
786 * See if we have everything needed...
798 * Display the printer entry if needed...
801 if (match_list(printers
, printer
))
803 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
806 _cupsLangPrintf(stdout
, _("%s accepting requests since %s"),
807 printer
, printer_state_time
);
810 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -"),
811 printer
, printer_state_time
);
812 _cupsLangPrintf(stdout
, _("\t%s"),
813 (message
== NULL
|| !*message
) ?
814 "reason unknown" : message
);
817 for (i
= 0; i
< num_dests
; i
++)
818 if (!_cups_strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
821 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s"),
822 printer
, dests
[i
].instance
, printer_state_time
);
825 _cupsLangPrintf(stdout
,
826 _("%s/%s not accepting requests since %s -"),
827 printer
, dests
[i
].instance
, printer_state_time
);
828 _cupsLangPrintf(stdout
, _("\t%s"),
829 (message
== NULL
|| !*message
) ?
830 "reason unknown" : message
);
847 * 'show_classes()' - Show printer classes.
850 static int /* O - 0 on success, 1 on fail */
851 show_classes(const char *dests
) /* I - Destinations */
853 int i
; /* Looping var */
854 ipp_t
*request
, /* IPP Request */
855 *response
, /* IPP Response */
856 *response2
; /* IPP response from remote server */
857 http_t
*http2
; /* Remote server */
858 ipp_attribute_t
*attr
; /* Current attribute */
859 const char *printer
, /* Printer class name */
860 *printer_uri
; /* Printer class URI */
861 ipp_attribute_t
*members
; /* Printer members */
862 char method
[HTTP_MAX_URI
], /* Request method */
863 username
[HTTP_MAX_URI
], /* Username:password */
864 server
[HTTP_MAX_URI
], /* Server name */
865 resource
[HTTP_MAX_URI
]; /* Resource name */
866 int port
; /* Port number */
867 static const char *cattrs
[] = /* Attributes we need for classes... */
870 "printer-uri-supported",
875 DEBUG_printf(("show_classes(dests=\"%s\")\n", dests
));
877 if (dests
!= NULL
&& !strcmp(dests
, "all"))
881 * Build a CUPS_GET_CLASSES request, which requires the following
885 * attributes-natural-language
886 * requested-attributes
887 * requesting-user-name
890 request
= ippNewRequest(CUPS_GET_CLASSES
);
892 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
893 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
896 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
900 * Do the request and get back a response...
903 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
905 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
906 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
908 _cupsLangPrintf(stderr
,
909 _("%s: Error - add '/version=1.1' to server name."),
914 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
916 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
923 DEBUG_puts("show_classes: request succeeded...");
925 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
927 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
933 * Loop through the printers returned in the list and display
937 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
940 * Skip leading attributes until we hit a job...
943 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
950 * Pull the needed attributes from this job...
957 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
959 if (!strcmp(attr
->name
, "printer-name") &&
960 attr
->value_tag
== IPP_TAG_NAME
)
961 printer
= attr
->values
[0].string
.text
;
963 if (!strcmp(attr
->name
, "printer-uri-supported") &&
964 attr
->value_tag
== IPP_TAG_URI
)
965 printer_uri
= attr
->values
[0].string
.text
;
967 if (!strcmp(attr
->name
, "member-names") &&
968 attr
->value_tag
== IPP_TAG_NAME
)
975 * If this is a remote class, grab the class info from the
980 if (members
== NULL
&& printer_uri
!= NULL
)
982 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
983 username
, sizeof(username
), server
, sizeof(server
),
984 &port
, resource
, sizeof(resource
));
986 if (!_cups_strcasecmp(server
, cupsServer()))
987 http2
= CUPS_HTTP_DEFAULT
;
989 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
992 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
993 * following attributes:
996 * attributes-natural-language
998 * requested-attributes
1001 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
1003 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1004 "printer-uri", NULL
, printer_uri
);
1006 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1007 "requested-attributes",
1008 sizeof(cattrs
) / sizeof(cattrs
[0]),
1011 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
1012 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
1019 * See if we have everything needed...
1022 if (printer
== NULL
)
1025 ippDelete(response2
);
1034 * Display the printer entry if needed...
1037 if (match_list(dests
, printer
))
1039 _cupsLangPrintf(stdout
, _("members of class %s:"), printer
);
1043 for (i
= 0; i
< members
->num_values
; i
++)
1044 _cupsLangPrintf(stdout
, "\t%s", members
->values
[i
].string
.text
);
1047 _cupsLangPuts(stdout
, "\tunknown");
1051 ippDelete(response2
);
1057 ippDelete(response
);
1065 * 'show_default()' - Show default destination.
1069 show_default(cups_dest_t
*dest
) /* I - Default destination */
1071 const char *printer
, /* Printer name */
1072 *val
; /* Environment variable name */
1078 _cupsLangPrintf(stdout
, _("system default destination: %s/%s"),
1079 dest
->name
, dest
->instance
);
1081 _cupsLangPrintf(stdout
, _("system default destination: %s"),
1088 if ((printer
= getenv("LPDEST")) == NULL
)
1090 if ((printer
= getenv("PRINTER")) != NULL
)
1092 if (!strcmp(printer
, "lp"))
1102 _cupsLangPrintf(stdout
,
1103 _("lpstat: error - %s environment variable names "
1104 "non-existent destination \"%s\"."),
1107 _cupsLangPuts(stdout
, _("no system default destination"));
1113 * 'show_devices()' - Show printer devices.
1116 static int /* O - 0 on success, 1 on fail */
1117 show_devices(const char *printers
, /* I - Destinations */
1118 int num_dests
, /* I - Number of user-defined dests */
1119 cups_dest_t
*dests
) /* I - User-defined destinations */
1121 int i
; /* Looping var */
1122 ipp_t
*request
, /* IPP Request */
1123 *response
; /* IPP Response */
1124 ipp_attribute_t
*attr
; /* Current attribute */
1125 const char *printer
, /* Printer name */
1126 *uri
, /* Printer URI */
1127 *device
; /* Printer device URI */
1128 static const char *pattrs
[] = /* Attributes we need for printers... */
1131 "printer-uri-supported",
1136 DEBUG_printf(("show_devices(printers=\"%s\")\n", printers
));
1138 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1142 * Build a CUPS_GET_PRINTERS request, which requires the following
1145 * attributes-charset
1146 * attributes-natural-language
1147 * requested-attributes
1148 * requesting-user-name
1151 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1153 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1154 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1157 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1161 * Do the request and get back a response...
1164 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1166 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1167 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1169 _cupsLangPrintf(stderr
,
1170 _("%s: Error - add '/version=1.1' to server name."),
1172 ippDelete(response
);
1175 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1177 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1178 ippDelete(response
);
1184 DEBUG_puts("show_devices: request succeeded...");
1187 * Loop through the printers returned in the list and display
1191 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1194 * Skip leading attributes until we hit a job...
1197 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1204 * Pull the needed attributes from this job...
1211 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1213 if (!strcmp(attr
->name
, "printer-name") &&
1214 attr
->value_tag
== IPP_TAG_NAME
)
1215 printer
= attr
->values
[0].string
.text
;
1217 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1218 attr
->value_tag
== IPP_TAG_URI
)
1219 uri
= attr
->values
[0].string
.text
;
1221 if (!strcmp(attr
->name
, "device-uri") &&
1222 attr
->value_tag
== IPP_TAG_URI
)
1223 device
= attr
->values
[0].string
.text
;
1229 * See if we have everything needed...
1232 if (printer
== NULL
)
1241 * Display the printer entry if needed...
1244 if (match_list(printers
, printer
))
1247 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1249 else if (!strncmp(device
, "file:", 5))
1250 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1251 printer
, device
+ 5);
1253 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1256 for (i
= 0; i
< num_dests
; i
++)
1258 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1261 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1262 printer
, dests
[i
].instance
, uri
);
1263 else if (!strncmp(device
, "file:", 5))
1264 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1265 printer
, dests
[i
].instance
, device
+ 5);
1267 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1268 printer
, dests
[i
].instance
, device
);
1277 ippDelete(response
);
1285 * 'show_jobs()' - Show active print jobs.
1288 static int /* O - 0 on success, 1 on fail */
1289 show_jobs(const char *dests
, /* I - Destinations */
1290 const char *users
, /* I - Users */
1291 int long_status
, /* I - Show long status? */
1292 int ranking
, /* I - Show job ranking? */
1293 const char *which
) /* I - Show which jobs? */
1295 int i
; /* Looping var */
1296 ipp_t
*request
, /* IPP Request */
1297 *response
; /* IPP Response */
1298 ipp_attribute_t
*attr
, /* Current attribute */
1299 *reasons
; /* Job state reasons attribute */
1300 const char *dest
, /* Pointer into job-printer-uri */
1301 *username
, /* Pointer to job-originating-user-name */
1302 *message
, /* Pointer to job-printer-state-message */
1303 *time_at
; /* time-at-xxx attribute name to use */
1304 int rank
, /* Rank in queue */
1306 size
; /* job-k-octets */
1307 time_t jobtime
; /* time-at-creation */
1308 char temp
[255], /* Temporary buffer */
1309 date
[255]; /* Date buffer */
1310 static const char *jattrs
[] = /* Attributes we need for jobs... */
1315 "job-originating-user-name",
1316 "job-printer-state-message",
1318 "job-state-reasons",
1324 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1325 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1328 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1332 * Build a IPP_GET_JOBS request, which requires the following
1335 * attributes-charset
1336 * attributes-natural-language
1338 * requested-attributes
1339 * requesting-user-name
1343 request
= ippNewRequest(IPP_GET_JOBS
);
1345 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1346 NULL
, "ipp://localhost/");
1348 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1349 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1352 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1355 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1359 * Do the request and get back a response...
1362 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1364 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1365 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1367 _cupsLangPrintf(stderr
,
1368 _("%s: Error - add '/version=1.1' to server name."),
1370 ippDelete(response
);
1373 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1375 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1376 ippDelete(response
);
1383 * Loop through the job list and display them...
1386 if (!strcmp(which
, "aborted") ||
1387 !strcmp(which
, "canceled") ||
1388 !strcmp(which
, "completed"))
1389 time_at
= "time-at-completed";
1391 time_at
= "time-at-creation";
1395 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1398 * Skip leading attributes until we hit a job...
1401 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1408 * Pull the needed attributes from this job...
1419 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1421 if (!strcmp(attr
->name
, "job-id") &&
1422 attr
->value_tag
== IPP_TAG_INTEGER
)
1423 jobid
= attr
->values
[0].integer
;
1424 else if (!strcmp(attr
->name
, "job-k-octets") &&
1425 attr
->value_tag
== IPP_TAG_INTEGER
)
1426 size
= attr
->values
[0].integer
;
1427 else if (!strcmp(attr
->name
, time_at
) && attr
->value_tag
== IPP_TAG_INTEGER
)
1428 jobtime
= attr
->values
[0].integer
;
1429 else if (!strcmp(attr
->name
, "job-printer-state-message") &&
1430 attr
->value_tag
== IPP_TAG_TEXT
)
1431 message
= attr
->values
[0].string
.text
;
1432 else if (!strcmp(attr
->name
, "job-printer-uri") &&
1433 attr
->value_tag
== IPP_TAG_URI
)
1435 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1438 else if (!strcmp(attr
->name
, "job-originating-user-name") &&
1439 attr
->value_tag
== IPP_TAG_NAME
)
1440 username
= attr
->values
[0].string
.text
;
1441 else if (!strcmp(attr
->name
, "job-state-reasons") &&
1442 attr
->value_tag
== IPP_TAG_KEYWORD
)
1449 * See if we have everything needed...
1452 if (dest
== NULL
|| jobid
== 0)
1461 * Display the job...
1466 if (match_list(dests
, dest
) && match_list(users
, username
))
1468 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1470 _cupsStrDate(date
, sizeof(date
), jobtime
);
1473 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s",
1474 rank
, temp
, username
? username
: "unknown",
1475 1024.0 * size
, date
);
1477 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s",
1478 temp
, username
? username
: "unknown",
1479 1024.0 * size
, date
);
1483 _cupsLangPrintf(stdout
, _("\tStatus: %s"), message
);
1487 char alerts
[1024], /* Alerts string */
1488 *aptr
; /* Pointer into alerts string */
1490 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1493 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1495 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1497 aptr
+= strlen(aptr
);
1500 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1503 _cupsLangPrintf(stdout
, _("\tqueued for %s"), dest
);
1511 ippDelete(response
);
1519 * 'show_printers()' - Show printers.
1522 static int /* O - 0 on success, 1 on fail */
1523 show_printers(const char *printers
, /* I - Destinations */
1524 int num_dests
, /* I - Number of user-defined dests */
1525 cups_dest_t
*dests
, /* I - User-defined destinations */
1526 int long_status
) /* I - Show long status? */
1528 int i
, j
; /* Looping vars */
1529 ipp_t
*request
, /* IPP Request */
1530 *response
, /* IPP Response */
1531 *jobs
; /* IPP Get Jobs response */
1532 ipp_attribute_t
*attr
, /* Current attribute */
1533 *jobattr
, /* Job ID attribute */
1534 *reasons
; /* Job state reasons attribute */
1535 const char *printer
, /* Printer name */
1536 *message
, /* Printer state message */
1537 *description
, /* Description of printer */
1538 *location
, /* Location of printer */
1539 *make_model
, /* Make and model of printer */
1540 *uri
; /* URI of printer */
1541 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1542 *denied
; /* requestint-user-name-denied */
1543 ipp_pstate_t pstate
; /* Printer state */
1544 cups_ptype_t ptype
; /* Printer type */
1545 time_t ptime
; /* Printer state time */
1546 int jobid
; /* Job ID of current job */
1547 char printer_uri
[HTTP_MAX_URI
],
1549 printer_state_time
[255];/* Printer state time */
1550 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1551 static const char *pattrs
[] = /* Attributes we need for printers... */
1555 "printer-state-message",
1556 "printer-state-reasons",
1557 "printer-state-change-time",
1561 "printer-make-and-model",
1562 "printer-uri-supported",
1563 "requesting-user-name-allowed",
1564 "requesting-user-name-denied"
1566 static const char *jattrs
[] = /* Attributes we need for jobs... */
1573 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1574 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1576 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1580 * Build a CUPS_GET_PRINTERS request, which requires the following
1583 * attributes-charset
1584 * attributes-natural-language
1585 * requested-attributes
1586 * requesting-user-name
1589 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1591 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1592 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1595 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1599 * Do the request and get back a response...
1602 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1604 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1605 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1607 _cupsLangPrintf(stderr
,
1608 _("%s: Error - add '/version=1.1' to server name."),
1610 ippDelete(response
);
1613 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1615 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1616 ippDelete(response
);
1622 DEBUG_puts("show_printers: request succeeded...");
1625 * Loop through the printers returned in the list and display
1629 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1632 * Skip leading attributes until we hit a job...
1635 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1642 * Pull the needed attributes from this job...
1647 ptype
= CUPS_PRINTER_LOCAL
;
1648 pstate
= IPP_PRINTER_IDLE
;
1659 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1661 if (!strcmp(attr
->name
, "printer-name") &&
1662 attr
->value_tag
== IPP_TAG_NAME
)
1663 printer
= attr
->values
[0].string
.text
;
1664 else if (!strcmp(attr
->name
, "printer-state") &&
1665 attr
->value_tag
== IPP_TAG_ENUM
)
1666 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1667 else if (!strcmp(attr
->name
, "printer-type") &&
1668 attr
->value_tag
== IPP_TAG_ENUM
)
1669 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1670 else if (!strcmp(attr
->name
, "printer-state-message") &&
1671 attr
->value_tag
== IPP_TAG_TEXT
)
1672 message
= attr
->values
[0].string
.text
;
1673 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1674 attr
->value_tag
== IPP_TAG_INTEGER
)
1675 ptime
= (time_t)attr
->values
[0].integer
;
1676 else if (!strcmp(attr
->name
, "printer-info") &&
1677 attr
->value_tag
== IPP_TAG_TEXT
)
1678 description
= attr
->values
[0].string
.text
;
1679 else if (!strcmp(attr
->name
, "printer-location") &&
1680 attr
->value_tag
== IPP_TAG_TEXT
)
1681 location
= attr
->values
[0].string
.text
;
1682 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1683 attr
->value_tag
== IPP_TAG_TEXT
)
1684 make_model
= attr
->values
[0].string
.text
;
1685 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1686 attr
->value_tag
== IPP_TAG_URI
)
1687 uri
= attr
->values
[0].string
.text
;
1688 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1689 attr
->value_tag
== IPP_TAG_KEYWORD
)
1691 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1692 attr
->value_tag
== IPP_TAG_NAME
)
1694 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1695 attr
->value_tag
== IPP_TAG_NAME
)
1702 * See if we have everything needed...
1705 if (printer
== NULL
)
1714 * Display the printer entry if needed...
1717 if (match_list(printers
, printer
))
1720 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1721 * current job for the printer.
1724 if (pstate
== IPP_PRINTER_PROCESSING
)
1727 * Build an IPP_GET_JOBS request, which requires the following
1730 * attributes-charset
1731 * attributes-natural-language
1734 * requested-attributes
1737 request
= ippNewRequest(IPP_GET_JOBS
);
1739 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1740 request
->request
.op
.request_id
= 1;
1742 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1743 "requested-attributes",
1744 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1746 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1747 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1748 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1749 "printer-uri", NULL
, printer_uri
);
1751 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1754 * Get the current active job on this queue...
1757 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1760 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1764 if (jobstate
== IPP_JOB_PROCESSING
)
1770 if (!strcmp(jobattr
->name
, "job-id") &&
1771 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1772 jobid
= jobattr
->values
[0].integer
;
1773 else if (!strcmp(jobattr
->name
, "job-state") &&
1774 jobattr
->value_tag
== IPP_TAG_ENUM
)
1775 jobstate
= (ipp_jstate_t
)jobattr
->values
[0].integer
;
1778 if (jobstate
!= IPP_JOB_PROCESSING
)
1789 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
1793 case IPP_PRINTER_IDLE
:
1794 if (ippContainsString(reasons
, "hold-new-jobs"))
1795 _cupsLangPrintf(stdout
, _("printer %s is holding new jobs. enabled since %s"), printer
, printer_state_time
);
1797 _cupsLangPrintf(stdout
, _("printer %s is idle. enabled since %s"), printer
, printer_state_time
);
1799 case IPP_PRINTER_PROCESSING
:
1800 _cupsLangPrintf(stdout
, _("printer %s now printing %s-%d. enabled since %s"), printer
, printer
, jobid
, printer_state_time
);
1802 case IPP_PRINTER_STOPPED
:
1803 _cupsLangPrintf(stdout
, _("printer %s disabled since %s -"), printer
, printer_state_time
);
1807 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1809 if (!message
|| !*message
)
1810 _cupsLangPuts(stdout
, _("\treason unknown"));
1812 _cupsLangPrintf(stdout
, "\t%s", message
);
1815 if (long_status
> 1)
1817 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1818 _cupsLangPuts(stdout
, _("\tContent types: any"));
1819 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1824 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1825 description
? description
: "");
1829 char alerts
[1024], /* Alerts string */
1830 *aptr
; /* Pointer into alerts string */
1832 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1835 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1837 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1839 aptr
+= strlen(aptr
);
1842 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1845 if (long_status
> 1)
1847 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1848 location
? location
: "");
1850 if (ptype
& CUPS_PRINTER_REMOTE
)
1852 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1854 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1855 !strstr(make_model
, "Raw Printer") && uri
)
1856 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"),
1861 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1863 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1864 _cupsLangPrintf(stdout
,
1865 _("\tInterface: %s/ppd/%s.ppd"),
1866 cg
->cups_serverroot
, printer
);
1868 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1869 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1870 /* TODO update to use printer-error-policy */
1873 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1874 for (j
= 0; j
< allowed
->num_values
; j
++)
1875 _cupsLangPrintf(stdout
, "\t\t%s",
1876 allowed
->values
[j
].string
.text
);
1880 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1881 for (j
= 0; j
< denied
->num_values
; j
++)
1882 _cupsLangPrintf(stdout
, "\t\t%s",
1883 denied
->values
[j
].string
.text
);
1887 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1888 _cupsLangPuts(stdout
, _("\t\t(all)"));
1890 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1891 _cupsLangPuts(stdout
, _("\t\t(none)"));
1892 _cupsLangPuts(stdout
, _("\tBanner required"));
1893 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1894 _cupsLangPuts(stdout
, _("\t\t(none)"));
1895 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1896 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1897 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1900 for (i
= 0; i
< num_dests
; i
++)
1901 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1905 case IPP_PRINTER_IDLE
:
1906 _cupsLangPrintf(stdout
,
1907 _("printer %s/%s is idle. "
1908 "enabled since %s"),
1909 printer
, dests
[i
].instance
,
1910 printer_state_time
);
1912 case IPP_PRINTER_PROCESSING
:
1913 _cupsLangPrintf(stdout
,
1914 _("printer %s/%s now printing %s-%d. "
1915 "enabled since %s"),
1916 printer
, dests
[i
].instance
, printer
, jobid
,
1917 printer_state_time
);
1919 case IPP_PRINTER_STOPPED
:
1920 _cupsLangPrintf(stdout
,
1921 _("printer %s/%s disabled since %s -"),
1922 printer
, dests
[i
].instance
,
1923 printer_state_time
);
1927 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1929 if (!message
|| !*message
)
1930 _cupsLangPuts(stdout
, _("\treason unknown"));
1932 _cupsLangPrintf(stdout
, "\t%s", message
);
1935 if (long_status
> 1)
1937 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1938 _cupsLangPuts(stdout
, _("\tContent types: any"));
1939 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1944 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1945 description
? description
: "");
1949 char alerts
[1024], /* Alerts string */
1950 *aptr
; /* Pointer into alerts string */
1952 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1955 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1957 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1959 aptr
+= strlen(aptr
);
1962 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1965 if (long_status
> 1)
1967 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1968 location
? location
: "");
1970 if (ptype
& CUPS_PRINTER_REMOTE
)
1972 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1974 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1975 !strstr(make_model
, "Raw Printer") && uri
)
1976 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"), uri
);
1980 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1982 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1983 _cupsLangPrintf(stdout
,
1984 _("\tInterface: %s/ppd/%s.ppd"),
1985 cg
->cups_serverroot
, printer
);
1987 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1988 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1989 /* TODO update to use printer-error-policy */
1992 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1993 for (j
= 0; j
< allowed
->num_values
; j
++)
1994 _cupsLangPrintf(stdout
, "\t\t%s",
1995 allowed
->values
[j
].string
.text
);
1999 _cupsLangPuts(stdout
, _("\tUsers denied:"));
2000 for (j
= 0; j
< denied
->num_values
; j
++)
2001 _cupsLangPrintf(stdout
, "\t\t%s",
2002 denied
->values
[j
].string
.text
);
2006 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
2007 _cupsLangPuts(stdout
, _("\t\t(all)"));
2009 _cupsLangPuts(stdout
, _("\tForms allowed:"));
2010 _cupsLangPuts(stdout
, _("\t\t(none)"));
2011 _cupsLangPuts(stdout
, _("\tBanner required"));
2012 _cupsLangPuts(stdout
, _("\tCharset sets:"));
2013 _cupsLangPuts(stdout
, _("\t\t(none)"));
2014 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
2015 _cupsLangPuts(stdout
, _("\tDefault page size:"));
2016 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
2025 ippDelete(response
);
2033 * 'show_scheduler()' - Show scheduler status.
2037 show_scheduler(void)
2039 http_t
*http
; /* Connection to server */
2042 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
2043 cupsEncryption())) != NULL
)
2045 _cupsLangPuts(stdout
, _("scheduler is running"));
2049 _cupsLangPuts(stdout
, _("scheduler is not running"));