4 * This file contains functions which handle the mapping of Internet addresses
5 * to users on the Citadel system.
17 #include <sys/types.h>
19 #if TIME_WITH_SYS_TIME
20 # include <sys/time.h>
24 # include <sys/time.h>
33 #include <libcitadel.h>
36 #include "sysdep_decls.h"
37 #include "citserver.h"
41 #include "internet_addressing.h"
44 #include "parsedate.h"
57 * Wrapper around iconv_open()
58 * Our version adds aliases for non-standard Microsoft charsets
59 * such as 'MS950', aliasing them to names like 'CP950'
61 * tocode Target encoding
62 * fromcode Source encoding
64 iconv_t ctdl_iconv_open(const char *tocode, const char *fromcode)
66 iconv_t ic = (iconv_t)(-1) ;
67 ic = iconv_open(tocode, fromcode);
68 if (ic == (iconv_t)(-1) ) {
69 char alias_fromcode[64];
70 if ( (strlen(fromcode) == 5) && (!strncasecmp(fromcode, "MS", 2)) ) {
71 safestrncpy(alias_fromcode, fromcode, sizeof alias_fromcode);
72 alias_fromcode[0] = 'C';
73 alias_fromcode[1] = 'P';
74 ic = iconv_open(tocode, alias_fromcode);
81 /* This is the non-define version in case of s.b. needing to debug */
82 inline void FindNextEnd (char *bptr, char *end)
84 /* Find the next ?Q? */
85 end = strchr(bptr + 2, '?');
86 if (end == NULL) return NULL;
87 if (((*(end + 1) == 'B') || (*(end + 1) == 'Q')) &&
88 (*(end + 2) == '?')) {
89 /* skip on to the end of the cluster, the next ?= */
90 end = strstr(end + 3, "?=");
93 /* sort of half valid encoding, try to find an end. */
94 end = strstr(bptr, "?=");
98 #define FindNextEnd(bptr, end) { \
99 end = strchr(bptr + 2, '?'); \
101 if (((*(end + 1) == 'B') || (*(end + 1) == 'Q')) && (*(end + 2) == '?')) { \
102 end = strstr(end + 3, "?="); \
103 } else end = strstr(bptr, "?="); \
108 * Handle subjects with RFC2047 encoding such as:
109 * =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=
111 void utf8ify_rfc822_string(char *buf) {
112 char *start, *end, *next, *nextend, *ptr;
117 iconv_t ic = (iconv_t)(-1) ;
118 char *ibuf; /**< Buffer of characters to be converted */
119 char *obuf; /**< Buffer for converted characters */
120 size_t ibuflen; /**< Length of input buffer */
121 size_t obuflen; /**< Length of output buffer */
122 char *isav; /**< Saved pointer to input buffer */
123 char *osav; /**< Saved pointer to output buffer */
126 int illegal_non_rfc2047_encoding = 0;
128 /* Sometimes, badly formed messages contain strings which were simply
129 * written out directly in some foreign character set instead of
130 * using RFC2047 encoding. This is illegal but we will attempt to
131 * handle it anyway by converting from a user-specified default
132 * charset to UTF-8 if we see any nonprintable characters.
135 for (i=0; i<len; ++i) {
136 if ((buf[i] < 32) || (buf[i] > 126)) {
137 illegal_non_rfc2047_encoding = 1;
138 i = len; ///< take a shortcut, it won't be more than one.
141 if (illegal_non_rfc2047_encoding) {
142 const char *default_header_charset = "iso-8859-1";
143 if ( (strcasecmp(default_header_charset, "UTF-8")) && (strcasecmp(default_header_charset, "us-ascii")) ) {
144 ic = ctdl_iconv_open("UTF-8", default_header_charset);
145 if (ic != (iconv_t)(-1) ) {
148 safestrncpy(ibuf, buf, 1024);
149 ibuflen = strlen(ibuf);
151 obuf = (char *) malloc(obuflen);
153 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
154 osav[1024-obuflen] = 0;
163 /* pre evaluate the first pair */
164 nextend = end = NULL;
166 start = strstr(buf, "=?");
168 FindNextEnd (start, end);
170 while ((start != NULL) && (end != NULL))
172 next = strstr(end, "=?");
174 FindNextEnd(next, nextend);
178 /* did we find two partitions */
179 if ((next != NULL) &&
183 while ((ptr < next) &&
189 /* did we find a gab just filled with blanks? */
194 len - (next - start));
196 /* now terminate the gab at the end */
197 delta = (next - end) - 2;
201 /* move next to its new location. */
206 /* our next-pair is our new first pair now. */
211 /* Now we handle foreign character sets properly encoded
214 start = strstr(buf, "=?");
215 FindNextEnd((start != NULL)? start : buf, end);
216 while (start != NULL && end != NULL && end > start)
218 extract_token(charset, start, 1, '?', sizeof charset);
219 extract_token(encoding, start, 2, '?', sizeof encoding);
220 extract_token(istr, start, 3, '?', sizeof istr);
224 if (!strcasecmp(encoding, "B")) { /**< base64 */
225 ibuflen = CtdlDecodeBase64(ibuf, istr, strlen(istr));
227 else if (!strcasecmp(encoding, "Q")) { /**< quoted-printable */
235 if (istr[pos] == '_') istr[pos] = ' ';
239 ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, len);
242 strcpy(ibuf, istr); /**< unknown encoding */
243 ibuflen = strlen(istr);
246 ic = ctdl_iconv_open("UTF-8", charset);
247 if (ic != (iconv_t)(-1) ) {
249 obuf = (char *) malloc(obuflen);
251 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
252 osav[1024-obuflen] = 0;
257 remove_token(end, 0, '?');
258 remove_token(end, 0, '?');
259 remove_token(end, 0, '?');
260 remove_token(end, 0, '?');
261 strcpy(end, &end[1]);
263 snprintf(newbuf, sizeof newbuf, "%s%s%s", buf, osav, end);
272 remove_token(end, 0, '?');
273 remove_token(end, 0, '?');
274 remove_token(end, 0, '?');
275 remove_token(end, 0, '?');
276 strcpy(end, &end[1]);
278 snprintf(newbuf, sizeof newbuf, "%s(unreadable)%s", buf, end);
285 * Since spammers will go to all sorts of absurd lengths to get their
286 * messages through, there are LOTS of corrupt headers out there.
287 * So, prevent a really badly formed RFC2047 header from throwing
288 * this function into an infinite loop.
291 if (passes > 20) return;
293 start = strstr(buf, "=?");
294 FindNextEnd((start != NULL)? start : buf, end);
299 inline void utf8ify_rfc822_string(char *a){};
310 char *inetcfg = NULL;
311 struct spamstrings_t *spamstrings = NULL;
315 * Return nonzero if the supplied name is an alias for this host.
317 int CtdlHostAlias(char *fqdn) {
321 char host[256], type[256];
323 if (fqdn == NULL) return(hostalias_nomatch);
324 if (IsEmptyStr(fqdn)) return(hostalias_nomatch);
325 if (!strcasecmp(fqdn, "localhost")) return(hostalias_localhost);
326 if (!strcasecmp(fqdn, config.c_fqdn)) return(hostalias_localhost);
327 if (!strcasecmp(fqdn, config.c_nodename)) return(hostalias_localhost);
328 if (inetcfg == NULL) return(hostalias_nomatch);
330 config_lines = num_tokens(inetcfg, '\n');
331 for (i=0; i<config_lines; ++i) {
332 extract_token(buf, inetcfg, i, '\n', sizeof buf);
333 extract_token(host, buf, 0, '|', sizeof host);
334 extract_token(type, buf, 1, '|', sizeof type);
336 if ( (!strcasecmp(type, "localhost"))
337 && (!strcasecmp(fqdn, host)))
338 return(hostalias_localhost);
340 if ( (!strcasecmp(type, "directory"))
341 && (!strcasecmp(fqdn, host)))
342 return(hostalias_directory);
344 if ( (!strcasecmp(type, "masqdomain"))
345 && (!strcasecmp(fqdn, host)))
346 return(hostalias_masq);
350 return(hostalias_nomatch);
360 * Return 0 if a given string fuzzy-matches a Citadel user account
362 * FIXME ... this needs to be updated to handle aliases.
364 int fuzzy_match(struct ctdluser *us, char *matchstring) {
368 if ( (!strncasecmp(matchstring, "cit", 3))
369 && (atol(&matchstring[3]) == us->usernum)) {
373 len = strlen(matchstring);
374 for (a=0; !IsEmptyStr(&us->fullname[a]); ++a) {
375 if (!strncasecmp(&us->fullname[a],
385 * Unfold a multi-line field into a single line, removing multi-whitespaces
387 void unfold_rfc822_field(char *field) {
391 striplt(field); /* remove leading/trailing whitespace */
393 /* convert non-space whitespace to spaces, and remove double blanks */
394 for (i=0; i<strlen(field); ++i) {
395 if (field[i]=='\"') quote = 1 - quote;
397 if (isspace(field[i])) field[i] = ' ';
398 while (isspace(field[i]) && isspace(field[i+1])) {
399 strcpy(&field[i+1], &field[i+2]);
408 * Split an RFC822-style address into userid, host, and full name
411 void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
416 strcpy(node, config.c_fqdn);
419 if (rfc822 == NULL) return;
421 /* extract full name - first, it's From minus <userid> */
422 strcpy(name, rfc822);
423 stripout(name, '<', '>');
425 /* strip anything to the left of a bang */
426 while ((!IsEmptyStr(name)) && (haschar(name, '!') > 0))
427 strcpy(name, &name[1]);
429 /* and anything to the right of a @ or % */
430 for (a = 0; a < strlen(name); ++a) {
437 /* but if there are parentheses, that changes the rules... */
438 if ((haschar(rfc822, '(') == 1) && (haschar(rfc822, ')') == 1)) {
439 strcpy(name, rfc822);
440 stripallbut(name, '(', ')');
443 /* but if there are a set of quotes, that supersedes everything */
444 if (haschar(rfc822, 34) == 2) {
445 strcpy(name, rfc822);
446 while ((!IsEmptyStr(name)) && (name[0] != 34)) {
447 strcpy(&name[0], &name[1]);
449 strcpy(&name[0], &name[1]);
450 for (a = 0; a < strlen(name); ++a)
454 /* extract user id */
455 strcpy(user, rfc822);
457 /* first get rid of anything in parens */
458 stripout(user, '(', ')');
460 /* if there's a set of angle brackets, strip it down to that */
461 if ((haschar(user, '<') == 1) && (haschar(user, '>') == 1)) {
462 stripallbut(user, '<', '>');
465 /* strip anything to the left of a bang */
466 while ((!IsEmptyStr(user)) && (haschar(user, '!') > 0))
467 strcpy(user, &user[1]);
469 /* and anything to the right of a @ or % */
470 for (a = 0; a < strlen(user); ++a) {
478 /* extract node name */
479 strcpy(node, rfc822);
481 /* first get rid of anything in parens */
482 stripout(node, '(', ')');
484 /* if there's a set of angle brackets, strip it down to that */
485 if ((haschar(node, '<') == 1) && (haschar(node, '>') == 1)) {
486 stripallbut(node, '<', '>');
489 /* If no node specified, tack ours on instead */
491 (haschar(node, '@')==0)
492 && (haschar(node, '%')==0)
493 && (haschar(node, '!')==0)
495 strcpy(node, config.c_nodename);
500 /* strip anything to the left of a @ */
501 while ((!IsEmptyStr(node)) && (haschar(node, '@') > 0))
502 strcpy(node, &node[1]);
504 /* strip anything to the left of a % */
505 while ((!IsEmptyStr(node)) && (haschar(node, '%') > 0))
506 strcpy(node, &node[1]);
508 /* reduce multiple system bang paths to node!user */
509 while ((!IsEmptyStr(node)) && (haschar(node, '!') > 1))
510 strcpy(node, &node[1]);
512 /* now get rid of the user portion of a node!user string */
513 for (a = 0; a < strlen(node); ++a)
518 /* strip leading and trailing spaces in all strings */
523 /* If we processed a string that had the address in angle brackets
524 * but no name outside the brackets, we now have an empty name. In
525 * this case, use the user portion of the address as the name.
527 if ((IsEmptyStr(name)) && (!IsEmptyStr(user))) {
535 * convert_field() is a helper function for convert_internet_message().
536 * Given start/end positions for an rfc822 field, it converts it to a Citadel
537 * field if it wants to, and unfolds it if necessary.
539 * Returns 1 if the field was converted and inserted into the Citadel message
540 * structure, implying that the source field should be removed from the
543 int convert_field(struct CtdlMessage *msg, int beg, int end) {
556 rfc822 = msg->cm_fields['M']; /* M field contains rfc822 text */
557 for (i = end; i >= beg; --i) {
558 if (rfc822[i] == ':') colonpos = i;
561 if (colonpos < 0) return(0); /* no colon? not a valid header line */
563 key = malloc((end - beg) + 2);
564 safestrncpy(key, &rfc822[beg], (end-beg)+1);
565 key[colonpos - beg] = 0;
566 value = &key[(colonpos - beg) + 1];
567 unfold_rfc822_field(value);
570 * Here's the big rfc822-to-citadel loop.
573 /* Date/time is converted into a unix timestamp. If the conversion
574 * fails, we replace it with the time the message arrived locally.
576 if (!strcasecmp(key, "Date")) {
577 parsed_date = parsedate(value);
578 if (parsed_date < 0L) parsed_date = time(NULL);
579 snprintf(buf, sizeof buf, "%ld", (long)parsed_date );
580 if (msg->cm_fields['T'] == NULL)
581 msg->cm_fields['T'] = strdup(buf);
585 else if (!strcasecmp(key, "From")) {
586 process_rfc822_addr(value, user, node, name);
587 CtdlLogPrintf(CTDL_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name);
588 snprintf(addr, sizeof addr, "%s@%s", user, node);
589 if (msg->cm_fields['A'] == NULL)
590 msg->cm_fields['A'] = strdup(name);
592 if (msg->cm_fields['F'] == NULL)
593 msg->cm_fields['F'] = strdup(addr);
597 else if (!strcasecmp(key, "Subject")) {
598 if (msg->cm_fields['U'] == NULL)
599 msg->cm_fields['U'] = strdup(value);
603 else if (!strcasecmp(key, "To")) {
604 if (msg->cm_fields['R'] == NULL)
605 msg->cm_fields['R'] = strdup(value);
609 else if (!strcasecmp(key, "CC")) {
610 if (msg->cm_fields['Y'] == NULL)
611 msg->cm_fields['Y'] = strdup(value);
615 else if (!strcasecmp(key, "Message-ID")) {
616 if (msg->cm_fields['I'] != NULL) {
617 CtdlLogPrintf(CTDL_WARNING, "duplicate message id\n");
620 if (msg->cm_fields['I'] == NULL) {
621 msg->cm_fields['I'] = strdup(value);
623 /* Strip angle brackets */
624 while (haschar(msg->cm_fields['I'], '<') > 0) {
625 strcpy(&msg->cm_fields['I'][0],
626 &msg->cm_fields['I'][1]);
628 for (i = 0; i<strlen(msg->cm_fields['I']); ++i)
629 if (msg->cm_fields['I'][i] == '>')
630 msg->cm_fields['I'][i] = 0;
636 else if (!strcasecmp(key, "Return-Path")) {
637 if (msg->cm_fields['P'] == NULL)
638 msg->cm_fields['P'] = strdup(value);
642 else if (!strcasecmp(key, "Envelope-To")) {
643 if (msg->cm_fields['V'] == NULL)
644 msg->cm_fields['V'] = strdup(value);
648 else if (!strcasecmp(key, "References")) {
649 if (msg->cm_fields['W'] != NULL) {
650 free(msg->cm_fields['W']);
652 msg->cm_fields['W'] = strdup(value);
656 else if (!strcasecmp(key, "In-reply-to")) {
657 if (msg->cm_fields['W'] == NULL) { /* References: supersedes In-reply-to: */
658 msg->cm_fields['W'] = strdup(value);
665 /* Clean up and move on. */
666 free(key); /* Don't free 'value', it's actually the same buffer */
672 * Convert RFC822 references format (References) to Citadel references format (Weferences)
674 void convert_references_to_wefewences(char *str) {
675 int bracket_nesting = 0;
677 char *moveptr = NULL;
684 if (bracket_nesting < 0) bracket_nesting = 0;
686 if ((ch == '>') && (bracket_nesting == 0) && (*(ptr+1)) && (ptr>str) ) {
690 else if (bracket_nesting > 0) {
696 *moveptr = *(moveptr+1);
700 if (ch == '<') ++bracket_nesting;
707 * Convert an RFC822 message (headers + body) to a CtdlMessage structure.
708 * NOTE: the supplied buffer becomes part of the CtdlMessage structure, and
709 * will be deallocated when CtdlFreeMessage() is called. Therefore, the
710 * supplied buffer should be DEREFERENCED. It should not be freed or used
713 struct CtdlMessage *convert_internet_message(char *rfc822) {
715 struct CtdlMessage *msg;
716 int pos, beg, end, msglen;
721 msg = malloc(sizeof(struct CtdlMessage));
722 if (msg == NULL) return msg;
724 memset(msg, 0, sizeof(struct CtdlMessage));
725 msg->cm_magic = CTDLMESSAGE_MAGIC; /* self check */
726 msg->cm_anon_type = 0; /* never anonymous */
727 msg->cm_format_type = FMT_RFC822; /* internet message */
728 msg->cm_fields['M'] = rfc822;
735 /* Locate beginning and end of field, keeping in mind that
736 * some fields might be multiline
741 msglen = strlen(rfc822);
742 while ( (end < 0) && (done == 0) ) {
744 if ((rfc822[pos]=='\n')
745 && (!isspace(rfc822[pos+1]))) {
749 /* done with headers? */
750 if ( (rfc822[pos]=='\n')
751 && ( (rfc822[pos+1]=='\n')
752 ||(rfc822[pos+1]=='\r')) ) {
757 if (pos >= (msglen-1) ) {
766 /* At this point we have a field. Are we interested in it? */
767 converted = convert_field(msg, beg, end);
769 /* Strip the field out of the RFC822 header if we used it */
771 strcpy(&rfc822[beg], &rfc822[pos]);
775 /* If we've hit the end of the message, bail out */
776 if (pos > strlen(rfc822)) done = 1;
779 /* Follow-up sanity checks... */
781 /* If there's no timestamp on this message, set it to now. */
782 if (msg->cm_fields['T'] == NULL) {
783 snprintf(buf, sizeof buf, "%ld", (long)time(NULL));
784 msg->cm_fields['T'] = strdup(buf);
787 /* If a W (references, or rather, Wefewences) field is present, we
788 * have to convert it from RFC822 format to Citadel format.
790 if (msg->cm_fields['W'] != NULL) {
791 convert_references_to_wefewences(msg->cm_fields['W']);
800 * Look for a particular header field in an RFC822 message text. If the
801 * requested field is found, it is unfolded (if necessary) and returned to
802 * the caller. The field name is stripped out, leaving only its contents.
803 * The caller is responsible for freeing the returned buffer. If the requested
804 * field is not present, or anything else goes wrong, it returns NULL.
806 char *rfc822_fetch_field(char *rfc822, char *fieldname) {
807 char *fieldbuf = NULL;
808 char *end_of_headers;
814 /* Should never happen, but sometimes we get stupid */
815 if (rfc822 == NULL) return(NULL);
816 if (fieldname == NULL) return(NULL);
818 snprintf(fieldhdr, sizeof fieldhdr, "%s:", fieldname);
820 /* Locate the end of the headers, so we don't run past that point */
821 end_of_headers = bmstrcasestr(rfc822, "\n\r\n");
822 if (end_of_headers == NULL) {
823 end_of_headers = bmstrcasestr(rfc822, "\n\n");
825 if (end_of_headers == NULL) return (NULL);
827 field_start = bmstrcasestr(rfc822, fieldhdr);
828 if (field_start == NULL) return(NULL);
829 if (field_start > end_of_headers) return(NULL);
831 fieldbuf = malloc(SIZ);
832 strcpy(fieldbuf, "");
835 ptr = memreadline(ptr, fieldbuf, SIZ-strlen(fieldbuf) );
836 while ( (isspace(ptr[0])) && (ptr < end_of_headers) ) {
837 strcat(fieldbuf, " ");
838 cont = &fieldbuf[strlen(fieldbuf)];
839 ptr = memreadline(ptr, cont, SIZ-strlen(fieldbuf) );
843 strcpy(fieldbuf, &fieldbuf[strlen(fieldhdr)]);
851 /*****************************************************************************
852 * DIRECTORY MANAGEMENT FUNCTIONS *
853 *****************************************************************************/
856 * Generate the index key for an Internet e-mail address to be looked up
859 void directory_key(char *key, char *addr) {
863 for (i=0; !IsEmptyStr(&addr[i]); ++i) {
864 if (!isspace(addr[i])) {
865 key[keylen++] = tolower(addr[i]);
870 CtdlLogPrintf(CTDL_DEBUG, "Directory key is <%s>\n", key);
875 /* Return nonzero if the supplied address is in a domain we keep in
878 int IsDirectory(char *addr, int allow_masq_domains) {
882 extract_token(domain, addr, 1, '@', sizeof domain);
885 h = CtdlHostAlias(domain);
887 if ( (h == hostalias_masq) && allow_masq_domains)
890 if ( (h == hostalias_localhost) || (h == hostalias_directory) ) {
900 * Initialize the directory database (erasing anything already there)
902 void CtdlDirectoryInit(void) {
903 cdb_trunc(CDB_DIRECTORY);
908 * Add an Internet e-mail address to the directory for a user
910 void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) {
913 CtdlLogPrintf(CTDL_DEBUG, "Dir: %s --> %s\n",
914 internet_addr, citadel_addr);
915 if (IsDirectory(internet_addr, 0) == 0) return;
917 directory_key(key, internet_addr);
919 cdb_store(CDB_DIRECTORY, key, strlen(key),
920 citadel_addr, strlen(citadel_addr)+1 );
925 * Delete an Internet e-mail address from the directory.
927 * (NOTE: we don't actually use or need the citadel_addr variable; it's merely
928 * here because the callback API expects to be able to send it.)
930 void CtdlDirectoryDelUser(char *internet_addr, char *citadel_addr) {
933 directory_key(key, internet_addr);
934 cdb_delete(CDB_DIRECTORY, key, strlen(key) );
939 * Look up an Internet e-mail address in the directory.
940 * On success: returns 0, and Citadel address stored in 'target'
941 * On failure: returns nonzero
943 int CtdlDirectoryLookup(char *target, char *internet_addr, size_t targbuflen) {
944 struct cdbdata *cdbrec;
947 /* Dump it in there unchanged, just for kicks */
948 safestrncpy(target, internet_addr, targbuflen);
950 /* Only do lookups for addresses with hostnames in them */
951 if (num_tokens(internet_addr, '@') != 2) return(-1);
953 /* Only do lookups for domains in the directory */
954 if (IsDirectory(internet_addr, 0) == 0) return(-1);
956 directory_key(key, internet_addr);
957 cdbrec = cdb_fetch(CDB_DIRECTORY, key, strlen(key) );
958 if (cdbrec != NULL) {
959 safestrncpy(target, cdbrec->ptr, targbuflen);
969 * Harvest any email addresses that someone might want to have in their
970 * "collected addresses" book.
972 char *harvest_collected_addresses(struct CtdlMessage *msg) {
975 char user[256], node[256], name[256];
980 if (msg == NULL) return(NULL);
984 if (msg->cm_fields['A'] != NULL) {
985 strcat(addr, msg->cm_fields['A']);
987 if (msg->cm_fields['F'] != NULL) {
989 strcat(addr, msg->cm_fields['F']);
991 if (IsDirectory(msg->cm_fields['F'], 0)) {
996 if (is_harvestable) {
1003 if (coll == NULL) return(NULL);
1005 /* Scan both the R (To) and Y (CC) fields */
1006 for (i = 0; i < 2; ++i) {
1007 if (i == 0) field = 'R' ;
1008 if (i == 1) field = 'Y' ;
1010 if (msg->cm_fields[field] != NULL) {
1011 for (j=0; j<num_tokens(msg->cm_fields[field], ','); ++j) {
1012 extract_token(addr, msg->cm_fields[field], j, ',', sizeof addr);
1013 utf8ify_rfc822_string(addr);
1014 process_rfc822_addr(addr, user, node, name);
1015 h = CtdlHostAlias(node);
1016 if ( (h != hostalias_localhost) && (h != hostalias_directory) ) {
1017 coll = realloc(coll, strlen(coll) + strlen(addr) + 4);
1018 if (coll == NULL) return(NULL);
1019 if (!IsEmptyStr(coll)) {
1029 if (IsEmptyStr(coll)) {