示例#1
0
NITFAPI(cgm_Element*) cgm_PolyLineElement_construct(nitf_Error* error)
{
    cgm_Element* element = cgm_Element_construct(CGM_POLYLINE_ELEMENT, error);
    if (element)
    {
        cgm_PolyLineElement* poly = (cgm_PolyLineElement*)
        NITF_MALLOC(sizeof(cgm_PolyLineElement));

        if (!poly)
        {
            NITF_FREE(element);
            return NULL;
        }
        poly->attributes = NULL;
        poly->vertices = nitf_List_construct(error);
        if (!poly->vertices)
        {
            NITF_FREE(poly);
            NITF_FREE(element);
            return NULL;
        }
        element->data = (NITF_DATA*)poly;
    }
    element->print = &polyPrint;
    element->clone = &polyClone;
    element->destroy = &polyDestroy;

    return element;
}
示例#2
0
/*
 *  TODO: Can DefaultTRE use these now that they're not private?
 *
 */
NITFAPI(nitf_List*) nitf_TREUtils_basicFind(nitf_TRE* tre,
                                            const char* pattern,
                                            nitf_Error* error)
{
    nitf_List* list;

    nitf_HashTableIterator it = nitf_HashTable_begin(
            ((nitf_TREPrivateData*)tre->priv)->hash);
    nitf_HashTableIterator end = nitf_HashTable_end(
            ((nitf_TREPrivateData*)tre->priv)->hash);

    list = nitf_List_construct(error);
    if (!list) return NULL;

    while (nitf_HashTableIterator_notEqualTo(&it, &end))
    {
        nitf_Pair* pair = nitf_HashTableIterator_get(&it);

        if (strstr(pair->key, pattern))
        {
            /* Should check this, I suppose */
            nitf_List_pushBack(list, pair, error);

        }
        nitf_HashTableIterator_increment(&it);
    }

    return list;
}
示例#3
0
NITFAPI(cgm_PictureBody*) cgm_PictureBody_construct(nitf_Error* error)
{
    cgm_PictureBody* body =
        (cgm_PictureBody*)NITF_MALLOC(sizeof(cgm_PictureBody));

    if (!body)
    {
        nitf_Error_init(error, NITF_STRERROR(NITF_ERRNO),
                NITF_CTXT, NITF_ERR_MEMORY);
        return NULL;
    }

    body->auxColor = NULL;
    body->elements = NULL;

    body->elements = nitf_List_construct(error);
    if (!body->elements)
    {
        cgm_PictureBody_destruct(&body);
        return NULL;
    }

    body->auxColor = cgm_Color_construct(-1, -1, -1, error);
    if (!body->auxColor)
    {
        cgm_PictureBody_destruct(&body);
        return NULL;
    }

    body->transparency = 1;
    return body;
}
示例#4
0
NITFPRIV(nitf_PluginRegistry *) implicitConstruct(nitf_Error * error)
{
    size_t pathLen;
    const char *pluginEnvVar;

    /*  Create the registry object  */
    nitf_PluginRegistry *reg =
        (nitf_PluginRegistry *) NITF_MALLOC(sizeof(nitf_PluginRegistry));

    /*  If we have a memory problem, init our error struct and return  */
    if (!reg)
    {
        nitf_Error_init(error,
                        NITF_STRERROR(NITF_ERRNO),
                        NITF_CTXT, NITF_ERR_MEMORY);
        return NULL;
    }

    /* set these to NULL to possibly protect us later */
    reg->compressionHandlers = NULL;
    reg->treHandlers = NULL;
    reg->decompressionHandlers = NULL;
    reg->dsos = NULL;

    reg->dsos = nitf_List_construct(error);
    if (!reg->dsos)
    {
        implicitDestruct(&reg);
        return NULL;
    }


    /*  Construct our hash object  */
    reg->treHandlers = nitf_HashTable_construct(NITF_TRE_HASH_SIZE, error);

    /*  If we have a problem, get rid of this object and return  */
    if (!reg->treHandlers)
    {
        implicitDestruct(&reg);
        return NULL;
    }

    /* do not adopt the data - we will clean it up ourselves */
    nitf_HashTable_setPolicy(reg->treHandlers, NITF_DATA_RETAIN_OWNER);

    reg->compressionHandlers =
        nitf_HashTable_construct(NITF_COMPRESSION_HASH_SIZE, error);


    /*  If we have a problem, get rid of this object and return  */
    if (!reg->compressionHandlers)
    {
        implicitDestruct(&reg);
        return NULL;
    }

    /* do not adopt the data - we will clean it up ourselves */
    nitf_HashTable_setPolicy(reg->compressionHandlers, NITF_DATA_RETAIN_OWNER);

    reg->decompressionHandlers =
        nitf_HashTable_construct(NITF_DECOMPRESSION_HASH_SIZE, error);

    /*  If we have a problem, get rid of this object and return  */
    if (!reg->decompressionHandlers)
    {
        implicitDestruct(&reg);
        return NULL;
    }

    /* do not adopt the data - we will clean it up ourselves */
    nitf_HashTable_setPolicy(reg->decompressionHandlers,
                             NITF_DATA_RETAIN_OWNER);

    /*  Start with a clean slate  */
    memset(reg->path, 0, NITF_MAX_PATH);

    /*  Take the environment variable, or...  */
    pluginEnvVar = getenv(NITF_PLUGIN_PATH);
    if (!pluginEnvVar)
    {
        /*  Take the default path  */
        /*strcpy(reg->path, NITF_DEFAULT_PLUGIN_PATH);*/
        return reg;
    }
    else
    {
        strcpy(reg->path, pluginEnvVar);
    }
    /*
     * If the we have a user-defined path, they might not
     * have terminated their environment variable with a
     * trailing delimiter.  No problem, we can do it for them.
     */
    pathLen = strlen(reg->path);
    if (pathLen > 0 && !isDelimiter(reg->path[pathLen - 1]))
    {
        /*  Need to append delimiter to end  */
        reg->path[pathLen++] = DIR_DELIMITER;
        reg->path[pathLen++] = '\0';
    }

    /*  Return the object, its okay!  */
    return reg;
}