aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_indications.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-30 17:10:11 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-30 17:10:11 +0000
commit70020a2853bd51930d36fd997fc71eedfe71eb6e (patch)
tree56636b4d708638cdb380dc76672be39341eec1f9 /res/res_indications.c
parentcd3c76f7f1e6a0655e035b8ab8d164109d31f92c (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: http://svn.digium.com/svn/asterisk/trunk@16532 f38db490-d61c-443f-a65b-d21fe96a405b
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;
}