.CM  SCRIPT , Version - 1.1 , last edited by holger
.pa
.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 1998-2005 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.TT 1 $SQL$Project Distributed Database System$VIN021$
.tt 2 $$$
.TT 3 $$non_db_init$1998-05-29$
***********************************************************
.nf

.nf

.nf

    ========== licence begin  GPL
    Copyright (c) 1998-2005 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


.fo
.nf
.sp
MODULE  : non_db_init
=========
.sp
Purpose : Allocation and initialization of the global variable I01G.
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :

        PROCEDURE
              i021init (
                    VAR g_area : tin_global_in_vars );

        FUNCTION
              in02130 : tsp00_Int4;

.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :

&       ifdef WINDOWS
        FROM
              Windows_RTE_Extension : VEN102W ;

        FUNCTION
              sqlwmalloc (
                    size : tsp00_Int4) : tsp00_Int4;

        FUNCTION
              sqlwmlock (
                    handle : tsp00_Int4) : tin_global_in_vars;
&       endif

.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :

        PROCEDURE
              sqlwmlock;

              tsp00_ObjAddr tin_global_in_vars

.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : 
.sp
.cp 3
Created : 1985-04-19
.sp
.cp 3
Version : 1998-05-29
.sp
.cp 3
Release :      Date : 1998-05-29
.sp
***********************************************************
.sp
.cp 20
.fo
.oc _/1
Specification:

.CM *-END-* specification -------------------------------
.sp 2.fo
***********************************************************
.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
.oc _/1
.CM -lll-
Code    :


&ifdef WINDOWS
VAR
      i02handle : tsp00_Int4;
&     endif


(*------------------------------*)

FUNCTION
      in02130 : tsp00_Int4;

BEGIN
(* linkcheck function *)
in02130 := 219020526;
END;

(*------------------------------*)

PROCEDURE
      i021init (
            VAR g_area : tin_global_in_vars );

VAR
      i : integer;
      j : integer;

BEGIN
i021getgp (g_area);
i021inigp (g_area, g_area^.global_end);
WITH g_area^ DO
    BEGIN
    FOR i := 1 TO mxin_dbs DO
        WITH session [i] DO
            BEGIN
            is_connected   := FALSE;
            connect_status := rc_ok;
            as_utility     := FALSE;
            nolog_session  := FALSE;
            is_unicode_db  := FALSE;
            curr_packet    := 1;
            packet_nesting := 0;
            FOR j := 1 TO cin_maxpackets DO
                WITH packet_control [j] DO
                    BEGIN
                    snd_packet_ptr := NIL;
                    rcv_packet_ptr := NIL;
                    curr_segm_ptr  := NIL;
                    curr_part_ptr  := NIL;
                    packet_stat    := p_waiting;
                    END;
                (*ENDWITH*)
            (*ENDFOR*)
            END;
        (*ENDWITH*)
    (*ENDFOR*)
    dbno := 1;
    END;
(*ENDWITH*)
WITH g_area^ DO
    BEGIN
    session [1].symbolic_dbname := session [1].serverdb;
    session [1].is_connected := true;
    FOR i := 2 TO mxin_dbs DO
        BEGIN
        session [i].is_connected := false;
        session [i].symbolic_dbname := bsp_dbname;
        session [i].serverdb := bsp_dbname;
        session [i].service  := sql_user;
        session [i].connect_status := rc_ok;
        END;
    (*ENDFOR*)
    session [dbno].service := sql_user;
    END;
(*ENDWITH*)
g_area^.i20.swap := i021swapkind;
IF  ord (' ') = 32
THEN
    g_area^.i20.code_type := csp_ascii
ELSE
    g_area^.i20.code_type := csp_ebcdic;
(*ENDIF*)
WITH g_area^.multibyte DO
    BEGIN
    encodings_ptr   := NIL;
    encoding_cnt    := 0;
    dblang          := bsp_c64;
    dblang_idx      := 0;
    IF  i021swapkind = sw_normal
    THEN
        unicode_type := csp_unicode
    ELSE
        unicode_type := csp_unicode_swap;
    (*ENDIF*)
    END;
(*ENDWITH*)
END; (* i021init *)

(*------------------------------*)

PROCEDURE
      i021getgp (
            VAR p : tin_global_in_vars);

BEGIN
&ifdef WINDOWS
i02handle := sqlwmalloc( sizeof (p^) );
p := sqlwmlock( i02handle );
&else
new(p);
&endif
END;

(*------------------------------*)

PROCEDURE
      i021inigp (
            VAR p     : tin_global_in_vars;
            VAR pende : integer);

BEGIN
END;

(*------------------------------*)

FUNCTION
      i021swapkind : tsp00_SwapKind;

VAR

      i4c4 : RECORD
            CASE  boolean OF
                true :
                    (iiii : tsp00_Int4);
                false :
                    (cccc : tsp00_C4);
                END;
            (*ENDCASE*)


BEGIN
WITH i4c4 DO
    BEGIN
    iiii := 1;
    IF  cccc  [4]  = chr (1)
    THEN
        i021swapkind := sw_normal
    ELSE
        IF  cccc  [1]  = chr (1)
        THEN
            i021swapkind := sw_full_swapped
        ELSE
            i021swapkind := sw_part_swapped;
        (*ENDIF*)
    (*ENDIF*)
    END;
(*ENDWITH*)
END; (* i021swapkind *)

.CM *-END-* code ----------------------------------------
.SP 2
***********************************************************
*-PRETTY-*  statements    :         53
*-PRETTY-*  lines of code :        155        PRETTYX 3.10
*-PRETTY-*  lines in file :        271         1997-12-10
.PA
