/*	$CoreSDI: modtypes.h,v 1.25 2001/05/08 19:14:44 claudio Exp $	*/

/*
 *   Copyright (c) 2000, 2001, Core SDI S.A., Argentina
 *   All rights reserved
 *  
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *  
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *   3. Neither name of the Core SDI S.A. nor the names of its contributors
 *      may be used to endorse or promote products derived from this software
 *      without specific prior written permission.
 *  
 *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 *   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 *   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 *   IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef MODTYPES_H
#define MODTYPES_H

/* Generic module structure */
struct module {
	void		*handle;
	int		(*proc_entry)(int, void *, void *);
};

/* Module contexts */
typedef struct _authcon AUTHCON;
typedef struct _iacon IACON;
typedef struct _attrcon ATTRCON;
typedef struct _cmd_line CMD_LINE;
typedef struct _raw_logset RAW_LOGSET;
typedef struct _session SESSION;
typedef struct _logset_info LOGSET_INFO;
typedef struct _attr ATTR;

struct _authcon {
	struct module	 mod;
	char		 peername[MAXHOSTNAMELEN];	/* Username	*/
	RESLIST		*rlist;				/* Res. list	*/
	PACKET		*packet;			/* Connection	*/
};

struct _iacon {
	struct module	 mod;
	LOGSET_INFO	*logset;			/* Logset list	*/
};

struct _attrcon {
	struct module	 mod;
	const char	*attr_name;			/* Module name	*/
	SESSION		*s;
};


/* IA initialization structures */
/* XXX: I don't like _cmd_line nor _raw_logset */
struct _cmd_line {
	int		argc;
	char		**argv;
	char		*data;
	CMD_LINE 	*next;
}; 

struct _raw_logset {
	CMD_LINE	*cmd;
#define a_
	RAW_LOGSET	*prev;
	RAW_LOGSET	*next;
};


/* Attribute list for specific logset */
struct _attr {
	ATTRCON		*atcon;
	ATTR		*next;
};
#define a_handle	atcon->mod.handle 		/* XXX used?	*/
#define a_proc		atcon->mod.proc_entry
#define a_attrname	atcon->attr_name
#define a_session	atcon->s			/* XXX used?	*/


/* Logset information */
struct _logset_info {
	unsigned int	perms;				/* IA perms	*/
	int		names;				/* Logset names	*/
	const char	**names_str;			/* Names	*/
	ATTR		*attr;				/* Attr list	*/
	LOGSET_INFO	*next;				/* Next logset	*/
};


/* Session */
struct _session {
	AUTHCON		*aucon;
	IACON		*iacon;
};
#define s_peername	aucon->peername			/* Client name	*/
#define s_packet	aucon->packet			/* Connection	*/
#define s_rlist		aucon->rlist			/* Res. list	*/
#define s_logset	iacon->logset			/* Logset list	*/
#define s_iaproc	iacon->mod.proc_entry		/* IA proc	*/

#endif /* MODTYPES_H */

