-
-
Notifications
You must be signed in to change notification settings - Fork 3
qgetservbyname.3
qgetservent, qgetservbyname, qgetservbyport, qsetservent, qendservent - get service entry
#include <qgetpwgr.h>
struct servent *qgetservent(void);
struct servent *qgetservbyname(const char *name, const char *proto);
struct servent *qgetservbyport(int port, const char *proto);
void qsetservent(int stayopen);
void endservent(void);
The qgetservent() function reads the next entry from the services database (see services(5)) and returns a servent structure containing the broken-out fields from the entry.
The qgetservbyname() function returns a servent structure for the entry from the services database that matches the service name using protocol proto. If proto is NULL, any protocol will be matched.
The qgetservbyport() function returns a servent structure for the entry from the database that matches the port port (given in network byte order) using protocol proto. If proto is NULL, any protocol will be matched.
The qsetservent() function rewinds to the beginning of the services database.
The qendservent() function is used to close the services database after all processing has been performed.
The servent structure is defined in <netdb.h> as follows:
struct servent {
char *s_name; /* official service name */
char **s_aliases; /* alias list */
int s_port; /* port number */
char *s_proto; /* protocol to use */
}
The members of the servent structure are:
s_name
The official name of the service.
s_aliases
A NULL-terminated list of alternative names for the service.
s_port
The port number for the service given in network byte order.
s_proto
The name of the protocol to use with this service.
The qgetservent(), qgetservbyname(), and qgetservbyport() functions return a pointer to a statically allocated servent structure, or NULL if an error occurs or the end of the file is reached.
/etc/services
services database file
qgetservent_r(3), services(5)