LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLDataSources.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 40 0.0 %
Date: 2021-10-13 02:24:04 Functions: 0 2 0.0 %

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

Generated by: LCOV version 1.14