static void StrBufRFC2047encodeMessageStdin(void) { int fdin = 0;// STDIN const char *Err; StrBuf *Target; StrBuf *Source; StrBuf *Src; Source = NewStrBuf(); Src = NewStrBuf(); printf("["); while (fdin == 0) { StrBufTCP_read_line(Source, &fdin, 0, &Err); StrBufAppendBuf(Src, Source, 0); StrBufAppendBufPlain(Src, HKEY("\n"), 0); } Target = StrBufRFC2047encodeMessage(Src); printf("Target: \n%s\n", ChrPtr(Target)); FreeStrBuf(&Source); FreeStrBuf(&Src); FreeStrBuf(&Target); }
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 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); }
void render_MIME_VNote(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset) { wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH); if (StrLength(Mime->Data) == 0) MimeLoadData(Mime); if (StrLength(Mime->Data) > 0) { struct vnote *v; StrBuf *Buf; char *vcard; Buf = NewStrBuf(); vcard = SmashStrBuf(&Mime->Data); v = vnote_new_from_str(vcard); free (vcard); if (v) { WCTemplputParams TP; memset(&TP, 0, sizeof(WCTemplputParams)); TP.Filter.ContextType = CTX_VNOTE; TP.Context = v; DoTemplate(HKEY("mail_vnoteitem"), Buf, &TP); vnote_free(v); Mime->Data = Buf; } else { if (Mime->Data == NULL) Mime->Data = NewStrBuf(); else FlushStrBuf(Mime->Data); } } }
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 TestEncodeEmailSTDIN(void) { int fdin = 0;// STDIN const char *Err; StrBuf *Target; StrBuf *Source; StrBuf *UserName = NewStrBuf(); StrBuf *EmailAddress = NewStrBuf(); StrBuf *EncBuf = NewStrBuf(); Source = NewStrBuf(); while (fdin == 0) { StrBufTCP_read_line(Source, &fdin, 0, &Err); printf("the source:>%s<\n", ChrPtr(Source)); Target = StrBufSanitizeEmailRecipientVector( Source, UserName, EmailAddress, EncBuf ); TestRevalidateStrBuf(Target); 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); }
HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP) { StrBuf *Buf; HashList *Hash; char nnn[64]; char buf[SIZ]; int nUsed; NodeConf *Node; serv_puts("CONF getsys|application/x-citadel-ignet-config"); serv_getln(buf, sizeof buf); if (buf[0] == '1') { Hash = NewHash(1, NULL); Buf = NewStrBuf(); while (StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) { Node = NewNode(Buf); if (Node != NULL) { nUsed = GetCount(Hash); nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1); Put(Hash, nnn, nUsed, Node, DeleteNodeConf); } } FreeStrBuf(&Buf); return Hash; } return NULL; }
void save_net_conf(HashList *Nodelist) { char buf[SIZ]; StrBuf *Buf; HashPos *where; void *vNode; NodeConf *Node; const char *Key; long KeyLen; serv_puts("CONF putsys|application/x-citadel-ignet-config"); serv_getln(buf, sizeof buf); if (buf[0] == '4') { if ((Nodelist != NULL) && (GetCount(Nodelist) > 0)) { where = GetNewHashPos(Nodelist, 0); Buf = NewStrBuf(); while (GetNextHashPos(Nodelist, where, &KeyLen, &Key, &vNode)) { Node = (NodeConf*) vNode; if (Node->DeleteMe==0) { SerializeNode(Node, Buf); serv_putbuf(Buf); } } FreeStrBuf(&Buf); DeleteHashPos(&where); } serv_puts("000"); } }
// upload the picture (icon, photo, whatever) associated with the current room void common_code_for_editroompic_and_editpic(char *servcmd) { if (havebstr("cancel_button")) { AppendImportantMessage(_("Graphics upload has been cancelled."), -1); display_main_menu(); return; } if (WC->upload_length == 0) { AppendImportantMessage(_("You didn't upload a file."), -1); display_main_menu(); return; } serv_printf("%s %ld|%s", servcmd, (long)WC->upload_length, GuessMimeType(ChrPtr(WC->upload), WC->upload_length)); StrBuf *Line = NewStrBuf(); StrBuf_ServGetln(Line); if (GetServerStatusMsg(Line, NULL, 0, 0) == 7) { serv_write(ChrPtr(WC->upload), WC->upload_length); display_success(ChrPtr(Line) + 4); } else { AppendImportantMessage((ChrPtr(Line) + 4), -1); display_main_menu(); } FreeStrBuf(&Line); }
/* * Fetch the "mortuary" - a list of dead buddies which we keep around forever * so we can remove them from any client's roster that still has them listed */ void xmpp_store_mortuary(HashList *mortuary) { HashPos *HashPos; long len; void *Value; const char *Key; StrBuf *themsg; themsg = NewStrBuf(); StrBufPrintf(themsg, "Content-type: " XMPPMORTUARY "\n" "Content-transfer-encoding: 7bit\n" "\n" ); HashPos = GetNewHashPos(mortuary, 0); while (GetNextHashPos(mortuary, HashPos, &len, &Key, &Value) != 0) { StrBufAppendPrintf(themsg, "%s\n", (char *)Value); } DeleteHashPos(&HashPos); /* Delete the old mortuary */ CtdlDeleteMessages(USERCONFIGROOM, NULL, 0, XMPPMORTUARY); /* And save the new one to disk */ quickie_message("Citadel", NULL, NULL, USERCONFIGROOM, ChrPtr(themsg), 4, "XMPP Mortuary"); FreeStrBuf(&themsg); }
/* * Embed the room banner * * got The information returned from a GOTO server command * navbar_style Determines which navigation buttons to display */ void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP) { wcsession *WCC = WC; /* Refresh current room states. Doesn't work? gotoroom(NULL); */ wc_printf("<div id=\"banner\">\n"); /* The browser needs some information for its own use */ wc_printf("<script type=\"text/javascript\"> \n" " room_is_trash = %d; \n" "</script>\n", ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) ); /* * If the user happens to select the "make this my start page" link, * we want it to remember the URL as a "/dotskip" one instead of * a "skip" or "gotonext" or something like that. */ if (WCC->Hdr->this_page == NULL) { WCC->Hdr->this_page = NewStrBuf(); } StrBufPrintf(WCC->Hdr->this_page, "dotskip?room=%s", ChrPtr(WC->CurRoom.name)); do_template("roombanner"); do_template("navbar"); wc_printf("</div>\n"); }
void OpenMainFile (const char* Name) /* Open the main file. Will call Fatal() in case of failures. */ { AFile* MainFile; /* Setup a new IFile structure for the main file */ IFile* IF = NewIFile (Name, IT_MAIN); /* Open the file for reading */ FILE* F = fopen (Name, "r"); if (F == 0) { /* Cannot open */ Fatal ("Cannot open input file `%s': %s", Name, strerror (errno)); } /* Allocate a new AFile structure for the file */ MainFile = NewAFile (IF, F); /* Allocate the input line buffer */ Line = NewStrBuf (); /* Update the line infos, so we have a valid line info even at start of * the main file before the first line is read. */ UpdateLineInfo (MainFile->Input, MainFile->Line, Line); }
void SessionNewModule_WEBCIT (wcsession *sess) { sess->ImportantMsg = NewStrBuf(); sess->WBuf = NewStrBufPlain(NULL, SIZ * 4); sess->HBuf = NewStrBufPlain(NULL, SIZ / 4); }
void do_graphics_upload(char *filename) { StrBuf *Line; const char *MimeType; wcsession *WCC = WC; int bytes_remaining; int pos = 0; int thisblock; bytes_remaining = WCC->upload_length; if (havebstr("cancel_button")) { AppendImportantMessage(_("Graphics upload has been cancelled."), -1); display_main_menu(); return; } if (WCC->upload_length == 0) { AppendImportantMessage(_("You didn't upload a file."), -1); display_main_menu(); return; } MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining); serv_printf("UIMG 1|%s|%s", MimeType, filename); Line = NewStrBuf(); StrBuf_ServGetln(Line); if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) { display_main_menu(); FreeStrBuf(&Line); return; } while (bytes_remaining) { thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining); serv_printf("WRIT %d", thisblock); StrBuf_ServGetln(Line); if (GetServerStatusMsg(Line, NULL, 1, 7) != 7) { serv_puts("UCLS 0"); StrBuf_ServGetln(Line); display_main_menu(); FreeStrBuf(&Line); return; } thisblock = extract_int(ChrPtr(Line) +4, 0); serv_write(&ChrPtr(WCC->upload)[pos], thisblock); pos += thisblock; bytes_remaining -= thisblock; } serv_puts("UCLS 1"); StrBuf_ServGetln(Line); if (*ChrPtr(Line) != 'x') { display_success(ChrPtr(Line) + 4); } FreeStrBuf(&Line); }
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; }
void Header_HandleHost(StrBuf *Line, ParsedHttpHdrs *hdr) { if (hdr->HostHeader != NULL) { FreeStrBuf(&hdr->HostHeader); } hdr->HostHeader = NewStrBuf(); StrBufAppendPrintf(hdr->HostHeader, "%s://", (is_https ? "https" : "http") ); StrBufAppendBuf(hdr->HostHeader, Line, 0); }
NodeConf *NewNode(StrBuf *SerializedNode) { NodeConf *Node; if (StrLength(SerializedNode) < 8) return NULL; /** we need at least 4 pipes and some other text so its invalid. */ Node = (NodeConf *) malloc(sizeof(NodeConf)); Node->DeleteMe = 0; Node->NodeName=NewStrBuf(); StrBufExtract_token(Node->NodeName, SerializedNode, 0, '|'); Node->Secret=NewStrBuf(); StrBufExtract_token(Node->Secret, SerializedNode, 1, '|'); Node->Host=NewStrBuf(); StrBufExtract_token(Node->Host, SerializedNode, 2, '|'); Node->Port=NewStrBuf(); StrBufExtract_token(Node->Port, SerializedNode, 3, '|'); return Node; }
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 SortPregetMatter(HashList *Cals) { disp_cal *Cal; void *vCal; const char *Key; long KLen; IcalEnumMap *SortMap[10]; IcalEnumMap *Map; void *vSort; const char *Next = NULL; const StrBuf *SortVector; StrBuf *SortBy; int i = 0; HashPos *It; SortVector = SBSTR("ICALSortVec"); if (SortVector == NULL) return; for (i = 0; i < 10; i++) SortMap[i] = NULL; SortBy = NewStrBuf(); while (StrBufExtract_NextToken(SortBy, SortVector, &Next, ':') > 0) { GetHash(IcalComponentMap, SKEY(SortBy), &vSort); Map = (IcalEnumMap*) vSort; SortMap[i] = Map; i++; if (i > 9) break; } if (i == 0) return; switch (SortMap[i - 1]->map) { /* case */ default: break; } It = GetNewHashPos(Cals, 0); while (GetNextHashPos(Cals, It, &KLen, &Key, &vCal)) { i = 0; Cal = (disp_cal*) vCal; Cal->Status = icalcomponent_get_status(Cal->cal); Cal->SortBy = Cal->cal; while ((SortMap[i] != NULL) && (Cal->SortBy != NULL)) { /****Cal->SortBy = icalcomponent_get_first_property(Cal->SortBy, SortMap[i++]->map); */ } } }
// display the picture (icon, photo, whatever) associated with the current room void display_roompic(void) { off_t bytes; StrBuf *Buf = NewStrBuf(); serv_printf("DLRI"); StrBuf_ServGetln(Buf); if (GetServerStatus(Buf, NULL) == 6) { StrBufCutLeft(Buf, 4); bytes = StrBufExtract_long(Buf, 0, '|'); StrBuf *content_type = NewStrBuf(); StrBufExtract_token(content_type, Buf, 3, '|'); WC->WBuf = NewStrBuf(); StrBuf_ServGetBLOBBuffered(WC->WBuf, bytes); http_transmit_thing(ChrPtr(content_type), 0); FreeStrBuf(&content_type); } else { output_error_pic("", ""); } FreeStrBuf(&Buf); }
void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr) { if (!follow_xff) return; if (hdr->HostHeader != NULL) { FreeStrBuf(&hdr->HostHeader); } hdr->HostHeader = NewStrBuf(); StrBufAppendPrintf(hdr->HostHeader, "http://"); /* this is naive; do something about it */ StrBufAppendBuf(hdr->HostHeader, Line, 0); }
/* * Display a list of all pages in a Wiki room (template callback) */ void tmplput_display_wiki_pagelist(StrBuf *Target, WCTemplputParams *TP) { StrBuf *Buf; int row = 0; if (!IsEmptyStr(bstr("query"))) { serv_printf("MSGS SEARCH|%s||4", bstr("query")); /* search-reduced list */ } else { serv_printf("MSGS ALL|||4"); /* full list */ } Buf = NewStrBuf(); StrBuf_ServGetln(Buf); if (GetServerStatus(Buf, NULL) == 1) { StrBuf *pagetitle = NewStrBuf(); wc_printf("<table class=\"wiki_pagelist_background\">"); wc_printf("<th>%s</th>", _("Page title")); while((StrBuf_ServGetln(Buf) >= 0) && strcmp(ChrPtr(Buf), "000")) { StrBufExtract_token(pagetitle, Buf, 1, '|'); if (!bmstrcasestr((char *)ChrPtr(pagetitle), "_HISTORY_")) { /* no history pages */ wc_printf("<tr bgcolor=\"%s\">", ((row%2) ? "#FFFFFF" : "#DDDDDD")); wc_printf("<td><a href=\"wiki?page="); urlescputs(ChrPtr(pagetitle)); wc_printf("\">"); escputs(ChrPtr(pagetitle)); wc_printf("</a></td>"); wc_printf("</tr>\n"); ++row; } } wc_printf("</table>\n"); FreeStrBuf(&pagetitle); } FreeStrBuf(&Buf); }
void display_error(char *error_message_format, ...) { StrBuf *Msg; va_list arg_ptr; Msg = NewStrBuf(); va_start(arg_ptr, error_message_format); StrBufVAppendPrintf(Msg, error_message_format, arg_ptr); va_end(arg_ptr); important_message(_("Error"), ChrPtr(Msg)); FreeStrBuf(&Msg); }
/* * Detach an OpenID from the currently logged-in account */ void openid_detach(void) { StrBuf *Line; if (havebstr("id_to_detach")) { serv_printf("OIDD %s", bstr("id_to_detach")); Line = NewStrBuf(); StrBuf_ServGetln(Line); GetServerStatusMsg(Line, NULL, 1, 2); FreeStrBuf(&Line); } display_openids(); }
static void TestUrlescEncodeStdin(void) { int fdin = 0;// STDIN const char *Err; StrBuf *Target; StrBuf *Source; Source = NewStrBuf(); while (fdin == 0) { StrBufTCP_read_line(Source, &fdin, 0, &Err); Target = NewStrBuf(); StrBufUrlescAppend(Target, Source, NULL); TestRevalidateStrBuf(Target); printf("%s\n", ChrPtr(Target)); FreeStrBuf(&Target); } FreeStrBuf(&Source); }
/* * Parse an XRDS document. * If an OpenID Provider URL is discovered, op_url to that value and return nonzero. * If nothing useful happened, return 0. */ int parse_xrds_document(StrBuf *ReplyBuf) { ctdl_openid *oiddata = (ctdl_openid *) CC->openid_data; struct xrds xrds; int return_value = 0; memset(&xrds, 0, sizeof (struct xrds)); xrds.selected_service_priority = INT_MAX; xrds.CharData = NewStrBuf(); xrds.current_service_uri = NewStrBuf(); xrds.selected_service_uri = NewStrBuf(); XML_Parser xp = XML_ParserCreate(NULL); if (xp) { XML_SetUserData(xp, &xrds); XML_SetElementHandler(xp, xrds_xml_start, xrds_xml_end); XML_SetCharacterDataHandler(xp, xrds_xml_chardata); XML_Parse(xp, ChrPtr(ReplyBuf), StrLength(ReplyBuf), 0); XML_Parse(xp, "", 0, 1); XML_ParserFree(xp); } else { syslog(LOG_ALERT, "Cannot create XML parser"); } if (xrds.selected_service_priority < INT_MAX) { if (oiddata->op_url == NULL) { oiddata->op_url = NewStrBuf(); } FlushStrBuf(oiddata->op_url); StrBufAppendBuf(oiddata->op_url, xrds.selected_service_uri, 0); return_value = openid_disco_xrds; } FreeStrBuf(&xrds.CharData); FreeStrBuf(&xrds.current_service_uri); FreeStrBuf(&xrds.selected_service_uri); return(return_value); }
static void ME_AppendActual (MacroExp* E, StrBuf* Arg) /* Add a copy of Arg to the list of actual macro arguments. * NOTE: This function will clear Arg! */ { /* Create a new string buffer */ StrBuf* A = NewStrBuf (); /* Move the contents of Arg to A */ SB_Move (A, Arg); /* Add A to the actual arguments */ CollAppend (&E->ActualArgs, A); }
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 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); }