XFS_EXTERN rc_t CC XFSTreeFindNodeForPath ( const struct XFSTree * self, const struct VPath * Path, const struct XFSNode ** Node ) { rc_t RCt; char Buf [ XFS_SIZE_4096 ]; RCt = 0; * Buf = 0; if ( self == NULL || Path == NULL || Node == NULL ) { return XFS_RC ( rcNull ); } * Node = NULL; RCt = XFS_ReadVPath_ZHR ( Path, Buf, sizeof ( Buf ) , "" ); if ( RCt == 0 ) { RCt = XFSTreeFindNode ( self, Buf, Node ); } return RCt; } /* XFSTreeFindNodeForPath () */
LIB_EXPORT rc_t CC XFSOwpListKeys ( const struct XFSOwp * self, const struct KNamelist ** Keys ) { rc_t RCt; struct VNamelist * List; RCt = 0; if ( self == NULL || Keys == NULL ) { return XFS_RC ( rcNull ); } * Keys = NULL; RCt = VNamelistMake ( & List, 16 /* ?? */ ); if ( RCt == 0 ) { BSTreeForEach ( ( BSTree * ) self, false, _ListKeysCallback, List ); RCt = VNamelistToConstNamelist ( List, Keys ); VNamelistRelease ( List ); } return RCt; } /* XFSOwpListKeys () */
rc_t CC _DocNodeFile_v1 ( const struct XFSNode * self, const struct XFSFileEditor ** File ) { rc_t RCt; struct XFSDocFileEditor * FileEditor; struct XFSFileEditor * Editor; RCt = 0; FileEditor = NULL; Editor = NULL; if ( self == NULL || File == NULL ) { return XFS_RC ( rcNull ); } * File = NULL; FileEditor = calloc ( 1, sizeof ( struct XFSDocFileEditor ) ); if ( FileEditor == NULL ) { return XFS_RC ( rcExhausted ); } Editor = & ( FileEditor -> Papahen ); RCt = XFSEditorInit ( & ( Editor -> Papahen ), self, _DocFile_dispose_v1 ); if ( RCt == 0 ) { Editor -> open = _DocFile_open_v1; Editor -> close = _DocFile_close_v1; Editor -> read = _DocFile_read_v1; Editor -> write = NULL; * File = Editor; } else { free ( Editor ); } return RCt; } /* _DocNodeFile_v1 () */
static rc_t CC _DocNodeAttr_v1 ( const struct XFSNode * self, const struct XFSAttrEditor ** Attr ) { rc_t RCt; struct XFSAttrEditor * Editor; RCt = 0; Editor = NULL; if ( Attr != NULL ) { * Attr = NULL; } if ( self == NULL || Attr == NULL ) { return XFS_RC ( rcNull ); } Editor = calloc ( 1, sizeof ( struct XFSAttrEditor ) ); if ( Editor == NULL ) { return XFS_RC ( rcExhausted ); } RCt = XFSEditorInit ( & ( Editor -> Papahen ), self, _DocAttr_dispose_v1 ); if ( RCt == 0 ) { Editor -> permissions = _DocAttr_permissions_v1; Editor -> set_permissions = NULL; Editor -> date = _DocAttr_date_v1; Editor -> set_date = NULL; Editor -> type = _DocAttr_type_v1; * Attr = Editor; } else { free ( Editor ); } return RCt; } /* _DocNodeAttr_v1 () */
static rc_t CC _KartCollectionNodeConstructorEx ( const struct XFSModel * Model, const struct XFSModelNode * Template, const char * Alias, XFSNType Type, const struct XFSNode ** Node ) { rc_t RCt; struct XFSNode * TheNode; const char * NodeName; const char * Path; RCt = 0; TheNode = NULL; NodeName = NULL; Path = NULL; if ( Model == NULL || Template == NULL || Node == NULL ) { return XFS_RC ( rcNull ); } * Node = NULL; NodeName = Alias == NULL ? XFSModelNodeName ( Template ) : Alias; Path = XFSModelNodeProperty ( Template, XFS_MODEL_SOURCE ); if ( Path != NULL ) { RCt = XFSKartCollectionNodeMake ( NodeName, Path, XFSModelNodeSecurity ( Template ), & TheNode ); } else { RCt = _KartCollectionNodeMakeFromModel ( NodeName, Model, Template, & TheNode ); } if ( RCt == 0 ) { * Node = TheNode; } else { * Node = NULL; if ( TheNode != NULL ) { XFSNodeDispose ( TheNode ); } } return RCt; } /* _KartCollectionNodeConstructorEx () */
static rc_t CC XFS_ReadCEverything_ZHR ( const char * Url, char * Buffer, size_t BufferSize, const char * Filler, XFS_ReadV_ZHR Reader ) { rc_t RCt; size_t NR; const char * DefaultFiller = "NULL"; struct VPath * Path; RCt = 0; NR = 0; Path = NULL; if ( Buffer == NULL || BufferSize <= 0 ) { return XFS_RC ( rcNull ); } * Buffer = 0; if ( Url == NULL ) { RCt = XFS_RC ( rcNull ); string_copy_measure ( Buffer, sizeof ( Buffer ), ( Filler == NULL ? DefaultFiller : Filler ) ); } else { RCt = VFSManagerMakePath ( XFS_VfsManager (), & Path, Url ); if ( RCt == 0 ) { RCt = Reader ( Path, Buffer, BufferSize, & NR ); VPathRelease ( Path ); } } return RCt; } /* XFS_ReadCEverything_ZHR () */
static rc_t CC _TeleportAdd ( const char * Name, XFSTeleportProvider_t Provider ) { rc_t RCt; struct _TNode * Tde; RCt = 0; if ( Name == NULL || Provider == NULL ) { return XFS_RC ( rcNull ); } if ( _TeleportHas ( Name ) == true ) { return XFS_RC ( rcInvalid ); } Tde = calloc ( 1, sizeof ( struct _TNode ) ); if ( Tde == NULL ) { return XFS_RC ( rcExhausted ); } if ( XFS_StrDup ( Name, & ( Tde -> Type ) ) != 0 ) { free ( Tde ); return XFS_RC ( rcExhausted ); } RCt = Provider ( & Tde -> Teleport ); if ( RCt != 0 || Tde -> Teleport == NULL ) { free ( ( char * ) Tde -> Type ); free ( Tde ); return XFS_RC ( rcInvalid ); } BSTreeInsert ( ( struct BSTree * ) & _sTeleport, ( struct BSTNode * ) Tde, _TeleportAddCallback ); return RCt; } /* _TeleportAdd () */
static rc_t CC _KartCollectionNodeMake ( const char * Name, const char * Path, /* Could be NULL */ const char * Perm, struct XFSKartCollectionNode ** Node ) { rc_t RCt; struct XFSKartCollectionNode * KartNode; RCt = 0; KartNode = NULL; if ( Node != NULL ) { * Node = NULL; } if ( Node == NULL || Path == NULL || Name == NULL ) { return XFS_RC ( rcNull ); } KartNode = calloc ( 1, sizeof ( struct XFSKartCollectionNode ) ); if ( KartNode == NULL ) { RCt = XFS_RC ( rcExhausted ); } else { RCt = XFSContNodeInit ( & ( KartNode -> node . node ), Name, Perm, _sFlavorOfKartCollection, _KartCollectionNodeDispose ); if ( RCt == 0 ) { RCt = XFS_StrDup ( Path, & ( KartNode -> path ) ); if ( RCt == 0 ) { * Node = KartNode; } } } return RCt; } /* _KartCollectionNodeMake () */
LIB_EXPORT rc_t CC XFSGapKartNodeMake ( struct XFSNode ** Node, const char * Name, uint32_t ProjectId, const char * Perm ) { rc_t RCt; struct XFSKartNode * KartNode; RCt = 0; KartNode = NULL; XFS_CSAN ( Node ) XFS_CAN ( Node ) XFS_CAN ( Name ) KartNode = calloc ( 1, sizeof ( struct XFSKartNode ) ); if ( KartNode == NULL ) { RCt = XFS_RC ( rcExhausted ); } else { RCt = XFSContNodeInit ( & ( KartNode -> node . node ), Name, Perm, _sFlavorOfGapKart, _KartNodeDispose ); if ( RCt == 0 ) { KartNode -> project_id = ProjectId; RCt = _LoadKart ( KartNode ); if ( RCt == 0 ) { * Node = ( struct XFSNode * ) KartNode; } } } if ( RCt != 0 ) { * Node = NULL; if ( KartNode != NULL ) { XFSNodeDispose ( & ( KartNode -> node . node ) ); KartNode = NULL; } } /* pLogMsg ( klogDebug, "XFSGapKartNodeMake ND[$(node)] NM[$(name)] TP[$(project_id)]", "node=%p,name=%s,project_id=%d", ( void * ) Node, Name, ProjectId ); */ return RCt; } /* XFSGapKartNodeMake () */
/*)) // Statics but usefuls ((*/ static rc_t CC _GetUserName ( char * Buffer, size_t BufferSize ) { DWORD BS; if ( Buffer == NULL || BufferSize == 0 ) { return XFS_RC ( rcNull ); } BS = BufferSize; if ( GetUserNameA ( Buffer, & BS ) == 0 ) { return XFS_RC ( rcExhausted ); } return 0; } /* _GetUserName () */
static rc_t CC _AuthMake ( const char * Name, bool NameDefaulted, bool CanRead, bool CanWrite, bool CanExecute, const struct XFSAuth ** Auth ) { struct XFSAuth * TheAuth; if ( Name == NULL || Auth == NULL ) { return XFS_RC ( rcNull ); } * Auth = NULL; TheAuth = calloc ( 1, sizeof ( struct XFSAuth ) ); if ( TheAuth == NULL ) { return XFS_RC ( rcExhausted ); } if ( ! NameDefaulted ) { TheAuth -> Name = string_dup_measure ( Name, NULL ); if ( TheAuth -> Name == NULL ) { _AuthDispose ( TheAuth ); return XFS_RC ( rcExhausted ); } } else { TheAuth -> Name = ( char * ) Name; } TheAuth -> NameDefaulted = NameDefaulted; TheAuth -> CanRead = CanRead; TheAuth -> CanWrite = CanWrite; TheAuth -> CanExecute = CanExecute; * Auth = TheAuth; return 0; } /* _AuthMake () */
static rc_t CC _BogusNodeMake ( const char * NodeName, bool NotFoundType, const struct XFSBogusNode ** Node ) { rc_t RCt; struct XFSBogusNode * TheNode; RCt = 0; TheNode = NULL; if ( NodeName == NULL || Node == NULL ) { return XFS_RC ( rcNull ); } * Node = NULL; TheNode = calloc ( 1, sizeof ( struct XFSBogusNode ) ); if ( TheNode == NULL ) { RCt = XFS_RC ( rcExhausted ); } else { TheNode -> NotFoundType = NotFoundType; RCt = XFSNodeInitVT ( & ( TheNode -> Node ), NodeName, ( const union XFSNode_vt * ) & _sBogusNodeVT_v1 ); if ( RCt == 0 ) { * Node = TheNode; } else { XFSNodeDispose ( ( const struct XFSNode * ) TheNode ); } } /* printf ( "_BogusNodeMake ( %s, 0x%p )\n", NodeName, ( void * ) TheNode ); */ return RCt; } /* _BogusNodeMake () */
static rc_t CC _BogusNodeAttr_v1 ( const struct XFSNode * self, const struct XFSAttrEditor ** Attr ) { rc_t RCt; struct XFSAttrEditor * Editor; RCt = 0; Editor = NULL; if ( self == NULL || Attr == NULL ) { return XFS_RC ( rcNull ); } * Attr = NULL; Editor = calloc ( 1, sizeof ( struct XFSAttrEditor ) ); if ( Editor == NULL ) { XFSNodeRelease ( self ); return XFS_RC ( rcExhausted ); } RCt = XFSEditorInit ( & ( Editor -> Papahen ), self, _BogusNodeAttr_dispose_v1 ); if ( RCt == 0 ) { Editor -> type = _BogusNodeAttr_type_v1; * Attr = Editor; } else { free ( Editor ); } /* printf ( " _BogusNodeAttr_ ( 0x%p )\n", Editor ); */ return RCt; } /* _BogusNodeAttr_v1 () */
LIB_EXPORT rc_t CC XFSNodeFindNode ( const struct XFSNode * self, const struct XFSPath * Path, uint32_t PathIndex, const struct XFSNode ** Node ) { rc_t RCt; RCt = 0; if ( self == NULL || Path == NULL || Node == NULL ) { return XFS_RC ( rcNull ); } * Node = NULL; switch ( self -> vt -> v1.maj ) { case 1 : if ( self -> vt -> v1.findnode != NULL ) { RCt = self -> vt -> v1.findnode ( self, Path, PathIndex, Node ); } else { /* pLogMsg ( klogDebug, "XFSNodeAttrEditor ( $(node) ): unimplemented method 'findnode'", "node=%p", ( void * ) self ); */ RCt = XFS_RC ( rcUnsupported ); } break; default : RCt = XFS_RC ( rcBadVersion ); break; } return RCt; } /* XFSNodeFindNode () */
rc_t CC _BogusNodeFindNode_v1 ( const struct XFSNode * self, const struct XFSPath * Path, uint32_t PathIndex, const struct XFSNode ** Node ) { return XFS_RC ( rcInvalid ); } /* _BogusNodeFindNode () */
/*)) Something unusual. Will check-initialize NativeDir and Node // NativeDir and Node could be NULL ((*/ static rc_t CC _DocAttr_init_check_v1 ( const struct XFSAttrEditor * self, const struct XFSDocNode ** Node ) { rc_t RCt; const struct XFSDocNode * RetNode; RCt = 0; RetNode = NULL; if ( Node != NULL ) { * Node = NULL; } if ( self == NULL ) { return XFS_RC ( rcNull ); } RetNode = ( const struct XFSDocNode * ) XFSEditorNode ( & ( self -> Papahen ) ); if ( RetNode == NULL ) { return XFS_RC ( rcInvalid ); } if ( RetNode -> doc == NULL ) { return XFS_RC ( rcInvalid ); } if ( RCt == 0 ) { if ( Node != NULL ) { * Node = RetNode; } } return RCt; } /* _DocAttr_init_check_v1 () */
static rc_t CC _KartNodeConstructorEx ( const struct XFSModel * Model, const struct XFSModelNode * Template, const char * Alias, XFSNType Type, const struct XFSNode ** Node ) { rc_t RCt; struct XFSNode * TheNode; const char * NodeName; uint32_t ProjectId; const char * Var; RCt = 0; TheNode = NULL; NodeName = NULL; ProjectId = 0; Var = NULL; XFS_CSAN ( Node ) XFS_CAN ( Model ) XFS_CAN ( Template ) XFS_CAN ( Node ) NodeName = Alias == NULL ? XFSModelNodeName ( Template ) : Alias; Var = XFSModelNodeProperty ( Template, XFS_MODEL_PROJECTID ); if ( Var == NULL ) { return XFS_RC ( rcInvalid ); } ProjectId = atol ( Var ); RCt = XFSGapKartNodeMake ( & TheNode, NodeName, ProjectId, XFSModelNodeSecurity ( Template ) ); if ( RCt == 0 ) { * Node = TheNode; } else { * Node = NULL; if ( TheNode != NULL ) { XFSNodeDispose ( TheNode ); } } return RCt; } /* _KartNodeConstructorEx () */
static rc_t CC _DocFile_open_v1 ( const struct XFSFileEditor * self, XFSNMode Mode ) { const struct XFSDocNode * Node; struct KFile * File; rc_t RCt; Node = NULL; File = NULL; RCt = 0; if ( self == NULL ) { return XFS_RC ( rcNull ); } Node = ( const struct XFSDocNode * ) XFSEditorNode ( & ( self -> Papahen ) ); if ( Node == NULL ) { return XFS_RC ( rcInvalid ); } if ( Mode != kxfsRead ) { return XFS_RC ( rcInvalid ); } RCt = XFSDocFileMake ( XFSNodeName ( & ( Node -> node ) ), Node -> doc, & File ); if ( RCt == 0 ) { ( ( struct XFSDocFileEditor * ) self ) -> file = File; } return RCt; } /* _DocFile_open_v1 () */
LIB_EXPORT rc_t CC XFSNodeDispose ( const struct XFSNode * self ) { rc_t RCt; struct XFSNode * Node; RCt = 0; Node = ( struct XFSNode * ) self; /* pLogMsg ( klogDebug, "XFSNodeDispose ( $(node) )", "node=%p", ( void * ) self ); */ if ( Node == NULL ) { return XFS_RC ( rcNull ); } KRefcountWhack ( & ( Node -> refcount ), _sXFSNode_classname ); if ( Node -> Name != NULL ) { /* pLogMsg ( klogDebug, " [XFSNodeDispose] [$(node)] [$(name)]", "node=%p,name=%s", ( void * ) Node, Node -> Name ); */ free ( Node -> Name ); Node -> Name = NULL; } switch ( self -> vt -> v1.maj ) { case 1 : if ( Node -> vt -> v1.dispose != NULL ) { RCt = Node -> vt -> v1.dispose ( Node ); } break; default : RCt = XFS_RC ( rcBadVersion ); break; } return RCt; } /* XFSNodeDispose () */
LIB_EXPORT rc_t CC XFSReadMeProvider ( const struct XFSTeleport ** Teleport ) { if ( Teleport == NULL ) { return XFS_RC ( rcNull ); } * Teleport = & _sReadMeTeleport; return 0; } /* XFSReadMeProvider () */
LIB_EXPORT rc_t CC XFSEncryptedFileProvider ( const struct XFSTeleport ** Teleport ) { if ( Teleport == NULL ) { return XFS_RC ( rcNull ); } * Teleport = & _sEncryptedFileTeleport; return 0; } /* XFSEncryptedFileProvider () */
LIB_EXPORT rc_t CC XFSOwpInit ( struct XFSOwp * self ) { if ( self == NULL ) { return XFS_RC ( rcNull ); } BSTreeInit ( ( BSTree * ) self ); return 0; } /* XFSOwpInit () */
LIB_EXPORT rc_t CC XFSOwpWhack ( struct XFSOwp * self ) { if ( self == NULL ) { return XFS_RC ( rcNull ); } BSTreeWhack ( ( BSTree * ) self, _OWPEntryWhack, NULL ); return 0; } /* XFSOwpWhack () */
static rc_t CC _AddKartItem ( struct XFSKartNode * Node, const struct XFSGapKart * Kart, const char * ItemName ) { rc_t RCt; struct XFSNode * ItemNode; const struct XFSGapKartItem * KartItem; RCt = 0; ItemNode = NULL; KartItem = NULL; XFS_CAN ( Node ) XFS_CAN ( Kart ) XFS_CAN ( ItemName ) KartItem = XFSGapKartGet ( Kart, ItemName ); if ( KartItem == NULL ) { return XFS_RC ( rcInvalid ); } RCt = XFSGapFileNodeMake ( & ItemNode, ItemName, XFSGapKartItemProjectId ( KartItem ), XFSGapKartItemAccession ( KartItem ), XFSGapKartItemObjectId ( KartItem ) ); if ( RCt == 0 ) { RCt = XFSContNodeAddChild ( & ( Node -> node . node ), ItemNode ); if ( GetRCState ( RCt ) == rcExists ) { RCt = 0; } /* We do not dispose node here, but on the caller level */ } if ( RCt != 0 ) { if ( ItemNode != NULL ) { XFSNodeDispose ( ItemNode ); ItemNode = NULL; } } return RCt; } /* _AddKartItem () */
LIB_EXPORT rc_t CC XFSGapKartProvider ( const struct XFSTeleport ** Teleport ) { if ( Teleport == NULL ) { return XFS_RC ( rcNull ); } * Teleport = & _sKartNodeTeleport; return 0; } /* XFSGapKartProvider () */
LIB_EXPORT rc_t CC XFSTreeDepotResource ( const struct XFSTreeDepot * self, char * Buffer, size_t BufferSize ) { rc_t RCt; const struct XFSTree * Tree; RCt = 0; Tree = NULL; if ( self == NULL || Buffer == NULL || BufferSize == 0 ) { return XFS_RC ( rcNull ); } * Buffer = 0; RCt = XFSTreeDepotGet ( self, & Tree ); if ( RCt == 0 ) { if ( Tree != NULL ) { if ( Tree -> Resource != NULL ) { string_copy_measure ( Buffer, BufferSize, Tree -> Resource ); } XFSTreeRelease ( Tree ); } else { RCt = XFS_RC ( rcNotFound ); } } return RCt; } /* XFSTreeDepotResource () */
static rc_t CC _DocFile_size_v1 ( const struct XFSFileEditor * self, uint64_t * Size ) { const struct XFSDocNode * Node; uint64_t TempSize; rc_t RCt; Node = NULL; TempSize = 0; RCt = 0; if ( Size == NULL ) { return XFS_RC ( rcNull ); } * Size = 0; Node = ( const struct XFSDocNode * ) XFSEditorNode ( & ( self -> Papahen ) ); if ( Node == NULL ) { return XFS_RC ( rcInvalid ); } if ( Node -> doc == NULL ) { return XFS_RC ( rcInvalid ); } RCt = XFSDocSize ( Node -> doc, & TempSize ); if ( RCt == 0 ) { * Size = TempSize; } return RCt; } /* _DocFile_size_v1 () */
static rc_t CC _KartCollectionNodeMakeFromModel ( const char * Name, const struct XFSModel * Model, const struct XFSModelNode * Template, struct XFSNode ** Node ) { rc_t RCt; struct XFSKartCollectionNode * KartNode; RCt = 0; KartNode = NULL; if ( Node != NULL ) { * Node = NULL; } if ( Name == NULL || Model == NULL || Template == NULL || Node == NULL ) { return XFS_RC ( rcNull ); } RCt = _KartCollectionNodeMake ( Name, "generic", XFSModelNodeSecurity ( Template ), & KartNode ); if ( RCt == 0 ) { RCt = _LoadKartScanChildren ( Model, Template, KartNode ); if ( RCt == 0 ) { * Node = & ( KartNode -> node . node ); } } if ( RCt != 0 ) { * Node = NULL; if ( KartNode != NULL ) { XFSNodeDispose ( & ( KartNode -> node . node ) ); KartNode = NULL; } } /* printf ( "KartNodeMakeFromModel ND[0x%p] NM[%s] TP[%d]\n", ( void * ) Node, Name, Type ); */ return RCt; } /* _KartCollectionNodeMakeFromModel () */
/*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*/ LIB_EXPORT rc_t CC XFSTeleportLookup ( const char * NodeType, const struct XFSTeleport ** Teleport ) { rc_t RCt; const struct _TNode * tNode; RCt = 0; tNode = NULL; if ( NodeType == NULL || Teleport == NULL ) { return XFS_RC ( rcNull ); } * Teleport = NULL; if ( _sTeleportInited == false ) { /* HOHOA, will init it somewhere else RCt = _TeleportInit (); */ return XFS_RC ( rcInvalid ); } if ( RCt == 0 ) { tNode = _TeleportLookup ( NodeType ); if ( tNode == NULL ) { RCt = XFS_RC ( rcNotFound ); } else { * Teleport = tNode -> Teleport; } } return RCt; } /* XFSTeleportLookup () */
static rc_t CC _DocFile_read_v1 ( const struct XFSFileEditor * self, uint64_t Offset, void * Buffer, size_t SizeToRead, size_t * NumReaded ) { struct XFSDocFileEditor * Editor; rc_t RCt; Editor = NULL; RCt = 0; if ( self == NULL ) { return XFS_RC ( rcNull ); } Editor = ( struct XFSDocFileEditor * ) self; if ( Editor -> file == NULL ) { return XFS_RC ( rcInvalid ); } RCt = KFileRead ( Editor -> file, Offset, Buffer, SizeToRead, NumReaded ); /* here may be debutt */ return RCt; } /* _DocFile_read_v1 () */