-const char cgi_rcs[] = "$Id: cgi.c,v 1.39 2001/11/16 00:48:13 jongfoster Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.40 2002/01/09 14:26:46 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.c,v $
*
* Revisions :
* $Log: cgi.c,v $
+ * Revision 1.40 2002/01/09 14:26:46 oes
+ * Added support for thread-safe gmtime_r call.
+ *
* Revision 1.39 2001/11/16 00:48:13 jongfoster
* Fixing a compiler warning
*
*
* Function : dispatch_cgi
*
- * Description : Checks if a request URL has either the magical hostname
- * i.j.b or matches HOME_PAGE_URL/config/. If so, it passes
+ * Description : Checks if a request URL has either the magical
+ * hostname CGI_SITE_1_HOST (usully http://i.j.b/) or
+ * matches CGI_SITE_2_HOST CGI_SITE_2_PATH (usually
+ * http://ijbswa.sourceforge.net/config). If so, it passes
* the (rest of the) path onto dispatch_known_cgi, which
* calls the relevant CGI handler function.
*
* Should we intercept ?
*/
- /* Either the host matches CGI_PREFIX_HOST ..*/
- if ( (0 == strcmpic(host, CGI_PREFIX_HOST))
+ /* Note: "example.com" and "example.com." are equivalent hostnames. */
+
+ /* Either the host matches CGI_SITE_1_HOST ..*/
+ if ( ( (0 == strcmpic(host, CGI_SITE_1_HOST))
+ || (0 == strcmpic(host, CGI_SITE_1_HOST ".")))
&& (path[0] == '/') )
{
/* ..then the path will all be for us. Remove leading '/' */
path++;
}
- /* Or it's the host part HOME_PAGE_URL, and the path /config/ */
- else if ( (0 == strcmpic(host, HOME_PAGE_URL + 7 ))
- && (0 == strncmpic(path,"/config", 7)) )
+ /* Or it's the host part CGI_SITE_2_HOST, and the path CGI_SITE_2_PATH */
+ else if ( ( (0 == strcmpic(host, CGI_SITE_2_HOST ))
+ || (0 == strcmpic(host, CGI_SITE_2_HOST ".")) )
+ && (0 == strncmpic(path, CGI_SITE_2_PATH, strlen(CGI_SITE_2_PATH))) )
{
- /* take everything following "/config" */
- path += 7;
+ /* take everything following CGI_SITE_2_PATH */
+ path += strlen(CGI_SITE_2_PATH);
if (*path == '/')
{
- /* skip the forward slash after "/config" */
+ /* skip the forward slash after CGI_SITE_2_PATH */
path++;
}
else if (*path != '\0')
{
- /* wierdness: URL is /configXXX, where XXX is some string */
+ /*
+ * wierdness: URL is /configXXX, where XXX is some string
+ * Do *NOT* intercept.
+ */
return NULL;
}
}
if (!err) err = map(exports, "my-ip-address", 1, csp->my_ip_addr_str ? csp->my_ip_addr_str : "unknown", 1);
if (!err) err = map(exports, "my-hostname", 1, csp->my_hostname ? csp->my_hostname : "unknown", 1);
if (!err) err = map(exports, "homepage", 1, HOME_PAGE_URL, 1);
- if (!err) err = map(exports, "default-cgi", 1, HOME_PAGE_URL "/config", 1);
+ if (!err) err = map(exports, "default-cgi", 1, CGI_PREFIX, 1);
if (!err) err = map(exports, "menu", 1, make_menu(caller), 0);
if (!err) err = map(exports, "code-status", 1, CODE_STATUS, 1);
if (!err) err = map_conditional(exports, "enabled-display", g_bToggleIJB);
{
if (d->description && strcmp(d->name, self))
{
- snprintf(buf, BUFFER_SIZE, "<li><a href=\"%s/config/%s\">%s</a></li>\n",
- HOME_PAGE_URL, d->name, d->description);
+ snprintf(buf, BUFFER_SIZE, "<li><a href=\"%s%s\">%s</a></li>\n",
+ CGI_PREFIX, d->name, d->description);
result = strsav(result, buf);
}
}
-const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.7 2001/11/13 00:28:24 jongfoster Exp $";
+const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.8 2001/11/30 23:35:51 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgiedit.c,v $
*
* Revisions :
* $Log: cgiedit.c,v $
+ * Revision 1.8 2001/11/30 23:35:51 jongfoster
+ * Renaming actionsfile to ijb.action
+ *
* Revision 1.7 2001/11/13 00:28:24 jongfoster
* - Renaming parameters from edit-actions-for-url so that they only
* contain legal JavaScript characters. If we wanted to write
#include "errlog.h"
#include "loadcfg.h"
/* loadcfg.h is for g_bToggleIJB only */
+#include "urlmatch.h"
const char cgiedit_h_rcs[] = CGIEDIT_H_VERSION;
{
return JB_ERR_MEMORY;
}
- if (enlist_unique_header(rsp->headers, "Location", "http://ijbswa.sourceforge.net/config/edit-actions-list?filename=ijb"))
+ if (enlist_unique_header(rsp->headers, "Location",
+ CGI_PREFIX "edit-actions-list?filename=ijb"))
{
free(rsp->status);
rsp->status = NULL;
return err;
}
- target = strdup("http://ijbswa.sourceforge.net/config/edit-actions-list?filename=");
+ target = strdup(CGI_PREFIX "edit-actions-list?filename=");
string_append(&target, file->identifier);
edit_free_file(file);
return err;
}
- target = strdup("http://ijbswa.sourceforge.net/config/edit-actions-list?filename=");
+ target = strdup(CGI_PREFIX "edit-actions-list?filename=");
string_append(&target, file->identifier);
edit_free_file(file);
unsigned line_number;
char * target;
jb_err err;
+ struct url_spec compiled[1];
if (0 == (csp->config->feature_flags & RUNTIME_FEATURE_CGI_EDIT_ACTIONS))
{
return JB_ERR_CGI_PARAMS;
}
+ /* Check that regex is valid */
+ err = create_url_spec(compiled, newval);
+ if (err)
+ {
+ return (err == JB_ERR_MEMORY) ? JB_ERR_MEMORY : JB_ERR_CGI_PARAMS;
+ }
+ free_url_spec(compiled);
+
err = edit_read_actions_file(csp, rsp, parameters, 1, &file);
if (err)
{
return err;
}
- target = strdup("http://ijbswa.sourceforge.net/config/edit-actions-list?filename=");
+ target = strdup(CGI_PREFIX "edit-actions-list?filename=");
string_append(&target, file->identifier);
edit_free_file(file);
return err;
}
- target = strdup("http://ijbswa.sourceforge.net/config/edit-actions-list?filename=");
+ target = strdup(CGI_PREFIX "edit-actions-list?filename=");
string_append(&target, file->identifier);
edit_free_file(file);
return err;
}
- target = strdup("http://ijbswa.sourceforge.net/config/edit-actions-list?filename=");
+ target = strdup(CGI_PREFIX "edit-actions-list?filename=");
string_append(&target, file->identifier);
edit_free_file(file);
return err;
}
- target = strdup("http://ijbswa.sourceforge.net/config/edit-actions-list?filename=");
+ target = strdup(CGI_PREFIX "edit-actions-list?filename=");
string_append(&target, file->identifier);
edit_free_file(file);