--- /home/defer/temp/scron/crond.c 2014-07-05 12:16:11.917457442 +0300 +++ crond.c 2014-07-05 12:47:43.147434577 +0300 @@ -23,6 +23,7 @@ struct range { int low; int high; + int div; }; struct ctabentry { @@ -150,12 +151,15 @@ matchentry(struct ctabentry *cte, struct size_t i; for (i = 0; i < LEN(matchtbl); i++) { + printf("%d %d %d\n", matchtbl[i].r->low, matchtbl[i].r->high, matchtbl[i].r->div); /* this is the match-any case, '*' */ if (matchtbl[i].r->low == -1 && matchtbl[i].r->high == -1) continue; if (matchtbl[i].r->high == -1) { if (matchtbl[i].r->low == matchtbl[i].tm) continue; + else if (matchtbl[i].tm % matchtbl[i].r->div == 0) + continue; } else { if (matchtbl[i].r->low <= matchtbl[i].tm && matchtbl[i].r->high >= matchtbl[i].tm) @@ -171,7 +175,7 @@ matchentry(struct ctabentry *cte, struct static int parsefield(const char *field, int low, int high, struct range *r) { - int min, max; + int min, max, div; char *e1, *e2; if (strcmp(field, "*") == 0) { @@ -180,6 +184,7 @@ parsefield(const char *field, int low, i return 0; } + div = -1; max = -1; min = strtol(field, &e1, 10); @@ -190,6 +195,15 @@ parsefield(const char *field, int low, i if (e2[0] != '\0') return -1; break; + case '*': + e1++; + if (e1[0] == '/') { + e1++; + div = strtol(e1, &e2, 10); + if (e2[0] != '\0') + return -1; + break; + } case '\0': break; default: @@ -204,6 +218,7 @@ parsefield(const char *field, int low, i r->low = min; r->high = max; + r->div = div; return 0; }