]>
git.ipfire.org Git - thirdparty/cups.git/blob - cgi-bin/html.c
2 * "$Id: html.c 6649 2007-07-11 21:46:42Z mike $"
4 * HTML support functions for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2008 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cgiEndHTML() - End a HTML page.
18 * cgiEndMultipart() - End the delivery of a multipart web page.
19 * cgiFormEncode() - Encode a string as a form variable...
20 * cgiStartHTML() - Start a HTML page.
21 * cgiStartMultipart() - Start a multipart delivery of a web page...
22 * cgi_null_passwd() - Return a NULL password for authentication.
26 * Include necessary headers...
29 #include "cgi-private.h"
36 static const char *cgi_multipart
= NULL
;
37 /* Multipart separator, if any */
44 static const char *cgi_null_passwd(const char *prompt
);
48 * 'cgiEndHTML()' - End a HTML page.
55 * Send the standard trailer...
58 cgiCopyTemplateLang("trailer.tmpl");
63 * 'cgiEndMultipart()' - End the delivery of a multipart web page.
70 printf("\n%s--\n", cgi_multipart
);
75 * 'cgiFormEncode()' - Encode a string as a form variable...
78 char * /* O - Destination string */
79 cgiFormEncode(char *dst
, /* I - Destination string */
80 const char *src
, /* I - Source string */
81 size_t dstsize
) /* I - Size of destination string */
83 char *dstptr
, /* Pointer into destination */
84 *dstend
; /* End of destination */
85 static const char *hex
= /* Hexadecimal characters */
90 * Mark the end of the string...
93 dstend
= dst
+ dstsize
- 1;
96 * Loop through the source string and copy...
99 for (dstptr
= dst
; *src
&& dstptr
< dstend
;)
105 * Encode spaces with a "+"...
116 * Encode special characters with %XX escape...
119 if (dstptr
< (dstend
- 2))
122 *dstptr
++ = hex
[(*src
& 255) >> 4];
123 *dstptr
++ = hex
[*src
& 15];
130 * Copy other characters literally...
139 * Nul-terminate the destination string...
145 * Return the encoded string...
153 * 'cgiStartHTML()' - Start a HTML page.
157 cgiStartHTML(const char *title
) /* I - Title of page */
160 * Disable any further authentication attempts...
163 cupsSetPasswordCB(cgi_null_passwd
);
166 * Tell the client to expect UTF-8 encoded HTML...
172 puts("Content-Type: text/html;charset=utf-8\n");
175 * Send a standard header...
178 cgiSetVariable("TITLE", title
);
179 cgiSetServerVersion();
181 cgiCopyTemplateLang("header.tmpl");
186 * 'cgiStartMultipart()' - Start a multipart delivery of a web page...
190 cgiStartMultipart(void)
192 puts("MIME-Version: 1.0");
193 puts("Content-Type: multipart/x-mixed-replace; boundary=\"CUPS-MULTIPART\"\n");
194 cgi_multipart
= "--CUPS-MULTIPART";
199 * 'cgi_null_passwd()' - Return a NULL password for authentication.
202 static const char * /* O - NULL */
203 cgi_null_passwd(const char *prompt
) /* I - Prompt string (unused) */
207 fprintf(stderr
, "DEBUG: cgi_null_passwd(prompt=\"%s\") called!\n",
208 prompt
? prompt
: "(null)");
215 * End of "$Id: html.c 6649 2007-07-11 21:46:42Z mike $".