.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 19:19:11 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Wed Oct 18 20:23:54 1995 by Martin Schulze .\" Modified Mon Apr 22 01:50:54 1996 by Martin Schulze .\" 2001-07-25 added a clause about NULL proto (Martin Michlmayr or David N. Welton) .\" Traducción revisada por Miguel Pérez Ibars el 19-marzo-2005 .\" .TH GETSERVENT 3 "25 julio 2001" "BSD" "Manual del Programador de Linux" .SH NOMBRE getservent, getservbyname, getservbyport, setservent, endservent \- obtener valores de servicios .SH SINOPSIS .nf .B #include .sp .B struct servent *getservent(void); .sp .BI "struct servent *getservbyname(const char *" name ", const char *" proto ); .sp .BI "struct servent *getservbyport(int " port ", const char *" proto ); .sp .BI "void setservent(int " stayopen ); .sp .B void endservent(void); .fi .SH DESCRIPCIÓN La función \fBgetservent()\fP lee la siguiente línea del fichero \fI/etc/services\fP y devuelve una estructura \fIservent\fP que contiene en sus campos los campos de la línea. Si es necesario, se abre el fichero \fI/etc/services\fP. .PP La función \fBgetservbyname()\fP devuelve una estructura \fIservent\fP conteniendo los campos de la línea de \fI/etc/services\fP que contiene el servicio \fIname\fP y usa el protocolo \fIproto\fP. Si \fIproto\fP vale NULL, cualquier protocolo se dará como válido. .PP La función \fBgetservbyport()\fP devuelve una estructura de tipo \fIservent\fP con los datos de la línea que contiene el puerto \fIport\fP (con los bytes en el orden de red) y usa el protocolo \fIproto\fP. Si \fIproto\fP vale NULL, cualquier protocolo se dará como válido. .PP La función \fBsetservent()\fP abre y reinicia el fichero \fI/etc/services\fP. Si \fIstayopen\fP es verdadero (1), entonces no se cerrará el fichero entre llamadas a las funciones \fBgetservbyname()\fP y \fBgetservbyport()\fP. .PP La función \fBendservent()\fP cierra el fichero \fI/etc/services\fP. .PP La estructura \fIservent\fP está definida en \fI\fP como sigue: .sp .RS .nf .ne 6 .ta 8n 16n 32n struct servent { char *s_name; /* nombre oficial del servicio */ char **s_aliases; /* lista de alias */ int s_port; /* número de puerto */ char *s_proto; /* protocolo a usar */ } .ta .fi .RE .PP Los miembros de la estructura \fIservent\fP son: .TP .I s_name El nombre oficial del servicio. .TP .I s_aliases Una lista terminada en cero de nombres alternativos para el servicio. .TP .I s_port El numero de puerto para el servicio, con sus bytes en el orden de red. .TP .I s_proto El nombre del protoclo a usar con este servicio. .SH "VALOR DEVUELTO" Las funciones \fBgetservent()\fP, \fBgetservbyname()\fP y \fBgetservbyport()\fP devuelve una estructura de tipo \fIservent\fP, o un puntero NULL si ha ocurrido un error o se ha alcanzado el final del fichero. .SH FICHEROS .TP .I /etc/services Fichero de base de datos de servicios .SH "CONFORME A" BSD 4.3 .SH "VÉASE TAMBIÉN" .BR getprotoent "(3), " getnetent "(3), " services (5)