home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
dax1.exe
/
CP
/
CPC
/
CPRECV.C
< prev
next >
Wrap
Text File
|
1992-07-15
|
6KB
|
138 lines
// ╔════════════════════════════════════════════════════════════════════╗
// ║ ║
// ║ module: cprecv.c ║
// ║ abstract: This module contains the APIs to receive messages ║
// ║ from the application server. ║
// ║ ║
// ║ 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cp/cpsys.h"
void CPInitRecvPacket(WORD socket,
ECB *ecb,
IPXHeader *packet,
void *reply,
WORD replySize)
{
ECBSOCKET(ecb) = socket;
ECBFRAGCOUNT(ecb) = 2;
ECBFRAGADDR(ecb,0) = packet;
ECBFRAGSIZE(ecb,0) = sizeof(IPXHeader);
ECBFRAGADDR(ecb,1) = reply;
ECBFRAGSIZE(ecb,1) = replySize;
}
T_RC CPInitializeRecvLogic(CPDATA *CPid)
{
int i;
//
// Get two recv ECBs ready. One for receiving requests, and one
// for receiving replies.
//
for(i=0; i < CPCNUMRECVECBS; ++i){
CPInitRecvPacket(CPid->skt,
&CPid->recvs[i].ecb,
&CPid->recvs[i].ipx,
&CPid->recvs[i].cpmsg,
sizeof CPid->recvs[i].cpmsg);
IPXReceive(&CPid->recvs[i].ecb);
}
return CP_SUCCESS;
}
#if 0
//
//!! remove this prototype from header file, not needed any longer...
//
void CPRepostAnyCompletedECBs(CPDATA *CPid)
{
int i;
for(i=0; i < CPCNUMRECVECBS; ++i){
if( !ECBISINUSE(&CPid->recvs[i].ecb) ){
//
// Return this ECB to the listening pool
//
DIAG3("CPRepostECBs() detected completed ECB!");
IPXReceive(&CPid->recvs[i].ecb);
}
}
}
#endif
T_RC CPRecvMessage(CPDATA *CPid, void *recbuf, unsigned length)
{
int i;
for(i=0; i < CPCNUMRECVECBS; ++i){
if( !ECBISINUSE(&CPid->recvs[i].ecb) ){
//
// If an error occured on the receive, just return. Don't
// even bother to repost the ECB. Should put in a more
// intelligent error handler here, as some errors can be
// handled without just giving up like this...
//
if( COMPLETIONCODE(&CPid->recvs[i].ecb) ) return CP_TRANSPORT_ERROR;
//
// Save the header info from the CP Layer on the server
// side. This keeps us in sync with the server side.
// Verify that the CP signature on the packet header is valid!
//
if( CPid->recvs[i].cpmsg.cphdr.signature != CPPKTSIG ) return CP_TRANSPORT_ERROR;
//
// Save the cphdr for next time
//
CPid->cphdr = CPid->recvs[i].cpmsg.cphdr;
HEXDIAG4("CP Layer session id is ",CPid->cphdr.serverID);
//
// Transfer the received data to the user buffer.
//
memmove(recbuf,CPid->recvs[i].cpmsg.msg,min(CPMAXMSG,length));
//
// Return this ECB to the listening pool
//
IPXReceive(&CPid->recvs[i].ecb);
//
// Return success to the caller. i.e. we got something.
//
return CP_SUCCESS;
}
}
return CP_NO_MESSAGE;
}
#pragma off(unreferenced);
void CPDeInitializeRecvLogic(CPDATA *CPid)
#pragma on(unreferenced);
{
int i;
//
// If any ECBs are still active, go ahead and cancel them.
//
for(i=0; i < CPCNUMRECVECBS; ++i)
if( ECBISINUSE(&CPid->recvs[i].ecb) )
IPXCancelEvent(&CPid->recvs[i].ecb);
}