home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
sapit.exe
/
SAPQ.C
< prev
Wrap
Text File
|
1994-07-29
|
4KB
|
120 lines
/****************************************************************************
** File: SAPQ.C
**
** Desc: Sample SAP QUERY
**
** This program simply issues a SAP query for a specific server type.
**
**
** DISCLAIMER
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
**
** Programmers:
**
** Ini Who Firm
** -----------------------------------------------------------------------
** KLB Karl L Bunnell Novell Developer Support.
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 09-14-94 KLB First code.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdio.h>
/*------------------------------------------------------------------------
** SAP and NetWare
*/
#include <sap.h>
#include <nwmisc.h>
/****************************************************************************
** This function is the entire program.
** Simply run SAPQ from the command line. This code will strip out the
** Network:Node:Socket for the Advertising server and build an IPX packet
** with each keystroke that is entered and send it to the server machine
** running SAPIT and diplay the keystroke on the screen. Pressing the tilde
** '~' key will terminate the session on both ends.
*/
main()
{
WORD sType, qType, rSize, Socket = 0x9000;
SAP sBuf;
int ccode;
char msg, c='\0';
IPXHeader sHeader;
ECB sECB;
sType = 0x9001;
qType = 0x3;
rSize = 96;
/*------------------------------------------------------------------------
** Query services and build IPX packets to send key stroke characters.
*/
ccode = QueryServices (qType, sType, rSize, &sBuf);
printf("Server Type is: %2X\n", IntSwap(sBuf.ServerType));
printf("Server name is: %s\n", sBuf.ServerName);
ccode = IPXInitialize();
memcpy(sHeader.destination.network, sBuf.Network, 4);
memcpy(sHeader.destination.node, sBuf.Node,6);
memcpy(sHeader.destination.socket, sBuf.Socket, 2);
sHeader.length = IntSwap(sizeof(IPXHeader));
sHeader.packetType = 4;
sECB.ESRAddress = 0;
sECB.inUseFlag = 0;
sECB.fragmentCount = 2;
sECB.socketNumber = Socket;
memcpy(sECB.immediateAddress, sBuf.Node, 6);
sECB.fragmentDescriptor[0].address = (&sHeader);
sECB.fragmentDescriptor[0].size = sizeof(IPXHeader);
sECB.fragmentDescriptor[1].address = (&msg);
sECB.fragmentDescriptor[1].size = sizeof(char);
/*------------------------------------------------------------------------
** Remain in Send Loop until a '~' key is pressed.
*/
while(c != '~')
{
c=getch();
msg=(char)c;
IPXSendPacket(&sECB);
while(sECB.inUseFlag)
IPXRelinquishControl();
}
IPXCloseSocket(Socket);
}