MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / add_db_url

Function add_db_url

modules/sqlops/sqlops_db.c:83–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81
82
83int add_db_url(modparam_t type, void *val)
84{
85 char *param=(char*)val, *url=0;;
86 long idx;
87
88 if(!param)
89 return E_UNSPEC;
90 if(STR_PARAM & (type != STR_PARAM)){
91 LM_ERR("Expected string type parameter for DBX URL.\n");
92 return E_CFG;
93 }
94
95 idx = strtol(param, &url, 10);
96 if(param==url) {
97 /* default URL */
98 idx = 0;
99 }
100
101 while(isspace(*url)) url++;
102
103 if (no_db_urls==0) {
104 db_urls = (struct db_url*)pkg_malloc(sizeof(struct db_url));
105 } else {
106 if (get_db_url(idx)!=NULL) {
107 LM_ERR("db_url idx %ld overwritten (multiple definitions)\n",idx);
108 return E_CFG;
109 }
110 db_urls = (struct db_url*)pkg_realloc
111 (db_urls, (no_db_urls+1)*sizeof(struct db_url));
112 }
113
114 if (db_urls==NULL) {
115 LM_ERR("failed to alloc pkg array\n");
116 return E_OUT_OF_MEM;
117 }
118
119 memset(&db_urls[no_db_urls], '\0', sizeof *db_urls);
120
121 db_urls[no_db_urls].url.s = url;
122 db_urls[no_db_urls].url.len = strlen(url);
123 db_urls[no_db_urls].idx = idx;
124
125 no_db_urls++;
126
127 return 0;
128}
129
130
131

Callers 1

sqlops_initFunction · 0.85

Calls 1

get_db_urlFunction · 0.85

Tested by

no test coverage detected