#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:
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);
}