/* @lastChanged: "1998-02-16 12:00"
 
 * @filename:   vta12
 * @purpose:    "TA_write_protfile"
 * @release:    7.1.0.0
 * @see:        "-.-"
 *
 * @Copyright (c) 1998-2005 SAP AG"
 */
 
.tt 1 $SAP$LiveCache$VTA12$
.tt 3 $$TA_write_protfile$1998-05-25$
 
.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
***********************************************************
 
Module  : TA_write_protfile
 
Define  :
 
        PROCEDURE
              t12create_prot (VAR protfile : tut_vf_fileref);
 
        PROCEDURE
              t12fncreate_prot (VAR protfile : tut_vf_fileref;
                    fn          : tsp00_VFilename;
                    append      : boolean;
                    VAR errtext : tsp00_ErrText;
                    VAR error   : integer);
 
        PROCEDURE
              t12write_prot (VAR protfile : tut_vf_fileref;
                    VAR ln    : tsp00_Line;
                    length    : integer;
                    VAR error : integer);
 
        PROCEDURE
              t12close_prot (VAR protfile : tut_vf_fileref);
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              RTE_driver : VEN102;
 
        PROCEDURE
              sqlos (VAR os : tsp00_Os);
 
        PROCEDURE
              sqlfclosep (
                    fhandle : tsp00_Int4;
                    option  : tsp05_RteCloseOption;
                    VAR err : tsp05_RteFileError);
 
        PROCEDURE
              sqlfopenp (
                    VAR fname   : tsp00_VFilename;
                    datakind    : tsp05_RteDataKind;
                    filemode    : tsp05_RteFileMode;
                    buffering   : tsp05_RteBufferingKind;
                    VAR fhandle : tsp00_Int4;
                    VAR err     : tsp05_RteFileError);
 
        PROCEDURE
              sqlfwritep (
                    fhandle : tsp00_Int4;
                    VAR buf : tsp00_Line;
                    inlen   : tsp00_Longint;
                    VAR err : tsp05_RteFileError);
 
        PROCEDURE
              sqltermid (VAR terminalid : tsp00_TermId);
 
        PROCEDURE
              sqlwrite (VAR ln : tsp00_Line);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              sqlfwritep;
 
              tsp00_MoveObj tsp00_Line
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : JuergenA
.sp
.cp 3
Created : 1983-07-07
.sp
.cp 3
Version : 2002-03-04
.sp
.cp 3
Release :      Date : 1998-05-25
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
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
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      c_append = true;
 
 
(*------------------------------*) 
 
PROCEDURE
      t12create_prot (VAR protfile : tut_vf_fileref);
 
CONST
      prot_os2      = 'ci.prt            ';
      prot_unix     = 'ci.prt            ';
      prot_windows  = 'ci.prt            ';
      prot_win32    = 'ci.prt            ';
      prot_vms      = 'RVX_CI_DN         ';
 
VAR
      os          : tsp00_Os;
      i           : integer;
      err         : integer;
      start_pos   : integer;
      end_pos     : integer;
      n           : tsp00_Name;
      n_extension : tsp00_Name;
      termid      : tsp00_TermId;
      fn          : tsp00_VFilename;
      errtxt      : tsp00_ErrText;
 
BEGIN
sqlos (os);
CASE os OF
    os_os2:
        n := prot_os2;
    os_unix:
        n := prot_unix;
    os_vms:
        n := prot_vms;
    os_windows:
        n := prot_windows;
    os_win32:
        n := prot_win32;
    OTHERWISE
        n := prot_unix
    END;
(*ENDCASE*) 
FOR i := 1 TO sizeof (fn) DO
    fn [i] := ' ';
i := 1;
WHILE i <= sizeof (n) DO
    BEGIN
    fn [i] := n [i];
    i:= succ(i)
    END;
(*ENDWHILE*) 
t12fncreate_prot (protfile, fn, NOT c_append, errtxt, err)
END;
 
(*------------------------------*) 
 
PROCEDURE
      t12fncreate_prot (VAR protfile : tut_vf_fileref;
            fn          : tsp00_VFilename;
            append      : boolean;
            VAR errtext : tsp00_ErrText;
            VAR error   : integer);
 
VAR
      filemode : tsp05_RteFileMode;
      open_err : tsp05_RteFileError;
      i        : integer;
      n        : tsp00_Sname;
      ln       : tsp00_Line;
 
BEGIN
error                := 0;
errtext              := bsp_errtext;
protfile.utvf_handle := 0;
protfile.utvf_filler := 0;
IF  append
THEN
    filemode := sp5vf_append
ELSE
    filemode := sp5vf_write;
(*ENDIF*) 
sqlfopenp (fn, sp5vf_text, filemode, sp5bk_unbuffered,
      protfile.utvf_handle, open_err);
IF  open_err.sp5fe_result <> vf_ok
THEN
    BEGIN
    i := 1;
    WHILE i <= sizeof (ln) DO
        BEGIN
        ln [i] := ' ';
        i := succ(i)
        END;
    (*ENDWHILE*) 
    n := '*** PROT:   ';
    i := 1;
    WHILE i <= 9 DO
        BEGIN
        ln [i] := n [i];
        i := succ(i)
        END;
    (*ENDWHILE*) 
    i := 1;
    WHILE i <= sizeof (open_err.sp5fe_text) DO
        BEGIN
        ln [10+i] := open_err.sp5fe_text [i];
        i := succ(i)
        END;
    (*ENDWHILE*) 
    sqlwrite (ln);
    protfile.utvf_handle := 0;
    error                := ord (open_err.sp5fe_result);
    errtext              := open_err.sp5fe_text
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      t12write_prot (VAR protfile : tut_vf_fileref;
            VAR ln    : tsp00_Line;
            length    : integer;
            VAR error : integer);
 
VAR
      write_err : tsp05_RteFileError;
      len       : tsp00_Int4;
 
BEGIN
error := 0;
IF  length > 0
THEN
    BEGIN
    IF  length > sizeof (ln)
    THEN
        len := sizeof (ln)
    ELSE
        len := length;
    (*ENDIF*) 
    WHILE (len > 1) AND (ln [len] = ' ') DO
        len := len - 1
    (*ENDWHILE*) 
    END
ELSE
    BEGIN
    ln [1] := ' ';
    len    := 1
    END;
(*ENDIF*) 
IF  protfile.utvf_handle = 0
THEN
    error := 2
ELSE
    BEGIN
    sqlfwritep (protfile.utvf_handle, ln, len, write_err);
    IF  write_err.sp5fe_result <> vf_ok
    THEN
        BEGIN
        error := ord (write_err.sp5fe_result);
        sqlfclosep (protfile.utvf_handle, sp5vf_close_normal,
              write_err);
        protfile.utvf_handle := 0
        END
    (*ENDIF*) 
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      t12close_prot (VAR protfile : tut_vf_fileref);
 
VAR
      close_err : tsp05_RteFileError;
 
BEGIN
IF  protfile.utvf_handle <> 0
THEN
    sqlfclosep (protfile.utvf_handle, sp5vf_close_normal,
          close_err)
(*ENDIF*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :         58
*-PRETTY-*  lines of code :        185        PRETTYX 3.10 
*-PRETTY-*  lines in file :        349         1997-12-10 
.PA 
