| 265 | |
| 266 | |
| 267 | static 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); |
nothing calls this directly
no test coverage detected