void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt) { wcsession *WCC = WC; int n; n = GetCount(WCC->Hdr->HTTPHeaders); Put(WCC->Hdr->HTTPHeaders, IKEY(n), Data, DeleteIt); }
void NewMailQEntry(OneQueItem *Item) { Item->Current = (MailQEntry*) malloc(sizeof(MailQEntry)); memset(Item->Current, 0, sizeof(MailQEntry)); if (Item->MailQEntries == NULL) Item->MailQEntries = NewHash(1, Flathash); /* alocate big buffer so we won't get problems reallocating later. */ Item->Current->StatusMessage = NewStrBufPlain(NULL, SIZ); Item->Current->n = GetCount(Item->MailQEntries); Put(Item->MailQEntries, IKEY(Item->Current->n), Item->Current, FreeMailQEntry); }
HashList *iterate_FindConflict(StrBuf *Target, WCTemplputParams *TP) { StrBuf *Line; HashList *Conflicts = NULL; CalendarConflict *Conflict; wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH); serv_printf("ICAL conflicts|%ld|%s|", Mime->msgnum, ChrPtr(Mime->PartNum)); Line = NewStrBuf(); StrBuf_ServGetln(Line); if (GetServerStatus(Line, NULL) == 1) { const char *Pos = NULL; int Done = 0; int n = 0; Conflicts = NewHash(1, Flathash); while(!Done && (StrBuf_ServGetln(Line) >= 0) ) if ( (StrLength(Line)==3) && !strcmp(ChrPtr(Line), "000")) { Done = 1; } else { Conflict = (CalendarConflict *) malloc(sizeof(CalendarConflict)); Conflict->conflict_event_uid = NewStrBufPlain(NULL, StrLength(Line)); Conflict->conflict_event_summary = NewStrBufPlain(NULL, StrLength(Line)); Conflict->existing_msgnum = StrBufExtractNext_long(Line, &Pos, '|'); StrBufSkip_NTokenS(Line, &Pos, '|', 1); StrBufExtract_NextToken(Conflict->conflict_event_uid, Line, &Pos, '|'); StrBufExtract_NextToken(Conflict->conflict_event_summary, Line, &Pos, '|'); Conflict->is_update = StrBufExtractNext_long(Line, &Pos, '|'); Put(Conflicts, IKEY(n), Conflict, DeleteConflict); n++; Pos = NULL; } } FreeStrBuf(&Line); syslog(LOG_DEBUG, "...done.\n"); return Conflicts; }
eNextState QueueAnDBOperation(AsyncIO *IO) { IOAddHandler *h; int i; SetEVState(IO, eDBQ); h = (IOAddHandler*)malloc(sizeof(IOAddHandler)); h->IO = IO; assert(IO->ReAttachCB != NULL); h->EvAttch = IO->ReAttachCB; ev_cleanup_init(&IO->db_abort_by_shutdown, IO_abort_shutdown_callback); IO->db_abort_by_shutdown.data = IO; pthread_mutex_lock(&DBEventQueueMutex); if (DBInboundEventQueue == NULL) { /* shutting down... */ free(h); EVM_syslog(LOG_DEBUG, "DBEVENT Q exiting.\n"); pthread_mutex_unlock(&DBEventQueueMutex); return eAbort; } EVM_syslog(LOG_DEBUG, "DBEVENT Q\n"); i = ++evdb_count ; Put(DBInboundEventQueue, IKEY(i), h, NULL); pthread_mutex_unlock(&DBEventQueueMutex); pthread_mutex_lock(&DBEventExitQueueMutex); if (event_db == NULL) { pthread_mutex_unlock(&DBEventExitQueueMutex); return eAbort; } ev_async_send (event_db, &DBAddJob); pthread_mutex_unlock(&DBEventExitQueueMutex); EVQM_syslog(LOG_DEBUG, "DBEVENT Q Done.\n"); return eDBQuery; }
HashList *iterate_get_ical_attendees(StrBuf *Target, WCTemplputParams *TP) { icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL); icalparameter *partstat_param; icalproperty *p; CalAttendee *Att; HashList *Attendees = NULL; const char *ch; int n = 0; /* If the component has attendees, iterate through them. */ for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); (p != NULL); p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) { ch = icalproperty_get_attendee(p); if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) { Att = (CalAttendee*) malloc(sizeof(CalAttendee)); /** screen name or email address */ Att->AttendeeStr = NewStrBufPlain(ch + 7, -1); StrBufTrim(Att->AttendeeStr); /** participant status */ partstat_param = icalproperty_get_first_parameter( p, ICAL_PARTSTAT_PARAMETER ); if (partstat_param == NULL) { Att->partstat = ICAL_PARTSTAT_X; } else { Att->partstat = icalparameter_get_partstat(partstat_param); } if (Attendees == NULL) Attendees = NewHash(1, Flathash); Put(Attendees, IKEY(n), Att, DeleteAtt); n++; } } return Attendees; }
eNextState QueueAnEventContext(AsyncIO *IO) { IOAddHandler *h; int i; SetEVState(IO, eIOQ); h = (IOAddHandler*)malloc(sizeof(IOAddHandler)); h->IO = IO; assert(IO->ReAttachCB != NULL); h->EvAttch = IO->ReAttachCB; ev_cleanup_init(&IO->abort_by_shutdown, IO_abort_shutdown_callback); IO->abort_by_shutdown.data = IO; pthread_mutex_lock(&EventQueueMutex); if (InboundEventQueue == NULL) { free(h); /* shutting down... */ EVM_syslog(LOG_DEBUG, "EVENT Q exiting.\n"); pthread_mutex_unlock(&EventQueueMutex); return eAbort; } EVM_syslog(LOG_DEBUG, "EVENT Q\n"); i = ++evbase_count; Put(InboundEventQueue, IKEY(i), h, NULL); pthread_mutex_unlock(&EventQueueMutex); pthread_mutex_lock(&EventExitQueueMutex); if (event_base == NULL) { pthread_mutex_unlock(&EventExitQueueMutex); return eAbort; } ev_async_send (event_base, &AddJob); pthread_mutex_unlock(&EventExitQueueMutex); EVM_syslog(LOG_DEBUG, "EVENT Q Done.\n"); return eSendReply; }
eNextState QueueCurlContext(AsyncIO *IO) { IOAddHandler *h; int i; SetEVState(IO, eCurlQ); h = (IOAddHandler*)malloc(sizeof(IOAddHandler)); h->IO = IO; h->EvAttch = evcurl_handle_start; pthread_mutex_lock(&EventQueueMutex); if (InboundEventQueue == NULL) { /* shutting down... */ free(h); EVM_syslog(LOG_DEBUG, "EVENT Q exiting.\n"); pthread_mutex_unlock(&EventQueueMutex); return eAbort; } EVM_syslog(LOG_DEBUG, "EVENT Q\n"); i = ++evbase_count; Put(InboundEventQueue, IKEY(i), h, NULL); pthread_mutex_unlock(&EventQueueMutex); pthread_mutex_lock(&EventExitQueueMutex); if (event_base == NULL) { pthread_mutex_unlock(&EventExitQueueMutex); return eAbort; } ev_async_send (event_base, &AddJob); pthread_mutex_unlock(&EventExitQueueMutex); EVM_syslog(LOG_DEBUG, "EVENT Q Done.\n"); return eSendReply; }