NCBI C++ ToolKit
Classes | Macros | Functions | Variables
winsetup.c File Reference
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include "resource.h"
#include <freetds/tds.h>
#include <freetds/odbc.h>
#include <freetds/string.h>
#include <freetds/convert.h>
#include "replacements.h"
#include <olectl.h>
+ Include dependency graph for winsetup.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  DSNINFO
 

Macros

#define WRITESTR(n, s)   if (!SQLWritePrivateProfileString(section, (n), (s), odbcini)) return FALSE
 Update the attributes. More...
 
#define FIELD_STRING(f)   tds_dstr_cstr(&di->login->f)
 
#define GetWindowUserData(wnd)   GetWindowLong((wnd), GWL_USERDATA)
 
#define SetWindowUserData(wnd, data)   SetWindowLong((wnd), GWL_USERDATA, (data))
 

Functions

static DSNINFOalloc_dsninfo (void)
 Create an empty DSNINFO struct. More...
 
static void free_dsninfo (DSNINFO *di)
 Destroy a DSNINFO struct, freeing all memory associated with it. More...
 
static void parse_wacky_dsn_string (LPCSTR attribs, DSNINFO *di)
 Parse a DSN string which is delimited with NULs instead of semicolons. More...
 
static BOOL write_all_strings (DSNINFO *di)
 
static const char * validate (DSNINFO *di)
 Go looking for trouble. More...
 
static BOOL CALLBACK DSNDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 Callback function for the DSN Configuration dialog. More...
 
BOOL INSTAPI ConfigDSN (HWND hwndParent, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszAttributes)
 Add, remove, or modify a data source. More...
 
BOOL INSTAPI ConfigDriver (HWND hwndParent, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszArgs, LPSTR lpszMsg, WORD cbMsgMax, WORD *pcbMsgOut)
 Add or remove an ODBC driver. More...
 
BOOL INSTAPI ConfigTranslator (HWND hwndParent, DWORD *pvOption)
 
HRESULT WINAPI DllRegisterServer (void)
 Allow install using regsvr32. More...
 
HRESULT WINAPI DllUnregisterServer (void)
 Allow uninstall using regsvr32 command. More...
 

Variables

HINSTANCE hinstFreeTDS
 

Macro Definition Documentation

◆ FIELD_STRING

#define FIELD_STRING (   f)    tds_dstr_cstr(&di->login->f)

Definition at line 143 of file winsetup.c.

◆ GetWindowUserData

#define GetWindowUserData (   wnd)    GetWindowLong((wnd), GWL_USERDATA)

Definition at line 194 of file winsetup.c.

◆ SetWindowUserData

#define SetWindowUserData (   wnd,
  data 
)    SetWindowLong((wnd), GWL_USERDATA, (data))

Definition at line 195 of file winsetup.c.

◆ WRITESTR

#define WRITESTR (   n,
 
)    if (!SQLWritePrivateProfileString(section, (n), (s), odbcini)) return FALSE

Update the attributes.

Return TRUE if successful, else FALSE. The names written here correspond to the names read by odbc_get_dsn_info().

Definition at line 142 of file winsetup.c.

Function Documentation

◆ alloc_dsninfo()

static DSNINFO* alloc_dsninfo ( void  )
static

Create an empty DSNINFO struct.

Definition at line 75 of file winsetup.c.

References DSNINFO::dsn, DSNINFO::login, malloc(), NULL, DSNINFO::origdsn, tds_alloc_login, tds_dstr_init(), and tds_init_login.

Referenced by ConfigDSN().

◆ ConfigDriver()

BOOL INSTAPI ConfigDriver ( HWND  hwndParent,
WORD  fRequest,
LPCSTR  lpszDriver,
LPCSTR  lpszArgs,
LPSTR  lpszMsg,
WORD  cbMsgMax,
WORD pcbMsgOut 
)

Add or remove an ODBC driver.

Definition at line 394 of file winsetup.c.

References NULL, ODBC_INSTALL_DRIVER, ODBC_REMOVE_DRIVER, and TRUE.

◆ ConfigDSN()

