2 * "$Id: lpstat.c 7921 2008-09-10 15:42:24Z mike $"
4 * "lpstat" command for CUPS.
6 * Copyright 2007-2010 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 compiled in\n"),
104 #endif /* HAVE_SSL */
107 case 'H' : /* Show server and port */
108 if (cupsServer()[0] == '/')
109 _cupsLangPrintf(stdout
, "%s\n", cupsServer());
111 _cupsLangPrintf(stdout
, "%s:%d\n", 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
);
209 case 'b' : /* Show both the local and remote status */
215 * The local and remote status are separated by a blank line;
216 * since all CUPS jobs are networked, we only output the
217 * second list for now... In the future, we might further
218 * emulate this by listing the remote server's queue, but
219 * for now this is enough to make the SGI printstatus program
223 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
226 status
|= show_jobs(argv
[i
] + 2, NULL
, 3, ranking
, which
);
230 _cupsLangPrintf(stderr
,
231 _("%s: Error - expected destination after "
240 case 'c' : /* Show classes and members */
245 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
247 status
|= show_classes(argv
[i
] + 2);
249 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
253 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
255 status
|= show_classes(argv
[i
]);
258 status
|= show_classes(NULL
);
261 case 'd' : /* Show default destination */
264 if (num_dests
!= 1 || !dests
[0].is_default
)
266 cupsFreeDests(num_dests
, dests
);
268 dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, NULL
, NULL
);
269 num_dests
= dests
? 1 : 0;
275 case 'f' : /* Show forms */
281 case 'h' : /* Connect to host */
283 cupsSetServer(argv
[i
] + 2);
290 _cupsLangPrintf(stderr
,
291 _("%s: Error - expected hostname after "
297 cupsSetServer(argv
[i
]);
301 case 'l' : /* Long status or long job status */
307 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
309 status
|= show_jobs(argv
[i
] + 2, NULL
, 3, ranking
, which
);
316 case 'o' : /* Show jobs by destination */
321 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
323 status
|= show_jobs(argv
[i
] + 2, NULL
, long_status
, ranking
,
326 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
330 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
332 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
335 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
338 case 'p' : /* Show printers */
343 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
345 status
|= show_printers(argv
[i
] + 2, num_dests
, dests
,
348 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
352 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
354 status
|= show_printers(argv
[i
], num_dests
, dests
, long_status
);
360 cupsFreeDests(num_dests
, dests
);
361 num_dests
= cupsGetDests(&dests
);
364 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
368 case 'r' : /* Show scheduler status */
374 case 's' : /* Show summary */
379 cupsFreeDests(num_dests
, dests
);
380 num_dests
= cupsGetDests(&dests
);
383 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
384 status
|= show_classes(NULL
);
385 status
|= show_devices(NULL
, num_dests
, dests
);
388 case 't' : /* Show all info */
393 cupsFreeDests(num_dests
, dests
);
394 num_dests
= cupsGetDests(&dests
);
398 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
399 status
|= show_classes(NULL
);
400 status
|= show_devices(NULL
, num_dests
, dests
);
401 status
|= show_accepting(NULL
, num_dests
, dests
);
402 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
403 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
406 case 'u' : /* Show jobs by user */
410 status
|= show_jobs(NULL
, argv
[i
] + 2, long_status
, ranking
,
412 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
415 status
|= show_jobs(NULL
, argv
[i
], long_status
, ranking
, which
);
418 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
421 case 'v' : /* Show printer devices */
426 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
428 status
|= show_devices(argv
[i
] + 2, num_dests
, dests
);
430 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
434 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
436 status
|= show_devices(argv
[i
], num_dests
, dests
);
442 cupsFreeDests(num_dests
, dests
);
443 num_dests
= cupsGetDests(&dests
);
446 status
|= show_devices(NULL
, num_dests
, dests
);
451 _cupsLangPrintf(stderr
,
452 _("%s: Error - unknown option \'%c\'\n"),
453 argv
[0], argv
[i
][1]);
458 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
463 status
|= show_jobs(NULL
, cupsUser(), long_status
, ranking
, which
);
470 * 'check_dest()' - Verify that the named destination(s) exists.
474 check_dest(const char *command
, /* I - Command name */
475 const char *name
, /* I - List of printer/class names */
476 int *num_dests
, /* IO - Number of destinations */
477 cups_dest_t
**dests
) /* IO - Destinations */
479 const char *dptr
; /* Pointer into name */
480 char *pptr
, /* Pointer into printer */
481 printer
[1024]; /* Current printer/class name */
485 * Load the destination list as necessary...
491 cupsFreeDests(*num_dests
, *dests
);
493 if (strchr(name
, ','))
494 *num_dests
= cupsGetDests(dests
);
497 strlcpy(printer
, name
, sizeof(printer
));
498 if ((pptr
= strchr(printer
, '/')) != NULL
)
501 if ((*dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, printer
, pptr
)) == NULL
)
503 _cupsLangPrintf(stderr
,
504 _("%s: Invalid destination name in list \"%s\"\n"),
517 * Scan the name string for printer/class name(s)...
520 for (dptr
= name
; *dptr
;)
523 * Skip leading whitespace and commas...
526 while (isspace(*dptr
& 255) || *dptr
== ',')
533 * Extract a single destination name from the name string...
536 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
;)
538 if ((pptr
- printer
) < (sizeof(printer
) - 1))
542 _cupsLangPrintf(stderr
,
543 _("%s: Invalid destination name in list \"%s\"\n"),
552 * Check the destination...
555 if (!cupsGetDest(printer
, NULL
, *num_dests
, *dests
))
557 _cupsLangPrintf(stderr
,
558 _("%s: Unknown destination \"%s\"\n"), command
, printer
);
566 * 'match_list()' - Match a name from a list of comma or space-separated names.
569 static int /* O - 1 on match, 0 on no match */
570 match_list(const char *list
, /* I - List of names */
571 const char *name
) /* I - Name to find */
573 const char *nameptr
; /* Pointer into name */
577 * An empty list always matches...
586 * Skip leading whitespace and commas...
589 while (isspace(*list
& 255) || *list
== ',')
600 *nameptr
&& *list
&& tolower(*nameptr
& 255) == tolower(*list
& 255);
601 nameptr
++, list
++);
603 if (!*nameptr
&& (!*list
|| *list
== ',' || isspace(*list
& 255)))
606 while (*list
&& !isspace(*list
& 255) && *list
!= ',')
615 * 'show_accepting()' - Show acceptance status.
618 static int /* O - 0 on success, 1 on fail */
619 show_accepting(const char *printers
, /* I - Destinations */
620 int num_dests
, /* I - Number of user-defined dests */
621 cups_dest_t
*dests
) /* I - User-defined destinations */
623 int i
; /* Looping var */
624 ipp_t
*request
, /* IPP Request */
625 *response
; /* IPP Response */
626 ipp_attribute_t
*attr
; /* Current attribute */
627 const char *printer
, /* Printer name */
628 *message
; /* Printer device URI */
629 int accepting
; /* Accepting requests? */
630 time_t ptime
; /* Printer state time */
631 struct tm
*pdate
; /* Printer state date & time */
632 char printer_state_time
[255];/* Printer state time */
633 static const char *pattrs
[] = /* Attributes we need for printers... */
636 "printer-state-change-time",
637 "printer-state-message",
638 "printer-is-accepting-jobs"
642 DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers
));
644 if (printers
!= NULL
&& !strcmp(printers
, "all"))
648 * Build a CUPS_GET_PRINTERS request, which requires the following
652 * attributes-natural-language
653 * requested-attributes
654 * requesting-user-name
657 request
= ippNewRequest(CUPS_GET_PRINTERS
);
659 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
660 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
663 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
667 * Do the request and get back a response...
670 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
672 DEBUG_puts("show_accepting: request succeeded...");
674 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
676 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
682 * Loop through the printers returned in the list and display
686 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
689 * Skip leading attributes until we hit a printer...
692 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
699 * Pull the needed attributes from this printer...
707 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
709 if (!strcmp(attr
->name
, "printer-name") &&
710 attr
->value_tag
== IPP_TAG_NAME
)
711 printer
= attr
->values
[0].string
.text
;
712 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
713 attr
->value_tag
== IPP_TAG_INTEGER
)
714 ptime
= (time_t)attr
->values
[0].integer
;
715 else if (!strcmp(attr
->name
, "printer-state-message") &&
716 attr
->value_tag
== IPP_TAG_TEXT
)
717 message
= attr
->values
[0].string
.text
;
718 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
719 attr
->value_tag
== IPP_TAG_BOOLEAN
)
720 accepting
= attr
->values
[0].boolean
;
726 * See if we have everything needed...
738 * Display the printer entry if needed...
741 if (match_list(printers
, printer
))
743 pdate
= localtime(&ptime
);
744 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
747 _cupsLangPrintf(stdout
, _("%s accepting requests since %s\n"),
748 printer
, printer_state_time
);
750 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -\n"
752 printer
, printer_state_time
,
753 (message
== NULL
|| !*message
) ?
754 "reason unknown" : message
);
756 for (i
= 0; i
< num_dests
; i
++)
757 if (!strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
760 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s\n"),
761 printer
, dests
[i
].instance
, printer_state_time
);
763 _cupsLangPrintf(stdout
, _("%s/%s not accepting requests since "
765 printer
, dests
[i
].instance
, printer_state_time
,
766 (message
== NULL
|| !*message
) ?
767 "reason unknown" : message
);
779 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
788 * 'show_classes()' - Show printer classes.
791 static int /* O - 0 on success, 1 on fail */
792 show_classes(const char *dests
) /* I - Destinations */
794 int i
; /* Looping var */
795 ipp_t
*request
, /* IPP Request */
796 *response
, /* IPP Response */
797 *response2
; /* IPP response from remote server */
798 http_t
*http2
; /* Remote server */
799 ipp_attribute_t
*attr
; /* Current attribute */
800 const char *printer
, /* Printer class name */
801 *printer_uri
; /* Printer class URI */
802 ipp_attribute_t
*members
; /* Printer members */
803 char method
[HTTP_MAX_URI
], /* Request method */
804 username
[HTTP_MAX_URI
], /* Username:password */
805 server
[HTTP_MAX_URI
], /* Server name */
806 resource
[HTTP_MAX_URI
]; /* Resource name */
807 int port
; /* Port number */
808 static const char *cattrs
[] = /* Attributes we need for classes... */
811 "printer-uri-supported",
816 DEBUG_printf(("show_classes(dests=\"%s\")\n", dests
));
818 if (dests
!= NULL
&& !strcmp(dests
, "all"))
822 * Build a CUPS_GET_CLASSES request, which requires the following
826 * attributes-natural-language
827 * requested-attributes
828 * requesting-user-name
831 request
= ippNewRequest(CUPS_GET_CLASSES
);
833 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
834 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
837 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
841 * Do the request and get back a response...
844 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
846 DEBUG_puts("show_classes: request succeeded...");
848 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
850 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
856 * Loop through the printers returned in the list and display
860 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
863 * Skip leading attributes until we hit a job...
866 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
873 * Pull the needed attributes from this job...
880 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
882 if (!strcmp(attr
->name
, "printer-name") &&
883 attr
->value_tag
== IPP_TAG_NAME
)
884 printer
= attr
->values
[0].string
.text
;
886 if (!strcmp(attr
->name
, "printer-uri-supported") &&
887 attr
->value_tag
== IPP_TAG_URI
)
888 printer_uri
= attr
->values
[0].string
.text
;
890 if (!strcmp(attr
->name
, "member-names") &&
891 attr
->value_tag
== IPP_TAG_NAME
)
898 * If this is a remote class, grab the class info from the
903 if (members
== NULL
&& printer_uri
!= NULL
)
905 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
906 username
, sizeof(username
), server
, sizeof(server
),
907 &port
, resource
, sizeof(resource
));
909 if (!strcasecmp(server
, cupsServer()))
910 http2
= CUPS_HTTP_DEFAULT
;
912 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
915 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
916 * following attributes:
919 * attributes-natural-language
921 * requested-attributes
924 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
926 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
927 "printer-uri", NULL
, printer_uri
);
929 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
930 "requested-attributes",
931 sizeof(cattrs
) / sizeof(cattrs
[0]),
934 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
935 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
942 * See if we have everything needed...
948 ippDelete(response2
);
957 * Display the printer entry if needed...
960 if (match_list(dests
, printer
))
962 _cupsLangPrintf(stdout
, _("members of class %s:\n"), printer
);
966 for (i
= 0; i
< members
->num_values
; i
++)
967 _cupsLangPrintf(stdout
, "\t%s\n",
968 members
->values
[i
].string
.text
);
971 _cupsLangPuts(stdout
, "\tunknown\n");
975 ippDelete(response2
);
985 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
994 * 'show_default()' - Show default destination.
998 show_default(cups_dest_t
*dest
) /* I - Default destination */
1000 const char *printer
, /* Printer name */
1001 *val
; /* Environment variable name */
1007 _cupsLangPrintf(stdout
, _("system default destination: %s/%s\n"),
1008 dest
->name
, dest
->instance
);
1010 _cupsLangPrintf(stdout
, _("system default destination: %s\n"),
1017 if ((printer
= getenv("LPDEST")) == NULL
)
1019 if ((printer
= getenv("PRINTER")) != NULL
)
1021 if (!strcmp(printer
, "lp"))
1031 _cupsLangPrintf(stdout
,
1032 _("lpstat: error - %s environment variable names "
1033 "non-existent destination \"%s\"\n"),
1036 _cupsLangPuts(stdout
, _("no system default destination\n"));
1042 * 'show_devices()' - Show printer devices.
1045 static int /* O - 0 on success, 1 on fail */
1046 show_devices(const char *printers
, /* I - Destinations */
1047 int num_dests
, /* I - Number of user-defined dests */
1048 cups_dest_t
*dests
) /* I - User-defined destinations */
1050 int i
; /* Looping var */
1051 ipp_t
*request
, /* IPP Request */
1052 *response
; /* IPP Response */
1053 ipp_attribute_t
*attr
; /* Current attribute */
1054 const char *printer
, /* Printer name */
1055 *uri
, /* Printer URI */
1056 *device
; /* Printer device URI */
1057 static const char *pattrs
[] = /* Attributes we need for printers... */
1060 "printer-uri-supported",
1065 DEBUG_printf(("show_devices(printers=\"%s\")\n", printers
));
1067 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1071 * Build a CUPS_GET_PRINTERS request, which requires the following
1074 * attributes-charset
1075 * attributes-natural-language
1076 * requested-attributes
1077 * requesting-user-name
1080 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1082 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1083 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1086 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1090 * Do the request and get back a response...
1093 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1095 DEBUG_puts("show_devices: request succeeded...");
1097 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1099 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1100 ippDelete(response
);
1105 * Loop through the printers returned in the list and display
1109 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1112 * Skip leading attributes until we hit a job...
1115 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1122 * Pull the needed attributes from this job...
1129 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1131 if (!strcmp(attr
->name
, "printer-name") &&
1132 attr
->value_tag
== IPP_TAG_NAME
)
1133 printer
= attr
->values
[0].string
.text
;
1135 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1136 attr
->value_tag
== IPP_TAG_URI
)
1137 uri
= attr
->values
[0].string
.text
;
1139 if (!strcmp(attr
->name
, "device-uri") &&
1140 attr
->value_tag
== IPP_TAG_URI
)
1141 device
= attr
->values
[0].string
.text
;
1147 * See if we have everything needed...
1150 if (printer
== NULL
)
1159 * Display the printer entry if needed...
1162 if (match_list(printers
, printer
))
1164 #ifdef __osf__ /* Compaq/Digital like to do it their own way... */
1165 char scheme
[HTTP_MAX_URI
], /* Components of printer URI */
1166 username
[HTTP_MAX_URI
],
1167 hostname
[HTTP_MAX_URI
],
1168 resource
[HTTP_MAX_URI
];
1174 httpSeparateURI(HTTP_URI_CODING_ALL
, uri
, scheme
, sizeof(scheme
),
1175 username
, sizeof(username
), hostname
,
1176 sizeof(hostname
), &port
, resource
, sizeof(resource
));
1177 _cupsLangPrintf(stdout
,
1178 _("Output for printer %s is sent to remote "
1179 "printer %s on %s\n"),
1180 printer
, strrchr(resource
, '/') + 1, hostname
);
1182 else if (!strncmp(device
, "file:", 5))
1183 _cupsLangPrintf(stdout
,
1184 _("Output for printer %s is sent to %s\n"),
1185 printer
, device
+ 5);
1187 _cupsLangPrintf(stdout
,
1188 _("Output for printer %s is sent to %s\n"),
1191 for (i
= 0; i
< num_dests
; i
++)
1192 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1195 _cupsLangPrintf(stdout
,
1196 _("Output for printer %s/%s is sent to "
1197 "remote printer %s on %s\n"),
1198 printer
, dests
[i
].instance
,
1199 strrchr(resource
, '/') + 1, hostname
);
1200 else if (!strncmp(device
, "file:", 5))
1201 _cupsLangPrintf(stdout
,
1202 _("Output for printer %s/%s is sent to %s\n"),
1203 printer
, dests
[i
].instance
, device
+ 5);
1205 _cupsLangPrintf(stdout
,
1206 _("Output for printer %s/%s is sent to %s\n"),
1207 printer
, dests
[i
].instance
, device
);
1211 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1213 else if (!strncmp(device
, "file:", 5))
1214 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1215 printer
, device
+ 5);
1217 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1220 for (i
= 0; i
< num_dests
; i
++)
1221 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1224 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1225 printer
, dests
[i
].instance
, uri
);
1226 else if (!strncmp(device
, "file:", 5))
1227 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1228 printer
, dests
[i
].instance
, device
+ 5);
1230 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1231 printer
, dests
[i
].instance
, device
);
1233 #endif /* __osf__ */
1240 ippDelete(response
);
1244 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1253 * 'show_jobs()' - Show active print jobs.
1256 static int /* O - 0 on success, 1 on fail */
1257 show_jobs(const char *dests
, /* I - Destinations */
1258 const char *users
, /* I - Users */
1259 int long_status
, /* I - Show long status? */
1260 int ranking
, /* I - Show job ranking? */
1261 const char *which
) /* I - Show which jobs? */
1263 int i
; /* Looping var */
1264 ipp_t
*request
, /* IPP Request */
1265 *response
; /* IPP Response */
1266 ipp_attribute_t
*attr
, /* Current attribute */
1267 *reasons
; /* Job state reasons attribute */
1268 const char *dest
, /* Pointer into job-printer-uri */
1269 *username
, /* Pointer to job-originating-user-name */
1270 *title
; /* Pointer to job-name */
1271 int rank
, /* Rank in queue */
1273 size
; /* job-k-octets */
1274 time_t jobtime
; /* time-at-creation */
1275 struct tm
*jobdate
; /* Date & time */
1276 char temp
[255], /* Temporary buffer */
1277 date
[255]; /* Date buffer */
1278 static const char *jattrs
[] = /* Attributes we need for jobs... */
1283 "job-originating-user-name",
1285 "job-state-reasons",
1290 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1291 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1294 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1298 * Build a IPP_GET_JOBS request, which requires the following
1301 * attributes-charset
1302 * attributes-natural-language
1304 * requested-attributes
1305 * requesting-user-name
1309 request
= ippNewRequest(IPP_GET_JOBS
);
1311 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1312 NULL
, "ipp://localhost/");
1314 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1315 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1318 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1321 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1325 * Do the request and get back a response...
1328 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1331 * Loop through the job list and display them...
1334 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1336 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1337 ippDelete(response
);
1343 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1346 * Skip leading attributes until we hit a job...
1349 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1356 * Pull the needed attributes from this job...
1367 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1369 if (!strcmp(attr
->name
, "job-id") &&
1370 attr
->value_tag
== IPP_TAG_INTEGER
)
1371 jobid
= attr
->values
[0].integer
;
1373 if (!strcmp(attr
->name
, "job-k-octets") &&
1374 attr
->value_tag
== IPP_TAG_INTEGER
)
1375 size
= attr
->values
[0].integer
;
1377 if (!strcmp(attr
->name
, "time-at-creation") &&
1378 attr
->value_tag
== IPP_TAG_INTEGER
)
1379 jobtime
= attr
->values
[0].integer
;
1381 if (!strcmp(attr
->name
, "job-printer-uri") &&
1382 attr
->value_tag
== IPP_TAG_URI
)
1383 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1386 if (!strcmp(attr
->name
, "job-originating-user-name") &&
1387 attr
->value_tag
== IPP_TAG_NAME
)
1388 username
= attr
->values
[0].string
.text
;
1390 if (!strcmp(attr
->name
, "job-name") &&
1391 attr
->value_tag
== IPP_TAG_NAME
)
1392 title
= attr
->values
[0].string
.text
;
1394 if (!strcmp(attr
->name
, "job-state-reasons") &&
1395 attr
->value_tag
== IPP_TAG_KEYWORD
)
1402 * See if we have everything needed...
1405 if (dest
== NULL
|| jobid
== 0)
1414 * Display the job...
1419 if (match_list(dests
, dest
) || match_list(users
, username
))
1421 jobdate
= localtime(&jobtime
);
1422 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1424 if (long_status
== 3)
1427 * Show the consolidated output format for the SGI tools...
1430 if (!strftime(date
, sizeof(date
), "%b %d %H:%M", jobdate
))
1431 strcpy(date
, "Unknown");
1433 _cupsLangPrintf(stdout
, "%s;%s;%d;%s;%s\n",
1434 temp
, username
? username
: "unknown",
1435 size
, title
? title
: "unknown", date
);
1439 if (!strftime(date
, sizeof(date
), "%c", jobdate
))
1440 strcpy(date
, "Unknown");
1443 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s\n",
1444 rank
, temp
, username
? username
: "unknown",
1445 1024.0 * size
, date
);
1447 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s\n",
1448 temp
, username
? username
: "unknown",
1449 1024.0 * size
, date
);
1454 _cupsLangPuts(stdout
, _("\tAlerts:"));
1455 for (i
= 0; i
< reasons
->num_values
; i
++)
1456 _cupsLangPrintf(stdout
, " %s",
1457 reasons
->values
[i
].string
.text
);
1458 _cupsLangPuts(stdout
, "\n");
1460 _cupsLangPrintf(stdout
, _("\tqueued for %s\n"), dest
);
1469 ippDelete(response
);
1473 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1482 * 'show_printers()' - Show printers.
1485 static int /* O - 0 on success, 1 on fail */
1486 show_printers(const char *printers
, /* I - Destinations */
1487 int num_dests
, /* I - Number of user-defined dests */
1488 cups_dest_t
*dests
, /* I - User-defined destinations */
1489 int long_status
) /* I - Show long status? */
1491 int i
, j
; /* Looping vars */
1492 ipp_t
*request
, /* IPP Request */
1493 *response
, /* IPP Response */
1494 *jobs
; /* IPP Get Jobs response */
1495 ipp_attribute_t
*attr
, /* Current attribute */
1496 *jobattr
, /* Job ID attribute */
1497 *reasons
; /* Job state reasons attribute */
1498 const char *printer
, /* Printer name */
1499 *message
, /* Printer state message */
1500 *description
, /* Description of printer */
1501 *location
, /* Location of printer */
1502 *make_model
, /* Make and model of printer */
1503 *uri
; /* URI of printer */
1504 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1505 *denied
; /* requestint-user-name-denied */
1506 ipp_pstate_t pstate
; /* Printer state */
1507 cups_ptype_t ptype
; /* Printer type */
1508 time_t ptime
; /* Printer state time */
1509 struct tm
*pdate
; /* Printer state date & time */
1510 int jobid
; /* Job ID of current job */
1511 char printer_uri
[HTTP_MAX_URI
],
1513 printer_state_time
[255];/* Printer state time */
1514 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1515 static const char *pattrs
[] = /* Attributes we need for printers... */
1519 "printer-state-message",
1520 "printer-state-reasons",
1521 "printer-state-change-time",
1525 "printer-make-and-model",
1526 "printer-uri-supported",
1527 "requesting-user-name-allowed",
1528 "requesting-user-name-denied"
1530 static const char *jattrs
[] = /* Attributes we need for jobs... */
1536 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1537 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1539 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1543 * Build a CUPS_GET_PRINTERS request, which requires the following
1546 * attributes-charset
1547 * attributes-natural-language
1548 * requested-attributes
1549 * requesting-user-name
1552 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1554 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1555 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1558 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1562 * Do the request and get back a response...
1565 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1567 DEBUG_puts("show_printers: request succeeded...");
1569 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1571 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1572 ippDelete(response
);
1577 * Loop through the printers returned in the list and display
1581 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1584 * Skip leading attributes until we hit a job...
1587 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1594 * Pull the needed attributes from this job...
1599 ptype
= CUPS_PRINTER_LOCAL
;
1600 pstate
= IPP_PRINTER_IDLE
;
1611 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1613 if (!strcmp(attr
->name
, "printer-name") &&
1614 attr
->value_tag
== IPP_TAG_NAME
)
1615 printer
= attr
->values
[0].string
.text
;
1616 else if (!strcmp(attr
->name
, "printer-state") &&
1617 attr
->value_tag
== IPP_TAG_ENUM
)
1618 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1619 else if (!strcmp(attr
->name
, "printer-type") &&
1620 attr
->value_tag
== IPP_TAG_ENUM
)
1621 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1622 else if (!strcmp(attr
->name
, "printer-state-message") &&
1623 attr
->value_tag
== IPP_TAG_TEXT
)
1624 message
= attr
->values
[0].string
.text
;
1625 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1626 attr
->value_tag
== IPP_TAG_INTEGER
)
1627 ptime
= (time_t)attr
->values
[0].integer
;
1628 else if (!strcmp(attr
->name
, "printer-info") &&
1629 attr
->value_tag
== IPP_TAG_TEXT
)
1630 description
= attr
->values
[0].string
.text
;
1631 else if (!strcmp(attr
->name
, "printer-location") &&
1632 attr
->value_tag
== IPP_TAG_TEXT
)
1633 location
= attr
->values
[0].string
.text
;
1634 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1635 attr
->value_tag
== IPP_TAG_TEXT
)
1636 make_model
= attr
->values
[0].string
.text
;
1637 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1638 attr
->value_tag
== IPP_TAG_URI
)
1639 uri
= attr
->values
[0].string
.text
;
1640 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1641 attr
->value_tag
== IPP_TAG_KEYWORD
)
1643 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1644 attr
->value_tag
== IPP_TAG_NAME
)
1646 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1647 attr
->value_tag
== IPP_TAG_NAME
)
1654 * See if we have everything needed...
1657 if (printer
== NULL
)
1666 * Display the printer entry if needed...
1669 if (match_list(printers
, printer
))
1672 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1673 * current job for the printer.
1676 if (pstate
== IPP_PRINTER_PROCESSING
)
1679 * Build an IPP_GET_JOBS request, which requires the following
1682 * attributes-charset
1683 * attributes-natural-language
1686 * requested-attributes
1689 request
= ippNewRequest(IPP_GET_JOBS
);
1691 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1692 request
->request
.op
.request_id
= 1;
1694 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1695 "requested-attributes",
1696 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1698 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1699 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1700 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1701 "printer-uri", NULL
, printer_uri
);
1703 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1706 * Get the current active job on this queue...
1709 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1712 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1716 if (jobstate
== IPP_JOB_PROCESSING
)
1722 if (!strcmp(jobattr
->name
, "job-id") &&
1723 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1724 jobid
= jobattr
->values
[0].integer
;
1725 else if (!strcmp(jobattr
->name
, "job-state") &&
1726 jobattr
->value_tag
== IPP_TAG_ENUM
)
1727 jobstate
= jobattr
->values
[0].integer
;
1730 if (jobstate
!= IPP_JOB_PROCESSING
)
1741 pdate
= localtime(&ptime
);
1742 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
1746 case IPP_PRINTER_IDLE
:
1747 _cupsLangPrintf(stdout
,
1748 _("printer %s is idle. enabled since %s\n"),
1749 printer
, printer_state_time
);
1751 case IPP_PRINTER_PROCESSING
:
1752 _cupsLangPrintf(stdout
,
1753 _("printer %s now printing %s-%d. "
1754 "enabled since %s\n"),
1755 printer
, printer
, jobid
, printer_state_time
);
1757 case IPP_PRINTER_STOPPED
:
1758 _cupsLangPrintf(stdout
,
1759 _("printer %s disabled since %s -\n"),
1760 printer
, printer_state_time
);
1764 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1766 if (!message
|| !*message
)
1767 _cupsLangPuts(stdout
, _("\treason unknown\n"));
1769 _cupsLangPrintf(stdout
, "\t%s\n", message
);
1772 if (long_status
> 1)
1773 _cupsLangPuts(stdout
,
1774 _("\tForm mounted:\n"
1775 "\tContent types: any\n"
1776 "\tPrinter types: unknown\n"));
1780 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
1781 description
? description
: "");
1785 _cupsLangPuts(stdout
, _("\tAlerts:"));
1786 for (j
= 0; j
< reasons
->num_values
; j
++)
1787 _cupsLangPrintf(stdout
, " %s",
1788 reasons
->values
[j
].string
.text
);
1789 _cupsLangPuts(stdout
, "\n");
1792 if (long_status
> 1)
1794 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
1795 location
? location
: "");
1797 if (ptype
& CUPS_PRINTER_REMOTE
)
1799 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
1801 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1802 !strstr(make_model
, "Raw Printer") && uri
)
1803 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
1808 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
1810 if (make_model
&& strstr(make_model
, "System V Printer"))
1811 _cupsLangPrintf(stdout
,
1812 _("\tInterface: %s/interfaces/%s\n"),
1813 cg
->cups_serverroot
, printer
);
1814 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1815 _cupsLangPrintf(stdout
,
1816 _("\tInterface: %s/ppd/%s.ppd\n"),
1817 cg
->cups_serverroot
, printer
);
1819 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
1820 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
1821 /* TODO update to use printer-error-policy */
1824 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1825 for (j
= 0; j
< allowed
->num_values
; j
++)
1826 _cupsLangPrintf(stdout
, "\t\t%s\n",
1827 allowed
->values
[j
].string
.text
);
1831 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
1832 for (j
= 0; j
< denied
->num_values
; j
++)
1833 _cupsLangPrintf(stdout
, "\t\t%s\n",
1834 denied
->values
[j
].string
.text
);
1838 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1839 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
1841 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
1842 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1843 _cupsLangPuts(stdout
, _("\tBanner required\n"));
1844 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
1845 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1846 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
1847 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
1848 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
1851 for (i
= 0; i
< num_dests
; i
++)
1852 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1856 case IPP_PRINTER_IDLE
:
1857 _cupsLangPrintf(stdout
,
1858 _("printer %s/%s is idle. "
1859 "enabled since %s\n"),
1860 printer
, dests
[i
].instance
,
1861 printer_state_time
);
1863 case IPP_PRINTER_PROCESSING
:
1864 _cupsLangPrintf(stdout
,
1865 _("printer %s/%s now printing %s-%d. "
1866 "enabled since %s\n"),
1867 printer
, dests
[i
].instance
, printer
, jobid
,
1868 printer_state_time
);
1870 case IPP_PRINTER_STOPPED
:
1871 _cupsLangPrintf(stdout
,
1872 _("printer %s/%s disabled since %s -\n"),
1873 printer
, dests
[i
].instance
,
1874 printer_state_time
);
1878 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1880 if (!message
|| !*message
)
1881 _cupsLangPuts(stdout
, _("\treason unknown\n"));
1883 _cupsLangPrintf(stdout
, "\t%s\n", message
);
1886 if (long_status
> 1)
1887 _cupsLangPuts(stdout
,
1888 _("\tForm mounted:\n"
1889 "\tContent types: any\n"
1890 "\tPrinter types: unknown\n"));
1894 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
1895 description
? description
: "");
1899 _cupsLangPuts(stdout
, _("\tAlerts:"));
1900 for (j
= 0; j
< reasons
->num_values
; j
++)
1901 _cupsLangPrintf(stdout
, " %s",
1902 reasons
->values
[j
].string
.text
);
1903 _cupsLangPuts(stdout
, "\n");
1906 if (long_status
> 1)
1908 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
1909 location
? location
: "");
1911 if (ptype
& CUPS_PRINTER_REMOTE
)
1913 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
1915 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1916 !strstr(make_model
, "Raw Printer") && uri
)
1917 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
1922 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
1924 if (make_model
&& strstr(make_model
, "System V Printer"))
1925 _cupsLangPrintf(stdout
,
1926 _("\tInterface: %s/interfaces/%s\n"),
1927 cg
->cups_serverroot
, printer
);
1928 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1929 _cupsLangPrintf(stdout
,
1930 _("\tInterface: %s/ppd/%s.ppd\n"),
1931 cg
->cups_serverroot
, printer
);
1933 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
1934 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
1935 /* TODO update to use printer-error-policy */
1938 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1939 for (j
= 0; j
< allowed
->num_values
; j
++)
1940 _cupsLangPrintf(stdout
, "\t\t%s\n",
1941 allowed
->values
[j
].string
.text
);
1945 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
1946 for (j
= 0; j
< denied
->num_values
; j
++)
1947 _cupsLangPrintf(stdout
, "\t\t%s\n",
1948 denied
->values
[j
].string
.text
);
1952 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1953 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
1955 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
1956 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1957 _cupsLangPuts(stdout
, _("\tBanner required\n"));
1958 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
1959 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1960 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
1961 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
1962 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
1971 ippDelete(response
);
1975 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1984 * 'show_scheduler()' - Show scheduler status.
1988 show_scheduler(void)
1990 http_t
*http
; /* Connection to server */
1993 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
1994 cupsEncryption())) != NULL
)
1996 _cupsLangPuts(stdout
, _("scheduler is running\n"));
2000 _cupsLangPuts(stdout
, _("scheduler is not running\n"));
2005 * End of "$Id: lpstat.c 7921 2008-09-10 15:42:24Z mike $".