~ubuntu-branches/debian/sid/unixodbc/sid

« back to all changes in this revision

Viewing changes to odbcinst/SQLSetConfigMode.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2004-10-15 03:07:52 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041015030752-dzw4vhxlgycz3woj
Tags: 2.2.4-11
Brown paper bag me: conflicts do not write themselves just because
you add a line to the changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#include <stdlib.h>
14
14
#include <odbcinstext.h>
15
15
 
16
 
BOOL SQLSetConfigMode(                  UWORD   nConfigMode )
17
 
{
18
 
        switch ( nConfigMode )
 
16
/*
 
17
 * This avoids all sorts of problems with using putenv, we need to check 
 
18
 * that drivers can see this as well though....
 
19
 */
 
20
 
 
21
static int __config_mode = ODBC_BOTH_DSN;
 
22
 
 
23
__set_config_mode( int mode )
 
24
{
 
25
    __config_mode = mode;
 
26
}
 
27
 
 
28
__get_config_mode()
 
29
{
 
30
    char *p;
 
31
 
 
32
    /* 
 
33
     * if the environment var is set then it overrides the flag
 
34
     */
 
35
 
 
36
        p  = getenv( "ODBCSEARCH" );
 
37
        if ( p )
19
38
        {
20
 
        case ODBC_USER_DSN:
21
 
#ifdef HAVE_SETENV
22
 
                if ( setenv( "ODBCSEARCH", "ODBC_USER_DSN", 1 ) == 0 )
23
 
#else
24
 
                if ( putenv( "ODBCSEARCH=ODBC_USER_DSN" ) == 0 )
25
 
#endif
26
 
                {
27
 
                        return TRUE;
28
 
                }
29
 
                break;
30
 
        case ODBC_SYSTEM_DSN:
31
 
#ifdef HAVE_SETENV
32
 
                if ( setenv( "ODBCSEARCH", "ODBC_SYSTEM_DSN", 1 ) == 0 )
33
 
#else
34
 
                if ( putenv( "ODBCSEARCH=ODBC_SYSTEM_DSN" ) == 0 )
35
 
#endif
36
 
                {
37
 
                        return TRUE;
38
 
                }
39
 
                break;
40
 
    default:
41
 
#ifdef HAVE_SETENV
42
 
                if ( setenv( "ODBCSEARCH", "ODBC_BOTH_DSN", 1 ) == 0 )
43
 
#else
44
 
                if ( putenv( "ODBCSEARCH=ODBC_BOTH_DSN" ) == 0 )
45
 
#endif
46
 
                {
47
 
                        return TRUE;
48
 
                }
49
 
                break;
 
39
                if ( strcmp( p, "ODBC_SYSTEM_DSN" ) == 0 )
 
40
                {
 
41
            __config_mode = ODBC_SYSTEM_DSN;
 
42
                }
 
43
                else if ( strcmp( p, "ODBC_USER_DSN" ) == 0 )
 
44
                {
 
45
            __config_mode = ODBC_USER_DSN;
 
46
                }
 
47
                else if ( strcmp( p, "ODBC_BOTH_DSN" ) == 0 )
 
48
                {
 
49
            __config_mode = ODBC_BOTH_DSN;
 
50
                }
50
51
        }
51
52
 
52
 
        inst_logPushMsg( __FILE__, 
53
 
            __FILE__, __LINE__, LOG_CRITICAL, ODBC_ERROR_OUT_OF_MEM, "" );
54
 
        
55
 
        return FALSE;
56
 
}
57
 
 
58
 
 
59
 
 
60
 
 
61
 
 
 
53
    return __config_mode;
 
54
}
 
55
 
 
56
BOOL SQLSetConfigMode(                  UWORD   nConfigMode )
 
57
{
 
58
    __set_config_mode( nConfigMode );
 
59
    return TRUE;
 
60
}