~ubuntu-branches/ubuntu/trusty/psqlodbc/trusty-proposed

« back to all changes in this revision

Viewing changes to setup.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2011-04-05 14:48:23 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110405144823-n77supsa1hjj0ik6
Tags: 1:09.00.0200-1
* New upstream release.
* Fix installing {A,W}/usr/lib/odbc.  Closes: #618210.
* Convert to 3.0 (quilt).
* Remove psqlodbc-580878.diff: implemented upstream.
* Remove psqlodbc-585476.diff: was caused by #519006 which is now closed.
* Update description, suggested by Martin Eberhard Schauer.
  Closes: #565611.
* New maintainer.  Closes: #472818.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *
8
8
 * Classes:                     n/a
9
9
 *
10
 
 * API functions:       ConfigDSN
 
10
 * API functions:       ConfigDSN, ConfigDriver
11
11
 *
12
12
 * Comments:            See "notice.txt" for copyright and license information.
13
13
 *-------
123
123
        return fSuccess;
124
124
}
125
125
 
 
126
/*--------
 
127
 *      ConfigDriver
 
128
 *
 
129
 *      Description:    ODBC Setup entry point
 
130
 *                      This entry point is called by the ODBC Installer
 
131
 *                      (see file header for more details)
 
132
 *      Arguments :     hwnd ----------- Parent window handle
 
133
 *                      fRequest ------- Request type (i.e., add, config, or remove)
 
134
 *                      lpszDriver ----- Driver name
 
135
 *                      lpszArgs ------- A null-terminated string containing
 
136
                                arguments for a driver specific fRequest
 
137
 *                      lpszMsg -------- A null-terimated string containing
 
138
                                an output message from the driver setup
 
139
 *                      cnMsgMax ------- Length of lpszMSg
 
140
 *                      pcbMsgOut ------ Total number of bytes available to
 
141
                                return in lpszMsg 
 
142
 *      Returns :       TRUE success, FALSE otherwise
 
143
 *--------
 
144
 */
 
145
static BOOL SetDriverAttributes(LPCSTR lpszDriver);
 
146
BOOL            CALLBACK
 
147
ConfigDriver(HWND hwnd,
 
148
                WORD fRequest,
 
149
                LPCSTR lpszDriver,
 
150
                LPCSTR lpszArgs,
 
151
                LPSTR lpszMsg,
 
152
                WORD cbMsgMax,
 
153
                WORD *pcbMsgOut)
 
154
{
 
155
        BOOL    fSuccess = TRUE;        /* Success/fail flag */
 
156
 
 
157
        /* Add the driver */
 
158
        if (ODBC_INSTALL_DRIVER == fRequest)
 
159
                fSuccess = SetDriverAttributes(lpszDriver);
 
160
 
 
161
        return fSuccess;
 
162
}
 
163
 
126
164
 
127
165
/*-------
128
166
 * CenterDialog
301
339
                                                        conn = CC_Constructor();
302
340
                                                if (conn)
303
341
                                                {
304
 
                                                        char *emsg;
 
342
                                                        char *emsg, *allocstr = NULL;
 
343
#ifdef  UNICODE_SUPPORT
 
344
                                                        int     tlen;
 
345
                                                        SQLWCHAR *wermsg = NULL;
 
346
                                                        SQLULEN ulen;
 
347
#endif /* UNICODE_SUPPORT */
305
348
                                                        int errnum;
306
349
 
307
350
                                                        EN_add_connection(env, conn);
308
351
                                                        memcpy(&conn->connInfo, &lpsetupdlg->ci, sizeof(ConnInfo));
309
352
                                                        CC_initialize_pg_version(conn);
310
353
                                                        logs_on_off(1, conn->connInfo.drivers.debug, conn->connInfo.drivers.commlog);
 
354
#ifdef  UNICODE_SUPPORT
 
355
                                                        CC_set_in_unicode_driver(conn);
 
356
#endif /* UNICODE_SUPPORT */
311
357
                                                        if (CC_connect(conn, AUTH_REQ_OK, NULL) > 0)
