]> andersk Git - moira.git/commitdiff
remove dependancy on resolver internals
authormar <mar>
Fri, 8 Mar 1991 11:29:35 +0000 (11:29 +0000)
committermar <mar>
Fri, 8 Mar 1991 11:29:35 +0000 (11:29 +0000)
lib/fixhost.c

index dae2acc3057c5464aca63efca08e340331fb426e..50c39080f8cf28503f0d8db1f7b44738f4273a2e 100644 (file)
@@ -16,20 +16,14 @@ static char *rcsid_fixhost_c = "$Header$";
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include <arpa/nameser.h>
-#if defined(sun) || defined(AIX386)
-#include <resolv.h>
-#else
-#include <arpa/resolv.h>
-#endif
 #include <netdb.h>
 #include <stdio.h>
 #include <strings.h>
 #include <ctype.h>
+#include <moira.h>
 
 extern char *malloc();
 extern char *realloc();
-extern char *strsave();
 
 /*
  * Canonicalize hostname:
@@ -78,7 +72,18 @@ canonicalize_hostname(host)
            has_dot |= (c == '.');
        }
        if (!has_dot) {
-           (void) sprintf(tbuf, "%s.%s", host, _res.defdname);
+           static char *domain = NULL;
+
+           if (domain == NULL) {
+               gethostname(tbuf, sizeof(tbuf));
+               hp = gethostbyname(tbuf);
+               cp = index(hp->h_name, '.');
+               if (cp)
+                 domain = strsave(++cp);
+               else
+                 domain = "";
+           }
+           (void) sprintf(tbuf, "%s.%s", host, domain);
            free(host);
            host = strsave(tbuf);
        }
This page took 0.131354 seconds and 5 git commands to generate.