X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=loaders.c;h=2ec1ffed6386544b4c375ca184a7d24da80c222c;hp=93bea4ef34eb5af8d17c021b07e45b90cea24efe;hb=e35f06fcd3ddae77f971db673e9eca97ce9a0a5f;hpb=1e394f79a14ff27e921802252cbfa76393570969 diff --git a/loaders.c b/loaders.c index 93bea4ef..2ec1ffed 100644 --- a/loaders.c +++ b/loaders.c @@ -1,4 +1,4 @@ -const char loaders_rcs[] = "$Id: loaders.c,v 1.31 2001/10/26 17:39:01 oes Exp $"; +const char loaders_rcs[] = "$Id: loaders.c,v 1.34 2001/12/30 14:07:32 steudten Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loaders.c,v $ @@ -35,6 +35,23 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.31 2001/10/26 17:39:01 oes Exp $" * * Revisions : * $Log: loaders.c,v $ + * Revision 1.34 2001/12/30 14:07:32 steudten + * - Add signal handling (unix) + * - Add SIGHUP handler (unix) + * - Add creation of pidfile (unix) + * - Add action 'top' in rc file (RH) + * - Add entry 'SIGNALS' to manpage + * - Add exit message to logfile (unix) + * + * Revision 1.33 2001/11/13 00:16:38 jongfoster + * Replacing references to malloc.h with the standard stdlib.h + * (See ANSI or K&R 2nd Ed) + * + * Revision 1.32 2001/11/07 00:02:13 steudten + * Add line number in error output for lineparsing for + * actionsfile and configfile. + * Special handling for CLF added. + * * Revision 1.31 2001/10/26 17:39:01 oes * Removed csp->referrer * Moved ijb_isspace and ijb_tolower to project.h @@ -196,7 +213,6 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.31 2001/10/26 17:39:01 oes Exp $" #include #include #include -#include #include #include #include @@ -215,6 +231,7 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.31 2001/10/26 17:39:01 oes Exp $" #include "miscutil.h" #include "errlog.h" #include "actions.h" +#include "urlmatch.h" const char loaders_h_rcs[] = LOADERS_H_VERSION; @@ -355,174 +372,6 @@ void sweep(void) } -/********************************************************************* - * - * Function : create_url_spec - * - * Description : Creates a "url_spec" structure from a string. - * When finished, free with unload_url(). - * - * Parameters : - * 1 : url = Target url_spec to be filled in. Must be - * zeroed out before the call (e.g. using zalloc). - * 2 : buf = Source pattern, null terminated. NOTE: The - * contents of this buffer are destroyed by this - * function. If this function succeeds, the - * buffer is copied to url->spec. If this - * function fails, the contents of the buffer - * are lost forever. - * - * Returns : JB_ERR_OK - Success - * JB_ERR_MEMORY - Out of memory - * JB_ERR_PARSE - Cannot parse regex (Detailed message - * written to system log) - * - *********************************************************************/ -jb_err create_url_spec(struct url_spec * url, char * buf) -{ - char *p; - struct url_spec tmp_url[1]; - - assert(url); - assert(buf); - - /* save a copy of the orignal specification */ - if ((url->spec = strdup(buf)) == NULL) - { - return JB_ERR_MEMORY; - } - - if ((p = strchr(buf, '/'))) - { - if (NULL == (url->path = strdup(p))) - { - freez(url->spec); - return JB_ERR_MEMORY; - } - url->pathlen = strlen(url->path); - *p = '\0'; - } - else - { - url->path = NULL; - url->pathlen = 0; - } -#ifdef REGEX - if (url->path) - { - int errcode; - char rebuf[BUFFER_SIZE]; - - if (NULL == (url->preg = zalloc(sizeof(*url->preg)))) - { - freez(url->spec); - freez(url->path); - return JB_ERR_MEMORY; - } - - sprintf(rebuf, "^(%s)", url->path); - - errcode = regcomp(url->preg, rebuf, - (REG_EXTENDED|REG_NOSUB|REG_ICASE)); - if (errcode) - { - size_t errlen = regerror(errcode, - url->preg, rebuf, sizeof(rebuf)); - - if (errlen > (sizeof(rebuf) - (size_t)1)) - { - errlen = sizeof(rebuf) - (size_t)1; - } - rebuf[errlen] = '\0'; - - log_error(LOG_LEVEL_ERROR, "error compiling %s: %s", - url->spec, rebuf); - - freez(url->spec); - freez(url->path); - freez(url->preg); - - return JB_ERR_PARSE; - } - } -#endif - if ((p = strchr(buf, ':')) == NULL) - { - url->port = 0; - } - else - { - *p++ = '\0'; - url->port = atoi(p); - } - - if ((url->domain = strdup(buf)) == NULL) - { - freez(url->spec); - freez(url->path); -#ifdef REGEX - freez(url->preg); -#endif /* def REGEX */ - return JB_ERR_MEMORY; - } - - /* split domain into components */ - - *tmp_url = dsplit(url->domain); - if (tmp_url->dbuf == NULL) - { - freez(url->spec); - freez(url->path); - freez(url->domain); -#ifdef REGEX - freez(url->preg); -#endif /* def REGEX */ - return JB_ERR_MEMORY; - } - - url->dbuf = tmp_url->dbuf; - url->dcnt = tmp_url->dcnt; - url->dvec = tmp_url->dvec; - url->unanchored = tmp_url->unanchored; - - return JB_ERR_OK; - -} - - -/********************************************************************* - * - * Function : free_url - * - * Description : Called from the "unloaders". Freez the url - * structure elements. - * - * Parameters : - * 1 : url = pointer to a url_spec structure. - * - * Returns : N/A - * - *********************************************************************/ -void free_url(struct url_spec *url) -{ - if (url == NULL) return; - - freez(url->spec); - freez(url->domain); - freez(url->dbuf); - freez(url->dvec); - freez(url->path); -#ifdef REGEX - if (url->preg) - { - regfree(url->preg); - freez(url->preg); - } -#endif - -} - - /********************************************************************* * * Function : check_file_changed @@ -568,11 +417,11 @@ int check_file_changed(const struct file_list * current, && (current->lastmodified == statbuf->st_mtime) && (0 == strcmp(current->filename, filename))) { - return 0; + /* force reload of configfile and all the logs */ + if ( !MustReload ) return 0; } fs = (struct file_list *)zalloc(sizeof(struct file_list)); - if (fs == NULL) { /* Out of memory error */ @@ -588,11 +437,8 @@ int check_file_changed(const struct file_list * current, freez (fs); return 1; } - - *newfl = fs; return 1; - } @@ -714,7 +560,7 @@ static void unload_trustfile(void *f) unload_trustfile(b->next); /* Stack is cheap, isn't it? */ - free_url(b->url); + free_url_spec(b->url); freez(b); @@ -826,6 +672,7 @@ int load_trustfile(struct client_state *csp) if (trusted) { *tl++ = b->url; + /* FIXME BUFFER OVERFLOW if >=64 entries */ } }