示例#1
0
struct XFSOwpEntry * CC
_OWPEntryMake ( const char * Key, const char * Property )
{
    struct XFSOwpEntry * Entry;

    Entry = calloc ( 1, sizeof ( struct XFSOwpEntry ) );
    if ( Entry != NULL ) {
        if ( XFS_StrDup ( Key, ( const char ** ) & ( Entry -> Key ) ) == 0 ) {

            if ( Property == NULL ) {
                return Entry;
            }
            else {
                if ( XFS_StrDup ( Property, ( const char ** ) & ( Entry -> Property ) ) == 0 ) {
                    return Entry;
                }
            }

            free ( Entry -> Key );
        }

        free ( Entry );
    }

    return NULL;
}   /* _OWPEntryMake () */
示例#2
0
文件: node.c 项目: binlu1981/ncbi-vdb
static
rc_t CC
_NodeSetName ( const struct XFSNode * self, const char * Name )
{
    struct XFSNode * Node = ( struct XFSNode * ) self;

    if ( Node == NULL || Name == NULL ) {
        return XFS_RC ( rcNull );
    }

    if ( Node -> Name != NULL ) {
        free ( Node -> Name );
        Node -> Name = NULL;
    }

    return XFS_StrDup ( Name, ( const char ** ) & ( Node -> Name ) );
}   /* _NodeSetName () */
示例#3
0
文件: karts.c 项目: ImAWolf/ncbi-vdb
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 () */
示例#4
0
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 () */
示例#5
0
文件: tree.c 项目: ImAWolf/ncbi-vdb
LIB_EXPORT
rc_t CC
XFSTreeMake ( const struct XFSModel * Model, struct XFSTree ** Tree )
{
    rc_t RCt;
    struct XFSTree * tTree;

    RCt = 0;

    if ( Model == NULL || Tree == NULL ) { 
        return XFS_RC ( rcNull );
    }

    * Tree = NULL;

        /* Creating a tree */
    tTree = calloc ( 1, sizeof ( struct XFSTree ) );
/*
printf ( " |<- ThreeMake ( 0x%p )\n", ( void * ) tTree );
*/
    if ( tTree == NULL ) {
        return XFS_RC ( rcExhausted );
    }

    if ( XFS_StrDup (
                    XFSModelResource ( Model ),
                    & ( tTree -> Resource )
                    ) != 0
    ) {
        XFSTreeDispose ( tTree );
        return XFS_RC ( rcExhausted );
    }

    if ( XFSModelVersion ( Model ) != NULL ) {
        if ( XFS_StrDup (
                        XFSModelVersion ( Model ),
                        & ( tTree -> Version ) ) != 0
        ) {
            XFSTreeDispose ( tTree );
            return XFS_RC ( rcExhausted );
        }
    }
    else {
        tTree -> Version = NULL;
    }

    RCt = XFSNodeMake (
                    Model,
                    XFSModelNodeName ( XFSModelRootNode ( Model ) ),
                    NULL,
                    ( const struct XFSNode ** ) & ( tTree -> Root )
                    );
    if ( RCt == 0 ) {
        KRefcountInit (
                        & ( tTree -> refcount ),
                        1,
                        _sXFSTree_classname,
                        "XFSTreeMake",
                        "Tree"
                        );
    }

    if ( RCt == 0 ) {
        * Tree = tTree;
    }
    else {
        XFSTreeDispose ( tTree );

        tTree = NULL;
    }

/*
printf ( " ->| ThreeMake ( 0x%p )\n", ( void * ) * Tree );
*/

    return RCt;
}   /* XFSTreeMake () */
示例#6
0
LIB_EXPORT
rc_t CC
XFSDocNodeMakeWithFlavor (
            struct XFSNode ** Node,
            const struct XFSDoc * Doc,
            const char * Name,
            const char * Perm,          /* Could be NULL */
            uint32_t Flavor
)
{
    rc_t RCt;
    struct XFSDocNode * TheNode;

    RCt = 0;
    TheNode = NULL;

    if ( Node != NULL ) {
        * Node = NULL;
    }

    if ( Node == NULL || Name == NULL || Doc == NULL ) {
        return XFS_RC ( rcNull );
    }

    TheNode = calloc ( 1, sizeof ( struct XFSDocNode ) );
    if ( TheNode == NULL ) {
        RCt = XFS_RC ( rcExhausted );
    }
    else {
        RCt = XFSNodeInitVT (
                        & ( TheNode -> node),
                        Name,
                        ( const union XFSNode_vt * ) & _sDocNodeVT_v1
                        );
        if ( RCt == 0 ) {
            if ( Perm != NULL ) {
                RCt = XFS_StrDup ( Perm, & ( TheNode -> perm ) );
            }

            if ( RCt == 0 ) {
                RCt = XFSDocAddRef ( Doc );
                if ( RCt == 0 ) {
                    TheNode -> doc = Doc;

                    TheNode -> flavor = Flavor;

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

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

/*
pLogMsg ( klogDebug, "XFSDocNodeMake ND[$(node)] NM[$(name)] Doc[$(doc)]", "node=%p,name=%s,doc=%s", ( void * ) TheNode, Name, Doc );
*/

    return RCt;
}   /* XFSDocNodeMakeWithFlavor () */