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

« back to all changes in this revision

Viewing changes to odbcapi25w.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-10-24 07:21:55 UTC
  • mfrom: (16.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131024072155-xlf5odyk3iblcd51
Tags: 1:09.02.0100-2ubuntu1
* Merge with Debian unstable. Remaining Ubuntu changes:
  - debian/tests: Disable iodbc test and dependency, as in Ubuntu iodbc and
    unixodbc are not installable in parallel, and iodbc is obsolete and
    should be removed at some point.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-------
2
 
 * Module:                      odbcapi25w.c
3
 
 *
4
 
 * Description:         This module contains UNICODE routines
5
 
 *
6
 
 * Classes:                     n/a
7
 
 *
8
 
 * API functions:       SQLColAttributesW, SQLErrorW, SQLGetConnectOptionW,
9
 
                        SQLSetConnectOptionW
10
 
 *-------
11
 
 */
12
 
 
13
 
#include "psqlodbc.h"
14
 
#include <stdio.h>
15
 
#include <string.h>
16
 
 
17
 
#include "pgapifunc.h"
18
 
#include "connection.h"
19
 
#include "statement.h"
20
 
 
21
 
RETCODE  SQL_API SQLErrorW(HENV EnvironmentHandle,
22
 
           HDBC ConnectionHandle, HSTMT StatementHandle,
23
 
           SQLWCHAR *Sqlstate, SQLINTEGER *NativeError,
24
 
           SQLWCHAR *MessageText, SQLSMALLINT BufferLength,
25
 
           SQLSMALLINT *TextLength)
26
 
{
27
 
        RETCODE ret;
28
 
        SWORD   tlen, buflen;
29
 
        char    *qst = NULL, *mtxt = NULL;
30
 
 
31
 
        mylog("[SQLErrorW]");
32
 
        if (Sqlstate)
33
 
                qst = malloc(8);
34
 
        buflen = 0;
35
 
        if (MessageText && BufferLength > 0)
36
 
        {
37
 
                buflen = BufferLength * 3 + 1;
38
 
                mtxt = malloc(buflen);
39
 
        }
40
 
        ret = PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle,
41
 
                qst, NativeError, mtxt, buflen, &tlen);
42
 
        if (qst)
43
 
                utf8_to_ucs2(qst, strlen(qst), Sqlstate, 5);
44
 
        if (NULL != mtxt)
45
 
        {
46
 
                SQLULEN tulen = utf8_to_ucs2(mtxt, tlen, MessageText, BufferLength);
47
 
                if (NULL != TextLength)
48
 
                        *TextLength = tulen;
49
 
                free(mtxt);
50
 
        }
51
 
        if (qst)
52
 
                free(qst);
53
 
        return ret;
54
 
}
55
 
 
56
 
RETCODE  SQL_API SQLGetConnectOptionW(HDBC ConnectionHandle,
57
 
           SQLUSMALLINT Option, PTR Value)
58
 
{
59
 
        mylog("[SQLGetConnectOptionW]");
60
 
        CC_set_in_unicode_driver((ConnectionClass *) ConnectionHandle);
61
 
        return PGAPI_GetConnectOption(ConnectionHandle, Option, Value, NULL, 64);
62
 
63
 
 
64
 
RETCODE  SQL_API SQLSetConnectOptionW(HDBC ConnectionHandle,
65
 
           SQLUSMALLINT Option, SQLUINTEGER Value)
66
 
{
67
 
        mylog("[SQLSetConnectionOptionW]");
68
 
if (!ConnectionHandle)  return SQL_ERROR;
69
 
        CC_set_in_unicode_driver((ConnectionClass *) ConnectionHandle);
70
 
        return PGAPI_SetConnectOption(ConnectionHandle, Option, Value);
71
 
}
72
 
 
73
 
RETCODE SQL_API SQLColAttributesW(
74
 
    HSTMT           hstmt,
75
 
    SQLUSMALLINT       icol,
76
 
    SQLUSMALLINT       fDescType,
77
 
    PTR         rgbDesc,
78
 
    SQLSMALLINT        cbDescMax,
79
 
    SQLSMALLINT           *pcbDesc,
80
 
    SQLINTEGER            *pfDesc)
81
 
{
82
 
        mylog("[SQLColAttributesW]");
83
 
        return PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc,
84
 
                cbDescMax, pcbDesc, pfDesc);
85
 
}
 
