34
34
# error broken invariant
35
35
#endif
36
36
37
+ /* Macro to calculate error code returned by hs_get_h_errno */
38
+ #define __HS_GET_H_ERRNO (h_errno ) \
39
+ switch(h_errno) \
40
+ { \
41
+ case HOST_NOT_FOUND: return 1; \
42
+ case NO_DATA: return 2; \
43
+ case NO_RECOVERY: return 3; \
44
+ case TRY_AGAIN: return 4; \
45
+ default: return -1; \
46
+ }
47
+
37
48
#if USE_RES_NQUERY
38
49
39
50
inline static int
@@ -92,39 +103,16 @@ hs_res_close(struct __res_state *s)
92
103
93
104
#if defined(HAVE_DECL_H_ERRNO )
94
105
95
- #if defined(HAVE_STRUCT___RES_STATE_RES_H_ERRNO )
96
-
97
106
inline static int
98
107
hs_get_h_errno (struct __res_state * s )
99
108
{
109
+ #if defined(HAVE_STRUCT___RES_STATE_RES_H_ERRNO )
100
110
assert (s );
101
-
102
- switch (s -> res_h_errno )
103
- {
104
- case HOST_NOT_FOUND : return 1 ;
105
- case NO_DATA : return 2 ;
106
- case NO_RECOVERY : return 3 ;
107
- case TRY_AGAIN : return 4 ;
108
- default : return -1 ;
109
- }
110
- }
111
-
111
+ __HS_GET_H_ERRNO (s -> res_h_errno )
112
112
#else
113
-
114
- inline static int
115
- hs_get_h_errno (struct __res_state * s )
116
- {
117
- switch (h_errno )
118
- {
119
- case HOST_NOT_FOUND : return 1 ;
120
- case NO_DATA : return 2 ;
121
- case NO_RECOVERY : return 3 ;
122
- case TRY_AGAIN : return 4 ;
123
- default : return -1 ;
124
- }
125
- }
126
-
113
+ __HS_GET_H_ERRNO (h_errno )
127
114
#endif
115
+ }
128
116
129
117
#else
130
118
@@ -134,9 +122,9 @@ hs_get_h_errno(struct __res_state *s)
134
122
return -1 ;
135
123
}
136
124
137
- #endif
125
+ #endif /* HAVE_DECL_H_ERRNO */
138
126
139
- #else
127
+ #else /* USE_RES_NQUERY */
140
128
141
129
/* use non-reentrant API */
142
130
@@ -194,14 +182,7 @@ hs_res_close(void *s)
194
182
inline static int
195
183
hs_get_h_errno (void * s )
196
184
{
197
- switch (h_errno )
198
- {
199
- case HOST_NOT_FOUND : return 1 ;
200
- case NO_DATA : return 2 ;
201
- case NO_RECOVERY : return 3 ;
202
- case TRY_AGAIN : return 4 ;
203
- default : return -1 ;
204
- }
185
+ __HS_GET_H_ERRNO (h_errno )
205
186
}
206
187
207
188
#else
@@ -212,8 +193,8 @@ hs_get_h_errno(void *s)
212
193
return -1 ;
213
194
}
214
195
215
- #endif
196
+ #endif /* HAVE_DECL_H_ERRNO */
216
197
217
- #endif
198
+ #endif /* USE_RES_NQUERY */
218
199
219
200
#endif /* HS_RESOLV_H */
0 commit comments