/* cleanup.h */
/*
 *
 * $Author: Espie $
 * $Date: 91/04/24 02:40:48 $
 * $Revision: 1.1 $
 * $Log:        cleanup.h,v $
 * Revision 1.1  91/04/24  02:40:48  Espie
 * Initial revision
 * 
 *
 */
 
#ifndef CUSTOM_CLEANUP_H
#define CUSTOM_CLEANUP_H

#ifndef NIL
#define NIL (void *)0
#endif

typedef void *GENERIC;
typedef long INTEGER;
typedef struct clean *CLEAN;
typedef void (*FUNC0)(void);
typedef void (*FUNC1)(GENERIC);
typedef void (*FUNC2)(GENERIC, INTEGER);
typedef void (*FUNC3)(GENERIC, INTEGER, INTEGER);

#define ToClean0(f) ToClean0L(NIL, f)
#define ToClean(f, o) ToCleanL(NIL, f, o)
#define ToClean2(f, o, i) ToClean2L(NIL, f, o, i)
#define ToClean3(f, o, i, j) ToClean3L(NIL, f, o, i, j)
#define ToClean0(f) ToClean0L(NIL, f)
#define AllocClean(f) AllocCleanL(NIL, f)

extern void ToClean0L(CLEAN stem, void (*f)(void));
extern void ToCleanL(CLEAN stem, void (*f)(GENERIC), GENERIC o);
extern void ToClean2L(CLEAN stem, void (*f)(GENERIC, INTEGER), 
        GENERIC o, INTEGER i);
extern void ToClean3L(CLEAN stem, void (*f)(GENERIC, INTEGER, INTEGER),
        GENERIC o, INTEGER i1, INTEGER i2);
extern CLEAN AllocCleanL(CLEAN base, void (*panic)(char *));

extern void CleanUp(CLEAN base);
extern void SetUpCleanUp(void (*panic)(char *));
extern void SafeCleanUp(CLEAN *base);
extern CLEAN AllocPrivateClean(void (*panic)(char *));

extern void PanicL(CLEAN stem, char *message);
#define Panic(message) PanicL(NIL, message)

/* should never be defined when compiling cleanup.c itself */

#ifdef USE_ANSI_AT_EXIT
extern int ANSIatexit(void (*func)(void));
#define atexit ANSIatexit
#define onexit ANSIatexit
#endif



#endif
