38 static const char* task_str =
"task";
50 static int ntaskreg = 0;
56 for (i=0; i<ntaskreg; ++i) {
57 if (strcmp(taskreg[i].long_name,long_name)==0) {
65 static const char *task_id_to_short_name(
task_id id,
const char *def)
88 for (i=0; i<ntaskreg; ++i) {
89 if (strcmp(long_name, taskreg[i].long_name)==0) {
96 ods_log_error(
"Unable to register additional name,how pairs for tasks.");
101 taskreg[ntaskreg].
how =
how;
111 void* context,
how_type clean_context)
115 if (!who || !context) {
116 ods_log_error(
"[%s] cannot create: missing context info", task_str);
120 ods_log_assert(context);
124 ods_log_error(
"[%s] cannot create: malloc failed", task_str);
127 task->
what = what_id;
132 task->
who = strdup(who);
133 task->
dname = ldns_dname_new_frm_str(what);
137 if (!task_id_to_how(what_id, &task->
how))
153 ldns_rdf_deep_free(task->
dname);
187 return ldns_dname_compare((
const void*) x->
dname,
188 (
const void*) y->
dname);
202 return ldns_dname_compare((
const void*) x->
dname,
203 (
const void*) y->
dname);
216 return "do nothing with";
218 return "load signconf for";
230 return task_id_to_short_name(what,
"???");
257 time_t now = time_now();
258 char* strtime = NULL;
259 char* strtask = NULL;
263 strtime = ctime_r(&now,ctimebuf);
265 strtime = ctime_r(&task->
when,ctimebuf);
268 strtime[strlen(strtime)-1] =
'\0';
271 (void)snprintf(buftask, ODS_SE_MAXLINE,
"On %s I will [%s] %s" 276 strtask = (
char*) calloc(ODS_SE_MAXLINE,
sizeof(
char));
277 snprintf(strtask, ODS_SE_MAXLINE,
"On %s I will [%s] %s\n",
295 return task->
how(task);
void ods_log_error(const char *format,...)
bool task_id_from_long_name(const char *long_name, task_id *pwhat)
task_type *(* how)(task_type *task)
enum task_id_enum task_id
task_type * task_perform(task_type *task)
void task_cleanup(task_type *task)
const char * task_what2str(int what)
task_type *(* clean_context)(task_type *task)
const char * task_who2str(const char *who)
task_id task_register(const char *short_name, const char *long_name, how_type how)
task_type * task_create(task_id what_id, time_t when, const char *who, const char *what, void *context, how_type clean_context)
int task_compare(const void *a, const void *b)
char * task2str(task_type *task, char *buftask)
int task_compare_name(const void *a, const void *b)
task_type *(* how_type)(task_type *task)