Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 5 Oct 2013 03:40:30 +0000 (05:40 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sat, 5 Oct 2013 03:40:30 +0000 (05:40 +0200)
21 files changed:
citadel/citadel.h
citadel/config.c
citadel/config.h
citadel/control.c
citadel/include/ctdl_module.h
citadel/modules/calendar/serv_calendar.c
citadel/modules/imap/imap_fetch.c
citadel/modules/imap/imap_misc.c
citadel/modules/instmsg/serv_instmsg.c
citadel/modules/network/serv_netspool.c
citadel/modules/network/serv_network.c
citadel/modules/notes/serv_notes.c
citadel/modules/rssclient/serv_rssclient.c
citadel/modules/smtp/serv_smtp.c
citadel/modules/smtp/serv_smtpqueue.c
citadel/modules/smtp/smtp_util.c
citadel/modules/vcard/serv_vcard.c
citadel/modules/wiki/serv_wiki.c
citadel/msgbase.c
citadel/msgbase.h
citadel/user_ops.c

index a3ad3c3121e6134b55b5f1280366e99336193309..b8e245bae6296ec8241093984569561bf26c8544 100644 (file)
@@ -98,16 +98,6 @@ struct march {
        int march_access;
 };
 
-#define NODENAME               config.c_nodename
-#define FQDN                   config.c_fqdn
-#define HUMANNODE              config.c_humannode
-#define PHONENUM               config.c_phonenum
-#define CTDLUID                        config.c_ctdluid
-#define CREATAIDE              config.c_creataide
-#define REGISCALL              config.c_regiscall
-#define TWITDETECT             config.c_twitdetect
-#define TWITROOM               config.c_twitroom
-#define RESTRICT_INTERNET      config.c_restrict
 
 /*
  * User records.
index 7ac1a748bbd478e8ece0e5c6c5b566e62f690e40..25b7f66e27026650f3dd678eec28f07132b9ec04 100644 (file)
@@ -20,6 +20,7 @@
 #include "ctdl_module.h"
 
 struct config config;
+struct configlen configlen;
 
 /*
  * Put some sane default values into our configuration.  Some will be overridden when we run setup.
@@ -32,25 +33,25 @@ void brand_new_installation_set_defaults(void) {
 
        /* Determine our host name, in case we need to use it as a default */
        uname(&my_utsname);
-
+       memset(&configlen, 0, sizeof(struct configlen));
        /* set some sample/default values in place of blanks... */
-       extract_token(config.c_nodename, my_utsname.nodename, 0, '.', sizeof config.c_nodename);
+       configlen.c_nodename = extract_token(config.c_nodename, my_utsname.nodename, 0, '.', sizeof config.c_nodename);
        if (IsEmptyStr(config.c_fqdn) ) {
                if ((he = gethostbyname(my_utsname.nodename)) != NULL) {
-                       safestrncpy(config.c_fqdn, he->h_name, sizeof config.c_fqdn);
+                       configlen.c_fqdn = safestrncpy(config.c_fqdn, he->h_name, sizeof config.c_fqdn);
                }
                else {
-                       safestrncpy(config.c_fqdn, my_utsname.nodename, sizeof config.c_fqdn);
+                       configlen.c_fqdn = safestrncpy(config.c_fqdn, my_utsname.nodename, sizeof config.c_fqdn);
                }
        }
 
-       safestrncpy(config.c_humannode, "Citadel Server", sizeof config.c_humannode);
-       safestrncpy(config.c_phonenum, "US 800 555 1212", sizeof config.c_phonenum);
+       configlen.c_humannode = safestrncpy(config.c_humannode, "Citadel Server", sizeof config.c_humannode);
+       configlen.c_phonenum = safestrncpy(config.c_phonenum, "US 800 555 1212", sizeof config.c_phonenum);
        config.c_initax = 4;
-       safestrncpy(config.c_moreprompt, "<more>", sizeof config.c_moreprompt);
-       safestrncpy(config.c_twitroom, "Trashcan", sizeof config.c_twitroom);
-       safestrncpy(config.c_baseroom, BASEROOM, sizeof config.c_baseroom);
-       safestrncpy(config.c_aideroom, "Aide", sizeof config.c_aideroom);
+       configlen.c_moreprompt = safestrncpy(config.c_moreprompt, "<more>", sizeof config.c_moreprompt);
+       configlen.c_twitroom = safestrncpy(config.c_twitroom, "Trashcan", sizeof config.c_twitroom);
+       configlen.c_baseroom = safestrncpy(config.c_baseroom, BASEROOM, sizeof config.c_baseroom);
+       configlen.c_aideroom = safestrncpy(config.c_aideroom, "Aide", sizeof config.c_aideroom);
        config.c_port_number = 504;
        config.c_sleeping = 900;
 
@@ -92,7 +93,34 @@ void brand_new_installation_set_defaults(void) {
        config.c_xmpp_s2s_port = 5269;
 }
 
-
+void setcfglen(void)
+{
+       configlen.c_nodename = strlen(config.c_nodename);
+       configlen.c_fqdn = strlen(config.c_fqdn);
+       configlen.c_humannode = strlen(config.c_humannode);
+       configlen.c_phonenum = strlen(config.c_phonenum);
+       configlen.c_twitroom = strlen(config.c_twitroom);
+       configlen.c_moreprompt = strlen(config.c_moreprompt);
+       configlen.c_site_location = strlen(config.c_site_location);
+       configlen.c_sysadm = strlen(config.c_sysadm);
+       configlen.c_niu_2 = strlen(config.c_niu_2);
+       configlen.c_ip_addr = strlen(config.c_ip_addr);
+       configlen.c_logpages = strlen(config.c_logpages);
+       configlen.c_baseroom = strlen(config.c_baseroom);
+       configlen.c_aideroom = strlen(config.c_aideroom);
+       configlen.c_ldap_host = strlen(config.c_ldap_host);
+       configlen.c_ldap_base_dn = strlen(config.c_ldap_base_dn);
+       configlen.c_ldap_bind_dn = strlen(config.c_ldap_bind_dn);
+       configlen.c_ldap_bind_pw = strlen(config.c_ldap_bind_pw);
+       configlen.c_journal_dest = strlen(config.c_journal_dest);
+       configlen.c_default_cal_zone = strlen(config.c_default_cal_zone);
+       configlen.c_funambol_host = strlen(config.c_funambol_host);
+       configlen.c_funambol_source = strlen(config.c_funambol_source);
+       configlen.c_funambol_auth = strlen(config.c_funambol_auth);
+       configlen.c_master_user = strlen(config.c_master_user);
+       configlen.c_master_pass = strlen(config.c_master_pass);
+       configlen.c_pager_program = strlen(config.c_pager_program);
+}
 
 /*
  * get_config() is called during the initialization of Citadel server.
@@ -123,6 +151,7 @@ void get_config(void) {
                        );
                }
                fclose(cfp);
+               setcfglen();
        }
        else {
                brand_new_installation_set_defaults();
index f541ebfa2528cf39522b5ff6414f449981cd9c7f..d1529c5a00cfb79dca8e8404643359db4acbe6e7 100644 (file)
@@ -19,4 +19,3 @@ void put_config(void);
 
 char *CtdlGetSysConfig(char *sysconfname);
 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
-
index cc3165531666dc4990ab151a8633ef3906df3e1b..f543e8d4382acd29c845b5adb82a3aaf8ca5b9cc 100644 (file)
@@ -397,20 +397,20 @@ void cmd_conf(char *argbuf)
                while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) {
                        switch (a) {
                        case 0:
-                               safestrncpy(config.c_nodename, buf,
-                                           sizeof config.c_nodename);
+                               configlen.c_nodename = safestrncpy(config.c_nodename, buf,
+                                                                  sizeof config.c_nodename);
                                break;
                        case 1:
-                               safestrncpy(config.c_fqdn, buf,
-                                           sizeof config.c_fqdn);
+                               configlen.c_fqdn = safestrncpy(config.c_fqdn, buf,
+                                                              sizeof config.c_fqdn);
                                break;
                        case 2:
-                               safestrncpy(config.c_humannode, buf,
-                                           sizeof config.c_humannode);
+                               configlen.c_humannode = safestrncpy(config.c_humannode, buf,
+                                                                   sizeof config.c_humannode);
                                break;
                        case 3:
-                               safestrncpy(config.c_phonenum, buf,
-                                           sizeof config.c_phonenum);
+                               configlen.c_phonenum = safestrncpy(config.c_phonenum, buf,
+                                                                  sizeof config.c_phonenum);
                                break;
                        case 4:
                                config.c_creataide = atoi(buf);
@@ -436,12 +436,12 @@ void cmd_conf(char *argbuf)
                                        config.c_twitdetect = 1;
                                break;
                        case 9:
-                               safestrncpy(config.c_twitroom, buf,
-                                           sizeof config.c_twitroom);
+                               configlen.c_twitroom = safestrncpy(config.c_twitroom, buf,
+                                                                  sizeof config.c_twitroom);
                                break;
                        case 10:
-                               safestrncpy(config.c_moreprompt, buf,
-                                           sizeof config.c_moreprompt);
+                               configlen.c_moreprompt = safestrncpy(config.c_moreprompt, buf,
+                                                                    sizeof config.c_moreprompt);
                                break;
                        case 11:
                                config.c_restrict = atoi(buf);
@@ -449,12 +449,13 @@ void cmd_conf(char *argbuf)
                                        config.c_restrict = 1;
                                break;
                        case 12:
-                               safestrncpy(config.c_site_location, buf,
-                                           sizeof config.c_site_location);
+                               configlen.c_site_location = safestrncpy(
+                                       config.c_site_location, buf,
+                                       sizeof config.c_site_location);
                                break;
                        case 13:
-                               safestrncpy(config.c_sysadm, buf,
-                                           sizeof config.c_sysadm);
+                               configlen.c_sysadm = safestrncpy(config.c_sysadm, buf,
+                                                                sizeof config.c_sysadm);
                                break;
                        case 14:
                                config.c_maxsessions = atoi(buf);
@@ -471,8 +472,8 @@ void cmd_conf(char *argbuf)
                                config.c_roompurge = atoi(buf);
                                break;
                        case 18:
-                               safestrncpy(config.c_logpages, buf,
-                                           sizeof config.c_logpages);
+                               configlen.c_logpages = safestrncpy(config.c_logpages, buf,
+                                                                  sizeof config.c_logpages);
                                break;
                        case 19:
                                config.c_createax = atoi(buf);
@@ -521,34 +522,34 @@ void cmd_conf(char *argbuf)
                                break;
                        case 31:
                                if ((config.c_purge_hour >= 0)
-                                  && (config.c_purge_hour <= 23)) {
+                                   && (config.c_purge_hour <= 23)) {
                                        config.c_purge_hour = atoi(buf);
                                }
                                break;
 #ifdef HAVE_LDAP
                        case 32:
-                               safestrncpy(config.c_ldap_host, buf,
-                                           sizeof config.c_ldap_host);
+                               configlen.c_ldap_host = safestrncpy(config.c_ldap_host, buf,
+                                                                   sizeof config.c_ldap_host);
                                break;
                        case 33:
                                config.c_ldap_port = atoi(buf);
                                break;
                        case 34:
-                               safestrncpy(config.c_ldap_base_dn, buf,
-                                           sizeof config.c_ldap_base_dn);
+                               configlen.c_ldap_base_dn = safestrncpy(config.c_ldap_base_dn, buf,
+                                                                      sizeof config.c_ldap_base_dn);
                                break;
                        case 35:
-                               safestrncpy(config.c_ldap_bind_dn, buf,
-                                           sizeof config.c_ldap_bind_dn);
+                               configlen.c_ldap_bind_dn = safestrncpy(config.c_ldap_bind_dn, buf,
+                                                                      sizeof config.c_ldap_bind_dn);
                                break;
                        case 36:
-                               safestrncpy(config.c_ldap_bind_pw, buf,
-                                           sizeof config.c_ldap_bind_pw);
+                               configlen.c_ldap_bind_pw = safestrncpy(config.c_ldap_bind_pw, buf,
+                                                                      sizeof config.c_ldap_bind_pw);
                                break;
 #endif
                        case 37:
-                               safestrncpy(config.c_ip_addr, buf,
-                                               sizeof config.c_ip_addr);
+                               configlen.c_ip_addr = safestrncpy(config.c_ip_addr, buf,
+                                                                 sizeof config.c_ip_addr);
                        case 38:
                                config.c_msa_port = atoi(buf);
                                break;
@@ -580,11 +581,12 @@ void cmd_conf(char *argbuf)
                                config.c_journal_pubmsgs = atoi(buf);
                                break;
                        case 48:
-                               safestrncpy(config.c_journal_dest, buf,
-                                               sizeof config.c_journal_dest);
+                               configlen.c_journal_dest = safestrncpy(config.c_journal_dest, buf,
+                                                                      sizeof config.c_journal_dest);
                        case 49:
-                               safestrncpy(config.c_default_cal_zone, buf,
-                                               sizeof config.c_default_cal_zone);
+                               configlen.c_default_cal_zone = safestrncpy(
+                                       config.c_default_cal_zone, buf,
+                                       sizeof config.c_default_cal_zone);
                                break;
                        case 50:
                                config.c_pftcpdict_port = atoi(buf);
@@ -595,35 +597,38 @@ void cmd_conf(char *argbuf)
                        case 52:
                                config.c_auth_mode = atoi(buf);
                        case 53:
-                               safestrncpy(config.c_funambol_host, buf,
+                               configlen.c_funambol_host = safestrncpy(
+                                       config.c_funambol_host, buf,
                                        sizeof config.c_funambol_host);
                                break;
                        case 54:
                                config.c_funambol_port = atoi(buf);
                                break;
                        case 55:
-                               safestrncpy(config.c_funambol_source,
-                                       buf, 
+                               configlen.c_funambol_source = safestrncpy(
+                                       config.c_funambol_source, buf, 
                                        sizeof config.c_funambol_source);
                                break;
                        case 56:
-                               safestrncpy(config.c_funambol_auth,
-                                       buf,
+                               configlen.c_funambol_auth = safestrncpy(
+                                       config.c_funambol_auth, buf,
                                        sizeof config.c_funambol_auth);
                                break;
                        case 57:
                                config.c_rbl_at_greeting = atoi(buf);
                                break;
                        case 58:
-                               safestrncpy(config.c_master_user, buf, sizeof config.c_master_user);
+                               configlen.c_master_user = safestrncpy(
+                                       config.c_master_user,
+                                       buf, sizeof config.c_master_user);
                                break;
                        case 59:
-                               safestrncpy(config.c_master_pass, buf, sizeof config.c_master_pass);
+                               configlen.c_master_pass = safestrncpy(
+                                       config.c_master_pass, buf, sizeof config.c_master_pass);
                                break;
                        case 60:
-                               safestrncpy(config.c_pager_program,
-                                       buf,
-                                       sizeof config.c_pager_program);
+                               configlen.c_pager_program = safestrncpy(
+                                       config.c_pager_program, buf, sizeof config.c_pager_program);
                                break;
                        case 61:
                                config.c_imap_keep_from = atoi(buf);
index ca447f595e0398adb053d08cf2ef4d90a7b98a61..8a0f265ff8dba1b7198572bca6f3f2600d1fa752 100644 (file)
@@ -390,9 +390,48 @@ struct config {
        int c_spam_flag_only;
        int c_guest_logins;
 };
+struct configlen {
+       long c_nodename;
+       long c_fqdn;
+       long c_humannode;
+       long c_phonenum;
+       long c_twitroom;
+       long c_moreprompt;
+       long c_site_location;
+       long c_sysadm;
+       long c_niu_2;
+       long c_ip_addr;
+       long c_logpages;
+       long c_baseroom;
+       long c_aideroom;
+       long c_ldap_host;
+       long c_ldap_base_dn;
+       long c_ldap_bind_dn;
+       long c_ldap_bind_pw;
+       long c_journal_dest;
+       long c_default_cal_zone;
+       long c_funambol_host;
+       long c_funambol_source;
+       long c_funambol_auth;
+       long c_master_user;
+       long c_master_pass;
+       long c_pager_program;
+};
 
 extern struct config config;
+extern struct configlen configlen;
+
+
+#define NODENAME               config.c_nodename
+#define FQDN                   config.c_fqdn
+#define CTDLUID                        config.c_ctdluid
+#define CREATAIDE              config.c_creataide
+#define REGISCALL              config.c_regiscall
+#define TWITDETECT             config.c_twitdetect
+#define TWITROOM               config.c_twitroom
+#define RESTRICT_INTERNET      config.c_restrict
 
+#define CFG_KEY(which) config.which, configlen.which
 
 typedef void (*CfgLineParser)(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *rncfg);
 typedef void (*CfgLineSerializer)(const CfgLineType *ThisOne, StrBuf *OuptputBuffer, OneRoomNetCfg *rncfg, RoomNetCfgLine *data);
index 8d3fe42cbb8ee13106532ac429de4f7c581c1d0b..1504fcc93bca1b92eb087fc44366bd2ed4894246 100644 (file)
@@ -149,8 +149,8 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
                msg->cm_format_type = 4;
                CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
                CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
-               CM_SetField(msg, eNodeName, config.c_nodename, strlen(config.c_nodename));
-               CM_SetField(msg, eHumanNode, config.c_humannode, strlen(config.c_humannode));
+               CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+               CM_SetField(msg, eHumanNode, CFG_KEY(c_humannode));
 
                MsgBody = NewStrBufPlain(NULL, serlen + 100);
                StrBufAppendBufPlain(MsgBody, HKEY("Content-type: text/calendar\r\n\r\n"), 0);
@@ -386,12 +386,11 @@ void ical_respond(long msgnum, char *partnum, char *action) {
 
        memset(&ird, 0, sizeof ird);
        strcpy(ird.desired_partnum, partnum);
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *ical_locate_part,              /* callback function */
-               NULL, NULL,
-               (void *) &ird,                  /* user data */
-               0
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *ical_locate_part,          /* callback function */
+                   NULL, NULL,
+                   (void *) &ird,                      /* user data */
+                   0
        );
 
        /* We're done with the incoming message, because we now have a
@@ -642,12 +641,11 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
                return(2);                      /* internal error */
        }
        oec.c = NULL;
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *ical_locate_original_event,    /* callback function */
-               NULL, NULL,
-               &oec,                           /* user data */
-               0
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *ical_locate_original_event,        /* callback function */
+                   NULL, NULL,
+                   &oec,                               /* user data */
+                   0
        );
        CM_Free(msg);
 
