LTP GCOV extension - code coverage report
Current view: directory - odbc - connectparams.c
Test: FreeTDS coverage
Date: 2008-11-21 Instrumented lines: 173
Code covered: 68.8 % Executed lines: 119

       1                 : /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
       2                 :  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005  Brian Bruns
       3                 :  * Copyright (C) 2005 Frediano Ziglio
       4                 :  *
       5                 :  * This library is free software; you can redistribute it and/or
       6                 :  * modify it under the terms of the GNU Library General Public
       7                 :  * License as published by the Free Software Foundation; either
       8                 :  * version 2 of the License, or (at your option) any later version.
       9                 :  *
      10                 :  * This library is distributed in the hope that it will be useful,
      11                 :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12                 :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13                 :  * Library General Public License for more details.
      14                 :  *
      15                 :  * You should have received a copy of the GNU Library General Public
      16                 :  * License along with this library; if not, write to the
      17                 :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      18                 :  * Boston, MA 02111-1307, USA.
      19                 :  */
      20                 : 
      21                 : #if HAVE_CONFIG_H
      22                 : #include <config.h>
      23                 : #endif
      24                 : 
      25                 : #include <stdlib.h>
      26                 : #include <stdio.h>
      27                 : #include <string.h>
      28                 : #include <ctype.h>
      29                 : #include <sys/stat.h>
      30                 : 
      31                 : #include "tdsodbc.h"
      32                 : #include "tdsstring.h"
      33                 : #include "replacements.h"
      34                 : 
      35                 : #ifdef DMALLOC
      36                 : #include <dmalloc.h>
      37                 : #endif
      38                 : 
      39                 : TDS_RCSID(var, "$Id: connectparams.c,v 1.66 2005/07/17 07:48:10 freddy77 Exp $");
      40                 : 
      41                 : #if !HAVE_SQLGETPRIVATEPROFILESTRING
      42                 : 
      43                 : /*
      44                 :  * Last resort place to check for INI file. This is usually set at compile time
      45                 :  * by build scripts.
      46                 :  */
      47                 : #ifndef SYS_ODBC_INI
      48                 : #define SYS_ODBC_INI "/etc/odbc.ini"
      49                 : #endif
      50                 : 
      51                 : /**
      52                 :  * Call this to get the INI file containing Data Source Names.
      53                 :  * @note rules for determining the location of ODBC config may be different 
      54                 :  * then what you expect - at this time they differ from unixODBC 
      55                 :  *
      56                 :  * @return file opened or NULL if error
      57                 :  * @retval 1 worked
      58                 :  */
      59                 : static FILE *tdoGetIniFileName(void);
      60                 : 
      61                 : /**
      62                 :  * SQLGetPrivateProfileString
      63                 :  *
      64                 :  * PURPOSE
      65                 :  *
      66                 :  *  This is an implementation of a common MS API call. This implementation 
      67                 :  *  should only be used if the ODBC sub-system/SDK does not have it.
      68                 :  *  For example; unixODBC has its own so those using unixODBC should NOT be
      69                 :  *  using this implementation because unixODBC;
      70                 :  *  - provides caching of ODBC config data 
      71                 :  *  - provides consistent interpretation of ODBC config data (i.e, location)
      72                 :  *
      73                 :  * ARGS
      74                 :  *
      75                 :  *  see ODBC documentation
      76                 :  *                      
      77                 :  * RETURNS
      78                 :  *
      79                 :  *  see ODBC documentation
      80                 :  *
      81                 :  * NOTES:
      82                 :  *
      83                 :  *  - the spec is not entirely implemented... consider this a lite version
      84                 :  *  - rules for determining the location of ODBC config may be different then what you 
      85                 :  *    expect see tdoGetIniFileName().
      86                 :  *
      87                 :  */
      88                 : static int SQLGetPrivateProfileString(LPCSTR pszSection, LPCSTR pszEntry, LPCSTR pszDefault, LPSTR pRetBuffer, int nRetBuffer,
      89                 :                                       LPCSTR pszFileName);
      90                 : #endif
      91                 : 
      92                 : #if defined(FILENAME_MAX) && FILENAME_MAX < 512
      93                 : #undef FILENAME_MAX
      94                 : #define FILENAME_MAX 512
      95                 : #endif
      96                 : 
      97                 : static int
      98                 : parse_server(char *server, TDSCONNECTION * connection)
      99               2 : {
     100                 :         char ip[64];
     101               2 :         char *p = (char *) strchr(server, '\\');
     102                 : 
     103               2 :         if (p) {
     104               0 :                 if (!tds_dstr_copy(&connection->instance_name, p+1))
     105               0 :                         return 0;
     106               0 :                 *p = 0;
     107                 :         }
     108                 : 
     109               2 :         tds_lookup_host(server, ip);
     110               2 :         if (!tds_dstr_copy(&connection->ip_addr, ip))
     111               0 :                 return 0;
     112                 : 
     113               2 :         return 1;
     114                 : }
     115                 : 
     116                 : /** 
     117                 :  * Read connection information from given DSN
     118                 :  * @param DSN           DSN name
     119                 :  * @param connection    where to store connection info
     120                 :  * @return 1 if success 0 otherwhise
     121                 :  */
     122                 : int
     123                 : odbc_get_dsn_info(const char *DSN, TDSCONNECTION * connection)
     124              88 : {
     125                 :         char tmp[FILENAME_MAX];
     126              88 :         int freetds_conf_less = 1;
     127              88 :         int address_specified = 0;
     128                 : 
     129                 :         /* use old servername */
     130              88 :         tmp[0] = '\0';
     131              88 :         if (SQLGetPrivateProfileString(DSN, "Servername", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
     132              88 :                 freetds_conf_less = 0;
     133              88 :                 tds_dstr_copy(&connection->server_name, tmp);
     134              88 :                 tds_read_conf_file(connection, tmp);
     135                 :         }
     136                 : 
     137                 :         /* search for server (compatible with ms one) */
     138              88 :         if (freetds_conf_less) {
     139               0 :                 tmp[0] = '\0';
     140               0 :                 if (SQLGetPrivateProfileString(DSN, "Address", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
     141               0 :                         address_specified = 1;
     142                 :                         /* TODO parse like MS */
     143               0 :                         tds_lookup_host(tmp, tmp);
     144               0 :                         tds_dstr_copy(&connection->ip_addr, tmp);
     145                 :                 }
     146                 : 
     147               0 :                 tmp[0] = '\0';
     148               0 :                 if (SQLGetPrivateProfileString(DSN, "Server", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
     149               0 :                         tds_dstr_copy(&connection->server_name, tmp);
     150               0 :                         if (!address_specified) {
     151               0 :                                 if (!parse_server(tmp, connection))
     152               0 :                                         return 0;
     153                 :                         }
     154                 :                 }
     155                 :         }
     156                 : 
     157              88 :         tmp[0] = '\0';
     158              88 :         if (SQLGetPrivateProfileString(DSN, "Port", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
     159               0 :                 connection->port = atoi(tmp);
     160                 :         }
     161                 : 
     162              88 :         tmp[0] = '\0';
     163              88 :         if (SQLGetPrivateProfileString(DSN, "TDS_Version", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
     164               0 :                 tds_config_verstr(tmp, connection);
     165                 :         }
     166                 : 
     167              88 :         tmp[0] = '\0';
     168              88 :         if (SQLGetPrivateProfileString(DSN, "Language", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
     169               0 :                 tds_dstr_copy(&connection->language, tmp);
     170                 :         }
     171                 : 
     172              88 :         tmp[0] = '\0';
     173              88 :         if (SQLGetPrivateProfileString(DSN, "Database", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
     174              88 :                 tds_dstr_copy(&connection->database, tmp);
     175                 :         }
     176                 : 
     177              88 :         tmp[0] = '\0';
     178              88 :         if (SQLGetPrivateProfileString(DSN, "TextSize", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
     179               0 :                 connection->text_size = atoi(tmp);
     180                 :         }
     181                 : 
     182              88 :         tmp[0] = '\0';
     183              88 :         if (SQLGetPrivateProfileString(DSN, "PacketSize", "", tmp, FILENAME_MAX, "odbc.ini") > 0) {
     184               0 :                 connection->block_size = atoi(tmp);
     185                 :         }
     186                 : 
     187              88 :         return 1;
     188                 : }
     189                 : 
     190                 : /** 
     191                 :  * Parse connection string and fill connection according
     192                 :  * @param connect_string     connect string
     193                 :  * @param connect_string_end connect string end (pointer to char past last)
     194                 :  * @param connection         where to store connection info
     195                 :  * @return 1 if success 0 otherwhise
     196                 :  */
     197                 : int
     198                 : odbc_parse_connect_string(const char *connect_string, const char *connect_string_end, TDSCONNECTION * connection)
     199               8 : {
     200                 :         const char *p, *end;
     201                 :         DSTR *dest_s, value;
     202               8 :         int reparse = 0;        /* flag for indicate second parse of string */
     203                 :         char option[16];
     204                 : 
     205               8 :         tds_dstr_init(&value);
     206              68 :         for (p = connect_string; p && *p;) {
     207              52 :                 dest_s = NULL;
     208                 : 
     209                 :                 /* parse option */
     210              52 :                 end = (const char *) memchr(p, '=', connect_string_end - p);
     211              52 :                 if (!end)
     212               0 :                         break;
     213                 : 
     214                 :                 /* account for spaces between ;'s. */
     215             104 :                 while (p < end && *p == ' ')
     216               0 :                         ++p;
     217                 : 
     218              52 :                 if ((end - p) >= (int) sizeof(option))
     219               0 :                         option[0] = 0;
     220                 :                 else {
     221              52 :                         memcpy(option, p, end - p);
     222              52 :                         option[end - p] = 0;
     223                 :                 }
     224                 : 
     225                 :                 /* parse value */
     226              52 :                 p = end + 1;
     227              52 :                 if (*p == '{') {
     228               0 :                         ++p;
     229                 :                         /* search "};" */
     230               0 :                         end = p;
     231               0 :                         while ((end = (const char *) memchr(end, '}', connect_string_end - end)) != NULL) {
     232               0 :                                 if ((end + 1) != connect_string_end && end[1] == ';')
     233               0 :                                         break;
     234               0 :                                 ++end;
     235                 :                         }
     236                 :                 } else {
     237              52 :                         end = (const char *) memchr(p, ';', connect_string_end - p);
     238                 :                 }
     239              52 :                 if (!end)
     240               0 :                         end = connect_string_end;
     241                 : 
     242              52 :                 if (!tds_dstr_copyn(&value, p, end - p))
     243               0 :                         return 0;
     244                 : 
     245              52 :                 if (strcasecmp(option, "SERVER") == 0) {
     246                 :                         /* ignore if servername or DSN specified */
     247               2 :                         if (!reparse) {
     248               2 :                                 dest_s = &connection->server_name;
     249                 :                                 /* not that safe cast but works -- freddy77 */
     250               2 :                                 if (!parse_server((char *) tds_dstr_cstr(&value), connection)) {
     251               0 :                                         tds_dstr_free(&value);
     252               0 :                                         return 0;
     253                 :                                 }
     254                 :                         }
     255              50 :                 } else if (strcasecmp(option, "SERVERNAME") == 0) {
     256               8 :                         if (!reparse) {
     257               4 :                                 tds_dstr_copy(&connection->server_name, tds_dstr_cstr(&value));
     258               4 :                                 tds_read_conf_file(connection, tds_dstr_cstr(&value));
     259               4 :                                 reparse = 1;
     260               4 :                                 p = connect_string;
     261               4 :                                 continue;
     262                 :                         }
     263              42 :                 } else if (strcasecmp(option, "DSN") == 0) {
     264               4 :                         if (!reparse) {
     265               2 :                                 odbc_get_dsn_info(tds_dstr_cstr(&value), connection);
     266               2 :                                 reparse = 1;
     267               2 :                                 p = connect_string;
     268               2 :                                 continue;
     269                 :                         }
     270              38 :                 } else if (strcasecmp(option, "DATABASE") == 0) {
     271               8 :                         dest_s = &connection->database;
     272              30 :                 } else if (strcasecmp(option, "UID") == 0) {
     273               8 :                         dest_s = &connection->user_name;
     274              22 :                 } else if (strcasecmp(option, "PWD") == 0) {
     275               8 :                         dest_s = &connection->password;
     276              14 :                 } else if (strcasecmp(option, "APP") == 0) {
     277               0 :                         dest_s = &connection->app_name;
     278              14 :                 } else if (strcasecmp(option, "WSID") == 0) {
     279               0 :                         dest_s = &connection->host_name;
     280              14 :                 } else if (strcasecmp(option, "LANGUAGE") == 0) {
     281               0 :                         dest_s = &connection->language;
     282              14 :                 } else if (strcasecmp(option, "Port") == 0) {
     283               2 :                         connection->port = atoi(tds_dstr_cstr(&value));
     284              12 :                 } else if (strcasecmp(option, "TDS_Version") == 0) {
     285               2 :                         tds_config_verstr(tds_dstr_cstr(&value), connection);
     286              10 :                 } else if (strcasecmp(option, "TextSize") == 0) {
     287               0 :                         connection->text_size = atoi(tds_dstr_cstr(&value));
     288              10 :                 } else if (strcasecmp(option, "PacketSize") == 0) {
     289               0 :                         connection->block_size = atoi(tds_dstr_cstr(&value));
     290                 :                         /* TODO "Address" field */
     291                 :                 }
     292                 : 
     293                 :                 /* copy to destination */
     294              46 :                 if (dest_s) {
     295              26 :                         tds_dstr_set(dest_s, tds_dstr_cstr(&value));
     296              26 :                         tds_dstr_init(&value);
     297                 :                 }
     298                 : 
     299              46 :                 p = end;
     300                 :                 /* handle "" ";.." "};.." cases */
     301              46 :                 if (p >= connect_string_end)
     302               0 :                         break;
     303              46 :                 if (*p == '}')
     304               0 :                         ++p;
     305              46 :                 ++p;
     306                 :         }
     307                 : 
     308               8 :         tds_dstr_free(&value);
     309               8 :         return p != NULL;
     310                 : }
     311                 : 
     312                 : #if !HAVE_SQLGETPRIVATEPROFILESTRING
     313                 : 
     314                 : #ifdef WIN32
     315                 : #  error There is something wrong  in configuration...
     316                 : #endif
     317                 : 
     318                 : typedef struct
     319                 : {
     320                 :         LPCSTR entry;
     321                 :         LPSTR buffer;
     322                 :         int buffer_len;
     323                 :         int ret_val;
     324                 :         int found;
     325                 : }
     326                 : ProfileParam;
     327                 : 
     328                 : static void
     329                 : tdoParseProfile(const char *option, const char *value, void *param)
     330            1848 : {
     331            1848 :         ProfileParam *p = (ProfileParam *) param;
     332                 : 
     333            1848 :         if (strcasecmp(p->entry, option) == 0) {
     334             176 :                 tds_strlcpy(p->buffer, value, p->buffer_len);
     335                 : 
     336             176 :                 p->ret_val = strlen(p->buffer);
     337             176 :                 p->found = 1;
     338                 :         }
     339            1848 : }
     340                 : 
     341                 : static int
     342                 : SQLGetPrivateProfileString(LPCSTR pszSection, LPCSTR pszEntry, LPCSTR pszDefault, LPSTR pRetBuffer, int nRetBuffer,
     343                 :                            LPCSTR pszFileName)
     344             616 : {
     345                 :         FILE *hFile;
     346                 :         ProfileParam param;
     347                 : 
     348             616 :         if (!pszSection) {
     349                 :                 /* spec says return list of all section names - but we will just return nothing */
     350               0 :                 tdsdump_log(TDS_DBG_WARN, "WARNING: Functionality for NULL pszSection not implemented.\n");
     351               0 :                 return 0;
     352                 :         }
     353                 : 
     354             616 :         if (!pszEntry) {
     355                 :                 /* spec says return list of all key names in section - but we will just return nothing */
     356               0 :                 tdsdump_log(TDS_DBG_WARN, "WARNING: Functionality for NULL pszEntry not implemented.\n");
     357               0 :                 return 0;
     358                 :         }
     359                 : 
     360             616 :         if (nRetBuffer < 1)
     361               0 :                 tdsdump_log(TDS_DBG_WARN, "WARNING: No space to return a value because nRetBuffer < 1.\n");
     362                 : 
     363             616 :         if (pszFileName && *pszFileName == '/')
     364               0 :                 hFile = fopen(pszFileName, "r");
     365                 :         else
     366             616 :                 hFile = tdoGetIniFileName();
     367                 : 
     368             616 :         if (hFile == NULL) {
     369               0 :                 tdsdump_log(TDS_DBG_ERROR, "ERROR: Could not open configuration file\n");
     370               0 :                 return 0;
     371                 :         }
     372                 : 
     373             616 :         param.entry = pszEntry;
     374             616 :         param.buffer = pRetBuffer;
     375             616 :         param.buffer_len = nRetBuffer;
     376             616 :         param.ret_val = 0;
     377             616 :         param.found = 0;
     378                 : 
     379             616 :         pRetBuffer[0] = 0;
     380             616 :         tds_read_conf_section(hFile, pszSection, tdoParseProfile, &param);
     381                 : 
     382             616 :         if (pszDefault && !param.found) {
     383             440 :                 tds_strlcpy(pRetBuffer, pszDefault, nRetBuffer);
     384                 : 
     385             440 :                 param.ret_val = strlen(pRetBuffer);
     386                 :         }
     387                 : 
     388             616 :         fclose(hFile);
     389             616 :         return param.ret_val;
     390                 : }
     391                 : 
     392                 : static FILE *
     393                 : tdoGetIniFileName()
     394             616 : {
     395             616 :         FILE *ret = NULL;
     396                 :         char *p;
     397                 :         char *fn;
     398                 : 
     399                 :         /*
     400                 :          * First, try the ODBCINI environment variable
     401                 :          */
     402             616 :         if ((p = getenv("ODBCINI")) != NULL)
     403             616 :                 ret = fopen(p, "r");
     404                 : 
     405                 :         /*
     406                 :          * Second, try the HOME environment variable
     407                 :          */
     408             616 :         if (!ret && (p = tds_get_homedir()) != NULL) {
     409               0 :                 fn = NULL;
     410               0 :                 if (asprintf(&fn, "%s/.odbc.ini", p) > 0) {
     411               0 :                         ret = fopen(fn, "r");
     412               0 :                         free(fn);
     413                 :                 }
     414               0 :                 free(p);
     415                 :         }
     416                 : 
     417                 :         /*
     418                 :          * As a last resort, try SYS_ODBC_INI
     419                 :          */
     420             616 :         if (!ret)
     421               0 :                 ret = fopen(SYS_ODBC_INI, "r");
     422                 : 
     423             616 :         return ret;
     424                 : }
     425                 : 
     426                 : #endif /* !HAVE_SQLGETPRIVATEPROFILESTRING */
     427                 : 
     428                 : #ifdef UNIXODBC
     429                 : 
     430                 : /*
     431                 :  * Begin BIG Hack.
     432                 :  *  
     433                 :  * We need these from odbcinstext.h but it wants to 
     434                 :  * include <log.h> and <ini.h>, which are not in the 
     435                 :  * standard include path.  XXX smurph
     436                 :  * confirmed by unixODBC stuff, odbcinstext.h shouldn't be installed. freddy77
     437                 :  */
     438                 : #define     INI_MAX_LINE            1000
     439                 : #define     INI_MAX_OBJECT_NAME     INI_MAX_LINE
     440                 : #define     INI_MAX_PROPERTY_NAME   INI_MAX_LINE
     441                 : #define     INI_MAX_PROPERTY_VALUE  INI_MAX_LINE
     442                 : 
     443                 : #define ODBCINST_PROMPTTYPE_LABEL               0       /* readonly */
     444                 : #define ODBCINST_PROMPTTYPE_TEXTEDIT    1
     445                 : #define ODBCINST_PROMPTTYPE_LISTBOX             2
     446                 : #define ODBCINST_PROMPTTYPE_COMBOBOX    3
     447                 : #define ODBCINST_PROMPTTYPE_FILENAME    4
     448                 : #define ODBCINST_PROMPTTYPE_HIDDEN          5
     449                 : 
     450                 : typedef struct tODBCINSTPROPERTY
     451                 : {
     452                 :         struct tODBCINSTPROPERTY *pNext;        /* pointer to next property, NULL if last property                                                                              */
     453                 : 
     454                 :         char szName[INI_MAX_PROPERTY_NAME + 1]; /* property name                                                                                                                                                */
     455                 :         char szValue[INI_MAX_PROPERTY_VALUE + 1];       /* property value                                                                                                                                               */
     456                 :         int nPromptType;        /* PROMPTTYPE_TEXTEDIT, PROMPTTYPE_LISTBOX, PROMPTTYPE_COMBOBOX, PROMPTTYPE_FILENAME    */
     457                 :         char **aPromptData;     /* array of pointers terminated with a NULL value in array.                                                     */
     458                 :         char *pszHelp;          /* help on this property (driver setups should keep it short)                                                   */
     459                 :         void *pWidget;          /* CALLER CAN STORE A POINTER TO ? HERE                                                                                                 */
     460                 :         int bRefresh;           /* app should refresh widget ie Driver Setup has changed aPromptData or szValue                 */
     461                 :         void *hDLL;             /* for odbcinst internal use... only first property has valid one                                               */
     462                 : }
     463                 : ODBCINSTPROPERTY, *HODBCINSTPROPERTY;
     464                 : 
     465                 : /* 
     466                 :  * End BIG Hack.
     467                 :  */
     468                 : 
     469                 : int ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty);
     470                 : 
     471                 : static const char *const aTDSver[] = {
     472                 :         "",
     473                 :         "4.2",
     474                 :         "5.0",
     475                 :         "7.0",
     476                 :         "8.0",
     477                 :         NULL
     478                 : };
     479                 : 
     480                 : static const char *const aLanguage[] = {
     481                 :         "us_english",
     482                 :         NULL
     483                 : };
     484                 : 
     485                 : /*
     486                 : static const char *aAuth[] = {
     487                 :         "Server",
     488                 :         "Domain",
     489                 :         "Both",
     490                 :         NULL
     491                 : };
     492                 : */
     493                 : 
     494                 : int
     495                 : ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty)
     496                 : {
     497                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     498                 :         hLastProperty = hLastProperty->pNext;
     499                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     500                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
     501                 :         tds_strlcpy(hLastProperty->szName, "Servername", INI_MAX_PROPERTY_NAME);
     502                 :         tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
     503                 :         hLastProperty->pszHelp = (char *) strdup("Name of FreeTDS connection to connect to.\n"
     504                 :                                                  "This server name refer to entry in freetds.conf file, not real server name.\n"
     505                 :                                                  "This property cannot be used with Server property.");
     506                 : 
     507                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     508                 :         hLastProperty = hLastProperty->pNext;
     509                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     510                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
     511                 :         tds_strlcpy(hLastProperty->szName, "Server", INI_MAX_PROPERTY_NAME);
     512                 :         tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
     513                 :         hLastProperty->pszHelp = (char *) strdup("Name of server to connect to.\n"
     514                 :                                                  "This should be the name of real server.\n"
     515                 :                                                  "This property cannot be used with Servername property.");
     516                 : 
     517                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     518                 :         hLastProperty = hLastProperty->pNext;
     519                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     520                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
     521                 :         tds_strlcpy(hLastProperty->szName, "Address", INI_MAX_PROPERTY_NAME);
     522                 :         tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
     523                 :         hLastProperty->pszHelp = (char *) strdup("The hostname or ip address of the server.");
     524                 : 
     525                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     526                 :         hLastProperty = hLastProperty->pNext;
     527                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     528                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
     529                 :         tds_strlcpy(hLastProperty->szName, "Port", INI_MAX_PROPERTY_NAME);
     530                 :         tds_strlcpy(hLastProperty->szValue, "1433", INI_MAX_PROPERTY_VALUE);
     531                 :         hLastProperty->pszHelp = (char *) strdup("TCP/IP Port to connect to.");
     532                 : 
     533                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     534                 :         hLastProperty = hLastProperty->pNext;
     535                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     536                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
     537                 :         tds_strlcpy(hLastProperty->szName, "Database", INI_MAX_PROPERTY_NAME);
     538                 :         tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
     539                 :         hLastProperty->pszHelp = (char *) strdup("Default database.");
     540                 : 
     541                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     542                 :         hLastProperty = hLastProperty->pNext;
     543                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     544                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX;
     545                 :         hLastProperty->aPromptData = malloc(sizeof(aTDSver));
     546                 :         memcpy(hLastProperty->aPromptData, aTDSver, sizeof(aTDSver));
     547                 :         tds_strlcpy(hLastProperty->szName, "TDS_Version", INI_MAX_PROPERTY_NAME);
     548                 :         tds_strlcpy(hLastProperty->szValue, "4.2", INI_MAX_PROPERTY_VALUE);
     549                 :         hLastProperty->pszHelp = (char *) strdup("The TDS protocol version.\n"
     550                 :                                                  " 4.2 MSSQL 6.5 or Sybase < 10.x\n"
     551                 :                                                  " 5.0 Sybase >= 10.x\n" " 7.0 MSSQL 7 or MSSQL 2000\n" " 8.0 MSSQL 2000");
     552                 : 
     553                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     554                 :         hLastProperty = hLastProperty->pNext;
     555                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     556                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX;
     557                 :         hLastProperty->aPromptData = malloc(sizeof(aLanguage));
     558                 :         memcpy(hLastProperty->aPromptData, aLanguage, sizeof(aLanguage));
     559                 :         tds_strlcpy(hLastProperty->szName, "Language", INI_MAX_PROPERTY_NAME);
     560                 :         tds_strlcpy(hLastProperty->szValue, "us_english", INI_MAX_PROPERTY_VALUE);
     561                 :         hLastProperty->pszHelp = (char *) strdup("The default language setting.");
     562                 : 
     563                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     564                 :         hLastProperty = hLastProperty->pNext;
     565                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     566                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_HIDDEN;
     567                 :         tds_strlcpy(hLastProperty->szName, "TextSize", INI_MAX_PROPERTY_NAME);
     568                 :         tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
     569                 :         hLastProperty->pszHelp = (char *) strdup("Text datatype limit.");
     570                 : 
     571                 :         /* ??? in odbc.ini ??? */
     572                 : /*
     573                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     574                 :         hLastProperty = hLastProperty->pNext;
     575                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     576                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
     577                 :         tds_strlcpy(hLastProperty->szName, "UID", INI_MAX_PROPERTY_NAME);
     578                 :         tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
     579                 :         hLastProperty->pszHelp = (char *) strdup("User ID (Beware of security issues).");
     580                 : 
     581                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     582                 :         hLastProperty = hLastProperty->pNext;
     583                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     584                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
     585                 :         tds_strlcpy(hLastProperty->szName, "PWD", INI_MAX_PROPERTY_NAME);
     586                 :         tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
     587                 :         hLastProperty->pszHelp = (char *) strdup("Password (Beware of security issues).");
     588                 : */
     589                 : 
     590                 : /*
     591                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     592                 :         hLastProperty = hLastProperty->pNext;
     593                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     594                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX;
     595                 :         hLastProperty->aPromptData = malloc(sizeof(aAuth));
     596                 :         memcpy(hLastProperty->aPromptData, aAuth, sizeof(aAuth));
     597                 :         tds_strlcpy(hLastProperty->szName, "Authentication", INI_MAX_PROPERTY_NAME);
     598                 :         tds_strlcpy(hLastProperty->szValue, "Server", INI_MAX_PROPERTY_VALUE);
     599                 :         hLastProperty->pszHelp = (char *) strdup("The server authentication mechanism.");
     600                 : */
     601                 : 
     602                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     603                 :         hLastProperty = hLastProperty->pNext;
     604                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     605                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
     606                 :         tds_strlcpy(hLastProperty->szName, "Domain", INI_MAX_PROPERTY_NAME);
     607                 :         tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
     608                 :         hLastProperty->pszHelp = (char *) strdup("The default domain to use when using Domain Authentication.");
     609                 : 
     610                 :         hLastProperty->pNext = (HODBCINSTPROPERTY) malloc(sizeof(ODBCINSTPROPERTY));
     611                 :         hLastProperty = hLastProperty->pNext;
     612                 :         memset(hLastProperty, 0, sizeof(ODBCINSTPROPERTY));
     613                 :         hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT;
     614                 :         tds_strlcpy(hLastProperty->szName, "PacketSize", INI_MAX_PROPERTY_NAME);
     615                 :         tds_strlcpy(hLastProperty->szValue, "", INI_MAX_PROPERTY_VALUE);
     616                 :         hLastProperty->pszHelp = (char *) strdup("Size of network packets.");
     617                 : 
     618                 :         return 1;
     619                 : }
     620                 : 
     621                 : #endif

Generated by: LTP GCOV extension version 1.6