.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 2000-2004 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VPR03CAC$
.tt 2 $$$
.tt 3 $$SQLCA Initialisierung$2000-09-05$
***********************************************************
.nf

.nf


    ========== licence begin  GPL
    Copyright (c) 2000-2004 SAP AG

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end

.fo


.fo
Module  :
=========
.sp
Purpose :
.CM *-END-* purpose -------------------------------------
Define  :

#include "vpr01Module.h"

typedef struct {
sqlgatype sqlga;
sqlgaentry sqlgae [sqlgamax];
sqlratype sqlra;
sqltatype sqlta;
sqloatype sqloa;
sqlmatype sqlma;
sqlmftype sqlmf;
sqlcxatype sqlcxa;
struct SQLERROR sqlem;
} p03sqlareas;

void *p03caci (sqlcatype *sqlcar, sqlxatype *sqlxar, 
               tpr01_Precompiledfor pcfor);

.CM *-END-* define --------------------------------------
Use     :
.CM *-END-* use -----------------------------------------
Synonym :
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : 
.sp
.cp 3
Created : 1996-08-29
.sp
.cp 3
Version : 1996-08-29
.sp
.cp 3
Release :      Date : 2000-09-05
Specification:
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.sp
.CM -lll-
Code    :
/* PRETTY */
/* -------------------------------- */
/*				    */
/*  Initialize external variables   */
/*				    */
/* -------------------------------- */

#ifndef SQLODBC
static p03sqlareas sqlarea;
#endif
tpr01_EnvContainer *sqlEnvCont=NULL;

void *p03caci (sqlcatype *sqlcar, sqlxatype *sqlxar, 
               tpr01_Precompiledfor pcfor)
{
  int i;
  p03sqlareas *p;
#ifndef SQLODBC
  p = &sqlarea;
#else
  p = pr03mAllocat(sizeof(p03sqlareas), "sqlarea");
  if (!p)
    return(NULL);
  memset(p, 0, sizeof(p03sqlareas));
#endif	
  if (p) {
    if (sqlxar)
      p->sqlra.ralang = sqlxar->xalang;
    p->sqlra.rasqltap = &p->sqlta;
    p->sqlra.rasqlldp = NULL;
    p->sqlra.raprofstmtp = NULL;
    memset (&p->sqlmf, 0, sizeof (sqlmftype));
    for (i = 0; i < sqlgamax; i++)
      p->sqlga.gaentry [i] = &p->sqlgae[i];

    sqlcar->sqlgap = &p->sqlga;
    sqlcar->sqlrap = &p->sqlra;
    sqlcar->sqloap = &p->sqloa;
    sqlcar->sqlmap = &p->sqlma;
    sqlcar->sqlmfp = &p->sqlmf;
    sqlcar->sqlemp = &p->sqlem;
    sqlcar->sqlcxap = &p->sqlcxa;
    sqlcar->sqlplp = NULL;
	
    sqlcar->sqlxadesc.descNelem = 0;
    sqlcar->sqlxadesc.descMaxelem = 0;
    sqlcar->sqlxadesc.descElemSize = sizeof (void*);
    sqlcar->sqlxadesc.descIncr = 32;
    sqlcar->sqlxadesc.descElemPtr = NULL;
    if (!sqlcar->sqlEnvDesc) {
      if (!sqlEnvCont) {
        sqlEnvCont = pr01EnvNewCont();
      }
      sqlcar->sqlEnvDesc = sqlEnvCont->AddDesc(sqlEnvCont, sqlcar);
    }
#ifdef SQLODBC
    sqlxar = (sqlxatype *) sqlcar->sqlcxap;  /* PTS 1110487 */
#endif
    if (!sqlxar->xaModDesc) {
      tpr01_ModuleContainer *Module = sqlcar->sqlEnvDesc->Module;
      sqlxar->xaModDesc = Module->AddDesc(Module, sqlxar);
      sqlxar->xaModDesc->PrecompiledforUnicode = pcfor;	
    }
  }
  return(p);
}

void p03EnvDelete( sqlcatype *sqlcar )
{
  if (sqlEnvCont && sqlcar->sqlEnvDesc ) {
    tpr01_ConContainer *Connection = sqlcar->sqlEnvDesc->Connection;
    /* PTS 1104786 */
    if (Connection->GetCount(Connection) == 0) {
      sqlEnvCont->DeleteDesc( sqlcar->sqlEnvDesc );
      sqlcar->sqlEnvDesc = NULL;
      if (!sqlEnvCont->GetCount(sqlEnvCont)) { /* last envDesc ? */
	pr01EnvDeleteCont(sqlEnvCont);
	sqlEnvCont = NULL;
      }
    }
  }
}

void p03EnvClear( sqlcatype *sqlcar )
{
  if (sqlEnvCont && sqlcar->sqlEnvDesc ) {
    tpr01_ConContainer *Connection = sqlcar->sqlEnvDesc->Connection;
    if (Connection->GetCount(Connection) == 0) {
          Connection->EmptyCont(Connection);
    }
  }
}
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
