#ifndef LIBRARIES_NCPLIB_H
#define LIBRARIES_NCPLIB_H

/*
**
**  ncp.library
**  -----------
**
*/

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#define NCP_NAME "amigancp.library"
#define NCP_VERSION 5

extern struct Library *NCPBase;

/*
** 'fake' types for intel byte order support 
*/
typedef unsigned short IWORD;
typedef unsigned long ILONG;

/*
** Error returns from Read/Write
*/

#define NCPE_INUSE -1		/* Read/Write already pending */
#define NCPE_ABORTED -2		/* Aborted */
#define NCPE_OFFLINE -3		/* Connection offline */
#define NCPE_INACTIVE -4	/* Channel inactive */
#define NCPE_NOTFOUND -5	/* Remote Process not found */
#define NCPE_RECONNECTED -6 /* Informational warning: Channel has been reconnected */
#define NCPE_NEWUSER -7		/* User process changed! */

/*
**	SAS/C Pragmas
*/

#ifdef __SASC

#pragma libcall NCPBase NCP_Rexx 1E 0
#pragma libcall NCPBase NCP_IWORD 24 001
#pragma libcall NCPBase NCP_ILONG 2A 001
#pragma libcall NCPBase NCP_OpenChannel 30 09803
#pragma libcall NCPBase NCP_CloseChannel 36 801
#pragma libcall NCPBase NCP_Read 3C 09803
#pragma libcall NCPBase NCP_BeginRead 42 09803
#pragma libcall NCPBase NCP_CheckRead 48 801
#pragma libcall NCPBase NCP_AbortRead 4E 801
#pragma libcall NCPBase NCP_WaitRead 54 801
#pragma libcall NCPBase NCP_Write 5A 09803
#pragma libcall NCPBase NCP_BeginWrite 60 09803
#pragma libcall NCPBase NCP_CheckWrite 66 801
#pragma libcall NCPBase NCP_AbortWrite 6C 801
#pragma libcall NCPBase NCP_WaitWrite 72 801
#pragma libcall NCPBase NCP_IWORDP 78 9802
#pragma libcall NCPBase NCP_ILONGP 7E 9802
#pragma libcall NCPBase NCP_IWORDPI 84 801
#pragma libcall NCPBase NCP_ILONGPI 8A 801
#pragma libcall NCPBase NCP_private1 90 A01
#pragma libcall NCPBase NCP_ReadSig 96 801
#pragma libcall NCPBase NCP_WriteSig 9c 801
#pragma libcall NCPBase NCP_ibm2iso ae 001
#pragma libcall NCPBase NCP_iso2ibm b4 001
#pragma libcall NCPBase NCP_clnl ba 801
#pragma libcall NCPBase NCP_Fault c0 198004
#pragma libcall NCPBase NCP_LinkRemoteRun c6 09803
#pragma libcall NCPBase NCP_CreatePool cc 21003
#pragma libcall NCPBase NCP_DeletePool d2 801
#pragma libcall NCPBase NCP_AllocPooled d8 0802
#pragma libcall NCPBase NCP_FreePooled de 09803
#pragma libcall NCPBase NCP_tab_ibm2iso e4 0
#pragma libcall NCPBase NCP_tab_iso2ibm ea 0

#endif

/*
**	ANSI Prototypes
*/

#ifndef NO_PROTOS

IWORD NCP_IWORD( IWORD inval );
ILONG NCP_ILONG( ILONG inval );
APTR NCP_OpenChannel( STRPTR localname, STRPTR remotename, ULONG flags );
VOID NCP_CloseChannel( APTR ncpchannel );
LONG NCP_Read( APTR ncpchannel, APTR buffer, LONG len );
LONG NCP_BeginRead( APTR ncpchannel, APTR buffer, LONG len );
LONG NCP_CheckRead( APTR ncpchannel );
LONG NCP_WaitRead( APTR ncpchannel );
LONG NCP_AbortRead( APTR ncpchannel );
LONG NCP_Write( APTR ncpchannel, APTR buffer, LONG len );
LONG NCP_BeginWrite( APTR ncpchannel, APTR buffer, LONG len );
LONG NCP_CheckWrite( APTR ncpchannel );
LONG NCP_WaitWrite( APTR ncpchannel );
LONG NCP_AbortWrite( APTR ncpchannel );
IWORD NCP_IWORDP( APTR from, APTR to );
ILONG NCP_ILONGP( APTR from, APTR to );
IWORD NCP_IWORDPI( APTR from );
ILONG NCP_ILONGPI( APTR from );
ULONG NCP_ReadSig( APTR ncpchannel );
ULONG NCP_WriteSig( APTR ncpchannel );
UBYTE NCP_iso2ibm( UBYTE isoch );
UBYTE NCP_ibm2iso( UBYTE ibmch );
void NCP_clnl( STRPTR string );
void NCP_Fault( LONG code, STRPTR header, STRPTR buffer, LONG buffersize );
LONG NCP_LinkRemoteRun( STRPTR remotefilename, STRPTR cmdline, ULONG cmdlinelen );
APTR NCP_CreatePool( unsigned long requirements, unsigned long puddleSize,
	unsigned long threshSize );
void NCP_DeletePool( APTR poolHeader );
APTR NCP_AllocPooled( APTR poolHeader, unsigned long memSize );
void NCP_FreePooled( APTR poolHeader, APTR memory, unsigned long memSize );
UBYTE * NCP_tab_ibm2iso( void );
UBYTE * NCP_tab_iso2ibm( void );

#endif

#endif
