1 /*  START OF:       ssu_standalone_command_.incl.pl1          *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * */
  2 
  3 
  4 /****^  HISTORY COMMENTS:
  5   1) change(2019-08-17,GDixon), approve(2019-10-23,MCR10069),
  6      audit(2020-01-20,Swenson), install(2020-01-20,MR12.6g-0035):
  7      Declarations needed by standalone commands that make use of the ssu_
  8      infrastructure to simplify command/AF programming.
  9   2) change(2021-02-22,GDixon), approve(2021-02-22,MCR10089),
 10      audit(2021-03-31,Swenson), install(2021-03-31,MR12.6g-0053):
 11      Add declarations for ssu_$execute_string and ssu_$get_info_ptr support
 12      routines.
 13                                                    END HISTORY COMMENTS */
 14 
 15   dcl  cu_$arg_list_ptr entry() returns (ptr);              /* Command / ssu_ request support routines.               */
 16   dcl  ssu_$abort_line entry() options(variable);
 17   dcl  ssu_$abort_subsystem entry() options(variable);
 18   dcl  ssu_$arg_ptr entry (ptr, fixed bin, ptr, fixed bin(21));
 19   dcl  ssu_$create_invocation entry (char(*), char(*), ptr, ptr, char(*), ptr, fixed bin(35));
 20   dcl  ssu_$destroy_invocation entry (ptr);
 21   dcl  ssu_$execute_line entry (ptr, ptr, fixed bin(21), fixed bin(35));
 22   dcl  ssu_$execute_string entry (ptr, char(*), fixed bin(35));
 23   dcl  ssu_$get_area entry (ptr, ptr, char(*), ptr);
 24   dcl  ssu_$get_info_ptr entry (ptr) returns(ptr);
 25   dcl  ssu_$get_subsystem_name entry (ptr) returns(char(32));
 26   dcl  ssu_$listen entry (ptr, ptr, fixed bin(35));
 27   dcl  ssu_$print_message entry() options(variable);
 28   dcl  ssu_$return_arg entry (ptr, fixed bin, bit(1) aligned, ptr, fixed bin(21));
 29   dcl  ssu_$set_prompt entry (ptr, char(64) var);
 30   dcl  ssu_$set_prompt_mode entry (ptr, bit(*));
 31   dcl  ssu_$standalone_invocation entry (ptr, char(*), char(*), ptr, entry, fixed bin(35));
 32 
 33   dcl (F init("0"b), T init("1"b)) bit(1) aligned int static options(constant);
 34                                                             /* Constants used in this include file.                   */
 35 
 36   dcl  ssu_et_$subsystem_aborted fixed bin(35) ext static;  /* External variables.                                    */
 37 
 38   dcl  cleanup condition;                                   /* Conditions used in this include file.                  */
 39 
 40                                                             /* Automatic variables.                                   */
 41   dcl  argCount fixed bin;                                  /* Count of arguments in command/request line.            */
 42   dcl  argI fixed bin init (0);                             /* Index of argument last examined.                       */
 43 
 44   dcl  arg char(argL) based(argP),                          /* Argument returned by ssu_$arg_ptr                      */
 45        argL fixed bin(21),
 46        argP ptr;
 47 
 48   dcl  af_ret char (af_retL) varying based(af_retP),        /* When called as active function, this is return value.  */
 49        af_retL fixed bin (21),
 50        af_retP ptr;
 51 
 52   dcl  code fixed bin(35);                                  /* Status code.                                           */
 53 
 54   dcl  isAF bit(1) aligned;                                 /* T: an active request; F: a command request             */
 55   dcl  isStandalone bit(1) aligned;                         /* T: a standalone invocation; F: a request invocation    */
 56 
 57   dcl  sciP ptr;                                            /* Pointer to ssu_$standalone_invocation data, which      */
 58                                                             /*  must be cleaned up before returning from command.     */
 59 
 60 %page;
 61           /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *   */
 62           /*                                                                                                */
 63           /* Support Routines:  argument processing, and ssu_$standalone_invocation and aborting            */
 64           /*                                                                                                */
 65           /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *   */
 66 
 67 arg_setup:
 68           proc (AsciP);
 69 
 70   dcl  AsciP ptr;
 71 
 72           call ssu_$return_arg (AsciP, argCount, isAF, af_retP, af_retL);
 73           end arg_setup;
 74 
 75 
 76 args_remain:                                                /* Function to report whether any arguments               */
 77           proc () returns (bit (1) aligned);                /*  remain to be processed.                               */
 78           return (argI < argCount);
 79           end args_remain;
 80 
 81 
 82 isControlArg:                                               /* Returns T if arg is in form of a -control_arg.         */
 83           proc (Aarg) returns (bit(1) aligned);
 84 
 85   dcl  Aarg char(*);
 86   dcl  argFirst char(1) defined(Aarg);
 87   dcl  length builtin;
 88 
 89           if  length(Aarg) = 0  then return(F);             /* empty string is not an option.                         */
 90           if  argFirst ^= "-"   then return(F);             /* does not start with - , then not an option.            */
 91           return(T);
 92           end isControlArg;
 93 
 94 
 95 abort_to_EXIT:                                              /* Called by ssu_$abort_line & ssu_$abort_subsystem.      */
 96           proc();
 97           goto EXIT;                                        /* Do non-local transfer, to end command/AF and cleanup   */
 98           end abort_to_EXIT;                                /*  the standalone subsystem.                             */
 99 
100 
101 standalone_cleanup_handler:
102           proc(AisStandalone, AsciP);
103 
104   dcl  AisStandalone bit(1) aligned;                        /* T: ssu_$standalone_invocation created; F: not created  */
105   dcl  AsciP ptr;                                           /* Pointer to ssu_$standalone_invocation data.            */
106 
107           if AisStandalone then do;
108                call ssu_$destroy_invocation (AsciP);
109                AisStandalone = F;
110                end;
111           return;
112 
113           end standalone_cleanup_handler;
114 
115 /*  END OF:         ssu_standalone_command_.incl.pl1          *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * */