home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
broad.exe
/
BROAD.C
next >
Wrap
C/C++ Source or Header
|
1995-01-04
|
4KB
|
123 lines
/****************************************************************************
** DISCLAIMER
**
** This program 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.
**
****************************************************************************
**
** File: broad.c
**
** Desc: Program to send and get broadcast messages.
**
** API Calls:
** NWCallsInit()
** NWGetDefaultConnectionID()
** NWSetBroadcastMode()
** NWGetObjectConnectionNumbers()
** NWSendBroadcastMessage()
** NWGetBroadcastMessage()
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** BBA Belinda Adams Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 01-04-95 BBA Original.
*/
/****************************************************************************
** Include Headers, Macros & function Prototypes.
*/
#include <stdlib.h>
#include <stdio.h>
#define NWDOS
#include <nwcalls.h>
NWCCODE cCode;
NWCONN_HANDLE connHandle;
void main(void)
{
int i;
char msg[256], user[30];
NWFLAGS resultList;
NWNUMBER numConnections;
NWCONN_NUM doubleWordConnList[50];
NWCONN_NUM_WORD wordConnList[50];
/* Initialize NWCalls */
if ( cCode = NWCallsInit( NULL, NULL ) )
{
printf( "\nNWCallsInit failed: %04x", cCode );
exit(1);
}
if (cCode = NWGetDefaultConnectionID(&connHandle) )
{
printf( "\nNWGetDefaultConnectionID: failed %04x", cCode );
exit(1);
}
/* Set broadcast mode to 3: all messages stored but not displayed */
if (cCode = NWSetBroadcastMode(connHandle, 0x0003) )
printf( "\nNWSetBroadcastMode: failed %04x", cCode );
printf("\nSend broadcast message to? ");
/* expects user name to be in capital letters */
scanf("%s", user);
if (cCode = NWGetObjectConnectionNumbers(connHandle, user, OT_USER,
&numConnections, doubleWordConnList, 50) )
{
printf( "\nNWGetObjectConnectionNumbers: failed %04x", cCode );
exit(1);
}
/* convert connection list from double word to word */
for (i=0; i < numConnections; i++)
wordConnList[i] = (WORD)doubleWordConnList[i];
if (cCode = NWSendBroadcastMessage(connHandle, "Test Message 1" , numConnections,
wordConnList, &resultList) )
{
printf( "\nNWSendBroadcastMessage: failed %04x", cCode );
exit(1);
}
/* Retrieve a stored broadcast message */
if (cCode = NWGetBroadcastMessage(connHandle, msg) )
{
printf( "\nNWGetBroadcastMessage: failed %04x", cCode );
exit(1);
}
printf("\nMessage Received: %s", msg);
/* Reset broadcast mode to default: all messages displayed */
if (cCode = NWSetBroadcastMode(connHandle, 0x0000) )
printf( "\nNWSetBroadcastMode: failed %04x", cCode );
if (cCode = NWSendBroadcastMessage(connHandle, "Test Message 2",
numConnections,
wordConnList, &resultList) )
{
printf( "\nNWSendBroadcastMessage: failed %04x", cCode );
exit(1);
}
}