4 * "lpstat" command for CUPS.
6 * Copyright 2007-2011 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 * main() - Parse options and show status information.
18 * check_dest() - Verify that the named destination(s) exists.
19 * match_list() - Match a name from a list of comma or space-separated
21 * show_accepting() - Show acceptance status.
22 * show_classes() - Show printer classes.
23 * show_default() - Show default destination.
24 * show_devices() - Show printer devices.
25 * show_jobs() - Show active print jobs.
26 * show_printers() - Show printers.
27 * show_scheduler() - Show scheduler status.
31 * Include necessary headers...
34 #include <cups/cups-private.h>
41 static void check_dest(const char *command
, const char *name
,
42 int *num_dests
, cups_dest_t
**dests
);
43 static int match_list(const char *list
, const char *name
);
44 static int show_accepting(const char *printers
, int num_dests
,
46 static int show_classes(const char *dests
);
47 static void show_default(cups_dest_t
*dest
);
48 static int show_devices(const char *printers
, int num_dests
,
50 static int show_jobs(const char *dests
, const char *users
, int long_status
,
51 int ranking
, const char *which
);
52 static int show_printers(const char *printers
, int num_dests
,
53 cups_dest_t
*dests
, int long_status
);
54 static void show_scheduler(void);
58 * 'main()' - Parse options and show status information.
62 main(int argc
, /* I - Number of command-line arguments */
63 char *argv
[]) /* I - Command-line arguments */
65 int i
, /* Looping var */
66 status
; /* Exit status */
67 int num_dests
; /* Number of user destinations */
68 cups_dest_t
*dests
; /* User destinations */
69 int long_status
; /* Long status report? */
70 int ranking
; /* Show job ranking? */
71 const char *which
; /* Which jobs to show? */
72 char op
; /* Last operation on command-line */
78 * Parse command-line options...
86 which
= "not-completed";
89 for (i
= 1; i
< argc
; i
++)
90 if (argv
[i
][0] == '-')
93 case 'D' : /* Show description */
97 case 'E' : /* Encrypt */
99 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
101 _cupsLangPrintf(stderr
,
102 _("%s: Sorry, no encryption support."),
104 #endif /* HAVE_SSL */
107 case 'H' : /* Show server and port */
108 if (cupsServer()[0] == '/')
109 _cupsLangPuts(stdout
, cupsServer());
111 _cupsLangPrintf(stdout
, "%s:%d", cupsServer(), ippPort());
114 case 'P' : /* Show paper types */
118 case 'R' : /* Show ranking */
122 case 'S' : /* Show charsets */
128 case 'U' : /* Username */
130 cupsSetUser(argv
[i
] + 2);
136 _cupsLangPrintf(stderr
,
137 _("%s: Error - expected username after "
143 cupsSetUser(argv
[i
]);
147 case 'W' : /* Show which jobs? */
156 _cupsLangPrintf(stderr
,
157 _("%s: Error - need \"completed\", "
158 "\"not-completed\", or \"all\" after "
167 if (strcmp(which
, "completed") && strcmp(which
, "not-completed") &&
168 strcmp(which
, "all"))
170 _cupsLangPrintf(stderr
,
171 _("%s: Error - need \"completed\", "
172 "\"not-completed\", or \"all\" after "
179 case 'a' : /* Show acceptance status */
184 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
186 status
|= show_accepting(argv
[i
] + 2, num_dests
, dests
);
188 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
192 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
194 status
|= show_accepting(argv
[i
], num_dests
, dests
);
200 cupsFreeDests(num_dests
, dests
);
201 num_dests
= cupsGetDests(&dests
);
204 status
|= show_accepting(NULL
, num_dests
, dests
);
208 case 'c' : /* Show classes and members */
213 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
215 status
|= show_classes(argv
[i
] + 2);
217 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
221 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
223 status
|= show_classes(argv
[i
]);
226 status
|= show_classes(NULL
);
229 case 'd' : /* Show default destination */
232 if (num_dests
!= 1 || !dests
[0].is_default
)
234 cupsFreeDests(num_dests
, dests
);
236 dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, NULL
, NULL
);
237 num_dests
= dests
? 1 : 0;
243 case 'f' : /* Show forms */
249 case 'h' : /* Connect to host */
251 cupsSetServer(argv
[i
] + 2);
258 _cupsLangPrintf(stderr
,
259 _("%s: Error - expected hostname after "
265 cupsSetServer(argv
[i
]);
269 case 'l' : /* Long status or long job status */
273 case 'o' : /* Show jobs by destination */
278 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
280 status
|= show_jobs(argv
[i
] + 2, NULL
, long_status
, ranking
,
283 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
287 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
289 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
292 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
295 case 'p' : /* Show printers */
300 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
302 status
|= show_printers(argv
[i
] + 2, num_dests
, dests
,
305 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
309 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
311 status
|= show_printers(argv
[i
], num_dests
, dests
, long_status
);
317 cupsFreeDests(num_dests
, dests
);
318 num_dests
= cupsGetDests(&dests
);
321 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
325 case 'r' : /* Show scheduler status */
331 case 's' : /* Show summary */
336 cupsFreeDests(num_dests
, dests
);
337 num_dests
= cupsGetDests(&dests
);
340 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
341 status
|= show_classes(NULL
);
342 status
|= show_devices(NULL
, num_dests
, dests
);
345 case 't' : /* Show all info */
350 cupsFreeDests(num_dests
, dests
);
351 num_dests
= cupsGetDests(&dests
);
355 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
356 status
|= show_classes(NULL
);
357 status
|= show_devices(NULL
, num_dests
, dests
);
358 status
|= show_accepting(NULL
, num_dests
, dests
);
359 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
360 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
363 case 'u' : /* Show jobs by user */
367 status
|= show_jobs(NULL
, argv
[i
] + 2, long_status
, ranking
,
369 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
372 status
|= show_jobs(NULL
, argv
[i
], long_status
, ranking
, which
);
375 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
378 case 'v' : /* Show printer devices */
383 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
385 status
|= show_devices(argv
[i
] + 2, num_dests
, dests
);
387 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
391 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
393 status
|= show_devices(argv
[i
], num_dests
, dests
);
399 cupsFreeDests(num_dests
, dests
);
400 num_dests
= cupsGetDests(&dests
);
403 status
|= show_devices(NULL
, num_dests
, dests
);
408 _cupsLangPrintf(stderr
,
409 _("%s: Error - unknown option \"%c\"."),
410 argv
[0], argv
[i
][1]);
415 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
420 status
|= show_jobs(NULL
, cupsUser(), long_status
, ranking
, which
);
427 * 'check_dest()' - Verify that the named destination(s) exists.
431 check_dest(const char *command
, /* I - Command name */
432 const char *name
, /* I - List of printer/class names */
433 int *num_dests
, /* IO - Number of destinations */
434 cups_dest_t
**dests
) /* IO - Destinations */
436 const char *dptr
; /* Pointer into name */
437 char *pptr
, /* Pointer into printer */
438 printer
[1024]; /* Current printer/class name */
442 * Load the destination list as necessary...
448 cupsFreeDests(*num_dests
, *dests
);
450 if (strchr(name
, ','))
451 *num_dests
= cupsGetDests(dests
);
454 strlcpy(printer
, name
, sizeof(printer
));
455 if ((pptr
= strchr(printer
, '/')) != NULL
)
458 if ((*dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, printer
, pptr
)) == NULL
)
460 _cupsLangPrintf(stderr
,
461 _("%s: Invalid destination name in list \"%s\"."),
474 * Scan the name string for printer/class name(s)...
477 for (dptr
= name
; *dptr
;)
480 * Skip leading whitespace and commas...
483 while (isspace(*dptr
& 255) || *dptr
== ',')
490 * Extract a single destination name from the name string...
493 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
;)
495 if ((pptr
- printer
) < (sizeof(printer
) - 1))
499 _cupsLangPrintf(stderr
,
500 _("%s: Invalid destination name in list \"%s\"."),
509 * Check the destination...
512 if (!cupsGetDest(printer
, NULL
, *num_dests
, *dests
))
514 _cupsLangPrintf(stderr
,
515 _("%s: Unknown destination \"%s\"."), command
, printer
);
523 * 'match_list()' - Match a name from a list of comma or space-separated names.
526 static int /* O - 1 on match, 0 on no match */
527 match_list(const char *list
, /* I - List of names */
528 const char *name
) /* I - Name to find */
530 const char *nameptr
; /* Pointer into name */
534 * An empty list always matches...
546 * Skip leading whitespace and commas...
549 while (isspace(*list
& 255) || *list
== ',')
560 *nameptr
&& *list
&& tolower(*nameptr
& 255) == tolower(*list
& 255);
561 nameptr
++, list
++);
563 if (!*nameptr
&& (!*list
|| *list
== ',' || isspace(*list
& 255)))
566 while (*list
&& !isspace(*list
& 255) && *list
!= ',')
575 * 'show_accepting()' - Show acceptance status.
578 static int /* O - 0 on success, 1 on fail */
579 show_accepting(const char *printers
, /* I - Destinations */
580 int num_dests
, /* I - Number of user-defined dests */
581 cups_dest_t
*dests
) /* I - User-defined destinations */
583 int i
; /* Looping var */
584 ipp_t
*request
, /* IPP Request */
585 *response
; /* IPP Response */
586 ipp_attribute_t
*attr
; /* Current attribute */
587 const char *printer
, /* Printer name */
588 *message
; /* Printer device URI */
589 int accepting
; /* Accepting requests? */
590 time_t ptime
; /* Printer state time */
591 struct tm
*pdate
; /* Printer state date & time */
592 char printer_state_time
[255];/* Printer state time */
593 static const char *pattrs
[] = /* Attributes we need for printers... */
596 "printer-state-change-time",
597 "printer-state-message",
598 "printer-is-accepting-jobs"
602 DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers
));
604 if (printers
!= NULL
&& !strcmp(printers
, "all"))
608 * Build a CUPS_GET_PRINTERS request, which requires the following
612 * attributes-natural-language
613 * requested-attributes
614 * requesting-user-name
617 request
= ippNewRequest(CUPS_GET_PRINTERS
);
619 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
620 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
623 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
627 * Do the request and get back a response...
630 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
632 DEBUG_puts("show_accepting: request succeeded...");
634 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
636 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
642 * Loop through the printers returned in the list and display
646 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
649 * Skip leading attributes until we hit a printer...
652 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
659 * Pull the needed attributes from this printer...
667 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
669 if (!strcmp(attr
->name
, "printer-name") &&
670 attr
->value_tag
== IPP_TAG_NAME
)
671 printer
= attr
->values
[0].string
.text
;
672 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
673 attr
->value_tag
== IPP_TAG_INTEGER
)
674 ptime
= (time_t)attr
->values
[0].integer
;
675 else if (!strcmp(attr
->name
, "printer-state-message") &&
676 attr
->value_tag
== IPP_TAG_TEXT
)
677 message
= attr
->values
[0].string
.text
;
678 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
679 attr
->value_tag
== IPP_TAG_BOOLEAN
)
680 accepting
= attr
->values
[0].boolean
;
686 * See if we have everything needed...
698 * Display the printer entry if needed...
701 if (match_list(printers
, printer
))
703 pdate
= localtime(&ptime
);
704 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
707 _cupsLangPrintf(stdout
, _("%s accepting requests since %s"),
708 printer
, printer_state_time
);
711 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -"),
712 printer
, printer_state_time
);
713 _cupsLangPrintf(stdout
, _("\t%s"),
714 (message
== NULL
|| !*message
) ?
715 "reason unknown" : message
);
718 for (i
= 0; i
< num_dests
; i
++)
719 if (!_cups_strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
722 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s"),
723 printer
, dests
[i
].instance
, printer_state_time
);
726 _cupsLangPrintf(stdout
,
727 _("%s/%s not accepting requests since %s -"),
728 printer
, dests
[i
].instance
, printer_state_time
);
729 _cupsLangPrintf(stdout
, _("\t%s"),
730 (message
== NULL
|| !*message
) ?
731 "reason unknown" : message
);
744 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
753 * 'show_classes()' - Show printer classes.
756 static int /* O - 0 on success, 1 on fail */
757 show_classes(const char *dests
) /* I - Destinations */
759 int i
; /* Looping var */
760 ipp_t
*request
, /* IPP Request */
761 *response
, /* IPP Response */
762 *response2
; /* IPP response from remote server */
763 http_t
*http2
; /* Remote server */
764 ipp_attribute_t
*attr
; /* Current attribute */
765 const char *printer
, /* Printer class name */
766 *printer_uri
; /* Printer class URI */
767 ipp_attribute_t
*members
; /* Printer members */
768 char method
[HTTP_MAX_URI
], /* Request method */
769 username
[HTTP_MAX_URI
], /* Username:password */
770 server
[HTTP_MAX_URI
], /* Server name */
771 resource
[HTTP_MAX_URI
]; /* Resource name */
772 int port
; /* Port number */
773 static const char *cattrs
[] = /* Attributes we need for classes... */
776 "printer-uri-supported",
781 DEBUG_printf(("show_classes(dests=\"%s\")\n", dests
));
783 if (dests
!= NULL
&& !strcmp(dests
, "all"))
787 * Build a CUPS_GET_CLASSES request, which requires the following
791 * attributes-natural-language
792 * requested-attributes
793 * requesting-user-name
796 request
= ippNewRequest(CUPS_GET_CLASSES
);
798 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
799 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
802 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
806 * Do the request and get back a response...
809 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
811 DEBUG_puts("show_classes: request succeeded...");
813 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
815 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
821 * Loop through the printers returned in the list and display
825 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
828 * Skip leading attributes until we hit a job...
831 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
838 * Pull the needed attributes from this job...
845 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
847 if (!strcmp(attr
->name
, "printer-name") &&
848 attr
->value_tag
== IPP_TAG_NAME
)
849 printer
= attr
->values
[0].string
.text
;
851 if (!strcmp(attr
->name
, "printer-uri-supported") &&
852 attr
->value_tag
== IPP_TAG_URI
)
853 printer_uri
= attr
->values
[0].string
.text
;
855 if (!strcmp(attr
->name
, "member-names") &&
856 attr
->value_tag
== IPP_TAG_NAME
)
863 * If this is a remote class, grab the class info from the
868 if (members
== NULL
&& printer_uri
!= NULL
)
870 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
871 username
, sizeof(username
), server
, sizeof(server
),
872 &port
, resource
, sizeof(resource
));
874 if (!_cups_strcasecmp(server
, cupsServer()))
875 http2
= CUPS_HTTP_DEFAULT
;
877 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
880 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
881 * following attributes:
884 * attributes-natural-language
886 * requested-attributes
889 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
891 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
892 "printer-uri", NULL
, printer_uri
);
894 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
895 "requested-attributes",
896 sizeof(cattrs
) / sizeof(cattrs
[0]),
899 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
900 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
907 * See if we have everything needed...
913 ippDelete(response2
);
922 * Display the printer entry if needed...
925 if (match_list(dests
, printer
))
927 _cupsLangPrintf(stdout
, _("members of class %s:"), printer
);
931 for (i
= 0; i
< members
->num_values
; i
++)
932 _cupsLangPrintf(stdout
, "\t%s", members
->values
[i
].string
.text
);
935 _cupsLangPuts(stdout
, "\tunknown");
939 ippDelete(response2
);
949 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
958 * 'show_default()' - Show default destination.
962 show_default(cups_dest_t
*dest
) /* I - Default destination */
964 const char *printer
, /* Printer name */
965 *val
; /* Environment variable name */
971 _cupsLangPrintf(stdout
, _("system default destination: %s/%s"),
972 dest
->name
, dest
->instance
);
974 _cupsLangPrintf(stdout
, _("system default destination: %s"),
981 if ((printer
= getenv("LPDEST")) == NULL
)
983 if ((printer
= getenv("PRINTER")) != NULL
)
985 if (!strcmp(printer
, "lp"))
995 _cupsLangPrintf(stdout
,
996 _("lpstat: error - %s environment variable names "
997 "non-existent destination \"%s\"."),
1000 _cupsLangPuts(stdout
, _("no system default destination"));
1006 * 'show_devices()' - Show printer devices.
1009 static int /* O - 0 on success, 1 on fail */
1010 show_devices(const char *printers
, /* I - Destinations */
1011 int num_dests
, /* I - Number of user-defined dests */
1012 cups_dest_t
*dests
) /* I - User-defined destinations */
1014 int i
; /* Looping var */
1015 ipp_t
*request
, /* IPP Request */
1016 *response
; /* IPP Response */
1017 ipp_attribute_t
*attr
; /* Current attribute */
1018 const char *printer
, /* Printer name */
1019 *uri
, /* Printer URI */
1020 *device
; /* Printer device URI */
1021 static const char *pattrs
[] = /* Attributes we need for printers... */
1024 "printer-uri-supported",
1029 DEBUG_printf(("show_devices(printers=\"%s\")\n", printers
));
1031 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1035 * Build a CUPS_GET_PRINTERS request, which requires the following
1038 * attributes-charset
1039 * attributes-natural-language
1040 * requested-attributes
1041 * requesting-user-name
1044 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1046 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1047 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1050 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1054 * Do the request and get back a response...
1057 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1059 DEBUG_puts("show_devices: request succeeded...");
1061 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1063 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1064 ippDelete(response
);
1069 * Loop through the printers returned in the list and display
1073 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1076 * Skip leading attributes until we hit a job...
1079 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1086 * Pull the needed attributes from this job...
1093 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1095 if (!strcmp(attr
->name
, "printer-name") &&
1096 attr
->value_tag
== IPP_TAG_NAME
)
1097 printer
= attr
->values
[0].string
.text
;
1099 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1100 attr
->value_tag
== IPP_TAG_URI
)
1101 uri
= attr
->values
[0].string
.text
;
1103 if (!strcmp(attr
->name
, "device-uri") &&
1104 attr
->value_tag
== IPP_TAG_URI
)
1105 device
= attr
->values
[0].string
.text
;
1111 * See if we have everything needed...
1114 if (printer
== NULL
)
1123 * Display the printer entry if needed...
1126 if (match_list(printers
, printer
))
1128 #ifdef __osf__ /* Compaq/Digital like to do it their own way... */
1129 char scheme
[HTTP_MAX_URI
], /* Components of printer URI */
1130 username
[HTTP_MAX_URI
],
1131 hostname
[HTTP_MAX_URI
],
1132 resource
[HTTP_MAX_URI
];
1138 httpSeparateURI(HTTP_URI_CODING_ALL
, uri
, scheme
, sizeof(scheme
),
1139 username
, sizeof(username
), hostname
,
1140 sizeof(hostname
), &port
, resource
, sizeof(resource
));
1141 _cupsLangPrintf(stdout
,
1142 _("Output for printer %s is sent to remote "
1143 "printer %s on %s"),
1144 printer
, strrchr(resource
, '/') + 1, hostname
);
1146 else if (!strncmp(device
, "file:", 5))
1147 _cupsLangPrintf(stdout
,
1148 _("Output for printer %s is sent to %s"),
1149 printer
, device
+ 5);
1151 _cupsLangPrintf(stdout
,
1152 _("Output for printer %s is sent to %s"),
1155 for (i
= 0; i
< num_dests
; i
++)
1156 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1159 _cupsLangPrintf(stdout
,
1160 _("Output for printer %s/%s is sent to "
1161 "remote printer %s on %s"),
1162 printer
, dests
[i
].instance
,
1163 strrchr(resource
, '/') + 1, hostname
);
1164 else if (!strncmp(device
, "file:", 5))
1165 _cupsLangPrintf(stdout
,
1166 _("Output for printer %s/%s is sent to %s"),
1167 printer
, dests
[i
].instance
, device
+ 5);
1169 _cupsLangPrintf(stdout
,
1170 _("Output for printer %s/%s is sent to %s"),
1171 printer
, dests
[i
].instance
, device
);
1175 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1177 else if (!strncmp(device
, "file:", 5))
1178 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1179 printer
, device
+ 5);
1181 _cupsLangPrintf(stdout
, _("device for %s: %s"),
1184 for (i
= 0; i
< num_dests
; i
++)
1185 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1188 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1189 printer
, dests
[i
].instance
, uri
);
1190 else if (!strncmp(device
, "file:", 5))
1191 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1192 printer
, dests
[i
].instance
, device
+ 5);
1194 _cupsLangPrintf(stdout
, _("device for %s/%s: %s"),
1195 printer
, dests
[i
].instance
, device
);
1197 #endif /* __osf__ */
1204 ippDelete(response
);
1208 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1217 * 'show_jobs()' - Show active print jobs.
1220 static int /* O - 0 on success, 1 on fail */
1221 show_jobs(const char *dests
, /* I - Destinations */
1222 const char *users
, /* I - Users */
1223 int long_status
, /* I - Show long status? */
1224 int ranking
, /* I - Show job ranking? */
1225 const char *which
) /* I - Show which jobs? */
1227 int i
; /* Looping var */
1228 ipp_t
*request
, /* IPP Request */
1229 *response
; /* IPP Response */
1230 ipp_attribute_t
*attr
, /* Current attribute */
1231 *reasons
; /* Job state reasons attribute */
1232 const char *dest
, /* Pointer into job-printer-uri */
1233 *username
, /* Pointer to job-originating-user-name */
1234 *title
, /* Pointer to job-name */
1235 *message
; /* Pointer to job-printer-state-message */
1236 int rank
, /* Rank in queue */
1238 size
; /* job-k-octets */
1239 time_t jobtime
; /* time-at-creation */
1240 struct tm
*jobdate
; /* Date & time */
1241 char temp
[255], /* Temporary buffer */
1242 date
[255]; /* Date buffer */
1243 static const char *jattrs
[] = /* Attributes we need for jobs... */
1248 "job-originating-user-name",
1249 "job-printer-state-message",
1251 "job-state-reasons",
1256 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1257 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1260 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1264 * Build a IPP_GET_JOBS request, which requires the following
1267 * attributes-charset
1268 * attributes-natural-language
1270 * requested-attributes
1271 * requesting-user-name
1275 request
= ippNewRequest(IPP_GET_JOBS
);
1277 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1278 NULL
, "ipp://localhost/");
1280 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1281 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1284 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1287 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1291 * Do the request and get back a response...
1294 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1297 * Loop through the job list and display them...
1300 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1302 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1303 ippDelete(response
);
1309 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1312 * Skip leading attributes until we hit a job...
1315 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1322 * Pull the needed attributes from this job...
1334 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1336 if (!strcmp(attr
->name
, "job-id") &&
1337 attr
->value_tag
== IPP_TAG_INTEGER
)
1338 jobid
= attr
->values
[0].integer
;
1339 else if (!strcmp(attr
->name
, "job-k-octets") &&
1340 attr
->value_tag
== IPP_TAG_INTEGER
)
1341 size
= attr
->values
[0].integer
;
1342 else if (!strcmp(attr
->name
, "time-at-creation") &&
1343 attr
->value_tag
== IPP_TAG_INTEGER
)
1344 jobtime
= attr
->values
[0].integer
;
1345 else if (!strcmp(attr
->name
, "job-printer-state-message") &&
1346 attr
->value_tag
== IPP_TAG_TEXT
)
1347 message
= attr
->values
[0].string
.text
;
1348 else if (!strcmp(attr
->name
, "job-printer-uri") &&
1349 attr
->value_tag
== IPP_TAG_URI
)
1351 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1354 else if (!strcmp(attr
->name
, "job-originating-user-name") &&
1355 attr
->value_tag
== IPP_TAG_NAME
)
1356 username
= attr
->values
[0].string
.text
;
1357 else if (!strcmp(attr
->name
, "job-name") &&
1358 attr
->value_tag
== IPP_TAG_NAME
)
1359 title
= attr
->values
[0].string
.text
;
1360 else if (!strcmp(attr
->name
, "job-state-reasons") &&
1361 attr
->value_tag
== IPP_TAG_KEYWORD
)
1368 * See if we have everything needed...
1371 if (dest
== NULL
|| jobid
== 0)
1380 * Display the job...
1385 if (match_list(dests
, dest
) && match_list(users
, username
))
1387 jobdate
= localtime(&jobtime
);
1388 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1390 if (long_status
== 3)
1393 * Show the consolidated output format for the SGI tools...
1396 if (!strftime(date
, sizeof(date
), "%b %d %H:%M", jobdate
))
1397 strlcpy(date
, "Unknown", sizeof(date
));
1399 _cupsLangPrintf(stdout
, "%s;%s;%d;%s;%s",
1400 temp
, username
? username
: "unknown",
1401 size
, title
? title
: "unknown", date
);
1405 if (!strftime(date
, sizeof(date
), "%c", jobdate
))
1406 strlcpy(date
, "Unknown", sizeof(date
));
1409 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s",
1410 rank
, temp
, username
? username
: "unknown",
1411 1024.0 * size
, date
);
1413 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s",
1414 temp
, username
? username
: "unknown",
1415 1024.0 * size
, date
);
1419 _cupsLangPrintf(stdout
, _("\tStatus: %s"), message
);
1423 char alerts
[1024], /* Alerts string */
1424 *aptr
; /* Pointer into alerts string */
1426 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1429 snprintf(aptr
, sizeof(alerts
) - (aptr
- alerts
), " %s",
1430 reasons
->values
[i
].string
.text
);
1432 strlcpy(alerts
, reasons
->values
[i
].string
.text
,
1435 aptr
+= strlen(aptr
);
1438 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1441 _cupsLangPrintf(stdout
, _("\tqueued for %s"), dest
);
1450 ippDelete(response
);
1454 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1463 * 'show_printers()' - Show printers.
1466 static int /* O - 0 on success, 1 on fail */
1467 show_printers(const char *printers
, /* I - Destinations */
1468 int num_dests
, /* I - Number of user-defined dests */
1469 cups_dest_t
*dests
, /* I - User-defined destinations */
1470 int long_status
) /* I - Show long status? */
1472 int i
, j
; /* Looping vars */
1473 ipp_t
*request
, /* IPP Request */
1474 *response
, /* IPP Response */
1475 *jobs
; /* IPP Get Jobs response */
1476 ipp_attribute_t
*attr
, /* Current attribute */
1477 *jobattr
, /* Job ID attribute */
1478 *reasons
; /* Job state reasons attribute */
1479 const char *printer
, /* Printer name */
1480 *message
, /* Printer state message */
1481 *description
, /* Description of printer */
1482 *location
, /* Location of printer */
1483 *make_model
, /* Make and model of printer */
1484 *uri
; /* URI of printer */
1485 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1486 *denied
; /* requestint-user-name-denied */
1487 ipp_pstate_t pstate
; /* Printer state */
1488 cups_ptype_t ptype
; /* Printer type */
1489 time_t ptime
; /* Printer state time */
1490 struct tm
*pdate
; /* Printer state date & time */
1491 int jobid
; /* Job ID of current job */
1492 char printer_uri
[HTTP_MAX_URI
],
1494 printer_state_time
[255];/* Printer state time */
1495 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1496 static const char *pattrs
[] = /* Attributes we need for printers... */
1500 "printer-state-message",
1501 "printer-state-reasons",
1502 "printer-state-change-time",
1506 "printer-make-and-model",
1507 "printer-uri-supported",
1508 "requesting-user-name-allowed",
1509 "requesting-user-name-denied"
1511 static const char *jattrs
[] = /* Attributes we need for jobs... */
1518 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1519 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1521 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1525 * Build a CUPS_GET_PRINTERS request, which requires the following
1528 * attributes-charset
1529 * attributes-natural-language
1530 * requested-attributes
1531 * requesting-user-name
1534 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1536 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1537 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1540 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1544 * Do the request and get back a response...
1547 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1549 DEBUG_puts("show_printers: request succeeded...");
1551 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1553 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1554 ippDelete(response
);
1559 * Loop through the printers returned in the list and display
1563 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1566 * Skip leading attributes until we hit a job...
1569 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1576 * Pull the needed attributes from this job...
1581 ptype
= CUPS_PRINTER_LOCAL
;
1582 pstate
= IPP_PRINTER_IDLE
;
1593 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1595 if (!strcmp(attr
->name
, "printer-name") &&
1596 attr
->value_tag
== IPP_TAG_NAME
)
1597 printer
= attr
->values
[0].string
.text
;
1598 else if (!strcmp(attr
->name
, "printer-state") &&
1599 attr
->value_tag
== IPP_TAG_ENUM
)
1600 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1601 else if (!strcmp(attr
->name
, "printer-type") &&
1602 attr
->value_tag
== IPP_TAG_ENUM
)
1603 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1604 else if (!strcmp(attr
->name
, "printer-state-message") &&
1605 attr
->value_tag
== IPP_TAG_TEXT
)
1606 message
= attr
->values
[0].string
.text
;
1607 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1608 attr
->value_tag
== IPP_TAG_INTEGER
)
1609 ptime
= (time_t)attr
->values
[0].integer
;
1610 else if (!strcmp(attr
->name
, "printer-info") &&
1611 attr
->value_tag
== IPP_TAG_TEXT
)
1612 description
= attr
->values
[0].string
.text
;
1613 else if (!strcmp(attr
->name
, "printer-location") &&
1614 attr
->value_tag
== IPP_TAG_TEXT
)
1615 location
= attr
->values
[0].string
.text
;
1616 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1617 attr
->value_tag
== IPP_TAG_TEXT
)
1618 make_model
= attr
->values
[0].string
.text
;
1619 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1620 attr
->value_tag
== IPP_TAG_URI
)
1621 uri
= attr
->values
[0].string
.text
;
1622 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1623 attr
->value_tag
== IPP_TAG_KEYWORD
)
1625 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1626 attr
->value_tag
== IPP_TAG_NAME
)
1628 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1629 attr
->value_tag
== IPP_TAG_NAME
)
1636 * See if we have everything needed...
1639 if (printer
== NULL
)
1648 * Display the printer entry if needed...
1651 if (match_list(printers
, printer
))
1654 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1655 * current job for the printer.
1658 if (pstate
== IPP_PRINTER_PROCESSING
)
1661 * Build an IPP_GET_JOBS request, which requires the following
1664 * attributes-charset
1665 * attributes-natural-language
1668 * requested-attributes
1671 request
= ippNewRequest(IPP_GET_JOBS
);
1673 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1674 request
->request
.op
.request_id
= 1;
1676 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1677 "requested-attributes",
1678 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1680 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1681 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1682 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1683 "printer-uri", NULL
, printer_uri
);
1685 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1688 * Get the current active job on this queue...
1691 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1694 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1698 if (jobstate
== IPP_JOB_PROCESSING
)
1704 if (!strcmp(jobattr
->name
, "job-id") &&
1705 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1706 jobid
= jobattr
->values
[0].integer
;
1707 else if (!strcmp(jobattr
->name
, "job-state") &&
1708 jobattr
->value_tag
== IPP_TAG_ENUM
)
1709 jobstate
= jobattr
->values
[0].integer
;
1712 if (jobstate
!= IPP_JOB_PROCESSING
)
1723 pdate
= localtime(&ptime
);
1724 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
1728 case IPP_PRINTER_IDLE
:
1729 _cupsLangPrintf(stdout
,
1730 _("printer %s is idle. enabled since %s"),
1731 printer
, printer_state_time
);
1733 case IPP_PRINTER_PROCESSING
:
1734 _cupsLangPrintf(stdout
,
1735 _("printer %s now printing %s-%d. "
1736 "enabled since %s"),
1737 printer
, printer
, jobid
, printer_state_time
);
1739 case IPP_PRINTER_STOPPED
:
1740 _cupsLangPrintf(stdout
,
1741 _("printer %s disabled since %s -"),
1742 printer
, printer_state_time
);
1746 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1748 if (!message
|| !*message
)
1749 _cupsLangPuts(stdout
, _("\treason unknown"));
1751 _cupsLangPrintf(stdout
, "\t%s", message
);
1754 if (long_status
> 1)
1756 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1757 _cupsLangPuts(stdout
, _("\tContent types: any"));
1758 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1763 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1764 description
? description
: "");
1768 char alerts
[1024], /* Alerts string */
1769 *aptr
; /* Pointer into alerts string */
1771 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1774 snprintf(aptr
, sizeof(alerts
) - (aptr
- alerts
), " %s",
1775 reasons
->values
[i
].string
.text
);
1777 strlcpy(alerts
, reasons
->values
[i
].string
.text
,
1780 aptr
+= strlen(aptr
);
1783 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1786 if (long_status
> 1)
1788 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1789 location
? location
: "");
1791 if (ptype
& CUPS_PRINTER_REMOTE
)
1793 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1795 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1796 !strstr(make_model
, "Raw Printer") && uri
)
1797 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"),
1802 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1804 if (make_model
&& strstr(make_model
, "System V Printer"))
1805 _cupsLangPrintf(stdout
,
1806 _("\tInterface: %s/interfaces/%s"),
1807 cg
->cups_serverroot
, printer
);
1808 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1809 _cupsLangPrintf(stdout
,
1810 _("\tInterface: %s/ppd/%s.ppd"),
1811 cg
->cups_serverroot
, printer
);
1813 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1814 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1815 /* TODO update to use printer-error-policy */
1818 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1819 for (j
= 0; j
< allowed
->num_values
; j
++)
1820 _cupsLangPrintf(stdout
, "\t\t%s",
1821 allowed
->values
[j
].string
.text
);
1825 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1826 for (j
= 0; j
< denied
->num_values
; j
++)
1827 _cupsLangPrintf(stdout
, "\t\t%s",
1828 denied
->values
[j
].string
.text
);
1832 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1833 _cupsLangPuts(stdout
, _("\t\t(all)"));
1835 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1836 _cupsLangPuts(stdout
, _("\t\t(none)"));
1837 _cupsLangPuts(stdout
, _("\tBanner required"));
1838 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1839 _cupsLangPuts(stdout
, _("\t\t(none)"));
1840 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1841 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1842 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1845 for (i
= 0; i
< num_dests
; i
++)
1846 if (!_cups_strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1850 case IPP_PRINTER_IDLE
:
1851 _cupsLangPrintf(stdout
,
1852 _("printer %s/%s is idle. "
1853 "enabled since %s"),
1854 printer
, dests
[i
].instance
,
1855 printer_state_time
);
1857 case IPP_PRINTER_PROCESSING
:
1858 _cupsLangPrintf(stdout
,
1859 _("printer %s/%s now printing %s-%d. "
1860 "enabled since %s"),
1861 printer
, dests
[i
].instance
, printer
, jobid
,
1862 printer_state_time
);
1864 case IPP_PRINTER_STOPPED
:
1865 _cupsLangPrintf(stdout
,
1866 _("printer %s/%s disabled since %s -"),
1867 printer
, dests
[i
].instance
,
1868 printer_state_time
);
1872 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1874 if (!message
|| !*message
)
1875 _cupsLangPuts(stdout
, _("\treason unknown"));
1877 _cupsLangPrintf(stdout
, "\t%s", message
);
1880 if (long_status
> 1)
1882 _cupsLangPuts(stdout
, _("\tForm mounted:"));
1883 _cupsLangPuts(stdout
, _("\tContent types: any"));
1884 _cupsLangPuts(stdout
, _("\tPrinter types: unknown"));
1889 _cupsLangPrintf(stdout
, _("\tDescription: %s"),
1890 description
? description
: "");
1894 char alerts
[1024], /* Alerts string */
1895 *aptr
; /* Pointer into alerts string */
1897 for (i
= 0, aptr
= alerts
; i
< reasons
->num_values
; i
++)
1900 snprintf(aptr
, sizeof(alerts
) - (aptr
- alerts
), " %s",
1901 reasons
->values
[i
].string
.text
);
1903 strlcpy(alerts
, reasons
->values
[i
].string
.text
,
1906 aptr
+= strlen(aptr
);
1909 _cupsLangPrintf(stdout
, _("\tAlerts: %s"), alerts
);
1912 if (long_status
> 1)
1914 _cupsLangPrintf(stdout
, _("\tLocation: %s"),
1915 location
? location
: "");
1917 if (ptype
& CUPS_PRINTER_REMOTE
)
1919 _cupsLangPuts(stdout
, _("\tConnection: remote"));
1921 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1922 !strstr(make_model
, "Raw Printer") && uri
)
1923 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd"), uri
);
1927 _cupsLangPuts(stdout
, _("\tConnection: direct"));
1929 if (make_model
&& strstr(make_model
, "System V Printer"))
1930 _cupsLangPrintf(stdout
,
1931 _("\tInterface: %s/interfaces/%s"),
1932 cg
->cups_serverroot
, printer
);
1933 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1934 _cupsLangPrintf(stdout
,
1935 _("\tInterface: %s/ppd/%s.ppd"),
1936 cg
->cups_serverroot
, printer
);
1938 _cupsLangPuts(stdout
, _("\tOn fault: no alert"));
1939 _cupsLangPuts(stdout
, _("\tAfter fault: continue"));
1940 /* TODO update to use printer-error-policy */
1943 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1944 for (j
= 0; j
< allowed
->num_values
; j
++)
1945 _cupsLangPrintf(stdout
, "\t\t%s",
1946 allowed
->values
[j
].string
.text
);
1950 _cupsLangPuts(stdout
, _("\tUsers denied:"));
1951 for (j
= 0; j
< denied
->num_values
; j
++)
1952 _cupsLangPrintf(stdout
, "\t\t%s",
1953 denied
->values
[j
].string
.text
);
1957 _cupsLangPuts(stdout
, _("\tUsers allowed:"));
1958 _cupsLangPuts(stdout
, _("\t\t(all)"));
1960 _cupsLangPuts(stdout
, _("\tForms allowed:"));
1961 _cupsLangPuts(stdout
, _("\t\t(none)"));
1962 _cupsLangPuts(stdout
, _("\tBanner required"));
1963 _cupsLangPuts(stdout
, _("\tCharset sets:"));
1964 _cupsLangPuts(stdout
, _("\t\t(none)"));
1965 _cupsLangPuts(stdout
, _("\tDefault pitch:"));
1966 _cupsLangPuts(stdout
, _("\tDefault page size:"));
1967 _cupsLangPuts(stdout
, _("\tDefault port settings:"));
1976 ippDelete(response
);
1980 _cupsLangPrintf(stderr
, "lpstat: %s", cupsLastErrorString());
1989 * 'show_scheduler()' - Show scheduler status.
1993 show_scheduler(void)
1995 http_t
*http
; /* Connection to server */
1998 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
1999 cupsEncryption())) != NULL
)
2001 _cupsLangPuts(stdout
, _("scheduler is running"));
2005 _cupsLangPuts(stdout
, _("scheduler is not running"));