2 * "lpstat" command for CUPS.
4 * Copyright 2007-2014 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 * file is 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 int num_dests
; /* Number of user destinations */
52 cups_dest_t
*dests
; /* User destinations */
53 int long_status
; /* Long status report? */
54 int ranking
; /* Show job ranking? */
55 const char *which
; /* Which jobs to show? */
56 char op
; /* Last operation on command-line */
62 * Parse command-line options...
70 which
= "not-completed";
73 for (i
= 1; i
< argc
; i
++)
74 if (argv
[i
][0] == '-')
77 case 'D' : /* Show description */
81 case 'E' : /* Encrypt */
83 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
85 _cupsLangPrintf(stderr
,
86 _("%s: Sorry, no encryption support."),
91 case 'H' : /* Show server and port */
92 if (cupsServer()[0] == '/')
93 _cupsLangPuts(stdout
, cupsServer());
95 _cupsLangPrintf(stdout
, "%s:%d", cupsServer(), ippPort());
99 case 'P' : /* Show paper types */
103 case 'R' : /* Show ranking */
107 case 'S' : /* Show charsets */
113 case 'U' : /* Username */
115 cupsSetUser(argv
[i
] + 2);
121 _cupsLangPrintf(stderr
,
122 _("%s: Error - expected username after "
128 cupsSetUser(argv
[i
]);
132 case 'W' : /* Show which jobs? */
141 _cupsLangPrintf(stderr
,
142 _("%s: Error - need \"completed\", "
143 "\"not-completed\", or \"all\" after "
152 if (strcmp(which
, "completed") && strcmp(which
, "not-completed") &&
153 strcmp(which
, "all"))
155 _cupsLangPrintf(stderr
,
156 _("%s: Error - need \"completed\", "
157 "\"not-completed\", or \"all\" after "
164 case 'a' : /* Show acceptance status */
169 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
171 status
|= show_accepting(argv
[i
] + 2, num_dests
, dests
);
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 &&
189 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
190 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
192 _cupsLangPrintf(stderr
,
193 _("%s: Error - add '/version=1.1' to server "
199 status
|= show_accepting(NULL
, num_dests
, dests
);
203 case 'c' : /* Show classes and members */
208 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
210 status
|= show_classes(argv
[i
] + 2);
212 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
216 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
218 status
|= show_classes(argv
[i
]);
221 status
|= show_classes(NULL
);
224 case 'd' : /* Show default destination */
227 if (num_dests
!= 1 || !dests
[0].is_default
)
229 cupsFreeDests(num_dests
, dests
);
231 dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, NULL
, NULL
);
232 num_dests
= dests
? 1 : 0;
234 if (num_dests
== 0 &&
235 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
236 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
238 _cupsLangPrintf(stderr
,
239 _("%s: Error - add '/version=1.1' to server "
248 case 'f' : /* Show forms */
254 case 'h' : /* Connect to host */
256 cupsSetServer(argv
[i
] + 2);
263 _cupsLangPrintf(stderr
,
264 _("%s: Error - expected hostname after "
270 cupsSetServer(argv
[i
]);
274 case 'l' : /* Long status or long job status */
278 case 'o' : /* Show jobs by destination */
283 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
285 status
|= show_jobs(argv
[i
] + 2, NULL
, long_status
, ranking
,
288 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
292 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
294 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
297 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
300 case 'p' : /* Show printers */
305 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
307 status
|= show_printers(argv
[i
] + 2, num_dests
, dests
,
310 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
314 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
316 status
|= show_printers(argv
[i
], num_dests
, dests
, long_status
);
322 cupsFreeDests(num_dests
, dests
);
323 num_dests
= cupsGetDests(&dests
);
325 if (num_dests
== 0 &&
326 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
327 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
329 _cupsLangPrintf(stderr
,
330 _("%s: Error - add '/version=1.1' to server "
336 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
340 case 'r' : /* Show scheduler status */
346 case 's' : /* Show summary */
351 cupsFreeDests(num_dests
, dests
);
352 num_dests
= cupsGetDests(&dests
);
354 if (num_dests
== 0 &&
355 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
356 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
358 _cupsLangPrintf(stderr
,
359 _("%s: Error - add '/version=1.1' to server "
365 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
366 status
|= show_classes(NULL
);
367 status
|= show_devices(NULL
, num_dests
, dests
);
370 case 't' : /* Show all info */
375 cupsFreeDests(num_dests
, dests
);
376 num_dests
= cupsGetDests(&dests
);
378 if (num_dests
== 0 &&
379 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
380 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
382 _cupsLangPrintf(stderr
,
383 _("%s: Error - add '/version=1.1' to server "
390 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
391 status
|= show_classes(NULL
);
392 status
|= show_devices(NULL
, num_dests
, dests
);
393 status
|= show_accepting(NULL
, num_dests
, dests
);
394 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
395 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
398 case 'u' : /* Show jobs by user */
402 status
|= show_jobs(NULL
, argv
[i
] + 2, long_status
, ranking
,
404 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
407 status
|= show_jobs(NULL
, argv
[i
], long_status
, ranking
, which
);
410 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
413 case 'v' : /* Show printer devices */
418 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
420 status
|= show_devices(argv
[i
] + 2, num_dests
, dests
);
422 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
426 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
428 status
|= show_devices(argv
[i
], num_dests
, dests
);
434 cupsFreeDests(num_dests
, dests
);
435 num_dests
= cupsGetDests(&dests
);
437 if (num_dests
== 0 &&
438 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
439 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
441 _cupsLangPrintf(stderr
,
442 _("%s: Error - add '/version=1.1' to server "
448 status
|= show_devices(NULL
, num_dests
, dests
);
453 _cupsLangPrintf(stderr
,
454 _("%s: Error - unknown option \"%c\"."),
455 argv
[0], argv
[i
][1]);
460 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
465 status
|= show_jobs(NULL
, cupsUser(), long_status
, ranking
, which
);
472 * 'check_dest()' - Verify that the named destination(s) exists.
476 check_dest(const char *command
, /* I - Command name */
477 const char *name
, /* I - List of printer/class names */
478 int *num_dests
, /* IO - Number of destinations */
479 cups_dest_t
**dests
) /* IO - Destinations */
481 const char *dptr
; /* Pointer into name */
482 char *pptr
, /* Pointer into printer */
483 printer
[1024]; /* Current printer/class name */
487 * Load the destination list as necessary...
493 cupsFreeDests(*num_dests
, *dests
);
495 if (strchr(name
, ','))
496 *num_dests
= cupsGetDests(dests
);
499 strlcpy(printer
, name
, sizeof(printer
));
500 if ((pptr
= strchr(printer
, '/')) != NULL
)
503 if ((*dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, printer
, pptr
)) == NULL
)
505 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
506 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
507 _cupsLangPrintf(stderr
,
508 _("%s: Error - add '/version=1.1' to server name."),
511 _cupsLangPrintf(stderr
,
512 _("%s: Invalid destination name in list \"%s\"."),
526 * Scan the name string for printer/class name(s)...
529 for (dptr
= name
; *dptr
;)
532 * Skip leading whitespace and commas...
535 while (isspace(*dptr
& 255) || *dptr
== ',')
542 * Extract a single destination name from the name string...
545 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
;)
547 if ((size_t)(pptr
- printer
) < (sizeof(printer
) - 1))
551 _cupsLangPrintf(stderr
,
552 _("%s: Invalid destination name in list \"%s\"."),
561 * Check the destination...
564 if (!cupsGetDest(printer
, NULL
, *num_dests
, *dests
))
566 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
567 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
568 _cupsLangPrintf(stderr
,
569 _("%s: Error - add '/version=1.1' to server name."),
572 _cupsLangPrintf(stderr
,
573 _("%s: Unknown destination \"%s\"."), command
, printer
);
582 * 'match_list()' - Match a name from a list of comma or space-separated names.
585 static int /* O - 1 on match, 0 on no match */
586 match_list(const char *list
, /* I - List of names */
587 const char *name
) /* I - Name to find */
589 const char *nameptr
; /* Pointer into name */
593 * An empty list always matches...
605 * Skip leading whitespace and commas...
608 while (isspace(*list
& 255) || *list
== ',')
619 *nameptr
&& *list
&& tolower(*nameptr
& 255) == tolower(*list
& 255);
620 nameptr
++, list
++);
622 if (!*nameptr
&& (!*list
|| *list
== ',' || isspace(*list
& 255)))
625 while (*list
&& !isspace(*list
& 255) && *list
!= ',')
634 * 'show_accepting()' - Show acceptance status.
637 static int /* O - 0 on success, 1 on fail */
638 show_accepting(const char *printers
, /* I - Destinations */
639 int num_dests
, /* I - Number of user-defined dests */
640 cups_dest_t
*dests
) /* I - User-defined destinations */
642 int i
; /* Looping var */
643 ipp_t
*request
, /* IPP Request */
644 *response
; /* IPP Response */
645 ipp_attribute_t
*attr
; /* Current attribute */
646 const char *printer
, /* Printer name */
647 *message
; /* Printer device URI */
648 int accepting
; /* Accepting requests? */
649 time_t ptime
; /* Printer state time */
650 char printer_state_time
[255];/* Printer state time */
651 static const char *pattrs
[] = /* Attributes we need for printers... */
654 "printer-state-change-time",
655 "printer-state-message",
656 "printer-is-accepting-jobs"
660 DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers
));
662 if (printers
!= NULL
&& !strcmp(printers
, "all"))
666 * Build a CUPS_GET_PRINTERS request, which requires the following
670 * attributes-natural-language
671 * requested-attributes
672 * requesting-user-name
675 request
= ippNewRequest(CUPS_GET_PRINTERS
);
677 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
678 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
681 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
685 * Do the request and get back a response...
688 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
690 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
691 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
693 _cupsLangPrintf(stderr
,
694 _("%s: Error - add '/version=1.1' to server name."),
699 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
701 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
708 DEBUG_puts("show_accepting: request succeeded...");
711 * Loop through the printers returned in the list and display
715 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
718 * Skip leading attributes until we hit a printer...
721 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
728 * Pull the needed attributes from this printer...
736 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
738 if (!strcmp(attr
->name
, "printer-name") &&
739 attr
->value_tag
== IPP_TAG_NAME
)
740 printer
= attr
->values
[0].string
.text
;
741 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
742 attr
->value_tag
== IPP_TAG_INTEGER
)
743 ptime
= (time_t)attr
->values
[0].integer
;
744 else if (!strcmp(attr
->name
, "printer-state-message") &&
745 attr
->value_tag
== IPP_TAG_TEXT
)
746 message
= attr
->values
[0].string
.text
;
747 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
748 attr
->value_tag
== IPP_TAG_BOOLEAN
)
749 accepting
= attr
->values
[0].boolean
;
755 * See if we have everything needed...
767 * Display the printer entry if needed...
770 if (match_list(printers
, printer
))
772 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
775 _cupsLangPrintf(stdout
, _("%s accepting requests since %s"),
776 printer
, printer_state_time
);
779 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -"),
780 printer
, printer_state_time
);
781 _cupsLangPrintf(stdout
, _("\t%s"),
782 (message
== NULL
|| !*message
) ?
783 "reason unknown" : message
);
786 for (i
= 0; i
< num_dests
; i
++)
787 if (!_cups_strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
790 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s"),
791 printer
, dests
[i
].instance
, printer_state_time
);
794 _cupsLangPrintf(stdout
,
795 _("%s/%s not accepting requests since %s -"),
796 printer
, dests
[i
].instance
, printer_state_time
);
797 _cupsLangPrintf(stdout
, _("\t%s"),
798 (message
== NULL
|| !*message
) ?
799 "reason unknown" : message
);
816 * 'show_classes()' - Show printer classes.
819 static int /* O - 0 on success, 1 on fail */
820 show_classes(const char *dests
) /* I - Destinations */
822 int i
; /* Looping var */
823 ipp_t
*request
, /* IPP Request */
824 *response
, /* IPP Response */
825 *response2
; /* IPP response from remote server */
826 http_t
*http2
; /* Remote server */
827 ipp_attribute_t
*attr
; /* Current attribute */
828 const char *printer
, /* Printer class name */
829 *printer_uri
; /* Printer class URI */
830 ipp_attribute_t
*members
; /* Printer members */
831 char method
[HTTP_MAX_URI
], /* Request method */
832 username
[HTTP_MAX_URI
], /* Username:password */
833 server
[HTTP_MAX_URI
], /* Server name */
834 resource
[HTTP_MAX_URI
]; /* Resource name */
835 int port
; /* Port number */
836 static const char *cattrs
[] = /* Attributes we need for classes... */
839 "printer-uri-supported",
844 DEBUG_printf(("show_classes(dests=\"%s\")\n", dests
));
846 if (dests
!= NULL
&& !strcmp(dests
, "all"))
850 * Build a CUPS_GET_CLASSES request, which requires the following
854 * attributes-natural-language
855 * requested-attributes
856 * requesting-user-name
859 request
= ippNewRequest(CUPS_GET_CLASSES
);
861 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
862 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
865 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
869 * Do the request and get back a response...
872 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
874 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
875 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
877 _cupsLangPrintf(stderr
,
878 _("%s: Error - add '/version=1.1' to server name."),
883 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
885 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
892 DEBUG_puts("show_classes: request succeeded...");
894 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
896 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
902 * Loop through the printers returned in the list and display
906 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
909 * Skip leading attributes until we hit a job...
912 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
919 * Pull the needed attributes from this job...
926 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
928 if (!strcmp(attr
->name
, "printer-name") &&
929 attr
->value_tag
== IPP_TAG_NAME
)
930 printer
= attr
->values
[0].string
.text
;
932 if (!strcmp(attr
->name
, "printer-uri-supported") &&
933 attr
->value_tag
== IPP_TAG_URI
)
934 printer_uri
= attr
->values
[0].string
.text
;
936 if (!strcmp(attr
->name
, "member-names") &&
937 attr
->value_tag
== IPP_TAG_NAME
)
944 * If this is a remote class, grab the class info from the
949 if (members
== NULL
&& printer_uri
!= NULL
)
951 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
952 username
, sizeof(username
), server
, sizeof(server
),
953 &port
, resource
, sizeof(resource
));
955 if (!_cups_strcasecmp(server
, cupsServer()))
956 http2
= CUPS_HTTP_DEFAULT
;
958 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
961 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
962 * following attributes:
965 * attributes-natural-language
967 * requested-attributes
970 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
972 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
973 "printer-uri", NULL
, printer_uri
);
975 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
976 "requested-attributes",
977 sizeof(cattrs
) / sizeof(cattrs
[0]),
980 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
981 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
988 * See if we have everything needed...
994 ippDelete(response2
);
1003 * Display the printer entry if needed...
1006 if (match_list(dests
, printer
))
1008 _cupsLangPrintf(stdout
, _("members of class %s:"), printer
);
1012 for (i
= 0; i
< members
->num_values
; i
++)
1013 _cupsLangPrintf(stdout
, "\t%s", members
->values
[i
].string
.text
);
1016 _cupsLangPuts(stdout
, "\tunknown");
1020 ippDelete(response2
);
1026 ippDelete(response
);
1034 * 'show_default()' - Show default destination.
1038 show_default(cups_dest_t
*dest
) /* I - Default destination */
1040 const char *printer
, /* Printer name */
1041 *val
; /* Environment variable name */
1047 _cupsLangPrintf(stdout
, _("system default destination: %s/%s"),
1048 dest
->name
, dest
->instance
);
1050 _cupsLangPrintf(stdout
, _("system default destination: %s"),
1057 if ((printer
= getenv("LPDEST")) == NULL
)
1059 if ((printer
= getenv("PRINTER")) != NULL
)
1061 if (!strcmp(printer
, "lp"))
1071 _cupsLangPrintf(stdout
,
1072 _("lpstat: error - %s environment variable names "
1073 "non-existent destination \"%s\"."),
1076 _cupsLangPuts(stdout
, _("no system default destination"));
1082 * 'show_devices()' - Show printer devices.
1085 static int /* O - 0 on success, 1 on fail */
1086 show_devices(const char *printers
, /* I - Destinations */
1087 int num_dests
, /* I - Number of user-defined dests */
1088 cups_dest_t
*dests
) /* I - User-defined destinations */
1090 int i
; /* Looping var */
1091 ipp_t
*request
, /* IPP Request */
1092 *response
; /* IPP Response */
1093 ipp_attribute_t
*attr
; /* Current attribute */
1094 const char *printer
, /* Printer name */
1095 *uri
, /* Printer URI */
1096 *device
; /* Printer device URI */
1097 static const char *pattrs
[] = /* Attributes we need for printers... */
1100 "printer-uri-supported",
1105 DEBUG_printf(("show_devices(printers=\"%s\")\n", printers
));
1107 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1111 * Build a CUPS_GET_PRINTERS request, which requires the following
1114 * attributes-charset
1115 * attributes-natural-language
1116 * requested-attributes
1117 * requesting-user-name
1120 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1122 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1123 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1126 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1130 * Do the request and get back a response...
1133 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1135 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1136 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1138 _cupsLangPrintf(stderr
,
1139 _("%s: Error - add '/version=1.1' to server name."),
1141 ippDelete(response
);
1144 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1146 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1147 ippDelete(response
);
1153 DEBUG_puts("show_devices: request succeeded...");
1156 * Loop through the printers returned in the list and display
1160 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1163 * Skip leading attributes until we hit a job...
1166 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1173 * Pull the needed attributes from this job...
1180 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1182 if (!strcmp(attr
->name
, "printer-name") &&
1183 attr
->value_tag
== IPP_TAG_NAME
)
1184 printer
= attr
->values
[0].string
.text
;
1186 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1187 attr
->value_tag
== IPP_TAG_URI
)
1188 uri
= attr
->values
[0].string
.text
;
1190 if (!strcmp(attr
->name
, "device-uri") &&
1191 attr
->value_tag
== IPP_TAG_URI
)
1192 device
= attr
->values
[0].string
.text
;
1198 * See if we have everything needed...
1201 if (printer
== NULL
)
1210 * Display the printer entry if needed...
1213 if (match_list(printers
, printer
))
1216 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1218 else if (!strncmp(device
, "file:", 5))
1219 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1220 printer
, device
+ 5);
1222 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1225 for (i
= 0; i
< num_dests
; i
++)
1227 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1230 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1231 printer
, dests
[i
].instance
, uri
);
1232 else if (!strncmp(device
, "file:", 5))
1233 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1234 printer
, dests
[i
].instance
, device
+ 5);
1236 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1237 printer
, dests
[i
].instance
, device
);
1246 ippDelete(response
);
1254 * 'show_jobs()' - Show active print jobs.
1257 static int /* O - 0 on success, 1 on fail */
1258 show_jobs(const char *dests
, /* I - Destinations */
1259 const char *users
, /* I - Users */
1260 int long_status
, /* I - Show long status? */
1261 int ranking
, /* I - Show job ranking? */
1262 const char *which
) /* I - Show which jobs? */
1264 int i
; /* Looping var */
1265 ipp_t
*request
, /* IPP Request */
1266 *response
; /* IPP Response */
1267 ipp_attribute_t
*attr
, /* Current attribute */
1268 *reasons
; /* Job state reasons attribute */
1269 const char *dest
, /* Pointer into job-printer-uri */
1270 *username
, /* Pointer to job-originating-user-name */
1271 *message
, /* Pointer to job-printer-state-message */
1272 *time_at
; /* time-at-xxx attribute name to use */
1273 int rank
, /* Rank in queue */
1275 size
; /* job-k-octets */
1276 time_t jobtime
; /* time-at-creation */
1277 char temp
[255], /* Temporary buffer */
1278 date
[255]; /* Date buffer */
1279 static const char *jattrs
[] = /* Attributes we need for jobs... */
1284 "job-originating-user-name",
1285 "job-printer-state-message",
1287 "job-state-reasons",
1293 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1294 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1297 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1301 * Build a IPP_GET_JOBS request, which requires the following
1304 * attributes-charset
1305 * attributes-natural-language
1307 * requested-attributes
1308 * requesting-user-name
1312 request
= ippNewRequest(IPP_GET_JOBS
);
1314 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1315 NULL
, "ipp://localhost/");
1317 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1318 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1321 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1324 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1328 * Do the request and get back a response...
1331 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1333 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1334 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1336 _cupsLangPrintf(stderr
,
1337 _("%s: Error - add '/version=1.1' to server name."),
1339 ippDelete(response
);
1342 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1344 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1345 ippDelete(response
);
1352 * Loop through the job list and display them...
1355 if (!strcmp(which
, "aborted") ||
1356 !strcmp(which
, "canceled") ||
1357 !strcmp(which
, "completed"))
1358 time_at
= "time-at-completed";
1360 time_at
= "time-at-creation";
1364 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1367 * Skip leading attributes until we hit a job...
1370 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1377 * Pull the needed attributes from this job...
1388 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1390 if (!strcmp(attr
->name
, "job-id") &&
1391 attr
->value_tag
== IPP_TAG_INTEGER
)
1392 jobid
= attr
->values
[0].integer
;
1393 else if (!strcmp(attr
->name
, "job-k-octets") &&
1394 attr
->value_tag
== IPP_TAG_INTEGER
)
1395 size
= attr
->values
[0].integer
;
1396 else if (!strcmp(attr
->name
, time_at
) && attr
->value_tag
== IPP_TAG_INTEGER
)
1397 jobtime
= attr
->values
[0].integer
;
1398 else if (!strcmp(attr
->name
, "job-printer-state-message") &&
1399 attr
->value_tag
== IPP_TAG_TEXT
)
1400 message
= attr
->values
[0].string
.text
;
1401 else if (!strcmp(attr
->name
, "job-printer-uri") &&
1402 attr
->value_tag
== IPP_TAG_URI
)
1404 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1407 else if (!strcmp(attr
->name
, "job-originating-user-name") &&
1408 attr
->value_tag
== IPP_TAG_NAME
)
1409 username
= attr
->values
[0].string
.text
;
1410 else if (!strcmp(attr
->name
, "job-state-reasons") &&
1411 attr
->value_tag
== IPP_TAG_KEYWORD
)
1418 * See if we have everything needed...
1421 if (dest
== NULL
|| jobid
== 0)
1430 * Display the job...
1435 if (match_list(dests
, dest
) && match_list(users
, username
))
1437 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1439 _cupsStrDate(date
, sizeof(date
), jobtime
);
1442 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s",
1443 rank
, temp
, username
? username
: "unknown",
1444 1024.0 * size
, date
);
1446 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s",
1447 temp
, username
? username
: "unknown",
1448 1024.0 * size
, date
);
1452 _cupsLangPrintf(stdout
, _("\tStatus: %s"), message
);
1456 char alerts
[1024], /* Alerts string */
1457 *aptr
; /* Pointer into alerts string */
1459 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1462 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1464 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1466 aptr
+= strlen(aptr
);
1469 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1472 _cupsLangPrintf(stdout
, _("\tqueued for %s"), dest
);
1480 ippDelete(response
);
1488 * 'show_printers()' - Show printers.
1491 static int /* O - 0 on success, 1 on fail */
1492 show_printers(const char *printers
, /* I - Destinations */
1493 int num_dests
, /* I - Number of user-defined dests */
1494 cups_dest_t
*dests
, /* I - User-defined destinations */
1495 int long_status
) /* I - Show long status? */
1497 int i
, j
; /* Looping vars */
1498 ipp_t
*request
, /* IPP Request */
1499 *response
, /* IPP Response */
1500 *jobs
; /* IPP Get Jobs response */
1501 ipp_attribute_t
*attr
, /* Current attribute */
1502 *jobattr
, /* Job ID attribute */
1503 *reasons
; /* Job state reasons attribute */
1504 const char *printer
, /* Printer name */
1505 *message
, /* Printer state message */
1506 *description
, /* Description of printer */
1507 *location
, /* Location of printer */
1508 *make_model
, /* Make and model of printer */
1509 *uri
; /* URI of printer */
1510 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1511 *denied
; /* requestint-user-name-denied */
1512 ipp_pstate_t pstate
; /* Printer state */
1513 cups_ptype_t ptype
; /* Printer type */
1514 time_t ptime
; /* Printer state time */
1515 int jobid
; /* Job ID of current job */
1516 char printer_uri
[HTTP_MAX_URI
],
1518 printer_state_time
[255];/* Printer state time */
1519 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1520 static const char *pattrs
[] = /* Attributes we need for printers... */
1524 "printer-state-message",
1525 "printer-state-reasons",
1526 "printer-state-change-time",
1530 "printer-make-and-model",
1531 "printer-uri-supported",
1532 "requesting-user-name-allowed",
1533 "requesting-user-name-denied"
1535 static const char *jattrs
[] = /* Attributes we need for jobs... */
1542 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1543 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1545 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1549 * Build a CUPS_GET_PRINTERS request, which requires the following
1552 * attributes-charset
1553 * attributes-natural-language
1554 * requested-attributes
1555 * requesting-user-name
1558 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1560 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1561 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1564 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1568 * Do the request and get back a response...
1571 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1573 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1574 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1576 _cupsLangPrintf(stderr
,
1577 _("%s: Error - add '/version=1.1' to server name."),
1579 ippDelete(response
);
1582 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1584 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1585 ippDelete(response
);
1591 DEBUG_puts("show_printers: request succeeded...");
1594 * Loop through the printers returned in the list and display
1598 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1601 * Skip leading attributes until we hit a job...
1604 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1611 * Pull the needed attributes from this job...
1616 ptype
= CUPS_PRINTER_LOCAL
;
1617 pstate
= IPP_PRINTER_IDLE
;
1628 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1630 if (!strcmp(attr
->name
, "printer-name") &&
1631 attr
->value_tag
== IPP_TAG_NAME
)
1632 printer
= attr
->values
[0].string
.text
;
1633 else if (!strcmp(attr
->name
, "printer-state") &&
1634 attr
->value_tag
== IPP_TAG_ENUM
)
1635 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1636 else if (!strcmp(attr
->name
, "printer-type") &&
1637 attr
->value_tag
== IPP_TAG_ENUM
)
1638 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1639 else if (!strcmp(attr
->name
, "printer-state-message") &&
1640 attr
->value_tag
== IPP_TAG_TEXT
)
1641 message
= attr
->values
[0].string
.text
;
1642 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1643 attr
->value_tag
== IPP_TAG_INTEGER
)
1644 ptime
= (time_t)attr
->values
[0].integer
;
1645 else if (!strcmp(attr
->name
, "printer-info") &&
1646 attr
->value_tag
== IPP_TAG_TEXT
)
1647 description
= attr
->values
[0].string
.text
;
1648 else if (!strcmp(attr
->name
, "printer-location") &&
1649 attr
->value_tag
== IPP_TAG_TEXT
)
1650 location
= attr
->values
[0].string
.text
;
1651 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1652 attr
->value_tag
== IPP_TAG_TEXT
)
1653 make_model
= attr
->values
[0].string
.text
;
1654 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1655 attr
->value_tag
== IPP_TAG_URI
)
1656 uri
= attr
->values
[0].string
.text
;
1657 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1658 attr
->value_tag
== IPP_TAG_KEYWORD
)
1660 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1661 attr
->value_tag
== IPP_TAG_NAME
)
1663 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1664 attr
->value_tag
== IPP_TAG_NAME
)
1671 * See if we have everything needed...
1674 if (printer
== NULL
)
1683 * Display the printer entry if needed...
1686 if (match_list(printers
, printer
))
1689 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1690 * current job for the printer.
1693 if (pstate
== IPP_PRINTER_PROCESSING
)
1696 * Build an IPP_GET_JOBS request, which requires the following
1699 * attributes-charset
1700 * attributes-natural-language
1703 * requested-attributes
1706 request
= ippNewRequest(IPP_GET_JOBS
);
1708 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1709 request
->request
.op
.request_id
= 1;
1711 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1712 "requested-attributes",
1713 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1715 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1716 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1717 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1718 "printer-uri", NULL
, printer_uri
);
1720 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1723 * Get the current active job on this queue...
1726 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1729 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1733 if (jobstate
== IPP_JOB_PROCESSING
)
1739 if (!strcmp(jobattr
->name
, "job-id") &&
1740 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1741 jobid
= jobattr
->values
[0].integer
;
1742 else if (!strcmp(jobattr
->name
, "job-state") &&
1743 jobattr
->value_tag
== IPP_TAG_ENUM
)
1744 jobstate
= (ipp_jstate_t
)jobattr
->values
[0].integer
;
1747 if (jobstate
!= IPP_JOB_PROCESSING
)
1758 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
1762 case IPP_PRINTER_IDLE
:
1763 _cupsLangPrintf(stdout
,
1764 _("printer %s is idle. enabled since %s"),
1765 printer
, printer_state_time
);
1767 case IPP_PRINTER_PROCESSING
:
1768 _cupsLangPrintf(stdout
,
1769 _("printer %s now printing %s-%d. "
1770 "enabled since %s"),
1771 printer
, printer
, jobid
, printer_state_time
);
1773 case IPP_PRINTER_STOPPED
:
1774 _cupsLangPrintf(stdout
,
1775 _("printer %s disabled since %s -"),
1776 printer
, printer_state_time
);
1780 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1782 if (!message
|| !*message
)
1783 _cupsLangPuts(stdout
, _("\treason unknown"));
1785 _cupsLangPrintf(stdout
, "\t%s", message
);
1788 if (long_status
> 1)
1790 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1791 _cupsLangPuts(stdout
, _("\tContent types: any"));
1792 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1797 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1798 description
? description
: "");
1802 char alerts
[1024], /* Alerts string */
1803 *aptr
; /* Pointer into alerts string */
1805 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1808 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1810 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1812 aptr
+= strlen(aptr
);
1815 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1818 if (long_status
> 1)
1820 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1821 location
? location
: "");
1823 if (ptype
& CUPS_PRINTER_REMOTE
)
1825 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1827 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1828 !strstr(make_model
, "Raw Printer") && uri
)
1829 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"),
1834 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1836 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1837 _cupsLangPrintf(stdout
,
1838 _("\tInterface: %s/ppd/%s.ppd"),
1839 cg
->cups_serverroot
, printer
);
1841 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1842 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1843 /* TODO update to use printer-error-policy */
1846 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1847 for (j
= 0; j
< allowed
->num_values
; j
++)
1848 _cupsLangPrintf(stdout
, "\t\t%s",
1849 allowed
->values
[j
].string
.text
);
1853 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1854 for (j
= 0; j
< denied
->num_values
; j
++)
1855 _cupsLangPrintf(stdout
, "\t\t%s",
1856 denied
->values
[j
].string
.text
);
1860 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1861 _cupsLangPuts(stdout
, _("\t\t(all)"));
1863 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1864 _cupsLangPuts(stdout
, _("\t\t(none)"));
1865 _cupsLangPuts(stdout
, _("\tBanner required"));
1866 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1867 _cupsLangPuts(stdout
, _("\t\t(none)"));
1868 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1869 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1870 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1873 for (i
= 0; i
< num_dests
; i
++)
1874 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1878 case IPP_PRINTER_IDLE
:
1879 _cupsLangPrintf(stdout
,
1880 _("printer %s/%s is idle. "
1881 "enabled since %s"),
1882 printer
, dests
[i
].instance
,
1883 printer_state_time
);
1885 case IPP_PRINTER_PROCESSING
:
1886 _cupsLangPrintf(stdout
,
1887 _("printer %s/%s now printing %s-%d. "
1888 "enabled since %s"),
1889 printer
, dests
[i
].instance
, printer
, jobid
,
1890 printer_state_time
);
1892 case IPP_PRINTER_STOPPED
:
1893 _cupsLangPrintf(stdout
,
1894 _("printer %s/%s disabled since %s -"),
1895 printer
, dests
[i
].instance
,
1896 printer_state_time
);
1900 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1902 if (!message
|| !*message
)
1903 _cupsLangPuts(stdout
, _("\treason unknown"));
1905 _cupsLangPrintf(stdout
, "\t%s", message
);
1908 if (long_status
> 1)
1910 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1911 _cupsLangPuts(stdout
, _("\tContent types: any"));
1912 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1917 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1918 description
? description
: "");
1922 char alerts
[1024], /* Alerts string */
1923 *aptr
; /* Pointer into alerts string */
1925 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1928 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1930 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1932 aptr
+= strlen(aptr
);
1935 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1938 if (long_status
> 1)
1940 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1941 location
? location
: "");
1943 if (ptype
& CUPS_PRINTER_REMOTE
)
1945 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1947 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1948 !strstr(make_model
, "Raw Printer") && uri
)
1949 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"), uri
);
1953 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1955 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1956 _cupsLangPrintf(stdout
,
1957 _("\tInterface: %s/ppd/%s.ppd"),
1958 cg
->cups_serverroot
, printer
);
1960 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1961 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1962 /* TODO update to use printer-error-policy */
1965 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1966 for (j
= 0; j
< allowed
->num_values
; j
++)
1967 _cupsLangPrintf(stdout
, "\t\t%s",
1968 allowed
->values
[j
].string
.text
);
1972 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1973 for (j
= 0; j
< denied
->num_values
; j
++)
1974 _cupsLangPrintf(stdout
, "\t\t%s",
1975 denied
->values
[j
].string
.text
);
1979 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1980 _cupsLangPuts(stdout
, _("\t\t(all)"));
1982 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1983 _cupsLangPuts(stdout
, _("\t\t(none)"));
1984 _cupsLangPuts(stdout
, _("\tBanner required"));
1985 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1986 _cupsLangPuts(stdout
, _("\t\t(none)"));
1987 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1988 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1989 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1998 ippDelete(response
);
2006 * 'show_scheduler()' - Show scheduler status.
2010 show_scheduler(void)
2012 http_t
*http
; /* Connection to server */
2015 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
2016 cupsEncryption())) != NULL
)
2018 _cupsLangPuts(stdout
, _("scheduler is running"));
2022 _cupsLangPuts(stdout
, _("scheduler is not running"));