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 if (printers
!= NULL
&& !strcmp(printers
, "all"))
695 * Build a CUPS_GET_PRINTERS request, which requires the following
699 * attributes-natural-language
700 * requested-attributes
701 * requesting-user-name
704 request
= ippNewRequest(CUPS_GET_PRINTERS
);
706 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
707 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
710 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
714 * Do the request and get back a response...
717 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
719 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
720 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
722 _cupsLangPrintf(stderr
,
723 _("%s: Error - add '/version=1.1' to server name."),
728 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
730 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
738 * Loop through the printers returned in the list and display
742 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
745 * Skip leading attributes until we hit a printer...
748 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
755 * Pull the needed attributes from this printer...
763 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
765 if (!strcmp(attr
->name
, "printer-name") &&
766 attr
->value_tag
== IPP_TAG_NAME
)
767 printer
= attr
->values
[0].string
.text
;
768 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
769 attr
->value_tag
== IPP_TAG_INTEGER
)
770 ptime
= (time_t)attr
->values
[0].integer
;
771 else if (!strcmp(attr
->name
, "printer-state-message") &&
772 attr
->value_tag
== IPP_TAG_TEXT
)
773 message
= attr
->values
[0].string
.text
;
774 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
775 attr
->value_tag
== IPP_TAG_BOOLEAN
)
776 accepting
= attr
->values
[0].boolean
;
782 * See if we have everything needed...
794 * Display the printer entry if needed...
797 if (match_list(printers
, printer
))
799 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
802 _cupsLangPrintf(stdout
, _("%s accepting requests since %s"),
803 printer
, printer_state_time
);
806 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -"),
807 printer
, printer_state_time
);
808 _cupsLangPrintf(stdout
, _("\t%s"),
809 (message
== NULL
|| !*message
) ?
810 "reason unknown" : message
);
813 for (i
= 0; i
< num_dests
; i
++)
814 if (!_cups_strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
817 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s"),
818 printer
, dests
[i
].instance
, printer_state_time
);
821 _cupsLangPrintf(stdout
,
822 _("%s/%s not accepting requests since %s -"),
823 printer
, dests
[i
].instance
, printer_state_time
);
824 _cupsLangPrintf(stdout
, _("\t%s"),
825 (message
== NULL
|| !*message
) ?
826 "reason unknown" : message
);
843 * 'show_classes()' - Show printer classes.
846 static int /* O - 0 on success, 1 on fail */
847 show_classes(const char *dests
) /* I - Destinations */
849 int i
; /* Looping var */
850 ipp_t
*request
, /* IPP Request */
851 *response
, /* IPP Response */
852 *response2
; /* IPP response from remote server */
853 http_t
*http2
; /* Remote server */
854 ipp_attribute_t
*attr
; /* Current attribute */
855 const char *printer
, /* Printer class name */
856 *printer_uri
; /* Printer class URI */
857 ipp_attribute_t
*members
; /* Printer members */
858 char method
[HTTP_MAX_URI
], /* Request method */
859 username
[HTTP_MAX_URI
], /* Username:password */
860 server
[HTTP_MAX_URI
], /* Server name */
861 resource
[HTTP_MAX_URI
]; /* Resource name */
862 int port
; /* Port number */
863 static const char *cattrs
[] = /* Attributes we need for classes... */
866 "printer-uri-supported",
871 if (dests
!= NULL
&& !strcmp(dests
, "all"))
875 * Build a CUPS_GET_CLASSES request, which requires the following
879 * attributes-natural-language
880 * requested-attributes
881 * requesting-user-name
884 request
= ippNewRequest(CUPS_GET_CLASSES
);
886 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
887 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
890 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
894 * Do the request and get back a response...
897 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
899 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
900 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
902 _cupsLangPrintf(stderr
,
903 _("%s: Error - add '/version=1.1' to server name."),
908 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
910 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
917 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
919 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
925 * Loop through the printers returned in the list and display
929 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
932 * Skip leading attributes until we hit a job...
935 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
942 * Pull the needed attributes from this job...
949 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
951 if (!strcmp(attr
->name
, "printer-name") &&
952 attr
->value_tag
== IPP_TAG_NAME
)
953 printer
= attr
->values
[0].string
.text
;
955 if (!strcmp(attr
->name
, "printer-uri-supported") &&
956 attr
->value_tag
== IPP_TAG_URI
)
957 printer_uri
= attr
->values
[0].string
.text
;
959 if (!strcmp(attr
->name
, "member-names") &&
960 attr
->value_tag
== IPP_TAG_NAME
)
967 * If this is a remote class, grab the class info from the
972 if (members
== NULL
&& printer_uri
!= NULL
)
974 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
975 username
, sizeof(username
), server
, sizeof(server
),
976 &port
, resource
, sizeof(resource
));
978 if (!_cups_strcasecmp(server
, cupsServer()))
979 http2
= CUPS_HTTP_DEFAULT
;
981 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
984 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
985 * following attributes:
988 * attributes-natural-language
990 * requested-attributes
993 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
995 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
996 "printer-uri", NULL
, printer_uri
);
998 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
999 "requested-attributes",
1000 sizeof(cattrs
) / sizeof(cattrs
[0]),
1003 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
1004 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
1011 * See if we have everything needed...
1014 if (printer
== NULL
)
1017 ippDelete(response2
);
1026 * Display the printer entry if needed...
1029 if (match_list(dests
, printer
))
1031 _cupsLangPrintf(stdout
, _("members of class %s:"), printer
);
1035 for (i
= 0; i
< members
->num_values
; i
++)
1036 _cupsLangPrintf(stdout
, "\t%s", members
->values
[i
].string
.text
);
1039 _cupsLangPuts(stdout
, "\tunknown");
1043 ippDelete(response2
);
1049 ippDelete(response
);
1057 * 'show_default()' - Show default destination.
1061 show_default(cups_dest_t
*dest
) /* I - Default destination */
1063 const char *printer
, /* Printer name */
1064 *val
; /* Environment variable name */
1070 _cupsLangPrintf(stdout
, _("system default destination: %s/%s"),
1071 dest
->name
, dest
->instance
);
1073 _cupsLangPrintf(stdout
, _("system default destination: %s"),
1080 if ((printer
= getenv("LPDEST")) == NULL
)
1082 if ((printer
= getenv("PRINTER")) != NULL
)
1084 if (!strcmp(printer
, "lp"))
1094 _cupsLangPrintf(stdout
,
1095 _("lpstat: error - %s environment variable names "
1096 "non-existent destination \"%s\"."),
1099 _cupsLangPuts(stdout
, _("no system default destination"));
1105 * 'show_devices()' - Show printer devices.
1108 static int /* O - 0 on success, 1 on fail */
1109 show_devices(const char *printers
, /* I - Destinations */
1110 int num_dests
, /* I - Number of user-defined dests */
1111 cups_dest_t
*dests
) /* I - User-defined destinations */
1113 int i
; /* Looping var */
1114 ipp_t
*request
, /* IPP Request */
1115 *response
; /* IPP Response */
1116 ipp_attribute_t
*attr
; /* Current attribute */
1117 const char *printer
, /* Printer name */
1118 *uri
, /* Printer URI */
1119 *device
; /* Printer device URI */
1120 static const char *pattrs
[] = /* Attributes we need for printers... */
1123 "printer-uri-supported",
1128 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1132 * Build a CUPS_GET_PRINTERS request, which requires the following
1135 * attributes-charset
1136 * attributes-natural-language
1137 * requested-attributes
1138 * requesting-user-name
1141 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1143 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1144 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1147 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1151 * Do the request and get back a response...
1154 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1156 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1157 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1159 _cupsLangPrintf(stderr
,
1160 _("%s: Error - add '/version=1.1' to server name."),
1162 ippDelete(response
);
1165 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1167 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1168 ippDelete(response
);
1175 * Loop through the printers returned in the list and display
1179 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1182 * Skip leading attributes until we hit a job...
1185 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1192 * Pull the needed attributes from this job...
1199 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1201 if (!strcmp(attr
->name
, "printer-name") &&
1202 attr
->value_tag
== IPP_TAG_NAME
)
1203 printer
= attr
->values
[0].string
.text
;
1205 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1206 attr
->value_tag
== IPP_TAG_URI
)
1207 uri
= attr
->values
[0].string
.text
;
1209 if (!strcmp(attr
->name
, "device-uri") &&
1210 attr
->value_tag
== IPP_TAG_URI
)
1211 device
= attr
->values
[0].string
.text
;
1217 * See if we have everything needed...
1220 if (printer
== NULL
)
1229 * Display the printer entry if needed...
1232 if (match_list(printers
, printer
))
1235 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1237 else if (!strncmp(device
, "file:", 5))
1238 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1239 printer
, device
+ 5);
1241 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1244 for (i
= 0; i
< num_dests
; i
++)
1246 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1249 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1250 printer
, dests
[i
].instance
, uri
);
1251 else if (!strncmp(device
, "file:", 5))
1252 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1253 printer
, dests
[i
].instance
, device
+ 5);
1255 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1256 printer
, dests
[i
].instance
, device
);
1265 ippDelete(response
);
1273 * 'show_jobs()' - Show active print jobs.
1276 static int /* O - 0 on success, 1 on fail */
1277 show_jobs(const char *dests
, /* I - Destinations */
1278 const char *users
, /* I - Users */
1279 int long_status
, /* I - Show long status? */
1280 int ranking
, /* I - Show job ranking? */
1281 const char *which
) /* I - Show which jobs? */
1283 int i
; /* Looping var */
1284 ipp_t
*request
, /* IPP Request */
1285 *response
; /* IPP Response */
1286 ipp_attribute_t
*attr
, /* Current attribute */
1287 *reasons
; /* Job state reasons attribute */
1288 const char *dest
, /* Pointer into job-printer-uri */
1289 *username
, /* Pointer to job-originating-user-name */
1290 *message
, /* Pointer to job-printer-state-message */
1291 *time_at
; /* time-at-xxx attribute name to use */
1292 int rank
, /* Rank in queue */
1294 size
; /* job-k-octets */
1295 time_t jobtime
; /* time-at-creation */
1296 char temp
[255], /* Temporary buffer */
1297 date
[255]; /* Date buffer */
1298 static const char *jattrs
[] = /* Attributes we need for jobs... */
1303 "job-originating-user-name",
1304 "job-printer-state-message",
1306 "job-state-reasons",
1312 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1316 * Build a IPP_GET_JOBS request, which requires the following
1319 * attributes-charset
1320 * attributes-natural-language
1322 * requested-attributes
1323 * requesting-user-name
1327 request
= ippNewRequest(IPP_GET_JOBS
);
1329 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1330 NULL
, "ipp://localhost/");
1332 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1333 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1336 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1339 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1343 * Do the request and get back a response...
1346 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1348 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1349 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1351 _cupsLangPrintf(stderr
,
1352 _("%s: Error - add '/version=1.1' to server name."),
1354 ippDelete(response
);
1357 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1359 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1360 ippDelete(response
);
1367 * Loop through the job list and display them...
1370 if (!strcmp(which
, "aborted") ||
1371 !strcmp(which
, "canceled") ||
1372 !strcmp(which
, "completed"))
1373 time_at
= "time-at-completed";
1375 time_at
= "time-at-creation";
1379 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1382 * Skip leading attributes until we hit a job...
1385 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1392 * Pull the needed attributes from this job...
1403 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1405 if (!strcmp(attr
->name
, "job-id") &&
1406 attr
->value_tag
== IPP_TAG_INTEGER
)
1407 jobid
= attr
->values
[0].integer
;
1408 else if (!strcmp(attr
->name
, "job-k-octets") &&
1409 attr
->value_tag
== IPP_TAG_INTEGER
)
1410 size
= attr
->values
[0].integer
;
1411 else if (!strcmp(attr
->name
, time_at
) && attr
->value_tag
== IPP_TAG_INTEGER
)
1412 jobtime
= attr
->values
[0].integer
;
1413 else if (!strcmp(attr
->name
, "job-printer-state-message") &&
1414 attr
->value_tag
== IPP_TAG_TEXT
)
1415 message
= attr
->values
[0].string
.text
;
1416 else if (!strcmp(attr
->name
, "job-printer-uri") &&
1417 attr
->value_tag
== IPP_TAG_URI
)
1419 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1422 else if (!strcmp(attr
->name
, "job-originating-user-name") &&
1423 attr
->value_tag
== IPP_TAG_NAME
)
1424 username
= attr
->values
[0].string
.text
;
1425 else if (!strcmp(attr
->name
, "job-state-reasons") &&
1426 attr
->value_tag
== IPP_TAG_KEYWORD
)
1433 * See if we have everything needed...
1436 if (dest
== NULL
|| jobid
== 0)
1445 * Display the job...
1450 if (match_list(dests
, dest
) && match_list(users
, username
))
1452 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1454 _cupsStrDate(date
, sizeof(date
), jobtime
);
1457 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s",
1458 rank
, temp
, username
? username
: "unknown",
1459 1024.0 * size
, date
);
1461 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s",
1462 temp
, username
? username
: "unknown",
1463 1024.0 * size
, date
);
1467 _cupsLangPrintf(stdout
, _("\tStatus: %s"), message
);
1471 char alerts
[1024], /* Alerts string */
1472 *aptr
; /* Pointer into alerts string */
1474 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1477 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1479 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1481 aptr
+= strlen(aptr
);
1484 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1487 _cupsLangPrintf(stdout
, _("\tqueued for %s"), dest
);
1495 ippDelete(response
);
1503 * 'show_printers()' - Show printers.
1506 static int /* O - 0 on success, 1 on fail */
1507 show_printers(const char *printers
, /* I - Destinations */
1508 int num_dests
, /* I - Number of user-defined dests */
1509 cups_dest_t
*dests
, /* I - User-defined destinations */
1510 int long_status
) /* I - Show long status? */
1512 int i
, j
; /* Looping vars */
1513 ipp_t
*request
, /* IPP Request */
1514 *response
, /* IPP Response */
1515 *jobs
; /* IPP Get Jobs response */
1516 ipp_attribute_t
*attr
, /* Current attribute */
1517 *jobattr
, /* Job ID attribute */
1518 *reasons
; /* Job state reasons attribute */
1519 const char *printer
, /* Printer name */
1520 *message
, /* Printer state message */
1521 *description
, /* Description of printer */
1522 *location
, /* Location of printer */
1523 *make_model
, /* Make and model of printer */
1524 *uri
; /* URI of printer */
1525 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1526 *denied
; /* requestint-user-name-denied */
1527 ipp_pstate_t pstate
; /* Printer state */
1528 cups_ptype_t ptype
; /* Printer type */
1529 time_t ptime
; /* Printer state time */
1530 int jobid
; /* Job ID of current job */
1531 char printer_uri
[HTTP_MAX_URI
],
1533 printer_state_time
[255];/* Printer state time */
1534 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1535 static const char *pattrs
[] = /* Attributes we need for printers... */
1539 "printer-state-message",
1540 "printer-state-reasons",
1541 "printer-state-change-time",
1545 "printer-make-and-model",
1546 "printer-uri-supported",
1547 "requesting-user-name-allowed",
1548 "requesting-user-name-denied"
1550 static const char *jattrs
[] = /* Attributes we need for jobs... */
1557 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1561 * Build a CUPS_GET_PRINTERS request, which requires the following
1564 * attributes-charset
1565 * attributes-natural-language
1566 * requested-attributes
1567 * requesting-user-name
1570 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1572 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1573 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1576 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1580 * Do the request and get back a response...
1583 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1585 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1586 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1588 _cupsLangPrintf(stderr
,
1589 _("%s: Error - add '/version=1.1' to server name."),
1591 ippDelete(response
);
1594 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1596 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1597 ippDelete(response
);
1604 * Loop through the printers returned in the list and display
1608 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1611 * Skip leading attributes until we hit a job...
1614 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1621 * Pull the needed attributes from this job...
1626 ptype
= CUPS_PRINTER_LOCAL
;
1627 pstate
= IPP_PRINTER_IDLE
;
1638 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1640 if (!strcmp(attr
->name
, "printer-name") &&
1641 attr
->value_tag
== IPP_TAG_NAME
)
1642 printer
= attr
->values
[0].string
.text
;
1643 else if (!strcmp(attr
->name
, "printer-state") &&
1644 attr
->value_tag
== IPP_TAG_ENUM
)
1645 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1646 else if (!strcmp(attr
->name
, "printer-type") &&
1647 attr
->value_tag
== IPP_TAG_ENUM
)
1648 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1649 else if (!strcmp(attr
->name
, "printer-state-message") &&
1650 attr
->value_tag
== IPP_TAG_TEXT
)
1651 message
= attr
->values
[0].string
.text
;
1652 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1653 attr
->value_tag
== IPP_TAG_INTEGER
)
1654 ptime
= (time_t)attr
->values
[0].integer
;
1655 else if (!strcmp(attr
->name
, "printer-info") &&
1656 attr
->value_tag
== IPP_TAG_TEXT
)
1657 description
= attr
->values
[0].string
.text
;
1658 else if (!strcmp(attr
->name
, "printer-location") &&
1659 attr
->value_tag
== IPP_TAG_TEXT
)
1660 location
= attr
->values
[0].string
.text
;
1661 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1662 attr
->value_tag
== IPP_TAG_TEXT
)
1663 make_model
= attr
->values
[0].string
.text
;
1664 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1665 attr
->value_tag
== IPP_TAG_URI
)
1666 uri
= attr
->values
[0].string
.text
;
1667 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1668 attr
->value_tag
== IPP_TAG_KEYWORD
)
1670 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1671 attr
->value_tag
== IPP_TAG_NAME
)
1673 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1674 attr
->value_tag
== IPP_TAG_NAME
)
1681 * See if we have everything needed...
1684 if (printer
== NULL
)
1693 * Display the printer entry if needed...
1696 if (match_list(printers
, printer
))
1699 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1700 * current job for the printer.
1703 if (pstate
== IPP_PRINTER_PROCESSING
)
1706 * Build an IPP_GET_JOBS request, which requires the following
1709 * attributes-charset
1710 * attributes-natural-language
1713 * requested-attributes
1716 request
= ippNewRequest(IPP_GET_JOBS
);
1718 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1719 request
->request
.op
.request_id
= 1;
1721 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1722 "requested-attributes",
1723 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1725 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1726 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1727 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1728 "printer-uri", NULL
, printer_uri
);
1730 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1733 * Get the current active job on this queue...
1736 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1739 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1743 if (jobstate
== IPP_JOB_PROCESSING
)
1749 if (!strcmp(jobattr
->name
, "job-id") &&
1750 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1751 jobid
= jobattr
->values
[0].integer
;
1752 else if (!strcmp(jobattr
->name
, "job-state") &&
1753 jobattr
->value_tag
== IPP_TAG_ENUM
)
1754 jobstate
= (ipp_jstate_t
)jobattr
->values
[0].integer
;
1757 if (jobstate
!= IPP_JOB_PROCESSING
)
1768 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
1772 case IPP_PRINTER_IDLE
:
1773 if (ippContainsString(reasons
, "hold-new-jobs"))
1774 _cupsLangPrintf(stdout
, _("printer %s is holding new jobs. enabled since %s"), printer
, printer_state_time
);
1776 _cupsLangPrintf(stdout
, _("printer %s is idle. enabled since %s"), printer
, printer_state_time
);
1778 case IPP_PRINTER_PROCESSING
:
1779 _cupsLangPrintf(stdout
, _("printer %s now printing %s-%d. enabled since %s"), printer
, printer
, jobid
, printer_state_time
);
1781 case IPP_PRINTER_STOPPED
:
1782 _cupsLangPrintf(stdout
, _("printer %s disabled since %s -"), printer
, printer_state_time
);
1786 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1788 if (!message
|| !*message
)
1789 _cupsLangPuts(stdout
, _("\treason unknown"));
1791 _cupsLangPrintf(stdout
, "\t%s", message
);
1794 if (long_status
> 1)
1796 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1797 _cupsLangPuts(stdout
, _("\tContent types: any"));
1798 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1803 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1804 description
? description
: "");
1808 char alerts
[1024], /* Alerts string */
1809 *aptr
; /* Pointer into alerts string */
1811 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1814 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1816 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1818 aptr
+= strlen(aptr
);
1821 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1824 if (long_status
> 1)
1826 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1827 location
? location
: "");
1829 if (ptype
& CUPS_PRINTER_REMOTE
)
1831 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1833 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1834 !strstr(make_model
, "Raw Printer") && uri
)
1835 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"),
1840 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1842 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1843 _cupsLangPrintf(stdout
,
1844 _("\tInterface: %s/ppd/%s.ppd"),
1845 cg
->cups_serverroot
, printer
);
1847 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1848 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1849 /* TODO update to use printer-error-policy */
1852 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1853 for (j
= 0; j
< allowed
->num_values
; j
++)
1854 _cupsLangPrintf(stdout
, "\t\t%s",
1855 allowed
->values
[j
].string
.text
);
1859 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1860 for (j
= 0; j
< denied
->num_values
; j
++)
1861 _cupsLangPrintf(stdout
, "\t\t%s",
1862 denied
->values
[j
].string
.text
);
1866 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1867 _cupsLangPuts(stdout
, _("\t\t(all)"));
1869 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1870 _cupsLangPuts(stdout
, _("\t\t(none)"));
1871 _cupsLangPuts(stdout
, _("\tBanner required"));
1872 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1873 _cupsLangPuts(stdout
, _("\t\t(none)"));
1874 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1875 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1876 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1879 for (i
= 0; i
< num_dests
; i
++)
1880 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1884 case IPP_PRINTER_IDLE
:
1885 _cupsLangPrintf(stdout
,
1886 _("printer %s/%s is idle. "
1887 "enabled since %s"),
1888 printer
, dests
[i
].instance
,
1889 printer_state_time
);
1891 case IPP_PRINTER_PROCESSING
:
1892 _cupsLangPrintf(stdout
,
1893 _("printer %s/%s now printing %s-%d. "
1894 "enabled since %s"),
1895 printer
, dests
[i
].instance
, printer
, jobid
,
1896 printer_state_time
);
1898 case IPP_PRINTER_STOPPED
:
1899 _cupsLangPrintf(stdout
,
1900 _("printer %s/%s disabled since %s -"),
1901 printer
, dests
[i
].instance
,
1902 printer_state_time
);
1906 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1908 if (!message
|| !*message
)
1909 _cupsLangPuts(stdout
, _("\treason unknown"));
1911 _cupsLangPrintf(stdout
, "\t%s", message
);
1914 if (long_status
> 1)
1916 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1917 _cupsLangPuts(stdout
, _("\tContent types: any"));
1918 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1923 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1924 description
? description
: "");
1928 char alerts
[1024], /* Alerts string */
1929 *aptr
; /* Pointer into alerts string */
1931 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1934 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1936 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1938 aptr
+= strlen(aptr
);
1941 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1944 if (long_status
> 1)
1946 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1947 location
? location
: "");
1949 if (ptype
& CUPS_PRINTER_REMOTE
)
1951 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1953 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1954 !strstr(make_model
, "Raw Printer") && uri
)
1955 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"), uri
);
1959 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1961 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1962 _cupsLangPrintf(stdout
,
1963 _("\tInterface: %s/ppd/%s.ppd"),
1964 cg
->cups_serverroot
, printer
);
1966 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1967 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1968 /* TODO update to use printer-error-policy */
1971 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1972 for (j
= 0; j
< allowed
->num_values
; j
++)
1973 _cupsLangPrintf(stdout
, "\t\t%s",
1974 allowed
->values
[j
].string
.text
);
1978 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1979 for (j
= 0; j
< denied
->num_values
; j
++)
1980 _cupsLangPrintf(stdout
, "\t\t%s",
1981 denied
->values
[j
].string
.text
);
1985 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1986 _cupsLangPuts(stdout
, _("\t\t(all)"));
1988 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1989 _cupsLangPuts(stdout
, _("\t\t(none)"));
1990 _cupsLangPuts(stdout
, _("\tBanner required"));
1991 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1992 _cupsLangPuts(stdout
, _("\t\t(none)"));
1993 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1994 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1995 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
2004 ippDelete(response
);
2012 * 'show_scheduler()' - Show scheduler status.
2016 show_scheduler(void)
2018 http_t
*http
; /* Connection to server */
2021 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
2022 cupsEncryption())) != NULL
)
2024 _cupsLangPuts(stdout
, _("scheduler is running"));
2028 _cupsLangPuts(stdout
, _("scheduler is not running"));