BOOL INSTAPI ConfigDSN ( HWND  hwndParent,
WORD  fRequest,
LPCSTR  lpszDriver,
LPCSTR  lpszAttributes 
)

Add, remove, or modify a data source.

Parameters
hwndParentparent for dialog, NULL for batch ops
fRequestrequest type
lpszDriverdriver name (for humans, not DLL name)
lpszAttributesattribute list

Definition at line 300 of file winsetup.c.

References alloc_dsninfo(), buf, DONESOCKET, DSNINFO::dsn, DSNDlgProc(), FALSE, free_dsninfo(), hinstFreeTDS, IDD_DSN, INITSOCKET, NULL, ODBC_ADD_DSN, ODBC_CONFIG_DSN, ODBC_ERROR_REQUEST_FAILED, ODBC_REMOVE_DSN, DSNINFO::origdsn, parse_wacky_dsn_string(), result, SQLPostInstallerError(), SQLRemoveDSNFromIni(), SQLWriteDSNToIni(), strcasecmp, tds_dstr_cstr(), TRUE, validate(), and write_all_strings().

◆ ConfigTranslator()

BOOL INSTAPI ConfigTranslator ( HWND  hwndParent,
DWORD pvOption 
)

Definition at line 416 of file winsetup.c.

References TRUE.

◆ DllRegisterServer()

HRESULT WINAPI DllRegisterServer ( void  )

Allow install using regsvr32.

Definition at line 425 of file winsetup.c.

References asprintf, cnt, free(), hinstFreeTDS, NULL, ODBC_INSTALL_COMPLETE, SQLInstallDriverEx(), and TDS_VECTOR_SIZE.

◆ DllUnregisterServer()

HRESULT WINAPI DllUnregisterServer ( void  )

Allow uninstall using regsvr32 command.

Definition at line 465 of file winsetup.c.

References cnt, FALSE, and SQLRemoveDriver().

◆ DSNDlgProc()

static BOOL CALLBACK DSNDlgProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Callback function for the DSN Configuration dialog.

Parameters
hDlgidentifies the dialog
messagewhat happened to the dialog
wParamvaries with message
lParampointer to DSNINFO struct

Definition at line 209 of file winsetup.c.

References tds_login::database, DSNINFO::dsn, FALSE, GetWindowUserData, i, IDC_ADDRESS, IDC_DATABASE, IDC_DSNNAME, IDC_HINT, IDC_PORT, IDC_PROTOCOL, DSNINFO::login, NULL, tds_login::port, tds_login::server_name, SetWindowUserData, tds_dstr_copy(), tds_dstr_cstr(), TDS_MAJOR, TDS_MINOR, tds_login::tds_version, tmp, TRUE, and validate().

Referenced by ConfigDSN().

◆ free_dsninfo()

static void free_dsninfo ( DSNINFO di)
static

Destroy a DSNINFO struct, freeing all memory associated with it.

Definition at line 92 of file winsetup.c.

References DSNINFO::dsn, free(), DSNINFO::login, DSNINFO::origdsn, tds_dstr_free(), and tds_free_login.

Referenced by ConfigDSN().

◆ parse_wacky_dsn_string()

static void parse_wacky_dsn_string ( LPCSTR  attribs,
DSNINFO di 
)
static

Parse a DSN string which is delimited with NULs instead of semicolons.

This uses odbc_parse_connect_string() internally, and also adds support for parsing the DSN and driver

Parameters
attribs0-delimited string, with \0\0 terminator
diwhere to store the results

Definition at line 109 of file winsetup.c.

References DSNINFO::dsn, DSNINFO::login, malloc(), NULL, odbc_parse_connect_string(), DSNINFO::origdsn, str(), strcat, strncasecmp, and tds_dstr_copy().

Referenced by ConfigDSN().

◆ validate()

static const char* validate ( DSNINFO di)
static

◆ write_all_strings()

static BOOL write_all_strings ( DSNINFO di)
static

Variable Documentation

◆ hinstFreeTDS

HINSTANCE hinstFreeTDS
extern

Definition at line 10 of file initnet.c.

Referenced by ConfigDSN(), and DllRegisterServer().

Modified on Fri Mar 01 10:06:48 2024 by modify_doxy.py rev. 669887