home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. CD ROM (Annual Premium Edition)
/
premium.zip
/
premium
/
IBMOS2_2
/
MAILMIND.ZIP
/
NETLSTNM.C
< prev
next >
Wrap
Text File
|
1992-03-11
|
2KB
|
90 lines
/* netlstnm.c - list NETBIOS names
* 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"},
{STATUS_UNKNOWN, "?"}
};
/* globals */
NB_STATUS Nb;
NCB Ncb;
/* function prototypes */
short main(short argc, string argv[]);
word NetAdapterStatus(string sName);
/* 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(short argc, string argv[])
{
char caAdapter[NETBIOS_NAME_LEN];
short i;
word wStatus;
printf("Netlstnm v1.01\nNETBIOS names for ");
memset(caAdapter, 0, NETBIOS_NAME_LEN);
if (argc > 1)
{
strncpy(caAdapter, argv[1], NETBIOS_NAME_LEN);
printf("%s:\n", caAdapter);
}
else
{
strcpy(caAdapter, "*");
printf("this computer:\n");
}
if ((wStatus = NetAdapterStatus(caAdapter)) == 0)
{
for (i = 0; i < Nb.wNames; i++)
printf("%s %d\n", Nb.aNameEntry[i].caName,
Nb.aNameEntry[i].byNcbNum);
}
for (i = 0; *(aStatus[i].sText) != '?'; i++)
if (aStatus[i].wCode == wStatus) break;
printf("Netlstnm status: %s (%d)\n", aStatus[i].sText, Ncb.NCB_CMD_CPLT);
return(i);
} /* main */