|
| 1 | +/*------- |
| 2 | + * Module: odbcapi30w.c |
| 3 | + * |
| 4 | + * Description: This module contains UNICODE routines |
| 5 | + * |
| 6 | + * Classes: n/a |
| 7 | + * |
| 8 | + * API functions: SQLColAttributeW, SQLGetStmtW, SQLSetStmtW, |
| 9 | + SQLSetConnectAttrW, SQLGetConnectAttrW, |
| 10 | + SQLGetDescFieldW, SQLGetDescRecW, SQLGetDiagFieldW, |
| 11 | + SQLGetDiagRecW, |
| 12 | + *------- |
| 13 | + */ |
| 14 | + |
| 15 | +#include "psqlodbc.h" |
| 16 | +#include <stdio.h> |
| 17 | +#include <string.h> |
| 18 | + |
| 19 | +#include "pgapifunc.h" |
| 20 | +#include "connection.h" |
| 21 | +#include "statement.h" |
| 22 | + |
| 23 | + |
| 24 | +RETCODE SQL_API SQLGetStmtAttrW(SQLHSTMT hstmt, |
| 25 | + SQLINTEGER fAttribute, |
| 26 | + PTR rgbValue, |
| 27 | + SQLINTEGER cbValueMax, |
| 28 | + SQLINTEGER *pcbValue) |
| 29 | +{ |
| 30 | + RETCODE ret; |
| 31 | + |
| 32 | + mylog("[SQLGetStmtAttrW]"); |
| 33 | + ret = PGAPI_GetStmtAttr(hstmt, fAttribute, rgbValue, |
| 34 | + cbValueMax, pcbValue); |
| 35 | + return ret; |
| 36 | +} |
| 37 | + |
| 38 | +RETCODE SQL_API SQLSetStmtAttrW(SQLHSTMT hstmt, |
| 39 | + SQLINTEGER fAttribute, |
| 40 | + PTR rgbValue, |
| 41 | + SQLINTEGER cbValueMax) |
| 42 | +{ |
| 43 | + RETCODE ret; |
| 44 | + |
| 45 | + mylog("[SQLSetStmtAttrW]"); |
| 46 | + ret = PGAPI_SetStmtAttr(hstmt, fAttribute, rgbValue, |
| 47 | + cbValueMax); |
| 48 | + return ret; |
| 49 | +} |
| 50 | + |
| 51 | +RETCODE SQL_API SQLGetConnectAttrW(HDBC hdbc, |
| 52 | + SQLINTEGER fAttribute, |
| 53 | + PTR rgbValue, |
| 54 | + SQLINTEGER cbValueMax, |
| 55 | + SQLINTEGER *pcbValue) |
| 56 | +{ |
| 57 | + RETCODE ret; |
| 58 | + |
| 59 | + mylog("[SQLGetConnectAttrW]"); |
| 60 | + ret = PGAPI_GetConnectAttr(hdbc, fAttribute, rgbValue, |
| 61 | + cbValueMax, pcbValue); |
| 62 | + return ret; |
| 63 | +} |
| 64 | + |
| 65 | +RETCODE SQL_API SQLSetConnectAttrW(HDBC hdbc, |
| 66 | + SQLINTEGER fAttribute, |
| 67 | + PTR rgbValue, |
| 68 | + SQLINTEGER cbValue) |
| 69 | +{ |
| 70 | + RETCODE ret; |
| 71 | + |
| 72 | + mylog("[SQLSetConnectAttrW]"); |
| 73 | + ret = PGAPI_SetConnectAttr(hdbc, fAttribute, rgbValue, |
| 74 | + cbValue); |
| 75 | + return ret; |
| 76 | +} |
| 77 | + |
| 78 | +RETCODE SQL_API SQLGetDiagRecW(SWORD fHandleType, |
| 79 | + SQLHANDLE handle, |
| 80 | + SQLSMALLINT iRecord, |
| 81 | + SQLWCHAR *szSqlState, |
| 82 | + SQLINTEGER *pfNativeError, |
| 83 | + SQLWCHAR *szErrorMsg, |
| 84 | + SQLSMALLINT cbErrorMsgMax, |
| 85 | + SQLSMALLINT *pcbErrorMsg) |
| 86 | +{ |
| 87 | + RETCODE ret; |
| 88 | + SWORD tlen; |
| 89 | + char *qst = NULL, *mtxt = NULL; |
| 90 | + |
| 91 | + mylog("[SQLGetDiagRecW]"); |
| 92 | + if (szSqlState) |
| 93 | + qst = malloc(8); |
| 94 | + if (szErrorMsg) |
| 95 | + mtxt = malloc(cbErrorMsgMax); |
| 96 | + ret = PGAPI_GetDiagRec(fHandleType, handle, iRecord, qst, |
| 97 | + pfNativeError, mtxt, cbErrorMsgMax, &tlen); |
| 98 | + if (qst) |
| 99 | + utf8_to_ucs2(qst, strlen(qst), szSqlState, 5); |
| 100 | + if (pcbErrorMsg) |
| 101 | + *pcbErrorMsg = utf8_to_ucs2(mtxt, tlen, szErrorMsg, cbErrorMsgMax); |
| 102 | + free(qst); |
| 103 | + free(mtxt); |
| 104 | + return ret; |
| 105 | +} |
| 106 | + |
| 107 | +RETCODE SQL_API SQLColAttributeW( |
| 108 | + HSTMT hstmt, |
| 109 | + SQLUSMALLINT icol, |
| 110 | + SQLUSMALLINT fDescType, |
| 111 | + PTR rgbDesc, |
| 112 | + SQLSMALLINT cbDescMax, |
| 113 | + SQLSMALLINT *pcbDesc, |
| 114 | + SQLINTEGER *pfDesc) |
| 115 | +{ |
| 116 | + RETCODE ret; |
| 117 | + |
| 118 | + mylog("[SQLColAttributeW]"); |
| 119 | + ret = PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc, |
| 120 | + cbDescMax, pcbDesc, pfDesc); |
| 121 | + return ret; |
| 122 | +} |
0 commit comments