1 /* ******************************************************
  2    *                                                    *
  3    *                                                    *
  4    * Copyright (c) 1972 by Massachusetts Institute of   *
  5    * Technology and Honeywell Information Systems, Inc. *
  6    *                                                    *
  7    *                                                    *
  8    ****************************************************** */
  9 
 10 lss_login_responder_:
 11      proc;
 12 
 13 /* This login responder initializes the Limited
 14    Service System.  It sets up the command limitation
 15    by calling command_processor_$setup_lss, and
 16    the governing of cpu usage by calling start_governor_.
 17 
 18    Coded Nov 1970 by Dan Bricklin */
 19 
 20 /* last modified 3 May 1971 by Dan B */
 21 /* Modified 750422 by PG to call logout properly & use iox_ */
 22 /* Modified 751124 by L Hazelton to call listen_ correctly
 23    and to allow the "brief" option to be used during login. */
 24 /* Modified 751128 by L Hazelton to execute a start_up.ec if
 25    it exists and the user does not specify not to do so.    */
 26 
 27 /* builtins */
 28 
 29 dcl (addr, divide, null, index) builtin;
 30 
 31 dcl
 32      user_info_ entry (char (*), char (*)),
 33      user_info_$usage_data ext entry (fixed bin),
 34      user_info_$attributes entry (char (300) var),
 35      user_info_$homedir entry (char (*)),
 36      nproc fixed bin,
 37      hcs_$status_minf entry (char (*), char (*), fixed bin (1), fixed bin (2), fixed bin (24), fixed bin (35)),
 38      hcs_$initiate_count entry (char (*), char (*), char (*), fixed bin (24), fixed bin (1), ptr, fixed bin),
 39      hcs_$initiate_search_rules entry (ptr, fixed bin),
 40      iox_$put_chars entry (ptr, ptr, fixed bin (21), fixed bin),
 41      iox_$user_output external static ptr,
 42      hcs_$terminate_noname ext entry (ptr, fixed bin),
 43      motd_len fixed bin (24),
 44      motd_ptr ptr,
 45      hcs_$initiate entry (char (*), char (*), char (*), fixed bin (2), fixed bin (1), ptr, fixed bin),
 46      start_governor_ ext entry (fixed bin (17), fixed bin (17)),
 47      error_table_$segknown ext fixed bin (17),
 48      ioa_ entry options (variable),
 49      logout entry options (variable),
 50      command_processor_$setup_lss entry (ptr),
 51      listen_ entry (char (*) var),
 52      condition_ entry (char (*), entry),
 53      standard_default_handler_ ext entry,
 54 
 55      attr char (300) var,
 56      person char (22),
 57      project char (9),
 58      hdir char (64),
 59      standard bit (1) aligned,
 60 
 61      1 info based (command_table) aligned,
 62      2 ratio fixed bin (17),
 63      2 interval_length fixed bin (17),
 64 
 65      1 search_rules aligned int static,
 66      2 num fixed bin init (5),
 67      2 names (5) char (168) aligned
 68      init ("initiated_segments", "referencing_dir",
 69      ">system_library_standard", ">system_library_1",
 70      ">system_library_unbundled"),
 71 
 72      entry_type fixed bin (2),
 73      bit_cnt fixed bin (24),
 74      mcode fixed bin (35),
 75      code fixed bin (17),
 76      command_table ptr;
 77 
 78 /* Standard entry point */
 79 
 80           standard = "1"b;
 81           go to common;
 82 
 83 /* Limited Command System entry point - means
 84    look in >udd>project before system's for lss_commands */
 85 
 86 limited_command_system_:
 87           entry;
 88 
 89           standard = "0"b;
 90 
 91 
 92 /* Set up condition handlers */
 93 /* and initiate the search rules we want */
 94 
 95 common:
 96           call hcs_$initiate_search_rules (addr (search_rules), code);
 97           if code ^= 0 then go to error;
 98 
 99           call condition_ ("any_other", standard_default_handler_);
100 
101 /* Initiate data segment for ratio, interval_length and transform_command_ table */
102 
103           if ^standard then do;                             /* LCS search for >udd>project>lss_command_list_ */
104                call user_info_ (person, project);
105                call hcs_$initiate (">user_dir_dir>"|| project, "lss_command_list_", "", 0b, 0b,
106                     command_table, code);                   /* look for >udd>project>lss_command_list_ */
107                if code = 0 then go to got_ptr;
108                if code = error_table_$segknown then go to got_ptr;
109           end;
110 
111 /* Look for standard table */
112 
113           call hcs_$initiate (">system_library_standard", "lss_command_list_", "", 0b, 0b, command_table, code);
114 
115           if code ^= 0 then
116                if code ^= error_table_$segknown then do;    /* If segment not found */
117 
118 error:              call ioa_ ("The system is currently unavailable");
119                     call logout ("-hold");
120                end;
121 
122 /* Start transforming of commands */
123 
124 got_ptr:  call command_processor_$setup_lss (command_table);
125 
126 /* Print message of the day if first process and user
127    did not login with the "brief" option.    */
128 
129           call user_info_$attributes (attr);
130           call user_info_$usage_data (nproc);
131           if index (attr, "brief") = 0 then do;
132                if nproc = 1 then do;
133                     call hcs_$initiate_count (">system_control_1", "message_of_the_day", "", motd_len, 1, motd_ptr, code);
134                     if motd_ptr ^= null then do;
135                          call iox_$put_chars (iox_$user_output, motd_ptr, divide (motd_len + 8, 9, 24, 0), code);
136                          call hcs_$terminate_noname (motd_ptr, code);
137                     end;
138                end;
139           end;
140 
141 /* Start governing of cpu usage */
142 
143           call start_governor_ (ratio, interval_length);
144 
145 /* If the user has a start_up.ec and has not logged in with the
146    "-nostartup" or "ns" option, start the listener and execute
147    the start_up.ec     */
148 
149           if index (attr, "nostartup") ^= 0 then go to no_init_com_line;
150           call user_info_$homedir (hdir); /*start_up.ec or link should be in user's homedir. */
151 /* Find out if the start_up.ec exists and if we have access to it. */
152           call hcs_$status_minf (hdir,  "start_up.ec", 1, entry_type, bit_cnt, mcode);
153           if nproc = 1 & mcode = 0 & entry_type = 1 then do;
154                call listen_ ("exec_com start_up login interactive");
155                go to all_set;
156           end;
157 
158 /* Otherwise, just start the listener.  */
159 
160 no_init_com_line: call listen_ ("");
161 
162 all_set:  ;
163 
164      end lss_login_responder_;