예제 #1
0
nitf_GraphicSubheader_clone(nitf_GraphicSubheader * source,
                            nitf_Error * error)
{
    nitf_GraphicSubheader *subhdr = NULL;
    if (source)
    {
        subhdr =
            (nitf_GraphicSubheader *)
            NITF_MALLOC(sizeof(nitf_GraphicSubheader));
        if (!subhdr)
        {
            nitf_Error_init(error, NITF_STRERROR(NITF_ERRNO),
                            NITF_CTXT, NITF_ERR_MEMORY);
            return NULL;
        }

        subhdr->securityGroup =
            nitf_FileSecurity_clone(source->securityGroup, error);

        /*  Copy some fields  */
        _NITF_CLONE_FIELD(subhdr, source, NITF_SY);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SID);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SNAME);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SSCLAS);
        _NITF_CLONE_FIELD(subhdr, source, NITF_ENCRYP);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SFMT);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SSTRUCT);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SDLVL);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SALVL);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SLOC);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SBND1);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SCOLOR);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SBND2);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SRES2);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SXSHDL);
        _NITF_CLONE_FIELD(subhdr, source, NITF_SXSOFL);

        /* init to NULL for safety */
        subhdr->extendedSection = NULL;

        if (source->extendedSection)
        {
            subhdr->extendedSection =
                nitf_Extensions_clone(source->extendedSection, error);

            if (!subhdr->extendedSection)
                goto CATCH_ERROR;
        }

        return subhdr;
    }

CATCH_ERROR:
    nitf_GraphicSubheader_destruct(&subhdr);
    return NULL;
}
예제 #2
0
NITFAPI(void) nitf_GraphicSegment_destruct(nitf_GraphicSegment ** segment)
{
    if (*segment)
    {
        if ((*segment)->subheader)
        {
            /*  Destroy subheader info  */
            nitf_GraphicSubheader_destruct(&(*segment)->subheader);
        }
    }
    NITF_FREE(*segment);
    *segment = NULL;
}
예제 #3
0
nitf_GraphicSubheader_construct(nitf_Error * error)
{
    /*  Start by allocating the header */
    nitf_GraphicSubheader *subhdr = (nitf_GraphicSubheader *)
                                    NITF_MALLOC(sizeof(nitf_GraphicSubheader));

    /*  Return now if we have a problem above */
    if (!subhdr)
    {
        nitf_Error_init(error, NITF_STRERROR(NITF_ERRNO),
                        NITF_CTXT, NITF_ERR_MEMORY);
        goto CATCH_ERROR;
    }

    subhdr->extendedSection = NULL;
    subhdr->securityGroup = NULL;
    
    subhdr->securityGroup = nitf_FileSecurity_construct(error);
    if (!subhdr->securityGroup)
        goto CATCH_ERROR;

    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SY, NITF_BCS_A);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SID, NITF_BCS_A);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SNAME, NITF_BCS_A);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SSCLAS, NITF_BCS_A);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_ENCRYP, NITF_BCS_A);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SFMT, NITF_BCS_A);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SSTRUCT, NITF_BCS_N);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SDLVL, NITF_BCS_N);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SALVL, NITF_BCS_N);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SLOC, NITF_BCS_N);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SBND1, NITF_BCS_N);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SCOLOR, NITF_BCS_A);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SBND2, NITF_BCS_N);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SRES2, NITF_BCS_N);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SXSHDL, NITF_BCS_N);
    _NITF_CONSTRUCT_FIELD(subhdr, NITF_SXSOFL, NITF_BCS_N);

    subhdr->extendedSection = nitf_Extensions_construct(error);
    if (!subhdr->extendedSection)
        goto CATCH_ERROR;

    return subhdr;

CATCH_ERROR:
    if (subhdr)
    	nitf_GraphicSubheader_destruct(&subhdr);
    return NULL;
}