2 * "$Id: lpstat.c 4948 2006-01-19 03:23:41Z mike $"
4 * "lpstat" command for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2006 by Easy Software Products.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
26 * main() - Parse options and show status information.
27 * check_dest() - Verify that the named destination(s) exists.
28 * connect_server() - Connect to the server as necessary...
29 * show_accepting() - Show acceptance status.
30 * show_classes() - Show printer classes.
31 * show_default() - Show default destination.
32 * show_devices() - Show printer devices.
33 * show_jobs() - Show active print jobs.
34 * show_printers() - Show printers.
35 * show_scheduler() - Show scheduler status.
39 * Include necessary headers...
45 #include <cups/string.h>
46 #include <cups/cups.h>
47 #include <cups/i18n.h>
48 #include <cups/debug.h>
55 static void check_dest(const char *, http_t
*, const char *, int *,
57 static http_t
*connect_server(const char *, http_t
*);
58 static int show_accepting(http_t
*, const char *, int, cups_dest_t
*);
59 static int show_classes(http_t
*, const char *);
60 static void show_default(int, cups_dest_t
*);
61 static int show_devices(http_t
*, const char *, int, cups_dest_t
*);
62 static int show_jobs(http_t
*, const char *, const char *, int, int,
64 static int show_printers(http_t
*, const char *, int, cups_dest_t
*, int);
65 static void show_scheduler(http_t
*);
69 * 'main()' - Parse options and show status information.
73 main(int argc
, /* I - Number of command-line arguments */
74 char *argv
[]) /* I - Command-line arguments */
76 int i
, /* Looping var */
77 status
; /* Exit status */
78 http_t
*http
; /* Connection to server */
79 int num_dests
; /* Number of user destinations */
80 cups_dest_t
*dests
; /* User destinations */
81 int long_status
; /* Long status report? */
82 int ranking
; /* Show job ranking? */
83 const char *which
; /* Which jobs to show? */
84 char op
; /* Last operation on command-line */
88 setlocale(LC_TIME
, "");
97 which
= "not-completed";
100 for (i
= 1; i
< argc
; i
++)
101 if (argv
[i
][0] == '-')
104 case 'D' : /* Show description */
108 case 'E' : /* Encrypt */
110 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
113 httpEncryption(http
, HTTP_ENCRYPT_REQUIRED
);
115 _cupsLangPrintf(stderr
,
116 _("%s: Sorry, no encryption support compiled in!\n"),
118 #endif /* HAVE_SSL */
121 case 'P' : /* Show paper types */
125 case 'R' : /* Show ranking */
129 case 'S' : /* Show charsets */
135 case 'U' : /* Username */
136 if (argv
[i
][2] != '\0')
137 cupsSetUser(argv
[i
] + 2);
143 _cupsLangPrintf(stderr
,
144 _("%s: Error - expected username after "
150 cupsSetUser(argv
[i
]);
154 case 'W' : /* Show which jobs? */
163 _cupsLangPrintf(stderr
,
164 _("%s: Error - need \"completed\", "
165 "\"not-completed\", or \"all\" after "
174 if (strcmp(which
, "completed") && strcmp(which
, "not-completed") &&
175 strcmp(which
, "all"))
177 _cupsLangPrintf(stderr
,
178 _("%s: Error - need \"completed\", "
179 "\"not-completed\", or \"all\" after "
186 case 'a' : /* Show acceptance status */
188 http
= connect_server(argv
[0], http
);
190 if (argv
[i
][2] != '\0')
192 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
194 status
|= show_accepting(http
, argv
[i
] + 2, num_dests
, dests
);
196 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
200 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
202 status
|= show_accepting(http
, argv
[i
], num_dests
, dests
);
207 num_dests
= cupsGetDests2(http
, &dests
);
209 status
|= show_accepting(http
, NULL
, num_dests
, dests
);
214 case 'b' : /* Show both the local and remote status */
216 http
= connect_server(argv
[0], http
);
218 if (argv
[i
][2] != '\0')
221 * The local and remote status are separated by a blank line;
222 * since all CUPS jobs are networked, we only output the
223 * second list for now... In the future, we might further
224 * emulate this by listing the remote server's queue, but
225 * for now this is enough to make the SGI printstatus program
229 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
232 status
|= show_jobs(http
, argv
[i
] + 2, NULL
, 3, ranking
, which
);
236 _cupsLangPuts(stderr
,
237 _("%s: Error - expected destination after "
246 case 'c' : /* Show classes and members */
248 http
= connect_server(argv
[0], http
);
250 if (argv
[i
][2] != '\0')
252 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
254 status
|= show_classes(http
, argv
[i
] + 2);
256 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
260 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
262 status
|= show_classes(http
, argv
[i
]);
265 status
|= show_classes(http
, NULL
);
268 case 'd' : /* Show default destination */
270 http
= connect_server(argv
[0], http
);
273 num_dests
= cupsGetDests2(http
, &dests
);
275 show_default(num_dests
, dests
);
278 case 'f' : /* Show forms */
284 case 'h' : /* Connect to host */
291 if (argv
[i
][2] != '\0')
292 cupsSetServer(argv
[i
] + 2);
299 _cupsLangPrintf(stderr
,
300 _("%s: Error - expected hostname after "
306 cupsSetServer(argv
[i
]);
310 case 'l' : /* Long status or long job status */
313 http
= connect_server(argv
[0], http
);
315 if (argv
[i
][2] != '\0')
317 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
319 status
|= show_jobs(http
, argv
[i
] + 2, NULL
, 3, ranking
, which
);
326 case 'o' : /* Show jobs by destination */
328 http
= connect_server(argv
[0], http
);
330 if (argv
[i
][2] != '\0')
332 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
334 status
|= show_jobs(http
, argv
[i
] + 2, NULL
, long_status
,
337 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
341 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
343 status
|= show_jobs(http
, argv
[i
], NULL
, long_status
,
347 status
|= show_jobs(http
, NULL
, NULL
, long_status
,
351 case 'p' : /* Show printers */
353 http
= connect_server(argv
[0], http
);
355 if (argv
[i
][2] != '\0')
357 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
359 status
|= show_printers(http
, argv
[i
] + 2, num_dests
, dests
, long_status
);
361 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
365 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
367 status
|= show_printers(http
, argv
[i
], num_dests
, dests
, long_status
);
372 num_dests
= cupsGetDests2(http
, &dests
);
374 status
|= show_printers(http
, NULL
, num_dests
, dests
, long_status
);
378 case 'r' : /* Show scheduler status */
380 http
= connect_server(argv
[0], http
);
382 show_scheduler(http
);
385 case 's' : /* Show summary */
387 http
= connect_server(argv
[0], http
);
390 num_dests
= cupsGetDests2(http
, &dests
);
392 show_default(num_dests
, dests
);
393 status
|= show_classes(http
, NULL
);
394 status
|= show_devices(http
, NULL
, num_dests
, dests
);
397 case 't' : /* Show all info */
399 http
= connect_server(argv
[0], http
);
402 num_dests
= cupsGetDests2(http
, &dests
);
404 show_scheduler(http
);
405 show_default(num_dests
, dests
);
406 status
|= show_classes(http
, NULL
);
407 status
|= show_devices(http
, NULL
, num_dests
, dests
);
408 status
|= show_accepting(http
, NULL
, num_dests
, dests
);
409 status
|= show_printers(http
, NULL
, num_dests
, dests
, long_status
);
410 status
|= show_jobs(http
, NULL
, NULL
, long_status
, ranking
, which
);
413 case 'u' : /* Show jobs by user */
415 http
= connect_server(argv
[0], http
);
417 if (argv
[i
][2] != '\0')
418 status
|= show_jobs(http
, NULL
, argv
[i
] + 2, long_status
,
420 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
423 status
|= show_jobs(http
, NULL
, argv
[i
], long_status
,
427 status
|= show_jobs(http
, NULL
, NULL
, long_status
,
431 case 'v' : /* Show printer devices */
433 http
= connect_server(argv
[0], http
);
435 if (argv
[i
][2] != '\0')
437 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
439 status
|= show_devices(http
, argv
[i
] + 2, num_dests
, dests
);
441 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
445 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
447 status
|= show_devices(http
, argv
[i
], num_dests
, dests
);
452 num_dests
= cupsGetDests2(http
, &dests
);
454 status
|= show_devices(http
, NULL
, num_dests
, dests
);
460 _cupsLangPrintf(stderr
,
461 _("%s: Error - unknown option \'%c\'!\n"),
462 argv
[0], argv
[i
][1]);
467 http
= connect_server(argv
[0], http
);
469 status
|= show_jobs(http
, argv
[i
], NULL
, long_status
, ranking
, which
);
475 http
= connect_server(argv
[0], http
);
477 status
|= show_jobs(http
, NULL
, cupsUser(), long_status
, ranking
, which
);
485 * 'check_dest()' - Verify that the named destination(s) exists.
489 check_dest(const char *command
, /* I - Command name */
490 http_t
*http
, /* I - HTTP connection */
491 const char *name
, /* I - Name of printer/class(es) */
492 int *num_dests
, /* IO - Number of destinations */
493 cups_dest_t
**dests
) /* IO - Destinations */
501 * Load the destination list as necessary...
505 *num_dests
= cupsGetDests2(http
, dests
);
508 * Scan the name string for printer/class name(s)...
511 for (dptr
= name
; *dptr
!= '\0';)
514 * Skip leading whitespace and commas...
517 while (isspace(*dptr
& 255) || *dptr
== ',')
524 * Extract a single destination name from the name string...
527 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0';)
529 if ((pptr
- printer
) < (sizeof(printer
) - 1))
533 _cupsLangPrintf(stderr
,
534 _("%s: Invalid destination name in list \"%s\"!\n"),
543 * Check the destination...
546 if (cupsGetDest(printer
, NULL
, *num_dests
, *dests
) == NULL
)
548 _cupsLangPrintf(stderr
,
549 _("%s: Unknown destination \"%s\"!\n"), command
, printer
);
557 * 'connect_server()' - Connect to the server as necessary...
560 static http_t
* /* O - New HTTP connection */
561 connect_server(const char *command
, /* I - Command name */
562 http_t
*http
) /* I - Current HTTP connection */
566 http
= httpConnectEncrypt(cupsServer(), ippPort(),
571 _cupsLangPrintf(stderr
, _("%s: Unable to connect to server\n"), command
);
581 * 'show_accepting()' - Show acceptance status.
584 static int /* O - 0 on success, 1 on fail */
585 show_accepting(http_t
*http
, /* I - HTTP connection to server */
586 const char *printers
, /* I - Destinations */
587 int num_dests
, /* I - Number of user-defined dests */
588 cups_dest_t
*dests
) /* I - User-defined destinations */
590 int i
; /* Looping var */
591 ipp_t
*request
, /* IPP Request */
592 *response
; /* IPP Response */
593 ipp_attribute_t
*attr
; /* Current attribute */
594 const char *printer
, /* Printer name */
595 *message
; /* Printer device URI */
596 int accepting
; /* Accepting requests? */
597 time_t ptime
; /* Printer state time */
598 struct tm
*pdate
; /* Printer state date & time */
599 char printer_state_time
[255];/* Printer state time */
600 const char *dptr
, /* Pointer into destination list */
601 *ptr
; /* Pointer into printer name */
602 int match
; /* Non-zero if this job matches */
603 static const char *pattrs
[] = /* Attributes we need for printers... */
606 "printer-state-change-time",
607 "printer-state-message",
608 "printer-is-accepting-jobs"
612 DEBUG_printf(("show_accepting(%p, %p)\n", http
, printers
));
617 if (printers
!= NULL
&& !strcmp(printers
, "all"))
621 * Build a CUPS_GET_PRINTERS request, which requires the following
625 * attributes-natural-language
626 * requested-attributes
627 * requesting-user-name
630 request
= ippNewRequest(CUPS_GET_PRINTERS
);
632 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
633 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
636 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
640 * Do the request and get back a response...
643 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
645 DEBUG_puts("show_accepting: request succeeded...");
647 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
649 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
655 * Loop through the printers returned in the list and display
659 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
662 * Skip leading attributes until we hit a printer...
665 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
672 * Pull the needed attributes from this printer...
680 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
682 if (!strcmp(attr
->name
, "printer-name") &&
683 attr
->value_tag
== IPP_TAG_NAME
)
684 printer
= attr
->values
[0].string
.text
;
685 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
686 attr
->value_tag
== IPP_TAG_INTEGER
)
687 ptime
= (time_t)attr
->values
[0].integer
;
688 else if (!strcmp(attr
->name
, "printer-state-message") &&
689 attr
->value_tag
== IPP_TAG_TEXT
)
690 message
= attr
->values
[0].string
.text
;
691 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
692 attr
->value_tag
== IPP_TAG_BOOLEAN
)
693 accepting
= attr
->values
[0].boolean
;
699 * See if we have everything needed...
711 * See if this is a printer we're interested in...
714 match
= printers
== NULL
;
716 if (printers
!= NULL
)
718 for (dptr
= printers
; *dptr
!= '\0';)
721 * Skip leading whitespace and commas...
724 while (isspace(*dptr
& 255) || *dptr
== ',')
735 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
738 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
745 * Skip trailing junk...
748 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
750 while (isspace(*dptr
& 255) || *dptr
== ',')
759 * Display the printer entry if needed...
764 pdate
= localtime(&ptime
);
765 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
768 _cupsLangPrintf(stdout
, _("%s accepting requests since %s\n"),
769 printer
, printer_state_time
);
771 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -\n"
773 printer
, printer_state_time
,
774 message
== NULL
? "reason unknown" : message
);
776 for (i
= 0; i
< num_dests
; i
++)
777 if (!strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
780 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s\n"),
781 printer
, dests
[i
].instance
, printer_state_time
);
783 _cupsLangPrintf(stdout
, _("%s/%s not accepting requests since "
785 printer
, dests
[i
].instance
, printer_state_time
,
786 message
== NULL
? "reason unknown" : message
);
798 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
807 * 'show_classes()' - Show printer classes.
810 static int /* O - 0 on success, 1 on fail */
811 show_classes(http_t
*http
, /* I - HTTP connection to server */
812 const char *dests
) /* I - Destinations */
814 int i
; /* Looping var */
815 ipp_t
*request
, /* IPP Request */
816 *response
, /* IPP Response */
817 *response2
; /* IPP response from remote server */
818 http_t
*http2
; /* Remote server */
819 ipp_attribute_t
*attr
; /* Current attribute */
820 const char *printer
, /* Printer class name */
821 *printer_uri
; /* Printer class URI */
822 ipp_attribute_t
*members
; /* Printer members */
823 char method
[HTTP_MAX_URI
], /* Request method */
824 username
[HTTP_MAX_URI
], /* Username:password */
825 server
[HTTP_MAX_URI
], /* Server name */
826 resource
[HTTP_MAX_URI
]; /* Resource name */
827 int port
; /* Port number */
828 const char *dptr
, /* Pointer into destination list */
829 *ptr
; /* Pointer into printer name */
830 int match
; /* Non-zero if this job matches */
831 static const char *cattrs
[] = /* Attributes we need for classes... */
834 "printer-uri-supported",
839 DEBUG_printf(("show_classes(%p, %p)\n", http
, dests
));
844 if (dests
!= NULL
&& !strcmp(dests
, "all"))
848 * Build a CUPS_GET_CLASSES request, which requires the following
852 * attributes-natural-language
853 * requested-attributes
854 * requesting-user-name
857 request
= ippNewRequest(CUPS_GET_CLASSES
);
859 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
860 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
863 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
867 * Do the request and get back a response...
870 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
872 DEBUG_puts("show_classes: request succeeded...");
874 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
876 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
882 * Loop through the printers returned in the list and display
886 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
889 * Skip leading attributes until we hit a job...
892 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
899 * Pull the needed attributes from this job...
906 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
908 if (!strcmp(attr
->name
, "printer-name") &&
909 attr
->value_tag
== IPP_TAG_NAME
)
910 printer
= attr
->values
[0].string
.text
;
912 if (!strcmp(attr
->name
, "printer-uri-supported") &&
913 attr
->value_tag
== IPP_TAG_URI
)
914 printer_uri
= attr
->values
[0].string
.text
;
916 if (!strcmp(attr
->name
, "member-names") &&
917 attr
->value_tag
== IPP_TAG_NAME
)
924 * If this is a remote class, grab the class info from the
929 if (members
== NULL
&& printer_uri
!= NULL
)
931 httpSeparateURI(printer_uri
, method
, sizeof(method
),
932 username
, sizeof(username
), server
, sizeof(server
),
933 &port
, resource
, sizeof(resource
));
935 if (!strcasecmp(server
, http
->hostname
))
938 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
943 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
944 * following attributes:
947 * attributes-natural-language
949 * requested-attributes
952 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
954 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
955 "printer-uri", NULL
, printer_uri
);
957 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
958 "requested-attributes",
959 sizeof(cattrs
) / sizeof(cattrs
[0]),
962 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
963 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
971 * See if we have everything needed...
977 ippDelete(response2
);
986 * See if this is a printer we're interested in...
989 match
= dests
== NULL
;
993 for (dptr
= dests
; *dptr
!= '\0';)
996 * Skip leading whitespace and commas...
999 while (isspace(*dptr
& 255) || *dptr
== ',')
1010 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1013 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1020 * Skip trailing junk...
1023 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1025 while (isspace(*dptr
& 255) || *dptr
== ',')
1034 * Display the printer entry if needed...
1039 _cupsLangPrintf(stdout
, _("members of class %s:\n"), printer
);
1043 for (i
= 0; i
< members
->num_values
; i
++)
1044 _cupsLangPrintf(stdout
, "\t%s\n",
1045 members
->values
[i
].string
.text
);
1048 _cupsLangPuts(stdout
, "\tunknown\n");
1052 ippDelete(response2
);
1058 ippDelete(response
);
1062 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1071 * 'show_default()' - Show default destination.
1075 show_default(int num_dests
, /* I - Number of user-defined dests */
1076 cups_dest_t
*dests
) /* I - User-defined destinations */
1078 cups_dest_t
*dest
; /* Destination */
1079 const char *printer
, /* Printer name */
1080 *val
; /* Environment variable name */
1082 if ((dest
= cupsGetDest(NULL
, NULL
, num_dests
, dests
)) != NULL
)
1085 _cupsLangPrintf(stdout
, _("system default destination: %s/%s\n"),
1086 dest
->name
, dest
->instance
);
1088 _cupsLangPrintf(stdout
, _("system default destination: %s\n"),
1095 if ((printer
= getenv("LPDEST")) == NULL
)
1097 if ((printer
= getenv("PRINTER")) != NULL
)
1099 if (!strcmp(printer
, "lp"))
1108 if (printer
&& !cupsGetDest(printer
, NULL
, num_dests
, dests
))
1109 _cupsLangPrintf(stdout
,
1110 _("lpstat: error - %s environment variable names "
1111 "non-existent destination \"%s\"!\n"),
1114 _cupsLangPuts(stdout
, _("no system default destination\n"));
1120 * 'show_devices()' - Show printer devices.
1123 static int /* O - 0 on success, 1 on fail */
1124 show_devices(http_t
*http
, /* I - HTTP connection to server */
1125 const char *printers
, /* I - Destinations */
1126 int num_dests
, /* I - Number of user-defined dests */
1127 cups_dest_t
*dests
) /* I - User-defined destinations */
1129 int i
; /* Looping var */
1130 ipp_t
*request
, /* IPP Request */
1131 *response
; /* IPP Response */
1132 ipp_attribute_t
*attr
; /* Current attribute */
1133 const char *printer
, /* Printer name */
1134 *uri
, /* Printer URI */
1135 *device
, /* Printer device URI */
1136 *dptr
, /* Pointer into destination list */
1137 *ptr
; /* Pointer into printer name */
1138 int match
; /* Non-zero if this job matches */
1139 static const char *pattrs
[] = /* Attributes we need for printers... */
1142 "printer-uri-supported",
1147 DEBUG_printf(("show_devices(%p, %p)\n", http
, dests
));
1152 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1156 * Build a CUPS_GET_PRINTERS request, which requires the following
1159 * attributes-charset
1160 * attributes-natural-language
1161 * requested-attributes
1162 * requesting-user-name
1165 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1167 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1168 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1171 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1175 * Do the request and get back a response...
1178 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1180 DEBUG_puts("show_devices: request succeeded...");
1182 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1184 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1185 ippDelete(response
);
1190 * Loop through the printers returned in the list and display
1194 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1197 * Skip leading attributes until we hit a job...
1200 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1207 * Pull the needed attributes from this job...
1214 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1216 if (!strcmp(attr
->name
, "printer-name") &&
1217 attr
->value_tag
== IPP_TAG_NAME
)
1218 printer
= attr
->values
[0].string
.text
;
1220 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1221 attr
->value_tag
== IPP_TAG_URI
)
1222 uri
= attr
->values
[0].string
.text
;
1224 if (!strcmp(attr
->name
, "device-uri") &&
1225 attr
->value_tag
== IPP_TAG_URI
)
1226 device
= attr
->values
[0].string
.text
;
1232 * See if we have everything needed...
1235 if (printer
== NULL
)
1244 * See if this is a printer we're interested in...
1247 match
= printers
== NULL
;
1249 if (printers
!= NULL
)
1251 for (dptr
= printers
; *dptr
!= '\0';)
1254 * Skip leading whitespace and commas...
1257 while (isspace(*dptr
& 255) || *dptr
== ',')
1268 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1271 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1278 * Skip trailing junk...
1281 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1283 while (isspace(*dptr
& 255) || *dptr
== ',')
1292 * Display the printer entry if needed...
1297 #ifdef __osf__ /* Compaq/Digital like to do it their own way... */
1298 char method
[HTTP_MAX_URI
], /* Components of printer URI */
1299 username
[HTTP_MAX_URI
],
1300 hostname
[HTTP_MAX_URI
],
1301 resource
[HTTP_MAX_URI
];
1307 httpSeparate(uri
, method
, username
, hostname
, &port
, resource
);
1308 _cupsLangPrintf(stdout
,
1309 _("Output for printer %s is sent to remote "
1310 "printer %s on %s\n"),
1311 printer
, strrchr(resource
, '/') + 1, hostname
);
1313 else if (!strncmp(device
, "file:", 5))
1314 _cupsLangPrintf(stdout
,
1315 _("Output for printer %s is sent to %s\n"),
1316 printer
, device
+ 5);
1318 _cupsLangPrintf(stdout
,
1319 _("Output for printer %s is sent to %s\n"),
1322 for (i
= 0; i
< num_dests
; i
++)
1323 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1326 _cupsLangPrintf(stdout
,
1327 _("Output for printer %s/%s is sent to "
1328 "remote printer %s on %s\n"),
1329 printer
, dests
[i
].instance
,
1330 strrchr(resource
, '/') + 1, hostname
);
1331 else if (!strncmp(device
, "file:", 5))
1332 _cupsLangPrintf(stdout
,
1333 _("Output for printer %s/%s is sent to %s\n"),
1334 printer
, dests
[i
].instance
, device
+ 5);
1336 _cupsLangPrintf(stdout
,
1337 _("Output for printer %s/%s is sent to %s\n"),
1338 printer
, dests
[i
].instance
, device
);
1342 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1344 else if (!strncmp(device
, "file:", 5))
1345 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1346 printer
, device
+ 5);
1348 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1351 for (i
= 0; i
< num_dests
; i
++)
1352 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1355 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1356 printer
, dests
[i
].instance
, uri
);
1357 else if (!strncmp(device
, "file:", 5))
1358 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1359 printer
, dests
[i
].instance
, device
+ 5);
1361 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1362 printer
, dests
[i
].instance
, device
);
1364 #endif /* __osf__ */
1371 ippDelete(response
);
1375 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1384 * 'show_jobs()' - Show active print jobs.
1387 static int /* O - 0 on success, 1 on fail */
1388 show_jobs(http_t
*http
, /* I - HTTP connection to server */
1389 const char *dests
, /* I - Destinations */
1390 const char *users
, /* I - Users */
1391 int long_status
, /* I - Show long status? */
1392 int ranking
, /* I - Show job ranking? */
1393 const char *which
) /* I - Show which jobs? */
1395 ipp_t
*request
, /* IPP Request */
1396 *response
; /* IPP Response */
1397 ipp_attribute_t
*attr
; /* Current attribute */
1398 const char *dest
, /* Pointer into job-printer-uri */
1399 *username
, /* Pointer to job-originating-user-name */
1400 *title
; /* Pointer to job-name */
1401 int rank
, /* Rank in queue */
1403 size
; /* job-k-octets */
1404 time_t jobtime
; /* time-at-creation */
1405 struct tm
*jobdate
; /* Date & time */
1406 const char *dptr
, /* Pointer into destination list */
1407 *ptr
; /* Pointer into printer name */
1408 int match
; /* Non-zero if this job matches */
1409 char temp
[255], /* Temporary buffer */
1410 date
[255]; /* Date buffer */
1411 static const char *jattrs
[] = /* Attributes we need for jobs... */
1418 "job-originating-user-name"
1422 DEBUG_printf(("show_jobs(%p, %p, %p)\n", http
, dests
, users
));
1427 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1431 * Build a IPP_GET_JOBS request, which requires the following
1434 * attributes-charset
1435 * attributes-natural-language
1437 * requested-attributes
1440 request
= ippNewRequest(IPP_GET_JOBS
);
1442 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1443 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1446 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "job-uri",
1447 NULL
, "ipp://localhost/jobs/");
1449 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1453 * Do the request and get back a response...
1456 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1459 * Loop through the job list and display them...
1462 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1464 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1465 ippDelete(response
);
1471 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1474 * Skip leading attributes until we hit a job...
1477 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1484 * Pull the needed attributes from this job...
1494 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1496 if (!strcmp(attr
->name
, "job-id") &&
1497 attr
->value_tag
== IPP_TAG_INTEGER
)
1498 jobid
= attr
->values
[0].integer
;
1500 if (!strcmp(attr
->name
, "job-k-octets") &&
1501 attr
->value_tag
== IPP_TAG_INTEGER
)
1502 size
= attr
->values
[0].integer
;
1504 if (!strcmp(attr
->name
, "time-at-creation") &&
1505 attr
->value_tag
== IPP_TAG_INTEGER
)
1506 jobtime
= attr
->values
[0].integer
;
1508 if (!strcmp(attr
->name
, "job-printer-uri") &&
1509 attr
->value_tag
== IPP_TAG_URI
)
1510 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1513 if (!strcmp(attr
->name
, "job-originating-user-name") &&
1514 attr
->value_tag
== IPP_TAG_NAME
)
1515 username
= attr
->values
[0].string
.text
;
1517 if (!strcmp(attr
->name
, "job-name") &&
1518 attr
->value_tag
== IPP_TAG_NAME
)
1519 title
= attr
->values
[0].string
.text
;
1525 * See if we have everything needed...
1528 if (dest
== NULL
|| jobid
== 0)
1537 * See if this is a job we're interested in...
1540 match
= (dests
== NULL
&& users
== NULL
);
1545 for (dptr
= dests
; *dptr
!= '\0';)
1548 * Skip leading whitespace and commas...
1551 while (isspace(*dptr
& 255) || *dptr
== ',')
1562 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1565 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1572 * Skip trailing junk...
1575 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1577 while (isspace(*dptr
& 255) || *dptr
== ',')
1585 if (users
!= NULL
&& username
!= NULL
)
1587 for (dptr
= users
; *dptr
!= '\0';)
1590 * Skip leading whitespace and commas...
1593 while (isspace(*dptr
& 255) || *dptr
== ',')
1603 for (ptr
= username
;
1604 *ptr
!= '\0' && *dptr
!= '\0' && *ptr
== *dptr
;
1607 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1614 * Skip trailing junk...
1617 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1619 while (isspace(*dptr
& 255) || *dptr
== ',')
1628 * Display the job...
1633 jobdate
= localtime(&jobtime
);
1634 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1636 if (long_status
== 3)
1639 * Show the consolidated output format for the SGI tools...
1642 if (!strftime(date
, sizeof(date
), "%b %d %H:%M", jobdate
))
1643 strcpy(date
, "Unknown");
1645 _cupsLangPrintf(stdout
, "%s;%s;%d;%s;%s\n",
1646 temp
, username
? username
: "unknown",
1647 size
, title
? title
: "unknown", date
);
1651 if (!strftime(date
, sizeof(date
), "%c", jobdate
))
1652 strcpy(date
, "Unknown");
1655 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s\n",
1656 rank
, temp
, username
? username
: "unknown",
1657 1024.0 * size
, date
);
1659 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s\n",
1660 temp
, username
? username
: "unknown",
1661 1024.0 * size
, date
);
1663 _cupsLangPrintf(stdout
, _("\tqueued for %s\n"), dest
);
1671 ippDelete(response
);
1675 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1684 * 'show_printers()' - Show printers.
1687 static int /* O - 0 on success, 1 on fail */
1688 show_printers(http_t
*http
, /* I - HTTP connection to server */
1689 const char *printers
, /* I - Destinations */
1690 int num_dests
, /* I - Number of user-defined dests */
1691 cups_dest_t
*dests
, /* I - User-defined destinations */
1692 int long_status
) /* I - Show long status? */
1694 int i
; /* Looping var */
1695 ipp_t
*request
, /* IPP Request */
1696 *response
, /* IPP Response */
1697 *jobs
; /* IPP Get Jobs response */
1698 ipp_attribute_t
*attr
, /* Current attribute */
1699 *jobattr
, /* Job ID attribute */
1700 *reasons
; /* Job state reasons attribute */
1701 const char *printer
, /* Printer name */
1702 *message
, /* Printer state message */
1703 *description
, /* Description of printer */
1704 *location
, /* Location of printer */
1705 *make_model
, /* Make and model of printer */
1706 *uri
; /* URI of printer */
1707 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1708 *denied
; /* requestint-user-name-denied */
1709 ipp_pstate_t pstate
; /* Printer state */
1710 cups_ptype_t ptype
; /* Printer type */
1711 time_t ptime
; /* Printer state time */
1712 struct tm
*pdate
; /* Printer state date & time */
1713 int jobid
; /* Job ID of current job */
1714 const char *dptr
, /* Pointer into destination list */
1715 *ptr
; /* Pointer into printer name */
1716 int match
; /* Non-zero if this job matches */
1717 char printer_uri
[HTTP_MAX_URI
],
1719 printer_state_time
[255];/* Printer state time */
1720 const char *root
; /* Server root directory... */
1721 static const char *pattrs
[] = /* Attributes we need for printers... */
1725 "printer-state-message",
1726 "printer-state-reasons",
1727 "printer-state-change-time",
1731 "printer-make-and-model",
1732 "printer-uri-supported",
1733 "requesting-user-name-allowed",
1734 "requesting-user-name-denied"
1736 static const char *jattrs
[] = /* Attributes we need for jobs... */
1742 DEBUG_printf(("show_printers(%p, %p)\n", http
, dests
));
1747 if ((root
= getenv("CUPS_SERVERROOT")) == NULL
)
1748 root
= CUPS_SERVERROOT
;
1750 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1754 * Build a CUPS_GET_PRINTERS request, which requires the following
1757 * attributes-charset
1758 * attributes-natural-language
1759 * requested-attributes
1760 * requesting-user-name
1763 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1765 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1766 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1769 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1773 * Do the request and get back a response...
1776 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1778 DEBUG_puts("show_printers: request succeeded...");
1780 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1782 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1783 ippDelete(response
);
1788 * Loop through the printers returned in the list and display
1792 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1795 * Skip leading attributes until we hit a job...
1798 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1805 * Pull the needed attributes from this job...
1810 ptype
= CUPS_PRINTER_LOCAL
;
1811 pstate
= IPP_PRINTER_IDLE
;
1822 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1824 if (!strcmp(attr
->name
, "printer-name") &&
1825 attr
->value_tag
== IPP_TAG_NAME
)
1826 printer
= attr
->values
[0].string
.text
;
1827 else if (!strcmp(attr
->name
, "printer-state") &&
1828 attr
->value_tag
== IPP_TAG_ENUM
)
1829 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1830 else if (!strcmp(attr
->name
, "printer-type") &&
1831 attr
->value_tag
== IPP_TAG_ENUM
)
1832 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1833 else if (!strcmp(attr
->name
, "printer-state-message") &&
1834 attr
->value_tag
== IPP_TAG_TEXT
)
1835 message
= attr
->values
[0].string
.text
;
1836 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1837 attr
->value_tag
== IPP_TAG_INTEGER
)
1838 ptime
= (time_t)attr
->values
[0].integer
;
1839 else if (!strcmp(attr
->name
, "printer-info") &&
1840 attr
->value_tag
== IPP_TAG_TEXT
)
1841 description
= attr
->values
[0].string
.text
;
1842 else if (!strcmp(attr
->name
, "printer-location") &&
1843 attr
->value_tag
== IPP_TAG_TEXT
)
1844 location
= attr
->values
[0].string
.text
;
1845 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1846 attr
->value_tag
== IPP_TAG_TEXT
)
1847 make_model
= attr
->values
[0].string
.text
;
1848 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1849 attr
->value_tag
== IPP_TAG_URI
)
1850 uri
= attr
->values
[0].string
.text
;
1851 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1852 attr
->value_tag
== IPP_TAG_KEYWORD
)
1854 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1855 attr
->value_tag
== IPP_TAG_NAME
)
1857 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1858 attr
->value_tag
== IPP_TAG_NAME
)
1865 * See if we have everything needed...
1868 if (printer
== NULL
)
1877 * See if this is a printer we're interested in...
1880 match
= printers
== NULL
;
1882 if (printers
!= NULL
)
1884 for (dptr
= printers
; *dptr
!= '\0';)
1887 * Skip leading whitespace and commas...
1890 while (isspace(*dptr
& 255) || *dptr
== ',')
1901 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1904 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1911 * Skip trailing junk...
1914 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1916 while (isspace(*dptr
& 255) || *dptr
== ',')
1925 * Display the printer entry if needed...
1931 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1932 * current job for the printer.
1935 if (pstate
== IPP_PRINTER_PROCESSING
)
1938 * Build an IPP_GET_JOBS request, which requires the following
1941 * attributes-charset
1942 * attributes-natural-language
1945 * requested-attributes
1948 request
= ippNewRequest(IPP_GET_JOBS
);
1950 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1951 request
->request
.op
.request_id
= 1;
1953 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1954 "requested-attributes",
1955 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1957 httpAssembleURIf(printer_uri
, sizeof(printer_uri
), "ipp", NULL
,
1958 "localhost", 0, "/printers/%s", printer
);
1959 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1960 "printer-uri", NULL
, printer_uri
);
1962 if ((jobs
= cupsDoRequest(http
, request
, "/")) != NULL
)
1965 * Get the current active job on this queue...
1970 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1975 if (!strcmp(jobattr
->name
, "job-id") &&
1976 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1977 jobid
= jobattr
->values
[0].integer
;
1978 else if (!strcmp(jobattr
->name
, "job-state") &&
1979 jobattr
->value_tag
== IPP_TAG_ENUM
&&
1980 jobattr
->values
[0].integer
== IPP_JOB_PROCESSING
)
1992 pdate
= localtime(&ptime
);
1993 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
1997 case IPP_PRINTER_IDLE
:
1998 _cupsLangPrintf(stdout
,
1999 _("printer %s is idle. enabled since %s\n"),
2000 printer
, printer_state_time
);
2002 case IPP_PRINTER_PROCESSING
:
2003 _cupsLangPrintf(stdout
,
2004 _("printer %s now printing %s-%d. "
2005 "enabled since %s\n"),
2006 printer
, printer
, jobid
, printer_state_time
);
2008 case IPP_PRINTER_STOPPED
:
2009 _cupsLangPrintf(stdout
,
2010 _("printer %s disabled since %s -\n"),
2011 printer
, printer_state_time
);
2015 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
2017 if (!message
|| !*message
)
2018 _cupsLangPuts(stdout
, _("\treason unknown\n"));
2020 _cupsLangPrintf(stdout
, "\t%s\n", message
);
2023 if (long_status
> 1)
2024 _cupsLangPuts(stdout
,
2025 _("\tForm mounted:\n"
2026 "\tContent types: any\n"
2027 "\tPrinter types: unknown\n"));
2031 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
2032 description
? description
: "");
2036 _cupsLangPuts(stdout
, _("\tAlerts:"));
2037 for (i
= 0; i
< reasons
->num_values
; i
++)
2038 _cupsLangPrintf(stdout
, " %s",
2039 reasons
->values
[i
].string
.text
);
2040 _cupsLangPuts(stdout
, "\n");
2043 if (long_status
> 1)
2045 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
2046 location
? location
: "");
2048 if (ptype
& CUPS_PRINTER_REMOTE
)
2050 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
2052 if (make_model
&& !strstr(make_model
, "System V Printer") &&
2053 !strstr(make_model
, "Raw Printer") && uri
)
2054 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
2059 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
2061 if (make_model
&& strstr(make_model
, "System V Printer"))
2062 _cupsLangPrintf(stdout
,
2063 _("\tInterface: %s/interfaces/%s\n"),
2065 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
2066 _cupsLangPrintf(stdout
,
2067 _("\tInterface: %s/ppd/%s.ppd\n"), root
, printer
);
2069 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
2070 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
2071 // TODO update to use printer-error-policy
2074 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
2075 for (i
= 0; i
< allowed
->num_values
; i
++)
2076 _cupsLangPrintf(stdout
, "\t\t%s\n",
2077 allowed
->values
[i
].string
.text
);
2081 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
2082 for (i
= 0; i
< denied
->num_values
; i
++)
2083 _cupsLangPrintf(stdout
, "\t\t%s\n",
2084 denied
->values
[i
].string
.text
);
2088 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
2089 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
2091 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
2092 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
2093 _cupsLangPuts(stdout
, _("\tBanner required\n"));
2094 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
2095 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
2096 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
2097 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
2098 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
2101 for (i
= 0; i
< num_dests
; i
++)
2102 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
2106 case IPP_PRINTER_IDLE
:
2107 _cupsLangPrintf(stdout
,
2108 _("printer %s/%s is idle. "
2109 "enabled since %s\n"),
2110 printer
, dests
[i
].instance
,
2111 printer_state_time
);
2113 case IPP_PRINTER_PROCESSING
:
2114 _cupsLangPrintf(stdout
,
2115 _("printer %s/%s now printing %s-%d. "
2116 "enabled since %s\n"),
2117 printer
, dests
[i
].instance
, printer
, jobid
,
2118 printer_state_time
);
2120 case IPP_PRINTER_STOPPED
:
2121 _cupsLangPrintf(stdout
,
2122 _("printer %s/%s disabled since %s -\n"),
2123 printer
, dests
[i
].instance
,
2124 printer_state_time
);
2128 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
2130 if (!message
|| !*message
)
2131 _cupsLangPuts(stdout
, _("\treason unknown\n"));
2133 _cupsLangPrintf(stdout
, "\t%s\n", message
);
2136 if (long_status
> 1)
2137 _cupsLangPuts(stdout
,
2138 _("\tForm mounted:\n"
2139 "\tContent types: any\n"
2140 "\tPrinter types: unknown\n"));
2144 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
2145 description
? description
: "");
2149 _cupsLangPuts(stdout
, _("\tAlerts:"));
2150 for (i
= 0; i
< reasons
->num_values
; i
++)
2151 _cupsLangPrintf(stdout
, " %s",
2152 reasons
->values
[i
].string
.text
);
2153 _cupsLangPuts(stdout
, "\n");
2156 if (long_status
> 1)
2158 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
2159 location
? location
: "");
2161 if (ptype
& CUPS_PRINTER_REMOTE
)
2163 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
2165 if (make_model
&& !strstr(make_model
, "System V Printer") &&
2166 !strstr(make_model
, "Raw Printer") && uri
)
2167 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
2172 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
2174 if (make_model
&& strstr(make_model
, "System V Printer"))
2175 _cupsLangPrintf(stdout
,
2176 _("\tInterface: %s/interfaces/%s\n"),
2178 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
2179 _cupsLangPrintf(stdout
,
2180 _("\tInterface: %s/ppd/%s.ppd\n"), root
, printer
);
2182 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
2183 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
2184 // TODO update to use printer-error-policy
2187 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
2188 for (i
= 0; i
< allowed
->num_values
; i
++)
2189 _cupsLangPrintf(stdout
, "\t\t%s\n",
2190 allowed
->values
[i
].string
.text
);
2194 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
2195 for (i
= 0; i
< denied
->num_values
; i
++)
2196 _cupsLangPrintf(stdout
, "\t\t%s\n",
2197 denied
->values
[i
].string
.text
);
2201 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
2202 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
2204 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
2205 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
2206 _cupsLangPuts(stdout
, _("\tBanner required\n"));
2207 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
2208 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
2209 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
2210 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
2211 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
2220 ippDelete(response
);
2224 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
2233 * 'show_scheduler()' - Show scheduler status.
2237 show_scheduler(http_t
*http
) /* I - HTTP connection to server */
2240 _cupsLangPuts(stdout
, _("scheduler is running\n"));
2242 _cupsLangPuts(stdout
, _("scheduler is not running\n"));
2247 * End of "$Id: lpstat.c 4948 2006-01-19 03:23:41Z mike $".