Scroll to navigation

XDR(3) Manual del Programador de Linux XDR(3)

NOMBRE

xdr - rutinas de biblioteca para la representación externa de datos

SINOPSIS Y DESCRIPCIÓN

Estas rutinas permiten a los programadores de C describir estructuras de datos arbitrarias de una forma independiente de la máquina. Los datos para las llamadas a procedimientos remotos se transmiten usando estas rutinas.

The prototypes below are declared in <rpc/xdr.h> and make use of the following types:

typedef int bool_t;
typedef bool_t (*xdrproc_t) (XDR *, void *,...);

For the declaration of the XDR type, see <rpc/xdr.h>.

bool_t xdr_array(XDR *xdrs, char **arrp, unsigned int *sizep,
                 unsigned int maxsize, unsigned int elsize,
                 xdrproc_t elproc);
A filter primitive that translates between variable-length arrays and their corresponding external representations. The argument arrp is the address of the pointer to the array, while sizep is the address of the element count of the array; this element count cannot exceed maxsize. The argument elsize is the sizeof each of the array's elements, and elproc is an XDR filter that translates between the array elements' C form, and their external representation. This routine returns one if it succeeds, zero otherwise.

bool_t xdr_bool(XDR *xdrs, bool_t *bp);
Una primitiva de filtro que convierte booleanos (enteros de C) a sus representaciones externas y viceversa. Cuando se condifican datos, este filtro produce valores de uno o de cero. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_bytes(XDR *xdrs, char **sp, unsigned int *sizep,
                 unsigned int maxsize);
A filter primitive that translates between counted byte strings and their external representations. The argument sp is the address of the string pointer. The length of the string is located at address sizep; strings cannot be longer than maxsize. This routine returns one if it succeeds, zero otherwise.

bool_t xdr_char(XDR *xdrs, char *cp);
Una primitiva de filtro que convierte caracteres de C a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario. Nota: los caracteres codificados no se empaquetan y cada uno ocupa 4 bytes. Para arrays de caracteres, vale la pena considerar xdr_bytes(), xdr_opaque() o xdr_string().

void xdr_destroy(XDR *xdrs);
Una macro que invoca a la rutina de destrucción asociada con el flujo XDR, xdrs. Usualmente, la destrucción implica la liberación de estructuras de datos privadas asociadas con el flujo. El uso de xdrs después de llamar a xdr_destroy() es indefinido.

bool_t xdr_double(XDR *xdrs, double *dp);
Una primitiva de filtro que convierte números de precisión doble de C (double) a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_enum(XDR *xdrs, enum_t *ep);
Una primitiva de filtro que convierte enumerados de C (enums) (enteros en realidad) a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_float(XDR *xdrs, float *fp);
Una primitiva de filtro que convierte números flotantes de C (floats) a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

void xdr_free(xdrproc_t proc, char *objp);
Rutina genérica de liberación. El primer argumento es la rutina XDR para que libera el objeto. El segundo argumento es un puntero al propio objeto. Nota: no se libera el puntero pasado a esta rutina, sino a lo que él apunta (de forma recursiva).

unsigned int xdr_getpos(XDR *xdrs);
Una macro que llama a la rutina "obtener posición" asociada con el flujo XDR, xdrs. La rutina devuelve un entero sin signo que indica la posición en el flujo de bytes XDR. Una caracterísitica deseable de los flujos XDR es que la aritmética simple funcione con este número, aunque las instancias de flujos XDR no necesitan garantizar esto.

long *xdr_inline(XDR *xdrs, int len);
Una macro que llama a la rutina "en línea" asociada con el flujo XDR, xdrs. La rutina devuelve un puntero a una porción contigua del buffer del flujo. len es la longitud en bytes del buffer deseado. Nota: el puntero se convierte al tipo long *.
Cuidado: xdr_inline() puede devolver NULL (0) si no puede reservar una porción contigua de buffer. Por lo tanto, el comportamiento puede varias entre instancias de flujo. Existe por el bien de la eficiencia.

bool_t xdr_int(XDR *xdrs, int *ip);
Una primitiva de filtro que convierte enteros de C a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_long(XDR *xdrs, long *lp);
Una primitiva de filtro que convierte enteros largos de C (long) a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

void xdrmem_create(XDR *xdrs, char *addr, unsigned int size,
                   enum xdr_op op);
