diff options
Diffstat (limited to 'libc/dns/net/getservbyname.c')
-rw-r--r-- | libc/dns/net/getservbyname.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/libc/dns/net/getservbyname.c b/libc/dns/net/getservbyname.c index c95c9b0..c32416c 100644 --- a/libc/dns/net/getservbyname.c +++ b/libc/dns/net/getservbyname.c @@ -25,29 +25,19 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include <sys/cdefs.h> -#include <sys/types.h> -#include <netdb.h> -#include "servent.h" -struct servent * -getservbyname(const char *name, const char *proto) -{ - res_static rs = __res_get_static(); +#include <netdb.h> - if (rs == NULL || proto == NULL || name == NULL) { - errno = EINVAL; - return NULL; - } +#include "servent.h" - rs->servent_ptr = NULL; - while (1) { - struct servent* s = getservent_r(rs); - if (s == NULL) - break; - if ( !strcmp( s->s_name, name ) && !strcmp( s->s_proto, proto ) ) - return s; +struct servent* getservbyname(const char* name, const char* proto) { + res_static rs = __res_get_static(); + rs->servent_ptr = NULL; + struct servent* s; + while ((s = getservent_r(rs)) != NULL) { + if (strcmp(s->s_name, name) == 0 && (proto == NULL || strcmp(s->s_proto, proto) == 0)) { + return s; } - - return NULL; + } + return NULL; } |