-}
-
-
-/*********************************************************************\r
- *\r
- * Function : create_url_spec\r
- *\r
- * Description : Creates a "url_spec" structure from a string.\r
- * When finished, free with unload_url().\r
- *\r
- * Parameters :\r
- * 1 : url = Target url_spec to be filled in. Must be\r
- * zeroed out before the call (e.g. using zalloc).\r
- * 2 : buf = Source pattern, null terminated. NOTE: The\r
- * contents of this buffer are destroyed by this\r
- * function. If this function succeeds, the\r
- * buffer is copied to url->spec. If this\r
- * function fails, the contents of the buffer\r
- * are lost forever.\r
- *\r
- * Returns : 0 => Ok, everything else is an error.\r
- *\r
- *********************************************************************/\r
-static int create_url_spec(struct url_spec * url, char * buf)\r
-{\r
- char *p;\r
- struct url_spec tmp_url[1];\r
-\r
- /* paranoia - should never happen. */\r
- if ((url == NULL) || (buf == NULL))\r
- {\r
- return 1;\r
- }\r
-\r
- /* save a copy of the orignal specification */\r
- if ((url->spec = strdup(buf)) == NULL)\r
- {\r
- return 1;\r
- }\r
-\r
- if ((p = strchr(buf, '/')))\r
- {\r
- if (NULL == (url->path = strdup(p)))\r
- {\r
- freez(url->spec);\r
- return 1;\r
- }\r
- url->pathlen = strlen(url->path);\r
- *p = '\0';\r
- }\r
- else\r
- {\r
- url->path = NULL;\r
- url->pathlen = 0;\r
- }\r
-#ifdef REGEX\r
- if (url->path)\r
- {\r
- int errcode;\r
- char rebuf[BUFSIZ];\r
-\r
- if (NULL == (url->preg = zalloc(sizeof(*url->preg))))\r
- {\r
- freez(url->spec);\r
- freez(url->path);\r
- return 1;\r
- }\r
-\r
- sprintf(rebuf, "^(%s)", url->path);\r
-\r
- errcode = regcomp(url->preg, rebuf,\r
- (REG_EXTENDED|REG_NOSUB|REG_ICASE));\r
- if (errcode)\r
- {\r
- size_t errlen =\r
- regerror(errcode,\r
- url->preg, buf, sizeof(buf));\r
-\r
- buf[errlen] = '\0';\r
-\r
- log_error(LOG_LEVEL_ERROR, "error compiling %s: %s",\r
- url->spec, buf);\r
-\r
- freez(url->spec);\r
- freez(url->path);\r
- freez(url->preg);\r
-\r
- return 1;\r
- }\r
- }\r
-#endif\r
- if ((p = strchr(buf, ':')) == NULL)\r
- {\r
- url->port = 0;\r
- }\r
- else\r
- {\r
- *p++ = '\0';\r
- url->port = atoi(p);\r
- }\r
-\r
- if ((url->domain = strdup(buf)) == NULL)\r
- {\r
- freez(url->spec);\r
- freez(url->path);\r
-#ifdef REGEX\r
- freez(url->preg);\r
-#endif /* def REGEX */\r
- return 1;\r
- }\r
-\r
- /* split domain into components */\r
-\r
- *tmp_url = dsplit(url->domain);\r
- url->dbuf = tmp_url->dbuf;\r
- url->dcnt = tmp_url->dcnt;\r
- url->dvec = tmp_url->dvec;\r
-\r
- return 0; /* OK */\r
-}\r
-\r
-\r
-/*********************************************************************
- *
- * Function : unload_url
- *
- * Description : Called from the "unloaders". Freez the url
- * structure elements.
- *
- * Parameters :
- * 1 : url = pointer to a url_spec structure.
- *
- * Returns : N/A
- *
- *********************************************************************/
-static void unload_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
-
-}
-
-
-#ifdef ACL_FILES
-/*********************************************************************
- *
- * Function : unload_aclfile
- *
- * Description : Unloads an aclfile.
- *
- * Parameters :
- * 1 : f = the data structure associated with the aclfile.
- *
- * Returns : N/A
- *
- *********************************************************************/
-static void unload_aclfile(void *f)
-{
- struct access_control_list *b = (struct access_control_list *)f;
- if (b == NULL) return;
-
- unload_aclfile(b->next);
-
- freez(b);
-
-}
-#endif /* def ACL_FILES */
-
-/*********************************************************************
- *
- * Function : unload_blockfile
- *
- * Description : Unloads a blockfile.
- *
- * Parameters :
- * 1 : f = the data structure associated with the blockfile.
- *
- * Returns : N/A
- *
- *********************************************************************/
-static void unload_blockfile(void *f)
-{
- struct block_spec *b = (struct block_spec *)f;
- if (b == NULL) return;
-
- unload_blockfile(b->next);
-
- unload_url(b->url);
-
- freez(b);
-
-}
-
-
-#ifdef USE_IMAGE_LIST
-/*********************************************************************
- *
- * Function : unload_imagefile
- *
- * Description : Unloads an imagefile.
- *
- * Parameters :
- * 1 : f = the data structure associated with the imagefile.
- *
- * Returns : N/A
- *
- *********************************************************************/
-static void unload_imagefile(void *f)
-{
- struct block_spec *b = (struct block_spec *)f;
- if (b == NULL) return;
-
- unload_imagefile(b->next);
-
- unload_url(b->url);
-
- freez(b);
-
-}
-#endif /* def USE_IMAGE_LIST */
-
-
-/*********************************************************************
- *
- * Function : unload_permissions_file
- *
- * Description : Unloads a permissions file.
- *
- * Parameters :
- * 1 : file_data = the data structure associated with the\r
- * permissions file.
- *
- * Returns : N/A
- *
- *********************************************************************/
-static void unload_permissions_file(void *file_data)
-{\r
- struct permissions_spec * next;
- struct permissions_spec * cur = (struct permissions_spec *)file_data;
- while (cur != NULL)\r
- {\r
- next = cur->next;
- unload_url(cur->url);
- freez(cur);\r
- cur = next;\r
- }
-
-}
-
-
-#ifdef TRUST_FILES
-/*********************************************************************
- *
- * Function : unload_trustfile
- *
- * Description : Unloads a trustfile.
- *
- * Parameters :
- * 1 : f = the data structure associated with the trustfile.
- *
- * Returns : N/A
- *
- *********************************************************************/
-static void unload_trustfile(void *f)
-{
- struct block_spec *b = (struct block_spec *)f;
- if (b == NULL) return;
-
- unload_trustfile(b->next);
-
- unload_url(b->url);
-
- freez(b);
-
-}
-#endif /* def TRUST_FILES */
-
-
-/*********************************************************************
- *
- * Function : unload_forwardfile
- *
- * Description : Unloads a forwardfile.
- *
- * Parameters :
- * 1 : f = the data structure associated with the forwardfile.
- *
- * Returns : N/A
- *
- *********************************************************************/
-static void unload_forwardfile(void *f)
-{
- struct forward_spec *b = (struct forward_spec *)f;
- if (b == NULL) return;
-
- unload_forwardfile(b->next);
-
- unload_url(b->url);
-
- freez(b->gw->gateway_host);
- freez(b->gw->forward_host);
-
- freez(b);
-
-}
-
-
-#ifdef PCRS
-/*********************************************************************
- *
- * Function : unload_re_filterfile
- *
- * Description : Unload the re_filter list.
- *
- * Parameters :
- * 1 : f = the data structure associated with the filterfile.
- *
- * Returns : N/A
- *
- *********************************************************************/
-static void unload_re_filterfile(void *f)
-{
- pcrs_job *joblist;
- struct re_filterfile_spec *b = (struct re_filterfile_spec *)f;
-
- if (b == NULL) return;
-
- destroy_list(b->patterns);
-
- joblist = b->joblist;
- while ( NULL != (joblist = pcrs_free_job(joblist)) ) {}
-
- freez(b);