/* Services file parser in nss_files module.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
#include GENERIC
-DB_LOOKUP (servbyname, 2 + strlen (name) + strlen (proto),
- (".%s/%s", name, proto),
+DB_LOOKUP (servbyname, 2 + strlen (name) + (proto ? strlen (proto) : 0),
+ (".%s/%s", name, proto ?: ""),
{
/* Must match both protocol (if specified) and name. */
if (proto != NULL && strcmp (result->s_proto, proto))
},
const char *name, const char *proto)
-DB_LOOKUP (servbyport, 21 + strlen (proto), ("=%d/%s", port, proto),
+DB_LOOKUP (servbyport, 21 + (proto ? strlen (proto) : 0),
+ ("=%d/%s", ntohs (port), proto ?: ""),
{
/* Must match both port and protocol. */
if (result->s_port == port
- && strcmp (result->s_proto, proto) == 0)
+ && (proto == NULL
+ || strcmp (result->s_proto, proto) == 0))
break;
}, int port, const char *proto)