decompiled_code:
void __fastcall extend_bindings(__int64 a1, unsigned int a2)
{
_DWORD *v3; // rbp
char *v4; // rdi
__int64 v5; // rdx
__int64 v6; // rdx
unsigned __int64 v7; // rax
void *v8; // rdi

mylog(
"%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n",
"extend_bindings",
a1,
*(unsigned int *)(a1 + 120),
a2);
if ( *(_DWORD *)(a1 + 120) >= (signed int)a2 )
{
LABEL_9:
mylog("exit extend_bindings\n");
return;
}
v3 = create_empty_bindings(a2);
if ( v3 )
{
v4 = *(char **)(a1 + 80);
if ( v4 )
{
v5 = *(int *)(a1 + 120);
if ( (int)v5 > 0 )
{
v6 = 32 * v5;
v7 = 0LL;
do
{
*(__m128i *)&v3[v7 / 4] = _mm_loadu_si128((const __m128i *)&v4[v7]);
*(__m128i *)&v3[v7 / 4 + 4] = _mm_loadu_si128((const __m128i *)&v4[v7 + 16]);
v7 += 32LL;
}
while ( v7 != v6 );
}
free(v4);
}
*(_QWORD *)(a1 + 80) = v3;
*(_DWORD *)(a1 + 120) = a2;
goto LABEL_9;
}
mylog(
"%s: unable to create %d new bindings from %d old bindings\n",
"extend_bindings",
a2,
*(unsigned int *)(a1 + 120));
v8 = *(void **)(a1 + 80);
if ( v8 )
{
free(v8);
*(_QWORD *)(a1 + 80) = 0LL;
}
*(_DWORD *)(a1 + 120) = 0;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, unsigned int a2)
{
_DWORD *v3; // rbp
char *v4; // rdi
__int64 v5; // rdx
__int64 v6; // rdx
unsigned __int64 v7; // rax
void *v8; // rdi

mylog(
"%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n",
"extend_bindings",
a1,
*(unsigned int *)(a1 + 120),
a2);
if ( *(_DWORD *)(a1 + 120) >= (signed int)a2 )
{
LABEL_9:
mylog("exit extend_bindings\n");
return;
}
v3 = create_empty_bindings(a2);
if ( v3 )
{
v4 = *(char **)(a1 + 80);
if ( v4 )
{
v5 = *(int *)(a1 + 120);
if ( (int)v5 > 0 )
{
v6 = 32 * v5;
v7 = 0LL;
do
{
*(__m128i *)&v3[v7 / 4] = _mm_loadu_si128((const __m128i *)&v4[v7]);
*(__m128i *)&v3[v7 / 4 + 4] = _mm_loadu_si128((const __m128i *)&v4[v7 + 16]);
v7 += 32LL;
}
while ( v7 != v6 );
}
free(v4);
}
*(_QWORD *)(a1 + 80) = v3;
*(_DWORD *)(a1 + 120) = a2;
goto LABEL_9;
}
mylog(
"%s: unable to create %d new bindings from %d old bindings\n",
"extend_bindings",
a2,
*(unsigned int *)(a1 + 120));
v8 = *(void **)(a1 + 80);
if ( v8 )
{
free(v8);
*(_QWORD *)(a1 + 80) = 0LL;
}
*(_DWORD *)(a1 + 120) = 0;
}

original_code:
void
extend_bindings(StatementClass *stmt, int num_columns)
{
static char* const func="extend_bindings";
BindInfoClass *new_bindings;
int i;
mylog("%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n", func, stmt, stmt->bindings_allocated, num_columns);
 if(stmt->bindings_allocated < num_columns) {
  new_bindings = create_empty_bindings(num_columns);
  if ( ! new_bindings) {
           mylog("%s: unable to create %d new bindings from %d old bindings\n", func, num_columns, stmt->bindings_allocated);
   if (stmt->bindings) {
    free(stmt->bindings);
    stmt->bindings = ((void *)0);
   }
   stmt->bindings_allocated = 0;
   return;
  }
  if(stmt->bindings) {
   for(i=0; i<stmt->bindings_allocated; i++)
    new_bindings[i] = stmt->bindings[i];
   free(stmt->bindings);
  }
  stmt->bindings = new_bindings;
  stmt->bindings_allocated = num_columns;
    }
 mylog("exit extend_bindings\n");
}

canonical_original_code:
void extend_bindings(struct StatementClass_ *stmt, int num_columns)
{
static char *func = "extend_bindings";
struct BindInfoClass_ *new_bindings;
int i;
mylog("%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n", func, stmt, stmt->bindings_allocated, num_columns);
 if(stmt->bindings_allocated < num_columns) {
  new_bindings = create_empty_bindings(num_columns);
  if ( ! new_bindings) {
           mylog("%s: unable to create %d new bindings from %d old bindings\n", func, num_columns, stmt->bindings_allocated);
   if (stmt->bindings) {
    free(stmt->bindings);
    stmt->bindings = ((void *)0);
   }
   stmt->bindings_allocated = 0;
   return;
  }
  if(stmt->bindings) {
   for(i=0; i<stmt->bindings_allocated; i++)
    new_bindings[i] = stmt->bindings[i];
   free(stmt->bindings);
  }
  stmt->bindings = new_bindings;
  stmt->bindings_allocated = num_columns;
    }
 mylog("exit extend_bindings\n");
}

variable_types: struct StatementClass_ { struct ConnectionClass_ { void *henv; struct StatementOptions_ { int maxRows; int maxLength; int rowset_size; int keyset_size; int cursor_type; int scroll_concurrency; int retrieve_data; int bind_size; int use_bookmarks; } stmtOptions; char *__error_message; int __error_number; enum CONN_Status { CONN_NOT_CONNECTED=0, CONN_CONNECTED=1, CONN_DOWN=2, CONN_EXECUTING=3 } status; struct ConnInfo { char dsn[256]; char desc[256]; char driver[256]; char server[256]; char database[256]; char username[256]; char password[256]; char conn_settings[4096]; char protocol[10]; char port[10]; char uds[4096]; char onlyread[10]; char fake_oid_index[10]; char show_oid_column[10]; char row_versioning[10]; char show_system_tables[10]; char translation_dll[256]; char translation_option[10]; char focus_password; } connInfo; struct StatementClass_ **stmts; int num_stmts; struct SocketClass_ { int buffer_filled_in; int buffer_filled_out; int buffer_read_in; unsigned char *buffer_in; unsigned char *buffer_out; int socket; char *errormsg; int errornumber; char reverse; } *sock; int lobj_type; int ntables; struct col_info { struct QResultClass_ { struct ColumnInfoClass_ { short num_fields; char **name; unsigned int *adtid; short *adtsize; short *display_size; int *atttypmod; } *fields; struct TupleListClass_ { int num_fields; int num_tuples; struct TupleNode_ { struct TupleNode_ *prev; struct TupleField_ { int len; void *value; } tuple[1]; } *list_start; int last_indexed; } *manual_tuples; struct ConnectionClass_ *conn; int fetch_count; int fcount; int currTuple; int base; int num_fields; int cache_size; int rowset_size; enum QueryResultCode_ { PGRES_EMPTY_QUERY=0, PGRES_COMMAND_OK=1, PGRES_TUPLES_OK=2, PGRES_COPY_OUT=3, PGRES_COPY_IN=4, PGRES_BAD_RESPONSE=5, PGRES_NONFATAL_ERROR=6, PGRES_FATAL_ERROR=7, PGRES_FIELDS_OK=8, PGRES_END_TUPLES=9, PGRES_INTERNAL_ERROR=10 } status; char *message; char *cursor; char *command; char *notice; struct TupleField_ *backend_tuples; struct TupleField_ *tupleField; char inTuples; char aborted; } *result; char name[-1]; } **col_info; long translation_option; void *translation_handle; int (*DataSourceToDriver)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); int (*DriverToDataSource)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); short driver_version; char transact_status; char errormsg_created; char pg_version[128]; float pg_version_number; short pg_version_major; short pg_version_minor; char ms_jet; char unicode; char result_uncommitted; char schema_support; char *client_encoding; char *server_encoding; int ccsc; int be_pid; int be_key; unsigned int isolation; char *current_schema; int num_discardp; char **discardp; } *hdbc; struct QResultClass_ *result; void **phstmt; struct StatementOptions_ options; enum STMT_Status { STMT_ALLOCATED=0, STMT_READY=1, STMT_PREMATURE=2, STMT_FINISHED=3, STMT_EXECUTING=4 } status; char *__error_message; int __error_number; struct BindInfoClass_ { int buflen; int data_left; char *buffer; long *used; short returntype; } *bindings; struct BindInfoClass_ bookmark; int bindings_allocated; int parameters_allocated; struct ParameterInfoClass_ { int buflen; char *buffer; long *used; short paramType; short CType; short SQLType; unsigned int precision; short scale; unsigned int lobj_oid; int *EXEC_used; char *EXEC_buffer; char data_at_exec; } *parameters; int currTuple; int save_rowset_size; int rowset_start; int bind_row; int last_fetch_count; int current_col; int lobj_fd; char *statement; struct TABLE_INFO { struct col_info *col_info; char name[-1]; char alias[-1]; } **ti; struct FIELD_INFO { struct TABLE_INFO *ti; int precision; int display_size; int length; int type; char nullable; char func; char expr; char quote; char dquote; char numeric; char dot[-1]; char name[-1]; char alias[-1]; } **fi; int nfld; int ntab; int parse_status; int statement_type; int data_at_exec; int current_exec_param; char put_data; char errormsg_created; char manual_result; char prepare; char internal; char cursor_name[-1]; char stmt_with_params[65536]; int reexecute; } *

variable_types:
func
char *

user_defined_types: struct ConnectionClass_ { void *henv; struct StatementOptions_ stmtOptions; char *__error_message; int __error_number; enum CONN_Status status; struct ConnInfo connInfo; struct StatementClass_ **stmts; int num_stmts; struct SocketClass_ *sock; int lobj_type; int ntables; struct col_info **col_info; long translation_option; void *translation_handle; int (*DataSourceToDriver)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); int (*DriverToDataSource)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); short driver_version; char transact_status; char errormsg_created; char pg_version[128]; float pg_version_number; short pg_version_major; short pg_version_minor; char ms_jet; char unicode; char result_uncommitted; char schema_support; char *client_encoding; char *server_encoding; int ccsc; int be_pid; int be_key; unsigned int isolation; char *current_schema; int num_discardp; char **discardp; }


repo: xiaotmiaomiao/unixODBC-SPEC

