summaryrefslogtreecommitdiff
path: root/res/res_indications.c
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2006-03-30 17:10:11 +0000
committerLuigi Rizzo <rizzo@icir.org>2006-03-30 17:10:11 +0000
commit48864ab877d4e9038f3f8c0e119ab7e02c07523c (patch)
tree56636b4d708638cdb380dc76672be39341eec1f9 /res/res_indications.c
parent6d2fbc0b909d9802f67345630cb967311d72eb1c (diff)
do not export the tzlock and the list head, and introduce a new method,
ast_walk_indications(), to walk through the list of indications. The new method returns an unlocked record, which is no different from the behaviour of other existing methods in indications.c (i.e. they all need to be fixed, with refcounts or some similar method). Note that ast_walk_indications() uses the pointer argument only as a search key, so its implementation is completely safe. In turn, this change allows the removal of AST_MUTEX_DEFINE_EXPORTED. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16532 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_indications.c')
-rw-r--r--res/res_indications.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/res/res_indications.c b/res/res_indications.c
index 1188b0586..cb3a766ec 100644
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -149,26 +149,20 @@ static int handle_remove_indication(int fd, int argc, char *argv[])
*/
static int handle_show_indications(int fd, int argc, char *argv[])
{
- struct tone_zone *tz;
+ struct tone_zone *tz = NULL;
char buf[256];
int found_country = 0;
- if (ast_mutex_lock(&tzlock)) {
- ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
- return 0;
- }
if (argc == 2) {
/* no arguments, show a list of countries */
ast_cli(fd,"Country Alias Description\n"
"===========================\n");
- for (tz=tone_zones; tz; tz=tz->next) {
+ while ( (tz = ast_walk_indications(tz) ) )
ast_cli(fd,"%-7.7s %-7.7s %s\n", tz->country, tz->alias, tz->description);
- }
- ast_mutex_unlock(&tzlock);
return 0;
}
/* there was a request for specific country(ies), lets humor them */
- for (tz=tone_zones; tz; tz=tz->next) {
+ while ( (tz = ast_walk_indications(tz) ) ) {
int i,j;
for (i=2; i<argc; i++) {
if (strcasecmp(tz->country,argv[i])==0 &&
@@ -183,7 +177,8 @@ static int handle_show_indications(int fd, int argc, char *argv[])
for (i=0; i<tz->nrringcadence; i++) {
j += snprintf(buf+j,sizeof(buf)-j,"%d,",tz->ringcadence[i]);
}
- if (tz->nrringcadence) j--;
+ if (tz->nrringcadence)
+ j--;
ast_copy_string(buf+j,"\n",sizeof(buf)-j);
ast_cli(fd,buf);
for (ts=tz->tones; ts; ts=ts->next)
@@ -194,7 +189,6 @@ static int handle_show_indications(int fd, int argc, char *argv[])
}
if (!found_country)
ast_cli(fd,"No countries matched your criteria.\n");
- ast_mutex_unlock(&tzlock);
return -1;
}