Changeset 3167

Fix GotoIfTime/ExecIfTime

Committed by:  mjagdis
Date:  Jun 27 2007 * 00:23 (about 1 year ago)

Affected files:

callweaver/trunk/corelib/pbx.c (unified diff)

r3077r3167
64616461 static int pbx_builtin_gotoiftime(struct opbx_channel *chan, int argc, char **argv)
64626462 {
64636463 struct opbx_timing timing;
6464 char *s;
6464 char *s, *q;
64656465
6466 s = NULL;
6467 if (argc > 3) {
6468 s = strchr(argv[3], '?');
6469 if (s) while (isspace(*(++s)));
6470 }
6471
6472 if (!s || !*s || argc > 6) {
6466 if (argc < 4 || argc > 6 || !(s = strchr(argv[3], '?'))) {
64736467 opbx_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>?[[context,]extension,]priority\n");
64746468 return -1;
64756469 }
64766470
6471 /* Trim trailing space from the timespec */
6472 q = s;
6473 do { *(q--) = '\0'; } while (q >= argv[3] && isspace(*q));
6474
64776475 get_timerange(&timing, argv[0]);
64786476 timing.dowmask = get_dow(argv[1]);
64796477 timing.daymask = get_day(argv[2]);
64806478 timing.monthmask = get_month(argv[3]);
64816479
64826480 if (opbx_check_timing(&timing)) {
6481 do { *(s++) = '\0'; } while (isspace(*s));
64836482 argv[3] = s;
64846483 argv += 3;
64856484 argc -= 3;
------
64926491 static int pbx_builtin_execiftime(struct opbx_channel *chan, int argc, char **argv)
64936492 {
64946493 struct opbx_timing timing;
6495 char *s;
6494 char *s, *q;
64966495
6497 s = NULL;
6498 if (argc > 3) {
6499 s = strchr(argv[3], '?');
6500 if (s) while (isspace(*(++s)));
6501 }
6502
6503 if (!s || !*s) {
6496 if (argc < 4 || !(s = strchr(argv[3], '?'))) {
65046497 opbx_log(LOG_WARNING, "ExecIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>?<appname>[(<args>)]\n");
65056498 return -1;
65066499 }
65076500
6501 /* Trim trailing space from the timespec */
6502 q = s;
6503 do { *(q--) = '\0'; } while (q >= argv[3] && isspace(*q));
6504
65086505 get_timerange(&timing, argv[0]);
65096506 timing.dowmask = get_dow(argv[1]);
65106507 timing.daymask = get_day(argv[2]);
65116508 timing.monthmask = get_month(argv[3]);
65126509
65136510 if (opbx_check_timing(&timing)) {
6514 struct opbx_app *app = pbx_findapp(s);
6511 struct opbx_app *app;
6512 do { *(s++) = '\0'; } while (isspace(*s));
6513 app = pbx_findapp(s);
65156514 if (app) {
65166515 if ((s = strchr(s, '('))) {
65176516 argv[0] = s + 1;
------
65196518 *s = '\0';
65206519 return pbx_exec(chan, app, argv[0]);
65216520 } else {
6522 return pbx_exec_argv(chan, app, argc - 4, argv + 5);
6521 return pbx_exec_argv(chan, app, argc - 4, argv + 4);
65236522 }
65246523 } else {
65256524 opbx_log(LOG_WARNING, "Cannot locate application %s\n", s);