]> mj.ucw.cz Git - eval.git/blob - submit/tasks.c
e420bef392ad7ce7faab6a54f9fed0b2842c2625
[eval.git] / submit / tasks.c
1 /*
2  *  The Submit Daemon: Tasks
3  *
4  *  (c) 2007 Martin Mares <mj@ucw.cz>
5  */
6
7 #include "lib/lib.h"
8 #include "lib/conf.h"
9 #include "lib/stkstring.h"
10
11 #include <sys/stat.h>
12
13 #include "submitd.h"
14
15 clist task_list;
16
17 static byte *
18 tasks_conf_init(void)
19 {
20   clist_init(&task_list);
21   return NULL;
22 }
23
24 static struct cf_section task_conf = {
25   CF_TYPE(struct task),
26   CF_ITEMS {
27     CF_STRING("Name", PTR_TO(struct task, name)),
28     CF_END
29   }
30 };
31
32 struct cf_section tasks_conf = {
33   CF_INIT(tasks_conf_init),
34   CF_ITEMS {
35     CF_LIST("Task", &task_list, &task_conf),
36     CF_END
37   }
38 };
39
40 struct task *
41 task_find(byte *name)
42 {
43   CLIST_FOR_EACH(struct task *, t, task_list)
44     if (!strcasecmp(t->name, name))
45       return t;
46   return NULL;
47 }
48
49 int
50 user_exists_p(byte *user)
51 {
52   byte *fn = stk_printf("solutions/%s/status", user);
53   struct stat st;
54   return !stat(fn, &st) && S_ISREG(st.st_mode);
55 }