/********************************************************************
 ** FILESYSTEM THINGY
 **
 ** (c) Spak, Darrell Tam, c9107253@firebird.newcastle.edu.au (1994)
 ** phone (Australia) 049-829-710
 **                    49-829-710
 ** (c) SST 1994
 **
 ** JUMP TABLE TO ACTION THINGYS
 **
 ** TABS to 4
 ********************************************************************/

#include "/snd/everything.h"
#include "act.h"

/********************************************************************/
				void *which_action(long pkt)
/********************************************************************
            Return which function which should be called
                      but don't actually call it
      Use the supplied look up tables to find the routine address
 ********************************************************************/
{
static void *actions0to34[] = {
	action_nil,				/* 0 */
	action_unused,			/* 1 */
	action_get_block,		/* 2 */
	action_unused,			/* 3 */
	action_set_map,			/* 4 */
	action_die,				/* 5 */
	action_event,			/* 6 */
	action_current_volume,	/* 7 */
	action_locate_object,	/* 8 */
	action_rename_disk,		/* 9 */
	action_unused,			/* 10 */
	action_unused,			/* 11 */
	action_unused,			/* 12 */
	action_unused,			/* 13 */
	action_unused,			/* 14 */
	action_free_lock,		/* 15 */
	action_delete_object,	/* 16 */
	action_rename_object,	/* 17 */
	action_more_cache,		/* 18 */
	action_copy_dir,		/* 19 */
	action_wait_char,		/* 20 */
	action_set_protect,		/* 21 */
	action_create_dir,		/* 22 */
	action_examine_object,	/* 23 */
	action_examine_next,	/* 24 */
	action_disk_info,		/* 25 */
	action_info,			/* 26 */
	action_flush,			/* 27 */
	action_set_comment,		/* 28 */
	action_parent,			/* 29 */
	action_timer,			/* 30 */
	action_inhibit,			/* 31 */
	action_disk_type,		/* 32 */
	action_disk_change,		/* 33 */
	action_set_date			/* 34 */
};

static void *actions1001to1036[] = {
	action_read_return,		/* 1001 */
	action_write_return,	/* 1002 */
	action_unused,			/* 1003 */
	action_openfile,		/* 1004 */
	action_openfile,		/* 1005 */
	action_openfile,		/* 1006 */
	action_end,				/* 1007 */
	action_seek,			/* 1008 */
	action_unused,			/* 1009 */
	action_unused,			/* 1010 */
	action_unused,			/* 1011 */
	action_unused,			/* 1012 */
	action_unused,			/* 1013 */
	action_unused,			/* 1014 */
	action_unused,			/* 1015 */
	action_unused,			/* 1016 */
	action_unused,			/* 1017 */
	action_unused,			/* 1018 */
	action_unused,			/* 1019 */
	action_format,			/* 1020 */
	action_make_link,		/* 1021 */
	action_set_file_size,	/* 1022 */
	action_write_protect,	/* 1023 */
	action_read_link,		/* 1024 */
	action_unused,			/* 1025 */
	action_fh_from_lock,	/* 1026 */
	action_is_filesystem,	/* 1027 */
	action_change_mode,		/* 1028 */
	action_unused,			/* 1029 */
	action_copy_dir_fh,		/* 1030 */
	action_parent_fh,		/* 1031 */
	action_unused,			/* 1032 */
	action_examine_all,		/* 1033 */
	action_examine_fh,		/* 1034 */
	action_examine_all_end,	/* 1035 */
	action_set_owner		/* 1036 */
};
	switch(pkt) {
		case ACTION_READ: return(action_read);
		case ACTION_WRITE: return(action_write);
	default:
		if(pkt >= 0 && pkt <= 34) return(actions0to34[pkt]);
		else if(pkt >= 1001 && pkt <= 1036) return(actions1001to1036[pkt-1001]);
		else
		switch(pkt) {
			case ACTION_SAME_LOCK:		return(action_same_lock);		/* 40 */
			case ACTION_SCREEN_MODE:	return(action_screen_mode);		/* 994 */
			case ACTION_CHANGE_SIGNAL:	return(action_change_signal);	/* 995 */
			case ACTION_LOCK_RECORD:	return(action_lock_record);		/* 2008 */
			case ACTION_FREE_RECORD:	return(action_free_record);		/* 2009 */
			case ACTION_ADD_NOTIFY:		return(action_add_notify);		/* 4097 */
			case ACTION_REMOVE_NOTIFY:	return(action_remove_notify);	/* 4098 */
			case ACTION_SERIALIZE_DISK:	return(action_serialize_disk);	/* 4200 */
		}
	}
	return(action_unused);
}

