本文整理汇总了C++中ChrPtr函数的典型用法代码示例。如果您正苦于以下问题:C++ ChrPtr函数的具体用法?C++ ChrPtr怎么用?C++ ChrPtr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ChrPtr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestEncodeEmail
static void TestEncodeEmail(void)
{
StrBuf *Target;
StrBuf *Source;
StrBuf *UserName = NewStrBuf();
StrBuf *EmailAddress = NewStrBuf();
StrBuf *EncBuf = NewStrBuf();
Source = NewStrBuf();
// Source = NewStrBufPlain(HKEY("Art Cancro <[email protected]>, Art Cancro <[email protected]>"));
Source = NewStrBufPlain(HKEY("\"Alexandra Weiz, Restless GmbH\" <[email protected]>, \"NetIN\" <[email protected]>, \" יריב ברקאי, מולטימדי\" <[email protected]>"));
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);
}
示例2: openid_attach
/*
* Attempt to attach an OpenID to an existing, logged-in account
*/
void openid_attach(void) {
char buf[4096];
if (havebstr("attach_button")) {
syslog(LOG_DEBUG, "Attempting to attach %s\n", bstr("openid_url"));
snprintf(buf, sizeof buf,
"OIDS %s|%s/finalize_openid_login?attach_existing=1|%s",
bstr("openid_url"),
ChrPtr(site_prefix),
ChrPtr(site_prefix)
);
serv_puts(buf);
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
syslog(LOG_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
http_redirect(&buf[4]);
return;
}
else {
syslog(LOG_DEBUG, "OpenID attach failed: %s\n", &buf[4]);
}
}
/* If we get to this point then something failed. */
display_openids();
}
示例3: TestEncodeEmailSTDIN
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);
}
示例4: SMTPC_read_EHLO_reply
eNextState SMTPC_read_EHLO_reply(SmtpOutMsg *Msg)
{
AsyncIO *IO = &Msg->IO;
SMTP_DBG_READ();
if (SMTP_IS_STATE('2')) {
READ_NEXT_STATE(eSMTPAuth);
if ((Msg->pCurrRelay == NULL) ||
(Msg->pCurrRelay->User == NULL))
READ_NEXT_STATE(eFROM); /* Skip auth... */
if (Msg->pCurrRelay != NULL)
{
if (strstr(ChrPtr(Msg->IO.IOBuf), "LOGIN") != NULL)
Msg->SendLogin = 1;
else if ((Msg->MultiLineBuf != NULL) &&
strstr(ChrPtr(Msg->MultiLineBuf), "LOGIN") != NULL)
{
Msg->SendLogin = 1;
}
}
}
/* else we fall back to 'helo' */
return eSendReply;
}
示例5: authorization_required
/*
* Authorization required page (sends a 401, causing the browser to request login credentials)
*/
void authorization_required(void)
{
wcsession *WCC = WC;
const char *message = "";
hprintf("HTTP/1.1 401 Authorization Required\r\n");
hprintf(
"Server: %s / %s\r\n"
"Connection: close\r\n",
PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
);
hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", ChrPtr(WC->serv_info->serv_humannode));
/* if this is a false cookie authentication, remove it to avoid endless loops. */
if (StrLength(WCC->Hdr->HR.RawCookie) > 0)
stuff_to_cookie(1);
hprintf("Content-Type: text/html\r\n");
begin_burst();
wc_printf("<h1>");
wc_printf(_("Authorization Required"));
wc_printf("</h1>\r\n");
if (WCC->ImportantMsg != NULL) {
message = ChrPtr(WCC->ImportantMsg);
}
wc_printf(
_("The resource you requested requires a valid username and password. "
"You could not be logged in: %s\n"),
message
);
wDumpContent(0);
}
示例6: common_code_for_editroompic_and_editpic
// 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);
}
示例7: POP3C_GetOneMessageIDState
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:%[email protected]%s",
ChrPtr(RecvMsg->RoomName),
ChrPtr(RecvMsg->CurrMsg->MsgUIDL),
RecvMsg->IO.ConnectMe->User,
RecvMsg->IO.ConnectMe->Host);
RecvMsg->State --;
return eSendReply;
}
示例8: pop_destination
/*
* Go to the URL saved by push_destination()
*/
void pop_destination(void) {
wcsession *WCC = WC;
/*
* If we are in the middle of a new user signup, the server may request that
* we first pass through a registration screen.
*/
if ((WCC) && (WCC->need_regi)) {
if ((WCC->PushedDestination != NULL) && (StrLength(WCC->PushedDestination) > 0)) {
/* Registering will take us to the My Citadel Config room, so save our place */
StrBufAppendBufPlain(WCC->PushedDestination, HKEY("?go="), 0);
StrBufUrlescAppend(WCC->PushedDestination, WCC->CurRoom.name, NULL);
}
WCC->need_regi = 0;
display_reg(1);
return;
}
/*
* Do something reasonable if we somehow ended up requesting a pop without
* having first done a push.
*/
if ( (!WCC) || (WCC->PushedDestination == NULL) || (StrLength(WCC->PushedDestination) == 0) ) {
do_welcome();
return;
}
/*
* All righty then! We have a destination saved, so go there now.
*/
if (verbose)
syslog(LOG_DEBUG, "Pop: %s", ChrPtr(WCC->PushedDestination));
http_redirect(ChrPtr(WCC->PushedDestination));
}
示例9: NewStrBufPlain
/**
* 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;
}
示例10: POP3C_GetListOneLine
eNextState POP3C_GetListOneLine(pop3aggr *RecvMsg)
{
AsyncIO *IO = &RecvMsg->IO;
#if 0
int rc;
#endif
const char *pch;
FetchItem *OneMsg = NULL;
POP3C_DBG_READ();
if ((StrLength(RecvMsg->IO.IOBuf) == 1) &&
(ChrPtr(RecvMsg->IO.IOBuf)[0] == '.'))
{
if (GetCount(RecvMsg->MsgNumbers) == 0)
{
//// RecvMsg->Sate = ReadQuitState;
}
else
{
RecvMsg->Pos = GetNewHashPos(RecvMsg->MsgNumbers, 0);
}
return eSendReply;
}
/*
* work around buggy pop3 servers which send
* empty lines in their listings.
*/
if ((StrLength(RecvMsg->IO.IOBuf) == 0) ||
!isdigit(ChrPtr(RecvMsg->IO.IOBuf)[0]))
{
return eReadMore;
}
OneMsg = (FetchItem*) malloc(sizeof(FetchItem));
memset(OneMsg, 0, sizeof(FetchItem));
OneMsg->MSGID = atol(ChrPtr(RecvMsg->IO.IOBuf));
pch = strchr(ChrPtr(RecvMsg->IO.IOBuf), ' ');
if (pch != NULL)
{
OneMsg->MSGSize = atol(pch + 1);
}
#if 0
rc = TestValidateHash(RecvMsg->MsgNumbers);
if (rc != 0)
EVP3CCS_syslog(LOG_DEBUG, "Hash Invalid: %d\n", rc);
#endif
Put(RecvMsg->MsgNumbers, LKEY(OneMsg->MSGID), OneMsg, HfreeFetchItem);
#if 0
rc = TestValidateHash(RecvMsg->MsgNumbers);
if (rc != 0)
EVP3CCS_syslog(LOG_DEBUG, "Hash Invalid: %d\n", rc);
#endif
//RecvMsg->State --; /* read next Line */
return eReadMore;
}
示例11: SerializeNode
void SerializeNode(NodeConf *Node, StrBuf *Buf)
{
StrBufPrintf(Buf, "%s|%s|%s|%s",
ChrPtr(Node->NodeName),
ChrPtr(Node->Secret),
ChrPtr(Node->Host),
ChrPtr(Node->Port));
}
示例12: do_graphics_upload
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);
}
示例13: evcurl_handle_start
eNextState
evcurl_handle_start(AsyncIO *IO)
{
CURLMcode msta;
CURLcode sta;
CURL *chnd;
SetEVState(IO, eCurlStart);
chnd = IO->HttpReq.chnd;
EVCURL_syslog(LOG_DEBUG,
"EVCURL: Loading URL: %s\n", IO->ConnectMe->PlainUrl);
OPT(URL, IO->ConnectMe->PlainUrl);
if (StrLength(IO->ConnectMe->CurlCreds))
{
OPT(HTTPAUTH, (long)CURLAUTH_BASIC);
OPT(USERPWD, ChrPtr(IO->ConnectMe->CurlCreds));
}
if (StrLength(IO->HttpReq.PostData) > 0)
{
OPT(POSTFIELDS, ChrPtr(IO->HttpReq.PostData));
OPT(POSTFIELDSIZE, StrLength(IO->HttpReq.PostData));
}
else if ((IO->HttpReq.PlainPostDataLen != 0) &&
(IO->HttpReq.PlainPostData != NULL))
{
OPT(POSTFIELDS, IO->HttpReq.PlainPostData);
OPT(POSTFIELDSIZE, IO->HttpReq.PlainPostDataLen);
}
OPT(HTTPHEADER, IO->HttpReq.headers);
IO->NextState = eConnect;
EVCURLM_syslog(LOG_DEBUG, "EVCURL: attaching to curl multi handle\n");
msta = curl_multi_add_handle(global.mhnd, IO->HttpReq.chnd);
if (msta)
{
EVCURL_syslog(LOG_ERR,
"EVCURL: error attaching to curl multi handle: %s\n",
curl_multi_strerror(msta));
}
IO->HttpReq.attached = 1;
ev_async_send (event_base, &WakeupCurl);
ev_cleanup_init(&IO->abort_by_shutdown,
IOcurl_abort_shutdown_callback);
ev_cleanup_start(event_base, &IO->abort_by_shutdown);
return eReadMessage;
}
示例14: GetAuthBasic
wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t *ListMutex)
{
wcsession *sptr = NULL;
wcsession *TheSession = NULL;
if (Hdr->HR.got_auth == AUTH_BASIC) {
GetAuthBasic(Hdr);
}
CtdlLogResult(pthread_mutex_lock(ListMutex));
for (sptr = *wclist; ((sptr != NULL) && (TheSession == NULL)); sptr = sptr->next) {
/* If HTTP-AUTH, look for a session with matching credentials */
switch (Hdr->HR.got_auth)
{
case AUTH_BASIC:
if ( (!strcasecmp(ChrPtr(Hdr->c_username), ChrPtr(sptr->wc_username)))
&& (!strcasecmp(ChrPtr(Hdr->c_password), ChrPtr(sptr->wc_password)))
&& (sptr->killthis == 0)
) {
if (verbose)
syslog(LOG_DEBUG, "Matched a session with the same http-auth");
TheSession = sptr;
}
break;
case AUTH_COOKIE:
/* If cookie-session, look for a session with matching session ID */
if ( (Hdr->HR.desired_session != 0)
&& (sptr->wc_session == Hdr->HR.desired_session)
) {
if (verbose)
syslog(LOG_DEBUG, "Matched a session with the same cookie");
TheSession = sptr;
}
break;
case NO_AUTH:
/* Any unbound session is a candidate */
if ( (sptr->wc_session == 0) && (sptr->inuse == 0) ) {
if (verbose)
syslog(LOG_DEBUG, "Reusing an unbound session");
TheSession = sptr;
}
break;
}
}
CtdlLogResult(pthread_mutex_unlock(ListMutex));
if (TheSession == NULL) {
syslog(LOG_DEBUG, "No existing session was matched");
}
return TheSession;
}
示例15: ReadPostData
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;
}