]> git.saurik.com Git - wxWidgets.git/blame - src/iodbc/henv.c
rtti api mods added
[wxWidgets.git] / src / iodbc / henv.c
CommitLineData
cd5bf2a6
RR
1/*
2 * henv.c
3 *
4 * $Id$
5 *
6 * Environment object management functions
7 *
8 * The iODBC driver manager.
9 *
10 * Copyright (C) 1995 by Ke Jin <kejin@empress.com>
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
88ac883a 27#include "config.h"
cd5bf2a6 28
88ac883a
VZ
29#include "isql.h"
30#include "isqlext.h"
cd5bf2a6 31
88ac883a 32#include "dlproc.h"
cd5bf2a6 33
88ac883a
VZ
34#include "herr.h"
35#include "henv.h"
cd5bf2a6 36
88ac883a 37#include "itrace.h"
cd5bf2a6
RR
38
39RETCODE SQL_API
40SQLAllocEnv (HENV FAR * phenv)
1a6944fd 41{
cd5bf2a6 42 GENV_t FAR *genv;
1a6944fd 43
cd5bf2a6 44 genv = (GENV_t *) MEM_ALLOC (sizeof (GENV_t));
1a6944fd 45
cd5bf2a6
RR
46 if (genv == NULL)
47 {
48 *phenv = SQL_NULL_HENV;
1a6944fd 49
cd5bf2a6
RR
50 return SQL_ERROR;
51 }
1a6944fd
RR
52
53#if (ODBCVER >= 0x0300 )
cd5bf2a6 54 genv->type = SQL_HANDLE_ENV;
1a6944fd
RR
55#endif
56
cd5bf2a6
RR
57 genv->henv = SQL_NULL_HENV; /* driver's env list */
58 genv->hdbc = SQL_NULL_HDBC; /* driver's dbc list */
59 genv->herr = SQL_NULL_HERR; /* err list */
1a6944fd 60
cd5bf2a6 61 *phenv = (HENV) genv;
1a6944fd 62
cd5bf2a6 63 return SQL_SUCCESS;
1a6944fd
RR
64}
65
cd5bf2a6
RR
66
67RETCODE SQL_API
68SQLFreeEnv (HENV henv)
1a6944fd 69{
cd5bf2a6 70 GENV_t FAR *genv = (GENV_t *) henv;
1a6944fd 71
cd5bf2a6
RR
72 if (henv == SQL_NULL_HENV)
73 {
74 return SQL_INVALID_HANDLE;
75 }
1a6944fd 76
cd5bf2a6
RR
77 if (genv->hdbc != SQL_NULL_HDBC)
78 {
79 PUSHSQLERR (genv->herr, en_S1010);
1a6944fd 80
cd5bf2a6
RR
81 return SQL_ERROR;
82 }
1a6944fd 83
cd5bf2a6 84 _iodbcdm_freesqlerrlist (genv->herr);
1a6944fd 85
cd5bf2a6 86 MEM_FREE (henv);
1a6944fd 87
cd5bf2a6 88 return SQL_SUCCESS;
1a6944fd 89}