12 #include <sys/socket.h>
13 #include <netinet/in.h>
26 * for inet addresses only
29 gethostbyname(char *name)
35 static struct hostent h;
36 static char buf[1024];
37 static char *nptr[Nname+1];
38 static char *aptr[Nname+1];
39 static char addr[Nname][4];
42 t = _sock_ipattr(name);
44 /* connect to server */
45 fd = open("/net/cs", O_RDWR);
48 h_errno = NO_RECOVERY;
52 /* construct the query, always expect an ip# back */
55 snprintf(buf, sizeof buf, "!sys=%s ip=*", name);
58 snprintf(buf, sizeof buf, "!dom=%s ip=*", name);
61 snprintf(buf, sizeof buf, "!ip=%s", name);
65 /* query the server */
66 if(write(fd, buf, strlen(buf)) < 0){
72 for(i = 0; i < sizeof(buf)-1; i += m){
73 m = read(fd, buf+i, sizeof(buf) - 1 - i);
88 if(strcmp(bp, "dom") == 0){
93 } else if(strcmp(bp, "sys") == 0){
96 } else if(strcmp(bp, "ip") == 0){
108 while(*p && *p != ' ')
115 h_errno = HOST_NOT_FOUND;
122 h.h_addr_list = aptr;
124 h.h_addrtype = AF_INET;