4 * "lpstat" command for CUPS.
6 * Copyright 2007-2013 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 struct tm
*pdate
; /* Printer state date & time */
653 char printer_state_time
[255];/* Printer state time */
654 static const char *pattrs
[] = /* Attributes we need for printers... */
657 "printer-state-change-time",
658 "printer-state-message",
659 "printer-is-accepting-jobs"
663 DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers
));
665 if (printers
!= NULL
&& !strcmp(printers
, "all"))
669 * Build a CUPS_GET_PRINTERS request, which requires the following
673 * attributes-natural-language
674 * requested-attributes
675 * requesting-user-name
678 request
= ippNewRequest(CUPS_GET_PRINTERS
);
680 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
681 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
684 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
688 * Do the request and get back a response...
691 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
693 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
694 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
696 _cupsLangPrintf(stderr
,
697 _("%s: Error - add '/version=1.1' to server name."),
702 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
704 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
711 DEBUG_puts("show_accepting: request succeeded...");
714 * Loop through the printers returned in the list and display
718 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
721 * Skip leading attributes until we hit a printer...
724 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
731 * Pull the needed attributes from this printer...
739 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
741 if (!strcmp(attr
->name
, "printer-name") &&
742 attr
->value_tag
== IPP_TAG_NAME
)
743 printer
= attr
->values
[0].string
.text
;
744 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
745 attr
->value_tag
== IPP_TAG_INTEGER
)
746 ptime
= (time_t)attr
->values
[0].integer
;
747 else if (!strcmp(attr
->name
, "printer-state-message") &&
748 attr
->value_tag
== IPP_TAG_TEXT
)
749 message
= attr
->values
[0].string
.text
;
750 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
751 attr
->value_tag
== IPP_TAG_BOOLEAN
)
752 accepting
= attr
->values
[0].boolean
;
758 * See if we have everything needed...
770 * Display the printer entry if needed...
773 if (match_list(printers
, printer
))
775 pdate
= localtime(&ptime
);
776 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
779 _cupsLangPrintf(stdout
, _("%s accepting requests since %s"),
780 printer
, printer_state_time
);
783 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -"),
784 printer
, printer_state_time
);
785 _cupsLangPrintf(stdout
, _("\t%s"),
786 (message
== NULL
|| !*message
) ?
787 "reason unknown" : message
);
790 for (i
= 0; i
< num_dests
; i
++)
791 if (!_cups_strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
794 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s"),
795 printer
, dests
[i
].instance
, printer_state_time
);
798 _cupsLangPrintf(stdout
,
799 _("%s/%s not accepting requests since %s -"),
800 printer
, dests
[i
].instance
, printer_state_time
);
801 _cupsLangPrintf(stdout
, _("\t%s"),
802 (message
== NULL
|| !*message
) ?
803 "reason unknown" : message
);
820 * 'show_classes()' - Show printer classes.
823 static int /* O - 0 on success, 1 on fail */
824 show_classes(const char *dests
) /* I - Destinations */
826 int i
; /* Looping var */
827 ipp_t
*request
, /* IPP Request */
828 *response
, /* IPP Response */
829 *response2
; /* IPP response from remote server */
830 http_t
*http2
; /* Remote server */
831 ipp_attribute_t
*attr
; /* Current attribute */
832 const char *printer
, /* Printer class name */
833 *printer_uri
; /* Printer class URI */
834 ipp_attribute_t
*members
; /* Printer members */
835 char method
[HTTP_MAX_URI
], /* Request method */
836 username
[HTTP_MAX_URI
], /* Username:password */
837 server
[HTTP_MAX_URI
], /* Server name */
838 resource
[HTTP_MAX_URI
]; /* Resource name */
839 int port
; /* Port number */
840 static const char *cattrs
[] = /* Attributes we need for classes... */
843 "printer-uri-supported",
848 DEBUG_printf(("show_classes(dests=\"%s\")\n", dests
));
850 if (dests
!= NULL
&& !strcmp(dests
, "all"))
854 * Build a CUPS_GET_CLASSES request, which requires the following
858 * attributes-natural-language
859 * requested-attributes
860 * requesting-user-name
863 request
= ippNewRequest(CUPS_GET_CLASSES
);
865 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
866 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
869 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
873 * Do the request and get back a response...
876 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
878 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
879 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
881 _cupsLangPrintf(stderr
,
882 _("%s: Error - add '/version=1.1' to server name."),
887 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
889 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
896 DEBUG_puts("show_classes: request succeeded...");
898 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
900 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
906 * Loop through the printers returned in the list and display
910 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
913 * Skip leading attributes until we hit a job...
916 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
923 * Pull the needed attributes from this job...
930 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
932 if (!strcmp(attr
->name
, "printer-name") &&
933 attr
->value_tag
== IPP_TAG_NAME
)
934 printer
= attr
->values
[0].string
.text
;
936 if (!strcmp(attr
->name
, "printer-uri-supported") &&
937 attr
->value_tag
== IPP_TAG_URI
)
938 printer_uri
= attr
->values
[0].string
.text
;
940 if (!strcmp(attr
->name
, "member-names") &&
941 attr
->value_tag
== IPP_TAG_NAME
)
948 * If this is a remote class, grab the class info from the
953 if (members
== NULL
&& printer_uri
!= NULL
)
955 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
956 username
, sizeof(username
), server
, sizeof(server
),
957 &port
, resource
, sizeof(resource
));
959 if (!_cups_strcasecmp(server
, cupsServer()))
960 http2
= CUPS_HTTP_DEFAULT
;
962 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
965 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
966 * following attributes:
969 * attributes-natural-language
971 * requested-attributes
974 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
976 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
977 "printer-uri", NULL
, printer_uri
);
979 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
980 "requested-attributes",
981 sizeof(cattrs
) / sizeof(cattrs
[0]),
984 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
985 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
992 * See if we have everything needed...
998 ippDelete(response2
);
1007 * Display the printer entry if needed...
1010 if (match_list(dests
, printer
))
1012 _cupsLangPrintf(stdout
, _("members of class %s:"), printer
);
1016 for (i
= 0; i
< members
->num_values
; i
++)
1017 _cupsLangPrintf(stdout
, "\t%s", members
->values
[i
].string
.text
);
1020 _cupsLangPuts(stdout
, "\tunknown");
1024 ippDelete(response2
);
1030 ippDelete(response
);
1038 * 'show_default()' - Show default destination.
1042 show_default(cups_dest_t
*dest
) /* I - Default destination */
1044 const char *printer
, /* Printer name */
1045 *val
; /* Environment variable name */
1051 _cupsLangPrintf(stdout
, _("system default destination: %s/%s"),
1052 dest
->name
, dest
->instance
);
1054 _cupsLangPrintf(stdout
, _("system default destination: %s"),
1061 if ((printer
= getenv("LPDEST")) == NULL
)
1063 if ((printer
= getenv("PRINTER")) != NULL
)
1065 if (!strcmp(printer
, "lp"))
1075 _cupsLangPrintf(stdout
,
1076 _("lpstat: error - %s environment variable names "
1077 "non-existent destination \"%s\"."),
1080 _cupsLangPuts(stdout
, _("no system default destination"));
1086 * 'show_devices()' - Show printer devices.
1089 static int /* O - 0 on success, 1 on fail */
1090 show_devices(const char *printers
, /* I - Destinations */
1091 int num_dests
, /* I - Number of user-defined dests */
1092 cups_dest_t
*dests
) /* I - User-defined destinations */
1094 int i
; /* Looping var */
1095 ipp_t
*request
, /* IPP Request */
1096 *response
; /* IPP Response */
1097 ipp_attribute_t
*attr
; /* Current attribute */
1098 const char *printer
, /* Printer name */
1099 *uri
, /* Printer URI */
1100 *device
; /* Printer device URI */
1101 static const char *pattrs
[] = /* Attributes we need for printers... */
1104 "printer-uri-supported",
1109 DEBUG_printf(("show_devices(printers=\"%s\")\n", printers
));
1111 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1115 * Build a CUPS_GET_PRINTERS request, which requires the following
1118 * attributes-charset
1119 * attributes-natural-language
1120 * requested-attributes
1121 * requesting-user-name
1124 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1126 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1127 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1130 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1134 * Do the request and get back a response...
1137 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1139 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1140 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1142 _cupsLangPrintf(stderr
,
1143 _("%s: Error - add '/version=1.1' to server name."),
1145 ippDelete(response
);
1148 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1150 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1151 ippDelete(response
);
1157 DEBUG_puts("show_devices: request succeeded...");
1160 * Loop through the printers returned in the list and display
1164 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1167 * Skip leading attributes until we hit a job...
1170 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1177 * Pull the needed attributes from this job...
1184 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1186 if (!strcmp(attr
->name
, "printer-name") &&
1187 attr
->value_tag
== IPP_TAG_NAME
)
1188 printer
= attr
->values
[0].string
.text
;
1190 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1191 attr
->value_tag
== IPP_TAG_URI
)
1192 uri
= attr
->values
[0].string
.text
;
1194 if (!strcmp(attr
->name
, "device-uri") &&
1195 attr
->value_tag
== IPP_TAG_URI
)
1196 device
= attr
->values
[0].string
.text
;
1202 * See if we have everything needed...
1205 if (printer
== NULL
)
1214 * Display the printer entry if needed...
1217 if (match_list(printers
, printer
))
1220 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1222 else if (!strncmp(device
, "file:", 5))
1223 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1224 printer
, device
+ 5);
1226 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1229 for (i
= 0; i
< num_dests
; i
++)
1231 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1234 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1235 printer
, dests
[i
].instance
, uri
);
1236 else if (!strncmp(device
, "file:", 5))
1237 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1238 printer
, dests
[i
].instance
, device
+ 5);
1240 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1241 printer
, dests
[i
].instance
, device
);
1250 ippDelete(response
);
1258 * 'show_jobs()' - Show active print jobs.
1261 static int /* O - 0 on success, 1 on fail */
1262 show_jobs(const char *dests
, /* I - Destinations */
1263 const char *users
, /* I - Users */
1264 int long_status
, /* I - Show long status? */
1265 int ranking
, /* I - Show job ranking? */
1266 const char *which
) /* I - Show which jobs? */
1268 int i
; /* Looping var */
1269 ipp_t
*request
, /* IPP Request */
1270 *response
; /* IPP Response */
1271 ipp_attribute_t
*attr
, /* Current attribute */
1272 *reasons
; /* Job state reasons attribute */
1273 const char *dest
, /* Pointer into job-printer-uri */
1274 *username
, /* Pointer to job-originating-user-name */
1275 *title
, /* Pointer to job-name */
1276 *message
; /* Pointer to job-printer-state-message */
1277 int rank
, /* Rank in queue */
1279 size
; /* job-k-octets */
1280 time_t jobtime
; /* time-at-creation */
1281 struct tm
*jobdate
; /* Date & time */
1282 char temp
[255], /* Temporary buffer */
1283 date
[255]; /* Date buffer */
1284 static const char *jattrs
[] = /* Attributes we need for jobs... */
1289 "job-originating-user-name",
1290 "job-printer-state-message",
1292 "job-state-reasons",
1297 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1298 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1301 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1305 * Build a IPP_GET_JOBS request, which requires the following
1308 * attributes-charset
1309 * attributes-natural-language
1311 * requested-attributes
1312 * requesting-user-name
1316 request
= ippNewRequest(IPP_GET_JOBS
);
1318 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1319 NULL
, "ipp://localhost/");
1321 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1322 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1325 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1328 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1332 * Do the request and get back a response...
1335 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1337 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1338 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1340 _cupsLangPrintf(stderr
,
1341 _("%s: Error - add '/version=1.1' to server name."),
1343 ippDelete(response
);
1346 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1348 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1349 ippDelete(response
);
1356 * Loop through the job list and display them...
1361 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1364 * Skip leading attributes until we hit a job...
1367 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1374 * Pull the needed attributes from this job...
1386 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1388 if (!strcmp(attr
->name
, "job-id") &&
1389 attr
->value_tag
== IPP_TAG_INTEGER
)
1390 jobid
= attr
->values
[0].integer
;
1391 else if (!strcmp(attr
->name
, "job-k-octets") &&
1392 attr
->value_tag
== IPP_TAG_INTEGER
)
1393 size
= attr
->values
[0].integer
;
1394 else if (!strcmp(attr
->name
, "time-at-creation") &&
1395 attr
->value_tag
== IPP_TAG_INTEGER
)
1396 jobtime
= attr
->values
[0].integer
;
1397 else if (!strcmp(attr
->name
, "job-printer-state-message") &&
1398 attr
->value_tag
== IPP_TAG_TEXT
)
1399 message
= attr
->values
[0].string
.text
;
1400 else if (!strcmp(attr
->name
, "job-printer-uri") &&
1401 attr
->value_tag
== IPP_TAG_URI
)
1403 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1406 else if (!strcmp(attr
->name
, "job-originating-user-name") &&
1407 attr
->value_tag
== IPP_TAG_NAME
)
1408 username
= attr
->values
[0].string
.text
;
1409 else if (!strcmp(attr
->name
, "job-name") &&
1410 attr
->value_tag
== IPP_TAG_NAME
)
1411 title
= 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 jobdate
= localtime(&jobtime
);
1440 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1442 if (long_status
== 3)
1445 * Show the consolidated output format for the SGI tools...
1448 if (!strftime(date
, sizeof(date
), "%b %d %H:%M", jobdate
))
1449 strlcpy(date
, "Unknown", sizeof(date
));
1451 _cupsLangPrintf(stdout
, "%s;%s;%d;%s;%s",
1452 temp
, username
? username
: "unknown",
1453 size
, title
? title
: "unknown", date
);
1457 if (!strftime(date
, sizeof(date
), "%c", jobdate
))
1458 strlcpy(date
, "Unknown", sizeof(date
));
1461 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s",
1462 rank
, temp
, username
? username
: "unknown",
1463 1024.0 * size
, date
);
1465 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s",
1466 temp
, username
? username
: "unknown",
1467 1024.0 * size
, date
);
1471 _cupsLangPrintf(stdout
, _("\tStatus: %s"), message
);
1475 char alerts
[1024], /* Alerts string */
1476 *aptr
; /* Pointer into alerts string */
1478 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1481 snprintf(aptr
, sizeof(alerts
) - (aptr
- alerts
), " %s",
1482 reasons
->values
[i
].string
.text
);
1484 strlcpy(alerts
, reasons
->values
[i
].string
.text
,
1487 aptr
+= strlen(aptr
);
1490 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1493 _cupsLangPrintf(stdout
, _("\tqueued for %s"), dest
);
1502 ippDelete(response
);
1510 * 'show_printers()' - Show printers.
1513 static int /* O - 0 on success, 1 on fail */
1514 show_printers(const char *printers
, /* I - Destinations */
1515 int num_dests
, /* I - Number of user-defined dests */
1516 cups_dest_t
*dests
, /* I - User-defined destinations */
1517 int long_status
) /* I - Show long status? */
1519 int i
, j
; /* Looping vars */
1520 ipp_t
*request
, /* IPP Request */
1521 *response
, /* IPP Response */
1522 *jobs
; /* IPP Get Jobs response */
1523 ipp_attribute_t
*attr
, /* Current attribute */
1524 *jobattr
, /* Job ID attribute */
1525 *reasons
; /* Job state reasons attribute */
1526 const char *printer
, /* Printer name */
1527 *message
, /* Printer state message */
1528 *description
, /* Description of printer */
1529 *location
, /* Location of printer */
1530 *make_model
, /* Make and model of printer */
1531 *uri
; /* URI of printer */
1532 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1533 *denied
; /* requestint-user-name-denied */
1534 ipp_pstate_t pstate
; /* Printer state */
1535 cups_ptype_t ptype
; /* Printer type */
1536 time_t ptime
; /* Printer state time */
1537 struct tm
*pdate
; /* Printer state date & time */
1538 int jobid
; /* Job ID of current job */
1539 char printer_uri
[HTTP_MAX_URI
],
1541 printer_state_time
[255];/* Printer state time */
1542 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1543 static const char *pattrs
[] = /* Attributes we need for printers... */
1547 "printer-state-message",
1548 "printer-state-reasons",
1549 "printer-state-change-time",
1553 "printer-make-and-model",
1554 "printer-uri-supported",
1555 "requesting-user-name-allowed",
1556 "requesting-user-name-denied"
1558 static const char *jattrs
[] = /* Attributes we need for jobs... */
1565 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1566 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1568 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1572 * Build a CUPS_GET_PRINTERS request, which requires the following
1575 * attributes-charset
1576 * attributes-natural-language
1577 * requested-attributes
1578 * requesting-user-name
1581 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1583 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1584 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1587 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1591 * Do the request and get back a response...
1594 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1596 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1597 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1599 _cupsLangPrintf(stderr
,
1600 _("%s: Error - add '/version=1.1' to server name."),
1602 ippDelete(response
);
1605 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1607 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1608 ippDelete(response
);
1614 DEBUG_puts("show_printers: request succeeded...");
1617 * Loop through the printers returned in the list and display
1621 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1624 * Skip leading attributes until we hit a job...
1627 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1634 * Pull the needed attributes from this job...
1639 ptype
= CUPS_PRINTER_LOCAL
;
1640 pstate
= IPP_PRINTER_IDLE
;
1651 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1653 if (!strcmp(attr
->name
, "printer-name") &&
1654 attr
->value_tag
== IPP_TAG_NAME
)
1655 printer
= attr
->values
[0].string
.text
;
1656 else if (!strcmp(attr
->name
, "printer-state") &&
1657 attr
->value_tag
== IPP_TAG_ENUM
)
1658 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1659 else if (!strcmp(attr
->name
, "printer-type") &&
1660 attr
->value_tag
== IPP_TAG_ENUM
)
1661 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1662 else if (!strcmp(attr
->name
, "printer-state-message") &&
1663 attr
->value_tag
== IPP_TAG_TEXT
)
1664 message
= attr
->values
[0].string
.text
;
1665 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1666 attr
->value_tag
== IPP_TAG_INTEGER
)
1667 ptime
= (time_t)attr
->values
[0].integer
;
1668 else if (!strcmp(attr
->name
, "printer-info") &&
1669 attr
->value_tag
== IPP_TAG_TEXT
)
1670 description
= attr
->values
[0].string
.text
;
1671 else if (!strcmp(attr
->name
, "printer-location") &&
1672 attr
->value_tag
== IPP_TAG_TEXT
)
1673 location
= attr
->values
[0].string
.text
;
1674 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1675 attr
->value_tag
== IPP_TAG_TEXT
)
1676 make_model
= attr
->values
[0].string
.text
;
1677 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1678 attr
->value_tag
== IPP_TAG_URI
)
1679 uri
= attr
->values
[0].string
.text
;
1680 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1681 attr
->value_tag
== IPP_TAG_KEYWORD
)
1683 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1684 attr
->value_tag
== IPP_TAG_NAME
)
1686 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1687 attr
->value_tag
== IPP_TAG_NAME
)
1694 * See if we have everything needed...
1697 if (printer
== NULL
)
1706 * Display the printer entry if needed...
1709 if (match_list(printers
, printer
))
1712 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1713 * current job for the printer.
1716 if (pstate
== IPP_PRINTER_PROCESSING
)
1719 * Build an IPP_GET_JOBS request, which requires the following
1722 * attributes-charset
1723 * attributes-natural-language
1726 * requested-attributes
1729 request
= ippNewRequest(IPP_GET_JOBS
);
1731 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1732 request
->request
.op
.request_id
= 1;
1734 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1735 "requested-attributes",
1736 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1738 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1739 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1740 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1741 "printer-uri", NULL
, printer_uri
);
1743 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1746 * Get the current active job on this queue...
1749 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1752 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1756 if (jobstate
== IPP_JOB_PROCESSING
)
1762 if (!strcmp(jobattr
->name
, "job-id") &&
1763 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1764 jobid
= jobattr
->values
[0].integer
;
1765 else if (!strcmp(jobattr
->name
, "job-state") &&
1766 jobattr
->value_tag
== IPP_TAG_ENUM
)
1767 jobstate
= jobattr
->values
[0].integer
;
1770 if (jobstate
!= IPP_JOB_PROCESSING
)
1781 pdate
= localtime(&ptime
);
1782 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
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
) - (aptr
- alerts
), " %s",
1833 reasons
->values
[i
].string
.text
);
1835 strlcpy(alerts
, reasons
->values
[i
].string
.text
,
1838 aptr
+= strlen(aptr
);
1841 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1844 if (long_status
> 1)
1846 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1847 location
? location
: "");
1849 if (ptype
& CUPS_PRINTER_REMOTE
)
1851 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1853 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1854 !strstr(make_model
, "Raw Printer") && uri
)
1855 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"),
1860 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1862 if (make_model
&& strstr(make_model
, "System V Printer"))
1863 _cupsLangPrintf(stdout
,
1864 _("\tInterface: %s/interfaces/%s"),
1865 cg
->cups_serverroot
, printer
);
1866 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1867 _cupsLangPrintf(stdout
,
1868 _("\tInterface: %s/ppd/%s.ppd"),
1869 cg
->cups_serverroot
, printer
);
1871 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1872 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1873 /* TODO update to use printer-error-policy */
1876 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1877 for (j
= 0; j
< allowed
->num_values
; j
++)
1878 _cupsLangPrintf(stdout
, "\t\t%s",
1879 allowed
->values
[j
].string
.text
);
1883 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1884 for (j
= 0; j
< denied
->num_values
; j
++)
1885 _cupsLangPrintf(stdout
, "\t\t%s",
1886 denied
->values
[j
].string
.text
);
1890 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1891 _cupsLangPuts(stdout
, _("\t\t(all)"));
1893 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1894 _cupsLangPuts(stdout
, _("\t\t(none)"));
1895 _cupsLangPuts(stdout
, _("\tBanner required"));
1896 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1897 _cupsLangPuts(stdout
, _("\t\t(none)"));
1898 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1899 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1900 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1903 for (i
= 0; i
< num_dests
; i
++)
1904 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1908 case IPP_PRINTER_IDLE
:
1909 _cupsLangPrintf(stdout
,
1910 _("printer %s/%s is idle. "
1911 "enabled since %s"),
1912 printer
, dests
[i
].instance
,
1913 printer_state_time
);
1915 case IPP_PRINTER_PROCESSING
:
1916 _cupsLangPrintf(stdout
,
1917 _("printer %s/%s now printing %s-%d. "
1918 "enabled since %s"),
1919 printer
, dests
[i
].instance
, printer
, jobid
,
1920 printer_state_time
);
1922 case IPP_PRINTER_STOPPED
:
1923 _cupsLangPrintf(stdout
,
1924 _("printer %s/%s disabled since %s -"),
1925 printer
, dests
[i
].instance
,
1926 printer_state_time
);
1930 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1932 if (!message
|| !*message
)
1933 _cupsLangPuts(stdout
, _("\treason unknown"));
1935 _cupsLangPrintf(stdout
, "\t%s", message
);
1938 if (long_status
> 1)
1940 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1941 _cupsLangPuts(stdout
, _("\tContent types: any"));
1942 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1947 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1948 description
? description
: "");
1952 char alerts
[1024], /* Alerts string */
1953 *aptr
; /* Pointer into alerts string */
1955 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1958 snprintf(aptr
, sizeof(alerts
) - (aptr
- alerts
), " %s",
1959 reasons
->values
[i
].string
.text
);
1961 strlcpy(alerts
, reasons
->values
[i
].string
.text
,
1964 aptr
+= strlen(aptr
);
1967 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1970 if (long_status
> 1)
1972 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1973 location
? location
: "");
1975 if (ptype
& CUPS_PRINTER_REMOTE
)
1977 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1979 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1980 !strstr(make_model
, "Raw Printer") && uri
)
1981 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"), uri
);
1985 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1987 if (make_model
&& strstr(make_model
, "System V Printer"))
1988 _cupsLangPrintf(stdout
,
1989 _("\tInterface: %s/interfaces/%s"),
1990 cg
->cups_serverroot
, printer
);
1991 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1992 _cupsLangPrintf(stdout
,
1993 _("\tInterface: %s/ppd/%s.ppd"),
1994 cg
->cups_serverroot
, printer
);
1996 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1997 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1998 /* TODO update to use printer-error-policy */
2001 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
2002 for (j
= 0; j
< allowed
->num_values
; j
++)
2003 _cupsLangPrintf(stdout
, "\t\t%s",
2004 allowed
->values
[j
].string
.text
);
2008 _cupsLangPuts(stdout
, _("\tUsers denied:"));
2009 for (j
= 0; j
< denied
->num_values
; j
++)
2010 _cupsLangPrintf(stdout
, "\t\t%s",
2011 denied
->values
[j
].string
.text
);
2015 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
2016 _cupsLangPuts(stdout
, _("\t\t(all)"));
2018 _cupsLangPuts(stdout
, _("\tForms allowed:"));
2019 _cupsLangPuts(stdout
, _("\t\t(none)"));
2020 _cupsLangPuts(stdout
, _("\tBanner required"));
2021 _cupsLangPuts(stdout
, _("\tCharset sets:"));
2022 _cupsLangPuts(stdout
, _("\t\t(none)"));
2023 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
2024 _cupsLangPuts(stdout
, _("\tDefault page size:"));
2025 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
2034 ippDelete(response
);
2042 * 'show_scheduler()' - Show scheduler status.
2046 show_scheduler(void)
2048 http_t
*http
; /* Connection to server */
2051 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
2052 cupsEncryption())) != NULL
)
2054 _cupsLangPuts(stdout
, _("scheduler is running"));
2058 _cupsLangPuts(stdout
, _("scheduler is not running"));