home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
dax1.exe
/
CP
/
CPS
/
CPINIT.C
< prev
next >
Wrap
Text File
|
1992-07-15
|
4KB
|
112 lines
// ╔════════════════════════════════════════════════════════════════════╗
// ║ ║
// ║ module: cpinit.c ║
// ║ abstract: This module contains the initialization code for the ║
// ║ server side of the communication protocol layer. ║
// ║ ║
// ║ environment: NetWare 3.x v3.11 ║
// ║ Network C for NLMs SDK ║
// ║ CLib v3.11 ║
// ║ ║
// ║ This software is provided as is and carries no warranty ║
// ║ whatsoever. Novell disclaims and excludes any and all implied ║
// ║ warranties of merchantability, title and fitness for a particular ║
// ║ purpose. Novell does not warrant that the software will satisfy ║
// ║ your requirements or that the software is without defect or error ║
// ║ or that operation of the software will be uninterrupted. You are ║
// ║ using the software at your risk. The software is not a product ║
// ║ of Novell, Inc. or any of subsidiaries. ║
// ║ ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ maintenance history: ║
// ║ level date pi description ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ 001 01/29/92 kl initial release. ║
// ╚════════════════════════════════════════════════════════════════════╝
#include <string.h>
#include <conio.h>
#include <process.h>
#include <library.h>
#include <sap.h>
#include "cp/cpsys.h"
//------------------------------------------------------------------------
STATIC WORD messageSocket; // socket messages received on
STATIC WORD cpInited; // TRUE if we're initialized
//
// This API returns the socket that we are advertising our services on
//
WORD CPGetAdvertisingSocket()
{
return messageSocket;
}
//------------------------------------------------------------------------
STATIC LONG SAPHandle; // handle Advertise returns...
//
// This API initializes the server application. It begins advertising
// our service using SAP.
//
T_RC CPInitialize(char *srvname,
WORD type,
void (*EnqueueAPI)(UINT32, void *),
int (*ioRoutine)(char *fmt, ...))
{
//
// Don't be initialized twice!
//
if( cpInited ) return TRUE;
cpInited = TRUE;
//
// ioRoutine is called to print messages to the console.
//
if( ioRoutine ) _CPioRoutine = ioRoutine;
//
// Open the socket, then initialize the remaining modules.
//
if( IpxOpenSocket(&messageSocket) != NULL ) goto error0;
if( CPInitializeSendLogic() ) goto error1;
if( CPInitializeRecvLogic(EnqueueAPI) ) goto error1;
if( CPInitializeConnLogic() ) goto error1;
//
// Start advertising the server
//
if((SAPHandle = AdvertiseService(type,srvname,messageSocket)) == -1){
goto error1;
}
return CP_SUCCESS;
error0:
return CP_TRANSPORT_ERROR;
error1:
CPDeInitialize();
goto error0;
}
void CPDeInitialize()
{
if( cpInited ){
IpxCloseSocket(messageSocket); // kill receiving ECBs
if( SAPHandle ) ShutdownAdvertising(SAPHandle);
CPDeInitializeConnLogic();
CPDeInitializeRecvLogic();
CPDeInitializeSendLogic();
_CPioRoutine = __CPIgnoreIO;
cpInited = FALSE;
}
}
main()
{
ConsolePrintf("CPLayer: APIs ready for use\r\n");
AtUnload(CPDeInitialize);
xDIAG1(RenameThread(GetThreadID(),"CP_INIT"));
while(1) SuspendThread(GetThreadID());
}