Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 260883) +++ apps/app_queue.c (working copy) @@ -421,42 +421,40 @@ }; struct call_queue { - AST_DECLARE_STRING_FIELDS( - /*! Queue name */ - AST_STRING_FIELD(name); - /*! Music on Hold class */ - AST_STRING_FIELD(moh); - /*! Announcement to play when call is answered */ - AST_STRING_FIELD(announce); - /*! Exit context */ - AST_STRING_FIELD(context); - /*! Macro to run upon member connection */ - AST_STRING_FIELD(membermacro); - /*! Gosub to run upon member connection */ - AST_STRING_FIELD(membergosub); - /*! Default rule to use if none specified in call to Queue() */ - AST_STRING_FIELD(defaultrule); - /*! Sound file: "Your call is now first in line" (def. queue-youarenext) */ - AST_STRING_FIELD(sound_next); - /*! Sound file: "There are currently" (def. queue-thereare) */ - AST_STRING_FIELD(sound_thereare); - /*! Sound file: "calls waiting to speak to a representative." (def. queue-callswaiting) */ - AST_STRING_FIELD(sound_calls); - /*! Sound file: "The current estimated total holdtime is" (def. queue-holdtime) */ - AST_STRING_FIELD(sound_holdtime); - /*! Sound file: "minutes." (def. queue-minutes) */ - AST_STRING_FIELD(sound_minutes); - /*! Sound file: "minute." (def. queue-minute) */ - AST_STRING_FIELD(sound_minute); - /*! Sound file: "seconds." (def. queue-seconds) */ - AST_STRING_FIELD(sound_seconds); - /*! Sound file: "Thank you for your patience." (def. queue-thankyou) */ - AST_STRING_FIELD(sound_thanks); - /*! Sound file: Custom announce for caller, no default */ - AST_STRING_FIELD(sound_callerannounce); - /*! Sound file: "Hold time" (def. queue-reporthold) */ - AST_STRING_FIELD(sound_reporthold); - ); + /*! Queue name */ + char name[80]; + /*! Music on Hold class */ + char moh[80]; + /*! Announcement to play when call is answered */ + char announce[80]; + /*! Exit context */ + char context[AST_MAX_CONTEXT]; + /*! Macro to run upon member connection */ + char membermacro[AST_MAX_CONTEXT]; + /*! Gosub to run upon member connection */ + char membergosub[AST_MAX_CONTEXT]; + /*! Default rule to use if none specified in call to Queue() */ + char defaultrule[AST_MAX_CONTEXT]; + /*! Sound file: "Your call is now first in line" (def. queue-youarenext) */ + char sound_next[80]; + /*! Sound file: "There are currently" (def. queue-thereare) */ + char sound_thereare[80]; + /*! Sound file: "calls waiting to speak to a representative." (def. queue-callswaiting) */ + char sound_calls[80]; + /*! Sound file: "The current estimated total holdtime is" (def. queue-holdtime) */ + char sound_holdtime[80]; + /*! Sound file: "minutes." (def. queue-minutes) */ + char sound_minutes[80]; + /*! Sound file: "minute." (def. queue-minute) */ + char sound_minute[80]; + /*! Sound file: "seconds." (def. queue-seconds) */ + char sound_seconds[80]; + /*! Sound file: "Thank you for your patience." (def. queue-thankyou) */ + char sound_thanks[80]; + /*! Sound file: Custom announce for caller, no default */ + char sound_callerannounce[80]; + /*! Sound file: "Hold time" (def. queue-reporthold) */ + char sound_reporthold[80]; /*! Sound files: Custom announce, no default */ struct ast_str *sound_periodicannounce[MAX_PERIODIC_ANNOUNCEMENTS]; unsigned int dead:1; @@ -966,18 +964,23 @@ q->membercount = 0; q->found = 1; - ast_string_field_set(q, sound_next, "queue-youarenext"); - ast_string_field_set(q, sound_thereare, "queue-thereare"); - ast_string_field_set(q, sound_calls, "queue-callswaiting"); - ast_string_field_set(q, sound_holdtime, "queue-holdtime"); - ast_string_field_set(q, sound_minutes, "queue-minutes"); - ast_string_field_set(q, sound_minute, "queue-minute"); - ast_string_field_set(q, sound_seconds, "queue-seconds"); - ast_string_field_set(q, sound_thanks, "queue-thankyou"); - ast_string_field_set(q, sound_reporthold, "queue-reporthold"); + ast_copy_string(q->sound_next, "queue-youarenext", sizeof(q->sound_next)); + ast_copy_string(q->sound_thereare, "queue-thereare", sizeof(q->sound_thereare)); + ast_copy_string(q->sound_calls, "queue-callswaiting", sizeof(q->sound_calls)); + ast_copy_string(q->sound_holdtime, "queue-holdtime", sizeof(q->sound_holdtime)); + ast_copy_string(q->sound_minutes, "queue-minutes", sizeof(q->sound_minutes)); + ast_copy_string(q->sound_minute, "queue-minute", sizeof(q->sound_minute)); + ast_copy_string(q->sound_seconds, "queue-seconds", sizeof(q->sound_seconds)); + ast_copy_string(q->sound_thanks, "queue-thankyou", sizeof(q->sound_thanks)); + ast_copy_string(q->sound_reporthold, "queue-reporthold", sizeof(q->sound_reporthold)); - if ((q->sound_periodicannounce[0] = ast_str_create(32))) + if (!q->sound_periodicannounce[0]) { + q->sound_periodicannounce[0] = ast_str_create(32); + } + + if (q->sound_periodicannounce[0]) { ast_str_set(&q->sound_periodicannounce[0], 0, "queue-periodic-announce"); + } for (i = 1; i < MAX_PERIODIC_ANNOUNCEMENTS; i++) { if (q->sound_periodicannounce[i]) @@ -1175,11 +1178,11 @@ { if (!strcasecmp(param, "musicclass") || !strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) { - ast_string_field_set(q, moh, val); + ast_copy_string(q->moh, val, sizeof(q->moh)); } else if (!strcasecmp(param, "announce")) { - ast_string_field_set(q, announce, val); + ast_copy_string(q->announce, val, sizeof(q->announce)); } else if (!strcasecmp(param, "context")) { - ast_string_field_set(q, context, val); + ast_copy_string(q->context, val, sizeof(q->context)); } else if (!strcasecmp(param, "timeout")) { q->timeout = atoi(val); if (q->timeout < 0) @@ -1195,29 +1198,29 @@ } else if (!strcasecmp(param, "monitor-format")) { ast_copy_string(q->monfmt, val, sizeof(q->monfmt)); } else if (!strcasecmp(param, "membermacro")) { - ast_string_field_set(q, membermacro, val); + ast_copy_string(q->membermacro, val, sizeof(q->membermacro)); } else if (!strcasecmp(param, "membergosub")) { - ast_string_field_set(q, membergosub, val); + ast_copy_string(q->membergosub, val, sizeof(q->membergosub)); } else if (!strcasecmp(param, "queue-youarenext")) { - ast_string_field_set(q, sound_next, val); + ast_copy_string(q->sound_next, val, sizeof(q->sound_next)); } else if (!strcasecmp(param, "queue-thereare")) { - ast_string_field_set(q, sound_thereare, val); + ast_copy_string(q->sound_thereare, val, sizeof(q->sound_thereare)); } else if (!strcasecmp(param, "queue-callswaiting")) { - ast_string_field_set(q, sound_calls, val); + ast_copy_string(q->sound_calls, val, sizeof(q->sound_calls)); } else if (!strcasecmp(param, "queue-holdtime")) { - ast_string_field_set(q, sound_holdtime, val); + ast_copy_string(q->sound_holdtime, val, sizeof(q->sound_holdtime)); } else if (!strcasecmp(param, "queue-minutes")) { - ast_string_field_set(q, sound_minutes, val); + ast_copy_string(q->sound_minutes, val, sizeof(q->sound_minutes)); } else if (!strcasecmp(param, "queue-minute")) { - ast_string_field_set(q, sound_minute, val); + ast_copy_string(q->sound_minute, val, sizeof(q->sound_minute)); } else if (!strcasecmp(param, "queue-seconds")) { - ast_string_field_set(q, sound_seconds, val); + ast_copy_string(q->sound_seconds, val, sizeof(q->sound_seconds)); } else if (!strcasecmp(param, "queue-thankyou")) { - ast_string_field_set(q, sound_thanks, val); + ast_copy_string(q->sound_thanks, val, sizeof(q->sound_thanks)); } else if (!strcasecmp(param, "queue-callerannounce")) { - ast_string_field_set(q, sound_callerannounce, val); + ast_copy_string(q->sound_callerannounce, val, sizeof(q->sound_callerannounce)); } else if (!strcasecmp(param, "queue-reporthold")) { - ast_string_field_set(q, sound_reporthold, val); + ast_copy_string(q->sound_reporthold, val, sizeof(q->sound_reporthold)); } else if (!strcasecmp(param, "announce-frequency")) { q->announcefrequency = atoi(val); } else if (!strcasecmp(param, "min-announce-frequency")) { @@ -1344,7 +1347,7 @@ } else if (!strcasecmp(param, "timeoutrestart")) { q->timeoutrestart = ast_true(val); } else if (!strcasecmp(param, "defaultrule")) { - ast_string_field_set(q, defaultrule, val); + ast_copy_string(q->defaultrule, val, sizeof(q->defaultrule)); } else if (failunknown) { if (linenum >= 0) { ast_log(LOG_WARNING, "Unknown keyword in queue '%s': %s at line %d of queues.conf\n", @@ -1433,7 +1436,6 @@ int i; free_members(q, 1); - ast_string_field_free_memory(q); for (i = 0; i < MAX_PERIODIC_ANNOUNCEMENTS; i++) { if (q->sound_periodicannounce[i]) free(q->sound_periodicannounce[i]); @@ -1446,11 +1448,7 @@ struct call_queue *q; if ((q = ao2_alloc(sizeof(*q), destroy_queue))) { - if (ast_string_field_init(q, 64)) { - ao2_ref(q, -1); - return NULL; - } - ast_string_field_set(q, name, queuename); + ast_copy_string(q->name, queuename, sizeof(q->name)); } return q; } @@ -1468,9 +1466,7 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config) { struct ast_variable *v; - struct call_queue *q, tmpq = { - .name = queuename, - }; + struct call_queue *q, tmpq; struct member *m; struct ao2_iterator mem_iter; char *interface = NULL; @@ -1478,6 +1474,8 @@ char *tmp; char tmpbuf[64]; /* Must be longer than the longest queue param name. */ + ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); + /* Static queues override realtime. */ if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { ao2_lock(q); @@ -1602,11 +1600,10 @@ { struct ast_variable *queue_vars; struct ast_config *member_config = NULL; - struct call_queue *q = NULL, tmpq = { - .name = queuename, - }; + struct call_queue *q = NULL, tmpq; /* Find the queue in the in-core list first. */ + ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); q = ao2_find(queues, &tmpq, OBJ_POINTER); if (!q || q->realtime) { @@ -4121,12 +4118,11 @@ */ static int remove_from_queue(const char *queuename, const char *interface) { - struct call_queue *q, tmpq = { - .name = queuename, - }; + struct call_queue *q, tmpq; struct member *mem, tmpmem; int res = RES_NOSUCHQUEUE; + ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface)); if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { ao2_lock(queues); @@ -4349,11 +4345,10 @@ static int get_member_penalty(char *queuename, char *interface) { int foundqueue = 0, penalty; - struct call_queue *q, tmpq = { - .name = queuename, - }; + struct call_queue *q, tmpq; struct member *mem; + ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { foundqueue = 1; ao2_lock(q); @@ -4404,9 +4399,8 @@ queue_name = entry->key + strlen(pm_family) + 2; { - struct call_queue tmpq = { - .name = queue_name, - }; + struct call_queue tmpq; + ast_copy_string(tmpq.name, queue_name, sizeof(tmpq.name)); cur_queue = ao2_find(queues, &tmpq, OBJ_POINTER); } @@ -5058,18 +5052,17 @@ static int queue_function_var(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { int res = -1; - struct call_queue *q, tmpq = { - .name = data, - }; + struct call_queue *q, tmpq; char interfacevar[256]=""; - float sl = 0; + float sl = 0; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd); return -1; } + ast_copy_string(tmpq.name, data, sizeof(tmpq.name)); if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { ao2_lock(q); if (q->setqueuevar) { @@ -5200,9 +5193,7 @@ static int queue_function_queuewaitingcount(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { int count = 0; - struct call_queue *q, tmpq = { - .name = data, - }; + struct call_queue *q, tmpq; struct ast_variable *var = NULL; buf[0] = '\0'; @@ -5212,6 +5203,7 @@ return -1; } + ast_copy_string(tmpq.name, data, sizeof(tmpq.name)); if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { ao2_lock(q); count = q->count; @@ -5235,9 +5227,7 @@ /*! \brief Dialplan function QUEUE_MEMBER_LIST() Get list of members in a specific queue */ static int queue_function_queuememberlist(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { - struct call_queue *q, tmpq = { - .name = data, - }; + struct call_queue *q, tmpq; struct member *m; /* Ensure an otherwise empty list doesn't return garbage */ @@ -5248,6 +5238,7 @@ return -1; } + ast_copy_string(tmpq.name, data, sizeof(tmpq.name)); if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { int buflen = 0, count = 0; struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0); @@ -5535,9 +5526,9 @@ shared_lastcall = ast_true(general_val); } else { /* Define queue */ /* Look for an existing one */ - struct call_queue tmpq = { - .name = cat, - }; + struct call_queue tmpq; + + ast_copy_string(tmpq.name, cat, sizeof(tmpq.name)); if (!(q = ao2_find(queues, &tmpq, OBJ_POINTER))) { /* Make one then */ if (!(q = alloc_queue(cat))) {