home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
phylck.exe
/
SCANLOCK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-06
|
4KB
|
146 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.
****************************************************************************
**
** File: SCANLOCK.C
**
** Desc: This program will take a file name on the command line in the
** format of VOLUME:PATH and scan the file for physical record
** locks. The locks are displayed in a simmilar format to the
** monitor NLM that ships with NetWare.
**
**
** Netware API Calls: NWCallsInit()
** NWGetDefaultConnectionID()
** NWScanPhysicalLocksByFile()
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** CRG Calvin R. Gaisford Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 06-06-95 CRG First code.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/*------------------------------------------------------------------
** NetWare
*/
#include <nwcalls.h>
/*------------------------------------------------------------------
** Defines
*/
#define NWDOS
/*------------------------------------------------------------------
** Prototypes
*/
/* Entire program contained in main() */
/****************************************************************************
** Program Start
*/
int main(int argc, char *argv[])
{
NWCONN_HANDLE defaultConnID;
NWCCODE ccode;
NWLAST_RECORD lastRecord;
PHYSICAL_LOCK lock;
PHYSICAL_LOCKS locks;
if(argc < 2)
{
printf("Usage: filelock <filename (VOL:PATH)>\n");
return 1;
}
ccode=NWCallsInit(NULL,NULL);
if(ccode)
{
printf("Unable to intialize Shell/Requester tables. Status = %04X\n");
return 1;
}
ccode=NWGetDefaultConnectionID(&defaultConnID);
if(ccode)
{
printf("Error in NWGetDefaultConnectionID. Status = %04X\n",ccode);
return 1;
}
lastRecord = 0;
printf("Conn Start End Physical Record Locks\n");
do
{
ccode = NWScanPhysicalLocksByFile(
/* Connection Handle */ defaultConnID,
/* Directory Handle */ 0,
/* File Path */ argv[1],
/* DataStream */ 0,
/* last record */ &lastRecord,
/* PHYSICAL_LOCK info*/ &lock,
/* PHYSICAL_LOCKS inf*/ &locks);
if(ccode == 0x88FF)
{
/* File Scan is done */
return 0;
}
if(ccode)
{
printf("NWScanPhysicalLocksByFile Failed with status = %04X\n", ccode);
return ccode;
}
printf("%-4d %08lX %08lX ",lock.connNumber, lock.recordStart, lock.recordEnd);
if(lock.loggedCount)
printf("Logged ");
else
printf("Not Logged ");
if(lock.lockType)
printf("Locked \n");
else
printf("Not Locked\n");
}
while(lastRecord != -1);
return 0;
}