コード例 #1
0
NITFPRIV(const char **) doInit(nitf_DLL * dll,
                               const char *prefix,
                               nitf_Error * error)
{
    NITF_PLUGIN_INIT_FUNCTION init;
    const char **ident;

    char name[NITF_MAX_PATH];
    memset(name, 0, NITF_MAX_PATH);
    NITF_SNPRINTF(name, NITF_MAX_PATH, "%s%s", prefix, NITF_PLUGIN_INIT_SUFFIX);
    init = (NITF_PLUGIN_INIT_FUNCTION) nitf_DLL_retrieve(dll, name, error);
    if (!init)
    {
        nitf_Error_print(error, stdout, "Invalid init hook in DSO");
        return NULL;
    }

    /*  Else, call it  */

    ident = (*init)(error);
    if (!ident)
    {
        nitf_Error_initf(error,
                         NITF_CTXT,
                         NITF_ERR_INVALID_OBJECT,
                         "The plugin [%s] is not retrievable", prefix);
        return NULL;
    }
    return ident;
}
コード例 #2
0
ファイル: PluginRegistry.c プロジェクト: abellgithub/nitro
NITFPRIV(NITF_BOOL) insertCreator(nitf_DLL* dso, 
                                  nitf_HashTable* hash,
                                  const char* ident,
                                  const char* suffix,
                                  nitf_Error* error)
{
    /*  We are trying to find tre_main  */
    NITF_DLL_FUNCTION_PTR dsoMain = NULL;

    /*  Get the name of the handler  */
    char name[NITF_MAX_PATH];
    char* p = NULL;

    if (!nitf_DLL_isValid(dso))
    {
        nitf_Error_initf(error,
                         NITF_CTXT,
                         NITF_ERR_INVALID_PARAMETER,
                         "DSO is not valid for [%s]",
                         ident);

    }

    memset(name, 0, NITF_MAX_PATH);
    NITF_SNPRINTF(name, NITF_MAX_PATH, "%s%s", ident, suffix);

    nitf_Utils_replace(name, ' ', '_');

    /*  No error has occurred (yet)  */
#if NITF_DEBUG_PLUGIN_REG
    printf("Loading function [%s] in dso at [%p]\n", name, dso);
#endif

    /*  Retrieve the main  */
    dsoMain = nitf_DLL_retrieve(dso, name, error);

    if (!dsoMain)
    {
        /*  If it didnt work, we are done  */
        return NITF_FAILURE;
    }

#if NITF_DEBUG_PLUGIN_REG
    if (nitf_HashTable_exists(hash, ident))
    {
        printf("Warning, overriding [%s] hook", ident);
        
    }
#endif
    
    return nitf_HashTable_insert(hash, ident, dsoMain, error);

}
コード例 #3
0
/*
 *  Cleanup the DLL.  This is called once when the registry is
 *  shut down.
 */
NITFPRIV(int) doCleanup(nitf_DLL * dll, nitf_Error* error)
{
    NITF_PLUGIN_CLEANUP_FUNCTION cleanup;
    const char* cleanupName = NITF_PLUGIN_CLEANUP;

    cleanup = (NITF_PLUGIN_CLEANUP_FUNCTION)nitf_DLL_retrieve(dll,
                                                              cleanupName,
                                                              error);
    if (!cleanup)
    {
        return 0;
    }
    /*  Else, call it  */
    cleanup();

    return 1;
}