-const char cgi_rcs[] = "$Id: cgi.c,v 1.26 2001/09/16 15:47:37 jongfoster Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.27 2001/09/16 17:08:54 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.c,v $
*
* Revisions :
* $Log: cgi.c,v $
+ * Revision 1.27 2001/09/16 17:08:54 jongfoster
+ * Moving simple CGI functions from cgi.c to new file cgisimple.c
+ *
* Revision 1.26 2001/09/16 15:47:37 jongfoster
* First version of CGI-based edit interface. This is very much a
* work-in-progress, and you can't actually use it to edit anything
/* Can't get here, since cgi_default will match all requests */
free_http_response(rsp);
return(NULL);
+
}
}
return(finish_http_response(rsp));
+
}
* Returns : N/A
*
*********************************************************************/
-void get_http_time(int time_offset, char * buf)
+void get_http_time(int time_offset, char *buf)
{
static const char day_names[7][4] =
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
time(¤t_time); /* get current time */
-/* FIXME: is this needed? time() can't fail on Win32. What about Linux?
- if(current_time <= 0)
- {
- return NULL;
- }
-*/
-
current_time += time_offset;
/* get and save the gmt */
t->tm_sec
);
buf[32] = '\0';
+
}
* Returns : pointer to a new http_response, or NULL.
*
*********************************************************************/
-struct http_response * alloc_http_response(void)
+struct http_response *alloc_http_response(void)
{
return (struct http_response *) zalloc(sizeof(struct http_response));
+
}
* Function : fill_template
*
* Description : CGI support function that loads a given HTML
- * template from the confdir, and fills it in
- * by replacing @name@ with value using pcrs,
- * for each item in the output map.
+ * template from the confdir, ignoring comment
+ * lines.
*
* Parameters :
* 1 : csp = Current client state (buffers, headers, etc...)
fclose(fp);
return(file_buffer);
+
}
*
* Function : fill_template
*
- * Description : CGI support function that loads a given HTML
- * template from the confdir, and fills it in
- * by replacing @name@ with value using pcrs,
- * for each item in the output map.
+ * Description : CGI support function that fills in a pre-loaded
+ * HTML template by replacing @name@ with value using
+ * pcrs, for each item in the output map.
+ *
+ * Note that a leading '$' charachter in the export map's
+ * values will be stripped and toggle on backreference
+ * interpretation.
*
* Parameters :
* 1 : template_ptr = IN: Template to be filled out.
* Returns : N/A
*
*********************************************************************/
-void template_fill(char ** template_ptr, struct map *exports)
+void template_fill(char **template_ptr, struct map *exports)
{
struct map_entry *m;
pcrs_job *job;
char *file_buffer;
int size;
int error;
- const char * flags;
+ const char *flags;
assert(template_ptr);
assert(*template_ptr);
else
{
pcrs_execute(job, file_buffer, size, &tmp_out_buffer, &size);
- if (file_buffer != tmp_out_buffer)
+ if (NULL != tmp_out_buffer)
{
free(file_buffer);
file_buffer = tmp_out_buffer;
* Return
*/
*template_ptr = file_buffer;
+
}
* Returns : NULL if no memory, else map
*
*********************************************************************/
-struct map * default_exports(const struct client_state *csp, const char *caller)
+struct map *default_exports(const struct client_state *csp, const char *caller)
{
char buf[20];
struct map * exports = new_map();
}
return (exports);
+
}
snprintf(buf, 1000, "if-%s-start.*if-%s-end", name, name);
map(exports, buf, 1, "", 1);
+
}
snprintf(buf, 1000, (choose_first ? "if-%s-then" : "endif-%s"), name);
map(exports, buf, 1, "", 1);
+
}