/*
 *  FILE
 *	clop.h
 *
 *  DESCRIPTION
 *	Some support for the clop() function.
 *
 *  AUTHOR
 *	Anders 'ALi' Lindgren
 *	Mälarblick 8
 *	S-161 51 Bromma
 *	Sweden
 *
 *  STATUS
 *	All rights reserved.  
 */

extern unsigned char * 	__stdargs clop(unsigned char *, struct clop_list *,
					     struct clop_array *);
extern void		__stdargs freeclop(struct clop_array *);


/*
 *  STRUCTURE
 *	clop_list
 *
 *  DESCRIPTION
 *	This array contains returned error information.
 *
 *  DISCUSSION
 *	Rename it altogeteher? Or simply replace it with something better?
 */
 
struct clop_list {
    long error;			/* CLOPE_* (See below)	*/
    unsigned char failing_opt;	/* Name of failing option */
};


/*
 *  STRUCTURE
 *	clop_array
 *
 *  DESCRIPTION
 *	This array conatins all the information needed for the
 *	clop() function.
 *
 *	This array can be sent several times through the clop()
 *	function, so that preset, env: and command line options
 *	can easily be used.
 */
	
struct clop_array {
    unsigned char  option;		/* Which option		*/
    unsigned char  type; 		/* CLOPT_* (see below)	*/
    unsigned char  inflags;		/* CLOPIF_*	"	*/
    unsigned char  outflags;		/* CLOPOF_*	"	*/
    				/*
				 * The following union contains returned
				 * values, or preset values.
				 */
    union {
	signed   long	number;		/* unsigned number	*/
	unsigned long	unumber;	/* signed number	*/
	unsigned char * string;		/* String pointer	*/
	long		bool;		/* 1 or 0		*/
    } value;
};


/*
 *  DEFINITIONS
 *	CLOPIF_*	- CLOP In Flags
 *
 *	None, so far.
 */

#define CLOPIF_SINGLE	0x01


/*
 *  DEFINITIONS
 *	CLOPOF_*	- CLOP Out Flags
 *
 *	CLOPOF_PRESENT	- Set if option present
 */

#define	CLOPOF_PRESENT		0x01
#define CLOPOF_ALLOCATED	0x02	/* NYI */


/*
 *  DEFINITIONS
 *	CLOPT_*
 *
 *  DESCRIPTION
 *	Type field.
 */

#define CLOPT_END	0
#define	CLOPT_NUMBER	1
#define CLOPT_UNUMBER	2
#define CLOPT_STRING	3
#define CLOPT_BOOL	4
#define CLOPT_FLOAT	5	/* NYI */


/*
 *  DEFINITIONS
 *	CLOPE_*
 *
 *  DESCRIPTION
 *	Errorcodes.
 */

#define CLOPE_OK		0
#define CLOPE_NYI		1
#define CLOPE_UNKNOWN_OPTION	2
#define CLOPE_UNKNOWN_TYPE	3
#define CLOPE_ILLEGAL_NUMBER	4
#define CLOPE_ILLEGAL_BOOL	5
#define CLOPE_ILLEGAL_STRING	6
#define CLOPE_MULTIPLE_SINGLE	7

#ifndef NULL
#define NULL 0L
#endif
