.CM *ID* VSP70    VDN      changed on 1992-10-20-07.11.43 by CARSTEN   *
.CM  SCRIPT , Version - 1.1 , last edited by peter
.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 1997-2004 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VSP70$
.tt 2 $$$
.tt 3 $$RTE-Extension-70$1997-02-07$
***********************************************************
.nf

.nf


    ========== licence begin  GPL
    Copyright (c) 1997-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
.nf
.sp
Module  : RTE-Extension-70
=========
.sp
Purpose : Analyze EXEC Command String and Return SQLEXEC Params,
          Interface SQL-PL / Precompiler for the Handling of
          Terminal Attributes.
 
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              s70execanalyze (VAR cmd : tsp00_Buf;
                    cmdl              : tsp00_Int2;
                    VAR ex_command    : tsp00_ExecLine;
                    VAR ex_mode       : tsp00_ExecMode;
                    VAR spec_complete : boolean);
 
        PROCEDURE
              s70attrtoint1 ( attr : tsp00_VtAttrib; VAR integ : tsp00_Uint1 );
 
        PROCEDURE
              s70int1toattr (VAR attr : tsp00_VtAttrib; integ : tsp00_Uint1 );
 
        PROCEDURE
              s70colorint1 ( attr : tsp00_VtColor; VAR integ : tsp00_Uint1 );
 
        PROCEDURE
              s70int1color (VAR attr : tsp00_VtColor; integ : tsp00_Uint1 );
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              Kernel_move_and_fill : VGG101;
 
        PROCEDURE
              SAPDB_PascalForcedFill (
                    size        : tsp00_Int4;
                    m           : tsp00_MoveObjPtr;
                    pos         : tsp00_Int4;
                    len         : tsp00_Int4;
                    fillchar    : char);
 
        PROCEDURE
              SAPDB_PascalForcedMove (
                    source_upb  : tsp00_Int4;
                    destin_upb  : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;
                    source_pos  : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;
                    destin_pos  : tsp00_Int4;
                    length      : tsp00_Int4);
 
        PROCEDURE
              s10mv (
                    source_upb  : tsp00_Int4;       
                    destin_upb  : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;    
                    source_pos  : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;    
                    destin_pos  : tsp00_Int4;
                    length      : tsp00_Int4);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : 
.sp
.cp 3
Created : 1989-08-14
.sp
.cp 3
Version : 1997-02-07
.sp
.cp 3
Release :  6.2 	 Date : 1997-02-07
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
DIALOG, Precompiler programs and other dialog components
can use this procedure to analyze a command line and get
the parameters needed for the sqlexec RTE procedure
(progname, arguments, exec-mode). SPEC_COMPLETE is true if
the command consists not only of these parameters but is
introduced by one of the possible exec keywords.
.sp;.nf
The following formats are recognized as "exec" sign:
.sp
!<command>   <=> synchronous (UNIX) call opening new session
!&<command>  <=> asynchronous (UNIX) call
 
exec <command>         <=> general call
exec async <command>   <=> general call, asynchrous execution wanted
 
cms <command>         <=> CMS call
cms <async command>   <=> CMS call, asynchrous execution wanted
 
<command> ::= <programname> <arguments>
.fo
.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
.oc _/1
.CM -lll-
Code    :
 
 
&if $os in [ unix, os2, win32, msdos ]
(*------------------------------*) 
 
PROCEDURE
      s70execanalyze (VAR cmd : tsp00_Buf;
            cmdl              : tsp00_Int2;
            VAR ex_command    : tsp00_ExecLine;
            VAR ex_mode       : tsp00_ExecMode;
            VAR spec_complete : boolean);
 
VAR
      pos           : integer;
      found         : boolean;
 
BEGIN
SAPDB_PascalForcedFill (sizeof (ex_command), @ex_command, 1, sizeof (ex_command),
      bsp_c1);
