| 151 | |
| 152 | |
| 153 | static int mod_init(void) |
| 154 | { |
| 155 | int i; |
| 156 | |
| 157 | if (filename.s==NULL) { |
| 158 | LM_ERR("invalid framework\n"); |
| 159 | return -1; |
| 160 | } |
| 161 | filename.len = strlen(filename.s); |
| 162 | |
| 163 | http_root.len = strlen(http_root.s); |
| 164 | |
| 165 | if (http_method<0 || http_method>1) { |
| 166 | LM_ERR("pi_http_method can be between [0,1]\n"); |
| 167 | return -1; |
| 168 | } |
| 169 | |
| 170 | /* Load httpd api */ |
| 171 | if(load_httpd_api(&httpd_api)<0) { |
| 172 | LM_ERR("Failed to load httpd api\n"); |
| 173 | return -1; |
| 174 | } |
| 175 | /* Load httpd hooks */ |
| 176 | httpd_api.register_httpdcb(exports.name, &http_root, |
| 177 | &ph_answer_to_connection, |
| 178 | &ph_flush_data, |
| 179 | HTTPD_TEXT_HTML_TYPE, |
| 180 | &proc_init); |
| 181 | |
| 182 | /* Build a cache of all provisionning commands */ |
| 183 | if (0!=ph_init_cmds(&ph_framework_data, filename.s)) |
| 184 | return -1; |
| 185 | |
| 186 | /* init db connections */ |
| 187 | for(i=0;i<ph_framework_data->ph_db_urls_size;i++){ |
| 188 | ph_framework_data->ph_db_urls[i].http_db_handle = |
| 189 | pkg_malloc(sizeof(db_con_t *)); |
| 190 | *ph_framework_data->ph_db_urls[i].http_db_handle = 0; |
| 191 | |
| 192 | LM_DBG("initializing db[%d] [%s]\n", |
| 193 | i, ph_framework_data->ph_db_urls[i].db_url.s); |
| 194 | if (init_http_db(ph_framework_data, i)!=0) { |
| 195 | LM_ERR("failed to initialize the DB support\n"); |
| 196 | return -1; |
| 197 | } |
| 198 | |
| 199 | |
| 200 | } |
| 201 | |
| 202 | /* Build async lock */ |
| 203 | if (ph_init_async_lock() != 0) exit(-1); |
| 204 | |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | static int child_init(int rank) |
| 209 | { |
nothing calls this directly
no test coverage detected