Changeset 3168

Merge 3167 from trunk (Fix GotoIfTime/ExecIfTime)

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

Affected files:

callweaver/branches/rel/1.2/corelib/pbx.c (unified diff)

r3078r3168
64586458 static int pbx_builtin_gotoiftime(struct opbx_channel *chan, int argc, char **argv)
64596459 {
64606460 struct opbx_timing timing;
6461 char *s;
6461 char *s, *q;
64626462
6463 s = NULL;
6464 if (argc > 3) {
6465 s = strchr(argv[3], '?');
6466 if (s) while (isspace(*(++s)));
6467 }
6468
6469 if (!s || !*s || argc > 6) {
6463 if (argc < 4 || argc > 6 || !(s = strchr(argv[3], '?'))) {
64706464 opbx_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>?[[context,]extension,]priority\n");
64716465 return -1;
64726466 }
64736467
6468 /* Trim trailing space from the timespec */
6469 q = s;
6470 do { *(q--) = '\0'; } while (q >= argv[3] && isspace(*q));
6471
64746472 get_timerange(&timing, argv[0]);
64756473 timing.dowmask = get_dow(argv[1]);
64766474 timing.daymask = get_day(argv[2]);
64776475 timing.monthmask = get_month(argv[3]);
64786476
64796477 if (opbx_check_timing(&timing)) {
6478 do { *(s++) = '\0'; } while (isspace(*s));
64806479 argv[3] = s;
64816480 argv += 3;
64826481 argc -= 3;
------
64896488 static int pbx_builtin_execiftime(struct opbx_channel *chan, int argc, char **argv)
64906489 {
64916490 struct opbx_timing timing;
6492 char *s;
6491 char *s, *q;
64936492
6494 s = NULL;
6495 if (argc > 3) {
6496 s = strchr(argv[3], '?');
6497 if (s) while (isspace(*(++s)));
6498 }
6499
6500 if (!s || !*s) {
6493 if (argc < 4 || !(s = strchr(argv[3], '?'))) {
65016494 opbx_log(LOG_WARNING, "ExecIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>?<appname>[(<args>)]\n");
65026495 return -1;
65036496 }
65046497
6498 /* Trim trailing space from the timespec */
6499 q = s;
6500 do { *(q--) = '\0'; } while (q >= argv[3] && isspace(*q));
6501
65056502 get_timerange(&timing, argv[0]);
65066503 timing.dowmask = get_dow(argv[1]);
65076504 timing.daymask = get_day(argv[2]);
65086505 timing.monthmask = get_month(argv[3]);
65096506
65106507 if (opbx_check_timing(&timing)) {
6511 struct opbx_app *app = pbx_findapp(s);
6508 struct opbx_app *app;
6509 do { *(s++) = '\0'; } while (isspace(*s));
6510 app = pbx_findapp(s);
65126511 if (app) {
65136512 if ((s = strchr(s, '('))) {
65146513 argv[0] = s + 1;
------
65166515 *s = '\0';
65176516 return pbx_exec(chan, app, argv[0]);
65186517 } else {
6519 return pbx_exec_argv(chan, app, argc - 4, argv + 5);
6518 return pbx_exec_argv(chan, app, argc - 4, argv + 4);
65206519 }
65216520 } else {
65226521 opbx_log(LOG_WARNING, "Cannot locate application %s\n", s);