diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-09-14 23:43:59 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-09-14 23:43:59 +0000 |
commit | 9d61e1fd4b8a32fbf966aed7d5ea3cecac1c9d52 (patch) | |
tree | 350b97018c1afd6aaa5231dfb98d8b0dccfe1bb4 /src | |
parent | ea4d707d129d45c3cfb2f3d78370f04cb97fe47d (diff) |
Removed these files since their functionality has been replaced.
Diffstat (limited to 'src')
-rw-r--r-- | src/uri.c | 119 | ||||
-rw-r--r-- | src/uri.h | 32 |
2 files changed, 0 insertions, 151 deletions
diff --git a/src/uri.c b/src/uri.c deleted file mode 100644 index a14b0ad..0000000 --- a/src/uri.c +++ /dev/null @@ -1,119 +0,0 @@ -/* $Id: uri.c,v 1.6 2001-09-11 04:13:58 rjkaes Exp $ - * - * This borrows the REGEX from RFC2396 to split a URI string into the five - * primary components. The components are: - * scheme the uri method (like "http", "ftp", "gopher") - * authority the domain and optional ":" port - * path path to the document/resource - * query an optional query (separated with a "?") - * fragment an optional fragement (separated with a "#") - * - * Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ - -#include "tinyproxy.h" - -#include "log.h" -#include "regexp.h" -#include "uri.h" -#include "utils.h" - -#define NMATCH 10 - -#define URIPATTERN "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?" - -#define SCHEME 2 -#define AUTHORITY 4 -#define PATH 5 -#define QUERY_MARK 6 -#define QUERY 7 -#define FRAGMENT_MARK 8 -#define FRAGMENT 9 - -static int extract_uri(regmatch_t pmatch[], const char *buffer, char **section, - int substring) -{ - size_t len = pmatch[substring].rm_eo - pmatch[substring].rm_so; - if ((*section = safecalloc(sizeof(char), len + 1)) == NULL) { - log_message(LOG_ERR, "Could not allocate memory for extracting URI."); - return -1; - } - - memcpy(*section, buffer + pmatch[substring].rm_so, len); - - return 0; -} - -void free_uri(URI * uri) -{ - safefree(uri->scheme); - safefree(uri->authority); - safefree(uri->path); - safefree(uri->query); - safefree(uri->fragment); - safefree(uri); -} - -URI *explode_uri(const char *string) -{ - URI *uri; - regmatch_t pmatch[NMATCH]; - regex_t preg; - - if (regcomp(&preg, URIPATTERN, REG_EXTENDED) != 0) { - log_message(LOG_ERR, "Regular Expression compiler error."); - return NULL; - } - - if (regexec(&preg, string, NMATCH, pmatch, 0) != 0) { - log_message(LOG_ERR, "Regular Expression search error."); - regfree(&preg); - return NULL; - } - - regfree(&preg); - - if (!(uri = safecalloc(1, sizeof(URI)))) - return NULL; - - if (pmatch[SCHEME].rm_so != -1) { - if (extract_uri(pmatch, string, &uri->scheme, SCHEME) < 0) - goto ERROR_EXIT; - } - - if (pmatch[AUTHORITY].rm_so != -1) { - if (extract_uri(pmatch, string, &uri->authority, AUTHORITY) < 0) - goto ERROR_EXIT; - } - - if (pmatch[PATH].rm_so != -1) { - if (extract_uri(pmatch, string, &uri->path, PATH) < 0) - goto ERROR_EXIT; - } - - if (pmatch[QUERY_MARK].rm_so != -1) { - if (extract_uri(pmatch, string, &uri->query, QUERY) < 0) - goto ERROR_EXIT; - } - - if (pmatch[FRAGMENT_MARK].rm_so != -1) { - if (extract_uri(pmatch, string, &uri->fragment, FRAGMENT) < 0) - goto ERROR_EXIT; - } - - return uri; - - ERROR_EXIT: - free_uri(uri); - return NULL; -} diff --git a/src/uri.h b/src/uri.h deleted file mode 100644 index a66bb3c..0000000 --- a/src/uri.h +++ /dev/null @@ -1,32 +0,0 @@ -/* $Id: uri.h,v 1.2 2000-09-11 23:57:43 rjkaes Exp $ - * - * See 'uri.c' for a detailed description. - * - * Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ - -#ifndef _TINYPROXY_URI_H_ -#define _TINYPROXY_URI_H_ - -typedef struct { - char *scheme; - char *authority; - char *path; - char *query; - char *fragment; -} URI; - -extern URI *explode_uri(const char *string); -extern void free_uri(URI *uri); - -#endif |