Exemplo n.º 1
0
int module_run(char* name)
{
    // Get just name part - not full path
    char *s = strrchr(name,'/');
    if (s) name = s + 1;

    int i;
    for (i=0; i<MAX_SIMPLE_MODULE; i++)
    {
        // Check if module loaded (otherwise name not valid)
        if (*h_run[i].lib != h_run[i].default_lib)
        {
            if (name_match(name,h_run[i].name))
            {
                // Already loaded
                return (*h_run[i].lib)->run();
            }
        }
    }
    for (i=0; i<MAX_SIMPLE_MODULE; i++)
    {
        // Look for empty slot
        if (*h_run[i].lib == h_run[i].default_lib)
        {
            // Found space - run module
            strcpy(h_run[i].name,name);
            return (*h_run[i].lib)->run();
        }
    }

    // Error - no space
    module_run_error(LANG_MODULE_NO_SPACE, name);

    return -1;
}
Exemplo n.º 2
0
//-----------------------------------------------
// PURPOSE:      run simple module "name"
// RETURN VALUE: passed from module. -1 if something was failed
//-----------------------------------------------
int module_run(char* name)
{
    int i;
    for (i=0; i<MAX_SIMPLE_MODULE; i++)
    {
        // Check if module loaded (otherwise name not valid)
        if (*h_run[i].lib != h_run[i].default_lib)
        {
            if (namecmp(name, h_run[i].name))
            {
                // Already loaded
                return (*h_run[i].lib)->run();
            }
        }
    }
    for (i=0; i<MAX_SIMPLE_MODULE; i++)
    {
        // Look for empty slot
        if (*h_run[i].lib == h_run[i].default_lib)
        {
            // Found space - run module
            strcpy(h_run[i].name, name);
            return (*h_run[i].lib)->run();
        }
    }

    // Error - no space
    module_run_error(LANG_MODULE_NO_SPACE, name);

    return -1;
}
Exemplo n.º 3
0
static int default_run(int n)
{
    if (module_load(&h_run[n]))
    {
        if ((*h_run[n].lib)->run)
        {
            return (*h_run[n].lib)->run();
        }
        else
        {
            // Error - module does not support 'simple' mode
            module_run_error(LANG_MODULE_NOT_SIMPLE, h_run[n].name);
        }
    }

    return -1;
}
Exemplo n.º 4
0
// Default run method
// If module loaded in selected slot call the 'run' method.
// If not 'run' method defined then display error
static int default_run(int n)
{
    if (module_load(&h_run[n]))
    {
        if ((*h_run[n].lib)->run)
        {
            return (*h_run[n].lib)->run();
        }
        else
        {
            // Error - module does not support 'simple' mode
            module_run_error(LANG_MODULE_NOT_SIMPLE, h_run[n].name);
            // Assumption - module will unload automatically via module_tick_unloader()
        }
    }

    return -1;
}