up | Inhaltsverzeichniss | Kommentar

Manual page for T_ALLOC(3N)

t_alloc - allocate a library structure

SYNOPSIS

#include <tiuser.h>

char *t_alloc(fd, struct_type, fields)
int fd;
int struct_type;
int fields;

DESCRIPTION

t_alloc() dynamically allocates memory for the various transport function argument structures as specified below. t_alloc() allocates memory for the specified structure and for buffers referenced by the structure.

The structure to allocate is specified by struct_type, and can be one of the following (each of of these structures may be used as an argument to one or more transport functions):

T_BIND		 struct t_bind
T_CALL		 struct t_call
T_OPTMGMT	 struct t_optmgmt
T_DIS 		 struct t_discon
T_UNITDATA 	 struct t_unitdata
T_UDERROR	 struct t_uderr
T_INFO		 struct t_info

Each of the above structures, except T_INFO, contains at least one field of type `struct netbuf'. The maxlen, len, and buf members of the netbuf structure are described in t_accept.3n For each field of this type, the user may specify that the buffer for that field should be allocated as well. The fields argument specifies this option, where the argument is the bitwise-OR of any of the following:

T_ADDR
The addr field of the t_bind, t_call, t_unitdata, or t_uderr structures.
T_OPT
The opt field of the t_optmgmt, t_call, t_unitdata, or t_uderr structures.
T_UDATA
The udata field of the t_call, t_discon, or t_unitdata structures.
T_ALL
All relevant fields of the given structure.

For each field specified in fields, t_alloc() allocates memory for the buffer associated with the field, and initializes the buf pointer and maxlen field accordingly. The length of the buffer allocated is based on the same size information returned to the user on t_open.3n and t_getinfo.3n Thus, fd must refer to the transport endpoint through which the newly allocated structure is passed, so that the appropriate size information can be accessed. If the size value associated with any specified field is -1 or -2 (see t_open.3n or t_getinfo.3n t_alloc() is unable to determine the size of the buffer to allocate and fails, setting t_errno to TSYSERR and errno to EINVAL . For any field not specified in fields, buf is set to NULL and maxlen is set to zero.

Use of t_alloc() to allocate structures helps ensure the compatibility of user programs with future releases of the transport interface.

RETURN VALUES

On success, t_alloc() returns a pointer to the type of structure specified by struct_type. On failure, it returns NULL and sets t_errno to indicate the error.

ERRORS

TBADF
The specified file descriptor does not refer to a transport endpoint.
TSYSERR
The function failed due to a system error and set errno to indicate the error.

SEE ALSO

intro.3 t_free.3n t_getinfo.3n t_open.3n

[a manual with the abbreviation NETP]


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97