decompiled_code:
__int64 __fastcall PG_SQLBindCol(__int64 a1, unsigned __int16 a2, __int16 a3, __int64 a4, int a5, __int64 a6)
{
__int64 v9; // rcx
__int64 v10; // r8
__int64 v11; // rdx
__int64 v12; // rax
__int64 result; // rax
const char *v14; // rdx
__int64 v15; // rsi

mylog("%s: entering...\n", "SQLBindCol");
mylog("**** SQLBindCol: stmt = %u, icol = %d\n", a1, a2);
if ( !a1 )
{
SC_log_error("SQLBindCol", &LC2, 0LL);
return 4294967294LL;
}
SC_clear_error(a1);
if ( *(_DWORD *)(a1 + 60) == 4 )
{
v14 = "Can't bind columns while statement is still executing.";
v15 = 3LL;
LABEL_17:
SC_set_error(a1, v15, v14, v9, v10);
SC_log_error("SQLBindCol", &LC2, a1);
return 0xFFFFFFFFLL;
}
if ( !a2 )
{
if ( !a4 )
{
*(_QWORD *)(a1 + 96) = 0LL;
result = 0LL;
*(_QWORD *)(a1 + 104) = 0LL;
return result;
}
if ( (a3 & 0xFFEF) == 0xFFEE )
{
*(_QWORD *)(a1 + 96) = a4;
result = 0LL;
*(_QWORD *)(a1 + 104) = a6;
return result;
}
v14 = "Column 0 is not of type SQL_C_BOOKMARK";
v15 = 26LL;
goto LABEL_17;
}
if ( a2 > *(int *)(a1 + 120) )
extend_bindings(a1, a2);
v11 = *(_QWORD *)(a1 + 80);
if ( !v11 )
{
v14 = "Could not allocate memory for bindings.";
v15 = 4LL;
goto LABEL_17;
}
v12 = v11 + 32LL * (unsigned __int16)(a2 - 1);
*(_DWORD *)(v12 + 4) = -1;
if ( a4 )
{
*(_QWORD *)(v12 + 8) = a4;
*(_QWORD *)(v12 + 16) = a6;
*(_DWORD *)v12 = a5;
*(_WORD *)(v12 + 24) = a3;
mylog(" bound buffer[%d] = %u\n", (unsigned __int16)(a2 - 1), a4);
}
else
{
*(_DWORD *)v12 = 0;
*(_QWORD *)(v12 + 8) = 0LL;
*(_QWORD *)(v12 + 16) = 0LL;
*(_WORD *)(v12 + 24) = 1;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned __int16 a2, __int16 a3, __int64 a4, int a5, __int64 a6)
{
__int64 v9; // rcx
__int64 v10; // r8
__int64 v11; // rdx
__int64 v12; // rax
__int64 result; // rax
const char *v14; // rdx
__int64 v15; // rsi

mylog("%s: entering...\n", "SQLBindCol");
mylog("**** SQLBindCol: stmt = %u, icol = %d\n", a1, a2);
if ( !a1 )
{
SC_log_error("SQLBindCol", &LC2, 0LL);
return 4294967294LL;
}
SC_clear_error(a1);
if ( *(_DWORD *)(a1 + 60) == 4 )
{
v14 = "Can't bind columns while statement is still executing.";
v15 = 3LL;
LABEL_17:
SC_set_error(a1, v15, v14, v9, v10);
SC_log_error("SQLBindCol", &LC2, a1);
return 0xFFFFFFFFLL;
}
if ( !a2 )
{
if ( !a4 )
{
*(_QWORD *)(a1 + 96) = 0LL;
result = 0LL;
*(_QWORD *)(a1 + 104) = 0LL;
return result;
}
if ( (a3 & 0xFFEF) == 0xFFEE )
{
*(_QWORD *)(a1 + 96) = a4;
result = 0LL;
*(_QWORD *)(a1 + 104) = a6;
return result;
}
v14 = "Column 0 is not of type SQL_C_BOOKMARK";
v15 = 26LL;
goto LABEL_17;
}
if ( a2 > *(int *)(a1 + 120) )
func4(a1, a2);
v11 = *(_QWORD *)(a1 + 80);
if ( !v11 )
{
v14 = "Could not allocate memory for bindings.";
v15 = 4LL;
goto LABEL_17;
}
v12 = v11 + 32LL * (unsigned __int16)(a2 - 1);
*(_DWORD *)(v12 + 4) = -1;
if ( a4 )
{
*(_QWORD *)(v12 + 8) = a4;
*(_QWORD *)(v12 + 16) = a6;
*(_DWORD *)v12 = a5;
*(_WORD *)(v12 + 24) = a3;
mylog(" bound buffer[%d] = %u\n", (unsigned __int16)(a2 - 1), a4);
}
else
{
*(_DWORD *)v12 = 0;
*(_QWORD *)(v12 + 8) = 0LL;
*(_QWORD *)(v12 + 16) = 0LL;
*(_WORD *)(v12 + 24) = 1;
}
return 0LL;
}

original_code:
RETCODE PG_SQLBindCol(
        HSTMT hstmt,
        UWORD icol,
        SWORD fCType,
        PTR rgbValue,
        SQLINTEGER cbValueMax,
        SQLINTEGER *pcbValue)
{
StatementClass *stmt = (StatementClass *) hstmt;
static char* const func="SQLBindCol";
 mylog( "%s: entering...\n", func);
mylog("**** SQLBindCol: stmt = %u, icol = %d\n", stmt, icol);
 if ( ! stmt) {
  SC_log_error(func, "", ((void *)0));
  return (-2);
 }
 SC_clear_error(stmt);
 if( stmt->status == STMT_EXECUTING) {
  SC_set_error(stmt, 3, "Can't bind columns while statement is still executing.");
  SC_log_error(func, "", stmt);
  return (-1);
 }
 if (icol == 0) {
  if (rgbValue == ((void *)0)) {
   stmt->bookmark.buffer = ((void *)0);
   stmt->bookmark.used = ((void *)0);
  }
  else {
   if ( fCType != (4 +(-22)) && fCType != (-2) ) {
    SC_set_error(stmt, 26, "Column 0 is not of type SQL_C_BOOKMARK");
    SC_log_error(func, "", stmt);
    return (-1);
   }
   stmt->bookmark.buffer = rgbValue;
   stmt->bookmark.used = pcbValue;
  }
  return 0;
 }
 if ( icol > stmt->bindings_allocated)
  extend_bindings(stmt, icol);
 if ( ! stmt->bindings) {
  SC_set_error(stmt, 4, "Could not allocate memory for bindings.");
  SC_log_error(func, "", stmt);
  return (-1);
 }
 icol--;
 stmt->bindings[icol].data_left = -1;
 if (rgbValue == ((void *)0)) {
  stmt->bindings[icol].buflen = 0;
  stmt->bindings[icol].buffer = ((void *)0);
  stmt->bindings[icol].used = ((void *)0);
  stmt->bindings[icol].returntype = 1;
 } else {
  stmt->bindings[icol].buflen = cbValueMax;
  stmt->bindings[icol].buffer = rgbValue;
  stmt->bindings[icol].used = pcbValue;
  stmt->bindings[icol].returntype = fCType;
  mylog("       bound buffer[%d] = %u\n", icol, stmt->bindings[icol].buffer);
 }
 return 0;
}

canonical_original_code:
short PG_SQLBindCol(void *hstmt, unsigned short icol, short fCType, void *rgbValue, long cbValueMax, long *pcbValue)
{
struct StatementClass_ *stmt = (StatementClass *) hstmt;
static char *func = "SQLBindCol";
 mylog( "%s: entering...\n", func);
mylog("**** SQLBindCol: stmt = %u, icol = %d\n", stmt, icol);
 if ( ! stmt) {
  SC_log_error(func, "", ((void *)0));
  return (-2);
 }
 SC_clear_error(stmt);
 if( stmt->status == STMT_EXECUTING) {
  SC_set_error(stmt, 3, "Can't bind columns while statement is still executing.");
  SC_log_error(func, "", stmt);
  return (-1);
 }
 if (icol == 0) {
  if (rgbValue == ((void *)0)) {
   stmt->bookmark.buffer = ((void *)0);
   stmt->bookmark.used = ((void *)0);
  }
  else {
   if ( fCType != (4 +(-22)) && fCType != (-2) ) {
    SC_set_error(stmt, 26, "Column 0 is not of type SQL_C_BOOKMARK");
    SC_log_error(func, "", stmt);
    return (-1);
   }
   stmt->bookmark.buffer = rgbValue;
   stmt->bookmark.used = pcbValue;
  }
  return 0;
 }
 if ( icol > stmt->bindings_allocated)
  extend_bindings(stmt, icol);
 if ( ! stmt->bindings) {
  SC_set_error(stmt, 4, "Could not allocate memory for bindings.");
  SC_log_error(func, "", stmt);
  return (-1);
 }
 icol--;
 stmt->bindings[icol].data_left = -1;
 if (rgbValue == ((void *)0)) {
  stmt->bindings[icol].buflen = 0;
  stmt->bindings[icol].buffer = ((void *)0);
  stmt->bindings[icol].used = ((void *)0);
  stmt->bindings[icol].returntype = 1;
 } else {
  stmt->bindings[icol].buflen = cbValueMax;
  stmt->bindings[icol].buffer = rgbValue;
  stmt->bindings[icol].used = pcbValue;
  stmt->bindings[icol].returntype = fCType;
  mylog("       bound buffer[%d] = %u\n", icol, stmt->bindings[icol].buffer);
 }
 return 0;
}

variable_types:
hstmt
void *

variable_types:
icol
unsigned short

variable_types: fCType short

variable_types:
rgbValue
void *

variable_types: cbValueMax long

variable_types:
pcbValue
long *

return_type: short

user_defined_types: struct StatementClass_ { struct ConnectionClass_ *hdbc; struct QResultClass_ *result; void **phstmt; struct StatementOptions_ options; enum STMT_Status status; char *__error_message; int __error_number; struct BindInfoClass_ *bindings; struct BindInfoClass_ bookmark; int bindings_allocated; int parameters_allocated; struct ParameterInfoClass_ *parameters; int currTuple; int save_rowset_size; int rowset_start; int bind_row; int last_fetch_count; int current_col; int lobj_fd; char *statement; struct TABLE_INFO **ti; struct FIELD_INFO **fi; int nfld; int ntab; int parse_status; int statement_type; int data_at_exec; int current_exec_param; char put_data; char errormsg_created; char manual_result; char prepare; char internal; char cursor_name[-1]; char stmt_with_params[65536]; int reexecute; }

user_defined_types: enum STMT_Status { STMT_ALLOCATED=0, STMT_READY=1, STMT_PREMATURE=2, STMT_FINISHED=3, STMT_EXECUTING=4 }

user_defined_types: struct BindInfoClass_ { int buflen; int data_left; char *buffer; long *used; short returntype; }

user_defined_types: struct ParameterInfoClass_ { int buflen; char *buffer; long *used; short paramType; short CType; short SQLType; unsigned int precision; short scale; unsigned int lobj_oid; int *EXEC_used; char *EXEC_buffer; char data_at_exec; }

user_defined_types: struct StatementOptions_ { int maxRows; int maxLength; int rowset_size; int keyset_size; int cursor_type; int scroll_concurrency; int retrieve_data; int bind_size; int use_bookmarks; }

user_defined_types: enum CONN_Status { CONN_NOT_CONNECTED=0, CONN_CONNECTED=1, CONN_DOWN=2, CONN_EXECUTING=3 }

user_defined_types: struct ConnInfo { char dsn[256]; char desc[256]; char driver[256]; char server[256]; char database[256]; char username[256]; char password[256]; char conn_settings[4096]; char protocol[10]; char port[10]; char uds[4096]; char onlyread[10]; char fake_oid_index[10]; char show_oid_column[10]; char row_versioning[10]; char show_system_tables[10]; char translation_dll[256]; char translation_option[10]; char focus_password; }

user_defined_types: struct TABLE_INFO { struct col_info *col_info; char name[-1]; char alias[-1]; }

user_defined_types: struct FIELD_INFO { struct TABLE_INFO *ti; int precision; int display_size; int length; int type; char nullable; char func; char expr; char quote; char dquote; char numeric; char dot[-1]; char name[-1]; char alias[-1]; }

user_defined_types: struct SocketClass_ { int buffer_filled_in; int buffer_filled_out; int buffer_read_in; unsigned char *buffer_in; unsigned char *buffer_out; int socket; char *errormsg; int errornumber; char reverse; }

user_defined_types: struct col_info { struct QResultClass_ *result; char name[-1]; }

user_defined_types: struct QResultClass_ { struct ColumnInfoClass_ *fields; struct TupleListClass_ *manual_tuples; struct ConnectionClass_ *conn; int fetch_count; int fcount; int currTuple; int base; int num_fields; int cache_size; int rowset_size; enum QueryResultCode_ status; char *message; char *cursor; char *command; char *notice; struct TupleField_ *backend_tuples; struct TupleField_ *tupleField; char inTuples; char aborted; }

user_defined_types: enum QueryResultCode_ { PGRES_EMPTY_QUERY=0, PGRES_COMMAND_OK=1, PGRES_TUPLES_OK=2, PGRES_COPY_OUT=3, PGRES_COPY_IN=4, PGRES_BAD_RESPONSE=5, PGRES_NONFATAL_ERROR=6, PGRES_FATAL_ERROR=7, PGRES_FIELDS_OK=8, PGRES_END_TUPLES=9, PGRES_INTERNAL_ERROR=10 }

user_defined_types: struct ColumnInfoClass_ { short num_fields; char **name; unsigned int *adtid; short *adtsize; short *display_size; int *atttypmod; }

user_defined_types: struct TupleListClass_ { int num_fields; int num_tuples; struct TupleNode_ *list_start; int last_indexed; }

user_defined_types: struct TupleNode_ { struct TupleNode_ *prev; struct TupleField_ tuple[1]; }

user_defined_types: struct TupleField_ { int len; void *value; }


SQLBindParameter

original_code:
SQLRETURN SQLBindParameter(
    SQLHSTMT hstmt,
    SQLUSMALLINT ipar,
    SQLSMALLINT fParamType,
    SQLSMALLINT fCType,
    SQLSMALLINT fSqlType,
    SQLUINTEGER cbColDef,
    SQLSMALLINT ibScale,
    SQLPOINTER rgbValue,
    SQLINTEGER cbValueMax,
    SQLINTEGER *pcbValue)
{
StatementClass *stmt = (StatementClass *) hstmt;
static char* const func="SQLBindParameter";
 mylog( "%s: entering...\n", func);
 if( ! stmt) {
  SC_log_error(func, "", ((void *)0));
  return (-2);
 }
 if(stmt->parameters_allocated < ipar) {
  ParameterInfoClass *old_parameters;
  int i, old_parameters_allocated;
  old_parameters = stmt->parameters;
  old_parameters_allocated = stmt->parameters_allocated;
  stmt->parameters = (ParameterInfoClass *) malloc(sizeof(ParameterInfoClass)*(ipar));
  if ( ! stmt->parameters) {
   SC_set_error(stmt, 4, "Could not allocate memory for statement parameters");
   SC_log_error(func, "", stmt);
   return (-1);
  }
  stmt->parameters_allocated = ipar;
  for(i = 0; i < old_parameters_allocated; i++) {
   stmt->parameters[i] = old_parameters[i];
  }
  if(old_parameters)
   free(old_parameters);
  for(; i < stmt->parameters_allocated; i++) {
   stmt->parameters[i].buflen = 0;
   stmt->parameters[i].buffer = 0;
   stmt->parameters[i].used = 0;
   stmt->parameters[i].paramType = 0;
   stmt->parameters[i].CType = 0;
   stmt->parameters[i].SQLType = 0;
   stmt->parameters[i].precision = 0;
   stmt->parameters[i].scale = 0;
   stmt->parameters[i].data_at_exec = (int)0;
   stmt->parameters[i].lobj_oid = 0;
   stmt->parameters[i].EXEC_used = ((void *)0);
   stmt->parameters[i].EXEC_buffer = ((void *)0);
  }
 }
 ipar--;
 stmt->parameters[ipar].buflen = cbValueMax;
 stmt->parameters[ipar].buffer = rgbValue;
 stmt->parameters[ipar].used = pcbValue;
 stmt->parameters[ipar].paramType = fParamType;
 stmt->parameters[ipar].CType = fCType;
 stmt->parameters[ipar].SQLType = fSqlType;
 stmt->parameters[ipar].precision = cbColDef;
 stmt->parameters[ipar].scale = ibScale;
 if (stmt->parameters[ipar].EXEC_used) {
  free(stmt->parameters[ipar].EXEC_used);
  stmt->parameters[ipar].EXEC_used = ((void *)0);
 }
 if (stmt->parameters[ipar].EXEC_buffer) {
  if (stmt->parameters[ipar].SQLType != (-4))
   free(stmt->parameters[ipar].EXEC_buffer);
  stmt->parameters[ipar].EXEC_buffer = ((void *)0);
 }
 if ((fSqlType == (-4) || fSqlType == (-1)) && pcbValue && (*pcbValue <= (-100) || *pcbValue == (-2) ))
  stmt->parameters[ipar].data_at_exec = (int)1;
 else
  stmt->parameters[ipar].data_at_exec = (int)0;
 mylog("SQLBindParamater: ipar=%d, paramType=%d, fCType=%d, fSqlType=%d, cbColDef=%d, ibScale=%d, rgbValue=%d, *pcbValue = %d, data_at_exec = %d\n", ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, pcbValue ? *pcbValue: -777, stmt->parameters[ipar].data_at_exec);
 return 0;
}

canonical_original_code:
short SQLBindParameter(void *hstmt, unsigned short ipar, short fParamType, short fCType, short fSqlType, unsigned long cbColDef, short ibScale, void *rgbValue, long cbValueMax, long *pcbValue)
{
struct StatementClass_ *stmt = (StatementClass *) hstmt;
static char *func = "SQLBindParameter";
 mylog( "%s: entering...\n", func);
 if( ! stmt) {
  SC_log_error(func, "", ((void *)0));
  return (-2);
 }
 if(stmt->parameters_allocated < ipar) {
  struct ParameterInfoClass_ *old_parameters;
  int i; int old_parameters_allocated;
  old_parameters = stmt->parameters;
  old_parameters_allocated = stmt->parameters_allocated;
  stmt->parameters = (struct ParameterInfoClass_ *) malloc(sizeof(ParameterInfoClass)*(ipar));
  if ( ! stmt->parameters) {
   SC_set_error(stmt, 4, "Could not allocate memory for statement parameters");
   SC_log_error(func, "", stmt);
   return (-1);
  }
  stmt->parameters_allocated = ipar;
  for(i = 0; i < old_parameters_allocated; i++) {
   stmt->parameters[i] = old_parameters[i];
  }
  if(old_parameters)
   free(old_parameters);
  for(; i < stmt->parameters_allocated; i++) {
   stmt->parameters[i].buflen = 0;
   stmt->parameters[i].buffer = 0;
   stmt->parameters[i].used = 0;
   stmt->parameters[i].paramType = 0;
   stmt->parameters[i].CType = 0;
   stmt->parameters[i].SQLType = 0;
   stmt->parameters[i].precision = 0;
   stmt->parameters[i].scale = 0;
   stmt->parameters[i].data_at_exec = (int)0;
   stmt->parameters[i].lobj_oid = 0;
   stmt->parameters[i].EXEC_used = ((void *)0);
   stmt->parameters[i].EXEC_buffer = ((void *)0);
  }
 }
 ipar--;
 stmt->parameters[ipar].buflen = cbValueMax;
 stmt->parameters[ipar].buffer = rgbValue;
 stmt->parameters[ipar].used = pcbValue;
 stmt->parameters[ipar].paramType = fParamType;
 stmt->parameters[ipar].CType = fCType;
 stmt->parameters[ipar].SQLType = fSqlType;
 stmt->parameters[ipar].precision = cbColDef;
 stmt->parameters[ipar].scale = ibScale;
 if (stmt->parameters[ipar].EXEC_used) {
  free(stmt->parameters[ipar].EXEC_used);
  stmt->parameters[ipar].EXEC_used = ((void *)0);
 }
 if (stmt->parameters[ipar].EXEC_buffer) {
  if (stmt->parameters[ipar].SQLType != (-4))
   free(stmt->parameters[ipar].EXEC_buffer);
  stmt->parameters[ipar].EXEC_buffer = ((void *)0);
 }
 if ((fSqlType == (-4) || fSqlType == (-1)) && pcbValue && (*pcbValue <= (-100) || *pcbValue == (-2) ))
  stmt->parameters[ipar].data_at_exec = (int)1;
 else
  stmt->parameters[ipar].data_at_exec = (int)0;
 mylog("SQLBindParamater: ipar=%d, paramType=%d, fCType=%d, fSqlType=%d, cbColDef=%d, ibScale=%d, rgbValue=%d, *pcbValue = %d, data_at_exec = %d\n", ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, pcbValue ? *pcbValue: -777, stmt->parameters[ipar].data_at_exec);
 return 0;
}

variable_types:
ipar
unsigned short

variable_types: fParamType short

variable_types: fSqlType short

variable_types:
cbColDef
unsigned long

variable_types: ibScale short

variable_types: struct ParameterInfoClass_ { int buflen; char *buffer; long *used; short paramType; short CType; short SQLType; unsigned int precision; short scale; unsigned int lobj_oid; int *EXEC_used; char *EXEC_buffer; char data_at_exec; } *

variable_types: i int

user_defined_types: struct StatementClass_ { struct ConnectionClass_ *hdbc; struct QResultClass_ *result; void **phstmt; struct StatementOptions_ options; enum STMT_Status status; char *__error_message; int __error_number; struct BindInfoClass_ *bindings; struct BindInfoClass_ bookmark; int bindings_allocated; int parameters_allocated; struct ParameterInfoClass_ *parameters; int currTuple; int save_rowset_size; int rowset_start; int bind_row; int last_fetch_count; int current_col; int lobj_fd; char *statement; struct TABLE_INFO **ti; struct FIELD_INFO **fi; int nfld; int ntab; int parse_status; int statement_type; int data_at_exec; int current_exec_param; char put_data; char errormsg_created; char manual_result; char prepare; char internal; char cursor_name[-1]; char stmt_with_params[65536]; int reexecute; }

user_defined_types: struct ConnectionClass_ { void *henv; struct StatementOptions_ stmtOptions; char *__error_message; int __error_number; enum CONN_Status status; struct ConnInfo connInfo; struct StatementClass_ **stmts; int num_stmts; struct SocketClass_ *sock; int lobj_type; int ntables; struct col_info **col_info; long translation_option; void *translation_handle; int (*DataSourceToDriver)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); int (*DriverToDataSource)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); short driver_version; char transact_status; char errormsg_created; char pg_version[128]; float pg_version_number; short pg_version_major; short pg_version_minor; char ms_jet; char unicode; char result_uncommitted; char schema_support; char *client_encoding; char *server_encoding; int ccsc; int be_pid; int be_key; unsigned int isolation; char *current_schema; int num_discardp; char **discardp; }


SQLDescribeParam

decompiled_code:
__int64 __fastcall SQLDescribeParam(__int64 a1, unsigned __int16 a2, _WORD *a3, _QWORD *a4, _WORD *a5, _WORD *a6)
{
__int64 v10; // rcx
__int64 v11; // r8
unsigned __int16 v12; // bx
unsigned int v13; // er12

mylog("%s: entering...\n", "SQLDescribeParam");
if ( a1 )
{
if ( a2 && a2 <= *(int *)(a1 + 124) )
{
v12 = a2 - 1;
if ( a3 )
*a3 = *(_WORD *)(*(_QWORD *)(a1 + 128) + 72LL * v12 + 28);
if ( a4 )
*a4 = *(unsigned int *)(*(_QWORD *)(a1 + 128) + 72LL * v12 + 32);
if ( a5 )
*a5 = *(_WORD *)(*(_QWORD *)(a1 + 128) + 72LL * v12 + 36);
v13 = 0;
if ( a6 )
*a6 = pgtype_nullable(a1, (unsigned int)*(__int16 *)(*(_QWORD *)(a1 + 128) + 72LL * v12 + 24));
}
else
{
v13 = -1;
SC_set_error(a1, 11LL, "Invalid parameter number for SQLDescribeParam.", v10, v11);
SC_log_error("SQLDescribeParam", &LC2, a1);
}
}
else
{
v13 = -2;
SC_log_error("SQLDescribeParam", &LC2, 0LL);
}
return v13;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned __int16 a2, _WORD *a3, _QWORD *a4, _WORD *a5, _WORD *a6)
{
__int64 v10; // rcx
__int64 v11; // r8
unsigned __int16 v12; // bx
unsigned int v13; // er12

mylog("%s: entering...\n", "SQLDescribeParam");
if ( a1 )
{
if ( a2 && a2 <= *(int *)(a1 + 124) )
{
v12 = a2 - 1;
if ( a3 )
*a3 = *(_WORD *)(*(_QWORD *)(a1 + 128) + 72LL * v12 + 28);
if ( a4 )
*a4 = *(unsigned int *)(*(_QWORD *)(a1 + 128) + 72LL * v12 + 32);
if ( a5 )
*a5 = *(_WORD *)(*(_QWORD *)(a1 + 128) + 72LL * v12 + 36);
v13 = 0;
if ( a6 )
*a6 = pgtype_nullable(a1, (unsigned int)*(__int16 *)(*(_QWORD *)(a1 + 128) + 72LL * v12 + 24));
}
else
{
v13 = -1;
SC_set_error(a1, 11LL, "Invalid parameter number for SQLDescribeParam.", v10, v11);
SC_log_error("SQLDescribeParam", &LC2, a1);
}
}
else
{
v13 = -2;
SC_log_error("SQLDescribeParam", &LC2, 0LL);
}
return v13;
}

original_code:
RETCODE SQLDescribeParam(
        HSTMT hstmt,
        UWORD ipar,
        SWORD *pfSqlType,
        SQLUINTEGER *pcbColDef,
        SWORD *pibScale,
        SWORD *pfNullable)
{
StatementClass *stmt = (StatementClass *) hstmt;
static char* const func = "SQLDescribeParam";
 mylog( "%s: entering...\n", func);
 if( ! stmt) {
  SC_log_error(func, "", ((void *)0));
  return (-2);
 }
 if( (ipar < 1) || (ipar > stmt->parameters_allocated) ) {
  SC_set_error(stmt, 11, "Invalid parameter number for SQLDescribeParam.");
  SC_log_error(func, "", stmt);
  return (-1);
 }
 ipar--;
 if(pfSqlType)
  *pfSqlType = stmt->parameters[ipar].SQLType;
 if(pcbColDef)
  *pcbColDef = stmt->parameters[ipar].precision;
 if(pibScale)
  *pibScale = stmt->parameters[ipar].scale;
 if(pfNullable)
  *pfNullable = pgtype_nullable(stmt, stmt->parameters[ipar].paramType);
 return 0;
}

canonical_original_code:
short SQLDescribeParam(void *hstmt, unsigned short ipar, short *pfSqlType, unsigned long *pcbColDef, short *pibScale, short *pfNullable)
{
struct StatementClass_ *stmt = (StatementClass *) hstmt;
static char *func = "SQLDescribeParam";
 mylog( "%s: entering...\n", func);
 if( ! stmt) {
  SC_log_error(func, "", ((void *)0));
  return (-2);
 }
 if( (ipar < 1) || (ipar > stmt->parameters_allocated) ) {
  SC_set_error(stmt, 11, "Invalid parameter number for SQLDescribeParam.");
  SC_log_error(func, "", stmt);
  return (-1);
 }
 ipar--;
 if(pfSqlType)
  *pfSqlType = stmt->parameters[ipar].SQLType;
 if(pcbColDef)
  *pcbColDef = stmt->parameters[ipar].precision;
 if(pibScale)
  *pibScale = stmt->parameters[ipar].scale;
 if(pfNullable)
  *pfNullable = pgtype_nullable(stmt, stmt->parameters[ipar].paramType);
 return 0;
}

variable_types:
pfSqlType
short *

variable_types:
pcbColDef
unsigned long *

variable_types:
pibScale
short *

variable_types:
pfNullable
short *

user_defined_types: enum STMT_Status { STMT_ALLOCATED=0, STMT_READY=1, STMT_PREMATURE=2, STMT_FINISHED=3, STMT_EXECUTING=4 }

user_defined_types: struct BindInfoClass_ { int buflen; int data_left; char *buffer; long *used; short returntype; }


SQLParamOptions

decompiled_code:
__int64 __fastcall SQLParamOptions(__int64 a1)
{
mylog("%s: entering...\n", "SQLParamOptions");
SC_log_error("SQLParamOptions", "Function not implemented", a1);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
mylog("%s: entering...\n", "SQLParamOptions");
SC_log_error("SQLParamOptions", "Function not implemented", a1);
return 0xFFFFFFFFLL;
}

original_code:
RETCODE SQLParamOptions(
        HSTMT hstmt,
        SQLUINTEGER crow,
        SQLUINTEGER *pirow)
{
static char* const func = "SQLParamOptions";
 mylog( "%s: entering...\n", func);
 SC_log_error(func, "Function not implemented", (StatementClass *) hstmt);
 return (-1);
}

canonical_original_code:
short SQLParamOptions(void *hstmt, unsigned long crow, unsigned long *pirow)
{
static char *func = "SQLParamOptions";
 mylog( "%s: entering...\n", func);
 SC_log_error(func, "Function not implemented", (struct StatementClass_ *) hstmt);
 return (-1);
}

variable_types:
hstmt
void *

variable_types:
crow
unsigned long

variable_types:
pirow
unsigned long *

variable_types:
func
char *

user_defined_types: struct ParameterInfoClass_ { int buflen; char *buffer; long *used; short paramType; short CType; short SQLType; unsigned int precision; short scale; unsigned int lobj_oid; int *EXEC_used; char *EXEC_buffer; char data_at_exec; }

user_defined_types: struct StatementOptions_ { int maxRows; int maxLength; int rowset_size; int keyset_size; int cursor_type; int scroll_concurrency; int retrieve_data; int bind_size; int use_bookmarks; }


SQLNumParams

decompiled_code:
__int64 __fastcall SQLNumParams(__int64 a1, _WORD *a2)
{
__int64 v3; // rcx
__int64 v4; // r8
const char *v5; // rbx
size_t v6; // rsi
unsigned int v7; // edx
char v8; // cl
__int64 v9; // rax
char v10; // al
__int64 result; // rax

mylog("%s: entering...\n", "SQLNumParams");
if ( a1 )
{
if ( a2 )
{
v5 = *(const char **)(a1 + 168);
*a2 = 0;
if ( v5 )
{
v6 = strlen(v5);
if ( v6 )
{
v7 = 0;
v8 = 0;
v9 = 0LL;
while ( 1 )
{
v10 = v5[v9];
if ( v10 != 63 )
break;
if ( v8 )
{
LABEL_8:
v9 = ++v7;
if ( v7 >= v6 )
goto LABEL_12;
}
else
{
++*a2;
v9 = ++v7;
if ( v7 >= v6 )
goto LABEL_12;
}
}
if ( v10 == 39 )
v8 ^= 1u;
goto LABEL_8;
}
LABEL_12:
result = 0LL;
}
else
{
SC_set_error(a1, 3LL, "SQLNumParams called with no statement ready.", v3, v4);
SC_log_error("SQLNumParams", &LC2, a1);
result = 0xFFFFFFFFLL;
}
}
else
{
SC_log_error("SQLNumParams", "pcpar was null", a1);
result = 0xFFFFFFFFLL;
}
}
else
{
SC_log_error("SQLNumParams", &LC2, 0LL);
result = 4294967294LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _WORD *a2)
{
__int64 v3; // rcx
__int64 v4; // r8
const char *v5; // rbx
size_t v6; // rsi
unsigned int v7; // edx
char v8; // cl
__int64 v9; // rax
char v10; // al
__int64 result; // rax

mylog("%s: entering...\n", "SQLNumParams");
if ( a1 )
{
if ( a2 )
{
v5 = *(const char **)(a1 + 168);
*a2 = 0;
if ( v5 )
{
v6 = strlen(v5);
if ( v6 )
{
v7 = 0;
v8 = 0;
v9 = 0LL;
while ( 1 )
{
v10 = v5[v9];
if ( v10 != 63 )
break;
if ( v8 )
{
LABEL_8:
v9 = ++v7;
if ( v7 >= v6 )
goto LABEL_12;
}
else
{
++*a2;
v9 = ++v7;
if ( v7 >= v6 )
goto LABEL_12;
}
}
if ( v10 == 39 )
v8 ^= 1u;
goto LABEL_8;
}
LABEL_12:
result = 0LL;
}
else
{
SC_set_error(a1, 3LL, "SQLNumParams called with no statement ready.", v3, v4);
SC_log_error("SQLNumParams", &LC2, a1);
result = 0xFFFFFFFFLL;
}
}
else
{
SC_log_error("SQLNumParams", "pcpar was null", a1);
result = 0xFFFFFFFFLL;
}
}
else
{
SC_log_error("SQLNumParams", &LC2, 0LL);
result = 4294967294LL;
}
return result;
}

original_code:
RETCODE SQLNumParams(
        HSTMT hstmt,
        SWORD *pcpar)
{
StatementClass *stmt = (StatementClass *) hstmt;
char in_quote = (int)0;
unsigned int i;
static char* const func = "SQLNumParams";
 mylog( "%s: entering...\n", func);
 if(!stmt) {
  SC_log_error(func, "", ((void *)0));
  return (-2);
 }
 if (pcpar)
  *pcpar = 0;
 else {
  SC_log_error(func, "pcpar was null", stmt);
  return (-1);
 }
 if(!stmt->statement) {
  SC_set_error(stmt, 3, "SQLNumParams called with no statement ready.");
  SC_log_error(func, "", stmt);
  return (-1);
 } else {
  size_t stlen=strlen(stmt->statement);
  for(i=0; i < stlen; i++) {
   if(stmt->statement[i] == '?' && !in_quote)
    (*pcpar)++;
   else {
    if (stmt->statement[i] == '\'')
     in_quote = (in_quote ? (int)0 : (int)1);
   }
  }
  return 0;
 }
}

canonical_original_code:
short SQLNumParams(void *hstmt, short *pcpar)
{
struct StatementClass_ *stmt = (StatementClass *) hstmt;
char in_quote = (int)0;
unsigned int i;
static char *func = "SQLNumParams";
 mylog( "%s: entering...\n", func);
 if(!stmt) {
  SC_log_error(func, "", ((void *)0));
  return (-2);
 }
 if (pcpar)
  *pcpar = 0;
 else {
  SC_log_error(func, "pcpar was null", stmt);
  return (-1);
 }
 if(!stmt->statement) {
  SC_set_error(stmt, 3, "SQLNumParams called with no statement ready.");
  SC_log_error(func, "", stmt);
  return (-1);
 } else {
  unsigned long stlen = strlen(stmt->statement);
  for(i=0; i < stlen; i++) {
   if(stmt->statement[i] == '?' && !in_quote)
    (*pcpar)++;
   else {
    if (stmt->statement[i] == '\'')
     in_quote = (in_quote ? (int)0 : (int)1);
   }
  }
  return 0;
 }
}

variable_types:
pcpar
short *

variable_types: struct StatementClass_ { struct ConnectionClass_ { void *henv; struct StatementOptions_ { int maxRows; int maxLength; int rowset_size; int keyset_size; int cursor_type; int scroll_concurrency; int retrieve_data; int bind_size; int use_bookmarks; } stmtOptions; char *__error_message; int __error_number; enum CONN_Status { CONN_NOT_CONNECTED=0, CONN_CONNECTED=1, CONN_DOWN=2, CONN_EXECUTING=3 } status; struct ConnInfo { char dsn[256]; char desc[256]; char driver[256]; char server[256]; char database[256]; char username[256]; char password[256]; char conn_settings[4096]; char protocol[10]; char port[10]; char uds[4096]; char onlyread[10]; char fake_oid_index[10]; char show_oid_column[10]; char row_versioning[10]; char show_system_tables[10]; char translation_dll[256]; char translation_option[10]; char focus_password; } connInfo; struct StatementClass_ **stmts; int num_stmts; struct SocketClass_ { int buffer_filled_in; int buffer_filled_out; int buffer_read_in; unsigned char *buffer_in; unsigned char *buffer_out; int socket; char *errormsg; int errornumber; char reverse; } *sock; int lobj_type; int ntables; struct col_info { struct QResultClass_ { struct ColumnInfoClass_ { short num_fields; char **name; unsigned int *adtid; short *adtsize; short *display_size; int *atttypmod; } *fields; struct TupleListClass_ { int num_fields; int num_tuples; struct TupleNode_ { struct TupleNode_ *prev; struct TupleField_ { int len; void *value; } tuple[1]; } *list_start; int last_indexed; } *manual_tuples; struct ConnectionClass_ *conn; int fetch_count; int fcount; int currTuple; int base; int num_fields; int cache_size; int rowset_size; enum QueryResultCode_ { PGRES_EMPTY_QUERY=0, PGRES_COMMAND_OK=1, PGRES_TUPLES_OK=2, PGRES_COPY_OUT=3, PGRES_COPY_IN=4, PGRES_BAD_RESPONSE=5, PGRES_NONFATAL_ERROR=6, PGRES_FATAL_ERROR=7, PGRES_FIELDS_OK=8, PGRES_END_TUPLES=9, PGRES_INTERNAL_ERROR=10 } status; char *message; char *cursor; char *command; char *notice; struct TupleField_ *backend_tuples; struct TupleField_ *tupleField; char inTuples; char aborted; } *result; char name[-1]; } **col_info; long translation_option; void *translation_handle; int (*DataSourceToDriver)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); int (*DriverToDataSource)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); short driver_version; char transact_status; char errormsg_created; char pg_version[128]; float pg_version_number; short pg_version_major; short pg_version_minor; char ms_jet; char unicode; char result_uncommitted; char schema_support; char *client_encoding; char *server_encoding; int ccsc; int be_pid; int be_key; unsigned int isolation; char *current_schema; int num_discardp; char **discardp; } *hdbc; struct QResultClass_ *result; void **phstmt; struct StatementOptions_ options; enum STMT_Status { STMT_ALLOCATED=0, STMT_READY=1, STMT_PREMATURE=2, STMT_FINISHED=3, STMT_EXECUTING=4 } status; char *__error_message; int __error_number; struct BindInfoClass_ { int buflen; int data_left; char *buffer; long *used; short returntype; } *bindings; struct BindInfoClass_ bookmark; int bindings_allocated; int parameters_allocated; struct ParameterInfoClass_ { int buflen; char *buffer; long *used; short paramType; short CType; short SQLType; unsigned int precision; short scale; unsigned int lobj_oid; int *EXEC_used; char *EXEC_buffer; char data_at_exec; } *parameters; int currTuple; int save_rowset_size; int rowset_start; int bind_row; int last_fetch_count; int current_col; int lobj_fd; char *statement; struct TABLE_INFO { struct col_info *col_info; char name[-1]; char alias[-1]; } **ti; struct FIELD_INFO { struct TABLE_INFO *ti; int precision; int display_size; int length; int type; char nullable; char func; char expr; char quote; char dquote; char numeric; char dot[-1]; char name[-1]; char alias[-1]; } **fi; int nfld; int ntab; int parse_status; int statement_type; int data_at_exec; int current_exec_param; char put_data; char errormsg_created; char manual_result; char prepare; char internal; char cursor_name[-1]; char stmt_with_params[65536]; int reexecute; } *

variable_types:
i
unsigned int

variable_types:
stlen
unsigned long


SQLBindCol

decompiled_code:
__int64 __fastcall SQLBindCol(__int64 a1, unsigned __int16 a2, __int16 a3, __int64 a4, int a5, __int64 a6)
{
return PG_SQLBindCol(a1, a2, a3, a4, a5, a6);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned __int16 a2, __int16 a3, __int64 a4, int a5, __int64 a6)
{
return func5(a1, a2, a3, a4, a5, a6);
}

original_code:
SQLRETURN SQLBindCol(SQLHSTMT hstmt,
     SQLUSMALLINT icol, SQLSMALLINT fCType,
     SQLPOINTER rgbValue, SQLINTEGER cbValueMax,
        SQLINTEGER *pcbValue)
{
    return PG_SQLBindCol( hstmt,
                        icol,
                        fCType,
                        rgbValue,
                        cbValueMax,
                        pcbValue );
}

canonical_original_code:
short SQLBindCol(void *hstmt, unsigned short icol, short fCType, void *rgbValue, long cbValueMax, long *pcbValue)
{
    return PG_SQLBindCol( hstmt,
                        icol,
                        fCType,
                        rgbValue,
                        cbValueMax,
                        pcbValue );
}

variable_types:
icol
unsigned short

variable_types: fCType short

variable_types:
rgbValue
void *

variable_types: cbValueMax long

variable_types:
pcbValue
long *


SQLInstallDriverManager

decompiled_code:
__int64 __fastcall SQLInstallDriverManager(char *s, unsigned __int16 a2, _WORD *a3)
{
unsigned int v4; // er13
const char *v5; // rax
char *v6; // rax
__int64 v8; // [rsp+0h] [rbp-518h] BYREF
char dest[1048]; // [rsp+100h] [rbp-418h] BYREF

inst_logClear();
if ( s && a2 > 1u )
{
v4 = 1;
v5 = (const char *)odbcinst_system_file_path(&v8);
v6 = strcpy(dest, v5);
strncpy(s, v6, a2);
if ( a3 )
*a3 = strlen(s);
}
else
{
v4 = 0;
inst_logPushMsg("SQLInstallDriverManager.c", "SQLInstallDriverManager.c", 31LL, 2LL, 1LL, &LC0);
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s, unsigned __int16 a2, _WORD *a3)
{
unsigned int v4; // er13
const char *v5; // rax
char *v6; // rax
__int64 v8; // [rsp+0h] [rbp-518h] BYREF
char dest[1048]; // [rsp+100h] [rbp-418h] BYREF

inst_logClear();
if ( s && a2 > 1u )
{
v4 = 1;
v5 = (const char *)odbcinst_system_file_path(&v8);
v6 = strcpy(dest, v5);
strncpy(s, v6, a2);
if ( a3 )
*a3 = strlen(s);
}
else
{
v4 = 0;
inst_logPushMsg("SQLInstallDriverManager.c", "SQLInstallDriverManager.c", 31LL, 2LL, 1LL, &LC0);
}
return v4;
}

original_code:
int SQLInstallDriverManager( LPSTR pszPath,
        WORD nPathMax,
        WORD *pnPathOut )
{
    char szIniName[ 1000 + 1 ];
 char b1[ 256 ];
    inst_logClear();
 if ( pszPath == ((void *)0) || nPathMax < 2 )
 {
        inst_logPushMsg( "SQLInstallDriverManager.c", "SQLInstallDriverManager.c", 31, 2, 1, "" );
  return 0;
 }
    sprintf( szIniName, "%s", odbcinst_system_file_path( b1 ) );
 strncpy( pszPath, szIniName, nPathMax );
 if ( pnPathOut != ((void *)0) )
  *pnPathOut = strlen( pszPath );
 return 1;
}

canonical_original_code:
int SQLInstallDriverManager(char *pszPath, unsigned short nPathMax, unsigned short *pnPathOut)
{
    char szIniName[-1];
 char b1[256];
    inst_logClear();
 if ( pszPath == ((void *)0) || nPathMax < 2 )
 {
        inst_logPushMsg( "SQLInstallDriverManager.c", "SQLInstallDriverManager.c", 31, 2, 1, "" );
  return 0;
 }
    sprintf( szIniName, "%s", odbcinst_system_file_path( b1 ) );
 strncpy( pszPath, szIniName, nPathMax );
 if ( pnPathOut != ((void *)0) )
  *pnPathOut = strlen( pszPath );
 return 1;
}

variable_types:
pszPath
char *

variable_types:
nPathMax
unsigned short

variable_types:
pnPathOut
unsigned short *

variable_types:
szIniName
char [-1]

return_type: int


SQLInstallDriverManagerW

decompiled_code:
__int64 __fastcall SQLInstallDriverManagerW(__int64 a1, unsigned __int16 a2, _WORD *a3)
{
char *v4; // rbp
unsigned int v5; // er13

inst_logClear();
v4 = (char *)calloc(a2, 1uLL);
v5 = SQLInstallDriverManager(v4, a2, a3);
if ( v5 )
single_string_copy_to_wide(a1, v4, a2);
free(v4);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned __int16 a2, _WORD *a3)
{
char *v4; // rbp
unsigned int v5; // er13

inst_logClear();
v4 = (char *)calloc(a2, 1uLL);
v5 = func0(v4, a2, a3);
if ( v5 )
single_string_copy_to_wide(a1, v4, a2);
free(v4);
return v5;
}

original_code:
int SQLInstallDriverManagerW (LPWSTR lpszPath,
                                      WORD cbPathMax,
                                      WORD * pcbPathOut)
{
 char *path;
 int ret;
    inst_logClear();
 path = calloc( cbPathMax, 1 );
 ret = SQLInstallDriverManager( path, cbPathMax, pcbPathOut );
 if ( ret )
 {
  _single_string_copy_to_wide( lpszPath, path, cbPathMax );
 }
 free( path );
 return ret;
}

canonical_original_code:
int SQLInstallDriverManagerW(unsigned short *lpszPath, unsigned short cbPathMax, unsigned short *pcbPathOut)
{
 char *path;
 int ret;
    inst_logClear();
 path = calloc( cbPathMax, 1 );
 ret = SQLInstallDriverManager( path, cbPathMax, pcbPathOut );
 if ( ret )
 {
  _single_string_copy_to_wide( lpszPath, path, cbPathMax );
 }
 free( path );
 return ret;
}

variable_types:
lpszPath
unsigned short *

variable_types:
cbPathMax
unsigned short

variable_types:
pcbPathOut
unsigned short *

variable_types:
path
char *

variable_types: ret int


SQLSpecialColumns

decompiled_code:
__int64 __fastcall SQLSpecialColumns(__int64 a1)
{
if ( !a1 )
return 4294967294LL;
sprintf((char *)(a1 + 136), "hStmt = $%08lX", a1);
logPushMsg(*(_QWORD *)(a1 + 1160), "SQLSpecialColumns.c", "SQLSpecialColumns.c", 46LL, 1LL, 1LL, a1 + 136);
logPushMsg(
*(_QWORD *)(a1 + 1160),
"SQLSpecialColumns.c",
"SQLSpecialColumns.c",
52LL,
1LL,
1LL,
"SQL_ERROR This function not supported");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( !a1 )
return 4294967294LL;
sprintf((char *)(a1 + 136), "hStmt = $%08lX", a1);
logPushMsg(*(_QWORD *)(a1 + 1160), "SQLSpecialColumns.c", "SQLSpecialColumns.c", 46LL, 1LL, 1LL, a1 + 136);
logPushMsg(
*(_QWORD *)(a1 + 1160),
"SQLSpecialColumns.c",
"SQLSpecialColumns.c",
52LL,
1LL,
1LL,
"SQL_ERROR This function not supported");
return 0xFFFFFFFFLL;
}

original_code:
RETCODE SQLSpecialColumns(
                                  HSTMT hstmt,
                                  UWORD fColType,
                                  UCHAR * szTableQualifier,
                                  SWORD cbTableQualifier,
                                  UCHAR * szTableOwner,
                                  SWORD cbTableOwner,
                                  UCHAR * szTableName,
                                  SWORD cbTableName,
                                  UWORD fScope,
                                  UWORD fNullable)
{
static char* const func = "SQLSpecialColumns";
TupleNode *row;
StatementClass *stmt = (StatementClass *) hstmt;
ConnInfo *ci;
HSTMT hcol_stmt;
StatementClass *col_stmt;
char columns_query[65536];
RETCODE result;
char relhasrules[128];
mylog("%s: entering...stmt=%u\n", func, stmt);
    if( ! stmt) {
  SC_log_error(func, "", ((void *)0));
        return (-2);
    }
 ci = &stmt->hdbc->connInfo;
 stmt->manual_result = (int)1;
 sprintf(columns_query, "select c.relhasrules "
  "from pg_user u, pg_class c where "
  "u.usesysid = c.relowner");
 my_strcat(columns_query, " and c.relname like '%.*s'", (char*)szTableName, cbTableName);
 my_strcat(columns_query, " and u.usename like '%.*s'", (char*)szTableOwner, cbTableOwner);
    result = PG_SQLAllocStmt( stmt->hdbc, &hcol_stmt);
    if((result != 0) && (result != 1)) {
  SC_set_error(stmt, 4, "Couldn't allocate statement for SQLSpecialColumns result.");
  SC_log_error(func, "", stmt);
        return (-1);
    }
 col_stmt = (StatementClass *) hcol_stmt;
 mylog("SQLSpecialColumns: hcol_stmt = %u, col_stmt = %u\n", hcol_stmt, col_stmt);
    result = PG_SQLExecDirect(hcol_stmt, columns_query,
                           strlen(columns_query));
    if((result != 0) && (result != 1)) {
  SC_set_error(stmt, (col_stmt->__error_number), SC_create_errormsg((StatementClass *)hcol_stmt));
  SC_log_error(func, "", stmt);
  PG_SQLFreeStmt(hcol_stmt, 1);
        return (-1);
    }
    result = PG_SQLBindCol(hcol_stmt, 1, 1,
                        relhasrules, 128, ((void *)0));
    if((result != 0) && (result != 1)) {
  SC_set_error(stmt, (col_stmt->__error_number), (col_stmt->__error_message));
  SC_log_error(func, "", stmt);
  PG_SQLFreeStmt(hcol_stmt, 1);
        return (-1);
    }
 result = PG_SQLFetch(hcol_stmt);
 PG_SQLFreeStmt(hcol_stmt, 1);
    stmt->result = QR_Constructor();
    extend_bindings(stmt, 8);
    QR_set_num_fields(stmt->result, 8);
    (CI_set_field_info(stmt->result->fields, 0, "SCOPE", 21, 2, -1));
    (CI_set_field_info(stmt->result->fields, 1, "COLUMN_NAME", 25, 128, -1));
    (CI_set_field_info(stmt->result->fields, 2, "DATA_TYPE", 21, 2, -1));
    (CI_set_field_info(stmt->result->fields, 3, "TYPE_NAME", 25, 128, -1));
    (CI_set_field_info(stmt->result->fields, 4, "PRECISION", 23, 4, -1));
    (CI_set_field_info(stmt->result->fields, 5, "LENGTH", 23, 4, -1));
    (CI_set_field_info(stmt->result->fields, 6, "SCALE", 21, 2, -1));
    (CI_set_field_info(stmt->result->fields, 7, "PSEUDO_COLUMN", 21, 2, -1));
    if ( relhasrules[0] != '1' ) {
  if(fColType == 1) {
   row = (TupleNode *)malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField));
   set_tuplefield_int2(&row->tuple[0], 2);
   set_tuplefield_string(&row->tuple[1], "oid");
   set_tuplefield_int2(&row->tuple[2], pgtype_to_sqltype(stmt, 26));
   set_tuplefield_string(&row->tuple[3], "OID");
   set_tuplefield_int4(&row->tuple[4], pgtype_precision(stmt, 26, -1, -1));
   set_tuplefield_int4(&row->tuple[5], pgtype_length(stmt, 26, -1, -1));
   set_tuplefield_int2(&row->tuple[6], pgtype_scale(stmt, 26, -1));
   set_tuplefield_int2(&row->tuple[7], 2);
   (TL_add_tuple(stmt->result->manual_tuples, row));
  } else if(fColType == 2) {
   short the_type = 23;
   if (atoi(ci->row_versioning)) {
    row = (TupleNode *)malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField));
    set_tuplefield_null(&row->tuple[0]);
    set_tuplefield_string(&row->tuple[1], "xmin");
    set_tuplefield_int2(&row->tuple[2], pgtype_to_sqltype(stmt, the_type));
    set_tuplefield_string(&row->tuple[3], pgtype_to_name(stmt, the_type));
    set_tuplefield_int4(&row->tuple[4], pgtype_precision(stmt, the_type, -1, -1));
    set_tuplefield_int4(&row->tuple[5], pgtype_length(stmt, the_type, -1, -1));
    set_tuplefield_int2(&row->tuple[6], pgtype_scale(stmt, the_type, -1));
    set_tuplefield_int2(&row->tuple[7], 2);
    (TL_add_tuple(stmt->result->manual_tuples, row));
   }
  }
 }
    stmt->status = STMT_FINISHED;
    stmt->currTuple = -1;
 stmt->rowset_start = -1;
 stmt->current_col = -1;
 mylog("SQLSpecialColumns(): EXIT,  stmt=%u\n", stmt);
    return 0;
}

canonical_original_code:
short SQLSpecialColumns(void *hstmt, unsigned short fColType, unsigned char *szTableQualifier, short cbTableQualifier, unsigned char *szTableOwner, short cbTableOwner, unsigned char *szTableName, short cbTableName, unsigned short fScope, unsigned short fNullable)
{
static char *func = "SQLSpecialColumns";
struct TupleNode_ *row;
struct StatementClass_ *stmt = (StatementClass *) hstmt;
struct ConnInfo *ci;
void *hcol_stmt;
struct StatementClass_ *col_stmt;
char columns_query[65536];
short result;
char relhasrules[128];
mylog("%s: entering...stmt=%u\n", func, stmt);
    if( ! stmt) {
  SC_log_error(func, "", ((void *)0));
        return (-2);
    }
 ci = &stmt->hdbc->connInfo;
 stmt->manual_result = (int)1;
 sprintf(columns_query, "select c.relhasrules "
  "from pg_user u, pg_class c where "
  "u.usesysid = c.relowner");
 my_strcat(columns_query, " and c.relname like '%.*s'", (char *)szTableName, cbTableName);
 my_strcat(columns_query, " and u.usename like '%.*s'", (char *)szTableOwner, cbTableOwner);
    result = PG_SQLAllocStmt( stmt->hdbc, &hcol_stmt);
    if((result != 0) && (result != 1)) {
  SC_set_error(stmt, 4, "Couldn't allocate statement for SQLSpecialColumns result.");
  SC_log_error(func, "", stmt);
        return (-1);
    }
 col_stmt = (struct StatementClass_ *) hcol_stmt;
 mylog("SQLSpecialColumns: hcol_stmt = %u, col_stmt = %u\n", hcol_stmt, col_stmt);
    result = PG_SQLExecDirect(hcol_stmt, columns_query,
                           strlen(columns_query));
    if((result != 0) && (result != 1)) {
  SC_set_error(stmt, (col_stmt->__error_number), SC_create_errormsg((struct StatementClass_ *)hcol_stmt));
  SC_log_error(func, "", stmt);
  PG_SQLFreeStmt(hcol_stmt, 1);
        return (-1);
    }
    result = PG_SQLBindCol(hcol_stmt, 1, 1,
                        relhasrules, 128, ((void *)0));
    if((result != 0) && (result != 1)) {
  SC_set_error(stmt, (col_stmt->__error_number), (col_stmt->__error_message));
  SC_log_error(func, "", stmt);
  PG_SQLFreeStmt(hcol_stmt, 1);
        return (-1);
    }
 result = PG_SQLFetch(hcol_stmt);
 PG_SQLFreeStmt(hcol_stmt, 1);
    stmt->result = QR_Constructor();
    extend_bindings(stmt, 8);
    QR_set_num_fields(stmt->result, 8);
    (CI_set_field_info(stmt->result->fields, 0, "SCOPE", 21, 2, -1));
    (CI_set_field_info(stmt->result->fields, 1, "COLUMN_NAME", 25, 128, -1));
    (CI_set_field_info(stmt->result->fields, 2, "DATA_TYPE", 21, 2, -1));
    (CI_set_field_info(stmt->result->fields, 3, "TYPE_NAME", 25, 128, -1));
    (CI_set_field_info(stmt->result->fields, 4, "PRECISION", 23, 4, -1));
    (CI_set_field_info(stmt->result->fields, 5, "LENGTH", 23, 4, -1));
    (CI_set_field_info(stmt->result->fields, 6, "SCALE", 21, 2, -1));
    (CI_set_field_info(stmt->result->fields, 7, "PSEUDO_COLUMN", 21, 2, -1));
    if ( relhasrules[0] != '1' ) {
  if(fColType == 1) {
   row = (struct TupleNode_ *)malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField));
   set_tuplefield_int2(&row->tuple[0], 2);
   set_tuplefield_string(&row->tuple[1], "oid");
   set_tuplefield_int2(&row->tuple[2], pgtype_to_sqltype(stmt, 26));
   set_tuplefield_string(&row->tuple[3], "OID");
   set_tuplefield_int4(&row->tuple[4], pgtype_precision(stmt, 26, -1, -1));
   set_tuplefield_int4(&row->tuple[5], pgtype_length(stmt, 26, -1, -1));
   set_tuplefield_int2(&row->tuple[6], pgtype_scale(stmt, 26, -1));
   set_tuplefield_int2(&row->tuple[7], 2);
   (TL_add_tuple(stmt->result->manual_tuples, row));
  } else if(fColType == 2) {
   short the_type = 23;
   if (atoi(ci->row_versioning)) {
    row = (struct TupleNode_ *)malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField));
    set_tuplefield_null(&row->tuple[0]);
    set_tuplefield_string(&row->tuple[1], "xmin");
    set_tuplefield_int2(&row->tuple[2], pgtype_to_sqltype(stmt, the_type));
    set_tuplefield_string(&row->tuple[3], pgtype_to_name(stmt, the_type));
    set_tuplefield_int4(&row->tuple[4], pgtype_precision(stmt, the_type, -1, -1));
    set_tuplefield_int4(&row->tuple[5], pgtype_length(stmt, the_type, -1, -1));
    set_tuplefield_int2(&row->tuple[6], pgtype_scale(stmt, the_type, -1));
    set_tuplefield_int2(&row->tuple[7], 2);
    (TL_add_tuple(stmt->result->manual_tuples, row));
   }
  }
 }
    stmt->status = STMT_FINISHED;
    stmt->currTuple = -1;
 stmt->rowset_start = -1;
 stmt->current_col = -1;
 mylog("SQLSpecialColumns(): EXIT,  stmt=%u\n", stmt);
    return 0;
}

variable_types:
hstmt
void *

variable_types:
fColType
unsigned short

variable_types:
szTableQualifier
unsigned char *

variable_types: cbTableQualifier short

variable_types:
szTableOwner
unsigned char *

variable_types: cbTableOwner short

variable_types:
szTableName
unsigned char *

variable_types: cbTableName short

variable_types:
fScope
unsigned short

variable_types:
fNullable
unsigned short

variable_types:
func
char *

variable_types: struct StatementClass_ { struct ConnectionClass_ { void *henv; struct StatementOptions_ { int maxRows; int maxLength; int rowset_size; int keyset_size; int cursor_type; int scroll_concurrency; int retrieve_data; int bind_size; int use_bookmarks; } stmtOptions; char *__error_message; int __error_number; enum CONN_Status { CONN_NOT_CONNECTED=0, CONN_CONNECTED=1, CONN_DOWN=2, CONN_EXECUTING=3 } status; struct ConnInfo { char dsn[256]; char desc[256]; char driver[256]; char server[256]; char database[256]; char username[256]; char password[256]; char conn_settings[4096]; char protocol[10]; char port[10]; char uds[4096]; char onlyread[10]; char fake_oid_index[10]; char show_oid_column[10]; char row_versioning[10]; char show_system_tables[10]; char translation_dll[256]; char translation_option[10]; char focus_password; } connInfo; struct StatementClass_ **stmts; int num_stmts; struct SocketClass_ { int buffer_filled_in; int buffer_filled_out; int buffer_read_in; unsigned char *buffer_in; unsigned char *buffer_out; int socket; char *errormsg; int errornumber; char reverse; } *sock; int lobj_type; int ntables; struct col_info { struct QResultClass_ { struct ColumnInfoClass_ { short num_fields; char **name; unsigned int *adtid; short *adtsize; short *display_size; int *atttypmod; } *fields; struct TupleListClass_ { int num_fields; int num_tuples; struct TupleNode_ { struct TupleNode_ *prev; struct TupleField_ { int len; void *value; } tuple[1]; } *list_start; int last_indexed; } *manual_tuples; struct ConnectionClass_ *conn; int fetch_count; int fcount; int currTuple; int base; int num_fields; int cache_size; int rowset_size; enum QueryResultCode_ { PGRES_EMPTY_QUERY=0, PGRES_COMMAND_OK=1, PGRES_TUPLES_OK=2, PGRES_COPY_OUT=3, PGRES_COPY_IN=4, PGRES_BAD_RESPONSE=5, PGRES_NONFATAL_ERROR=6, PGRES_FATAL_ERROR=7, PGRES_FIELDS_OK=8, PGRES_END_TUPLES=9, PGRES_INTERNAL_ERROR=10 } status; char *message; char *cursor; char *command; char *notice; struct TupleField_ *backend_tuples; struct TupleField_ *tupleField; char inTuples; char aborted; } *result; char name[-1]; } **col_info; long translation_option; void *translation_handle; int (*DataSourceToDriver)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); int (*DriverToDataSource)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); short driver_version; char transact_status; char errormsg_created; char pg_version[128]; float pg_version_number; short pg_version_major; short pg_version_minor; char ms_jet; char unicode; char result_uncommitted; char schema_support; char *client_encoding; char *server_encoding; int ccsc; int be_pid; int be_key; unsigned int isolation; char *current_schema; int num_discardp; char **discardp; } *hdbc; struct QResultClass_ *result; void **phstmt; struct StatementOptions_ options; enum STMT_Status { STMT_ALLOCATED=0, STMT_READY=1, STMT_PREMATURE=2, STMT_FINISHED=3, STMT_EXECUTING=4 } status; char *__error_message; int __error_number; struct BindInfoClass_ { int buflen; int data_left; char *buffer; long *used; short returntype; } *bindings; struct BindInfoClass_ bookmark; int bindings_allocated; int parameters_allocated; struct ParameterInfoClass_ { int buflen; char *buffer; long *used; short paramType; short CType; short SQLType; unsigned int precision; short scale; unsigned int lobj_oid; int *EXEC_used; char *EXEC_buffer; char data_at_exec; } *parameters; int currTuple; int save_rowset_size; int rowset_start; int bind_row; int last_fetch_count; int current_col; int lobj_fd; char *statement; struct TABLE_INFO { struct col_info *col_info; char name[-1]; char alias[-1]; } **ti; struct FIELD_INFO { struct TABLE_INFO *ti; int precision; int display_size; int length; int type; char nullable; char func; char expr; char quote; char dquote; char numeric; char dot[-1]; char name[-1]; char alias[-1]; } **fi; int nfld; int ntab; int parse_status; int statement_type; int data_at_exec; int current_exec_param; char put_data; char errormsg_created; char manual_result; char prepare; char internal; char cursor_name[-1]; char stmt_with_params[65536]; int reexecute; } *

variable_types: struct ConnInfo { char dsn[256]; char desc[256]; char driver[256]; char server[256]; char database[256]; char username[256]; char password[256]; char conn_settings[4096]; char protocol[10]; char port[10]; char uds[4096]; char onlyread[10]; char fake_oid_index[10]; char show_oid_column[10]; char row_versioning[10]; char show_system_tables[10]; char translation_dll[256]; char translation_option[10]; char focus_password; } *

variable_types: result short

variable_types:
relhasrules
char [128]


decompiled_code:
__int64 __fastcall nnsql_getcolidxbyname(__int64 a1)
{
int v1; // ebp
char **v2; // rbx

if ( nncol_info_tab[0] == 21 )
return 0xFFFFFFFFLL;
v1 = 0;
v2 = &off_268;
do
{
if ( (unsigned int)upper_strneq(a1, *v2, 16LL) )
return (unsigned int)nncol_info_tab[8 * v1];
v2 += 4;
++v1;
}
while ( *((_DWORD *)v2 - 2) != 21 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
int v1; // ebp
char **v2; // rbx

if ( nncol_info_tab[0] == 21 )
return 0xFFFFFFFFLL;
v1 = 0;
v2 = &off_268;
do
{
if ( (unsigned int)upper_strneq(a1, *v2, 16LL) )
return (unsigned int)nncol_info_tab[8 * v1];
v2 += 4;
++v1;
}
while ( *((_DWORD *)v2 - 2) != 21 );
return 0xFFFFFFFFLL;
}

original_code:
int nnsql_getcolidxbyname( char* col_name )
{
 int i;
 for( i= 0; nncol_info_tab[i].idx != en_sql_count; i++ )
 {
  if(upper_strneq( col_name, nncol_info_tab[i].name, 16))
   return nncol_info_tab[i].idx;
 }
 return -1;
}

canonical_original_code:
int nnsql_getcolidxbyname(char *col_name)
{
 int i;
 for( i= 0; nncol_info_tab[i].idx != en_sql_count; i++ )
 {
  if(upper_strneq( col_name, nncol_info_tab[i].name, 16))
   return nncol_info_tab[i].idx;
 }
 return -1;
}

variable_types: i int


decompiled_code:
__int64 __fastcall nnsql_getcolnamebyidx(int a1)
{
int *v1; // rax
int v2; // eax
int *v3; // rdx
int v4; // ecx

v1 = &nncol_info_tab[8 * a1];
if ( *v1 == a1 )
return *((_QWORD *)v1 + 1);
v2 = nncol_info_tab[0];
v3 = &nncol_info_tab[8];
v4 = 0;
if ( nncol_info_tab[0] == 21 )
return 0LL;
while ( a1 != v2 )
{
v2 = *v3;
v3 += 8;
++v4;
if ( v2 == 21 )
return 0LL;
}
return *(_QWORD *)&nncol_info_tab[8 * v4 + 2];
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
int *v1; // rax
int v2; // eax
int *v3; // rdx
int v4; // ecx

v1 = &nncol_info_tab[8 * a1];
if ( *v1 == a1 )
return *((_QWORD *)v1 + 1);
v2 = nncol_info_tab[0];
v3 = &nncol_info_tab[8];
v4 = 0;
if ( nncol_info_tab[0] == 21 )
return 0LL;
while ( a1 != v2 )
{
v2 = *v3;
v3 += 8;
++v4;
if ( v2 == 21 )
return 0LL;
}
return *(_QWORD *)&nncol_info_tab[8 * v4 + 2];
}

original_code:
char* nnsql_getcolnamebyidx( int idx )
{
 int i;
 if( nncol_info_tab[idx].idx == idx )
  return nncol_info_tab[idx].name;
 for(i=0; nncol_info_tab[i].idx != en_sql_count;i++)
 {
  if( nncol_info_tab[i].idx == idx )
   return nncol_info_tab[i].name;
 }
 return 0;
}

canonical_original_code:
char *nnsql_getcolnamebyidx(int idx)
{
 int i;
 if( nncol_info_tab[idx].idx == idx )
  return nncol_info_tab[idx].name;
 for(i=0; nncol_info_tab[i].idx != en_sql_count;i++)
 {
  if( nncol_info_tab[i].idx == idx )
   return nncol_info_tab[i].name;
 }
 return 0;
}

variable_types: idx int

return_type: char *


decompiled_code:
int *__fastcall nnsql_getcoldescbyidx(int a1)
{
int v1; // eax
int *v2; // rdx

v1 = 0;
v2 = nncol_info_tab;
if ( nncol_info_tab[8 * a1] == a1 )
return &nncol_info_tab[8 * a1];
do
{
if ( *v2 == a1 )
return &nncol_info_tab[8 * v1];
++v1;
v2 += 8;
}
while ( v1 != 31 );
return 0LL;
}

canonical_decompiled_code:
int *__fastcall func2(int a1)
{
int v1; // eax
int *v2; // rdx

v1 = 0;
v2 = nncol_info_tab;
if ( nncol_info_tab[8 * a1] == a1 )
return &nncol_info_tab[8 * a1];
do
{
if ( *v2 == a1 )
return &nncol_info_tab[8 * v1];
++v1;
v2 += 8;
}
while ( v1 != 31 );
return 0LL;
}

original_code:
void* nnsql_getcoldescbyidx( int idx )
{
 int i;
 if( nncol_info_tab[idx].idx == idx )
  return &(nncol_info_tab[idx]);
 for(i=0; i<sizeof(nncol_info_tab)/sizeof(nncol_info_tab[0]); i++)
 {
  if( nncol_info_tab[i].idx == idx )
   return &(nncol_info_tab[i]);
 }
 return 0;
}

canonical_original_code:
void *nnsql_getcoldescbyidx(int idx)
{
 int i;
 if( nncol_info_tab[idx].idx == idx )
  return &(nncol_info_tab[idx]);
 for(i=0; i<sizeof(nncol_info_tab)/sizeof(nncol_info_tab[0]); i++)
 {
  if( nncol_info_tab[i].idx == idx )
   return &(nncol_info_tab[i]);
 }
 return 0;
}

return_type: void *


decompiled_code:
__int64 __fastcall nnsql_getcolnamebydesc(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

original_code:
char* nnsql_getcolnamebydesc( void* hdesc )
{
 col_desc_t* desc = hdesc;
 return desc->name;
}

canonical_original_code:
char *nnsql_getcolnamebydesc(void *hdesc)
{
 struct col_desc_t *desc = hdesc;
 return desc->name;
}

variable_types:
hdesc
void *

variable_types: struct col_desc_t { int idx; char *name; int datatype; int nullable; int writable; } *


decompiled_code:
__int64 __fastcall nnsql_getcoldatatypebydesc(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

original_code:
int nnsql_getcoldatatypebydesc( void* hdesc )
{
 col_desc_t* desc = hdesc;
 return desc->datatype;
}

canonical_original_code:
int nnsql_getcoldatatypebydesc(void *hdesc)
{
 struct col_desc_t *desc = hdesc;
 return desc->datatype;
}

user_defined_types: struct col_desc_t { int idx; char *name; int datatype; int nullable; int writable; }


decompiled_code:
__int64 __fastcall nnsql_getcolnullablebydesc(__int64 a1)
{
return *(unsigned int *)(a1 + 20);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(unsigned int *)(a1 + 20);
}

original_code:
int nnsql_getcolnullablebydesc( void* hdesc )
{
 col_desc_t* desc = hdesc;
 return desc->nullable;
}

canonical_original_code:
int nnsql_getcolnullablebydesc(void *hdesc)
{
 struct col_desc_t *desc = hdesc;
 return desc->nullable;
}


decompiled_code:
__int64 __fastcall set_statement_option(_DWORD *a1, _DWORD *a2, unsigned __int16 a3, __int64 a4)
{
__int64 result; // rax
unsigned int v6; // er12
char s[104]; // [rsp+10h] [rbp-68h] BYREF

switch ( a3 )
{
case 0u:
mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", a4);
return 0LL;
case 1u:
mylog("SetStmtOption(): SQL_MAX_ROWS, vParam = %d\n", a4);
if ( a1 )
a1[2] = a4;
if ( !a2 )
goto LABEL_15;
a2[6] = a4;
return 0LL;
case 2u:
mylog("SetStmtOption: SQL_NOSCAN, vParam = %d\n", a4);
return 0LL;
case 3u:
mylog("SetStmtOption(): SQL_MAX_LENGTH, vParam = %d\n", a4);
if ( a1 )
a1[3] = a4;
if ( !a2 )
goto LABEL_15;
a2[7] = a4;
return 0LL;
case 4u:
goto LABEL_15;
case 5u:
if ( a1 )
a1[9] = a4;
if ( !a2 )
goto LABEL_15;
a2[13] = a4;
return 0LL;
case 6u:
mylog("SetStmtOption(): SQL_CURSOR_TYPE = %d\n", a4);
if ( globals[30] )
goto LABEL_62;
if ( globals[26] )
{
if ( a1 )
a1[6] = 0;
if ( a2 )
{
a2[10] = 0;
if ( !a4 )
goto LABEL_15;
goto LABEL_30;
}
if ( a4 )
goto LABEL_31;
result = 0LL;
}
else
{
if ( a4 && a4 != 3 )
{
if ( a1 )
{
a1[6] = 3;
if ( !a2 )
goto LABEL_68;
}
else if ( !a2 )
{
return 1LL;
}
a2[10] = 3;
goto LABEL_30;
}
LABEL_62:
if ( a1 )
a1[6] = a4;
if ( a2 )
{
a2[10] = a4;
return 0LL;
}
LABEL_15:
result = 0LL;
}
return result;
case 7u:
if ( a1 )
a1[7] = a4;
if ( !a2 )
goto LABEL_15;
a2[11] = a4;
return 0LL;
case 8u:
mylog("SetStmtOption(): SQL_KEYSET_SIZE, vParam = %d\n", a4);
if ( a1 )
a1[5] = a4;
if ( !a2 )
goto LABEL_15;
a2[9] = a4;
return 0LL;
case 9u:
mylog("SetStmtOption(): SQL_ROWSET_SIZE, vParam = %d\n", a4);
if ( a2 && (int)a2[35] <= 0 && (int)a2[38] > 0 )
a2[35] = a2[8];
if ( !a4 )
{
if ( a1 )
{
a1[4] = 1;
if ( !a2 )
{
LABEL_68:
CC_set_error(a1, 16LL, "Requested value changed.");
return 1LL;
}
}
else if ( !a2 )
{
return 1LL;
}
a2[8] = 1;
LABEL_30:
SC_set_error(a2, 16LL, "Requested value changed.");
LABEL_31:
if ( !a1 )
return 1LL;
goto LABEL_68;
}
if ( a1 )
{
a1[4] = a4;
if ( !a2 )
goto LABEL_15;
goto LABEL_14;
}
if ( a2 )
{
LABEL_14:
a2[8] = a4;
goto LABEL_15;
}
return 0LL;
case 0xAu:
if ( a2 )
{
SC_set_error(a2, 10LL, "Simulated positioned update/delete not supported. Use the cursor library.");
SC_log_error("set_statement_option", &LC10, a2);
}
result = 0xFFFFFFFFLL;
if ( a1 )
{
CC_set_error(a1, 10LL, "Simulated positioned update/delete not supported. Use the cursor library.");
CC_log_error("set_statement_option", &LC10, a1);
result = 0xFFFFFFFFLL;
}
return result;
case 0xBu:
mylog("SetStmtOption(): SQL_RETRIEVE_DATA, vParam = %d\n", a4);
if ( a1 )
a1[8] = a4;
if ( !a2 )
goto LABEL_15;
a2[12] = a4;
return 0LL;
case 0xCu:
if ( a2 )
a2[14] = a4;
if ( !a1 )
goto LABEL_15;
a1[10] = a4;
return 0LL;
default:
result = 0LL;
if ( a3 != 0xFFFE )
{
v6 = a3;
if ( a2 )
{
SC_set_error(a2, 10LL, "Unknown statement option (Set)");
sprintf(s, "fOption=%d, vParam=%ld", v6, a4);
SC_log_error("set_statement_option", s, a2);
}
if ( a1 )
{
CC_set_error(a1, 10LL, "Unknown statement option (Set)");
sprintf(s, "fOption=%d, vParam=%ld", v6, a4);
CC_log_error("set_statement_option", s, a1);
}
result = 0xFFFFFFFFLL;
}
return result;
}
}

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD *a1, _DWORD *a2, unsigned __int16 a3, __int64 a4)
{
__int64 result; // rax
unsigned int v6; // er12
char s[104]; // [rsp+10h] [rbp-68h] BYREF

switch ( a3 )
{
case 0u:
mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", a4);
return 0LL;
case 1u:
mylog("SetStmtOption(): SQL_MAX_ROWS, vParam = %d\n", a4);
if ( a1 )
a1[2] = a4;
if ( !a2 )
goto LABEL_15;
a2[6] = a4;
return 0LL;
case 2u:
mylog("SetStmtOption: SQL_NOSCAN, vParam = %d\n", a4);
return 0LL;
case 3u:
mylog("SetStmtOption(): SQL_MAX_LENGTH, vParam = %d\n", a4);
if ( a1 )
a1[3] = a4;
if ( !a2 )
goto LABEL_15;
a2[7] = a4;
return 0LL;
case 4u:
goto LABEL_15;
case 5u:
if ( a1 )
a1[9] = a4;
if ( !a2 )
goto LABEL_15;
a2[13] = a4;
return 0LL;
case 6u:
mylog("SetStmtOption(): SQL_CURSOR_TYPE = %d\n", a4);
if ( globals[30] )
goto LABEL_62;
if ( globals[26] )
{
if ( a1 )
a1[6] = 0;
if ( a2 )
{
a2[10] = 0;
if ( !a4 )
goto LABEL_15;
goto LABEL_30;
}
if ( a4 )
goto LABEL_31;
result = 0LL;
}
else
{
if ( a4 && a4 != 3 )
{
if ( a1 )
{
a1[6] = 3;
if ( !a2 )
goto LABEL_68;
}
else if ( !a2 )
{
return 1LL;
}
a2[10] = 3;
goto LABEL_30;
}
LABEL_62:
if ( a1 )
a1[6] = a4;
if ( a2 )
{
a2[10] = a4;
return 0LL;
}
LABEL_15:
result = 0LL;
}
return result;
case 7u:
if ( a1 )
a1[7] = a4;
if ( !a2 )
goto LABEL_15;
a2[11] = a4;
return 0LL;
case 8u:
mylog("SetStmtOption(): SQL_KEYSET_SIZE, vParam = %d\n", a4);
if ( a1 )
a1[5] = a4;
if ( !a2 )
goto LABEL_15;
a2[9] = a4;
return 0LL;
case 9u:
mylog("SetStmtOption(): SQL_ROWSET_SIZE, vParam = %d\n", a4);
if ( a2 && (int)a2[35] <= 0 && (int)a2[38] > 0 )
a2[35] = a2[8];
if ( !a4 )
{
if ( a1 )
{
a1[4] = 1;
if ( !a2 )
{
LABEL_68:
CC_set_error(a1, 16LL, "Requested value changed.");
return 1LL;
}
}
else if ( !a2 )
{
return 1LL;
}
a2[8] = 1;
LABEL_30:
SC_set_error(a2, 16LL, "Requested value changed.");
LABEL_31:
if ( !a1 )
return 1LL;
goto LABEL_68;
}
if ( a1 )
{
a1[4] = a4;
if ( !a2 )
goto LABEL_15;
goto LABEL_14;
}
if ( a2 )
{
LABEL_14:
a2[8] = a4;
goto LABEL_15;
}
return 0LL;
case 0xAu:
if ( a2 )
{
SC_set_error(a2, 10LL, "Simulated positioned update/delete not supported. Use the cursor library.");
SC_log_error("set_statement_option", &LC10, a2);
}
result = 0xFFFFFFFFLL;
if ( a1 )
{
CC_set_error(a1, 10LL, "Simulated positioned update/delete not supported. Use the cursor library.");
CC_log_error("set_statement_option", &LC10, a1);
result = 0xFFFFFFFFLL;
}
return result;
case 0xBu:
mylog("SetStmtOption(): SQL_RETRIEVE_DATA, vParam = %d\n", a4);
if ( a1 )
a1[8] = a4;
if ( !a2 )
goto LABEL_15;
a2[12] = a4;
return 0LL;
case 0xCu:
if ( a2 )
a2[14] = a4;
if ( !a1 )
goto LABEL_15;
a1[10] = a4;
return 0LL;
default:
result = 0LL;
if ( a3 != 0xFFFE )
{
v6 = a3;
if ( a2 )
{
SC_set_error(a2, 10LL, "Unknown statement option (Set)");
sprintf(s, "fOption=%d, vParam=%ld", v6, a4);
SC_log_error("set_statement_option", s, a2);
}
if ( a1 )
{
CC_set_error(a1, 10LL, "Unknown statement option (Set)");
sprintf(s, "fOption=%d, vParam=%ld", v6, a4);
CC_log_error("set_statement_option", s, a1);
}
result = 0xFFFFFFFFLL;
}
return result;
}
}

original_code:
RETCODE set_statement_option(ConnectionClass *conn,
        StatementClass *stmt,
        UWORD fOption,
        UDWORD vParam)
{
static char* const func="set_statement_option";
char changed = (int)0;
 switch(fOption) {
 case 4:
  break;
 case 5:
  if (conn) conn->stmtOptions.bind_size = vParam;
  if (stmt) stmt->options.bind_size = vParam;
  break;
 case 7:
  if (conn) conn->stmtOptions.scroll_concurrency = vParam;
  if (stmt) stmt->options.scroll_concurrency = vParam;
  break;
 case 6:
  mylog("SetStmtOption(): SQL_CURSOR_TYPE = %d\n", vParam);
  if (globals.lie) {
   if (conn) conn->stmtOptions.cursor_type = vParam;
   if (stmt) stmt->options.cursor_type = vParam;
  }
  else {
   if (globals.use_declarefetch) {
    if (conn) conn->stmtOptions.cursor_type = 0UL;
    if (stmt) stmt->options.cursor_type = 0UL;
    if (vParam != 0UL)
     changed = (int)1;
   }
   else {
    if (vParam == 0UL || vParam == 3UL) {
     if (conn) conn->stmtOptions.cursor_type = vParam;
     if (stmt) stmt->options.cursor_type = vParam;
    }
    else {
     if (conn) conn->stmtOptions.cursor_type = 3UL;
     if (stmt) stmt->options.cursor_type = 3UL;
     changed = (int)1;
    }
   }
  }
  break;
 case 8:
  mylog("SetStmtOption(): SQL_KEYSET_SIZE, vParam = %d\n", vParam);
  if (conn) conn->stmtOptions.keyset_size = vParam;
  if (stmt) stmt->options.keyset_size = vParam;
  break;
 case 3:
  mylog("SetStmtOption(): SQL_MAX_LENGTH, vParam = %d\n", vParam);
  if (conn) conn->stmtOptions.maxLength = vParam;
  if (stmt) stmt->options.maxLength = vParam;
  break;
 case 1:
  mylog("SetStmtOption(): SQL_MAX_ROWS, vParam = %d\n", vParam);
  if (conn) conn->stmtOptions.maxRows = vParam;
  if (stmt) stmt->options.maxRows = vParam;
  break;
 case 2:
  mylog("SetStmtOption: SQL_NOSCAN, vParam = %d\n", vParam);
  break;
 case 0:
  mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", vParam);
  break;
 case 11:
  mylog("SetStmtOption(): SQL_RETRIEVE_DATA, vParam = %d\n", vParam);
  if (conn) conn->stmtOptions.retrieve_data = vParam;
  if (stmt) stmt->options.retrieve_data = vParam;
  break;
 case 9:
  mylog("SetStmtOption(): SQL_ROWSET_SIZE, vParam = %d\n", vParam);
  if (stmt && stmt->save_rowset_size <= 0 && stmt->last_fetch_count > 0 )
   stmt->save_rowset_size = stmt->options.rowset_size;
  if (vParam < 1) {
   vParam = 1;
   changed = (int)1;
  }
  if (conn) conn->stmtOptions.rowset_size = vParam;
  if (stmt) stmt->options.rowset_size = vParam;
  break;
 case 10:
  if (stmt) {
   SC_set_error(stmt, 10, "Simulated positioned update/delete not supported.  Use the cursor library.");
   SC_log_error(func, "", stmt);
  }
  if (conn) {
   CC_set_error(conn, 10, "Simulated positioned update/delete not supported.  Use the cursor library.");
   CC_log_error(func, "", conn);
  }
  return (-1);
 case 12:
  if (stmt) stmt->options.use_bookmarks = vParam;
  if (conn) conn->stmtOptions.use_bookmarks = vParam;
  break;
    case 65534:
        break;
    default:
  {
  char option[64];
  if (stmt) {
   SC_set_error(stmt, 10, "Unknown statement option (Set)");
   sprintf(option, "fOption=%d, vParam=%ld", fOption, (long)vParam);
   SC_log_error(func, option, stmt);
  }
  if (conn) {
   CC_set_error(conn, 10, "Unknown statement option (Set)");
   sprintf(option, "fOption=%d, vParam=%ld", fOption, (long)vParam);
   CC_log_error(func, option, conn);
  }
        return (-1);
  }
    }
 if (changed) {
  if (stmt) {
   SC_set_error(stmt, 16, "Requested value changed.");
  }
  if (conn) {
   CC_set_error(conn, 16, "Requested value changed.");
  }
  return 1;
 }
 else
  return 0;
}

canonical_original_code:
short set_statement_option(struct ConnectionClass_ *conn, struct StatementClass_ *stmt, unsigned short fOption, unsigned long vParam)
{
static char *func = "set_statement_option";
char changed = (int)0;
 switch(fOption) {
 case 4:
  break;
 case 5:
  if (conn) conn->stmtOptions.bind_size = vParam;
  if (stmt) stmt->options.bind_size = vParam;
  break;
 case 7:
  if (conn) conn->stmtOptions.scroll_concurrency = vParam;
  if (stmt) stmt->options.scroll_concurrency = vParam;
  break;
 case 6:
  mylog("SetStmtOption(): SQL_CURSOR_TYPE = %d\n", vParam);
  if (globals.lie) {
   if (conn) conn->stmtOptions.cursor_type = vParam;
   if (stmt) stmt->options.cursor_type = vParam;
  }
  else {
   if (globals.use_declarefetch) {
    if (conn) conn->stmtOptions.cursor_type = 0UL;
    if (stmt) stmt->options.cursor_type = 0UL;
    if (vParam != 0UL)
     changed = (int)1;
   }
   else {
    if (vParam == 0UL || vParam == 3UL) {
     if (conn) conn->stmtOptions.cursor_type = vParam;
     if (stmt) stmt->options.cursor_type = vParam;
    }
    else {
     if (conn) conn->stmtOptions.cursor_type = 3UL;
     if (stmt) stmt->options.cursor_type = 3UL;
     changed = (int)1;
    }
   }
  }
  break;
 case 8:
  mylog("SetStmtOption(): SQL_KEYSET_SIZE, vParam = %d\n", vParam);
  if (conn) conn->stmtOptions.keyset_size = vParam;
  if (stmt) stmt->options.keyset_size = vParam;
  break;
 case 3:
  mylog("SetStmtOption(): SQL_MAX_LENGTH, vParam = %d\n", vParam);
  if (conn) conn->stmtOptions.maxLength = vParam;
  if (stmt) stmt->options.maxLength = vParam;
  break;
 case 1:
  mylog("SetStmtOption(): SQL_MAX_ROWS, vParam = %d\n", vParam);
  if (conn) conn->stmtOptions.maxRows = vParam;
  if (stmt) stmt->options.maxRows = vParam;
  break;
 case 2:
  mylog("SetStmtOption: SQL_NOSCAN, vParam = %d\n", vParam);
  break;
 case 0:
  mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", vParam);
  break;
 case 11:
  mylog("SetStmtOption(): SQL_RETRIEVE_DATA, vParam = %d\n", vParam);
  if (conn) conn->stmtOptions.retrieve_data = vParam;
  if (stmt) stmt->options.retrieve_data = vParam;
  break;
 case 9:
  mylog("SetStmtOption(): SQL_ROWSET_SIZE, vParam = %d\n", vParam);
  if (stmt && stmt->save_rowset_size <= 0 && stmt->last_fetch_count > 0 )
   stmt->save_rowset_size = stmt->options.rowset_size;
  if (vParam < 1) {
   vParam = 1;
   changed = (int)1;
  }
  if (conn) conn->stmtOptions.rowset_size = vParam;
  if (stmt) stmt->options.rowset_size = vParam;
  break;
 case 10:
  if (stmt) {
   SC_set_error(stmt, 10, "Simulated positioned update/delete not supported.  Use the cursor library.");
   SC_log_error(func, "", stmt);
  }
  if (conn) {
   CC_set_error(conn, 10, "Simulated positioned update/delete not supported.  Use the cursor library.");
   CC_log_error(func, "", conn);
  }
  return (-1);
 case 12:
  if (stmt) stmt->options.use_bookmarks = vParam;
  if (conn) conn->stmtOptions.use_bookmarks = vParam;
  break;
    case 65534:
        break;
    default:
  {
  char option[64];
  if (stmt) {
   SC_set_error(stmt, 10, "Unknown statement option (Set)");
   sprintf(option, "fOption=%d, vParam=%ld", fOption, (long)vParam);
   SC_log_error(func, option, stmt);
  }
  if (conn) {
   CC_set_error(conn, 10, "Unknown statement option (Set)");
   sprintf(option, "fOption=%d, vParam=%ld", fOption, (long)vParam);
   CC_log_error(func, option, conn);
  }
        return (-1);
  }
    }
 if (changed) {
  if (stmt) {
   SC_set_error(stmt, 16, "Requested value changed.");
  }
  if (conn) {
   CC_set_error(conn, 16, "Requested value changed.");
  }
  return 1;
 }
 else
  return 0;
}

variable_types: struct ConnectionClass_ { void *henv; struct StatementOptions_ { int maxRows; int maxLength; int rowset_size; int keyset_size; int cursor_type; int scroll_concurrency; int retrieve_data; int bind_size; int use_bookmarks; } stmtOptions; char *__error_message; int __error_number; enum CONN_Status { CONN_NOT_CONNECTED=0, CONN_CONNECTED=1, CONN_DOWN=2, CONN_EXECUTING=3 } status; struct ConnInfo { char dsn[256]; char desc[256]; char driver[256]; char server[256]; char database[256]; char username[256]; char password[256]; char conn_settings[4096]; char protocol[10]; char port[10]; char uds[4096]; char onlyread[10]; char fake_oid_index[10]; char show_oid_column[10]; char row_versioning[10]; char show_system_tables[10]; char translation_dll[256]; char translation_option[10]; char focus_password; } connInfo; struct StatementClass_ { struct ConnectionClass_ *hdbc; struct QResultClass_ { struct ColumnInfoClass_ { short num_fields; char **name; unsigned int *adtid; short *adtsize; short *display_size; int *atttypmod; } *fields; struct TupleListClass_ { int num_fields; int num_tuples; struct TupleNode_ { struct TupleNode_ *prev; struct TupleField_ { int len; void *value; } tuple[1]; } *list_start; int last_indexed; } *manual_tuples; struct ConnectionClass_ *conn; int fetch_count; int fcount; int currTuple; int base; int num_fields; int cache_size; int rowset_size; enum QueryResultCode_ { PGRES_EMPTY_QUERY=0, PGRES_COMMAND_OK=1, PGRES_TUPLES_OK=2, PGRES_COPY_OUT=3, PGRES_COPY_IN=4, PGRES_BAD_RESPONSE=5, PGRES_NONFATAL_ERROR=6, PGRES_FATAL_ERROR=7, PGRES_FIELDS_OK=8, PGRES_END_TUPLES=9, PGRES_INTERNAL_ERROR=10 } status; char *message; char *cursor; char *command; char *notice; struct TupleField_ *backend_tuples; struct TupleField_ *tupleField; char inTuples; char aborted; } *result; void **phstmt; struct StatementOptions_ options; enum STMT_Status { STMT_ALLOCATED=0, STMT_READY=1, STMT_PREMATURE=2, STMT_FINISHED=3, STMT_EXECUTING=4 } status; char *__error_message; int __error_number; struct BindInfoClass_ { int buflen; int data_left; char *buffer; long *used; short returntype; } *bindings; struct BindInfoClass_ bookmark; int bindings_allocated; int parameters_allocated; struct ParameterInfoClass_ { int buflen; char *buffer; long *used; short paramType; short CType; short SQLType; unsigned int precision; short scale; unsigned int lobj_oid; int *EXEC_used; char *EXEC_buffer; char data_at_exec; } *parameters; int currTuple; int save_rowset_size; int rowset_start; int bind_row; int last_fetch_count; int current_col; int lobj_fd; char *statement; struct TABLE_INFO { struct col_info { struct QResultClass_ *result; char name[-1]; } *col_info; char name[-1]; char alias[-1]; } **ti; struct FIELD_INFO { struct TABLE_INFO *ti; int precision; int display_size; int length; int type; char nullable; char func; char expr; char quote; char dquote; char numeric; char dot[-1]; char name[-1]; char alias[-1]; } **fi; int nfld; int ntab; int parse_status; int statement_type; int data_at_exec; int current_exec_param; char put_data; char errormsg_created; char manual_result; char prepare; char internal; char cursor_name[-1]; char stmt_with_params[65536]; int reexecute; } **stmts; int num_stmts; struct SocketClass_ { int buffer_filled_in; int buffer_filled_out; int buffer_read_in; unsigned char *buffer_in; unsigned char *buffer_out; int socket; char *errormsg; int errornumber; char reverse; } *sock; int lobj_type; int ntables; struct col_info **col_info; long translation_option; void *translation_handle; int (*DataSourceToDriver)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); int (*DriverToDataSource)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); short driver_version; char transact_status; char errormsg_created; char pg_version[128]; float pg_version_number; short pg_version_major; short pg_version_minor; char ms_jet; char unicode; char result_uncommitted; char schema_support; char *client_encoding; char *server_encoding; int ccsc; int be_pid; int be_key; unsigned int isolation; char *current_schema; int num_discardp; char **discardp; } *

