home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
lockr.exe
/
LOGLOCK.C
< prev
next >
Wrap
Text File
|
1995-02-05
|
8KB
|
245 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: loglock.c
**
** Desc: Program that tests the logical record locks.
**
** Parameter descriptions: > input
** < output
**
** API Calls:
** NWCallsInit
** NWGetConnectionHandle
** NWLogLogicalRecord
** NWLockLogicalRecord
** NWGetConnectionNumber
** NWScanLogicalLocksByConn
** NWClearLogicalRecord
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 06-28-94 ARM First code.
*/
/****************************************************************************
** Include Headers, Macros & function Prototypes.
*/
/*-------------------------------------------------------------------
** Borland C.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <mem.h>
#define RETURN '\r'
/*-------------------------------------------------------------------
** NetWare API's
*/
#include <nwcalls.h>
/*-------------------------------------------------------------------
** Defines
*/
#define NWDOS
/****************************************************************************
** Program start.
*/
void main(int argc, char *argv[ ])
{
NWCONN_HANDLE connHandle;
CONNECT_INFO connInfo;
NWCCODE ccode;
char server[50];
NWCONN_NUM connNumber;
NWLAST_RECORD lastRecord;
CONN_LOGICAL_LOCKS logicalLocks;
CONN_LOGICAL_LOCK logicalLock;
setmem(&logicalLocks,sizeof(CONN_LOGICAL_LOCKS),'\0');
setmem(&logicalLock,sizeof(CONN_LOGICAL_LOCK),'\0');
if(argc != 2) {
printf("Usage: LOGLOCK <servername> \n");
exit(1);
}
strcpy(server, strupr(argv[1]));
ccode = NWCallsInit(NULL, NULL);
if(ccode)
exit(1);
ccode = NWGetConnectionHandle(
/* > servername */ server,
/* Novell Reserved1 */ 0,
/* < connection Handle */ &connHandle,
/* Novell Reserved2 */ NULL);
if(ccode){
printf("NWGetConnectionHandle failed error %X\n",ccode);
exit(1);
}
ccode = NWLogLogicalRecord(
/* > connection Handle */ connHandle,
/* > Pointer to record Name */ "test",
/* > Lock flags 0 logonly
0 Log Only
1 log and lock exclusive
3 log and lock sharable */ 1,
/* > timeOutLimit */ 0);
if(ccode){
printf("NWLogLogicalRecord failed error %X\n",ccode);
exit(1);
}
ccode = NWLogLogicalRecord(
/* > connection Handle */ connHandle,
/* > Pointer to record Name */ "test1",
/* > Lock flags 0 logonly
0 Log Only
1 log and lock exclusive
3 log and lock sharable */ 3,
/* > timeOutLimit `` */ 0);
if(ccode){
printf("NWLogLogicalRecord failed error %X\n",ccode);
exit(1);
}
ccode = NWLockLogicalRecordSet(
/* > lockflags 0 = shareable Lock
1 = exclusive Lock */ 1,
/* > timeOutLimit */ 16);
if(ccode){
printf("NWLockLogicalRecordSet failed error %X\n",ccode);
exit(1);
}
ccode = NWGetConnectionNumber(
/* > connection Handle */ connHandle,
/* < connection Number */ &connNumber);
if(ccode){
printf("NWGetConnectionNumber failed error %X\n",ccode);
exit(1);
}
lastRecord=0;
do{
ccode = NWScanLogicalLocksByConn(
/* > connection Handle */ connHandle,
/* > connection Number */ connNumber,
/* <>Pointer to next record */ &lastRecord,
/* < pointer to CONN_LOGICAL_LOCKS(opt) */ &logicalLock,
/* < pointer to CONN_LOGICAL_LOCKS */ &logicalLocks);
switch(ccode){
case 0x8801 :
printf("ERROR: NWScanLogicalLocksByConn =%X INVALID_CONNECTION",
ccode);
exit(0);
break;
case 0x88FF :
printf("ERROR: NWScanLogicalLocksByConn =%X Scan Completed",
ccode);
exit(0);
break;
case 0x89C6 :
printf("ERROR: NWScanLogicalLocksByConn =%X NO_CONSOLE_PRIVILEGES",
ccode);
exit(0);
break;
case 0x88FD :
printf("ERROR: NWScanLogicalLocksByConn =%X Bad Connection Number",
ccode);
exit(0);
break;
default : break;
}
if (ccode>0 && ccode<0x87FF){
printf("ERROR: NWScanLogicalLocksByConn =%X WorkStation Error",
ccode);
exit(0);
}
if (ccode>=0x8800 && ccode<0x88FE && ccode!=0x8801){
printf("ERROR: NWScanLogicalLocksByConn =%X Requester/Shell Error",
ccode);
exit(0);
}
if (ccode>=0x8900 && ccode<0x89FF && ccode!=0x89C6 & ccode!=0x89FD){
printf("ERROR: NWScanLogicalLocksByConn =%X NetWare Error",
ccode);
exit(0);
}
/*--------------------------------------------------------------------
** NOTE: lockStatus is a bit mask describing how the file is locked:
** 0x01 = Locked
** 0x02 = Open shareable
** 0x04 = Logged
** 0x08 = OpenNormal
** 0x40 = TTS holding
** 0x80 = Transaction flag set
*/
printf ("TaskNumber = %d\n LockStatus = %X\n logicalName = %s\n\n",
logicalLock.taskNumber,
logicalLock.lockStatus,
logicalLock.logicalName);
}while(lastRecord !=-1);
if(ccode && ccode !=0x88FF){
printf("NWScanLogicalLocksByConn failed error %X\n",ccode);
exit(1);
}
ccode = NWClearLogicalRecord(connHandle,"test1");
if (ccode){
printf("NWClearLogicalRecord failed %X\n",ccode);
exit(1);
}
ccode = NWClearLogicalRecord(connHandle,"test");
if (ccode){
printf("NWClearLogicalRecord failed %X\n",ccode);
exit(1);
}
}