home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. CD ROM (Annual Premium Edition)
/
premium.zip
/
premium
/
IBMOS2_2
/
MAILMIND.ZIP
/
NETSEND2.C
< prev
next >
Wrap
Text File
|
1991-04-12
|
2KB
|
85 lines
/* netsend2.c - send a message from an OS/2 machine
* Division of Cancer Prevention & Control, NCI
*/
/* Revision history:
* 1.02 tam 04/12/91 convert to OS/2, temporarily eliminating prompt mode
* 1.01 tam 02/07/91 prompt for username & msg
* 1.00 tam 01/31/91 first release
*/
#include <local.h> /* standard definitions */
#define INCL_NETBIOS
#define INCL_NETERRORS
#include <lan.h> /* LAN Manager header files */
/* defines */
#define NETBIOS_NAME_LEN 16
#define NCB_CHAIN_SINGLE 0
#define HELP 1
#define USER_NUM 2 /* ? */
/* status structure */
#define STATUS_NOPARAM 100
#define STATUS_UNKNOWN 0xff
#define STATUS_STRUCT struct status
STATUS_STRUCT
{
word wCode;
string sText;
};
STATUS_STRUCT aStatus[] =
{
{0, "OK"},
{9, "no local name"},
{STATUS_NOPARAM, "too few parameters"},
{STATUS_UNKNOWN, "?"}
};
/* globals */
NCB Ncb;
/* function prototypes */
short main(short argc, string argv[]);
word NetSend(string sName, string sMsg, word iNbNum);
/* main */
short main(short argc, string argv[])
{
short i;
word wStatus = 0;
printf("Netsend2 v1.02");
if (argc < 3) wStatus = STATUS_NOPARAM;
else
wStatus = NetSend(argv[1], argv[2], (argc > 3) ? atoi(argv[3]) : USER_NUM);
for (i = 0; *(aStatus[i].sText) != '?'; i++)
if (aStatus[i].wCode == wStatus) break;
printf("\nNetsend2 status: %s (%d)\n", aStatus[i].sText, Ncb.ncb_cmd_cplt);
return(i);
} /* main */
/* send a Msg to Name from iNbNum */
word NetSend(string sName, string sMsg, word iNbNum)
{
string s;
word wStatus;
word wHandle; /* Handle to logical network */
wStatus = NetBiosOpen("NET1", 0, NB_REGULAR, &wHandle);
if (wStatus == NERR_Success)
{
memset(&Ncb, 0, sizeof(NCB));
Ncb.ncb_command = NCBDGSEND;
Ncb.ncb_num = (byte) iNbNum;
strncpy(Ncb.ncb_callname, sName, NETBIOS_NAME_LEN);
for (s = Ncb.ncb_callname; s < Ncb.ncb_name - 1; s++)
*s = ((*s) ? toupper(*s) : ' ');
Ncb.ncb_buffer = (void far *) sMsg;
Ncb.ncb_length = strlen(sMsg);
Ncb.ncb_cmd_cplt = (byte) STATUS_UNKNOWN;
NetBiosSubmit(wHandle, NCB_CHAIN_SINGLE, &Ncb);
NetBiosClose(wHandle, 0);
wStatus = (word) Ncb.ncb_retcode;
}
return(wStatus);
} /* NetSend */