/*	$CoreSDI: resource.h,v 1.8 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 RESOURCE_H
#define RESOURCE_H

typedef struct _resource RESOURCE;
struct _resource {
	char	 *name;			/* Resource name	*/
	ssize_t	  dsize;		/* Resource data size	*/
	void	 *data;			/* Resource data	*/
	RESOURCE *next;			/* Next resource	*/
	RESOURCE *prev;			/* Previous resource	*/
};

typedef struct _reslist RESLIST;
struct _reslist {
	char	  lname[MAXPATHLEN];	/* Resource list name	*/
#define RF_MODIFIED	0x01
	int	  flags;		/* See RF_xxxx defines	*/
	RESOURCE *first_res;		/* First resource	*/
	RESOURCE *last_res;		/* Last resource	*/
	RESLIST  *lnext;		/* Next list		*/
};

/* Res_open_list modes for create list */
enum {
	RES_NOTREAD,			/* Dont read data	*/
	RES_FORCEREAD,			/* Read data 		*/
	RES_READ			/* Read only if exists	*/
};

int		res_module_init (const char *);
void		res_module_release ();

int		res_check_list (const char *);
RESLIST *	res_open_list (const char *, int);
void		res_release_list (RESLIST *);
int		res_remove_list (const char *);
int		res_save_list (const RESLIST *);

int		res_add (RESLIST *, const char *, const void *, ssize_t);
void		res_remove (RESLIST *, const char *);
int		res_replace (RESLIST *, RESOURCE *, const void *, ssize_t);
RESOURCE *	res_find (const RESLIST *, const char *);

#endif /* RESOURCE_H */

