home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. CD ROM (Annual Premium Edition)
/
premium.zip
/
premium
/
IBMOS2_2
/
MAILMIND.ZIP
/
NETCLRNM.C
< prev
next >
Wrap
Text File
|
1992-03-11
|
2KB
|
100 lines
/* netclrnm.c - clear NETBIOS names greater than 3
* 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_UNKNOWN 0xff
#define STATUS_STRUCT struct status
typedef STATUS_STRUCT
{
word wCode;
string sText;
};
STATUS_STRUCT aStatus[] =
{
{0, "OK"},
{21, "not found"},
{STATUS_UNKNOWN, "?"}
};
/* globals */
NB_STATUS Nb;
NCB Ncb;
/* function prototypes */
short main(void);
word NetAdapterStatus(string sName);
word NetDelName(string sName);
/* delete a name from NETBIOS */
word NetDelName(string sName)
{
printf("Deleting %s ", sName);
memset(&Ncb, 0, sizeof(NCB));
Ncb.NCB_COMMAND = DELETE_NAME_WAIT;
strncpy(Ncb.NCB_NAME, sName, NETBIOS_NAME_LEN);
Ncb.NCB_CMD_CPLT = STATUS_UNKNOWN;
_ES = FP_SEG(&Ncb);
_BX = FP_OFF(&Ncb);
_AX = 0x0100;
geninterrupt(0x5c);
if (Ncb.NCB_CMD_CPLT) printf("FAILED\n");
else printf("(deleted)\n");
return(Ncb.NCB_CMD_CPLT);
} /* NetDelName */
/* check the adapter status */
word NetAdapterStatus(string sName)
{
string s, t;
memset(&Ncb, 0, sizeof(NCB));
Ncb.NCB_COMMAND = STATUS_WAIT;
strncpy(Ncb.NCB_CALLNAME, sName, NETBIOS_NAME_LEN);
for (s = Ncb.NCB_CALLNAME, t = s + NETBIOS_NAME_LEN - 1; s < t; s++)
*s = ((*s) ? toupper(*s) : ' ');
Ncb.NCB_BUFFER = (void far *) &Nb;
Ncb.NCB_LENGTH = sizeof(Nb);
Ncb.NCB_CMD_CPLT = STATUS_UNKNOWN;
_ES = FP_SEG(&Ncb);
_BX = FP_OFF(&Ncb);
_AX = 0x0100;
geninterrupt(0x5c);
return(Ncb.NCB_CMD_CPLT);
} /* NetAdapterStatus */
/* main */
short main(void)
{
short i;
word wStatus;
printf("Netclrnm v1.01\n");
if ((wStatus = NetAdapterStatus("*")) == 0)
{
for (i = 0; i < Nb.wNames; i++)
{
if (Nb.aNameEntry[i].byNcbNum > 3) wStatus =
NetDelName(Nb.aNameEntry[i].caName);
if (wStatus) break;
}
}
for (i = 0; *(aStatus[i].sText) != '?'; i++)
if (aStatus[i].wCode == wStatus) break;
printf("Netclrnm status: %s (%d)\n", aStatus[i].sText, Ncb.NCB_CMD_CPLT);
return(i);
} /* main */