]> git.saurik.com Git - wxWidgets.git/blob - src/iodbc/henv.c
added ODBC support
[wxWidgets.git] / src / iodbc / henv.c
1 /** Environment object managment functions
2
3 Copyright (C) 1995 by Ke Jin <kejin@empress.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 **/
15
16 #include <../iodbc/iodbc.h>
17
18 #include <../iodbc/isql.h>
19 #include <../iodbc/isqlext.h>
20
21 #include <../iodbc/dlproc.h>
22
23 #include <../iodbc/herr.h>
24 #include <../iodbc/henv.h>
25
26 #include <../iodbc/itrace.h>
27
28 RETCODE SQL_API SQLAllocEnv( HENV FAR* phenv )
29 {
30 GENV_t FAR* genv;
31
32 genv = (GENV_t*)MEM_ALLOC( sizeof(GENV_t) );
33
34 if( genv == NULL )
35 {
36 *phenv = SQL_NULL_HENV;
37
38 return SQL_ERROR;
39 }
40
41 #if (ODBCVER >= 0x0300 )
42 genv->type = SQL_HANDLE_ENV;
43 #endif
44
45 genv->henv = SQL_NULL_HENV; /* driver's env list */
46 genv->hdbc = SQL_NULL_HDBC; /* driver's dbc list */
47 genv->herr = SQL_NULL_HERR; /* err list */
48
49 *phenv = (HENV)genv;
50
51 return SQL_SUCCESS;
52 }
53
54 RETCODE SQL_API SQLFreeEnv ( HENV henv )
55 {
56 GENV_t FAR* genv = (GENV_t*)henv;
57
58 if( henv == SQL_NULL_HENV )
59 {
60 return SQL_INVALID_HANDLE;
61 }
62
63 if( genv->hdbc != SQL_NULL_HDBC )
64 {
65 PUSHSQLERR ( genv->herr, en_S1010 );
66
67 return SQL_ERROR;
68 }
69
70 _iodbcdm_freesqlerrlist( genv->herr );
71
72 MEM_FREE( henv );
73
74 return SQL_SUCCESS;
75 }