1 /* 2 * henv.c 3 * 4 * $Id: henv.c 2613 1999-06-01 15:32:12Z VZ $ 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 27 #include "config.h" 28 29 #include "isql.h" 30 #include "isqlext.h" 31 32 #include "dlproc.h" 33 34 #include "herr.h" 35 #include "henv.h" 36 37 #include "itrace.h" 38 39 RETCODE SQL_API SQLAllocEnv(HENV FAR * phenv)40SQLAllocEnv (HENV FAR * phenv) 41 { 42 GENV_t FAR *genv; 43 44 genv = (GENV_t *) MEM_ALLOC (sizeof (GENV_t)); 45 46 if (genv == NULL) 47 { 48 *phenv = SQL_NULL_HENV; 49 50 return SQL_ERROR; 51 } 52 53 #if (ODBCVER >= 0x0300 ) 54 genv->type = SQL_HANDLE_ENV; 55 #endif 56 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 */ 60 61 *phenv = (HENV) genv; 62 63 return SQL_SUCCESS; 64 } 65 66 67 RETCODE SQL_API SQLFreeEnv(HENV henv)68SQLFreeEnv (HENV henv) 69 { 70 GENV_t FAR *genv = (GENV_t *) henv; 71 72 if (henv == SQL_NULL_HENV) 73 { 74 return SQL_INVALID_HANDLE; 75 } 76 77 if (genv->hdbc != SQL_NULL_HDBC) 78 { 79 PUSHSQLERR (genv->herr, en_S1010); 80 81 return SQL_ERROR; 82 } 83 84 _iodbcdm_freesqlerrlist (genv->herr); 85 86 MEM_FREE (henv); 87 88 return SQL_SUCCESS; 89 } 90