]> mj.ucw.cz Git - moe.git/blob - submit/submitd.h
Keep history of submitted tasks.
[moe.git] / submit / submitd.h
1 /*
2  *  The Submit Daemon
3  *
4  *  (c) 2007 Martin Mares <mj@ucw.cz>
5  */
6
7 #ifndef _SUBMITD_H
8 #define _SUBMITD_H
9
10 #include "lib/clists.h"
11 #include "lib/ipaccess.h"
12 #include "lib/fastbuf.h"
13
14 #include <gnutls/gnutls.h>
15 #include <gnutls/x509.h>
16
17 struct ip_node {
18   cnode n;
19   struct ip_addrmask addrmask;
20 };
21
22 struct access_rule {
23   cnode n;
24   clist ip_list;
25   uns allow_admin;
26   uns plain_text;
27   uns max_conn;
28 };
29
30 struct conn {
31   // Set up by the master process
32   cnode n;
33   u32 ip;
34   byte *ip_string;                      // (xmalloced)
35   pid_t pid;
36   uns id;
37   struct access_rule *rule;             // Rule matched by this connection
38   int sk;                               // Client socket
39   byte *cert_name;                      // Client name from the certificate (NULL if no TLS) (xmalloced)
40
41   // Used by the child process
42   gnutls_session_t tls;                 // TLS session
43   struct fastbuf rx_fb, tx_fb;          // Fastbufs for communication with the client (either plain-text or TLS)
44   struct mempool *pool;
45   struct odes *request;
46   struct odes *reply;
47   struct odes *task_status;
48   int task_lock_fd;
49   byte *user;
50 };
51
52 extern uns max_request_size, max_attachment_size, trace_commands;
53 extern byte *history_format;
54
55 /* submitd.c */
56
57 void NONRET client_error(char *msg, ...);
58
59 /* commands.c */
60
61 int process_init(struct conn *c);
62 int process_command(struct conn *c);
63
64 /* tasks.c */
65
66 struct task {
67   cnode n;
68   byte *name;
69   uns open_data;        // Number of parts for open-data tasks
70   uns max_size;         // Maximum size (0=use global default)
71   clist parts;          // List of parts of this task (simp_nodes)
72   clist *extensions;    // List of allowed extensions for this task (simp_nodes)
73 };
74
75 extern clist task_list;
76 extern struct cf_section tasks_conf;
77
78 struct task *task_find(byte *name);
79 int part_exists_p(struct task *t, byte *name);
80 int user_exists_p(byte *user);
81 int ext_exists_p(struct task *t, byte *ext);
82
83 void task_lock_status(struct conn *c);
84 void task_unlock_status(struct conn *c, uns write_back);
85 void task_load_status(struct conn *c);
86
87 struct odes *task_status_find_task(struct conn *c, struct task *t, uns create);
88 struct odes *task_status_find_part(struct odes *t, byte *part, uns create);
89
90 void task_submit_part(byte *user, byte *task, byte *part, byte *ext, uns version, struct fastbuf *fb);
91 void task_delete_part(byte *user, byte *task, byte *part, byte *ext, uns version);
92
93 #endif