@@ -729,13 +727,12 @@ void ical_handle_rsvp(long msgnum, char *partnum, char *action) {
 
        memset(&ird, 0, sizeof ird);
        strcpy(ird.desired_partnum, partnum);
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *ical_locate_part,              /* callback function */
-               NULL, NULL,
-               (void *) &ird,                  /* user data */
-               0
-       );
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *ical_locate_part,          /* callback function */
+                   NULL, NULL,
+                   (void *) &ird,                      /* user data */
+                   0
+               );
 
        /* We're done with the incoming message, because we now have a
         * calendar object in memory.
@@ -1161,12 +1158,11 @@ void ical_hunt_for_conflicts_backend(long msgnum, void *data) {
        if (msg == NULL) return;
        memset(&ird, 0, sizeof ird);
        strcpy(ird.desired_partnum, "_HUNT_");
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *ical_locate_part,              /* callback function */
-               NULL, NULL,
-               (void *) &ird,                  /* user data */
-               0
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *ical_locate_part,          /* callback function */
+                   NULL, NULL,
+                   (void *) &ird,                      /* user data */
+                   0
        );
        CM_Free(msg);
 
@@ -1230,13 +1226,12 @@ void ical_conflicts(long msgnum, char *partnum) {
 
        memset(&ird, 0, sizeof ird);
        strcpy(ird.desired_partnum, partnum);
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *ical_locate_part,              /* callback function */
-               NULL, NULL,
-               (void *) &ird,                  /* user data */
-               0
-       );
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *ical_locate_part,          /* callback function */
+                   NULL, NULL,
+                   (void *) &ird,                      /* user data */
+                   0
+               );
 
        CM_Free(msg);
 
