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)
| r3077 | r3167 | |
|---|---|---|
| 6461 | 6461 | static int pbx_builtin_gotoiftime(struct opbx_channel *chan, int argc, char **argv) |
| 6462 | 6462 | { |
| 6463 | 6463 | struct opbx_timing timing; |
| 6464 | char *s; | |
| 6464 | char *s, *q; | |
| 6465 | 6465 | |
| 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], '?'))) { | |
| 6473 | 6467 | opbx_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>?[[context,]extension,]priority\n"); |
| 6474 | 6468 | return -1; |
| 6475 | 6469 | } |
| 6476 | 6470 | |
| 6471 | /* Trim trailing space from the timespec */ | |
| 6472 | q = s; | |
| 6473 | do { *(q--) = '\0'; } while (q >= argv[3] && isspace(*q)); | |
| 6474 | ||
| 6477 | 6475 | get_timerange(&timing, argv[0]); |
| 6478 | 6476 | timing.dowmask = get_dow(argv[1]); |
| 6479 | 6477 | timing.daymask = get_day(argv[2]); |
| 6480 | 6478 | timing.monthmask = get_month(argv[3]); |
| 6481 | 6479 | |
| 6482 | 6480 | if (opbx_check_timing(&timing)) { |
| 6481 | do { *(s++) = '\0'; } while (isspace(*s)); | |
| 6483 | 6482 | argv[3] = s; |
| 6484 | 6483 | argv += 3; |
| 6485 | 6484 | argc -= 3; |
| --- | --- | |
| 6492 | 6491 | static int pbx_builtin_execiftime(struct opbx_channel *chan, int argc, char **argv) |
| 6493 | 6492 | { |
| 6494 | 6493 | struct opbx_timing timing; |
| 6495 | char *s; | |
| 6494 | char *s, *q; | |
| 6496 | 6495 | |
| 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], '?'))) { | |
| 6504 | 6497 | opbx_log(LOG_WARNING, "ExecIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>?<appname>[(<args>)]\n"); |
| 6505 | 6498 | return -1; |
| 6506 | 6499 | } |
| 6507 | 6500 | |
| 6501 | /* Trim trailing space from the timespec */ | |
| 6502 | q = s; | |
| 6503 | do { *(q--) = '\0'; } while (q >= argv[3] && isspace(*q)); | |
| 6504 | ||
| 6508 | 6505 | get_timerange(&timing, argv[0]); |
| 6509 | 6506 | timing.dowmask = get_dow(argv[1]); |
| 6510 | 6507 | timing.daymask = get_day(argv[2]); |
| 6511 | 6508 | timing.monthmask = get_month(argv[3]); |
| 6512 | 6509 | |
| 6513 | 6510 | 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); | |
| 6515 | 6514 | if (app) { |
| 6516 | 6515 | if ((s = strchr(s, '('))) { |
| 6517 | 6516 | argv[0] = s + 1; |
| --- | --- | |
| 6519 | 6518 | *s = '\0'; |
| 6520 | 6519 | return pbx_exec(chan, app, argv[0]); |
| 6521 | 6520 | } else { |
| 6522 | return pbx_exec_argv(chan, app, argc - 4, argv + 5); | |
| 6521 | return pbx_exec_argv(chan, app, argc - 4, argv + 4); | |
| 6523 | 6522 | } |
| 6524 | 6523 | } else { |
| 6525 | 6524 | opbx_log(LOG_WARNING, "Cannot locate application %s\n", s); |
![Home changeset 3167 [home]](/images/logo.png?1180520111)
RSS Feeds