home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / prok345.zip / KITINIT.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-11  |  6KB  |  240 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1991 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*
  14.  * KitInit - initialization unit for ProKit system (3-1-89)
  15.  *
  16.  *)
  17.  
  18. {$i prodef.inc}
  19.  
  20. unit KitInit;
  21.  
  22. interface
  23.  
  24.    Uses
  25.      MiniCrt,
  26.      Tools,
  27.      MDosio,
  28.      OpenShare,
  29.      Debugs,
  30.      ProData,
  31.      ProBye,
  32.      ProSysf,
  33.      ProRoot,
  34.      ProUtil,
  35.      ProUtil2;
  36.  
  37.    procedure init;
  38.    procedure init_standalone;
  39.    procedure uninit;
  40.    procedure close_down_door(messages: boolean);
  41.  
  42.    var
  43.       local_testing:  boolean;
  44.  
  45. implementation
  46.  
  47.  
  48.    { I probye.inc}      (* automatic logoff *)
  49.  
  50.    (* ------------------------------------------------------------------- *)
  51.    procedure load_config_file;
  52.       (* load the configuration file *)
  53.    var
  54.       fd:    text;
  55.       temp:  string;
  56.  
  57.    begin
  58.       (* load and interpret the configuration file *)
  59.       getdir(0,home_dir);
  60.       bios_comm := false;
  61.  
  62.       if config_file <> 'NONE' then
  63.       begin
  64.          assignText(fd,config_file);
  65.          {$i-} reset(fd); {$i+}
  66.          ok := ioresult = 0;
  67.          if not ok then
  68.             file_missing(10000);
  69.  
  70.          readln(fd,temp);
  71.          stoupper(temp);
  72.  
  73.          if (temp[1] <> 'I'{nterrupt}) and (temp[1] <> 'H'{andshake}) then
  74.             bios_comm := true;
  75.  
  76.          close(fd);
  77.       end;
  78.    end;
  79.  
  80.  
  81.    (* ------------------------------------------------------------------- *)
  82.    procedure init_standalone;
  83.       (* initialize for stand-alone testing (without PCBoard) *)
  84.    begin
  85.       {create a "fake" pcboard.sys record}
  86.       option := o_logok; 
  87.       getdir(0,home_dir);
  88.       baudrate := 'Local';
  89.       username := 'SYSOP';
  90.       first_name := 'SYSOP';
  91.  
  92.       fill_chars(pcbsys.time_logged,system_time,5);
  93.       pcbsys.alarm := '-1';
  94.       pcbsys.usernum := 1;
  95.       pcbsys.time_credit := 0;
  96.       graphics := false;
  97.  
  98.       pcbsys.time_on := get_mins;
  99.       pcbsys.time_limit := 120;
  100.       pcbsys.time_limit := 120;
  101.       pcbsys.time_added := 0;
  102.       pcbsys.time_credit := 0;
  103.       pcbsys.prev_used := 0;
  104.       pcbsys.curconf := user.curconf;
  105.       pcbsys.graphics := 'N';
  106.       fill_chars(pcbsys.name,username,sizeof(pcbsys.name));
  107.  
  108.       load_pcbdat_file;
  109.       {load_cnames_file;}
  110.       load_user_rec;
  111.       {user.pagelen := 22;}
  112.  
  113.       {switch to color/graphics mode if pcbsetup says you login
  114.        locally in graphics mode}
  115.       if pcbsetup.local_graphics then
  116.       begin
  117.          graphics := true;
  118.          pcbsys.graphics := 'Y';
  119.       end;
  120.  
  121.       par := '@SYSDATE@ (@SYSTIME@) ';
  122.       if pcbsetup.under_network then
  123.          par := par + '($NODE$)';
  124.       make_raw_log_entry(par+' SYSOP (Local) '+progname+' '+paramstr(0));
  125.    end;
  126.  
  127.  
  128.    (* ------------------------------------------------------------------- *)
  129.    procedure init;
  130.       (* set things up so nothing goes crazy during initialization *)
  131.       (* note -- some inits are done in the body of ProLib *)
  132.    begin
  133.       progname := name_only(paramstr(1));
  134.       install_error_handler;
  135.  
  136.       if paramcount < 2 then
  137.       begin
  138.          writeln;
  139.          writeln('Usage:   ',progname,' CONFIG_FILE SYSTEM_DIR [LOCAL]');
  140.          writeln('Example: prokit prokit.cnf c:\pcb2 LOCAL');
  141.          usage(' Invalid command parameters');
  142.       end;
  143.  
  144.       local_testing := paramstr(paramcount) = 'LOCAL';
  145.  
  146.    (* get things ready to go *)
  147.       if local_testing then
  148.          init_standalone
  149.       else
  150.       begin
  151.          load_pcbsys_file;
  152.          load_pcbdat_file;
  153.          load_config_file;
  154.          load_user_rec;
  155.       end;
  156.  
  157.       NormalVideo;
  158.       init_com;
  159.       check_carrier_loss;
  160.       init_status_display;
  161.  
  162.       cnf.playpen_dir := home_dir;
  163.       build_scratchnames;
  164.       setdebug := debugging;
  165.  
  166.       if setdebug then
  167.          open_capture;
  168.    
  169.       cmdline := '';
  170.       par := '';
  171.       allow_flagging := false;
  172.  
  173.       if setdebug then 
  174.          writeln(dbfd,system_date,' ',system_time,' (',baudrate,') ',username);
  175.  
  176.       {checking for an event adjusts for pending events}
  177.       if event_run_needed(event_possible) then ;
  178.    end;
  179.  
  180.  
  181.    (* ------------------------------------------------------------------- *)
  182.    procedure close_down_door(messages: boolean);
  183.    begin
  184.       if messages then
  185.       begin
  186.          newline;
  187.          pdispln('$GRAY$<ProKIT '+version_number+' (C) 1992 S.H.Smith; The Tool Shop (818) 891-6780>$WHITE$');
  188.          newline;
  189.       end;
  190.  
  191.    (* update system files *)
  192.       if not local_testing then
  193.       begin
  194.          if not dump_user then
  195.          begin
  196.             if messages then
  197.                displn('Returning to system.  Please wait...');
  198.          end
  199.          else
  200.  
  201.       (* hang up on the user if he has said 'goodbye' *)
  202.          begin
  203.             good_bye;
  204.             drop_carrier;
  205.             if event_pending or pcbsetup.recycle_offhook then
  206.                force_offhook;
  207.          end;
  208.       end;
  209.  
  210.       save_user_rec;
  211.  
  212.       if local_testing then
  213.          delete_status_display
  214.       else
  215.       begin
  216.          if dump_user then
  217.             save_offline_pcbsys_file
  218.          else
  219.             save_pcbsys_file;
  220.       end;
  221.  
  222.  
  223.    (* remove interrupt handlers and recycle to external protocol or
  224.       back into pcboard *)
  225.       uninit_com;
  226.  
  227.       close_capture;
  228.       halt(0);
  229.    end;
  230.  
  231.    procedure uninit;
  232.    begin
  233.       if local_testing then
  234.          logoff_log_entry(time_used);
  235.       close_down_door(true);
  236.    end;
  237.  
  238. end.
  239.  
  240.