0566 nwnss: import COMN semantic agent message helpers
This commit is contained in:
@@ -106,6 +106,7 @@ add_library(nwnss SHARED
|
||||
comn/common/comnMacShortName.c
|
||||
comn/common/comnUnicode.c
|
||||
comn/common/registerLSS.c
|
||||
comn/common/sazLib.c
|
||||
comn/common/comnVariableData.c
|
||||
comn/common/zAPI.c
|
||||
comn/namespace/dosNSWild.c
|
||||
|
||||
320
src/nwnss/comn/common/sazLib.c
Normal file
320
src/nwnss/comn/common/sazLib.c
Normal file
@@ -0,0 +1,320 @@
|
||||
/****************************************************************************
|
||||
|
|
||||
| (C) Copyright 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 (NSS) Z Semantic Agent libarary
|
||||
|
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| $Author: vandana $
|
||||
| $Date: 2006-06-27 02:37:42 +0530 (Tue, 27 Jun 2006) $
|
||||
|
|
||||
| $RCSfile$
|
||||
| $Revision: 1425 $
|
||||
|
|
||||
|---------------------------------------------------------------------------
|
||||
| This module is used to:
|
||||
| This contains the support routines for the "Z" Semantic Agent.
|
||||
+-------------------------------------------------------------------------*/
|
||||
#include <string.h>
|
||||
#include <pssDebug.h> /* NSS Library Includes*/
|
||||
#include <xError.h>
|
||||
|
||||
#include "fileHandle.h"
|
||||
#include <stdint.h>
|
||||
#include "msgName.h"
|
||||
#include "zParams.h"
|
||||
#include "fsmsg.h"
|
||||
#include "comnBeasts.h"
|
||||
#include "volume.h"
|
||||
|
||||
zMatchAttr_s *setMatchAttribute (zMatchAttr_s *matchAttr, NINT match)
|
||||
{
|
||||
if ((match == zMATCH_ALL) || (match == 0))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
bzero(matchAttr, sizeof(zMatchAttr_s));
|
||||
|
||||
if (match & zMATCH_HIDDEN)
|
||||
{
|
||||
matchAttr->matchFileAttrSet |= zFA_HIDDEN;
|
||||
}
|
||||
if (match & zMATCH_NON_HIDDEN)
|
||||
{
|
||||
matchAttr->matchFileAttrNotSet |= zFA_HIDDEN;
|
||||
}
|
||||
if (match & zMATCH_DIRECTORY)
|
||||
{
|
||||
matchAttr->matchFileAttrSet |= zFA_SUBDIRECTORY;
|
||||
}
|
||||
if (match & zMATCH_NON_DIRECTORY)
|
||||
{
|
||||
matchAttr->matchFileAttrNotSet |= zFA_SUBDIRECTORY;
|
||||
}
|
||||
if (match & zMATCH_SYSTEM)
|
||||
{
|
||||
matchAttr->matchFileAttrSet |= zFA_SYSTEM;
|
||||
}
|
||||
if (match & zMATCH_NON_SYSTEM)
|
||||
{
|
||||
matchAttr->matchFileAttrNotSet |= zFA_SYSTEM;
|
||||
}
|
||||
return matchAttr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup name message for pattern matching interfaces (zWildRead).
|
||||
*/
|
||||
STATUS MSG_InitPatternMsg (
|
||||
zNSSMsg_s *msg,
|
||||
NamingMsg_s *nameMsg,
|
||||
zMatchAttr_s *matchAttr,
|
||||
NINT *srchOpt)
|
||||
{
|
||||
FileHandle_s *fileHandle = (FileHandle_s *)msg->sys.door;
|
||||
|
||||
COMN_INIT_NAMING_MSG(nameMsg);
|
||||
|
||||
if (fileHandle->file == NULL)
|
||||
{
|
||||
SetStatus(msg, zERR_BAD_PARAMETER_VALUE);
|
||||
return zFAILURE;
|
||||
}
|
||||
COMN_SET_FILEHANDLE( &nameMsg->fileHandle, fileHandle->door.dr_key,
|
||||
fileHandle);
|
||||
|
||||
if (fileHandle->file->FILEattributes & zFA_IS_LINK)
|
||||
{
|
||||
COMN_SET_NAMING_MSG_OPERATE_ON_LINK(nameMsg);
|
||||
}
|
||||
|
||||
nameMsg->pathCount = 0; /* NOT USED */
|
||||
nameMsg->pathLength = 0; /* NOT USED */
|
||||
nameMsg->match = setMatchAttribute(matchAttr, msg->body.wild.match);
|
||||
nameMsg->parseMode = NAMPMODE_Undefined;
|
||||
|
||||
nameMsg->handlePathType = zHPT_SEARCH_PATTERN;
|
||||
|
||||
nameMsg->nameSpaceID = fileHandle->dataStreamNameSpaceID;
|
||||
switch (msg->body.wild.nameType)
|
||||
{
|
||||
case zNTYPE_FILE:
|
||||
case zNTYPE_DATA_STREAM:
|
||||
case zNTYPE_EXTENDED_ATTRIBUTE:
|
||||
case zNTYPE_DELETED_FILE:
|
||||
nameMsg->nameType = msg->body.wild.nameType;
|
||||
break;
|
||||
default:
|
||||
SetStatus(msg, zERR_BAD_PARAMETER_VALUE);
|
||||
return zFAILURE;
|
||||
}
|
||||
if (msg->sys.numDataAreas == 1)
|
||||
{
|
||||
/* No pattern, set MATCH ALL */
|
||||
nameMsg->pathFormat = 0;
|
||||
*srchOpt = SMAPOPT_32BitMode | SMAPOPT_matchAllEntries;
|
||||
nameMsg->handlePathType = zHPT_VOLUME_ZID;
|
||||
nameMsg->path.voidPtr = NULL;
|
||||
}
|
||||
else if (msg->sys.numDataAreas == 2)
|
||||
{
|
||||
switch (msg->body.wild.characterCode)
|
||||
{
|
||||
case zPFMT_UTF8:
|
||||
case zPFMT_UNICODE:
|
||||
nameMsg->pathFormat = msg->body.wild.characterCode;
|
||||
break;
|
||||
default:
|
||||
SetStatus(msg, zERR_BAD_PARAMETER_VALUE);
|
||||
return zFAILURE;
|
||||
}
|
||||
*srchOpt = SMAPOPT_32BitMode;
|
||||
nameMsg->path.voidPtr = (void *)(uintptr_t)msg->sys.data[PATTERN_DATA].start;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStatus(msg, zERR_BAD_PARAMETER_VALUE);
|
||||
return zFAILURE;
|
||||
}
|
||||
nameMsg->latchType = SLATCHED;
|
||||
|
||||
return zOK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup name message for zMSG based interfaces.
|
||||
*/
|
||||
STATUS MSG_InitNameMsg (
|
||||
zNSSMsg_s *msg,
|
||||
NamingMsg_s *nameMsg,
|
||||
void *name,
|
||||
NINT nameSpace,
|
||||
NINT latchType)
|
||||
{
|
||||
FileHandle_s *fileHandle = (FileHandle_s *)msg->sys.door;
|
||||
|
||||
COMN_INIT_NAMING_MSG(nameMsg);
|
||||
|
||||
nameMsg->pathCount = 0; /* NOT USED */
|
||||
nameMsg->pathLength = 0; /* NOT USED */
|
||||
nameMsg->match = NULL; /* NOT USED */
|
||||
nameMsg->parseMode = NAMPMODE_Undefined;
|
||||
nameMsg->master = (struct Master_s *)msg->sys.owner;
|
||||
|
||||
if (nameSpace & zMODE_UTF8)
|
||||
{
|
||||
nameMsg->pathFormat = zPFMT_UTF8;
|
||||
}
|
||||
else
|
||||
{
|
||||
nameMsg->pathFormat = zPFMT_UNICODE;
|
||||
}
|
||||
nameMsg->nameSpaceID = nameSpace & 0xff;
|
||||
if (nameSpace & zMODE_DELETED)
|
||||
{
|
||||
nameMsg->nameType = zNTYPE_DELETED_FILE;
|
||||
}
|
||||
else switch (nameMsg->nameSpaceID)
|
||||
{
|
||||
case zNSPACE_DATA_STREAM:
|
||||
nameMsg->nameType = zNTYPE_DATA_STREAM;
|
||||
break;
|
||||
|
||||
case zNSPACE_EXTENDED_ATTRIBUTE:
|
||||
nameMsg->nameType = zNTYPE_EXTENDED_ATTRIBUTE;
|
||||
break;
|
||||
|
||||
case zNSPACE_DOS:
|
||||
case zNSPACE_MAC:
|
||||
case zNSPACE_UNIX:
|
||||
case zNSPACE_LONG:
|
||||
default:
|
||||
nameMsg->nameType = zNTYPE_FILE;
|
||||
break;
|
||||
}
|
||||
if (nameSpace & zMODE_LINK)
|
||||
{
|
||||
COMN_SET_NAMING_MSG_OPERATE_ON_LINK(nameMsg);
|
||||
}
|
||||
nameMsg->match = NULL;
|
||||
nameMsg->path.voidPtr = name;
|
||||
if (fileHandle->file != NULL)
|
||||
{
|
||||
nameMsg->handlePathType = zHPT_BEAST;
|
||||
|
||||
COMN_SET_FILEHANDLE( &nameMsg->fileHandle, fileHandle->door.dr_key,
|
||||
fileHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
nameMsg->handlePathType = zHPT_SIMPLE;
|
||||
}
|
||||
nameMsg->latchType = latchType;
|
||||
|
||||
return zOK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup name message for zMSG based interfaces.
|
||||
*/
|
||||
STATUS MSG_InitZidNameMsg (
|
||||
zNSSMsg_s *msg,
|
||||
NamingMsg_s *nameMsg,
|
||||
Zid_t zid,
|
||||
void *name,
|
||||
NINT nameSpace,
|
||||
NINT latchType)
|
||||
{
|
||||
FileHandle_s *fh = (FileHandle_s *)msg->sys.door;
|
||||
VolumeID_t *volumeID;
|
||||
NINT nameType;
|
||||
NINT pathFormat;
|
||||
|
||||
if (msg->body.id.internalFlags & HAVE_VOLUME_ID)
|
||||
{
|
||||
volumeID = &msg->body.byZid.volumeID;
|
||||
}
|
||||
else if (fh->file)
|
||||
{
|
||||
volumeID = &fh->file->FILEvolume->volumeID;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStatus(msg, zERR_BAD_PARAMETER_VALUE);
|
||||
return zFAILURE;
|
||||
}
|
||||
COMN_INIT_NAMING_MSG(nameMsg);
|
||||
|
||||
nameMsg->master = (struct Master_s *)msg->sys.owner;
|
||||
|
||||
if (nameSpace & zMODE_UTF8)
|
||||
{
|
||||
pathFormat = zPFMT_UTF8;
|
||||
}
|
||||
else
|
||||
{
|
||||
pathFormat = zPFMT_UNICODE;
|
||||
}
|
||||
if (nameSpace & zMODE_DELETED)
|
||||
{
|
||||
nameType = zNTYPE_DELETED_FILE;
|
||||
}
|
||||
else switch (nameSpace & 0xff)
|
||||
{
|
||||
case zNSPACE_DATA_STREAM:
|
||||
nameType = zNTYPE_DATA_STREAM;
|
||||
break;
|
||||
|
||||
case zNSPACE_EXTENDED_ATTRIBUTE:
|
||||
nameType = zNTYPE_EXTENDED_ATTRIBUTE;
|
||||
break;
|
||||
|
||||
case zNSPACE_DOS:
|
||||
case zNSPACE_MAC:
|
||||
case zNSPACE_UNIX:
|
||||
case zNSPACE_LONG:
|
||||
default:
|
||||
nameType = zNTYPE_FILE;
|
||||
break;
|
||||
}
|
||||
COMN_SETUP_NAMING_MSG_VOLUME_ZID_PATH(nameMsg,
|
||||
*volumeID, /* volumeID */
|
||||
/* cnt zFNU_FIRST_PARENT, fileNameUniquifier */
|
||||
zid, /* fileZid */
|
||||
nameType, /* file type */
|
||||
name, /* path name */
|
||||
pathFormat, /* path format */
|
||||
NAMPMODE_Undefined, /* parse mode */
|
||||
XLATCHED, /* latchType */
|
||||
(nameSpace & 0xff), /* nameSpaceID */
|
||||
zNTYPE_FILE, /* nameType */
|
||||
NULL, /* match */
|
||||
0, /* _retPLen */
|
||||
NULL, /* _retVolume */
|
||||
NULL); /* _retpath */
|
||||
|
||||
if (nameSpace & zMODE_LINK)
|
||||
{
|
||||
COMN_SET_NAMING_MSG_OPERATE_ON_LINK(nameMsg);
|
||||
}
|
||||
return zOK;
|
||||
}
|
||||
@@ -52,6 +52,8 @@
|
||||
|
||||
extern VersionInformation_s CMN_VersionInfo;
|
||||
|
||||
extern zMatchAttr_s *setMatchAttribute(zMatchAttr_s *matchAttr, NINT match);
|
||||
|
||||
#define CHECK(expr) do { \
|
||||
if (!(expr)) { \
|
||||
fprintf(stderr, "CHECK failed: %s:%d: %s\n", __FILE__, __LINE__, #expr); \
|
||||
@@ -167,6 +169,17 @@ int main(void)
|
||||
CHECK(CMN_VersionInfo.majorVersion >= 0);
|
||||
CHECK(CMN_VersionInfo.patentInfo == VERINFO_PATENT_PENDING);
|
||||
|
||||
{
|
||||
zMatchAttr_s match_attr;
|
||||
CHECK(setMatchAttribute(&match_attr, zMATCH_ALL) == NULL);
|
||||
CHECK(setMatchAttribute(&match_attr, zMATCH_HIDDEN | zMATCH_DIRECTORY) == &match_attr);
|
||||
CHECK((match_attr.matchFileAttrSet & zFA_HIDDEN) != 0);
|
||||
CHECK((match_attr.matchFileAttrSet & zFA_SUBDIRECTORY) != 0);
|
||||
CHECK((match_attr.matchFileAttrNotSet & zFA_SYSTEM) == 0);
|
||||
CHECK(setMatchAttribute(&match_attr, zMATCH_NON_SYSTEM) == &match_attr);
|
||||
CHECK((match_attr.matchFileAttrNotSet & zFA_SYSTEM) != 0);
|
||||
}
|
||||
|
||||
{
|
||||
unicode_t unicode_name[32];
|
||||
char byte_name[32];
|
||||
|
||||
Reference in New Issue
Block a user