home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / xetat / part01 < prev    next >
Encoding:
Text File  |  1992-03-17  |  42.6 KB  |  1,383 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  3. From: pierre%system@uunet.UU.NET (Pierre Ficheux)
  4. Subject: v17i019: xetat : graphical system activity reporter, Part01/02
  5. Message-ID: <csx-17i019-xetat@uunet.UU.NET>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. Date: Wed, 18 Mar 1992 21:36:24 GMT
  10. Approved: dcmartin@msi.com
  11.  
  12. Submitted-by: pierre%system@uunet.UU.NET (Pierre Ficheux)
  13. Posting-number: Volume 17, Issue 19
  14. Archive-name: xetat/part01
  15.  
  16. [ I could not compile this program since it needs SYSVR3.2 - dcm ]
  17.  
  18. #!/bin/sh
  19. # This is a shell archive (produced by shar 3.49)
  20. # To extract the files from this archive, save it to a file, remove
  21. # everything above the "!/bin/sh" line above, and type "sh file_name".
  22. #
  23. # made 03/10/1992 15:58 UTC by pficheux@lectra.gna.org
  24. # Source directory /X11/Divers/contrib/lectra/xetat/distrib
  25. #
  26. # existing files will NOT be overwritten unless -c is specified
  27. #
  28. # This shar contains:
  29. # length  mode       name
  30. # ------ ---------- ------------------------------------------
  31. #   1090 -rw-r--r-- README.en
  32. #   1070 -rw-r--r-- README.fr
  33. #    303 -rw-r--r-- Imakefile
  34. #   1775 -rw-r--r-- activite.bit
  35. #   1778 -rw-r--r-- processus.bit
  36. #   1766 -rw-r--r-- xetat.bit
  37. #   9502 -r--r--r-- activite.c
  38. #     21 -rw-r--r-- patchlevel.h
  39. #  19144 -r--r--r-- processus.c
  40. #  12724 -r--r--r-- xetat.c
  41. #   1279 -rw-r--r-- xetat.man.en
  42. #   1640 -rw-r--r-- xetat.man.fr
  43. #   5546 -rw-r--r-- XEtat.ad.en
  44. #   5539 -rw-r--r-- XEtat.ad.fr
  45. #
  46. # ============= README.en ==============
  47. if test -f 'README.en' -a X"$1" != X"-c"; then
  48.     echo 'x - skipping README.en (File already exists)'
  49. else
  50. echo 'x - extracting README.en (Text)'
  51. sed 's/^X//' << 'SHAR_EOF' > 'README.en' &&
  52. X
  53. X                XETAT    1.x
  54. X
  55. X        graphical system activity reporter        
  56. X
  57. X                 Pierre Ficheux 12/91
  58. X
  59. X
  60. 1-Introduction
  61. --------------
  62. X
  63. XXETAT must be used with UNIX SVR3.2 and displays graphical informations about your 
  64. system (such informations can also be collected by "sar"). 
  65. X
  66. 2-Generation
  67. ------------
  68. X
  69. First, you must copy the english (if you read this, i assume you speak english!) 
  70. version of the resource file and man pages to the generic files :
  71. X
  72. X        "cp XEtat.ad.en    XEtat.ad" 
  73. X        "cp xetat.man.en xetat.man"
  74. X
  75. Then, you just have to follow the standard X11R4 client generation procedure :
  76. X
  77. X    1- generate the Makefile using "imake" 
  78. X
  79. X        imake -DUseInstalled -I/usr/lib/X11/config -DTOPDIR=/usr/lib/X11
  80. X
  81. X    2- create the dependencies with "make depend"
  82. X
  83. X    3- create the program with "make all"
  84. X
  85. X    4- install it with "make install"
  86. X
  87. X    5- install the man pages with "make install.man"
  88. X
  89. X
  90. Have fun !
  91. X
  92. X
  93. X    Pierre FICHEUX        Lectra-Systemes Service R & D 
  94. X                                ZI Marticot
  95. X                                33610 Cestas    FRANCE         
  96. X                E-mail : pficheux@lectra.gna.org
  97. X
  98. X
  99. X
  100. X
  101. X
  102. X
  103. X
  104. X
  105. X
  106. X
  107. X
  108. X
  109. X
  110. X
  111. X
  112. X
  113. SHAR_EOF
  114. chmod 0644 README.en ||
  115. echo 'restore of README.en failed'
  116. Wc_c="`wc -c < 'README.en'`"
  117. test 1090 -eq "$Wc_c" ||
  118.     echo 'README.en: original size 1090, current size' "$Wc_c"
  119. fi
  120. # ============= README.fr ==============
  121. if test -f 'README.fr' -a X"$1" != X"-c"; then
  122.     echo 'x - skipping README.fr (File already exists)'
  123. else
  124. echo 'x - extracting README.fr (Text)'
  125. sed 's/^X//' << 'SHAR_EOF' > 'README.fr' &&
  126. X                XETAT    1.x
  127. X
  128. X        graphical system activity reporter        
  129. X
  130. X                 Pierre Ficheux 12/91
  131. X
  132. X
  133. X
  134. X
  135. 1-Introduction
  136. --------------
  137. X
  138. XXETAT est destine a System V 3.2 et permet de visualiser graphiquement des 
  139. informations collectees habituellement par "sar". 
  140. X
  141. 2-Generation
  142. ------------
  143. X
  144. Si vous desirez le programme en francais, vous devez copier la version francaise du
  145. fichier de resource et du man sur les fichiers generiques
  146. X
  147. X    "cp XEtat.ad.fr XEtat.ad"
  148. X    "cp xetat.man.fr xetat.man"
  149. X
  150. Ensuite, il vous suffit de suivre la methode standard de generation d'un client X11 :
  151. X
  152. X    1- generation du Makfile par "imake" 
  153. X
  154. X        imake -DUseInstalled -I/usr/lib/X11/config -DTOPDIR=/usr/lib/X11
  155. X
  156. X    2- creation des dependance par "make depend"
  157. X
  158. X    3- creation du programme par "make all"
  159. X
  160. X    4- installation par "make install"
  161. X
  162. X    5- installation du man par "make install.man"
  163. X
  164. Bon courage !
  165. X
  166. X    Pierre FICHEUX        Lectra-Systemes Service R & D 
  167. X                                ZI Marticot
  168. X                                33610 Cestas    FRANCE         
  169. X                E-mail : pficheux@lectra.gna.org
  170. X
  171. X
  172. X
  173. X
  174. X
  175. X
  176. X
  177. X
  178. X
  179. X
  180. X
  181. X
  182. X
  183. X
  184. X
  185. X
  186. SHAR_EOF
  187. chmod 0644 README.fr ||
  188. echo 'restore of README.fr failed'
  189. Wc_c="`wc -c < 'README.fr'`"
  190. test 1070 -eq "$Wc_c" ||
  191.     echo 'README.fr: original size 1070, current size' "$Wc_c"
  192. fi
  193. # ============= Imakefile ==============
  194. if test -f 'Imakefile' -a X"$1" != X"-c"; then
  195.     echo 'x - skipping Imakefile (File already exists)'
  196. else
  197. echo 'x - extracting Imakefile (Text)'
  198. sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' &&
  199. #
  200. # Imakefile pour XETAT
  201. #
  202. X         INSTALL = bsdinst    
  203. X            SRCS = xetat.c activite.c processus.c
  204. X            OBJS = xetat.o activite.o processus.o
  205. X          LDLIBS = -lXaw -lXmu -lXext -lXt -lX11 $(EXTRA_LIBRARIES)
  206. X        PROGRAMS = xetat
  207. X
  208. ComplexProgramTarget(xetat)
  209. InstallAppDefaults(XEtat)
  210. SHAR_EOF
  211. chmod 0644 Imakefile ||
  212. echo 'restore of Imakefile failed'
  213. Wc_c="`wc -c < 'Imakefile'`"
  214. test 303 -eq "$Wc_c" ||
  215.     echo 'Imakefile: original size 303, current size' "$Wc_c"
  216. fi
  217. # ============= activite.bit ==============
  218. if test -f 'activite.bit' -a X"$1" != X"-c"; then
  219.     echo 'x - skipping activite.bit (File already exists)'
  220. else
  221. echo 'x - extracting activite.bit (Text)'
  222. sed 's/^X//' << 'SHAR_EOF' > 'activite.bit' &&
  223. #define activite_width 45
  224. #define activite_height 45
  225. static char activite_bits[] = {
  226. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  227. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  228. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x07,
  229. X   0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x40, 0x40, 0x40, 0x00, 0x04,
  230. X   0x04, 0x60, 0x40, 0xc0, 0x00, 0x04, 0x04, 0xc0, 0x40, 0x60, 0x00, 0x04,
  231. X   0x84, 0x80, 0x41, 0x20, 0x60, 0x04, 0x84, 0x01, 0x43, 0x30, 0x30, 0x04,
  232. X   0x04, 0x03, 0x41, 0x10, 0x98, 0x04, 0x04, 0x06, 0x00, 0x00, 0x4c, 0x04,
  233. X   0x04, 0x0c, 0x00, 0x00, 0x20, 0x04, 0x04, 0x80, 0x08, 0x11, 0x18, 0x04,
  234. X   0x04, 0x80, 0x08, 0x11, 0x04, 0x04, 0x34, 0x80, 0x08, 0x11, 0x82, 0x05,
  235. X   0xe4, 0x80, 0x08, 0x91, 0xe1, 0x04, 0x84, 0x03, 0x07, 0x51, 0x70, 0x04,
  236. X   0x04, 0x01, 0x02, 0x2e, 0x00, 0x04, 0x04, 0x00, 0xf0, 0x11, 0x00, 0x04,
  237. X   0x04, 0x00, 0xf8, 0x0f, 0x00, 0x04, 0x04, 0x00, 0xfc, 0x07, 0x00, 0x04,
  238. X   0x04, 0x00, 0xfc, 0x07, 0x00, 0x04, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x07,
  239. X   0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0x06, 0x54, 0x55, 0x55, 0x55, 0x55, 0x05,
  240. X   0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0x06, 0x54, 0x55, 0x55, 0x55, 0x55, 0x05,
  241. X   0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0x06, 0x54, 0x55, 0x55, 0x55, 0x55, 0x05,
  242. X   0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0x06, 0x54, 0x55, 0x55, 0x55, 0x55, 0x05,
  243. X   0xfc, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  244. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  245. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  246. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  247. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  248. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  249. SHAR_EOF
  250. chmod 0644 activite.bit ||
  251. echo 'restore of activite.bit failed'
  252. Wc_c="`wc -c < 'activite.bit'`"
  253. test 1775 -eq "$Wc_c" ||
  254.     echo 'activite.bit: original size 1775, current size' "$Wc_c"
  255. fi
  256. # ============= processus.bit ==============
  257. if test -f 'processus.bit' -a X"$1" != X"-c"; then
  258.     echo 'x - skipping processus.bit (File already exists)'
  259. else
  260. echo 'x - extracting processus.bit (Text)'
  261. sed 's/^X//' << 'SHAR_EOF' > 'processus.bit' &&
  262. #define processus_width 45
  263. #define processus_height 45
  264. static char processus_bits[] = {
  265. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00,
  266. X   0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00,
  267. X   0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00,
  268. X   0x00, 0xe0, 0xff, 0xff, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0xff, 0x01, 0x00,
  269. X   0x00, 0xfc, 0x41, 0xf0, 0x07, 0x00, 0x00, 0x7e, 0x40, 0xc0, 0x0f, 0x00,
  270. X   0x00, 0x1f, 0x40, 0x00, 0x1f, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x1e, 0x00,
  271. X   0x80, 0x07, 0x00, 0x00, 0x3c, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x78, 0x00,
  272. X   0xc0, 0x03, 0x00, 0x0c, 0x78, 0x00, 0xe0, 0x01, 0x00, 0x0e, 0xf0, 0x00,
  273. X   0xe0, 0x01, 0x00, 0x07, 0xf0, 0x00, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00,
  274. X   0xf0, 0x00, 0x80, 0x03, 0xe0, 0x01, 0xf0, 0x00, 0x80, 0x03, 0xe0, 0x01,
  275. X   0xf0, 0x00, 0xc0, 0x01, 0xe0, 0x01, 0x70, 0x00, 0xc0, 0x00, 0xc0, 0x01,
  276. X   0x70, 0x07, 0xe0, 0x00, 0xdc, 0x01, 0x70, 0x00, 0x60, 0x00, 0xc0, 0x01,
  277. X   0xf0, 0x00, 0xe0, 0x01, 0xe0, 0x01, 0xf0, 0x00, 0xc0, 0x03, 0xe0, 0x01,
  278. X   0xf0, 0x00, 0x80, 0x07, 0xe0, 0x01, 0xe0, 0x00, 0x00, 0x0f, 0xe0, 0x00,
  279. X   0xe0, 0x01, 0x00, 0x1e, 0xf0, 0x00, 0xe0, 0x01, 0x00, 0x3c, 0xf0, 0x00,
  280. X   0xc0, 0x03, 0x00, 0x78, 0x78, 0x00, 0xc0, 0x03, 0x00, 0x70, 0x78, 0x00,
  281. X   0x80, 0x07, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x1e, 0x00,
  282. X   0x00, 0x1f, 0x40, 0x00, 0x1f, 0x00, 0x00, 0x7e, 0x40, 0xc0, 0x0f, 0x00,
  283. X   0x00, 0xfc, 0x41, 0xf0, 0x07, 0x00, 0x00, 0xf0, 0x1f, 0xff, 0x01, 0x00,
  284. X   0x00, 0xe0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00,
  285. X   0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  286. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  287. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  288. SHAR_EOF
  289. chmod 0644 processus.bit ||
  290. echo 'restore of processus.bit failed'
  291. Wc_c="`wc -c < 'processus.bit'`"
  292. test 1778 -eq "$Wc_c" ||
  293.     echo 'processus.bit: original size 1778, current size' "$Wc_c"
  294. fi
  295. # ============= xetat.bit ==============
  296. if test -f 'xetat.bit' -a X"$1" != X"-c"; then
  297.     echo 'x - skipping xetat.bit (File already exists)'
  298. else
  299. echo 'x - extracting xetat.bit (Text)'
  300. sed 's/^X//' << 'SHAR_EOF' > 'xetat.bit' &&
  301. #define xetat_width 45
  302. #define xetat_height 45
  303. static char xetat_bits[] = {
  304. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
  305. X   0x80, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
  306. X   0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x17, 0x00, 0x00, 0x00, 0x00,
  307. X   0x40, 0x15, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xf5, 0xff, 0xff, 0xff, 0x03,
  308. X   0x44, 0x15, 0x00, 0x00, 0x00, 0x02, 0x44, 0x15, 0x00, 0x00, 0x00, 0x02,
  309. X   0x44, 0x15, 0x00, 0x00, 0x00, 0x02, 0x44, 0x15, 0x04, 0x00, 0x00, 0x02,
  310. X   0x44, 0x15, 0x04, 0x00, 0x00, 0x02, 0x44, 0x15, 0x06, 0x00, 0x00, 0x02,
  311. X   0x44, 0x15, 0x0a, 0x00, 0x00, 0x02, 0x7c, 0xf5, 0xff, 0xff, 0xff, 0x03,
  312. X   0x44, 0x15, 0x09, 0x00, 0x00, 0x02, 0x44, 0x17, 0x09, 0x00, 0x00, 0x02,
  313. X   0x44, 0x17, 0x09, 0x00, 0x00, 0x02, 0x44, 0x97, 0x08, 0x00, 0x00, 0x02,
  314. X   0x44, 0x97, 0x10, 0x00, 0x00, 0x02, 0x44, 0x57, 0x10, 0x00, 0x40, 0x02,
  315. X   0x44, 0x57, 0x10, 0x00, 0xc0, 0x02, 0x44, 0x57, 0x10, 0x00, 0xa0, 0x02,
  316. X   0x7c, 0xf7, 0xff, 0xff, 0xff, 0x03, 0x44, 0x37, 0x10, 0x08, 0x10, 0x03,
  317. X   0x44, 0x17, 0x20, 0x16, 0x10, 0x02, 0x44, 0x17, 0xa0, 0x21, 0x08, 0x02,
  318. X   0x44, 0x17, 0x60, 0x40, 0x08, 0x02, 0x44, 0x17, 0x00, 0x80, 0x04, 0x02,
  319. X   0x44, 0x17, 0x00, 0x00, 0x05, 0x02, 0x44, 0x17, 0x00, 0x00, 0x02, 0x02,
  320. X   0x7c, 0xf7, 0xff, 0xff, 0xff, 0x03, 0x64, 0x17, 0x00, 0x00, 0x00, 0x02,
  321. X   0x54, 0x17, 0x00, 0x00, 0x00, 0x02, 0x54, 0x17, 0x00, 0x00, 0x00, 0x02,
  322. X   0x4c, 0x10, 0x00, 0x00, 0x00, 0x02, 0x84, 0x0f, 0x00, 0x00, 0x00, 0x02,
  323. X   0x04, 0x07, 0x00, 0x00, 0x00, 0x02, 0x04, 0x07, 0x00, 0x00, 0x00, 0x02,
  324. X   0xfc, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
  325. X   0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
  326. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  327. SHAR_EOF
  328. chmod 0644 xetat.bit ||
  329. echo 'restore of xetat.bit failed'
  330. Wc_c="`wc -c < 'xetat.bit'`"
  331. test 1766 -eq "$Wc_c" ||
  332.     echo 'xetat.bit: original size 1766, current size' "$Wc_c"
  333. fi
  334. # ============= activite.c ==============
  335. if test -f 'activite.c' -a X"$1" != X"-c"; then
  336.     echo 'x - skipping activite.c (File already exists)'
  337. else
  338. echo 'x - extracting activite.c (Text)'
  339. sed 's/^X//' << 'SHAR_EOF' > 'activite.c' &&
  340. /*
  341. X * xetat - graphical system activity reporter
  342. X *
  343. X * Copyright 1991 Lectra Systemes
  344. X *
  345. X * Permission to use, copy, modify, and distribute this software and its
  346. X * documentation for any purpose and without fee is hereby granted, provided
  347. X * that the above copyright notice appear in all copies and that both that
  348. X * copyright notice and this permission notice appear in supporting
  349. X * documentation, and that the name of Lectra Systemes not be used in advertising or
  350. X * publicity pertaining to distribution of the software without specific,
  351. X * written prior permission.  Lectra Systemes makes no representations about the
  352. X * suitability of this software for any purpose.  It is provided "as is"
  353. X * without express or implied warranty.
  354. X *
  355. X * Auteur : Pierre FICHEUX     Lectra Systemes R & D
  356. X *
  357. X */
  358. static char sccsid[] = "@(#)activite.c    1.1 3/10/92";
  359. X
  360. /*
  361. X * Visualisation de l'activite
  362. X */
  363. X
  364. /* 
  365. X * Fichiers standards du toolkit Xt
  366. X */
  367. #include <X11/Intrinsic.h>
  368. #include <X11/StringDefs.h>
  369. #include <X11/XawMisc.h>
  370. #include <X11/Form.h>
  371. #include <X11/Label.h>
  372. #include <X11/Shell.h>
  373. #include <X11/Xaw/StripChart.h>
  374. /*
  375. X * Public include files for widgets used in this file.
  376. X */
  377. #ifdef X11R3
  378. #include <X11/Command.h>
  379. #include <X11/Box.h>
  380. #else /* R4 or later */
  381. #include <X11/Xaw/Command.h>
  382. #include <X11/Xaw/Box.h>
  383. #endif /* X11R3 */
  384. X
  385. #include <sys/types.h>
  386. #include <sys/sysinfo.h>
  387. #include <nlist.h>
  388. X
  389. #define U        0
  390. #define V        1
  391. #define PROC        2
  392. #define FREEMEM     3
  393. #define SYSINFO        4
  394. #define AVAILRMEM     5
  395. X
  396. #define VALEUR_FREEMEM        5
  397. X
  398. struct nlist namelist[] =
  399. {
  400. X    { "u", },
  401. X    { "v", },
  402. X    { "proc", },
  403. X    { "freemem", },
  404. X    { "sysinfo", },
  405. X    { "availrmem", },
  406. X    { 0, },
  407. };
  408. X
  409. long availrmem;
  410. extern int kmem;
  411. struct sysinfo old, new;
  412. static char buf[80];
  413. Dimension largeur_boite, hauteur_boite, distance_horizontale, distance_verticale, largeur_bord;
  414. X
  415. extern Widget forme_activite, topLevel, shell_activite;
  416. extern Widget titre_idle, titre_user, titre_kernel, titre_wait, titre_sxbrk, titre_freemem;
  417. extern Widget boite_idle, boite_user, boite_kernel, boite_wait, boite_sxbrk, boite_freemem;
  418. extern Widget indicateur_idle, indicateur_user, indicateur_kernel, indicateur_wait, indicateur_sxbrk, indicateur_freemem;
  419. extern Widget afficheur_idle, afficheur_user, afficheur_kernel, afficheur_wait, afficheur_sxbrk, afficheur_freemem;
  420. Dimension largeur_idle=1, largeur_user=1, largeur_kernel=1, largeur_wait=1, largeur_sxbrk=1, largeur_freemem=1;
  421. X
  422. double charge_courante_systeme[6];
  423. extern void init_charge ();
  424. static char flag_popup_actif = FALSE;
  425. X
  426. /*
  427. X * Lecture de la charge initiale du systeme
  428. X */
  429. X
  430. void init_charge ()
  431. {
  432. X    register int i;
  433. X
  434. X    if (nlist("/unix", namelist) != 0) {
  435. X    perror ("init_charge-nlist");
  436. X    exit(1);
  437. X    }
  438. X
  439. X    /* lecture de l'etat du systeme */
  440. X    if (lseek (kmem, namelist[SYSINFO].n_value, 0) < 0) {
  441. X    perror ("init_charge-lseek");
  442. X    exit (1);
  443. X    }
  444. X    
  445. X    if (read (kmem, (char *)&old, sizeof(old)) != sizeof (old)) {
  446. X    perror ("init_charge-read");
  447. X    exit (1);
  448. X    }
  449. X
  450. X    /* mesure de availrmem */
  451. X    if (lseek(kmem, (long) namelist[AVAILRMEM].n_value, 0) < 0) {
  452. X    perror ("mesure_charge_courante_systeme-lseek");
  453. X    exit (1);
  454. X    }
  455. X
  456. X    if (read(kmem, &availrmem, sizeof(availrmem)) != sizeof (availrmem)) {
  457. X    perror ("mesure_charge_courante_systeme-read");
  458. X    exit (1);
  459. X    }
  460. X
  461. X
  462. #ifdef DEBUG
  463. X    for (i = 0 ; i != 5 ; i++)
  464. X    printf ("old.cpu[%d] = %ld\n", i, old.cpu[i]);
  465. #endif
  466. }
  467. X
  468. /*
  469. X * Lecture de la charge courante du systeme
  470. X */
  471. X
  472. void mesure_charge_courante_systeme ()
  473. {
  474. X    extern double charge_courante_systeme[];
  475. X    register double tdiff, valeur;
  476. X    register int i;
  477. X    long freemem;
  478. X
  479. X    /* mesure de availrmem */
  480. X    if (lseek(kmem, (long) namelist[AVAILRMEM].n_value, 0) < 0) {
  481. X    perror ("mesure_charge_courante_systeme-lseek");
  482. X    exit (1);
  483. X    }
  484. X
  485. X    if (read(kmem, &availrmem, sizeof(availrmem)) != sizeof (availrmem)) {
  486. X    perror ("mesure_charge_courante_systeme-read");
  487. X    exit (1);
  488. X    }
  489. X
  490. X    /* mesure de freemem */
  491. X    if (lseek(kmem, (long) namelist[FREEMEM].n_value, 0) < 0) {
  492. X    perror ("mesure_charge_courante_systeme-lseek");
  493. X    exit (1);
  494. X    }
  495. X
  496. X    if (read(kmem, &freemem, sizeof(freemem)) != sizeof (freemem)) {
  497. X    perror ("mesure_charge_courante_systeme-read");
  498. X    exit (1);
  499. X    }
  500. X
  501. X    /* lecture de l'etat du systeme */
  502. X    if (lseek (kmem, namelist[SYSINFO].n_value, 0) < 0) {
  503. X    perror ("mesure_charge_courante_systeme-lseek");
  504. X    exit (1);
  505. X    }
  506. X    
  507. X    if (read (kmem, (char *)&new, sizeof(new)) != sizeof (new)) {
  508. X    perror ("mesure_charge_courante_systeme-read");
  509. X    exit (1);
  510. X    }
  511. X
  512. #ifdef DEBUG
  513. X    printf ("mesure_charge : apres lecture...\n");
  514. X    for (i = 0 ; i != 5 ; i++)
  515. X    printf ("new.cpu[%d] = %ld\n", i, new.cpu[i]);
  516. #endif
  517. X
  518. X    /* Somme des differences de temps */
  519. X    tdiff = (double)(new.cpu[0]-old.cpu[0]) + (double)(new.cpu[1]-old.cpu[1]) + (double)(new.cpu[2]-old.cpu[2]) + (double)(new.cpu[3]-old.cpu[3]) + (double)(new.cpu[4]-old.cpu[4]);
  520. X
  521. X    /* calcul des charges */
  522. X    for (i = 0 ; i != 5 ; i++) {
  523. X    charge_courante_systeme[i] = (double)(new.cpu[i]-old.cpu[i]) / tdiff;
  524. X
  525. #ifdef DEBUG
  526. X    printf ("mesure_charge : tdiff = %g  c[%d] = %g\n", tdiff, i, charge_courante_systeme[i]);
  527. #endif
  528. X    }
  529. #ifdef DEBUG
  530. X    printf ("freemem %ld availrmem = %ld\n*****************************\n", freemem, availrmem);
  531. #endif
  532. X    charge_courante_systeme[5] = (double)freemem;
  533. X
  534. X    /* New devient Old */
  535. X    for (i = 0 ; i != 5 ; i++)
  536. X    old.cpu[i] = new.cpu[i];
  537. X
  538. X    /* Initialise le comptage */
  539. X    XtAddTimeOut ((unsigned long)4000, mesure_charge_courante_systeme, (caddr_t)NULL);
  540. }
  541. X
  542. X
  543. X
  544. /*
  545. X * Fonction periodique de mise a jour des graphes
  546. X */
  547. X
  548. /* Mise a jour de la valeur affichee */
  549. X
  550. void mise_a_jour_mesure(widget_afficheur, format, valeur_mesure)
  551. Widget widget_afficheur;
  552. char *format;
  553. long valeur_mesure;
  554. {
  555. X    Arg args[10];
  556. X    register int n;
  557. X
  558. X    /* Formatage de la mesure */
  559. X    sprintf (buf, format, valeur_mesure);
  560. X
  561. X    n = 0;
  562. X    XtSetArg (args[n], XtNlabel, buf); n++;
  563. X    XtSetValues (widget_afficheur, args, n);
  564. }
  565. X
  566. /*
  567. X * Callbacks utilises par les stripCharts (Idle, User, ...)
  568. X */
  569. X
  570. void Mise_a_jour_idle(w, closure, call_data)
  571. X     Widget    w;        /* unused */
  572. X     caddr_t    closure;    /* unused */
  573. X     caddr_t    call_data;    /* pointer to (double) return value */
  574. {
  575. X    double *valeur = (double *)call_data;
  576. X
  577. X    mise_a_jour_mesure (afficheur_idle, "%3d %%", (int) ((double)100. * charge_courante_systeme[CPU_IDLE]));
  578. X
  579. #ifdef DEBUG
  580. X    printf ("Mise a jour idle %g\n", charge_courante_systeme[CPU_IDLE]);
  581. #endif
  582. X    *valeur = charge_courante_systeme[CPU_IDLE];
  583. }
  584. X
  585. void Mise_a_jour_user(w, closure, call_data)
  586. X     Widget    w;        /* unused */
  587. X     caddr_t    closure;    /* unused */
  588. X     caddr_t    call_data;    /* pointer to (double) return value */
  589. {
  590. X    double *valeur = (double *)call_data;
  591. X
  592. X    mise_a_jour_mesure (afficheur_user, "%3d %%", (int)((double)100. * charge_courante_systeme[CPU_USER]));
  593. X
  594. #ifdef DEBUG
  595. X    printf ("Mise a jour user %g\n", charge_courante_systeme[CPU_USER]);
  596. #endif
  597. X    *valeur = charge_courante_systeme[CPU_USER];
  598. }
  599. X
  600. void Mise_a_jour_kernel(w, closure, call_data)
  601. X     Widget    w;        /* unused */
  602. X     caddr_t    closure;    /* unused */
  603. X     caddr_t    call_data;    /* pointer to (double) return value */
  604. {
  605. X    double *valeur = (double *)call_data;
  606. X
  607. X    mise_a_jour_mesure (afficheur_kernel, "%3d %%", (int)((double)100. * charge_courante_systeme[CPU_KERNEL]));
  608. X
  609. #ifdef DEBUG
  610. X    printf ("Mise a jour kernel %g\n", charge_courante_systeme[CPU_KERNEL]);
  611. #endif
  612. X    *valeur = charge_courante_systeme[CPU_KERNEL];
  613. }
  614. X
  615. void Mise_a_jour_wait(w, closure, call_data)
  616. X     Widget    w;        /* unused */
  617. X     caddr_t    closure;    /* unused */
  618. X     caddr_t    call_data;    /* pointer to (double) return value */
  619. {
  620. X    double *valeur = (double *)call_data;
  621. X
  622. X    mise_a_jour_mesure (afficheur_wait, "%3d %%", (int)((double)100. * charge_courante_systeme[CPU_WAIT]));
  623. X
  624. #ifdef DEBUG
  625. X    printf ("Mise a jour wait %g\n", charge_courante_systeme[CPU_WAIT]);
  626. #endif
  627. X    *valeur = charge_courante_systeme[CPU_WAIT];
  628. }
  629. X
  630. void Mise_a_jour_sxbrk(w, closure, call_data)
  631. X     Widget    w;        /* unused */
  632. X     caddr_t    closure;    /* unused */
  633. X     caddr_t    call_data;    /* pointer to (double) return value */
  634. {
  635. X    double *valeur = (double *)call_data;
  636. X
  637. X    mise_a_jour_mesure (afficheur_sxbrk, "%3d %%", (int)((double)100. * charge_courante_systeme[CPU_SXBRK]));
  638. X
  639. #ifdef DEBUG
  640. X    printf ("Mise a jour sxbrk %g\n", charge_courante_systeme[CPU_SXBRK]);
  641. #endif
  642. X    *valeur = charge_courante_systeme[CPU_SXBRK];
  643. }
  644. X
  645. void Mise_a_jour_freemem(w, closure, call_data)
  646. X     Widget    w;        /* unused */
  647. X     caddr_t    closure;    /* unused */
  648. X     caddr_t    call_data;    /* pointer to (double) return value */
  649. {
  650. X    double *valeur = (double *)call_data;
  651. X
  652. X    mise_a_jour_mesure (afficheur_freemem, "%3d", (int)charge_courante_systeme[VALEUR_FREEMEM]);
  653. X
  654. #ifdef DEBUG
  655. X    printf ("Mise a jour freemem %g\n", charge_courante_systeme[VALEUR_FREEMEM] / (double)availrmem);
  656. #endif
  657. X    *valeur = charge_courante_systeme[VALEUR_FREEMEM] / (double)availrmem;
  658. }
  659. X
  660. /* 
  661. X * Fonction d'initialisation de l'affichage de l'activite 
  662. X */
  663. X
  664. void Activite (w, client_data, call_data)
  665. Widget w;
  666. caddr_t client_data, call_data;
  667. {
  668. #ifdef DEBUG
  669. X    printf (stderr, "Activite...\n");
  670. #endif
  671. X    
  672. X    if (flag_popup_actif == FALSE) {
  673. X
  674. X    /* affiche la fenetre */
  675. X    XtPopup (shell_activite, XtGrabNone);
  676. X
  677. X    flag_popup_actif = TRUE;
  678. X    }
  679. }
  680. X
  681. /*
  682. X * Callback du bouton Quitte du shell d'activite
  683. X */
  684. X
  685. void Quit_activite (w, client_data, call_data)
  686. Widget w;
  687. caddr_t client_data, call_data;
  688. {
  689. X    flag_popup_actif = FALSE;
  690. X    XtPopdown (shell_activite);
  691. }
  692. X
  693. X
  694. X
  695. X
  696. X
  697. X
  698. X
  699. SHAR_EOF
  700. chmod 0444 activite.c ||
  701. echo 'restore of activite.c failed'
  702. Wc_c="`wc -c < 'activite.c'`"
  703. test 9502 -eq "$Wc_c" ||
  704.     echo 'activite.c: original size 9502, current size' "$Wc_c"
  705. fi
  706. # ============= patchlevel.h ==============
  707. if test -f 'patchlevel.h' -a X"$1" != X"-c"; then
  708.     echo 'x - skipping patchlevel.h (File already exists)'
  709. else
  710. echo 'x - extracting patchlevel.h (Text)'
  711. sed 's/^X//' << 'SHAR_EOF' > 'patchlevel.h' &&
  712. #define PATCHLEVEL    0
  713. SHAR_EOF
  714. chmod 0644 patchlevel.h ||
  715. echo 'restore of patchlevel.h failed'
  716. Wc_c="`wc -c < 'patchlevel.h'`"
  717. test 21 -eq "$Wc_c" ||
  718.     echo 'patchlevel.h: original size 21, current size' "$Wc_c"
  719. fi
  720. # ============= processus.c ==============
  721. if test -f 'processus.c' -a X"$1" != X"-c"; then
  722.     echo 'x - skipping processus.c (File already exists)'
  723. else
  724. echo 'x - extracting processus.c (Text)'
  725. sed 's/^X//' << 'SHAR_EOF' > 'processus.c' &&
  726. /*
  727. X * xetat - graphical system activity reporter
  728. X *
  729. X * Copyright 1991 Lectra Systemes
  730. X *
  731. X * Permission to use, copy, modify, and distribute this software and its
  732. X * documentation for any purpose and without fee is hereby granted, provided
  733. X * that the above copyright notice appear in all copies and that both that
  734. X * copyright notice and this permission notice appear in supporting
  735. X * documentation, and that the name of Lectra Systemes not be used in advertising or
  736. X * publicity pertaining to distribution of the software without specific,
  737. X * written prior permission.  Lectra Systemes makes no representations about the
  738. X * suitability of this software for any purpose.  It is provided "as is"
  739. X * without express or implied warranty.
  740. X *
  741. X * Auteur : Pierre FICHEUX     Lectra Systemes R & D
  742. X *
  743. X */
  744. static char sccsid[] = "@(#)processus.c    1.1 3/10/92";
  745. X
  746. /*
  747. X * Fonctions de visualisation des processus        
  748. X */
  749. X
  750. #include <stdio.h>
  751. #include <string.h>
  752. #include <time.h>
  753. X
  754. /*
  755. X * Fichiers d'inclusion X11
  756. X */
  757. #include <X11/Intrinsic.h>
  758. #include <X11/StringDefs.h>
  759. #include <X11/XawMisc.h>
  760. #include <X11/Form.h>
  761. #include <X11/Label.h>
  762. #include <X11/Shell.h>
  763. #include <X11/List.h>
  764. #include <X11/Paned.h>
  765. #include <X11/Viewport.h>
  766. #include <X11/Xaw/StripChart.h>
  767. X
  768. #ifdef X11R3
  769. #include <X11/Command.h>
  770. #include <X11/Box.h>
  771. #else /* R4 or later */
  772. #include <X11/Xaw/Command.h>
  773. #include <X11/Xaw/Box.h>
  774. #endif /* X11R3 */
  775. X
  776. #include <sys/types.h>
  777. #include <sys/param.h>
  778. #include <sys/immu.h>
  779. #include <sys/signal.h>
  780. #include <sys/region.h>
  781. #include <sys/var.h>
  782. #include <sys/proc.h>
  783. #include <sys/dir.h>
  784. #include <sys/user.h>
  785. #include <sys/syslocal.h>
  786. #include <nlist.h>
  787. #include <fcntl.h>
  788. X
  789. X
  790. /* Structure de definition d'un shell processus */
  791. X
  792. struct definition_processus {
  793. X    char flag_shell_actif;    /* TRUE si un popup shell existe */
  794. X    Widget popup_shell;        /* widget popup shell */
  795. X    Widget forme;        /* widget form contenant les infos */
  796. X    Widget paned;        /* Paned utilise pour l'affichage de p_size */
  797. X    Widget afficheur;        /* widget d'affichage de la taille du processus */
  798. X    Widget indicateur;        /* widget indicateur de la taille */
  799. X    Widget label_titre;        /* widget titre */
  800. X    Widget label_car;        /* widget informations */
  801. X    Widget quit;        /* widget de sortie */
  802. X    pid_t p_pid, p_ppid;    /* Informations sur le processus ... */
  803. X    uid_t p_uid;
  804. X    uint p_size;
  805. X    long p_stime;
  806. X    long p_utime;
  807. };
  808. X
  809. /* Maxi 400 processus */
  810. X
  811. #define MAXPROC    400
  812. X
  813. /* Indice des elements de namelist[] */
  814. X
  815. #define U        0
  816. #define V        1
  817. #define PROC        2
  818. #define FREEMEM     3
  819. #define SYSINFO        4
  820. #define AVAILRMEM     5
  821. X
  822. extern Pixmap pixmap_processus;
  823. extern Widget prototype_bouton_quit, prototype_label_titre, prototype_indicateur, prototype_afficheur, prototype_paned;
  824. extern Widget shell_processus, liste_processus;
  825. extern int kmem;            /* descripteur memoire noyau */
  826. static int nb_processus;        /* nombre courant de processus */
  827. String table_processus[MAXPROC];    /* liste des noms des rpocessus */
  828. struct proc proctab;            /* structure de definition d'un processus */
  829. struct user usertab;            /* suite de la definition ... */
  830. struct var  vartab;            /* pointe de la zone v */
  831. static char buf[100], buf1[100],buf2[100];    
  832. static long valeur_freemem;        /* valeur courante freemem */
  833. char flag_mise_a_jour_autorisee;    /* TRUE si la mise a jour est autorisee */
  834. X
  835. /* liste des definitions de processus */
  836. static struct definition_processus *definition_processus[MAXPROC], *tempo[MAXPROC]; 
  837. /* liste des variables exploitees */
  838. extern struct nlist namelist[];
  839. X
  840. extern char host[];
  841. X
  842. void mise_a_jour_liste_processus ();
  843. X
  844. /*ARGSUSED*/
  845. void Quit_processus(w, client_data, call_data)
  846. Widget w;
  847. caddr_t client_data, call_data;
  848. {
  849. #ifdef DEBUG
  850. X    printf ("Quitte processus...\n");
  851. #endif
  852. X    XtPopdown (shell_processus);
  853. }
  854. X
  855. /*
  856. X * Ferme la fenetre apres click sur Ok (sans tuer le shell)
  857. X */
  858. X
  859. void Quit_definition_processus(w, client_data, call_data)
  860. Widget w;
  861. caddr_t client_data, call_data;
  862. {
  863. X    XtPopdown ((Widget)client_data);
  864. }
  865. X
  866. /*
  867. X * Mise a jour manuelle
  868. X */
  869. X
  870. void Mise_a_jour_liste (w, client_data, call_data)
  871. Widget w;
  872. caddr_t client_data, call_data;
  873. {
  874. X    register int n;
  875. X    Arg args[10];
  876. X
  877. X    flag_mise_a_jour_autorisee = FALSE;
  878. X
  879. X    mise_a_jour_liste_processus ();
  880. X
  881. X    XtUnmapWidget (liste_processus);
  882. X    XtMapWidget (liste_processus);
  883. X
  884. X    /* la mise a jour est de nouveau autorisee */
  885. X    flag_mise_a_jour_autorisee = TRUE;
  886. }
  887. X
  888. X
  889. /*
  890. X * Fonction de mise a jour d'un processus a partir de son indice dans
  891. X * la liste definition_processsus
  892. X */
  893. X
  894. mise_a_jour_d_un_processus (indice_processus)
  895. int indice_processus;
  896. {
  897. X    register int i;
  898. X    int existe = FALSE; 
  899. X
  900. X    /* Pointe la zone v */
  901. X    if (lseek(kmem, (long) namelist[V].n_value, 0) < 0) {
  902. X    perror ("mise_a_jour_d_un_processus-lseek");
  903. X    exit (1);
  904. X    }
  905. X    
  906. X    if (read(kmem, &vartab, sizeof(vartab)) != sizeof(vartab)) {
  907. X    perror ("mise_a_jour_d_un_processus-read");
  908. X    exit (1);
  909. X    }
  910. X
  911. X    /* Pointe la zone proc */
  912. X    if (lseek(kmem, (long) namelist[PROC].n_value, 0) < 0) {
  913. X    perror ("mise_a_jour_d_un_processus-lseek");
  914. X    exit (1);
  915. X    }
  916. X
  917. X    /* On determine tous les processus existants */
  918. X    for (i = 0 ; i < vartab.v_proc ; i++)
  919. X    {
  920. X    if (read(kmem, &proctab, sizeof(proctab)) != sizeof(proctab)) {
  921. X        perror ("mise_a_jour_d_un_processus-read");
  922. X        exit (1);
  923. X    }
  924. X
  925. X    /* Si etat != 0 et c'est le PID cherche */
  926. X    if (proctab.p_stat != 0 && proctab.p_pid == definition_processus[indice_processus]->p_pid) {
  927. X        /*
  928. X             * lit la zone u associee au processus 
  929. X         */
  930. X        if (sysmot (RDUBLK, proctab.p_pid, &usertab, sizeof(usertab)) < 0) {
  931. X        continue;
  932. X        }
  933. X
  934. X        existe = TRUE;
  935. X        /* Mise a jour */
  936. X        /* Affecte les caracteristiques */
  937. X        definition_processus[indice_processus]->p_size = proctab.p_size;
  938. X        definition_processus[indice_processus]->p_stime = proctab.p_stime;
  939. X        definition_processus[indice_processus]->p_utime = proctab.p_utime;
  940. X    }
  941. X    }
  942. X
  943. X    return (existe);
  944. }        
  945. X
  946. X
  947. void Mise_a_jour_graphe_processus(w, client_data, call_data)
  948. X     Widget    w;        /* unused */
  949. X     caddr_t    client_data;    /* pointe le numero du processus dans la liste */
  950. X     caddr_t    call_data;    /* pointer to (double) return value */
  951. {
  952. X    double *valeur = (double *)call_data;
  953. X    struct definition_processus *p = (struct definition_processus *)client_data;
  954. X    int n;
  955. X    Arg args[10];
  956. X
  957. #ifdef DEBUG
  958. X    printf ("Mise a jour %d\n", p->p_pid);
  959. printf ("pid %d %ld %ld\n", p->p_pid, p->p_stime ,p->p_utime);
  960. #endif
  961. X    cftime (buf1, "%M:%S", &p->p_stime);    
  962. X    cftime (buf2, "%M:%S", &p->p_utime);    
  963. #ifdef DEBUG
  964. printf ("pid %d %s %s\n", p->p_pid, buf1, buf2);
  965. #endif
  966. X    sprintf (buf, "%-3d %-5d %-5d %-6s  %-6s", p->p_uid, p->p_pid, p->p_ppid, buf1, buf2);
  967. X
  968. X    /* Mise a jour du widget */
  969. X    n = 0;
  970. X    XtSetArg (args[n], XtNlabel, buf); n++;
  971. X    XtSetValues (p->label_car, args, n);
  972. X    
  973. X    /* Mise a jour de l'afficheur */
  974. X    sprintf (buf, "%-4d/%-4d", p->p_size, valeur_freemem);
  975. X    n = 0;
  976. X    XtSetArg (args[n], XtNlabel, buf); n++;
  977. X    XtSetValues (p->afficheur, args, n);
  978. X    
  979. X    /* Mise a jour du graphe */
  980. X    *valeur = (double)p->p_size / (double)valeur_freemem;
  981. }
  982. X
  983. /*
  984. X * Fonction de mise a jour periodique des informations sur les processus
  985. X */
  986. XXtTimerCallbackProc mise_a_jour_processus (closure, id)
  987. caddr_t closure;
  988. XXtIntervalId *id;
  989. {
  990. X    register int i, n;
  991. X    Arg args[10];
  992. X    Dimension largeur_boite, hauteur_boite, distance_horizontale, largeur_bord;
  993. X    Dimension distance_verticale, largeur_indicateur;
  994. X
  995. X    if (flag_mise_a_jour_autorisee == TRUE) {
  996. X
  997. X    /*
  998. X     * Mise a jour de la liste des processus
  999. X     */
  1000. X    for (i = 0 ; i != nb_processus ; i++) {
  1001. X        if (definition_processus[i] != NULL && definition_processus[i]->flag_shell_actif == TRUE) {
  1002. #ifdef DEBUG
  1003. X        printf ("mise a jour %d ", i);
  1004. #endif
  1005. X        /* 
  1006. X         * Si le processus n'existe plus, on tue le shell et on
  1007. X         * libere la cellule definissant le processus 
  1008. X         */
  1009. X        if (mise_a_jour_d_un_processus (i) == FALSE) {
  1010. #ifdef DEBUG
  1011. X            printf ("rate !!\n");
  1012. #endif
  1013. X            XtPopdown (definition_processus[i]->popup_shell);
  1014. X            free (definition_processus[i]);
  1015. X            mise_a_jour_liste_processus ();
  1016. X            XtUnmapWidget (liste_processus);
  1017. X            XtMapWidget (liste_processus);
  1018. X
  1019. X            break;
  1020. X        }
  1021. X        }
  1022. X    }
  1023. X
  1024. X    /* mesure de freemem */
  1025. X    if (lseek(kmem, (long) namelist[FREEMEM].n_value, 0) < 0) {
  1026. X    perror ("mesure_charge_courante_systeme-lseek");
  1027. X    exit (1);
  1028. X    }
  1029. X    
  1030. X    if (read(kmem, &valeur_freemem, sizeof(valeur_freemem)) != sizeof (valeur_freemem)) {
  1031. X    perror ("mesure_charge_courante_systeme-read");
  1032. X    exit (1);
  1033. X    }
  1034. #ifdef DEBUG
  1035. X    printf ("freemem = %ld\n", valeur_freemem);
  1036. #endif
  1037. X    
  1038. #ifdef DEBUG
  1039. X    printf ("\n");
  1040. #endif
  1041. X    }
  1042. X    
  1043. X    /* Initialise le comptage */
  1044. X    XtAddTimeOut ((unsigned long)4000, mise_a_jour_processus, (caddr_t)NULL);
  1045. }
  1046. X
  1047. /*
  1048. X * Selection d'un processsus
  1049. X * Cette fonction est appelee lors de la selection d'un processus dans la liste
  1050. X * affichee. Elle ouvre un popup shell contenant les informations concernant
  1051. X * le processus.
  1052. X */
  1053. X
  1054. void Selection (w, client_data, call_data)
  1055. Widget w;
  1056. caddr_t client_data, call_data;
  1057. {
  1058. X    int n;
  1059. X    Arg args[10];
  1060. X    int distance_horizontale;
  1061. X    Dimension largeur, hauteur;
  1062. X    String label;
  1063. X    Pixel background;
  1064. X    XtJustify justification;
  1065. X    Boolean showgrip;
  1066. X
  1067. /*    XtListReturnStruct *p = (XtListReturnStruct *) call_data;*/
  1068. X    XawListReturnStruct *p = (XawListReturnStruct *) call_data;
  1069. X
  1070. #ifdef DEBUG
  1071. X    printf (stderr, "Selection\n"); 
  1072. #endif
  1073. #ifdef DEBUG
  1074. X    printf (stderr, "chaine %s index %d\n", p->string, p->list_index);
  1075. #endif
  1076. X
  1077. X    /* Si le processus n'est pas deja espionne */
  1078. X    if (definition_processus[p->list_index]->flag_shell_actif == FALSE) {
  1079. X
  1080. X    /* On cree un shell application au nom du processus  */
  1081. X    n = 0;
  1082. X    XtSetArg(args[n], XtNiconPixmap, pixmap_processus); n++;
  1083. X    definition_processus[p->list_index]->popup_shell = XtCreatePopupShell (strcat (strcpy (buf, host), p->string), applicationShellWidgetClass, liste_processus, args, n);
  1084. X    
  1085. X    /* 
  1086. X     * Creation du widget forme 
  1087. X     */
  1088. X    sprintf (buf, "forme%d", p->list_index);
  1089. X    definition_processus[p->list_index]->forme = XtCreateManagedWidget (buf, formWidgetClass, definition_processus[p->list_index]->popup_shell, NULL, 0);
  1090. X    
  1091. X    /* 
  1092. X     * Creation du widget titre 
  1093. X     */
  1094. X    /* lecture des valeurs dans le prototype */
  1095. X    n = 0;
  1096. X    XtSetArg (args[n], XtNlabel, &label); n++;
  1097. X    XtGetValues (prototype_label_titre, args, n);
  1098. X
  1099. X    sprintf (buf, "label_titre%d", p->list_index);
  1100. X    n = 0;
  1101. X    XtSetArg (args[n], XtNlabel, label); n++;
  1102. X    definition_processus[p->list_index]->label_titre = XtCreateManagedWidget (buf, labelWidgetClass, definition_processus[p->list_index]->forme, args, n);
  1103. X
  1104. X    /*
  1105. X     * Creation du widget caracteristiques
  1106. X     */
  1107. X    /* formatage des valeurs */
  1108. X    cftime (buf1, "%M:%S", &definition_processus[p->list_index]->p_stime);    
  1109. X    cftime (buf2, "%M:%S", &definition_processus[p->list_index]->p_utime);    
  1110. X    sprintf (buf, "%-3d %-5d %-5d %-6s  %-6s", definition_processus[p->list_index]->p_uid, definition_processus[p->list_index]->p_pid, definition_processus[p->list_index]->p_ppid, buf1, buf2);
  1111. X    
  1112. X    /* creation du widget */
  1113. X    n = 0;
  1114. X    XtSetArg (args[n], XtNlabel, buf); n++;
  1115. X    XtSetArg (args[n], XtNborderWidth, 0); n++;
  1116. X    XtSetArg (args[n], XtNfromVert, definition_processus[p->list_index]->label_titre); n++;
  1117. X    sprintf (buf1, "label_car%d", p->list_index);
  1118. X    definition_processus[p->list_index]->label_car = XtCreateManagedWidget (buf1, labelWidgetClass, definition_processus[p->list_index]->forme, args, n);
  1119. X
  1120. X    /* Creation du widget Paned contenant la taille et le graphe */
  1121. X    n = 0;
  1122. X    XtSetArg (args[n], XtNwidth, &largeur); n++;
  1123. X    XtSetArg (args[n], XtNheight, &hauteur); n++;
  1124. X    XtSetArg (args[n], XtNjustify, &justification); n++;
  1125. X    XtSetArg (args[n], XtNshowGrip, &showgrip); n++;
  1126. X    XtGetValues (prototype_paned, args, n);
  1127. X
  1128. X    n = 0;
  1129. X    XtSetArg (args[n], XtNwidth, largeur); n++;
  1130. X    XtSetArg (args[n], XtNheight, hauteur); n++;
  1131. X    XtSetArg (args[n], XtNjustify, justification); n++;
  1132. X    XtSetArg (args[n], XtNshowGrip, showgrip); n++;
  1133. X    XtSetArg (args[n], XtNfromVert, definition_processus[p->list_index]->label_car); n++;
  1134. X    sprintf (buf, "paned%d", p->list_index);
  1135. X    definition_processus[p->list_index]->paned = XtCreateManagedWidget (buf, panedWidgetClass, definition_processus[p->list_index]->forme, args, n);
  1136. X
  1137. X    /* creation du widget afficheur */
  1138. X    n = 0;
  1139. X    XtSetArg (args[n], XtNwidth, &largeur); n++;
  1140. X    XtSetArg (args[n], XtNheight, &hauteur); n++;
  1141. X    XtGetValues (prototype_afficheur, args, n);
  1142. X
  1143. X    n = 0;
  1144. X    XtSetArg (args[n], XtNlabel, ""); n++;
  1145. X    XtSetArg (args[n], XtNwidth, largeur); n++;
  1146. X    XtSetArg (args[n], XtNheight, hauteur); n++;
  1147. X
  1148. X    sprintf (buf, "afficheur%d", p->list_index);
  1149. X    definition_processus[p->list_index]->afficheur = XtCreateManagedWidget (buf, labelWidgetClass, definition_processus[p->list_index]->paned, args, n);
  1150. X
  1151. X
  1152. X    /* creation du widget indicateur (graphe) */
  1153. X    /* lecture des valeurs dans le prototype */
  1154. X    n = 0;
  1155. X    XtSetArg (args[n], XtNwidth, &largeur); n++;
  1156. X    XtSetArg (args[n], XtNheight, &hauteur); n++;
  1157. X    XtGetValues (prototype_indicateur, args, n);
  1158. X
  1159. X    n = 0;
  1160. X    XtSetArg (args[n], XtNwidth, largeur); n++;
  1161. X    XtSetArg (args[n], XtNheight, hauteur); n++;
  1162. X    sprintf (buf, "indicateur%d", p->list_index);
  1163. X    definition_processus[p->list_index]->indicateur = XtCreateManagedWidget (buf, stripChartWidgetClass, definition_processus[p->list_index]->paned, args, n);
  1164. X    XtAddCallback(definition_processus[p->list_index]->indicateur, XtNgetValue, Mise_a_jour_graphe_processus, (caddr_t)definition_processus[p->list_index]);
  1165. X
  1166. X
  1167. X    /* Creation du widget quit */
  1168. X    sprintf (buf, "quit%d", p->list_index);
  1169. X
  1170. X    /* lecture des valeurs dans le prototype */
  1171. X    n = 0;
  1172. X    XtSetArg (args[n], XtNlabel, &label); n++;
  1173. X    XtSetArg (args[n], XtNwidth, &largeur); n++;
  1174. X    XtSetArg (args[n], XtNhorizDistance, &distance_horizontale); n++;
  1175. X    XtGetValues (prototype_bouton_quit, args, n);
  1176. X
  1177. X    /* Fixe les valeurs */
  1178. X    n = 0;
  1179. X    XtSetArg (args[n], XtNlabel, label); n++;
  1180. X    XtSetArg (args[n], XtNfromVert, definition_processus[p->list_index]->paned); n++;
  1181. X    XtSetArg (args[n], XtNhorizDistance, distance_horizontale); n++;
  1182. X    XtSetArg (args[n], XtNwidth, largeur); n++;
  1183. X    definition_processus[p->list_index]->quit = XtCreateManagedWidget (buf, commandWidgetClass, definition_processus[p->list_index]->forme, args, n);
  1184. X    
  1185. X    /* callback du quit */
  1186. X    XtAddCallback(definition_processus[p->list_index]->quit, XtNcallback, Quit_definition_processus, (caddr_t)definition_processus[p->list_index]->popup_shell);
  1187. X    
  1188. X    /* Affichage */
  1189. X    definition_processus[p->list_index]->flag_shell_actif = TRUE;
  1190. X    }
  1191. X
  1192. X    /* affiche le popup shell */
  1193. X    XtPopup (definition_processus[p->list_index]->popup_shell, XtGrabNone);
  1194. }
  1195. X
  1196. /*
  1197. X * Mise a jour de la liste des processus
  1198. X * Cette fonction est appelee si un processus espionne est tue ou bien
  1199. X * si l'utilisateur demande une nouvelle liste des processus
  1200. X */
  1201. void mise_a_jour_liste_processus ()
  1202. {
  1203. X    register int i, j, nb, n;
  1204. X    Arg args[10];
  1205. X
  1206. X    /* interdit la mise a jour ! */    
  1207. X    flag_mise_a_jour_autorisee = FALSE;
  1208. X
  1209. X    /* Pointe la zone v */
  1210. X    if (lseek(kmem, (long) namelist[V].n_value, 0) < 0) {
  1211. X    perror ("mise_a_jour_liste_processus-lseek");
  1212. X    exit (1);
  1213. X    }
  1214. X    
  1215. X    if (read(kmem, &vartab, sizeof(vartab)) != sizeof(vartab)) {
  1216. X    perror ("mise_a_jour_liste_processus-read");
  1217. X    exit (1);
  1218. X    }
  1219. X
  1220. X    /* Pointe la zone proc */
  1221. X    if (lseek(kmem, (long) namelist[PROC].n_value, 0) < 0) {
  1222. X    perror ("mise_a_jour_liste_processus-lseek");
  1223. X    exit (1);
  1224. X    }
  1225. X
  1226. X    /* On determine tous les processus existants */
  1227. X    nb = 0;
  1228. X    for (i = 0 ; i < vartab.v_proc ; i++)
  1229. X    {
  1230. X    if (read(kmem, &proctab, sizeof(proctab)) != sizeof(proctab)) {
  1231. X        perror ("mise_a_jour_liste_processus-read");
  1232. X        exit (1);
  1233. X    }
  1234. X
  1235. X    /* Si etat != 0 */
  1236. X    if (proctab.p_stat != 0) {
  1237. X        /*
  1238. X             * lit la zone u associee au processus 
  1239. X         */
  1240. X        if (sysmot (RDUBLK, proctab.p_pid, &usertab, sizeof(usertab)) < 0) {
  1241. X        continue;
  1242. X        }
  1243. X
  1244. X        /* On remplit la liste */
  1245. X        sprintf (buf, "%s-%d", usertab.u_comm, proctab.p_pid);
  1246. #ifdef DEBUG
  1247. printf ("processus %s\n", buf);
  1248. #endif
  1249. X        if (table_processus[nb] != NULL)
  1250. X          free (table_processus[nb]);
  1251. X        if ((table_processus[nb] = (String) calloc (1, 1 + strlen (buf))) == NULL) {
  1252. X        perror ("mise_a_jour_liste_processus-calloc");
  1253. X        exit (1);
  1254. X        }
  1255. X        strcpy (table_processus[nb], buf);
  1256. X
  1257. X        /* Allocation de la structure de definition */
  1258. X        if ((tempo[nb] = (struct definition_processus *) calloc (1, sizeof(struct definition_processus))) == NULL) {
  1259. X        perror ("mise_a_jour_liste_processus-calloc");
  1260. X        exit (1);
  1261. X        }
  1262. X
  1263. X
  1264. X        /* Affecte les caracteristiques */
  1265. X        /* 
  1266. X         * Si le processus etait deja espionne, on continue de l'espionner...
  1267. X         */
  1268. X        /* Recherche le processus dans definition_processus */
  1269. X        for (j = 0 ; j != nb_processus ; j++) {
  1270. X        if (definition_processus[j]->p_pid == proctab.p_pid && definition_processus[j]->flag_shell_actif == TRUE) {
  1271. #ifdef DEBUG
  1272. X            printf ("%d deja affiche !!!\n", j);
  1273. #endif
  1274. X            /*
  1275. X                     * Recopie les widgets
  1276. X             */
  1277. X            tempo[nb]->flag_shell_actif = TRUE;
  1278. X            tempo[nb]->popup_shell = definition_processus[j]->popup_shell;
  1279. X            tempo[nb]->forme = definition_processus[j]->forme;
  1280. X            tempo[nb]->label_titre = definition_processus[j]->label_titre;
  1281. X            tempo[nb]->label_car = definition_processus[j]->label_car;
  1282. X            tempo[nb]->quit = definition_processus[j]->quit;
  1283. X
  1284. X            break;
  1285. X        }
  1286. X        }
  1287. X
  1288. X        /* Charge les caracteristiques du processus */
  1289. X        tempo[nb]->p_pid = proctab.p_pid;
  1290. X        tempo[nb]->p_ppid = proctab.p_ppid;
  1291. X        tempo[nb]->p_utime = proctab.p_utime;
  1292. X        tempo[nb]->p_stime = proctab.p_stime;
  1293. X        tempo[nb]->p_uid = proctab.p_uid;
  1294. X        tempo[nb++]->p_size = proctab.p_size;
  1295. X    }
  1296. X    }
  1297. X
  1298. X    /* 
  1299. X     * Modification de la liste : on recopie tempo sur definition processus
  1300. X     */
  1301. X    for (i = 0 ; i != nb ; i++) {
  1302. X    if (definition_processus[i] != NULL)
  1303. X      free ((char *)definition_processus[i]);
  1304. X    definition_processus[i] = tempo[i];
  1305. X    }
  1306. X    for ( ; i < nb_processus ; i++) {
  1307. X    free ((char *)definition_processus[i]);
  1308. X    }
  1309. X
  1310. X    /* Mise a jour du nombre de processus courant */
  1311. X    nb_processus = nb;
  1312. X
  1313. X    /* Modification du widget liste */
  1314. X    n = 0;
  1315. X    XtSetArg (args[n], XtNnumberStrings, nb_processus); n++;
  1316. X    XtSetValues (liste_processus, args, n);
  1317. X
  1318. X    /* la mise a jour est de nouveau autorisee */
  1319. X    flag_mise_a_jour_autorisee = TRUE;
  1320. }
  1321. X
  1322. /*
  1323. X * Lecture et affichage de la liste des processus
  1324. X * Cette fonction cree et affiche la liste des processus, elle lance de plus
  1325. X * la mise a jour periodique des caracteristiques des processus espionnes
  1326. X */
  1327. X
  1328. void Processus(w, client_data, call_data)
  1329. Widget w;
  1330. caddr_t client_data, call_data;
  1331. {
  1332. X    int i, n;
  1333. X    Arg args[10];
  1334. X
  1335. #ifdef DEBUG
  1336. X    printf ("Processus...\n");
  1337. #endif
  1338. X
  1339. X    /* Creation de la liste des processus */
  1340. X    nb_processus = 0;
  1341. X    mise_a_jour_liste_processus ();
  1342. X
  1343. X
  1344. X    /* Modification du widget liste */
  1345. X    n = 0;
  1346. X    XtSetArg (args[n], XtNnumberStrings, nb_processus); n++;
  1347. X    XtSetValues (liste_processus, args, n);
  1348. X
  1349. X    /* affichage */
  1350. X    XtPopup (shell_processus, XtGrabNone);
  1351. X
  1352. X    /* Initialise le comptage */
  1353. X    flag_mise_a_jour_autorisee = TRUE;
  1354. X    XtAddTimeOut ((unsigned long)4000, mise_a_jour_processus, (caddr_t)NULL);
  1355. }
  1356. X
  1357. SHAR_EOF
  1358. chmod 0444 processus.c ||
  1359. echo 'restore of processus.c failed'
  1360. Wc_c="`wc -c < 'processus.c'`"
  1361. test 19144 -eq "$Wc_c" ||
  1362.     echo 'processus.c: original size 19144, current size' "$Wc_c"
  1363. fi
  1364. true || echo 'restore of xetat.c failed'
  1365. echo End of part 1, continue with part 2
  1366. exit 0
  1367.  
  1368.  _____________________________________________________________________________
  1369. | Pierre FICHEUX                     | Certains hommes n'ont que ce qu'ils    |
  1370. | Lectra Systemes                    | meritent, les autres sont celibataires |
  1371. | ZI Marticot  33610 CESTAS          |                                        |
  1372. | FRANCE                             |                   Sacha Guitry         |
  1373. |------------------------------------|----------------------------------------'
  1374. |tel   : (33) 56 68 80 00            |
  1375. |fax   : (33) 56 78 88 31            |
  1376. |E-mail: pficheux@lectra.gna.org     |
  1377. |____________________________________|
  1378. -- 
  1379. --
  1380. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1381. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1382. Sunnyvale, California 94086            at&t: 408/522-9236
  1383.