@@ -1411,13 +1406,12 @@ void ical_freebusy_backend(long msgnum, void *data) {
        if (msg == NULL) return;
        memset(&ird, 0, sizeof ird);
        strcpy(ird.desired_partnum, "_HUNT_");
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *ical_locate_part,              /* callback function */
-               NULL, NULL,
-               (void *) &ird,                  /* user data */
-               0
-       );
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *ical_locate_part,          /* callback function */
+                   NULL, NULL,
+                   (void *) &ird,                      /* user data */
+                   0
+               );
        CM_Free(msg);
 
        if (ird.cal) {
@@ -1612,12 +1606,11 @@ void ical_getics_backend(long msgnum, void *data) {
        if (msg == NULL) return;
        memset(&ird, 0, sizeof ird);
        strcpy(ird.desired_partnum, "_HUNT_");
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *ical_locate_part,              /* callback function */
-               NULL, NULL,
-               (void *) &ird,                  /* user data */
-               0
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *ical_locate_part,          /* callback function */
+                   NULL, NULL,
+                   (void *) &ird,                      /* user data */
+                   0
        );
        CM_Free(msg);
 
@@ -2413,13 +2406,12 @@ int ical_obj_beforesave(struct CtdlMessage *msg, recptypes *recp)
        }
 
        /* Do all of our lovely back-end parsing */
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *ical_obj_beforesave_backend,
-               NULL, NULL,
-               (void *)msg,
-               0
-       );
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *ical_obj_beforesave_backend,
+                   NULL, NULL,
+                   (void *)msg,
+                   0
+               );
 
        return(0);
 }
