/*
 *	Name:				hook.c
 *
 * Description:	Implements XfqHook()
 *
 * Copyright:		1992-1993 by David Jones.
 *
 * Distribution:
 *		This program is free software; you can redistribute it and/or modify
 *		it under the terms of the GNU General Public License as published by
 *		the Free Software Foundation; either version 2 of the License, or
 *		(at your option) any later version.
 *
 *		This program 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 General Public License for more details.
 *
 *		You should have received a copy of the GNU General Public License
 *		along with this program; if not, write to:
 *
 *				The Free Software Foundation		David Jones
 *				675 Mass Ave							6730 Tooney Drive
 *				Cambridge, MA							Orleans, Ontario
 *				02139										K1C 6R4
 *				USA										Canada
 *
 *	Usenet:	gnu@prep.ai.mit.edu					aa457@freenet.carleton.ca
 *	Fidonet:												1:163/109.8
 *
 *		$Log: $
 *
 */

#include <exec/types.h>
#include <exec/libraries.h>
#include <proto/utility.h>
#include <utility/tagitem.h>
#include "xferq.h"
#include "xferqint.h"

extern BOOL DeathKiss;
extern struct MinList MemoryList;
extern long NumUsed[], NumFree[];
extern char *ObjNames[];

void *LibHook(struct TagItem *tags)
/*
 *	In:	tags		A0		Taglist giving instructions
 *
 * Does:	This function implements private magic according to the
 *			tags passed in.
 */
{
struct TagItem *tag, *walk;

	walk = tags;
	while (tag = NextTagItem(&walk)) {
		switch (tag->ti_Tag) {
		case XQ_DeathKiss:
			DeathKiss = TRUE;
			XferqBase->lib_OpenCnt = 1;
			break;
		case XQ_GetCore:
			CoreDump();
			break;
		case XQ_Meter: {
			struct meter {
				long numobjs;
				long *used;
				long *free;
				char **names;
			} *meter;
			
				meter = (struct meter *)tag->ti_Data;
				meter->used = NumUsed;
				meter->free = NumFree;
				meter->numobjs = XQO_MAX;
				meter->names = ObjNames;
				return meter;
			}
		}
	}
	return NULL;
}


void *__saveds __asm LIBHook(register __a0 struct TagItem *tags)
{
void *p;

	p = LibHook(tags);
	SetErrorTags(NULL);
	return p;
}


