SmtpOutMsg *new_smtp_outmsg(OneQueItem *MyQItem, MailQEntry *MyQEntry, int MsgCount) { SmtpOutMsg * Msg; Msg = (SmtpOutMsg *) malloc(sizeof(SmtpOutMsg)); if (Msg == NULL) return NULL; memset(Msg, 0, sizeof(SmtpOutMsg)); Msg->n = MsgCount; Msg->MyQEntry = MyQEntry; Msg->MyQItem = MyQItem; Msg->pCurrRelay = MyQItem->URL; InitIOStruct(&Msg->IO, Msg, eReadMessage, SMTP_C_ReadServerStatus, SMTP_C_DNSFail, SMTP_C_DispatchWriteDone, SMTP_C_DispatchReadDone, SMTP_C_Terminate, SMTP_C_TerminateDB, SMTP_C_ConnFail, SMTP_C_Timeout, SMTP_C_Shutdown); Msg->IO.ErrMsg = Msg->MyQEntry->StatusMessage; return Msg; }
int pop3_do_fetching(pop3aggr *cpptr) { AsyncIO *IO = &cpptr->IO; InitIOStruct(IO, cpptr, eReadMessage, POP3_C_ReadServerStatus, POP3_C_DNSFail, POP3_C_DispatchWriteDone, POP3_C_DispatchReadDone, POP3_C_Terminate, POP3_C_TerminateDB, POP3_C_ConnFail, POP3_C_Timeout, POP3_C_Shutdown); safestrncpy(((CitContext *)cpptr->IO.CitContext)->cs_host, ChrPtr(cpptr->Url), sizeof(((CitContext *)cpptr->IO.CitContext)->cs_host)); if (cpptr->IO.ConnectMe->IsIP) { QueueEventContext(&cpptr->IO, pop3_connect_ip); } else { QueueEventContext(&cpptr->IO, pop3_get_one_host_ip); } return 1; }
void KillAsyncIOContext(AsyncIO *IO) { KillOtherSessionContext *Ctx; Ctx = (KillOtherSessionContext*) malloc(sizeof(KillOtherSessionContext)); memset(Ctx, 0, sizeof(KillOtherSessionContext)); InitIOStruct(&Ctx->IO, Ctx, eReadMessage, NULL, NULL, NULL, NULL, KillTerminate, NULL, NULL, NULL, KillShutdown); Ctx->OtherOne = IO; switch(IO->NextState) { case eSendDNSQuery: case eReadDNSReply: case eConnect: case eSendReply: case eSendMore: case eSendFile: case eReadMessage: case eReadMore: case eReadPayload: case eReadFile: Ctx->IO.ReAttachCB = KillOtherContextNow; QueueAnEventContext(&Ctx->IO); break; case eDBQuery: Ctx->IO.ReAttachCB = KillOtherContextNow; QueueAnDBOperation(&Ctx->IO); break; case eTerminateConnection: case eAbort: /*hm, its already dying, dunno which Queue its in... */ free(Ctx); } }