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/http-private.h>
46 #include <cups/string.h>
47 #include <cups/cups.h>
48 #include <cups/i18n.h>
49 #include <cups/debug.h>
56 static void check_dest(const char *, http_t
*, const char *, int *,
58 static http_t
*connect_server(const char *, http_t
*);
59 static int show_accepting(http_t
*, const char *, int, cups_dest_t
*);
60 static int show_classes(http_t
*, const char *);
61 static void show_default(int, cups_dest_t
*);
62 static int show_devices(http_t
*, const char *, int, cups_dest_t
*);
63 static int show_jobs(http_t
*, const char *, const char *, int, int,
65 static int show_printers(http_t
*, const char *, int, cups_dest_t
*, int);
66 static void show_scheduler(http_t
*);
70 * 'main()' - Parse options and show status information.
74 main(int argc
, /* I - Number of command-line arguments */
75 char *argv
[]) /* I - Command-line arguments */
77 int i
, /* Looping var */
78 status
; /* Exit status */
79 http_t
*http
; /* Connection to server */
80 int num_dests
; /* Number of user destinations */
81 cups_dest_t
*dests
; /* User destinations */
82 int long_status
; /* Long status report? */
83 int ranking
; /* Show job ranking? */
84 const char *which
; /* Which jobs to show? */
85 char op
; /* Last operation on command-line */
89 * Set the locale so that times, etc. are displayed properly.
91 * Unfortunately, while we need the localized time value, we *don't*
92 * want to use the localized charset for the time value, so we need
93 * to set LC_TIME to the locale name with .UTF-8 on the end (if
94 * the locale includes a character set specifier...)
97 setlocale(LC_ALL
, "");
101 const char *lc_time
; /* Current LC_TIME value */
102 char new_lc_time
[255], /* New LC_TIME value */
103 *charset
; /* Pointer to character set */
105 if ((lc_time
= setlocale(LC_TIME
, NULL
)) == NULL
)
106 lc_time
= setlocale(LC_ALL
, NULL
);
110 strlcpy(new_lc_time
, lc_time
, sizeof(new_lc_time
));
111 if ((charset
= strchr(new_lc_time
, '.')) == NULL
)
112 charset
= new_lc_time
+ strlen(new_lc_time
);
114 strlcpy(charset
, ".UTF-8", sizeof(new_lc_time
) - (charset
- new_lc_time
));
117 strcpy(new_lc_time
, "C");
119 setlocale(LC_TIME
, new_lc_time
);
124 * Parse command-line options...
133 which
= "not-completed";
136 for (i
= 1; i
< argc
; i
++)
137 if (argv
[i
][0] == '-')
140 case 'D' : /* Show description */
144 case 'E' : /* Encrypt */
146 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
149 httpEncryption(http
, HTTP_ENCRYPT_REQUIRED
);
151 _cupsLangPrintf(stderr
,
152 _("%s: Sorry, no encryption support compiled in!\n"),
154 #endif /* HAVE_SSL */
157 case 'P' : /* Show paper types */
161 case 'R' : /* Show ranking */
165 case 'S' : /* Show charsets */
171 case 'U' : /* Username */
172 if (argv
[i
][2] != '\0')
173 cupsSetUser(argv
[i
] + 2);
179 _cupsLangPrintf(stderr
,
180 _("%s: Error - expected username after "
186 cupsSetUser(argv
[i
]);
190 case 'W' : /* Show which jobs? */
199 _cupsLangPrintf(stderr
,
200 _("%s: Error - need \"completed\", "
201 "\"not-completed\", or \"all\" after "
210 if (strcmp(which
, "completed") && strcmp(which
, "not-completed") &&
211 strcmp(which
, "all"))
213 _cupsLangPrintf(stderr
,
214 _("%s: Error - need \"completed\", "
215 "\"not-completed\", or \"all\" after "
222 case 'a' : /* Show acceptance status */
224 http
= connect_server(argv
[0], http
);
226 if (argv
[i
][2] != '\0')
228 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
230 status
|= show_accepting(http
, argv
[i
] + 2, num_dests
, dests
);
232 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
236 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
238 status
|= show_accepting(http
, argv
[i
], num_dests
, dests
);
243 num_dests
= cupsGetDests2(http
, &dests
);
245 status
|= show_accepting(http
, NULL
, num_dests
, dests
);
250 case 'b' : /* Show both the local and remote status */
252 http
= connect_server(argv
[0], http
);
254 if (argv
[i
][2] != '\0')
257 * The local and remote status are separated by a blank line;
258 * since all CUPS jobs are networked, we only output the
259 * second list for now... In the future, we might further
260 * emulate this by listing the remote server's queue, but
261 * for now this is enough to make the SGI printstatus program
265 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
268 status
|= show_jobs(http
, argv
[i
] + 2, NULL
, 3, ranking
, which
);
272 _cupsLangPrintf(stderr
,
273 _("%s: Error - expected destination after "
282 case 'c' : /* Show classes and members */
284 http
= connect_server(argv
[0], http
);
286 if (argv
[i
][2] != '\0')
288 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
290 status
|= show_classes(http
, argv
[i
] + 2);
292 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
296 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
298 status
|= show_classes(http
, argv
[i
]);
301 status
|= show_classes(http
, NULL
);
304 case 'd' : /* Show default destination */
306 http
= connect_server(argv
[0], http
);
309 num_dests
= cupsGetDests2(http
, &dests
);
311 show_default(num_dests
, dests
);
314 case 'f' : /* Show forms */
320 case 'h' : /* Connect to host */
327 if (argv
[i
][2] != '\0')
328 cupsSetServer(argv
[i
] + 2);
335 _cupsLangPrintf(stderr
,
336 _("%s: Error - expected hostname after "
342 cupsSetServer(argv
[i
]);
346 case 'l' : /* Long status or long job status */
349 http
= connect_server(argv
[0], http
);
351 if (argv
[i
][2] != '\0')
353 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
355 status
|= show_jobs(http
, argv
[i
] + 2, NULL
, 3, ranking
, which
);
362 case 'o' : /* Show jobs by destination */
364 http
= connect_server(argv
[0], http
);
366 if (argv
[i
][2] != '\0')
368 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
370 status
|= show_jobs(http
, argv
[i
] + 2, NULL
, long_status
,
373 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
377 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
379 status
|= show_jobs(http
, argv
[i
], NULL
, long_status
,
383 status
|= show_jobs(http
, NULL
, NULL
, long_status
,
387 case 'p' : /* Show printers */
389 http
= connect_server(argv
[0], http
);
391 if (argv
[i
][2] != '\0')
393 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
395 status
|= show_printers(http
, argv
[i
] + 2, num_dests
, dests
, long_status
);
397 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
401 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
403 status
|= show_printers(http
, argv
[i
], num_dests
, dests
, long_status
);
408 num_dests
= cupsGetDests2(http
, &dests
);
410 status
|= show_printers(http
, NULL
, num_dests
, dests
, long_status
);
414 case 'r' : /* Show scheduler status */
416 http
= connect_server(argv
[0], http
);
418 show_scheduler(http
);
421 case 's' : /* Show summary */
423 http
= connect_server(argv
[0], http
);
426 num_dests
= cupsGetDests2(http
, &dests
);
428 show_default(num_dests
, dests
);
429 status
|= show_classes(http
, NULL
);
430 status
|= show_devices(http
, NULL
, num_dests
, dests
);
433 case 't' : /* Show all info */
435 http
= connect_server(argv
[0], http
);
438 num_dests
= cupsGetDests2(http
, &dests
);
440 show_scheduler(http
);
441 show_default(num_dests
, dests
);
442 status
|= show_classes(http
, NULL
);
443 status
|= show_devices(http
, NULL
, num_dests
, dests
);
444 status
|= show_accepting(http
, NULL
, num_dests
, dests
);
445 status
|= show_printers(http
, NULL
, num_dests
, dests
, long_status
);
446 status
|= show_jobs(http
, NULL
, NULL
, long_status
, ranking
, which
);
449 case 'u' : /* Show jobs by user */
451 http
= connect_server(argv
[0], http
);
453 if (argv
[i
][2] != '\0')
454 status
|= show_jobs(http
, NULL
, argv
[i
] + 2, long_status
,
456 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
459 status
|= show_jobs(http
, NULL
, argv
[i
], long_status
,
463 status
|= show_jobs(http
, NULL
, NULL
, long_status
,
467 case 'v' : /* Show printer devices */
469 http
= connect_server(argv
[0], http
);
471 if (argv
[i
][2] != '\0')
473 check_dest(argv
[0], http
, argv
[i
] + 2, &num_dests
, &dests
);
475 status
|= show_devices(http
, argv
[i
] + 2, num_dests
, dests
);
477 else if ((i
+ 1) < argc
&& argv
[i
+ 1][0] != '-')
481 check_dest(argv
[0], http
, argv
[i
], &num_dests
, &dests
);
483 status
|= show_devices(http
, argv
[i
], num_dests
, dests
);
488 num_dests
= cupsGetDests2(http
, &dests
);
490 status
|= show_devices(http
, NULL
, num_dests
, dests
);
496 _cupsLangPrintf(stderr
,
497 _("%s: Error - unknown option \'%c\'!\n"),
498 argv
[0], argv
[i
][1]);
503 http
= connect_server(argv
[0], http
);
505 status
|= show_jobs(http
, argv
[i
], NULL
, long_status
, ranking
, which
);
511 http
= connect_server(argv
[0], http
);
513 status
|= show_jobs(http
, NULL
, cupsUser(), long_status
, ranking
, which
);
521 * 'check_dest()' - Verify that the named destination(s) exists.
525 check_dest(const char *command
, /* I - Command name */
526 http_t
*http
, /* I - HTTP connection */
527 const char *name
, /* I - Name of printer/class(es) */
528 int *num_dests
, /* IO - Number of destinations */
529 cups_dest_t
**dests
) /* IO - Destinations */
537 * Load the destination list as necessary...
541 *num_dests
= cupsGetDests2(http
, dests
);
544 * Scan the name string for printer/class name(s)...
547 for (dptr
= name
; *dptr
!= '\0';)
550 * Skip leading whitespace and commas...
553 while (isspace(*dptr
& 255) || *dptr
== ',')
560 * Extract a single destination name from the name string...
563 for (pptr
= printer
; !isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0';)
565 if ((pptr
- printer
) < (sizeof(printer
) - 1))
569 _cupsLangPrintf(stderr
,
570 _("%s: Invalid destination name in list \"%s\"!\n"),
579 * Check the destination...
582 if (cupsGetDest(printer
, NULL
, *num_dests
, *dests
) == NULL
)
584 _cupsLangPrintf(stderr
,
585 _("%s: Unknown destination \"%s\"!\n"), command
, printer
);
593 * 'connect_server()' - Connect to the server as necessary...
596 static http_t
* /* O - New HTTP connection */
597 connect_server(const char *command
, /* I - Command name */
598 http_t
*http
) /* I - Current HTTP connection */
602 http
= httpConnectEncrypt(cupsServer(), ippPort(),
607 _cupsLangPrintf(stderr
, _("%s: Unable to connect to server\n"), command
);
617 * 'show_accepting()' - Show acceptance status.
620 static int /* O - 0 on success, 1 on fail */
621 show_accepting(http_t
*http
, /* I - HTTP connection to server */
622 const char *printers
, /* I - Destinations */
623 int num_dests
, /* I - Number of user-defined dests */
624 cups_dest_t
*dests
) /* I - User-defined destinations */
626 int i
; /* Looping var */
627 ipp_t
*request
, /* IPP Request */
628 *response
; /* IPP Response */
629 ipp_attribute_t
*attr
; /* Current attribute */
630 const char *printer
, /* Printer name */
631 *message
; /* Printer device URI */
632 int accepting
; /* Accepting requests? */
633 time_t ptime
; /* Printer state time */
634 struct tm
*pdate
; /* Printer state date & time */
635 char printer_state_time
[255];/* Printer state time */
636 const char *dptr
, /* Pointer into destination list */
637 *ptr
; /* Pointer into printer name */
638 int match
; /* Non-zero if this job matches */
639 static const char *pattrs
[] = /* Attributes we need for printers... */
642 "printer-state-change-time",
643 "printer-state-message",
644 "printer-is-accepting-jobs"
648 DEBUG_printf(("show_accepting(%p, %p)\n", http
, printers
));
653 if (printers
!= NULL
&& !strcmp(printers
, "all"))
657 * Build a CUPS_GET_PRINTERS request, which requires the following
661 * attributes-natural-language
662 * requested-attributes
663 * requesting-user-name
666 request
= ippNewRequest(CUPS_GET_PRINTERS
);
668 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
669 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
672 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
676 * Do the request and get back a response...
679 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
681 DEBUG_puts("show_accepting: request succeeded...");
683 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
685 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
691 * Loop through the printers returned in the list and display
695 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
698 * Skip leading attributes until we hit a printer...
701 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
708 * Pull the needed attributes from this printer...
716 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
718 if (!strcmp(attr
->name
, "printer-name") &&
719 attr
->value_tag
== IPP_TAG_NAME
)
720 printer
= attr
->values
[0].string
.text
;
721 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
722 attr
->value_tag
== IPP_TAG_INTEGER
)
723 ptime
= (time_t)attr
->values
[0].integer
;
724 else if (!strcmp(attr
->name
, "printer-state-message") &&
725 attr
->value_tag
== IPP_TAG_TEXT
)
726 message
= attr
->values
[0].string
.text
;
727 else if (!strcmp(attr
->name
, "printer-is-accepting-jobs") &&
728 attr
->value_tag
== IPP_TAG_BOOLEAN
)
729 accepting
= attr
->values
[0].boolean
;
735 * See if we have everything needed...
747 * See if this is a printer we're interested in...
750 match
= printers
== NULL
;
752 if (printers
!= NULL
)
754 for (dptr
= printers
; *dptr
!= '\0';)
757 * Skip leading whitespace and commas...
760 while (isspace(*dptr
& 255) || *dptr
== ',')
771 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
774 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
781 * Skip trailing junk...
784 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
786 while (isspace(*dptr
& 255) || *dptr
== ',')
795 * Display the printer entry if needed...
800 pdate
= localtime(&ptime
);
801 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
804 _cupsLangPrintf(stdout
, _("%s accepting requests since %s\n"),
805 printer
, printer_state_time
);
807 _cupsLangPrintf(stdout
, _("%s not accepting requests since %s -\n"
809 printer
, printer_state_time
,
810 message
== NULL
? "reason unknown" : message
);
812 for (i
= 0; i
< num_dests
; i
++)
813 if (!strcasecmp(dests
[i
].name
, printer
) && dests
[i
].instance
)
816 _cupsLangPrintf(stdout
, _("%s/%s accepting requests since %s\n"),
817 printer
, dests
[i
].instance
, printer_state_time
);
819 _cupsLangPrintf(stdout
, _("%s/%s not accepting requests since "
821 printer
, dests
[i
].instance
, printer_state_time
,
822 message
== NULL
? "reason unknown" : message
);
834 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
843 * 'show_classes()' - Show printer classes.
846 static int /* O - 0 on success, 1 on fail */
847 show_classes(http_t
*http
, /* I - HTTP connection to server */
848 const char *dests
) /* I - Destinations */
850 int i
; /* Looping var */
851 ipp_t
*request
, /* IPP Request */
852 *response
, /* IPP Response */
853 *response2
; /* IPP response from remote server */
854 http_t
*http2
; /* Remote server */
855 ipp_attribute_t
*attr
; /* Current attribute */
856 const char *printer
, /* Printer class name */
857 *printer_uri
; /* Printer class URI */
858 ipp_attribute_t
*members
; /* Printer members */
859 char method
[HTTP_MAX_URI
], /* Request method */
860 username
[HTTP_MAX_URI
], /* Username:password */
861 server
[HTTP_MAX_URI
], /* Server name */
862 resource
[HTTP_MAX_URI
]; /* Resource name */
863 int port
; /* Port number */
864 const char *dptr
, /* Pointer into destination list */
865 *ptr
; /* Pointer into printer name */
866 int match
; /* Non-zero if this job matches */
867 static const char *cattrs
[] = /* Attributes we need for classes... */
870 "printer-uri-supported",
875 DEBUG_printf(("show_classes(%p, %p)\n", http
, dests
));
880 if (dests
!= NULL
&& !strcmp(dests
, "all"))
884 * Build a CUPS_GET_CLASSES request, which requires the following
888 * attributes-natural-language
889 * requested-attributes
890 * requesting-user-name
893 request
= ippNewRequest(CUPS_GET_CLASSES
);
895 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
896 "requested-attributes", sizeof(cattrs
) / sizeof(cattrs
[0]),
899 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
903 * Do the request and get back a response...
906 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
908 DEBUG_puts("show_classes: request succeeded...");
910 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
912 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
918 * Loop through the printers returned in the list and display
922 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
925 * Skip leading attributes until we hit a job...
928 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
935 * Pull the needed attributes from this job...
942 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
944 if (!strcmp(attr
->name
, "printer-name") &&
945 attr
->value_tag
== IPP_TAG_NAME
)
946 printer
= attr
->values
[0].string
.text
;
948 if (!strcmp(attr
->name
, "printer-uri-supported") &&
949 attr
->value_tag
== IPP_TAG_URI
)
950 printer_uri
= attr
->values
[0].string
.text
;
952 if (!strcmp(attr
->name
, "member-names") &&
953 attr
->value_tag
== IPP_TAG_NAME
)
960 * If this is a remote class, grab the class info from the
965 if (members
== NULL
&& printer_uri
!= NULL
)
967 httpSeparateURI(HTTP_URI_CODING_ALL
, printer_uri
, method
, sizeof(method
),
968 username
, sizeof(username
), server
, sizeof(server
),
969 &port
, resource
, sizeof(resource
));
971 if (!strcasecmp(server
, http
->hostname
))
974 http2
= httpConnectEncrypt(server
, port
, cupsEncryption());
979 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the
980 * following attributes:
983 * attributes-natural-language
985 * requested-attributes
988 request
= ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES
);
990 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
991 "printer-uri", NULL
, printer_uri
);
993 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
994 "requested-attributes",
995 sizeof(cattrs
) / sizeof(cattrs
[0]),
998 if ((response2
= cupsDoRequest(http2
, request
, "/")) != NULL
)
999 members
= ippFindAttribute(response2
, "member-names", IPP_TAG_NAME
);
1007 * See if we have everything needed...
1010 if (printer
== NULL
)
1013 ippDelete(response2
);
1022 * See if this is a printer we're interested in...
1025 match
= dests
== NULL
;
1029 for (dptr
= dests
; *dptr
!= '\0';)
1032 * Skip leading whitespace and commas...
1035 while (isspace(*dptr
& 255) || *dptr
== ',')
1046 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1049 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1056 * Skip trailing junk...
1059 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1061 while (isspace(*dptr
& 255) || *dptr
== ',')
1070 * Display the printer entry if needed...
1075 _cupsLangPrintf(stdout
, _("members of class %s:\n"), printer
);
1079 for (i
= 0; i
< members
->num_values
; i
++)
1080 _cupsLangPrintf(stdout
, "\t%s\n",
1081 members
->values
[i
].string
.text
);
1084 _cupsLangPuts(stdout
, "\tunknown\n");
1088 ippDelete(response2
);
1094 ippDelete(response
);
1098 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1107 * 'show_default()' - Show default destination.
1111 show_default(int num_dests
, /* I - Number of user-defined dests */
1112 cups_dest_t
*dests
) /* I - User-defined destinations */
1114 cups_dest_t
*dest
; /* Destination */
1115 const char *printer
, /* Printer name */
1116 *val
; /* Environment variable name */
1118 if ((dest
= cupsGetDest(NULL
, NULL
, num_dests
, dests
)) != NULL
)
1121 _cupsLangPrintf(stdout
, _("system default destination: %s/%s\n"),
1122 dest
->name
, dest
->instance
);
1124 _cupsLangPrintf(stdout
, _("system default destination: %s\n"),
1131 if ((printer
= getenv("LPDEST")) == NULL
)
1133 if ((printer
= getenv("PRINTER")) != NULL
)
1135 if (!strcmp(printer
, "lp"))
1144 if (printer
&& !cupsGetDest(printer
, NULL
, num_dests
, dests
))
1145 _cupsLangPrintf(stdout
,
1146 _("lpstat: error - %s environment variable names "
1147 "non-existent destination \"%s\"!\n"),
1150 _cupsLangPuts(stdout
, _("no system default destination\n"));
1156 * 'show_devices()' - Show printer devices.
1159 static int /* O - 0 on success, 1 on fail */
1160 show_devices(http_t
*http
, /* I - HTTP connection to server */
1161 const char *printers
, /* I - Destinations */
1162 int num_dests
, /* I - Number of user-defined dests */
1163 cups_dest_t
*dests
) /* I - User-defined destinations */
1165 int i
; /* Looping var */
1166 ipp_t
*request
, /* IPP Request */
1167 *response
; /* IPP Response */
1168 ipp_attribute_t
*attr
; /* Current attribute */
1169 const char *printer
, /* Printer name */
1170 *uri
, /* Printer URI */
1171 *device
, /* Printer device URI */
1172 *dptr
, /* Pointer into destination list */
1173 *ptr
; /* Pointer into printer name */
1174 int match
; /* Non-zero if this job matches */
1175 static const char *pattrs
[] = /* Attributes we need for printers... */
1178 "printer-uri-supported",
1183 DEBUG_printf(("show_devices(%p, %p)\n", http
, dests
));
1188 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1192 * Build a CUPS_GET_PRINTERS request, which requires the following
1195 * attributes-charset
1196 * attributes-natural-language
1197 * requested-attributes
1198 * requesting-user-name
1201 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1203 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1204 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1207 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1211 * Do the request and get back a response...
1214 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1216 DEBUG_puts("show_devices: request succeeded...");
1218 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1220 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1221 ippDelete(response
);
1226 * Loop through the printers returned in the list and display
1230 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1233 * Skip leading attributes until we hit a job...
1236 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1243 * Pull the needed attributes from this job...
1250 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1252 if (!strcmp(attr
->name
, "printer-name") &&
1253 attr
->value_tag
== IPP_TAG_NAME
)
1254 printer
= attr
->values
[0].string
.text
;
1256 if (!strcmp(attr
->name
, "printer-uri-supported") &&
1257 attr
->value_tag
== IPP_TAG_URI
)
1258 uri
= attr
->values
[0].string
.text
;
1260 if (!strcmp(attr
->name
, "device-uri") &&
1261 attr
->value_tag
== IPP_TAG_URI
)
1262 device
= attr
->values
[0].string
.text
;
1268 * See if we have everything needed...
1271 if (printer
== NULL
)
1280 * See if this is a printer we're interested in...
1283 match
= printers
== NULL
;
1285 if (printers
!= NULL
)
1287 for (dptr
= printers
; *dptr
!= '\0';)
1290 * Skip leading whitespace and commas...
1293 while (isspace(*dptr
& 255) || *dptr
== ',')
1304 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1307 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1314 * Skip trailing junk...
1317 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1319 while (isspace(*dptr
& 255) || *dptr
== ',')
1328 * Display the printer entry if needed...
1333 #ifdef __osf__ /* Compaq/Digital like to do it their own way... */
1334 char method
[HTTP_MAX_URI
], /* Components of printer URI */
1335 username
[HTTP_MAX_URI
],
1336 hostname
[HTTP_MAX_URI
],
1337 resource
[HTTP_MAX_URI
];
1343 httpSeparateURI(HTTP_URI_CODING_ALL
, uri
, method
, sizeof(method
),
1344 username
, sizeof(username
), hostname
,
1345 sizeof(hostname
), &port
, resource
, sizeof(resource
));
1346 _cupsLangPrintf(stdout
,
1347 _("Output for printer %s is sent to remote "
1348 "printer %s on %s\n"),
1349 printer
, strrchr(resource
, '/') + 1, hostname
);
1351 else if (!strncmp(device
, "file:", 5))
1352 _cupsLangPrintf(stdout
,
1353 _("Output for printer %s is sent to %s\n"),
1354 printer
, device
+ 5);
1356 _cupsLangPrintf(stdout
,
1357 _("Output for printer %s is sent to %s\n"),
1360 for (i
= 0; i
< num_dests
; i
++)
1361 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1364 _cupsLangPrintf(stdout
,
1365 _("Output for printer %s/%s is sent to "
1366 "remote printer %s on %s\n"),
1367 printer
, dests
[i
].instance
,
1368 strrchr(resource
, '/') + 1, hostname
);
1369 else if (!strncmp(device
, "file:", 5))
1370 _cupsLangPrintf(stdout
,
1371 _("Output for printer %s/%s is sent to %s\n"),
1372 printer
, dests
[i
].instance
, device
+ 5);
1374 _cupsLangPrintf(stdout
,
1375 _("Output for printer %s/%s is sent to %s\n"),
1376 printer
, dests
[i
].instance
, device
);
1380 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1382 else if (!strncmp(device
, "file:", 5))
1383 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1384 printer
, device
+ 5);
1386 _cupsLangPrintf(stdout
, _("device for %s: %s\n"),
1389 for (i
= 0; i
< num_dests
; i
++)
1390 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
1393 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1394 printer
, dests
[i
].instance
, uri
);
1395 else if (!strncmp(device
, "file:", 5))
1396 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1397 printer
, dests
[i
].instance
, device
+ 5);
1399 _cupsLangPrintf(stdout
, _("device for %s/%s: %s\n"),
1400 printer
, dests
[i
].instance
, device
);
1402 #endif /* __osf__ */
1409 ippDelete(response
);
1413 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1422 * 'show_jobs()' - Show active print jobs.
1425 static int /* O - 0 on success, 1 on fail */
1426 show_jobs(http_t
*http
, /* I - HTTP connection to server */
1427 const char *dests
, /* I - Destinations */
1428 const char *users
, /* I - Users */
1429 int long_status
, /* I - Show long status? */
1430 int ranking
, /* I - Show job ranking? */
1431 const char *which
) /* I - Show which jobs? */
1433 ipp_t
*request
, /* IPP Request */
1434 *response
; /* IPP Response */
1435 ipp_attribute_t
*attr
; /* Current attribute */
1436 const char *dest
, /* Pointer into job-printer-uri */
1437 *username
, /* Pointer to job-originating-user-name */
1438 *title
; /* Pointer to job-name */
1439 int rank
, /* Rank in queue */
1441 size
; /* job-k-octets */
1442 time_t jobtime
; /* time-at-creation */
1443 struct tm
*jobdate
; /* Date & time */
1444 const char *dptr
, /* Pointer into destination list */
1445 *ptr
; /* Pointer into printer name */
1446 int match
; /* Non-zero if this job matches */
1447 char temp
[255], /* Temporary buffer */
1448 date
[255]; /* Date buffer */
1449 static const char *jattrs
[] = /* Attributes we need for jobs... */
1456 "job-originating-user-name"
1460 DEBUG_printf(("show_jobs(%p, %p, %p)\n", http
, dests
, users
));
1465 if (dests
!= NULL
&& !strcmp(dests
, "all"))
1469 * Build a IPP_GET_JOBS request, which requires the following
1472 * attributes-charset
1473 * attributes-natural-language
1475 * requested-attributes
1478 request
= ippNewRequest(IPP_GET_JOBS
);
1480 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1481 "requested-attributes", sizeof(jattrs
) / sizeof(jattrs
[0]),
1484 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "job-uri",
1485 NULL
, "ipp://localhost/jobs/");
1487 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "which-jobs",
1491 * Do the request and get back a response...
1494 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1497 * Loop through the job list and display them...
1500 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1502 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1503 ippDelete(response
);
1509 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1512 * Skip leading attributes until we hit a job...
1515 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_JOB
)
1522 * Pull the needed attributes from this job...
1532 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_JOB
)
1534 if (!strcmp(attr
->name
, "job-id") &&
1535 attr
->value_tag
== IPP_TAG_INTEGER
)
1536 jobid
= attr
->values
[0].integer
;
1538 if (!strcmp(attr
->name
, "job-k-octets") &&
1539 attr
->value_tag
== IPP_TAG_INTEGER
)
1540 size
= attr
->values
[0].integer
;
1542 if (!strcmp(attr
->name
, "time-at-creation") &&
1543 attr
->value_tag
== IPP_TAG_INTEGER
)
1544 jobtime
= attr
->values
[0].integer
;
1546 if (!strcmp(attr
->name
, "job-printer-uri") &&
1547 attr
->value_tag
== IPP_TAG_URI
)
1548 if ((dest
= strrchr(attr
->values
[0].string
.text
, '/')) != NULL
)
1551 if (!strcmp(attr
->name
, "job-originating-user-name") &&
1552 attr
->value_tag
== IPP_TAG_NAME
)
1553 username
= attr
->values
[0].string
.text
;
1555 if (!strcmp(attr
->name
, "job-name") &&
1556 attr
->value_tag
== IPP_TAG_NAME
)
1557 title
= attr
->values
[0].string
.text
;
1563 * See if we have everything needed...
1566 if (dest
== NULL
|| jobid
== 0)
1575 * See if this is a job we're interested in...
1578 match
= (dests
== NULL
&& users
== NULL
);
1583 for (dptr
= dests
; *dptr
!= '\0';)
1586 * Skip leading whitespace and commas...
1589 while (isspace(*dptr
& 255) || *dptr
== ',')
1600 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1603 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1610 * Skip trailing junk...
1613 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1615 while (isspace(*dptr
& 255) || *dptr
== ',')
1623 if (users
!= NULL
&& username
!= NULL
)
1625 for (dptr
= users
; *dptr
!= '\0';)
1628 * Skip leading whitespace and commas...
1631 while (isspace(*dptr
& 255) || *dptr
== ',')
1641 for (ptr
= username
;
1642 *ptr
!= '\0' && *dptr
!= '\0' && *ptr
== *dptr
;
1645 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1652 * Skip trailing junk...
1655 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1657 while (isspace(*dptr
& 255) || *dptr
== ',')
1666 * Display the job...
1671 jobdate
= localtime(&jobtime
);
1672 snprintf(temp
, sizeof(temp
), "%s-%d", dest
, jobid
);
1674 if (long_status
== 3)
1677 * Show the consolidated output format for the SGI tools...
1680 if (!strftime(date
, sizeof(date
), "%b %d %H:%M", jobdate
))
1681 strcpy(date
, "Unknown");
1683 _cupsLangPrintf(stdout
, "%s;%s;%d;%s;%s\n",
1684 temp
, username
? username
: "unknown",
1685 size
, title
? title
: "unknown", date
);
1689 if (!strftime(date
, sizeof(date
), "%c", jobdate
))
1690 strcpy(date
, "Unknown");
1693 _cupsLangPrintf(stdout
, "%3d %-21s %-13s %8.0f %s\n",
1694 rank
, temp
, username
? username
: "unknown",
1695 1024.0 * size
, date
);
1697 _cupsLangPrintf(stdout
, "%-23s %-13s %8.0f %s\n",
1698 temp
, username
? username
: "unknown",
1699 1024.0 * size
, date
);
1701 _cupsLangPrintf(stdout
, _("\tqueued for %s\n"), dest
);
1709 ippDelete(response
);
1713 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1722 * 'show_printers()' - Show printers.
1725 static int /* O - 0 on success, 1 on fail */
1726 show_printers(http_t
*http
, /* I - HTTP connection to server */
1727 const char *printers
, /* I - Destinations */
1728 int num_dests
, /* I - Number of user-defined dests */
1729 cups_dest_t
*dests
, /* I - User-defined destinations */
1730 int long_status
) /* I - Show long status? */
1732 int i
; /* Looping var */
1733 ipp_t
*request
, /* IPP Request */
1734 *response
, /* IPP Response */
1735 *jobs
; /* IPP Get Jobs response */
1736 ipp_attribute_t
*attr
, /* Current attribute */
1737 *jobattr
, /* Job ID attribute */
1738 *reasons
; /* Job state reasons attribute */
1739 const char *printer
, /* Printer name */
1740 *message
, /* Printer state message */
1741 *description
, /* Description of printer */
1742 *location
, /* Location of printer */
1743 *make_model
, /* Make and model of printer */
1744 *uri
; /* URI of printer */
1745 ipp_attribute_t
*allowed
, /* requesting-user-name-allowed */
1746 *denied
; /* requestint-user-name-denied */
1747 ipp_pstate_t pstate
; /* Printer state */
1748 cups_ptype_t ptype
; /* Printer type */
1749 time_t ptime
; /* Printer state time */
1750 struct tm
*pdate
; /* Printer state date & time */
1751 int jobid
; /* Job ID of current job */
1752 const char *dptr
, /* Pointer into destination list */
1753 *ptr
; /* Pointer into printer name */
1754 int match
; /* Non-zero if this job matches */
1755 char printer_uri
[HTTP_MAX_URI
],
1757 printer_state_time
[255];/* Printer state time */
1758 const char *root
; /* Server root directory... */
1759 static const char *pattrs
[] = /* Attributes we need for printers... */
1763 "printer-state-message",
1764 "printer-state-reasons",
1765 "printer-state-change-time",
1769 "printer-make-and-model",
1770 "printer-uri-supported",
1771 "requesting-user-name-allowed",
1772 "requesting-user-name-denied"
1774 static const char *jattrs
[] = /* Attributes we need for jobs... */
1780 DEBUG_printf(("show_printers(%p, %p)\n", http
, dests
));
1785 if ((root
= getenv("CUPS_SERVERROOT")) == NULL
)
1786 root
= CUPS_SERVERROOT
;
1788 if (printers
!= NULL
&& !strcmp(printers
, "all"))
1792 * Build a CUPS_GET_PRINTERS request, which requires the following
1795 * attributes-charset
1796 * attributes-natural-language
1797 * requested-attributes
1798 * requesting-user-name
1801 request
= ippNewRequest(CUPS_GET_PRINTERS
);
1803 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1804 "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]),
1807 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
1811 * Do the request and get back a response...
1814 if ((response
= cupsDoRequest(http
, request
, "/")) != NULL
)
1816 DEBUG_puts("show_printers: request succeeded...");
1818 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
1820 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
1821 ippDelete(response
);
1826 * Loop through the printers returned in the list and display
1830 for (attr
= response
->attrs
; attr
!= NULL
; attr
= attr
->next
)
1833 * Skip leading attributes until we hit a job...
1836 while (attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_PRINTER
)
1843 * Pull the needed attributes from this job...
1848 ptype
= CUPS_PRINTER_LOCAL
;
1849 pstate
= IPP_PRINTER_IDLE
;
1860 while (attr
!= NULL
&& attr
->group_tag
== IPP_TAG_PRINTER
)
1862 if (!strcmp(attr
->name
, "printer-name") &&
1863 attr
->value_tag
== IPP_TAG_NAME
)
1864 printer
= attr
->values
[0].string
.text
;
1865 else if (!strcmp(attr
->name
, "printer-state") &&
1866 attr
->value_tag
== IPP_TAG_ENUM
)
1867 pstate
= (ipp_pstate_t
)attr
->values
[0].integer
;
1868 else if (!strcmp(attr
->name
, "printer-type") &&
1869 attr
->value_tag
== IPP_TAG_ENUM
)
1870 ptype
= (cups_ptype_t
)attr
->values
[0].integer
;
1871 else if (!strcmp(attr
->name
, "printer-state-message") &&
1872 attr
->value_tag
== IPP_TAG_TEXT
)
1873 message
= attr
->values
[0].string
.text
;
1874 else if (!strcmp(attr
->name
, "printer-state-change-time") &&
1875 attr
->value_tag
== IPP_TAG_INTEGER
)
1876 ptime
= (time_t)attr
->values
[0].integer
;
1877 else if (!strcmp(attr
->name
, "printer-info") &&
1878 attr
->value_tag
== IPP_TAG_TEXT
)
1879 description
= attr
->values
[0].string
.text
;
1880 else if (!strcmp(attr
->name
, "printer-location") &&
1881 attr
->value_tag
== IPP_TAG_TEXT
)
1882 location
= attr
->values
[0].string
.text
;
1883 else if (!strcmp(attr
->name
, "printer-make-and-model") &&
1884 attr
->value_tag
== IPP_TAG_TEXT
)
1885 make_model
= attr
->values
[0].string
.text
;
1886 else if (!strcmp(attr
->name
, "printer-uri-supported") &&
1887 attr
->value_tag
== IPP_TAG_URI
)
1888 uri
= attr
->values
[0].string
.text
;
1889 else if (!strcmp(attr
->name
, "printer-state-reasons") &&
1890 attr
->value_tag
== IPP_TAG_KEYWORD
)
1892 else if (!strcmp(attr
->name
, "requesting-user-name-allowed") &&
1893 attr
->value_tag
== IPP_TAG_NAME
)
1895 else if (!strcmp(attr
->name
, "requesting-user-name-denied") &&
1896 attr
->value_tag
== IPP_TAG_NAME
)
1903 * See if we have everything needed...
1906 if (printer
== NULL
)
1915 * See if this is a printer we're interested in...
1918 match
= printers
== NULL
;
1920 if (printers
!= NULL
)
1922 for (dptr
= printers
; *dptr
!= '\0';)
1925 * Skip leading whitespace and commas...
1928 while (isspace(*dptr
& 255) || *dptr
== ',')
1939 *ptr
!= '\0' && *dptr
!= '\0' && tolower(*ptr
& 255) == tolower(*dptr
& 255);
1942 if (*ptr
== '\0' && (*dptr
== '\0' || *dptr
== ',' || isspace(*dptr
& 255)))
1949 * Skip trailing junk...
1952 while (!isspace(*dptr
& 255) && *dptr
!= ',' && *dptr
!= '\0')
1954 while (isspace(*dptr
& 255) || *dptr
== ',')
1963 * Display the printer entry if needed...
1969 * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
1970 * current job for the printer.
1973 if (pstate
== IPP_PRINTER_PROCESSING
)
1976 * Build an IPP_GET_JOBS request, which requires the following
1979 * attributes-charset
1980 * attributes-natural-language
1983 * requested-attributes
1986 request
= ippNewRequest(IPP_GET_JOBS
);
1988 request
->request
.op
.operation_id
= IPP_GET_JOBS
;
1989 request
->request
.op
.request_id
= 1;
1991 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
,
1992 "requested-attributes",
1993 sizeof(jattrs
) / sizeof(jattrs
[0]), NULL
, jattrs
);
1995 httpAssembleURIf(HTTP_URI_CODING_ALL
, printer_uri
, sizeof(printer_uri
),
1996 "ipp", NULL
, "localhost", 0, "/printers/%s", printer
);
1997 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
1998 "printer-uri", NULL
, printer_uri
);
2000 if ((jobs
= cupsDoRequest(http
, request
, "/")) != NULL
)
2003 * Get the current active job on this queue...
2008 for (jobattr
= jobs
->attrs
; jobattr
; jobattr
= jobattr
->next
)
2013 if (!strcmp(jobattr
->name
, "job-id") &&
2014 jobattr
->value_tag
== IPP_TAG_INTEGER
)
2015 jobid
= jobattr
->values
[0].integer
;
2016 else if (!strcmp(jobattr
->name
, "job-state") &&
2017 jobattr
->value_tag
== IPP_TAG_ENUM
&&
2018 jobattr
->values
[0].integer
== IPP_JOB_PROCESSING
)
2030 pdate
= localtime(&ptime
);
2031 strftime(printer_state_time
, sizeof(printer_state_time
), "%c", pdate
);
2035 case IPP_PRINTER_IDLE
:
2036 _cupsLangPrintf(stdout
,
2037 _("printer %s is idle. enabled since %s\n"),
2038 printer
, printer_state_time
);
2040 case IPP_PRINTER_PROCESSING
:
2041 _cupsLangPrintf(stdout
,
2042 _("printer %s now printing %s-%d. "
2043 "enabled since %s\n"),
2044 printer
, printer
, jobid
, printer_state_time
);
2046 case IPP_PRINTER_STOPPED
:
2047 _cupsLangPrintf(stdout
,
2048 _("printer %s disabled since %s -\n"),
2049 printer
, printer_state_time
);
2053 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
2055 if (!message
|| !*message
)
2056 _cupsLangPuts(stdout
, _("\treason unknown\n"));
2058 _cupsLangPrintf(stdout
, "\t%s\n", message
);
2061 if (long_status
> 1)
2062 _cupsLangPuts(stdout
,
2063 _("\tForm mounted:\n"
2064 "\tContent types: any\n"
2065 "\tPrinter types: unknown\n"));
2069 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
2070 description
? description
: "");
2074 _cupsLangPuts(stdout
, _("\tAlerts:"));
2075 for (i
= 0; i
< reasons
->num_values
; i
++)
2076 _cupsLangPrintf(stdout
, " %s",
2077 reasons
->values
[i
].string
.text
);
2078 _cupsLangPuts(stdout
, "\n");
2081 if (long_status
> 1)
2083 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
2084 location
? location
: "");
2086 if (ptype
& CUPS_PRINTER_REMOTE
)
2088 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
2090 if (make_model
&& !strstr(make_model
, "System V Printer") &&
2091 !strstr(make_model
, "Raw Printer") && uri
)
2092 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
2097 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
2099 if (make_model
&& strstr(make_model
, "System V Printer"))
2100 _cupsLangPrintf(stdout
,
2101 _("\tInterface: %s/interfaces/%s\n"),
2103 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
2104 _cupsLangPrintf(stdout
,
2105 _("\tInterface: %s/ppd/%s.ppd\n"), root
, printer
);
2107 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
2108 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
2109 /* TODO update to use printer-error-policy */
2112 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
2113 for (i
= 0; i
< allowed
->num_values
; i
++)
2114 _cupsLangPrintf(stdout
, "\t\t%s\n",
2115 allowed
->values
[i
].string
.text
);
2119 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
2120 for (i
= 0; i
< denied
->num_values
; i
++)
2121 _cupsLangPrintf(stdout
, "\t\t%s\n",
2122 denied
->values
[i
].string
.text
);
2126 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
2127 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
2129 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
2130 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
2131 _cupsLangPuts(stdout
, _("\tBanner required\n"));
2132 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
2133 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
2134 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
2135 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
2136 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
2139 for (i
= 0; i
< num_dests
; i
++)
2140 if (!strcasecmp(printer
, dests
[i
].name
) && dests
[i
].instance
)
2144 case IPP_PRINTER_IDLE
:
2145 _cupsLangPrintf(stdout
,
2146 _("printer %s/%s is idle. "
2147 "enabled since %s\n"),
2148 printer
, dests
[i
].instance
,
2149 printer_state_time
);
2151 case IPP_PRINTER_PROCESSING
:
2152 _cupsLangPrintf(stdout
,
2153 _("printer %s/%s now printing %s-%d. "
2154 "enabled since %s\n"),
2155 printer
, dests
[i
].instance
, printer
, jobid
,
2156 printer_state_time
);
2158 case IPP_PRINTER_STOPPED
:
2159 _cupsLangPrintf(stdout
,
2160 _("printer %s/%s disabled since %s -\n"),
2161 printer
, dests
[i
].instance
,
2162 printer_state_time
);
2166 if ((message
&& *message
) || pstate
== IPP_PRINTER_STOPPED
)
2168 if (!message
|| !*message
)
2169 _cupsLangPuts(stdout
, _("\treason unknown\n"));
2171 _cupsLangPrintf(stdout
, "\t%s\n", message
);
2174 if (long_status
> 1)
2175 _cupsLangPuts(stdout
,
2176 _("\tForm mounted:\n"
2177 "\tContent types: any\n"
2178 "\tPrinter types: unknown\n"));
2182 _cupsLangPrintf(stdout
, _("\tDescription: %s\n"),
2183 description
? description
: "");
2187 _cupsLangPuts(stdout
, _("\tAlerts:"));
2188 for (i
= 0; i
< reasons
->num_values
; i
++)
2189 _cupsLangPrintf(stdout
, " %s",
2190 reasons
->values
[i
].string
.text
);
2191 _cupsLangPuts(stdout
, "\n");
2194 if (long_status
> 1)
2196 _cupsLangPrintf(stdout
, _("\tLocation: %s\n"),
2197 location
? location
: "");
2199 if (ptype
& CUPS_PRINTER_REMOTE
)
2201 _cupsLangPuts(stdout
, _("\tConnection: remote\n"));
2203 if (make_model
&& !strstr(make_model
, "System V Printer") &&
2204 !strstr(make_model
, "Raw Printer") && uri
)
2205 _cupsLangPrintf(stdout
, _("\tInterface: %s.ppd\n"),
2210 _cupsLangPuts(stdout
, _("\tConnection: direct\n"));
2212 if (make_model
&& strstr(make_model
, "System V Printer"))
2213 _cupsLangPrintf(stdout
,
2214 _("\tInterface: %s/interfaces/%s\n"),
2216 else if (make_model
&& !strstr(make_model
, "Raw Printer"))
2217 _cupsLangPrintf(stdout
,
2218 _("\tInterface: %s/ppd/%s.ppd\n"), root
, printer
);
2220 _cupsLangPuts(stdout
, _("\tOn fault: no alert\n"));
2221 _cupsLangPuts(stdout
, _("\tAfter fault: continue\n"));
2222 /* TODO update to use printer-error-policy */
2225 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
2226 for (i
= 0; i
< allowed
->num_values
; i
++)
2227 _cupsLangPrintf(stdout
, "\t\t%s\n",
2228 allowed
->values
[i
].string
.text
);
2232 _cupsLangPuts(stdout
, _("\tUsers denied:\n"));
2233 for (i
= 0; i
< denied
->num_values
; i
++)
2234 _cupsLangPrintf(stdout
, "\t\t%s\n",
2235 denied
->values
[i
].string
.text
);
2239 _cupsLangPuts(stdout
, _("\tUsers allowed:\n"));
2240 _cupsLangPuts(stdout
, _("\t\t(all)\n"));
2242 _cupsLangPuts(stdout
, _("\tForms allowed:\n"));
2243 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
2244 _cupsLangPuts(stdout
, _("\tBanner required\n"));
2245 _cupsLangPuts(stdout
, _("\tCharset sets:\n"));
2246 _cupsLangPuts(stdout
, _("\t\t(none)\n"));
2247 _cupsLangPuts(stdout
, _("\tDefault pitch:\n"));
2248 _cupsLangPuts(stdout
, _("\tDefault page size:\n"));
2249 _cupsLangPuts(stdout
, _("\tDefault port settings:\n"));
2258 ippDelete(response
);
2262 _cupsLangPrintf(stderr
, "lpstat: %s\n", cupsLastErrorString());
2271 * 'show_scheduler()' - Show scheduler status.
2275 show_scheduler(http_t
*http
) /* I - HTTP connection to server */
2278 _cupsLangPuts(stdout
, _("scheduler is running\n"));
2280 _cupsLangPuts(stdout
, _("scheduler is not running\n"));