task.h (922B)
1 #ifndef TASK_H 2 #define TASK_H 3 4 struct client; 5 6 enum task { 7 TASK_READ = 0, 8 TASK_DIR, 9 TASK_TXT, 10 TASK_GOPHERMAP, 11 TASK_GPH, 12 TASK_BINARY, 13 TASK_ERROR, 14 TASK_REDIRECT, 15 TASK_CGI, 16 TASK_DCGI, 17 }; 18 19 struct dir_task { 20 struct dirent **entries; 21 char *base; 22 int n; 23 int i; 24 int dfd; 25 }; 26 27 struct txt_task { 28 char linebuf[512]; 29 int rfd; 30 size_t used; 31 }; 32 33 struct gph_task { 34 char linebuf[512]; 35 size_t used; 36 char *base; 37 int rfd; 38 }; 39 40 struct binary_task { 41 int rfd; 42 }; 43 44 struct cgi_task { 45 ev_io input_watcher; 46 ev_child child_watcher; 47 pid_t pid; 48 int rfd; 49 }; 50 51 struct dcgi_task { 52 struct gph_task gpht; 53 struct cgi_task ct; 54 }; 55 56 struct task_ { 57 void (*init)(EV_P_ struct client *c, int fd, struct stat *sb, const char *path, const char *fn, const char *pi, const char *qs, const char *ss); 58 void (*update)(EV_P_ struct client *c, int events); 59 void (*finish)(EV_P_ struct client *c); 60 }; 61 62 extern const struct task_ tasks[]; 63 64 #endif