summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e02c731)
Author: noodles
Date: 2002/09/08 10:27:47
Pulled out HTML start/end code to getcgi.c and added DOCTYPE & charset.
for (i = 0; params != NULL && params[i] != NULL; i += 2) {
if (!strcmp(params[i], "keytext")) {
ctx.buffer = params[i+1];
for (i = 0; params != NULL && params[i] != NULL; i += 2) {
if (!strcmp(params[i], "keytext")) {
ctx.buffer = params[i+1];
+ } else {
+ free(params[i+1]);
+ params[i+1] = NULL;
+ free(params[i]);
+ params[i] = NULL;
+ }
+ if (params != NULL) {
+ free(params);
+ params = NULL;
- puts("Content-Type: text/html\n");
- puts("<html><title>onak : Add</title><body>");
+ start_html("onak : Add");
if (ctx.buffer == NULL) {
puts("Error: No keytext to add supplied.");
} else {
if (ctx.buffer == NULL) {
puts("Error: No keytext to add supplied.");
} else {
puts("No OpenPGP packets found in input.");
}
}
puts("No OpenPGP packets found in input.");
}
}
- puts("</body></html>");
char *ptr = NULL;
char *nextptr = NULL;
char *ptr = NULL;
char *nextptr = NULL;
ptr = strchr(string, '<');
if (ptr != NULL) {
ptr = strchr(string, '<');
if (ptr != NULL) {
+/*
+ * start_html - Start HTML output.
+ * @title: The title for the HTML.
+ *
+ * Takes a title string and starts HTML output, including the
+ * Content-Type header all the way up to <BODY>.
+ */
+void start_html(const char *title)
+{
+ puts("Content-Type: text/html; charset=utf8\n");
+ puts("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2 Final//EN'>");
+ puts("<HTML>");
+ puts("<HEAD>");
+ printf("<TITLE>%s</TITLE>\n", title);
+ puts("</HEAD>");
+ puts("<BODY>");
+
+ return;
+}
+
+/*
+ * end_html - End HTML output.
+ *
+ * Ends HTML output - closes the BODY and HTML tags.
+ */
+void end_html(void)
+{
+ puts("</BODY>");
+ puts("</HTML>");
+
+ return;
+}
+
+
/* Convert a two-char hex string into the char it represents */
/* Convert a two-char hex string into the char it represents */
+char x2c(const char *what)
*/
char *txt2html(const char *string);
*/
char *txt2html(const char *string);
+/*
+ * start_html - Start HTML output.
+ * @title: The title for the HTML.
+ *
+ * Takes a title string and starts HTML output, including the
+ * Content-Type header all the way up to <BODY>.
+ */
+void start_html(const char *title);
+
+/*
+ * end_html - End HTML output.
+ *
+ * Ends HTML output - closes the BODY and HTML tags.
+ */
+void end_html(void);
+
+char x2c(const char *what);
void unescape_url(char *url);
char **getcgivars(int argc, char *argv[]);
void unescape_url(char *url);
char **getcgivars(int argc, char *argv[]);
int putnextchar(void *ctx, size_t count, unsigned char *c)
{
int putnextchar(void *ctx, size_t count, unsigned char *c)
{
- return printf("%.*s", count, c);
+ return printf("%.*s", (int) count, c);
}
void find_keys(char *search, uint64_t keyid, bool ishex,
}
void find_keys(char *search, uint64_t keyid, bool ishex,
}
} else if (!strcmp(params[i], "search")) {
search = params[i+1];
}
} else if (!strcmp(params[i], "search")) {
search = params[i+1];
if (search != NULL) {
keyid = strtoul(search, &end, 16);
if (*search != 0 &&
if (search != NULL) {
keyid = strtoul(search, &end, 16);
if (*search != 0 &&
+ free(params[i]);
+ params[i] = NULL;
+ if (params[i+1] != NULL) {
+ free(params[i+1]);
+ params[i+1] = NULL;
+ }
+ }
+ if (params != NULL) {
+ free(params);
+ params = NULL;
-// puts("HTTP/1.0 200 OK");
-// puts("Server: onak 0.0.1");
- puts("Content-Type: text/html\n");
- puts("<html>\n<title>Lookup of key</title>");
- puts("<body>");
+ start_html("Lookup of key");
if (op == OP_UNKNOWN) {
puts("Error: No operation supplied.");
if (op == OP_UNKNOWN) {
puts("Error: No operation supplied.");
}
puts("<hr>");
puts("Produced by onak " VERSION " by Jonathan McDowell");
}
puts("<hr>");
puts("Produced by onak " VERSION " by Jonathan McDowell");
- puts("</body>\n</html>");
+ end_html();
+
+ if (search != NULL) {
+ free(search);
+ search = NULL;
+ }
+