aboutsummaryrefslogtreecommitdiff
path: root/cron.c
diff options
context:
space:
mode:
authorKlaatu <[email protected]>2015-05-17 15:33:21 +1200
committerKlaatu <[email protected]>2015-05-17 15:33:21 +1200
commitb0de699679e8f1e39af847ed172d1ba605b4370c (patch)
tree01dac00471d61f727394e508c613b29cff0ceae5 /cron.c
bulk upload of source
Diffstat (limited to 'cron.c')
-rw-r--r--cron.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/cron.c b/cron.c
new file mode 100644
index 0000000..05a94a8
--- /dev/null
+++ b/cron.c
@@ -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;
+}