Changeset: 8173493d7ea1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8173493d7ea1 Added Files: clients/odbc/driver/ODBCAttrs.c Modified Files: clients/odbc/driver/CMakeLists.txt clients/odbc/driver/SQLConnect.c Branch: odbc-tls Log Message:
Move attr_settings to their own file diffs (124 lines): diff --git a/clients/odbc/driver/CMakeLists.txt b/clients/odbc/driver/CMakeLists.txt --- a/clients/odbc/driver/CMakeLists.txt +++ b/clients/odbc/driver/CMakeLists.txt @@ -20,6 +20,7 @@ add_library(MonetODBC target_sources(MonetODBC PRIVATE ODBCAttrs.h + ODBCAttrs.c ODBCConvert.c ODBCDbc.c ODBCDbc.h diff --git a/clients/odbc/driver/ODBCAttrs.c b/clients/odbc/driver/ODBCAttrs.c new file mode 100644 --- /dev/null +++ b/clients/odbc/driver/ODBCAttrs.c @@ -0,0 +1,58 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright 2024 MonetDB Foundation; + * Copyright August 2008 - 2023 MonetDB B.V.; + * Copyright 1997 - July 2008 CWI. + */ + +#include "ODBCGlobal.h" +#include "ODBCAttrs.h" + +#ifdef HAVE_ODBCINST_H +#include <odbcinst.h> +#endif + + +#define SUGGEST_BOOLEAN "{True,False}" + +const struct attr_setting attr_settings[] = { + { "UID", "User", MP_USER }, + { "PWD", "Password", MP_PASSWORD }, + { "DATABASE", "Database", MP_DATABASE }, + { "PORT", "Port", MP_PORT }, + { "HOST", "Server", MP_HOST }, + { "SOCK", "Unix Socket", MP_SOCK }, + { "TLS", "Encrypt", MP_TLS, .suggest_values = SUGGEST_BOOLEAN }, + { "CERT", "Server Certificate", MP_CERT }, + { "CERTHASH", "Server Certificate Hash", MP_CERTHASH }, + { "CLIENTKEY", "Client Key", MP_CLIENTKEY }, + { "CLIENTCERT", "Client Certificate", MP_CLIENTCERT }, + { "AUTOCOMMIT", "Autocommit", MP_AUTOCOMMIT, .suggest_values = SUGGEST_BOOLEAN }, + { "SCHEMA", "Schema", MP_SCHEMA }, + { "TIMEZONE", "Time Zone", MP_TIMEZONE }, + { "REPLYSIZE", "Reply Size", MP_REPLYSIZE }, + { "LOGFILE", "Log File", MP_LOGFILE }, + { "LOGINTIMEOUT", "Login Timeout", MP_CONNECT_TIMEOUT}, + { "CONNECTIONTIMEOUT", "Connection Timeout", MP_REPLY_TIMEOUT}, +}; + +const int attr_setting_count = sizeof(attr_settings) / sizeof(attr_settings[0]); + +int +attr_setting_lookup(const char *attr_name, bool allow_alt_name) +{ + for (int i = 0; i < attr_setting_count; i++) { + const struct attr_setting *entry = &attr_settings[i]; + if (strcasecmp(attr_name, entry->name) == 0) + return i; + if (allow_alt_name && entry->alt_name && strcasecmp(attr_name, entry->alt_name) == 0) + return i; + } + return -1; +} + diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c --- a/clients/odbc/driver/SQLConnect.c +++ b/clients/odbc/driver/SQLConnect.c @@ -45,46 +45,6 @@ #define SQLGetPrivateProfileString(section,entry,default,buffer,bufferlen,filename) ((int) strcpy_len(buffer,default,bufferlen)) #endif -#define SUGGEST_BOOLEAN "{True,False}" - -const struct attr_setting attr_settings[] = { - { "UID", "User", MP_USER }, - { "PWD", "Password", MP_PASSWORD }, - { "DATABASE", "Database", MP_DATABASE }, - { "PORT", "Port", MP_PORT }, - { "HOST", "Server", MP_HOST }, - { "SOCK", "Unix Socket", MP_SOCK }, - { "TLS", "Encrypt", MP_TLS, .suggest_values = SUGGEST_BOOLEAN }, - { "CERT", "Server Certificate", MP_CERT }, - { "CERTHASH", "Server Certificate Hash", MP_CERTHASH }, - { "CLIENTKEY", "Client Key", MP_CLIENTKEY }, - { "CLIENTCERT", "Client Certificate", MP_CLIENTCERT }, - { "AUTOCOMMIT", "Autocommit", MP_AUTOCOMMIT, .suggest_values = SUGGEST_BOOLEAN }, - { "SCHEMA", "Schema", MP_SCHEMA }, - { "TIMEZONE", "Time Zone", MP_TIMEZONE }, - { "REPLYSIZE", "Reply Size", MP_REPLYSIZE }, - { "LOGFILE", "Log File", MP_LOGFILE }, - { "LOGINTIMEOUT", "Login Timeout", MP_CONNECT_TIMEOUT}, - { "CONNECTIONTIMEOUT", "Connection Timeout", MP_REPLY_TIMEOUT}, -}; - -const int attr_setting_count = sizeof(attr_settings) / sizeof(attr_settings[0]); - - -int -attr_setting_lookup(const char *attr_name, bool allow_alt_name) -{ - for (int i = 0; i < attr_setting_count; i++) { - const struct attr_setting *entry = &attr_settings[i]; - if (strcasecmp(attr_name, entry->name) == 0) - return i; - if (allow_alt_name && entry->alt_name && strcasecmp(attr_name, entry->alt_name) == 0) - return i; - } - return -1; -} - - static SQLRETURN get_serverinfo(ODBCDbc *dbc) { _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org