aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-18 22:43:45 +0000
committerqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-18 22:43:45 +0000
commitab51c0d7fad1957b36454533cd8e786ed66efa61 (patch)
treed49317ce7050cdca6ecef46706a320e879421c61 /res/res_musiconhold.c
parentcedd5ba68f094ce4082e42b47674c0f1c01d447d (diff)
(issue #10724)
Reported by: eliel Patches: res_features.c.patch uploaded by eliel (license 64) res_agi.c.patch uploaded by seanbright (license 71) res_musiconhold.c.patch uploaded by seanbright (license 71) pbx.c.patch uploaded by moy (license 222) logger.c.patch uploaded by moy (license 222) frame.c.patch uploaded by moy (license 222) manager.c.patch uploaded by moy (license 222) http.c.patch uploaded by moy (license 222) dnsmgr.c.patch uploaded by moy (license 222) res_realtime.c.patch uploaded by eliel (license 64) res_odbc.c.patch uploaded by seanbright (license 71) res_jabber.c.patch uploaded by eliel (license 64) chan_local.c.patch uploaded by eliel (license 64) chan_agent.c.patch uploaded by eliel (license 64) chan_alsa.c.patch uploaded by eliel (license 64) chan_features.c.patch uploaded by eliel (license 64) chan_sip.c.patch uploaded by eliel (license 64) RollUp.1.patch (includes all of the above patches) uploaded by seanbright (license 71) Convert many CLI commands to the NEW_CLI format. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82930 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c92
1 files changed, 63 insertions, 29 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 047cf3cce..5c6490fcc 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -854,10 +854,8 @@ static int moh_scan_files(struct mohclass *class) {
if (!S_ISREG(statbuf.st_mode))
continue;
- if ((ext = strrchr(filepath, '.'))) {
+ if ((ext = strrchr(filepath, '.')))
*ext = '\0';
- ext++;
- }
/* if the file is present in multiple formats, ensure we only put it into the list once */
for (i = 0; i < class->total_files; i++)
@@ -1147,66 +1145,102 @@ static void ast_moh_destroy(void)
AST_RWLIST_UNLOCK(&mohclasses);
}
-static int moh_cli(int fd, int argc, char *argv[])
+static char *handle_cli_moh_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "moh reload";
+ e->usage =
+ "Usage: moh reload\n"
+ " Reloads the MusicOnHold module.\n"
+ " Alias for 'module reload res_musiconhold.so'\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
+
reload();
- return 0;
+ return CLI_SUCCESS;
}
-static int cli_files_show(int fd, int argc, char *argv[])
+static char *handle_cli_moh_show_files(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int i;
struct mohclass *class;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "moh show files";
+ e->usage =
+ "Usage: moh show files\n"
+ " Lists all loaded file-based MusicOnHold classes and their\n"
+ " files.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
+
AST_RWLIST_RDLOCK(&mohclasses);
AST_RWLIST_TRAVERSE(&mohclasses, class, list) {
if (!class->total_files)
continue;
- ast_cli(fd, "Class: %s\n", class->name);
+ ast_cli(a->fd, "Class: %s\n", class->name);
for (i = 0; i < class->total_files; i++)
- ast_cli(fd, "\tFile: %s\n", class->filearray[i]);
+ ast_cli(a->fd, "\tFile: %s\n", class->filearray[i]);
}
AST_RWLIST_UNLOCK(&mohclasses);
- return 0;
+ return CLI_SUCCESS;
}
-static int moh_classes_show(int fd, int argc, char *argv[])
+static char *handle_cli_moh_show_classes(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct mohclass *class;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "moh show classes";
+ e->usage =
+ "Usage: moh show classes\n"
+ " Lists all MusicOnHold classes.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
+
AST_RWLIST_RDLOCK(&mohclasses);
AST_RWLIST_TRAVERSE(&mohclasses, class, list) {
- ast_cli(fd, "Class: %s\n", class->name);
- ast_cli(fd, "\tMode: %s\n", S_OR(class->mode, "<none>"));
- ast_cli(fd, "\tDirectory: %s\n", S_OR(class->dir, "<none>"));
- ast_cli(fd, "\tUse Count: %d\n", class->inuse);
+ ast_cli(a->fd, "Class: %s\n", class->name);
+ ast_cli(a->fd, "\tMode: %s\n", S_OR(class->mode, "<none>"));
+ ast_cli(a->fd, "\tDirectory: %s\n", S_OR(class->dir, "<none>"));
+ ast_cli(a->fd, "\tUse Count: %d\n", class->inuse);
if (class->digit)
- ast_cli(fd, "\tDigit: %c\n", class->digit);
+ ast_cli(a->fd, "\tDigit: %c\n", class->digit);
if (ast_test_flag(class, MOH_CUSTOM))
- ast_cli(fd, "\tApplication: %s\n", S_OR(class->args, "<none>"));
+ ast_cli(a->fd, "\tApplication: %s\n", S_OR(class->args, "<none>"));
if (strcasecmp(class->mode, "files"))
- ast_cli(fd, "\tFormat: %s\n", ast_getformatname(class->format));
+ ast_cli(a->fd, "\tFormat: %s\n", ast_getformatname(class->format));
}
AST_RWLIST_UNLOCK(&mohclasses);
- return 0;
+ return CLI_SUCCESS;
}
static struct ast_cli_entry cli_moh[] = {
- { { "moh", "reload"},
- moh_cli, "Music On Hold",
- "Music On Hold" },
-
- { { "moh", "show", "classes"},
- moh_classes_show, "List MOH classes",
- "Lists all MOH classes" },
-
- { { "moh", "show", "files"},
- cli_files_show, "List MOH file-based classes",
- "Lists all loaded file-based MOH classes and their files" },
+ NEW_CLI(handle_cli_moh_reload, "Reload MusicOnHold"),
+ NEW_CLI(handle_cli_moh_show_classes, "List MusicOnHold classes"),
+ NEW_CLI(handle_cli_moh_show_files, "List MusicOnHold file-based classes")
};
static int init_classes(int reload)