1
/*-------
 
2
 * Module:                      odbcapi25w.c
 
3
 *
 
4
 * Description:         This module contains UNICODE routines
 
5
 *
 
6
 * Classes:                     n/a
 
7
 *
 
8
 * API functions:       SQLColAttributesW, SQLErrorW, SQLGetConnectOptionW,
 
9
                        SQLSetConnectOptionW
 
10
 *-------
 
11
 */
 
12
 
 
13
#include "psqlodbc.h"
 
14
#include <stdio.h>
 
15
#include <string.h>
 
16
 
 
17
#include "pgapifunc.h"
 
18
#include "connection.h"
 
19
#include "statement.h"
 
20
 
 
21
RETCODE  SQL_API SQLErrorW(HENV EnvironmentHandle,
 
22
           HDBC ConnectionHandle, HSTMT StatementHandle,
 
23
           SQLWCHAR *Sqlstate, SQLINTEGER *NativeError,
 
24
           SQLWCHAR *MessageText, SQLSMALLINT BufferLength,
 
25
           SQLSMALLINT *TextLength)
 
26
{
 
27
        RETCODE ret;
 
28
        SWORD   tlen, buflen;
 
29
        char    *qst = NULL, *mtxt = NULL;
 
30
 
 
31
        mylog("[SQLErrorW]");
 
32
        if (Sqlstate)
 
33
                qst = malloc(8);
 
34
        buflen = 0;
 
35
        if (MessageText && BufferLength > 0)
 
36
        {
 
37
                buflen = BufferLength * 3 + 1;
 
38
                mtxt = malloc(buflen);
 
39
        }
 
40
        ret = PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle,
 
41
                qst, NativeError, mtxt, buflen, &tlen);
 
42
        if (qst)
 
43
                utf8_to_ucs2(qst, strlen(qst), Sqlstate, 5);
 
44
        if (NULL != mtxt)
 
45
        {
 
46
                SQLULEN tulen = utf8_to_ucs2(mtxt, tlen, MessageText, BufferLength);
 
47
                if (NULL != TextLength)
 
48
                        *TextLength = tulen;
 
49
                free(mtxt);
 
50
        }
 
51
        if (qst)
 
52
                free(qst);
 
53
        return ret;
 
54
}
 
55
 
 
56
RETCODE  SQL_API SQLGetConnectOptionW(HDBC ConnectionHandle,
 
57
           SQLUSMALLINT Option, PTR Value)
 
58
{
 
59
        mylog("[SQLGetConnectOptionW]");
 
60
        CC_set_in_unicode_driver((ConnectionClass *) ConnectionHandle);
 
61
        return PGAPI_GetConnectOption(ConnectionHandle, Option, Value, NULL, 64);
 
62
 
63
 
 
64
RETCODE  SQL_API SQLSetConnectOptionW(HDBC ConnectionHandle,
 
65
           SQLUSMALLINT Option, SQLUINTEGER Value)
 
66
{
 
67
        mylog("[SQLSetConnectionOptionW]");
 
68
if (!ConnectionHandle)  return SQL_ERROR;
 
69
        CC_set_in_unicode_driver((ConnectionClass *) ConnectionHandle);
 
70
        return PGAPI_SetConnectOption(ConnectionHandle, Option, Value);
 
71
}
 
72
 
 
73
RETCODE SQL_API SQLColAttributesW(
 
74
    HSTMT           hstmt,
 
75
    SQLUSMALLINT       icol,
 
76
    SQLUSMALLINT       fDescType,
 
77
    PTR         rgbDesc,
 
78
    SQLSMALLINT        cbDescMax,
 
79
    SQLSMALLINT           *pcbDesc,
 
80
    SQLINTEGER            *pfDesc)
 
81
{
 
82
        mylog("[SQLColAttributesW]");
 
83
        return PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc,
 
84
                cbDescMax, pcbDesc, pfDesc);
 
85
}