2 * "$Id: lpstat.c 4922 2006-01-12 22:05:06Z 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(http_t
*, const char *, int *, cups_dest_t
**);
56 static http_t
*connect_server(http_t
*);
57 static int show_accepting(http_t
*, const char *, int, cups_dest_t
*);
58 static int show_classes(http_t
*, const char *);
59 static void show_default(int, cups_dest_t
*);
60 static int show_devices(http_t
*, const char *, int, cups_dest_t
*);
61 static int show_jobs(http_t
*, const char *, const char *, int, int,
63 static int show_printers(http_t
*, const char *, int, cups_dest_t
*, int);
64 static void show_scheduler(http_t
*);
68 * 'main()' - Parse options and show status information.
72 main(int argc
, /* I - Number of command-line arguments */
73 char *argv
[]) /* I - Command-line arguments */
75 int i
, /* Looping var */
76 status
; /* Exit status */
77 http_t
*http
; /* Connection to server */
78 int num_dests
; /* Number of user destinations */
79 cups_dest_t
*dests
; /* User destinations */
80 int long_status
; /* Long status report? */
81 int ranking
; /* Show job ranking? */
82 const char *which
; /* Which jobs to show? */
83 char op
; /* Last operation on command-line */
87 setlocale(LC_TIME
, "");
96 which
= "not-completed";
99 for (i
= 1; i
< argc
; i
++)
100 if (argv
[i
][0] == '-')
103 case 'D' : /* Show description */
107 case 'E' : /* Encrypt */
109 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
112 httpEncryption(http
, HTTP_ENCRYPT_REQUIRED
);
114 _cupsLangPrintf(stderr
, NULL
,
115 _("%s: Sorry, no encryption support compiled in!\n"),
117 #endif /* HAVE_SSL */
120 case 'P' : /* Show paper types */
124 case 'R' : /* Show ranking */
128 case 'S' : /* Show charsets */
134 case 'W' : /* Show which jobs? */
143 _cupsLangPuts(stderr
, NULL
,
144 _("lpstat: Need \"completed\" or "
145 "\"not-completed\" after -W!\n"));
152 if (strcmp(which
, "completed") && strcmp(which
, "not-completed"))
154 _cupsLangPuts(stderr
, NULL
,
155 _("lpstat: Need \"completed\" or "
156 "\"not-completed\" after -W!\n"));
161 case 'a' : /* Show acceptance status */
163 http
= connect_server(http
);
165 if (argv
[i
][2] != '\0')
167 check_dest(http
, argv
[i
] + 2, &num_dests
, &dests
);
169 status
|= show_accepting(http
, argv
[i
] + 2, num_dests
, dests
);
171 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
175 check_dest(http
, argv
[i
], &num_dests
, &dests
);
177 status
|= show_accepting(http
, argv
[i
], num_dests
, dests
);
182 num_dests
= cupsGetDests2(http
, &dests
);
184 status
|= show_accepting(http
, NULL
, num_dests
, dests
);
189 case 'b' : /* Show both the local and remote status */
191 http
= connect_server(http
);
193 if (argv
[i
][2] != '\0')
196 * The local and remote status are separated by a blank line;
197 * since all CUPS jobs are networked, we only output the
198 * second list for now... In the future, we might further
199 * emulate this by listing the remote server's queue, but
200 * for now this is enough to make the SGI printstatus program
204 check_dest(http
, argv
[i
] + 2, &num_dests
, &dests
);
207 status
|= show_jobs(http
, argv
[i
] + 2, NULL
, 3, ranking
, which
);
211 _cupsLangPuts(stderr
, NULL
,
212 _("lpstat: The -b option requires a destination "
220 case 'c' : /* Show classes and members */
222 http
= connect_server(http
);
224 if (argv
[i
][2] != '\0')
226 check_dest(http
, argv
[i
] + 2, &num_dests
, &dests
);
228 status
|= show_classes(http
, argv
[i
] + 2);
230 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
234 check_dest(http
, argv
[i
], &num_dests
, &dests
);
236 status
|= show_classes(http
, argv
[i
]);
239 status
|= show_classes(http
, NULL
);
242 case 'd' : /* Show default destination */
244 http
= connect_server(http
);
247 num_dests
= cupsGetDests2(http
, &dests
);
249 show_default(num_dests
, dests
);
252 case 'f' : /* Show forms */
258 case 'h' : /* Connect to host */
265 if (argv
[i
][2] != '\0')
266 cupsSetServer(argv
[i
] + 2);
273 _cupsLangPuts(stderr
, NULL
,
274 _("Error: need hostname after \'-h\' option!\n"));
278 cupsSetServer(argv
[i
]);
282 case 'l' : /* Long status or long job status */
285 http
= connect_server(http
);
287 if (argv
[i
][2] != '\0')
289 check_dest(http
, argv
[i
] + 2, &num_dests
, &dests
);
291 status
|= show_jobs(http
, argv
[i
] + 2, NULL
, 3, ranking
, which
);
298 case 'o' : /* Show jobs by destination */
300 http
= connect_server(http
);
302 if (argv
[i
][2] != '\0')
304 check_dest(http
, argv
[i
] + 2, &num_dests
, &dests
);
306 status
|= show_jobs(http
, argv
[i
] + 2, NULL
, long_status
,
309 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
313 check_dest(http
, argv
[i
], &num_dests
, &dests
);
315 status
|= show_jobs(http
, argv
[i
], NULL
, long_status
,
319 status
|= show_jobs(http
, NULL
, NULL
, long_status
,
323 case 'p' : /* Show printers */
325 http
= connect_server(http
);
327 if (argv
[i
][2] != '\0')
329 check_dest(http
, argv
[i
] + 2, &num_dests
, &dests
);
331 status
|= show_printers(http
, argv
[i
] + 2, num_dests
, dests
, long_status
);
333 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
337 check_dest(http
, argv
[i
], &num_dests
, &dests
);
339 status
|= show_printers(http
, argv
[i
], num_dests
, dests
, long_status
);
344 num_dests
= cupsGetDests2(http
, &dests
);
346 status
|= show_printers(http
, NULL
, num_dests
, dests
, long_status
);
350 case 'r' : /* Show scheduler status */
352 http
= connect_server(http
);
354 show_scheduler(http
);
357 case 's' : /* Show summary */
359 http
= connect_server(http
);
362 num_dests
= cupsGetDests2(http
, &dests
);
364 show_default(num_dests
, dests
);
365 status
|= show_classes(http
, NULL
);
366 status
|= show_devices(http
, NULL
, num_dests
, dests
);
369 case 't' : /* Show all info */
371 http
= connect_server(http
);
374 num_dests
= cupsGetDests2(http
, &dests
);
376 show_scheduler(http
);
377 show_default(num_dests
, dests
);
378 status
|= show_classes(http
, NULL
);
379 status
|= show_devices(http
, NULL
, num_dests
, dests
);
380 status
|= show_accepting(http
, NULL
, num_dests
, dests
);
381 status
|= show_printers(http
, NULL
, num_dests
, dests
, long_status
);
382 status
|= show_jobs(http
, NULL
, NULL
, long_status
, ranking
, which
);
385 case 'u' : /* Show jobs by user */
387 http
= connect_server(http
);
389 if (argv
[i
][2] != '\0')
390 status
|= show_jobs(http
, NULL
, argv
[i
] + 2, long_status
,
392 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
395 status
|= show_jobs(http
, NULL
, argv
[i
], long_status
,
399 status
|= show_jobs(http
, NULL
, NULL
, long_status
,
403 case 'v' : /* Show printer devices */
405 http
= connect_server(http
);
407 if (argv
[i
][2] != '\0')
409 check_dest(http
, argv
[i
] + 2, &num_dests
, &dests
);
411 status
|= show_devices(http
, argv
[i
] + 2, num_dests
, dests
);
413 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
417 check_dest(http
, argv
[i
], &num_dests
, &dests
);
419 status
|= show_devices(http
, argv
[i
], num_dests
, dests
);
424 num_dests
= cupsGetDests2(http
, &dests
);
426 status
|= show_devices(http
, NULL
, num_dests
, dests
);
432 _cupsLangPrintf(stderr
, NULL
,
433 _("lpstat: Unknown option \'%c\'!\n"), argv
[i
][1]);
438 http
= connect_server(http
);
440 status
|= show_jobs(http
, argv
[i
], NULL
, long_status
, ranking
, which
);
446 http
= connect_server(http
);
448 status
|= show_jobs(http
, NULL
, cupsUser(), long_status
, ranking
, which
);
456 * 'check_dest()' - Verify that the named destination(s) exists.
460 check_dest(http_t
*http
, /* I - HTTP connection */
461 const char *name
, /* I - Name of printer/class(es) */
462 int *num_dests
, /* IO - Number of destinations */
463 cups_dest_t
**dests
) /* IO - Destinations */
471 * Load the destination list as necessary...
475 *num_dests
= cupsGetDests2(http
, dests
);
478 * Scan the name string for printer/class name(s)...
481 for (dptr
= name
; *dptr
!= '\0';)
484 * Skip leading whitespace and commas...
487 while (isspace(*dptr
& 255) || *dptr
== ',')
494 * Extract a single destination name from the name string...
497 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0';)
499 if ((pptr
- printer
) < (sizeof(printer
) - 1))
503 _cupsLangPrintf(stderr
, NULL
,
504 _("lpstat: Invalid destination name in list \"%s\"!\n"),
513 * Check the destination...
516 if (cupsGetDest(printer
, NULL
, *num_dests
, *dests
) == NULL
)
518 _cupsLangPrintf(stderr
, NULL
,
519 _("lpstat: Unknown destination \"%s\"!\n"), printer
);
527 * 'connect_server()' - Connect to the server as necessary...
530 static http_t
* /* O - New HTTP connection */
531 connect_server(http_t
*http
) /* I - Current HTTP connection */
535 http
= httpConnectEncrypt(cupsServer(), ippPort(),
540 _cupsLangPrintf(stderr
, NULL
,
541 _("lpstat: Unable to connect to server %s on port %d: %s\n"),
542 cupsServer(), ippPort(), strerror(errno
));
552 * 'show_accepting()' - Show acceptance status.
555 static int /* O - 0 on success, 1 on fail */
556 show_accepting(http_t
*http
, /* I - HTTP connection to server */
557 const char *printers
, /* I - Destinations */
558 int num_dests
, /* I - Number of user-defined dests */
559 cups_dest_t
*dests
) /* I - User-defined destinations */
561 int i
; /* Looping var */
562 ipp_t
*request
, /* IPP Request */
563 *response
; /* IPP Response */
564 ipp_attribute_t
*attr
; /* Current attribute */
565 const char *printer
, /* Printer name */
566 *message
; /* Printer device URI */
567 int accepting
; /* Accepting requests? */
568 const char *dptr
, /* Pointer into destination list */
569 *ptr
; /* Pointer into printer name */
570 int match
; /* Non-zero if this job matches */
571 static const char *pattrs
[] = /* Attributes we need for printers... */
574 "printer-state-message",
575 "printer-is-accepting-jobs"
579 DEBUG_printf(("show_accepting(%p, %p)\n", http
, printers
));
584 if (printers
!= NULL
&& strcmp(printers
, "all") == 0)
588 * Build a CUPS_GET_PRINTERS request, which requires the following
592 * attributes-natural-language
593 * requested-attributes
596 request
= ippNewRequest(CUPS_GET_PRINTERS
);
598 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
599 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
603 * Do the request and get back a response...
606 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
608 DEBUG_puts("show_accepting: request succeeded...");
610 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
612 _cupsLangPrintf(stderr
, NULL
,
613 _("lpstat: get-printers failed: %s\n"),
614 ippErrorString(response
->request
.status
.status_code
));
620 * Loop through the printers returned in the list and display
624 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
627 * Skip leading attributes until we hit a printer...
630 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
637 * Pull the needed attributes from this printer...
644 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
646 if (!strcmp(attr
->name
, "printer-name") &&
647 attr
->value_tag
== IPP_TAG_NAME
)
648 printer
= attr
->values
[0].string
.text
;
650 if (!strcmp(attr
->name
, "printer-state-message") &&
651 attr
->value_tag
== IPP_TAG_TEXT
)
652 message
= attr
->values
[0].string
.text
;
654 if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
655 attr
->value_tag
== IPP_TAG_BOOLEAN
)
656 accepting
= attr
->values
[0].boolean
;
662 * See if we have everything needed...
674 * See if this is a printer we're interested in...
677 match
= printers
== NULL
;
679 if (printers
!= NULL
)
681 for (dptr
= printers
; *dptr
!= '\0';)
684 * Skip leading whitespace and commas...
687 while (isspace(*dptr
& 255) || *dptr
== ',')
698 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
701 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
708 * Skip trailing junk...
711 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
713 while (isspace(*dptr
& 255) || *dptr
== ',')
722 * Display the printer entry if needed...
728 _cupsLangPrintf(stdout
, NULL
,
729 _("%s accepting requests since Jan 01 00:00\n"),
732 _cupsLangPrintf(stdout
, NULL
,
733 _("%s not accepting requests since Jan 01 00:00 -\n"
735 printer
, message
== NULL
? "reason unknown" : message
);
737 for (i
= 0; i
< num_dests
; i
++)
738 if (!strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
741 _cupsLangPrintf(stdout
, NULL
,
742 _("%s/%s accepting requests since Jan 01 00:00\n"),
743 printer
, dests
[i
].instance
);
745 _cupsLangPrintf(stdout
, NULL
,
746 _("%s/%s not accepting requests since "
747 "Jan 01 00:00 -\n\t%s\n"),
748 printer
, dests
[i
].instance
,
749 message
== NULL
? "reason unknown" : message
);
761 _cupsLangPrintf(stderr
, NULL
, _("lpstat: get-printers failed: %s\n"),
762 ippErrorString(cupsLastError()));
771 * 'show_classes()' - Show printer classes.
774 static int /* O - 0 on success, 1 on fail */
775 show_classes(http_t
*http
, /* I - HTTP connection to server */
776 const char *dests
) /* I - Destinations */
778 int i
; /* Looping var */
779 ipp_t
*request
, /* IPP Request */
780 *response
, /* IPP Response */
781 *response2
; /* IPP response from remote server */
782 http_t
*http2
; /* Remote server */
783 ipp_attribute_t
*attr
; /* Current attribute */
784 const char *printer
, /* Printer class name */
785 *printer_uri
; /* Printer class URI */
786 ipp_attribute_t
*members
; /* Printer members */
787 char method
[HTTP_MAX_URI
], /* Request method */
788 username
[HTTP_MAX_URI
], /* Username:password */
789 server
[HTTP_MAX_URI
], /* Server name */
790 resource
[HTTP_MAX_URI
]; /* Resource name */
791 int port
; /* Port number */
792 const char *dptr
, /* Pointer into destination list */
793 *ptr
; /* Pointer into printer name */
794 int match
; /* Non-zero if this job matches */
795 static const char *cattrs
[] = /* Attributes we need for classes... */
798 "printer-uri-supported",
803 DEBUG_printf(("show_classes(%p, %p)\n", http
, dests
));
808 if (dests
!= NULL
&& strcmp(dests
, "all") == 0)
812 * Build a CUPS_GET_CLASSES request, which requires the following
816 * attributes-natural-language
817 * requested-attributes
820 request
= ippNewRequest(CUPS_GET_CLASSES
);
822 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
823 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
827 * Do the request and get back a response...
830 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
832 DEBUG_puts("show_classes: request succeeded...");
834 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
836 _cupsLangPrintf(stderr
, NULL
,
837 _("lpstat: get-classes failed: %s\n"),
838 ippErrorString(response
->request
.status
.status_code
));
844 * Loop through the printers returned in the list and display
848 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
851 * Skip leading attributes until we hit a job...
854 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
861 * Pull the needed attributes from this job...
868 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
870 if (!strcmp(attr
->name
, "printer-name") &&
871 attr
->value_tag
== IPP_TAG_NAME
)
872 printer
= attr
->values
[0].string
.text
;
874 if (!strcmp(attr
->name
, "printer-uri-supported") &&
875 attr
->value_tag
== IPP_TAG_URI
)
876 printer_uri
= attr
->values
[0].string
.text
;
878 if (!strcmp(attr
->name
, "member-names") &&
879 attr
->value_tag
== IPP_TAG_NAME
)
886 * If this is a remote class, grab the class info from the
891 if (members
== NULL
&& printer_uri
!= NULL
)
893 httpSeparateURI(printer_uri
, method
, sizeof(method
),
894 username
, sizeof(username
), server
, sizeof(server
),
895 &port
, resource
, sizeof(resource
));
897 if (!strcasecmp(server
, http
->hostname
))
900 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
905 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
906 * following attributes:
909 * attributes-natural-language
911 * requested-attributes
914 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
916 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
917 "printer-uri", NULL
, printer_uri
);
919 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
920 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
923 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
924 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
932 * See if we have everything needed...
938 ippDelete(response2
);
947 * See if this is a printer we're interested in...
950 match
= dests
== NULL
;
954 for (dptr
= dests
; *dptr
!= '\0';)
957 * Skip leading whitespace and commas...
960 while (isspace(*dptr
& 255) || *dptr
== ',')
971 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
974 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
981 * Skip trailing junk...
984 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
986 while (isspace(*dptr
& 255) || *dptr
== ',')
995 * Display the printer entry if needed...
1000 _cupsLangPrintf(stdout
, NULL
, _("members of class %s:\n"), printer
);
1004 for (i
= 0; i
< members
->num_values
; i
++)
1005 _cupsLangPrintf(stdout
, NULL
, "\t%s\n",
1006 members
->values
[i
].string
.text
);
1009 _cupsLangPuts(stdout
, NULL
, "\tunknown\n");
1013 ippDelete(response2
);
1019 ippDelete(response
);
1023 _cupsLangPrintf(stderr
, NULL
, _("lpstat: get-classes failed: %s\n"),
1024 ippErrorString(cupsLastError()));
1033 * 'show_default()' - Show default destination.
1037 show_default(int num_dests
, /* I - Number of user-defined dests */
1038 cups_dest_t
*dests
) /* I - User-defined destinations */
1040 cups_dest_t
*dest
; /* Destination */
1041 const char *printer
, /* Printer name */
1042 *val
; /* Environment variable name */
1044 if ((dest
= cupsGetDest(NULL
, NULL
, num_dests
, dests
)) != NULL
)
1047 _cupsLangPrintf(stdout
, NULL
, _("system default destination: %s/%s\n"),
1048 dest
->name
, dest
->instance
);
1050 _cupsLangPrintf(stdout
, NULL
, _("system default destination: %s\n"),
1057 if ((printer
= getenv("LPDEST")) == NULL
)
1059 if ((printer
= getenv("PRINTER")) != NULL
)
1061 if (!strcmp(printer
, "lp"))
1070 if (printer
&& !cupsGetDest(printer
, NULL
, num_dests
, dests
))
1071 _cupsLangPrintf(stdout
, NULL
,
1072 _("lpstat: error - %s environment variable names "
1073 "non-existent destination \"%s\"!\n"),
1076 _cupsLangPuts(stdout
, NULL
, _("no system default destination\n"));
1082 * 'show_devices()' - Show printer devices.
1085 static int /* O - 0 on success, 1 on fail */
1086 show_devices(http_t
*http
, /* I - HTTP connection to server */
1087 const char *printers
, /* I - Destinations */
1088 int num_dests
, /* I - Number of user-defined dests */
1089 cups_dest_t
*dests
) /* I - User-defined destinations */
1091 int i
; /* Looping var */
1092 ipp_t
*request
, /* IPP Request */
1093 *response
; /* IPP Response */
1094 ipp_attribute_t
*attr
; /* Current attribute */
1095 const char *printer
, /* Printer name */
1096 *uri
, /* Printer URI */
1097 *device
, /* Printer device URI */
1098 *dptr
, /* Pointer into destination list */
1099 *ptr
; /* Pointer into printer name */
1100 int match
; /* Non-zero if this job matches */
1101 static const char *pattrs
[] = /* Attributes we need for printers... */
1104 "printer-uri-supported",
1109 DEBUG_printf(("show_devices(%p, %p)\n", http
, dests
));
1114 if (printers
!= NULL
&& strcmp(printers
, "all") == 0)
1118 * Build a CUPS_GET_PRINTERS request, which requires the following
1121 * attributes-charset
1122 * attributes-natural-language
1123 * requested-attributes
1126 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1128 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1129 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1133 * Do the request and get back a response...
1136 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1138 DEBUG_puts("show_devices: request succeeded...");
1140 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1142 _cupsLangPrintf(stderr
, NULL
, _("lpstat: get-printers failed: %s\n"),
1143 ippErrorString(response
->request
.status
.status_code
));
1144 ippDelete(response
);
1149 * Loop through the printers returned in the list and display
1153 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1156 * Skip leading attributes until we hit a job...
1159 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1166 * Pull the needed attributes from this job...
1173 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1175 if (!strcmp(attr
->name
, "printer-name") &&
1176 attr
->value_tag
== IPP_TAG_NAME
)
1177 printer
= attr
->values
[0].string
.text
;
1179 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1180 attr
->value_tag
== IPP_TAG_URI
)
1181 uri
= attr
->values
[0].string
.text
;
1183 if (!strcmp(attr
->name
, "device-uri") &&
1184 attr
->value_tag
== IPP_TAG_URI
)
1185 device
= attr
->values
[0].string
.text
;
1191 * See if we have everything needed...
1194 if (printer
== NULL
)
1203 * See if this is a printer we're interested in...
1206 match
= printers
== NULL
;
1208 if (printers
!= NULL
)
1210 for (dptr
= printers
; *dptr
!= '\0';)
1213 * Skip leading whitespace and commas...
1216 while (isspace(*dptr
& 255) || *dptr
== ',')
1227 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1230 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1237 * Skip trailing junk...
1240 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1242 while (isspace(*dptr
& 255) || *dptr
== ',')
1251 * Display the printer entry if needed...
1256 #ifdef __osf__ /* Compaq/Digital like to do it their own way... */
1257 char method
[HTTP_MAX_URI
], /* Components of printer URI */
1258 username
[HTTP_MAX_URI
],
1259 hostname
[HTTP_MAX_URI
],
1260 resource
[HTTP_MAX_URI
];
1266 httpSeparate(uri
, method
, username
, hostname
, &port
, resource
);
1267 _cupsLangPrintf(stdout
, NULL
,
1268 _("Output for printer %s is sent to remote "
1269 "printer %s on %s\n"),
1270 printer
, strrchr(resource
, '/') + 1, hostname
);
1272 else if (strncmp(device
, "file:", 5) == 0)
1273 _cupsLangPrintf(stdout
, NULL
,
1274 _("Output for printer %s is sent to %s\n"),
1275 printer
, device
+ 5);
1277 _cupsLangPrintf(stdout
, NULL
,
1278 _("Output for printer %s is sent to %s\n"),
1281 for (i
= 0; i
< num_dests
; i
++)
1282 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1285 _cupsLangPrintf(stdout
, NULL
,
1286 _("Output for printer %s/%s is sent to "
1287 "remote printer %s on %s\n"),
1288 printer
, dests
[i
].instance
,
1289 strrchr(resource
, '/') + 1, hostname
);
1290 else if (!strncmp(device
, "file:", 5))
1291 _cupsLangPrintf(stdout
, NULL
,
1292 _("Output for printer %s/%s is sent to %s\n"),
1293 printer
, dests
[i
].instance
, device
+ 5);
1295 _cupsLangPrintf(stdout
, NULL
,
1296 _("Output for printer %s/%s is sent to %s\n"),
1297 printer
, dests
[i
].instance
, device
);
1301 _cupsLangPrintf(stdout
, NULL
, _("device for %s: %s\n"),
1303 else if (!strncmp(device
, "file:", 5))
1304 _cupsLangPrintf(stdout
, NULL
, _("device for %s: %s\n"),
1305 printer
, device
+ 5);
1307 _cupsLangPrintf(stdout
, NULL
, _("device for %s: %s\n"),
1310 for (i
= 0; i
< num_dests
; i
++)
1311 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1314 _cupsLangPrintf(stdout
, NULL
, _("device for %s/%s: %s\n"),
1315 printer
, dests
[i
].instance
, uri
);
1316 else if (!strncmp(device
, "file:", 5))
1317 _cupsLangPrintf(stdout
, NULL
, _("device for %s/%s: %s\n"),
1318 printer
, dests
[i
].instance
, device
+ 5);
1320 _cupsLangPrintf(stdout
, NULL
, _("device for %s/%s: %s\n"),
1321 printer
, dests
[i
].instance
, device
);
1323 #endif /* __osf__ */
1330 ippDelete(response
);
1334 _cupsLangPrintf(stderr
, NULL
, _("lpstat: get-printers failed: %s\n"),
1335 ippErrorString(cupsLastError()));
1344 * 'show_jobs()' - Show active print jobs.
1347 static int /* O - 0 on success, 1 on fail */
1348 show_jobs(http_t
*http
, /* I - HTTP connection to server */
1349 const char *dests
, /* I - Destinations */
1350 const char *users
, /* I - Users */
1351 int long_status
, /* I - Show long status? */
1352 int ranking
, /* I - Show job ranking? */
1353 const char *which
) /* I - Show which jobs? */
1355 ipp_t
*request
, /* IPP Request */
1356 *response
; /* IPP Response */
1357 ipp_attribute_t
*attr
; /* Current attribute */
1358 const char *dest
, /* Pointer into job-printer-uri */
1359 *username
, /* Pointer to job-originating-user-name */
1360 *title
; /* Pointer to job-name */
1361 int rank
, /* Rank in queue */
1363 size
; /* job-k-octets */
1364 time_t jobtime
; /* time-at-creation */
1365 struct tm
*jobdate
; /* Date & time */
1366 const char *dptr
, /* Pointer into destination list */
1367 *ptr
; /* Pointer into printer name */
1368 int match
; /* Non-zero if this job matches */
1369 char temp
[255], /* Temporary buffer */
1370 date
[255]; /* Date buffer */
1371 static const char *jattrs
[] = /* Attributes we need for jobs... */
1378 "job-originating-user-name"
1382 DEBUG_printf(("show_jobs(%p, %p, %p)\n", http
, dests
, users
));
1387 if (dests
!= NULL
&& strcmp(dests
, "all") == 0)
1391 * Build a IPP_GET_JOBS request, which requires the following
1394 * attributes-charset
1395 * attributes-natural-language
1397 * requested-attributes
1400 request
= ippNewRequest(IPP_GET_JOBS
);
1402 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1403 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1406 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "job-uri",
1407 NULL
, "ipp://localhost/jobs/");
1409 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1413 * Do the request and get back a response...
1416 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1419 * Loop through the job list and display them...
1422 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1424 _cupsLangPrintf(stderr
, NULL
, _("lpstat: get-jobs failed: %s\n"),
1425 ippErrorString(response
->request
.status
.status_code
));
1426 ippDelete(response
);
1432 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1435 * Skip leading attributes until we hit a job...
1438 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1445 * Pull the needed attributes from this job...
1455 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1457 if (strcmp(attr
->name
, "job-id") == 0 &&
1458 attr
->value_tag
== IPP_TAG_INTEGER
)
1459 jobid
= attr
->values
[0].integer
;
1461 if (strcmp(attr
->name
, "job-k-octets") == 0 &&
1462 attr
->value_tag
== IPP_TAG_INTEGER
)
1463 size
= attr
->values
[0].integer
;
1465 if (strcmp(attr
->name
, "time-at-creation") == 0 &&
1466 attr
->value_tag
== IPP_TAG_INTEGER
)
1467 jobtime
= attr
->values
[0].integer
;
1469 if (strcmp(attr
->name
, "job-printer-uri") == 0 &&
1470 attr
->value_tag
== IPP_TAG_URI
)
1471 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1474 if (strcmp(attr
->name
, "job-originating-user-name") == 0 &&
1475 attr
->value_tag
== IPP_TAG_NAME
)
1476 username
= attr
->values
[0].string
.text
;
1478 if (strcmp(attr
->name
, "job-name") == 0 &&
1479 attr
->value_tag
== IPP_TAG_NAME
)
1480 title
= attr
->values
[0].string
.text
;
1486 * See if we have everything needed...
1489 if (dest
== NULL
|| jobid
== 0)
1498 * See if this is a job we're interested in...
1501 match
= (dests
== NULL
&& users
== NULL
);
1506 for (dptr
= dests
; *dptr
!= '\0';)
1509 * Skip leading whitespace and commas...
1512 while (isspace(*dptr
& 255) || *dptr
== ',')
1523 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1526 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1533 * Skip trailing junk...
1536 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1538 while (isspace(*dptr
& 255) || *dptr
== ',')
1546 if (users
!= NULL
&& username
!= NULL
)
1548 for (dptr
= users
; *dptr
!= '\0';)
1551 * Skip leading whitespace and commas...
1554 while (isspace(*dptr
& 255) || *dptr
== ',')
1564 for (ptr
= username
;
1565 *ptr
!= '\0' && *dptr
!= '\0' && *ptr
== *dptr
;
1568 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1575 * Skip trailing junk...
1578 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1580 while (isspace(*dptr
& 255) || *dptr
== ',')
1589 * Display the job...
1594 jobdate
= localtime(&jobtime
);
1595 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1597 if (long_status
== 3)
1600 * Show the consolidated output format for the SGI tools...
1603 if (!strftime(date
, sizeof(date
), "%b %d %H:%M", jobdate
))
1604 strcpy(date
, "Unknown");
1606 _cupsLangPrintf(stdout
, NULL
, "%s;%s;%d;%s;%s\n",
1607 temp
, username
? username
: "unknown",
1608 size
, title
? title
: "unknown", date
);
1612 if (!strftime(date
, sizeof(date
), "%c", jobdate
))
1613 strcpy(date
, "Unknown");
1616 _cupsLangPrintf(stdout
, NULL
, "%3d %-21s %-13s %8.0f %s\n",
1617 rank
, temp
, username
? username
: "unknown",
1618 1024.0 * size
, date
);
1620 _cupsLangPrintf(stdout
, NULL
, "%-23s %-13s %8.0f %s\n",
1621 temp
, username
? username
: "unknown",
1622 1024.0 * size
, date
);
1624 _cupsLangPrintf(stdout
, NULL
, _("\tqueued for %s\n"), dest
);
1632 ippDelete(response
);
1636 _cupsLangPrintf(stderr
, NULL
, _("lpstat: get-jobs failed: %s\n"),
1637 ippErrorString(cupsLastError()));
1646 * 'show_printers()' - Show printers.
1649 static int /* O - 0 on success, 1 on fail */
1650 show_printers(http_t
*http
, /* I - HTTP connection to server */
1651 const char *printers
, /* I - Destinations */
1652 int num_dests
, /* I - Number of user-defined dests */
1653 cups_dest_t
*dests
, /* I - User-defined destinations */
1654 int long_status
) /* I - Show long status? */
1656 int i
; /* Looping var */
1657 ipp_t
*request
, /* IPP Request */
1658 *response
, /* IPP Response */
1659 *jobs
; /* IPP Get Jobs response */
1660 ipp_attribute_t
*attr
, /* Current attribute */
1661 *jobattr
, /* Job ID attribute */
1662 *reasons
; /* Job state reasons attribute */
1663 const char *printer
, /* Printer name */
1664 *message
, /* Printer state message */
1665 *description
, /* Description of printer */
1666 *location
, /* Location of printer */
1667 *make_model
, /* Make and model of printer */
1668 *uri
; /* URI of printer */
1669 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1670 *denied
; /* requestint-user-name-denied */
1671 ipp_pstate_t pstate
; /* Printer state */
1672 cups_ptype_t ptype
; /* Printer type */
1673 time_t ptime
; /* Printer state time */
1674 struct tm
*pdate
; /* Printer state date & time */
1675 int jobid
; /* Job ID of current job */
1676 const char *dptr
, /* Pointer into destination list */
1677 *ptr
; /* Pointer into printer name */
1678 int match
; /* Non-zero if this job matches */
1679 char printer_uri
[HTTP_MAX_URI
],
1681 printer_state_time
[255];/* Printer state time */
1682 const char *root
; /* Server root directory... */
1683 static const char *pattrs
[] = /* Attributes we need for printers... */
1687 "printer-state-message",
1688 "printer-state-reasons",
1689 "printer-state-change-time",
1693 "printer-make-and-model",
1694 "printer-uri-supported",
1695 "requesting-user-name-allowed",
1696 "requesting-user-name-denied"
1698 static const char *jattrs
[] = /* Attributes we need for jobs... */
1704 DEBUG_printf(("show_printers(%p, %p)\n", http
, dests
));
1709 if ((root
= getenv("CUPS_SERVERROOT")) == NULL
)
1710 root
= CUPS_SERVERROOT
;
1712 if (printers
!= NULL
&& strcmp(printers
, "all") == 0)
1716 * Build a CUPS_GET_PRINTERS request, which requires the following
1719 * attributes-charset
1720 * attributes-natural-language
1721 * requested-attributes
1724 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1726 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1727 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1731 * Do the request and get back a response...
1734 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1736 DEBUG_puts("show_printers: request succeeded...");
1738 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1740 _cupsLangPrintf(stderr
, NULL
, _("lpstat: get-printers failed: %s\n"),
1741 ippErrorString(response
->request
.status
.status_code
));
1742 ippDelete(response
);
1747 * Loop through the printers returned in the list and display
1751 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1754 * Skip leading attributes until we hit a job...
1757 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1764 * Pull the needed attributes from this job...
1769 ptype
= CUPS_PRINTER_LOCAL
;
1770 pstate
= IPP_PRINTER_IDLE
;
1781 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1783 if (!strcmp(attr
->name
, "printer-name") &&
1784 attr
->value_tag
== IPP_TAG_NAME
)
1785 printer
= attr
->values
[0].string
.text
;
1786 else if (!strcmp(attr
->name
, "printer-state") &&
1787 attr
->value_tag
== IPP_TAG_ENUM
)
1788 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1789 else if (!strcmp(attr
->name
, "printer-type") &&
1790 attr
->value_tag
== IPP_TAG_ENUM
)
1791 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1792 else if (!strcmp(attr
->name
, "printer-state-message") &&
1793 attr
->value_tag
== IPP_TAG_TEXT
)
1794 message
= attr
->values
[0].string
.text
;
1795 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1796 attr
->value_tag
== IPP_TAG_INTEGER
)
1797 ptime
= (time_t)attr
->values
[0].integer
;
1798 else if (!strcmp(attr
->name
, "printer-info") &&
1799 attr
->value_tag
== IPP_TAG_TEXT
)
1800 description
= attr
->values
[0].string
.text
;
1801 else if (!strcmp(attr
->name
, "printer-location") &&
1802 attr
->value_tag
== IPP_TAG_TEXT
)
1803 location
= attr
->values
[0].string
.text
;
1804 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1805 attr
->value_tag
== IPP_TAG_TEXT
)
1806 make_model
= attr
->values
[0].string
.text
;
1807 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1808 attr
->value_tag
== IPP_TAG_URI
)
1809 uri
= attr
->values
[0].string
.text
;
1810 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1811 attr
->value_tag
== IPP_TAG_KEYWORD
)
1813 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1814 attr
->value_tag
== IPP_TAG_NAME
)
1816 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1817 attr
->value_tag
== IPP_TAG_NAME
)
1824 * See if we have everything needed...
1827 if (printer
== NULL
)
1836 * See if this is a printer we're interested in...
1839 match
= printers
== NULL
;
1841 if (printers
!= NULL
)
1843 for (dptr
= printers
; *dptr
!= '\0';)
1846 * Skip leading whitespace and commas...
1849 while (isspace(*dptr
& 255) || *dptr
== ',')
1860 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1863 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1870 * Skip trailing junk...
1873 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1875 while (isspace(*dptr
& 255) || *dptr
== ',')
1884 * Display the printer entry if needed...
1890 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1891 * current job for the printer.
1894 if (pstate
== IPP_PRINTER_PROCESSING
)
1897 * Build an IPP_GET_JOBS request, which requires the following
1900 * attributes-charset
1901 * attributes-natural-language
1904 * requested-attributes
1907 request
= ippNewRequest(IPP_GET_JOBS
);
1909 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1910 request
->request
.op
.request_id
= 1;
1912 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1913 "requested-attributes",
1914 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1916 httpAssembleURIf(printer_uri
, sizeof(printer_uri
), "ipp", NULL
,
1917 "localhost", 0, "/printers/%s", printer
);
1918 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1919 "printer-uri", NULL
, printer_uri
);
1921 if ((jobs
= cupsDoRequest(http
, request
, "/")) != NULL
)
1924 * Get the current active job on this queue...
1929 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
1934 if (!strcmp(jobattr
->name
, "job-id") &&
1935 jobattr
->value_tag
== IPP_TAG_INTEGER
)
1936 jobid
= jobattr
->values
[0].integer
;
1937 else if (!strcmp(jobattr
->name
, "job-state") &&
1938 jobattr
->value_tag
== IPP_TAG_ENUM
&&
1939 jobattr
->values
[0].integer
== IPP_JOB_PROCESSING
)
1951 pdate
= localtime(&ptime
);
1952 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
1956 case IPP_PRINTER_IDLE
:
1957 _cupsLangPrintf(stdout
, NULL
,
1958 _("printer %s is idle. enabled since %s\n"),
1959 printer
, printer_state_time
);
1961 case IPP_PRINTER_PROCESSING
:
1962 _cupsLangPrintf(stdout
, NULL
,
1963 _("printer %s now printing %s-%d. "
1964 "enabled since %s\n"),
1965 printer
, printer
, jobid
, printer_state_time
);
1967 case IPP_PRINTER_STOPPED
:
1968 _cupsLangPrintf(stdout
, NULL
,
1969 _("printer %s disabled since %s -\n"),
1970 printer
, printer_state_time
);
1974 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
1976 if (!message
|| !*message
)
1977 _cupsLangPuts(stdout
, NULL
, _("\treason unknown\n"));
1979 _cupsLangPrintf(stdout
, NULL
, "\t%s\n", message
);
1982 if (long_status
> 1)
1983 _cupsLangPuts(stdout
, NULL
,
1984 _("\tForm mounted:\n"
1985 "\tContent types: any\n"
1986 "\tPrinter types: unknown\n"));
1990 _cupsLangPrintf(stdout
, NULL
, _("\tDescription: %s\n"),
1991 description
? description
: "");
1995 _cupsLangPuts(stdout
, NULL
, _("\tAlerts:"));
1996 for (i
= 0; i
< reasons
->num_values
; i
++)
1997 _cupsLangPrintf(stdout
, NULL
, " %s",
1998 reasons
->values
[i
].string
.text
);
1999 _cupsLangPuts(stdout
, NULL
, "\n");
2002 if (long_status
> 1)
2004 _cupsLangPrintf(stdout
, NULL
, _("\tLocation: %s\n"),
2005 location
? location
: "");
2007 if (ptype
& CUPS_PRINTER_REMOTE
)
2009 _cupsLangPuts(stdout
, NULL
, _("\tConnection: remote\n"));
2011 if (make_model
&& !strstr(make_model
, "System V Printer") &&
2012 !strstr(make_model
, "Raw Printer") && uri
)
2013 _cupsLangPrintf(stdout
, NULL
, _("\tInterface: %s.ppd\n"),
2018 _cupsLangPuts(stdout
, NULL
, _("\tConnection: direct\n"));
2020 if (make_model
&& strstr(make_model
, "System V Printer"))
2021 _cupsLangPrintf(stdout
, NULL
,
2022 _("\tInterface: %s/interfaces/%s\n"),
2024 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
2025 _cupsLangPrintf(stdout
, NULL
,
2026 _("\tInterface: %s/ppd/%s.ppd\n"), root
, printer
);
2028 _cupsLangPuts(stdout
, NULL
, _("\tOn fault: no alert\n"));
2029 _cupsLangPuts(stdout
, NULL
, _("\tAfter fault: continue\n"));
2030 // TODO update to use printer-error-policy
2033 _cupsLangPuts(stdout
, NULL
, _("\tUsers allowed:\n"));
2034 for (i
= 0; i
< allowed
->num_values
; i
++)
2035 _cupsLangPrintf(stdout
, NULL
, "\t\t%s\n",
2036 allowed
->values
[i
].string
.text
);
2040 _cupsLangPuts(stdout
, NULL
, _("\tUsers denied:\n"));
2041 for (i
= 0; i
< denied
->num_values
; i
++)
2042 _cupsLangPrintf(stdout
, NULL
, "\t\t%s\n",
2043 denied
->values
[i
].string
.text
);
2047 _cupsLangPuts(stdout
, NULL
, _("\tUsers allowed:\n"));
2048 _cupsLangPuts(stdout
, NULL
, _("\t\t(all)\n"));
2050 _cupsLangPuts(stdout
, NULL
, _("\tForms allowed:\n"));
2051 _cupsLangPuts(stdout
, NULL
, _("\t\t(none)\n"));
2052 _cupsLangPuts(stdout
, NULL
, _("\tBanner required\n"));
2053 _cupsLangPuts(stdout
, NULL
, _("\tCharset sets:\n"));
2054 _cupsLangPuts(stdout
, NULL
, _("\t\t(none)\n"));
2055 _cupsLangPuts(stdout
, NULL
, _("\tDefault pitch:\n"));
2056 _cupsLangPuts(stdout
, NULL
, _("\tDefault page size:\n"));
2057 _cupsLangPuts(stdout
, NULL
, _("\tDefault port settings:\n"));
2060 for (i
= 0; i
< num_dests
; i
++)
2061 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
2065 case IPP_PRINTER_IDLE
:
2066 _cupsLangPrintf(stdout
, NULL
,
2067 _("printer %s/%s is idle. "
2068 "enabled since %s\n"),
2069 printer
, dests
[i
].instance
,
2070 printer_state_time
);
2072 case IPP_PRINTER_PROCESSING
:
2073 _cupsLangPrintf(stdout
, NULL
,
2074 _("printer %s/%s now printing %s-%d. "
2075 "enabled since %s\n"),
2076 printer
, dests
[i
].instance
, printer
, jobid
,
2077 printer_state_time
);
2079 case IPP_PRINTER_STOPPED
:
2080 _cupsLangPrintf(stdout
, NULL
,
2081 _("printer %s/%s disabled since %s -\n"),
2082 printer
, dests
[i
].instance
,
2083 printer_state_time
);
2087 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
2089 if (!message
|| !*message
)
2090 _cupsLangPuts(stdout
, NULL
, _("\treason unknown\n"));
2092 _cupsLangPrintf(stdout
, NULL
, "\t%s\n", message
);
2095 if (long_status
> 1)
2096 _cupsLangPuts(stdout
, NULL
,
2097 _("\tForm mounted:\n"
2098 "\tContent types: any\n"
2099 "\tPrinter types: unknown\n"));
2103 _cupsLangPrintf(stdout
, NULL
, _("\tDescription: %s\n"),
2104 description
? description
: "");
2108 _cupsLangPuts(stdout
, NULL
, _("\tAlerts:"));
2109 for (i
= 0; i
< reasons
->num_values
; i
++)
2110 _cupsLangPrintf(stdout
, NULL
, " %s",
2111 reasons
->values
[i
].string
.text
);
2112 _cupsLangPuts(stdout
, NULL
, "\n");
2115 if (long_status
> 1)
2117 _cupsLangPrintf(stdout
, NULL
, _("\tLocation: %s\n"),
2118 location
? location
: "");
2120 if (ptype
& CUPS_PRINTER_REMOTE
)
2122 _cupsLangPuts(stdout
, NULL
, _("\tConnection: remote\n"));
2124 if (make_model
&& !strstr(make_model
, "System V Printer") &&
2125 !strstr(make_model
, "Raw Printer") && uri
)
2126 _cupsLangPrintf(stdout
, NULL
, _("\tInterface: %s.ppd\n"),
2131 _cupsLangPuts(stdout
, NULL
, _("\tConnection: direct\n"));
2133 if (make_model
&& strstr(make_model
, "System V Printer"))
2134 _cupsLangPrintf(stdout
, NULL
,
2135 _("\tInterface: %s/interfaces/%s\n"),
2137 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
2138 _cupsLangPrintf(stdout
, NULL
,
2139 _("\tInterface: %s/ppd/%s.ppd\n"), root
, printer
);
2141 _cupsLangPuts(stdout
, NULL
, _("\tOn fault: no alert\n"));
2142 _cupsLangPuts(stdout
, NULL
, _("\tAfter fault: continue\n"));
2143 // TODO update to use printer-error-policy
2146 _cupsLangPuts(stdout
, NULL
, _("\tUsers allowed:\n"));
2147 for (i
= 0; i
< allowed
->num_values
; i
++)
2148 _cupsLangPrintf(stdout
, NULL
, "\t\t%s\n",
2149 allowed
->values
[i
].string
.text
);
2153 _cupsLangPuts(stdout
, NULL
, _("\tUsers denied:\n"));
2154 for (i
= 0; i
< denied
->num_values
; i
++)
2155 _cupsLangPrintf(stdout
, NULL
, "\t\t%s\n",
2156 denied
->values
[i
].string
.text
);
2160 _cupsLangPuts(stdout
, NULL
, _("\tUsers allowed:\n"));
2161 _cupsLangPuts(stdout
, NULL
, _("\t\t(all)\n"));
2163 _cupsLangPuts(stdout
, NULL
, _("\tForms allowed:\n"));
2164 _cupsLangPuts(stdout
, NULL
, _("\t\t(none)\n"));
2165 _cupsLangPuts(stdout
, NULL
, _("\tBanner required\n"));
2166 _cupsLangPuts(stdout
, NULL
, _("\tCharset sets:\n"));
2167 _cupsLangPuts(stdout
, NULL
, _("\t\t(none)\n"));
2168 _cupsLangPuts(stdout
, NULL
, _("\tDefault pitch:\n"));
2169 _cupsLangPuts(stdout
, NULL
, _("\tDefault page size:\n"));
2170 _cupsLangPuts(stdout
, NULL
, _("\tDefault port settings:\n"));
2179 ippDelete(response
);
2183 _cupsLangPrintf(stderr
, NULL
, _("lpstat: get-printers failed: %s\n"),
2184 ippErrorString(cupsLastError()));
2193 * 'show_scheduler()' - Show scheduler status.
2197 show_scheduler(http_t
*http
) /* I - HTTP connection to server */
2200 _cupsLangPuts(stdout
, NULL
, _("scheduler is running\n"));
2202 _cupsLangPuts(stdout
, NULL
, _("scheduler is not running\n"));
2207 * End of "$Id: lpstat.c 4922 2006-01-12 22:05:06Z mike $".