home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
sndmes.exe
/
SENDMESS.C
next >
Wrap
Text File
|
1995-06-23
|
3KB
|
122 lines
/****************************************************************************
** 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.
***************************************************************************/
#include <stdio.h>
#include <string.h>
#define NWDOS
#include <nwcalls.h>
void main (int argc, char *argv[])
{
NWCCODE ccode;
NWCONN_HANDLE conn;
NWNUMBER maxConns;
NWOBJ_ID userID, ID;
NWFLAGS flag;
int i;
char message[256];
char server[50];
char user[50];
if (argc < 4)
{
printf ("Usage: SENDMESS serverName userName message\n");
printf ("You must be logged in to the server\n");
return;
}
strcpy (server, strupr (argv[1]));
strcpy (user, strupr (argv[2]));
strcpy (message, "");
for (i = 3; i < argc; i++)
{
strcat (message, argv[i]);
strcat (message, " ");
}
message[strlen (message) - 1] = '\x0';
ccode = NWCallsInit (NULL,NULL);
if (ccode) return;
ccode = NWGetConnectionHandle (server, 0, &conn, NULL);
if (ccode)
{
printf ("NWGetConnectionHandle returned %X\n", ccode);
return;
}
ccode = NWGetObjectID (conn, user, OT_USER, &userID);
if (ccode)
{
printf ("NWGetObjectID returned %X\n", ccode);
return;
}
ccode = NWGetFileServerInformation (
conn,
NULL,
NULL,
NULL,
NULL,
&maxConns,
NULL,
NULL,
NULL,
NULL,
NULL);
if (ccode)
{
printf ("NWGetFileServerInformation returned %X\n", ccode);
return;
}
for (i = 0; i < maxConns; i++)
{
NWGetConnectionInformation (conn, i, NULL, NULL, &ID, NULL);
if (ID == userID) break;
}
if (ID == userID)
{
ccode = NWSendBroadcastMessage (conn, message, 1,
(NWCONN_NUM_WORD NWFAR *) &i,
&flag);
if (ccode)
{
printf ("NWSendBroadcastMessage returned %X\n", ccode);
return;
}
if (flag)
{
printf ("Server return code was %X\n", flag);
return;
}
printf ("Message sent successfully\n");
}
else
{
printf ("User %s not found on server %s\n", user, server);
return;
}
}