本文整理汇总了C++中dtmail::Envelope::getHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ Envelope::getHeader方法的具体用法?C++ Envelope::getHeader怎么用?C++ Envelope::getHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtmail::Envelope
的用法示例。
在下文中一共展示了Envelope::getHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
void
DmxMsg::display (
DmxPrintHeadersEnum header_format,
DmxPrintOutputProc print_proc,
XtPointer stream)
{
DtMailEnv env;
DtMailBoolean FirstIsText = DTM_FALSE;
DtMail::BodyPart *firstPart = NULL, *nextpart = NULL;
char *buf = NULL,
*description = NULL,
*name = NULL,
*newline = NULL,
*sunDataDescription = NULL,
*type = NULL;
void *contents = NULL;
unsigned long length = 0;
int mode = 0;
// For CHARSET
char v3_cs[64],
*mime_cs = NULL,
*from_cs = NULL,
*to_cs = NULL;
// read in body part info
if (cachedValues != DTM_TRUE)
parse ();
firstPart = bodyParts [0];
firstPart->getContents(env,
(const void **) &contents,
&length,
NULL, //type
NULL, //name
NULL, //mode
NULL); //description
if (handleError(env, "getContents") == DTM_TRUE)
exit (1);
// For CHARSET
DtMailValueSeq value;
DtMailBoolean err = DTM_FALSE;
// Get the bodypart's charset - Try MIME first then V3
firstPart->getHeader(env, DtMailMessageContentType, DTM_TRUE, value);
if (env.isNotSet()) {
mime_cs = firstPart->csFromContentType(value);
} else {
env.clear();
value.clear();
firstPart->getHeader(env, DtMailMessageV3charset, DTM_TRUE, value);
if (env.isNotSet()) {
strcpy(v3_cs, *(value[0]));
} else {
err = DTM_TRUE;
env.clear();
value.clear();
}
}
// If cannot obtain bodypart's charset header, then maybe this message
// has only one bodypart, then in this case the charset header maybe
// among the message's envelope (main message headers).
// Get the envelope of the message (in order to access the headers)
DtMail::Envelope *envelope = NULL;
if (err == DTM_TRUE) {
envelope = message->getEnvelope(env);
err = DTM_FALSE;
#ifdef DEBUG
env.logError(
DTM_FALSE,
"DEBUG dtmailpr: Looking at main message header\n");
#endif
}
// Check for MIME charset header and then for V3 charset header
if (envelope != NULL) {
envelope->getHeader(env, DtMailMessageContentType, DTM_TRUE, value);
if (env.isNotSet()) {
mime_cs = firstPart->csFromContentType(value);
} else {
err = DTM_TRUE;
env.clear();
}
if (mime_cs == NULL || err == DTM_TRUE) {
value.clear();
envelope->getHeader(env, DtMailMessageV3charset, DTM_TRUE, value);
if (env.isNotSet()) {
strcpy(v3_cs, *(value[0]));
} else {
err = DTM_TRUE;
env.clear();
}
}
} else {
//.........这里部分代码省略.........
示例2: strcmp
void
RFCFormat::writeHeaders(DtMailEnv & error,
DtMail::Message & msg,
DtMailBoolean include_unix_from,
const char * extra_headers,
const char ** suppress_headers,
Buffer & buf)
{
error.clear();
// First we copy each header from the message to the
// buffer. The headers may need encoding to put them away, so
// we will apply RFC1522 if necessary.
//
DtMailHeaderHandle hnd;
DtMail::Envelope * env = msg.getEnvelope(error);
if (error.isSet()) {
return;
}
char * name = NULL;
DtMailValueSeq value;
hnd = env->getFirstHeader(error, &name, value);
if (!hnd || error.isSet()) {
return;
}
if (include_unix_from &&
(error.isSet() || strcmp(name, "From") != 0)) {
// We require a Unix from line, and we don't have one.
// we will make one up using the sender, and the current
// date.
//
char *unix_from = new char[100];
strcpy(unix_from, "From ");
DtMailValueSeq sender;
env->getHeader(error, DtMailMessageSender, DTM_TRUE, sender);
if (error.isSet()) {
// We no longer know who this is really from.
//
strcat(unix_from, "[email protected]");
}
else {
DtMailAddressSeq * addrSeq = sender[0]->toAddress();
strcat(unix_from, (*addrSeq)[0]->dtm_address);
delete addrSeq;
}
error.clear();
time_t now = time(NULL);
char time_format[30];
SafeCtime(&now, time_format, sizeof(time_format));
strcat(unix_from, " ");
strcat(unix_from, time_format);
buf.appendData(unix_from, strlen(unix_from));
delete [] unix_from;
}
else {
// Put out any header, except Unix From line
//
if (strcmp(name, "From") == 0) {
value.clear();
free(name);
hnd = env->getNextHeader(error, hnd, &name, value);
}
}
for (; // First time is determined above.
hnd && !error.isSet();
value.clear(), hnd = env->getNextHeader(error, hnd, &name, value)) {
const char **hdr;
for (hdr = suppress_headers; *hdr; hdr++) {
if (strcasecmp(name, *hdr) == 0)
break;
}
//add _is_write_bcc for fixing aix defect 177096
if (*hdr || strcasecmp(name, "bcc") == 0 && !_is_write_bcc ) {
free(name);
continue; // We will generate these headers.
}
int name_len = strlen(name);
for (int val = 0; val < value.length(); val++) {
//
// If the value is null or empty do not emit this field
const char *valPtr;
for (valPtr = *(value[val]);
*valPtr && (isspace((unsigned char)*valPtr));
valPtr++)
{}
if (!*valPtr)
continue;
//.........这里部分代码省略.........