OpenSolaris_b135/uts/common/smbsrv/ndl/ndrtypes.ndl

/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (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
 * or http://www.opensolaris.org/os/licensing.
 * 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 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _NDR_TYPES_NDL_
#define _NDR_TYPES_NDL_

#define TYPEINFO(TYPE)  ndt__##TYPE

#ifdef NDRGEN

#define ALIGN(X)	[align(X)]
#define OPERATION(X)	[operation(X)]
#define IN		[in]
#define OUT		[out]
#define INOUT		[in out]

#define STRING		[string]
#define SIZE_IS(X)	[size_is(X)]

#define SWITCH(X)	[switch_is(X)]
#define CASE(X)		[case(X)]
#define DEFAULT		[default]

#define INTERFACE(X)	[interface(X)]
#define UUID(X)		[uuid(X)]

#define ARG_IS(X)	[arg_is(X)]

#define REFERENCE	[reference]
#define REF		[reference]
#define UNIQUE		[unique]
#define PTR		[ptr]
#define POINTER_DEFAULT(X)	[pointer_default(X)]

#define ANY_SIZE_ARRAY	*

#define IMPORT_EXTERN	[extern]

#define BYTE	uchar
#define WORD	ushort
#define DWORD	ulong
#define ntstatus_t	ulong

#define LPTSTR	STRING wchar *

#define LPBYTE  uchar *
#define LPWORD  ushort *
#define LPDWORD ulong *

/*
 * Opaque context handle.
 */
#ifndef CONTEXT_HANDLE
#define CONTEXT_HANDLE(NAME)	\
	struct NAME {		\
		DWORD data1;    \
		DWORD data2;    \
		WORD  data3[2]; \
		BYTE  data4[8];	\
	};			\
	typedef struct NAME
#endif /* CONTEXT_HANDLE */

#define EXTERNTYPEINFO(TYPE)

#else /* NDRGEN */

#define ALIGN(X)
#define OPERATION(X)
#define IN
#define OUT
#define INOUT

#define STRING
#define SIZE_IS(X)

#define SWITCH(X)
#define CASE(X)
#define DEFAULT

#define INTERFACE(X)
#define UUID(X)

#define ARG_IS(X)

#define REFERENCE
#define REF
#define UNIQUE
#define PTR
#define POINTER_DEFAULT(X)

#define IMPORT_EXTERN

/*
 * When not using ndrgen, get BYTE, WORD, DWORD definitions from wintypes.h.
 */
#include <smbsrv/wintypes.h>

#define EXTERNTYPEINFO(TYPE)	extern struct ndr_typeinfo TYPEINFO(TYPE);


/*
 ***********************************************************************
 * There is a bug in the way that midl and the marshalling code handles
 * unions so we need to fix some of the data offsets at runtime. The
 * following macros and the fixup function handle the correction.
 ***********************************************************************
 */

/*
 * DECL_FIXUP_STRUCT allows us to declare external references to data
 * structures generated by ndrgen in the _ndr.c file.
 */
#define DECL_FIXUP_STRUCT(NAME)	extern struct ndr_typeinfo ndt__##NAME

/*
 * CASE_INFO_ENT is intended to simplify the declaration of the case
 * statement in the fixup function. Assuming you have followed the
 * convention for naming the individual structures all you have to do
 * is add a single line to the fixup function for each new case.
 */
#define CASE_INFO_ENT(NAME,N) \
			case N: size1 = sizeof (struct NAME##N); \
			break

/*
 * FIXUP_PDU_SIZE is used to patch the appropriate structures (identified
 * by DECL_FIXUP_STRUCT) at runtime. The values are based on the
 * switch_index.
 */
#define FIXUP_PDU_SIZE(NAME,SIZE) { \
	ndt__##NAME.pdu_size_fixed_part = SIZE; \
	ndt__##NAME.c_size_fixed_part = SIZE; \
}


#endif /* NDRGEN */

/*
 * UNION_INFO_ENT is intended to simplify adding new entries to a union.
 * If the entry structures are named using the form FunctionNameX,
 * where X is the sitch_value, you can just add a single line. Note
 * that you must also update the fixup function in mlsvc_xxx.c.
 */
#define UNION_INFO_ENT(N,NAME) CASE(N) struct NAME##N info##N
#define UNION_INFO_PTR(N,NAME) CASE(N) struct NAME##N *info##N

#endif /* _NDR_TYPES_NDL_ */