Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

wap-maps.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

void wap_map_add_url (Octstr *name, Octstr *url, Octstr *map_url, Octstr *send_msisdn_query, Octstr *send_msisdn_header, Octstr *send_msisdn_format, int accept_cookies)
void wap_map_add_user (Octstr *name, Octstr *user, Octstr *pass, Octstr *msisdn)
void wap_map_destroy (void)
void wap_map_user_destroy (void)
void wap_map_url (Octstr **osp, Octstr **send_msisdn_query, Octstr **send_msisdn_header, Octstr **send_msisdn_format, int *accept_cookies)
int wap_map_user (Octstr **msisdn, Octstr *user, Octstr *pass)
void wap_map_url_config_device_home (char *to)
void wap_map_url_config (char *s)


Function Documentation

void wap_map_add_url Octstr name,
Octstr url,
Octstr map_url,
Octstr send_msisdn_query,
Octstr send_msisdn_header,
Octstr send_msisdn_format,
int  accept_cookies
 

Definition at line 101 of file wap-maps.c.

References gwlist_append(), gwlist_create, url_map_struct::name, and url_map.

Referenced by config_reload(), wap_map_url_config(), and wap_map_url_config_device_home().

00105                                          {
00106     struct url_map_struct *entry;
00107 
00108     if (url_map == NULL) 
00109         url_map = gwlist_create();
00110 
00111     entry = gw_malloc(sizeof(*entry));
00112     entry->name = name;
00113     entry->url = url;
00114     entry->map_url = map_url;
00115     entry->send_msisdn_query = send_msisdn_query;
00116     entry->send_msisdn_header = send_msisdn_header;
00117     entry->send_msisdn_format = send_msisdn_format;
00118     entry->accept_cookies = accept_cookies;
00119     
00120     gwlist_append(url_map, entry);
00121 }

Here is the call graph for this function:

void wap_map_add_user Octstr name,
Octstr user,
Octstr pass,
Octstr msisdn
 

Definition at line 136 of file wap-maps.c.

References dict_create(), dict_put(), user_map_struct::name, user_map, and wap_user_map_destroy().

Referenced by config_reload().

00137                                       {
00138     struct user_map_struct *entry;
00139 
00140     if (user_map == NULL) 
00141         user_map = dict_create(32, wap_user_map_destroy);
00142 
00143     entry = gw_malloc(sizeof(*entry));
00144     entry->name = name;
00145     entry->user = user;
00146     entry->pass = pass;
00147     entry->msisdn = msisdn;
00148     dict_put(user_map, entry->user, entry);
00149 }

Here is the call graph for this function:

void wap_map_destroy void   ) 
 

Definition at line 152 of file wap-maps.c.

References gwlist_destroy(), gwlist_get(), gwlist_len(), url_map_struct::map_url, url_map_struct::name, octstr_destroy(), url_map_struct::send_msisdn_format, url_map_struct::send_msisdn_header, url_map_struct::send_msisdn_query, url_map_struct::url, and url_map.

Referenced by config_reload(), main(), and wap_appl_shutdown().

00153 {
00154     long i;
00155     struct url_map_struct *entry;
00156 
00157     if (url_map != NULL) {
00158         for (i = 0; i < gwlist_len(url_map); i++) {
00159             entry = gwlist_get(url_map, i);
00160             octstr_destroy(entry->name);
00161             octstr_destroy(entry->url);
00162             octstr_destroy(entry->map_url);
00163             octstr_destroy(entry->send_msisdn_query);
00164             octstr_destroy(entry->send_msisdn_header);
00165             octstr_destroy(entry->send_msisdn_format);
00166             gw_free(entry);
00167         }
00168         gwlist_destroy(url_map, NULL);
00169     }
00170     url_map = NULL;
00171 }

Here is the call graph for this function:

void wap_map_url Octstr **  osp,
Octstr **  send_msisdn_query,
Octstr **  send_msisdn_header,
Octstr **  send_msisdn_format,
int *  accept_cookies
 

Definition at line 208 of file wap-maps.c.

References url_map_struct::accept_cookies, debug(), gwlist_get(), gwlist_len(), url_map_struct::map_url, octstr_append(), octstr_case_compare(), octstr_copy, octstr_delete(), octstr_destroy(), octstr_duplicate, octstr_get_char(), octstr_get_cstr, octstr_len(), url_map_struct::send_msisdn_format, url_map_struct::send_msisdn_header, url_map_struct::send_msisdn_query, url_map_struct::url, and url_map.

Referenced by start_fetch().

