diff options
| author | Klaatu <[email protected]> | 2015-05-17 15:33:21 +1200 |
|---|---|---|
| committer | Klaatu <[email protected]> | 2015-05-17 15:33:21 +1200 |
| commit | b0de699679e8f1e39af847ed172d1ba605b4370c (patch) | |
| tree | 01dac00471d61f727394e508c613b29cff0ceae5 /cron.c | |
bulk upload of source
Diffstat (limited to 'cron.c')
| -rw-r--r-- | cron.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -0,0 +1,27 @@ +#include <time.h> +#include "ninitfeatures.h" + +void cron(char **argv, unsigned long *ret) /*EXTRACT_INCL*/ { + unsigned long a,b,n, cron=0, now=time(0); + unsigned long u[3]; + int dummy; + char *p; + + for (; *argv; argv++) { + p = *argv; + u[2] = 0; + if (scan_ulongs(p,u,3, scan_sec,':',&dummy) < 2) continue; + + if ((a=u[0])==0 || a > (1<<29)) continue; + n = now; + b = u[1]; + + if ((a % 604800) == 0) { b += 3*86400; n -= 3*86400; } + b %= a; + n = n + b - (n % a); + while (n <= now) n += a; + + if (cron==0 || n < cron) { cron = n; ret[1] = u[2]; } + } + ret[0] = cron; +} |
