-/* Variables for username masquerading: */
- boolean draft_from_masquerading = FALSE;
-static boolean mmailid_masquerading = FALSE;
- boolean username_extension_masquerading = FALSE; /* " from addrsbr.c */
-static char* masquerade = "";
-
-/*
- * 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[] = {
- { "mmdfldir", &mmdfldir },
- { "mmdflfil", &mmdflfil },
- { "uucpldir", &uucpldir },
- { "uucplfil", &uucplfil },
- { "mmdelim1", &mmdlm1 },
- { "mmdelim2", &mmdlm2 },
- { "masquerade", &masquerade },
- { "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)
-{
- const char *cp;
- FILE *fp;
- static int inited = 0;
-
- if (inited++ || (fp = fopen (get_mtsconf_pathname(), "r")) == NULL)
- return;
- mts_read_conf_file(fp);
- fclose (fp);
-
- cp = get_mtsuserconf_pathname();
- if (cp != NULL &&
- ((fp = fopen (get_mtsuserconf_pathname(), "r")) != NULL)) {
- mts_read_conf_file(fp);
- 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;
-}
-
-
-#define QUOTE '\\'
-
-/*
- * Convert escaped values, malloc some new space,
- * and copy string to malloc'ed memory.
- */
-
-static char *
-tailor_value (unsigned 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;
- bp = mh_xmalloc (len);
- memcpy (bp, buffer, len);
-
- return bp;
-}
-
-/*
- * Get the fully qualified name of the local host.
- */
-
-char *
-LocalName (void)
-{
- static char buffer[BUFSIZ] = "";
- struct addrinfo hints, *res;
-#ifdef HAVE_UNAME
- struct utsname name;
-#endif
-
- /* check if we have cached the local name */
- if (buffer[0])
- return buffer;
-
- mts_init ("mts");
-
- memset(buffer, 0, sizeof(buffer));
-#ifdef HAVE_UNAME
- /* first get our local name */
- uname (&name);
- strncpy (buffer, name.nodename, sizeof(buffer) - 1);
-#else
- /* first get our local name */
- gethostname (buffer, sizeof(buffer) - 1);
-#endif
- /* now fully qualify our name */
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_CANONNAME;
- hints.ai_family = PF_UNSPEC;
- if (getaddrinfo(buffer, NULL, &hints, &res) == 0) {
- strncpy(buffer, res->ai_canonname, sizeof(buffer) - 1);
- freeaddrinfo(res);
- }
-
- return buffer;
-}
-