Example #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;
}
Example #2
0
nitf_TextSubheader_clone(nitf_TextSubheader * source, nitf_Error * error)
{
    nitf_TextSubheader *subhdr = NULL;
    if (source)
    {
        subhdr =
            (nitf_TextSubheader *) NITF_MALLOC(sizeof(nitf_TextSubheader));
        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);

        if (!subhdr->securityGroup)
            goto CATCH_ERROR;

        /*  Copy some fields  */
        _NITF_CLONE_FIELD(subhdr, source, NITF_TE);
        _NITF_CLONE_FIELD(subhdr, source, NITF_TEXTID);

        _NITF_CLONE_FIELD(subhdr, source, NITF_TXTALVL);

        _NITF_CLONE_FIELD(subhdr, source, NITF_TXTDT);
        _NITF_CLONE_FIELD(subhdr, source, NITF_TXTITL);
        _NITF_CLONE_FIELD(subhdr, source, NITF_TSCLAS);

        _NITF_CLONE_FIELD(subhdr, source, NITF_ENCRYP);
        _NITF_CLONE_FIELD(subhdr, source, NITF_TXTFMT);

        _NITF_CLONE_FIELD(subhdr, source, NITF_TXSHDL);
        _NITF_CLONE_FIELD(subhdr, source, NITF_TXSOFL);

        /* init to NULL in case */
        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_TextSubheader_destruct(&subhdr);
    return NULL;
}
Example #3
0
nitf_RESubheader_clone(nitf_RESubheader * source, nitf_Error * error)
{
    nitf_Uint32 subLen;
    nitf_RESubheader *subhdr = NULL;
    if (source)
    {
        subhdr =
            (nitf_RESubheader *) NITF_MALLOC(sizeof(nitf_RESubheader));
        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);

        if (!subhdr->securityGroup)
            goto CATCH_ERROR;

        /*  Copy some fields  */
        _NITF_CLONE_FIELD(subhdr, source, NITF_RE);
        _NITF_CLONE_FIELD(subhdr, source, NITF_RESTAG);
        _NITF_CLONE_FIELD(subhdr, source, NITF_RESVER);
        _NITF_CLONE_FIELD(subhdr, source, NITF_RESCLAS);

        /*  And some ints  */
        _NITF_CLONE_FIELD(subhdr, source, NITF_RESSHL);
        subhdr->dataLength = source->dataLength;
        subhdr->subheaderFields = NULL;

        NITF_TRY_GET_UINT32(source->subheaderFieldsLength, &subLen, error);
        if (source->subheaderFields)
        {
            subhdr->subheaderFields = (char* )NITF_MALLOC(subLen);
            if (!subhdr->subheaderFields)
            {
                nitf_Error_init(error, NITF_STRERROR(NITF_ERRNO),
                                NITF_CTXT, NITF_ERR_MEMORY);
                return NULL;
            }
            memcpy(subhdr->subheaderFields,
                   source->subheaderFields, subLen);
        }
        return subhdr;
    }

CATCH_ERROR:
    return NULL;
}