示例#1
0
static
rc_t CC
_EncAttr_init_check_v1 (
                const struct XFSAttrEditor * self,
                const struct XFSEncEntry ** Entry
)
{
    struct XFSEncNode * Node = NULL;

    XFS_CSAN ( Entry )

    XFS_CAN ( self )
    XFS_CAN ( Entry )


    Node = ( struct XFSEncNode * ) XFSEditorNode (
                                                & ( self -> Papahen )
                                                );

    XFS_CA ( Node, NULL )
    XFS_CA ( Node -> entry, NULL )

    * Entry = Node -> entry;

    return 0;
}   /* _EncAttr_init_check_v1 () */
示例#2
0
文件: gapk.c 项目: binlu1981/ncbi-vdb
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 () */
示例#3
0
文件: gapk.c 项目: binlu1981/ncbi-vdb
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 () */
示例#4
0
LIB_EXPORT
rc_t CC
XFSEncryptedFileNodeMake (
                    const char * Name,
                    const char * Path,
                    const char * Passwd,
                    const char * EncType,
                    struct XFSNode ** Node
)
{
    rc_t RCt;
    const struct XFSEncEntry * Entry;
    struct XFSNode * TheNode;

    RCt = 0;
    Entry = NULL;
    TheNode = NULL;

    XFS_CSAN ( Node )

    XFS_CAN ( Name )
    XFS_CAN ( Path )
    XFS_CAN ( Passwd )
    XFS_CAN ( Node )

    RCt = XFSEncEntryFindOrCreate ( Path, Passwd, EncType, & Entry );
    if ( RCt == 0 ) {
        RCt = XFSEncNodeMake ( & TheNode, Name, Entry );
        if ( RCt == 0 ) {
            * Node = TheNode;
        }
    }

    if ( RCt != 0 ) {
        * Node = NULL;

        if ( TheNode != NULL ) {
            XFSNodeDispose ( TheNode );
        }
        else {
            if ( Entry != NULL ) {
                XFSEncEntryDispose ( Entry );
            }
        }
    }

    return RCt;
}   /* XFSEncryptedFileNodeMake () */
示例#5
0
static
rc_t CC
XFSEncNodeMake (
    struct XFSNode ** Node,
    const char * Name,
    const struct XFSEncEntry * Entry
)
{
    rc_t RCt;
    struct XFSEncNode * xNode;

    RCt = 0;
    xNode = NULL;

    XFS_CSAN ( Node )

    XFS_CAN ( Node )
    XFS_CAN ( Name )
    XFS_CAN ( Entry )

    xNode = calloc ( 1, sizeof ( struct XFSEncNode ) );
    if ( xNode == NULL ) {
        return XFS_RC ( rcNull );
    }

    RCt = XFSNodeInitVT (
                    & ( xNode -> node ),
                    Name,
                    ( const union XFSNode_vt * ) & _sEncNodeVT_v1
                    );

    if ( RCt == 0 ) {
        RCt = XFSEncEntryAddRef ( Entry );
        if ( RCt == 0 ) {
            xNode -> entry = Entry;

            * Node = & ( xNode -> node );
        }
    }

    if ( RCt != 0 ) {
        if ( xNode != NULL ) {
            RCt = XFSNodeDispose ( & ( xNode -> node ) );
        }
    }

    return RCt;
}   /* XFSEncNodeMake () */
示例#6
0
rc_t CC
_EncNodeFile_v1 (
            const struct XFSNode * self,
            const struct XFSFileEditor ** File
)
{
    rc_t RCt;
    struct XFSEncFileEditor * FileEditor;
    struct XFSFileEditor * Editor;

    RCt = 0;
    FileEditor = NULL;
    Editor = NULL;

    XFS_CSAN ( File )

    XFS_CAN ( self )
    XFS_CAN ( File )

    FileEditor = calloc ( 1, sizeof ( struct XFSEncFileEditor ) );
    if ( FileEditor == NULL ) { 
        return XFS_RC ( rcExhausted );
    }

    memset ( FileEditor, 0, sizeof ( struct XFSEncFileEditor ) );

    Editor = & ( FileEditor -> Papahen );

    RCt = XFSEditorInit (
                    & ( Editor -> Papahen ),
                    self,
                    _EncFile_dispose_v1
                    );

    if ( RCt == 0 ) {
        Editor -> open = _EncFile_open_v1;
        Editor -> close = _EncFile_close_v1;
        Editor -> read = _EncFile_read_v1;

        * File = Editor;
    }
    else {
        free ( Editor );
    }

    return RCt;
}   /* _EncNodeFile_v1 () */
示例#7
0
文件: xgapk.c 项目: ncbi/ncbi-vdb
static
rc_t CC
_LaInMake ( const struct _LaIn ** LaIn )
{
    struct _LaIn * Ret = NULL;

    XFS_CSAN ( LaIn )
    XFS_CAN ( LaIn )

    Ret = calloc ( 1, sizeof ( struct _LaIn ) );
    if ( Ret == NULL ) {
        return XFS_RC ( rcExhausted );
    }

    * LaIn = Ret;

    return 0;
}   /* _LaInMake () */
示例#8
0
static
rc_t CC
_EncNodeAttr_v1 (
            const struct XFSNode * self,
            const struct XFSAttrEditor ** Attr
)
{
    rc_t RCt;
    struct XFSAttrEditor * Editor;

    RCt = 0;
    Editor = NULL;

    XFS_CSAN ( Attr )

    XFS_CAN ( self )
    XFS_CAN ( Attr )

    Editor = calloc ( 1, sizeof ( struct XFSAttrEditor ) );
    if ( Editor == NULL ) {
        return XFS_RC ( rcExhausted );
    }

    RCt = XFSEditorInit (
                    & ( Editor -> Papahen ),
                    self,
                    _EncAttr_dispose_v1
                    );
    if ( RCt == 0 ) {
        Editor -> permissions = _EncAttr_permissions_v1;
        Editor -> size = _EncAttr_size_v1;
        Editor -> date = _EncAttr_date_v1;
        Editor -> type = _EncAttr_type_v1;

        * Attr = Editor;
    }
    else {
        free ( Editor );
    }

    return RCt;
}   /* _EncNodeAttr_v1 () */
示例#9
0
static
rc_t CC
_EncAttr_permissions_v1 (
                        const struct XFSAttrEditor * self,
                        const char ** Permissions
)
{
    rc_t RCt;
    const struct XFSEncEntry * Entry;

    RCt = 0;
    Entry = NULL;

    XFS_CSAN ( Permissions )
    XFS_CAN ( Permissions )

    RCt = _EncAttr_init_check_v1 ( self, & Entry );
    if ( RCt == 0 ) {
        * Permissions = XFSPermRODefNodeChar ();
    }

    return RCt;
}   /* _EncAttr_permissions_v1 () */
示例#10
0
文件: xgapk.c 项目: ncbi/ncbi-vdb
static
rc_t CC
_KartItemMake (
            struct XFSGapKartItem ** RetItem,
            const struct KartItem * Item
)
{
    rc_t RCt;
    const struct String * TheString;
    struct XFSGapKartItem * xItem;
    uint64_t ProjectId, ObjectId;

    RCt = 0;
    TheString = NULL;
    xItem = NULL;
    ProjectId = ObjectId = 0;

    XFS_CSAN ( RetItem )
    XFS_CAN ( RetItem )
    XFS_CAN ( Item )

    xItem = calloc ( 1, sizeof ( struct XFSGapKartItem ) );
    if ( xItem == NULL ) {
        return XFS_RC ( rcExhausted );
    }

    KRefcountInit (
                & ( xItem -> refcount ),
                1,
                _sXFSGapKartItem_classname,
                "_KartItemMake",
                "KartItem"
                );

    RCt = KartItemProjIdNumber ( Item, & ProjectId );
    if ( RCt == 0 ) {
        xItem -> project_id = ( uint32_t ) ProjectId;
    }

    if ( RCt == 0 ) {
        RCt = KartItemItemId ( Item, & TheString );
        if ( RCt == 0 && TheString -> len != 0 ) {
            RCt = KartItemItemIdNumber ( Item, & ObjectId );
            if ( RCt == 0 ) {
                xItem -> object_id = ( uint32_t ) ObjectId;
            }
        }
        else {
            xItem -> object_id = 0;
        }
    }

    if ( RCt == 0 ) {
        RCt = KartItemAccession ( Item, & TheString );
        if ( RCt == 0 && TheString -> len != 0 ) {
            RCt = XFS_SStrDup ( TheString, & xItem -> accession );
        }
        else {
            xItem -> accession = NULL;
        }
    }

    if ( RCt == 0 ) {
        RCt = KartItemName ( Item, & TheString );
        if ( RCt == 0 && TheString -> len != 0 ) {
            RCt = XFS_SStrDup ( TheString, & xItem -> name );
        }
        else {
            xItem -> name = NULL;
        }
    }

    if ( RCt == 0 ) {
        RCt = KartItemItemDesc ( Item, & TheString );
        if ( RCt == 0 && TheString -> len != 0 ) {
            RCt = XFS_SStrDup ( TheString, & xItem -> description );
        }
        else {
            xItem -> description = NULL;
        }
    }

    if ( xItem -> object_id == 0 && xItem -> accession == NULL ) {
        RCt = XFS_RC ( rcInvalid );
    }

    if ( RCt == 0 ) {
        * RetItem = xItem;
    }
    else {
        if ( xItem != NULL ) {
            _KartItemDispose ( xItem );
        }
    }

    return RCt;
}   /* _KartItemMake () */