Files
mars-nwe/include/nwnss/include/msg.h
2026-06-15 00:31:09 +02:00

316 lines
7.3 KiB
C

/****************************************************************************
|
| (C) Copyright 1995-1998 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 Storage Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2007-04-12 01:48:56 +0530 (Thu, 12 Apr 2007) $
|
| $RCSfile$
| $Revision: 1932 $
|
|---------------------------------------------------------------------------
| This module is used to:
| Define the message structures used by NSS and the bit masks and
| other values used by NSS APIs.
+-------------------------------------------------------------------------*/
#ifndef _NSS_MSG_H_
#define _NSS_MSG_H_
#ifndef _ZOMNI_H_
# include <zOmni.h>
#endif
#ifndef _ZMSG_H_
# include <zMsg.h>
#endif
#ifndef _QUE_H_
# include <que.h>
#endif
#ifndef _SLAB_H
# include <slab.h>
#endif
typedef void *(*objfunc_t)(); /* Function returns a pointer to an object */
typedef struct XIPC_Msg_s
{
zWorkProc_s work;
CIRlink_t link;
void *page;
struct net_s
{
LONG dataLength;
LONG type;
QUAD key;
LONG method;
Msg_s msg;
} net;
} XIPC_Msg_s;
/*
* An Object is an instance of a Type. The Object holds the data
* while the Type has the methods.
*/
typedef struct mObject_s
{
struct mType_s *o_type; /* Type of the object -- methods */
NINT o_count; /* Number of references to object */
DQlink_t o_instance; /* Other instances of this object type */
NINT o_properties;
#if 0
// struct {
// NINT w_next;
//#define NUM_WHERE 32
// char *w_where[NUM_WHERE];
// } o_w;
#endif
} mObject_s;
#if 0
#define OBJ_TRACE(_obj) \
((_obj)->o_w.w_where[(_obj)->o_w.w_next++ & (NUM_WHERE-1)] = WHERE)
#endif
/*
* A door maps a key to an object and keeps track of
* who owns the object.
*/
typedef struct mDoor_s
{
mObject_s dr_obj;
struct mDoor_s *dr_next;
Key_t dr_key;
struct mManager_s *dr_owner;
DQlink_t dr_ownerList;
} mDoor_s;
/*
* Managers create and own doors. It has a table of doors
* that it manages. In a more traditional system, this would
* be a process.
*/
typedef struct mManager_s
{
mObject_s obj;
DQhead_t doors; /* All the doors this manager owns */
DQhead_t types; /* All the types this manager created */
} mManager_s;
/*
* Each Door Manager can manage a number of different
* door types. This could also be thought of as a class.
* All the methods are held by the type.
*
* In addition to the method table, a number of standard
* functions can be set. If not supplied, a default function
* will be provided.
* preconstructor - used by objCache to initialize obj when
* slab is first allocated. Not called
* on subsequent allocations.
* constructor - called each time the object is allocated to
* initialize the object. Because no
* arguments can be passed, this is of
* limited use.
* destructor - called to clean up the object.
* notify - called to notify someone that the object
* is about to be destroyed.
* unregister - called when unregistering a type. Example:
* types that have doors, will use MSG_BreakDoor.
*/
#define MSG_INIT_TYPE(name, parent, objSize, numMethods, \
preconstructor, constructor, destructor, notify, unregister)\
{ \
name, parent, objSize, numMethods, NULL, \
(voidfunc_t)preconstructor, (objfunc_t)constructor, \
(statusfunc_t)destructor, (voidfunc_t)notify, \
(voidfunc_t)unregister, \
{ 0 } \
}
typedef struct mTypeHeader_s
{
char *name;
struct mTypeHeader_s *parent; /* Weak inheritance */
NINT objSize;
NINT numMethods;
mManager_s *manager;
voidfunc_t preconstructor;
objfunc_t constructor;
statusfunc_t destructor; // Used in multiple places
voidfunc_t notify;
voidfunc_t unregister;
DQlink_t typeList;
DQhead_t instances;
ObjCache_s objCache;
} mTypeHeader_s;
typedef struct mType_s
{
mTypeHeader_s hdr;
statusfunc_t method[1];
} mType_s;
/*
* The Manager Manager.
*/
#define NUM_MGR_METHODS 0
typedef struct mVirtualType_s /* Has no methods nor objects */
{
mTypeHeader_s hdr;
} mVirtualType_s;
typedef STATUS (*MSG_RemoteMethod_t)(
mDoor_s *door,
NINT method,
Msg_s *msg);
typedef STATUS (*MSG_RemoteMethodKey_t)(
mDoor_s *door,
NINT method,
Msg_s *msg,
mDoor_s *passedDoor);
extern mVirtualType_s DoorType;
extern mVirtualType_s ManagerType;
extern mManager_s *Manager;
/**********************
* Function prototypes
*/
STATUS MSG_DestroyKey(Key_t key);
STATUS NullMethod(Msg_s *msg);
STATUS MSG_Call(
Key_t key,
NINT method,
Msg_s *msg);
STATUS MSG_SendKey(
Key_t key,
NINT method,
Msg_s *msg);
STATUS zMSG_Call(
Key_t key,
NINT method,
Msg_s *msg);
STATUS mpkMSG_Call(
Key_t key,
NINT method,
Msg_s *msg);
STATUS MSG_Send(
Key_t key,
NINT method,
Msg_s *msg);
void MSG_ChangeOwner(
mDoor_s *door,
mManager_s *owner);
void *MSG_CreateDoor(
mTypeHeader_s *type,
mManager_s *manager,
NINT properties,
Key_t *retKey);
void *MSG_CreateObject(
mTypeHeader_s *type);
void MSG_ReleaseObject(mObject_s *obj);
STATUS MSG_DestroyKey(Key_t key);
STATUS MSG_RegisterType(
mTypeHeader_s *type,
mManager_s *manager);
void MSG_UnregisterType(mTypeHeader_s *type);
void MSG_KillManager(mManager_s *mgr);
STATUS MSG_BreakDoor(mDoor_s *door);
void MSG_BreakSetOfDoors(
mTypeHeader_s *type,
boolfunc_t match,
void *args);
void MSG_DestroySetOfKeys(
mManager_s *owner,
mTypeHeader_s *type,
boolfunc_t match,
void *args);
Key_t MSG_LookupShortKey(LONG key);
void msgFreeDoor(mDoor_s *door);
extern NINT NSS_StoreCallers(void **, NINT,SNINT);
#define MSG_USE_OBJECT(_obj) (++(_obj).o_count)
#define MSG_RELEASE_OBJECT(_obj) { \
(--(_obj).o_count); \
MSG_ReleaseObject( &(_obj)); \
}
#define MSG_USE_DOOR(_door) (++(_door)->dr_obj.o_count)
/*
* The door should be freed.
* By giving a door an initial count of zero, we
* can handle one time doors here without any
* additional tests.
* Re-get the type because the door may have
* been broken while the last message was being
* processed.
*/
#define MSG_RELEASE_DOOR(_door) \
{ \
--(_door)->dr_obj.o_count; \
if ((_door)->dr_obj.o_count == 0) \
{ \
msgFreeDoor(_door); \
} \
}
void MSG_RegisterXIPC(
MSG_RemoteMethod_t call,
MSG_RemoteMethod_t send,
MSG_RemoteMethodKey_t sendKey);
void MSG_UnregisterXIPC(void);
extern mDoor_s *findDoor(Key_t key);
extern XIPC_Msg_s *allocMsgBuf();
extern void freeMsgBuf(XIPC_Msg_s *xmsg);
#endif