2 * "lpstat" command for CUPS.
4 * Copyright 2007-2017 by Apple Inc.
5 * Copyright 1997-2006 by Easy Software Products.
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 * which should have been included with this file. If this file is
11 * missing or damaged, see the license at "http://www.cups.org/".
15 * Include necessary headers...
18 #include <cups/cups-private.h>
25 static void check_dest(const char *command
, const char *name
,
26 int *num_dests
, cups_dest_t
**dests
);
27 static int match_list(const char *list
, const char *name
);
28 static int show_accepting(const char *printers
, int num_dests
,
30 static int show_classes(const char *dests
);
31 static void show_default(cups_dest_t
*dest
);
32 static int show_devices(const char *printers
, int num_dests
,
34 static int show_jobs(const char *dests
, const char *users
, int long_status
,
35 int ranking
, const char *which
);
36 static int show_printers(const char *printers
, int num_dests
,
37 cups_dest_t
*dests
, int long_status
);
38 static void show_scheduler(void);
42 * 'main()' - Parse options and show status information.
46 main(int argc
, /* I - Number of command-line arguments */
47 char *argv
[]) /* I - Command-line arguments */
49 int i
, /* Looping var */
50 status
; /* Exit status */
51 char *opt
; /* Option pointer */
52 int num_dests
; /* Number of user destinations */
53 cups_dest_t
*dests
; /* User destinations */
54 int long_status
; /* Long status report? */
55 int ranking
; /* Show job ranking? */
56 const char *which
; /* Which jobs to show? */
57 char op
; /* Last operation on command-line */
63 * Parse command-line options...
71 which
= "not-completed";
74 for (i
= 1; i
< argc
; i
++)
76 if (argv
[i
][0] == '-')
78 for (opt
= argv
[i
] + 1; *opt
; opt
++)
82 case 'D' : /* Show description */
86 case 'E' : /* Encrypt */
88 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
90 _cupsLangPrintf(stderr
,
91 _("%s: Sorry, no encryption support."),
96 case 'H' : /* Show server and port */
97 if (cupsServer()[0] == '/')
98 _cupsLangPuts(stdout
, cupsServer());
100 _cupsLangPrintf(stdout
, "%s:%d", cupsServer(), ippPort());
104 case 'P' : /* Show paper types */
108 case 'R' : /* Show ranking */
112 case 'S' : /* Show charsets */
118 case 'U' : /* Username */
121 cupsSetUser(opt
+ 1);
122 opt
+= strlen(opt
) - 1;
129 _cupsLangPrintf(stderr
, _("%s: Error - expected username after \"-U\" option."), argv
[0]);
133 cupsSetUser(argv
[i
]);
137 case 'W' : /* Show which jobs? */
141 opt
+= strlen(opt
) - 1;
149 _cupsLangPrintf(stderr
, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv
[0]);
156 if (strcmp(which
, "completed") && strcmp(which
, "not-completed") && strcmp(which
, "all"))
158 _cupsLangPrintf(stderr
, _("%s: Error - need \"completed\", \"not-completed\", or \"all\" after \"-W\" option."), argv
[0]);
163 case 'a' : /* Show acceptance status */
168 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
170 status
|= show_accepting(opt
+ 1, num_dests
, dests
);
171 opt
+= strlen(opt
) - 1;
173 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
177 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
179 status
|= show_accepting(argv
[i
], num_dests
, dests
);
185 cupsFreeDests(num_dests
, dests
);
186 num_dests
= cupsGetDests(&dests
);
188 if (num_dests
== 0 && (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
|| cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
190 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
195 status
|= show_accepting(NULL
, num_dests
, dests
);
199 case 'c' : /* Show classes and members */
204 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
206 status
|= show_classes(opt
+ 1);
207 opt
+= strlen(opt
) - 1;
209 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
213 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
215 status
|= show_classes(argv
[i
]);
218 status
|= show_classes(NULL
);
221 case 'd' : /* Show default destination */
224 if (num_dests
!= 1 || !dests
[0].is_default
)
226 cupsFreeDests(num_dests
, dests
);
228 dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, NULL
, NULL
);
229 num_dests
= dests
? 1 : 0;
231 if (num_dests
== 0 &&
232 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
233 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
235 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
243 case 'e' : /* List destinations */
245 cups_dest_t
*temp
= NULL
, *dest
;
246 int j
, num_temp
= cupsGetDests(&temp
);
250 for (j
= num_temp
, dest
= temp
; j
> 0; j
--, dest
++)
253 printf("%s/%s", dest
->name
, dest
->instance
);
255 fputs(dest
->name
, stdout
);
258 printf(" %s\n", cupsGetOption("device-uri", dest
->num_options
, dest
->options
));
263 cupsFreeDests(num_temp
, temp
);
267 case 'f' : /* Show forms */
271 opt
+= strlen(opt
) - 1;
281 case 'h' : /* Connect to host */
284 cupsSetServer(opt
+ 1);
285 opt
+= strlen(opt
) - 1;
293 _cupsLangPrintf(stderr
, _("%s: Error - expected hostname after \"-h\" option."), argv
[0]);
297 cupsSetServer(argv
[i
]);
301 case 'l' : /* Long status or long job status */
305 case 'o' : /* Show jobs by destination */
310 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
312 status
|= show_jobs(opt
+ 1, NULL
, long_status
, ranking
, which
);
313 opt
+= strlen(opt
) - 1;
315 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
319 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
321 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
324 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
327 case 'p' : /* Show printers */
332 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
334 status
|= show_printers(opt
+ 1, num_dests
, dests
,
336 opt
+= strlen(opt
) - 1;
338 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
342 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
344 status
|= show_printers(argv
[i
], num_dests
, dests
, long_status
);
350 cupsFreeDests(num_dests
, dests
);
351 num_dests
= cupsGetDests(&dests
);
353 if (num_dests
== 0 &&
354 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
355 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
357 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
362 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
366 case 'r' : /* Show scheduler status */
372 case 's' : /* Show summary */
377 cupsFreeDests(num_dests
, dests
);
378 num_dests
= cupsGetDests(&dests
);
380 if (num_dests
== 0 &&
381 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
382 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
384 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
389 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
390 status
|= show_classes(NULL
);
391 status
|= show_devices(NULL
, num_dests
, dests
);
394 case 't' : /* Show all info */
399 cupsFreeDests(num_dests
, dests
);
400 num_dests
= cupsGetDests(&dests
);
402 if (num_dests
== 0 &&
403 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
404 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
406 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
412 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
413 status
|= show_classes(NULL
);
414 status
|= show_devices(NULL
, num_dests
, dests
);
415 status
|= show_accepting(NULL
, num_dests
, dests
);
416 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
417 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
420 case 'u' : /* Show jobs by user */
425 status
|= show_jobs(NULL
, opt
+ 1, long_status
, ranking
, which
);
426 opt
+= strlen(opt
) - 1;
428 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
431 status
|= show_jobs(NULL
, argv
[i
], long_status
, ranking
, which
);
434 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
437 case 'v' : /* Show printer devices */
442 check_dest(argv
[0], opt
+ 1, &num_dests
, &dests
);
444 status
|= show_devices(opt
+ 1, num_dests
, dests
);
445 opt
+= strlen(opt
) - 1;
447 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
451 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
453 status
|= show_devices(argv
[i
], num_dests
, dests
);
459 cupsFreeDests(num_dests
, dests
);
460 num_dests
= cupsGetDests(&dests
);
462 if (num_dests
== 0 &&
463 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
464 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
466 _cupsLangPrintf(stderr
, _("%s: Error - add '/version=1.1' to server name."), argv
[0]);
471 status
|= show_devices(NULL
, num_dests
, dests
);
476 _cupsLangPrintf(stderr
, _("%s: Error - unknown option \"%c\"."), argv
[0], argv
[i
][1]);
483 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
489 status
|= show_jobs(NULL
, cupsUser(), long_status
, ranking
, which
);
496 * 'check_dest()' - Verify that the named destination(s) exists.
500 check_dest(const char *command
, /* I - Command name */
501 const char *name
, /* I - List of printer/class names */
502 int *num_dests
, /* IO - Number of destinations */
503 cups_dest_t
**dests
) /* IO - Destinations */
505 const char *dptr
; /* Pointer into name */
506 char *pptr
, /* Pointer into printer */
507 printer
[1024]; /* Current printer/class name */
511 * Load the destination list as necessary...
517 cupsFreeDests(*num_dests
, *dests
);
519 if (strchr(name
, ','))
520 *num_dests
= cupsGetDests(dests
);
523 strlcpy(printer
, name
, sizeof(printer
));
524 if ((pptr
= strchr(printer
, '/')) != NULL
)
527 if ((*dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, printer
, pptr
)) == NULL
)
529 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
530 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
531 _cupsLangPrintf(stderr
,
532 _("%s: Error - add '/version=1.1' to server name."),
535 _cupsLangPrintf(stderr
,
536 _("%s: Invalid destination name in list \"%s\"."),
550 * Scan the name string for printer/class name(s)...
553 for (dptr
= name
; *dptr
;)
556 * Skip leading whitespace and commas...
559 while (isspace(*dptr
& 255) || *dptr
== ',')
566 * Extract a single destination name from the name string...
569 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
;)
571 if ((size_t)(pptr
- printer
) < (sizeof(printer
) - 1))
575 _cupsLangPrintf(stderr
,
576 _("%s: Invalid destination name in list \"%s\"."),
585 * Check the destination...
588 if (!cupsGetDest(printer
, NULL
, *num_dests
, *dests
))
590 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
591 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
592 _cupsLangPrintf(stderr
,
593 _("%s: Error - add '/version=1.1' to server name."),
596 _cupsLangPrintf(stderr
,
597 _("%s: Unknown destination \"%s\"."), command
, printer
);
606 * 'match_list()' - Match a name from a list of comma or space-separated names.
609 static int /* O - 1 on match, 0 on no match */
610 match_list(const char *list
, /* I - List of names */
611 const char *name
) /* I - Name to find */
613 const char *nameptr
; /* Pointer into name */
617 * An empty list always matches...
629 * Skip leading whitespace and commas...
632 while (isspace(*list
& 255) || *list
== ',')
643 *nameptr
&& *list
&& tolower(*nameptr
& 255) == tolower(*list
& 255);
644 nameptr
++, list
++);
646 if (!*nameptr
&& (!*list
|| *list
== ',' || isspace(*list
& 255)))
649 while (*list
&& !isspace(*list
& 255) && *list
!= ',')
658 * 'show_accepting()' - Show acceptance status.
661 static int /* O - 0 on success, 1 on fail */
662 show_accepting(const char *printers
, /* I - Destinations */
663 int num_dests
, /* I - Number of user-defined dests */
664 cups_dest_t
*dests
) /* I - User-defined destinations */
666 int i
; /* Looping var */
667 ipp_t
*request
, /* IPP Request */
668 *response
; /* IPP Response */
669 ipp_attribute_t
*attr
; /* Current attribute */
670 const char *printer
, /* Printer name */
671 *message
; /* Printer device URI */
672 int accepting
; /* Accepting requests? */
673 time_t ptime
; /* Printer state time */
674 char printer_state_time
[255];/* Printer state time */
675 static const char *pattrs
[] = /* Attributes we need for printers... */
678 "printer-state-change-time",
679 "printer-state-message",
680 "printer-is-accepting-jobs"
684 DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers
));
686 if (printers
!= NULL
&& !strcmp(printers
, "all"))
690 * Build a CUPS_GET_PRINTERS request, which requires the following
694 * attributes-natural-language
695 * requested-attributes
696 * requesting-user-name
699 request
= ippNewRequest(CUPS_GET_PRINTERS
);
701 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
702 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
705 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
709 * Do the request and get back a response...
712 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
714 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
715 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
717 _cupsLangPrintf(stderr
,
718 _("%s: Error - add '/version=1.1' to server name."),
723 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
725 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
732 DEBUG_puts("show_accepting: request succeeded...");
735 * Loop through the printers returned in the list and display
739 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
742 * Skip leading attributes until we hit a printer...
745 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
752 * Pull the needed attributes from this printer...
760 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
762 if (!strcmp(attr
->name
, "printer-name") &&
763 attr
->value_tag
== IPP_TAG_NAME
)
764 printer
= attr
->values
[0].string
.text
;
765 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
766 attr
->value_tag
== IPP_TAG_INTEGER
)
767 ptime
= (time_t)attr
->values
[0].integer
;
768 else if (!strcmp(attr
->name
, "printer-state-message") &&
769 attr
->value_tag
== IPP_TAG_TEXT
)
770 message
= attr
->values
[0].string
.text
;
771 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
772 attr
->value_tag
== IPP_TAG_BOOLEAN
)
773 accepting
= attr
->values
[0].boolean
;
779 * See if we have everything needed...
791 * Display the printer entry if needed...
794 if (match_list(printers
, printer
))
796 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
799 _cupsLangPrintf(stdout
, _("%s accepting requests since %s"),
800 printer
, printer_state_time
);
803 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -"),
804 printer
, printer_state_time
);
805 _cupsLangPrintf(stdout
, _("\t%s"),
806 (message
== NULL
|| !*message
) ?
807 "reason unknown" : message
);
810 for (i
= 0; i
< num_dests
; i
++)
811 if (!_cups_strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
814 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s"),
815 printer
, dests
[i
].instance
, printer_state_time
);
818 _cupsLangPrintf(stdout
,
819 _("%s/%s not accepting requests since %s -"),
820 printer
, dests
[i
].instance
, printer_state_time
);
821 _cupsLangPrintf(stdout
, _("\t%s"),
822 (message
== NULL
|| !*message
) ?
823 "reason unknown" : message
);
840 * 'show_classes()' - Show printer classes.
843 static int /* O - 0 on success, 1 on fail */
844 show_classes(const char *dests
) /* I - Destinations */
846 int i
; /* Looping var */
847 ipp_t
*request
, /* IPP Request */
848 *response
, /* IPP Response */
849 *response2
; /* IPP response from remote server */
850 http_t
*http2
; /* Remote server */
851 ipp_attribute_t
*attr
; /* Current attribute */
852 const char *printer
, /* Printer class name */
853 *printer_uri
; /* Printer class URI */
854 ipp_attribute_t
*members
; /* Printer members */
855 char method
[HTTP_MAX_URI
], /* Request method */
856 username
[HTTP_MAX_URI
], /* Username:password */
857 server
[HTTP_MAX_URI
], /* Server name */
858 resource
[HTTP_MAX_URI
]; /* Resource name */
859 int port
; /* Port number */
860 static const char *cattrs
[] = /* Attributes we need for classes... */
863 "printer-uri-supported",
868 DEBUG_printf(("show_classes(dests=\"%s\")\n", dests
));
870 if (dests
!= NULL
&& !strcmp(dests
, "all"))
874 * Build a CUPS_GET_CLASSES request, which requires the following
878 * attributes-natural-language
879 * requested-attributes
880 * requesting-user-name
883 request
= ippNewRequest(CUPS_GET_CLASSES
);
885 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
886 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
889 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
893 * Do the request and get back a response...
896 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
898 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
899 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
901 _cupsLangPrintf(stderr
,
902 _("%s: Error - add '/version=1.1' to server name."),
907 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
909 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
916 DEBUG_puts("show_classes: request succeeded...");
918 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
920 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
926 * Loop through the printers returned in the list and display
930 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
933 * Skip leading attributes until we hit a job...
936 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
943 * Pull the needed attributes from this job...
950 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
952 if (!strcmp(attr
->name
, "printer-name") &&
953 attr
->value_tag
== IPP_TAG_NAME
)
954 printer
= attr
->values
[0].string
.text
;
956 if (!strcmp(attr
->name
, "printer-uri-supported") &&
957 attr
->value_tag
== IPP_TAG_URI
)
958 printer_uri
= attr
->values
[0].string
.text
;
960 if (!strcmp(attr
->name
, "member-names") &&
961 attr
->value_tag
== IPP_TAG_NAME
)
968 * If this is a remote class, grab the class info from the
973 if (members
== NULL
&& printer_uri
!= NULL
)
975 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
976 username
, sizeof(username
), server
, sizeof(server
),
977 &port
, resource
, sizeof(resource
));
979 if (!_cups_strcasecmp(server
, cupsServer()))
980 http2
= CUPS_HTTP_DEFAULT
;
982 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
985 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
986 * following attributes:
989 * attributes-natural-language
991 * requested-attributes
994 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
996 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
997 "printer-uri", NULL
, printer_uri
);
999 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1000 "requested-attributes",
1001 sizeof(cattrs
) / sizeof(cattrs
[0]),
1004 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
1005 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
1012 * See if we have everything needed...
1015 if (printer
== NULL
)
1018 ippDelete(response2
);
1027 * Display the printer entry if needed...
1030 if (match_list(dests
, printer
))
1032 _cupsLangPrintf(stdout
, _("members of class %s:"), printer
);
1036 for (i
= 0; i
< members
->num_values
; i
++)
1037 _cupsLangPrintf(stdout
, "\t%s", members
->values
[i
].string
.text
);
1040 _cupsLangPuts(stdout
, "\tunknown");
1044 ippDelete(response2
);
1050 ippDelete(response
);
1058 * 'show_default()' - Show default destination.
1062 show_default(cups_dest_t
*dest
) /* I - Default destination */
1064 const char *printer
, /* Printer name */
1065 *val
; /* Environment variable name */
1071 _cupsLangPrintf(stdout
, _("system default destination: %s/%s"),
1072 dest
->name
, dest
->instance
);
1074 _cupsLangPrintf(stdout
, _("system default destination: %s"),
1081 if ((printer
= getenv("LPDEST")) == NULL
)
1083 if ((printer
= getenv("PRINTER")) != NULL
)
1085 if (!strcmp(printer
, "lp"))
1095 _cupsLangPrintf(stdout
,
1096 _("lpstat: error - %s environment variable names "
1097 "non-existent destination \"%s\"."),
1100 _cupsLangPuts(stdout
, _("no system default destination"));
1106 * 'show_devices()' - Show printer devices.
1109 static int /* O - 0 on success, 1 on fail */
1110 show_devices(const char *printers
, /* I - Destinations */
1111 int num_dests
, /* I - Number of user-defined dests */
1112 cups_dest_t
*dests
) /* I - User-defined destinations */
1114 int i
; /* Looping var */
1115 ipp_t
*request
, /* IPP Request */
1116 *response
; /* IPP Response */
1117 ipp_attribute_t
*attr
; /* Current attribute */
1118 const char *printer
, /* Printer name */
1119 *uri
, /* Printer URI */
1120 *device
; /* Printer device URI */
1121 static const char *pattrs
[] = /* Attributes we need for printers... */
1124 "printer-uri-supported",
1129 DEBUG_printf(("show_devices(printers=\"%s\")\n", printers
));
1131 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1135 * Build a CUPS_GET_PRINTERS request, which requires the following
1138 * attributes-charset
1139 * attributes-natural-language
1140 * requested-attributes
1141 * requesting-user-name
1144 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1146 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1147 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1150 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1154 * Do the request and get back a response...
1157 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1159 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1160 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1162 _cupsLangPrintf(stderr
,
1163 _("%s: Error - add '/version=1.1' to server name."),
1165 ippDelete(response
);
1168 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1170 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1171 ippDelete(response
);
1177 DEBUG_puts("show_devices: request succeeded...");
1180 * Loop through the printers returned in the list and display
1184 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1187 * Skip leading attributes until we hit a job...
1190 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1197 * Pull the needed attributes from this job...
1204 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1206 if (!strcmp(attr
->name
, "printer-name") &&
1207 attr
->value_tag
== IPP_TAG_NAME
)
1208 printer
= attr
->values
[0].string
.text
;
1210 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1211 attr
->value_tag
== IPP_TAG_URI
)
1212 uri
= attr
->values
[0].string
.text
;
1214 if (!strcmp(attr
->name
, "device-uri") &&
1215 attr
->value_tag
== IPP_TAG_URI
)
1216 device
= attr
->values
[0].string
.text
;
1222 * See if we have everything needed...
1225 if (printer
== NULL
)
1234 * Display the printer entry if needed...
1237 if (match_list(printers
, printer
))
1240 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1242 else if (!strncmp(device
, "file:", 5))
1243 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1244 printer
, device
+ 5);
1246 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1249 for (i
= 0; i
< num_dests
; i
++)
1251 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1254 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1255 printer
, dests
[i
].instance
, uri
);
1256 else if (!strncmp(device
, "file:", 5))
1257 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1258 printer
, dests
[i
].instance
, device
+ 5);
1260 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1261 printer
, dests
[i
].instance
, device
);
1270 ippDelete(response
);
1278 * 'show_jobs()' - Show active print jobs.
1281 static int /* O - 0 on success, 1 on fail */
1282 show_jobs(const char *dests
, /* I - Destinations */
1283 const char *users
, /* I - Users */
1284 int long_status
, /* I - Show long status? */
1285 int ranking
, /* I - Show job ranking? */
1286 const char *which
) /* I - Show which jobs? */
1288 int i
; /* Looping var */
1289 ipp_t
*request
, /* IPP Request */
1290 *response
; /* IPP Response */
1291 ipp_attribute_t
*attr
, /* Current attribute */
1292 *reasons
; /* Job state reasons attribute */
1293 const char *dest
, /* Pointer into job-printer-uri */
1294 *username
, /* Pointer to job-originating-user-name */
1295 *message
, /* Pointer to job-printer-state-message */
1296 *time_at
; /* time-at-xxx attribute name to use */
1297 int rank
, /* Rank in queue */
1299 size
; /* job-k-octets */
1300 time_t jobtime
; /* time-at-creation */
1301 char temp
[255], /* Temporary buffer */
1302 date
[255]; /* Date buffer */
1303 static const char *jattrs
[] = /* Attributes we need for jobs... */
1308 "job-originating-user-name",
1309 "job-printer-state-message",
1311 "job-state-reasons",
1317 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1318 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1321 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1325 * Build a IPP_GET_JOBS request, which requires the following
1328 * attributes-charset
1329 * attributes-natural-language
1331 * requested-attributes
1332 * requesting-user-name
1336 request
= ippNewRequest(IPP_GET_JOBS
);
1338 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1339 NULL
, "ipp://localhost/");
1341 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1342 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1345 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1348 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1352 * Do the request and get back a response...
1355 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1357 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1358 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1360 _cupsLangPrintf(stderr
,
1361 _("%s: Error - add '/version=1.1' to server name."),
1363 ippDelete(response
);
1366 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1368 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1369 ippDelete(response
);
1376 * Loop through the job list and display them...
1379 if (!strcmp(which
, "aborted") ||
1380 !strcmp(which
, "canceled") ||
1381 !strcmp(which
, "completed"))
1382 time_at
= "time-at-completed";
1384 time_at
= "time-at-creation";
1388 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1391 * Skip leading attributes until we hit a job...
1394 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1401 * Pull the needed attributes from this job...
1412 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1414 if (!strcmp(attr
->name
, "job-id") &&
1415 attr
->value_tag
== IPP_TAG_INTEGER
)
1416 jobid
= attr
->values
[0].integer
;
1417 else if (!strcmp(attr
->name
, "job-k-octets") &&
1418 attr
->value_tag
== IPP_TAG_INTEGER
)
1419 size
= attr
->values
[0].integer
;
1420 else if (!strcmp(attr
->name
, time_at
) && attr
->value_tag
== IPP_TAG_INTEGER
)
1421 jobtime
= attr
->values
[0].integer
;
1422 else if (!strcmp(attr
->name
, "job-printer-state-message") &&
1423 attr
->value_tag
== IPP_TAG_TEXT
)
1424 message
= attr
->values
[0].string
.text
;
1425 else if (!strcmp(attr
->name
, "job-printer-uri") &&
1426 attr
->value_tag
== IPP_TAG_URI
)
1428 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1431 else if (!strcmp(attr
->name
, "job-originating-user-name") &&
1432 attr
->value_tag
== IPP_TAG_NAME
)
1433 username
= attr
->values
[0].string
.text
;
1434 else if (!strcmp(attr
->name
, "job-state-reasons") &&
1435 attr
->value_tag
== IPP_TAG_KEYWORD
)
1442 * See if we have everything needed...
1445 if (dest
== NULL
|| jobid
== 0)
1454 * Display the job...
1459 if (match_list(dests
, dest
) && match_list(users
, username
))
1461 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1463 _cupsStrDate(date
, sizeof(date
), jobtime
);
1466 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s",
1467 rank
, temp
, username
? username
: "unknown",
1468 1024.0 * size
, date
);
1470 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s",
1471 temp
, username
? username
: "unknown",
1472 1024.0 * size
, date
);
1476 _cupsLangPrintf(stdout
, _("\tStatus: %s"), message
);
1480 char alerts
[1024], /* Alerts string */
1481 *aptr
; /* Pointer into alerts string */
1483 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1486 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1488 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1490 aptr
+= strlen(aptr
);
1493 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1496 _cupsLangPrintf(stdout
, _("\tqueued for %s"), dest
);
1504 ippDelete(response
);
1512 * 'show_printers()' - Show printers.
1515 static int /* O - 0 on success, 1 on fail */
1516 show_printers(const char *printers
, /* I - Destinations */
1517 int num_dests
, /* I - Number of user-defined dests */
1518 cups_dest_t
*dests
, /* I - User-defined destinations */
1519 int long_status
) /* I - Show long status? */
1521 int i
, j
; /* Looping vars */
1522 ipp_t
*request
, /* IPP Request */
1523 *response
, /* IPP Response */
1524 *jobs
; /* IPP Get Jobs response */
1525 ipp_attribute_t
*attr
, /* Current attribute */
1526 *jobattr
, /* Job ID attribute */
1527 *reasons
; /* Job state reasons attribute */
1528 const char *printer
, /* Printer name */
1529 *message
, /* Printer state message */
1530 *description
, /* Description of printer */
1531 *location
, /* Location of printer */
1532 *make_model
, /* Make and model of printer */
1533 *uri
; /* URI of printer */
1534 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1535 *denied
; /* requestint-user-name-denied */
1536 ipp_pstate_t pstate
; /* Printer state */
1537 cups_ptype_t ptype
; /* Printer type */
1538 time_t ptime
; /* Printer state time */
1539 int jobid
; /* Job ID of current job */
1540 char printer_uri
[HTTP_MAX_URI
],
1542 printer_state_time
[255];/* Printer state time */
1543 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1544 static const char *pattrs
[] = /* Attributes we need for printers... */
1548 "printer-state-message",
1549 "printer-state-reasons",
1550 "printer-state-change-time",
1554 "printer-make-and-model",
1555 "printer-uri-supported",
1556 "requesting-user-name-allowed",
1557 "requesting-user-name-denied"
1559 static const char *jattrs
[] = /* Attributes we need for jobs... */
1566 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1567 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1569 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1573 * Build a CUPS_GET_PRINTERS request, which requires the following
1576 * attributes-charset
1577 * attributes-natural-language
1578 * requested-attributes
1579 * requesting-user-name
1582 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1584 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1585 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1588 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1592 * Do the request and get back a response...
1595 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1597 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1598 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1600 _cupsLangPrintf(stderr
,
1601 _("%s: Error - add '/version=1.1' to server name."),
1603 ippDelete(response
);
1606 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1608 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1609 ippDelete(response
);
1615 DEBUG_puts("show_printers: request succeeded...");
1618 * Loop through the printers returned in the list and display
1622 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1625 * Skip leading attributes until we hit a job...
1628 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1635 * Pull the needed attributes from this job...
1640 ptype
= CUPS_PRINTER_LOCAL
;
1641 pstate
= IPP_PRINTER_IDLE
;
1652 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1654 if (!strcmp(attr
->name
, "printer-name") &&
1655 attr
->value_tag
== IPP_TAG_NAME
)
1656 printer
= attr
->values
[0].string
.text
;
1657 else if (!strcmp(attr
->name
, "printer-state") &&
1658 attr
->value_tag
== IPP_TAG_ENUM
)
1659 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1660 else if (!strcmp(attr
->name
, "printer-type") &&
1661 attr
->value_tag
== IPP_TAG_ENUM
)
1662 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1663 else if (!strcmp(attr
->name
, "printer-state-message") &&
1664 attr
->value_tag
== IPP_TAG_TEXT
)
1665 message
= attr
->values
[0].string
.text
;
1666 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1667 attr
->value_tag
== IPP_TAG_INTEGER
)
1668 ptime
= (time_t)attr
->values
[0].integer
;
1669 else if (!strcmp(attr
->name
, "printer-info") &&
1670 attr
->value_tag
== IPP_TAG_TEXT
)
1671 description
= attr
->values
[0].string
.text
;
1672 else if (!strcmp(attr
->name
, "printer-location") &&
1673 attr
->value_tag
== IPP_TAG_TEXT
)
1674 location
= attr
->values
[0].string
.text
;
1675 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1676 attr
->value_tag
== IPP_TAG_TEXT
)
1677 make_model
= attr
->values
[0].string
.text
;
1678 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1679 attr
->value_tag
== IPP_TAG_URI
)
1680 uri
= attr
->values
[0].string
.text
;
1681 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1682 attr
->value_tag
== IPP_TAG_KEYWORD
)
1684 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1685 attr
->value_tag
== IPP_TAG_NAME
)
1687 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1688 attr
->value_tag
== IPP_TAG_NAME
)
1695 * See if we have everything needed...
1698 if (printer
== NULL
)
1707 * Display the printer entry if needed...
1710 if (match_list(printers
, printer
))
1713 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1714 * current job for the printer.
1717 if (pstate
== IPP_PRINTER_PROCESSING
)
1720 * Build an IPP_GET_JOBS request, which requires the following
1723 * attributes-charset
1724 * attributes-natural-language
1727 * requested-attributes
1730 request
= ippNewRequest(IPP_GET_JOBS
);
1732 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1733 request
->request
.op
.request_id
= 1;
1735 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1736 "requested-attributes",
1737 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1739 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1740 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1741 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1742 "printer-uri", NULL
, printer_uri
);
1744 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1747 * Get the current active job on this queue...
1750 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1753 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1757 if (jobstate
== IPP_JOB_PROCESSING
)
1763 if (!strcmp(jobattr
->name
, "job-id") &&
1764 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1765 jobid
= jobattr
->values
[0].integer
;
1766 else if (!strcmp(jobattr
->name
, "job-state") &&
1767 jobattr
->value_tag
== IPP_TAG_ENUM
)
1768 jobstate
= (ipp_jstate_t
)jobattr
->values
[0].integer
;
1771 if (jobstate
!= IPP_JOB_PROCESSING
)
1782 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
1786 case IPP_PRINTER_IDLE
:
1787 _cupsLangPrintf(stdout
,
1788 _("printer %s is idle. enabled since %s"),
1789 printer
, printer_state_time
);
1791 case IPP_PRINTER_PROCESSING
:
1792 _cupsLangPrintf(stdout
,
1793 _("printer %s now printing %s-%d. "
1794 "enabled since %s"),
1795 printer
, printer
, jobid
, printer_state_time
);
1797 case IPP_PRINTER_STOPPED
:
1798 _cupsLangPrintf(stdout
,
1799 _("printer %s disabled since %s -"),
1800 printer
, printer_state_time
);
1804 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1806 if (!message
|| !*message
)
1807 _cupsLangPuts(stdout
, _("\treason unknown"));
1809 _cupsLangPrintf(stdout
, "\t%s", message
);
1812 if (long_status
> 1)
1814 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1815 _cupsLangPuts(stdout
, _("\tContent types: any"));
1816 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1821 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1822 description
? description
: "");
1826 char alerts
[1024], /* Alerts string */
1827 *aptr
; /* Pointer into alerts string */
1829 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1832 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1834 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1836 aptr
+= strlen(aptr
);
1839 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1842 if (long_status
> 1)
1844 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1845 location
? location
: "");
1847 if (ptype
& CUPS_PRINTER_REMOTE
)
1849 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1851 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1852 !strstr(make_model
, "Raw Printer") && uri
)
1853 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"),
1858 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1860 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1861 _cupsLangPrintf(stdout
,
1862 _("\tInterface: %s/ppd/%s.ppd"),
1863 cg
->cups_serverroot
, printer
);
1865 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1866 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1867 /* TODO update to use printer-error-policy */
1870 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1871 for (j
= 0; j
< allowed
->num_values
; j
++)
1872 _cupsLangPrintf(stdout
, "\t\t%s",
1873 allowed
->values
[j
].string
.text
);
1877 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1878 for (j
= 0; j
< denied
->num_values
; j
++)
1879 _cupsLangPrintf(stdout
, "\t\t%s",
1880 denied
->values
[j
].string
.text
);
1884 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1885 _cupsLangPuts(stdout
, _("\t\t(all)"));
1887 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1888 _cupsLangPuts(stdout
, _("\t\t(none)"));
1889 _cupsLangPuts(stdout
, _("\tBanner required"));
1890 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1891 _cupsLangPuts(stdout
, _("\t\t(none)"));
1892 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1893 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1894 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1897 for (i
= 0; i
< num_dests
; i
++)
1898 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1902 case IPP_PRINTER_IDLE
:
1903 _cupsLangPrintf(stdout
,
1904 _("printer %s/%s is idle. "
1905 "enabled since %s"),
1906 printer
, dests
[i
].instance
,
1907 printer_state_time
);
1909 case IPP_PRINTER_PROCESSING
:
1910 _cupsLangPrintf(stdout
,
1911 _("printer %s/%s now printing %s-%d. "
1912 "enabled since %s"),
1913 printer
, dests
[i
].instance
, printer
, jobid
,
1914 printer_state_time
);
1916 case IPP_PRINTER_STOPPED
:
1917 _cupsLangPrintf(stdout
,
1918 _("printer %s/%s disabled since %s -"),
1919 printer
, dests
[i
].instance
,
1920 printer_state_time
);
1924 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1926 if (!message
|| !*message
)
1927 _cupsLangPuts(stdout
, _("\treason unknown"));
1929 _cupsLangPrintf(stdout
, "\t%s", message
);
1932 if (long_status
> 1)
1934 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1935 _cupsLangPuts(stdout
, _("\tContent types: any"));
1936 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1941 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1942 description
? description
: "");
1946 char alerts
[1024], /* Alerts string */
1947 *aptr
; /* Pointer into alerts string */
1949 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1952 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1954 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1956 aptr
+= strlen(aptr
);
1959 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1962 if (long_status
> 1)
1964 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1965 location
? location
: "");
1967 if (ptype
& CUPS_PRINTER_REMOTE
)
1969 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1971 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1972 !strstr(make_model
, "Raw Printer") && uri
)
1973 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"), uri
);
1977 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1979 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1980 _cupsLangPrintf(stdout
,
1981 _("\tInterface: %s/ppd/%s.ppd"),
1982 cg
->cups_serverroot
, printer
);
1984 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1985 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1986 /* TODO update to use printer-error-policy */
1989 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1990 for (j
= 0; j
< allowed
->num_values
; j
++)
1991 _cupsLangPrintf(stdout
, "\t\t%s",
1992 allowed
->values
[j
].string
.text
);
1996 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1997 for (j
= 0; j
< denied
->num_values
; j
++)
1998 _cupsLangPrintf(stdout
, "\t\t%s",
1999 denied
->values
[j
].string
.text
);
2003 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
2004 _cupsLangPuts(stdout
, _("\t\t(all)"));
2006 _cupsLangPuts(stdout
, _("\tForms allowed:"));
2007 _cupsLangPuts(stdout
, _("\t\t(none)"));
2008 _cupsLangPuts(stdout
, _("\tBanner required"));
2009 _cupsLangPuts(stdout
, _("\tCharset sets:"));
2010 _cupsLangPuts(stdout
, _("\t\t(none)"));
2011 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
2012 _cupsLangPuts(stdout
, _("\tDefault page size:"));
2013 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
2022 ippDelete(response
);
2030 * 'show_scheduler()' - Show scheduler status.
2034 show_scheduler(void)
2036 http_t
*http
; /* Connection to server */
2039 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
2040 cupsEncryption())) != NULL
)
2042 _cupsLangPuts(stdout
, _("scheduler is running"));
2046 _cupsLangPuts(stdout
, _("scheduler is not running"));