X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=cgi.c;h=356f0e0e8d41239c63eefbe7807c8016419c6ecc;hb=260ad9899c2ad02c0f584ed00b60b3e03987f7fa;hp=e700c732205eb805d93ff51faed08c8c27f0045c;hpb=5bb7b8f89d7b6bb4177efc188ae2e488c85cb96f;p=privoxy.git diff --git a/cgi.c b/cgi.c index e700c732..356f0e0e 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.38 2001/11/13 00:31:21 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 $ @@ -38,6 +38,12 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.38 2001/11/13 00:31:21 jongfoster Exp $"; * * 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 + * * Revision 1.38 2001/11/13 00:31:21 jongfoster * - Adding new CGIs for use by non-JavaScript browsers: * edit-actions-url-form @@ -395,8 +401,10 @@ static struct map *parse_cgi_parameters(char *argstring); * * 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. * @@ -415,27 +423,34 @@ struct http_response *dispatch_cgi(struct client_state *csp) * 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; } } @@ -886,7 +901,14 @@ void get_http_time(int time_offset, char *buf) current_time += time_offset; /* get and save the gmt */ - t = gmtime(¤t_time); + { +#ifdef HAVE_GMTIME_R + struct tm dummy; + t = gmtime_r(¤t_time, &dummy); +#else + t = gmtime(¤t_time); +#endif + } /* Format: "Sun, 06 Nov 1994 08:49:37 GMT" */ snprintf(buf, 30, @@ -1350,7 +1372,7 @@ struct map *default_exports(const struct client_state *csp, const char *caller) 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); @@ -1507,8 +1529,8 @@ char *make_menu(const char *self) { if (d->description && strcmp(d->name, self)) { - snprintf(buf, BUFFER_SIZE, "
  • %s
  • \n", - HOME_PAGE_URL, d->name, d->description); + snprintf(buf, BUFFER_SIZE, "
  • %s
  • \n", + CGI_PREFIX, d->name, d->description); result = strsav(result, buf); } }