Revision 237 (by dpavlin, 2004/03/08 17:43:12) initial import of openisis 0.9.0 vendor drop
/*
	openisis - an open implementation of the CDS/ISIS database
	Version 0.8.x (patchlevel see file Version)
	Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License as published by the Free Software Foundation; either
	version 2.1 of the License, or (at your option) any later version.

	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
	Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with this library; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

	see README for more information
EOH */
#ifndef LSES_H

/*
	$Id: lses.h,v 1.8 2003/04/10 13:43:44 kripke Exp $
	session
*/

#include "loi.h"
#include "lio.h"

enum {
	LSES_FILE_MAX = 16
};

typedef struct Ses {
	int          id;
	char         name[64];
	Ios         *io[LSES_FILE_MAX];
	int          hash; /* -value of name */
	struct Ses  *nxt; /* chain in hash */
	int          accnt; /* # accesses */
	Tm           ctime;
	Tm           mtime;
	Tm           atime;

	Rec         *prop; /* session state */
	Rec         *res; /* a reusable result */
	struct Con  *cur; /* current connection */
	struct Con  *que; /* connection queue */
	/* actually this is followed by internal members ... */
}	Ses;


/**
	get the Session for the current thread.
	if it doesn't have one, one is created.
*/
extern Ses *sGet ();
extern void sSet ( Ses *ses );

#ifdef _REENTRANT
#define SESDECL  Session ses = sGet();
#define SESGET() sGet()
#define SESSET(s) sSet(s)
#else
extern Ses *ses;
#define SESDECL
#define SESGET() ses
#define SESSET(s) do { ses = (s); } while (0)
#endif

extern void lses_init ();
extern void lses_fini ();


/**
	get or create session by name (of len nlen).
	name will be cleaned of control chars (<32).
	touch atime (and ctime on new) with now (if not 0).
	clean and reuse sessions with atime < expire (if not 0)
*/
extern Ses *cSesByName ( char *name, int nlen, Tm *now, Tm *expire );


#define LSES_H
#endif /* LSES_H */