4 * "lpstat" command for CUPS.
6 * Copyright 2007-2014 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * Include necessary headers...
20 #include <cups/cups-private.h>
27 static void check_dest(const char *command
, const char *name
,
28 int *num_dests
, cups_dest_t
**dests
);
29 static int match_list(const char *list
, const char *name
);
30 static int show_accepting(const char *printers
, int num_dests
,
32 static int show_classes(const char *dests
);
33 static void show_default(cups_dest_t
*dest
);
34 static int show_devices(const char *printers
, int num_dests
,
36 static int show_jobs(const char *dests
, const char *users
, int long_status
,
37 int ranking
, const char *which
);
38 static int show_printers(const char *printers
, int num_dests
,
39 cups_dest_t
*dests
, int long_status
);
40 static void show_scheduler(void);
44 * 'main()' - Parse options and show status information.
48 main(int argc
, /* I - Number of command-line arguments */
49 char *argv
[]) /* I - Command-line arguments */
51 int i
, /* Looping var */
52 status
; /* Exit status */
53 int num_dests
; /* Number of user destinations */
54 cups_dest_t
*dests
; /* User destinations */
55 int long_status
; /* Long status report? */
56 int ranking
; /* Show job ranking? */
57 const char *which
; /* Which jobs to show? */
58 char op
; /* Last operation on command-line */
64 * Parse command-line options...
72 which
= "not-completed";
75 for (i
= 1; i
< argc
; i
++)
76 if (argv
[i
][0] == '-')
79 case 'D' : /* Show description */
83 case 'E' : /* Encrypt */
85 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
87 _cupsLangPrintf(stderr
,
88 _("%s: Sorry, no encryption support."),
93 case 'H' : /* Show server and port */
94 if (cupsServer()[0] == '/')
95 _cupsLangPuts(stdout
, cupsServer());
97 _cupsLangPrintf(stdout
, "%s:%d", cupsServer(), ippPort());
101 case 'P' : /* Show paper types */
105 case 'R' : /* Show ranking */
109 case 'S' : /* Show charsets */
115 case 'U' : /* Username */
117 cupsSetUser(argv
[i
] + 2);
123 _cupsLangPrintf(stderr
,
124 _("%s: Error - expected username after "
130 cupsSetUser(argv
[i
]);
134 case 'W' : /* Show which jobs? */
143 _cupsLangPrintf(stderr
,
144 _("%s: Error - need \"completed\", "
145 "\"not-completed\", or \"all\" after "
154 if (strcmp(which
, "completed") && strcmp(which
, "not-completed") &&
155 strcmp(which
, "all"))
157 _cupsLangPrintf(stderr
,
158 _("%s: Error - need \"completed\", "
159 "\"not-completed\", or \"all\" after "
166 case 'a' : /* Show acceptance status */
171 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
173 status
|= show_accepting(argv
[i
] + 2, num_dests
, dests
);
175 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
179 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
181 status
|= show_accepting(argv
[i
], num_dests
, dests
);
187 cupsFreeDests(num_dests
, dests
);
188 num_dests
= cupsGetDests(&dests
);
190 if (num_dests
== 0 &&
191 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
192 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
194 _cupsLangPrintf(stderr
,
195 _("%s: Error - add '/version=1.1' to server "
201 status
|= show_accepting(NULL
, num_dests
, dests
);
205 case 'c' : /* Show classes and members */
210 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
212 status
|= show_classes(argv
[i
] + 2);
214 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
218 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
220 status
|= show_classes(argv
[i
]);
223 status
|= show_classes(NULL
);
226 case 'd' : /* Show default destination */
229 if (num_dests
!= 1 || !dests
[0].is_default
)
231 cupsFreeDests(num_dests
, dests
);
233 dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, NULL
, NULL
);
234 num_dests
= dests
? 1 : 0;
236 if (num_dests
== 0 &&
237 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
238 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
240 _cupsLangPrintf(stderr
,
241 _("%s: Error - add '/version=1.1' to server "
250 case 'f' : /* Show forms */
256 case 'h' : /* Connect to host */
258 cupsSetServer(argv
[i
] + 2);
265 _cupsLangPrintf(stderr
,
266 _("%s: Error - expected hostname after "
272 cupsSetServer(argv
[i
]);
276 case 'l' : /* Long status or long job status */
280 case 'o' : /* Show jobs by destination */
285 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
287 status
|= show_jobs(argv
[i
] + 2, NULL
, long_status
, ranking
,
290 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
294 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
296 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
299 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
302 case 'p' : /* Show printers */
307 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
309 status
|= show_printers(argv
[i
] + 2, num_dests
, dests
,
312 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
316 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
318 status
|= show_printers(argv
[i
], num_dests
, dests
, long_status
);
324 cupsFreeDests(num_dests
, dests
);
325 num_dests
= cupsGetDests(&dests
);
327 if (num_dests
== 0 &&
328 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
329 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
331 _cupsLangPrintf(stderr
,
332 _("%s: Error - add '/version=1.1' to server "
338 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
342 case 'r' : /* Show scheduler status */
348 case 's' : /* Show summary */
353 cupsFreeDests(num_dests
, dests
);
354 num_dests
= cupsGetDests(&dests
);
356 if (num_dests
== 0 &&
357 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
358 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
360 _cupsLangPrintf(stderr
,
361 _("%s: Error - add '/version=1.1' to server "
367 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
368 status
|= show_classes(NULL
);
369 status
|= show_devices(NULL
, num_dests
, dests
);
372 case 't' : /* Show all info */
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
,
385 _("%s: Error - add '/version=1.1' to server "
392 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
393 status
|= show_classes(NULL
);
394 status
|= show_devices(NULL
, num_dests
, dests
);
395 status
|= show_accepting(NULL
, num_dests
, dests
);
396 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
397 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
400 case 'u' : /* Show jobs by user */
404 status
|= show_jobs(NULL
, argv
[i
] + 2, long_status
, ranking
,
406 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
409 status
|= show_jobs(NULL
, argv
[i
], long_status
, ranking
, which
);
412 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
415 case 'v' : /* Show printer devices */
420 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
422 status
|= show_devices(argv
[i
] + 2, num_dests
, dests
);
424 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
428 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
430 status
|= show_devices(argv
[i
], num_dests
, dests
);
436 cupsFreeDests(num_dests
, dests
);
437 num_dests
= cupsGetDests(&dests
);
439 if (num_dests
== 0 &&
440 (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
441 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
))
443 _cupsLangPrintf(stderr
,
444 _("%s: Error - add '/version=1.1' to server "
450 status
|= show_devices(NULL
, num_dests
, dests
);
455 _cupsLangPrintf(stderr
,
456 _("%s: Error - unknown option \"%c\"."),
457 argv
[0], argv
[i
][1]);
462 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
467 status
|= show_jobs(NULL
, cupsUser(), long_status
, ranking
, which
);
474 * 'check_dest()' - Verify that the named destination(s) exists.
478 check_dest(const char *command
, /* I - Command name */
479 const char *name
, /* I - List of printer/class names */
480 int *num_dests
, /* IO - Number of destinations */
481 cups_dest_t
**dests
) /* IO - Destinations */
483 const char *dptr
; /* Pointer into name */
484 char *pptr
, /* Pointer into printer */
485 printer
[1024]; /* Current printer/class name */
489 * Load the destination list as necessary...
495 cupsFreeDests(*num_dests
, *dests
);
497 if (strchr(name
, ','))
498 *num_dests
= cupsGetDests(dests
);
501 strlcpy(printer
, name
, sizeof(printer
));
502 if ((pptr
= strchr(printer
, '/')) != NULL
)
505 if ((*dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, printer
, pptr
)) == NULL
)
507 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
508 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
509 _cupsLangPrintf(stderr
,
510 _("%s: Error - add '/version=1.1' to server name."),
513 _cupsLangPrintf(stderr
,
514 _("%s: Invalid destination name in list \"%s\"."),
528 * Scan the name string for printer/class name(s)...
531 for (dptr
= name
; *dptr
;)
534 * Skip leading whitespace and commas...
537 while (isspace(*dptr
& 255) || *dptr
== ',')
544 * Extract a single destination name from the name string...
547 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
;)
549 if ((pptr
- printer
) < (sizeof(printer
) - 1))
553 _cupsLangPrintf(stderr
,
554 _("%s: Invalid destination name in list \"%s\"."),
563 * Check the destination...
566 if (!cupsGetDest(printer
, NULL
, *num_dests
, *dests
))
568 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
569 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
570 _cupsLangPrintf(stderr
,
571 _("%s: Error - add '/version=1.1' to server name."),
574 _cupsLangPrintf(stderr
,
575 _("%s: Unknown destination \"%s\"."), command
, printer
);
584 * 'match_list()' - Match a name from a list of comma or space-separated names.
587 static int /* O - 1 on match, 0 on no match */
588 match_list(const char *list
, /* I - List of names */
589 const char *name
) /* I - Name to find */
591 const char *nameptr
; /* Pointer into name */
595 * An empty list always matches...
607 * Skip leading whitespace and commas...
610 while (isspace(*list
& 255) || *list
== ',')
621 *nameptr
&& *list
&& tolower(*nameptr
& 255) == tolower(*list
& 255);
622 nameptr
++, list
++);
624 if (!*nameptr
&& (!*list
|| *list
== ',' || isspace(*list
& 255)))
627 while (*list
&& !isspace(*list
& 255) && *list
!= ',')
636 * 'show_accepting()' - Show acceptance status.
639 static int /* O - 0 on success, 1 on fail */
640 show_accepting(const char *printers
, /* I - Destinations */
641 int num_dests
, /* I - Number of user-defined dests */
642 cups_dest_t
*dests
) /* I - User-defined destinations */
644 int i
; /* Looping var */
645 ipp_t
*request
, /* IPP Request */
646 *response
; /* IPP Response */
647 ipp_attribute_t
*attr
; /* Current attribute */
648 const char *printer
, /* Printer name */
649 *message
; /* Printer device URI */
650 int accepting
; /* Accepting requests? */
651 time_t ptime
; /* Printer state time */
652 char printer_state_time
[255];/* Printer state time */
653 static const char *pattrs
[] = /* Attributes we need for printers... */
656 "printer-state-change-time",
657 "printer-state-message",
658 "printer-is-accepting-jobs"
662 DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers
));
664 if (printers
!= NULL
&& !strcmp(printers
, "all"))
668 * Build a CUPS_GET_PRINTERS request, which requires the following
672 * attributes-natural-language
673 * requested-attributes
674 * requesting-user-name
677 request
= ippNewRequest(CUPS_GET_PRINTERS
);
679 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
680 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
683 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
687 * Do the request and get back a response...
690 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
692 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
693 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
695 _cupsLangPrintf(stderr
,
696 _("%s: Error - add '/version=1.1' to server name."),
701 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
703 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
710 DEBUG_puts("show_accepting: request succeeded...");
713 * Loop through the printers returned in the list and display
717 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
720 * Skip leading attributes until we hit a printer...
723 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
730 * Pull the needed attributes from this printer...
738 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
740 if (!strcmp(attr
->name
, "printer-name") &&
741 attr
->value_tag
== IPP_TAG_NAME
)
742 printer
= attr
->values
[0].string
.text
;
743 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
744 attr
->value_tag
== IPP_TAG_INTEGER
)
745 ptime
= (time_t)attr
->values
[0].integer
;
746 else if (!strcmp(attr
->name
, "printer-state-message") &&
747 attr
->value_tag
== IPP_TAG_TEXT
)
748 message
= attr
->values
[0].string
.text
;
749 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
750 attr
->value_tag
== IPP_TAG_BOOLEAN
)
751 accepting
= attr
->values
[0].boolean
;
757 * See if we have everything needed...
769 * Display the printer entry if needed...
772 if (match_list(printers
, printer
))
774 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
777 _cupsLangPrintf(stdout
, _("%s accepting requests since %s"),
778 printer
, printer_state_time
);
781 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -"),
782 printer
, printer_state_time
);
783 _cupsLangPrintf(stdout
, _("\t%s"),
784 (message
== NULL
|| !*message
) ?
785 "reason unknown" : message
);
788 for (i
= 0; i
< num_dests
; i
++)
789 if (!_cups_strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
792 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s"),
793 printer
, dests
[i
].instance
, printer_state_time
);
796 _cupsLangPrintf(stdout
,
797 _("%s/%s not accepting requests since %s -"),
798 printer
, dests
[i
].instance
, printer_state_time
);
799 _cupsLangPrintf(stdout
, _("\t%s"),
800 (message
== NULL
|| !*message
) ?
801 "reason unknown" : message
);
818 * 'show_classes()' - Show printer classes.
821 static int /* O - 0 on success, 1 on fail */
822 show_classes(const char *dests
) /* I - Destinations */
824 int i
; /* Looping var */
825 ipp_t
*request
, /* IPP Request */
826 *response
, /* IPP Response */
827 *response2
; /* IPP response from remote server */
828 http_t
*http2
; /* Remote server */
829 ipp_attribute_t
*attr
; /* Current attribute */
830 const char *printer
, /* Printer class name */
831 *printer_uri
; /* Printer class URI */
832 ipp_attribute_t
*members
; /* Printer members */
833 char method
[HTTP_MAX_URI
], /* Request method */
834 username
[HTTP_MAX_URI
], /* Username:password */
835 server
[HTTP_MAX_URI
], /* Server name */
836 resource
[HTTP_MAX_URI
]; /* Resource name */
837 int port
; /* Port number */
838 static const char *cattrs
[] = /* Attributes we need for classes... */
841 "printer-uri-supported",
846 DEBUG_printf(("show_classes(dests=\"%s\")\n", dests
));
848 if (dests
!= NULL
&& !strcmp(dests
, "all"))
852 * Build a CUPS_GET_CLASSES request, which requires the following
856 * attributes-natural-language
857 * requested-attributes
858 * requesting-user-name
861 request
= ippNewRequest(CUPS_GET_CLASSES
);
863 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
864 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
867 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
871 * Do the request and get back a response...
874 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
876 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
877 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
879 _cupsLangPrintf(stderr
,
880 _("%s: Error - add '/version=1.1' to server name."),
885 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
887 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
894 DEBUG_puts("show_classes: request succeeded...");
896 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
898 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
904 * Loop through the printers returned in the list and display
908 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
911 * Skip leading attributes until we hit a job...
914 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
921 * Pull the needed attributes from this job...
928 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
930 if (!strcmp(attr
->name
, "printer-name") &&
931 attr
->value_tag
== IPP_TAG_NAME
)
932 printer
= attr
->values
[0].string
.text
;
934 if (!strcmp(attr
->name
, "printer-uri-supported") &&
935 attr
->value_tag
== IPP_TAG_URI
)
936 printer_uri
= attr
->values
[0].string
.text
;
938 if (!strcmp(attr
->name
, "member-names") &&
939 attr
->value_tag
== IPP_TAG_NAME
)
946 * If this is a remote class, grab the class info from the
951 if (members
== NULL
&& printer_uri
!= NULL
)
953 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
954 username
, sizeof(username
), server
, sizeof(server
),
955 &port
, resource
, sizeof(resource
));
957 if (!_cups_strcasecmp(server
, cupsServer()))
958 http2
= CUPS_HTTP_DEFAULT
;
960 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
963 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
964 * following attributes:
967 * attributes-natural-language
969 * requested-attributes
972 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
974 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
975 "printer-uri", NULL
, printer_uri
);
977 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
978 "requested-attributes",
979 sizeof(cattrs
) / sizeof(cattrs
[0]),
982 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
983 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
990 * See if we have everything needed...
996 ippDelete(response2
);
1005 * Display the printer entry if needed...
1008 if (match_list(dests
, printer
))
1010 _cupsLangPrintf(stdout
, _("members of class %s:"), printer
);
1014 for (i
= 0; i
< members
->num_values
; i
++)
1015 _cupsLangPrintf(stdout
, "\t%s", members
->values
[i
].string
.text
);
1018 _cupsLangPuts(stdout
, "\tunknown");
1022 ippDelete(response2
);
1028 ippDelete(response
);
1036 * 'show_default()' - Show default destination.
1040 show_default(cups_dest_t
*dest
) /* I - Default destination */
1042 const char *printer
, /* Printer name */
1043 *val
; /* Environment variable name */
1049 _cupsLangPrintf(stdout
, _("system default destination: %s/%s"),
1050 dest
->name
, dest
->instance
);
1052 _cupsLangPrintf(stdout
, _("system default destination: %s"),
1059 if ((printer
= getenv("LPDEST")) == NULL
)
1061 if ((printer
= getenv("PRINTER")) != NULL
)
1063 if (!strcmp(printer
, "lp"))
1073 _cupsLangPrintf(stdout
,
1074 _("lpstat: error - %s environment variable names "
1075 "non-existent destination \"%s\"."),
1078 _cupsLangPuts(stdout
, _("no system default destination"));
1084 * 'show_devices()' - Show printer devices.
1087 static int /* O - 0 on success, 1 on fail */
1088 show_devices(const char *printers
, /* I - Destinations */
1089 int num_dests
, /* I - Number of user-defined dests */
1090 cups_dest_t
*dests
) /* I - User-defined destinations */
1092 int i
; /* Looping var */
1093 ipp_t
*request
, /* IPP Request */
1094 *response
; /* IPP Response */
1095 ipp_attribute_t
*attr
; /* Current attribute */
1096 const char *printer
, /* Printer name */
1097 *uri
, /* Printer URI */
1098 *device
; /* Printer device URI */
1099 static const char *pattrs
[] = /* Attributes we need for printers... */
1102 "printer-uri-supported",
1107 DEBUG_printf(("show_devices(printers=\"%s\")\n", printers
));
1109 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1113 * Build a CUPS_GET_PRINTERS request, which requires the following
1116 * attributes-charset
1117 * attributes-natural-language
1118 * requested-attributes
1119 * requesting-user-name
1122 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1124 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1125 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1128 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1132 * Do the request and get back a response...
1135 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1137 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1138 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1140 _cupsLangPrintf(stderr
,
1141 _("%s: Error - add '/version=1.1' to server name."),
1143 ippDelete(response
);
1146 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1148 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1149 ippDelete(response
);
1155 DEBUG_puts("show_devices: request succeeded...");
1158 * Loop through the printers returned in the list and display
1162 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1165 * Skip leading attributes until we hit a job...
1168 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1175 * Pull the needed attributes from this job...
1182 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1184 if (!strcmp(attr
->name
, "printer-name") &&
1185 attr
->value_tag
== IPP_TAG_NAME
)
1186 printer
= attr
->values
[0].string
.text
;
1188 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1189 attr
->value_tag
== IPP_TAG_URI
)
1190 uri
= attr
->values
[0].string
.text
;
1192 if (!strcmp(attr
->name
, "device-uri") &&
1193 attr
->value_tag
== IPP_TAG_URI
)
1194 device
= attr
->values
[0].string
.text
;
1200 * See if we have everything needed...
1203 if (printer
== NULL
)
1212 * Display the printer entry if needed...
1215 if (match_list(printers
, printer
))
1218 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1220 else if (!strncmp(device
, "file:", 5))
1221 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1222 printer
, device
+ 5);
1224 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1227 for (i
= 0; i
< num_dests
; i
++)
1229 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1232 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1233 printer
, dests
[i
].instance
, uri
);
1234 else if (!strncmp(device
, "file:", 5))
1235 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1236 printer
, dests
[i
].instance
, device
+ 5);
1238 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1239 printer
, dests
[i
].instance
, device
);
1248 ippDelete(response
);
1256 * 'show_jobs()' - Show active print jobs.
1259 static int /* O - 0 on success, 1 on fail */
1260 show_jobs(const char *dests
, /* I - Destinations */
1261 const char *users
, /* I - Users */
1262 int long_status
, /* I - Show long status? */
1263 int ranking
, /* I - Show job ranking? */
1264 const char *which
) /* I - Show which jobs? */
1266 int i
; /* Looping var */
1267 ipp_t
*request
, /* IPP Request */
1268 *response
; /* IPP Response */
1269 ipp_attribute_t
*attr
, /* Current attribute */
1270 *reasons
; /* Job state reasons attribute */
1271 const char *dest
, /* Pointer into job-printer-uri */
1272 *username
, /* Pointer to job-originating-user-name */
1273 *message
, /* Pointer to job-printer-state-message */
1274 *time_at
; /* time-at-xxx attribute name to use */
1275 int rank
, /* Rank in queue */
1277 size
; /* job-k-octets */
1278 time_t jobtime
; /* time-at-creation */
1279 char temp
[255], /* Temporary buffer */
1280 date
[255]; /* Date buffer */
1281 static const char *jattrs
[] = /* Attributes we need for jobs... */
1286 "job-originating-user-name",
1287 "job-printer-state-message",
1289 "job-state-reasons",
1295 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1296 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1299 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1303 * Build a IPP_GET_JOBS request, which requires the following
1306 * attributes-charset
1307 * attributes-natural-language
1309 * requested-attributes
1310 * requesting-user-name
1314 request
= ippNewRequest(IPP_GET_JOBS
);
1316 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1317 NULL
, "ipp://localhost/");
1319 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1320 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1323 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1326 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1330 * Do the request and get back a response...
1333 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1335 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1336 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1338 _cupsLangPrintf(stderr
,
1339 _("%s: Error - add '/version=1.1' to server name."),
1341 ippDelete(response
);
1344 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1346 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1347 ippDelete(response
);
1354 * Loop through the job list and display them...
1357 if (!strcmp(which
, "aborted") ||
1358 !strcmp(which
, "canceled") ||
1359 !strcmp(which
, "completed"))
1360 time_at
= "time-at-completed";
1362 time_at
= "time-at-creation";
1366 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1369 * Skip leading attributes until we hit a job...
1372 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1379 * Pull the needed attributes from this job...
1390 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1392 if (!strcmp(attr
->name
, "job-id") &&
1393 attr
->value_tag
== IPP_TAG_INTEGER
)
1394 jobid
= attr
->values
[0].integer
;
1395 else if (!strcmp(attr
->name
, "job-k-octets") &&
1396 attr
->value_tag
== IPP_TAG_INTEGER
)
1397 size
= attr
->values
[0].integer
;
1398 else if (!strcmp(attr
->name
, time_at
) && attr
->value_tag
== IPP_TAG_INTEGER
)
1399 jobtime
= attr
->values
[0].integer
;
1400 else if (!strcmp(attr
->name
, "job-printer-state-message") &&
1401 attr
->value_tag
== IPP_TAG_TEXT
)
1402 message
= attr
->values
[0].string
.text
;
1403 else if (!strcmp(attr
->name
, "job-printer-uri") &&
1404 attr
->value_tag
== IPP_TAG_URI
)
1406 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1409 else if (!strcmp(attr
->name
, "job-originating-user-name") &&
1410 attr
->value_tag
== IPP_TAG_NAME
)
1411 username
= attr
->values
[0].string
.text
;
1412 else if (!strcmp(attr
->name
, "job-state-reasons") &&
1413 attr
->value_tag
== IPP_TAG_KEYWORD
)
1420 * See if we have everything needed...
1423 if (dest
== NULL
|| jobid
== 0)
1432 * Display the job...
1437 if (match_list(dests
, dest
) && match_list(users
, username
))
1439 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1441 _cupsStrDate(date
, sizeof(date
), jobtime
);
1444 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s",
1445 rank
, temp
, username
? username
: "unknown",
1446 1024.0 * size
, date
);
1448 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s",
1449 temp
, username
? username
: "unknown",
1450 1024.0 * size
, date
);
1454 _cupsLangPrintf(stdout
, _("\tStatus: %s"), message
);
1458 char alerts
[1024], /* Alerts string */
1459 *aptr
; /* Pointer into alerts string */
1461 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1464 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1466 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1468 aptr
+= strlen(aptr
);
1471 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1474 _cupsLangPrintf(stdout
, _("\tqueued for %s"), dest
);
1482 ippDelete(response
);
1490 * 'show_printers()' - Show printers.
1493 static int /* O - 0 on success, 1 on fail */
1494 show_printers(const char *printers
, /* I - Destinations */
1495 int num_dests
, /* I - Number of user-defined dests */
1496 cups_dest_t
*dests
, /* I - User-defined destinations */
1497 int long_status
) /* I - Show long status? */
1499 int i
, j
; /* Looping vars */
1500 ipp_t
*request
, /* IPP Request */
1501 *response
, /* IPP Response */
1502 *jobs
; /* IPP Get Jobs response */
1503 ipp_attribute_t
*attr
, /* Current attribute */
1504 *jobattr
, /* Job ID attribute */
1505 *reasons
; /* Job state reasons attribute */
1506 const char *printer
, /* Printer name */
1507 *message
, /* Printer state message */
1508 *description
, /* Description of printer */
1509 *location
, /* Location of printer */
1510 *make_model
, /* Make and model of printer */
1511 *uri
; /* URI of printer */
1512 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1513 *denied
; /* requestint-user-name-denied */
1514 ipp_pstate_t pstate
; /* Printer state */
1515 cups_ptype_t ptype
; /* Printer type */
1516 time_t ptime
; /* Printer state time */
1517 int jobid
; /* Job ID of current job */
1518 char printer_uri
[HTTP_MAX_URI
],
1520 printer_state_time
[255];/* Printer state time */
1521 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1522 static const char *pattrs
[] = /* Attributes we need for printers... */
1526 "printer-state-message",
1527 "printer-state-reasons",
1528 "printer-state-change-time",
1532 "printer-make-and-model",
1533 "printer-uri-supported",
1534 "requesting-user-name-allowed",
1535 "requesting-user-name-denied"
1537 static const char *jattrs
[] = /* Attributes we need for jobs... */
1544 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1545 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1547 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1551 * Build a CUPS_GET_PRINTERS request, which requires the following
1554 * attributes-charset
1555 * attributes-natural-language
1556 * requested-attributes
1557 * requesting-user-name
1560 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1562 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1563 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1566 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1570 * Do the request and get back a response...
1573 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1575 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1576 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1578 _cupsLangPrintf(stderr
,
1579 _("%s: Error - add '/version=1.1' to server name."),
1581 ippDelete(response
);
1584 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1586 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1587 ippDelete(response
);
1593 DEBUG_puts("show_printers: request succeeded...");
1596 * Loop through the printers returned in the list and display
1600 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1603 * Skip leading attributes until we hit a job...
1606 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1613 * Pull the needed attributes from this job...
1618 ptype
= CUPS_PRINTER_LOCAL
;
1619 pstate
= IPP_PRINTER_IDLE
;
1630 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1632 if (!strcmp(attr
->name
, "printer-name") &&
1633 attr
->value_tag
== IPP_TAG_NAME
)
1634 printer
= attr
->values
[0].string
.text
;
1635 else if (!strcmp(attr
->name
, "printer-state") &&
1636 attr
->value_tag
== IPP_TAG_ENUM
)
1637 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1638 else if (!strcmp(attr
->name
, "printer-type") &&
1639 attr
->value_tag
== IPP_TAG_ENUM
)
1640 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1641 else if (!strcmp(attr
->name
, "printer-state-message") &&
1642 attr
->value_tag
== IPP_TAG_TEXT
)
1643 message
= attr
->values
[0].string
.text
;
1644 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1645 attr
->value_tag
== IPP_TAG_INTEGER
)
1646 ptime
= (time_t)attr
->values
[0].integer
;
1647 else if (!strcmp(attr
->name
, "printer-info") &&
1648 attr
->value_tag
== IPP_TAG_TEXT
)
1649 description
= attr
->values
[0].string
.text
;
1650 else if (!strcmp(attr
->name
, "printer-location") &&
1651 attr
->value_tag
== IPP_TAG_TEXT
)
1652 location
= attr
->values
[0].string
.text
;
1653 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1654 attr
->value_tag
== IPP_TAG_TEXT
)
1655 make_model
= attr
->values
[0].string
.text
;
1656 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1657 attr
->value_tag
== IPP_TAG_URI
)
1658 uri
= attr
->values
[0].string
.text
;
1659 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1660 attr
->value_tag
== IPP_TAG_KEYWORD
)
1662 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1663 attr
->value_tag
== IPP_TAG_NAME
)
1665 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1666 attr
->value_tag
== IPP_TAG_NAME
)
1673 * See if we have everything needed...
1676 if (printer
== NULL
)
1685 * Display the printer entry if needed...
1688 if (match_list(printers
, printer
))
1691 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1692 * current job for the printer.
1695 if (pstate
== IPP_PRINTER_PROCESSING
)
1698 * Build an IPP_GET_JOBS request, which requires the following
1701 * attributes-charset
1702 * attributes-natural-language
1705 * requested-attributes
1708 request
= ippNewRequest(IPP_GET_JOBS
);
1710 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1711 request
->request
.op
.request_id
= 1;
1713 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1714 "requested-attributes",
1715 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1717 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1718 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1719 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1720 "printer-uri", NULL
, printer_uri
);
1722 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1725 * Get the current active job on this queue...
1728 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1731 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1735 if (jobstate
== IPP_JOB_PROCESSING
)
1741 if (!strcmp(jobattr
->name
, "job-id") &&
1742 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1743 jobid
= jobattr
->values
[0].integer
;
1744 else if (!strcmp(jobattr
->name
, "job-state") &&
1745 jobattr
->value_tag
== IPP_TAG_ENUM
)
1746 jobstate
= (ipp_jstate_t
)jobattr
->values
[0].integer
;
1749 if (jobstate
!= IPP_JOB_PROCESSING
)
1760 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
1764 case IPP_PRINTER_IDLE
:
1765 _cupsLangPrintf(stdout
,
1766 _("printer %s is idle. enabled since %s"),
1767 printer
, printer_state_time
);
1769 case IPP_PRINTER_PROCESSING
:
1770 _cupsLangPrintf(stdout
,
1771 _("printer %s now printing %s-%d. "
1772 "enabled since %s"),
1773 printer
, printer
, jobid
, printer_state_time
);
1775 case IPP_PRINTER_STOPPED
:
1776 _cupsLangPrintf(stdout
,
1777 _("printer %s disabled since %s -"),
1778 printer
, printer_state_time
);
1782 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1784 if (!message
|| !*message
)
1785 _cupsLangPuts(stdout
, _("\treason unknown"));
1787 _cupsLangPrintf(stdout
, "\t%s", message
);
1790 if (long_status
> 1)
1792 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1793 _cupsLangPuts(stdout
, _("\tContent types: any"));
1794 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1799 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1800 description
? description
: "");
1804 char alerts
[1024], /* Alerts string */
1805 *aptr
; /* Pointer into alerts string */
1807 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1810 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1812 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1814 aptr
+= strlen(aptr
);
1817 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1820 if (long_status
> 1)
1822 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1823 location
? location
: "");
1825 if (ptype
& CUPS_PRINTER_REMOTE
)
1827 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1829 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1830 !strstr(make_model
, "Raw Printer") && uri
)
1831 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"),
1836 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1838 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1839 _cupsLangPrintf(stdout
,
1840 _("\tInterface: %s/ppd/%s.ppd"),
1841 cg
->cups_serverroot
, printer
);
1843 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1844 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1845 /* TODO update to use printer-error-policy */
1848 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1849 for (j
= 0; j
< allowed
->num_values
; j
++)
1850 _cupsLangPrintf(stdout
, "\t\t%s",
1851 allowed
->values
[j
].string
.text
);
1855 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1856 for (j
= 0; j
< denied
->num_values
; j
++)
1857 _cupsLangPrintf(stdout
, "\t\t%s",
1858 denied
->values
[j
].string
.text
);
1862 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1863 _cupsLangPuts(stdout
, _("\t\t(all)"));
1865 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1866 _cupsLangPuts(stdout
, _("\t\t(none)"));
1867 _cupsLangPuts(stdout
, _("\tBanner required"));
1868 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1869 _cupsLangPuts(stdout
, _("\t\t(none)"));
1870 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1871 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1872 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1875 for (i
= 0; i
< num_dests
; i
++)
1876 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1880 case IPP_PRINTER_IDLE
:
1881 _cupsLangPrintf(stdout
,
1882 _("printer %s/%s is idle. "
1883 "enabled since %s"),
1884 printer
, dests
[i
].instance
,
1885 printer_state_time
);
1887 case IPP_PRINTER_PROCESSING
:
1888 _cupsLangPrintf(stdout
,
1889 _("printer %s/%s now printing %s-%d. "
1890 "enabled since %s"),
1891 printer
, dests
[i
].instance
, printer
, jobid
,
1892 printer_state_time
);
1894 case IPP_PRINTER_STOPPED
:
1895 _cupsLangPrintf(stdout
,
1896 _("printer %s/%s disabled since %s -"),
1897 printer
, dests
[i
].instance
,
1898 printer_state_time
);
1902 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1904 if (!message
|| !*message
)
1905 _cupsLangPuts(stdout
, _("\treason unknown"));
1907 _cupsLangPrintf(stdout
, "\t%s", message
);
1910 if (long_status
> 1)
1912 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1913 _cupsLangPuts(stdout
, _("\tContent types: any"));
1914 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1919 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1920 description
? description
: "");
1924 char alerts
[1024], /* Alerts string */
1925 *aptr
; /* Pointer into alerts string */
1927 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1930 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1932 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1934 aptr
+= strlen(aptr
);
1937 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1940 if (long_status
> 1)
1942 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1943 location
? location
: "");
1945 if (ptype
& CUPS_PRINTER_REMOTE
)
1947 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1949 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1950 !strstr(make_model
, "Raw Printer") && uri
)
1951 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"), uri
);
1955 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1957 if (make_model
&& !strstr(make_model
, "Raw Printer"))
1958 _cupsLangPrintf(stdout
,
1959 _("\tInterface: %s/ppd/%s.ppd"),
1960 cg
->cups_serverroot
, printer
);
1962 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1963 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1964 /* TODO update to use printer-error-policy */
1967 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1968 for (j
= 0; j
< allowed
->num_values
; j
++)
1969 _cupsLangPrintf(stdout
, "\t\t%s",
1970 allowed
->values
[j
].string
.text
);
1974 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1975 for (j
= 0; j
< denied
->num_values
; j
++)
1976 _cupsLangPrintf(stdout
, "\t\t%s",
1977 denied
->values
[j
].string
.text
);
1981 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1982 _cupsLangPuts(stdout
, _("\t\t(all)"));
1984 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1985 _cupsLangPuts(stdout
, _("\t\t(none)"));
1986 _cupsLangPuts(stdout
, _("\tBanner required"));
1987 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1988 _cupsLangPuts(stdout
, _("\t\t(none)"));
1989 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1990 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1991 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
2000 ippDelete(response
);
2008 * 'show_scheduler()' - Show scheduler status.
2012 show_scheduler(void)
2014 http_t
*http
; /* Connection to server */
2017 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
2018 cupsEncryption())) != NULL
)
2020 _cupsLangPuts(stdout
, _("scheduler is running"));
2024 _cupsLangPuts(stdout
, _("scheduler is not running"));