home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. CD ROM (Annual Premium Edition)
/
premium.zip
/
premium
/
IBMOS2_2
/
MAILMIND.ZIP
/
NETADDGR.C
< prev
next >
Wrap
Text File
|
1992-03-11
|
2KB
|
84 lines
/* netaddgr.c - add NETBIOS group name
* Thomas A. Marciniak, M.D. = ytm@nihccpc1.bitnet
* Division of Cancer Prevention & Control, NCI
*/
/* Revision history:
* 1.01 ytm 01/31/91 eliminate post routine
* 1.00 ytm 01/31/91 first release
*/
/* Program notes:
* Current versions are specific for TurboC.
*/
#include <local.h> /* standard definitions */
#include "netbios.h"
/* status structure */
#define STATUS_NONAME 100
#define STATUS_UNKNOWN 0xff
#define STATUS_STRUCT struct status
typedef STATUS_STRUCT
{
word wCode;
string sText;
};
STATUS_STRUCT aStatus[] =
{
{0, "OK"},
{13, "already present"},
{22, "at another station"},
{STATUS_NONAME, "NO name!"},
{STATUS_UNKNOWN, "?"}
};
/* globals */
NCB Ncb;
/* function prototypes */
short main(short argc, string argv[]);
void NetAddName(string sName);
/* add a name to the network */
void NetAddName(string sName)
{
memset(&Ncb, 0, sizeof(NCB));
Ncb.NCB_COMMAND = ADD_GROUP_NAME_WAIT;
strcpy(Ncb.NCB_NAME, sName);
Ncb.NCB_CMD_CPLT = STATUS_UNKNOWN;
_ES = FP_SEG(&Ncb);
_BX = FP_OFF(&Ncb);
_AX = 0x0100;
geninterrupt(0x5c);
} /* NetAddName */
/* main */
short main(short argc, string argv[])
{
char caName[NETBIOS_NAME_LEN];
short i;
string s, t;
word wStatus = STATUS_NONAME;
printf("Netaddgr v1.01\n");
memset(&Ncb, 0, sizeof(NCB));
memset(caName, 0, NETBIOS_NAME_LEN);
if (argc > 1)
{
strcpy(caName, argv[1]);
for (s = caName, t = s + NETBIOS_NAME_LEN - 1; s < t; s++)
*s = ((*s) ? toupper(*s) : ' ');
printf("Adding %s\n", caName);
NetAddName(caName);
wStatus = Ncb.NCB_CMD_CPLT;
}
for (i = 0; *(aStatus[i].sText) != '?'; i++)
if (aStatus[i].wCode == wStatus) break;
printf("Netaddgr status: %s (%d)", aStatus[i].sText, Ncb.NCB_CMD_CPLT);
if (Ncb.NCB_NUM) printf(" NETBIOS number %d\n", Ncb.NCB_NUM);
return(i);
} /* main */