312
358
                                                        {
313
359
                                                                if (CC_get_errornumber(conn) != 0)
316
362
                                                                        snprintf(szMsg, sizeof(szMsg), "Warning: %s", emsg);
317
363
                                                                }
318
364
                                                                else
319
 
                                                                        strncpy(szMsg, "Connection successful", sizeof(szMsg));
 
365
                                                                        strncpy_null(szMsg, "Connection successful", sizeof(szMsg));
320
366
                                                                emsg = szMsg;
321
367
                                                        }
322
368
                                                        else
323
369
                                                        {
324
370
                                                                CC_get_error(conn, &errnum, &emsg);
325
371
                                                        }
 
372
#ifdef  UNICODE_SUPPORT
 
373
                                                        tlen = strlen(emsg);
 
374
                                                        wermsg = (SQLWCHAR *) malloc(sizeof(SQLWCHAR) * (tlen + 1));
 
375
                                                        ulen = utf8_to_ucs2_lf1(emsg, SQL_NTS, FALSE, wermsg, tlen + 1);
 
376
                                                        if (ulen != (SQLULEN) -1)
 
377
                                                        {
 
378
                                                                allocstr = malloc(4 * tlen + 1);
 
379
                                                                tlen = (SQLSMALLINT) wstrtomsg(NULL, wermsg,
 
380
                                        (int) tlen, allocstr, (int) 4 * tlen + 1);
 
381
                                                                emsg = allocstr;
 
382
                                                        }
 
383
                                                        if (NULL != wermsg)
 
384
                                                                free(wermsg);
 
385
#endif /* UNICODE_SUPPORT */
326
386
                                                        MessageBox(lpsetupdlg->hwndParent, emsg, "Connection Test", MB_ICONEXCLAMATION | MB_OK);
327
387
                                                        logs_on_off(-1, conn->connInfo.drivers.debug, conn->connInfo.drivers.commlog);
328
388
                                                        EN_remove_connection(env, conn);
329
389
                                                        CC_Destructor(conn);
 
390
                                                        if (NULL != allocstr)
 
391
                                                                free(allocstr);
330
392
                                                }
331
393
                                                if (env)
332
394
                                                        EN_Destructor(env);
488
550
        return TRUE;
489
551
}
490
552
 
 
553
/*--------
 
554
 * SetDriverAttributes
 
555
 *
 
556
 *      Description:    Write driver information attributes to ODBCINST.INI
 
557
 *      Input    :      lpszDriver - The driver name
 
558
 *      Output   :      TRUE if successful, FALSE otherwise
 
559
 *--------
 
560
 */
 
561
static BOOL
 
562
SetDriverAttributes(LPCSTR lpszDriver)
 
563
{
 
564
        BOOL    ret = FALSE;
 
565
 
 
566
        /* Validate arguments */
 
567
        if (!lpszDriver || !lpszDriver[0])
 
568
                return FALSE;
 
569
 
 
570
        if (!SQLWritePrivateProfileString(lpszDriver, "APILevel", "1", ODBCINST_INI))
 
571
                goto cleanup;
 
572
        if (!SQLWritePrivateProfileString(lpszDriver, "ConnectFunctions", "YYN", ODBCINST_INI))
 
573
                goto cleanup;
 
574
        if (!SQLWritePrivateProfileString(lpszDriver, "DriverODBCVer",
 
575
#ifdef UNICODE_SUPPORT
 
576
                 "03.51",
 
577
#else
 
578
                 "03.00",
 
579
#endif
 
580
                ODBCINST_INI))
 
581
                goto cleanup;
 
582
        if (!SQLWritePrivateProfileString(lpszDriver, "FileUsage", "0", ODBCINST_INI))
 
583
                goto cleanup;
 
584
        if (!SQLWritePrivateProfileString(lpszDriver, "SQLLevel", "1", ODBCINST_INI))
 
585
                goto cleanup;
 
586
 
 
587
        ret = TRUE;
 
588
cleanup:
 
589
 
 
590
        return ret;
 
591
}
 
592
 
491
593
 
492
594
#ifdef  WIN32
493
595