Example #1
0
/*! \brief @@@@@ \todo document

 \param Context

 \return
*/
EXTERN BOOL CBMAPIDECL opencbm_plugin_get_all_plugin_names(opencbm_plugin_get_all_plugin_names_context_t * Context)
{
    BOOL error = TRUE;
    opencbm_configuration_handle configuration_handle = NULL;
    const char * configurationFilename = NULL;

    FUNC_ENTER();

    do {
        configurationFilename = configuration_get_default_filename();
        if (configurationFilename == NULL) {
            break;
        }

        configuration_handle = opencbm_configuration_open(configurationFilename);
        if (configuration_handle == NULL) {
            DBG_PRINT((DBG_PREFIX "No configuration file present. Is OpenCBM installed at all?"));
            break;
        }

        error = opencbm_configuration_enum_sections(configuration_handle,
            opencbm_plugin_get_all_plugin_names_callback, Context);

    } while (0);

    opencbm_configuration_close(configuration_handle);

    cbmlibmisc_strfree(configurationFilename);

    FUNC_LEAVE_BOOL(error);
}
Example #2
0
/*! \brief @@@@@ \todo document

 \param Handle

 \param Section

 \param Data

 \return
*/
static int opencbm_plugin_get_all_plugin_names_callback(opencbm_configuration_handle Handle,
                                                    const char Section[],
                                                    void * Data)
{
    opencbm_plugin_get_all_plugin_names_context_t * Context = Data;

    BOOL error = 0;

    FUNC_ENTER();

    do {
        if ( ! Section || strcmp(Section, "plugins") == 0 ) {
            break;
        }

        /*
         * check if the plugin is marked as active.
         * Only active plugins are reported back,
         */

        if ( ! plugin_is_active(Handle, Section) ) {
            break;
        }

       error = Context->Callback(Context->InstallParameter, Section);

    } while (0);

    FUNC_LEAVE_BOOL(error);
}
Example #3
0
BOOL
VDDInitialize(IN HANDLE Module, IN DWORD Reason, IN LPVOID Reserved)
{
    FUNC_ENTER();

    DBG_PRINT((DBG_PREFIX "OpencbmVDD.Entry: " __DATE__ " " __TIME__));

    switch (Reason) 
    {
        case DLL_PROCESS_ATTACH:
            vdd_handle = Module;
            VDDInstallUserHook(vdd_handle, NULL, NULL, VDDBlockHandler, NULL);
            break;

        case DLL_PROCESS_DETACH:
            DBG_ASSERT(vdd_handle == Module);
            vdd_uninstall_iohook_internal();
            VDDDeInstallUserHook(Module);

            // make sure all CBM_FILE handles are closed
            // whenever this VDD is unloaded
            vdd_cbmfile_closeall();
            break;

        default:
            break;

    }

    FUNC_LEAVE_BOOL(TRUE);
}
Example #4
0
BOOL
opencbm_init(IN HANDLE Module, IN DWORD Reason, IN LPVOID Reserved)
{
    static BOOL bIsOpen = FALSE;
    BOOLEAN Status = TRUE;

    FUNC_ENTER();

#if DBG

    if (Reason == DLL_PROCESS_ATTACH)
    {
        // Read the debugging flags from the registry

        cbm_i_get_debugging_flags();
    }

#endif

    /* make sure the definitions in opencbm.h and cbmioctl.h
     * match each other! 
     * Since we are the only instance which includes both files,
     * we are the only one which can ensure this.
     */

    DBG_ASSERT(IEC_LINE_CLOCK == IEC_CLOCK);
    DBG_ASSERT(IEC_LINE_RESET == IEC_RESET);
    DBG_ASSERT(IEC_LINE_DATA == IEC_DATA);
    DBG_ASSERT(IEC_LINE_ATN == IEC_ATN);

    switch (Reason) 
    {
        case DLL_PROCESS_ATTACH:

            Status = TRUE;
            break;

        case DLL_PROCESS_DETACH:

            vicerelease();
            Status = TRUE;
            break;

        default:
            break;

    }

    FUNC_LEAVE_BOOL(Status);
}
Example #5
0
/*! \brief @@@@@ \todo document

 \param Context

 \return
*/
BOOL CBMAPIDECL
opencbm_plugin_install_do_uninstall(void * Context)
{
    BOOL error = TRUE;

    FUNC_ENTER();

    DBG_PRINT((DBG_PREFIX "-- xum1541.uninstall" ));

    do {
        error = FALSE;
    } while (0);

    FUNC_LEAVE_BOOL(error);
}
Example #6
0
BOOL WINAPI
DllMain(IN HANDLE Module, IN DWORD Reason, IN LPVOID Reserved)
{
    static BOOL bIsOpen = FALSE;

    FUNC_ENTER();

#if DBG

    if (Reason == DLL_PROCESS_ATTACH)
    {
        // Read the debugging flags from the registry

        cbm_get_debugging_flags(NULL);
    }

#endif

    FUNC_LEAVE_BOOL(TRUE);
}
Example #7
0
/*! \brief @@@@@ \todo document

 \param DefaultPluginname

 \return
*/
BOOL CBMAPIDECL opencbm_plugin_install_generic(const char * DefaultPluginname)
{
    BOOL error = TRUE;

    opencbm_configuration_handle configuration_handle;

    const char * configurationFilename = NULL;

    FUNC_ENTER();

    do {
        /* create the INI file, if not present, and create the needed keys */

        configurationFilename = configuration_get_default_filename();
        if (configurationFilename == NULL) {
            break;
        }

        configuration_handle = opencbm_configuration_create(configurationFilename);

        if (configuration_handle == NULL) {
            break;
        }

        if (DefaultPluginname != NULL) {
            error = opencbm_configuration_set_data(configuration_handle, 
                       "plugins", "default", DefaultPluginname);
        }
        else {
            error = FALSE;
        }

        error = opencbm_configuration_close(configuration_handle) || error;

    } while (0);

    cbmlibmisc_strfree(configurationFilename);

    FUNC_LEAVE_BOOL(error);
}
Example #8
0
/*! \brief @@@@@ \todo document

 \param Pluginname

 \param Filepath

 \param CommandlineData

 \return
*/
BOOL CBMAPIDECL opencbm_plugin_install_plugin_data(const char * Pluginname, const char * Filepath, const CbmPluginInstallProcessCommandlineData_t * CommandlineData)
{
    BOOL error = TRUE;

    opencbm_configuration_handle configuration_handle;

    const char * configurationFilename = NULL; 

    FUNC_ENTER();

    do {
        /* create the INI file, if not present, and create the needed keys */

        configurationFilename = configuration_get_default_filename();

        if (configurationFilename == NULL) {
            break;
        }

        configuration_handle = opencbm_configuration_open(configurationFilename);
        if (configuration_handle == NULL) {
            DBG_PRINT((DBG_PREFIX "No configuration file present. Is OpenCBM installed at all?"));
            break;
        }

        error = opencbm_configuration_set_data(configuration_handle, 
                   Pluginname, "location", Filepath);

        if (error == 0) {
            error = cbm_plugin_call_self_init_plugin(Pluginname, Filepath, CommandlineData->OptionMemory);
        }

        error = opencbm_configuration_close(configuration_handle) || error;

    } while (0);

    cbmlibmisc_strfree(configurationFilename);

    FUNC_LEAVE_BOOL(error);
}
Example #9
0
static BOOL
cbm_plugin_call_self_init_plugin(const char * Pluginname, const char * Filepath, const CbmPluginInstallProcessCommandlineData_t * CommandlineData)
{
    BOOL error = TRUE;
    SHARED_OBJECT_HANDLE pluginHandle = SHARED_OBJECT_HANDLE_INVALID;

    FUNC_ENTER();

    do {
        opencbm_plugin_self_init_plugin_t * opencbm_plugin_self_init_plugin = NULL;

        pluginHandle = plugin_load(Filepath);
        if (pluginHandle == SHARED_OBJECT_HANDLE_INVALID) {
            DBG_ERROR((DBG_PREFIX "Could not load plugin '%s' at '%s' for self-init!\n", Pluginname, Filepath));
            break;
        }

        opencbm_plugin_self_init_plugin = plugin_get_address(pluginHandle, "opencbm_plugin_self_init_plugin");
        if ( ! opencbm_plugin_self_init_plugin ) {
            error = FALSE;
            break;
        }

        error = opencbm_plugin_self_init_plugin();
        if (error) {
            break;
        }

        error = plugin_set_active(Pluginname);

    } while (0);

    if (pluginHandle != SHARED_OBJECT_HANDLE_INVALID) {
        plugin_unload(pluginHandle);
    }

    FUNC_LEAVE_BOOL(error);
}
Example #10
0
BOOL
opencbm_init(IN HANDLE Module, IN DWORD Reason, IN LPVOID Reserved)
{
    static BOOL bIsOpen = FALSE;
    BOOLEAN Status = TRUE;

    FUNC_ENTER();

#if DBG

    if (Reason == DLL_PROCESS_ATTACH)
    {
        // Read the debugging flags from the registry

        cbm_i_get_debugging_flags();
    }

#endif

    /* make sure the definitions in opencbm.h and cbmioctl.h
     * match each other! 
     * Since we are the only instance which includes both files,
     * we are the only one which can ensure this.
     */

    DBG_ASSERT(IEC_LINE_CLOCK == IEC_CLOCK);
    DBG_ASSERT(IEC_LINE_RESET == IEC_RESET);
    DBG_ASSERT(IEC_LINE_DATA == IEC_DATA);
    DBG_ASSERT(IEC_LINE_ATN == IEC_ATN);

    switch (Reason) 
    {
        case DLL_PROCESS_ATTACH:

            if (IsDriverStartedAutomatically())
            {
                // the driver is started automatically, do not try
                // to start it

                Status = TRUE;
            }
            else
            {
                if (bIsOpen)
                {
                    DBG_ERROR((DBG_PREFIX "No multiple instances are allowed!"));
                    Status = FALSE;
                }
                else
                {
                    Status  = TRUE;
                    bIsOpen = cbm_i_driver_start();
                }
            }

            /* If the DLL loaded successfully, ask for fast scheduling */
            if (Status)
            {
                fastschedule_start();
            }
            break;

        case DLL_PROCESS_DETACH:

            if (IsDriverStartedAutomatically())
            {
                // the driver is started automatically, do not try
                // to stop it

                Status = TRUE;
            }
            else
            {
                if (!bIsOpen)
                {
                    DBG_ERROR((DBG_PREFIX "Driver is not running!"));
                    Status = FALSE;
                }
                else
                {
                    // it is arguable if the driver should be stopped
                    // whenever the DLL is unloaded.

                    cbm_i_driver_stop();
                    bIsOpen = FALSE;
                }
            }

            /* If the DLL unloaded successfully, we do not need fast scheduling anymore. */
            if (Status)
            {
                fastschedule_stop();
            }
            break;

        default:
            break;

    }

    FUNC_LEAVE_BOOL(Status);
}
Example #11
0
/*! \internal \brief Process a number

 This function processes a number which was given as a string.

 \param Argument:
   Pointer to the number in ASCII representation

 \param NextChar:
   Pointer to a PCHAR which will had the address of the next
   char not used on return. This can be NULL.

 \param ParameterGiven:
   Pointer to a BOOL which will be set to TRUE if the value
   could be calculated correctly. Can be NULL.

 \param ParameterValue:
   Pointer to a ULONG which will get the result.

 \return
   TRUE on error, FALSE on success.

 If this parameter is given more than once, the last occurence
 takes precedence.

 The number can be specified in octal (0***), hex (0x***), or
 decimal (anything else).

 If NextChar is NULL, the Argument *must* terminate at the
 end of the number. If NextChar is not NULL, the Argument might
 contain a comma.
*/
static BOOL
processNumber(const PCHAR Argument, PCHAR *NextChar, PBOOL ParameterGiven, PULONG ParameterValue)
{
    PCHAR p;
    BOOL error;
    int base;

    FUNC_ENTER();

    DBG_ASSERT(ParameterValue != NULL);

    error = FALSE;
    p = Argument;

    if (p)
    {
        // Find out which base to use (0***, 0x***, or anything else)

        switch (*p)
        {
        case 0:
            error = TRUE;
            break;

        case '0':
            switch (*++p)
            {
            case 'x': case 'X':
                base = 16;
                ++p;
                break;

            default:
                base = 8;
                break;
            };
            break;

        default:
            base = 10;
            break;
        }

        // Convert the value

        if (!error)
        {
            *ParameterValue = strtoul(p, &p, base);

            if (NextChar)
            {
                error = ((*p != 0) && (*p != ',')) ? TRUE : FALSE;
            }
            else
            {
                error = *p != 0 ? TRUE : FALSE;
            }

            if (!error)
            {
                if (NextChar != NULL)
                {
                    *NextChar = p + ((*p) ? 1 : 0);
                }

                if (ParameterGiven != NULL)
                {
                    *ParameterGiven = TRUE;
                }
            }
        }
    }

    FUNC_LEAVE_BOOL(error);
}