eNextState POP3C_GetOneMessageIDState(pop3aggr *RecvMsg) { AsyncIO *IO = &RecvMsg->IO; #if 0 int rc; rc = TestValidateHash(RecvMsg->MsgNumbers); if (rc != 0) EVP3CCS_syslog(LOG_DEBUG, "Hash Invalid: %d\n", rc); #endif POP3C_DBG_READ(); if (!POP3C_OK) return eTerminateConnection; RecvMsg->CurrMsg->MsgUIDL = NewStrBufPlain(NULL, StrLength(RecvMsg->IO.IOBuf)); RecvMsg->CurrMsg->MsgUID = NewStrBufPlain(NULL, StrLength(RecvMsg->IO.IOBuf) * 2); StrBufExtract_token(RecvMsg->CurrMsg->MsgUIDL, RecvMsg->IO.IOBuf, 2, ' '); StrBufPrintf(RecvMsg->CurrMsg->MsgUID, "pop3/%s/%s:%s@%s", ChrPtr(RecvMsg->RoomName), ChrPtr(RecvMsg->CurrMsg->MsgUIDL), RecvMsg->IO.ConnectMe->User, RecvMsg->IO.ConnectMe->Host); RecvMsg->State --; return eSendReply; }
void HttpNewModule_CONTEXT (ParsedHttpHdrs *httpreq) { httpreq->PlainArgs = NewStrBufPlain(NULL, SIZ); httpreq->this_page = NewStrBufPlain(NULL, SIZ); }
void SessionNewModule_WEBCIT (wcsession *sess) { sess->ImportantMsg = NewStrBuf(); sess->WBuf = NewStrBufPlain(NULL, SIZ * 4); sess->HBuf = NewStrBufPlain(NULL, SIZ / 4); }
void display_editfloorpic(void) { StrBuf *PicAction; PicAction = NewStrBuf(); StrBufPrintf(PicAction, "_floorpic_|%s", bstr("which_floor")); putbstr("__WHICHPIC", PicAction); putbstr("__PICDESC", NewStrBufPlain(_("the icon for this floor"), -1)); putbstr("__UPLURL", NewStrBufPlain(HKEY("editfloorpic"))); display_graphics_upload("editfloorpic"); }
void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, const char *DisplayName, long dslen, WebcitHandlerFunc F, long Flags) { WebcitHandler *NewHandler; NewHandler = (WebcitHandler*) malloc(sizeof(WebcitHandler)); NewHandler->F = F; NewHandler->Flags = Flags; NewHandler->Name = NewStrBufPlain(UrlString, UrlSLen); StrBufShrinkToFit(NewHandler->Name, 1); NewHandler->DisplayName = NewStrBufPlain(DisplayName, dslen); StrBufShrinkToFit(NewHandler->DisplayName, 1); Put(HandlerHash, UrlString, UrlSLen, NewHandler, DeleteWebcitHandler); }
void InitModule_WEBCIT (void) { char dir[SIZ]; WebcitAddUrlHandler(HKEY("blank"), "", 0, blank_page, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC); WebcitAddUrlHandler(HKEY("landing"), "", 0, display_default_landing_page, ANONYMOUS|COOKIEUNNEEDED); WebcitAddUrlHandler(HKEY("do_template"), "", 0, url_do_template, ANONYMOUS); WebcitAddUrlHandler(HKEY("sslg"), "", 0, seconds_since_last_gexp, AJAX|LOGCHATTY); WebcitAddUrlHandler(HKEY("ajax_servcmd"), "", 0, ajax_servcmd, 0); WebcitAddUrlHandler(HKEY("webcit"), "", 0, blank_page, URLNAMESPACE); WebcitAddUrlHandler(HKEY("push"), "", 0, push_destination, AJAX); WebcitAddUrlHandler(HKEY("pop"), "", 0, pop_destination, 0); WebcitAddUrlHandler(HKEY("401"), "", 0, authorization_required, ANONYMOUS|COOKIEUNNEEDED); RegisterConditional("COND:IMPMSG", 0, ConditionalImportantMesage, CTX_NONE); RegisterConditional("COND:REST:DEPTH", 0, Conditional_REST_DEPTH, CTX_NONE); RegisterConditional("COND:IS_HTTPS", 0, Conditional_IS_HTTPS, CTX_NONE); RegisterNamespace("CSSLOCAL", 0, 0, tmplput_csslocal, NULL, CTX_NONE); RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, NULL, CTX_NONE); RegisterNamespace("TRAILING_JAVASCRIPT", 0, 0, tmplput_trailing_javascript, NULL, CTX_NONE); RegisterNamespace("URL:DISPLAYNAME", 0, 1, tmplput_HANDLER_DISPLAYNAME, NULL, CTX_NONE); RegisterNamespace("PACKAGESTRING", 0, 1, tmplput_packagestring, NULL, CTX_NONE); snprintf(dir, SIZ, "%s/webcit.css", static_local_dir); if (!access(dir, R_OK)) { syslog(LOG_INFO, "Using local Stylesheet [%s]", dir); csslocal = NewStrBufPlain(HKEY("<link href=\"static.local/webcit.css\" rel=\"stylesheet\" type=\"text/css\" />")); } else syslog(LOG_INFO, "No Site-local Stylesheet [%s] installed.", dir); }
/** * this one has to have the context for loading the message via the redirect buffer... */ StrBuf *smtp_load_msg(OneQueItem *MyQItem, int n, char **Author, char **Address) { CitContext *CCC=CC; StrBuf *SendMsg; CCC->redirect_buffer = NewStrBufPlain(NULL, SIZ); CtdlOutputMsg(MyQItem->MessageID, MT_RFC822, HEADERS_ALL, 0, 1, NULL, (ESC_DOT|SUPPRESS_ENV_TO), Author, Address, NULL); SendMsg = CCC->redirect_buffer; CCC->redirect_buffer = NULL; if ((StrLength(SendMsg) > 0) && ChrPtr(SendMsg)[StrLength(SendMsg) - 1] != '\n') { SMTPC_syslog(LOG_WARNING, "[%d] Possible problem: message did not " "correctly terminate. (expecting 0x10, got 0x%02x)\n", MsgCount, //yes uncool, but best choice here... ChrPtr(SendMsg)[StrLength(SendMsg) - 1] ); StrBufAppendBufPlain(SendMsg, HKEY("\r\n"), 0); } return SendMsg; }
static void TestRFC822DecodeStdin(void) { int fdin = 0;// STDIN const char *Err; StrBuf *Target; StrBuf *Source; StrBuf *DefaultCharset; StrBuf *FoundCharset; DefaultCharset = NewStrBufPlain(HKEY("iso-8859-1")); FoundCharset = NewStrBuf(); Source = NewStrBuf(); while (fdin == 0) { StrBufTCP_read_line(Source, &fdin, 0, &Err); Target = NewStrBuf(); StrBuf_RFC822_to_Utf8(Target, Source, DefaultCharset, FoundCharset); TestRevalidateStrBuf(Target); printf("the ugly multi:>%s<\n", ChrPtr(Target)); FreeStrBuf(&Target); } FreeStrBuf(&Source); FreeStrBuf(&FoundCharset); FreeStrBuf(&DefaultCharset); }
int main(int argc, char* argv[]) { StrBuf *WFBuf; StrBuf *OutBuf; StrBuf *Info; int nWildfireHeaders = 0; StartLibCitadel(8); printf("%s == %d?\n", libcitadel_version_string(), libcitadel_version_number()); WildFireInitBacktrace(argv[0], 0); WFBuf = NewStrBuf(); OutBuf = NewStrBuf(); Info = NewStrBufPlain(HKEY("this is just a test message")); SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1); WildFireSerializePayload(WFBuf, OutBuf, &nWildfireHeaders, NULL); CreateWildfireSampleMessage(OutBuf); printf("%s\n\n", ChrPtr(OutBuf)); FreeStrBuf(&WFBuf); FreeStrBuf(&OutBuf); FreeStrBuf(&Info); ShutDownLibCitadel(); return 0; }
static void TestEncodeEmail(void) { StrBuf *Target; StrBuf *Source; StrBuf *UserName = NewStrBuf(); StrBuf *EmailAddress = NewStrBuf(); StrBuf *EncBuf = NewStrBuf(); Source = NewStrBuf(); // Source = NewStrBufPlain(HKEY("Art Cancro <*****@*****.**>, Art Cancro <*****@*****.**>")); Source = NewStrBufPlain(HKEY("\"Alexandra Weiz, Restless GmbH\" <*****@*****.**>, \"NetIN\" <*****@*****.**>, \" יריב ברקאי, מולטימדי\" <*****@*****.**>")); Target = StrBufSanitizeEmailRecipientVector( Source, UserName, EmailAddress, EncBuf ); TestRevalidateStrBuf(Target); printf("the source:>%s<\n", ChrPtr(Source)); printf("the target:>%s<\n", ChrPtr(Target)); FreeStrBuf(&Target); FreeStrBuf(&UserName); FreeStrBuf(&EmailAddress); FreeStrBuf(&EncBuf); FreeStrBuf(&Source); }
static void CreateWildfireSampleMessage(StrBuf *OutBuf) { JsonValue *Error; StrBuf *Buf; StrBuf *Header; StrBuf *Json; int n = 1; Header = NewStrBuf(); Json = NewStrBuf(); Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO); SerializeJson(Json, Error, 1); WildFireSerializePayload(Json, Header, &n, NULL); StrBufAppendBuf(OutBuf, Header, 0); FlushStrBuf(Json); FlushStrBuf(Header); Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Warn message"), eWARN); SerializeJson(Json, Error, 1); WildFireSerializePayload(Json, Header, &n, NULL); StrBufAppendBuf(OutBuf, Header, 0); FlushStrBuf(Json); FlushStrBuf(Header); Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Error message"), eERROR); SerializeJson(Json, Error, 1); WildFireSerializePayload(Json, Header, &n, NULL); StrBufAppendBuf(OutBuf, Header, 0); FlushStrBuf(Json); FlushStrBuf(Header); Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO); SerializeJson(Json, Error, 1); WildFireSerializePayload(Json, Header, &n, NULL); StrBufAppendBuf(OutBuf, Header, 0); FlushStrBuf(Json); FlushStrBuf(Header); Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO); SerializeJson(Json, Error, 1); WildFireSerializePayload(Json, Header, &n, NULL); StrBufAppendBuf(OutBuf, Header, 0); FlushStrBuf(Json); FlushStrBuf(Header); Buf = NewStrBufPlain(HKEY("test error message")); Error = WildFireException(HKEY(__FILE__), __LINE__, Buf, 1); SerializeJson(Json, Error, 1); WildFireSerializePayload(Json, Header, &n, NULL); StrBufAppendBuf(OutBuf, Header, 0); FreeStrBuf(&Buf); FreeStrBuf(&Json); FreeStrBuf(&Header); }
StrBuf *SerializeQueueItem(OneQueItem *MyQItem) { StrBuf *QMessage; HashPos *It; const char *Key; long len; void *vQE; QMessage = NewStrBufPlain(NULL, SIZ); StrBufPrintf(QMessage, "Content-type: %s\n", SPOOLMIME); // "attempted|%ld\n" "retry|%ld\n",, (long)time(NULL), (long)retry ); StrBufAppendBufPlain(QMessage, HKEY("\nmsgid|"), 0); StrBufAppendPrintf(QMessage, "%ld", MyQItem->MessageID); StrBufAppendBufPlain(QMessage, HKEY("\nsubmitted|"), 0); StrBufAppendPrintf(QMessage, "%ld", MyQItem->Submitted); if (StrLength(MyQItem->BounceTo) > 0) { StrBufAppendBufPlain(QMessage, HKEY("\nbounceto|"), 0); StrBufAppendBuf(QMessage, MyQItem->BounceTo, 0); } if (StrLength(MyQItem->EnvelopeFrom) > 0) { StrBufAppendBufPlain(QMessage, HKEY("\nenvelope_from|"), 0); StrBufAppendBuf(QMessage, MyQItem->EnvelopeFrom, 0); } if (StrLength(MyQItem->SenderRoom) > 0) { StrBufAppendBufPlain(QMessage, HKEY("\nsource_room|"), 0); StrBufAppendBuf(QMessage, MyQItem->SenderRoom, 0); } StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0); StrBufAppendPrintf(QMessage, "%ld", MyQItem->Retry); StrBufAppendBufPlain(QMessage, HKEY("\nattempted|"), 0); StrBufAppendPrintf(QMessage, "%ld", time(NULL) /*ctdl_ev_now()*/ + MyQItem->Retry); It = GetNewHashPos(MyQItem->MailQEntries, 0); while (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE)) { MailQEntry *ThisItem = vQE; StrBufAppendBufPlain(QMessage, HKEY("\nremote|"), 0); StrBufAppendBuf(QMessage, ThisItem->Recipient, 0); StrBufAppendBufPlain(QMessage, HKEY("|"), 0); StrBufAppendPrintf(QMessage, "%d", ThisItem->Status); StrBufAppendBufPlain(QMessage, HKEY("|"), 0); if (ThisItem->AllStatusMessages != NULL) StrBufAppendBuf(QMessage, ThisItem->AllStatusMessages, 0); else StrBufAppendBuf(QMessage, ThisItem->StatusMessage, 0); } DeleteHashPos(&It); StrBufAppendBufPlain(QMessage, HKEY("\n"), 0); return QMessage; }
OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID) { OneQueItem *Item; const char *pLine = NULL; StrBuf *Line; StrBuf *Token; void *v; Item = (OneQueItem*)malloc(sizeof(OneQueItem)); memset(Item, 0, sizeof(OneQueItem)); Item->Retry = SMTP_RETRY_INTERVAL; Item->MessageID = -1; Item->QueMsgID = QueMsgID; Token = NewStrBuf(); Line = NewStrBufPlain(NULL, 128); while (pLine != StrBufNOTNULL) { const char *pItemPart = NULL; void *vHandler; StrBufExtract_NextToken(Line, RawQItem, &pLine, '\n'); if (StrLength(Line) == 0) continue; StrBufExtract_NextToken(Token, Line, &pItemPart, '|'); if (GetHash(QItemHandlers, SKEY(Token), &vHandler)) { QItemHandlerStruct *HS; HS = (QItemHandlerStruct*) vHandler; HS->H(Item, Line, &pItemPart); } } FreeStrBuf(&Line); FreeStrBuf(&Token); if (Item->Retry >= MaxRetry) Item->FailNow = 1; pthread_mutex_lock(&ActiveQItemsLock); if (GetHash(ActiveQItems, LKEY(Item->MessageID), &v)) { /* WHOOPS. somebody else is already working on this. */ pthread_mutex_unlock(&ActiveQItemsLock); FreeQueItem(&Item); return NULL; } else { /* mark our claim on this. */ Put(ActiveQItems, LKEY(Item->MessageID), Item, HFreeQueItem); pthread_mutex_unlock(&ActiveQItemsLock); } return Item; }
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; }
void network_process_participate(SpoolControl *sc, struct CtdlMessage *omsg, long *delete_after_send) { struct CtdlMessage *msg = NULL; int ok_to_participate = 0; StrBuf *Buf = NULL; recptypes *valid; /* * Process client-side list participations for this room */ if (sc->Users[participate] == NULL) return; msg = CM_Duplicate(omsg); /* Only send messages which originated on our own * Citadel network, otherwise we'll end up sending the * remote mailing list's messages back to it, which * is rude... */ ok_to_participate = 0; if (!CM_IsEmpty(msg, eNodeName)) { if (!strcasecmp(msg->cm_fields[eNodeName], config.c_nodename)) { ok_to_participate = 1; } Buf = NewStrBufPlain(CM_KEY(msg, eNodeName)); if (CtdlIsValidNode(NULL, NULL, Buf, sc->working_ignetcfg, sc->the_netmap) == 0) { ok_to_participate = 1; } } if (ok_to_participate) { /* Replace the Internet email address of the * actual author with the email address of the * room itself, so the remote listserv doesn't * reject us. */ CM_SetField(msg, erFc822Addr, SKEY(sc->Users[roommailalias])); valid = validate_recipients(ChrPtr(sc->Users[participate]) , NULL, 0); CM_SetField(msg, eRecipient, SKEY(sc->Users[roommailalias])); CtdlSubmitMsg(msg, valid, "", 0); free_recipients(valid); } FreeStrBuf(&Buf); CM_Free(msg); }
static void ListCalculateSubject(struct CtdlMessage *msg) { struct CitContext *CCC = CC; StrBuf *Subject, *FlatSubject; int rlen; char *pCh; if (CM_IsEmpty(msg, eMsgSubject)) { Subject = NewStrBufPlain(HKEY("(no subject)")); } else { Subject = NewStrBufPlain(CM_KEY(msg, eMsgSubject)); } FlatSubject = NewStrBufPlain(NULL, StrLength(Subject)); StrBuf_RFC822_to_Utf8(FlatSubject, Subject, NULL, NULL); rlen = strlen(CCC->room.QRname); pCh = strstr(ChrPtr(FlatSubject), CCC->room.QRname); if ((pCh == NULL) || (*(pCh + rlen) != ']') || (pCh == ChrPtr(FlatSubject)) || (*(pCh - 1) != '[') ) { StrBuf *tmp; StrBufPlain(Subject, HKEY("[")); StrBufAppendBufPlain(Subject, CCC->room.QRname, rlen, 0); StrBufAppendBufPlain(Subject, HKEY("] "), 0); StrBufAppendBuf(Subject, FlatSubject, 0); /* so we can free the right one swap them */ tmp = Subject; Subject = FlatSubject; FlatSubject = tmp; StrBufRFC2047encode(&Subject, FlatSubject); } CM_SetAsFieldSB(msg, eMsgSubject, &Subject); FreeStrBuf(&FlatSubject); }
void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos) { if (Item->Current == NULL) NewMailQEntry(Item); if (Item->Current->Recipient == NULL) Item->Current->Recipient=NewStrBufPlain(NULL, StrLength(Line)); StrBufExtract_NextToken(Item->Current->Recipient, Line, Pos, '|'); Item->Current->Status = StrBufExtractNext_int(Line, Pos, '|'); StrBufExtract_NextToken(Item->Current->StatusMessage, Line, Pos, '|'); Item->Current = NULL; // TODO: is this always right? }
void InitIOStruct(AsyncIO *IO, void *Data, eNextState NextState, IO_LineReaderCallback LineReader, IO_CallBack DNS_Fail, IO_CallBack SendDone, IO_CallBack ReadDone, IO_CallBack Terminate, IO_CallBack DBTerminate, IO_CallBack ConnFail, IO_CallBack Timeout, IO_CallBack ShutdownAbort) { IO->Data = Data; IO->CitContext = CloneContext(CC); IO->CitContext->session_specific_data = Data; IO->CitContext->IO = IO; IO->NextState = NextState; IO->SendDone = SendDone; IO->ReadDone = ReadDone; IO->Terminate = Terminate; IO->DBTerminate = DBTerminate; IO->LineReader = LineReader; IO->ConnFail = ConnFail; IO->Timeout = Timeout; IO->ShutdownAbort = ShutdownAbort; IO->DNS.Fail = DNS_Fail; IO->SendBuf.Buf = NewStrBufPlain(NULL, 1024); IO->RecvBuf.Buf = NewStrBufPlain(NULL, 1024); IO->IOBuf = NewStrBuf(); EV_syslog(LOG_DEBUG, "EVENT: Session lives at %p IO at %p \n", Data, IO); }
/* * Offer the RSS feed button for this room */ void tmplput_rssbutton(StrBuf *Target, WCTemplputParams *TP) { StrBuf *FeedLink = NULL; FeedLink = NewStrBufPlain(HKEY("/feed_rss?go=")); StrBufUrlescAppend(FeedLink, WC->CurRoom.name, NULL); StrBufAppendPrintf(Target, "<a type=\"application/rss+xml\" href=\""); StrBufAppendBuf(Target, FeedLink, 0); StrBufAppendPrintf(Target, "\"><img src=\"static/webcit_icons/essen/16x16/rss.png\" alt=\"RSS\">"); StrBufAppendPrintf(Target, "</a>"); FreeStrBuf(&FeedLink); }
/* * Callback function for perform_openid2_discovery() * We're interested in the X-XRDS-Location: header. */ size_t yadis_headerfunction(void *ptr, size_t size, size_t nmemb, void *userdata) { char hdr[1024]; StrBuf **x_xrds_location = (StrBuf **) userdata; memcpy(hdr, ptr, (size*nmemb)); hdr[size*nmemb] = 0; if (!strncasecmp(hdr, "X-XRDS-Location:", 16)) { *x_xrds_location = NewStrBufPlain(&hdr[16], ((size*nmemb)-16)); StrBufTrim(*x_xrds_location); } return(size * nmemb); }
static void TestRFC822Decode(void) { StrBuf *Target; StrBuf *Source; StrBuf *DefaultCharset; StrBuf *FoundCharset; DefaultCharset = NewStrBufPlain(HKEY("iso-8859-1")); FoundCharset = NewStrBuf(); Source = NewStrBufPlain(HKEY("=?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=")); Target = NewStrBuf(); StrBuf_RFC822_to_Utf8(Target, Source, DefaultCharset, FoundCharset); TestRevalidateStrBuf(Target); printf("the ugly multi:>%s<\n", ChrPtr(Target)); FreeStrBuf(&Source); FreeStrBuf(&Target); FreeStrBuf(&FoundCharset); FreeStrBuf(&DefaultCharset); DefaultCharset = NewStrBufPlain(HKEY("iso-8859-1")); FoundCharset = NewStrBuf(); Source = NewStrBufPlain(HKEY("\"w.goesgens\" <*****@*****.**>, =?ISO-8859-15?Q?Walter_?= =?ISO-8859-15?Q?G=F6aoeus?= <*****@*****.**>, =?ISO-8859-15?Q?aoeuaoeuh?= =?ISO-8859-15?Q?_G=F6aoeus?= <*****@*****.**>, aoeuao aoeuaoeu <*****@*****.**")); Target = NewStrBufPlain(NULL, 256); StrBuf_RFC822_to_Utf8(Target, Source, DefaultCharset, FoundCharset); TestRevalidateStrBuf(Target); printf("the ugly multi:>%s<\n", ChrPtr(Target)); FreeStrBuf(&Source); FreeStrBuf(&Target); FreeStrBuf(&FoundCharset); FreeStrBuf(&DefaultCharset); }
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); }
void OverrideRequest(ParsedHttpHdrs *Hdr, const char *Line, long len) { StrBuf *Buf = NewStrBuf(); if (Hdr->HR.ReqLine != NULL) { FlushStrBuf(Hdr->HR.ReqLine); StrBufPlain(Hdr->HR.ReqLine, Line, len); } else { Hdr->HR.ReqLine = NewStrBufPlain(Line, len); } ReadHttpSubject(Hdr, Hdr->HR.ReqLine, Buf); FreeStrBuf(&Buf); }
int ReadPostData(void) { int rc; int urlencoded_post = 0; wcsession *WCC = WC; StrBuf *content = NULL; urlencoded_post = (strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33) == 0) ; content = NewStrBufPlain(NULL, WCC->Hdr->HR.ContentLength + 256); if (!urlencoded_post) { StrBufPrintf(content, "Content-type: %s\n" "Content-length: %ld\n\n", ChrPtr(WCC->Hdr->HR.ContentType), WCC->Hdr->HR.ContentLength); } /** Read the entire input data at once. */ rc = client_read_to(WCC->Hdr, content, WCC->Hdr->HR.ContentLength, SLEEPING); if (rc < 0) return rc; if (urlencoded_post) { ParseURLParams(content); } else if (!strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "multipart", 9)) { char *Buf; char *BufEnd; long len; len = StrLength(content); Buf = SmashStrBuf(&content); BufEnd = Buf + len; mime_parser(Buf, BufEnd, *upload_handler, NULL, NULL, NULL, 0); free(Buf); } else if (WCC->Hdr->HR.ContentLength > 0) { WCC->upload = content; WCC->upload_length = StrLength(WCC->upload); content = NULL; } FreeStrBuf(&content); return 1; }
static size_t gotdata(void *data, size_t size, size_t nmemb, void *cglobal) { AsyncIO *IO = (AsyncIO*) cglobal; SetEVState(IO, eCurlGotData); if (IO->HttpReq.ReplyData == NULL) { IO->HttpReq.ReplyData = NewStrBufPlain(NULL, SIZ); } IO->CitContext->lastcmd = IO->Now = ev_now(event_base); return CurlFillStrBuf_callback(data, size, nmemb, IO->HttpReq.ReplyData); }
void aggregate_recipients(StrBuf **recps, RoomNetCfg Which, OneRoomNetCfg *OneRNCfg, long nSegments) { int i; size_t recps_len = 0; RoomNetCfgLine *nptr; struct CitContext *CCC = CC; *recps = NULL; /* * Figure out how big a buffer we need to allocate */ for (nptr = OneRNCfg->NetConfigs[Which]; nptr != NULL; nptr = nptr->next) { recps_len = recps_len + StrLength(nptr->Value[0]) + 2; } /* Nothing todo... */ if (recps_len == 0) return; *recps = NewStrBufPlain(NULL, recps_len); if (*recps == NULL) { QN_syslog(LOG_EMERG, "Cannot allocate %ld bytes for recps...\n", (long)recps_len); abort(); } /* Each recipient */ for (nptr = OneRNCfg->NetConfigs[Which]; nptr != NULL; nptr = nptr->next) { if (nptr != OneRNCfg->NetConfigs[Which]) { for (i = 0; i < nSegments; i++) StrBufAppendBufPlain(*recps, HKEY(","), i); } StrBufAppendBuf(*recps, nptr->Value[0], 0); if (Which == ignet_push_share) { StrBufAppendBufPlain(*recps, HKEY(","), 0); StrBufAppendBuf(*recps, nptr->Value[1], 0); } } }
int main(int argc, char **argv) { StrBuf *setstr; StrBuf *lostr; StrBuf *histr; StrBuf *vset; const char *pvset; int i = 0; // char *teststring = "40:24524,24662,24673,27869:27935,28393,28426,31247:31258,31731,31749,31761,31778,31782,31801:31803,31813,31904,31915,33708,33935,34619,34672,34720:34723,34766,34835,37594,38854,39235,39942,40030,40142,40520,40815,40907,41201,41578,41781,41954,42292,43110,43565,43801,43998,44180,44241,44295,44401,44561,44635,44798,44861,44946,45022,45137:45148,45166,45179,45707,47114,47141:47157,47194,47314,47349,47386,47489,47496,47534:47543,54460,54601,54637:54652"; char *teststring = "one,two,three"; setstr = NewStrBuf(); vset = NewStrBufPlain(teststring, -1); while (StrBufExtract_NextToken(setstr, vset, &pvset, ',')) { printf("Token: '%s'\n", ChrPtr(setstr)); } exit(0); }
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; }
// // Utility function for nntp_last_next() that turns a msgnum into a message ID. // The memory for the returned string is pwnz0red by the caller. // char *message_id_from_msgnum(long msgnum) { char *fetched_message_id = NULL; CC->redirect_buffer = NewStrBufPlain(NULL, SIZ); CtdlOutputMsg(msgnum, MT_RFC822, // output in RFC822 format ... sort of HEADERS_FAST, // headers, body, or both? 0, // don't do Citadel protocol responses 1, // CRLF newlines NULL, // teh whole thing, not just a section 0, // no flags yet ... maybe new ones for Path: etc ? NULL, NULL, &fetched_message_id // extract the message ID from the message as we go... ); StrBuf *msgtext = CC->redirect_buffer; CC->redirect_buffer = NULL; FreeStrBuf(&msgtext); return(fetched_message_id); }
/* * Display the appropriate landing page for this site. */ void display_default_landing_page(void) { wcsession *WCC = WC; if (WCC && WCC->serv_info && WCC->serv_info->serv_supports_guest) { /* default action */ if (havebstr("go")) { if (verbose) syslog(LOG_DEBUG, "Explicit room selection: %s", bstr("go")); smart_goto(sbstr("go")); } else if (default_landing_page) { http_redirect(default_landing_page); } else { StrBuf *teh_lobby = NewStrBufPlain(HKEY("_BASEROOM_")); smart_goto(teh_lobby); FreeStrBuf(&teh_lobby); } } else { display_login(); } }