| 249 | |
| 250 | |
| 251 | int add_cc_flow( struct cc_data *data, str *id, int priority, str *skill, |
| 252 | str *cid, int max_wrapup, int diss_hangup, int diss_ewt_th, |
| 253 | int diss_qsize_th, int diss_onhold_th, str *recordings ) |
| 254 | { |
| 255 | struct cc_flow *flow, *prev_flow; |
| 256 | unsigned int i; |
| 257 | unsigned int skill_id; |
| 258 | #ifdef STATISTICS |
| 259 | char *name; |
| 260 | str s; |
| 261 | #endif |
| 262 | |
| 263 | /* is the flow a new one? - search by ID */ |
| 264 | flow = get_flow_by_name( data, id); |
| 265 | |
| 266 | if (flow==NULL) { |
| 267 | /* new flow -> create and populate one */ |
| 268 | flow = (struct cc_flow*)shm_malloc(sizeof(struct cc_flow)+id->len); |
| 269 | if (flow==NULL) { |
| 270 | LM_ERR("not enough shmem for a new flow\n"); |
| 271 | goto error; |
| 272 | } |
| 273 | memset( flow, 0, sizeof(struct cc_flow) ); |
| 274 | /* id */ |
| 275 | flow->id.s = (char*)(flow+1); |
| 276 | memcpy( flow->id.s, id->s, id->len); |
| 277 | flow->id.len = id->len; |
| 278 | /* priority */ |
| 279 | flow->priority = priority; |
| 280 | /* max wrapup time */ |
| 281 | flow->max_wrapup = max_wrapup; |
| 282 | /* dissuading related options */ |
| 283 | flow->diss_hangup = diss_hangup; |
| 284 | flow->diss_ewt_th = diss_ewt_th; |
| 285 | flow->diss_qsize_th = diss_qsize_th; |
| 286 | flow->diss_onhold_th = diss_onhold_th; |
| 287 | /* skill */ |
| 288 | flow->skill = get_skill_id( data, skill ); |
| 289 | if (flow->skill==0) { |
| 290 | LM_ERR("cannot get skill id\n"); |
| 291 | goto error; |
| 292 | } |
| 293 | /* cid */ |
| 294 | if (cid && cid->s && cid->len) { |
| 295 | flow->cid.s = (char*)shm_malloc(cid->len); |
| 296 | if (flow->cid.s==NULL) { |
| 297 | LM_ERR("not enough shmem for the cid of the flow\n"); |
| 298 | goto error; |
| 299 | } |
| 300 | memcpy( flow->cid.s, cid->s, cid->len); |
| 301 | flow->cid.len = cid->len; |
| 302 | } |
| 303 | /* audio messages */ |
| 304 | for( i=0 ; i<MAX_AUDIO ; i++ ) { |
| 305 | if (recordings[i].s && recordings[i].len) { |
| 306 | flow->recordings[i].s = (char*)shm_malloc(recordings[i].len); |
| 307 | if (flow->recordings[i].s==NULL) { |
| 308 | LM_ERR("not enough shmem for the message %d of the flow\n", |
no test coverage detected