X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-sys%2Fevtloop.h;h=84f2eb05ff116b773ad284f939a3bd915643c147;hb=7489084cbae92559260659c8606eea91d70e8f3b;hp=6c5e0d8bee0028e72c19858e4d5c215f860b0eba;hpb=b70142c2915d0b7bcbba1fcb8d24d8d05c9c1fca;p=apps%2Fmadmutt.git diff --git a/lib-sys/evtloop.h b/lib-sys/evtloop.h index 6c5e0d8..84f2eb0 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, @@ -55,12 +56,14 @@ typedef enum el_event { typedef struct job_t { int fd; + gnutls_session_t session; + el_state state : 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); @@ -75,10 +78,20 @@ typedef struct machine_t { 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); +__must_check__ ssize_t el_job_read(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);