      $set ans85 noosvs vsc2 mf
      ************************************************************************
      *
      * Copyright (C) 1986-2005 Micro Focus International Limited.
      * All rights reserved.
      *
      * The software and information contained herein are proprietary to, and
      * comprise valuable trade secrets of, Micro Focus International Ltd., 
      * which intends to preserve as trade secrets such software and 
      * information. This software is an unpublished copyright of Micro Focus  
      * and may not be used, copied, transmitted, or stored in any manner.  
      * This software and information or any other copies thereof may not be
      * provided or otherwise made available to any other person.
      *
      * Micro Focus Client-Server Bindings (CSBind)
      *
      * Source Module netxserv.cbl
      *
      * Last Modified on $Date: 2005/12/20 15:34:48 $
      *
      ************************************************************************
      *
      * Start of source module netxserv.cbl
      *
      ************************************************************************
       IDENTIFICATION DIVISION.
       PROGRAM-ID. NETXSERV.

       WORKING-STORAGE SECTION.
       01 SCCS-ID PIC X(40) VALUE "@(#)netxserv.cbl $Revision: 1.4 $".
       01  ws-filename                 PIC X(20) value "netxcpfl.dat".
       01  ws-pathname                 PIC X(64).
       01  ws-pathname-len             PIC X comp-x value 64.

       01  Locals.
           03  Access-Mode             PIC X       COMP-5 VALUE 2.
           03  Buffer-Size             PIC X(4)    COMP-5.
           03  Byte-Count              PIC X(4)    COMP-X.
           03  Prog-Test-State         PIC X       COMP-5 VALUE 0.
               78  Prog-Passed         VALUE       0.
               78  Prog-Failed         VALUE       1.
           03  Deny-Mode               PIC X       COMP-5 VALUE 3.
           03  Device                  PIC X       COMP-5 VALUE 0.
           03  Eof-Flag                PIC X       COMP-5.
           03  File-Details.
               05  File-Size           PIC X(8)    COMP-X.
               05  FILLER              PIC X(8).
           03  File-Handle             PIC X(4).
           03  File-Offset             PIC X(8)    COMP-X VALUE 0.
           03  Flags                   PIC X       COMP-5 VALUE 0.

       LINKAGE SECTION.

       copy "mfclisrv.cpy".

       01  Input-Rec                   PIC X(128).

       PROCEDURE DIVISION USING lnk-param-block.

           SET ADDRESS OF Input-Rec TO lnk-dblock-ptr.
           EVALUATE TRUE
              WHEN start-connection
      *-----------------------------------------------------------------
      * Remove any previously copied files and open a new one
      *-----------------------------------------------------------------
                 CALL "CBL_DELETE_FILE" USING ws-filename

                 CALL "CBL_CREATE_FILE" USING ws-filename
                                            Access-Mode
                                            Deny-Mode
                                            Device
                                            File-Handle
                 MOVE 0 TO Byte-Count, File-Offset
              WHEN client-ending
                 CONTINUE
              WHEN OTHER
                 IF lnk-data-length = 8 AND Input-Rec(1:8) = "END-DEMO"
                    CALL "CBL_CLOSE_FILE" USING File-Handle
                    MOVE SPACES TO Input-Rec
                    CALL "CBL_READ_DIR" USING Input-Rec
                                              ws-pathname-len
                    SET use-rdt TO TRUE
                    MOVE 64 TO lnk-data-length
                    MOVE 2 TO lnk-usr-retcode
                 ELSE 
      *-----------------------------------------------------------------
      * Write the copy file
      *-----------------------------------------------------------------
                    MOVE lnk-data-length TO Byte-Count
                    CALL "CBL_WRITE_FILE"
                         USING File-Handle
                               File-Offset
                               Byte-Count
                               Flags
                               Input-Rec(1:lnk-data-length)
                    ADD lnk-data-length TO File-Offset
                 END-IF
           END-EVALUATE.

           EXIT PROGRAM.
      * End of source module netxserv.cbl
