home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
whosdk.exe
/
WHO.C
next >
Wrap
C/C++ Source or Header
|
1994-09-29
|
4KB
|
124 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.
****************************************************************************
#define NWDOS
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <fcntl.h>
#include <nwcalls.h>
void main(int argc, char *argv[])
{
NWCCODE ccode;
NWCONN_HANDLE connHandle;
int *lastRec;
CONN_USING_FILE fUse;
CONNS_USING_FILE fUsed;
char *ptr;
int i;
char objectName[256];
NWOBJ_TYPE NWFAR *objectType;
NWOBJ_ID NWFAR *objectID;
BYTE NWFAR *loginTime;
if (argc != 3)
{
printf ("\nUsage: WHO <File Server Name> <Path and filename>");
return;
}
memset (&fUse, 0, sizeof (fUse));
memset (&fUsed, 0, sizeof (fUsed));
printf("\nScan Who is Using the File ...\n");
ccode = NWCallsInit(NULL, NULL);
// printf("\nNWCallsInit returned: %04X", ccode);
if(ccode) {
printf("\nNWCallsInit Error: %d", ccode);
exit(1);
}
ptr = strupr(argv[1]); /* Convert Server Name to upper case */
ccode = NWGetConnectionHandle(ptr, 0, &connHandle, 0);
// printf("\nNWGetConnectionHandle returned: %04X", ccode);
if(ccode) {
printf("\nNWGetConnectionHandle Error: %d", ccode);
exit(1);
}
// printf("\nString entered on command line is: %s", argv[2]);
ptr = strupr(argv[2]); /* Convert path to upper case */
lastRec[0]=0; lastRec[1]='\0';
do
{
ccode = NWScanConnectionsUsingFile(
/* Conn Handle */ connHandle,
/* Directory handle */ 0,
/* path */ ptr,
/* Last Record */ lastRec,
/* File Use */ &fUse,
/* File Used */ &fUsed
);
printf("\n NWScanConnectionsUsingFile returned %04X", ccode);
if(ccode) {
// printf("\nNWScanConnectionUsingFile Error: %d", ccode);
exit(1);
}
// printf ("\n CONNS_USING_FILE.connCount = %d", fUsed.connCount);
if(fUsed.connCount==0) {
printf("\nSorry. No one is using the file.");
exit(1);
}
if((ccode == 0) && (fUsed.connCount)) {
// printf("\nConnection number = %d", fUse.connNumber);
ccode=NWGetConnectionInformation(connHandle,
fUse.connNumber,
objectName,
objectType,
objectID,
loginTime);
if(ccode) {
printf("\nNWGetConnectionInformation Error: %d", ccode);
exit(1);
}
printf("\n%s", objectName);
}
}
while((!ccode) && (fUsed.connCount));
}