Esta rutina inicializa el objeto de flujo XDR apuntado por xdrs. Los datos del flujo se escriben en, o se leen de, una porción de memoria en la posición addr cuya longitud no es mayor que size bytes. El op determina la dirección del flujo XDR (bien XDR_ENCODE, XDR_DECODE o XDR_FREE).

bool_t xdr_opaque(XDR *xdrs, char *cp, unsigned int cnt);
A filter primitive that translates between fixed size opaque data and its external representation. The argument cp is the address of the opaque object, and cnt is its size in bytes. This routine returns one if it succeeds, zero otherwise.

bool_t xdr_pointer(XDR *xdrs, char **objpp,
                   unsigned int objsize, xdrproc_t xdrobj);
Como xdr_reference() salvo que serializa punteros NULL, mientras que xdr_reference() no lo hace. Por tanto, xdr_pointer() puede representar estructuras de datos recursivas, tales como árboles binarios o listas enlazadas.

void xdrrec_create(XDR *xdrs, unsigned int sendsize,
                   unsigned int recvsize, char *handle,
                   int (*readit) (char *, char *, int),
                   int (*writeit) (char *, char *, int));
This routine initializes the XDR stream object pointed to by xdrs. The stream's data is written to a buffer of size sendsize; a value of zero indicates the system should use a suitable default. The stream's data is read from a buffer of size recvsize; it too can be set to a suitable default by passing a zero value. When a stream's output buffer is full, writeit is called. Similarly, when a stream's input buffer is empty, readit is called. The behavior of these two routines is similar to the system calls read(2) and write(2), except that handle is passed to the former routines as the first argument. Note: the XDR stream's op field must be set by the caller.
Warning: to read from an XDR stream created by this API, you'll need to call xdrrec_skiprecord() first before calling any other XDR APIs. This inserts additional bytes in the stream to provide record boundary information. Also, XDR streams created with different xdr*_create APIs are not compatible for the same reason.

bool_t xdrrec_endofrecord(XDR *xdrs, int sendnow);
Esta rutina sólo puede llamarse sobre flujos creados por xdrrec_create(). Los datos del buffer de salida se marcan como un registro terminado y, opcionalmente, se escribe el buffer de salida si sendnow no es cero. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdrrec_eof(XDR *xdrs);
Sólo pueda llamarse a esta rutina sobre flujos creados por xdrrec_create(). Después de consumir el resto del registro actual en el flujo, esta rutina devuelve uno si el flujo no tiene más datos de entrada y cero en caso contrario.

bool_t xdrrec_skiprecord(XDR *xdrs);
Sólo pueda llamarse a esta rutina sobre flujos creados por xdrrec_create(). Le dice a la implementación XDR que se debería descartar el resto del registro actual en el buffer de entrada del flujo. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_reference(XDR *xdrs, char **pp, unsigned int size,
                     xdrproc_t proc);
A primitive that provides pointer chasing within structures. The argument pp is the address of the pointer; size is the sizeof the structure that *pp points to; and proc is an XDR procedure that filters the structure between its C form and its external representation. This routine returns one if it succeeds, zero otherwise.
Warning: this routine does not understand null pointers. Use xdr_pointer() instead.

xdr_setpos(XDR *xdrs, unsigned int pos);
A macro that invokes the set position routine associated with the XDR stream xdrs. The argument pos is a position value obtained from xdr_getpos(). This routine returns one if the XDR stream could be repositioned, and zero otherwise.
Cuidado: es difícil reposicionar algunos tipos de flujos XDR, por lo que esta rutina puede fallar con un tipo de flujo y tener éxito con otro.

bool_t xdr_short(XDR *xdrs, short *sp);
Una primitiva de filtro que convierte enteros cortos de C (short) a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

void xdrstdio_create(XDR *xdrs, FILE *file, enum xdr_op op);
This routine initializes the XDR stream object pointed to by xdrs. The XDR stream data is written to, or read from, the stdio stream file. The argument op determines the direction of the XDR stream (either XDR_ENCODE, XDR_DECODE, or XDR_FREE).
Cuidado: la rutina de destrucción asociada con tales flujos XDR llama a fflush() sobre el flujo file, pero nunca a fclose().

