char tfield[256];
char tvalue[256];
int cm_ref = 0;
- int i;
int with_template = 0;
struct CtdlMessage *template = NULL;
char search_string[1024];
template->cm_anon_type = MES_NORMAL;
while(client_getln(buf, sizeof buf) >= 0 && strcmp(buf,"000")) {
+ eMsgField f;
+
long tValueLen;
- extract_token(tfield, buf, 0, '|', sizeof tfield);
- tValueLen = extract_token(tvalue, buf, 1, '|', sizeof tvalue);
- if (tValueLen >= 0) {
- for (i='A'; i<='Z'; ++i) if (msgkeys[i]!=NULL) {
- if (!strcasecmp(tfield, msgkeys[i])) {
- CM_SetField(template, i, tvalue, tValueLen);
- }
+ tValueLen = extract_token(tfield, buf, 0, '|', sizeof tfield);
+ if ((tValueLen == 4) && GetFieldFromMnemonic(&f, tfield))
+ {
+ if (with_template == 1) {
+ tValueLen = extract_token(tvalue, buf, 1, '|', sizeof tvalue);
+ if (tValueLen >= 0) {
+ CM_SetField(template, f, tvalue, tValueLen);
}
+ }
+ else {
+
+ }
}
}
buffer_output();
* These are the four-character field headers we use when outputting
* messages in Citadel format (as opposed to RFC822 format).
*/
-char *msgkeys[] = {
+char *msgkeys[91] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
"wefw", /* W -> eWeferences */
NULL, /* X */
"cccc", /* Y -> eCarbonCopY */
- NULL /* Z */
+ NULL /* Z */
+
};
+HashList *msgKeyLookup = NULL;
+
+int GetFieldFromMnemonic(eMsgField *f, const char* c)
+{
+ void *v = NULL;
+ if (GetHash(msgKeyLookup, c, 4, &v)) {
+ *f = (eMsgField) v;
+ return 1;
+ }
+ return 0;
+}
+
+void FillMsgKeyLookupTable(void)
+{
+ long i;
+
+ msgKeyLookup = NewHash (1, FourHash);
+
+ for (i=0; i < 91; i++) {
+ if (msgkeys[i] != NULL) {
+ Put(msgKeyLookup, msgkeys[i], 4, (void*)i, reference_free_handler);
+ }
+ }
+}
eMsgField FieldOrder[] = {
/* Important fields */
CTDL_MODULE_INIT(msgbase)
{
if (!threading) {
+ FillMsgKeyLookupTable();
CtdlRegisterDebugFlagHook(HKEY("messages"), SetMessageDebugEnabled, &MessageDebugEnabled);
}
return 0;
}
-long FourHash(const char *key, long length)
-{
- int i;
- int ret = 0;
- const unsigned char *ptr = (const unsigned char*)key;
-
- for (i = 0; i < 4; i++, ptr ++)
- ret = (ret << 8) |
- ( ((*ptr >= 'a') &&
- (*ptr <= 'z'))?
- *ptr - 'a' + 'A':
- *ptr);
-
- return ret;
-}
-
void CtdlRegisterDebugFlagHook(const char *Name, long Len, CtdlDbgFunction F, const int *LogP)
{
LogDebugEntry *E;