ex_mode := sync_new_session;
spec_complete := false;
pos := 1;
sp70_next_nonblank (cmd, cmdl, pos, found);
IF  found
THEN
    BEGIN
    IF  cmd [ pos ] = '!'
    THEN
        BEGIN
        spec_complete := true;
        pos := pos + 1;
        sp70_next_nonblank (cmd, cmdl, pos, found);
        IF  found
        THEN
            IF  (cmd [ pos ] = '&')
            THEN
                BEGIN
                ex_mode := async;
                pos := pos + 1;
                END;
            (*ENDIF*) 
        (*ENDIF*) 
        END
    ELSE
        sp70_check_exec (cmd, cmdl, pos, spec_complete, ex_mode);
    (*ENDIF*) 
    END;
(*ENDIF*) 
IF  pos <= cmdl
THEN
    s10mv (sizeof (cmd), sizeof (ex_command),
          @cmd, pos, @ex_command, 1, cmdl - pos + 1);
(*ENDIF*) 
END; (* s70execanalyze *)
 
&else
(*------------------------------*) 
 
PROCEDURE
      s70execanalyze (VAR cmd : tsp00_Buf;
            cmdl              : tsp00_Int2;
            VAR ex_command    : tsp00_ExecLine;
            VAR ex_mode       : tsp00_ExecMode;
            VAR spec_complete : boolean);
 
VAR
      pos           : integer;
      found         : boolean;
 
BEGIN
SAPDB_PascalForcedFill (sizeof (ex_command), @ex_command, 1, sizeof (ex_command),
      bsp_c1);
ex_mode := sync_same_session;
spec_complete := false;
pos := 1;
sp70_next_nonblank (cmd, cmdl, pos, found);
sp70_check_exec (cmd, cmdl, pos, spec_complete, ex_mode);
&if $os = vmsp
IF  NOT spec_complete
THEN
    sp70_check_cms (cmd, cmdl, pos, spec_complete);
&endif
(*ENDIF*) 
IF  pos <= cmdl
THEN
    BEGIN
    sp70_next_nonblank (cmd, cmdl, pos, found);
    IF  found
    THEN
        s10mv (sizeof (cmd), sizeof (ex_command),
              @cmd, pos, @ex_command, 1, cmdl - pos + 1);
    (*ENDIF*) 
    END;
(*ENDIF*) 
END; (* s70execanalyze *)
 
&endif
(*------------------------------*) 
 
PROCEDURE
      sp70_check_exec (VAR cmd     : tsp00_Buf;
            cmdl              : tsp00_Int2;
            VAR pos           : integer;
            VAR spec_complete : boolean;
            VAR ex_mode       : tsp00_ExecMode);
 
VAR
      found : boolean;
 
BEGIN
IF  cmdl >= pos + 3
THEN
    IF  (cmd [ pos ] in [ 'e', 'E' ])
        AND (cmd [ pos + 1 ] in [ 'x', 'X' ])
        AND (cmd [ pos + 2 ] in [ 'e', 'E' ])
        AND (cmd [ pos + 3 ] in [ 'c', 'C' ])
    THEN
        BEGIN
        pos := pos + 4;
        spec_complete := true;
        END;
    (*ENDIF*) 
(*ENDIF*) 
IF  spec_complete
THEN
    BEGIN
    sp70_next_nonblank (cmd, cmdl, pos, found);
&   if $os in [ unix, os2, win32, msdos ]
    IF  found AND (cmdl >= pos + 4)
    THEN
        IF  (cmd [ pos ] in [ 'a', 'A' ])
            AND (cmd [ pos + 1 ] in [ 's', 'S' ])
            AND (cmd [ pos + 2 ] in [ 'y', 'Y' ])
            AND (cmd [ pos + 3 ] in [ 'n', 'N' ])
            AND (cmd [ pos + 4 ] in [ 'c', 'C' ])
        THEN
            BEGIN
            ex_mode := async;
            pos := pos + 5;
            sp70_next_nonblank (cmd, cmdl, pos, found);
            END;
