Exemplo n.º 1
0
int OdbcStaticConnection::do_rdbi_init (rdbi_context_def** rdbi_context)
{
#ifdef _WIN32
#ifdef RDBI_STATIC
        return (rdbi_init (rdbi_context, (initializer*)odbcdr_rdbi_init));
#else
        return (rdbi_initialize (rdbi_context, "SqlServerDriver"));
#endif
#else
	return 0;
#endif
}
Exemplo n.º 2
0
int rdbi_initialize (rdbi_context_def **contextp, char* driver)
{
    DWORD nchars;
    char module[MAX_PATH];
    char* last;
    HMODULE handle;
    FARPROC procedure;
    int status;

    debug_on("rdbi_initialize");

    nchars = GetModuleFileName (NULL, module, MAX_PATH);
    if (0 == nchars)
        strcpy (module, ".\\");
    else
    {   
        // scan the string for the last occurrence of a slash
        last = strrchr (module, '\\');
        if (NULL != last)
        {
            last++; // move past the slash
            *last = '\0'; // null terminate it there
        }
    }
    strcat (module, driver);
#ifdef _WIN32
    strcat (module, ".dll");
#else
    strcat (module, ".so"); // doesn't really work here, just a placeholder
#endif
    handle = LoadLibrary (module);
    if (NULL != handle)
    {
        procedure = GetProcAddress (handle, "init");
        if (NULL != procedure)
            status = rdbi_init (contextp, (initializer*)procedure);
        else
            status = RDBI_GENERIC_ERROR;
    }
    else
        status = RDBI_GENERIC_ERROR;
    
    debug_return(NULL, status);
}