X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-sys%2Fevtloop.h;h=8b465f582bbacff68e9e857de85d93ab4e19dc09;hb=f3076bd918cea51487a5b28dff9c69578f50b25e;hp=f08f1e76ceb8994a1a0c8623f0523f3b6ebf868e;hpb=66572f4a9c4574c9f2a2c3ef59526ac66b807b0b;p=apps%2Fmadmutt.git diff --git a/lib-sys/evtloop.h b/lib-sys/evtloop.h index f08f1e7..8b465f5 100644 --- a/lib-sys/evtloop.h +++ b/lib-sys/evtloop.h @@ -22,6 +22,7 @@ #define MUTT_LIB_SYS_EVTLOOP_H #include +#include typedef enum el_state { EL_LLP_INIT, @@ -30,10 +31,11 @@ typedef enum el_state { } el_state; typedef enum el_mode { - EL_IDLE = 0, + EL_NEW = 0, EL_READING = 1, EL_WRITING = 2, EL_RDWR = 3, + EL_IDLE = 4, } el_mode; typedef enum el_status { @@ -53,24 +55,48 @@ typedef enum el_event { typedef struct job_t { int fd; + int ssf; + + gnutls_session_t session; + gnutls_certificate_credentials_t xcred; el_state state : 2; - el_mode mode : 2; - el_mode emode : 2; + el_mode mode : 3; + el_mode emode : 3; int (*llp)(struct job_t *); - struct machine_t *m; + const struct machine_t *m; void *ptr; } job_t; +DO_INIT(job_t, job); +void job_wipe(job_t *w); +DO_NEW(job_t, job); +DO_DELETE(job_t, job); typedef struct machine_t { const char *name; __must_check__ int (*setup)(job_t *w, void *); - int (*on_event)(job_t *w, el_event); + __must_check__ int (*on_event)(job_t *w, el_event); void (*finalize)(job_t *w, el_status); } machine_t; +#define EL_JOB_CHECK(expr) \ + do { if ((expr) < 0) return -1; } while (0) + +__must_check__ int el_job_setmode(job_t *w, el_mode); __must_check__ int el_job_release(job_t *j, el_status); +__must_check__ int el_job_connect(job_t *w, struct sockaddr *, socklen_t len, + int type, int proto, int ssl); +__must_check__ int el_job_starttls(job_t *w); +__must_check__ ssize_t el_job_read(job_t *w, buffer_t *buf); +__must_check__ ssize_t el_job_write(job_t *w, buffer_t *buf); + +static inline job_t *el_job_start(const machine_t *m, void *cfg) { + job_t *w = job_new(); + w->m = m; + return m->setup(w, cfg) < 0 ? NULL : w; +} + int el_dispatch(int timeout); #endif