static void lmtp_handle_input(void *arg) { int l; char buffer[MAX_LINESIZE]; /* connection buffer */ ClientSession_T *session = (ClientSession_T *)arg; while (TRUE) { memset(buffer, 0, sizeof(buffer)); l = ci_readln(session->ci, buffer); if (l==0) break; if ((l = lmtp_tokenizer(session, buffer))) { if (l == -3) { client_session_bailout(&session); return; } if (l > 0) { if (lmtp(session) == -3) { client_session_bailout(&session); return; } client_session_reset_parser(session); } if (l < 0) { client_session_reset_parser(session); } } } TRACE(TRACE_DEBUG,"[%p] done", session); }
static void tims_handle_input(void *arg) { int l = 0; char buffer[MAX_LINESIZE]; /* connection buffer */ ClientSession_t *session = (ClientSession_t *)arg; ci_cork(session->ci); while (TRUE) { memset(buffer, 0, sizeof(buffer)); l = ci_readln(session->ci, buffer); if (l == 0) break; if ((l = tims_tokenizer(session, buffer))) { if (l == -3) { client_session_bailout(&session); return; } if (tims(session) == -3) { client_session_bailout(&session); return; } client_session_reset_parser(session); } } if (session->state < QUIT) ci_uncork(session->ci); }
void socket_write_cb(int fd UNUSED, short what UNUSED, void *arg) { ClientSession_t *session = (ClientSession_t *)arg; TRACE(TRACE_DEBUG,"[%p] state: [%d]", session, session->state); if (session->ci->cb_write) session->ci->cb_write(session); switch(session->state) { case CLIENTSTATE_INITIAL_CONNECT: case CLIENTSTATE_NON_AUTHENTICATED: TRACE(TRACE_DEBUG,"reset timeout [%d]", server_conf->login_timeout); client_session_set_timeout(session, server_conf->login_timeout); break; case CLIENTSTATE_AUTHENTICATED: case CLIENTSTATE_SELECTED: TRACE(TRACE_DEBUG,"reset timeout [%d]", server_conf->timeout); client_session_set_timeout(session, server_conf->timeout); break; default: case CLIENTSTATE_ANY: break; case CLIENTSTATE_LOGOUT: case CLIENTSTATE_QUIT: case CLIENTSTATE_ERROR: client_session_bailout(&session); break; } }
void client_session_read(void *arg) { int state; ClientSession_t *session = (ClientSession_t *)arg; TRACE(TRACE_DEBUG, "[%p] state: [%d]", session, session->state); ci_read_cb(session->ci); state = session->ci->client_state; if (state & CLIENT_ERR) { TRACE(TRACE_DEBUG,"client_state ERROR"); client_session_bailout(&session); } else if (state & CLIENT_EOF) { TRACE(TRACE_NOTICE,"reached EOF"); event_del(session->ci->rev); if (session->ci->read_buffer->len < 1) client_session_bailout(&session); else session->handle_input(session); } else if (state & CLIENT_OK || state & CLIENT_AGAIN) { session->handle_input(session); } }
void pop3_cb_write(void *arg) { ClientSession_t *session = (ClientSession_t *)arg; TRACE(TRACE_DEBUG, "[%p] state: [%d]", session, session->state); switch (session->state) { case CLIENTSTATE_QUIT: db_session_cleanup(session); client_session_bailout(&session); break; default: ci_write_cb(session->ci); session->handle_input(session); break; } }
void tims_cb_write(void *arg) { ClientSession_t *session = (ClientSession_t *)arg; TRACE(TRACE_DEBUG, "[%p] state: [%d]", session, session->state); switch(session->state) { case QUIT: client_session_bailout(&session); break; default: if (session->ci->write_buffer->len > session->ci->write_buffer_offset) { ci_write(session->ci,NULL); break; } session->handle_input(session); break; } }
static void pop3_handle_input(void *arg) { char buffer[MAX_LINESIZE]; /* connection buffer */ ClientSession_T *session = (ClientSession_T *)arg; if (p_string_len(session->ci->write_buffer)) { ci_write(session->ci, NULL); return; } memset(buffer, 0, sizeof(buffer)); if (ci_readln(session->ci, buffer) == 0) return; ci_cork(session->ci); if (pop3(session, buffer) <= 0) { client_session_bailout(&session); return; } ci_uncork(session->ci); }
int pop3_error(ClientSession_t * session, const char *formatstring, ...) { va_list ap, cp; char *s; clientbase_t *ci = session->ci; if (session->error_count >= MAX_ERRORS) { ci_write(ci, "-ERR too many errors\r\n"); client_session_bailout(&session); return -3; } else { va_start(ap, formatstring); va_copy(cp, ap); s = g_strdup_vprintf(formatstring, cp); va_end(cp); ci_write(ci, s); g_free(s); } TRACE(TRACE_DEBUG, "an invalid command was issued"); session->error_count++; return 1; }
void pop3_cb_time(void * arg) { ClientSession_T *session = (ClientSession_T *)arg; ci_write(session->ci, "-ERR I'm leaving, you're too slow\r\n"); client_session_bailout(&session); }