Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _URL_MAPPING_H_
00025 #define _URL_MAPPING_H_
00026
00027 #include "AclFiltering.h"
00028 #include "Main.h"
00029 #include "Error.h"
00030 #include "URL.h"
00031 #include "RemapPluginInfo.h"
00032
00033 #ifdef HAVE_PCRE_PCRE_H
00034 #include <pcre/pcre.h>
00035 #else
00036 #include <pcre.h>
00037 #endif
00038
00039 static const unsigned int MAX_REMAP_PLUGIN_CHAIN = 10;
00040
00041
00042
00043
00044
00045 class referer_info
00046 {
00047 public:
00048 referer_info(char *_ref, bool * error_flag = NULL, char *errmsgbuf = NULL, int errmsgbuf_size = 0);
00049 ~referer_info();
00050 referer_info *next;
00051 char *referer;
00052 int referer_size;
00053 bool any;
00054 bool negative;
00055 bool regx_valid;
00056 pcre* regx;
00057 };
00058
00059
00060
00061
00062 class redirect_tag_str
00063 {
00064 public:
00065 redirect_tag_str()
00066 : next(0), chunk_str(NULL), type(0)
00067 { }
00068
00069 ~redirect_tag_str()
00070 {
00071 type = 0;
00072 if (chunk_str) {
00073 ats_free(chunk_str);
00074 chunk_str = NULL;
00075 }
00076 }
00077
00078 redirect_tag_str *next;
00079 char *chunk_str;
00080 char type;
00081 static redirect_tag_str *parse_format_redirect_url(char *url);
00082 };
00083
00084
00085
00086
00087 class url_mapping
00088 {
00089 public:
00090 url_mapping(int rank = 0);
00091 ~url_mapping();
00092
00093 bool add_plugin(remap_plugin_info *i, void* ih);
00094 remap_plugin_info *get_plugin(unsigned int) const;
00095
00096 void* get_instance(unsigned int index) const { return _instance_data[index]; };
00097 void delete_instance(unsigned int index);
00098 void Print();
00099
00100 int from_path_len;
00101 URL fromURL;
00102 URL toUrl;
00103 bool homePageRedirect;
00104 bool unique;
00105 bool default_redirect_url;
00106 bool optional_referer;
00107 bool negative_referer;
00108 bool wildcard_from_scheme;
00109 char *tag;
00110 char *filter_redirect_url;
00111 unsigned int map_id;
00112 referer_info *referer_list;
00113 redirect_tag_str *redir_chunk_list;
00114 acl_filter_rule *filter;
00115 unsigned int _plugin_count;
00116 LINK(url_mapping, link);
00117
00118 int getRank() const { return _rank; };
00119
00120 private:
00121 remap_plugin_info* _plugin_list[MAX_REMAP_PLUGIN_CHAIN];
00122 void* _instance_data[MAX_REMAP_PLUGIN_CHAIN];
00123 int _rank;
00124 };
00125
00126
00127
00128
00129
00130
00131 class UrlMappingContainer {
00132 public:
00133 UrlMappingContainer()
00134 : _mapping(NULL), _toURLPtr(NULL), _heap(NULL)
00135 { }
00136
00137 explicit UrlMappingContainer(HdrHeap *heap)
00138 : _mapping(NULL), _toURLPtr(NULL), _heap(heap)
00139 { }
00140
00141 ~UrlMappingContainer() { deleteToURL(); }
00142
00143 URL * getToURL() const { return _toURLPtr; };
00144 URL * getFromURL() const { return _mapping ? &(_mapping->fromURL) : NULL; };
00145
00146 url_mapping *getMapping() const { return _mapping; };
00147
00148 void set(url_mapping *m) {
00149 deleteToURL();
00150 _mapping = m;
00151 _toURLPtr = m ? &(m->toUrl) : NULL;
00152 }
00153
00154 void set(HdrHeap *heap) {
00155 _heap = heap;
00156 }
00157
00158 URL *createNewToURL() {
00159 ink_assert(_heap != NULL);
00160 deleteToURL();
00161 _toURL.create(_heap);
00162 _toURLPtr = &_toURL;
00163 return _toURLPtr;
00164 }
00165
00166 void deleteToURL() {
00167 if (_toURLPtr == &_toURL) {
00168 _toURL.clear();
00169 }
00170 }
00171
00172 void clear() {
00173 deleteToURL();
00174 _mapping = NULL;
00175 _toURLPtr = NULL;
00176 _heap = NULL;
00177 }
00178
00179 private:
00180 url_mapping *_mapping;
00181 URL *_toURLPtr;
00182 URL _toURL;
00183 HdrHeap *_heap;
00184
00185
00186 UrlMappingContainer(const UrlMappingContainer &orig);
00187 UrlMappingContainer &operator =(const UrlMappingContainer &rhs);
00188 };
00189
00190 #endif