&       endif
        (*ENDIF*) 
    (*ENDIF*) 
    END;
(*ENDIF*) 
END; (* sp70_check_exec *)
 
(*------------------------------*) 
 
PROCEDURE
      sp70_check_cms (VAR cmd      : tsp00_Buf;
            cmdl              : tsp00_Int2;
            VAR pos           : integer;
            VAR spec_complete : boolean);
 
VAR
      found : boolean;
 
BEGIN
IF  cmdl >= pos + 2
THEN
    IF  (cmd [ pos ] in [ 'c', 'C' ])
        AND (cmd [ pos + 1 ] in [ 'm', 'M' ])
        AND (cmd [ pos + 2 ] in [ 's', 'S' ])
    THEN
        BEGIN
        pos := pos + 3;
        spec_complete := true;
        sp70_next_nonblank (cmd, cmdl, pos, found);
        END;
    (*ENDIF*) 
(*ENDIF*) 
END; (* sp70_check_cms *)
 
(*------------------------------*) 
 
PROCEDURE
      sp70_next_nonblank (VAR cmd : tsp00_Buf;
            cmdl      : tsp00_Int2;
            VAR pos   : integer;
            VAR found : boolean);
 
BEGIN
found := false;
WHILE (pos <= cmdl) AND NOT found DO
    IF  cmd [ pos ] = bsp_c1
    THEN
        pos := pos + 1
    ELSE
        found := true;
    (*ENDIF*) 
(*ENDWHILE*) 
END; (* sp70_next_nonblank *)
 
(*------------------------------*) 
 
PROCEDURE
      s70attrtoint1 ( attr : tsp00_VtAttrib; VAR integ : tsp00_Uint1 );
 
VAR
      vtm : tsp00_VtMode;
      increment : tsp00_Uint1;
 
BEGIN
integ := 0;
IF  attr <> [  ]
THEN
    FOR vtm := vt_bright TO vt_mixed DO
        BEGIN
        IF  vtm = vt_bright
        THEN
            increment := 1
        ELSE
            increment := increment * 2;
        (*ENDIF*) 
        IF  vtm IN attr
        THEN
            integ := integ + increment;
        (*ENDIF*) 
        END;
    (*ENDFOR*) 
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      s70int1toattr (VAR attr : tsp00_VtAttrib; integ : tsp00_Uint1 );
 
VAR
      vtm : tsp00_VtMode;
      increment : tsp00_Uint1;
 
BEGIN
increment := 32; (* means vt_mixed last of 6 vt_mode *)
attr := [  ];
FOR vtm := vt_mixed  DOWNTO vt_bright DO
    BEGIN
    IF  integ >= increment
    THEN
        BEGIN
        integ := integ - increment;
        attr := attr + [ vtm ];
        END;
    (*ENDIF*) 
    increment := increment DIV 2;
    END;
(*ENDFOR*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      s70colorint1 ( attr : tsp00_VtColor; VAR integ : tsp00_Uint1 );
 
BEGIN
integ := ord(attr);
END;
 
(*------------------------------*) 
 
PROCEDURE
      s70int1color (VAR attr : tsp00_VtColor; integ : tsp00_Uint1 );
 
BEGIN
CASE integ OF
    0 :
        attr := vt_default_color;
    1 :
        attr := vt_white;
    2 :
        attr := vt_black;
    3 :
        attr := vt_red;
    4 :
        attr := vt_green;
    5 :
        attr := vt_yellow;
    6 :
        attr := vt_blue;
    7 :
        attr := vt_pink;
    8 :
        attr := vt_light_blue;
    OTHERWISE:
        attr := vt_default_color;
    END;
(*ENDCASE*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :         77
*-PRETTY-*  lines of code :        288        PRETTY  3.09 
*-PRETTY-*  lines in file :        447         1992-11-23 
.PA 
