-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.27 2001/11/07 00:02:13 steudten Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.28 2001/12/30 14:07:32 steudten Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
*
* Revisions :
* $Log: loadcfg.c,v $
+ * Revision 1.28 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.27 2001/11/07 00:02:13 steudten
* Add line number in error output for lineparsing for
* actionsfile and configfile.
#include "errlog.h"
#include "ssplit.h"
#include "encode.h"
+#include "urlmatch.h"
const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
while (cur_fwd != NULL)
{
struct forward_spec * next_fwd = cur_fwd->next;
- free_url(cur_fwd->url);
+ free_url_spec(cur_fwd->url);
freez(cur_fwd->gateway_host);
freez(cur_fwd->forward_host);
-const char loaders_rcs[] = "$Id: loaders.c,v 1.33 2001/11/13 00:16:38 jongfoster 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)
#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
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 */
}
}
#ifndef LOADERS_H_INCLUDED
#define LOADERS_H_INCLUDED
-#define LOADERS_H_VERSION "$Id: loaders.h,v 1.12 2001/11/07 00:02:13 steudten Exp $"
+#define LOADERS_H_VERSION "$Id: loaders.h,v 1.13 2001/12/30 14:07:32 steudten Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loaders.h,v $
*
* Revisions :
* $Log: loaders.h,v $
+ * Revision 1.13 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.12 2001/11/07 00:02:13 steudten
* Add line number in error output for lineparsing for
* actionsfile and configfile.
-extern jb_err create_url_spec(struct url_spec * url, char * buf);
-extern void free_url(struct url_spec *url);
-
extern void add_loader(int (*loader)(struct client_state *),
struct configuration_spec * config);
extern int run_loader(struct client_state *csp);