/****************************************************************************
*			BBCNB32B.DLL :	General Header file for BBC NetBIOS implemenation	 *
*																									 *
*			(c) BBC Manchester 1993-2008	:	Author Simon Dowson					 *
*																									 *
* History :																						 *
*																									 *
*				01/10/93		:	Beta release 1.00											 *
*				23/12/93		:	All receives now LocalAlloc()                    *
* 1.00.00	29/12/93		:	NetVersion() added										 *
*									Implementation specific error codes added			 *
*									with bit 7 of NCB return code set					 *
* 1.01.00	07/01/98		:  Allows adaptor to be specified in INI file		 *
* 2.00.00	12/08/98		:  Converted to use Netbios() call for 32 bit dll	 *
* 3.00.00   28/10/99		:  Ported to 32 bit BBCNB32B.DLL                    *
* 3.00.01   03/03/00    :  Expanded return code strings in RC file          *
* 3.00.02   07/11/02    :  Adaptor parameter added to all functions         *
* 3.00.03   07/02/03    :  Modified NCB to use calloc() and free() 			 *
* 3.00.04   07/02/07		:	Built from CVS
* 3.00.05   14/05/08    :  Added NCBSTAT call and session table functions   *  
****************************************************************************/

#include <direct.h>
#include <dos.h>
#include <stdlib.h>
#include <nb30.h>

#define WM_NETBIOS			  WM_USER+2000
#define NETBIOS_NAME_LENGTH  16     /* Maximum NetBIOS name         */
#define NET_ERROR				  0x80

#define DEBUG_OFF		0
#define DEBUG_ON		1
#define DEBUG_EXTRA	2

#ifdef __cplusplus
extern "C" {
#endif

// Function prototypes
/****************************************************************************
	 FILE: BBC_NB32.C - Contains Initialisiation Routines
****************************************************************************/
void FAR PASCAL NetCmdCode(LPSTR, BYTE);
void FAR PASCAL NetRetCode(LPSTR, BYTE);

NCB_POST PostRoutine(PNCB);
void FAR PASCAL NetDebugMode(BOOL);

/****************************************************************************
	 FILE: NCBALLOC.C  -  Contains Memory Allocation Routines
****************************************************************************/

PNCB FAR PASCAL 	NetAllocNcbAndBuf( DWORD dwDataLen );
VOID FAR PASCAL	NetNcbFree       ( PNCB  pncbNcbWithBuffer);

/****************************************************************************
	 FILE: NCBCALLS.C - Contains routines which submit NCBs for caller.
****************************************************************************/

//Synchronous calls
BYTE FAR PASCAL NetAddName   	 	(LPSTR, LPBYTE, BYTE);
BYTE FAR PASCAL NetAddGroupName 	(LPSTR, LPBYTE, BYTE);
BYTE FAR PASCAL NetDeleteName 	(LPSTR, BYTE, BYTE);
BYTE FAR PASCAL NetHangUp    	 	(BYTE, BYTE);
BYTE FAR PASCAL NetCancel    	 	(PNCB, BYTE);
BYTE FAR PASCAL NetReset			(BYTE, BYTE, BYTE);

//Asynchronous calls
BYTE FAR PASCAL NetAdaptorStatus (HWND, WORD, LPSTR, PNCB FAR *, BYTE);
BYTE FAR PASCAL NetSessionStatus		(HWND, LPSTR, PNCB *, BYTE, BYTE);
BYTE FAR PASCAL NetCall 			(HWND, LPSTR, LPSTR, BYTE, BYTE, PNCB FAR *, BYTE);
BYTE FAR PASCAL NetListen 		 	(HWND, LPSTR, LPSTR, BYTE, BYTE, PNCB FAR *, BYTE);
BYTE FAR PASCAL NetSend			 	(HWND, LPSTR, WORD, BYTE, PNCB FAR *, BYTE);
BYTE FAR PASCAL NetSendDG			(HWND, LPSTR, WORD, LPSTR, BYTE, PNCB FAR *, BYTE);
BYTE FAR PASCAL NetSendBCDG		(HWND, LPSTR, WORD, BYTE, PNCB FAR *, BYTE);
BYTE FAR PASCAL NetReceive 		(HWND, WORD, BYTE, PNCB FAR *, BYTE);
BYTE FAR PASCAL NetReceiveAny	 	(HWND, WORD, BYTE, PNCB FAR *, BYTE);
BYTE FAR PASCAL NetReceiveDG		(HWND, WORD, BYTE, PNCB FAR *, BYTE);
BYTE FAR PASCAL NetReceiveBCDG	(HWND, WORD, BYTE, PNCB FAR *, BYTE);

/* Time out values */
#define CALL_TIME_OUT	 (double) (30 * 2) /* 2 Minutes */
#define SEND_TIME_OUT	 (double) (30 * 2) /* 2 Minutes */
#define RECEIVE_TIME_OUT (double) (60 * 2) /* 2 Minutes */

#define SEND_NCB_STO	(BYTE) ((2 * 30)* 1)   /* 1 Minutes in 1/2 sec intervals */
#define RECEIVE_NCB_RTO (BYTE) ((2 * 60)* 1)/* 1 Minutes in 1/2 sec intervals */

/****************************************************************************
	 FILE: NCBSUFU.C  -  General support Routines
****************************************************************************/

VOID FAR PASCAL NetCopyName 		(LPSTR, LPSTR);
VOID FAR PASCAL NetInitNCB			(void);
int  FAR PASCAL NetSetNCB			(PNCB, int);
int  FAR PASCAL NetGetNCB			(PNCB, PNCB);
int  FAR PASCAL NetClrNCB			(PNCB);
BYTE FAR PASCAL NetDumpSessionStatus(LPSTR acSessionName, BYTE bAdaptor);
void NetODS(LPCSTR szFmt, ...);

#define MAX_MESSAGELENGTH 512
#define MAXNCBSTACK 256
PNCB	pNCBStack[MAXNCBSTACK];
int	pNCBSize[MAXNCBSTACK];

#ifdef __cplusplus
}
#endif
