Re-indent hostent.h and res_comp.c
clang-format --style file -i hostent.h res_comp.c
Test: no functional changes
Change-Id: I47b4fdb9b28ee4e76748cd690de2ced08da514d8
diff --git a/resolv/res_comp.c b/resolv/res_comp.c
index 987b228..c194d92 100644
--- a/resolv/res_comp.c
+++ b/resolv/res_comp.c
@@ -79,11 +79,11 @@
#endif
#endif /* LIBC_SCCS and not lint */
-#include <sys/types.h>
-#include <sys/param.h>
-#include <netinet/in.h>
#include <arpa/nameser.h>
#include <ctype.h>
+#include <netinet/in.h>
+#include <sys/param.h>
+#include <sys/types.h>
#ifdef ANDROID_CHANGES
#include "resolv_private.h"
#else
@@ -100,15 +100,11 @@
* 'dst' is a pointer to a buffer of size 'dstsiz' for the result.
* Return size of compressed name or -1 if there was an error.
*/
-int
-dn_expand(const u_char *msg, const u_char *eom, const u_char *src,
- char *dst, int dstsiz)
-{
- int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz);
+int dn_expand(const u_char* msg, const u_char* eom, const u_char* src, char* dst, int dstsiz) {
+ int n = ns_name_uncompress(msg, eom, src, dst, (size_t) dstsiz);
- if (n > 0 && dst[0] == '.')
- dst[0] = '\0';
- return (n);
+ if (n > 0 && dst[0] == '.') dst[0] = '\0';
+ return (n);
}
/*
@@ -116,25 +112,19 @@
* Return the size of the compressed name or -1.
* 'length' is the size of the array pointed to by 'comp_dn'.
*/
-int
-dn_comp(const char *src, u_char *dst, int dstsiz,
- u_char **dnptrs, u_char **lastdnptr)
-{
- return (ns_name_compress(src, dst, (size_t)dstsiz,
- (const u_char **)dnptrs,
- (const u_char **)lastdnptr));
+int dn_comp(const char* src, u_char* dst, int dstsiz, u_char** dnptrs, u_char** lastdnptr) {
+ return (ns_name_compress(src, dst, (size_t) dstsiz, (const u_char**) dnptrs,
+ (const u_char**) lastdnptr));
}
/*
* Skip over a compressed domain name. Return the size or -1.
*/
-int
-dn_skipname(const u_char *ptr, const u_char *eom) {
- const u_char *saveptr = ptr;
+int dn_skipname(const u_char* ptr, const u_char* eom) {
+ const u_char* saveptr = ptr;
- if (ns_name_skip(&ptr, eom) == -1)
- return (-1);
- return (ptr - saveptr);
+ if (ns_name_skip(&ptr, eom) == -1) return (-1);
+ return (ptr - saveptr);
}
/*
@@ -154,98 +144,83 @@
*/
#define PERIOD 0x2e
-#define hyphenchar(c) ((c) == 0x2d)
+#define hyphenchar(c) ((c) == 0x2d)
#define bslashchar(c) ((c) == 0x5c)
#define periodchar(c) ((c) == PERIOD)
#define asterchar(c) ((c) == 0x2a)
-#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \
- || ((c) >= 0x61 && (c) <= 0x7a))
+#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) || ((c) >= 0x61 && (c) <= 0x7a))
#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
-#define underscorechar(c) ((c) == 0x5f)
+#define underscorechar(c) ((c) == 0x5f)
#define borderchar(c) (alphachar(c) || digitchar(c))
#define middlechar(c) (borderchar(c) || hyphenchar(c) || underscorechar(c))
-#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)
+#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)
-int
-res_hnok(const char *dn) {
- int pch = PERIOD, ch = *dn++;
+int res_hnok(const char* dn) {
+ int pch = PERIOD, ch = *dn++;
- while (ch != '\0') {
- int nch = *dn++;
+ while (ch != '\0') {
+ int nch = *dn++;
- if (periodchar(ch)) {
- ;
- } else if (periodchar(pch)) {
- if (!borderchar(ch))
- return (0);
- } else if (periodchar(nch) || nch == '\0') {
- if (!borderchar(ch))
- return (0);
- } else {
- if (!middlechar(ch))
- return (0);
- }
- pch = ch, ch = nch;
- }
- return (1);
+ if (periodchar(ch)) {
+ ;
+ } else if (periodchar(pch)) {
+ if (!borderchar(ch)) return (0);
+ } else if (periodchar(nch) || nch == '\0') {
+ if (!borderchar(ch)) return (0);
+ } else {
+ if (!middlechar(ch)) return (0);
+ }
+ pch = ch, ch = nch;
+ }
+ return (1);
}
/*
* hostname-like (A, MX, WKS) owners can have "*" as their first label
* but must otherwise be as a host name.
*/
-int
-res_ownok(const char *dn) {
- if (asterchar(dn[0])) {
- if (periodchar(dn[1]))
- return (res_hnok(dn+2));
- if (dn[1] == '\0')
- return (1);
- }
- return (res_hnok(dn));
+int res_ownok(const char* dn) {
+ if (asterchar(dn[0])) {
+ if (periodchar(dn[1])) return (res_hnok(dn + 2));
+ if (dn[1] == '\0') return (1);
+ }
+ return (res_hnok(dn));
}
/*
* SOA RNAMEs and RP RNAMEs can have any printable character in their first
* label, but the rest of the name has to look like a host name.
*/
-int
-res_mailok(const char *dn) {
- int ch, escaped = 0;
+int res_mailok(const char* dn) {
+ int ch, escaped = 0;
- /* "." is a valid missing representation */
- if (*dn == '\0')
- return (1);
+ /* "." is a valid missing representation */
+ if (*dn == '\0') return (1);
- /* otherwise <label>.<hostname> */
- while ((ch = *dn++) != '\0') {
- if (!domainchar(ch))
- return (0);
- if (!escaped && periodchar(ch))
- break;
- if (escaped)
- escaped = 0;
- else if (bslashchar(ch))
- escaped = 1;
- }
- if (periodchar(ch))
- return (res_hnok(dn));
- return (0);
+ /* otherwise <label>.<hostname> */
+ while ((ch = *dn++) != '\0') {
+ if (!domainchar(ch)) return (0);
+ if (!escaped && periodchar(ch)) break;
+ if (escaped)
+ escaped = 0;
+ else if (bslashchar(ch))
+ escaped = 1;
+ }
+ if (periodchar(ch)) return (res_hnok(dn));
+ return (0);
}
/*
* This function is quite liberal, since RFC 1034's character sets are only
* recommendations.
*/
-int
-res_dnok(const char *dn) {
- int ch;
+int res_dnok(const char* dn) {
+ int ch;
- while ((ch = *dn++) != '\0')
- if (!domainchar(ch))
- return (0);
- return (1);
+ while ((ch = *dn++) != '\0')
+ if (!domainchar(ch)) return (0);
+ return (1);
}
#ifdef BIND_4_COMPAT
@@ -257,10 +232,18 @@
* __getshort
* Note that one _ comes from C and the others come from us.
*/
-void __putlong(u_int32_t src, u_char *dst) { ns_put32(src, dst); }
-void __putshort(u_int16_t src, u_char *dst) { ns_put16(src, dst); }
+void __putlong(u_int32_t src, u_char* dst) {
+ ns_put32(src, dst);
+}
+void __putshort(u_int16_t src, u_char* dst) {
+ ns_put16(src, dst);
+}
#ifndef __ultrix__
-u_int32_t _getlong(const u_char *src) { return (ns_get32(src)); }
-u_int16_t _getshort(const u_char *src) { return (ns_get16(src)); }
+u_int32_t _getlong(const u_char* src) {
+ return (ns_get32(src));
+}
+u_int16_t _getshort(const u_char* src) {
+ return (ns_get16(src));
+}
#endif /*__ultrix__*/
#endif /*BIND_4_COMPAT*/