t_alloc.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 1993-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4.1.2 */
#include "mt.h"
#include <stdlib.h>
#include <unistd.h>
#include <stropts.h>
#define _SUN_TPI_VERSION 2
#include <xti.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include "tx.h"
/*
* Function protoypes
*/
int api_semantics);
char *
{
struct T_info_ack info;
union structptrs {
char *caddr;
struct t_unitdata *udata;
} p;
unsigned int dsize;
return (NULL);
}
/*
* Get size info for T_ADDR, T_OPT, and T_UDATA fields
*/
do {
if (retval < 0) {
return (NULL);
}
return (NULL);
}
/*
* Malloc appropriate structure and the specified
* fields within each structure. Initialize the
* 'buf' and 'maxlen' fields of each.
*/
switch (struct_type) {
case T_BIND:
goto errout;
fields, api_semantics) < 0)
goto errout;
}
return ((char *)p.bind);
case T_CALL:
goto errout;
fields, api_semantics) < 0)
goto errout;
}
/* compensate for XTI level options */
else
fields, api_semantics) < 0)
goto errout;
}
(int)info.DDATA_size);
fields, api_semantics) < 0)
goto errout;
}
return ((char *)p.call);
case T_OPTMGMT:
goto errout;
/* compensate for XTI level options */
else
fields, api_semantics) < 0)
goto errout;
}
return ((char *)p.opt);
case T_DIS:
goto errout;
fields, api_semantics) < 0)
goto errout;
}
return ((char *)p.dis);
case T_UNITDATA:
if ((p.udata = (struct t_unitdata *)
goto errout;
fields, api_semantics) < 0)
goto errout;
}
/* compensate for XTI level options */
else
fields, api_semantics) < 0)
goto errout;
}
fields, api_semantics) < 0)
goto errout;
}
return ((char *)p.udata);
case T_UDERROR:
goto errout;
fields, api_semantics) < 0)
goto errout;
}
/* compensate for XTI level options */
else
fields, api_semantics) < 0)
goto errout;
}
return ((char *)p.uderr);
case T_INFO:
goto errout;
return ((char *)p.info);
default:
if (_T_IS_XTI(api_semantics)) {
} else { /* TX_TLI_API */
}
return (NULL);
}
/*
* Clean up. Set t_errno to TSYSERR.
* If it is because memory could not be allocated
* then errno already should have been set to
* ENOMEM
*/
if (p.caddr)
return (NULL);
}
static int
{
trace2(TR__alloc_buf, 0, n);
switch (n) {
case T_INFINITE /* -1 */:
if (_T_IS_XTI(api_semantics)) {
/*
* Do not return error
* if T_ALL is used.
*/
return (-1);
}
} else { /* TX_TLI_API */
/*
* retain TLI behavior
*/
return (-1);
} else
}
break;
case 0:
break;
case T_INVALID /* -2 */:
if (_T_IS_XTI(api_semantics)) {
/*
* Do not return error
* if T_ALL is used.
*/
return (-1);
}
} else { /* TX_TLI_API */
/*
* retain TLI behavior
*/
}
break;
default:
return (-1);
} else
break;
}
return (0);
}