Files
mars-nwe/include/nwnss/include/virtualIO.h

357 lines
8.2 KiB
C

/****************************************************************************
|
| (C) Copyright 1999 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
|
|***************************************************************************
|
| Novell Storage Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: randys $
| $Date: 2005-03-09 03:04:04 +0530 (Wed, 09 Mar 2005) $
|
| $RCSfile$
| $Revision: 847 $
|
|---------------------------------------------------------------------------
| This module is used to:
| Header file for virtual IO
+-------------------------------------------------------------------------*/
#ifndef _VIRTUALIO_H_
#define _VIRTUALIO_H_
#if zNETWARE || (zLINUX && defined(__KERNEL__))
#ifndef _NSSPUBS_H_
#include "nssPubs.h"
#endif
#endif
/*
* Defines needed by user space programs
*/
#define ADM_KERNEL_MAGIC 0x21414b21 /* "!AK!" */
#define ADM_USER_MAGIC 0x21415521 /* "!AU!" */
#define ADM_ERROR_STATUS 987123
#define VIRT_RESULT_BUFFER_SIZE 8192
#define VIRT_RESULT_REALLOC_AMOUNT 4096
#if zNETWARE || defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)
/****************************************************************************
*
* Constants and macros
*
****************************************************************************/
#if 0
#define MAX_VIRTUAL_FILE_SIZE(_beast) \
((1 << (_beast)->FILEmycache.bufSizeShift) - sizeof(LONG))
#else
#define MAX_VIRTUAL_FILE_SIZE(_beast) 32*1024
#endif
#define VIRT_INVALID_INDEX -1
#define VIRT_RAW_REALLOC_AMOUNT 128
#define VIRT_NAME_REALLOC_AMOUNT 64
#define VIRT_EOF 1048576
#define VIRT_ACTUAL_EOF(_beast, _buffer) \
(*(LONG *)&(_buffer)[MAX_VIRTUAL_FILE_SIZE(_beast)])
#define MAX_VIRT_SYMBOL_LEN 63
#define MAX_TEXT_UNIT 1024
#define ADJUST_OFFSET(_offset, _adjustment) \
{ \
if ((_offset) >= (_adjustment)) \
{ \
(_offset) -= (_adjustment); \
} \
else \
{ \
(_adjustment) = 0; \
} \
}
#define VIRT_TEMPLATE(_beast) ((VirtTemplateInfo_s *)(*(_beast)->ROOTvariableData)[RVD_VIRTUAL_DATA])
#define VIRT_ADDLINE(_line, _buffer, _eof) \
{ \
NINT __lineLen; \
__lineLen = strlen((_line)); \
memcpy((_buffer)+(_eof), (_line), __lineLen); \
(_eof) += __lineLen; \
}
/* Definition of symbol types */
#define VIRT_TYPE_KERNEL 0
#define VIRT_TYPE_USER 1
#define VIRT_TYPE_JAVA 2
#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(MARS_NWE_NWNSS_USERSPACE)
/****************************************************************************
*
* Structures
*
****************************************************************************/
typedef struct LocationFormat_s
{
NINT locFormat; /* a format indicator -- see enum below */
union
{
NINT rawLength; /* used with raw format */
BOOL signedValue; /* used with all other formats */
} attrib;
} LocationFormat_s;
typedef struct CompiledTemplate_s
{
NINT datastreamNameIdx; /* index into the name buffer for the datastream name */
NINT datastreamNameLen; /* The number of bytes in the name */
NINT datastreamType; /* see enum below */
union
{
struct
{
NINT dataIdx;
NINT dataLen;
} data;
struct
{
NINT locSymIdx;
LONG (*locSymPtr)(); /* this is setup as a function pointer even
* though it is not a function so it can
* be passed to functions dealing with
* symbols */
NINT locOffset;
NINT locLeadingTextLen;
NINT locLeadingTextIdx;
NINT locTrailingTextLen;
NINT locTrailingTextIdx;
LocationFormat_s locReadFormat; /* a format indicator -- see enum below */
LocationFormat_s locWriteFormat; /* a format indicator -- see enum below */
} location;
struct
{
NINT readSymType;
NINT readSymIdx;
STATUS (*readFunctionPtr)();
NINT readParmIdx;
NINT readParmLen;
NINT readFlags; /* see enum below */
NINT readClassPathIdx;
NINT writeSymType;
NINT writeSymIdx;
STATUS (*writeFunctionPtr)();
NINT writeParmIdx;
NINT writeParmLen;
NINT writeClassPathIdx;
} function;
} u;
} CompiledTemplate_s;
/*
* enumeration for dataStreamType
*/
enum datastreamType_e
{
VIRT_TYPE_LOCATION = 1,
VIRT_TYPE_DATA = 2,
VIRT_TYPE_FUNCTION = 3,
};
/*
* enumeration for readFlag bits
*/
enum readFlags_e
{
VIRT_READFLAGS_COOKIE = 1,
};
/*
* enumeration for location format bits
*/
enum locFormat_e
{
VIRT_FORMAT_UNUSED = 0,
VIRT_FORMAT_BYTE = 1,
VIRT_FORMAT_WORD = 2,
VIRT_FORMAT_LONG = 3,
VIRT_FORMAT_QUAD = 4,
VIRT_FORMAT_RAW = 5,
};
typedef struct VirtTemplateInfo_s
{
Latch_s templateLatch; /* Latch for changing template data */
NINT usedRawDataSize; /* Amount of allocated raw data space actually in use */
NINT allocedRawDataSize; /* Amount of raw data space that has been allocated */
utf8_t *rawData; /* pointer to the allocated space */
NINT usedNameSize;
NINT allocatedNameSize;
BYTE *names; /* names found in template */
NINT numDatastreams;
NINT numAllocatedDatastreams;
CompiledTemplate_s *compDatastream;
/* compiled template data for each datastream */
} VirtTemplateInfo_s;
typedef struct JavaInfo_s
{
zNSSMsg_s *msg;
FileHandle_s *fileHandle;
VirtInfo_s *virtInfo;
CompiledTemplate_s *compInfo;
BOOL readFlag;
BOOL requesterWaiting;
BOOL handlerWaiting;
BOOL shutdown;
const char *retString;
NINT state;
STATUS status;
THREAD threadID;
Latch_s handlerLatch;
Latch_s requesterLatch;
BOOL jvmStarted;
} JavaInfo_s;
/* Defines for state */
/* States processed by the requester */
#define JAVA_NO_JVM 0
#define JAVA_READY_FOR_REQUEST 1
#define JAVA_REPLY_READY 2
#define JAVA_REQUEST_FINISHED 3
/* States processed by the handler */
#define JAVA_WAITING_FOR_JVM 100
#define JAVA_REQUEST_READY 101
#define JAVA_REPLY_PROCESSED 102
#define JAVA_SHUTDOWN_REQUEST 999
#define VIRT_TEST_BUF_LEN 4096
extern BYTE VIRT_test[VIRT_TEST_BUF_LEN];
extern QUAD AdminVolWrites;
extern QUAD AdminVolReads;
/****************************************************************************
*
* Function Prototypes
*
****************************************************************************/
STATUS VIRT_Write(
struct zNSSMsg_s *msg);
STATUS VIRT_InitVirtualFile(
Key_t key,
NINT *filePos);
STATUS VIRT_FinishVirtualFile(
Key_t key,
NINT *filePos);
STATUS VIRT_MakeReadWriteFuncDataStream(
Key_t key,
utf8_t *dataStreamName,
utf8_t *readRoutine,
utf8_t *readParm,
utf8_t *writeRoutine,
utf8_t *writeParm,
BOOL useCookieRead,
NINT *filePos);
STATUS VIRT_MakeUserReadWriteFuncDataStream(
Key_t key,
utf8_t *dataStreamName,
utf8_t *readLibrary,
utf8_t *readRoutine,
utf8_t *readParm,
utf8_t *writeLibrary,
utf8_t *writeRoutine,
utf8_t *writeParm,
BOOL useCookieRead,
NINT *filePos);
STATUS VIRT_MakeDataTypeDataStream(
Key_t key,
utf8_t *dataStreamName,
utf8_t *data,
NINT *filePos);
STATUS VIRT_testCommand(
NINT parmLen,
utf8_t *parm,
NINT dataLen,
BYTE *data,
NINT offset,
VirtInfo_s *virtInfo);
STATUS VIRT_testCookieRead(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS VIRT_testRead(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS VIRT_testWrite(
NINT parmLen,
utf8_t *parm,
NINT dataLen,
BYTE *data,
NINT offset,
VirtInfo_s *virtInfo);
#endif
#endif /* __KERNEL__ */
#include <public/zParams.h>
STATUS VIRT_CheckResultSize (
VirtInfo_s *virtInfo,
NINT dataLen);
STATUS VFS_ssprintf(
NINT bLen,
BYTE **bAdd,
NINT *rLen,
const char *format,
...);
STATUS VIRT_ssprintf(
VirtInfo_s *virtInfo,
const char *format,
...);
STATUS VIRT_AddUnicode( VirtInfo_s *virtInfo, unicode_t *uniName );
#endif /* _VIRTUALIO_H_ */