}
ret.len = 3;
+ assert(FieldOrder[NDiskFields-1] == eMessageText); // Message text MUST be last!
for (i=0; i < NDiskFields; ++i) {
if (msg->cm_fields[FieldOrder[i]] != NULL) {
ret.len += msg->cm_lengths[FieldOrder[i]] + 2;
for (i=0; i < NDiskFields; ++i) {
if (msg->cm_fields[FieldOrder[i]] != NULL) {
+ // future improvement: do the bigmsg check right here
ret.ser[wlen++] = (char)FieldOrder[i];
memcpy(&ret.ser[wlen], msg->cm_fields[FieldOrder[i]], msg->cm_lengths[FieldOrder[i]] + 1);
wlen = wlen + msg->cm_lengths[FieldOrder[i]] + 1;
}
}
- if (ret.len != wlen) {
- syslog(LOG_ERR, "msgbase: ERROR; len=%ld wlen=%ld", (long)ret.len, (long)wlen);
- }
-
+ assert(ret.len == wlen); // Make sure we measured it correctly
return(ret);
}
string_trim(content_type);
aptr = content_type;
while (!IsEmptyStr(aptr)) {
- if ((*aptr == ';')
- || (*aptr == ' ')
- || (*aptr == 13)
- || (*aptr == 10)) {
+ if ( (*aptr == ';')
+ || (*aptr == ' ')
+ || (*aptr == 13)
+ || (*aptr == 10)
+ ) {
*aptr = 0;
}
- else aptr++;
+ else {
+ aptr++;
+ }
}
}
}
long IsAscii;
IsAscii = -1;
i = 0;
- while ((subject[i] != '\0') && (IsAscii = isascii(subject[i]) != 0 ))
+ while ((subject[i] != '\0') && (IsAscii = isascii(subject[i]) != 0 )) {
i++;
- if (IsAscii != 0)
+ }
+ if (IsAscii != 0) {
CM_SetField(msg, eMsgSubject, subject);
+ }
else { // ok, we've got utf8 in the string.
char *rfc2047Subj;
rfc2047Subj = rfc2047encode(subject, length);
// Use the negative of the message number for the metadata db index
TheIndex = (0L - smibuf->meta_msgnum);
-
- cdb_store(CDB_MSGMAIN,
- &TheIndex, (int)sizeof(long),
- smibuf, (int)sizeof(struct MetaData)
- );
+ cdb_store(CDB_MSGMAIN, &TheIndex, (int)sizeof(long), smibuf, (int)sizeof(struct MetaData));
}
#define CM_RANGE(Message, Which) Message->cm_fields[Which], \
Message->cm_fields[Which] + Message->cm_lengths[Which]
+// Serialization routines use this struct to return a pointer and a length
+struct ser_ret {
+ size_t len;
+ unsigned char *ser;
+};
+
struct ser_ret CtdlSerializeMessage(struct CtdlMessage *);
struct CtdlMessage *CtdlDeserializeMessage(long msgnum, int with_body, const char *Buffer, long Length);
void ReplicationChecks(struct CtdlMessage *);
// Data types for the Citadel Server
//
-// Copyright (c) 1987-2023 by the citadel.org team
+// Copyright (c) 1987-2024 by the citadel.org team
//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
};
-// Serialization routines use this struct to return a pointer and a length
-struct ser_ret {
- size_t len;
- unsigned char *ser;
-};
-
-
// The S_USETABLE database is used in several modules now, so we define its format here.
struct UseTable {
int hash;