]>
git.ipfire.org Git - thirdparty/cups.git/blob - cgi-bin/html.c
2 * "$Id: html.c 177 2006-06-21 00:20:03Z jlovell $"
4 * HTML support functions 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 * cgiEndHTML() - End a HTML page.
27 * cgiFormEncode() - Encode a string as a form variable...
28 * cgiStartHTML() - Start a HTML page.
29 * cgi_null_passwd() - Return a NULL password for authentication.
33 * Include necessary headers...
36 #include "cgi-private.h"
43 static const char *cgi_null_passwd(const char *prompt
);
47 * 'cgiEndHTML()' - End a HTML page.
54 * Send the standard trailer...
57 cgiCopyTemplateLang("trailer.tmpl");
62 * 'cgiFormEncode()' - Encode a string as a form variable...
65 char * /* O - Destination string */
66 cgiFormEncode(char *dst
, /* I - Destination string */
67 const char *src
, /* I - Source string */
68 size_t dstsize
) /* I - Size of destination string */
70 char *dstptr
, /* Pointer into destination */
71 *dstend
; /* End of destination */
72 static const char *hex
= /* Hexadecimal characters */
77 * Mark the end of the string...
80 dstend
= dst
+ dstsize
- 1;
83 * Loop through the source string and copy...
86 for (dstptr
= dst
; *src
&& dstptr
< dstend
;)
92 * Encode spaces with a "+"...
103 * Encode special characters with %XX escape...
106 if (dstptr
< (dstend
- 2))
109 *dstptr
++ = hex
[(*src
& 255) >> 4];
110 *dstptr
++ = hex
[*src
& 15];
117 * Copy other characters literally...
126 * Nul-terminate the destination string...
132 * Return the encoded string...
140 * 'cgiStartHTML()' - Start a HTML page.
144 cgiStartHTML(const char *title
) /* I - Title of page */
147 * Disable any further authentication attempts...
150 cupsSetPasswordCB(cgi_null_passwd
);
153 * Tell the client to expect UTF-8 encoded HTML...
156 puts("Content-Type: text/html;charset=utf-8\n");
159 * Send a standard header...
162 cgiSetVariable("TITLE", title
);
163 cgiSetServerVersion();
165 cgiCopyTemplateLang("header.tmpl");
170 * 'cgi_null_passwd()' - Return a NULL password for authentication.
173 static const char * /* O - NULL */
174 cgi_null_passwd(const char *prompt
) /* I - Prompt string (unused) */
178 fprintf(stderr
, "DEBUG: cgi_null_passwd(prompt=\"%s\") called!\n",
179 prompt
? prompt
: "(null)");
186 * End of "$Id: html.c 177 2006-06-21 00:20:03Z jlovell $".