1 /*
2  *  GetConnectOption.c
3  *
4  *  $Id$
5  *
6  *  SQLGetConnectOption trace functions
7  *
8  *  The iODBC driver manager.
9  *
10  *  Copyright (C) 1996-2021 OpenLink Software <iodbc@openlinksw.com>
11  *  All Rights Reserved.
12  *
13  *  This software is released under the terms of either of the following
14  *  licenses:
15  *
16  *      - GNU Library General Public License (see LICENSE.LGPL)
17  *      - The BSD License (see LICENSE.BSD).
18  *
19  *  Note that the only valid version of the LGPL license as far as this
20  *  project is concerned is the original GNU Library General Public License
21  *  Version 2, dated June 1991.
22  *
23  *  While not mandated by the BSD license, any patches you make to the
24  *  iODBC source code may be contributed back into the iODBC project
25  *  at your discretion. Contributions will benefit the Open Source and
26  *  Data Access community as a whole. Submissions may be made at:
27  *
28  *      http://www.iodbc.org
29  *
30  *
31  *  GNU Library Generic Public License Version 2
32  *  ============================================
33  *  This library is free software; you can redistribute it and/or
34  *  modify it under the terms of the GNU Library General Public
35  *  License as published by the Free Software Foundation; only
36  *  Version 2 of the License dated June 1991.
37  *
38  *  This library is distributed in the hope that it will be useful,
39  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
40  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
41  *  Library General Public License for more details.
42  *
43  *  You should have received a copy of the GNU Library General Public
44  *  License along with this library; if not, write to the Free
45  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
46  *
47  *
48  *  The BSD License
49  *  ===============
50  *  Redistribution and use in source and binary forms, with or without
51  *  modification, are permitted provided that the following conditions
52  *  are met:
53  *
54  *  1. Redistributions of source code must retain the above copyright
55  *     notice, this list of conditions and the following disclaimer.
56  *  2. Redistributions in binary form must reproduce the above copyright
57  *     notice, this list of conditions and the following disclaimer in
58  *     the documentation and/or other materials provided with the
59  *     distribution.
60  *  3. Neither the name of OpenLink Software Inc. nor the names of its
61  *     contributors may be used to endorse or promote products derived
62  *     from this software without specific prior written permission.
63  *
64  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
65  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
66  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
67  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OPENLINK OR
68  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
69  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
70  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
71  *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
72  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
73  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
74  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75  */
76 
77 #include "trace.h"
78 
79 
80 void
_trace_connopt_type(SQLUSMALLINT type)81 _trace_connopt_type (SQLUSMALLINT type)
82 {
83   char *ptr = "unknown connection attribute";
84 
85   switch (type)
86     {
87       _S (SQL_ACCESS_MODE);
88       _S (SQL_AUTOCOMMIT);
89       _S (SQL_CURRENT_QUALIFIER);
90       _S (SQL_LOGIN_TIMEOUT);
91       _S (SQL_ODBC_CURSORS);
92       _S (SQL_OPT_TRACE);
93       _S (SQL_OPT_TRACEFILE);
94       _S (SQL_PACKET_SIZE);
95       _S (SQL_QUIET_MODE);
96       _S (SQL_TRANSLATE_DLL);
97       _S (SQL_TRANSLATE_OPTION);
98       _S (SQL_TXN_ISOLATION);
99 
100       /* 2.0 Driver Manager also allows statement options at this time */
101       _S (SQL_ASYNC_ENABLE);
102       _S (SQL_BIND_TYPE);
103       _S (SQL_CONCURRENCY);
104       _S (SQL_CURSOR_TYPE);
105       _S (SQL_KEYSET_SIZE);
106       _S (SQL_MAX_LENGTH);
107       _S (SQL_MAX_ROWS);
108       _S (SQL_NOSCAN);
109       _S (SQL_QUERY_TIMEOUT);
110       _S (SQL_RETRIEVE_DATA);
111       _S (SQL_ROWSET_SIZE);
112       _S (SQL_SIMULATE_CURSOR);
113       _S (SQL_USE_BOOKMARKS);
114     }
115 
116   trace_emit ("\t\t%-15.15s   %d (%s)\n", "SQLUSMALLINT ", (int) type, ptr);
117 }
118 
119 
120 void
trace_SQLGetConnectOption(int trace_leave,int retcode,SQLHDBC hdbc,SQLUSMALLINT fOption,SQLPOINTER pvParam)121 trace_SQLGetConnectOption (int trace_leave, int retcode,
122   SQLHDBC		  hdbc,
123   SQLUSMALLINT		  fOption,
124   SQLPOINTER		  pvParam)
125 {
126   /* Trace function */
127   _trace_print_function (en_GetConnectOption, trace_leave, retcode);
128 
129   /* Trace Arguments */
130   _trace_handle (SQL_HANDLE_DBC, hdbc);
131   _trace_connopt_type (fOption);
132   _trace_pointer (pvParam);
133 }
134 
135 
136 #if ODBCVER >= 0x0300
137 void
trace_SQLGetConnectOptionW(int trace_leave,int retcode,SQLHDBC hdbc,SQLUSMALLINT fOption,SQLPOINTER pvParam)138 trace_SQLGetConnectOptionW (int trace_leave, int retcode,
139   SQLHDBC		  hdbc,
140   SQLUSMALLINT		  fOption,
141   SQLPOINTER		  pvParam)
142 {
143   /* Trace function */
144   _trace_print_function (en_GetConnectOptionW, trace_leave, retcode);
145 
146   /* Trace Arguments */
147   _trace_handle (SQL_HANDLE_DBC, hdbc);
148   _trace_connopt_type (fOption);
149   _trace_pointer (pvParam);
150 }
151 #endif
152