]> git.ipfire.org Git - thirdparty/cups.git/blob - cgi-bin/jobs.c
287072e808c32679d47a1dfc9cd775aa6c773414
[thirdparty/cups.git] / cgi-bin / jobs.c
1 /*
2 * "$Id: jobs.c,v 1.15 2001/01/22 15:03:22 mike Exp $"
3 *
4 * Job status CGI for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2001 by Easy Software Products.
7 *
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
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
19 *
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * Contents:
25 *
26 * main() - Main entry for CGI.
27 */
28
29 /*
30 * Include necessary headers...
31 */
32
33 #include "ipp-var.h"
34
35
36 /*
37 * 'main()' - Main entry for CGI.
38 */
39
40 int /* O - Exit status */
41 main(int argc, /* I - Number of command-line arguments */
42 char *argv[]) /* I - Command-line arguments */
43 {
44 cups_lang_t *language; /* Language information */
45 http_t *http; /* Connection to the server */
46 const char *which_jobs; /* Which jobs to show */
47 ipp_t *request, /* IPP request */
48 *response; /* IPP response */
49
50
51 /*
52 * Get any form variables...
53 */
54
55 cgiInitialize();
56
57 /*
58 * Get the request language...
59 */
60
61 language = cupsLangDefault();
62
63 /*
64 * Connect to the HTTP server...
65 */
66
67 http = httpConnect("localhost", ippPort());
68
69 /*
70 * Tell the client to expect HTML...
71 */
72
73 printf("Content-Type: text/html;charset=%s\n\n", cupsLangEncoding(language));
74
75 cgiSetVariable("TITLE", "Jobs");
76
77 ippSetServerVersion();
78
79 cgiCopyTemplateLang(stdout, TEMPLATES, "header.tmpl", getenv("LANG"));
80
81 /*
82 * Build an IPP_GET_JOBS request, which requires the following
83 * attributes:
84 *
85 * attributes-charset
86 * attributes-natural-language
87 * printer-uri
88 */
89
90 request = ippNew();
91
92 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
93 "attributes-charset", NULL, cupsLangEncoding(language));
94
95 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
96 "attributes-natural-language", NULL, language->language);
97
98 request->request.op.operation_id = IPP_GET_JOBS;
99 request->request.op.request_id = 1;
100
101 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL,
102 "ipp://localhost/jobs");
103
104 if ((which_jobs = cgiGetVariable("which_jobs")) != NULL)
105 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs",
106 NULL, which_jobs);
107
108 /*
109 * Do the request and get back a response...
110 */
111
112 if ((response = cupsDoRequest(http, request, "/")) != NULL)
113 {
114 ippSetCGIVars(response, NULL, NULL);
115 ippDelete(response);
116
117 cgiCopyTemplateLang(stdout, TEMPLATES, "jobs.tmpl", getenv("LANG"));
118 }
119
120 cgiCopyTemplateLang(stdout, TEMPLATES, "trailer.tmpl", getenv("LANG"));
121
122 /*
123 * Close the HTTP server connection...
124 */
125
126 httpClose(http);
127 cupsLangFree(language);
128
129 /*
130 * Return with no errors...
131 */
132
133 return (0);
134 }
135
136
137 /*
138 * End of "$Id: jobs.c,v 1.15 2001/01/22 15:03:22 mike Exp $".
139 */