Files
mars-nwe/include/nwnss/comnSA/msgLock.h
2026-06-16 10:19:33 +02:00

144 lines
4.6 KiB
C

/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (PSS) Initialization module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| This module is used to:
| Define the lock message structures.
|
| WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
|
| This header file should ONLY be used for NSS internal development.
| This includes Semantic Agents (SA) and Loadable Storage Services (LSS).
| Any other use may cause conflicts which NSS will NOT fix.
+-------------------------------------------------------------------------*/
#ifndef _MSGLOCK_H_
#define _MSGLOCK_H_
#ifndef _OMNI_H_
#include <omni.h>
#endif
#ifndef _XLIMITS_H_
#include <xLimits.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Lock modes supported by NSS
*/
typedef enum LockMode_t
{
LK_NONE, /* Just put in lock set, later we will lock the set */
LK_SHARED, /* Shared or read access */
LK_EXCLUSIVE /* Exclusive or write access */
} LockMode_t;
/*
* CallBackMsg_s provides the data and routines for implementing
* callbacks to the user for all locking routines.
*/
typedef struct CallBackMsg_s
{
NINT waitTime; /* How long we will wait in ticks */
voidfunc_t saCallBack; /* Callback to semantic agent */
voidfunc_t userCallBack; /* Callback to user (called by SA) */
ADDR userData; /* Passed back in call back */
} CallBackMsg_s;
typedef struct LockByteRangeMsg_s
{
CallBackMsg_s callBack;
FileHandle_s *fh; /* File handle, so we can find lockset */
NamedBeast_s *beast; /* Byte range of this beast */
QUAD start; /* Byte offset of lock in file */
QUAD length; /* Length of the lock (num bytes) */
NINT mode; /* Type of lock (shared/excluisive/none) */
ADDR lockData; /* Additional data to identify lock */
} LockByteRangeMsg_s;
typedef struct LockSetMsg_s
{
CallBackMsg_s callBack;
NINT mode; /* Type of lock (shared/excluisive/none) */
} LockSetMsg_s;
typedef struct UnlockByteRangeMsg_s
{
QUAD start; /* Starting byte offset of lock in file */
QUAD end; /* Ending byte offset */
BOOL clear; /* FALSE->don't remove from log list */
ADDR lockData; /* lockData to be compared */
boolfunc_t userFunc; /* function to compare lockData */
struct LockSet_s *lockSet; /* Lock set lock is a member of */
struct NamedBeast_s *beast; /* Beast for lock */
} UnlockByteRangeMsg_s;
#define COMN_LOCK_BYTE_RANGE_MSG(_msg, _fh, _beast, _start, _length, _mode, _lockData) \
{ \
(_msg)->fh = (_fh); \
(_msg)->beast = (_beast); \
(_msg)->start = (_start); \
(_msg)->length = (_length); \
(_msg)->mode = (_mode); \
(_msg)->lockData = (_lockData); \
}
#define COMN_UNLOCK_BYTE_RANGE_MSG(_msg, _beast, _start, _length, _clrflg, _lockData, _userFunc) \
{ \
(_msg)->start = (_start); \
(_msg)->end = ((((_start)+(_length)) < (_start)) ? \
MAX_QUAD : ((_start)+(_length))); \
(_msg)->clear = ((_clrflg) != FALSE); \
(_msg)->lockSet = NULL; \
(_msg)->beast = (_beast); \
(_msg)->lockData = (_lockData); \
(_msg)->userFunc = (_userFunc); \
}
#define COMN_SETUP_CALLBACKS(_msg, _wait, _sa, _user, _data) \
{ \
(_msg)->waitTime = (_wait); \
(_msg)->saCallBack = (_sa); \
(_msg)->userCallBack = (_user); \
(_msg)->userData = (_data); \
}
#ifdef __cplusplus
}
#endif
#endif