00211 {
00212     long i;
00213     Octstr *newurl, *tmp1, *tmp2;
00214 
00215     newurl = tmp1 = tmp2 = NULL;
00216     *send_msisdn_query = *send_msisdn_header = *send_msisdn_format = NULL;
00217     *accept_cookies = -1;
00218 
00219     debug("wsp",0,"WSP: Mapping url <%s>", octstr_get_cstr(*osp));
00220     for (i = 0; url_map && i < gwlist_len(url_map); i++) {
00221         struct url_map_struct *entry;
00222         entry = gwlist_get(url_map, i);
00223 
00224         /* 
00225         debug("wsp",0,"WSP: matching <%s> with <%s>", 
00226               octstr_get_cstr(entry->url), octstr_get_cstr(entry->map_url)); 
00227         */
00228 
00229         /* DAVI: I only have '*' terminated entry->url implementation for now */
00230         tmp1 = octstr_duplicate(entry->url);
00231         octstr_delete(tmp1, octstr_len(tmp1)-1, 1); /* remove last '*' */
00232         tmp2 = octstr_copy(*osp, 0, octstr_len(tmp1));
00233 
00234         debug("wsp",0,"WSP: Matching <%s> with <%s>", 
00235               octstr_get_cstr(tmp1), octstr_get_cstr(tmp2));
00236 
00237         if (octstr_case_compare(tmp2, tmp1) == 0) {
00238             /* rewrite url if configured to do so */
00239             if (entry->map_url != NULL) {
00240                 if (octstr_get_char(entry->map_url, 
00241                                     octstr_len(entry->map_url)-1) == '*') {
00242                     newurl = octstr_duplicate(entry->map_url);
00243                     octstr_delete(newurl, octstr_len(newurl)-1, 1);
00244                     octstr_append(newurl, octstr_copy(*osp, 
00245                     octstr_len(entry->url)-1, 
00246                     octstr_len(*osp)-octstr_len(entry->url)+1));
00247                 } else {
00248                     newurl = octstr_duplicate(entry->map_url);
00249                 }
00250                 debug("wsp",0,"WSP: URL Rewriten from <%s> to <%s>", 
00251                       octstr_get_cstr(*osp), octstr_get_cstr(newurl));
00252                 octstr_destroy(*osp);
00253                 *osp = newurl;
00254             }
00255             *accept_cookies = entry->accept_cookies;
00256             *send_msisdn_query = octstr_duplicate(entry->send_msisdn_query);
00257             *send_msisdn_header = octstr_duplicate(entry->send_msisdn_header);
00258             *send_msisdn_format = octstr_duplicate(entry->send_msisdn_format);
00259             octstr_destroy(tmp1);
00260             octstr_destroy(tmp2);
00261             break;
00262         }
00263         octstr_destroy(tmp1);
00264         octstr_destroy(tmp2);
00265     }
00266 }

Here is the call graph for this function:

void wap_map_url_config char *  s  ) 
 

Definition at line 185 of file wap-maps.c.

References octstr_create, octstr_imm(), and wap_map_add_url().

Referenced by config_reload().

00186 {
00187     char *in, *out;
00188     
00189     s = gw_strdup(s);
00190     in = strtok(s, " \t");
00191     if (!in) 
00192         return;
00193     out = strtok(NULL, " \t");
00194     if (!out) 
00195         return;
00196     wap_map_add_url(octstr_imm("unknown"), octstr_create(in), 
00197                      octstr_create(out), NULL, NULL, NULL, 0);
00198     gw_free(s);
00199 }

Here is the call graph for this function:

void wap_map_url_config_device_home char *  to  ) 
 

Definition at line 201 of file wap-maps.c.

References octstr_create, octstr_imm(), and wap_map_add_url().

Referenced by config_reload().

00202 {
00203     wap_map_add_url(octstr_imm("Device Home"), octstr_imm("DEVICE:home*"),
00204                      octstr_create(to), NULL, NULL, NULL, -1);
00205 }

Here is the call graph for this function:

int wap_map_user Octstr **  msisdn,
Octstr user,
Octstr pass
 

Definition at line 268 of file wap-maps.c.

References dict_get(), user_map_struct::msisdn, octstr_compare(), octstr_duplicate, user_map_struct::pass, and user_map.

00269 {
00270     struct user_map_struct *entry;
00271 
00272     entry = dict_get(user_map, user);
00273     if (entry != NULL && octstr_compare(pass, entry->pass) == 0) {
00274         *msisdn = octstr_duplicate(entry->msisdn);
00275         return 1;
00276     }
00277     return 0;
00278 }

Here is the call graph for this function:

void wap_map_user_destroy void   ) 
 

Definition at line 174 of file wap-maps.c.

References dict_destroy(), and user_map.

Referenced by config_reload(), main(), and wap_appl_shutdown().

00175 {
00176     dict_destroy(user_map);
00177     user_map = NULL;
00178 }

Here is the call graph for this function:

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.