X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=getdomain.c;h=204a69363f6b9162bed821856cd772ad7cbe4c97;hp=23b2f48b5f81ade0943aac57c6b54780dda888a7;hb=97677c08933e16e25ecb3c12473ef1efdab7962b;hpb=6833ce8bdca2d64e14485118f2a4417b7e1cb1b1 diff --git a/getdomain.c b/getdomain.c index 23b2f48..204a693 100644 --- a/getdomain.c +++ b/getdomain.c @@ -1,7 +1,21 @@ +/* + * 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 #include #include +#include #include "mutt.h" #ifndef STDC_HEADERS @@ -15,10 +29,10 @@ int fclose (); static void strip_trailing_dot (char *q) { char *p = q; - + for (; *q; q++) p = q; - + if (*p == '.') *p = '\0'; } @@ -30,32 +44,31 @@ int getdnsdomainname (char *s, size_t l) char *p = NULL; char *q; - if ((f = fopen ("/etc/resolv.conf", "r")) == NULL) return (-1); + if ((f = fopen ("/etc/resolv.conf", "r")) == NULL) + return (-1); tmp[sizeof (tmp) - 1] = 0; - l--; /* save room for the terminal \0 */ + l--; /* save room for the terminal \0 */ - while (fgets (tmp, sizeof (tmp) - 1, f) != NULL) - { + while (fgets (tmp, sizeof (tmp) - 1, f) != NULL) { p = tmp; - while (ISSPACE (*p)) p++; - if (mutt_strncmp ("domain", p, 6) == 0 || mutt_strncmp ("search", p, 6) == 0) - { + 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); - strfcpy (s, q, l); - safe_fclose (&f); - return 0; + if (strcmp (q, ".")) + break; + + if (q) { + strip_trailing_dot (q); + m_strcpy(s, l, q); + safe_fclose (&f); + return 0; } - + } }