@@ -2482,13 +2474,12 @@ int ical_obj_aftersave(struct CtdlMessage *msg, recptypes *recp)
        if (CM_IsEmpty(msg, eMesageText)) return(1);
        
        /* Now recurse through it looking for our icalendar data */
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *ical_obj_aftersave_backend,
-               NULL, NULL,
-               NULL,
-               0
-       );
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *ical_obj_aftersave_backend,
+                   NULL, NULL,
+                   NULL,
+                   0
+               );
 
        return(0);
 }
index f9998937183a50652b1030986ec98440947497f7..75a4cdbea5a395b5a23ff182befe3acfde6587ba 100644 (file)
@@ -364,7 +364,7 @@ void imap_output_envelope_from(struct CtdlMessage *msg) {
                IPutStr(user, strlen(user));            /* mailbox name (user id) */
                IAPuts(" ");
                if (!strcasecmp(node, config.c_nodename)) {
-                       IPutStr(config.c_fqdn, strlen(config.c_fqdn));
+                       IPutStr(CFG_KEY(c_fqdn));
                }
                else {
                        IPutStr(node, strlen(node));            /* host name */
@@ -752,7 +752,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
         * (Note value of 1 passed as 'dont_decode' so client gets it encoded)
         */
        else {
-               mime_parser(msg->cm_fields[eMesageText], NULL,
+               mime_parser(CM_RANGE(msg, eMesageText),
                            *imap_load_part, NULL, NULL,
                            section,
                            1
@@ -1017,13 +1017,12 @@ void imap_fetch_bodystructure (long msgnum, const char *item,
 
        /* For messages already stored in RFC822 format, we have to parse. */
        IAPuts("BODYSTRUCTURE ");
-       mime_parser(msg->cm_fields[eMesageText],
-                       NULL,
-                       *imap_fetch_bodystructure_part, /* part */
-                       *imap_fetch_bodystructure_pre,  /* pre-multi */
-                       *imap_fetch_bodystructure_post, /* post-multi */
-                       NULL,
-                       1);     /* don't decode -- we want it as-is */
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *imap_fetch_bodystructure_part,     /* part */
+                   *imap_fetch_bodystructure_pre,      /* pre-multi */
+                   *imap_fetch_bodystructure_post,     /* post-multi */
+                   NULL,
+                   1); /* don't decode -- we want it as-is */
 }
 
 
index 5485836a9666de4984d61fcc90905be3e732a3e9..5cfe8be8fcf93177b4b59c4280051ab96d38b109 100644 (file)
@@ -387,8 +387,8 @@ void imap_append(int num_parms, ConstStr *Params) {
           if ( ((CCC->room.QRflags & QR_MAILBOX) == 0) && (config.c_imap_keep_from == 0)) {
 
                CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
-               CM_SetField(msg, eNodeName, config.c_nodename, strlen(config.c_nodename));
-               CM_SetField(msg, eHumanNode, config.c_humannode, strlen(config.c_humannode));
+               CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+               CM_SetField(msg, eHumanNode, CFG_KEY(c_humannode));
            }
        }
 
index 72f3256dee2185293635ec91a9f0787982cca63d..17ed7cc629830d372d2ffdc6230ede42ab34490a 100644 (file)
@@ -468,7 +468,7 @@ void flush_individual_conversation(struct imlog *im) {
        }
 
        CM_SetField(msg, eOriginalRoom, HKEY(PAGELOGROOM));
-       CM_SetField(msg, eNodeName, NODENAME, strlen(NODENAME));
+       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
        CM_SetAsFieldSB(msg, eMesageText, &im->conversation);   /* we own this memory now */
 
        /* Start with usernums[1] because it's guaranteed to be higher than usernums[0],
index 3dfec6375a9c379d4accf83812f327ae54ac2a0a..e5ca89a4de30d5f8530648301ea57b04abc8f852 100644 (file)
@@ -168,7 +168,7 @@ void Netmap_AddMe(struct CtdlMessage *msg, const char *defl, long defllen)
        if (CM_IsEmpty(msg, eMessagePath)) {
                CM_SetField(msg, eMessagePath, defl, defllen);
        }
-       node_len = strlen(config.c_nodename);
+       node_len = configlen.c_nodename;
        if (node_len >= SIZ) 
                node_len = SIZ - 1;
        memcpy(buf, config.c_nodename, node_len);
index ef9dfc56829fd4793e5a1cabea32427262087c19..9fa82734e8a278d52ba71bf5669164250177b36c 100644 (file)
@@ -391,7 +391,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason)
                       msg->cm_fields[eNodeName]);
 
        CM_SetField(msg, eAuthor, HKEY(BOUNCESOURCE));
-       CM_SetField(msg, eNodeName, config.c_nodename, strlen(config.c_nodename));
+       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
        CM_SetField(msg, eMsgSubject, HKEY("Delivery Status Notification (Failure)"));
 
        Netmap_AddMe(msg, HKEY("unknown_user"));
index a250c8ccd63a652d7a317d1f33ad99ee7256a1c5..cb21be03ddd55e6448a9e2421f038be56af5e02c 100644 (file)
@@ -130,12 +130,11 @@ int serv_notes_beforesave(struct CtdlMessage *msg, recptypes *recp)
 
        /* Modern clients are using vNote format.  Check for one... */
 
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *notes_extract_vnote,
-               NULL, NULL,
-               &v,             /* user data ptr - put the vnote here */
-               0
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *notes_extract_vnote,
+                   NULL, NULL,
+                   &v,         /* user data ptr - put the vnote here */
+                   0
        );
 
        if (v == NULL) return(0);       /* no vNotes were found in this message */
index f774fa3f543b0ea6d6a3f8083135ac518bb01a37..0df7bacad8243bd2229e0e7466b99a5c41694a1d 100644 (file)
@@ -333,7 +333,7 @@ int rss_format_item(AsyncIO *IO, networker_save_message *SaveMsg)
                CM_SetField(&SaveMsg->Msg, eAuthor, HKEY("rss"));
        }
 
-       CM_SetField(&SaveMsg->Msg, eNodeName, NODENAME, strlen(NODENAME));
+       CM_SetField(&SaveMsg->Msg, eNodeName, CFG_KEY(c_nodename));
        if (SaveMsg->title != NULL) {
                long len;
                char *Sbj;
index abdc2d1ad7eeec19606ec7a101298aee3cb53df4..1a5b6009c9d656ffbbe4b0bb506a3bd056383ec0 100644 (file)
@@ -859,8 +859,8 @@ void smtp_data(long offset, long flags)
                        return;
                }
 
-               CM_SetField(msg, eNodeName, config.c_nodename, strlen(config.c_nodename));
-               CM_SetField(msg, eHumanNode, config.c_humannode, strlen(config.c_humannode));
+               CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+               CM_SetField(msg, eHumanNode, CFG_KEY(c_humannode));
                CM_SetField(msg, eOriginalRoom, HKEY(MAILROOM));
                if (sSMTP->preferred_sender_name != NULL)
                        CM_SetField(msg, eAuthor, SKEY(sSMTP->preferred_sender_name));
index b2196a88755a1dc76fec4ed185606f0704b6a563..9a618e092ee88731c465c2e2683a397293a2a0f7 100644 (file)
@@ -702,7 +702,7 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt, ParsedURL *Relay)
 
        CM_SetField(bmsg, eOriginalRoom, HKEY(MAILROOM));
        CM_SetField(bmsg, eAuthor, HKEY("Citadel"));
-       CM_SetField(bmsg, eNodeName, config.c_nodename, strlen(config.c_nodename));
+       CM_SetField(bmsg, eNodeName, CFG_KEY(c_nodename));
        CM_SetField(bmsg, eMsgSubject, HKEY("Delivery Status Notification (Failure)"));
        CM_SetAsFieldSB(bmsg, eMesageText, &BounceMB);
 
index 675001ea0d3570cdfef6303a294c2cf0d5cad9d3..e4a4c2da5eadb0e83c6d1e3597354f37d9a914ea 100644 (file)
@@ -163,7 +163,7 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
        bmsg->cm_format_type = FMT_RFC822;
        CM_SetField(bmsg, eAuthor, HKEY("Citadel"));
        CM_SetField(bmsg, eOriginalRoom, HKEY(MAILROOM));
-       CM_SetField(bmsg, eNodeName, config.c_nodename, strlen(config.c_nodename));
+       CM_SetField(bmsg, eNodeName, CFG_KEY(c_nodename));
        CM_SetField(bmsg, eMsgSubject, HKEY("Delivery Status Notification (Failure)"));
        StrBufAppendBufPlain(
                BounceMB,
index 3d62c83d0b710e97442ab2e25f1af64b4070a0f0..d143fc776e924bb87b7980b409e6efeb5f993092 100644 (file)
@@ -375,12 +375,11 @@ int vcard_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) {
 
        if (CM_IsEmpty(msg, eMesageText)) return(0);
 
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *vcard_extract_vcard,
-               NULL, NULL,
-               &v,             /* user data ptr - put the vcard here */
-               0
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *vcard_extract_vcard,
+                   NULL, NULL,
+                   &v,         /* user data ptr - put the vcard here */
+                   0
        );
 
        if (v == NULL) return(0);       /* no vCards were found in this message */
@@ -906,7 +905,7 @@ void vcard_purge(struct ctdluser *usbuf) {
        msg->cm_format_type = 0;
        CM_SetField(msg, eAuthor, usbuf->fullname, strlen(usbuf->fullname));
        CM_SetField(msg, eOriginalRoom, HKEY(ADDRESS_BOOK_ROOM));
-       CM_SetField(msg, eNodeName, NODENAME, strlen(NODENAME));
+       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
        CM_SetField(msg, eMesageText, HKEY("Purge this vCard\n"));
 
        len = snprintf(buf, sizeof buf, VCARD_EXT_FORMAT,
@@ -1107,13 +1106,12 @@ void dvca_callback(long msgnum, void *userdata) {
 
        msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) return;
-       mime_parser(msg->cm_fields[eMesageText],
-               NULL,
-               *dvca_mime_callback,    /* callback function */
-               NULL, NULL,
-               NULL,                   /* user data */
-               0
-       );
+       mime_parser(CM_RANGE(msg, eMesageText),
+                   *dvca_mime_callback,        /* callback function */
+                   NULL, NULL,
+                   NULL,                       /* user data */
+                   0
+               );
        CM_Free(msg);
 }
 
index ccfc77b7e66495e3c274d32a9a825798a6a1056f..d656b2457c5c3a77e1158f0bd21fb4ce41faff1c 100644 (file)
@@ -407,7 +407,7 @@ void wiki_history(char *pagename) {
 
        
        cprintf("%d Revision history for '%s'\n", LISTING_FOLLOWS, pagename);
-       mime_parser(msg->cm_fields[eMesageText], NULL, *wiki_history_callback, NULL, NULL, NULL, 0);
+       mime_parser(CM_RANGE(msg, eMesageText), *wiki_history_callback, NULL, NULL, NULL, 0);
        cprintf("000\n");
 
        CM_Free(msg);
@@ -580,7 +580,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
        hecbd.stop_when = rev;
        striplt(hecbd.stop_when);
 
-       mime_parser(msg->cm_fields[eMesageText], NULL, *wiki_rev_callback, NULL, NULL, (void *)&hecbd, 0);
+       mime_parser(CM_RANGE(msg, eMesageText), *wiki_rev_callback, NULL, NULL, (void *)&hecbd, 0);
        CM_Free(msg);
 
        /* Were we successful? */
@@ -642,7 +642,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
                        CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
                        CM_SetField(msg, erFc822Addr, CCC->cs_inet_email, strlen(CCC->cs_inet_email));
                        CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
-                       CM_SetField(msg, eNodeName, NODENAME, strlen(NODENAME));
+                       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
                        CM_SetField(msg, eExclusiveID, pagename, strlen(pagename));
                        msgnum = CtdlSubmitMsg(msg, NULL, "", 0);       /* Replace the current revision */
                }
index d1270f4d1e75b18b0fa9e744eed4e821d56663e9..776680b6df7cd5dd04f16bd04979fe23cf07cff6 100644 (file)
@@ -1584,11 +1584,10 @@ int CtdlOutputMsg(long msg_num,         /* message number (local) to fetch */
        if (section) if (!IsEmptyStr(section)) if (strcmp(section, "0")) {
                memset(&encap, 0, sizeof encap);
                safestrncpy(encap.desired_section, section, sizeof encap.desired_section);
-               mime_parser(TheMessage->cm_fields[eMesageText],
-                       NULL,
-                       *extract_encapsulated_message,
-                       NULL, NULL, (void *)&encap, 0
-               );
+               mime_parser(CM_RANGE(TheMessage, eMesageText),
+                           *extract_encapsulated_message,
+                           NULL, NULL, (void *)&encap, 0
+                       );
 
                if ((Author != NULL) && (*Author == NULL))
                {
@@ -2004,7 +2003,6 @@ int CtdlOutputPreLoadedMsg(
 ) {
        struct CitContext *CCC = CC;
        int i;
-       char *mptr = NULL;
        const char *nl; /* newline string */
        struct ma_info ma;
 
@@ -2051,8 +2049,8 @@ int CtdlOutputPreLoadedMsg(
                                ERROR + RESOURCE_BUSY);
                } else {
                        /* Parse the message text component */
-                       mptr = TheMessage->cm_fields[eMesageText];
-                       mime_parser(mptr, NULL, *mime_download, NULL, NULL, NULL, 0);
+                       mime_parser(CM_RANGE(TheMessage, eMesageText),
+                                   *mime_download, NULL, NULL, NULL, 0);
                        /* If there's no file open by this time, the requested
                         * section wasn't found, so print an error
                         */
@@ -2078,8 +2076,8 @@ int CtdlOutputPreLoadedMsg(
                        /* Parse the message text component */
                        int found_it = 0;
 
-                       mptr = TheMessage->cm_fields[eMesageText];
-                       mime_parser(mptr, NULL, *mime_spew_section, NULL, NULL, (void *)&found_it, 0);
+                       mime_parser(CM_RANGE(TheMessage, eMesageText),
+                                   *mime_spew_section, NULL, NULL, (void *)&found_it, 0);
                        /* If section wasn't found, print an error
                         */
                        if (!found_it) {
@@ -2119,7 +2117,7 @@ int CtdlOutputPreLoadedMsg(
        strcpy(suser, "");
        strcpy(luser, "");
        strcpy(fuser, "");
-       strcpy(snode, NODENAME);
+       memcpy(snode, CFG_KEY(c_nodename) + 1);
        if (mode == MT_RFC822) 
                OutputRFC822MsgHeaders(
                        TheMessage,
@@ -2176,9 +2174,8 @@ START_TEXT:
        /* Tell the client about the MIME parts in this message */
        if (TheMessage->cm_format_type == FMT_RFC822) {
                if ( (mode == MT_CITADEL) || (mode == MT_MIME) ) {
-                       mptr = TheMessage->cm_fields[eMesageText];
                        memset(&ma, 0, sizeof(struct ma_info));
-                       mime_parser(mptr, NULL,
+                       mime_parser(CM_RANGE(TheMessage, eMesageText),
                                (do_proto ? *list_this_part : NULL),
                                (do_proto ? *list_this_pref : NULL),
                                (do_proto ? *list_this_suff : NULL),
@@ -2217,12 +2214,10 @@ START_TEXT:
         * message to the reader's screen width.
         */
        if (TheMessage->cm_format_type == FMT_CITADEL) {
-               mptr = TheMessage->cm_fields[eMesageText];
-
                if (mode == MT_MIME) {
                        cprintf("Content-type: text/x-citadel-variformat\n\n");
                }
-               memfmout(mptr, nl);
+               memfmout(TheMessage->cm_fields[eMesageText], nl);
        }
 
        /* If the message on disk is format 4 (MIME), we've gotta hand it
@@ -2238,17 +2233,17 @@ START_TEXT:
                        strcpy(ma.chosen_part, "1");
                        ma.chosen_pref = 9999;
                        ma.dont_decode = CCC->msg4_dont_decode;
-                       mime_parser(mptr, NULL,
-                               *choose_preferred, *fixed_output_pre,
-                               *fixed_output_post, (void *)&ma, 1);
-                       mime_parser(mptr, NULL,
-                               *output_preferred, NULL, NULL, (void *)&ma, 1);
+                       mime_parser(CM_RANGE(TheMessage, eMesageText),
+                                   *choose_preferred, *fixed_output_pre,
+                                   *fixed_output_post, (void *)&ma, 1);
+                       mime_parser(CM_RANGE(TheMessage, eMesageText),
+                                   *output_preferred, NULL, NULL, (void *)&ma, 1);
                }
                else {
                        ma.use_fo_hooks = 1;
-                       mime_parser(mptr, NULL,
-                               *fixed_output, *fixed_output_pre,
-                               *fixed_output_post, (void *)&ma, 0);
+                       mime_parser(CM_RANGE(TheMessage, eMesageText),
+                                   *fixed_output, *fixed_output_pre,
+                                   *fixed_output_post, (void *)&ma, 0);
                }
 
        }
@@ -2982,7 +2977,7 @@ void quickie_message(const char *from,
 
        if (fromaddr != NULL) CM_SetField(msg, erFc822Addr, fromaddr, strlen(fromaddr));
        if (room != NULL) CM_SetField(msg, eOriginalRoom, room, strlen(room));
-       CM_SetField(msg, eNodeName, NODENAME, strlen(NODENAME));
+       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
        if (to != NULL) {
                CM_SetField(msg, eRecipient, to, strlen(to));
                recp = validate_recipients(to, NULL, 0);
@@ -3442,8 +3437,8 @@ struct CtdlMessage *CtdlMakeMessageLen(
                CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
        }
 
-       CM_SetField(msg, eNodeName, NODENAME, strlen(NODENAME));
-       CM_SetField(msg, eHumanNode, HUMANNODE, strlen(HUMANNODE));
+       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+       CM_SetField(msg, eHumanNode, CFG_KEY(c_humannode));
 
        if (rcplen > 0) {
                CM_SetField(msg, eRecipient, recipient, rcplen);
@@ -3975,8 +3970,8 @@ void CtdlWriteObject(char *req_room,                      /* Room to stuff it in */
        msg->cm_format_type = 4;
        CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
        CM_SetField(msg, eOriginalRoom, req_room, strlen(req_room));
-       CM_SetField(msg, eNodeName, config.c_nodename, strlen(config.c_nodename));
-       CM_SetField(msg, eHumanNode, config.c_humannode, strlen(config.c_humannode));
+       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+       CM_SetField(msg, eHumanNode, CFG_KEY(c_humannode));
        msg->cm_flags = flags;
        
        CM_SetAsFieldSB(msg, eMesageText, &encoded_message);
index a9a4eaba47a1ef0848d10b8c7138014d11f074b5..aecdb18f6c9525dce5ea8578f464b39ff152006b 100644 (file)
@@ -146,6 +146,8 @@ void CM_FreeContents   (struct CtdlMessage *msg);
 int  CM_IsValidMsg     (struct CtdlMessage *msg);
 
 #define CM_KEY(Message, Which) Message->cm_fields[Which], Message->cm_lengths[Which]
+#define CM_RANGE(Message, Which) Message->cm_fields[Which], \
+               Message->cm_fields[Which] + Message->cm_lengths[Which]
 
 void CtdlSerializeMessage(struct ser_ret *, struct CtdlMessage *);
 void ReplicationChecks(struct CtdlMessage *);
index e55807dd33196103c1537c27ed5670d9dbcaf4cf..c79e87abd04dd40c86e3e23a3c61297aa1ef7bb5 100644 (file)
@@ -567,10 +567,12 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
 
        /* If a "master user" is defined, handle its authentication if specified */
        CC->is_master = 0;
-       if (strlen(config.c_master_user) > 0) if (strlen(config.c_master_pass) > 0) if (authname) {
-               if (!strcasecmp(authname, config.c_master_user)) {
-                       CC->is_master = 1;
-               }
+       if ((configlen.c_master_user > 0) && 
+           (configlen.c_master_pass > 0) &&
+           (authname != NULL) &&
+           (!strcasecmp(authname, config.c_master_user)))
+       {
+               CC->is_master = 1;
        }
 
        /* Continue attempting user validation... */