int _iodbcdm_cfg_search_init(PCONFIG *ppconf, const char *filename, int doCreate) { char pathbuf[1024]; int rc; if (strstr (filename, "odbc.ini") || strstr (filename, "ODBC.INI")) { char *fname_odbcini = _iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, doCreate); #if defined(__APPLE__) if (fname_odbcini && wSystemDSN == USERDSN_ONLY) _fix_office_access(fname_odbcini, FALSE); #endif rc = _iodbcdm_cfg_init (ppconf, fname_odbcini, doCreate); #if defined(__APPLE__) if (!rc && fname_odbcini && wSystemDSN == USERDSN_ONLY) { char buf[1024]; char *lib_odbcini = _getinifilename (buf, sizeof (buf), FALSE, FALSE); /* if we try open ~/Library/ODBC/odbc.ini */ if (lib_odbcini && strcmp(fname_odbcini, lib_odbcini)==0) _fix_home_odbc(*ppconf, fname_odbcini, FALSE); } #endif return rc; } else if (strstr (filename, "odbcinst.ini") || strstr (filename, "ODBCINST.INI")) { char *fname_odbcinst = _iodbcadm_getinifile (pathbuf, sizeof (pathbuf), TRUE, doCreate); #if defined(__APPLE__) if (fname_odbcinst && wSystemDSN == USERDSN_ONLY) _fix_office_access(fname_odbcinst, TRUE); #endif rc = _iodbcdm_cfg_init (ppconf, fname_odbcinst, doCreate); #if defined(__APPLE__) if (!rc && fname_odbcinst && wSystemDSN == USERDSN_ONLY) { char buf[1024]; char *lib_odbcinst = _getinifilename (buf, sizeof (buf), TRUE, FALSE); /* if we try open ~/Library/ODBC/odbcinst.ini */ if (lib_odbcinst && strcmp(fname_odbcinst, lib_odbcinst)==0) _fix_home_odbc(*ppconf, fname_odbcinst, TRUE); } #endif return rc; } else if (doCreate || (!doCreate && access(filename, R_OK) == 0)) return _iodbcdm_cfg_init (ppconf, filename, doCreate); else return -1; }
int _iodbcdm_cfg_search_init(PCONFIG *ppconf, const char *filename, int doCreate) { char pathbuf[1024]; if (strstr (filename, "odbc.ini") || strstr (filename, "ODBC.INI")) return _iodbcdm_cfg_init (ppconf, _iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, doCreate), doCreate); else if (strstr (filename, "odbcinst.ini") || strstr (filename, "ODBCINST.INI")) return _iodbcdm_cfg_init (ppconf, _iodbcadm_getinifile (pathbuf, sizeof (pathbuf), TRUE, doCreate), doCreate); else if (doCreate || (!doCreate && access(filename, R_OK) == 0)) return _iodbcdm_cfg_init (ppconf, filename, doCreate); else return -1; }
BOOL INSTAPI SQLWritePrivateProfileString (LPCSTR lpszSection, LPCSTR lpszEntry, LPCSTR lpszString, LPCSTR lpszFilename) { char pathbuf[1024]; BOOL retcode = FALSE; /* Check input parameters */ CLEAR_ERROR (); /* Else go through user/system odbc.ini */ switch (configMode) { case ODBC_USER_DSN: wSystemDSN = USERDSN_ONLY; if (lpszFilename) { retcode = WritePrivateProfileString (lpszSection, lpszEntry, lpszString, lpszFilename); goto quit; } if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE)) retcode = WritePrivateProfileString (lpszSection, lpszEntry, lpszString, pathbuf); goto quit; case ODBC_SYSTEM_DSN: wSystemDSN = SYSTEMDSN_ONLY; if (lpszFilename) { retcode = WritePrivateProfileString (lpszSection, lpszEntry, lpszString, lpszFilename); goto quit; } if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE)) retcode = WritePrivateProfileString (lpszSection, lpszEntry, lpszString, pathbuf); goto quit; case ODBC_BOTH_DSN: wSystemDSN = USERDSN_ONLY; if (lpszFilename) { retcode = WritePrivateProfileString (lpszSection, lpszEntry, lpszString, lpszFilename); if (!retcode) { CLEAR_ERROR (); wSystemDSN = SYSTEMDSN_ONLY; retcode = WritePrivateProfileString (lpszSection, lpszEntry, lpszString, lpszFilename); } goto quit; } if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE)) retcode = WritePrivateProfileString (lpszSection, lpszEntry, lpszString, pathbuf); else { CLEAR_ERROR (); wSystemDSN = SYSTEMDSN_ONLY; if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE)) retcode = WritePrivateProfileString (lpszSection, lpszEntry, lpszString, pathbuf); } goto quit; } PUSH_ERROR (ODBC_ERROR_GENERAL_ERR); goto quit; quit: wSystemDSN = USERDSN_ONLY; configMode = ODBC_BOTH_DSN; return retcode; }