*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: getservent | Section: 3 | Source: Digital UNIX | File: getservent.3.gz
getservent(3) Library Functions Manual getservent(3) NAME getservent, getservent_r - Get a services file entry from the /etc/ser- vices file. LIBRARY Standard C Library (libc.so, libc.a) SYNOPSIS #include <netdb.h> struct servent *getservent(void); [Digital] The following obsolete function is supported in order to maintain backward compatibility with previous versions of the operating system. You should not use it in new designs. int getservent_r( struct servent *serv, struct servent_data *serv_data); STANDARDS Interfaces documented on this reference page conform to industry stan- dards as follows: getservent(): XPG4-UNIX Refer to the standards(5) reference page for more information about in- dustry standards and associated tags. PARAMETERS [Digital] For getservent_r() only, this points to the servent struc- ture. The netdb.h header file defines the servent structure. [Digi- tal] For getservent_r() only, this points to the servent_data struc- ture. The netdb.h header file defines the servent_data structure. DESCRIPTION The getservent() (get service entry) function opens and reads the next line of either the local /etc/services file or the NIS distributed ser- vices file for the requested information. To determine which file or files to search, and in which order, the system uses the switches in the /etc/svc.conf file. An application program can use the getservent() function to retrieve information about network services and the protocol ports they use. The getservent() function returns a pointer to a servent structure, which contains fields for a line of information from the network ser- vices database file. The servent structure is defined in the netdb.h header file as follows: struct servent { char *s_name; /* official service name */ char **s_aliases; /* alias list */ int s_port; /* port # */ char *s_proto; /* protocol to use */ }; The network services database file remains open after a call by the getservent() function. Use the endservent() function to close the net- work services database file. Use the setservent() function to rewind. NOTES The getservent() function returns a pointer to thread-specific data. Subsequent calls to this or a related function from the same thread overwrite this data. [Digital] The getservent_r() function is an obsolete reentrant version of the getservent() function. It is supported in order to maintain backward compatibility with previous versions of the operating system and should not be used in new designs. Note that you must zero-fill the servent_data structure before its first access by the getser- vent_r() function. RETURN VALUES Upon successful completion, the getservent() function returns a pointer to a servent structure. If it fails or reaches the end of the network services database file, it returns a null pointer. [Digital] Upon successful completion, the getservent_r() function stores the servent structure in the location pointed to by serv, and returns a value of 0 (zero). Upon failure, it returns a value of -1. ERRORS Current industry standards do not define error values for the getser- vent() function. [Digital] If any of the following conditions occurs, the getser- vent_r() function sets errno to the corresponding value: The serv or serv_data parameter is invalid. The search failed. [Digital] In addition, if the function fails to open the file, it sets errno to indicate the cause of the failure. FILES The DARPA Internet network service name database file. Each record in the file occupies a single line and has four fields: the official ser- vice name, the port number, the protocol name, and aliases. The data- base service selection configuration file. RELATED INFORMATION Functions: getservbyport(3), getservbyname(3), endservent(3), setser- vent(3). Files: services(4), svc.conf(4). Networks: nis_intro(7). Standards: standards(5). delim off getservent(3)

Navigation Options