alias.c attach.c base64.c browser.c buffy.c \
charset.c compress.c commands.c complete.c \
compose.c copy.c editmsg.c init.c keymap.c lib.c \
- flags.c filter.c from.c getdomain.c \
- handler.c hcache.c hdrline.c headers.c help.c history.c hook.c \
+ flags.c filter.c from.c handler.c hcache.c hdrline.c headers.c help.c history.c hook.c \
main.c mbox.c mbyte.c mh.c muttlib.c mutt_idna.c mx.c \
pager.c pattern.c postpone.c query.c \
recvattach.c recvcmd.c rfc1524.c rfc3676.c \
+++ /dev/null
-/*
- * Copyright notice from original mutt:
- * [none]
- *
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
-#include <lib-lib/file.h>
-#include "mutt.h"
-
-#ifndef STDC_HEADERS
-int fclose ();
-#endif
-
-/* poor man's version of getdomainname() for systems where it does not return
- * return the DNS domain, but the NIS domain.
- */
-
-static void strip_trailing_dot (char *q)
-{
- char *p = q;
-
- for (; *q; q++)
- p = q;
-
- if (*p == '.')
- *p = '\0';
-}
-
-int getdnsdomainname (char *s, size_t l)
-{
- FILE *f;
- char tmp[1024];
- char *p = NULL;
- char *q;
-
- if ((f = fopen ("/etc/resolv.conf", "r")) == NULL)
- return (-1);
-
- tmp[sizeof (tmp) - 1] = 0;
-
- l--; /* save room for the terminal \0 */
-
- while (fgets (tmp, sizeof (tmp) - 1, f) != NULL) {
- p = tmp;
- while (ISSPACE (*p))
- p++;
- if (m_strncmp("domain", p, 6) == 0 || m_strncmp("search", p, 6) == 0) {
- p += 6;
-
- for (q = strtok (p, " \t\n"); q; q = strtok (NULL, " \t\n"))
- if (strcmp (q, "."))
- break;
-
- if (q) {
- strip_trailing_dot (q);
- m_strcpy(s, l, q);
- safe_fclose (&f);
- return 0;
- }
-
- }
- }
-
- safe_fclose (&f);
- return (-1);
-}
else
Hostname = m_strdup(utsname.nodename);
- if (!p && getdnsdomainname (buffer, sizeof(buffer)) == -1)
+ if (!p && getdnsdomainname(buffer, sizeof(buffer)) == -1)
Fqdn = m_strdup("@");
else
if (*buffer != '@') {
return s;
}
+static inline const char *m_strnextsp(const char *s) {
+ while (*s && !isspace((unsigned char)*s))
+ s++;
+ return s;
+}
+
static inline const char *skipspaces(const char *s) {
while (*s && isspace((unsigned char)*s))
s++;
*/
#include <errno.h>
+#include <ctype.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
#include <lib-lib/macros.h>
#include <lib-lib/mem.h>
#include <lib-lib/str.h>
+#include <lib-lib/file.h>
#include "unix.h"
#include "mutt_signal.h"
#include <imap/imap.h> /* for imap_wait_keepalive EEEEK */
-
/* Extract the real name from /etc/passwd's GECOS field.
* When set, honor the regular expression in rx,
* otherwise assume that the GECOS field is a comma-separated list.
return (pid > 0 && WIFEXITED(rc)) ? WEXITSTATUS(rc) : -1;
}
+
+int getdnsdomainname(char *s, ssize_t n)
+{
+ char tmp[1024];
+ FILE *f;
+
+ if ((f = fopen("/etc/resolv.conf", "r")) == NULL)
+ return -1;
+
+ while (fgets(tmp, sizeof(tmp), f)) {
+ const char *p = skipspaces(tmp);
+
+ if (m_strncmp("domain", p, 6) && m_strncmp("search", p, 6))
+ continue;
+
+ p += 6;
+
+ while (*p) {
+ int trailing_dot;
+ const char *q;
+
+ p = skipspaces(p);
+ q = m_strnextsp(p);
+
+ trailing_dot = q[-1] == '.';
+ if (!trailing_dot || q > p + 1) {
+ m_strncpy(s, n, p, p - q - trailing_dot);
+ safe_fclose(&f);
+ return 0;
+ }
+
+ p = q;
+ }
+ }
+
+ safe_fclose (&f);
+ return -1;
+}
#include <lib-lib/rx.h>
ssize_t mutt_gecos_name(char *dst, ssize_t n, struct passwd *pw, rx_t *rx);
-
+int getdnsdomainname(char *, ssize_t);
/* flags for _mutt_system() */
#define M_DETACH_PROCESS 1 /* detach subprocess from group */
#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK ? 1 : 0)
#endif
-int getdnsdomainname (char *, size_t);
-
/* According to SCO support, this is how to detect SCO */
#if defined (_M_UNIX) || defined (M_OS)
#define SCO