1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
/**************************************************
*
**************************************************
* This code was created by Peter Harvey @ CodeByDesign.
* Released under LGPL 28.JAN.99
*
* Contributions from...
* -----------------------------------------------
* Peter Harvey - pharvey@codebydesign.com
**************************************************/
#include <config.h>
#include <odbcinstext.h>
/*
* Add the historic ODBCINI value, mainly for applix.
*/
#ifdef VMS
char *odbcinst_system_file_path( char *buffer )
{
char *path;
if (( path = getvmsenv( "ODBCSYSINI" ))) {
strcpy( buffer, path );
return buffer;
}
#ifdef SYSTEM_FILE_PATH
else {
return SYSTEM_FILE_PATH;
}
#else
else {
return "ODBC_LIBDIR:";
}
#endif
}
char *odbcinst_system_file_name( char *buffer )
{
char *path;
if (( path = getvmsenv( "ODBCINSTINI" ))) {
strcpy( buffer, path );
return path;
}
else {
return "ODBCINST.INI";
}
}
char *odbcinst_user_file_path( char *buffer )
{
return "ODBC_LIBDIR:";
}
char *odbcinst_user_file_name( char *buffer )
{
return "ODBCINST.INI";
}
BOOL _odbcinst_SystemINI( char *pszFileName, BOOL bVerify )
{
FILE *hFile;
char b1[ 256 ];
sprintf( pszFileName, "%s:odbc.ini", odbcinst_system_file_path( b1 ));
if ( bVerify )
{
hFile = uo_fopen( pszFileName, "r" );
if ( hFile )
uo_fclose( hFile );
else
return FALSE;
}
return TRUE;
}
#else
char *odbcinst_system_file_name( char *buffer )
{
char *path;
static char save_path[ 512 ];
static int saved = 0;
if ( saved ) {
return save_path;
}
if (( path = getenv( "ODBCINSTINI" ))) {
strcpy( buffer, path );
strcpy( save_path, buffer );
saved = 1;
return buffer;
}
else {
strcpy( save_path, "odbcinst.ini" );
saved = 1;
return "odbcinst.ini";
}
}
char *odbcinst_system_file_path( char *buffer )
{
char *path;
static char save_path[ 512 ];
static int saved = 0;
if ( saved ) {
return save_path;
}
if (( path = getenv( "ODBCSYSINI" ))) {
strcpy( buffer, path );
strcpy( save_path, buffer );
saved = 1;
return buffer;
}
#ifdef SYSTEM_FILE_PATH
else {
strcpy( save_path, SYSTEM_FILE_PATH );
saved = 1;
return SYSTEM_FILE_PATH;
}
#else
else {
strcpy( save_path, "/etc" );
saved = 1;
return "/etc";
}
#endif
}
char *odbcinst_user_file_name( char *buffer )
{
return ".odbcinst.ini";
}
char *odbcinst_user_file_path( char *buffer )
{
char *path;
static char save_path[ 512 ];
static int saved = 0;
if ( saved ) {
return save_path;
}
if (( path = getenv( "HOME" ))) {
strcpy( buffer, path );
strcpy( save_path, buffer );
saved = 1;
return buffer;
}
else {
return "/home";
}
}
BOOL _odbcinst_SystemINI( char *pszFileName, BOOL bVerify )
{
FILE *hFile;
char b1[ 256 ];
sprintf( pszFileName, "%s/odbc.ini", odbcinst_system_file_path( b1 ));
if ( bVerify )
{
/* try opening for read */
hFile = uo_fopen( pszFileName, "r" );
if ( hFile )
uo_fclose( hFile );
else
{
/* does not exist so try creating it */
hFile = uo_fopen( pszFileName, "w" );
if ( hFile )
uo_fclose( hFile );
else
return FALSE;
}
}
return TRUE;
}
#endif
|