bool_t xdr_string(XDR *xdrs, char **sp, unsigned int maxsize);
Una primitiva de filtro que convierte cadenas de C en sus correspondientes representaciones externas y viceversa. Las candenas no pueden ser más largas de maxsize. Nota: sp es la dirección del puntero a la cadena. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_u_char(XDR *xdrs, unsigned char *ucp);
Una primitiva de filtro que convierte caracteres sin signo de C (unsigned char) a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_u_int(XDR *xdrs, unsigned *up);
Una primitiva de filtro que convierte enteros sin signo de C (unsigned) a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_u_long(XDR *xdrs, unsigned long *ulp);
Una primitiva de filtro que convierte enteros largos sin signo de C (unsigned long) a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_u_short(XDR *xdrs, unsigned short *usp);
Una primitiva de filtro que convierte enteros cortos sin signo de C (unsigned short) a sus representaciones externas y viceversa. Esta rutina devuelve uno si tiene éxito y cero en caso contrario.

bool_t xdr_union(XDR *xdrs, int *dscmp, char *unp,
                 struct xdr_discrim *choices,
                 xdrproc_t defaultarm);     /* may equal NULL */
A filter primitive that translates between a discriminated C union and its corresponding external representation. It first translates the discriminant of the union located at dscmp. This discriminant is always an enum_t. Next the union located at unp is translated. The argument choices is a pointer to an array of xdr_discrim() structures. Each structure contains an ordered pair of [value,proc]. If the union's discriminant is equal to the associated value, then the proc is called to translate the union. The end of the xdr_discrim() structure array is denoted by a routine of value NULL. If the discriminant is not found in the choices array, then the defaultarm procedure is called (if it is not NULL). Returns one if it succeeds, zero otherwise.

bool_t xdr_vector(XDR *xdrs, char *arrp, unsigned int size,
                  unsigned int elsize, xdrproc_t elproc);
A filter primitive that translates between fixed-length arrays and their corresponding external representations. The argument arrp is the address of the pointer to the array, while size is the element count of the array. The argument elsize is the sizeof each of the array's elements, and elproc is an XDR filter that translates between the array elements' C form, and their external representation. This routine returns one if it succeeds, zero otherwise.

bool_t xdr_void(void);
This routine always returns one. It may be passed to RPC routines that require a function argument, where nothing is to be done.

bool_t xdr_wrapstring(XDR *xdrs, char **sp);
A primitive that calls xdr_string(xdrs, sp,MAXUN.UNSIGNED ); where MAXUN.UNSIGNED is the maximum value of an unsigned integer. xdr_wrapstring() is handy because the RPC package passes a maximum of two XDR routines as arguments, and xdr_string(), one of the most frequently used primitives, requires three. Returns one if it succeeds, zero otherwise.

ATRIBUTOS

Para obtener una explicación de los términos usados en esta sección, véase attributes(7).

Interfaz Atributo Valor
xdr_array(), xdr_bool(), xdr_bytes(), xdr_char(), xdr_destroy(), xdr_double(), xdr_enum(), xdr_float(), xdr_free(), xdr_getpos(), xdr_inline(), xdr_int(), xdr_long(), xdrmem_create(), xdr_opaque(), xdr_pointer(), xdrrec_create(), xdrrec_eof(), xdrrec_endofrecord(), xdrrec_skiprecord(), xdr_reference(), xdr_setpos(), xdr_short(), xdrstdio_create(), xdr_string(), xdr_u_char(), xdr_u_int(), xdr_u_long(), xdr_u_short(), xdr_union(), xdr_vector(), xdr_void(), xdr_wrapstring() Seguridad del hilo Multi-hilo seguro

VÉASE TAMBIÉN

rpc(3)

Los siguientes manuales:

eXternal Data Representation Standard: Protocol Specification
eXternal Data Representation: Sun Technical Notes
XDR: External Data Representation Standard, RFC 1014, Sun Microsystems, Inc., USC-ISI.

COLOFÓN

Esta página es parte de la versión 5.10 del proyecto Linux man-pages. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en https://www.kernel.org/doc/man-pages/.

TRADUCCIÓN

La traducción al español de esta página del manual fue creada por Juan Piernas <piernas@ditec.um.es>

Esta traducción es documentación libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD.

Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a debian-l10n-spanish@lists.debian.org.

15 Septiembre 2017