/* CallList - Module to manipulate lists of functions to call - Copyright 1991 Bryan Ford */
#ifndef CALLLIST_H
#define CALLLIST_H

#ifndef EXEC_NODES_H
#include <exec/nodes.h>
#endif

#ifndef EXEC_LISTS_H
#include <exec/lists.h>
#endif

/* One of these structures "remembers" a function to be called later. */
struct CallNode
  {
    struct Node Node;                   /* Standard Exec node */
    LONG (*CallFunction)(LONG GlobalData,LONG LocalData); /* What to call */
    LONG LocalData;                     /* What to call it with */
  };
#define CNT_INLIST      NT_USER         /* ln_Type set to this when node is in a CallList */

#define DefCallNode(name,func,data,pri) struct CallNode name = {{0,0,0,pri},func,data}

/* We don't need any fancy structures here. */
#define CallList        MinList

/* Initializing a CallList is also very simple. */
#define InitCallList(calllistptr)       NewList((struct List*)(calllistptr))

/* Call() and CallRem() simply bounce to the more powerful versions. */
#define Call(CallList,GlobalData)       CallExt(CallList,GlobalData,NULL)
#define CallRem(CallList,GlobalData)    CallRemExt(CallList,GlobalData,NULL)

/* Function prototypes */
/* (See CallList.c for details on these functions.) */
void AddCallNode(struct CallList *l,struct CallNode *d);
void RemCallNode(struct CallNode *d);
long CallExt(struct CallList *l,long GlobalData,
  long (*AfterFunc)(struct CallNode *Node,long RetCode,long GlobalData));
long CallRemExt(struct CallList *l,long GlobalData,
  long (*AfterFunc)(struct CallNode *Node,long RetCode,long GlobalData));

#endif