home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / CMDS / SYSMON.lzh / sysmon.c
Text File  |  1993-03-09  |  167KB  |  5,515 lines

  1. /******************* S Y S M O N  -  S O U R C E ******************************
  2. *
  3. * This source code is the proprietary confidential property of
  4. * MAX PLANCK INSTITUTE KERNPHYSIK HEIDELBERG, and is provided to licensee
  5. * solely for documentation and educational purposes.  Reproduction,
  6. * publication, or distribution in any form to any party other than
  7. * the licensee is prohibited.
  8. * I have decided to distribute the source code to everybody on request !
  9. * Everybody who makes any changes to that program is pleased to send the 
  10. * latest version to the Author: F.R.Schmitt MPI/HD
  11. * So please, if you make any changes to that program, send a copy of the
  12. * source code to F.R.Schmitt [ jnet%"SCHMITT@DHDMPI5H" ] or direct
  13. * via poste to:
  14. *
  15. *                F.R.Schmitt / [TSR-GROUP/NB]
  16. *                Max-Planck Institude Nuclear Physics Heidelberg
  17. *                P.O-BOX 103980
  18. *                D-W-6900 Heidelberg
  19. *                Germany
  20. *                MAIL: jnet%"SCHMITT@DHDMPI5H"
  21. *                BTX:  *0622454879#
  22. *                PAKET-RADIO: DF3UM @ DB0GV.DL.EU    [Amateur-Radio]
  23. *                             DF3UM v DB0EQ          [Amateur-Radio direct]
  24. *                             DF3UM v DB0AAI         [Amateur-Radio direct]
  25. *                PHONE MPI: (06221)/516-284  or  516-515
  26. *                PRIVATE  : (06224)/54879     (telephone answering machine)
  27. *                
  28. *
  29. * Any change to this program is allowed as long the copyright message in
  30. * show_version() is displayed !
  31. * If You make any changes to the program let the versionnumber the same,
  32. * example: if versionnumber is 6.0 your new version can be 6.0a or 6.01 etc.
  33. *
  34. * So feel free to extend the program and to install new routines for other
  35. * terminals then VT100
  36. * Don't finally forget to send Your changed version to the author !
  37. *
  38. * NOTE: The Author is not responseable for any damage caused by this
  39. *       program !  
  40. *
  41. *!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  42. * Some advices how to compile the program:
  43. * The program should be compiled by a SUPER USER i.e. Group.Usr 0.X !
  44. * To compile the program say : "cc -it=/r0 -E=61 -BG -M=20 sysmon.c"
  45. * if you have a 68020 CPU say: "cc -it=/r0 -E=61 -BG -M=20 -K=2f sysmon.c"
  46. * if you have a 68040 CPU say: "cc -it=/r0 -E=61 -BG -X -M=20 -K=2f sysmon.c"
  47. * if you have a 68040 CPU and the Microware FPU-module say:
  48. *                              "cc -it=/r0 -E=61 -BG -M=20 -K=2f sysmon.c"
  49. *                                    ^        ^
  50. *                                    |        |
  51. *                                    | Edition-number i.e. 6.1
  52. *                                    |
  53. * NOTE: if you are using the option '-t=/r0' keep track that the size
  54. *       of your ram-disk is at least 2 MB , otherwise don't use it !!!
  55. *
  56. *
  57. *
  58. *  GOOD LUCK !
  59. *                FRANK
  60. ********************************************************************************
  61. *  PS: Special thanks to A.Kotanski [DESY/Germany] for the help of debugging
  62. *      the get_cputime() routine and to Doug Kemp [CERN/SWISS] for distributing 
  63. *      the program ! 
  64. *
  65. *      Special thanks also to F.Koeck [MPIK/HD/Germany] for debugging and 
  66. *      discussing the NETWORK-BUG [no longer hangup at network access] and
  67. *      for the ideas of some new features !!!
  68. *
  69. *      Special thanks also to H.Falb  [Schenck/Ap.EED-L/Germany] for providing
  70. *      information of the UNDOCUMENTED SYSTEMCALL  'OS9 I$SGetSt' !!!
  71. *
  72. *
  73. *
  74. *      |----------------------------------------------------|
  75. *      !  ! This program is dedicated to Ruth S. Schmitt !  !
  76. *      |----------------------------------------------------|
  77. *
  78. *
  79. *********************************************************************************
  80. * Edition History   last edition date:                                          */
  81. #define LAST_EDITION_DATE "09.03.1993"
  82. #define versi "V6.1"
  83. /*-------------------------------------------------------------------------------
  84. * ED        Date             Comments                                       by
  85. *----     ----------    ------------------------------------------------   -----  
  86. *-01        26-05-88         Start of development                           FRS
  87. *-02        14-08-88         User option implemented                        FRS
  88. *-03        06-12-88         Alphanumeric mode implemented                  FRS        
  89. *-04        23-02-89         CPU Processor type                             FRS
  90. *-05        02-03-89         Full line                                      FRS
  91. *-06        25-01-90         Switch forward & backwards (+/-)               FRS
  92. *-07        22-06-90         Kill process OPTION implemented                FRS
  93. *-08        10-07-90         Several bugs removed and more comfort impl.    FRS
  94. *-09        28-08-90         Several extentsions implemented                FRS
  95. *-10        18-09-90         Speed up the code                              FRS
  96. *-11        26-09-90         Alpha extended mode                            FRS
  97. *-12        09-10-90         Max-Hold-Function implemented                  FRS
  98. *-13        11-10-90         Big Bug in get_cputime() removed !             FRS
  99. *-14        21-11-90         Get the /dd name from the init module          FRS
  100. *-15        27-11-90         Module information option implemented          FRS
  101. *-16        12-02-91         TaskStop & RESET option implemented            FRS
  102. *-17        06-08-91         Automatic timeout for inkey routine            FRS
  103. *-18        01-10-91         RESET only for SUPERUSER via network !         FRS
  104. *-19        08-10-91         BIG BUG REMOVED FOR NETWORK ACCESS ! [fflush]  FRS
  105. *-20        25-10-91         LOGFILE OPTION IMPLEMENTED !                   FRS
  106. *-21        30-10-91         BUG IN SELECT ROUTINE REMOVED !                FRS        
  107. *-22        22-11-91         MORE USERINFORMATION PROVIDED !                FRS
  108. *-23        27-11-91         BIG BUG IN INTERCEPT HANDLING REMOVED          FRS
  109. *-24        17-12-91         CENTERING OF NODENAME IMPLEMENTED              FRS 
  110. *-25        10-01-92         CHANGED DELAY-TIME VIA TCPIP TELNET            FRS
  111. *-26        22-01-92         DISPLAY-ROUTINE CLEANUP                        FRS
  112. *-27        27-01-92         CURSOR KEYS OPTION IMPLEMENTED                 FRS
  113. *-28        10-02-92         BUG IN REFRESH ROUTINE REMOVED                 FRS
  114. *-29        12-02-92         TERMINAL CHECK IMPLEMENTED !                   FRS
  115. *-30        17-02-92         CORRECT TIMEOUT TO EXACT SECOND VALUE          FRS
  116. *-31        11-03-92         BUG IN SWITCH_CTRL FIXED !                     FRS
  117. *-32        12-03-92         FORKING THE SHELL WHICH IS SET WITH SETENV     FRS
  118. *-34        13-03-92         IOPATH-OPTION 'V' IMPLEMENTED                  FRS
  119. *-35        16-03-92         SYSTEMCALL DISPLAY IMPLEMENTED IN 'B' OPTION ! FRS
  120. *-36        18-03-92         MORE ACCURACY & SPEEDUP IN GET_CPUTIME ROUTINE FRS
  121. *-37        24-03-92         CREATION OF NODEDEF FILE IF DOESN'T EXIST      FRS
  122. *-38        27-03-92         USERSETTINGS LOAD/SAVE IMPLEMENTED !           FRS
  123. *-39        29-04-92         PROOFPASSWORD-ROUTINE MODIFIED !               FRS
  124. *-40        12-05-92         CHANGES IN 2. STATUSLINE ARE NOW HIGHLIGHTED ! FRS
  125. *-41        13-05-92         GENERAL CLEANUP PERFORMED !                    FRS
  126. *-42        28-10-92         For unpriviledged users :LOGIN instead of zsh  FRS
  127. *-43        19-02-93         Bug fixed  get_cputime [thanks to A.Kotanski]  FRS
  128. *-44        09-03-93         Nicer Outfit at helpuser-routine               FRS
  129. *
  130. */
  131. /*--------------------- DEFINITION OF INCLUDE FILES --------------------------*/
  132.  
  133. #include <procid.h>
  134. #include <time.h>
  135. #include <stdio.h>
  136. #include <modes.h>
  137. #include <errno.h>
  138. #include <signal.h>
  139. #include <sgstat.h>
  140. #include <ctype.h>
  141. #include <direct.h>
  142.  
  143. /*------------------------ DEFINITION OF CONSTANTS----------------------------*/
  144.  
  145. #define ESC 0x1b        
  146. #define DATAPRESENT 512        
  147. #define MAXPROCS 512        
  148. #define TRUE 1
  149. #define FALSE 0
  150. #define DONE  2
  151. #define TRISTATE 2
  152. #define TIMEOUT 3
  153. #define ON 1
  154. #define OFF 0
  155. #define SUSPEND 3
  156. #define REMOVE  4
  157. #define GET 2
  158. #define RESTORE 3
  159. #define STANDARDPRIOR 128
  160. #define MAXUSERS 100            /* maximum number of users in passwordfile */
  161. #define MAXLOGSIZE 200*1024     /* max. size of LOGFILE */
  162. #define ARG_ENV_NUM 5
  163. #define ARG_ENV_LEN 100
  164. #define PASSWORDPROOFTIME 20    /* all XX minutes proof the passwordfile ! */
  165. #ifdef DEMO
  166. #define DEMOMON 12
  167. #define DEMOYEAR 93
  168. #endif
  169. /*------------------------ DECLARATION OF GLOBAL VARIABLES -------------------*/
  170. FILE *lpp;
  171. char logfilenam[100];
  172. char logindi=FALSE;
  173. int  logfilesize=0;
  174. int  logpath;
  175. char monat,jahr,tag,std,min,sec;
  176.  
  177. struct     modulhead {
  178.                         short       modulsync;
  179.                         short       modulrevision;
  180.                         int         modulsize;
  181.                         int         modulowner;
  182.                         int         modulnameoffset;
  183.                         short       modulaccess;
  184.                         char        modultype;
  185.                         char        modullanguage;
  186.                         char        modulattr;
  187.                         char        modulrevlevel;
  188.                         short       moduledition;
  189.  
  190.                   } *modaccess;
  191.  
  192.  
  193.      char *monate[] = {
  194. "Jan",
  195. "Feb",
  196. "Mar",
  197. "Apr",
  198. "May",
  199. "Jun",
  200. "Jul",
  201. "Aug",
  202. "Sep",
  203. "Oct",
  204. "Nov",
  205. "Dec"};
  206.  
  207.      char *termtype[] = {
  208. "VT100",
  209. "VT101",
  210. "VT102",
  211. "VT200",
  212. "VT220",
  213. "VT320"};
  214.  
  215. char badcode[] = "???";
  216.  
  217. char *ossvtble[] = 
  218. {
  219.     /*  service call codes 0-38  */
  220.    "Link",     "Load",     "Unlink",   "Fork",     "Wait",
  221.    "Chain",    "Exit",     "Mem",      "Send",     "Icpt",
  222.  
  223.    "Sleep",    "SSpd",     "ID",       "SPrior",   "STrap",
  224.    "PErr",     "PrsNam",   "CmpNam",   "SchBit",   "AllBit",
  225.  
  226.    "DelBit",   "Time",     "STime",    "CRC",      "GPrDsc",
  227.    "GBlkMap",  "GModDir",  "CpyMem",   "SUser",    "UnLoad",
  228.  
  229.    "RTE",      "GPrDBT",   "Julian",   "TLink",    "DFork",
  230.    "DExec",    "DExit",    "DatMod",   "SetCRC",    "SetSys",
  231.  
  232.    "SRqMem",   "SRtMem",   "IRQ",      "IOQu",     "AProc",
  233.    "NProc",    "VModul",   "Find64",   "All64",    "Ret64",
  234.  
  235.    "SSvc",     "IODel",    "SLink",    badcode,    badcode,
  236.    "GProcP",   "Move",     "AllRAM",
  237.  
  238.     /*  dummy entries 58-74  */
  239.    badcode,    badcode,    badcode,    badcode,    badcode,
  240.    badcode,    badcode,    badcode,    badcode,    badcode,
  241.    badcode,    badcode,    badcode,    badcode,    badcode,
  242.    badcode,    badcode,
  243.  
  244.     /*  service call codes 75-81  */
  245.    "AllPrc",   "DelPrc",   "ELink",    "FModul",   "MapBlk",
  246.    "ClrBlk",   "DelRAM",    "SysDbg",  "Event"
  247. };
  248.  
  249. char *osiotble[] = 
  250. {
  251.    "Attach",   "Detach",   "Dup",      "Create",   "Open",
  252.    "MakDir",   "ChgDir",   "Delete",   "Seek",     "Read",
  253.    "Write",    "ReadLn",   "WritLn",   "GetStt",   "SetStt",
  254.    "Close",    badcode,    badcode,    "SGetSt",
  255. };
  256.  
  257.     char hdr[] =
  258. "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
  259. ;
  260.         char prozent[] =
  261. "0        25        50        75        100 %%";
  262.  
  263.         char loginfo[] =
  264. "\033[7;7m SYSMON: \033[0;0m  LOGFILE: '%s' open ! Size: %6d ";
  265.  
  266.         char referstr[] =
  267. "\033[7;7m CMD-REFERENCE: \033[0;0m [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Z,+,-,<,>,1,2]";
  268.  
  269.         char maxhstr[] =
  270. "\007\033[7;7m\033[1;1m SYSMON: \033[0;0m MAX-HOLD-FUNCTION enabled !";
  271.  
  272.         char maxhdstr[] =
  273. "\007\033[7;7m SYSMON: \033[0;0m MAX-HOLD-FUNCTION disabled !";
  274.  
  275.         char kernstr[] =
  276. "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m This process can't be affected !";
  277.  
  278.         char tickswarnstr[]=
  279. "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON-ERROR: \033[0;0m Can't get time of systemtick !";
  280.  
  281.         char selectstring[]=
  282. "\033[7;7m\033[1;1m SYSMON: \033[0;0m \033[7;7mSelect:\033[0;0m '<'/'>' \033[7;7mKill:\033[0;0m 'K' \033[7;7mPrior:\033[0;0m 'T' \033[7;7mQuit:\033[0;0m 'S'  \033[7;7mSuspend/Enable:\033[0;0m 'O'\033[K";  
  283.  
  284.         char timeoutstr[]=
  285. "\033[K\007\033[7;7m\033[1;1m SYSMON: \033[0;0m Keyboard timeout period expired !\n";
  286.  
  287.         char undefkeystr[]=
  288. "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Undefined key !";
  289.  
  290.         char termwarnstr[]=
  291. "SYSMON: Environment variable TERM not defined !";
  292.  
  293.         char jokestr[]=
  294. "\033[K\007\033[7;7m\033[5;5m\033[1;1m SYSMON-COMMENT: \033[0;0m You must be jokin , that's me !";
  295.  
  296.         char memprotstr[]=
  297. "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m This option does not work due to  MEMORYPROTECTION !";
  298.  
  299.         char mmu_errstr[]=
  300. "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON-FATAL-ERROR: \033[0;0m A MMU-ERROR occured !";
  301.  
  302.         char passfiledatestr[]=
  303. "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON-ERROR: \033[0;0m Can't determine passwordfile-date !";
  304.  
  305.         char readingpassstr[]=
  306. "\033[K\033[7;7m SYSMON: \033[0;0m reading password-file ...";
  307.  
  308.         char readpasserrstr[]=
  309. "\033[K\007\033[7;7m\033[1;1m SYSMON-WARNING : \033[0;0m password-file can't be read !!!";
  310.  
  311.         char readingmodipassstr[]=
  312. "\033[K\007\033[7;7m SYSMON: \033[0;0m reading modified password-file ...";
  313.  
  314.         char passworddatestr[]=
  315. "\033[K\007\033[7;7m SYSMON-WARNING: \033[0;0m passwordfile was modified at: ";
  316.  
  317.         char proofpassstr[]=
  318. "\033[K\033[7;7m SYSMON: \033[0;0m proofing password-file ...";
  319.  
  320.         char reached_endstr[]=
  321. "\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Selected process reached end of processtable !\033[K";
  322.  
  323.         char reached_beginstr[]=
  324. "\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Selected process reached begin of processtable !\033[K";
  325.  
  326.         char process_endstr[]=
  327. "\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m End of processtable reached !\033[K";
  328.  
  329.         char process_beginstr[]=
  330. "\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Begin of processtable reached !\033[K";
  331.  
  332.         char scann_str[]=
  333. "\033[K\033[7;7m\033[1;1m\033[5;5m SYSMON-INFO: \033[0;0m Scanning processtable ... ";
  334.  
  335.  
  336. extern int os9fork();
  337.  
  338.   char *argblk[ARG_ENV_NUM];
  339.   char **environa;
  340.  
  341.   char error_indi=FALSE;
  342.   char ret_disp=0;  
  343.   char reference=FALSE;  
  344.   char unkown_flag=FALSE;  
  345.   char watchy_flag=FALSE;
  346.   char killit=FALSE;  
  347.   char maxh_flag=FALSE;
  348.   char default_flag=FALSE;
  349.   char reset_flag=TRUE;
  350.   char prillow=TRUE;  
  351.   char spr_flag=FALSE;
  352.   char killer=FALSE;
  353.  
  354.   float cpu_time[MAXPROCS];
  355.  
  356.   int tickspsecond=0;
  357.   int MAXIMUM_PROCS=0;  
  358.   int oldus,oldgrp;  
  359.   int indi=0, iolen[100], scc=1,fa=0,fb=0;
  360.   int maxprocent[MAXPROCS];
  361.  
  362.   remote char iobuf[MAXUSERS+1][100];    
  363.   remote char fildesbuffer[sizeof(struct fildes)];
  364.  
  365.   char initbuf[512];
  366.   char ddnam[60];
  367.   char nodedefnam[100];  
  368.   char passwordnam[100];
  369.   char os9vers[5];
  370.   char displaystring[255];
  371.   
  372.   char names[MAXPROCS][16], nodename[80];
  373.   remote char piopath[MAXPROCS][40];
  374.   unsigned short id[MAXPROCS],pid[MAXPROCS];
  375.   unsigned short group[MAXPROCS],user[MAXPROCS],prior[MAXPROCS];
  376.   unsigned int cpu_use[MAXPROCS], cpu_sys[MAXPROCS];
  377.   unsigned int rxbytes[MAXPROCS], txbytes[MAXPROCS];
  378.   unsigned int fca[MAXPROCS], ica[MAXPROCS];
  379.   unsigned int callnam[MAXPROCS];
  380.   unsigned short signal[MAXPROCS], cid[MAXPROCS];
  381.  
  382.   int estd[MAXPROCS], emin[MAXPROCS], esec[MAXPROCS];
  383.   int ustd[MAXPROCS], umin[MAXPROCS], usec[MAXPROCS];
  384.   int modsize[MAXPROCS], adress[MAXPROCS];
  385.   int revision[MAXPROCS], modown[MAXPROCS];  
  386.  
  387.   int i,imax=0,old_imax=0,bytes,pwh=FALSE;
  388.   int cpu_proc[MAXPROCS];
  389.   int lastcount=0;
  390.   int delay=2;
  391.   int myolddelay=2;
  392.   int olddelay=2;
  393.   int mindelay=1;  
  394.   int processor=0;
  395.   int act_task=0;
  396.   int oldact_task=0;
  397.   int actualcount=0;  
  398.   int markpr=99000;
  399.   int markprior;  
  400.   int porthandle;
  401.   int ownuid=0;
  402.   int ownprior=128;
  403.   int orginatprior=128;
  404.   int passerror=0;  
  405.   int oldprocs=0;
  406.   int mark_proc=0;
  407.   int maxage;
  408.   int oldmaxage=0;
  409.   int minage;
  410.   int oldminage=0;    
  411.   int suspendcount=0;  
  412.   int abortsig;
  413.   int quitsig;
  414.   int pausesig;
  415.   int eofsig;
  416.   int echosig;
  417.   int nodenamlen=0;
  418.   int filestd[2];
  419.   int filedate[2];
  420.   int login_old=0;
  421.   int login_new=0;
  422.  
  423.   char mark=0;  
  424.   char prior_flag=0;
  425.   char mode_flag=0;
  426.   char exmode=0;
  427.   char icpt_flag=0;
  428.   char active_flag=0;
  429.   char nodeflag=0;
  430.   char name_flag=TRUE;
  431.   char refresh_flag=FALSE;
  432.   char clflg=FALSE;
  433.   char susy_flag=FALSE;  
  434.   char bell=OFF;  
  435.   char startc=0;
  436.   char killnam[80];  
  437.   char privileg=FALSE;
  438.   char start_flag=FALSE;  
  439.   char remove_flag=FALSE;
  440.   char portnam[100];
  441.   char messagebuf[100];
  442.   char lastpassworddate[10];    
  443.  
  444. struct    sgbuf    oldstat, newstat ;
  445.   
  446.  
  447. /*---------------------------- BEGIN OF CODE ---------------------------------*/
  448. reseter()
  449. {
  450. /*
  451. *
  452. Reset_card:
  453. *    this sections resets the CPU card by software reset request.
  454. *
  455. *    reset remark H.W.Heyng 08/06/88 :
  456. *    The following reset sequence is developed/tested by F.R.Schmitt/W.Ott
  457. *    (and not fully understand but it works...).
  458. */
  459. #asm
  460.           move.l    #$4,a3
  461.           move.l    (a3),a1
  462.           move.l    #$bc,a3
  463.       move.l    (a3),d2
  464.       lea       reset_vek(pc),a0
  465.       move.l    a0,(a3)
  466.       move.l    #0,d1
  467.       trap      #15
  468. reset_vek:
  469.           reset
  470.       clr.l     d3
  471. reset_loop:
  472.           add.l     #1,d3
  473.       nop
  474.       cmp.l     #10000,d3
  475.       bne.s     reset_loop
  476.           move.l    #$bc,a3
  477.       move.l    d2,(a3)
  478.           move.l    #$0,a3
  479.       move.l    (a3),a7    
  480.       jmp       (a1)     
  481. #endasm
  482. }
  483.  
  484. desolatesystem()
  485. {
  486. #asm
  487. ********************************************************************************
  488. *
  489. * Name: Permit             NOTE: (undocumented system-call) !!!
  490. *
  491. * Description:
  492. * This function enables (from C) access to a given memory segment if
  493. * the system security module (ssm) is installed.
  494. *
  495. * Call:
  496. *      Permit(addr,len,perm)
  497. *
  498. * Arguments:
  499. *      char *addr       start address of memory segment,
  500. *                       rounded down to a multiple of 4096
  501. *      int len          length of memory segment,
  502. *                       rounded up to a multiple of 4096
  503. *      int perm         access permissions
  504. *  
  505. * Return values:
  506. *      0  if successfull
  507. *     -1  if an error occurred (error number is loaded in global variable errno)
  508. *
  509. ********************************************************************************
  510. Permit:
  511.          link.w a5,#0                     * link frame pointer
  512.          movem.l  d1-d2/a0/a2,-(sp)       * save used registers
  513.          movea.l d0,a2                    * load a2 with startaddress
  514.          move.l  d1,d0                    * load d0 with len
  515.          move.l  8(a5),d1                 * load d1 with permissions
  516.          OS9 F$Permit                     * call F$Permit
  517.          bcc.b Pe_noerr                   * if carry==1 skip to error label
  518.          move.l d1,errno(a6)              * store d1 in global errno variable
  519.          moveq #-1,d0                     * function error return value
  520.          bra.b Pe_ret
  521. Pe_noerr moveq #0,d0                      * function ok return value
  522. Pe_ret   movem.l  (sp)+,d1-d2/a0/a2       * return used registers
  523.          unlk a5                          * unlink frame pointer
  524.          rts                              * return from function
  525.  
  526. ********************************************************************************
  527. *
  528. * Name: Protect
  529. *
  530. * Description:
  531. * This function disables (from C) access to a given memory segment if
  532. * the system security module (ssm) is installed.
  533. *
  534. * Call:
  535. *      Protect(addr,len)
  536. *
  537. * Arguments:
  538. *      char *addr       start address of memory segment
  539. *                       rounded down to a multiple of 4096
  540. *      int len          length of memory segment
  541. *                       rounded up to a multiple of 4096
  542. *  
  543. * Return values:
  544. *      0  if successfull
  545. *     -1  if an error occurred (error number is loaded in global variable errno)
  546. *
  547. ********************************************************************************
  548. Protect:
  549.          link.w a5,#0                     * link frame pointer
  550.          movem.l  d1-d2/a0/a2,-(sp)       * save used registers
  551.          movea.l d0,a2                    * load a2 with startaddress
  552.          move.l  d1,d0                    * load d0 with len
  553.          OS9 F$Protect                    * call F$Protect
  554.          bcc.b Pr_noerr                   * if carry==1 skip to error label
  555.          move.l d1,errno(a6)              * store d1 in global errno variable
  556.          moveq #-1,d0                     * function error return value
  557.          bra.b Pr_ret
  558. Pr_noerr moveq #0,d0                      * function ok return value
  559. Pr_ret   movem.l  (sp)+,d1-d2/a0/a2       * return used registers
  560.          unlk a5                          * unlink frame pointer
  561.          rts                              * return from function
  562. #endasm
  563. }
  564. /*----------------------------------------------------------------------------*/
  565. /* name: BUSTRAPERROR - HANDLER - ROUTINE                                     */
  566. /* function: routine checks if adress is valid or not !                       */
  567. /* by: F.SCHMITT                                                              */ 
  568. /* Date: 02-04-88                                                             */
  569. /*----------------------------------------------------------------------------*/
  570. bustraphandler()
  571. {
  572. #asm
  573.         align
  574. checkadr:
  575.         movem.l  a0-a6/d1-d7,-(sp)
  576.         move.l   #0,a0
  577.         lea      table(pc),a1
  578.         os9      F$STrap
  579.  
  580.         move.l   d0,a0
  581.         move.b   (a0),d1
  582.         move.l   #0,d0
  583.         move.l   #0,d1
  584. return:    
  585.         move.l   #0,a0
  586.         lea      notable(pc),a1
  587.         os9      F$STrap
  588.         movem.l  (sp)+,a0-a6/d1-d7
  589.         rts
  590.  
  591.         align
  592. buserror     movem.l  (a5)+,d0-d7/a0-a7
  593.         move.l   #255,d0                
  594.         bra.s    return
  595.  
  596.         align
  597. table        dc.w  T_BusErr,buserror-*-4
  598.         dc.w  -1
  599.     
  600.         align    
  601. notable         dc.w  T_BusErr,0
  602.         dc.w  -1
  603. #endasm
  604. }
  605.  
  606. /*-------------------------------------------------------------------------*/
  607. iocalc()
  608. {
  609. #asm
  610.  
  611.     ttl sgetst(pathnum,bufptr) - get path name
  612.  
  613. sgetst:
  614.     movem.l   a0-a6/d2-d7,-(sp)
  615.     move.l    d1,a0         get address of buffer
  616.     move.l       #SS_DevNm,d1 
  617.     OS9       I$SGetSt
  618.     bcc.s     noerror
  619.     moveq     #-1,d0
  620.         move.w    d1,errno(a6)
  621. noerror    ext.l     d0
  622.     movem.l   (sp)+,a0-a6/d2-d7
  623.         rts
  624. #endasm
  625. }
  626. /*-------------------------------------------------------------------------*/
  627. tmode(pausesw,echosw)
  628. register char pausesw;
  629. register char echosw;
  630. {
  631.     _gs_opt(0, &newstat);
  632.         
  633.     newstat.sg_echo = echosw;
  634.     newstat.sg_pause=pausesw;
  635.  
  636.     _ss_opt(0, &newstat);
  637. }
  638. /*-------------------------------------------------------------------------*/
  639. switch_ctrl(on)
  640. register int on;
  641. {
  642.         switch(on)      
  643.         {
  644.             case ON:
  645.             _gs_opt(0, &newstat);
  646.             newstat.sg_kbich=quitsig;    /* keyboard interrupt character */
  647.             newstat.sg_kbach=abortsig;    /* keyboard abort character */
  648.                 newstat.sg_eofch=eofsig;        /* keyboard eof character   */
  649.             _ss_opt(0, &newstat);
  650.                 break;
  651.  
  652.             case OFF:
  653.             _gs_opt(0, &newstat);
  654.             newstat.sg_kbich=0;        /* keyboard interrupt character */
  655.             newstat.sg_kbach=0;        /* keyboard abort character */
  656.                 newstat.sg_eofch=0;             /* keyboard eof character   */
  657.             _ss_opt(0, &newstat);
  658.                 break;
  659.  
  660.             case RESTORE:
  661.             _gs_opt(0, &newstat);
  662.             _gs_opt(0, &oldstat);
  663.  
  664.             newstat.sg_kbich=quitsig;    /* keyboard interrupt character */
  665.             oldstat.sg_kbich=quitsig;    /* keyboard interrupt character */
  666.             newstat.sg_kbach=abortsig;    /* keyboard abort character */
  667.             oldstat.sg_kbach=abortsig;    /* keyboard abort character */
  668.                 newstat.sg_echo=echosig;        /* keyboard echo on/off     */
  669.                 oldstat.sg_echo=echosig;        /* keyboard echo on/off     */
  670.             newstat.sg_pause=pausesig;      /* keyboard pause on/off    */
  671.             oldstat.sg_pause=pausesig;      /* keyboard pause on/off    */
  672.                 newstat.sg_eofch=eofsig;      /* keyboard eof character   */
  673.                 oldstat.sg_eofch=eofsig;      /* keyboard eof character   */
  674.  
  675.             _ss_opt(0, &newstat);
  676.             _ss_opt(0, &oldstat);
  677.                 break;
  678.  
  679.             case GET:
  680.             _gs_opt(0, &oldstat);
  681.                 quitsig=oldstat.sg_kbich;    /* keyboard interrupt character */
  682.             abortsig=oldstat.sg_kbach;    /* keyboard abort character */
  683.                 echosig=oldstat.sg_echo;        /* keyboard echo on/off     */
  684.             pausesig=oldstat.sg_pause;      /* keyboard pause on/off    */
  685.                 eofsig=oldstat.sg_eofch;      /* keyboard eof character   */
  686.                 break;
  687.         }
  688. }
  689. /*-------------------------------------------------------------------------*/
  690. cls()
  691. {
  692.   printf("\033[2J\033[1;H");
  693.   if(logindi)  
  694.     fprintf(lpp,"\033[2J\033[1;H");
  695. }
  696. /*-------------------------------------------------------------------------*/
  697. wrap_off()
  698. {
  699.       printf("\033[?7l");        /* set terminal to NOWRAP ! */
  700.       if(logindi)
  701.           fprintf(lpp,"\033[?7l");        /* set terminal to NOWRAP ! */
  702. }
  703. /*-------------------------------------------------------------------------*/
  704. gotoxy(x,y)
  705. register char x,y;
  706. {
  707.   printf("\033[%d;%dH",y,x);
  708.   fflush(stdout);
  709.   if(logindi)
  710.   {    
  711.     fprintf(lpp,"\033[%d;%dH",y,x);
  712.     fflush(lpp);
  713.   }  
  714. }
  715. /*-------------------------------------------------------------------------*/
  716. effect()
  717. {
  718.     register char i;
  719.  
  720.     for(i=0;i<12;i++)
  721.     {
  722.         gotoxy(1,12+i);
  723.         printf("\033[K\n");
  724.         if(logindi)
  725.             fprintf(lpp,"\033[K\n");
  726.         gotoxy(1,12-i);
  727.         printf("\033[K\n");
  728.         if(logindi)
  729.             fprintf(lpp,"\033[K\n");
  730.     }
  731. }
  732. /*-------------------------------------------------------------------------*/
  733. uppercase(buf)
  734. register char *buf;
  735. {
  736.     register char *a;
  737.     a=buf;
  738.     do
  739.     {
  740.         *a=toupper(*a);
  741.         a++;
  742.     }while(*a !=0);
  743. }
  744. /*-------------------------------------------------------------------------*/
  745. disp_user(di)
  746. register int di;
  747. {
  748.     char cmpbuf[100];
  749.     char usernam[100];
  750.  
  751.     register int sch, fi, slen;
  752.     int cmphandle, cmplen, uselen;
  753.  
  754.     if(user[di]==0 && group[di]==0)
  755.     {
  756.         printf("SYSTEM      ");
  757.         if(logindi)
  758.             fprintf(lpp,"SYSTEM      ");
  759.         return(TRUE);
  760.     }
  761.     else
  762.     {
  763.         sprintf(cmpbuf,",%d.%d,",group[di],user[di]);
  764.         cmplen=strlen(cmpbuf);
  765.  
  766.         for(sch=0;sch<=indi;sch++)    
  767.         {
  768.             slen=strlen(&iobuf[sch][0]);
  769.             for(fi=0;fi<=slen;fi++)
  770.             {
  771.                 cmphandle=strncmp(cmpbuf,&iobuf[sch][fi],cmplen);
  772.                 if(!cmphandle)
  773.                 {
  774.                     for(uselen=0;uselen<=100;uselen++)                     
  775.                     {
  776.                         if(iobuf[sch][uselen]==',')
  777.                             break;
  778.                     }
  779.                     if(!uselen)
  780.                         sprintf(usernam,"\033[7;7m<UNKOWN>\033[0;0m    ");
  781.                     else
  782.                     {
  783.                         strncpy(usernam,&iobuf[sch][0],uselen);
  784.                         usernam[uselen]=0;
  785.                         uppercase(usernam);
  786.                     }
  787.                     printf("%-11s ",usernam);
  788.                     if(logindi)
  789.                         fprintf(lpp,"%-11s ",usernam);
  790.                     sch=indi;
  791.                     return(TRUE);
  792.                 }
  793.             }   
  794.         }
  795.         sprintf(usernam,"\033[7;7m<UNKOWN>\033[0;0m    ");
  796.         printf("%-11s",usernam);
  797.         if(logindi)
  798.             fprintf(lpp,"%-11s",usernam);
  799.         if(!unkown_flag)
  800.             unkown_flag=TRUE;
  801.         return(FALSE);
  802.     }
  803. }
  804. /*-------------------------------------------------------------------------*/
  805. get_passworddate(dateindex)
  806. register int dateindex;
  807. {
  808.     register int fph;
  809.     register struct fildes *filpoi;
  810.  
  811.  
  812.     filpoi=(struct fildes *) fildesbuffer;
  813.  
  814.     fph=open(passwordnam,1);
  815.     if(fph==-1)
  816.     {
  817.         gotoxy(1,23);
  818.         printf("%s\n",passfiledatestr);
  819.       if(logindi)
  820.             fprintf(lpp,"%s\n",passfiledatestr);
  821.         sleep(2);
  822.         return(-1);
  823.     }
  824.  
  825.     if(_gs_gfd(fph,fildesbuffer,sizeof(struct fildes))==-1)
  826.     {
  827.         close(fph);
  828.         gotoxy(1,23);
  829.             printf("%s\n",passfiledatestr);
  830.       if(logindi)
  831.             fprintf(lpp,"%s\n",passfiledatestr);
  832.         sleep(2);
  833.         return(-1);
  834.     }
  835.  
  836.     filestd[dateindex]=
  837.     (filpoi->fd_date[4]) +
  838.     (filpoi->fd_date[3])*100;
  839.  
  840.     filedate[dateindex]=
  841.     (filpoi->fd_date[2]) +
  842.     (filpoi->fd_date[1])*100 +
  843.     (filpoi->fd_date[0])*10000;
  844.  
  845.     lastpassworddate[0]=filpoi->fd_date[2];
  846.     lastpassworddate[1]=filpoi->fd_date[1];
  847.     lastpassworddate[2]=filpoi->fd_date[0];
  848.     lastpassworddate[3]=filpoi->fd_date[3];
  849.     lastpassworddate[4]=filpoi->fd_date[4];
  850.  
  851.     close(fph);
  852.     return(0);
  853. }
  854. /*-------------------------------------------------------------------------*/
  855. get_password()
  856. {
  857.    register int fh, rh, koma1,koma2;
  858.    register char exeed_flag=FALSE; 
  859.  
  860.    passerror=0;
  861.    indi=0;
  862.  
  863.    if(chmod(passwordnam,0x09)==-1)
  864.    {
  865.         passerror=errno; 
  866.         return(FALSE);
  867.    }
  868.  
  869.    fh=open(passwordnam,1);
  870.    if(fh==-1)
  871.    {
  872.         passerror=errno;
  873.         return(FALSE);
  874.    }   
  875.  
  876.    for(;;)
  877.    {
  878.       rh=readln(fh,&iobuf[indi][0],100);
  879.       iolen[indi]=rh;
  880.       if(rh==0 || rh==-1)
  881.          break;
  882.  
  883.       koma1=findstr(1,&iobuf[indi][0],",");
  884.       koma2=findstr(koma1+1,&iobuf[indi][0],",");
  885.  
  886.       /* this is for that people can't look into the memory and see all the
  887.          passwords in the passwordfile !    */    
  888.       if(koma2>koma1+1)                        /* minimum 1 character ! */
  889.       {
  890.         for(rh=koma1;rh<koma2-1;rh++)
  891.             iobuf[indi][rh]='?';
  892.       }    
  893.  
  894.       indi++;   
  895.  
  896.       if(indi>MAXUSERS)
  897.       {
  898.         exeed_flag=TRUE;
  899.         gotoxy(1,23);
  900.         printf("\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON-ERROR: \033[0;0m Sorry passwordfile has more then %d entrys !\n",
  901.         MAXUSERS);
  902.         if(logindi)
  903.             fprintf(lpp,"\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON-ERROR: \033[0;0m Sorry passwordfile has more then %d entrys !\n",
  904.             MAXUSERS);
  905.         error_indi=TRUE;
  906.         sleep(2);
  907.         break;
  908.       }
  909.    }
  910.    close(fh);
  911.  
  912.    if(get_passworddate(0)==-1)
  913.       exeed_flag=TRUE;     
  914.  
  915.    if(chmod(passwordnam,0x01)==-1)
  916.    {
  917.       passerror=errno;
  918.       return(FALSE);
  919.    }
  920.  
  921.    if(icpt_flag==TRUE)
  922.    {
  923.       fflush(stdout);    
  924.       return(FALSE);
  925.    }
  926.  
  927.    if(exeed_flag)
  928.     return(FALSE);
  929.    else 
  930.     return(TRUE); 
  931. }  
  932. /*-------------------------------------------------------------------------*/
  933. under_title()
  934. {
  935.     register int actualis;
  936.  
  937.             if(imax+1>=actualcount+16)
  938.                   actualis=16;
  939.             else
  940.                 actualis=imax+1-actualcount;
  941.             
  942.             fa=actualcount;
  943.             fb=actualis;
  944.  
  945.             if(killer || spr_flag)  /* forbid undertitle when you are */
  946.                 return(0);          /* in question mode ! [Y/N]       */
  947.  
  948.             gotoxy(1,23);
  949.  
  950.             if(!start_flag)
  951.             {
  952.                 printf("%s\n",scann_str);
  953.                 if(logindi)
  954.                     fprintf(lpp,"%s\n",scann_str);
  955.                 return(0);
  956.             }
  957.  
  958.             if(reference)
  959.             {
  960.                 printf("\033[K%s \n",referstr);
  961.                 if(logindi)
  962.                     fprintf(lpp,"\033[K%s \n",referstr);
  963.                 return(0);
  964.             }
  965.  
  966.             if(maxh_flag)
  967.             {
  968.                 printf("\033[K%s \n",maxhstr);
  969.                 if(logindi)
  970.                     fprintf(lpp,"\033[K%s \n",maxhstr);
  971.                 return(0);
  972.             }
  973.  
  974.             if(logindi && !susy_flag)
  975.             {
  976.                 printf(loginfo,logfilenam,logfilesize);
  977.                 fprintf(lpp,loginfo,logfilenam,logfilesize);
  978.                 return(0);
  979.             }
  980.  
  981.             if(nodeflag)
  982.             {
  983.                 if(!susy_flag)
  984.                 {
  985.                     if(!active_flag)
  986.                     {
  987.                         printf("\033[KSYSMON %s    What's happening on %s                Processes: %3d+ %d \n",
  988.                         versi,nodename,actualcount,actualis);
  989.                         if(logindi)
  990.                             fprintf(lpp,"\033[KSYSMON %s    What's happening on %s                Processes: %3d+ %d \n",
  991.                             versi,nodename,actualcount,actualis);
  992.                     }
  993.                     else
  994.                     {
  995.                         printf("\033[KSYSMON %s    What's happening on %s           User-Processes: %3d+ %d \n",
  996.                         versi,nodename,actualcount,actualis);
  997.                         if(logindi)
  998.                             fprintf(lpp,"\033[KSYSMON %s    What's happening on %s           User-Processes: %3d+ %d \n",
  999.                             versi,nodename,actualcount,actualis);
  1000.                     }
  1001.                 }
  1002.                 else
  1003.                 {
  1004.                     printf("%s\n",selectstring);
  1005.                     if(logindi)
  1006.                         fprintf(lpp,"%s\n",selectstring);
  1007.                 }  
  1008.             }
  1009.             else
  1010.             {
  1011.                 if(!susy_flag)
  1012.                 {
  1013.                     if(!active_flag)
  1014.                     {
  1015.                     printf("\033[KSYSMON %s                                          Processes: %3d+ %d \n",
  1016.                         versi,actualcount,actualis);
  1017.                         if(logindi)
  1018.                         fprintf(lpp,"\033[KSYSMON %s                                          Processes: %3d+ %d \n",
  1019.                             versi,actualcount,actualis);
  1020.                     }
  1021.                     else
  1022.                     {
  1023.                     printf("\033[KSYSMON %s                                     User-Processes: %3d+ %d \n",
  1024.                         versi,actualcount,actualis);
  1025.                         if(logindi)
  1026.                         fprintf(lpp,"\033[KSYSMON %s                                     User-Processes: %3d+ %d \n",
  1027.                             versi,actualcount,actualis);
  1028.                     }
  1029.                 }  
  1030.                 else
  1031.                 {
  1032.                     printf("%s\n",selectstring);
  1033.                     if(logindi)
  1034.                            fprintf(lpp,"%s\n",selectstring);
  1035.                 }  
  1036.             }
  1037. }
  1038. /*-------------------------------------------------------------------------*/
  1039. display_frame()
  1040. {
  1041.   register int i;
  1042.  
  1043.   cursoroff();
  1044.   wrap_off();  
  1045.   cls();
  1046.   gotoxy(24,0);
  1047. #ifdef DEMO
  1048.   printf("OS9/68k %s Process Monitor Demo %s \n",os9vers,versi);
  1049.   if(logindi)  
  1050.     fprintf(lpp,"OS9/68k %s Process Monitor Demo %s \n",os9vers,versi);
  1051. #else
  1052.   printf("OS9/68k %s Process Monitor %s \n",os9vers,versi);
  1053.   if(logindi)  
  1054.     fprintf(lpp,"OS9/68k %s Process Monitor %s \n",os9vers,versi);
  1055. #endif
  1056.   display_time();
  1057.   printf("\n");
  1058.   if(logindi)
  1059.     fprintf(lpp,"\n");
  1060.   gotoxy(37,4);
  1061.   printf("%s\n",prozent);
  1062.   if(logindi)
  1063.     fprintf(lpp,"%s\n",prozent);
  1064.   gotoxy(1,5);
  1065.  
  1066.   if(name_flag)
  1067.   {  
  1068.     printf("Id  Username   Processname");
  1069.     if(logindi)
  1070.         fprintf(lpp,"Id  Username   Processname");
  1071.   }
  1072.   else
  1073.   {
  1074.     if(prior_flag)
  1075.     {
  1076.         printf("Id  Prior      Processname");
  1077.         if(logindi)
  1078.                fprintf(lpp,"Id  Prior      Processname");
  1079.     }
  1080.     else
  1081.     {
  1082.         printf("Id Grp.Usr     Processname");
  1083.         if(logindi)
  1084.             fprintf(lpp,"Id Grp.Usr     Processname");
  1085.     }  
  1086. }
  1087.   gotoxy(37,5);
  1088.   printf("\033(0tqqqqqqqqqnqqqqqqqqqnqqqqqqqqqnqqqqqqqqqqu\033(B\n");
  1089.   if(logindi)  
  1090.     fprintf(lpp,"\033(0tqqqqqqqqqnqqqqqqqqqnqqqqqqqqqnqqqqqqqqqqu\033(B\n");
  1091.   for(i=1;i<=16;i++)
  1092.   {
  1093.     gotoxy(37,5+i);
  1094.     printf("\033(0x");
  1095.     if(logindi) 
  1096.         fprintf(lpp,"\033(0x");
  1097.     gotoxy(47,5+i);
  1098.     printf("\033(0x");
  1099.     if(logindi) 
  1100.         fprintf(lpp,"\033(0x");
  1101.     gotoxy(57,5+i);
  1102.     printf("\033(0x");
  1103.     if(logindi)
  1104.         fprintf(lpp,"\033(0x");
  1105.     gotoxy(67,5+i);
  1106.     printf("\033(0x");
  1107.     if(logindi)
  1108.         fprintf(lpp,"\033(0x");
  1109.     gotoxy(78,5+i);
  1110.     printf("x\033(B\n");
  1111.     if(logindi)
  1112.         fprintf(lpp,"x\033(B\n");
  1113.   }
  1114.   gotoxy(37,22);
  1115.   printf("\033(0tqqqqqqqqqnqqqqqqqqqnqqqqqqqqqnqqqqqqqqqqu\033(B\n");
  1116.   if(logindi)  
  1117.     fprintf(lpp,"\033(0tqqqqqqqqqnqqqqqqqqqnqqqqqqqqqnqqqqqqqqqqu\033(B\n");
  1118.  
  1119.  
  1120.   if(logindi)
  1121.   {
  1122.     gotoxy(1,23);
  1123.     printf(loginfo,logfilenam,logfilesize);
  1124.     printf("\n");
  1125.     fprintf(lpp,loginfo,logfilenam,logfilesize);
  1126.     fprintf(lpp,"\n");
  1127.     return(0);
  1128.   }
  1129.  
  1130.   if(reference)
  1131.   {
  1132.     gotoxy(1,23);
  1133.     printf("\033[K%s\n",referstr);
  1134.     if(logindi)
  1135.         fprintf(lpp,"\033[K%s\n",referstr);
  1136.   }
  1137.   else
  1138.   {  
  1139.     if(maxh_flag)
  1140.     {
  1141.         gotoxy(1,23);
  1142.            printf("\033[K%s \n",maxhstr);
  1143.         if(logindi)
  1144.                fprintf(lpp,"\033[K%s \n",maxhstr);
  1145.     }
  1146.     else
  1147.     {
  1148.         gotoxy(37,23);
  1149.         printf("%s\n",prozent);
  1150.         if(logindi)
  1151.             fprintf(lpp,"%s\n",prozent);
  1152.     }
  1153.   }
  1154. }
  1155. /*-------------------------------------------------------------------------*/
  1156. display_dframe()
  1157. {
  1158.   cursoron();
  1159.   wrap_off();  
  1160.   cls();
  1161.   gotoxy(24,0);
  1162. #ifdef DEMO
  1163.   printf("OS9/68k %s Process Monitor Demo %s \n",os9vers,versi);
  1164.   if(logindi)  
  1165.     fprintf(lpp,"OS9/68k %s Process Monitor Demo %s \n",os9vers,versi);
  1166. #else
  1167.   printf("OS9/68k %s Process Monitor %s \n",os9vers,versi);
  1168.   if(logindi)  
  1169.     fprintf(lpp,"OS9/68k %s Process Monitor %s \n",os9vers,versi);
  1170. #endif
  1171.   display_time();
  1172.   gotoxy(1,4);  
  1173.   if(pwh && name_flag)
  1174.   {
  1175.     switch (exmode)
  1176.     {
  1177.         case 0:
  1178.             printf("Id  Pid  Username    Processname      Rxbytes  Txbytes  Cpu_System Cpu_User  CPU\n");
  1179.             if(logindi)
  1180.                    fprintf(lpp,"Id  Pid  Username    Processname      Rxbytes  Txbytes  Cpu_System Cpu_User  CPU\n");
  1181.             break;
  1182.         case 1:
  1183.           printf("Id  Pid  Username    Processname       Icalls   Fcalls Last   Signal  Child  CPU\n");
  1184.             if(logindi)
  1185.                    fprintf(lpp,"Id  Pid  Username    Processname       Icalls   Fcalls Last   Signal  Child  CPU\n");
  1186.             break;
  1187.         case 2:
  1188.           printf("Id  Pid  Username    Processname      MemAdr$  ModSize  Edition  ModulOwner  CPU\n");
  1189.             if(logindi)
  1190.               fprintf(lpp,"Id  Pid  Username    Processname      MemAdr$  ModSize  Edition  ModulOwner  CPU\n");
  1191.             break;
  1192.         case 3:
  1193.           printf("Id  Pid  Username    Processname     IO-Path                                 CPU\n");
  1194.             if(logindi)
  1195.               fprintf(lpp,"Id  Pid  Username    Processname     IO-Path                                 CPU\n");
  1196.             break;
  1197.     }  
  1198.   }
  1199.   else
  1200.   {
  1201.     switch (exmode)
  1202.     {
  1203.         case 0:
  1204.             printf("Id  Pid  prior  Own  Processname      Rxbytes  Txbytes  Cpu_Sys    Cpu_user  CPU\n");
  1205.             if(logindi)
  1206.                 fprintf(lpp,"Id  Pid  prior  Own  Processname      Rxbytes  Txbytes  Cpu_Sys    Cpu_user  CPU\n");
  1207.             break;
  1208.         case 1:
  1209.           printf("Id  Pid  prior  Own  Processname       Icalls   Fcalls Last   Signal  Child  CPU\n");
  1210.             if(logindi)
  1211.               fprintf(lpp,"Id  Pid  prior  Own  Processname       Icalls   Fcalls Last   Signal  Child  CPU\n");
  1212.             break;
  1213.         case 2:
  1214.           printf("Id  Pid  prior  Own  Processname      MemAdr$  ModSize  Edition  ModulOwner  CPU\n");
  1215.             if(logindi)
  1216.               fprintf(lpp,"Id  Pid  prior  Own  Processname      MemAdr$  ModSize  Edition  ModulOwner  CPU\n");
  1217.             break;
  1218.         case 3:
  1219.           printf("Id  Pid  prior  Own  Processname     IO-Path                                 CPU\n");
  1220.             if(logindi)
  1221.               fprintf(lpp,"Id  Pid  prior  Own  Processname     IO-Path                                 CPU\n");
  1222.             break;
  1223.     }  
  1224.   }
  1225.   printf ("\033(0");
  1226.   printf ("%s",hdr);
  1227.   printf ("\033(B\n");
  1228.   if(logindi)
  1229.   {    
  1230.     fprintf (lpp,"\033(0");
  1231.     fprintf (lpp,"%s",hdr);
  1232.     fprintf (lpp,"\033(B\n");
  1233.   }  
  1234.   gotoxy(0,22);
  1235.   printf ("\033(0");
  1236.   printf ("%s",hdr);
  1237.   printf ("\033(B\n");
  1238.   if(logindi)
  1239.   {    
  1240.     fprintf (lpp,"\033(0");
  1241.     fprintf (lpp,"%s",hdr);
  1242.     fprintf (lpp,"\033(B\n");
  1243.   }  
  1244.   under_title();
  1245. }
  1246. /*---------------------------------------------------------------------------*/
  1247. gotsignl(signum)
  1248. register int signum;
  1249. {
  1250.   if(signum!=DATAPRESENT)
  1251.     return(0);
  1252.  
  1253.   if(error_indi)  
  1254.     ret_disp++;  
  1255.   icpt_flag=TRUE;  
  1256. }      
  1257. /*---------------------------------------------------------------------------*/
  1258. getiopaths(descptr,piopp)
  1259. register procid *descptr;
  1260. register char *piopp;
  1261. {
  1262.     register int i,path,x;
  1263.     mod_exec *mod ;
  1264.     char namebuf[33];
  1265.     
  1266.     static char *stds[] = 
  1267.     {
  1268.       "<", ">", ">>"
  1269.     };
  1270.  
  1271.     *piopp=0;
  1272.     mod = descptr->_pmodul;
  1273.     for (i = 0; i < 3; i++) 
  1274.     {
  1275.         if ((path = descptr->_path[i]) != 0)
  1276.         {
  1277.               if (sgetst(path,namebuf) != -1)
  1278.             {
  1279.                   for (x = i; x < 3; x++)
  1280.                 { 
  1281.                     if (descptr->_path[x] == path) 
  1282.                       {
  1283.                         strcat(piopp,stds[x]);
  1284.                         descptr->_path[x] = 0;
  1285.                       }
  1286.                 }
  1287.                   strcat(piopp,namebuf);
  1288.                   strcat(piopp," ");
  1289.             }
  1290.         }
  1291.     }
  1292.     uppercase(piopp);
  1293. }
  1294. /*---------------------------------------------------------------------------*/
  1295. get_ticktime()
  1296. {
  1297.     int time, date,tick;
  1298.     short day;
  1299.  
  1300.     if((_sysdate(3,&time,&date,&day,&tick))==-1)
  1301.     {
  1302.         tmode(0,1);
  1303.         cursoron();
  1304.         printf("%s\n",tickswarnstr);        
  1305.         switch_ctrl(RESTORE);
  1306.         if(strncmp(portnam,"PKS",3)==0)
  1307.             sleep(2);
  1308.         exit(errno);
  1309.     }
  1310.     tickspsecond=(tick>>16) & 0xffff;
  1311.     if(tickspsecond<1)
  1312.     {
  1313.         tmode(0,1);
  1314.         cursoron();
  1315.         printf("\033[K\007\033[7;7m SYSMON-ERROR: \033[0;0m Illegal tickcount/second %d !!!\n",tickspsecond);        
  1316.         switch_ctrl(RESTORE);
  1317.         if(strncmp(portnam,"PKS",3)==0)
  1318.             sleep(2);
  1319.         exit(0);
  1320.     }
  1321. }
  1322. /*---------------------------------------------------------------------------*/
  1323. get_cputime()
  1324. {
  1325.   register int i, j=0, maxip=0, calcrest;
  1326.   register char *modadr;
  1327.  
  1328.   char *nameadr;
  1329.   unsigned int ticks[2][MAXPROCS];
  1330.   char newnames[20], internames[20];  
  1331.   char workbuff[100];
  1332.   unsigned short proctab[400];
  1333.   register struct pdsc *pr;
  1334.   int rrprior;    
  1335.   float all_cpu;
  1336.  
  1337.   suspendcount=0;
  1338.  
  1339.   if(logindi && !reference && !susy_flag && ! maxh_flag)
  1340.   {
  1341.         logfilesize=_gs_size(logpath);
  1342.         if(logfilesize==-1)
  1343.         {
  1344.             logindi=FALSE;
  1345.             fclose(lpp);
  1346.         }
  1347.         else
  1348.         {
  1349.             if(logfilesize>=MAXLOGSIZE)
  1350.             {
  1351.                 logindi=FALSE;
  1352.                 fclose(lpp);
  1353.                     close(logpath);        
  1354.                     gotoxy(1,23);
  1355.                     printf("\033[K\007\033[7;7m SYSMON-INFO: \033[0;0m logfile: '%s' full, capture closed !\n",logfilenam);
  1356.                     sleep(2);
  1357.                     error_indi=TRUE;
  1358.             }
  1359.             else
  1360.             {
  1361.                 gotoxy(1,23);
  1362.                 printf(loginfo,logfilenam,logfilesize);
  1363.                 fprintf(lpp,loginfo,logfilenam,logfilesize);
  1364.             }
  1365.         }
  1366.  
  1367.   }  
  1368.  
  1369.   pr = (struct pdsc *)proctab;
  1370.   
  1371.   for(i=1;i<=MAXPROCS;i++)              /* At first see how many processes */
  1372.   {                                       /* are running on the system !     */
  1373.         bytes = _get_process_desc(i,1,pr);
  1374.         if(bytes!=-1)
  1375.             maxip=i;
  1376.   }
  1377.  
  1378.     
  1379.   if(privileg && prillow)                /* rise priority to high value !   */  
  1380.     setpr(ownuid,65535);
  1381.   
  1382.   for(i=1;i<=maxip;i++)                    /* NOW SCANN ALL PROCESSES 1. TIME */
  1383.   {
  1384.     if(i%50==0)       /* if there are many processes don't consume to much CPU */
  1385.         tsleep(2);
  1386.  
  1387.     bytes = _get_process_desc(i,800, pr);
  1388.     if(bytes != -1)
  1389.     {    
  1390.       modadr = (char *)pr->_pmodul;
  1391.             
  1392.       if(modadr!=0)
  1393.       {
  1394.           _cpymem(pr->_pid, 4, modadr+0xc, &nameadr); 
  1395.           nameadr += (int)modadr;
  1396.           _cpymem(pr->_pid,16, nameadr,internames);
  1397.         internames[16]=0;
  1398.         strcpy(names[j],internames);
  1399.           uppercase(names[j]);    
  1400.       }    
  1401.       else
  1402.         sprintf(names[j],"<NONE>");
  1403.  
  1404.  
  1405.       id[j]=bytes;
  1406.       group[j]=pr->_group;
  1407.       user[j]=pr->_user;
  1408.       pid[j]=pr->_pid;
  1409.  
  1410.       getiopaths(pr,piopath[j]);
  1411.  
  1412.       if(id[j]==ownuid && privileg && prillow)
  1413.         prior[j]=ownprior;
  1414.       else
  1415.       {    
  1416.           prior[j]=pr->_prior;
  1417.         if(prior[j]==0 && minage==1)
  1418.             suspendcount++;
  1419.       }
  1420.  
  1421.       if(remove_flag)                /* that's for clearing the 0 priority */
  1422.       {    
  1423.         rrprior=pr->_prior;
  1424.           if(rrprior==0)
  1425.                  setpr(id[j],STANDARDPRIOR);
  1426.       }
  1427.  
  1428.       cpu_sys[j]=(unsigned int)pr->_sticks;
  1429.       estd[j]=cpu_sys[j]/(3600*tickspsecond);
  1430.       calcrest=cpu_sys[j]%(3600*tickspsecond);
  1431.       emin[j]=(calcrest/(60*tickspsecond));
  1432.       calcrest=(calcrest%(60*tickspsecond));
  1433.       esec[j]=(calcrest/tickspsecond);
  1434.  
  1435.       cpu_use[j]=(unsigned int)pr->_uticks;      
  1436.       ustd[j]=cpu_use[j]/(3600*tickspsecond);
  1437.       calcrest=cpu_use[j]%(3600*tickspsecond);
  1438.       umin[j]=(calcrest/(60*tickspsecond));
  1439.       calcrest=(calcrest%(60*tickspsecond));
  1440.       usec[j]=(calcrest/tickspsecond);
  1441.  
  1442.       rxbytes[j]=(unsigned int)pr->_rbytes;
  1443.       txbytes[j]=(unsigned int)pr->_wbytes;
  1444.       ica[j]=(unsigned int)pr->_icalls;
  1445.       fca[j]=(unsigned int)pr->_fcalls;
  1446.       callnam[j]=(unsigned int) pr->_scall & 0xFF;
  1447.       signal[j]=(unsigned short)pr->_signal;
  1448.       cid[j]=(unsigned short)pr->_cid;
  1449.       ticks[0][j] = pr->_uticks+pr->_sticks;
  1450.  
  1451.       adress[j]=(modlink(names[j],0));
  1452.       if(adress[j]>0)
  1453.       {
  1454.           _cpymem(0, 60, adress[j], workbuff); 
  1455.           modaccess=(struct modulhead *) workbuff;
  1456.           modsize[j]=modaccess->modulsize;
  1457.           modown[j]=modaccess->modulowner;
  1458.           revision[j]=modaccess->moduledition;
  1459.           munlink(adress[j]);
  1460.       }
  1461.       j++;
  1462.     }
  1463.   }
  1464.  
  1465.   if(privileg && prillow)          /* set back priority to normal value   */
  1466.     setpr(ownuid,ownprior);
  1467.  
  1468.  
  1469.   if(!icpt_flag)                /* sleep a little bit ! */
  1470.   {
  1471.     if(start_flag)
  1472.         tsleep(delay*50);
  1473.     else
  1474.     {
  1475.         start_flag=TRUE;
  1476.         tsleep(40);
  1477.     }
  1478.   }
  1479.  
  1480.   if(privileg && prillow)            /* set priority to maximum ! */  
  1481.     setpr(ownuid,65535);
  1482.  
  1483.   imax = j-1;
  1484.   for(i=0;i<=imax;i++)
  1485.   {
  1486.     
  1487.     bytes = _get_process_desc(id[i],800, pr);
  1488.     if(bytes != -1)
  1489.     {
  1490.       modadr = (char *)pr->_pmodul;
  1491.       if(modadr!=0)
  1492.       {
  1493.           _cpymem(pr->_pid, 4, modadr+0xc, &nameadr); 
  1494.           nameadr += (int)modadr;
  1495.           _cpymem(pr->_pid, 16, nameadr, internames);
  1496.         internames[16]=0;
  1497.         strcpy(newnames,internames);
  1498.         uppercase(newnames);    
  1499.       }    
  1500.       else
  1501.         sprintf(newnames,"<NONE>");
  1502.  
  1503.       if((strcmp(newnames,names[i]))==0)
  1504.       {                                        /* process is still the same ! */
  1505.         ticks[1][i] = pr->_uticks+pr->_sticks;
  1506.       }
  1507.       else                                  /* process is not the same !   */
  1508.       {
  1509.         strcpy(names[i],newnames);           /* get the new name of process ! */
  1510.           id[i]=bytes;                        /* now get all information again */
  1511.           group[i]=pr->_group;
  1512.           user[i]=pr->_user;
  1513.           pid[i]=pr->_pid;
  1514.  
  1515.         getiopaths(pr,piopath[i]);
  1516.  
  1517.         if(id[i]==ownuid && privileg)
  1518.             prior[i]=ownprior;
  1519.         else
  1520.               prior[i]=pr->_prior;
  1521.   
  1522.           cpu_sys[i]=(unsigned int)pr->_sticks;
  1523.           estd[i]=cpu_sys[i]/(3600*tickspsecond);
  1524.           calcrest=cpu_sys[i]%(3600*tickspsecond);
  1525.           emin[i]=(calcrest/(60*tickspsecond));
  1526.           calcrest=(calcrest%(60*tickspsecond));
  1527.           esec[i]=(calcrest/tickspsecond);
  1528.  
  1529.           cpu_use[i]=(unsigned int)pr->_uticks;      
  1530.           ustd[i]=cpu_use[i]/(3600*tickspsecond);
  1531.           calcrest=cpu_use[i]%(3600*tickspsecond);
  1532.           umin[i]=(calcrest/(60*tickspsecond));
  1533.           calcrest=(calcrest%(60*tickspsecond));
  1534.           usec[i]=(calcrest/tickspsecond);
  1535.  
  1536.           rxbytes[i]=(unsigned int)pr->_rbytes;
  1537.           txbytes[i]=(unsigned int)pr->_wbytes;
  1538.           ica[i]=(unsigned int)pr->_icalls;
  1539.           fca[i]=(unsigned int)pr->_fcalls;
  1540.         callnam[i]=(unsigned int) pr->_scall & 0xFF;
  1541.           signal[i]=(unsigned short)pr->_signal;
  1542.           cid[i]=(unsigned short)pr->_cid;
  1543.           ticks[0][i]=pr->_uticks+pr->_sticks;
  1544.         ticks[1][i]=ticks[0][i];            /* there are no ticks elapsed ! */
  1545.         adress[i]=(modlink(names[i],0));
  1546.         if(adress[i]>0)                 /* the module is accessable   ! */
  1547.         {
  1548.             _cpymem(0, 60, adress[i], workbuff); 
  1549.            modaccess=(struct modulhead *) workbuff;
  1550.             modsize[i]=modaccess->modulsize;
  1551.             modown[i]=modaccess->modulowner;
  1552.             revision[i]=modaccess->moduledition;
  1553.             munlink(adress[i]);
  1554.           }
  1555.         maxprocent[i]=0;                    /* due to the process is new !  */    
  1556.       }
  1557.     }
  1558.     else
  1559.     {
  1560.       ticks[1][i]=ticks[0][i];
  1561.       maxprocent[i]=0;
  1562.       piopath[i][0]=0;    
  1563.       names[i][0]=0;    
  1564.     }
  1565.   }
  1566.   if(privileg && prillow)      /* setback the priority to normal values */  
  1567.     setpr(ownuid,ownprior);
  1568.  
  1569.   all_cpu=0;
  1570.   for(i=0;i<=imax;i++)
  1571.   {
  1572.     cpu_time[i]=((float)(ticks[1][i]-ticks[0][i]))
  1573.     /(float)(delay*50);
  1574.     all_cpu+=cpu_time[i];
  1575.   }
  1576.  
  1577.   act_task=0;
  1578.   for (i=0;i<=imax;i++)
  1579.   {
  1580.     if(all_cpu>0)
  1581.         cpu_proc[i] = (int)(cpu_time[i]*100/all_cpu);
  1582.     else
  1583.         cpu_proc[i]=0;
  1584.  
  1585.     if(cpu_proc[i]>0 && i>0)
  1586.         act_task++;
  1587.   }  
  1588. }
  1589. /*--------------------------------------------------------------------------*/
  1590. display_time()
  1591. {
  1592.   register struct sgtbuf timebuf,*t;
  1593.   register int frs_delay;
  1594.  
  1595.   t=&timebuf;
  1596.   getime(t);
  1597.   monat=t->t_month;
  1598.   tag=t->t_day;
  1599.   jahr=t->t_year;
  1600.   std=t->t_hour;
  1601.   min=t->t_minute;
  1602.   sec=t->t_second;
  1603.  
  1604. #ifdef DEMO  
  1605.   if(monat>DEMOMON || jahr>DEMOYEAR)
  1606.   {
  1607.     tmode(0,1);
  1608.     cursoron();
  1609.     effect();
  1610.     cls();
  1611.     printf("Demoversion time exeeded !\n");
  1612.     switch_ctrl(RESTORE);
  1613.     if(strncmp(portnam,"PKS",3)==0)
  1614.         sleep(2);
  1615.     exit(0);
  1616.   }    
  1617. #endif
  1618.   
  1619.   if(delay>3)
  1620.     frs_delay=2;
  1621.   else
  1622.     frs_delay=delay;
  1623.  
  1624.   if(min==16 && sec==7)
  1625.   {
  1626.     gotoxy(1,23);
  1627.     printf("\033[K\033[7;7m NOTE: \033[0;0m This program is dedicated to: Ruth S. Schmitt !\n");
  1628.     if(logindi)
  1629.         fprintf(lpp,"\033[K\033[7;7m NOTE: \033[0;0m This program is dedicated to: Ruth S. Schmitt !\n");
  1630.     sleep(5);
  1631.     gotoxy(1,23);
  1632.     printf("\033[K\n");
  1633.     if(logindi)
  1634.         fprintf(lpp,"\033[K\n");
  1635.     error_indi=TRUE;
  1636.   }
  1637.  
  1638.  
  1639.   if(start_flag && pwh && icpt_flag!=TRUE)
  1640.   { 
  1641.     if(unkown_flag==TRUE || 
  1642.     (min%PASSWORDPROOFTIME==0 && (sec>=0 && sec<=(frs_delay))))
  1643.     /* get the passwordfile again ! */
  1644.     {
  1645.         if(!susy_flag && !unkown_flag)
  1646.         {
  1647.             gotoxy(1,23);
  1648.                 printf("%s \n",proofpassstr);
  1649.             if(logindi)
  1650.                 fprintf(lpp,"%s \n",proofpassstr);
  1651.             sleep(2);
  1652.         }
  1653.  
  1654.         setuid(0);
  1655.         get_passworddate(1);
  1656.         if(filedate[0]!=filedate[1] || filestd[0]!=filestd[1])
  1657.         {
  1658.             if(!susy_flag)
  1659.             {
  1660.                 gotoxy(1,23);
  1661.                 printf("%s %02d-%02d-%02d  %02d:%02d \n",
  1662.                 passworddatestr,
  1663.                 lastpassworddate[0],
  1664.                 lastpassworddate[1],
  1665.                 lastpassworddate[2],
  1666.                 lastpassworddate[3],
  1667.                 lastpassworddate[4]);
  1668.                 if(logindi)
  1669.                     fprintf(lpp,"%s %02d-%02d-%02d  %02d:%02d \n",
  1670.                     passworddatestr,
  1671.                     lastpassworddate[0],
  1672.                     lastpassworddate[1],
  1673.                     lastpassworddate[2],
  1674.                     lastpassworddate[3],
  1675.                     lastpassworddate[4]);
  1676.  
  1677.                 sleep(3);
  1678.  
  1679.                 gotoxy(1,23);
  1680.                 printf("%s \n",readingmodipassstr);
  1681.                 if(logindi)
  1682.                     fprintf(lpp,"%s \n",readingmodipassstr);
  1683.             }
  1684.             pwh=get_password();
  1685.         }
  1686.         else                /* passwordfile is still the same ! */
  1687.        {
  1688.             if(unkown_flag) /* but unkown_flag was set before ! */
  1689.             {
  1690.                 if(!susy_flag)
  1691.                 {
  1692.                     gotoxy(1,23);
  1693.                     printf("%s \n",readingpassstr);
  1694.                     if(logindi)
  1695.                         fprintf(lpp,"%s \n",readingpassstr);
  1696.                 }
  1697.                 pwh=get_password();
  1698.             }
  1699.         }
  1700.  
  1701.  
  1702.         setuid(oldgrp*65536+oldus);
  1703.         if(!pwh)
  1704.         {
  1705.             name_flag=FALSE;
  1706.             gotoxy(1,23);
  1707.             printf("%s \n",readpasserrstr);
  1708.             if(logindi)
  1709.                 fprintf(lpp,"%s \n",readpasserrstr);
  1710.             refresh_flag=TRUE;
  1711.             sleep(2);
  1712.            }
  1713.         else
  1714.         {
  1715.             sleep(1);
  1716.             if(!susy_flag)
  1717.             {
  1718.                 gotoxy(1,23);
  1719.                 printf("\033[K\n");
  1720.                 if(logindi)
  1721.                     fprintf(lpp,"\033[K\n");
  1722.                 error_indi=TRUE;
  1723.             }
  1724.          }
  1725.         unkown_flag=TRISTATE; 
  1726.     }
  1727.   }
  1728.  
  1729.  
  1730.   if(min)                   /* minute !=0 ??? */
  1731.   {
  1732.     if((min%15)==0)         /* clear screen & unkown_flag all 15 minutes ! */
  1733.     {
  1734.         if(sec>=30 && sec<=(31+frs_delay))
  1735.         {
  1736.             if(refresh_flag==FALSE) /* only if there was no refresh before !*/    
  1737.                 refresh_flag=TRUE;
  1738.             unkown_flag=FALSE;
  1739.         }
  1740.     }
  1741.   }
  1742.   else                                                /* minute = 0 !    */
  1743.   {
  1744.     if(sec>=30 && sec<=(30+frs_delay) && refresh_flag==FALSE) /* clear display ! */
  1745.         refresh_flag=TRUE;
  1746.   }
  1747.  
  1748.  
  1749.   minage=_getsys(D_MinPty,2);
  1750.   maxage=_getsys(D_MaxAge,2);
  1751.  
  1752.   if(nodeflag)
  1753.   {
  1754.       if(nodenamlen<6)
  1755.           gotoxy(10,2);
  1756.       else    
  1757.           gotoxy(10+5-nodenamlen,2);
  1758.  
  1759.       printf("\033[7;7m  ");
  1760.       if(logindi)    
  1761.           fprintf(lpp,"\033[7;7m  ");
  1762.       if(oldprocs==imax)
  1763.       {    
  1764.           printf("%02d:%02d:%02d  %02d-%3s-19%02d  NODE: %s  TASKS: %03d  CPU: %d  \033[0;0m\n",
  1765.           std, min ,sec, tag, monate[monat-1], jahr,nodename,imax+1,processor);
  1766.         if(logindi)
  1767.               fprintf(lpp,"%02d:%02d:%02d  %02d-%3s-19%02d  NODE: %s  TASKS: %03d  CPU: %d  \033[0;0m\n",
  1768.               std, min ,sec, tag, monate[monat-1], jahr,nodename,imax+1,processor);
  1769.       }    
  1770.       else
  1771.       {
  1772.           printf("%02d:%02d:%02d  %02d-%3s-19%02d  NODE: %s  TASKS: \033[1;1m%03d\033[0;0m\033[7;7m  CPU: %d  \033[0;0m\n",
  1773.           std, min ,sec, tag, monate[monat-1], jahr,nodename,imax+1,processor);
  1774.         if(logindi)
  1775.               fprintf(lpp,"%02d:%02d:%02d  %02d-%3s-19%02d  NODE: %s  TASKS: \033[1;1m%03d\033[0;0m\033[7;7m  CPU: %d  \033[0;0m\n",
  1776.               std, min ,sec, tag, monate[monat-1], jahr,nodename,imax+1,processor);
  1777.       }
  1778.   }
  1779.   else
  1780.   {
  1781.       gotoxy(17,2);
  1782.       printf("\033[7;7m  ");
  1783.       if(logindi)    
  1784.           fprintf(lpp,"\033[7;7m  ");
  1785.       if(oldprocs==imax)
  1786.       {    
  1787.           printf("%02d:%02d:%02d  %02d-%3s-19%02d  TASKS: %03d  CPU: %d  \033[0;0m\n",
  1788.           std, min ,sec, tag, monate[monat-1], jahr,imax+1,processor);
  1789.         if(logindi)
  1790.               fprintf(lpp,"%02d:%02d:%02d  %02d-%3s-19%02d  TASKS: %03d  CPU: %d  \033[0;0m\n",
  1791.               std, min ,sec, tag, monate[monat-1], jahr,imax+1,processor);
  1792.       }
  1793.       else
  1794.       {
  1795.           printf("%02d:%02d:%02d  %02d-%3s-19%02d  TASKS: \033[1;1m%03d\033[0;0m\033[7;7m  CPU: %d  \033[0;0m\n",
  1796.           std, min ,sec, tag, monate[monat-1], jahr,imax+1,processor);
  1797.         if(logindi)
  1798.               fprintf(lpp,"%02d:%02d:%02d  %02d-%3s-19%02d  TASKS: \033[1;1m%03d\033[0;0m\033[7;7m  CPU: %d  \033[0;0m\n",
  1799.               std, min ,sec, tag, monate[monat-1], jahr,imax+1,processor);
  1800.       }
  1801.   }
  1802.   oldprocs=imax;  
  1803.   sprintf(displaystring,"Minage: ");
  1804.  
  1805.   if(minage==oldminage)
  1806.     sprintf(&displaystring[strlen(displaystring)],"%05d  ",minage);
  1807.   else
  1808.     sprintf(&displaystring[strlen(displaystring)],"\033[7;7m\033[1;1m%05d\033[0;0m  ",minage);
  1809.  
  1810.   sprintf(&displaystring[strlen(displaystring)],"Maxage: ");
  1811.   
  1812.   if(maxage==oldmaxage)
  1813.     sprintf(&displaystring[strlen(displaystring)],"%05d  ",maxage);
  1814.   else
  1815.     sprintf(&displaystring[strlen(displaystring)],"\033[7;7m\033[1;1m%05d\033[0;0m  ",maxage);
  1816.  
  1817.   sprintf(&displaystring[strlen(displaystring)],"ActiveTasks: ");
  1818.  
  1819.   if(act_task!=oldact_task)
  1820.     sprintf(&displaystring[strlen(displaystring)],"\033[7;7m\033[1;1m%03d\033[0;0m  ",act_task);
  1821.   else
  1822.     sprintf(&displaystring[strlen(displaystring)],"%03d  ",act_task);
  1823.  
  1824.   sprintf(&displaystring[strlen(displaystring)],"Delay: ");
  1825.  
  1826.   if(delay!=myolddelay)
  1827.     sprintf(&displaystring[strlen(displaystring)],"\033[7;7m\033[1;1m%02ds\033[0;0m  ",delay);
  1828.   else    
  1829.     sprintf(&displaystring[strlen(displaystring)],"%02ds  ",delay);
  1830.  
  1831.   if(porthandle!=-1)
  1832.   {
  1833.     gotoxy(5,3);
  1834.     sprintf(&displaystring[strlen(displaystring)],"Port: /%s \n",portnam);
  1835.   }
  1836.   else
  1837.   {
  1838.     gotoxy(8,3);
  1839.     sprintf(&displaystring[strlen(displaystring)],"\n");
  1840.   }
  1841.   printf(displaystring);
  1842.   if(logindi)
  1843.     fprintf(lpp,displaystring);
  1844.  
  1845.   oldminage=minage;
  1846.   oldmaxage=maxage;
  1847.   oldact_task=act_task;
  1848.   myolddelay=delay;
  1849. }
  1850. /*--------------------------------------------------------------------------*/
  1851. balken(n)
  1852. register int n;
  1853. {
  1854.   register int i,j=0;
  1855.   
  1856.   printf("\033(0");
  1857.   if(logindi)  
  1858.     fprintf(lpp,"\033(0");
  1859.   for(i=1;i<=(n/2.5);i++)
  1860.   {
  1861.     printf("a");
  1862.     if(logindi)
  1863.         fprintf(lpp,"a");
  1864.     j++;
  1865.   }   
  1866.   printf("\033(B");
  1867.   if(logindi)  
  1868.     fprintf(lpp,"\033(B");
  1869.  
  1870.   if(n==100)
  1871.     return(0);  
  1872.  
  1873.    for(i=j+1;i<=40;i++)
  1874.    {
  1875.     if(i%10==0 && i!=40)
  1876.     {
  1877.         printf("\033(0x\033(B");
  1878.         if(logindi)
  1879.             fprintf(lpp,"\033(0x\033(B");
  1880.     } 
  1881.     else
  1882.     {
  1883.         printf(" ");
  1884.         if(logindi)
  1885.             fprintf(lpp," ");
  1886.     }
  1887.    }
  1888. }
  1889. /*--------------------------------------------------------------------------*/
  1890. display_procs()
  1891. {
  1892.   register int i,kj,count=0, im;
  1893.   int pmax=0,killus;
  1894.  
  1895.   for(i=0;i<=imax;i++)
  1896.   {
  1897.     if(icpt_flag)
  1898.     {
  1899.       fflush(stdout);    
  1900.       if(logindi)
  1901.           fflush(lpp);    
  1902.       return(0);
  1903.     }
  1904.  
  1905.     if(cpu_proc[i]>0)
  1906.     {
  1907.       gotoxy(0,6+count);
  1908.       printf("%03d",id[i]);
  1909.       if(logindi)
  1910.           fprintf(lpp,"%03d",id[i]);
  1911.  
  1912.       gotoxy(5,6+count);
  1913.  
  1914.       if(pwh && name_flag)
  1915.       {
  1916.           killus=disp_user(i);
  1917.         if(!killus && watchy_flag)
  1918.         {
  1919.             if(!mark_proc)
  1920.                 mark_proc=id[i];
  1921.             else
  1922.                 killit=TRUE;
  1923.         }
  1924.       }
  1925.       else
  1926.       {
  1927.           if(prior_flag)
  1928.           {
  1929.             if(prior[i]<=128)
  1930.             {
  1931.                 printf("%5d",prior[i]);
  1932.                 if(logindi)
  1933.                     fprintf(lpp,"%5d",prior[i]);
  1934.             }
  1935.             else
  1936.             {
  1937.                 printf("\033[7;7m%5d\033[0;0m",prior[i]);
  1938.                 if(logindi)
  1939.                     fprintf(lpp,"\033[7;7m%5d\033[0;0m",prior[i]);
  1940.             }
  1941.           }
  1942.           else
  1943.         {
  1944.             printf("%01d.%01d  ",group[i],user[i]);
  1945.             if(logindi)
  1946.                 fprintf(lpp,"%01d.%01d  ",group[i],user[i]);
  1947.         }
  1948.       }
  1949.  
  1950.       gotoxy(16,6+count); /* x was 12 */
  1951.       if(i!=0)
  1952.       {
  1953.               printf("%-15s ",names[i]);
  1954.             if(logindi)
  1955.                    fprintf(lpp,"%-15s ",names[i]);
  1956.       }
  1957.       else
  1958.       {
  1959.             printf("CPU IDLE        ");
  1960.             if(logindi)
  1961.                 fprintf(lpp,"CPU IDLE        ");
  1962.       }
  1963.  
  1964.       gotoxy(31,6+count);
  1965.       if(maxh_flag && i!=0)
  1966.       {
  1967.             if(maxprocent[i]<=cpu_proc[i])
  1968.                 maxprocent[i]=cpu_proc[i];
  1969.             printf("\033[7;7m\033[1;1m%3d %%\033[0;0m",maxprocent[i]);
  1970.             if(logindi)
  1971.                 fprintf(lpp,"\033[7;7m\033[1;1m%3d %%\033[0;0m",maxprocent[i]);
  1972.       }
  1973.       else
  1974.       {    
  1975.           if(mark && cpu_proc[i]>=75 && i!=0)
  1976.         {
  1977.             printf("\033[7;7m%3d %%\033[0;0m",cpu_proc[i]);
  1978.             if(logindi)
  1979.                 fprintf(lpp,"\033[7;7m%3d %%\033[0;0m",cpu_proc[i]);
  1980.         }
  1981.           else
  1982.         {
  1983.             printf("%3d %%",cpu_proc[i]);
  1984.             if(logindi)
  1985.                 fprintf(lpp,"%3d %%",cpu_proc[i]);
  1986.         }
  1987.       }
  1988.       gotoxy(38,6+count);
  1989.       balken(cpu_proc[i]);
  1990.       count++;
  1991.  
  1992.       if(count==16 && imax>=count)  /* next screen ! */
  1993.       {
  1994.         printf("\n");
  1995.         if(logindi)
  1996.             fprintf(lpp,"\n");
  1997.         if(!icpt_flag)
  1998.             sleep(2);
  1999.         clear_rest(count);
  2000.         if(icpt_flag)
  2001.         {
  2002.           fflush(stdout);
  2003.           if(logindi)
  2004.             fflush(lpp);
  2005.           return(0);
  2006.         }    
  2007.         count=0;
  2008.       }
  2009.     }
  2010.   }
  2011.   clear_rest(count);
  2012. }
  2013. /*--------------------------------------------------------------------------*/
  2014. char *syscname(n)
  2015. register int n;
  2016. {
  2017.    if(n >= 128 && (n-128 < (sizeof(osiotble) / sizeof(char*))))
  2018.       return osiotble[n-128];
  2019.    else if(n >= 0 && n < (sizeof(ossvtble) / sizeof(char*)))
  2020.          return ossvtble[n];
  2021.    else return badcode;
  2022. }
  2023. /*--------------------------------------------------------------------------*/
  2024. check_login()
  2025. {
  2026.     register int i, login_c=0;
  2027.  
  2028.     for(i=0;i<=imax;i++)
  2029.     {
  2030.         if(strncmp("LOGIN",names[i],5)==0)
  2031.         {
  2032.             gotoxy(1,23);
  2033.             printf("\033[7;7m\033[1;1m SYSMON-INFO: \033[0;0m Process: %d  '%s' %s in progress !\033[K\n",
  2034.             id[i],names[i],piopath[i]);
  2035.             if(logindi)
  2036.             {
  2037.                 fprintf(lpp,"\033[7;7m\033[1;1m SYSMON-INFO: \033[0;0m Process: %d  '%s' %s in progress !\033[K\n",
  2038.                 id[i],names[i],piopath[i]);
  2039.             }
  2040.             login_c++;
  2041.             sleep(1);
  2042.         }
  2043.     }
  2044.     return(login_c);
  2045. }
  2046. /*--------------------------------------------------------------------------*/
  2047. display_data()
  2048. {
  2049.   register int i,kj,count=0, im;
  2050.   int pmax=0,killus;
  2051.  
  2052.   if(old_imax!=imax)
  2053.   {
  2054.     under_title();
  2055.     old_imax=imax;      
  2056.   }    
  2057.  
  2058.   if(clflg)
  2059.   for(i=1;i<=15;i++)
  2060.   {
  2061.     gotoxy(77,6+i);
  2062.     printf("\033[K\n");
  2063.     if(logindi)
  2064.         fprintf(lpp,"\033[K\n");
  2065.   }
  2066.  
  2067.  
  2068.   for(i=actualcount;i<=actualcount+15;i++)
  2069.   {
  2070.     if(icpt_flag)
  2071.     {
  2072.         clear_restdata(count);    
  2073.         fflush(stdout);
  2074.         if(logindi)
  2075.             fflush(lpp);
  2076.           return(0);
  2077.     }
  2078.  
  2079.     if(i>imax)
  2080.       break;
  2081.  
  2082.     if(susy_flag && startc==count)
  2083.     {
  2084.         gotoxy(0,6+count);
  2085.         printf("\033[1;1m\033[7;7m");
  2086.         if(logindi)
  2087.             fprintf(lpp,"\033[1;1m\033[7;7m");
  2088.         markpr=id[i];
  2089.         markprior=prior[i];
  2090.         strcpy(killnam,names[i]);
  2091.     }
  2092.  
  2093.     if(!active_flag || user[i]!=0 || i==0) /* display user tasks */
  2094.     {
  2095.       gotoxy(0,6+count);  /* display id       */
  2096.       printf("%03d ",id[i]);
  2097.       if(logindi)    
  2098.           fprintf(lpp,"%03d ",id[i]);
  2099.       gotoxy(5,6+count);  /* display pid      */
  2100.       printf("%03d  ",pid[i]);
  2101.       if(logindi)    
  2102.           fprintf(lpp,"%03d  ",pid[i]);
  2103.       gotoxy(10,6+count);
  2104.  
  2105.       if(pwh && name_flag)
  2106.       {
  2107.         killus=disp_user(i);
  2108.         if(!killus && watchy_flag)
  2109.         {
  2110.             if(!mark_proc)
  2111.                 mark_proc=id[i];
  2112.             else
  2113.                 killit=TRUE;
  2114.         }
  2115.       }
  2116.       else
  2117.       {    
  2118.         if(prior[i]<=128 || !i || (susy_flag && startc==count)) /* display prior    */
  2119.         {
  2120.             printf("%5d  ",prior[i]);
  2121.             if(logindi)
  2122.                 fprintf(lpp,"%5d  ",prior[i]);
  2123.         }
  2124.           else
  2125.         {
  2126.             printf("\033[7;7m%5d\033[0;0m  ",prior[i]);
  2127.             if(logindi)
  2128.                 fprintf(lpp,"\033[7;7m%5d\033[0;0m  ",prior[i]);
  2129.         }
  2130.           gotoxy(17,6+count);
  2131.           printf("%01d.%01d  ",group[i],user[i]);
  2132.         if(logindi)
  2133.               fprintf(lpp,"%01d.%01d  ",group[i],user[i]);
  2134.       }
  2135.       fflush(stdout);
  2136.       gotoxy(22,6+count);
  2137.       if(i!=0)
  2138.       {
  2139.              printf("%-15s ",names[i]);
  2140.             if(logindi)
  2141.                   fprintf(lpp,"%-15s ",names[i]);
  2142.       }
  2143.       else
  2144.       {
  2145.         if(exmode==2)
  2146.         {
  2147.               printf("%-15s ",names[i]);
  2148.             if(logindi)
  2149.                   fprintf(lpp,"%-15s ",names[i]);
  2150.         }    
  2151.         else
  2152.         {    
  2153.               printf("CPU IDLE        ");
  2154.             if(logindi)
  2155.                   fprintf(lpp,"CPU IDLE        ");
  2156.         }
  2157.       }
  2158.       gotoxy(38,6+count);
  2159.       switch(exmode)
  2160.       {
  2161.         case 0:
  2162.             if(rxbytes[i]<1000000 && txbytes[i]<1000000)
  2163.             {
  2164.                  printf("%8d %8d ",rxbytes[i],txbytes[i]);
  2165.                     if(logindi)
  2166.                      fprintf(lpp,"%8d %8d ",rxbytes[i],txbytes[i]);
  2167.             }
  2168.             else
  2169.             {
  2170.                 if(rxbytes[i]>1000000000 || txbytes[i]>1000000000)
  2171.                 {
  2172.                     printf("%6dMB %6dMB ",(rxbytes[i]/1024000),(txbytes[i]/1024000));
  2173.                     if(logindi)
  2174.                         fprintf(lpp,"%6dMB %6dMB ",(rxbytes[i]/1024000),(txbytes[i]/1024000));
  2175.                 }
  2176.                 else
  2177.                 {
  2178.                     printf("%6dkb %6dkb ",(rxbytes[i]/1024),(txbytes[i]/1024));
  2179.                     if(logindi)
  2180.                         fprintf(lpp,"%6dkb %6dkb ",(rxbytes[i]/1024),(txbytes[i]/1024));
  2181.                 }
  2182.             }
  2183.             break;
  2184.         case 1:
  2185.             if(ica[i]<10000000)
  2186.             {
  2187.                   printf("%8d ",ica[i]);
  2188.                 if(logindi)
  2189.                       fprintf(lpp,"%8d ",ica[i]);
  2190.             }
  2191.             else
  2192.             {
  2193.                   printf("%7dK ",(ica[i]/1000));
  2194.                 if(logindi)
  2195.                       fprintf(lpp,"%7dK ",(ica[i]/1000));
  2196.             }
  2197.  
  2198.             if(fca[i]<10000000)
  2199.             {
  2200.                 printf("%8d ",fca[i]);
  2201.                 if(logindi)
  2202.                       fprintf(lpp,"%8d ",fca[i]);
  2203.             }
  2204.             else
  2205.             {
  2206.                 printf("%7dK ",(fca[i]/1000));
  2207.                 if(logindi)
  2208.                       fprintf(lpp,"%7dK ",(fca[i]/1000));
  2209.             }
  2210.             break;
  2211.         case 2:
  2212.             if(adress[i]>0)
  2213.             {
  2214.                   printf("%8x   %6d  ",adress[i],modsize[i]);
  2215.                 if(logindi)
  2216.                       fprintf(lpp,"%8x   %6d  ",adress[i],modsize[i]);
  2217.             }
  2218.             else
  2219.             {
  2220.                   printf("--------   ------  ");
  2221.                 if(logindi)
  2222.                       fprintf(lpp,"--------   ------  ");
  2223.             }
  2224.             break;
  2225.         case 3:
  2226.                 printf("%-40s",piopath[i]);
  2227.                 if(logindi)
  2228.                       fprintf(lpp,"%-40s",piopath[i]);
  2229.             break;
  2230.       }
  2231.       fflush(stdout);
  2232.     
  2233.       switch(exmode)
  2234.       {
  2235.         case 0:
  2236.             gotoxy(56,6+count);
  2237.               printf("%3d:%02d:%02d  ",estd[i],emin[i],esec[i]);
  2238.             if(logindi)
  2239.                   fprintf(lpp,"%3d:%02d:%02d  ",estd[i],emin[i],esec[i]);
  2240.               gotoxy(67,6+count);
  2241.               printf("%3d:%02d:%02d ",ustd[i],umin[i],usec[i]);
  2242.             if(logindi)
  2243.                   fprintf(lpp,"%3d:%02d:%02d ",ustd[i],umin[i],usec[i]);
  2244.             break;
  2245.         case 1:
  2246.             gotoxy(56,6+count);
  2247.               printf("%-7s ",syscname(callnam[i]));
  2248.             if(logindi)
  2249.                   fprintf(lpp,"%-7s ",syscname(callnam[i]));
  2250.             gotoxy(64,6+count);
  2251.               printf("%5d  ",signal[i]);
  2252.             if(logindi)
  2253.                   fprintf(lpp,"%5d  ",signal[i]);
  2254.               gotoxy(71,6+count);
  2255.               printf("%5d ",cid[i]);
  2256.             if(logindi)
  2257.                   fprintf(lpp,"%5d ",cid[i]);
  2258.               break;
  2259.         case 2:
  2260.             if(adress[i]>0)
  2261.             {
  2262.                 gotoxy(57,6+count);
  2263.                   printf("%5d      ",revision[i]);
  2264.                 if(logindi)
  2265.                       fprintf(lpp,"%5d      ",revision[i]);
  2266.                   gotoxy(68,6+count);
  2267.                   printf(" %d.%d     ",
  2268.                 ((modown[i] & 0xffff0000)>>16),
  2269.                 (modown[i] & 0x0000ffff));
  2270.                 if(logindi)
  2271.                       fprintf(lpp," %d.%d     ",
  2272.                     ((modown[i] & 0xffff0000)>>16),
  2273.                     (modown[i] & 0x0000ffff));
  2274.             }
  2275.             else
  2276.             {
  2277.                 gotoxy(57,6+count);
  2278.                   printf("-----      ");
  2279.                 if(logindi)
  2280.                       fprintf(lpp,"-----      ");
  2281.                   gotoxy(68,6+count);
  2282.                   printf("--.--     ");
  2283.                 if(logindi)
  2284.                       fprintf(lpp,"--.--     ");
  2285.             }
  2286.             break;
  2287.       }
  2288.       fflush(stdout);
  2289.       gotoxy(77,6+count);
  2290.  
  2291.       if(cpu_proc[i]>0)
  2292.       {
  2293.         if(maxh_flag && i!=0)
  2294.         {
  2295.             if(maxprocent[i]<=cpu_proc[i])
  2296.                 maxprocent[i]=cpu_proc[i];
  2297.             printf("\033[7;7m\033[1;1m%3d%%\033[0;0m\n",maxprocent[i]);
  2298.             if(logindi)
  2299.                 fprintf(lpp,"\033[7;7m\033[1;1m%3d%%\033[0;0m\n",maxprocent[i]);
  2300.         }    
  2301.         else    
  2302.         {
  2303.             printf("\033[7;7m%3d%%\033[0;0m\n",cpu_proc[i]);
  2304.             if(logindi)
  2305.                 fprintf(lpp,"\033[7;7m%3d%%\033[0;0m\n",cpu_proc[i]);
  2306.         }
  2307.       }
  2308.       else
  2309.       {
  2310.         if(susy_flag)
  2311.         {
  2312.             if(prior[i]==0 && minage==1)
  2313.             {
  2314.                 printf("\033[0;0m  *  \n");
  2315.                 if(logindi)
  2316.                     fprintf(lpp,"\033[0;0m  *  \n");
  2317.             }
  2318.             else
  2319.             {
  2320.                 printf("\033[0;0m     \n");
  2321.                 if(logindi)
  2322.                     fprintf(lpp,"\033[0;0m     \n");
  2323.             }
  2324.         }
  2325.         else
  2326.         {
  2327.             if(prior[i]==0 && minage==1)
  2328.             {
  2329.                 printf("  *  \n");
  2330.                 if(logindi)
  2331.                 fprintf(lpp,"  *  \n");
  2332.             }
  2333.             else
  2334.             {
  2335.                 printf("     \n");
  2336.                 if(logindi)
  2337.                     fprintf(lpp,"     \n");
  2338.             }
  2339.         }
  2340.       }
  2341.       fflush(stdout);        
  2342.       count++;
  2343.       
  2344.     }  /* end of active tasks !   */
  2345.  }
  2346.  clear_restdata(count);
  2347. }
  2348. /*----------------------------------------------------------------------*/
  2349. clear_restdata(ui)
  2350. register int ui;
  2351. {
  2352.   register int kj;
  2353.  
  2354.   for(kj=ui;kj<lastcount;kj++)
  2355.   {
  2356.     if(icpt_flag)
  2357.     {
  2358.       fflush(stdout);
  2359.       if(logindi)    
  2360.           fflush(lpp);
  2361.       return(0);
  2362.     }
  2363.     gotoxy(0,6+kj);
  2364.     printf("\033[K\n");
  2365.     if(logindi)
  2366.         fprintf(lpp,"\033[K\n");
  2367.   }
  2368.   lastcount=ui;
  2369. }
  2370. /*---------------------------------------------------------------------------*/
  2371. clear_rest(ui)
  2372. register int ui;
  2373. {
  2374.   register int kj;
  2375.  
  2376.   for(kj=ui;kj<lastcount;kj++)
  2377.   {
  2378.     if(icpt_flag)
  2379.     {
  2380.       fflush(stdout);
  2381.       if(logindi)
  2382.           fflush(lpp);
  2383.       return(0);
  2384.     }
  2385.     gotoxy(0,6+kj);
  2386.     printf("   ");
  2387.     if(logindi)
  2388.         fprintf(lpp,"   ");
  2389.     gotoxy(5,6+kj);
  2390.     if(pwh && name_flag)
  2391.     {
  2392.         printf("            ");
  2393.         if(logindi)
  2394.             fprintf(lpp,"            ");
  2395.     }
  2396.     else
  2397.     {
  2398.         printf("     ");
  2399.         if(logindi)
  2400.             fprintf(lpp,"     ");
  2401.     }
  2402.     gotoxy(16,6+kj);    /* x was 12 */
  2403.     printf("                ");
  2404.     if(logindi)
  2405.         fprintf(lpp,"                ");
  2406.     gotoxy(31,6+kj);
  2407.     printf("     ");
  2408.     if(logindi)
  2409.         fprintf(lpp,"     ");
  2410.     gotoxy(38,6+kj);
  2411.  
  2412.     printf(
  2413.     "         \033(0x\033(B         \033(0x\033(B         \033(0x\033(B          \n");
  2414.     if(logindi)
  2415.         fprintf(lpp,
  2416.     "         \033(0x\033(B         \033(0x\033(B         \033(0x\033(B          \n");
  2417.   }
  2418.   gotoxy(1,22);
  2419.   printf("\n");
  2420.   if(logindi)  
  2421.     fprintf(lpp,"\n");
  2422.   lastcount=ui;
  2423. }
  2424. /*------------------------------------------------------------------------*/
  2425. serial_error(seri_err)
  2426. int seri_err;
  2427. {
  2428.     gotoxy(1,23);
  2429.     printf("\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON-FATAL-ERROR: \033[0;0m Keyboard-Read failed !  errno=%d\n"
  2430.     ,seri_err);
  2431.     if(logindi)
  2432.         fprintf(lpp,"\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON-FATAL-ERROR: \033[0;0m Keyboard-Read failed !  errno=%d\n",
  2433.         seri_err);
  2434.     gotoxy(1,23);
  2435.     cursoron();
  2436.     tmode(0,1);
  2437.     if(logindi)
  2438.         fclose(lpp);
  2439.     switch_ctrl(RESTORE);
  2440.     if(strncmp(portnam,"PKS",3)==0)
  2441.         sleep(2);
  2442.     exit(0);
  2443. }
  2444. /*------------------------------------------------------------------------*/
  2445. clean_input()
  2446. {
  2447.     register int j, rbytes;
  2448.     char dumio[255];
  2449.  
  2450.     for(j=0;j<=10;j++)
  2451.     {
  2452.         rbytes=_gs_rdy(0);
  2453.         if(rbytes>0)
  2454.         {
  2455.             rbytes=read(0,dumio,rbytes); /* read the bytes !*/
  2456.             j=0;
  2457.         }
  2458.         else
  2459.             tsleep(5);
  2460.     }
  2461. }
  2462. /*------------------------------------------------------------------------*/
  2463. display()
  2464. {  
  2465.   register int bytes=0, rbytes=0, ptaste, i;
  2466.   int kha, inkh=0,prh, forkh,retstr=FALSE, j=0;
  2467.   int setprhand, newprior, delta=1, momage;
  2468.   int fid;
  2469.   char io_buff[255], inkstr[100], ptastbuff[100], clearcondi=2;
  2470.   char ushell[100];  
  2471.   char *sshell;
  2472.   char dc=0;
  2473.   char selecta=FALSE;
  2474.   char suicid_flag=FALSE;
  2475.  
  2476.  
  2477.  
  2478.   if(!mode_flag)
  2479.     display_frame();
  2480.   else
  2481.     display_dframe();
  2482.  
  2483.   if(!nodeflag)
  2484.   {
  2485.     gotoxy(1,23);
  2486.     printf(
  2487.     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Can't open '%s' [Node-definition file] \n",nodedefnam);
  2488.     if(logindi)
  2489.         fprintf(lpp,
  2490.     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Can't open '%s' [Node-definition file] \n",nodedefnam);
  2491.     error_indi=TRUE;
  2492.   }
  2493.  
  2494.   get_ticktime();               /* how long is a tick lasting ? */
  2495.   get_cputime();
  2496.   _ss_ssig(0,DATAPRESENT);      /* send  signal on data ready */
  2497.  
  2498.   for(;;)                 /* endless loop ! */
  2499.   {
  2500.     if(icpt_flag==FALSE)  /* icpt_flag=0 */
  2501.     {
  2502.         get_cputime();
  2503.  
  2504.         if(mode_flag && actualcount>=16 && 
  2505.         (imax+1-actualcount)==0)                     /* if last shown process */
  2506.         {                                            /* died, one page back ! */
  2507.             error_indi=FALSE;
  2508.             actualcount-=16;
  2509.             under_title();
  2510.             scc=fa+fb;
  2511.             startc=15;
  2512.         }
  2513.     }
  2514.     else        /* icpt_flag=TRUE */
  2515.     {
  2516.         fflush(stdout);
  2517.         i=0;
  2518.         ret_disp=0;
  2519.  
  2520.         for(;;)
  2521.         {
  2522.             bytes=_gs_rdy(0);
  2523.             if(bytes>0)            /* DATA PRESENT ON KYBD */
  2524.             {   
  2525.                 memset(&io_buff[0],0,sizeof(io_buff));  /* clear sign buffer */
  2526.                 
  2527.                 if(bytes>9)        /* BUFFER FULL ! */
  2528.                 {                   /* maximal 9 normal commands or 3 cursor */
  2529.                     gotoxy(1,23);   /* moves allowed ! */
  2530.                     clean_input(); /* empty pending inputbytes ! */
  2531.                     io_buff[0]='~';
  2532.                     break;
  2533.                 }
  2534.                 else
  2535.                     rbytes=read(0,io_buff,1);    /* read exactly one byte ! */
  2536.                 if(rbytes==-1)
  2537.                     serial_error(errno);
  2538.  
  2539.                 if(io_buff[0]!=ESC)    /* normal command ! */
  2540.                 {
  2541.                     io_buff[0]=toupper(io_buff[0]);
  2542.                     break;
  2543.                 }
  2544.                 else                /* ESC was detected !  */
  2545.                 {
  2546.                     for(j=0;j<=10;j++)
  2547.                     {
  2548.                         rbytes=_gs_rdy(0);
  2549.                         if(rbytes>=2)
  2550.                         {
  2551.                             j=0;
  2552.                             break;
  2553.                         }
  2554.                         else
  2555.                             tsleep(2);
  2556.                     }
  2557.  
  2558.                     if(rbytes>=2 && j==0)
  2559.                     {
  2560.                         rbytes=read(0,&io_buff[1],2);   /* read 2 more bytes !*/
  2561.                         if(rbytes==2)
  2562.                         {
  2563.                             if(io_buff[1]=='[')        /* ESC sequence detected !*/
  2564.                             {
  2565.                                 switch(io_buff[2])
  2566.                                 {
  2567.                                        case 'A':         /* CURSOR UP ! */
  2568.                                            io_buff[0]='<';
  2569.                                            break;
  2570.                                     case 'B':         /* CURSOR DOWN ! */
  2571.                                            io_buff[0]='>';
  2572.                                            break;
  2573.                                     case 'C':          /* CURSOR RIGHT ! */
  2574.                                            io_buff[0]='+';
  2575.                                            break;
  2576.                                     case 'D':        /* CURSOR LEFT ! */
  2577.                                            io_buff[0]='-';
  2578.                                            break;
  2579.                                     default:
  2580.                                         gotoxy(1,23);
  2581.                                         printf("%s\n",undefkeystr);
  2582.                                         if(logindi)
  2583.                                             fprintf(lpp,"%s\n",undefkeystr);
  2584.                                            io_buff[0]='~';
  2585.                                         error_indi=TRUE;
  2586.                                         break;
  2587.                                 }
  2588.                                 break;
  2589.                             }
  2590.                             else
  2591.                             {
  2592.                                 gotoxy(1,23);
  2593.                                 printf("%s\n",undefkeystr);
  2594.                                 if(logindi)
  2595.                                     fprintf(lpp,"%s\n",undefkeystr);
  2596.                                    io_buff[0]='~';
  2597.                                 error_indi=TRUE;
  2598.                                 break;
  2599.                             }
  2600.                         }
  2601.                         else
  2602.                             serial_error(errno);
  2603.                     }
  2604.                     else
  2605.                     {
  2606.                         gotoxy(1,23);
  2607.                         printf("%s\n",undefkeystr);
  2608.                         if(logindi)
  2609.                            fprintf(lpp,"%s\n",undefkeystr);
  2610.                         clean_input();
  2611.                         error_indi=TRUE;
  2612.                           io_buff[0]='~';
  2613.                         break;
  2614.                     }
  2615.                 }
  2616.             }
  2617.             else    /* no data present ! */
  2618.             {
  2619.                 if(i>=50)
  2620.                 {
  2621.                        gotoxy(1,23);
  2622.                     printf(
  2623.                      "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON-ERROR \033[0;0m SERIAL-DEVICE not ready ! errno=%d \n",errno);
  2624.                     if(logindi)
  2625.                         fprintf(lpp,
  2626.                          "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON-ERROR \033[0;0m SERIAL-DEVICE not ready ! errno=%d \n",errno);
  2627.                     gotoxy(1,23);
  2628.                     cursoron();
  2629.                     tmode(0,1);
  2630.                     if(logindi)
  2631.                         fclose(lpp);
  2632.                     switch_ctrl(RESTORE);
  2633.                     if(strncmp(portnam,"PKS",3)==0)
  2634.                         sleep(2);
  2635.                     exit(0);
  2636.                 }
  2637.                 tsleep(2);
  2638.                 i++;
  2639.             }
  2640.         }
  2641.  
  2642.  
  2643.         if(killer || spr_flag)
  2644.         {
  2645.             bell=OFF;
  2646.             if(killer)
  2647.             {
  2648.                 if(io_buff[0]=='Y')
  2649.                  {
  2650.                     if(suicid_flag==TRUE)
  2651.                     {
  2652.                      gotoxy(1,23);
  2653.                         printf("%s\n",jokestr);
  2654.                         if(logindi)
  2655.                             fprintf(lpp,"%s\n",jokestr);
  2656.                         suicid_flag=FALSE;
  2657.                          error_indi=TRUE;
  2658.                     }
  2659.                     else
  2660.                     {
  2661.                      gotoxy(1,23);
  2662.                         fflush(stdout);
  2663.                         tsleep(20);
  2664.                          kha=kill_pr(markpr);
  2665.                          if(kha==0)
  2666.                          {
  2667.                         sleep(1);
  2668.                              gotoxy(1,23);
  2669.                             printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Process: %d  '%s' has been killed !\n"
  2670.                              ,markpr,killnam);
  2671.                             if(logindi)
  2672.                                 fprintf(lpp,
  2673.                                  "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Process: %d  '%s' has been killed !\n"
  2674.                                  ,markpr,killnam);
  2675.                             sleep(1);
  2676.                              error_indi=TRISTATE;
  2677.                             get_cputime();
  2678.  
  2679.                             if(scc>fa+1)
  2680.                             {
  2681.                                 scc--;
  2682.                                 startc--;
  2683.                             }
  2684.                             else
  2685.                             {
  2686.                                 if(actualcount>=16)
  2687.                                 {
  2688.                                     actualcount-=16;
  2689.                                     under_title();
  2690.                                     scc--;
  2691.                                     startc=15;
  2692.                                 }
  2693.                                 else
  2694.                                     actualcount=0;
  2695.                             }
  2696.                          }
  2697.                          else
  2698.                         {
  2699.                             gotoxy(1,23);
  2700.                              printf(
  2701.                              "\033[K\007\033[7;7m\033[5;5m SYSMON ERROR: \033[0;0m Process: '%s' ID: %d can't be killed ! errno=%d \n"
  2702.                              ,killnam,markpr,kha);
  2703.                             if(logindi)                
  2704.                                  fprintf(lpp,
  2705.                                  "\033[K\007\033[7;7m\033[5;5m SYSMON ERROR: \033[0;0m Process: '%s' ID: %d can't be killed ! errno=%d \n"
  2706.                                  ,killnam,markpr,kha);
  2707.                          error_indi=TRUE;
  2708.                          }
  2709.                      }   /* end of suicid */
  2710.                  }
  2711.                  else
  2712.                  {
  2713.                      gotoxy(1,23);
  2714.                     printf(
  2715.                      "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Operation canceled. Process: %d  '%s' not killed !\n"
  2716.                      ,markpr,killnam);
  2717.                     if(logindi)
  2718.                         fprintf(lpp,
  2719.                          "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Operation canceled. Process: %d  '%s' not killed !\n"
  2720.                          ,markpr,killnam);
  2721.                     error_indi=TRUE;
  2722.                     suicid_flag=FALSE;
  2723.                  }
  2724.                  killer=FALSE;
  2725.             }    /* end of killer if */
  2726.  
  2727.             if(spr_flag==TRUE)
  2728.             {
  2729.              if(io_buff[0]=='Y')
  2730.              {
  2731.                  kha=setpr(markpr,newprior);
  2732.                  if(kha!=-1)
  2733.                  {
  2734.                     if(ownuid==markpr)
  2735.                         ownprior=newprior;
  2736.                      gotoxy(1,23);
  2737.                     printf(
  2738.                      "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Priority of process: %d  '%s' has been modified !\n"
  2739.                      ,markpr,killnam);
  2740.                     if(logindi)
  2741.                         fprintf(lpp,
  2742.                          "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Priority of process: %d  '%s' has been modified !\n"
  2743.                          ,markpr,killnam);
  2744.                     get_cputime();
  2745.                      error_indi=TRUE;
  2746.                     ret_disp=100;
  2747.                  }
  2748.                  else
  2749.                 {
  2750.                     gotoxy(1,23);
  2751.                      printf(
  2752.                      "\033[K\007\033[7;7m\033[5;5m SYSMON ERROR: \033[0;0m Priority of process: '%s' ID: %d can't be modified ! errno=%d \n"
  2753.                      ,killnam,markpr,kha);
  2754.                  error_indi=TRUE;
  2755.                     if(logindi)
  2756.                          fprintf(lpp,
  2757.                          "\033[K\007\033[7;7m\033[5;5m SYSMON ERROR: \033[0;0m Priority of process: '%s' ID: %d can't be modified ! errno=%d \n"
  2758.                          ,killnam,markpr,kha);
  2759.                  }
  2760.              }
  2761.              else
  2762.              {
  2763.                  gotoxy(1,23);
  2764.                 printf(
  2765.                  "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Operation canceled. Priority of process: '%s' not modified !\n"
  2766.                  ,killnam);
  2767.                 if(logindi)
  2768.                     fprintf(lpp,
  2769.                      "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Operation canceled. Priority of process: '%s' not modified !\n"
  2770.                      ,killnam);
  2771.                 error_indi=TRUE;
  2772.              }
  2773.              spr_flag=FALSE;
  2774.             }
  2775.  
  2776.             if(spr_flag==SUSPEND)
  2777.             {
  2778.                 if(io_buff[0]=='Y')
  2779.                  {
  2780.                     if(markprior>0)               /* the process is not suspended yet ! */
  2781.                     {
  2782.                         if(suicid_flag==TRUE)
  2783.                         {
  2784.                          gotoxy(1,23);
  2785.                             printf("%s\n",jokestr);
  2786.                             if(logindi)
  2787.                                 fprintf(lpp,"%s\n",jokestr);
  2788.                             suicid_flag=FALSE;
  2789.                              error_indi=TRUE;
  2790.                         }
  2791.                         else
  2792.                         {
  2793.                              setpr(ownuid,65535);   /* set own priority to maximum ! */ 
  2794.  
  2795.                              kha=setpr(markpr,0);   /* set process priority to 0 !   */ 
  2796.                              if(kha!=-1)    
  2797.                              {
  2798.                                 _setsys(D_MinPty,2,1);    /* set MINPTY to 1 ! */
  2799.                                 if(ownuid==markpr)
  2800.                                     ownprior=newprior;
  2801.                                  gotoxy(1,23);
  2802.                                 printf(
  2803.                                  "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Process: %d  '%s' has been suspended !\n"
  2804.                                  ,markpr,killnam);
  2805.                                 if(logindi)
  2806.                                     fprintf(lpp,
  2807.                                      "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Process: %d  '%s' has been suspended !\n"
  2808.                                      ,markpr,killnam);
  2809.                                 get_cputime();
  2810.                                  error_indi=TRUE;
  2811.                                 ret_disp=100;
  2812.                             }
  2813.                               else
  2814.                             {
  2815.                                 gotoxy(1,23);
  2816.                                  printf(
  2817.                                  "\033[K\007\033[7;7m\033[5;5m SYSMON ERROR: \033[0;0m Process: '%s' ID: %d can't be suspend ! errno=%d \n"
  2818.                                  ,killnam,markpr,kha);
  2819.                                 if(logindi)
  2820.                                  fprintf(lpp,
  2821.                                  "\033[K\007\033[7;7m\033[5;5m SYSMON ERROR: \033[0;0m Process: '%s' ID: %d can't be suspend ! errno=%d \n"
  2822.                                  ,killnam,markpr,kha);
  2823.                              error_indi=TRUE;
  2824.                              }
  2825.                         }
  2826.                     }
  2827.                     else
  2828.                     {
  2829.                          kha=setpr(markpr,STANDARDPRIOR);
  2830.                          if(kha!=-1)
  2831.                          {
  2832.                             if(ownuid==markpr)
  2833.                                 ownprior=newprior;
  2834.                              gotoxy(1,23);
  2835.                             printf(
  2836.                              "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Process: %d  '%s' has been enabled !\n"
  2837.                              ,markpr,killnam);
  2838.                             if(logindi)
  2839.                                 fprintf(lpp,
  2840.                                  "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Process: %d  '%s' has been enabled !\n"
  2841.                                  ,markpr,killnam);
  2842.                             get_cputime();        
  2843.                              error_indi=TRUE;
  2844.                             ret_disp=100;
  2845.                          }
  2846.                          else
  2847.                         {
  2848.                             gotoxy(1,23);
  2849.                              printf(
  2850.                              "\033[K\007\033[7;7m\033[5;5m SYSMON ERROR: \033[0;0m Process: '%s' ID: %d can't be enabled ! errno=%d \n"
  2851.                              ,killnam,markpr,kha);
  2852.                             if(logindi)
  2853.                                  fprintf(lpp,
  2854.                                  "\033[K\007\033[7;7m\033[5;5m SYSMON ERROR: \033[0;0m Process: '%s' ID: %d can't be enabled ! errno=%d \n"
  2855.                                  ,killnam,markpr,kha);
  2856.                          error_indi=TRUE;
  2857.                          }
  2858.                     }
  2859.                 }
  2860.                  else
  2861.                  {
  2862.                      gotoxy(1,23);
  2863.                     printf(
  2864.                      "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Operation canceled. Process: '%s' not suspend !\n"
  2865.                      ,killnam);
  2866.                     if(logindi)
  2867.                         fprintf(lpp,
  2868.                          "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Operation canceled. Process: '%s' not suspend !\n"
  2869.                          ,killnam);
  2870.                     error_indi=TRUE;
  2871.                  }
  2872.                  spr_flag=FALSE;
  2873.             }
  2874.         }
  2875.         else
  2876.         {
  2877.               if(io_buff[0]=='~')                    
  2878.                 goto Goon;
  2879.  
  2880.               if(io_buff[0]!='A' && io_buff[0]!='G' && io_buff[0]!='U' &&
  2881.               io_buff[0]!='+' && io_buff[0]!='-' && io_buff[0]!='H' &&
  2882.             io_buff[0]!='N' && io_buff[0]!='S' && io_buff[0]!='<' &&
  2883.             io_buff[0]!='>' && io_buff[0]!='K' && io_buff[0]!='P' &&
  2884.             io_buff[0]!='F' && io_buff[0]!='D' && io_buff[0]!='R' &&
  2885.             io_buff[0]!='T' && io_buff[0]!='M' && io_buff[0]!='C' &&
  2886.             io_buff[0]!='B' && io_buff[0]!='W' && io_buff[0]!='J' &&
  2887.             io_buff[0]!='E' && io_buff[0]!='I' && io_buff[0]!='O' &&
  2888.             io_buff[0]!='X' && io_buff[0]!='L' && io_buff[0]!='Z' &&
  2889.             io_buff[0]!='1' && io_buff[0]!='2' && io_buff[0]!='V')
  2890.               {
  2891.                 gotoxy(1,23);
  2892.                 cursoroff();
  2893.                 gotoxy(1,23);
  2894.                 retstr=inkey(15,"\033[K\007\033[7;7m SYSMON: \033[0;0m \033[1;1mYou want to quit ?  ARE YOU SURE \033[5;5m\033[7;7m[Y/N]\033[0;0m ?");
  2895.  
  2896.                 switch(retstr)
  2897.                 {
  2898.                     case TRUE:
  2899.                             if(lpp)
  2900.                                 logindi=TRUE;
  2901.                             effect();
  2902.                             cls();
  2903.                             cursoron();
  2904.                            tmode(0,1);
  2905.                             if(logindi)
  2906.                             {
  2907.                                 fclose(lpp);
  2908.                                 logindi=FALSE;
  2909.                             }
  2910.                             switch_ctrl(RESTORE);
  2911.                             if(strncmp(portnam,"PKS",3)==0)
  2912.                                 sleep(2);
  2913.                             exit(0);
  2914.                             break;
  2915.                 
  2916.                     case TIMEOUT:
  2917.                             error_indi=TRUE;
  2918.                             gotoxy(1,23);
  2919.                             printf("%s",timeoutstr);
  2920.                             if(logindi)
  2921.                                 fprintf(lpp,"%s",timeoutstr);
  2922.                             break;
  2923.  
  2924.                     default:
  2925.                             error_indi=TRUE;
  2926.                             ret_disp=100;
  2927.                             gotoxy(1,23);
  2928.                             printf("\033[K\n");
  2929.                             if(logindi)
  2930.                                 fprintf(lpp,"\033[K\n");
  2931.                             break;
  2932.                   }
  2933.   
  2934.                 if(mode_flag)
  2935.                 {
  2936.                     gotoxy(1,23);
  2937.                     cursoron();
  2938.                 }
  2939.             }
  2940.  
  2941.               if(io_buff[0]=='W')
  2942.             {
  2943.                 if(privileg)
  2944.                 {
  2945.                     if(pwh)
  2946.                     {
  2947.                         if(watchy_flag)
  2948.                         {
  2949.                             watchy_flag=FALSE;
  2950.                             gotoxy(1,23);
  2951.                             printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m WATCH-mode disabled !\n");
  2952.                             if(logindi)
  2953.                                 fprintf(lpp,
  2954.                                 "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m WATCH-mode disabled !\n");
  2955.                             error_indi=TRUE;
  2956.                         }
  2957.                         else
  2958.                         {
  2959.                             watchy_flag=TRUE;
  2960.                             gotoxy(1,23);
  2961.                             printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m WATCH-mode enabled ! [unkown user-processes will be killed]\n");
  2962.                             if(logindi)
  2963.                                 fprintf(lpp,
  2964.                                 "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m WATCH-mode enabled ! [unkown user-processes will be killed]\n");
  2965.                             error_indi=TRUE;
  2966.                         }
  2967.                     }
  2968.                     else
  2969.                     {
  2970.                         gotoxy(1,23);
  2971.                         printf(
  2972.                         "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m WATCH-mode can't be enabled !\n");
  2973.                         if(logindi)
  2974.                             fprintf(lpp,
  2975.                             "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m WATCH-mode can't be enabled !\n");
  2976.                         error_indi=TRUE;
  2977.                     }
  2978.                 }
  2979.                 else
  2980.                 {
  2981.                     gotoxy(1,23);
  2982.                     printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164\n");
  2983.                     if(logindi)
  2984.                         fprintf(lpp,"\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164\n");
  2985.                     error_indi=TRUE;
  2986.                 }
  2987.                 goto Goon;
  2988.             }
  2989.  
  2990.               if(io_buff[0]=='M')
  2991.             {
  2992.                 if(!mark)
  2993.                 {
  2994.                     mark=TRUE;
  2995.                     gotoxy(1,23);
  2996.                     printf(
  2997.                     "\033[K\007\033[7;7m SYSMON: \033[0;0m Mark-function enabled !\n");
  2998.                     if(logindi)
  2999.                         fprintf(lpp,
  3000.                         "\033[K\007\033[7;7m SYSMON: \033[0;0m Mark-function enabled !\n");
  3001.                     error_indi=TRUE;
  3002.                 }
  3003.                 else
  3004.                 {
  3005.                     mark=FALSE;
  3006.                     gotoxy(1,23);
  3007.                     printf(
  3008.                     "\033[K\007\033[7;7m SYSMON: \033[0;0m Mark-function disabled !\n");
  3009.                     if(logindi)
  3010.                         fprintf(lpp,
  3011.                         "\033[K\007\033[7;7m SYSMON: \033[0;0m Mark-function disabled !\n");
  3012.                     error_indi=TRUE;
  3013.                 }
  3014.                 goto Goon;
  3015.             }
  3016.  
  3017.               if(io_buff[0]=='C')
  3018.             {
  3019.                 if(!clflg)
  3020.                     clflg=TRUE;
  3021.                 else
  3022.                     clflg=FALSE;
  3023.                 goto Goon;
  3024.             }
  3025.  
  3026.               if(io_buff[0]=='R')
  3027.             {
  3028.                 if(!killer && !susy_flag)
  3029.                 {
  3030.                     if(reference)
  3031.                     {
  3032.                         reference=FALSE;
  3033.                         error_indi=TRUE;
  3034.                         gotoxy(1,23);
  3035.                         if(maxh_flag)
  3036.                         {
  3037.                             printf("\033[K%s \n",maxhstr);
  3038.                             if(logindi)
  3039.                                 fprintf(lpp,"\033[K%s \n",maxhstr);
  3040.                         }    
  3041.                         else
  3042.                         {
  3043.                             printf("\033[K\n");
  3044.                             if(logindi)
  3045.                                 fprintf(lpp,"\033[K\n");
  3046.                         }
  3047.                         ret_disp=100;
  3048.                     }
  3049.                     else
  3050.                     {
  3051.                         reference=TRUE;
  3052.                         error_indi=FALSE;
  3053.                         gotoxy(1,23);
  3054.                         printf("\033[K%s\n",referstr);
  3055.                         if(logindi)
  3056.                             fprintf(lpp,"\033[K%s\n",referstr);
  3057.                    }
  3058.                 }
  3059.                 goto Goon;
  3060.             }
  3061.  
  3062.  
  3063.               if(io_buff[0]=='N')
  3064.               {
  3065.                 error_indi=FALSE;
  3066.                   if(name_flag)
  3067.                 {
  3068.                 name_flag=FALSE;
  3069.                     if(pwh)
  3070.                     {
  3071.                         cls();
  3072.                     switch (mode_flag)
  3073.                     {
  3074.                         case 0:
  3075.                                 display_frame();
  3076.                             break;
  3077.                             case 1:
  3078.                                 display_dframe();
  3079.                                 break;
  3080.                         }
  3081.                 }
  3082.                 }
  3083.                 else
  3084.                 {
  3085.                     if(pwh)
  3086.                     {
  3087.                        name_flag=TRUE;
  3088.                         cls();
  3089.                     switch (mode_flag)
  3090.                     {
  3091.                         case 0:
  3092.                                 display_frame();
  3093.                             break;
  3094.                             case 1:
  3095.                                 display_dframe();
  3096.                                 break;
  3097.                     }
  3098.                     }
  3099.                     else
  3100.                     {
  3101.                         if(passerror==214 || passerror==164)
  3102.                         {
  3103.                             gotoxy(1,23);
  3104.                             printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=%d \n",passerror);
  3105.                             if(logindi)
  3106.                                 fprintf(lpp,"\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=%d \n",passerror);
  3107.                             error_indi=TRUE;
  3108.                         }
  3109.                         else
  3110.                         {
  3111.                             gotoxy(1,23);
  3112.                             printf("\033[K\007\033[7;7m\033[5;5m SYSMON-ERROR: \033[0;0m No passwordfile found, can't switch to NAME-mode !\n");
  3113.                             if(logindi)
  3114.                                 fprintf(lpp,"\033[K\007\033[7;7m\033[5;5m SYSMON-ERROR: \033[0;0m No passwordfile found, can't switch to NAME-mode !\n");
  3115.                             error_indi=TRUE;
  3116.                         }
  3117.                    }                
  3118.                }
  3119.                 goto Goon;
  3120.             }
  3121.  
  3122.               if(io_buff[0]=='H')
  3123.               {
  3124.                 cursoroff();
  3125.                 error_indi=FALSE;
  3126.                 retstr=show_version();
  3127.                 if(!retstr)
  3128.                 {
  3129.                     retstr=inkey(0,"\033[7;7m Press any key or 'Q' for previous screen \033[0;0m");
  3130.                     if(!retstr)
  3131.                     {
  3132.                         helpuser();
  3133.                         retstr=inkey(0,
  3134.                         "\033[7;7m Press any key to continue ... \033[0;0m");
  3135.                     }
  3136.                 }
  3137.                 effect();
  3138.                 cls();
  3139.                if(!mode_flag)
  3140.                     display_frame();
  3141.                 else
  3142.                     display_dframe();
  3143.                 goto Goon;
  3144.               }        
  3145.  
  3146.               if(io_buff[0]=='X')
  3147.             {
  3148.                 if(privileg)                    /* is user privileged ? */
  3149.                 {
  3150.                     if(reset_flag)              /* reset allowed from source ? */
  3151.                     {
  3152.                         kha=checkadr(0x4);    /* adress resetvector of CPU ! */
  3153.                         if(!kha)
  3154.                         {
  3155.                             retstr=inkey(15,"\033[K\007\033[7;7m\033[1;1m\033[5;5m WARNING: \033[0;0m THE SYSTEM WILL BE RESETTED ! \033[1;1m\033[5;5m ARE YOU SURE [Y/N] ???\033[0;0m\n");
  3156.  
  3157.                             switch(retstr)
  3158.                             {
  3159.                                 case TRUE:
  3160.                                     cls();
  3161.                                     cursoron();
  3162.                                     tsleep(10);
  3163.                                     reseter();
  3164.                                     switch_ctrl(RESTORE);
  3165.                                     if(strncmp(portnam,"PKS",3)==0)
  3166.                                         sleep(2);
  3167.                                     exit(0);
  3168.                                     break;
  3169.  
  3170.                                 case TIMEOUT:
  3171.                                     gotoxy(1,23);
  3172.                                     printf("%s",timeoutstr);
  3173.                                     if(logindi)
  3174.                                         fprintf(lpp,"%s",timeoutstr);
  3175.                                     error_indi=TRUE;
  3176.                                     break;
  3177.  
  3178.                                 default:
  3179.                                     gotoxy(1,23);
  3180.                                     printf("\033[K\n");
  3181.                                     if(logindi)
  3182.                                         fprintf(lpp,"\033[K\n");
  3183.                                     error_indi=TRUE;
  3184.                                     ret_disp=100;
  3185.                                     break;
  3186.                             }
  3187.                         }
  3188.                         else
  3189.                         {
  3190.                             retstr=Permit(0,4096,3);
  3191.                             if(retstr==-1)
  3192.                             {
  3193.                                 gotoxy(1,23);
  3194.                                 printf("%s\n",mmu_errstr);
  3195.                                 if(logindi)
  3196.                                     fprintf(lpp,"%s",mmu_errstr);
  3197.                                 error_indi=TRUE;
  3198.                             }
  3199.                             else
  3200.                             {
  3201.                                 kha=checkadr(0x4);    /* adress resetvector of CPU ! */
  3202.                                 if(!kha)
  3203.                                 {
  3204.                                     retstr=inkey(15,"\033[K\007\033[7;7m\033[1;1m\033[5;5m WARNING: \033[0;0m THE MMU-SYSTEM WILL BE RESETTED ! \033[1;1m\033[5;5m ARE YOU SURE [Y/N] ???\033[0;0m\n");
  3205.  
  3206.                                     switch(retstr)
  3207.                                     {
  3208.                                         case TRUE:
  3209.                                             cls();
  3210.                                             cursoron();
  3211.                                             tsleep(10);
  3212.                                             reseter();
  3213.                                             switch_ctrl(RESTORE);
  3214.                                             if(strncmp(portnam,"PKS",3)==0)
  3215.                                                 sleep(2);
  3216.                                             exit(0);
  3217.                                             break;
  3218.  
  3219.                                         case TIMEOUT:
  3220.                                             if(Protect(0,4096)!=0)
  3221.                                             {
  3222.                                                     kha=errno;
  3223.                                                 cls();
  3224.                                                 cursoron();
  3225.                                                    tmode(0,1);
  3226.                                                     if(logindi)
  3227.                                                     {
  3228.                                                         fclose(lpp);
  3229.                                                         logindi=FALSE;
  3230.                                                     }
  3231.                                                     switch_ctrl(RESTORE);
  3232.                                                     if(strncmp(portnam,"PKS",3)==0)
  3233.                                                         sleep(2);
  3234.                                                     exit(kha);
  3235.                                             }
  3236.                                             gotoxy(1,23);
  3237.                                             printf("%s",timeoutstr);
  3238.                                             if(logindi)
  3239.                                                 fprintf(lpp,"%s",timeoutstr);
  3240.                                             error_indi=TRUE;
  3241.                                             break;
  3242.  
  3243.                                         default:
  3244.                                             if(Protect(0,4096)!=0)
  3245.                                             {
  3246.                                                     kha=errno;
  3247.                                                 cls();
  3248.                                                 cursoron();
  3249.                                                    tmode(0,1);
  3250.                                                     if(logindi)
  3251.                                                     {
  3252.                                                         fclose(lpp);
  3253.                                                         logindi=FALSE;
  3254.                                                     }
  3255.                                                     switch_ctrl(RESTORE);
  3256.                                                     if(strncmp(portnam,"PKS",3)==0)
  3257.                                                         sleep(2);
  3258.                                                     exit(kha);
  3259.                                             }
  3260.                                             gotoxy(1,23);
  3261.                                             printf("\033[K\n");
  3262.                                             if(logindi)
  3263.                                                 fprintf(lpp,"\033[K\n");
  3264.                                             error_indi=TRUE;
  3265.                                             ret_disp=100;
  3266.                                             break;
  3267.                                     }
  3268.                                 }
  3269.                                 else
  3270.                                 {
  3271.                                     gotoxy(1,23);
  3272.                                     printf("%s\n",mmu_errstr);
  3273.                                     if(logindi)
  3274.                                         fprintf(lpp,"%s\n",mmu_errstr);
  3275.                                     error_indi=TRUE;
  3276.                                     if(Protect(0,4096)!=0)
  3277.                                     {
  3278.                                         kha=errno;
  3279.                                         cursoron();
  3280.                                        tmode(0,1);
  3281.                                         if(logindi)
  3282.                                         {
  3283.                                             fclose(lpp);
  3284.                                             logindi=FALSE;
  3285.                                         }
  3286.                                         switch_ctrl(RESTORE);
  3287.                                         if(strncmp(portnam,"PKS",3)==0)
  3288.                                             sleep(2);
  3289.                                         exit(kha);
  3290.                                     }
  3291.                                 }
  3292.                             }
  3293.                         }
  3294.                     }
  3295.                     else
  3296.                     {
  3297.                         gotoxy(1,23);
  3298.                         printf(
  3299.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation from this source ! errno=164 \n");
  3300.                         if(logindi)
  3301.                             fprintf(lpp,
  3302.                             "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation from this source ! errno=164 \n");
  3303.                         error_indi=TRUE;
  3304.                     }
  3305.                }
  3306.                 else
  3307.                 {
  3308.                     gotoxy(1,23);
  3309.                     printf(
  3310.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164 \n");
  3311.                     if(logindi)
  3312.                         fprintf(lpp,
  3313.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164 \n");
  3314.                     error_indi=TRUE;
  3315.                 }
  3316.                 goto Goon;
  3317.             }
  3318.  
  3319.               if(io_buff[0]=='L')
  3320.             {
  3321.                 if(privileg)
  3322.                 {
  3323.                     momage=_getsys(D_MinPty,2);
  3324.                     if(momage>0)
  3325.                     {
  3326.                         if(suspendcount>0)
  3327.                             sprintf(messagebuf,
  3328.                             "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m ALL %d SUSPENDED PROCESSES WILL BE ENABLED ! \033[1;1m\033[5;5m ARE YOU SURE ? [Y/N] \033[0;0m\n",suspendcount);
  3329.                         else
  3330.                             sprintf(messagebuf,
  3331.                             "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m RESET MINAGE ? \033[1;1m\033[5;5m ARE YOU SURE ? [Y/N] \033[0;0m\n",suspendcount);
  3332.     
  3333.                         retstr=inkey(30,messagebuf);  /* 30 seconds timeout ! */
  3334.                         if(retstr==TRUE)
  3335.                         {
  3336.                             remove_flag=TRUE;
  3337.                             get_cputime();
  3338.                             remove_flag=FALSE;
  3339.                             suspendcount=0;
  3340.                             _setsys(D_MinPty,2,0);
  3341.                         }
  3342.                         gotoxy(1,23);
  3343.                         printf("\033[K\n");
  3344.                         if(logindi)
  3345.                             fprintf(lpp,"\033[K\n");
  3346.                         error_indi=TRUE;
  3347.                         ret_disp=100;
  3348.                     }
  3349.                     else
  3350.                     {
  3351.                         gotoxy(1,23);
  3352.                         printf("\033[K\007\033[7;7m SYSMON: \033[0;0m There are no suspended processes to enable !\n");
  3353.                         if(logindi)
  3354.                             fprintf(lpp,"\033[K\007\033[7;7m SYSMON: \033[0;0m There are no suspended processes to enable !\n");
  3355.                         error_indi=TRUE;
  3356.                     }
  3357.                }
  3358.                 else
  3359.                 {
  3360.                     gotoxy(1,23);
  3361.                     printf(
  3362.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164 \n");
  3363.                     if(logindi)
  3364.                         fprintf(lpp,
  3365.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164 \n");
  3366.                     error_indi=TRUE;
  3367.                 }
  3368.                 goto Goon;
  3369.             }
  3370.  
  3371.              if(io_buff[0]=='F')
  3372.             {
  3373.                 if(privileg)
  3374.                 {
  3375.                       icpt_flag=FALSE;
  3376.                     error_indi=FALSE;
  3377.                     gotoxy(1,23);
  3378.                     cursoroff();
  3379.  
  3380.                     sshell=(char *) getenv("SHELL");
  3381.                     if(sshell!=0)
  3382.                     {
  3383.                         sprintf(ushell,"%s",sshell);
  3384.                         uppercase(ushell);
  3385.                         gotoxy(1,23);
  3386.                         printf(
  3387.                         "\033[K\033[7;7m SYSMON: \033[0;0m Trying to fork a '%s' ...\n",ushell);
  3388.                         if(logindi)
  3389.                             fprintf(lpp,
  3390.                             "\033[K\033[7;7m SYSMON: \033[0;0m Trying to fork a '%s' ...\n",ushell);
  3391.                         tmode(0,1);
  3392.                         sleep(1);
  3393.  
  3394.                         gotoxy(1,23);
  3395.                         cursoron();
  3396.                         switch_ctrl(ON);
  3397.  
  3398.                         sprintf(argblk[0],"%s",ushell);
  3399.                         if(strncmp("ZSH",ushell,3)==0)
  3400.                             sprintf(argblk[1],"-eyp=\"SYSMON:[''cdir']>\"");
  3401.                         else
  3402.                             sprintf(argblk[1],"-ep=\"SYSMON:%s> \"",ushell);
  3403.  
  3404.                         forkh = os9exec(os9fork,argblk[0],argblk,environa,
  3405.                         0,orginatprior,3);
  3406.                         if(forkh==-1)
  3407.                         {
  3408.                         switch_ctrl(OFF);
  3409.                             gotoxy(1,23);
  3410.                             cursoroff();
  3411.                             gotoxy(1,23);
  3412.                             printf(
  3413.                             "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON ERROR: \033[0;0m Sorry can't fork '%s' ! errno=%d\n"
  3414.                             ,ushell,errno);
  3415.                             if(logindi)
  3416.                                 fprintf(lpp,
  3417.                                 "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON ERROR: \033[0;0m Sorry can't fork '%s' ! errno=%d\n"
  3418.                                 ,ushell,errno);
  3419.                             sleep(3);
  3420.                             if(strncmp("SHELL",ushell,4)!=0)
  3421.                             {
  3422.                                 retstr=inkey(15,
  3423.                                 "\033[K\007\033[7;7m SYSMON: \033[0;0m\033[1;1m Do You want to fork a 'SHELL' ?  \033[5;5m\033[7;7m[Y/N]\033[0;0m");
  3424.                                 switch(retstr)
  3425.                                 {
  3426.                                     case TRUE:
  3427.                                         switch_ctrl(OFF);
  3428.                                         gotoxy(1,23);
  3429.                                         cursoroff();
  3430.                                         gotoxy(1,23);
  3431.                                         printf(
  3432.                                         "\033[K\033[7;7m SYSMON: \033[0;0m Ok !  Now trying to fork a SHELL ...\n");
  3433.                                         if(logindi)
  3434.                                         fprintf(lpp,
  3435.                                         "\033[K\033[7;7m SYSMON: \033[0;0m Ok !  Now trying to fork a SHELL ...\n");
  3436.                                         sleep(1);
  3437.                                         goto Alternativ;
  3438.                                         break;                
  3439.                                     case TIMEOUT:
  3440.                                         error_indi=TRUE;
  3441.                                         gotoxy(1,23);
  3442.                                         printf("%s",timeoutstr);
  3443.                                         if(logindi)
  3444.                                             fprintf(lpp,"%s",timeoutstr);
  3445.                                         sleep(2);
  3446.                                         break;
  3447.                                     default:
  3448.                                         error_indi=TRUE;
  3449.                                         ret_disp=100;
  3450.                                         gotoxy(1,23);
  3451.                                         printf("\033[K\n");
  3452.                                         if(logindi)
  3453.                                             fprintf(lpp,"\033[K\n");
  3454.                                         break;
  3455.                                 }
  3456.                             }
  3457.                           }
  3458.                         else
  3459.                         {
  3460.                             fid=forkh;
  3461.                             forkh=wait(0);
  3462.                             switch_ctrl(OFF);
  3463.                             gotoxy(1,23);
  3464.                             cursoroff();
  3465.                             cls();
  3466.                             gotoxy(1,23);
  3467.                             printf(
  3468.                             "\033[K\007\033[7;7m SYSMON: \033[0;0m Process: %d  '%s' terminated !\n",
  3469.                             fid,ushell);
  3470.                             if(logindi)
  3471.                                 fprintf(lpp,
  3472.                                 "\033[K\007\033[7;7m SYSMON: \033[0;0m Process: %d  '%s' terminated !\n",
  3473.                                 fid,ushell);
  3474.                             tsleep(50);
  3475.                             olddelay=delay;
  3476.                             delay=2;
  3477.                             get_cputime();
  3478.                             delay=olddelay;
  3479.                         }
  3480.                         cls();
  3481.                         tmode(0,0);
  3482.                         refresh_flag=TRUE;
  3483.                     }
  3484.                     else
  3485.                     {
  3486.                         gotoxy(1,23);
  3487.                         printf(
  3488.                         "\033[K\033[7;7m SYSMON: \033[0;0m Environment variable SHELL not set ! Trying to fork a ZSH ...\n");
  3489.                         if(logindi)
  3490.                             fprintf(lpp,
  3491.                             "\033[K\033[7;7m SYSMON: \033[0;0m Environment variable SHELL not set ! Trying to fork a ZSH ...\n");
  3492.                         tmode(0,1);
  3493.                         sleep(1);
  3494.  
  3495.                         gotoxy(1,23);
  3496.                         cursoron();
  3497.                         switch_ctrl(ON);
  3498.  
  3499.                         sprintf(argblk[0],"%s/cmds/zsh",ddnam);
  3500.                         sprintf(argblk[1],"-eyp=\"SYSMON:[''cdir']>\"");
  3501.  
  3502.                         forkh = os9exec(os9fork,argblk[0],argblk,environa,
  3503.                         0,orginatprior,3);
  3504.                         if(forkh==-1)
  3505.                         {
  3506.                             switch_ctrl(OFF);
  3507.                             gotoxy(1,23);
  3508.                             cursoroff();
  3509.                             gotoxy(1,23);
  3510.                             printf(
  3511.                             "\033[K\033[7;7m SYSMON: \033[0;0m No ZSH found ! Trying to fork a SHELL ...\n");
  3512.                             if(logindi)
  3513.                                 fprintf(lpp,
  3514.                                 "\033[K\033[7;7m SYSMON: \033[0;0m No ZSH found ! Trying to fork a SHELL ...\n");
  3515.                             sleep(1);
  3516.  
  3517.                         Alternativ:
  3518.                             gotoxy(1,23);
  3519.                             cursoron();
  3520.                             cls();
  3521.                             gotoxy(1,23);
  3522.                             fflush(stdout);
  3523.                                switch_ctrl(ON);
  3524.  
  3525.                          sprintf(argblk[0],"%s/cmds/shell",ddnam);
  3526.                             sprintf(argblk[1],"-ep=\"SYSMON:SHELL>\"");
  3527.                             forkh = os9exec(os9fork,argblk[0],argblk,environa,
  3528.                             0,orginatprior,3);
  3529.                             if(forkh!=-1)
  3530.                             {
  3531.                                 fid=forkh;
  3532.                                 forkh=wait(0);
  3533.                                 switch_ctrl(OFF);
  3534.                                 gotoxy(1,23);
  3535.                                 cursoroff();
  3536.                             cls();
  3537.                                 gotoxy(1,23);
  3538.                                 printf("\033[K\007\033[7;7m SYSMON: \033[0;0m Process: %d  'SHELL' terminated !\n",fid);
  3539.                                 if(logindi)
  3540.                                     fprintf(lpp,
  3541.                                     "\033[K\007\033[7;7m SYSMON: \033[0;0m Process: %d  'SHELL' terminated !\n",fid);
  3542.                                 tsleep(50);
  3543.                                 olddelay=delay;
  3544.                                 delay=2;
  3545.                                 get_cputime();
  3546.                                 delay=olddelay;
  3547.                             }
  3548.                             else
  3549.                             {
  3550.                             switch_ctrl(OFF);
  3551.                                 gotoxy(1,23);
  3552.                                 cursoroff();
  3553.                                 gotoxy(1,23);
  3554.                                 printf(
  3555.                                 "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON ERROR: \033[0;0m Sorry can't fork ZSH or SHELL ! errno=%d\n"
  3556.                                 ,errno);
  3557.                                 if(logindi)
  3558.                                 fprintf(lpp,
  3559.                                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON ERROR: \033[0;0m Sorry can't fork ZSH or SHELL ! errno=%d\n"
  3560.                                     ,errno);
  3561.                                 sleep(4);
  3562.                             }
  3563.                         }
  3564.                         else
  3565.                         {
  3566.                             fid=forkh;
  3567.                             forkh=wait(0);
  3568.                             switch_ctrl(OFF);
  3569.                             gotoxy(1,23);
  3570.                             cursoroff();
  3571.                             cls();
  3572.                             gotoxy(1,23);
  3573.                             printf(
  3574.                             "\033[K\007\033[7;7m SYSMON: \033[0;0m Process: %d  'ZSH' terminated !\n",fid);
  3575.                             if(logindi)
  3576.                                 fprintf(lpp,
  3577.                                 "\033[K\007\033[7;7m SYSMON: \033[0;0m Process: %d  'ZSH' terminated !\n",fid);
  3578.                             tsleep(50);
  3579.                             olddelay=delay;
  3580.                             delay=2;
  3581.                             get_cputime();
  3582.                             delay=olddelay;
  3583.                         }
  3584.                         cls();
  3585.                         tmode(0,0);
  3586.                         refresh_flag=TRUE;
  3587.                    }
  3588.                 }
  3589.                 else        /* user is not priviledged ! */
  3590.                 {
  3591.                       icpt_flag=FALSE;
  3592.                     error_indi=FALSE;
  3593.                     tmode(0,1);
  3594.                     cursoron();
  3595.                        switch_ctrl(ON);
  3596.                     cls();
  3597.                     gotoxy(1,23);
  3598.                     fflush(stdout);
  3599.  
  3600.                  sprintf(argblk[0],"%s/cmds/login",ddnam);
  3601.                     sprintf(argblk[1],"");
  3602.                     forkh = os9exec(os9fork,argblk[0],argblk,environa,
  3603.                     0,orginatprior,3);
  3604.                     if(forkh!=-1)
  3605.                     {
  3606.                            fid=forkh;
  3607.                            forkh=wait(0);
  3608.                            switch_ctrl(OFF);
  3609.                            gotoxy(1,23);
  3610.                            cursoroff();
  3611.                        cls();
  3612.                            gotoxy(1,23);
  3613.                            printf("\033[K\007\033[7;7m SYSMON: \033[0;0m Process: %d  'LOGIN' terminated !\n",fid);
  3614.                            if(logindi)
  3615.                                fprintf(lpp,
  3616.                                "\033[K\007\033[7;7m SYSMON: \033[0;0m Process: %d  'LOGIN' terminated !\n",fid);
  3617.                            tsleep(50);
  3618.                            olddelay=delay;
  3619.                            delay=2;
  3620.                            get_cputime();
  3621.                            delay=olddelay;
  3622.                     }
  3623.                     else
  3624.                     {
  3625.                     switch_ctrl(OFF);
  3626.                         gotoxy(1,23);
  3627.                         cursoroff();
  3628.                         gotoxy(1,23);
  3629.                         printf(
  3630.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON ERROR: \033[0;0m Sorry can't fork 'login' ! errno=%d\n"
  3631.                         ,errno);
  3632.                         if(logindi)
  3633.                                fprintf(lpp,
  3634.                             "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON ERROR: \033[0;0m Sorry can't fork 'login' ! errno=%d\n"
  3635.                             ,errno);
  3636.                         sleep(4);
  3637.                     }
  3638.                     tmode(0,0);
  3639.                     refresh_flag=TRUE;
  3640.                 }
  3641.                 goto Goon;
  3642.             }
  3643.  
  3644.              if(io_buff[0]=='I')
  3645.             {
  3646.                 if(privileg)  /* is the user privileged ???? */
  3647.                 {
  3648.                 gotoxy(1,23);
  3649.                     printf("%s \n",readingpassstr);
  3650.                     if(logindi)
  3651.                         fprintf(lpp,"%s \n",readingpassstr);
  3652.                     icpt_flag=TRISTATE;
  3653.                     pwh=get_password();
  3654.                     if(!pwh)
  3655.                     {
  3656.                         name_flag=FALSE;
  3657.                         gotoxy(1,23);
  3658.                         printf("%s \n",readpasserrstr);
  3659.                         if(logindi)
  3660.                             fprintf(lpp,"%s \n",readpasserrstr);
  3661.                         refresh_flag=TRUE;
  3662.                         sleep(2);
  3663.                     }
  3664.                     else
  3665.                     {
  3666.                         sleep(1);
  3667.                         gotoxy(1,23);
  3668.                         printf("\033[K\n");
  3669.                         if(logindi)
  3670.                             fprintf(lpp,"\033[K\n");
  3671.                         error_indi=TRUE;
  3672.                         ret_disp=100;
  3673.                     }
  3674.                 }
  3675.                 else
  3676.                 {
  3677.                     gotoxy(1,23);
  3678.                     printf(
  3679.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164 \n");
  3680.                     if(logindi)
  3681.                         fprintf(lpp,
  3682.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164 \n");
  3683.                     error_indi=TRUE;
  3684.                 }
  3685.                 goto Goon;
  3686.             }
  3687.  
  3688.              if(io_buff[0]=='G')
  3689.               {
  3690.                 effect();
  3691.                 cls();
  3692.                 susy_flag=FALSE;
  3693.                 error_indi=FALSE;
  3694.                 lastcount=0;
  3695.                 mode_flag=0;
  3696.                 active_flag=0;
  3697.                 scc=1;
  3698.                 startc=0;
  3699.                    actualcount=0;
  3700.                 display_frame();
  3701.                 goto Goon;
  3702.               }
  3703.  
  3704.             if(io_buff[0]=='J')
  3705.             {
  3706.                 gotoxy(1,23);
  3707.                 if(maxh_flag)
  3708.                 {
  3709.                     maxh_flag=FALSE;
  3710.                     printf("\033[K%s \n",maxhdstr);
  3711.                     if(logindi)
  3712.                         fprintf(lpp,"\033[K%s \n",maxhdstr);
  3713.                     error_indi=TRUE;
  3714.                 }
  3715.                 else
  3716.                 {
  3717.                      maxh_flag=TRUE;
  3718.                     printf("\033[K%s \n",maxhstr);
  3719.                     if(logindi)
  3720.                         fprintf(lpp,"\033[K%s \n",maxhstr);
  3721.                }    
  3722.                 for(i=0;i<MAXPROCS;maxprocent[i++]=0);
  3723.                 goto Goon;
  3724.             }
  3725.  
  3726.              if(io_buff[0]=='D')
  3727.             {
  3728.                 gotoxy(1,23);
  3729.                 cursoroff();
  3730.                 error_indi=TRUE;
  3731.                 gotoxy(1,23);
  3732.                 printf(
  3733.                 "\033[K\033[7;7m SYSMON: \033[0;0m CURRENT DELAY: %2d sec. Change with [+/-] - keys. Set delay with [CR] !\n",delay);
  3734.                 if(logindi)
  3735.                     fprintf(lpp,
  3736.                     "\033[K\033[7;7m SYSMON: \033[0;0m CURRENT DELAY: %2d sec. Change with [+/-] - keys. Set delay with [CR] !\n",delay);
  3737.                 for(i=0;i<500;i++)
  3738.                 {
  3739.                     io_buff[0]=0;
  3740.                     ptaste=_gs_rdy(0);
  3741.                       if(ptaste!=-1)
  3742.                       {
  3743.                         i=0;
  3744.                         read(0,ptastbuff,ptaste);
  3745.                            
  3746.                          if(ptastbuff[0]=='+' && delay<60)
  3747.                                delay++;
  3748.  
  3749.                        if(ptastbuff[0]=='-' && delay>mindelay)
  3750.                             delay--;
  3751.     
  3752.                     if(ptastbuff[0]==13)
  3753.                             break;
  3754.                         gotoxy(26,23);
  3755.                         printf("%2d\n",delay);
  3756.                         if(logindi)
  3757.                             fprintf(lpp,"%2d\n",delay);
  3758.                 }
  3759.                     if(ptaste==-1)
  3760.                           tsleep(5);
  3761.                 }
  3762.  
  3763.                 if(i>=500)              /* timeout ??? */
  3764.                 {
  3765.                     gotoxy(1,23);
  3766.                     printf("%s",timeoutstr);
  3767.                     if(logindi)
  3768.                         fprintf(lpp,"%s",timeoutstr);
  3769.                 }
  3770.                 else
  3771.                 {
  3772.                     ret_disp=100;
  3773.                     gotoxy(1,23);
  3774.                     printf("\033[K\n");
  3775.                     if(logindi)
  3776.                         fprintf(lpp,"\033[K\n");
  3777.                 }
  3778.  
  3779.                 if(mode_flag)
  3780.                 {
  3781.                     gotoxy(1,23);
  3782.                     cursoron();
  3783.                 }
  3784.                 goto Goon;
  3785.                }
  3786.  
  3787.  
  3788.               if(io_buff[0]=='A' || io_buff[0]=='B' ||
  3789.             io_buff[0]=='E' || io_buff[0]=='V')
  3790.               {
  3791.                 effect();
  3792.                 cls();
  3793.                 error_indi=FALSE;
  3794.                 susy_flag=FALSE;
  3795.                 startc=0;
  3796.                 scc=1;
  3797.                    actualcount=0;
  3798.                 lastcount=0;
  3799.                 mode_flag=1;
  3800.                 active_flag=0;
  3801.                 switch(io_buff[0])
  3802.                 {
  3803.                     case 'A':
  3804.                         exmode=FALSE;
  3805.                         break;
  3806.                     case 'B':
  3807.                         exmode=TRUE;
  3808.                         break;
  3809.                     case 'E':
  3810.                         exmode=2;
  3811.                         break;
  3812.                     case 'V':
  3813.                         exmode=3;
  3814.                         break;
  3815.                 }
  3816.                 display_dframe();
  3817.                 goto Goon;
  3818.               }
  3819.  
  3820.               if(io_buff[0]=='U')
  3821.               {
  3822.                 effect();
  3823.                 cls();
  3824.                 error_indi=FALSE;
  3825.                 susy_flag=FALSE;
  3826.                 scc=1;
  3827.                 startc=0;
  3828.                 lastcount=0;
  3829.                    actualcount=0;
  3830.                 mode_flag=1;
  3831.                 active_flag=1;
  3832.                 display_dframe();
  3833.                 goto Goon;
  3834.               }
  3835.  
  3836.               if(io_buff[0]=='S') 
  3837.               {
  3838.                 error_indi=FALSE;
  3839.                 if(privileg)  /* is the user privileged ???? */
  3840.                 {
  3841.                     reference=FALSE;                      /* switch of reference */  
  3842.                     if(mode_flag==1 && !active_flag)      /* only in */
  3843.                    {                                      /*alpha mode ! */
  3844.                         if(!susy_flag)
  3845.                         {                    
  3846.                             susy_flag=TRUE;
  3847.                             watchy_flag=FALSE;
  3848.                             under_title();
  3849.                         }
  3850.                         else
  3851.                         {
  3852.                              susy_flag=FALSE;
  3853.                             under_title();
  3854.                         }
  3855.                     }
  3856.                     else
  3857.                     {
  3858.                         cls();
  3859.                         lastcount=0;
  3860.                         mode_flag=1;
  3861.                         scc=1;
  3862.                         startc=0;
  3863.                         actualcount=0;
  3864.                         active_flag=0;
  3865.                         susy_flag=TRUE;
  3866.                     display_dframe();  
  3867.                     }
  3868.                 }
  3869.                 else
  3870.                 {
  3871.                     gotoxy(1,23);
  3872.                     printf(
  3873.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164 \n");
  3874.                     if(logindi)
  3875.                         fprintf(lpp,
  3876.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164 \n");
  3877.                     error_indi=TRUE;
  3878.                 }
  3879.                 goto Goon;
  3880.               }    
  3881.       
  3882.               if(io_buff[0]=='>')
  3883.               {
  3884.                 if(susy_flag)
  3885.                 {
  3886.                     if(scc<(fa+fb)) 
  3887.                     {
  3888.                         scc++;
  3889.                         startc++;
  3890.                         selecta=TRUE;
  3891.                     }
  3892.                     else
  3893.                     {
  3894.                     if(actualcount<imax-15)
  3895.                       {    
  3896.                         error_indi=FALSE;
  3897.                         actualcount+=16;
  3898.                             under_title();
  3899.                             startc=0;
  3900.                             scc++;
  3901.                         }
  3902.                         else
  3903.                         {
  3904.                             gotoxy(1,23);
  3905.                             printf("%s\n",reached_endstr);
  3906.                             if(logindi)
  3907.                                 fprintf(lpp,"%s\n",reached_endstr);
  3908.                             error_indi=TRUE;
  3909.                         }
  3910.                       }
  3911.                   }
  3912.                 else
  3913.                 {
  3914.                     gotoxy(1,23);
  3915.                     printf(
  3916.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m SELECT-MODE not enabled.  Use 'S' key to enable !\n");
  3917.                     if(logindi)
  3918.                         fprintf(lpp,
  3919.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m SELECT-MODE not enabled.  Use 'S' key to enable !\n");
  3920.                     error_indi=TRUE;
  3921.                 }
  3922.                 goto Goon;
  3923.               }
  3924.  
  3925.  
  3926.               if(io_buff[0]=='<')
  3927.               {
  3928.                 if(susy_flag)
  3929.                 {
  3930.                     if(scc>fa+1)
  3931.                     {
  3932.                         selecta=TRUE;
  3933.                         scc--;
  3934.                         startc--;
  3935.                     }
  3936.                     else
  3937.                     {
  3938.                         if(actualcount>=16)
  3939.                         {
  3940.                             error_indi=FALSE;
  3941.                             actualcount-=16;
  3942.                             under_title();
  3943.                             scc--;
  3944.                             startc=15;
  3945.                         }
  3946.                         else
  3947.                         {
  3948.                             actualcount=0;
  3949.                             gotoxy(1,23);
  3950.                             printf("%s\n",reached_beginstr);
  3951.                             if(logindi)
  3952.                                 fprintf(lpp,"%s\n",reached_beginstr);
  3953.                             error_indi=TRUE;
  3954.                         }
  3955.                     }
  3956.                 }
  3957.                 else
  3958.                 {
  3959.                     gotoxy(1,23);
  3960.                     printf(
  3961.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m SELECT-MODE not enabled.  Use 'S' key to enable !\n");
  3962.                     if(logindi)
  3963.                         fprintf(lpp,
  3964.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m SELECT-MODE not enabled.  Use 'S' key to enable !\n");
  3965.                     error_indi=TRUE;
  3966.                 }
  3967.                 goto Goon;
  3968.               }
  3969.  
  3970.  
  3971.               if(io_buff[0]=='K' && imax>1)
  3972.               {
  3973.                 error_indi=FALSE;
  3974.                 if(susy_flag)
  3975.                 {
  3976.                     if(markpr>1)
  3977.                     {
  3978.                         reference=FALSE;
  3979.                         refresh_flag=FALSE;
  3980.                         error_indi=FALSE;
  3981.                         killer=TRUE;
  3982.                         gotoxy(1,23);
  3983.                         if(markpr==ownuid)
  3984.                         {
  3985.                             printf(
  3986.                             "\033[K\007\033[7;7m SYSMON: \033[0;0m Kill own process '%s' ?  \033[5;5m Are You quite sure [Y]es/[N]o  ? \033[0;0m \n",killnam);
  3987.                             if(logindi)
  3988.                                 fprintf(lpp,
  3989.                                 "\033[K\007\033[7;7m SYSMON: \033[0;0m Kill own process '%s' ?  \033[5;5m Are You quite sure [Y]es/[N]o  ? \033[0;0m \n",killnam);
  3990.                                 suicid_flag=TRUE;
  3991.                         }
  3992.                         else
  3993.                         {
  3994.                             printf(
  3995.                             "\033[K\007\033[7;7m SYSMON: \033[0;0m Kill process '%s' ?  \033[5;5m Are You sure [Y]es/[N]o  ? \033[0;0m \n",killnam);
  3996.                             if(logindi)
  3997.                                 fprintf(lpp,
  3998.                                 "\033[K\007\033[7;7m SYSMON: \033[0;0m Kill process '%s' ?  \033[5;5m Are You sure [Y]es/[N]o  ? \033[0;0m \n",killnam);
  3999.                         }
  4000.                     }
  4001.                     else
  4002.                     {
  4003.                         gotoxy(1,23);
  4004.                         printf("%s\n",kernstr);
  4005.                         if(logindi)
  4006.                             fprintf(lpp,"%s\n",kernstr);
  4007.                         error_indi=TRUE;
  4008.                     }
  4009.                 }
  4010.                 else
  4011.                 {
  4012.                     gotoxy(1,23);
  4013.                     printf(
  4014.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Kill-option not enabled ! Use 'S' key to select process !\n");
  4015.                     if(logindi)
  4016.                         fprintf(lpp,
  4017.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Kill-option not enabled ! Use 'S' key to select process !\n");
  4018.                     error_indi=TRUE;
  4019.                    }
  4020.                 goto Goon;
  4021.               }
  4022.                 
  4023.               if(io_buff[0]=='O' && imax>1)
  4024.               {
  4025.                 error_indi=FALSE;
  4026.                 if(susy_flag)
  4027.                 {
  4028.                     if(markpr>1)
  4029.                     {
  4030.                         reference=FALSE;
  4031.                         refresh_flag=FALSE;
  4032.                         error_indi=FALSE;
  4033.                         spr_flag=SUSPEND;
  4034.                         gotoxy(1,23);
  4035.                         if(markprior>0)
  4036.                         {
  4037.                             if(markpr!=ownuid)
  4038.                             {
  4039.                                 if(pid[ownuid-1]==markpr)
  4040.                                 {
  4041.                                     printf(
  4042.                                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m WARNING: \033[0;0m Suspend your parent process '%s' ?  \033[5;5m Are You quite sure ? [Y/N] \033[0;0m \n",killnam);
  4043.                                     if(logindi)
  4044.                                         fprintf(lpp,
  4045.                                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m WARNING: \033[0;0m Suspend your parent process '%s' ?  \033[5;5m Are You quite sure ? [Y/N] \033[0;0m \n",killnam);
  4046.                                     bell=ON;
  4047.                                 }
  4048.                                 else
  4049.                                 {
  4050.                                     printf(
  4051.                                     "\033[K\007\033[7;7m SYSMON: \033[0;0m Suspend process '%s' ?  \033[5;5m Are You sure ? [Y/N] \033[0;0m \n",killnam);
  4052.                                     if(logindi)
  4053.                                         fprintf(lpp,
  4054.                                         "\033[K\007\033[7;7m SYSMON: \033[0;0m Suspend process '%s' ?  \033[5;5m Are You sure ? [Y/N] \033[0;0m \n",killnam);
  4055.                                 }
  4056.                             }
  4057.                             else
  4058.                             {        
  4059.                                 printf(
  4060.                                 "\033[K\007\033[7;7m\033[1;1m\033[5;5m WARNING: \033[0;0m Suspend your own process '%s' ?  \033[5;5m Are You quite sure ? [Y/N] \033[0;0m \n",killnam);
  4061.                                 if(logindi)
  4062.                                     fprintf(lpp,
  4063.                                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m WARNING: \033[0;0m Suspend your own process '%s' ?  \033[5;5m Are You quite sure ? [Y/N] \033[0;0m \n",killnam);
  4064.                                 bell=ON;
  4065.                                 suicid_flag=TRUE;
  4066.                             }
  4067.                         }
  4068.                         else
  4069.                         {
  4070.                             printf(
  4071.                             "\033[K\007\033[7;7m SYSMON: \033[0;0m Enable process '%s' ?  \033[5;5m Are You sure ? [Y/N] \033[0;0m \n",killnam);
  4072.                             if(logindi)
  4073.                                 fprintf(lpp,
  4074.                                 "\033[K\007\033[7;7m SYSMON: \033[0;0m Enable process '%s' ?  \033[5;5m Are You sure ? [Y/N] \033[0;0m \n",killnam);
  4075.                         }
  4076.                      }
  4077.                     else
  4078.                     {
  4079.                        gotoxy(1,23);
  4080.                         printf("%s\n",kernstr);
  4081.                         if(logindi)
  4082.                             fprintf(lpp,"%s\n",kernstr);
  4083.                         error_indi=TRUE;
  4084.                     }
  4085.                 }
  4086.                 else
  4087.                 {
  4088.                     gotoxy(1,23);
  4089.                     printf(
  4090.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Suspend-option not enabled ! Use 'S' key to select process !\n");
  4091.                     if(logindi)
  4092.                         fprintf(lpp,
  4093.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Suspend-option not enabled ! Use 'S' key to select process !\n");
  4094.                     error_indi=TRUE;
  4095.                    }
  4096.                 goto Goon;
  4097.               }
  4098.  
  4099.               if(io_buff[0]=='T' && imax>1)
  4100.               {
  4101.                 error_indi=FALSE;
  4102.                 if(susy_flag)
  4103.                 {
  4104.                     gotoxy(1,23);
  4105.                     cursoroff();
  4106.                     reference=FALSE;
  4107.                     refresh_flag=FALSE;
  4108.                     error_indi=FALSE;
  4109.  
  4110.                     if(ownuid==markpr && prillow==FALSE)    /* if selected process is not the own ! */
  4111.                     {
  4112.                         gotoxy(1,23);
  4113.                         printf(
  4114.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m You can't change priority from this source !\n");
  4115.                         if(logindi)
  4116.                             fprintf(lpp,
  4117.                             "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m You can't change priority from this source !\n");
  4118.                         error_indi=TRUE;
  4119.                     }
  4120.                     else
  4121.                     {
  4122.                         ret_disp=100;
  4123.                         newprior=prior[startc+actualcount];
  4124.  
  4125.                         gotoxy(1,23);
  4126.                         printf(
  4127.                         "\033[K\007\033[7;7m SYSMON: \033[0;0m ID: %03d %s \n"
  4128.                         ,markpr,killnam);
  4129.                         if(logindi)
  4130.                             fprintf(lpp,
  4131.                             "\033[K\007\033[7;7m SYSMON: \033[0;0m ID: %03d %s \n"
  4132.                             ,markpr,killnam);
  4133.                         gotoxy(35,23);
  4134.                         printf("priority: %6d Change [+/-] Set with [CR]\n",
  4135.                         newprior);
  4136.                         if(logindi)
  4137.                             fprintf(lpp,"priority: %6d Change [+/-] Set with [CR]\n",
  4138.                             newprior);
  4139.                     io_buff[0]=0;
  4140.                         dc=0;
  4141.  
  4142.                         for(;;)
  4143.                         {
  4144.                         ptaste=_gs_rdy(0);
  4145.                               if(ptaste>0)
  4146.                               {
  4147.                                 read(0,ptastbuff,ptaste);
  4148.                            
  4149.                                 if(ptastbuff[0]==13)
  4150.                                     break;
  4151.                                 else
  4152.                                 {
  4153.                                     switch(ptastbuff[0])
  4154.                                     {
  4155.                                         case '+':
  4156.                                         if((newprior+delta) <=65535)
  4157.                                             newprior+=delta;
  4158.                                         else
  4159.                                         {
  4160.                                             if(newprior<65535)
  4161.                                                 newprior++;
  4162.                                         }
  4163.                                         break;
  4164.  
  4165.                                         case '-':
  4166.                                         if((newprior-delta) >=0)
  4167.                                             newprior-=delta;
  4168.                                         else
  4169.                                         {
  4170.                                             if(newprior>0)
  4171.                                                 newprior--;
  4172.                                         }
  4173.                                         break;
  4174.                                     }
  4175.                                 }
  4176.  
  4177.                             gotoxy(45,23);
  4178.                                 printf("%6d\n",newprior);
  4179.                                 if(logindi)
  4180.                                     fprintf(lpp,"%6d\n",newprior);
  4181.  
  4182.                                 if(delta<1000)
  4183.                                     delta*=10;
  4184.                                 dc=0;
  4185.                             }                    
  4186.                           else
  4187.                             {
  4188.                                 tsleep(5);
  4189.                                 if(dc<10)
  4190.                                     dc++;
  4191.                                 else
  4192.                                     delta=1;
  4193.                             }
  4194.                         }
  4195.  
  4196.                         gotoxy(1,23);
  4197.                         printf(
  4198.                         "\033[K\007\033[7;7m SYSMON: \033[0;0m modify priority of process '%s' ? \033[7;7m\033[5;5m [Y]es/[N]o  ? \033[0;0m \n",killnam);
  4199.                         if(logindi)
  4200.                             fprintf(lpp,
  4201.                             "\033[K\007\033[7;7m SYSMON: \033[0;0m modify priority of process '%s' ? \033[7;7m\033[5;5m [Y]es/[N]o  ? \033[0;0m \n",killnam);
  4202.                         spr_flag=TRUE;
  4203.                     }
  4204.                 }
  4205.                 else
  4206.                 {
  4207.                     gotoxy(1,23);
  4208.                     printf(
  4209.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Priority-option not enabled ! Use 'S' key to select process !\n");
  4210.                     if(logindi)
  4211.                         fprintf(lpp,
  4212.                         "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Priority-option not enabled ! Use 'S' key to select process !\n");
  4213.                     error_indi=TRUE;
  4214.                    }
  4215.                 if(mode_flag==1)
  4216.                 {
  4217.                     gotoxy(1,23);
  4218.                     cursoron();
  4219.                 }
  4220.                 goto Goon;
  4221.               }    
  4222.  
  4223.               if(io_buff[0]=='Z')
  4224.             {
  4225.                 if(privileg)
  4226.                 {
  4227.                     if(lpp)
  4228.                     {
  4229.                             if(logindi)        /* log switched on ! */
  4230.                             {
  4231.                                 logindi=FALSE;
  4232.                                 gotoxy(1,23);
  4233.                             printf(
  4234.                                 "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Display isn't longer logged in file: '%s' \n",
  4235.                                 logfilenam);
  4236.                                error_indi=TRUE;
  4237.                             }
  4238.                         else            /* log is switched off ! */
  4239.                             {
  4240.                                 gotoxy(1,23);
  4241.                             printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Display is logged in file: '%s' \n",
  4242.                                 logfilenam);
  4243.                                 logindi=TRUE;
  4244.                                 refresh_flag=TRUE;
  4245.                             }
  4246.                     }
  4247.                     else
  4248.                     {    
  4249.                         sprintf(logfilenam,"SYSMON_%06d.LOG",
  4250.                         std*10000+min*100+sec );
  4251.                         lpp=fopen(logfilenam,"a+");
  4252.                         logpath=open(logfilenam,1);
  4253.                         if(lpp && logpath!=-1)
  4254.                         {
  4255.                             gotoxy(1,23);
  4256.                             printf(
  4257.                             "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m File: '%s' created, type 'Z' to log !\n",
  4258.                             logfilenam);
  4259.                             error_indi=TRUE;
  4260.                         }
  4261.                         else
  4262.                         {
  4263.                             gotoxy(1,23);
  4264.                             printf(
  4265.                             "\033[K\007\033[7;7m\033[5;5m SYSMON-ERROR: \033[0;0m File: '%s' can't be opened ! errno=%d\n",
  4266.                             logfilenam,errno);
  4267.                             error_indi=TRUE;
  4268.                         }
  4269.                     }
  4270.                 }
  4271.                 else
  4272.                 {
  4273.                     gotoxy(1,23);
  4274.                     printf(
  4275.                     "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m No privilege for attempted operation ! errno=164\n");
  4276.                     error_indi=TRUE;
  4277.                 }
  4278.                 goto Goon;
  4279.             }
  4280.  
  4281.  
  4282.               if(io_buff[0]=='P')
  4283.             {
  4284.                 error_indi=FALSE;
  4285.                 cls();
  4286.                 if(prior_flag)
  4287.                     prior_flag=FALSE;
  4288.                 else
  4289.                     prior_flag=TRUE;
  4290.  
  4291.                 name_flag=FALSE;
  4292.                 susy_flag=FALSE;
  4293.                 lastcount=0;
  4294.                 mode_flag=0;
  4295.                 active_flag=0;
  4296.                 scc=1;
  4297.                 startc=0;
  4298.                    actualcount=0;
  4299.                 display_frame();
  4300.                 goto Goon;
  4301.             }
  4302.  
  4303.               if(io_buff[0]=='1')        /* SAVEUSERSETUP */
  4304.             {
  4305.                 retstr=saveusersetup();
  4306.                 if(retstr==FALSE)
  4307.                 {
  4308.                     gotoxy(1,23);
  4309.                     printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Usersetup successfully saved !\n");
  4310.                     if(logindi)
  4311.                         fprintf(lpp,
  4312.                     "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Usersetup successfully saved !\n");
  4313.                     error_indi=TRUE;
  4314.                 }
  4315.                 else
  4316.                 {
  4317.                     gotoxy(1,23);
  4318.                     printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Usersetup save failed !   errno=%d\n",retstr);
  4319.                     if(logindi)
  4320.                         fprintf(lpp,
  4321.                         "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Usersetup save failed !   errno=%d\n",retstr);
  4322.                     error_indi=TRUE;
  4323.                 }
  4324.                 goto Goon;
  4325.             }
  4326.  
  4327.               if(io_buff[0]=='2')        /* LOADUSERSETUP */
  4328.             {
  4329.                 retstr=loadusersetup();
  4330.                 if(retstr==FALSE)
  4331.                 {
  4332.                     gotoxy(1,23);
  4333.                     printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Usersetup successfully loaded !\n");
  4334.                     if(logindi)
  4335.                         fprintf(lpp,
  4336.                         "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Usersetup successfully loaded !\n");
  4337.                     sleep(2);
  4338.                     refresh_flag=TRUE;
  4339.                 }
  4340.                 else
  4341.                 {
  4342.                     gotoxy(1,23);
  4343.                     printf("\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Usersetup load failed !   errno=%d\n",retstr);
  4344.                     if(logindi)
  4345.                         fprintf(lpp,
  4346.                         "\033[K\007\033[7;7m\033[5;5m SYSMON: \033[0;0m Usersetup load failed !   errno=%d\n",retstr);
  4347.                     error_indi=TRUE;
  4348.                 }
  4349.                 goto Goon;
  4350.             }
  4351.  
  4352.             if(mode_flag)
  4353.             {
  4354.                   if(io_buff[0]=='+')
  4355.                 {
  4356.                     if(actualcount<imax-15)
  4357.                       {    
  4358.                         error_indi=FALSE;
  4359.                         actualcount+=16;
  4360.                         under_title();
  4361.                         startc=0;
  4362.                         scc=fa+1;   /* +fb; */
  4363.                       }
  4364.                     else
  4365.                     {
  4366.                         gotoxy(1,23);
  4367.                         printf("%s\n",process_endstr);
  4368.                         if(logindi)
  4369.                             fprintf(lpp,"%s\n",process_endstr);
  4370.                         error_indi=TRUE;
  4371.                     }
  4372.                 }
  4373.             
  4374.                   if(io_buff[0]=='-')
  4375.                   {
  4376.                     if(actualcount>=16)
  4377.                     {
  4378.                         error_indi=FALSE;
  4379.                         actualcount-=16;
  4380.                         under_title();
  4381.                         scc=fa+fb;
  4382.                         startc=15;
  4383.                     }
  4384.                     else
  4385.                     {
  4386.                         actualcount=0;
  4387.                         gotoxy(1,23);
  4388.                         printf("%s\n",process_beginstr);
  4389.                         if(logindi)
  4390.                             fprintf(lpp,"%s\n",process_beginstr);
  4391.                         error_indi=TRUE;
  4392.                     }
  4393.                 }
  4394.               }
  4395.         }
  4396. Goon:
  4397.         get_ticktime();      /* how long is a tick lasting ? */
  4398.           icpt_flag=FALSE;  /* clear Icpt flag */
  4399.           tsleep(10);      /* sleep 100 ms     */
  4400.           _ss_ssig(0,DATAPRESENT);  /* send  signal on data ready */
  4401.     }
  4402.  
  4403.  
  4404.     if(refresh_flag==TRUE && !killer && !spr_flag)
  4405.     {       
  4406.         get_ticktime();        /* how long is a tick lasting ? */
  4407.         cls();
  4408.         switch (mode_flag)
  4409.         {
  4410.             case 0:
  4411.                 display_frame();
  4412.             break;
  4413.             case 1:
  4414.                 display_dframe();
  4415.                 break;
  4416.         }
  4417.         refresh_flag=DONE;
  4418.     }
  4419.     else
  4420.         refresh_flag=FALSE;
  4421.  
  4422.  
  4423.     if(!icpt_flag)
  4424.     {
  4425.         if(!selecta)
  4426.             display_time();
  4427.  
  4428.         if(bell==ON)
  4429.         {
  4430.             printf("\007");
  4431.             if(logindi)
  4432.                 fprintf(lpp,"\007");
  4433.         }
  4434.  
  4435.         switch (mode_flag)
  4436.         {
  4437.             case 0:
  4438.                 display_procs();
  4439.             break;
  4440.             case 1:
  4441.                 display_data();
  4442.                 break;
  4443.         }
  4444.         selecta=FALSE;    
  4445.  
  4446.         if(privileg && !killer && !spr_flag)
  4447.         {
  4448.             login_new=check_login();    /* are there any logins ??? */
  4449.             if(login_old && !login_new)
  4450.                 error_indi=TRUE;
  4451.             login_old=login_new;            
  4452.         }
  4453.  
  4454.     if(error_indi)
  4455.           {
  4456.             switch(mode_flag)
  4457.             {
  4458.                 case 0:
  4459.                     clearcondi=2;
  4460.                     break;
  4461.                 case 1:
  4462.                     clearcondi=1;
  4463.                     break;
  4464.             }
  4465.             if(delay>=10)
  4466.                 clearcondi=0;            
  4467.  
  4468.             if(ret_disp>=clearcondi)
  4469.             {
  4470.                 if(error_indi==TRISTATE)
  4471.                     refresh_flag=TRUE;
  4472.                 else
  4473.                 {
  4474.                     switch (mode_flag)
  4475.                     {
  4476.                         case 0:
  4477.                             gotoxy(1,23);
  4478.                             if(reference)
  4479.                             {        
  4480.                                 gotoxy(1,23);
  4481.                                 printf(
  4482.                                 "\033[K%s\n",referstr);
  4483.                                 if(logindi)
  4484.                                     fprintf(lpp,
  4485.                                     "\033[K%s\n",referstr);
  4486.                             }
  4487.                             else
  4488.                             {
  4489.                                 gotoxy(1,23);
  4490.                                 printf("\033[K\n");
  4491.                                 if(logindi)
  4492.                                     fprintf(lpp,"\033[K\n");
  4493.                                 gotoxy(37,23);
  4494.                                 printf("%s\n",prozent);
  4495.                                 if(logindi)
  4496.                                     fprintf(lpp,"%s\n",prozent);
  4497.                             }
  4498.                             break;
  4499.                         case 1:
  4500.                             under_title();
  4501.                             break;
  4502.                     }
  4503.                 }
  4504.                 ret_disp=0;
  4505.                 error_indi=FALSE;
  4506.             }
  4507.             ret_disp++;
  4508.         }
  4509.  
  4510.         if(killit)  /* process marked to kill ! */
  4511.         {
  4512.             gotoxy(1,23);
  4513.             fflush(stdout);
  4514.             tsleep(20);
  4515.             kha=kill_pr(mark_proc);
  4516.            if(!kha)
  4517.             {
  4518.                 sleep(1); 
  4519.                 gotoxy(1,23);
  4520.                 printf(
  4521.                 "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Unkown process: %d has been killed  !\n",mark_proc);
  4522.                 if(logindi)
  4523.                     fprintf(lpp,
  4524.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Unkown process: %d has been killed  !\n",mark_proc);
  4525.                 tsleep(50);
  4526.             }
  4527.             else
  4528.             {
  4529.                 gotoxy(1,23);
  4530.                 printf(
  4531.                 "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Unkown process: %d can't be killed  ! errno=%d\n",mark_proc,kha);
  4532.                 if(logindi)
  4533.                     fprintf(lpp,
  4534.                     "\033[K\007\033[7;7m\033[1;1m\033[5;5m SYSMON: \033[0;0m Unkown process: %d can't be killed  ! errno=%d\n",mark_proc,kha);
  4535.                 tsleep(50);
  4536.             }
  4537.             mark_proc=0;
  4538.             killit=FALSE;
  4539.             refresh_flag=TRUE;
  4540.         }    
  4541.     }
  4542.   }
  4543. }
  4544. /*---------------------------------------------------------------------------*/
  4545. /* name: KILL_PR                                                             */
  4546. /* function: kill process with PID                                           */
  4547. /* by: FRS                                                                   */
  4548. /* Date: 02/02/89                                                            */
  4549. /*---------------------------------------------------------------------------*/
  4550. kill_pr(num)
  4551. register int num;
  4552. {
  4553.     register int khandle;
  4554.  
  4555.     khandle=kill(num,SIGKILL);
  4556.     if(khandle==-1)
  4557.         return(errno);
  4558.     khandle=wait(0);
  4559.     return(0);
  4560. }
  4561. /*-----------------------------------------------------------------------*/
  4562. inkey(inmode,textpoi)
  4563. register int inmode;
  4564. register char *textpoi;
  4565. {
  4566.    register int taste;
  4567.    int tastcount=0, ref; 
  4568.    char tastbuff[255];
  4569.    int jtime, jdate,jtick;
  4570.    short jday;
  4571.  
  4572.  
  4573.    gotoxy(1,23); 
  4574.    printf("%s ",textpoi);
  4575.    if(logindi) 
  4576.     fprintf(lpp,"%s ",textpoi);
  4577.    gotoxy(1,22);
  4578.    printf("\n"); 
  4579.    if(logindi) 
  4580.     fprintf(lpp,"\n"); 
  4581.  
  4582.    _sysdate(0,&jtime,&jdate,&jday,&jtick);
  4583.    _julian(&jtime,&jdate);
  4584.    ref=86400*jdate+(86400-jtime);
  4585.  
  4586.    for(;;)
  4587.    {
  4588.       taste=_gs_rdy(0);
  4589.       if(taste>0)
  4590.       {
  4591.         read(0,tastbuff,taste);
  4592.         tastbuff[0]=toupper(tastbuff[0]);
  4593.         
  4594.          if(tastbuff[0]=='Y' || tastbuff[0]=='Q')
  4595.             return(TRUE);
  4596.         else
  4597.             return(FALSE);
  4598.         break;
  4599.       }
  4600.  
  4601.       _sysdate(0,&jtime,&jdate,&jday,&jtick);
  4602.       _julian(&jtime,&jdate);
  4603.       tastcount=ref-(86400*jdate+(86400-jtime));
  4604.       tsleep(10);
  4605.  
  4606.       if(inmode)    /* only if inmode !=0 */
  4607.       {    
  4608.           if(tastcount>inmode) 
  4609.             return(TIMEOUT);
  4610.       }    
  4611.    }
  4612.    return(FALSE);
  4613. }
  4614. /*-----------------------------------------------------------------------*/
  4615. helpuser()
  4616. {
  4617.   effect();  
  4618.   cls();
  4619.   printf("Syntax: sysmon [<opt>] \n");
  4620.   printf("Version: %s %s\n",versi,LAST_EDITION_DATE);
  4621.   printf("Function: show active tasks and cpu time consumption \n");  
  4622.   printf("Options: \n");
  4623.   printf("     -a      select alphanumeric mode \n");
  4624.   printf("     -b      select alphanumeric mode [extended]\n");
  4625.   printf("     -d      get default device from 'init'-module \n");
  4626.   printf("     -e      select alphanumeric mode [module information]\n");
  4627.   printf("     -j      enable max-hold function [dislay maximum cputime used]\n");
  4628.   printf("     -m      mark processes using more than 75 %% cpu time  [graphic mode]\n");
  4629.   printf("     -p      show process priority instead of group & user [graphic mode]\n");
  4630.   printf("     -q      disable priority rising during work of sysmon [only at /term]\n");
  4631.   printf("     -r      switch QUICK-REFERENCE on\n");
  4632.   printf("     -t=s    get value for scan-time [seconds]\n");
  4633.   printf("     -u      select user mode (display only user processes) \n");
  4634.   printf("     -v      show program version and explanation\n");
  4635.   printf("     -w      enable WATCH-mode [kill unkown user processes]\n");
  4636.   printf("     -?      show this explanation \n");
  4637.   printf("NOTE:    While the program is running you can switch from NAME - mode \n");
  4638.   printf("         to DATA - mode by typing the 'N' - key. It's also possible to \n");
  4639.   printf("         switch to ALFA - mode by typing 'A' - key or to switch to \n");
  4640.   printf("         GRAFIC - mode by typing the 'G' - key ! \n");
  4641.   if(logindi)
  4642.   {  
  4643.     fprintf(lpp,"Syntax: sysmon [<opt>] \n");
  4644.     fprintf(lpp,"Version: %s %s\n",versi,LAST_EDITION_DATE);
  4645.     fprintf(lpp,"Function: show active tasks and cpu time consumption \n");  
  4646.     fprintf(lpp,"Options: \n");
  4647.     fprintf(lpp,"     -a      select alphanumeric mode \n");
  4648.     fprintf(lpp,"     -b      select alphanumeric mode [extended]\n");
  4649.     fprintf(lpp,"     -d      get default device from 'init'-module \n");
  4650.     fprintf(lpp,"     -e      select alphanumeric mode [module information]\n");
  4651.     fprintf(lpp,"     -j      enable max-hold function [dislay maximum cputime used]\n");
  4652.     fprintf(lpp,"     -m      mark processes using more than 75 %% cpu time  [graphic mode]\n");
  4653.     fprintf(lpp,"     -p      show process priority instead of group & user [graphic mode]\n");
  4654.     fprintf(lpp,"     -q      disable priority rising during work of sysmon [only at /term]\n");
  4655.     fprintf(lpp,"     -r      switch QUICK-REFERENCE on\n");
  4656.     fprintf(lpp,"     -t=s    get value for scan-time [seconds]\n");
  4657.     fprintf(lpp,"     -u      select user mode (display only user processes) \n");
  4658.     fprintf(lpp,"     -v      show program version and explanation\n");
  4659.     fprintf(lpp,"     -w      enable WATCH-mode [kill unkown user processes]\n");
  4660.     fprintf(lpp,"     -?      show this explanation \n");
  4661.     fprintf(lpp,"NOTE:    While the program is running you can switch from NAME - mode \n");
  4662.     fprintf(lpp,"         to DATA - mode by typing the 'N' - key. It's also possible to \n");
  4663.     fprintf(lpp,"         switch to ALFA - mode by typing 'A' - key or to switch to \n");
  4664.     fprintf(lpp,"         GRAFIC - mode by typing the 'G' - key ! \n");
  4665.   }
  4666. }
  4667. /*---------------------------------------------------------------------------*/
  4668. show_version()
  4669. {
  4670.   int retstr;
  4671.   effect();  
  4672.   cls();
  4673.   printf ("\033(0");
  4674.   printf ("%s",hdr);
  4675.   printf ("\033(B\n");
  4676.   if(logindi)
  4677.   {  
  4678.     fprintf (lpp,"\033(0");
  4679.     fprintf (lpp,"%s",hdr);
  4680.     fprintf (lpp,"\033(B\n");
  4681.   }
  4682.   gotoxy(1,22);
  4683.   printf ("\033(0");
  4684.   printf ("%s",hdr);
  4685.   printf ("\033(B\n");
  4686.   if(logindi)
  4687.   {  
  4688.     fprintf (lpp,"\033(0");
  4689.     fprintf (lpp,"%s",hdr);
  4690.     fprintf (lpp,"\033(B\n");
  4691.   }
  4692.   gotoxy(1,2);
  4693.   printf("\033[7;7m SYSMON %s \033[0;0m by W.Ott & F.R.Schmitt MPI Kernphysik Heidelberg\n",versi);
  4694.   printf("We hope this is a very usefull tool for monitoring your system.\n"); 
  4695.   printf("For the usage of this program a VT100 [or better a VT220] terminal has to be\n"); 
  4696.   printf("connected to your OS9-System ! Baudrates > 9600 are usefull to get a very fast\n");
  4697.   printf("screenupdate. \n");
  4698.   printf("While the program is running, you can switch to the following modes:\n\n");
  4699.   printf("                                   A  => ALPHA MODE\n");
  4700.   printf("                                   B  => ALPHA MODE [extended]\n");
  4701.   printf("                                   C  => CLEAR CPU %% BEFORE UPDATE [ON/OFF]\n");
  4702.   printf("                                   D  => SET TIME DELAY\n");
  4703.   printf("                                   E  => MODUL INFORMATION\n");
  4704.   printf("                                   F  => FORK SHELL/ZSH\n");
  4705.   printf("                                   G  => GRAPHIC MODE\n");
  4706.   printf("                                   H  => ONLINE HELP\n");
  4707.   printf("                                   I  => READ PASSWORDFILE\n");
  4708.   printf("                                   J  => HOLD MAXIMUM CPUTIME CONSUPTION\n");
  4709.   printf("                                   K  => KILL SELECTED PROCESS\n");
  4710.   printf("                                   L  => ENABLE ALL SUSPENDED PROCESSES\n");
  4711.   if(logindi)
  4712.   {
  4713.     fprintf(lpp,"\033[7;7m SYSMON %s \033[0;0m by W.Ott & F.R.Schmitt MPI Kernphysik Heidelberg\n",versi);
  4714.     fprintf(lpp,"We hope this is a very usefull tool for monitoring your system.\n"); 
  4715.     fprintf(lpp,"For the usage of this program a VT100 [or better a VT220] terminal has to be\n"); 
  4716.     fprintf(lpp,"connected to your OS9-System ! Baudrates > 9600 are usefull to get a very fast\n");
  4717.     fprintf(lpp,"screenupdate. \n");
  4718.     fprintf(lpp,"While the program is running, you can switch to the following modes:\n\n");
  4719.     fprintf(lpp,"                                   A  => ALPHA MODE\n");
  4720.     fprintf(lpp,"                                   B  => ALPHA MODE [extended]\n");
  4721.     fprintf(lpp,"                                   C  => CLEAR CPU %% BEFORE UPDATE [ON/OFF]\n");
  4722.     fprintf(lpp,"                                   D  => SET TIME DELAY\n");
  4723.     fprintf(lpp,"                                   E  => MODUL INFORMATION\n");
  4724.     fprintf(lpp,"                                   F  => FORK SHELL/ZSH\n");
  4725.     fprintf(lpp,"                                   G  => GRAPHIC MODE\n");
  4726.     fprintf(lpp,"                                   H  => ONLINE HELP\n");
  4727.     fprintf(lpp,"                                   I  => READ PASSWORDFILE\n");
  4728.     fprintf(lpp,"                                   J  => HOLD MAXIMUM CPUTIME CONSUPTION\n");
  4729.     fprintf(lpp,"                                   K  => KILL SELECTED PROCESS\n");
  4730.     fprintf(lpp,"                                   L  => ENABLE ALL SUSPENDED PROCESSES\n");
  4731.   }
  4732.   retstr=inkey(0,"\033[7;7m Press any key for more or 'Q' to return. \033[0;0m");
  4733.   if(retstr)
  4734.     return(1);
  4735.   effect();
  4736.   cls();
  4737.   printf ("\033(0");
  4738.   printf ("%s",hdr);
  4739.   printf ("\033(B\n");
  4740.   if(logindi)
  4741.   {  
  4742.     fprintf (lpp,"\033(0");
  4743.     fprintf (lpp,"%s",hdr);
  4744.     fprintf (lpp,"\033(B\n");
  4745.   }
  4746.  
  4747.   gotoxy(1,22);  
  4748.   printf ("\033(0");
  4749.   printf ("%s",hdr);
  4750.   printf ("\033(B\n");
  4751.   if(logindi)
  4752.   {  
  4753.     fprintf (lpp,"\033(0");
  4754.     fprintf (lpp,"%s",hdr);
  4755.     fprintf (lpp,"\033(B\n");
  4756.   }
  4757.   gotoxy(1,2);  
  4758.   printf("                                   M  => MARK PROCESSES > 75 %% CPU\n");
  4759.   printf("                                   N  => NAME  MODE\n");
  4760.   printf("                                   O  => SUSPEND/ENABLE PROCESS\n");
  4761.   printf("                                   P  => PRIORITY display [ON/OFF]\n");
  4762.   printf("                                   Q  => QUIT SYSMON\n"); 
  4763.   printf("                                   R  => QUICK REFERENCE ON/OFF\n");
  4764.   printf("                                   S  => SELECT-MODE [ON/OFF]\n");
  4765.   printf("                                   T  => SET PROCESS PRIORITY\n");
  4766.   printf("                                   U  => ONLY DISPLAY USERPROCESSES\n");
  4767.   printf("                                   V  => SHOW IO PATHES\n");
  4768.   printf("                                   W  => KILL UNKOWN USER PROCESSES\n");
  4769.   printf("                                   X  => RESET CPU\n");
  4770.   printf("                                   Z  => ENABLE FILE LOGING\n");
  4771.   printf("                                   1  => SAVE USERSETTINGS\n");
  4772.   printf("                                   2  => LOAD USERSETTINGS\n\n");
  4773.   printf("       CURSOR RIGHT/LEFT  or   + / -  => NEXT 16 PROCESSES\n");
  4774.   printf("       CURSOR UP/DOWN     or   < / >  => SELECT PROCESS [SELECT MODE]\n\n");
  4775.   if(logindi)
  4776.   {
  4777.     fprintf(lpp,"                                   M  => MARK PROCESSES > 75 %% CPU\n");
  4778.     fprintf(lpp,"                                   N  => NAME  MODE\n");
  4779.     fprintf(lpp,"                                   O  => SUSPEND/ENABLE PROCESS\n");
  4780.     fprintf(lpp,"                                   P  => PRIORITY display [ON/OFF]\n");
  4781.     fprintf(lpp,"                                   Q  => QUIT SYSMON\n"); 
  4782.     fprintf(lpp,"                                   R  => QUICK REFERENCE ON/OFF\n");
  4783.     fprintf(lpp,"                                   S  => SELECT-MODE [ON/OFF]\n");
  4784.     fprintf(lpp,"                                   T  => SET PROCESS PRIORITY\n");
  4785.     fprintf(lpp,"                                   U  => ONLY DISPLAY USERPROCESSES\n");
  4786.     fprintf(lpp,"                                   V  => SHOW IO PATHES\n");
  4787.     fprintf(lpp,"                                   W  => KILL UNKOWN USER PROCESSES\n");
  4788.     fprintf(lpp,"                                   X  => RESET CPU\n");
  4789.     fprintf(lpp,"                                   Z  => ENABLE FILE LOGING\n");
  4790.     fprintf(lpp,"                                   1  => SAVE USERSETTINGS\n");
  4791.     fprintf(lpp,"                                   2  => LOAD USERSETTINGS\n\n");
  4792.     fprintf(lpp,"       CURSOR RIGHT/LEFT  or   + / -  => NEXT 16 PROCESSES\n");
  4793.     fprintf(lpp,"       CURSOR UP/DOWN     or   < / >  => SELECT PROCESS [SELECT MODE]\n\n");
  4794.   }  
  4795.   retstr=inkey(0,"\033[7;7m Press any key for more or 'Q' for to return. \033[0;0m");
  4796.   if(retstr)
  4797.     return(1);
  4798.   effect();
  4799.   cls();  
  4800.   printf ("\033(0");
  4801.   printf ("%s",hdr);
  4802.   printf ("\033(B\n");
  4803.   if(logindi)
  4804.   {  
  4805.     fprintf (lpp,"\033(0");
  4806.     fprintf (lpp,"%s",hdr);
  4807.     fprintf (lpp,"\033(B\n");
  4808.   }
  4809.   gotoxy(1,22);  
  4810.   printf ("\033(0");
  4811.   printf ("%s",hdr);
  4812.   printf ("\033(B\n");
  4813.   if(logindi)
  4814.   {  
  4815.     fprintf (lpp,"\033(0");
  4816.     fprintf (lpp,"%s",hdr);
  4817.     fprintf (lpp,"\033(B\n");
  4818.   }
  4819.   gotoxy(1,2);  
  4820.  
  4821.   printf("Send a mail if you are interested on the latest version !\n");  
  4822.   printf("Also send bug-reports, or any suggestions to improve this program, to:\n\n");
  4823.   printf("Frank Richard Schmitt\n");
  4824.   printf("MPI Kernphysik Heidelberg\n");
  4825.   printf("P.O.-BOX 103980\n");
  4826.   printf("D-6900 Heidelberg\n");
  4827.   printf("West Germany\n\n");
  4828.   printf("or phone: (06221)/516284 or 516515 \n");
  4829.   printf("BITNET: jnet%%\"SCHMITT@DHDMPI5H\"\n");
  4830.   printf("BTX: *0622454879#\n");
  4831.   printf("PACKET RADIO: DF3UM @DB0GV.DL.EU\n\n");
  4832.   if(logindi)
  4833.   {
  4834.     fprintf(lpp,"Send a mail if you are interested on the latest version !\n");  
  4835.     fprintf(lpp,"Also send bug-reports, or any suggestions to improve this program, to:\n\n");
  4836.     fprintf(lpp,"Frank Richard Schmitt\n");
  4837.     fprintf(lpp,"MPI Kernphysik Heidelberg\n");
  4838.     fprintf(lpp,"P.O.-BOX 103980\n");
  4839.     fprintf(lpp,"D-6900 Heidelberg\n");
  4840.     fprintf(lpp,"West Germany\n\n");
  4841.     fprintf(lpp,"or phone: (06221)/516284 or 516515 \n");
  4842.     fprintf(lpp,"BITNET: jnet%%\"SCHMITT@DHDMPI5H\"\n");
  4843.     fprintf(lpp,"BTX: *0622454879#\n");
  4844.     fprintf(lpp,"PACKET RADIO: DF3UM @DB0GV.DL.EU\n\n");
  4845.   }
  4846.   return(0);  
  4847. }
  4848. /*---------------------------------------------------------------------------*/
  4849. /* name: CHECK_IT                                                            */
  4850. /* function: check first if program is running under system                  */
  4851. /* by: FRS                                                                   */
  4852. /* Date: 08/10/91                                                            */
  4853. /*---------------------------------------------------------------------------*/
  4854. check_it()
  4855. {
  4856.    register int i, bytes;
  4857.  
  4858.    unsigned short id,pid,group,user;
  4859.    unsigned short proctab[sizeof(struct pdsc)];
  4860.    register struct pdsc *pr;
  4861.  
  4862.    ownuid=getpid();   /* get our own process id */
  4863.    if(ownuid==-1)
  4864.    {    
  4865.     gotoxy(1,23);    
  4866.     printf("\033[K\007\033[7;7m SYSMON-ERROR: \033[0;0m Can't get own process_uid : ",ownuid);
  4867.     if(logindi)
  4868.         fprintf(lpp,"\033[K\007\033[7;7m SYSMON-ERROR: \033[0;0m Can't get own process_uid : ",ownuid);
  4869.     switch_ctrl(RESTORE);
  4870.     exit(errno);
  4871.    }
  4872.  
  4873.    pr = (struct pdsc *)proctab;
  4874.  
  4875.    bytes = _get_process_desc(ownuid,sizeof(struct pdsc),pr);
  4876.    if(bytes != -1)
  4877.    {      
  4878.       id=bytes;
  4879.       group=oldgrp=pr->_group;
  4880.       user=oldus=pr->_user;
  4881.       orginatprior=pr->_prior;
  4882.    
  4883.       if(strncmp(portnam,"TERM",4)==0)  /* only at /TERM                   */
  4884.         ownprior=orginatprior;            /* priority => startuppriority !   */
  4885.       else
  4886.       {
  4887.         prillow=FALSE;        /* don't allow priority rising during activity !*/
  4888.         ownprior=128;        /* default priority for OS9/68k ! */
  4889.       }
  4890.  
  4891.       if(strncmp(portnam,"TERM",4)!=0 && user!=0)   /* only at /TERM      */
  4892.     reset_flag=FALSE;                           /* reset is allowed ! */
  4893.  
  4894.       if(!group && user!=9)
  4895.       {
  4896.         privileg=TRUE;
  4897.         mindelay=1;
  4898.       }
  4899.       else
  4900.       {
  4901.         if(group)
  4902.         {
  4903.             mindelay=delay+2;
  4904.             delay+=2;
  4905.         }
  4906.         privileg=FALSE;
  4907.       }
  4908.    }
  4909.    else
  4910.    {
  4911.       gotoxy(1,23);
  4912.       printf("\007\033[7;7m SYSMON-ERROR: \033[0;0m Can't get processdata for own process !\n");
  4913.       if(logindi)    
  4914.           fprintf(lpp,"\007\033[7;7m SYSMON-ERROR: \033[0;0m Can't get processdata for own process !\n");
  4915.       switch_ctrl(RESTORE);
  4916.       exit(errno);
  4917.    }
  4918. }
  4919. /*---------------------------------------------------------------------------*/
  4920. cursoroff()
  4921. {
  4922.     printf("\033[?25l\n");
  4923.     if(logindi)
  4924.         fprintf(lpp,"\033[?25l\n");
  4925. }
  4926. /*---------------------------------------------------------------------------*/
  4927. cursoron()
  4928. {
  4929.     printf("\033[?25h\n");
  4930.     if(logindi)
  4931.         fprintf(lpp,"\033[?25h\n");
  4932. }
  4933. /*---------------------------------------------------------------------------*/
  4934. termcheck()
  4935. {
  4936.     register char *pterminal, *puser;  
  4937.     register int i;
  4938.     char terminal[100];
  4939.     char user[100];
  4940.  
  4941.  
  4942.     pterminal=(char *) getenv("TERM");
  4943.     if(pterminal!=0)
  4944.     {
  4945.         sprintf(terminal,"%s",pterminal);
  4946.         uppercase(terminal);
  4947.  
  4948.         for(i=0;i<=5;i++)
  4949.         {
  4950.             if(strcmp(terminal,termtype[i])==0)
  4951.                 return(0);
  4952.         }
  4953.         printf("\nSYSMON: '%s' terminal not supported !\n",terminal);
  4954.         printf("        Only the following TERMINALS are supported:\n        ");
  4955.         for(i=0;i<=5;i++)
  4956.             printf("%s  ",termtype[i]);
  4957.         printf("\n\n");
  4958.         if(strncmp(portnam,"PKS",3)==0)
  4959.             sleep(2);
  4960.         exit(0);
  4961.     }  
  4962.     else
  4963.     {
  4964.         puser=(char *) getenv("USER");
  4965.         if(puser!=0)
  4966.         {
  4967.             sprintf(user,"%s",puser);
  4968.             uppercase(user);
  4969.             if(strncmp("SYSMON",user,6)==0)
  4970.             {
  4971.                 cls();
  4972.                   gotoxy(1,23);
  4973.                 printf("\033[7;7m SYSMON: \033[0;0m Environment variable 'TERM' not set !  Assumming VT100-terminal !\n"); 
  4974.                 sleep(3);
  4975.                 return(0);
  4976.             }
  4977.             else
  4978.             {
  4979.                 printf("%s\n",termwarnstr);
  4980.                 if(strncmp(portnam,"PKS",3)==0)
  4981.                     sleep(2);
  4982.                 exit(errno);
  4983.             }
  4984.         }
  4985.         else
  4986.         {
  4987.             printf("%s\n",termwarnstr);
  4988.             if(strncmp(portnam,"PKS",3)==0)
  4989.                 sleep(2);
  4990.             exit(errno);
  4991.         }
  4992.     }
  4993. }
  4994. /*---------------------------------------------------------------------------*/
  4995. nodedefcreate()
  4996. {
  4997.     FILE *nodedef_f;
  4998.     int askret;
  4999.     char inkstr[100];
  5000.  
  5001.     cls();
  5002.     sprintf(inkstr,
  5003.     "\033[K\007\033[7;7m SYSMON: \033[0;0m File: '%s' doesn't exist !  Create it \033[1;1m\033[5;5m\033[7;7m[Y/N]\033[0;0m ?",nodedefnam);
  5004.     askret=inkey(30,inkstr);
  5005.     switch(askret)
  5006.     {
  5007.         case TRUE:
  5008.             gotoxy(1,23);
  5009.             printf("\033[K\033[7;7m SYSMON: \033[0;0m Please enter SYSTEM-NODENAME [max 10 char] : ");
  5010.             fflush(stdout);  
  5011.             if(rawinput(nodename)==0)                
  5012.                 return(FALSE);
  5013.  
  5014.             nodedef_f=fopen(nodedefnam,"w+");
  5015.             if(nodedef_f==0)
  5016.             {
  5017.                   gotoxy(1,23);
  5018.                 printf("\033[K\007\033[7;7m SYSMON-ERROR: \033[0;0m Creation of '%s' failed !   errno=%d\n",nodedefnam,errno); 
  5019.                 error_indi=TRUE;
  5020.                 return(FALSE);
  5021.             }
  5022.             else
  5023.             {
  5024.                 uppercase(nodename);
  5025.                 fprintf(nodedef_f,"%s\n",nodename);
  5026.                 fclose(nodedef_f);
  5027.                 return(TRUE);
  5028.             }
  5029.             break;
  5030.  
  5031.         case TIMEOUT:
  5032.             error_indi=TRUE;
  5033.             gotoxy(1,23);
  5034.             printf("%s",timeoutstr);
  5035.             if(logindi)
  5036.                 fprintf(lpp,"%s",timeoutstr);
  5037.             sleep(2);
  5038.             return(FALSE);
  5039.             break;
  5040.  
  5041.         default:
  5042.             error_indi=TRUE;
  5043.             ret_disp=100;
  5044.             gotoxy(1,23);
  5045.             printf("\033[K\n");
  5046.             if(logindi)
  5047.                  fprintf(lpp,"\033[K\n");
  5048.             return(FALSE);
  5049.             break;
  5050.     }
  5051. }
  5052. /*---------------------------------------------------------------------------*/
  5053. rawinput(input)
  5054. char *input;
  5055. {
  5056.     register int i, ref;
  5057.     register int index=0;
  5058.     int bytes;
  5059.     char *inpoi;
  5060.     char taste;
  5061.  
  5062.     int jtime, jdate,jtick;
  5063.     short jday;
  5064.  
  5065.     inpoi=input;
  5066.  
  5067.     _sysdate(0,&jtime,&jdate,&jday,&jtick);
  5068.     _julian(&jtime,&jdate);
  5069.     ref=86400*jdate+(86400-jtime);
  5070.  
  5071.     for(;;)
  5072.     {
  5073.           if(_gs_rdy(0)>0)
  5074.           {
  5075.             if(read(0,&taste,1)==-1)        /* read one byte ! */
  5076.                 break;
  5077.  
  5078.             if(icpt_flag)
  5079.             {
  5080.                 *input=0;
  5081.                 return(0);
  5082.             }
  5083.  
  5084.             if(taste==25)                 /* ^Y detected ! */
  5085.             {
  5086.                 *input=0;
  5087.                 return(0);
  5088.             }
  5089.  
  5090.             if(taste==26)                 /* ^Z detected ! */
  5091.             {
  5092.                 printf("\033[7;7m EXIT \033[0;0m \n");
  5093.                 return(0);
  5094.             }
  5095.  
  5096.             if(taste=='\n')         /* CR detected ! */
  5097.             {
  5098.                 printf("\n");
  5099.                 break;
  5100.             }
  5101.  
  5102.             if(taste==8 || taste==0x7f)        /* BACKSPACE ! */    
  5103.             {
  5104.                 if(index>0)
  5105.                 {
  5106.                     index--;
  5107.                     inpoi--;
  5108.                     *inpoi=0;
  5109.                        printf("\033[1D\033[1P");
  5110.                     fflush(stdout);
  5111.                 }
  5112.             }
  5113.             else
  5114.             {
  5115.                 if(index>=10)        /* max 10 characters allowed ! */
  5116.                     continue;
  5117.  
  5118.                 printf("%c",taste);
  5119.             fflush(stdout);
  5120.                 *inpoi=taste;
  5121.                 inpoi++;
  5122.                 *inpoi=0;
  5123.                 index++;
  5124.             }
  5125.             _sysdate(0,&jtime,&jdate,&jday,&jtick);
  5126.             _julian(&jtime,&jdate);
  5127.             ref=86400*jdate+(86400-jtime);
  5128.           }
  5129.         else
  5130.         {
  5131.             _sysdate(0,&jtime,&jdate,&jday,&jtick);
  5132.             _julian(&jtime,&jdate);
  5133.             i=ref-(86400*jdate+(86400-jtime));
  5134.             tsleep(5);
  5135.         }
  5136.  
  5137.         if(i>60)              /* ca. 60 seconds TIMEOUT ! */
  5138.         {
  5139.                 gotoxy(1,23);
  5140.                 printf("\033[K\007\033[7;7;m SYSMON: \033[0;0m Input timeout period expired !\n");
  5141.                 sleep(3);
  5142.                 return(0);
  5143.         }
  5144.     }
  5145.  
  5146.     if(index<=2)
  5147.         return(0);
  5148.     else
  5149.         return(TRUE);
  5150. }
  5151. /*---------------------------------------------------------------------------*/
  5152. loadusersetup()
  5153. {
  5154.     FILE *setupf;
  5155.     register int errvar;
  5156.     register char *userssup;
  5157.     char usershome[100];  
  5158.     unsigned char values[10];
  5159.  
  5160.     userssup=(char *) getenv("HOME");
  5161.     if(userssup!=0)
  5162.     {
  5163.         sprintf(usershome,"%s/.sysmon.init",userssup);
  5164.         setupf=fopen(usershome,"r");
  5165.         if(setupf!=0)
  5166.         {
  5167.              if(fread(values,1,4,setupf)!=4)
  5168.             {
  5169.                 errvar=errno;
  5170.                 fclose(setupf);
  5171.                 return(errvar);
  5172.             }
  5173.             fclose(setupf);
  5174.  
  5175.             mode_flag=(values[0] & 0x01);
  5176.             exmode=(values[1] & 0x03);
  5177.             susy_flag=(values[2] & 0x01);
  5178.             delay=values[3];
  5179.             if(delay>60)
  5180.                 delay=60;
  5181.             if(privileg==FALSE)
  5182.                 susy_flag=FALSE;
  5183.  
  5184.               if(strncmp(portnam,"PKS",3)==0)
  5185.               {    
  5186.                 if(delay<6)
  5187.                        delay=6;
  5188.                 stdout->_flag |=_UNBUF;
  5189.               }
  5190.             myolddelay=delay;
  5191.             return(FALSE);
  5192.         }
  5193.         else
  5194.             return(errno);
  5195.     }
  5196.     else
  5197.         return(errno);
  5198. }
  5199. /*---------------------------------------------------------------------------*/
  5200. saveusersetup()
  5201. {
  5202.     FILE *setupf;
  5203.     register int errvar;
  5204.     register char *userssup;
  5205.     char usershome[100];  
  5206.     unsigned char values[10];
  5207.  
  5208.     userssup=(char *) getenv("HOME");
  5209.     if(userssup!=0)
  5210.     {
  5211.         sprintf(usershome,"%s/.sysmon.init",userssup);
  5212.         setupf=fopen(usershome,"w+");
  5213.         if(setupf!=0)
  5214.         {
  5215.             if(privileg==FALSE)
  5216.                 susy_flag=FALSE;
  5217.             values[0]=mode_flag;
  5218.             values[1]=exmode;
  5219.             values[2]=susy_flag;
  5220.             values[3]=delay;
  5221.  
  5222.              if(fwrite(values,1,4,setupf)!=4)
  5223.             {
  5224.                 errvar=errno;
  5225.                 fclose(setupf);
  5226.                 return(errvar);
  5227.             }
  5228.             fclose(setupf);
  5229.             return(FALSE);
  5230.         }
  5231.         return(errno);
  5232.     }
  5233.     else
  5234.         return(errno);
  5235. }
  5236. /*===========================================================================*/
  5237. main(argc,argv,envir)
  5238. int argc;
  5239. char *argv[];
  5240. char *envir[];
  5241. {
  5242.   FILE *nodedef;
  5243.   char *cpoi, *ppoi;
  5244.   char *fmodpoi;  
  5245.   register int i;
  5246.  
  5247.   int cpyh=0;
  5248.   short Sysdev_offset;
  5249.   short *Sysdev_poi;  
  5250.   char abort=0;  
  5251.     
  5252.   environa=(char **) envir;  
  5253.  
  5254.  
  5255.  
  5256.  
  5257.   /* THIS SECTION WAS PROGRAMMED BY F.KOECK  DESOLATE SYSTEMS INC. (C) 1992 */
  5258.   for(i=0;i<ARG_ENV_NUM-1;i++)
  5259.   {
  5260.      if((argblk[i]=(char *) calloc(1,ARG_ENV_LEN))==0)
  5261.      {
  5262.         printf("\007SYSMON: Can't get memory by the system !\n");
  5263.         exit(errno);
  5264.      }
  5265.   }
  5266.   argblk[ARG_ENV_NUM-1]=(char *) 0;
  5267.  
  5268.  
  5269.   porthandle=_gs_devn(0,portnam);
  5270.   if(porthandle==-1)
  5271.   {
  5272.     printf("\n\007SYSMON: Can't get own device-name !\n");
  5273.     sleep(1);
  5274.     exit(errno);
  5275.   }  
  5276.   uppercase(portnam);
  5277.  
  5278.   if(argc>1)
  5279.   {
  5280.     for(i=1;i<argc;i++)
  5281.     {
  5282.       cpoi=argv[i];
  5283.       if(*cpoi !='-')
  5284.       {
  5285.         cursoroff();
  5286.         helpuser();
  5287.         cursoron();
  5288.         if(strncmp(portnam,"PKS",3)==0)
  5289.             sleep(2);
  5290.         exit(0);
  5291.       }
  5292.       while(*cpoi++ != 0)
  5293.       {
  5294.         switch(tolower(*cpoi))
  5295.         {
  5296.         case '?':
  5297.           cursoroff();
  5298.           helpuser();
  5299.           cursoron();
  5300.           if(strncmp(portnam,"PKS",3)==0)
  5301.             sleep(2);
  5302.           exit(0);  
  5303.           break;
  5304.         case 'b':
  5305.           exmode=1;
  5306.           mode_flag=1;
  5307.           abort=TRUE;        
  5308.           break;
  5309.         case 'e':
  5310.           exmode=2;
  5311.           mode_flag=1;
  5312.           abort=TRUE;        
  5313.           break;
  5314.         case 'a':
  5315.           exmode=0;
  5316.           mode_flag=1;
  5317.           abort=TRUE;        
  5318.           break;
  5319.         case 'c':
  5320.           clflg=TRUE;
  5321.           abort=TRUE;
  5322.           break;
  5323.         case 'j':
  5324.           maxh_flag=TRUE;
  5325.           abort=TRUE;  
  5326.           break;
  5327.         case 'm':
  5328.           mark=TRUE;
  5329.           abort=TRUE;
  5330.           break;
  5331.         case 'p':
  5332.           prior_flag=TRUE;
  5333.           abort=TRUE;
  5334.           break;
  5335.         case 'q':
  5336.           prillow=FALSE;
  5337.           abort=TRUE;
  5338.           break;
  5339.         case 'u':
  5340.           mode_flag=1;
  5341.           active_flag=1;
  5342.           abort=TRUE;        
  5343.           break;
  5344.         case 'd':
  5345.           default_flag=TRUE;
  5346.           abort=TRUE;        
  5347.           break;
  5348.         case 'r':
  5349.           reference=TRUE;
  5350.           abort=TRUE;
  5351.           break;
  5352.         case 'w':
  5353.           watchy_flag=TRUE;
  5354.           abort=TRUE;
  5355.           break;
  5356.         case 'v':
  5357.           if(show_version()==1)
  5358.             cls();
  5359.           if(strncmp(portnam,"PKS",3)==0)
  5360.             sleep(2);
  5361.           exit(0);  
  5362.           break;  
  5363.         case 't':
  5364.           ppoi=cpoi;
  5365.           if(*(++ppoi) != '=')
  5366.           {
  5367.             cursoroff();
  5368.             helpuser();
  5369.             cursoron();
  5370.             if(strncmp(portnam,"PKS",3)==0)
  5371.                 sleep(2);
  5372.             exit(0);
  5373.           }
  5374.           ++ppoi;
  5375.           delay = atoi(ppoi);
  5376.           if(delay >60)
  5377.              delay=60;
  5378.           if(delay< 1)
  5379.              delay=1;
  5380.           abort=TRUE;
  5381.           myolddelay=delay;
  5382.           break;
  5383.         }
  5384.       }
  5385.       if(!abort)
  5386.       {
  5387.         cursoroff();
  5388.           helpuser();
  5389.         cursoron();
  5390.         if(strncmp(portnam,"PKS",3)==0)
  5391.             sleep(2);
  5392.         exit(0);
  5393.       }
  5394.     }
  5395.   }
  5396.  
  5397.  
  5398.   /* get system information for TERMINAL  */
  5399.   termcheck();
  5400.  
  5401.   /* get system information from init module ! */
  5402.   fmodpoi=(char *) (modlink("init",0));
  5403.   if(fmodpoi!= (char *) (-1))
  5404.   {
  5405.     munlink(fmodpoi);
  5406.     cpyh=_cpymem(0, sizeof(initbuf), fmodpoi, initbuf);
  5407.     sprintf(os9vers,"V%d.%d",*(initbuf+0x57),*(initbuf+0x58));
  5408.     if((*(initbuf+0x57)<2) || (*(initbuf+0x58)<3))
  5409.     {
  5410.         cls();
  5411.         gotoxy(1,23);
  5412.         printf(
  5413.         "\033[K\007\033[7;7m SYSMON-ERROR: \033[0;0m OS9/68k %s is too old for SYSMON %s\n"
  5414.         ,os9vers,versi);
  5415.         if(strncmp(portnam,"PKS",3)==0)
  5416.             sleep(2);
  5417.         exit(172);
  5418.     }
  5419.   }
  5420.   else
  5421.   {
  5422.     cls();
  5423.     gotoxy(1,23);
  5424.     printf("\033[K\007\033[7;7m SYSMON-ERROR: \033[0;0m Can't access 'INIT' module !\n");
  5425.     if(strncmp(portnam,"PKS",3)==0)
  5426.         sleep(2);
  5427.     exit(0);
  5428.   } 
  5429.  
  5430.   if(default_flag && fmodpoi!=(char *) (-1))
  5431.   {
  5432.     Sysdev_poi=(short *) (initbuf+0x40); 
  5433.     Sysdev_offset=*Sysdev_poi;
  5434.     strcpy(ddnam,initbuf+Sysdev_offset);
  5435.   }
  5436.   else
  5437.     sprintf(ddnam,"/dd");
  5438.  
  5439.   sprintf(nodedefnam,"%s/sys/nodedef",ddnam);
  5440.   sprintf(passwordnam,"%s/sys/password",ddnam);
  5441.  
  5442.   processor=_getsys(D_MPUType,4);
  5443.  
  5444.   if(processor>68010 || (strncmp(portnam,"TERM",4))!=0)
  5445.   {
  5446.       if(strncmp(portnam,"PKS",3)==0)
  5447.       {    
  5448.            olddelay=6;
  5449.         stdout->_flag |=_UNBUF;
  5450.       }
  5451.       else    
  5452.           olddelay=4;
  5453.   }
  5454.   
  5455.   if(delay>olddelay)
  5456.     olddelay=delay;
  5457.   else
  5458.     delay=olddelay;
  5459.  
  5460.   myolddelay=delay;
  5461.   intercept(gotsignl);      /* setup Intercept routine */
  5462.   check_it();
  5463.   setuid(0);  
  5464.   
  5465.   nodedef=fopen(nodedefnam,"r");
  5466.   if(nodedef)
  5467.   {
  5468.     fscanf(nodedef,"%s",nodename);
  5469.     fclose(nodedef);
  5470.     nodenamlen=strlen(nodename);
  5471.  
  5472.     if(nodenamlen<2 || nodenamlen>10)
  5473.     {
  5474.         setuid(oldgrp*65536+oldus);
  5475.         cursoron();
  5476.           printf(
  5477.         "\007\033[7;7m SYSMON-ERROR: \033[0;0m illegal nodenamelength !   [1 < nodename < 11 ]\n\n");
  5478.         if(strncmp(portnam,"PKS",3)==0)
  5479.             sleep(2);
  5480.         exit(0);
  5481.     }
  5482.     else
  5483.         nodeflag=TRUE;
  5484.   }
  5485.   else
  5486.   {
  5487.         if(errno==216 && privileg==TRUE)
  5488.         {
  5489.             tmode(0,0);
  5490.             nodeflag=nodedefcreate();
  5491.             tmode(0,1);
  5492.         }
  5493.       else
  5494.             nodeflag=FALSE;
  5495.   }  
  5496.   pwh=get_password();    
  5497.   if(!pwh)
  5498.     name_flag=FALSE;
  5499.  
  5500.   if(argc==1)
  5501.     loadusersetup();
  5502.  
  5503.   setuid(oldgrp*65536+oldus);
  5504.  
  5505.   for(i=0;i<MAXPROCS;maxprocent[i++]=0);
  5506.  
  5507.   switch_ctrl(GET);           /* get setings of tmode    */
  5508.   switch_ctrl(OFF);           /* disable ^C  &  ^E       */
  5509.   tmode(0,0);                /* nopause noecho !        */
  5510.   display();
  5511. }
  5512. /*---------------------- END OF SYSMON - SOURCE -----------------------------*/
  5513.