one too many levels of indirection (from ks@purdue)
[unix-history] / usr / src / lib / libc / net / res_send.c
index d0a1f66..8b7e02e 100644 (file)
@@ -1,6 +1,12 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)res_send.c 4.1 (Berkeley) %G%";
-#endif
+static char sccsid[] = "@(#)res_send.c 5.4 (Berkeley) %G%";
+#endif not lint
 
 /*
  * Send query to name server and wait for reply.
 
 /*
  * Send query to name server and wait for reply.
@@ -12,12 +18,12 @@ static char sccsid[] = "@(#)res_send.c      4.1 (Berkeley) %G%";
 #include <netinet/in.h>
 #include <stdio.h>
 #include <errno.h>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <errno.h>
-#include <nameser.h>
-#include <resolv.h>
+#include <arpa/nameser.h>
+#include <arpa/resolv.h>
 
 extern int errno;
 
 
 extern int errno;
 
-sendquery(buf, buflen, answer, anslen)
+res_send(buf, buflen, answer, anslen)
        char *buf;
        int buflen;
        char *answer;
        char *buf;
        int buflen;
        char *answer;
@@ -33,13 +39,11 @@ sendquery(buf, buflen, answer, anslen)
        HEADER *anhp = (HEADER *) answer;
 
        if (_res.options & RES_DEBUG) {
        HEADER *anhp = (HEADER *) answer;
 
        if (_res.options & RES_DEBUG) {
-               printf("sendquery()\n");
+               printf("res_send()\n");
                p_query(buf);
        }
                p_query(buf);
        }
-       if (!(_res.options & RES_INIT)) {
-               if (!res_init())
-                       return (-1);
-       }
+       if (!(_res.options & RES_INIT))
+               res_init();
        s = -1;
        v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
        id = hp->id;
        s = -1;
        v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
        id = hp->id;
@@ -143,12 +147,7 @@ sendquery(buf, buflen, answer, anslen)
                                 * response from old query, ignore it
                                 */
                                if (_res.options & RES_DEBUG) {
                                 * response from old query, ignore it
                                 */
                                if (_res.options & RES_DEBUG) {
-                                       int f;
-
                                        printf("old answer:\n");
                                        printf("old answer:\n");
-                                       f = creat("ro", 0644);
-                                       write(f, answer, resplen);
-                                       close(f);
                                        p_query(answer);
                                }
                                continue;
                                        p_query(answer);
                                }
                                continue;
@@ -170,7 +169,10 @@ sendquery(buf, buflen, answer, anslen)
                        printf("got answer:\n");
                        p_query(answer);
                }
                        printf("got answer:\n");
                        p_query(answer);
                }
+               (void) close(s);
                return (resplen);
        }
                return (resplen);
        }
+       (void) close(s);
+       errno = ETIMEDOUT;
        return (-1);
 }
        return (-1);
 }