| 1 | /************************************************** |
| 2 | * |
| 3 | ************************************************** |
| 4 | * This code was created by Peter Harvey @ CodeByDesign. |
| 5 | * Released under LGPL 28.JAN.99 |
| 6 | * |
| 7 | * Contributions from... |
| 8 | * ----------------------------------------------- |
| 9 | * Peter Harvey - pharvey@codebydesign.com |
| 10 | * Nick Gorham - nick@lurcher.org |
| 11 | **************************************************/ |
| 12 | |
| 13 | #include <config.h> |
| 14 | #include <stdlib.h> |
| 15 | #include <odbcinstext.h> |
| 16 | |
| 17 | /* |
| 18 | * This avoids all sorts of problems with using putenv, we need to check |
| 19 | * that drivers can see this as well though.... |
| 20 | */ |
| 21 | |
| 22 | static int __config_mode = ODBC_BOTH_DSN; |
| 23 | |
| 24 | void __set_config_mode( int mode ) |
| 25 | { |
| 26 | __config_mode = mode; |
| 27 | } |
| 28 | |
| 29 | int __get_config_mode( void ) |
| 30 | { |
| 31 | char *p; |
| 32 | |
| 33 | /* |
| 34 | * if the environment var is set then it overrides the flag |
| 35 | */ |
| 36 | |
| 37 | p = getenv( "ODBCSEARCH" ); |
| 38 | if ( p ) |
| 39 | { |
| 40 | if ( strcmp( p, "ODBC_SYSTEM_DSN" ) == 0 ) |
| 41 | { |
| 42 | __config_mode = ODBC_SYSTEM_DSN; |
| 43 | } |
| 44 | else if ( strcmp( p, "ODBC_USER_DSN" ) == 0 ) |
| 45 | { |
| 46 | __config_mode = ODBC_USER_DSN; |
| 47 | } |
| 48 | else if ( strcmp( p, "ODBC_BOTH_DSN" ) == 0 ) |
| 49 | { |
| 50 | __config_mode = ODBC_BOTH_DSN; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return __config_mode; |
| 55 | } |
| 56 | |
| 57 | BOOL SQLSetConfigMode( UWORD nConfigMode ) |
| 58 | { |
| 59 | inst_logClear(); |
| 60 | |
| 61 | __set_config_mode( nConfigMode ); |
| 62 | return TRUE; |
| 63 | } |
| 64 | |