mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
Create experimental new options API, various cleanups
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5171 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
1
Makefile
1
Makefile
@@ -430,6 +430,7 @@ bininstall: all
|
||||
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
|
||||
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
|
||||
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
|
||||
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
|
||||
install -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/
|
||||
install -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
|
||||
install -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
|
||||
|
35
app.c
35
app.c
@@ -1455,3 +1455,38 @@ char *ast_read_textfile(const char *filename)
|
||||
return output;
|
||||
}
|
||||
|
||||
int ast_parseoptions(const struct ast_option *options, struct ast_flags *flags, char **args, char *optstr)
|
||||
{
|
||||
char *s;
|
||||
int curarg;
|
||||
int argloc;
|
||||
char *arg;
|
||||
int res = 0;
|
||||
flags->flags = 0;
|
||||
if (!optstr)
|
||||
return 0;
|
||||
s = optstr;
|
||||
while(*s) {
|
||||
curarg = *s & 0x7f;
|
||||
flags->flags |= options[curarg].flag;
|
||||
argloc = options[curarg].argoption;
|
||||
s++;
|
||||
if (*s == '(') {
|
||||
/* Has argument */
|
||||
s++;
|
||||
arg = s;
|
||||
while(*s && (*s != ')')) s++;
|
||||
if (*s) {
|
||||
if (argloc)
|
||||
args[argloc - 1] = arg;
|
||||
*s = '\0';
|
||||
s++;
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Missing closing parenthesis for argument '%c'\n", curarg);
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@@ -94,7 +94,7 @@ int unload_module(void)
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
return ast_register_application(app, skel_exec, synopsis, tdesc);
|
||||
return ast_register_application(app, skel_exec, tdesc, synopsis);
|
||||
}
|
||||
|
||||
char *description(void)
|
||||
|
@@ -21,14 +21,15 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static char *tdesc_md5 = "MD5 checksum application";
|
||||
static char *tdesc_md5 = "MD5 checksum applications";
|
||||
static char *app_md5 = "MD5";
|
||||
static char *desc_md5 = "Calculate MD5 checksum";
|
||||
static char *synopsis_md5 =
|
||||
" MD5(<var>=<string>): Calculates a MD5 checksum on <string>.\n"
|
||||
"Returns hash value in a channel variable. Always return 0\n";
|
||||
|
||||
static char *tdesc_md5check = "MD5 checksum verification application";
|
||||
static char *app_md5check = "MD5Check";
|
||||
static char *desc_md5check = "Check MD5 checksum";
|
||||
static char *synopsis_md5check =
|
||||
" MD5Check(<md5hash>,<string>): Calculates a MD5 checksum on <string>\n"
|
||||
"and compares it with the hash. Returns 0 if <md5hash> is correct for <string>.\n"
|
||||
@@ -122,8 +123,8 @@ int load_module(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = ast_register_application(app_md5check, md5check_exec, synopsis_md5check, tdesc_md5check);
|
||||
res |= ast_register_application(app_md5, md5_exec, synopsis_md5, tdesc_md5);
|
||||
res = ast_register_application(app_md5check, md5check_exec, desc_md5check, synopsis_md5check);
|
||||
res |= ast_register_application(app_md5, md5_exec, desc_md5, synopsis_md5);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@@ -184,6 +184,35 @@ static void *recordthread(void *args);
|
||||
#define CONFFLAG_INTROUSER (1 << 14) /* If set, user will be ask record name on entry of conference */
|
||||
#define CONFFLAG_RECORDCONF (1<< 15) /* If set, the MeetMe will be recorded */
|
||||
#define CONFFLAG_MONITORTALKER (1 << 16) /* If set, the user will be monitored if the user is talking or not */
|
||||
#define CONFFLAG_DYNAMIC (1 << 17)
|
||||
#define CONFFLAG_DYNAMICPIN (1 << 18)
|
||||
#define CONFFLAG_EMPTY (1 << 19)
|
||||
#define CONFFLAG_EMPTYNOPIN (1 << 20)
|
||||
#define CONFFLAG_ALWAYSPROMPT (1 << 21)
|
||||
|
||||
|
||||
AST_DECLARE_OPTIONS(meetme_opts,{
|
||||
['a'] = { CONFFLAG_ADMIN },
|
||||
['T'] = { CONFFLAG_MONITORTALKER },
|
||||
['i'] = { CONFFLAG_INTROUSER },
|
||||
['m'] = { CONFFLAG_MONITOR },
|
||||
['p'] = { CONFFLAG_POUNDEXIT },
|
||||
['s'] = { CONFFLAG_STARMENU },
|
||||
['t'] = { CONFFLAG_TALKER },
|
||||
['q'] = { CONFFLAG_QUIET },
|
||||
['M'] = { CONFFLAG_MOH },
|
||||
['x'] = { CONFFLAG_MARKEDEXIT },
|
||||
['X'] = { CONFFLAG_EXIT_CONTEXT },
|
||||
['A'] = { CONFFLAG_MARKEDUSER },
|
||||
['b'] = { CONFFLAG_AGI },
|
||||
['w'] = { CONFFLAG_WAITMARKED },
|
||||
['r'] = { CONFFLAG_RECORDCONF },
|
||||
['d'] = { CONFFLAG_DYNAMIC },
|
||||
['D'] = { CONFFLAG_DYNAMICPIN },
|
||||
['e'] = { CONFFLAG_EMPTY },
|
||||
['E'] = { CONFFLAG_EMPTYNOPIN },
|
||||
['P'] = { CONFFLAG_ALWAYSPROMPT },
|
||||
});
|
||||
|
||||
static char *istalking(int x)
|
||||
{
|
||||
@@ -657,10 +686,11 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
|
||||
else
|
||||
strncpy(exitcontext, chan->context, sizeof(exitcontext) - 1);
|
||||
}
|
||||
snprintf(user->namerecloc,sizeof(user->namerecloc),"%s/meetme-username-%s-%d",AST_SPOOL_DIR,conf->confno,user->user_no);
|
||||
|
||||
if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_INTROUSER))
|
||||
if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_INTROUSER)) {
|
||||
snprintf(user->namerecloc,sizeof(user->namerecloc),"%s/meetme/meetme-username-%s-%d",ast_config_AST_SPOOL_DIR,conf->confno,user->user_no);
|
||||
ast_record_review(chan,"vm-rec-name",user->namerecloc, 10,"sln", &duration, NULL);
|
||||
}
|
||||
|
||||
while((confflags & CONFFLAG_WAITMARKED) && (conf->markedusers == 0)) {
|
||||
confflags &= ~CONFFLAG_QUIET;
|
||||
@@ -1363,7 +1393,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
|
||||
int allowretry = 0;
|
||||
int retrycnt = 0;
|
||||
struct ast_conference *cnf;
|
||||
int confflags = 0;
|
||||
struct ast_flags confflags = {0};
|
||||
int dynamic = 0;
|
||||
int empty = 0, empty_no_pin = 0;
|
||||
int always_prompt = 0;
|
||||
@@ -1396,52 +1426,14 @@ static int conf_exec(struct ast_channel *chan, void *data)
|
||||
strncpy(the_pin, inpin, sizeof(the_pin) - 1);
|
||||
|
||||
if (inflags) {
|
||||
if (strchr(inflags, 'a'))
|
||||
confflags |= CONFFLAG_ADMIN;
|
||||
if (strchr(inflags, 'T'))
|
||||
confflags |= CONFFLAG_MONITORTALKER;
|
||||
if (strchr(inflags, 'i'))
|
||||
confflags |= CONFFLAG_INTROUSER;
|
||||
if (strchr(inflags, 'm'))
|
||||
confflags |= CONFFLAG_MONITOR;
|
||||
if (strchr(inflags, 'p'))
|
||||
confflags |= CONFFLAG_POUNDEXIT;
|
||||
if (strchr(inflags, 's'))
|
||||
confflags |= CONFFLAG_STARMENU;
|
||||
if (strchr(inflags, 't'))
|
||||
confflags |= CONFFLAG_TALKER;
|
||||
if (strchr(inflags, 'q'))
|
||||
confflags |= CONFFLAG_QUIET;
|
||||
if (strchr(inflags, 'M'))
|
||||
confflags |= CONFFLAG_MOH;
|
||||
if (strchr(inflags, 'x'))
|
||||
confflags |= CONFFLAG_MARKEDEXIT;
|
||||
if (strchr(inflags, 'X'))
|
||||
confflags |= CONFFLAG_EXIT_CONTEXT;
|
||||
if (strchr(inflags, 'A'))
|
||||
confflags |= CONFFLAG_MARKEDUSER;
|
||||
if (strchr(inflags, 'b'))
|
||||
confflags |= CONFFLAG_AGI;
|
||||
if (strchr(inflags, 'w'))
|
||||
confflags |= CONFFLAG_WAITMARKED;
|
||||
if (strchr(inflags, 'r'))
|
||||
confflags |= CONFFLAG_RECORDCONF;
|
||||
if (strchr(inflags, 'd'))
|
||||
dynamic = 1;
|
||||
if (strchr(inflags, 'D')) {
|
||||
dynamic = 1;
|
||||
if (! inpin) {
|
||||
strncpy(the_pin, "q", sizeof(the_pin) - 1);
|
||||
}
|
||||
}
|
||||
if (strchr(inflags, 'e'))
|
||||
empty = 1;
|
||||
if (strchr(inflags, 'E')) {
|
||||
empty = 1;
|
||||
empty_no_pin = 1;
|
||||
}
|
||||
if (strchr(inflags, 'P'))
|
||||
always_prompt = 1;
|
||||
ast_parseoptions(meetme_opts, &confflags, NULL, inflags);
|
||||
dynamic = ast_test_flag(&confflags, CONFFLAG_DYNAMIC | CONFFLAG_DYNAMICPIN);
|
||||
if (ast_test_flag(&confflags, CONFFLAG_DYNAMICPIN) && !inpin)
|
||||
strncpy(the_pin, "q", sizeof(the_pin) - 1);
|
||||
|
||||
empty = ast_test_flag(&confflags, CONFFLAG_EMPTY | CONFFLAG_EMPTYNOPIN);
|
||||
empty_no_pin = ast_test_flag(&confflags, CONFFLAG_EMPTYNOPIN);
|
||||
always_prompt = ast_test_flag(&confflags, CONFFLAG_ALWAYSPROMPT);
|
||||
}
|
||||
|
||||
do {
|
||||
@@ -1568,7 +1560,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
|
||||
if (allowretry)
|
||||
confno[0] = '\0';
|
||||
} else {
|
||||
if ((!ast_strlen_zero(cnf->pin) && ! (confflags & CONFFLAG_ADMIN)) || (!ast_strlen_zero(cnf->pinadmin) && (confflags & CONFFLAG_ADMIN))) {
|
||||
if ((!ast_strlen_zero(cnf->pin) && !ast_test_flag(&confflags, CONFFLAG_ADMIN)) || (!ast_strlen_zero(cnf->pinadmin) && ast_test_flag(&confflags, CONFFLAG_ADMIN))) {
|
||||
char pin[AST_MAX_EXTENSION]="";
|
||||
int j;
|
||||
|
||||
@@ -1587,9 +1579,9 @@ static int conf_exec(struct ast_channel *chan, void *data)
|
||||
/* Pin correct */
|
||||
allowretry = 0;
|
||||
if (!ast_strlen_zero(cnf->pinadmin) && !strcasecmp(pin, cnf->pinadmin))
|
||||
confflags |= CONFFLAG_ADMIN;
|
||||
ast_set_flag(&confflags, CONFFLAG_ADMIN);
|
||||
/* Run the conference */
|
||||
res = conf_run(chan, cnf, confflags);
|
||||
res = conf_run(chan, cnf, confflags.flags);
|
||||
break;
|
||||
} else {
|
||||
/* Pin invalid */
|
||||
@@ -1620,7 +1612,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
|
||||
allowretry = 0;
|
||||
|
||||
/* Run the conference */
|
||||
res = conf_run(chan, cnf, confflags);
|
||||
res = conf_run(chan, cnf, confflags.flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ int unload_module(void)
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
return ast_register_application(app, skel_exec, synopsis, tdesc);
|
||||
return ast_register_application(app, skel_exec, tdesc, synopsis);
|
||||
}
|
||||
|
||||
char *description(void)
|
||||
|
@@ -65,6 +65,16 @@ struct ast_ivr_menu {
|
||||
|
||||
#define AST_IVR_FLAG_AUTORESTART (1 << 0)
|
||||
|
||||
struct ast_option {
|
||||
unsigned int flag;
|
||||
int argoption;
|
||||
};
|
||||
|
||||
extern int ast_parseoptions(const struct ast_option *options, struct ast_flags *flags, char **args, char *optstr);
|
||||
|
||||
#define AST_DECLARE_OPTIONS(holder,args...) \
|
||||
static struct ast_option holder[128] = args
|
||||
|
||||
#define AST_IVR_DECLARE_MENU(holder,title,flags,foo...) \
|
||||
static struct ast_ivr_option __options_##holder[] = foo;\
|
||||
static struct ast_ivr_menu holder = { title, flags, __options_##holder }
|
||||
|
Reference in New Issue
Block a user