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

Function get_skill_id

modules/call_center/cc_data.c:53–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52
53unsigned int get_skill_id(struct cc_data *data, str *name)
54{
55 struct cc_skill *skill;
56
57 /* search to see if exists */
58 for ( skill=data->skills_map ; skill ; skill=skill->next ) {
59 if ( (skill->name.len==name->len) &&
60 (memcmp(skill->name.s,name->s,name->len)==0) )
61 return skill->id;
62 }
63
64 /* none found, allocate a new one */
65 skill = (struct cc_skill*)shm_malloc( sizeof(struct cc_skill)+name->len );
66 if (skill==NULL) {
67 LM_ERR("no enough shm mem for a new skill map\n");
68 return 0;
69 }
70
71 skill->is_new = 1;
72 skill->name.s = (char*)(skill+1);
73 skill->name.len = name->len;
74 memcpy( skill->name.s , name->s, name->len);
75
76 skill->id = ++(data->last_skill_id);
77
78 /* link it */
79 skill->next = data->skills_map;
80 data->skills_map = skill;
81
82 return skill->id;
83}
84
85
86str* get_skill_by_id(struct cc_data *data, unsigned int id)

Callers 2

add_cc_flowFunction · 0.85
add_cc_agentFunction · 0.85

Calls 1

shm_mallocFunction · 0.85

Tested by

no test coverage detected