1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include <sysdeps.h>
#include <systime.h>
#include <stdlib.h>
#include <string.h>
#include <cli/cli.h>
#include <iobuf/iobuf.h>
#include <misc/misc.h>
#include <msg/msg.h>
#include "bcron.h"
const char program[] = "test-sched";
const int msg_show_pid = 0;
int msg_debug_bits = 0;
const char cli_help_prefix[] = "\n";
const char cli_help_suffix[] = "";
const char cli_args_usage[] = "cron-line time";
const int cli_args_min = 2;
const int cli_args_max = 2;
cli_option cli_options[] = {
{0,0,0,0,0,0,0}
};
int cli_main(int argc, char* argv[])
{
time_t start;
time_t next;
struct crontab c;
str jobstr;
msg_debug_init();
timespec_next_init();
memset(&c, 0, sizeof c);
jobstr.len = strlen(jobstr.s = argv[0]);
jobstr.size = 0;
if (!crontab_parse(&c, &jobstr, "nobody")
|| c.jobs == 0)
usage(111, "Invalid crontab line");
if ((start = strtol(argv[1], 0, 10)) <= 0)
usage(111, "Invalid timesstamp");
next = timespec_next(&c.jobs->times, start, localtime(&start));
obuf_put5s(&outbuf, "last: ", utoa(start), " ", fmttime(start), "\n");
obuf_put5s(&outbuf, "next: ", utoa(next), " ", fmttime(next), "\n");
obuf_flush(&outbuf);
return 0;
(void)argc;
}
|