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...
37 #include <cups/globals.h>
38 #include <cups/debug.h>
45 static void check_dest(const char *command
, const char *name
,
46 int *num_dests
, cups_dest_t
**dests
);
47 static int match_list(const char *list
, const char *name
);
48 static int show_accepting(const char *printers
, int num_dests
,
50 static int show_classes(const char *dests
);
51 static void show_default(cups_dest_t
*dest
);
52 static int show_devices(const char *printers
, int num_dests
,
54 static int show_jobs(const char *dests
, const char *users
, int long_status
,
55 int ranking
, const char *which
);
56 static int show_printers(const char *printers
, int num_dests
,
57 cups_dest_t
*dests
, int long_status
);
58 static void show_scheduler(void);
62 * 'main()' - Parse options and show status information.
66 main(int argc
, /* I - Number of command-line arguments */
67 char *argv
[]) /* I - Command-line arguments */
69 int i
, /* Looping var */
70 status
; /* Exit status */
71 int num_dests
; /* Number of user destinations */
72 cups_dest_t
*dests
; /* User destinations */
73 int long_status
; /* Long status report? */
74 int ranking
; /* Show job ranking? */
75 const char *which
; /* Which jobs to show? */
76 char op
; /* Last operation on command-line */
82 * Parse command-line options...
90 which
= "not-completed";
93 for (i
= 1; i
< argc
; i
++)
94 if (argv
[i
][0] == '-')
97 case 'D' : /* Show description */
101 case 'E' : /* Encrypt */
103 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
105 _cupsLangPrintf(stderr
,
106 _("%s: Sorry, no encryption support compiled in\n"),
108 #endif /* HAVE_SSL */
111 case 'H' : /* Show server and port */
112 if (cupsServer()[0] == '/')
113 _cupsLangPrintf(stdout
, "%s\n", cupsServer());
115 _cupsLangPrintf(stdout
, "%s:%d\n", cupsServer(), ippPort());
118 case 'P' : /* Show paper types */
122 case 'R' : /* Show ranking */
126 case 'S' : /* Show charsets */
132 case 'U' : /* Username */
134 cupsSetUser(argv
[i
] + 2);
140 _cupsLangPrintf(stderr
,
141 _("%s: Error - expected username after "
147 cupsSetUser(argv
[i
]);
151 case 'W' : /* Show which jobs? */
160 _cupsLangPrintf(stderr
,
161 _("%s: Error - need \"completed\", "
162 "\"not-completed\", or \"all\" after "
171 if (strcmp(which
, "completed") && strcmp(which
, "not-completed") &&
172 strcmp(which
, "all"))
174 _cupsLangPrintf(stderr
,
175 _("%s: Error - need \"completed\", "
176 "\"not-completed\", or \"all\" after "
183 case 'a' : /* Show acceptance status */
188 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
190 status
|= show_accepting(argv
[i
] + 2, num_dests
, dests
);
192 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
196 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
198 status
|= show_accepting(argv
[i
], num_dests
, dests
);
204 cupsFreeDests(num_dests
, dests
);
205 num_dests
= cupsGetDests(&dests
);
208 status
|= show_accepting(NULL
, num_dests
, dests
);
213 case 'b' : /* Show both the local and remote status */
219 * The local and remote status are separated by a blank line;
220 * since all CUPS jobs are networked, we only output the
221 * second list for now... In the future, we might further
222 * emulate this by listing the remote server's queue, but
223 * for now this is enough to make the SGI printstatus program
227 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
230 status
|= show_jobs(argv
[i
] + 2, NULL
, 3, ranking
, which
);
234 _cupsLangPrintf(stderr
,
235 _("%s: Error - expected destination after "
244 case 'c' : /* Show classes and members */
249 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
251 status
|= show_classes(argv
[i
] + 2);
253 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
257 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
259 status
|= show_classes(argv
[i
]);
262 status
|= show_classes(NULL
);
265 case 'd' : /* Show default destination */
268 if (num_dests
!= 1 || !dests
[0].is_default
)
270 cupsFreeDests(num_dests
, dests
);
272 dests
= cupsGetNamedDest(CUPS_HTTP_DEFAULT
, NULL
, NULL
);
273 num_dests
= dests
? 1 : 0;
279 case 'f' : /* Show forms */
285 case 'h' : /* Connect to host */
287 cupsSetServer(argv
[i
] + 2);
294 _cupsLangPrintf(stderr
,
295 _("%s: Error - expected hostname after "
301 cupsSetServer(argv
[i
]);
305 case 'l' : /* Long status or long job status */
311 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
313 status
|= show_jobs(argv
[i
] + 2, NULL
, 3, ranking
, which
);
320 case 'o' : /* Show jobs by destination */
325 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
327 status
|= show_jobs(argv
[i
] + 2, NULL
, long_status
, ranking
,
330 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
334 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
336 status
|= show_jobs(argv
[i
], NULL
, long_status
, ranking
, which
);
339 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
342 case 'p' : /* Show printers */
347 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
349 status
|= show_printers(argv
[i
] + 2, num_dests
, dests
,
352 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
356 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
358 status
|= show_printers(argv
[i
], num_dests
, dests
, long_status
);
364 cupsFreeDests(num_dests
, dests
);
365 num_dests
= cupsGetDests(&dests
);
368 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
372 case 'r' : /* Show scheduler status */
378 case 's' : /* Show summary */
383 cupsFreeDests(num_dests
, dests
);
384 num_dests
= cupsGetDests(&dests
);
387 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
388 status
|= show_classes(NULL
);
389 status
|= show_devices(NULL
, num_dests
, dests
);
392 case 't' : /* Show all info */
397 cupsFreeDests(num_dests
, dests
);
398 num_dests
= cupsGetDests(&dests
);
402 show_default(cupsGetDest(NULL
, NULL
, num_dests
, dests
));
403 status
|= show_classes(NULL
);
404 status
|= show_devices(NULL
, num_dests
, dests
);
405 status
|= show_accepting(NULL
, num_dests
, dests
);
406 status
|= show_printers(NULL
, num_dests
, dests
, long_status
);
407 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
410 case 'u' : /* Show jobs by user */
414 status
|= show_jobs(NULL
, argv
[i
] + 2, long_status
, ranking
,
416 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
419 status
|= show_jobs(NULL
, argv
[i
], long_status
, ranking
, which
);
422 status
|= show_jobs(NULL
, NULL
, long_status
, ranking
, which
);
425 case 'v' : /* Show printer devices */
430 check_dest(argv
[0], argv
[i
] + 2, &num_dests
, &dests
);
432 status
|= show_devices(argv
[i
] + 2, num_dests
, dests
);
434 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
438 check_dest(argv
[0], argv
[i
], &num_dests
, &dests
);
440 status
|= show_devices(argv
[i
], num_dests
, dests
);
446 cupsFreeDests(num_dests
, dests
);
447 num_dests
= cupsGetDests(&dests
);
450 status
|= show_devices(NULL
, num_dests
, dests
);
455 _cupsLangPrintf(stderr
,
456 _("%s: Error - unknown option \'%c\'\n"),
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 _cupsLangPrintf(stderr
,
508 _("%s: Invalid destination name in list \"%s\"\n"),
521 * Scan the name string for printer/class name(s)...
524 for (dptr
= name
; *dptr
;)
527 * Skip leading whitespace and commas...
530 while (isspace(*dptr
& 255) || *dptr
== ',')
537 * Extract a single destination name from the name string...
540 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
;)
542 if ((pptr
- printer
) < (sizeof(printer
) - 1))
546 _cupsLangPrintf(stderr
,
547 _("%s: Invalid destination name in list \"%s\"\n"),
556 * Check the destination...
559 if (!cupsGetDest(printer
, NULL
, *num_dests
, *dests
))
561 _cupsLangPrintf(stderr
,
562 _("%s: Unknown destination \"%s\"\n"), command
, printer
);
570 * 'match_list()' - Match a name from a list of comma or space-separated names.
573 static int /* O - 1 on match, 0 on no match */
574 match_list(const char *list
, /* I - List of names */
575 const char *name
) /* I - Name to find */
577 const char *nameptr
; /* Pointer into name */
581 * An empty list always matches...
590 * Skip leading whitespace and commas...
593 while (isspace(*list
& 255) || *list
== ',')
604 *nameptr
&& *list
&& tolower(*nameptr
& 255) == tolower(*list
& 255);
605 nameptr
++, list
++);
607 if (!*nameptr
&& (!*list
|| *list
== ',' || isspace(*list
& 255)))
610 while (*list
&& !isspace(*list
& 255) && *list
!= ',')
619 * 'show_accepting()' - Show acceptance status.
622 static int /* O - 0 on success, 1 on fail */
623 show_accepting(const char *printers
, /* I - Destinations */
624 int num_dests
, /* I - Number of user-defined dests */
625 cups_dest_t
*dests
) /* I - User-defined destinations */
627 int i
; /* Looping var */
628 ipp_t
*request
, /* IPP Request */
629 *response
; /* IPP Response */
630 ipp_attribute_t
*attr
; /* Current attribute */
631 const char *printer
, /* Printer name */
632 *message
; /* Printer device URI */
633 int accepting
; /* Accepting requests? */
634 time_t ptime
; /* Printer state time */
635 struct tm
*pdate
; /* Printer state date & time */
636 char printer_state_time
[255];/* Printer state time */
637 static const char *pattrs
[] = /* Attributes we need for printers... */
640 "printer-state-change-time",
641 "printer-state-message",
642 "printer-is-accepting-jobs"
646 DEBUG_printf(("show_accepting(printers=\"%s\")\n", printers
));
648 if (printers
!= NULL
&& !strcmp(printers
, "all"))
652 * Build a CUPS_GET_PRINTERS request, which requires the following
656 * attributes-natural-language
657 * requested-attributes
658 * requesting-user-name
661 request
= ippNewRequest(CUPS_GET_PRINTERS
);
663 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
664 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
667 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
671 * Do the request and get back a response...
674 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
676 DEBUG_puts("show_accepting: request succeeded...");
678 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
680 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
686 * Loop through the printers returned in the list and display
690 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
693 * Skip leading attributes until we hit a printer...
696 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
703 * Pull the needed attributes from this printer...
711 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
713 if (!strcmp(attr
->name
, "printer-name") &&
714 attr
->value_tag
== IPP_TAG_NAME
)
715 printer
= attr
->values
[0].string
.text
;
716 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
717 attr
->value_tag
== IPP_TAG_INTEGER
)
718 ptime
= (time_t)attr
->values
[0].integer
;
719 else if (!strcmp(attr
->name
, "printer-state-message") &&
720 attr
->value_tag
== IPP_TAG_TEXT
)
721 message
= attr
->values
[0].string
.text
;
722 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
723 attr
->value_tag
== IPP_TAG_BOOLEAN
)
724 accepting
= attr
->values
[0].boolean
;
730 * See if we have everything needed...
742 * Display the printer entry if needed...
745 if (match_list(printers
, printer
))
747 pdate
= localtime(&ptime
);
748 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
751 _cupsLangPrintf(stdout
, _("%s accepting requests since %s\n"),
752 printer
, printer_state_time
);
754 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -\n"
756 printer
, printer_state_time
,
757 (message
== NULL
|| !*message
) ?
758 "reason unknown" : message
);
760 for (i
= 0; i
< num_dests
; i
++)
761 if (!strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
764 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s\n"),
765 printer
, dests
[i
].instance
, printer_state_time
);
767 _cupsLangPrintf(stdout
, _("%s/%s not accepting requests since "
769 printer
, dests
[i
].instance
, printer_state_time
,
770 (message
== NULL
|| !*message
) ?
771 "reason unknown" : message
);
783 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
792 * 'show_classes()' - Show printer classes.
795 static int /* O - 0 on success, 1 on fail */
796 show_classes(const char *dests
) /* I - Destinations */
798 int i
; /* Looping var */
799 ipp_t
*request
, /* IPP Request */
800 *response
, /* IPP Response */
801 *response2
; /* IPP response from remote server */
802 http_t
*http2
; /* Remote server */
803 ipp_attribute_t
*attr
; /* Current attribute */
804 const char *printer
, /* Printer class name */
805 *printer_uri
; /* Printer class URI */
806 ipp_attribute_t
*members
; /* Printer members */
807 char method
[HTTP_MAX_URI
], /* Request method */
808 username
[HTTP_MAX_URI
], /* Username:password */
809 server
[HTTP_MAX_URI
], /* Server name */
810 resource
[HTTP_MAX_URI
]; /* Resource name */
811 int port
; /* Port number */
812 static const char *cattrs
[] = /* Attributes we need for classes... */
815 "printer-uri-supported",
820 DEBUG_printf(("show_classes(dests=\"%s\")\n", dests
));
822 if (dests
!= NULL
&& !strcmp(dests
, "all"))
826 * Build a CUPS_GET_CLASSES request, which requires the following
830 * attributes-natural-language
831 * requested-attributes
832 * requesting-user-name
835 request
= ippNewRequest(CUPS_GET_CLASSES
);
837 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
838 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
841 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
845 * Do the request and get back a response...
848 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
850 DEBUG_puts("show_classes: request succeeded...");
852 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
854 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
860 * Loop through the printers returned in the list and display
864 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
867 * Skip leading attributes until we hit a job...
870 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
877 * Pull the needed attributes from this job...
884 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
886 if (!strcmp(attr
->name
, "printer-name") &&
887 attr
->value_tag
== IPP_TAG_NAME
)
888 printer
= attr
->values
[0].string
.text
;
890 if (!strcmp(attr
->name
, "printer-uri-supported") &&
891 attr
->value_tag
== IPP_TAG_URI
)
892 printer_uri
= attr
->values
[0].string
.text
;
894 if (!strcmp(attr
->name
, "member-names") &&
895 attr
->value_tag
== IPP_TAG_NAME
)
902 * If this is a remote class, grab the class info from the
907 if (members
== NULL
&& printer_uri
!= NULL
)
909 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
910 username
, sizeof(username
), server
, sizeof(server
),
911 &port
, resource
, sizeof(resource
));
913 if (!strcasecmp(server
, cupsServer()))
914 http2
= CUPS_HTTP_DEFAULT
;
916 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
919 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
920 * following attributes:
923 * attributes-natural-language
925 * requested-attributes
928 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
930 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
931 "printer-uri", NULL
, printer_uri
);
933 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
934 "requested-attributes",
935 sizeof(cattrs
) / sizeof(cattrs
[0]),
938 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
939 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
946 * See if we have everything needed...
952 ippDelete(response2
);
961 * Display the printer entry if needed...
964 if (match_list(dests
, printer
))
966 _cupsLangPrintf(stdout
, _("members of class %s:\n"), printer
);
970 for (i
= 0; i
< members
->num_values
; i
++)
971 _cupsLangPrintf(stdout
, "\t%s\n",
972 members
->values
[i
].string
.text
);
975 _cupsLangPuts(stdout
, "\tunknown\n");
979 ippDelete(response2
);
989 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
998 * 'show_default()' - Show default destination.
1002 show_default(cups_dest_t
*dest
) /* I - Default destination */
1004 const char *printer
, /* Printer name */
1005 *val
; /* Environment variable name */
1011 _cupsLangPrintf(stdout
, _("system default destination: %s/%s\n"),
1012 dest
->name
, dest
->instance
);
1014 _cupsLangPrintf(stdout
, _("system default destination: %s\n"),
1021 if ((printer
= getenv("LPDEST")) == NULL
)
1023 if ((printer
= getenv("PRINTER")) != NULL
)
1025 if (!strcmp(printer
, "lp"))
1035 _cupsLangPrintf(stdout
,
1036 _("lpstat: error - %s environment variable names "
1037 "non-existent destination \"%s\"\n"),
1040 _cupsLangPuts(stdout
, _("no system default destination\n"));
1046 * 'show_devices()' - Show printer devices.
1049 static int /* O - 0 on success, 1 on fail */
1050 show_devices(const char *printers
, /* I - Destinations */
1051 int num_dests
, /* I - Number of user-defined dests */
1052 cups_dest_t
*dests
) /* I - User-defined destinations */
1054 int i
; /* Looping var */
1055 ipp_t
*request
, /* IPP Request */
1056 *response
; /* IPP Response */
1057 ipp_attribute_t
*attr
; /* Current attribute */
1058 const char *printer
, /* Printer name */
1059 *uri
, /* Printer URI */
1060 *device
; /* Printer device URI */
1061 static const char *pattrs
[] = /* Attributes we need for printers... */
1064 "printer-uri-supported",
1069 DEBUG_printf(("show_devices(printers=\"%s\")\n", printers
));
1071 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1075 * Build a CUPS_GET_PRINTERS request, which requires the following
1078 * attributes-charset
1079 * attributes-natural-language
1080 * requested-attributes
1081 * requesting-user-name
1084 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1086 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1087 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1090 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1094 * Do the request and get back a response...
1097 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1099 DEBUG_puts("show_devices: request succeeded...");
1101 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1103 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1104 ippDelete(response
);
1109 * Loop through the printers returned in the list and display
1113 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1116 * Skip leading attributes until we hit a job...
1119 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1126 * Pull the needed attributes from this job...
1133 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1135 if (!strcmp(attr
->name
, "printer-name") &&
1136 attr
->value_tag
== IPP_TAG_NAME
)
1137 printer
= attr
->values
[0].string
.text
;
1139 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1140 attr
->value_tag
== IPP_TAG_URI
)
1141 uri
= attr
->values
[0].string
.text
;
1143 if (!strcmp(attr
->name
, "device-uri") &&
1144 attr
->value_tag
== IPP_TAG_URI
)
1145 device
= attr
->values
[0].string
.text
;
1151 * See if we have everything needed...
1154 if (printer
== NULL
)
1163 * Display the printer entry if needed...
1166 if (match_list(printers
, printer
))
1168 #ifdef __osf__ /* Compaq/Digital like to do it their own way... */
1169 char scheme
[HTTP_MAX_URI
], /* Components of printer URI */
1170 username
[HTTP_MAX_URI
],
1171 hostname
[HTTP_MAX_URI
],
1172 resource
[HTTP_MAX_URI
];
1178 httpSeparateURI(HTTP_URI_CODING_ALL
, uri
, scheme
, sizeof(scheme
),
1179 username
, sizeof(username
), hostname
,
1180 sizeof(hostname
), &port
, resource
, sizeof(resource
));
1181 _cupsLangPrintf(stdout
,
1182 _("Output for printer %s is sent to remote "
1183 "printer %s on %s\n"),
1184 printer
, strrchr(resource
, '/') + 1, hostname
);
1186 else if (!strncmp(device
, "file:", 5))
1187 _cupsLangPrintf(stdout
,
1188 _("Output for printer %s is sent to %s\n"),
1189 printer
, device
+ 5);
1191 _cupsLangPrintf(stdout
,
1192 _("Output for printer %s is sent to %s\n"),
1195 for (i
= 0; i
< num_dests
; i
++)
1196 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1199 _cupsLangPrintf(stdout
,
1200 _("Output for printer %s/%s is sent to "
1201 "remote printer %s on %s\n"),
1202 printer
, dests
[i
].instance
,
1203 strrchr(resource
, '/') + 1, hostname
);
1204 else if (!strncmp(device
, "file:", 5))
1205 _cupsLangPrintf(stdout
,
1206 _("Output for printer %s/%s is sent to %s\n"),
1207 printer
, dests
[i
].instance
, device
+ 5);
1209 _cupsLangPrintf(stdout
,
1210 _("Output for printer %s/%s is sent to %s\n"),
1211 printer
, dests
[i
].instance
, device
);
1215 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1217 else if (!strncmp(device
, "file:", 5))
1218 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1219 printer
, device
+ 5);
1221 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1224 for (i
= 0; i
< num_dests
; i
++)
1225 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1228 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1229 printer
, dests
[i
].instance
, uri
);
1230 else if (!strncmp(device
, "file:", 5))
1231 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1232 printer
, dests
[i
].instance
, device
+ 5);
1234 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1235 printer
, dests
[i
].instance
, device
);
1237 #endif /* __osf__ */
1244 ippDelete(response
);
1248 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1257 * 'show_jobs()' - Show active print jobs.
1260 static int /* O - 0 on success, 1 on fail */
1261 show_jobs(const char *dests
, /* I - Destinations */
1262 const char *users
, /* I - Users */
1263 int long_status
, /* I - Show long status? */
1264 int ranking
, /* I - Show job ranking? */
1265 const char *which
) /* I - Show which jobs? */
1267 int i
; /* Looping var */
1268 ipp_t
*request
, /* IPP Request */
1269 *response
; /* IPP Response */
1270 ipp_attribute_t
*attr
, /* Current attribute */
1271 *reasons
; /* Job state reasons attribute */
1272 const char *dest
, /* Pointer into job-printer-uri */
1273 *username
, /* Pointer to job-originating-user-name */
1274 *title
; /* Pointer to job-name */
1275 int rank
, /* Rank in queue */
1277 size
; /* job-k-octets */
1278 time_t jobtime
; /* time-at-creation */
1279 struct tm
*jobdate
; /* Date & time */
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",
1289 "job-state-reasons",
1294 DEBUG_printf(("show_jobs(dests=\"%s\", users=\"%s\", long_status=%d, "
1295 "ranking=%d, which=\"%s\")\n", dests
, users
, long_status
,
1298 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1302 * Build a IPP_GET_JOBS request, which requires the following
1305 * attributes-charset
1306 * attributes-natural-language
1308 * requested-attributes
1309 * requesting-user-name
1313 request
= ippNewRequest(IPP_GET_JOBS
);
1315 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri",
1316 NULL
, "ipp://localhost/");
1318 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1319 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1322 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1325 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1329 * Do the request and get back a response...
1332 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1335 * Loop through the job list and display them...
1338 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1340 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1341 ippDelete(response
);
1347 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1350 * Skip leading attributes until we hit a job...
1353 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1360 * Pull the needed attributes from this job...
1371 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1373 if (!strcmp(attr
->name
, "job-id") &&
1374 attr
->value_tag
== IPP_TAG_INTEGER
)
1375 jobid
= attr
->values
[0].integer
;
1377 if (!strcmp(attr
->name
, "job-k-octets") &&
1378 attr
->value_tag
== IPP_TAG_INTEGER
)
1379 size
= attr
->values
[0].integer
;
1381 if (!strcmp(attr
->name
, "time-at-creation") &&
1382 attr
->value_tag
== IPP_TAG_INTEGER
)
1383 jobtime
= attr
->values
[0].integer
;
1385 if (!strcmp(attr
->name
, "job-printer-uri") &&
1386 attr
->value_tag
== IPP_TAG_URI
)
1387 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1390 if (!strcmp(attr
->name
, "job-originating-user-name") &&
1391 attr
->value_tag
== IPP_TAG_NAME
)
1392 username
= attr
->values
[0].string
.text
;
1394 if (!strcmp(attr
->name
, "job-name") &&
1395 attr
->value_tag
== IPP_TAG_NAME
)
1396 title
= attr
->values
[0].string
.text
;
1398 if (!strcmp(attr
->name
, "job-state-reasons") &&
1399 attr
->value_tag
== IPP_TAG_KEYWORD
)
1406 * See if we have everything needed...
1409 if (dest
== NULL
|| jobid
== 0)
1418 * Display the job...
1423 if (match_list(dests
, dest
) || match_list(users
, username
))
1425 jobdate
= localtime(&jobtime
);
1426 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1428 if (long_status
== 3)
1431 * Show the consolidated output format for the SGI tools...
1434 if (!strftime(date
, sizeof(date
), "%b %d %H:%M", jobdate
))
1435 strcpy(date
, "Unknown");
1437 _cupsLangPrintf(stdout
, "%s;%s;%d;%s;%s\n",
1438 temp
, username
? username
: "unknown",
1439 size
, title
? title
: "unknown", date
);
1443 if (!strftime(date
, sizeof(date
), "%c", jobdate
))
1444 strcpy(date
, "Unknown");
1447 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s\n",
1448 rank
, temp
, username
? username
: "unknown",
1449 1024.0 * size
, date
);
1451 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s\n",
1452 temp
, username
? username
: "unknown",
1453 1024.0 * size
, date
);
1458 _cupsLangPuts(stdout
, _("\tAlerts:"));
1459 for (i
= 0; i
< reasons
->num_values
; i
++)
1460 _cupsLangPrintf(stdout
, " %s",
1461 reasons
->values
[i
].string
.text
);
1462 _cupsLangPuts(stdout
, "\n");
1464 _cupsLangPrintf(stdout
, _("\tqueued for %s\n"), dest
);
1473 ippDelete(response
);
1477 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1486 * 'show_printers()' - Show printers.
1489 static int /* O - 0 on success, 1 on fail */
1490 show_printers(const char *printers
, /* I - Destinations */
1491 int num_dests
, /* I - Number of user-defined dests */
1492 cups_dest_t
*dests
, /* I - User-defined destinations */
1493 int long_status
) /* I - Show long status? */
1495 int i
, j
; /* Looping vars */
1496 ipp_t
*request
, /* IPP Request */
1497 *response
, /* IPP Response */
1498 *jobs
; /* IPP Get Jobs response */
1499 ipp_attribute_t
*attr
, /* Current attribute */
1500 *jobattr
, /* Job ID attribute */
1501 *reasons
; /* Job state reasons attribute */
1502 const char *printer
, /* Printer name */
1503 *message
, /* Printer state message */
1504 *description
, /* Description of printer */
1505 *location
, /* Location of printer */
1506 *make_model
, /* Make and model of printer */
1507 *uri
; /* URI of printer */
1508 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1509 *denied
; /* requestint-user-name-denied */
1510 ipp_pstate_t pstate
; /* Printer state */
1511 cups_ptype_t ptype
; /* Printer type */
1512 time_t ptime
; /* Printer state time */
1513 struct tm
*pdate
; /* Printer state date & time */
1514 int jobid
; /* Job ID of current job */
1515 char printer_uri
[HTTP_MAX_URI
],
1517 printer_state_time
[255];/* Printer state time */
1518 _cups_globals_t
*cg
= _cupsGlobals(); /* Global data */
1519 static const char *pattrs
[] = /* Attributes we need for printers... */
1523 "printer-state-message",
1524 "printer-state-reasons",
1525 "printer-state-change-time",
1529 "printer-make-and-model",
1530 "printer-uri-supported",
1531 "requesting-user-name-allowed",
1532 "requesting-user-name-denied"
1534 static const char *jattrs
[] = /* Attributes we need for jobs... */
1540 DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
1541 "long_status=%d)\n", printers
, num_dests
, dests
, long_status
));
1543 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1547 * Build a CUPS_GET_PRINTERS request, which requires the following
1550 * attributes-charset
1551 * attributes-natural-language
1552 * requested-attributes
1553 * requesting-user-name
1556 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1558 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1559 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1562 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1566 * Do the request and get back a response...
1569 if ((response
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1571 DEBUG_puts("show_printers: request succeeded...");
1573 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1575 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1576 ippDelete(response
);
1581 * Loop through the printers returned in the list and display
1585 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1588 * Skip leading attributes until we hit a job...
1591 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1598 * Pull the needed attributes from this job...
1603 ptype
= CUPS_PRINTER_LOCAL
;
1604 pstate
= IPP_PRINTER_IDLE
;
1615 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1617 if (!strcmp(attr
->name
, "printer-name") &&
1618 attr
->value_tag
== IPP_TAG_NAME
)
1619 printer
= attr
->values
[0].string
.text
;
1620 else if (!strcmp(attr
->name
, "printer-state") &&
1621 attr
->value_tag
== IPP_TAG_ENUM
)
1622 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1623 else if (!strcmp(attr
->name
, "printer-type") &&
1624 attr
->value_tag
== IPP_TAG_ENUM
)
1625 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1626 else if (!strcmp(attr
->name
, "printer-state-message") &&
1627 attr
->value_tag
== IPP_TAG_TEXT
)
1628 message
= attr
->values
[0].string
.text
;
1629 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1630 attr
->value_tag
== IPP_TAG_INTEGER
)
1631 ptime
= (time_t)attr
->values
[0].integer
;
1632 else if (!strcmp(attr
->name
, "printer-info") &&
1633 attr
->value_tag
== IPP_TAG_TEXT
)
1634 description
= attr
->values
[0].string
.text
;
1635 else if (!strcmp(attr
->name
, "printer-location") &&
1636 attr
->value_tag
== IPP_TAG_TEXT
)
1637 location
= attr
->values
[0].string
.text
;
1638 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1639 attr
->value_tag
== IPP_TAG_TEXT
)
1640 make_model
= attr
->values
[0].string
.text
;
1641 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1642 attr
->value_tag
== IPP_TAG_URI
)
1643 uri
= attr
->values
[0].string
.text
;
1644 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1645 attr
->value_tag
== IPP_TAG_KEYWORD
)
1647 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1648 attr
->value_tag
== IPP_TAG_NAME
)
1650 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1651 attr
->value_tag
== IPP_TAG_NAME
)
1658 * See if we have everything needed...
1661 if (printer
== NULL
)
1670 * Display the printer entry if needed...
1673 if (match_list(printers
, printer
))
1676 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1677 * current job for the printer.
1680 if (pstate
== IPP_PRINTER_PROCESSING
)
1683 * Build an IPP_GET_JOBS request, which requires the following
1686 * attributes-charset
1687 * attributes-natural-language
1690 * requested-attributes
1693 request
= ippNewRequest(IPP_GET_JOBS
);
1695 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1696 request
->request
.op
.request_id
= 1;
1698 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1699 "requested-attributes",
1700 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1702 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1703 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1704 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1705 "printer-uri", NULL
, printer_uri
);
1707 if ((jobs
= cupsDoRequest(CUPS_HTTP_DEFAULT
, request
, "/")) != NULL
)
1710 * Get the current active job on this queue...
1713 ipp_jstate_t jobstate
= IPP_JOB_PENDING
;
1716 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1720 if (jobstate
== IPP_JOB_PROCESSING
)
1726 if (!strcmp(jobattr
->name
, "job-id") &&
1727 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1728 jobid
= jobattr
->values
[0].integer
;
1729 else if (!strcmp(jobattr
->name
, "job-state") &&
1730 jobattr
->value_tag
== IPP_TAG_ENUM
)
1731 jobstate
= jobattr
->values
[0].integer
;
1734 if (jobstate
!= IPP_JOB_PROCESSING
)
1745 pdate
= localtime(&ptime
);
1746 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
1750 case IPP_PRINTER_IDLE
:
1751 _cupsLangPrintf(stdout
,
1752 _("printer %s is idle. enabled since %s\n"),
1753 printer
, printer_state_time
);
1755 case IPP_PRINTER_PROCESSING
:
1756 _cupsLangPrintf(stdout
,
1757 _("printer %s now printing %s-%d. "
1758 "enabled since %s\n"),
1759 printer
, printer
, jobid
, printer_state_time
);
1761 case IPP_PRINTER_STOPPED
:
1762 _cupsLangPrintf(stdout
,
1763 _("printer %s disabled since %s -\n"),
1764 printer
, printer_state_time
);
1768 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1770 if (!message
|| !*message
)
1771 _cupsLangPuts(stdout
, _("\treason unknown\n"));
1773 _cupsLangPrintf(stdout
, "\t%s\n", message
);
1776 if (long_status
> 1)
1777 _cupsLangPuts(stdout
,
1778 _("\tForm mounted:\n"
1779 "\tContent types: any\n"
1780 "\tPrinter types: unknown\n"));
1784 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
1785 description
? description
: "");
1789 _cupsLangPuts(stdout
, _("\tAlerts:"));
1790 for (j
= 0; j
< reasons
->num_values
; j
++)
1791 _cupsLangPrintf(stdout
, " %s",
1792 reasons
->values
[j
].string
.text
);
1793 _cupsLangPuts(stdout
, "\n");
1796 if (long_status
> 1)
1798 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
1799 location
? location
: "");
1801 if (ptype
& CUPS_PRINTER_REMOTE
)
1803 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
1805 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1806 !strstr(make_model
, "Raw Printer") && uri
)
1807 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
1812 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
1814 if (make_model
&& strstr(make_model
, "System V Printer"))
1815 _cupsLangPrintf(stdout
,
1816 _("\tInterface: %s/interfaces/%s\n"),
1817 cg
->cups_serverroot
, printer
);
1818 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1819 _cupsLangPrintf(stdout
,
1820 _("\tInterface: %s/ppd/%s.ppd\n"),
1821 cg
->cups_serverroot
, printer
);
1823 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
1824 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
1825 /* TODO update to use printer-error-policy */
1828 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1829 for (j
= 0; j
< allowed
->num_values
; j
++)
1830 _cupsLangPrintf(stdout
, "\t\t%s\n",
1831 allowed
->values
[j
].string
.text
);
1835 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
1836 for (j
= 0; j
< denied
->num_values
; j
++)
1837 _cupsLangPrintf(stdout
, "\t\t%s\n",
1838 denied
->values
[j
].string
.text
);
1842 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1843 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
1845 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
1846 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1847 _cupsLangPuts(stdout
, _("\tBanner required\n"));
1848 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
1849 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1850 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
1851 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
1852 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
1855 for (i
= 0; i
< num_dests
; i
++)
1856 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1860 case IPP_PRINTER_IDLE
:
1861 _cupsLangPrintf(stdout
,
1862 _("printer %s/%s is idle. "
1863 "enabled since %s\n"),
1864 printer
, dests
[i
].instance
,
1865 printer_state_time
);
1867 case IPP_PRINTER_PROCESSING
:
1868 _cupsLangPrintf(stdout
,
1869 _("printer %s/%s now printing %s-%d. "
1870 "enabled since %s\n"),
1871 printer
, dests
[i
].instance
, printer
, jobid
,
1872 printer_state_time
);
1874 case IPP_PRINTER_STOPPED
:
1875 _cupsLangPrintf(stdout
,
1876 _("printer %s/%s disabled since %s -\n"),
1877 printer
, dests
[i
].instance
,
1878 printer_state_time
);
1882 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1884 if (!message
|| !*message
)
1885 _cupsLangPuts(stdout
, _("\treason unknown\n"));
1887 _cupsLangPrintf(stdout
, "\t%s\n", message
);
1890 if (long_status
> 1)
1891 _cupsLangPuts(stdout
,
1892 _("\tForm mounted:\n"
1893 "\tContent types: any\n"
1894 "\tPrinter types: unknown\n"));
1898 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
1899 description
? description
: "");
1903 _cupsLangPuts(stdout
, _("\tAlerts:"));
1904 for (j
= 0; j
< reasons
->num_values
; j
++)
1905 _cupsLangPrintf(stdout
, " %s",
1906 reasons
->values
[j
].string
.text
);
1907 _cupsLangPuts(stdout
, "\n");
1910 if (long_status
> 1)
1912 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
1913 location
? location
: "");
1915 if (ptype
& CUPS_PRINTER_REMOTE
)
1917 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
1919 if (make_model
&& !strstr(make_model
, "System V Printer") &&
1920 !strstr(make_model
, "Raw Printer") && uri
)
1921 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
1926 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
1928 if (make_model
&& strstr(make_model
, "System V Printer"))
1929 _cupsLangPrintf(stdout
,
1930 _("\tInterface: %s/interfaces/%s\n"),
1931 cg
->cups_serverroot
, printer
);
1932 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
1933 _cupsLangPrintf(stdout
,
1934 _("\tInterface: %s/ppd/%s.ppd\n"),
1935 cg
->cups_serverroot
, printer
);
1937 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
1938 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
1939 /* TODO update to use printer-error-policy */
1942 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1943 for (j
= 0; j
< allowed
->num_values
; j
++)
1944 _cupsLangPrintf(stdout
, "\t\t%s\n",
1945 allowed
->values
[j
].string
.text
);
1949 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
1950 for (j
= 0; j
< denied
->num_values
; j
++)
1951 _cupsLangPrintf(stdout
, "\t\t%s\n",
1952 denied
->values
[j
].string
.text
);
1956 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
1957 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
1959 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
1960 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1961 _cupsLangPuts(stdout
, _("\tBanner required\n"));
1962 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
1963 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
1964 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
1965 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
1966 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
1975 ippDelete(response
);
1979 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1988 * 'show_scheduler()' - Show scheduler status.
1992 show_scheduler(void)
1994 http_t
*http
; /* Connection to server */
1997 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
1998 cupsEncryption())) != NULL
)
2000 _cupsLangPuts(stdout
, _("scheduler is running\n"));
2004 _cupsLangPuts(stdout
, _("scheduler is not running\n"));
2009 * End of "$Id: lpstat.c 7921 2008-09-10 15:42:24Z mike $".