Files
mars-nwe/include/nwnss/internal/mgmt.h

668 lines
21 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
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: blarsen $
| $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $
|
| $RCSfile$
| $Revision: 1325 $
|
|---------------------------------------------------------------------------
| This module is used to:
| Manage name space code.
+-------------------------------------------------------------------------*/
#ifndef _MGMT_H_
#define _MGMT_H_
#ifdef MARS_NWE_NWNSS_USERSPACE
typedef struct Volume_s Volume_s;
typedef struct Pool_s Pool_s;
#endif
#ifndef _MANAGE_H_
#include <manage.h>
#endif
#if zNETWARE || (zLINUX && defined(__KERNEL__))
#ifndef _ADMINVOLUME_H_
#include <adminVolume.h>
#endif
#ifndef _XMLNSS_H_
#include <xmlNSS.h>
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
//extern BOOL ComnMgmtFileSetup;
#define MAX_UTF8_BUF_SIZE ((zMAX_FULL_NAME + 1) * sizeof(utf8_t) * 3)
#if zNETWARE || zLINUX
/****************************************************************************
* Type definition used by Management files *
****************************************************************************/
#define AVFILEDIRATTR (zFA_SUBDIRECTORY | zFA_RENAME_INHIBIT | \
zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT)
#define AVFILEFILEATTR (zFA_DELETE_INHIBIT | zFA_RENAME_INHIBIT | \
zFA_COPY_INHIBIT | zFA_VOLATILE)
extern QUAD AVFileDirEOF;
extern QUAD AVFileFileEOF;
typedef struct AVFileLink_s
{
BYTE *path;
DQlink_t link;
}AVFileLink_s;
#endif
/*--------------------------------------------------------------------------*
* Functions for virtual files
*--------------------------------------------------------------------------*/
void MGMT_BuildResultNSS(
STATUS result,
utf8_t *buffer);
STATUS MGMT_ReturnResultNSS(
VirtInfo_s *virtInfo,
STATUS status);
void MGMT_BuildResultElement(
STATUS result,
utf8_t *description,
utf8_t *buffer);
#if NSS_DEBUG IS_ENABLED
STATUS DBG_EqualS(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
#endif
/*--------------------------------------------------------------------------*
* Functions for NSS static management files *
*--------------------------------------------------------------------------*/
#if zNETWARE || zLINUX
STATUS AVFileAddLink(
DQhead_t *RegMgmtFilesHead,
BYTE *pathStr);
STATUS AVFileRemoveLink(
DQhead_t *RegMgmtFilesHead,
BYTE *pathStr);
/*--------------------------------------------------------------------------*
* Functions for NSS static management files *
*--------------------------------------------------------------------------*/
extern STATUS MGMT_StartupReadInsts(
struct GeneralMsg_s *genMsg);
extern void MGMT_ShutdownReadInsts();
/*--------------------------------------------------------------------------*
* Functions for volume management files *
*--------------------------------------------------------------------------*/
extern STATUS addVolumeMgmtFile(GeneralMsg_s *genMsg, unicode_t *volumeName);
extern void removeVolumeMgmtFileByName(GeneralMsg_s *genMsg, unicode_t *volName);
extern void removeVolumeMgmtFile(GeneralMsg_s *genMsg, void *volume);
STATUS findVolume(
char *volName,
Volume_s **volume); /* out */
/*--------------------------------------------------------------------------*
* Functions for pool management files *
*--------------------------------------------------------------------------*/
extern STATUS addPoolMgmtFile(GeneralMsg_s *genMsg, unicode_t *poolName);
extern void removePoolMgmtFileByName(GeneralMsg_s *genMsg, unicode_t *poolName);
extern void removePoolMgmtFile(GeneralMsg_s *genMsg, void *pool);
/*--------------------------------------------------------------------------*
* Functions for server management files *
*--------------------------------------------------------------------------*/
extern STATUS MGMT_StartupOS();
extern void MGMT_ShutdownOS();
/*--------------------------------------------------------------------------*
* Functions for connection management files *
*--------------------------------------------------------------------------*/
extern void CNCT_addMgmtFile(SNINT connNum);
#ifdef ADMIN_NSS
///*--------------------------------------------------------------------------*
// * Functions for NSS XSL file *
// *--------------------------------------------------------------------------*/
///* NSS data type tag, tags are always appear as pairs. */
//#define NSSNONE 0 /* every element is preformatted */
//#define NSSNUMBER 2 /* the tag will be <NSSNUMBER> */
//#define NSSSTRING 4 /* the tag will be <NSSSTRING> */
//#define NSSPERCENT 6 /* the tag will be <NSSNUMBER percent="1"> */
//
//extern BYTE *NSStag[];
//
///* XML Form method */
//#define NONE 0
//#define PUT 1
//#define POST 2
//#define GET 3
//
//typedef struct XML_s
//{
// /* In this stucture, except data.content can not be NULL, everything else *
// * can be NULL. Every string should be NULL terminated if they are not NULL */
// BYTE *fname; /* file name, can be full path or single */
// /* name only */
// struct /* parts inside <NSS> tag. Normally this */
// { /* is the part where we put data. */
// NINT type; /* which type of data. can be number, string, */
// /* percent (0 < x < 100). If it's NSSNONE, */
// /* content is formated, can be used directory */
// /* This happens when more than one data types */
// /* are presented, or when data type has attributes */
// /* in it. */
// BYTE *content; /* data. can be formatted or unformatted, depends */
// /* on which data type it's using. Note, digits are*/
// /* in ASCII format */
// BYTE *desc; /* if not NULL, description for the content */
// BYTE *misc; /* currently, if not NULL: */
// /* if type is NSSNUMBER, it adds label element */
// /* for the purpose of display of percent */
// /* attribute. */
// /* if type is NSSNONE, it's assumed to be preformatted */
// /* and will be used directly */
// }data;
// struct /* if this file needs a way to write */
// { /* By default, we provide a FORM method to write */
// BOOL isWritable; /* if true, file is writable */
// NINT method; /* which form method to use */
// BYTE *action; /* which action to take */
// BYTE *done; /* where to go after done */
// BYTE *prompt; /* prompt for the action */
// }write;
//}XML_s;
//
////#define XML_INIT(_nameMsg) (LB_bzero((_nameMsg), sizeof(XML_s)))
//
//extern STATUS MGMT_StartupXSLPath();
//extern void MGMT_ShutdownXSLPath();
//
//extern STATUS XMLConvert(
// BYTE *path,
// BYTE *data,
// NINT type,
// BYTE *desc,
// BYTE *misc,
// NINT method,
// BYTE *action,
// BYTE *done,
// BYTE *prompt,
// BYTE *buffer,
// NINT bufferLength);
//
//extern void XMLUnConvert(
// BYTE *buffer,
// size_t bufLen,
// BYTE *content,
// size_t *retLen,
// void *number,
// BOOL *isQuad,
// NINT *type);
#endif
// Needed to load the CONONE.NSS and import functions from this NLM.
#define CONONE_NLM_NAME "CONONE.NSS"
#define CONONE_NLM MSGNot("\x0a" "CONONE.NSS")
extern struct LoadDefinitionStructure *CMN_ModuleHandle;
extern struct ScreenStruct *CMN_DefaultScreen;
extern void LoadCONONEnlm(zWorkProc_s *work);
void ScheduleCONONELoad(void);
#define NLM_NOT_LOADED 0x00000000
#define NLM_LOADED 0x00000001
#define NLM_LOADING 0x00000002
#define NLM_UNLOADING 0x00000003
typedef struct ConOneInfo_s
{
zWorkProc_s event; /*- work to do structure to do load CONONE nlm event -*/
NINT eventflag; /*- flag for event in use -*/
} ConOneInfo_s;
STATUS volume_dirInfo(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS volume_getExtendedInfo(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo,
Volume_s *volume);
STATUS volume_getInfo(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS volume_userInfo(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS pool_volumes(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS pool_info(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS OS_setParmRead(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS OS_setParmCommand(
NINT parmLen,
utf8_t *parm,
NINT bufferLength,
BYTE *buffer,
NINT offset,
VirtInfo_s *virtInfo);
STATUS pool_blockSize(
VirtInfo_s *virtInfo,
Pool_s *pool);
STATUS pool_salFreeableSize(
VirtInfo_s *virtInfo,
Pool_s *pool);
STATUS pool_salNonFreeableSize(
VirtInfo_s *virtInfo,
Pool_s *pool);
STATUS pool_salMinKeepSeconds(
VirtInfo_s *virtInfo,
Pool_s *pool);
STATUS pool_salMaxKeepSeconds(
VirtInfo_s *virtInfo,
Pool_s *pool);
STATUS pool_salLowWaterMark(
VirtInfo_s *virtInfo,
Pool_s *pool);
STATUS pool_salHighWaterMark(
VirtInfo_s *virtInfo,
Pool_s *pool);
STATUS MGMT_readOverride(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS MGMT_MakeFunctionVirtualFileWithHelp(
Key_t key,
utf8_t *help,
utf8_t *readRoutine,
utf8_t *readParm,
utf8_t *writeRoutine,
utf8_t *writeParm,
BOOL withCookie);
STATUS EFL_ControlReadFunc(
NINT parmLen,
utf8_t *parm,
VirtInfo_s *virtInfo);
STATUS EFL_ControlWriteFunc(
NINT parmLen,
utf8_t *parm,
NINT dataLen,
BYTE *data,
NINT offset,
VirtInfo_s *virtInfo);
STATUS COMN_VolumeCommonOpsViaVirtualFile(
NINT parmLen,
utf8_t *parm,
NINT dataLen,
BYTE *data,
NINT offset,
VirtInfo_s *virtInfo);
#endif
void MGMT_BuildResultNSSWithSetter(
STATUS result,
utf8_t *resultSetter,
utf8_t *buffer);
STATUS MGMT_ReturnResultNSSWithSetter(
struct VirtInfo_s *virtInfo,
STATUS result,
utf8_t *resultSetter );
STATUS MGMT_ErrNoAndErrNoSetterSet(
struct VirtInfo_s *virtInfo,
struct GeneralMsg_s *genMsg );
STATUS MNSS_GetNextTagString(
utf8_t *tagString, /* <Tag1><Tag2>...<TagN> */
utf8_t **tagStringOut, /* Output - Next 'tagString' */
NINT tagLen, /* Length of 'tagName' buffer. */
utf8_t *tagName ); /* Found Tag */
STATUS MNSS_GetSpecificTemplate(
utf8_t *tagString, /* Must be "<tag1><tag2>...<tagN>" */
NINT templateLen,
utf8_t *template,
XML_ElementInfo_s *resultInfo );
STATUS MNSS_GetResultTemplate(
utf8_t *tagString, /* Must be "<tag1><tag2>...<tagN>" */
NINT templateLen,
utf8_t *template,
XML_ElementInfo_s *resultInfo );
STATUS MNSS_GetResultValueAttribute(
utf8_t *tagString, /* Must be "<tag1><tag2>...<tagN>" */
NINT templateLen,
utf8_t *template,
SQUAD *sqValue ); /* Output - Value of Results 'value'
* attribute.
*/
/* Result macros that will generate the "result" items in-line */
#define MNSS_BuildResult( _vi, _r, _desc ) \
MNSS_BuildResult2( _vi, _r, _desc, WHERE, NULL )
#define MNSS_BuildResultWithOrigin( _vi, _r, _desc, _errnoSetter ) \
MNSS_BuildResult2( _vi, _r, _desc, WHERE, _errnoSetter )
/* Result macros that will place the "result" within the supplied 'tag' */
#define MNSS_ReturnResult( _vi, _tag, _r, _desc ) \
MNSS_ReturnResult2( _vi, _tag, _r, _desc, WHERE, NULL )
#define MNSS_ReturnResultWithOrigin( _vi, _tag, _r, _desc, _errnoSetter ) \
MNSS_ReturnResult2( _vi, _tag, _r, _desc, WHERE, _errnoSetter )
void MNSS_ReturnResult2(
struct VirtInfo_s *virtInfo,
utf8_t *tag,
LONG result, /* This is NOT always a zERR code */
utf8_t *desc,
char *where1,
char *where2);
void MNSS_BuildResult2(
struct VirtInfo_s *virtInfo,
LONG result, /* This is NOT always a zERR code */
utf8_t *desc,
char *where1, /* Where MNSS_Build... was called from */
char *where2); /* Where 'result' was set. Can be NULL
* because MM and other callers may not
* track. For NSS, generally called
* with GetErrnoSetter().
*/
extern NINT attrBitsToCheck;
extern utf8_t *attrTags[];
STATUS MNSS_ConvertBitsToTags(
QUAD value,
QUAD bitsToCheck,
utf8_t *tags[],
NINT bufLen,
utf8_t *buf,
NINT *dataLen);
QUAD MNSS_ConvertTagsToBits(
QUAD bitsToCheck,
utf8_t **tags,
utf8_t *buf,
NINT bufLen);
SNINT MNSS_ConvertNameSpaceTagsToValue(
utf8_t *nsStr);
SNINT MNSS_ConvertNameTypeTagsToValue(
utf8_t *ntStr);
#if zNETWARE || (zLINUX && !defined(__KERNEL__))
void LogoutFromNDS(
int context,
int agentIdentityHandle);
NINT LoginToNDS(
int context,
int *agentIdentityHandle);
void MNSS_ConvertToRootLeft(
utf8_t *name,
utf8_t *newName);
STATUS MNSS_GetObjectIDFromName(
utf8_t *container,
utf8_t *name,
LONG *objectID);
#define MNDS_GetObjectIDFromName MNSS_GetObjectIDFromName
#endif
STATUS MNSS_GetNDSNameFromGUID(
// Volume_s *volume,
void *volume,
UserID_t *guid,
utf8_t *objectName);
#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(MARS_NWE_NWNSS_USERSPACE)))
#if zLINUX
STATUS MNSS_FindUserIDByDN(
unsigned char *context,
unsigned char *dn,
UserID_t *userID);
#define MFILE_FindUserIDByDN MNSS_FindUserIDByDN
#endif
STATUS MNSS_FillUTCTime(
utf8_t *tag,
Time_t time,
NINT bufLen,
utf8_t *buf,
NINT *dataLen);
STATUS MNSS_FillInAnID(
utf8_t *tag,
UserID_t *id,
NINT bufLen,
utf8_t *buf,
NINT *dataLen);
STATUS MNSS_GetGUIDFromName(
utf8_t *name,
UserID_t *ndsGUID);
STATUS getModifyValue(
GeneralMsg_s *genMsg,
XML_ElementInfo_s *element,
utf8_t **oldValueStr,
utf8_t **newValueStr);
STATUS modifyInfoTimeStr(
GeneralMsg_s *genMsg,
void *beast,
ADDR address,
XML_ElementInfo_s *element,
Xaction_s *xaction,
BOOL doChange);
STATUS modifyTimeXML(
GeneralMsg_s *genMsg,
void *beast,
XML_ElementInfo_s *element,
ADDR address,
Xaction_s *xaction,
BOOL doChange);
STATUS modifyIDXML(
GeneralMsg_s *genMsg,
void *beast,
XML_ElementInfo_s *element,
ADDR address,
Xaction_s *xaction,
BOOL doChange);
STATUS modifyInfoBOOL(
GeneralMsg_s *genMsg,
void *beast,
ADDR address,
XML_ElementInfo_s *element,
Xaction_s *xaction,
BOOL doChange);
#define modifyInfoNumber(genMsg, beast, type, isSigned, address, element) \
{ \
type oldValue; \
type newValue; \
utf8_t *oldValueStr = NULL; \
utf8_t *newValueStr = NULL; \
\
getModifyValue(genMsg, element, &oldValueStr, &newValueStr); \
if (status == zOK) \
{ \
if (!newValueStr || !oldValueStr) \
{ \
SetErrno(genMsg, zERR_XML_IS_BAD); \
status = zFAILURE; \
} \
else \
{ \
if (sizeof(type) == sizeof(QUAD)) \
{ \
if (isSigned) \
{ \
oldValue = strtoq(oldValueStr, NULL, 10); \
newValue = strtoq(newValueStr, NULL, 10); \
} \
else \
{ \
oldValue = strtouq(oldValueStr, NULL, 10); \
newValue = strtouq(newValueStr, NULL, 10); \
} \
} \
else if (sizeof(type) <= sizeof(LONG)) \
{ \
if (isSigned) \
{ \
oldValue = strtol(oldValueStr, NULL, 10); \
newValue = strtol(newValueStr, NULL, 10); \
} \
else \
{ \
oldValue = strtoul(oldValueStr, NULL, 10); \
newValue = strtoul(newValueStr, NULL, 10); \
} \
} \
\
setNumberValueXML(genMsg, beast, type, address, NULL); \
} \
} \
if (status != zOK) \
{ \
goto Exit; \
} \
}
typedef STATUS (*mgmt_change_func_t)(GeneralMsg_s *, void *, void *, void *, Xaction_s *);
#define setNumberValueXML(genMsg, beast, type, address, changeFunc) \
{ \
if (!doChange) \
{ \
if (memcmp((void *)address, (void *)&oldValue, sizeof(type))) \
{ \
SetErrno(genMsg, zERR_VALUE_CHANGED); \
status = zFAILURE; \
} \
} \
else \
{ \
memcpy((void *)address, (void *)&newValue, sizeof(type)); \
if (((mgmt_change_func_t)changeFunc) != NULL) \
{ \
status = ((mgmt_change_func_t)changeFunc)(genMsg, beast, &oldValue, &newValue, xaction); \
} \
} \
}
#define modifyFlagsInfoXML(genMsg, beast, type, address, element, bitsToCheck, tags, changeFunc) \
{ \
utf8_t *oldValueStr = NULL; \
utf8_t *newValueStr = NULL; \
type oldValue = 0; \
type newValue = 0; \
\
status = getModifyValue(genMsg, element, &oldValueStr, &newValueStr); \
if (status != zOK) \
{ \
goto Exit; \
} \
\
if (oldValueStr) \
{ \
oldValue = (type)MNSS_ConvertTagsToBits(bitsToCheck, tags, oldValueStr, strlen(oldValueStr)); \
} \
if (newValueStr) \
{ \
newValue = (type)MNSS_ConvertTagsToBits(bitsToCheck, tags, newValueStr, strlen(newValueStr)); \
} \
\
setNumberValueXML(genMsg, beast, type, address, changeFunc); \
if (status != zOK) \
{ \
goto Exit; \
} \
}
#endif
#ifdef __cplusplus
}
#endif
#endif