/* The <ansi.h> header checks whether the compiler claims conformance to ANSI
 * Standard C. If so, the symbol _ANSI is defined as 1, otherwise it is 
 * defined as 0.  Based on the result, a macro
 *
 *	_PROTOTYPE(function, params)
 *
 * is defined.  This macro expands in different ways, generating either
 * ANSI Standard C prototypes or old-style K&R (Kernighan & Ritchie) 
 * prototypes, as needed.  Finally, some programs use _CONST, _VOID_PTR etc
 * in such a way that they are portable over both ANSI and K&R compilers.
 * The appropriate macros are defined here.
 */

#ifndef _ANSI_H
#define _ANSI_H

/* Define the
 * _PROTOTYPE macro to either expand both of its arguments (ANSI prototypes),
 * only the function name (K&R prototypes).
 */

#if __STDC__ == 1
#define	_PROTOTYPE(function, params)	function params
#define	_VOID_PTR	void *
#define	_VOID		void
#define	_CONST		const
#define	_VOLATILE	volatile

#define P0()	(void)
#define P1(type1, name1)	(type1, name1)
#define P2(type1, name1, type2, name2) (type1 name1, type2 name2)
#define P3(type1, name1, type2, name2, type3, name3) (type1 name1, type2 name2, type3 name3)
#else
#define	_PROTOTYPE(function, params)	function()
#define	_VOID_PTR	char *
#define _VOID
#define	_CONST
#define	_VOLATILE

#define P0()	()
#define P1(type1, name1)	(name1) type1 name1;
#define P2(type1, name1, type2, name2) (name1, name2) type1 name1; type2 name2;
#define P3(type1, name1, type2, name2, type3, name3) (name1, name2, name3) type1 name1; type2 name2; type3 name3;
#endif

#endif
