]>
Commit | Line | Data |
---|---|---|
53190348 | 1 | /* |
efb2f309 | 2 | * "$Id: jobs.c,v 1.17 2002/01/02 17:58:36 mike Exp $" |
53190348 | 3 | * |
4 | * Job status CGI for the Common UNIX Printing System (CUPS). | |
5 | * | |
efb2f309 | 6 | * Copyright 1997-2002 by Easy Software Products. |
53190348 | 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 | * | |
f63a2256 | 26 | * main() - Main entry for CGI. |
53190348 | 27 | */ |
28 | ||
29 | /* | |
30 | * Include necessary headers... | |
31 | */ | |
32 | ||
f63a2256 | 33 | #include "ipp-var.h" |
53190348 | 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 */ | |
53190348 | 45 | http_t *http; /* Connection to the server */ |
f63a2256 | 46 | const char *which_jobs; /* Which jobs to show */ |
47 | ipp_t *request, /* IPP request */ | |
48 | *response; /* IPP response */ | |
49 | ||
53190348 | 50 | |
f63a2256 | 51 | /* |
52 | * Get any form variables... | |
53 | */ | |
54 | ||
55 | cgiInitialize(); | |
53190348 | 56 | |
57 | /* | |
58 | * Get the request language... | |
59 | */ | |
60 | ||
61 | language = cupsLangDefault(); | |
62 | ||
63 | /* | |
64 | * Connect to the HTTP server... | |
65 | */ | |
66 | ||
a1793153 | 67 | http = httpConnectEncrypt("localhost", ippPort(), cupsEncryption()); |
53190348 | 68 | |
69 | /* | |
70 | * Tell the client to expect HTML... | |
71 | */ | |
72 | ||
73 | printf("Content-Type: text/html;charset=%s\n\n", cupsLangEncoding(language)); | |
74 | ||
f63a2256 | 75 | cgiSetVariable("TITLE", "Jobs"); |
3d9e2586 | 76 | |
77 | ippSetServerVersion(); | |
53190348 | 78 | |
a3e17a89 | 79 | cgiCopyTemplateLang(stdout, TEMPLATES, "header.tmpl", getenv("LANG")); |
580af8cf | 80 | |
53190348 | 81 | /* |
82 | * Build an IPP_GET_JOBS request, which requires the following | |
83 | * attributes: | |
84 | * | |
85 | * attributes-charset | |
86 | * attributes-natural-language | |
f63a2256 | 87 | * printer-uri |
53190348 | 88 | */ |
89 | ||
90 | request = ippNew(); | |
91 | ||
580af8cf | 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); | |
53190348 | 97 | |
f63a2256 | 98 | request->request.op.operation_id = IPP_GET_JOBS; |
53190348 | 99 | request->request.op.request_id = 1; |
100 | ||
f63a2256 | 101 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, |
102 | "ipp://localhost/jobs"); | |
53190348 | 103 | |
f63a2256 | 104 | if ((which_jobs = cgiGetVariable("which_jobs")) != NULL) |
105 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs", | |
106 | NULL, which_jobs); | |
53190348 | 107 | |
108 | /* | |
109 | * Do the request and get back a response... | |
110 | */ | |
111 | ||
f63a2256 | 112 | if ((response = cupsDoRequest(http, request, "/")) != NULL) |
580af8cf | 113 | { |
3d9e2586 | 114 | ippSetCGIVars(response, NULL, NULL); |
580af8cf | 115 | ippDelete(response); |
53190348 | 116 | |
a3e17a89 | 117 | cgiCopyTemplateLang(stdout, TEMPLATES, "jobs.tmpl", getenv("LANG")); |
580af8cf | 118 | } |
53190348 | 119 | |
a3e17a89 | 120 | cgiCopyTemplateLang(stdout, TEMPLATES, "trailer.tmpl", getenv("LANG")); |
53190348 | 121 | |
580af8cf | 122 | /* |
f63a2256 | 123 | * Close the HTTP server connection... |
580af8cf | 124 | */ |
53190348 | 125 | |
f63a2256 | 126 | httpClose(http); |
127 | cupsLangFree(language); | |
580af8cf | 128 | |
f63a2256 | 129 | /* |
130 | * Return with no errors... | |
131 | */ | |
580af8cf | 132 | |
f63a2256 | 133 | return (0); |
53190348 | 134 | } |
135 | ||
136 | ||
137 | /* | |
efb2f309 | 138 | * End of "$Id: jobs.c,v 1.17 2002/01/02 17:58:36 mike Exp $". |
53190348 | 139 | */ |