#include <sys/types.h>
#include <errno.h>
#include "funcdef.h"
#include "../defs.h"
#include "../funcs.h"

struct novell_func {
	int (_fastcall *proc)(short _far *);
} _near novell_funcs[] = {
	0,
	novell_init,
	novell_shutdown,
	novell_socket,
	novell_info,
	novell_accept,
	novell_drain,
	novell_release,
	novell_eof,
	novell_read,
	novell_write,
	novell_recv,
	novell_sendto,
	novell_select,
	0
};

#define N_FUNCS (sizeof (novell_funcs) / sizeof (novell_funcs[0]))

int
main(argc, argv, envp)
int argc;
char **argv;
char **envp;
{
	return 0;
}

int
rpc_entry(buf, size)
short _far *buf;
int size;
{
    struct novell_func near *nfp;
    int i;

    nfp = &novell_funcs[buf[0]];
    if ((unsigned)buf[0] >= N_FUNCS || !nfp->proc) {
	buf[0] = -1;
	buf[2] = NETERR_BADCALL;
	return 6;
    }
    i = (nfp->proc)(buf);
    if (i < 0) {
	buf[0] = i;
	buf[1] = errno;
	buf[2] = convert_error(errno);
	return 6;
    }
    return i;
}

int _fastcall
novell_shutdown(buf)
short _far *buf;
{
    return 0;
}
