X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fmsgbase.c;fp=citadel%2Fmsgbase.c;h=93c673faa3c1a245962136cd48c36ebdcdb5757d;hp=0d91873c5c21212de8f2557daec582012f4f721f;hb=e86cae42a7b279758e7d5de8785793af5cdf689d;hpb=0b309a2b8cf939c7a0f5c765a2ab64f8df23c511 diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 0d91873c5..93c673faa 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -45,7 +45,7 @@ int MessageDebugEnabled = 0; * 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, @@ -80,8 +80,33 @@ char *msgkeys[] = { "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 */ @@ -4120,6 +4145,7 @@ void SetMessageDebugEnabled(const int n) CTDL_MODULE_INIT(msgbase) { if (!threading) { + FillMsgKeyLookupTable(); CtdlRegisterDebugFlagHook(HKEY("messages"), SetMessageDebugEnabled, &MessageDebugEnabled); }