When working with dates, use numeric form whenever possible, as it's faster.

Also, a bunch of coding guidelines fixes.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@92855 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Tilghman Lesher 18 years ago
parent e6fea0b9b0
commit 652ee40acb

@ -380,7 +380,7 @@ struct ast_conference {
char pin[MAX_PIN]; /*!< If protected by a PIN */
char pinadmin[MAX_PIN]; /*!< If protected by a admin PIN */
char uniqueid[32];
char endtime[19]; /*!< When to end the conf if scheduled */
long endtime; /*!< When to end the conf if scheduled */
struct ast_frame *transframe[32];
struct ast_frame *origframe;
struct ast_trans_pvt *transpath[32];
@ -940,7 +940,7 @@ static char *complete_meetmecmd(const char *line, const char *word, int pos, int
}
AST_LIST_UNLOCK(&confs);
return usr ? ast_strdup(usrno) : NULL;
} else if ( strstr(line, "list") && ( 0 == state ) )
} else if (strstr(line, "list") && (state == 0))
return ast_strdup("concise");
}
@ -1060,7 +1060,7 @@ static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a
strncat(cmdline, a->argv[3], sizeof(cmdline) - strlen(cmdline) - 1);
}
} else if (strcmp(a->argv[1], "list") == 0) {
int concise = ( 4 == a->argc && ( !strcasecmp(a->argv[3], "concise") ) );
int concise = (a->argc == 4 && (!strcasecmp(a->argv[3], "concise")));
/* List all the users in a conference */
if (AST_LIST_EMPTY(&confs)) {
if (!concise)
@ -1520,7 +1520,6 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
char *buf = __buf + AST_FRIENDLY_OFFSET;
char *exitkeys = NULL;
time_t myt;
unsigned int calldurationlimit = 0;
long timelimit = 0;
long play_warning = 0;
@ -1546,8 +1545,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
if ((confflags & CONFFLAG_DURATION_STOP) && !ast_strlen_zero(optargs[OPT_ARG_DURATION_STOP])) {
calldurationlimit = atoi(optargs[OPT_ARG_DURATION_STOP]);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Setting call duration limit to %d seconds.\n",calldurationlimit);
ast_verb(3, "Setting call duration limit to %d seconds.\n", calldurationlimit);
}
if ((confflags & CONFFLAG_DURATION_LIMIT) && !ast_strlen_zero(optargs[OPT_ARG_DURATION_LIMIT])) {
@ -1962,33 +1960,24 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
outfd = -1;
ms = -1;
now = ast_tvnow();
if (rt_schedule) {
char currenttime[32];
struct ast_tm tm;
now = ast_tvnow();
if (now.tv_sec % 60 == 0) {
if (!checked) {
ast_localtime(&now, &tm, NULL);
ast_strftime(currenttime, sizeof(currenttime), DATE_FORMAT, &tm);
if (strcmp(currenttime, conf->endtime) > 0){
if (now.tv_sec > conf->endtime) {
ast_verbose("Quitting time...\n");
goto outrun;
}
if (!announcement_played && conf->endalert) {
now.tv_sec += conf->endalert;
ast_localtime(&now, &tm, NULL);
ast_strftime(currenttime, sizeof(currenttime), DATE_FORMAT, &tm);
if (strcmp(currenttime, conf->endtime) > 0){
if (now.tv_sec + conf->endalert > conf->endtime) {
if (!ast_streamfile(chan, "conf-will-end-in", chan->language))
ast_waitstream(chan, "");
ast_say_digits(chan, conf->endalert / 60, "", chan->language);
ast_say_digits(chan, (now.tv_sec + conf->endalert - conf->endtime) / 60, "", chan->language);
if (!ast_streamfile(chan, "minutes", chan->language))
ast_waitstream(chan, "");
announcement_played = 1;
}
}
checked = 1;
@ -1999,16 +1988,13 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
}
}
time(&myt); /* get current time */
if (user->kicktime && (user->kicktime < myt))
if (user->kicktime && (user->kicktime <= now.tv_sec))
break;
to = -1;
if (user->timelimit) {
struct timeval now;
int minutes = 0, seconds = 0, remain = 0;
now = ast_tvnow();
to = ast_tvdiff_ms(nexteventts, now);
if (to < 0)
to = 0;
@ -2064,7 +2050,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
}
}
if (timeout && time(NULL) >= timeout)
now = ast_tvnow();
if (timeout && now.tv_sec >= timeout)
break;
/* if we have just exited from the menu, and the user had a channel-driver
@ -2097,7 +2084,6 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms);
/* Update the struct with the actual confflags */
user->userflags = confflags;
@ -2240,7 +2226,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
/* If I have been kicked, exit the conference */
if (user->adminflags & ADMINFLAG_KICKME) {
//You have been kicked.
/* You have been kicked. */
if (!(confflags & CONFFLAG_QUIET) &&
!ast_streamfile(chan, "conf-kicked", chan->language)) {
ast_waitstream(chan, "");
@ -2706,12 +2692,11 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
int maxusers = 0;
struct timeval now;
char currenttime[19] = "";
char startTime[19] = "";
char endtime[19] = "";
char eatime[19] = "";
char userOpts[32] = "";
char adminOpts[32] = "";
char useropts[32] = "";
char adminopts[32] = "";
struct ast_tm tm, etm;
struct timeval starttime, endtime;
if (rt_schedule) {
now = ast_tvnow();
@ -2733,7 +2718,7 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
ast_debug(1, "Looking for conference %s that starts after %s\n", confno, eatime);
var = ast_load_realtime("meetme", "confno",
confno, "startTime<= ", eatime, "endtime>= ",
confno, "starttime <= ", eatime, "endtime >= ",
currenttime, NULL);
} else
var = ast_load_realtime("meetme", "confno", confno, NULL);
@ -2747,15 +2732,19 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
} else if (!strcasecmp(var->name, "adminpin")) {
pinadmin = ast_strdupa(var->value);
} else if (!strcasecmp(var->name, "opts")) {
ast_copy_string(userOpts, var->value, sizeof(userOpts));
ast_copy_string(useropts, var->value, sizeof(useropts));
} else if (!strcasecmp(var->name, "maxusers")) {
maxusers = atoi(var->value);
} else if (!strcasecmp(var->name, "adminopts")) {
ast_copy_string(adminOpts, var->value, sizeof(adminOpts));
ast_copy_string(adminopts, var->value, sizeof(adminopts));
} else if (!strcasecmp(var->name, "endtime")) {
ast_copy_string(endtime, var->value, sizeof(endtime));
struct ast_tm tm = { 0, };
strptime(var->value, "%Y-%m-%d %H:%M:%S", (struct tm *)&tm);
endtime = ast_mktime(&tm, NULL);
} else if (!strcasecmp(var->name, "starttime")) {
ast_copy_string(startTime, var->value, sizeof(startTime));
struct ast_tm tm = { 0, };
strptime(var->value, "%Y-%m-%d %H:%M:%S", (struct tm *)&tm);
starttime = ast_mktime(&tm, NULL);
}
var = var->next;
@ -2763,7 +2752,9 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
ast_variables_destroy(var);
if (earlyalert) {
if (strcmp(startTime, currenttime) > 0) {
now = ast_tvnow();
if (now.tv_sec + fuzzystart < starttime.tv_sec) {
/* Announce that the caller is early and exit */
if (!ast_streamfile(chan, "conf-has-not-started", chan->language))
ast_waitstream(chan, "");
@ -2777,7 +2768,7 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
if (cnf) {
cnf->maxusers = maxusers;
cnf->endalert = endalert;
ast_copy_string(cnf->endtime, endtime, sizeof(cnf->endtime));
cnf->endtime = endtime.tv_sec;
}
}

Loading…
Cancel
Save