-/* Variables for username masquerading: */
- boolean draft_from_masquerading = FALSE; /* also used from post.c */
-static boolean mmailid_masquerading = FALSE;
- boolean username_extension_masquerading = FALSE; /* " from addrsbr.c */
-static char* masquerade = "";
-
-/*
- * MTS specific variables
- */
-#if defined(SMTPMTS)
-static char *sm_method = "smtp";
-int sm_mts = MTS_SMTP;
-char *hostable = nmhetcdir(/hosts);
-char *sendmail = SENDMAILPATH;
-#endif
-
-/*
- * SMTP/POP stuff
- */
-char *clientname = NULL;
-char *servers = "localhost \01localnet";
-char *pophost = "";
-
-/*
- * BBoards-specific variables
- */
-char *bb_domain = "";
-
-
-/*
- * POP BBoards-specific variables
- */
-#ifdef BPOP
-char *popbbhost = "";
-char *popbbuser = "";
-char *popbblist = nmhetcdir(/hosts.popbb);
-#endif /* BPOP */
-
-/*
- * Global MailDelivery file
- */
-char *maildelivery = nmhetcdir(/maildelivery);
-
-
-/*
- * Aliasing Facility (doesn't belong here)
- */
-int Everyone = NOTOK;
-static char *everyone = "-1";
-char *NoShell = "";
-
-/*
- * Customize the MTS settings for nmh by adjusting
- * the file mts.conf in the nmh etc directory.
- */
-
-struct bind {
- char *keyword;
- char **value;
-};
-
-static struct bind binds[] = {
- { "localname", &localname },
- { "localdomain", &localdomain },
- { "systemname", &systemname },
- { "mmdfldir", &mmdfldir },
- { "mmdflfil", &mmdflfil },
- { "uucpldir", &uucpldir },
- { "uucplfil", &uucplfil },
- { "mmdelim1", &mmdlm1 },
- { "mmdelim2", &mmdlm2 },
- { "masquerade", &masquerade },
-
-#if defined(SMTPMTS)
- { "mts", &sm_method },
- { "hostable", &hostable },
- { "sendmail", &sendmail },
-#endif
-
- { "clientname", &clientname },
- { "servers", &servers },
- { "pophost", &pophost },
- { "bbdomain", &bb_domain },
-
-#ifdef BPOP
- { "popbbhost", &popbbhost },
- { "popbbuser", &popbbuser },
- { "popbblist", &popbblist },
-#endif
-
-#ifdef NNTP
- { "nntphost", &popbbhost },
-#endif
-
- { "maildelivery", &maildelivery },
- { "everyone", &everyone },
- { "noshell", &NoShell },
- { NULL, NULL }
-};
-
-
-/*
- * Read the configuration file for the nmh interface
- * to the mail transport system (MTS).
- */
-
-void
-mts_init (char *name)
-{
- char *bp, *cp, buffer[BUFSIZ];
- struct bind *b;
- FILE *fp;
- static int inited = 0;
-
- if (inited++ || (fp = fopen (mtsconf, "r")) == NULL)
- return;
-
- while (fgets (buffer, sizeof(buffer), fp)) {
- if (!(cp = strchr(buffer, '\n')))
- break;
- *cp = 0;
- if (*buffer == '#' || *buffer == '\0')
- continue;
- if (!(bp = strchr(buffer, ':')))
- break;
- *bp++ = 0;
- while (isspace (*bp))
- *bp++ = 0;
-
- for (b = binds; b->keyword; b++)
- if (!strcmp (buffer, b->keyword))
- break;
- if (b->keyword && (cp = tailor_value (bp)))
- *b->value = cp;
- }
-
- fclose (fp);
-
- Everyone = atoi (everyone);
-
- if (strstr(masquerade, "draft_from") != NULL)
- draft_from_masquerading = TRUE;
-
- if (strstr(masquerade, "mmailid") != NULL)
- mmailid_masquerading = TRUE;
-
- if (strstr(masquerade, "username_extension") != NULL)
- username_extension_masquerading = TRUE;
-
-#ifdef SMTPMTS
- if (strcmp(sm_method, "smtp") == 0)
- sm_mts = MTS_SMTP;
- else if (strcmp(sm_method, "sendmail") == 0)
- sm_mts = MTS_SENDMAIL;
- else {
- advise(NULL, "unsupported \"mts\" value in mts.conf: %s", sm_method);
- sm_mts = MTS_SMTP;
- }
-#endif
-}
-
-
-#define QUOTE '\\'
-
-/*
- * Convert escaped values, malloc some new space,
- * and copy string to malloc'ed memory.
- */
-
-static char *
-tailor_value (char *s)
-{
- int i, r;
- char *bp;
- char buffer[BUFSIZ];
- size_t len;
-
- for (bp = buffer; *s; bp++, s++) {
- if (*s != QUOTE) {
- *bp = *s;
- } else {
- switch (*++s) {
- case 'b': *bp = '\b'; break;
- case 'f': *bp = '\f'; break;
- case 'n': *bp = '\n'; break;
- case 't': *bp = '\t'; break;
-
- case 0: s--;
- case QUOTE:
- *bp = QUOTE;
- break;
-
- default:
- if (!isdigit (*s)) {
- *bp++ = QUOTE;
- *bp = *s;
- }
- r = *s != '0' ? 10 : 8;
- for (i = 0; isdigit (*s); s++)
- i = i * r + *s - '0';
- s--;
- *bp = toascii (i);
- break;
- }
- }
- }
- *bp = 0;
-
- len = strlen (buffer) + 1;
- if ((bp = malloc (len)))
- memcpy (bp, buffer, len);
-
- return bp;
-}