textops/api.c
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
00025
00026 #include "api.h"
00027 #include "textops.h"
00028 #include "../../mod_fix.h"
00029 #include "../../mem/mem.h"
00030
00031
00032
00033
00034
00035
00036 int append_hf_api(struct sip_msg *msg, str* str_hf){
00037 return add_hf_helper(msg, str_hf, NULL, NULL, 0, NULL);
00038 }
00039
00040
00041
00042
00043
00044 int remove_hf_api(struct sip_msg *msg, str* str_hf){
00045 return remove_hf_f(msg, (char*)str_hf,NULL);
00046 }
00047
00048
00049
00050
00051
00052
00053
00054 int search_append_api(struct sip_msg *msg, str *regex, str *data_str){
00055 int retval;
00056
00057 char *data=pkg_malloc(data_str->len+1);
00058 memcpy(data,data_str->s,data_str->len);
00059 memset(data+data_str->len,0,1);
00060
00061 void **param=pkg_malloc(sizeof(void*));
00062 *param=pkg_malloc(regex->len+1);
00063 memcpy(*param,regex->s,regex->len);
00064 memset(*param+regex->len,0,1);
00065
00066 fixup_regexp_none(param,1);
00067
00068 retval=search_append_f(msg, *param, data);
00069
00070 fixup_free_regexp_none(param,1);
00071
00072 pkg_free(param);
00073 pkg_free(data);
00074
00075 return retval;
00076
00077 }
00078
00079
00080
00081
00082 int search_api(struct sip_msg *msg, str *regex){
00083 int retval;
00084
00085 void **param=pkg_malloc(sizeof(void*));
00086
00087 *param=pkg_malloc(regex->len+1);
00088 memcpy(*param,regex->s,regex->len);
00089 memset(*param+regex->len,0,1);
00090
00091 fixup_regexp_none(param,1);
00092
00093 retval=search_f(msg, *param, NULL);
00094
00095 fixup_free_regexp_none(param,1);
00096 pkg_free(param);
00097
00098 return retval;
00099
00100 }
00101
00102
00103
00104 int load_textops(struct textops_binds *tob){
00105 if(tob==NULL){
00106 LM_WARN("textops_binds: Cannot load textops API into a NULL pointer\n");
00107 return -1;
00108 }
00109 tob->append_hf=append_hf_api;
00110 tob->remove_hf=remove_hf_api;
00111 tob->search_append=search_append_api;
00112 tob->search=search_api;
00113 return 0;
00114 }