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

Function cpl_init

modules/cpl_c/cpl.c:267–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265
266
267static int cpl_init(void)
268{
269 bind_usrloc_t bind_usrloc;
270 struct stat stat_t;
271 char *ptr;
272 int val;
273
274 init_db_url( db_url , 0 /*cannot be null*/);
275 db_table.len = strlen(db_table.s);
276 cpl_username_col.len = strlen(cpl_username_col.s);
277 cpl_domain_col.len = strlen(cpl_domain_col.s);
278 cpl_xml_col.len = strlen(cpl_xml_col.s);
279 cpl_bin_col.len = strlen(cpl_bin_col.s);
280
281 LM_INFO("initializing...\n");
282
283 if (proxy_route && proxy_route[0]) {
284 cpl_env.proxy_route = ref_script_route_by_name( proxy_route,
285 sroutes->request, RT_NO, REQUEST_ROUTE, 0);
286 if (!ref_script_route_is_valid(cpl_env.proxy_route)) {
287 LM_ERR("route <%s> does not exist\n",proxy_route);
288 return -1;
289 }
290 }
291
292 if (cpl_env.proxy_recurse>MAX_PROXY_RECURSE) {
293 LM_CRIT("value of proxy_recurse param (%d) exceeds "
294 "the maximum safety value (%d)\n",
295 cpl_env.proxy_recurse,MAX_PROXY_RECURSE);
296 goto error;
297 }
298
299 if (dtd_file==0) {
300 LM_CRIT("mandatory parameter \"cpl_dtd_file\" found empty\n");
301 goto error;
302 } else {
303 /* check if the dtd file exists */
304 if (stat( dtd_file, &stat_t)==-1) {
305 LM_ERR("checking file \"%s\" status failed; stat returned %s\n",
306 dtd_file,strerror(errno));
307 goto error;
308 }
309 if ( !S_ISREG( stat_t.st_mode ) ) {
310 LM_ERR("dir \"%s\" is not a regular file!\n", dtd_file);
311 goto error;
312 }
313 if (access( dtd_file, R_OK )==-1) {
314 LM_ERR("checking file \"%s\" for permissions "
315 "failed; access returned %s\n",dtd_file,strerror(errno));
316 goto error;
317 }
318 }
319
320 if (cpl_env.log_dir==0) {
321 LM_INFO("log_dir param found empty -> logging disabled!\n");
322 } else {
323 if ( strlen(cpl_env.log_dir)>MAX_LOG_DIR_SIZE ) {
324 LM_ERR("dir \"%s\" has a too long name :-(!\n", cpl_env.log_dir);

Callers

nothing calls this directly

Calls 10

ref_script_route_by_nameFunction · 0.85
cpl_db_bindFunction · 0.85
load_tm_apiFunction · 0.85
load_sig_apiFunction · 0.85
find_exportFunction · 0.85
bind_usrlocFunction · 0.85
init_CPL_parserFunction · 0.85
shm_mallocFunction · 0.85
strlowerFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected