1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2002-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20 21% 22%% 23 24%% Path to the c-program. 25-define(SERVERDIR, filename:nativename( 26 filename:join(code:priv_dir(odbc), "bin"))). 27 28%% Name of the C program 29-define(SERVERPROG, "odbcserver"). 30 31%% Constats defining the command protocol between the erlang control 32%% process and the port program. These constants must also be defined 33%% in the same way in the port program. 34 35-define(OPEN_CONNECTION, 1). 36-define(CLOSE_CONNECTION, 2). 37-define(COMMIT_TRANSACTION, 3). 38-define(COMMIT, 4). 39-define(ROLLBACK, 5). 40-define(QUERY, 6). 41-define(SELECT_COUNT, 7). 42-define(SELECT_FIRST, 8). 43-define(SELECT_LAST, 9). 44-define(SELECT_NEXT, 10). 45-define(SELECT_PREV, 11). 46-define(SELECT, 12). 47-define(SELECT_RELATIVE, 13). 48-define(SELECT_ABSOLUTE, 14). 49-define(SELECT_N_NEXT, 15). 50-define(PARAM_QUERY, 16). 51-define(DESCRIBE, 17). 52-define(SHUTDOWN, 18). 53-define(LENGTH_INDICATOR_SIZE, 4). 54-define(INT_VALUE, 1). 55-define(STR_VALUE, 2). 56-define(ON, 1). 57-define(OFF, 2). 58-define(DUMMY_OFFSET, 0). 59 60 61%% Types of parameters given to param_query 62-define(USER_SMALL_INT, 1). 63-define(USER_INT, 2). 64-define(USER_DECIMAL, 3). 65-define(USER_NUMERIC, 4). 66-define(USER_CHAR, 5). 67-define(USER_VARCHAR, 6). 68-define(USER_FLOAT, 7). 69-define(USER_REAL, 8). 70-define(USER_DOUBLE, 9). 71-define(USER_BOOLEAN, 10). 72-define(USER_TINY_INT, 11). 73-define(USER_WCHAR, 12). 74-define(USER_WVARCHAR, 13). 75-define(USER_TIMESTAMP, 14). 76-define(USER_WLONGVARCHAR, 15). 77 78%% INPUT & OUTPUT TYPE 79-define(IN, 0). 80-define(OUT, 1). 81-define(INOUT, 2). 82 83%% EXIT CODES 84-define(EXIT_SUCCESS, 0). % As defined in c iso_stdlib 85-define(EXIT_FAILURE, 1). % As defined in c iso_stdlib 86-define(EXIT_ALLOC, 2). 87-define(EXIT_ENV, 3). 88-define(EXIT_CONNECTION, 4). 89-define(EXIT_FREE, 5). 90-define(EXIT_STDIN_HEADER, 6). 91-define(EXIT_STDIN_BODY, 7). 92-define(EXIT_BIN, 8). 93-define(EXIT_THREAD, 9). 94-define(EXIT_PARAM_ARRAY, 10). 95-define(EXIT_OLD_WINSOCK, 11). 96-define(EXIT_SOCKET_CONNECT, 12). 97-define(EXIT_SOCKET_SEND_HEADER, 13). 98-define(EXIT_SOCKET_SEND_BODY, 14). 99-define(EXIT_SOCKET_RECV_MSGSIZE,15). 100-define(EXIT_SOCKET_SEND_MSGSIZE,16). 101-define(EXIT_SOCKET_RECV_HEADER, 17). 102-define(EXIT_SOCKET_RECV_BODY, 18). 103-define(EXIT_COLS, 19). 104-define(EXIT_ROWS, 20). 105-define(EXIT_DESC, 21). 106-define(EXIT_BIND, 22). 107-define(EXIT_DRIVER_INFO, 23). 108 109%% Misc constants 110-define(DEFAULT_TIMEOUT, infinity). 111-define(STR_TERMINATOR, 0). 112-define(MAX_SEQ_TIMEOUTS, 10). 113 114%% Handling of C exit codes 115-define(ENCODE_EXIT_FUN, 116 (fun(?EXIT_SUCCESS) -> 117 normal_exit; 118 (?EXIT_FAILURE) -> 119 abnormal_exit; 120 (?EXIT_ALLOC) -> 121 memory_allocation_failed; 122 (?EXIT_ENV) -> 123 setting_of_environment_attributes_failed; 124 (?EXIT_CONNECTION) -> 125 setting_of_connection_attributes_faild; 126 (?EXIT_FREE) -> 127 freeing_of_memory_failed; 128 (?EXIT_STDIN_HEADER) -> 129 receiving_port_message_header_failed; 130 (?EXIT_STDIN_BODY) -> 131 receiving_port_message_body_failed; 132 (?EXIT_BIN) -> 133 retrieving_of_binary_data_failed; 134 (?EXIT_THREAD) -> 135 failed_to_create_thread; 136 (?EXIT_PARAM_ARRAY) -> 137 does_not_support_param_arrays; 138 (?EXIT_OLD_WINSOCK) -> 139 too_old_verion_of_winsock; 140 (?EXIT_SOCKET_CONNECT) -> 141 socket_connect_failed; 142 (?EXIT_SOCKET_SEND_HEADER) -> 143 socket_send_message_header_failed; 144 (?EXIT_SOCKET_SEND_BODY) -> 145 socket_send_message_body_failed; 146 (?EXIT_SOCKET_RECV_MSGSIZE) -> 147 socket_received_too_large_message; 148 (?EXIT_SOCKET_SEND_MSGSIZE) -> 149 too_large_message_in_socket_send; 150 (?EXIT_SOCKET_RECV_HEADER) -> 151 socket_receive_message_header_failed; 152 (?EXIT_SOCKET_RECV_BODY) -> 153 socket_receive_message_body_failed; 154 (?EXIT_COLS) -> 155 could_not_access_column_count; 156 (?EXIT_ROWS) -> 157 could_not_access_row_count; 158 (?EXIT_DESC) -> 159 could_not_access_table_description; 160 (?EXIT_BIND) -> 161 could_not_bind_data_buffers; 162 (?EXIT_DRIVER_INFO) -> 163 collecting_of_driver_information_faild; 164 (_) -> 165 killed 166 end)). 167 168-define(PORT_EXIT_REASON(EXIT_STATUS), 169 ?ENCODE_EXIT_FUN(EXIT_STATUS)). 170