home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
dax1.exe
/
CP
/
CPC
/
CPINIT.C
< prev
next >
Wrap
Text File
|
1992-07-15
|
5KB
|
113 lines
// ╔════════════════════════════════════════════════════════════════════╗
// ║ ║
// ║ module: cpinit.c ║
// ║ abstract: This module initializes the CP Layer. ║
// ║ ║
// ║ environment: NetWare 3.x v3.11 ║
// ║ Network C for NLMs SDK v2.0d ║
// ║ CLib v3.11 ║
// ║ Network C for DOS v2.0 ║
// ║ NetWare C Interface DOS v1.2 ║
// ║ ║
// ║ 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/24/92 kl initial release. ║
// ║ 002 07/14/92 kl windows port. ║
// ╚════════════════════════════════════════════════════════════════════╝
#include <string.h>
#include <errno.h>
#include <malloc.h>
#include "cp/cpsys.h"
#if defined(WINCLIENT)
DWORD _TASKID; // used by all IPX calls
#endif
CPDATA *CPInitialize(char *name, UINT16 type)
{
#if !defined(DYNAMICMEM)
static CPDATA __cpd;
CPDATA *CPid = &__cpd;
#else
CPDATA *CPid;
#endif
char value[128],dummy;
//
// Get the C Interface ready to make IPX calls
//
if( IPXInitialize() ) goto error0;
#if defined(DYNAMICMEM)
//
// Allocate memory for __cpd
//
if((CPid = (CPDATA *)calloc(1,sizeof *CPid))==NULL) goto error0;
#endif
//
// Open a socket for our local application to listen on
//
if( IPXOpenSocket((BYTE *)&CPid->skt,SHORT_LIVED) ) goto error0;
//
// Get the address of the application server by reading the
// NET_ADDRESS property of that server from the bindery.
//
if( ReadPropertyValue(name,type,"NET_ADDRESS",1,value,&dummy,&dummy) )
return NULL;
//
// Save the server's address.
// Put the signature on the CP Layer packet header. This signature
// is used to authenticate the packets on both sides.
//
CPid->ipxaddr = *(IPXAddress *)value;
CPid->cphdr.signature = CPPKTSIG;
//
// Get the Send Logic ready to xfer messages to the server
//
if( CPInitializeSendLogic(CPid) ) goto error1;
//
// Get ready to receive messages from the server.
//
if( CPInitializeRecvLogic(CPid) ) goto error1;
//
// Do whatever prep is needed to establish connections.
//
if( CPInitializeConnLogic(CPid) ) goto error1;
//
// Okay, we're ready. Return structure pointer for use on
// subsequent API requests to the CP layer.
//
return CPid;
error0:
return NULL;
error1:
CPDeInitialize(CPid);
goto error0;
}
void CPDeInitialize(CPDATA *CPid)
{
if( CPid ){
if( CPid->skt ) IPXCloseSocket(CPid->skt);
CPDeInitializeRecvLogic(CPid);
CPDeInitializeSendLogic(CPid);
CPDeInitializeConnLogic(CPid);
memset(CPid,NULL,sizeof *CPid);
IPXDeInitialize();
#if defined(DYNAMICMEM)
free(CPid);
#endif
}
}