-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 $
*
* 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
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
-#include <malloc.h>
#include <errno.h>
#include <sys/stat.h>
#include <ctype.h>
#include "miscutil.h"
#include "errlog.h"
#include "actions.h"
+#include "urlmatch.h"
const char loaders_h_rcs[] = LOADERS_H_VERSION;
}
-/*********************************************************************
- *
- * 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
&& (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 */
freez (fs);
return 1;
}
-
-
*newfl = fs;
return 1;
-
}
unload_trustfile(b->next); /* Stack is cheap, isn't it? */
- free_url(b->url);
+ free_url_spec(b->url);
freez(b);
if (trusted)
{
*tl++ = b->url;
+ /* FIXME BUFFER OVERFLOW if >=64 entries */
}
}