2 * "$Id: lpstat.c 12066 2014-07-30 18:30:44Z msweet $"
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 *title
, /* Pointer to job-name */
1274 *message
, /* Pointer to job-printer-state-message */
1275 *time_at
; /* time-at-xxx attribute name to use */
1276 int rank
, /* Rank in queue */
1278 size
; /* job-k-octets */
1279 time_t jobtime
; /* time-at-creation */
1280 char temp
[255], /* Temporary buffer */
1281 date
[255]; /* Date buffer */
1282 static const char *jattrs
[] = /* Attributes we need for jobs... */
1287 "job-originating-user-name",
1288 "job-printer-state-message",
1290 "job-state-reasons",
1296 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1297 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1300 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1304 * Build a IPP_GET_JOBS request, which requires the following
1307 * attributes-charset
1308 * attributes-natural-language
1310 * requested-attributes
1311 * requesting-user-name
1315 request
= ippNewRequest(IPP_GET_JOBS
);
1317 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1318 NULL
, "ipp://localhost/");
1320 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1321 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1324 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1327 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1331 * Do the request and get back a response...
1334 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1336 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1337 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1339 _cupsLangPrintf(stderr
,
1340 _("%s: Error - add '/version=1.1' to server name."),
1342 ippDelete(response
);
1345 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1347 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1348 ippDelete(response
);
1355 * Loop through the job list and display them...
1358 if (!strcmp(which
, "aborted") ||
1359 !strcmp(which
, "canceled") ||
1360 !strcmp(which
, "completed"))
1361 time_at
= "time-at-completed";
1363 time_at
= "time-at-creation";
1367 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1370 * Skip leading attributes until we hit a job...
1373 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1380 * Pull the needed attributes from this job...
1392 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1394 if (!strcmp(attr
->name
, "job-id") &&
1395 attr
->value_tag
== IPP_TAG_INTEGER
)
1396 jobid
= attr
->values
[0].integer
;
1397 else if (!strcmp(attr
->name
, "job-k-octets") &&
1398 attr
->value_tag
== IPP_TAG_INTEGER
)
1399 size
= attr
->values
[0].integer
;
1400 else if (!strcmp(attr
->name
, time_at
) && attr
->value_tag
== IPP_TAG_INTEGER
)
1401 jobtime
= attr
->values
[0].integer
;
1402 else if (!strcmp(attr
->name
, "job-printer-state-message") &&
1403 attr
->value_tag
== IPP_TAG_TEXT
)
1404 message
= attr
->values
[0].string
.text
;
1405 else if (!strcmp(attr
->name
, "job-printer-uri") &&
1406 attr
->value_tag
== IPP_TAG_URI
)
1408 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1411 else if (!strcmp(attr
->name
, "job-originating-user-name") &&
1412 attr
->value_tag
== IPP_TAG_NAME
)
1413 username
= attr
->values
[0].string
.text
;
1414 else if (!strcmp(attr
->name
, "job-name") &&
1415 attr
->value_tag
== IPP_TAG_NAME
)
1416 title
= attr
->values
[0].string
.text
;
1417 else if (!strcmp(attr
->name
, "job-state-reasons") &&
1418 attr
->value_tag
== IPP_TAG_KEYWORD
)
1425 * See if we have everything needed...
1428 if (dest
== NULL
|| jobid
== 0)
1437 * Display the job...
1442 if (match_list(dests
, dest
) && match_list(users
, username
))
1444 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1446 _cupsStrDate(date
, sizeof(date
), jobtime
);
1449 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s",
1450 rank
, temp
, username
? username
: "unknown",
1451 1024.0 * size
, date
);
1453 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s",
1454 temp
, username
? username
: "unknown",
1455 1024.0 * size
, date
);
1459 _cupsLangPrintf(stdout
, _("\tStatus: %s"), message
);
1463 char alerts
[1024], /* Alerts string */
1464 *aptr
; /* Pointer into alerts string */
1466 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1469 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1471 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1473 aptr
+= strlen(aptr
);
1476 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1479 _cupsLangPrintf(stdout
, _("\tqueued for %s"), dest
);
1487 ippDelete(response
);
1495 * 'show_printers()' - Show printers.
1498 static int /* O - 0 on success, 1 on fail */
1499 show_printers(const char *printers
, /* I - Destinations */
1500 int num_dests
, /* I - Number of user-defined dests */
1501 cups_dest_t
*dests
, /* I - User-defined destinations */
1502 int long_status
) /* I - Show long status? */
1504 int i
, j
; /* Looping vars */
1505 ipp_t
*request
, /* IPP Request */
1506 *response
, /* IPP Response */
1507 *jobs
; /* IPP Get Jobs response */
1508 ipp_attribute_t
*attr
, /* Current attribute */
1509 *jobattr
, /* Job ID attribute */
1510 *reasons
; /* Job state reasons attribute */
1511 const char *printer
, /* Printer name */
1512 *message
, /* Printer state message */
1513 *description
, /* Description of printer */
1514 *location
, /* Location of printer */
1515 *make_model
, /* Make and model of printer */
1516 *uri
; /* URI of printer */
1517 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1518 *denied
; /* requestint-user-name-denied */
1519 ipp_pstate_t pstate
; /* Printer state */
1520 cups_ptype_t ptype
; /* Printer type */
1521 time_t ptime
; /* Printer state time */
1522 int jobid
; /* Job ID of current job */
1523 char printer_uri
[HTTP_MAX_URI
],
1525 printer_state_time
[255];/* Printer state time */
1526 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1527 static const char *pattrs
[] = /* Attributes we need for printers... */
1531 "printer-state-message",
1532 "printer-state-reasons",
1533 "printer-state-change-time",
1537 "printer-make-and-model",
1538 "printer-uri-supported",
1539 "requesting-user-name-allowed",
1540 "requesting-user-name-denied"
1542 static const char *jattrs
[] = /* Attributes we need for jobs... */
1549 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1550 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1552 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1556 * Build a CUPS_GET_PRINTERS request, which requires the following
1559 * attributes-charset
1560 * attributes-natural-language
1561 * requested-attributes
1562 * requesting-user-name
1565 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1567 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1568 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1571 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1575 * Do the request and get back a response...
1578 response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/");
1580 if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST
||
1581 cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
)
1583 _cupsLangPrintf(stderr
,
1584 _("%s: Error - add '/version=1.1' to server name."),
1586 ippDelete(response
);
1589 else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING
)
1591 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1592 ippDelete(response
);
1598 DEBUG_puts("show_printers: request succeeded...");
1601 * Loop through the printers returned in the list and display
1605 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1608 * Skip leading attributes until we hit a job...
1611 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1618 * Pull the needed attributes from this job...
1623 ptype
= CUPS_PRINTER_LOCAL
;
1624 pstate
= IPP_PRINTER_IDLE
;
1635 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1637 if (!strcmp(attr
->name
, "printer-name") &&
1638 attr
->value_tag
== IPP_TAG_NAME
)
1639 printer
= attr
->values
[0].string
.text
;
1640 else if (!strcmp(attr
->name
, "printer-state") &&
1641 attr
->value_tag
== IPP_TAG_ENUM
)
1642 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1643 else if (!strcmp(attr
->name
, "printer-type") &&
1644 attr
->value_tag
== IPP_TAG_ENUM
)
1645 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1646 else if (!strcmp(attr
->name
, "printer-state-message") &&
1647 attr
->value_tag
== IPP_TAG_TEXT
)
1648 message
= attr
->values
[0].string
.text
;
1649 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1650 attr
->value_tag
== IPP_TAG_INTEGER
)
1651 ptime
= (time_t)attr
->values
[0].integer
;
1652 else if (!strcmp(attr
->name
, "printer-info") &&
1653 attr
->value_tag
== IPP_TAG_TEXT
)
1654 description
= attr
->values
[0].string
.text
;
1655 else if (!strcmp(attr
->name
, "printer-location") &&
1656 attr
->value_tag
== IPP_TAG_TEXT
)
1657 location
= attr
->values
[0].string
.text
;
1658 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1659 attr
->value_tag
== IPP_TAG_TEXT
)
1660 make_model
= attr
->values
[0].string
.text
;
1661 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1662 attr
->value_tag
== IPP_TAG_URI
)
1663 uri
= attr
->values
[0].string
.text
;
1664 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1665 attr
->value_tag
== IPP_TAG_KEYWORD
)
1667 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1668 attr
->value_tag
== IPP_TAG_NAME
)
1670 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1671 attr
->value_tag
== IPP_TAG_NAME
)
1678 * See if we have everything needed...
1681 if (printer
== NULL
)
1690 * Display the printer entry if needed...
1693 if (match_list(printers
, printer
))
1696 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1697 * current job for the printer.
1700 if (pstate
== IPP_PRINTER_PROCESSING
)
1703 * Build an IPP_GET_JOBS request, which requires the following
1706 * attributes-charset
1707 * attributes-natural-language
1710 * requested-attributes
1713 request
= ippNewRequest(IPP_GET_JOBS
);
1715 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1716 request
->request
.op
.request_id
= 1;
1718 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1719 "requested-attributes",
1720 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1722 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1723 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1724 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1725 "printer-uri", NULL
, printer_uri
);
1727 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1730 * Get the current active job on this queue...
1733 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1736 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1740 if (jobstate
== IPP_JOB_PROCESSING
)
1746 if (!strcmp(jobattr
->name
, "job-id") &&
1747 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1748 jobid
= jobattr
->values
[0].integer
;
1749 else if (!strcmp(jobattr
->name
, "job-state") &&
1750 jobattr
->value_tag
== IPP_TAG_ENUM
)
1751 jobstate
= (ipp_jstate_t
)jobattr
->values
[0].integer
;
1754 if (jobstate
!= IPP_JOB_PROCESSING
)
1765 _cupsStrDate(printer_state_time
, sizeof(printer_state_time
), ptime
);
1769 case IPP_PRINTER_IDLE
:
1770 _cupsLangPrintf(stdout
,
1771 _("printer %s is idle. enabled since %s"),
1772 printer
, printer_state_time
);
1774 case IPP_PRINTER_PROCESSING
:
1775 _cupsLangPrintf(stdout
,
1776 _("printer %s now printing %s-%d. "
1777 "enabled since %s"),
1778 printer
, printer
, jobid
, printer_state_time
);
1780 case IPP_PRINTER_STOPPED
:
1781 _cupsLangPrintf(stdout
,
1782 _("printer %s disabled since %s -"),
1783 printer
, printer_state_time
);
1787 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1789 if (!message
|| !*message
)
1790 _cupsLangPuts(stdout
, _("\treason unknown"));
1792 _cupsLangPrintf(stdout
, "\t%s", message
);
1795 if (long_status
> 1)
1797 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1798 _cupsLangPuts(stdout
, _("\tContent types: any"));
1799 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1804 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1805 description
? description
: "");
1809 char alerts
[1024], /* Alerts string */
1810 *aptr
; /* Pointer into alerts string */
1812 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1815 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1817 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1819 aptr
+= strlen(aptr
);
1822 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1825 if (long_status
> 1)
1827 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1828 location
? location
: "");
1830 if (ptype
& CUPS_PRINTER_REMOTE
)
1832 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1834 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1835 !strstr(make_model
, "Raw Printer") && uri
)
1836 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"),
1841 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1843 if (make_model
&& strstr(make_model
, "System V Printer"))
1844 _cupsLangPrintf(stdout
,
1845 _("\tInterface: %s/interfaces/%s"),
1846 cg
->cups_serverroot
, printer
);
1847 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1848 _cupsLangPrintf(stdout
,
1849 _("\tInterface: %s/ppd/%s.ppd"),
1850 cg
->cups_serverroot
, printer
);
1852 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1853 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1854 /* TODO update to use printer-error-policy */
1857 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1858 for (j
= 0; j
< allowed
->num_values
; j
++)
1859 _cupsLangPrintf(stdout
, "\t\t%s",
1860 allowed
->values
[j
].string
.text
);
1864 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1865 for (j
= 0; j
< denied
->num_values
; j
++)
1866 _cupsLangPrintf(stdout
, "\t\t%s",
1867 denied
->values
[j
].string
.text
);
1871 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1872 _cupsLangPuts(stdout
, _("\t\t(all)"));
1874 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1875 _cupsLangPuts(stdout
, _("\t\t(none)"));
1876 _cupsLangPuts(stdout
, _("\tBanner required"));
1877 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1878 _cupsLangPuts(stdout
, _("\t\t(none)"));
1879 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1880 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1881 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1884 for (i
= 0; i
< num_dests
; i
++)
1885 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1889 case IPP_PRINTER_IDLE
:
1890 _cupsLangPrintf(stdout
,
1891 _("printer %s/%s is idle. "
1892 "enabled since %s"),
1893 printer
, dests
[i
].instance
,
1894 printer_state_time
);
1896 case IPP_PRINTER_PROCESSING
:
1897 _cupsLangPrintf(stdout
,
1898 _("printer %s/%s now printing %s-%d. "
1899 "enabled since %s"),
1900 printer
, dests
[i
].instance
, printer
, jobid
,
1901 printer_state_time
);
1903 case IPP_PRINTER_STOPPED
:
1904 _cupsLangPrintf(stdout
,
1905 _("printer %s/%s disabled since %s -"),
1906 printer
, dests
[i
].instance
,
1907 printer_state_time
);
1911 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1913 if (!message
|| !*message
)
1914 _cupsLangPuts(stdout
, _("\treason unknown"));
1916 _cupsLangPrintf(stdout
, "\t%s", message
);
1919 if (long_status
> 1)
1921 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1922 _cupsLangPuts(stdout
, _("\tContent types: any"));
1923 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1928 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1929 description
? description
: "");
1933 char alerts
[1024], /* Alerts string */
1934 *aptr
; /* Pointer into alerts string */
1936 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1939 snprintf(aptr
, sizeof(alerts
) - (size_t)(aptr
- alerts
), " %s", reasons
->values
[i
].string
.text
);
1941 strlcpy(alerts
, reasons
->values
[i
].string
.text
, sizeof(alerts
));
1943 aptr
+= strlen(aptr
);
1946 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1949 if (long_status
> 1)
1951 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1952 location
? location
: "");
1954 if (ptype
& CUPS_PRINTER_REMOTE
)
1956 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1958 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1959 !strstr(make_model
, "Raw Printer") && uri
)
1960 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"), uri
);
1964 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1966 if (make_model
&& strstr(make_model
, "System V Printer"))
1967 _cupsLangPrintf(stdout
,
1968 _("\tInterface: %s/interfaces/%s"),
1969 cg
->cups_serverroot
, printer
);
1970 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1971 _cupsLangPrintf(stdout
,
1972 _("\tInterface: %s/ppd/%s.ppd"),
1973 cg
->cups_serverroot
, printer
);
1975 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1976 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1977 /* TODO update to use printer-error-policy */
1980 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1981 for (j
= 0; j
< allowed
->num_values
; j
++)
1982 _cupsLangPrintf(stdout
, "\t\t%s",
1983 allowed
->values
[j
].string
.text
);
1987 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1988 for (j
= 0; j
< denied
->num_values
; j
++)
1989 _cupsLangPrintf(stdout
, "\t\t%s",
1990 denied
->values
[j
].string
.text
);
1994 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1995 _cupsLangPuts(stdout
, _("\t\t(all)"));
1997 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1998 _cupsLangPuts(stdout
, _("\t\t(none)"));
1999 _cupsLangPuts(stdout
, _("\tBanner required"));
2000 _cupsLangPuts(stdout
, _("\tCharset sets:"));
2001 _cupsLangPuts(stdout
, _("\t\t(none)"));
2002 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
2003 _cupsLangPuts(stdout
, _("\tDefault page size:"));
2004 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
2013 ippDelete(response
);
2021 * 'show_scheduler()' - Show scheduler status.
2025 show_scheduler(void)
2027 http_t
*http
; /* Connection to server */
2030 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
2031 cupsEncryption())) != NULL
)
2033 _cupsLangPuts(stdout
, _("scheduler is running"));
2037 _cupsLangPuts(stdout
, _("scheduler is not running"));
2042 * End of "$Id: lpstat.c 12066 2014-07-30 18:30:44Z msweet $".