LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLDataSources.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 52 0.0 %
Date: 2024-12-20 20:06:10 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*
       2             :  * SPDX-License-Identifier: MPL-2.0
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * Copyright 2024 MonetDB Foundation;
       9             :  * Copyright August 2008 - 2023 MonetDB B.V.;
      10             :  * Copyright 1997 - July 2008 CWI.
      11             :  */
      12             : 
      13             : /*
      14             :  * This code was created by Peter Harvey (mostly during Christmas 98/99).
      15             :  * This code is LGPL. Please ensure that this message remains in future
      16             :  * distributions and uses of this code (that's about all I get out of it).
      17             :  * - Peter Harvey pharvey@codebydesign.com
      18             :  *
      19             :  * This file has been modified for the MonetDB project.  See the file
      20             :  * Copyright in this directory for more information.
      21             :  */
      22             : 
      23             : /**********************************************************************
      24             :  * SQLDataSources()
      25             :  * CLI Compliance: ISO 92
      26             :  *
      27             :  * Author: Sjoerd Mullender
      28             :  * Date  : 4 sep 2003
      29             :  *
      30             :  **********************************************************************/
      31             : 
      32             : #include "ODBCGlobal.h"
      33             : #include "ODBCStmt.h"
      34             : #include "ODBCUtil.h"
      35             : 
      36             : 
      37             : static SQLRETURN
      38           0 : MNDBDataSources(ODBCEnv *env,
      39             :                 SQLUSMALLINT Direction,
      40             :                 SQLCHAR *ServerName,
      41             :                 SQLSMALLINT BufferLength1,
      42             :                 SQLSMALLINT *NameLength1,
      43             :                 SQLCHAR *Description,
      44             :                 SQLSMALLINT BufferLength2,
      45             :                 SQLSMALLINT *NameLength2)
      46             : {
      47           0 :         (void) Direction;
      48           0 :         (void) ServerName;
      49           0 :         (void) BufferLength1;
      50           0 :         (void) NameLength1;
      51           0 :         (void) Description;
      52           0 :         (void) BufferLength2;
      53           0 :         (void) NameLength2;
      54             : 
      55           0 :         if (env->sql_attr_odbc_version == 0) {
      56             :                 /* Function sequence error */
      57           0 :                 addEnvError(env, "HY010", NULL, 0);
      58           0 :                 return SQL_ERROR;
      59             :         }
      60             : 
      61             :         /* TODO: implement the requested behavior */
      62             : 
      63             :         /* Driver does not support this function */
      64           0 :         addEnvError(env, "IM001", NULL, 0);
      65           0 :         return SQL_ERROR;
      66             : }
      67             : 
      68             : #ifdef ODBCDEBUG
      69             : static char *
      70           0 : translateDirection(SQLUSMALLINT Direction)
      71             : {
      72           0 :         switch (Direction) {
      73             :         case SQL_FETCH_NEXT:
      74             :                 return "SQL_FETCH_NEXT";
      75           0 :         case SQL_FETCH_FIRST:
      76           0 :                 return "SQL_FETCH_FIRST";
      77           0 :         case SQL_FETCH_FIRST_USER:
      78           0 :                 return "SQL_FETCH_FIRST_USER";
      79           0 :         case SQL_FETCH_FIRST_SYSTEM:
      80           0 :                 return "SQL_FETCH_FIRST_SYSTEM";
      81           0 :         default:
      82           0 :                 return "unknown";
      83             :         }
      84             : }
      85             : #endif
      86             : 
      87             : SQLRETURN SQL_API
      88             : SQLDataSources(SQLHENV EnvironmentHandle,
      89             :                SQLUSMALLINT Direction,
      90             :                SQLCHAR *ServerName,
      91             :                SQLSMALLINT BufferLength1,
      92             :                SQLSMALLINT *NameLength1,
      93             :                SQLCHAR *Description,
      94             :                SQLSMALLINT BufferLength2,
      95             :                SQLSMALLINT *NameLength2)
      96             : {
      97           0 :         ODBCEnv *env = (ODBCEnv *) EnvironmentHandle;
      98             : 
      99             : #ifdef ODBCDEBUG
     100           0 :         ODBCLOG("SQLDataSources %p %s\n",
     101             :                 EnvironmentHandle, translateDirection(Direction));
     102             : #endif
     103             : 
     104           0 :         if (!isValidEnv(env))
     105             :                 return SQL_INVALID_HANDLE;
     106             : 
     107           0 :         clearEnvErrors(env);
     108             : 
     109           0 :         return MNDBDataSources(env, Direction,
     110             :                                ServerName, BufferLength1, NameLength1,
     111             :                                Description, BufferLength2, NameLength2);
     112             : }
     113             : 
     114             : SQLRETURN SQL_API
     115             : SQLDataSourcesA(SQLHENV EnvironmentHandle,
     116             :                 SQLUSMALLINT Direction,
     117             :                 SQLCHAR *ServerName,
     118             :                 SQLSMALLINT BufferLength1,
     119             :                 SQLSMALLINT *NameLength1,
     120             :                 SQLCHAR *Description,
     121             :                 SQLSMALLINT BufferLength2,
     122             :                 SQLSMALLINT *NameLength2)
     123             : {
     124           0 :         return SQLDataSources(EnvironmentHandle, Direction,
     125             :                               ServerName, BufferLength1, NameLength1,
     126             :                               Description, BufferLength2, NameLength2);
     127             : }
     128             : 
     129             : SQLRETURN SQL_API
     130             : SQLDataSourcesW(SQLHENV EnvironmentHandle,
     131             :                 SQLUSMALLINT Direction,
     132             :                 SQLWCHAR *ServerName,
     133             :                 SQLSMALLINT BufferLength1,
     134             :                 SQLSMALLINT *NameLength1,
     135             :                 SQLWCHAR *Description,
     136             :                 SQLSMALLINT BufferLength2,
     137             :                 SQLSMALLINT *NameLength2)
     138             : {
     139           0 :         ODBCEnv *env = (ODBCEnv *) EnvironmentHandle;
     140           0 :         SQLRETURN rc;
     141           0 :         SQLCHAR *server, *descr;
     142           0 :         SQLSMALLINT length1, length2;
     143             : 
     144             : #ifdef ODBCDEBUG
     145           0 :         ODBCLOG("SQLDataSourcesW %p %s\n",
     146             :                 EnvironmentHandle, translateDirection(Direction));
     147             : #endif
     148             : 
     149           0 :         if (!isValidEnv(env))
     150             :                 return SQL_INVALID_HANDLE;
     151             : 
     152           0 :         clearEnvErrors(env);
     153             : 
     154           0 :         server = malloc(100);
     155           0 :         descr = malloc(100);
     156           0 :         if (server == NULL || descr == NULL) {
     157             :                 /* Memory allocation error */
     158           0 :                 addEnvError(env, "HY001", NULL, 0);
     159           0 :                 if (server)
     160           0 :                         free(server);
     161           0 :                 if (descr)
     162           0 :                         free(descr);
     163           0 :                 return SQL_ERROR;
     164             :         }
     165             : 
     166           0 :         rc = MNDBDataSources(env, Direction,
     167             :                              server, 100, &length1,
     168             :                              descr, 100, &length2);
     169             : 
     170           0 :         if (SQL_SUCCEEDED(rc)) {
     171           0 :                 fixWcharOut(rc, server, length1,
     172             :                             ServerName, BufferLength1, NameLength1,
     173             :                             1, addEnvError, env);
     174           0 :                 fixWcharOut(rc, descr, length2,
     175             :                             Description, BufferLength2, NameLength2,
     176             :                             1, addEnvError, env);
     177             :         }
     178           0 :         free(server);
     179           0 :         free(descr);
     180             : 
     181           0 :         return rc;
     182             : }

Generated by: LCOV version 1.14