variable_types:
stmt
struct StatementClass_ *

variable_types:
fOption
unsigned short

variable_types:
vParam
unsigned long

variable_types: changed char

variable_types:
option
char [64]

user_defined_types: struct TABLE_INFO { struct col_info *col_info; char name[-1]; char alias[-1]; }


SQLSetConnectOption

decompiled_code:
__int64 __fastcall SQLSetConnectOption(__int64 a1, unsigned __int16 a2, __int64 a3)
{
__int64 result; // rax
const char *v6; // rdx
__int64 v7; // rsi
__int64 v8; // rbx
_DWORD *v9; // rsi
unsigned int v10; // eax
unsigned int v11; // [rsp+Ch] [rbp-6Ch]
char s[104]; // [rsp+10h] [rbp-68h] BYREF

mylog("%s: entering...\n", "SQLSetConnectOption");
if ( a1 )
{
if ( a2 <= 0xCu )
{
if ( *(int *)(a1 + 10400) > 0 )
{
v8 = 0LL;
do
{
v9 = *(_DWORD **)(*(_QWORD *)(a1 + 10392) + 8 * v8);
if ( v9 )
set_statement_option(0LL, v9, a2, a3);
++v8;
}
while ( *(_DWORD *)(a1 + 10400) > (int)v8 );
}
v10 = set_statement_option((_DWORD *)a1, 0LL, a2, a3);
if ( (_WORD)v10 == 1 )
{
v11 = v10;
CC_set_error(a1, 213LL, "Requested value changed.");
result = v11;
}
else
{
result = (unsigned int)-((_WORD)v10 == 0xFFFF);
}
}
else
{
switch ( a2 )
{
case 'e':
case 'g':
case 'l':
case 'm':
case 'o':
case 'p':
return 0LL;
case 'f':
if ( (*(_BYTE *)(a1 + 10466) & 2) != 0 )
{
v6 = "Cannot switch commit mode while a transaction is in progress";
v7 = 207LL;
goto LABEL_10;
}
mylog(
"SQLSetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n",
(unsigned int)*(char *)(a1 + 10466),
a3);
if ( a3 )
{
if ( a3 != 1 )
{
v6 = "Illegal parameter value for SQL_AUTOCOMMIT";
v7 = 206LL;
LABEL_10:
CC_set_error(a1, v7, v6);
CC_log_error("SQLSetConnectOption", &LC10, a1);
return 0xFFFFFFFFLL;
}
*(_BYTE *)(a1 + 10466) |= 1u;
result = 0LL;
}
else
{
*(_BYTE *)(a1 + 10466) &= 0xFEu;
result = 0LL;
}
break;
case 'h':
case 'i':
case 'j':
case 'k':
case 'n':
CC_log_error("SQLSetConnectOption", "This connect option (Set) is only used by the Driver Manager", a1);
return 0LL;
default:
CC_set_error(a1, 205LL, "Unknown connect option (Set)");
sprintf(s, "fOption=%d, vParam=%ld", a2, a3);
CC_log_error("SQLSetConnectOption", s, a1);
return 0xFFFFFFFFLL;
}
}
}
else
{
CC_log_error("SQLSetConnectOption", &LC10, 0LL);
result = 4294967294LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned __int16 a2, __int64 a3)
{
__int64 result; // rax
const char *v6; // rdx
__int64 v7; // rsi
__int64 v8; // rbx
_DWORD *v9; // rsi
unsigned int v10; // eax
unsigned int v11; // [rsp+Ch] [rbp-6Ch]
char s[104]; // [rsp+10h] [rbp-68h] BYREF

mylog("%s: entering...\n", "SQLSetConnectOption");
if ( a1 )
{
if ( a2 <= 0xCu )
{
if ( *(int *)(a1 + 10400) > 0 )
{
v8 = 0LL;
do
{
v9 = *(_DWORD **)(*(_QWORD *)(a1 + 10392) + 8 * v8);
if ( v9 )
func0(0LL, v9, a2, a3);
++v8;
}
while ( *(_DWORD *)(a1 + 10400) > (int)v8 );
}
v10 = func0((_DWORD *)a1, 0LL, a2, a3);
if ( (_WORD)v10 == 1 )
{
v11 = v10;
CC_set_error(a1, 213LL, "Requested value changed.");
result = v11;
}
else
{
result = (unsigned int)-((_WORD)v10 == 0xFFFF);
}
}
else
{
switch ( a2 )
{
case 'e':
case 'g':
case 'l':
case 'm':
case 'o':
case 'p':
return 0LL;
case 'f':
if ( (*(_BYTE *)(a1 + 10466) & 2) != 0 )
{
v6 = "Cannot switch commit mode while a transaction is in progress";
v7 = 207LL;
goto LABEL_10;
}
mylog(
"SQLSetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n",
(unsigned int)*(char *)(a1 + 10466),
a3);
if ( a3 )
{
if ( a3 != 1 )
{
v6 = "Illegal parameter value for SQL_AUTOCOMMIT";
v7 = 206LL;
LABEL_10:
CC_set_error(a1, v7, v6);
CC_log_error("SQLSetConnectOption", &LC10, a1);
return 0xFFFFFFFFLL;
}
*(_BYTE *)(a1 + 10466) |= 1u;
result = 0LL;
}
else
{
*(_BYTE *)(a1 + 10466) &= 0xFEu;
result = 0LL;
}
break;
case 'h':
case 'i':
case 'j':
case 'k':
case 'n':
CC_log_error("SQLSetConnectOption", "This connect option (Set) is only used by the Driver Manager", a1);
return 0LL;
default:
CC_set_error(a1, 205LL, "Unknown connect option (Set)");
sprintf(s, "fOption=%d, vParam=%ld", a2, a3);
CC_log_error("SQLSetConnectOption", s, a1);
return 0xFFFFFFFFLL;
}
}
}
else
{
CC_log_error("SQLSetConnectOption", &LC10, 0LL);
result = 4294967294LL;
}
return result;
}

original_code:
RETCODE SQLSetConnectOption(
        HDBC hdbc,
        UWORD fOption,
        SQLUINTEGER vParam)
{
static char* const func="SQLSetConnectOption";
ConnectionClass *conn = (ConnectionClass *) hdbc;
char changed = (int)0;
RETCODE retval;
int i;
 mylog("%s: entering...\n", func);
 if ( ! conn) {
  CC_log_error(func, "", ((void *)0));
  return (-2);
 }
 switch (fOption) {
 case 4:
 case 5:
 case 7:
 case 6:
 case 8:
 case 3:
 case 1:
 case 2:
 case 0:
 case 11:
 case 9:
 case 10:
 case 12:
  for (i = 0; i < conn->num_stmts; i++) {
   if ( conn->stmts[i]) {
    set_statement_option(((void *)0), conn->stmts[i], fOption, vParam);
   }
  }
  retval = set_statement_option(conn, ((void *)0), fOption, vParam);
  if (retval == 1)
   changed = (int)1;
  else if (retval == (-1))
   return (-1);
  break;
 case 101:
  break;
 case 102:
  if ((conn->transact_status & 0x02)) {
   CC_set_error(conn, 207, "Cannot switch commit mode while a transaction is in progress");
   CC_log_error(func, "", conn);
   return (-1);
  }
  mylog("SQLSetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n", conn->transact_status, vParam);
  switch(vParam) {
  case 0UL:
   (conn->transact_status &= ~0x01);
   break;
  case 1UL:
   (conn->transact_status |= 0x01);
   break;
  default:
   CC_set_error(conn, 206, "Illegal parameter value for SQL_AUTOCOMMIT");
   CC_log_error(func, "", conn);
   return (-1);
  }
  break;
 case 109:
  break;
 case 103:
  break;
 case 112:
  break;
 case 111:
  break;
 case 108:
  break;
 case 110:
 case 104:
 case 105:
 case 106:
 case 107:
  CC_log_error(func, "This connect option (Set) is only used by the Driver Manager", conn);
  break;
 default:
  {
  char option[64];
  CC_set_error(conn, 205, "Unknown connect option (Set)");
  sprintf(option, "fOption=%d, vParam=%ld", fOption, vParam);
  CC_log_error(func, option, conn);
  return (-1);
  }
 }
 if (changed) {
  CC_set_error(conn, 213, "Requested value changed.");
  return 1;
 }
 else
  return 0;
}

canonical_original_code:
short SQLSetConnectOption(void *hdbc, unsigned short fOption, unsigned long vParam)
{
static char *func = "SQLSetConnectOption";
struct ConnectionClass_ *conn = (ConnectionClass *) hdbc;
char changed = (int)0;
short retval;
int i;
 mylog("%s: entering...\n", func);
 if ( ! conn) {
  CC_log_error(func, "", ((void *)0));
  return (-2);
 }
 switch (fOption) {
 case 4:
 case 5:
 case 7:
 case 6:
 case 8:
 case 3:
 case 1:
 case 2:
 case 0:
 case 11:
 case 9:
 case 10:
 case 12:
  for (i = 0; i < conn->num_stmts; i++) {
   if ( conn->stmts[i]) {
    set_statement_option(((void *)0), conn->stmts[i], fOption, vParam);
   }
  }
  retval = set_statement_option(conn, ((void *)0), fOption, vParam);
  if (retval == 1)
   changed = (int)1;
  else if (retval == (-1))
   return (-1);
  break;
 case 101:
  break;
 case 102:
  if ((conn->transact_status & 0x02)) {
   CC_set_error(conn, 207, "Cannot switch commit mode while a transaction is in progress");
   CC_log_error(func, "", conn);
   return (-1);
  }
  mylog("SQLSetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n", conn->transact_status, vParam);
  switch(vParam) {
  case 0UL:
   (conn->transact_status &= ~0x01);
   break;
  case 1UL:
   (conn->transact_status |= 0x01);
   break;
  default:
   CC_set_error(conn, 206, "Illegal parameter value for SQL_AUTOCOMMIT");
   CC_log_error(func, "", conn);
   return (-1);
  }
  break;
 case 109:
  break;
 case 103:
  break;
 case 112:
  break;
 case 111:
  break;
 case 108:
  break;
 case 110:
 case 104:
 case 105:
 case 106:
 case 107:
  CC_log_error(func, "This connect option (Set) is only used by the Driver Manager", conn);
  break;
 default:
  {
  char option[64];
  CC_set_error(conn, 205, "Unknown connect option (Set)");
  sprintf(option, "fOption=%d, vParam=%ld", fOption, vParam);
  CC_log_error(func, option, conn);
  return (-1);
  }
 }
 if (changed) {
  CC_set_error(conn, 213, "Requested value changed.");
  return 1;
 }
 else
  return 0;
}

variable_types:
hdbc
void *

variable_types: retval short

user_defined_types: enum CONN_Status { CONN_NOT_CONNECTED=0, CONN_CONNECTED=1, CONN_DOWN=2, CONN_EXECUTING=3 }

user_defined_types: struct ConnInfo { char dsn[256]; char desc[256]; char driver[256]; char server[256]; char database[256]; char username[256]; char password[256]; char conn_settings[4096]; char protocol[10]; char port[10]; char uds[4096]; char onlyread[10]; char fake_oid_index[10]; char show_oid_column[10]; char row_versioning[10]; char show_system_tables[10]; char translation_dll[256]; char translation_option[10]; char focus_password; }

user_defined_types: struct FIELD_INFO { struct TABLE_INFO *ti; int precision; int display_size; int length; int type; char nullable; char func; char expr; char quote; char dquote; char numeric; char dot[-1]; char name[-1]; char alias[-1]; }


SQLGetConnectOption

decompiled_code:
__int64 __fastcall SQLGetConnectOption(__int64 a1, unsigned __int16 a2, _QWORD *a3)
{
__int64 result; // rax
char v5[88]; // [rsp+0h] [rbp-58h] BYREF

mylog("%s: entering...\n", "SQLGetConnectOption");
if ( a1 )
{
switch ( a2 )
{
case 'e':
case 'g':
case 'o':
*a3 = 0LL;
result = 0LL;
break;
case 'f':
*a3 = *(_BYTE *)(a1 + 10466) & 1;
result = 0LL;
break;
case 'h':
case 'i':
case 'j':
case 'k':
case 'n':
CC_log_error("SQLGetConnectOption", "This connect option (Get) is only used by the Driver Manager", a1);
result = 0LL;
break;
case 'l':
*a3 = 8LL;
result = 0LL;
break;
case 'm':
result = 0LL;
if ( a3 )
*(_BYTE *)a3 = 0;
break;
case 'p':
*a3 = *(int *)&globals[4];
result = 0LL;
break;
default:
CC_set_error(a1, 205LL, "Unknown connect option (Get)");
sprintf(v5, "fOption=%d", a2);
CC_log_error("SQLGetConnectOption", v5, a1);
result = 0xFFFFFFFFLL;
break;
}
}
else
{
CC_log_error("SQLGetConnectOption", &LC10, 0LL);
result = 4294967294LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned __int16 a2, _QWORD *a3)
{
__int64 result; // rax
char v5[88]; // [rsp+0h] [rbp-58h] BYREF

mylog("%s: entering...\n", "SQLGetConnectOption");
if ( a1 )
{
switch ( a2 )
{
case 'e':
case 'g':
case 'o':
*a3 = 0LL;
result = 0LL;
break;
case 'f':
*a3 = *(_BYTE *)(a1 + 10466) & 1;
result = 0LL;
break;
case 'h':
case 'i':
case 'j':
case 'k':
case 'n':
CC_log_error("SQLGetConnectOption", "This connect option (Get) is only used by the Driver Manager", a1);
result = 0LL;
break;
case 'l':
*a3 = 8LL;
result = 0LL;
break;
case 'm':
result = 0LL;
if ( a3 )
*(_BYTE *)a3 = 0;
break;
case 'p':
*a3 = *(int *)&globals[4];
result = 0LL;
break;
default:
CC_set_error(a1, 205LL, "Unknown connect option (Get)");
sprintf(v5, "fOption=%d", a2);
CC_log_error("SQLGetConnectOption", v5, a1);
result = 0xFFFFFFFFLL;
break;
}
}
else
{
CC_log_error("SQLGetConnectOption", &LC10, 0LL);
result = 4294967294LL;
}
return result;
}

original_code:
RETCODE SQLGetConnectOption(
        HDBC hdbc,
        UWORD fOption,
        PTR pvParam)
{
static char* const func="SQLGetConnectOption";
ConnectionClass *conn = (ConnectionClass *) hdbc;
 mylog("%s: entering...\n", func);
 if (! conn) {
  CC_log_error(func, "", ((void *)0));
  return (-2);
 }
 switch (fOption) {
 case 101:
  *((UDWORD *) pvParam) = 0UL;
  break;
 case 102:
  *((UDWORD *)pvParam) = (UDWORD)( (conn->transact_status & 0x01) ?
      1UL : 0UL);
  break;
 case 109:
  if(pvParam) {
   ((char*)pvParam)[0]='\0';
  }
  break;
 case 103:
  *((UDWORD *) pvParam) = 0;
  break;
 case 112:
  *((UDWORD *) pvParam) = globals.socket_buffersize;
  break;
 case 111:
  *((UDWORD *) pvParam) = (UDWORD) ((void *)0);
  break;
 case 108:
  *((UDWORD *) pvParam) = 0x00000008L;
  break;
 case 110:
 case 104:
 case 105:
 case 106:
 case 107:
  CC_log_error(func, "This connect option (Get) is only used by the Driver Manager", conn);
  break;
 default:
  {
  char option[64];
  CC_set_error(conn, 205, "Unknown connect option (Get)");
  sprintf(option, "fOption=%d", fOption);
  CC_log_error(func, option, conn);
  return (-1);
  break;
  }
 }
 return 0;
}

canonical_original_code:
short SQLGetConnectOption(void *hdbc, unsigned short fOption, void *pvParam)
{
static char *func = "SQLGetConnectOption";
struct ConnectionClass_ *conn = (ConnectionClass *) hdbc;
 mylog("%s: entering...\n", func);
 if (! conn) {
  CC_log_error(func, "", ((void *)0));
  return (-2);
 }
 switch (fOption) {
 case 101:
  *((unsigned long *) pvParam) = 0UL;
  break;
 case 102:
  *((unsigned long *)pvParam) = (UDWORD)( (conn->transact_status & 0x01) ?
      1UL : 0UL);
  break;
 case 109:
  if(pvParam) {
   ((char *)pvParam)[0]='\0';
  }
  break;
 case 103:
  *((unsigned long *) pvParam) = 0;
  break;
 case 112:
  *((unsigned long *) pvParam) = globals.socket_buffersize;
  break;
 case 111:
  *((unsigned long *) pvParam) = (UDWORD) ((void *)0);
  break;
 case 108:
  *((unsigned long *) pvParam) = 0x00000008L;
  break;
 case 110:
 case 104:
 case 105:
 case 106:
 case 107:
  CC_log_error(func, "This connect option (Get) is only used by the Driver Manager", conn);
  break;
 default:
  {
  char option[64];
  CC_set_error(conn, 205, "Unknown connect option (Get)");
  sprintf(option, "fOption=%d", fOption);
  CC_log_error(func, option, conn);
  return (-1);
  break;
  }
 }
 return 0;
}

variable_types:
pvParam
void *

variable_types:
func
char *

user_defined_types: struct SocketClass_ { int buffer_filled_in; int buffer_filled_out; int buffer_read_in; unsigned char *buffer_in; unsigned char *buffer_out; int socket; char *errormsg; int errornumber; char reverse; }

user_defined_types: struct QResultClass_ { struct ColumnInfoClass_ *fields; struct TupleListClass_ *manual_tuples; struct ConnectionClass_ *conn; int fetch_count; int fcount; int currTuple; int base; int num_fields; int cache_size; int rowset_size; enum QueryResultCode_ status; char *message; char *cursor; char *command; char *notice; struct TupleField_ *backend_tuples; struct TupleField_ *tupleField; char inTuples; char aborted; }

user_defined_types: struct col_info { struct QResultClass_ *result; char name[-1]; }