no retries or perror if EADDRNOTAVAIL, so can fail gracefully if no net
[unix-history] / usr / src / lib / libc / net / res_comp.c
index 08dee18..c1a0d9c 100644 (file)
@@ -1,11 +1,17 @@
+/*
+ * 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_comp.c 4.2 (Berkeley) %G%";
-#endif
+static char sccsid[] = "@(#)res_comp.c 5.3 (Berkeley) %G%";
+#endif not lint
 
 #include <sys/types.h>
 #include <stdio.h>
 #include <ctype.h>
 
 #include <sys/types.h>
 #include <stdio.h>
 #include <ctype.h>
-#include <nameser.h>
+#include <arpa/nameser.h>
 
 
 /*
 
 
 /*
@@ -224,3 +230,52 @@ dn_find(exp_dn, msg, dnptrs, lastdnptr)
        }
        return (-1);
 }
        }
        return (-1);
 }
+
+/*
+ * Routines to insert/extract short/long's. Must account for byte
+ * order and non-alignment problems. This code at least has the
+ * advantage of being portable.
+ */
+
+u_short
+getshort(msgp)
+       char *msgp;
+{
+       register u_char *p = (u_char *) msgp;
+
+       return ((*p++ << 8) | *p);
+}
+
+u_long
+getlong(msgp)
+       char *msgp;
+{
+       register u_char *p = (u_char *) msgp;
+       register u_long u;
+
+       u = *p++; u <<= 8;
+       u |= *p++; u <<= 8;
+       u |= *p++; u <<= 8;
+       return (u | *p);
+}
+
+
+putshort(s, msgp)
+       register u_short s;
+       register char *msgp;
+{
+
+       msgp[1] = s;
+       msgp[0] = s >> 8;
+}
+
+putlong(l, msgp)
+       register u_long l;
+       register char *msgp;
+{
+
+       msgp[3] = l;
+       msgp[2] = (l >>= 8);
+       msgp[1] = (l >>= 8);
+       msgp[0] = l >> 8;
+}