[go: up one dir, main page]

File: showgeneric.c

package info (click to toggle)
atop 1.16-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 468 kB
  • ctags: 554
  • sloc: ansic: 5,086; makefile: 99; sh: 87
file content (1705 lines) | stat: -rw-r--r-- 36,828 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
/*
** ATOP - System & Process Monitor 
**
** The program 'atop' offers the possibility to view the activity of
** the system on system-level as well as process-level.
** 
** This source-file contains the print-functions to visualize the calculated
** figures.
** ==========================================================================
** Author:      Gerlof Langeveld - AT Computing, Nijmegen, Holland
** E-mail:      gerlof@ATComputing.nl
** Date:        November 1996
** LINUX-port:  June 2000
** --------------------------------------------------------------------------
** Copyright (C) 2000-2005 Gerlof Langeveld
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 2, or (at your option) any
** later version.
**
** This program is distributed in the hope that it will be useful, but
** WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
** --------------------------------------------------------------------------
** 
** $Log: showgeneric.c,v $
** Revision 1.41  2006/04/03 05:42:35  gerlof
** *** empty log message ***
**
** Revision 1.40  2006/02/07 08:28:26  gerlof
** Improve screen-handling (less flashing) by exchanging clear()
** by werase() (contribution Folkert van Heusden).
**
** Revision 1.39  2005/11/04 14:16:16  gerlof
** Minor bug-solutions.
**
** Revision 1.38  2005/10/28 09:52:03  gerlof
** All flags/subcommands are defined as macro's.
** Subcommand 'p' has been changed to 'z' (pause).
**
** Revision 1.37  2005/10/24 06:12:17  gerlof
** Flag -L modified into -l.
**
** Revision 1.36  2005/10/21 09:50:46  gerlof
** Per-user accumulation of resource consumption.
** Possibility to send signal to process.
**
** Revision 1.35  2004/12/14 15:06:41  gerlof
** Implementation of patch-recognition for disk and network-statistics.
**
** Revision 1.34  2004/09/27 11:01:13  gerlof
** Corrected usage-info as suggested by Edelhard Becker.
**
** Revision 1.33  2004/09/13 09:19:14  gerlof
** Modify subcommands (former 's' -> 'v', 'v' -> 'V', new 's').
**
** Revision 1.32  2004/08/31 09:52:47  root
** information about underlying threads.
**
** Revision 1.31  2004/06/01 11:57:58  gerlof
** Regular expressions for selections on process-name and user-name.
**
** Revision 1.30  2003/07/07 09:27:24  gerlof
** Cleanup code (-Wall proof).
**
** Revision 1.29  2003/07/03 11:16:42  gerlof
** Implemented subcommand `r' (reset).
**
** Revision 1.28  2003/06/30 11:29:49  gerlof
** Handle configuration file ~/.atoprc
**
** Revision 1.27  2003/06/24 06:21:57  gerlof
** Limit number of system resource lines.
**
** Revision 1.26  2003/02/07 10:19:18  gerlof
** Possibility to show the version number and date.
**
** Revision 1.25  2003/01/17 07:32:16  gerlof
** Show the full command-line per process (option 'c').
**
** Revision 1.24  2002/10/30 13:47:20  gerlof
** Generate notification for statistics since boot.
**
** Revision 1.23  2002/10/08 12:00:30  gerlof
** *** empty log message ***
**
** Revision 1.22  2002/09/26 14:17:39  gerlof
** No beep when resizing the window.
**
** Revision 1.21  2002/09/26 13:52:26  gerlof
** Limit header lines by not showing disks.
**
** Revision 1.20  2002/09/18 07:15:59  gerlof
** Modified viewflag to rawreadflag.
**
** Revision 1.19  2002/09/17 13:17:39  gerlof
** Allow key 'T' to be pressed to view previous sample in raw file.
**
** Revision 1.18  2002/08/30 07:11:50  gerlof
** Minor changes to support viewing of raw atop data.
**
** Revision 1.17  2002/08/27 12:10:12  gerlof
** Allow raw data file to be written and to be read (with compression).
**
** Revision 1.16  2002/07/24 11:12:46  gerlof
** Changed to ease porting to other UNIX-platforms.
**
** Revision 1.15  2002/07/11 09:12:05  root
** Some minor updates.
**
** Revision 1.14  2002/07/10 05:00:37  root
** Counters pin/pout renamed to swin/swout (Linux conventions).
**
** Revision 1.13  2002/07/08 09:29:49  root
** Limitation for username and groupname (8 characters truncate).
**
** Revision 1.12  2002/07/02 07:14:02  gerlof
** More positions for the name of the disk-unit in the DSK-line.
**
** Revision 1.11  2002/01/22 13:40:42  gerlof
** Support for number of cpu's.
** Check if the window is large enough for the system-statistics.
**
** Revision 1.10  2001/11/30 09:09:36  gerlof
** Cosmetic chnage.
**
** Revision 1.9  2001/11/29 10:41:44  gerlof
** *** empty log message ***
**
** Revision 1.8  2001/11/29 10:38:16  gerlof
** Exit-code correctly printed.
**
** Revision 1.7  2001/11/26 11:18:45  gerlof
** Modified generic output in case that the kernel-patch is not installed.
**
** Revision 1.6  2001/11/13 08:24:50  gerlof
** Show blank columns for sockets and disk I/O when no kernel-patch installed.
**
** Revision 1.5  2001/11/07 09:19:28  gerlof
** Use /proc instead of /dev/kmem for process-level statistics.
**
** Revision 1.4  2001/10/05 13:46:32  gerlof
** Implemented paging through the process-list
**
** Revision 1.3  2001/10/04 08:47:27  gerlof
** Improved handling of error-messages
**
** Revision 1.2  2001/10/03 08:57:53  gerlof
** Improved help-screen shown in scrollable window
**
** Revision 1.1  2001/10/02 10:43:34  gerlof
** Initial revision
**
*/

static const char rcsid[] = "$Id: showgeneric.c,v 1.41 2006/04/03 05:42:35 gerlof Exp $";

#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <signal.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <termio.h>
#include <unistd.h>
#include <stdarg.h>
#include <curses.h>
#include <pwd.h>
#include <grp.h>
#include <regex.h>

#include "atop.h"
#include "photoproc.h"
#include "photosyst.h"
#include "showgeneric.h"

extern unsigned long	interval;
extern int		deviatonly;
extern char		rawreadflag;
extern struct utsname	utsname;
extern char		flaglist[];

struct selection procsel = {"", {USERSTUB, }, "", 0, { 0, }};

static void	showhelp(int);

static int	screen;     	/* boolean: screen control-codes needed */
static int	paused;     	/* boolean: currently in pause-mode     */
static int	fixedhead;	/* boolean: fixate header-lines         */
static int	avgval;		/* boolean: average values i.s.o. total */

static int	(*curcompar)(const void *, const void *) = compcpu;
static char	*sortorder = "CPU", showtype = MPROCGEN;

static int	maxcpulines = 999;  /* maximum cpu       lines          */
static int	maxdsklines = 999;  /* maximum disk      lines          */
static int	maxintlines = 999;  /* maximum interface lines          */

char    	*genhdr = "ATOP - %-18.18s "
                          "%s  %s     %12ld seconds elapsed\n";

static int	cumusers(struct pstat *, struct pstat *, int);
static int	cumprocs(struct pstat *, struct pstat *, int);
static long	getnumval(char *, long, int);

/*
** print the deviation-counters on process- and system-level
*/
char
generic_samp(time_t curtime, int nsecs,
           struct sstat *sstat, struct pstat *pstat,
           int nact, int nproc, int nzomb, int nexit, char bootflag)
{
	static int	callnr = 0;

	register int	i, curline, statline;
	int		firstproc = 0, plistsz, alistsz, killpid, killsig;
	int		lastchar;
	char		format1[16], format2[16];
	char		*statmsg = NULL;
	struct passwd 	*pwd;
	struct syscap	syscap;

	struct pstat	*save_pstat = NULL;
	int		 save_nact = 0;

	if (callnr == 0)	/* first call ? */
	{
		/*
		** check if default sortorder and/or showtype are overruled
		** by commando-line flags
		*/
		for (i=0; flaglist[i]; i++)
		{
			switch (flaglist[i])
			{
			   case MSORTCPU:
				curcompar = compcpu;
				sortorder = "CPU";
				break;

			   case MSORTMEM:
				curcompar = compmem;
				sortorder = "MEM";
				break;

			   case MSORTDSK:
				curcompar = compdsk;
				sortorder = "DSK";
				break;

			   case MSORTNET:
				curcompar = compnet;
				sortorder = "NET";
				break;

			   case MPROCGEN:
				showtype  = MPROCGEN;
				curcompar = compcpu;
				sortorder = "CPU";
				break;

			   case MPROCMEM:
				showtype  = MPROCMEM;
				curcompar = compmem;
				sortorder = "MEM";
				break;

			   case MPROCSCH:
				showtype  = MPROCSCH;
				curcompar = compcpu;
				sortorder = "CPU";
				break;

			   case MPROCDSK:
				if ( !(kernpatch & PATCHSTAT) )
				{
					fprintf(stderr,
						"No kernel-patch installed "
						"(no disk-statistics)\n");
					sleep(3);
					break;
				}

				showtype  = MPROCDSK;
				curcompar = compdsk;
				sortorder = "DSK";
				break;

			   case MPROCNET:
				if ( !(kernpatch & PATCHSTAT) )
				{
					fprintf(stderr,
						"No kernel-patch installed "
						"(no network-statistics)\n");
					sleep(3);
					break;
				}

				showtype  = MPROCNET;
				curcompar = compnet;
				sortorder = "NET";
				break;

			   case MPROCVAR:
				showtype  = MPROCVAR;
				break;

			   case MPROCARG:
				showtype  = MPROCARG;
				break;

			   case MAVGVAL:
				if (avgval)
					avgval=0;
				else
					avgval=1;
				break;

			   case MCUMUSER:
				showtype  = MCUMUSER;
				break;

			   case MCUMPROC:
				showtype  = MCUMPROC;
				break;

			   case MSYSFIXED:
				if (fixedhead)
					fixedhead=0;
				else
					fixedhead=1;
				break;

			   case MSYSLIMIT:
				maxcpulines = 0;
				maxdsklines = 5;
				maxintlines = 3;
				break;

			   case MVERSION:
				printf("%s\n", getversion());
				cleanstop(0);

			   default:
				prusage("atop");
			}
		}

        	/*
        	** set stdout output on line-basis
        	*/
        	setvbuf(stdout, (char *)0, _IOLBF, BUFSIZ);

        	/*
        	** check if STDOUT is related to a tty or
        	** something else (file, pipe)
        	*/
        	if ( isatty(1) )
                	screen = 1;
        	else
                	screen = 0;

        	/*
        	** install catch-routine to finish in a controlled way
		** and activate cbreak-mode
        	*/
        	if (screen)
		{
			/*
			** initialize screen-handling via curses
			*/
			initscr();
			cbreak();
			noecho();

			if (COLS  < 80)
			{
				printw("Not enough columns "
				       "(need at least %d columns)\n", 80);
				refresh();
				sleep(3);
				cleanstop(1);
			}
		} 
                signal(SIGINT,   cleanstop);
                signal(SIGTERM,  cleanstop);
	}

	callnr++;

	/*
	** compute the total capacity of this system for the 
	** four main resources
	*/
	totalcap(&syscap, sstat, pstat, nact);

	/*
	** loop in which the system resources and the list of active
	** processes is shown; the loop will be preempted by receiving
	** a timer-signal or when the trigger-button is pressed.
	*/
	while (1)
	{
		curline = 1;

	        /*
       	 	** prepare screen or file output for new sample
        	*/
        	if (screen)
               	 	werase(stdscr);
        	else
                	printf("\n\n");

        	/*
        	** print general headerlines
        	*/
        	convdate(curtime, format1);       /* date to ascii string   */
        	convtime(curtime, format2);       /* time to ascii string   */

		if (screen)
			attron(A_REVERSE);

       		printg(genhdr, utsname.nodename, format1, format2, nsecs);

		if (screen)
			attroff(A_REVERSE);

		/*
		** print cumulative system- and user-time for all processes
		*/
		pricumproc(pstat, nact, nproc, nzomb, nexit, avgval, nsecs);

		curline++;

		/*
		** sort per-cpu       statistics on busy percentage
		** sort per-disk      statistics on busy percentage
		** sort per-interface statistics on transferred packages
		*/
		if (sstat->cpu.nrcpu > 1)
			qsort(sstat->cpu.cpu, sstat->cpu.nrcpu,
		 	               sizeof sstat->cpu.cpu[0], cpucompar);

		if (sstat->xdsk.nrxdsk > 1)
			qsort(sstat->xdsk.xdsk, sstat->xdsk.nrxdsk,
				       sizeof sstat->xdsk.xdsk[0], diskcompar);

		if (sstat->intf.nrintf > 1)
			qsort(sstat->intf.intf, sstat->intf.nrintf,
			  	       sizeof sstat->intf.intf[0], intfcompar);

		/*
		** print other lines of system-wide statistics
		*/
		curline = prisyst(sstat, curline, nsecs, avgval, fixedhead,
				maxcpulines, maxdsklines, maxintlines);

		if (screen && curline+2 > LINES)
		{
			move(0, 0);
			clrtobot();
			move(0, 0);
			printw("Not enough screen-lines available "
			       "(need at least %d lines)\n", curline+2);
			move(1, 0);
			printw("Resize window or start atop with the -l flag"
		       	       "to limit system-resources");

			refresh();
			sleep(4);
			cleanstop(1);
		}

		statline = curline;

		if (statmsg)
		{
			clrtoeol();
			printg(statmsg);
			statmsg = NULL;
		}
		else
		{
			if (bootflag)
			{
				if (screen)
					attron(A_BLINK);

       				printg("                *** system and "
				       "process activity since boot ***");

				if (screen)
					attroff(A_BLINK);
			}
		}

		if (screen)
			plistsz = LINES-curline-2;
		else
			plistsz = nact;

		/*
		** if cumulative figures required, save the current
		** list of processes and accumulate resource consumption
		** of all processes in the current list
		*/
		if (showtype == MCUMUSER || showtype == MCUMPROC)
		{
			/*
			** remember info based on individual processes
			*/
			save_pstat = pstat;
			save_nact  = nact;

			/*
			** allocate space for new (temporary) list with
			** one entry per user/program (list has worst-case size)
			*/
			pstat = calloc(sizeof(struct pstat), nact);

			/*
			** accumulate all processes
			** return-value nact contains number of new entries
			*/ 
			switch (showtype)
			{
			   case MCUMUSER:
				nact = cumusers(save_pstat, pstat, save_nact);
				break;
			   case MCUMPROC:
				nact = cumprocs(save_pstat, pstat, save_nact);
				break;
			}

			if (screen)
				plistsz = LINES-curline-2;
			else
				plistsz = nact;
		}

		/*
		** sort the list in required order 
		** (default CPU-consumption) and print the list
		*/
		if (nact > 0 && plistsz > 0)
		{
			qsort(pstat, nact, sizeof(struct pstat), curcompar);

			if (screen)
				attron(A_REVERSE);

			/*
			** print the header
			*/
			priphead(firstproc/plistsz+1, (nact-1)/plistsz+1,
			        			sortorder, showtype);

			if (screen)
			{
				attroff(A_REVERSE);
				clrtobot();
			}

			/*
			** print the list
			*/
			priproc(pstat, firstproc, nact, curline+2,
			        firstproc/plistsz+1, (nact-1)/plistsz+1,
			        sortorder, &syscap, showtype, 
				&procsel, screen, nsecs, avgval);
		}

		alistsz = nact;		/* preserve size of active list */

		/*
		** if cumulative figures per user shown,
		** release temporary space and restore per-process values
		*/
		if (showtype == MCUMUSER || showtype == MCUMPROC)
		{
			free(pstat);

			pstat = save_pstat;
			nact  = save_nact;
		}

		/*
		** in case of writing to a terminal, the user can also enter
		** a character to switch options, etc
		*/
		if (screen)
		{
			/*
			** show blinking pause-indication if necessary
			*/
			if (paused)
			{
				move(statline, 73);
				attron(A_BLINK);
				attron(A_REVERSE);
				printw("PAUSED");
				attroff(A_REVERSE);
				attroff(A_BLINK);
			}

			/*
			** await input-character or interval-timer expiration
			*/
			switch ( (lastchar = mvgetch(statline, 0)) )
			{
			   /*
			   ** timer expired
			   */
			   case ERR:
			   case 0:
				return lastchar;	

			   /*
			   ** stop it
			   */
			   case MQUIT:
				move(LINES-1, 0);
				clrtoeol();
				refresh();
				cleanstop(0);

			   /*
			   ** manual trigger for next sample
			   */
			   case MSAMPNEXT:
				if (paused)
					break;

				getalarm(0);
				return lastchar;

			   /*
			   ** manual trigger for previous sample
			   */
			   case MSAMPPREV:
				if (!rawreadflag)
				{
					statmsg = "Only allowed when viewing "
					          "raw file!";
					beep();
					break;
				}

				if (paused)
					break;

				return lastchar;

			   /*
			   ** sort in cpu-activity order
			   */
			   case MSORTCPU:
				curcompar = compcpu;
				sortorder = "CPU";
				firstproc = 0;
				break;

			   /*
			   ** sort in memory-consumption order
			   */
			   case MSORTMEM:
				curcompar = compmem;
				sortorder = "MEM";
				firstproc = 0;
				break;

			   /*
			   ** sort in disk-activity order
			   */
			   case MSORTDSK:
				curcompar = compdsk;
				sortorder = "DSK";
				firstproc = 0;
				break;

			   /*
			   ** sort in network-activity order
			   */
			   case MSORTNET:
				curcompar = compnet;
				sortorder = "NET";
				firstproc = 0;
				break;

			   /*
			   ** general figures per process
			   */
			   case MPROCGEN:
				showtype  = MPROCGEN;
				curcompar = compcpu;
				sortorder = "CPU";
				firstproc = 0;
				break;

			   /*
			   ** memory-specific figures per process
			   */
			   case MPROCMEM:
				showtype  = MPROCMEM;
				curcompar = compmem;
				sortorder = "MEM";
				firstproc = 0;
				break;

			   /*
			   ** disk-specific figures per process
			   */
			   case MPROCDSK:
				if ( !(kernpatch & PATCHSTAT) )
				{
					statmsg = "No kernel-patch installed; "
					          "request ignored!";
					break;
				}
				showtype  = MPROCDSK;
				curcompar = compdsk;
				sortorder = "DSK";
				firstproc = 0;
				break;

			   /*
			   ** network-specific figures per process
			   */
			   case MPROCNET:
				if ( !(kernpatch & PATCHSTAT) )
				{
					statmsg = "No kernel-patch installed; "
					          "request ignored!";
					break;
				}
				showtype  = MPROCNET;
				curcompar = compnet;
				sortorder = "NET";
				firstproc = 0;
				break;

			   /*
			   ** various info per process
			   */
			   case MPROCVAR:
				showtype  = MPROCVAR;
				firstproc = 0;
				break;

			   /*
			   ** command-line per process
			   */
			   case MPROCARG:
				showtype  = MPROCARG;
				firstproc = 0;
				break;

			   /*
			   ** scheduling-values per process
			   */
			   case MPROCSCH:
				showtype  = MPROCSCH;
				curcompar = compcpu;
				sortorder = "CPU";
				firstproc = 0;
				break;

			   /*
			   ** accumulated resource consumption per user
			   */
			   case MCUMUSER:
				statmsg = "Consumption per user; use 'a' to "
				          "toggle between all/active processes";

				showtype  = MCUMUSER;
				firstproc = 0;
				break;

			   /*
			   ** accumulated resource consumption per program
			   */
			   case MCUMPROC:
				statmsg = "Consumption per program; use 'a' to "
				          "toggle between all/active processes";

				showtype  = MCUMPROC;
				firstproc = 0;
				break;

			   /*
			   ** help wanted?
			   */
			   case MHELP1:
			   case MHELP2:
				alarm(0);	/* stop the clock         */

				move(1, 0);
				clrtobot();	/* blank the screen */
				refresh();

				showhelp(2);

				move(statline, 0);

				if (interval && !paused && !rawreadflag)
					alarm(3); /* force new sample     */

				firstproc = 0;
				break;

			   /*
			   ** send signal to process
			   */
			   case MKILLPROC:
				if (rawreadflag)
				{
					statmsg = "Not possible when viewing "
					          "raw file!";
					beep();
					break;
				}

				alarm(0);	/* stop the clock */

				killpid = getnumval("Pid of process: ",
						     0, statline);

				switch (killpid)
				{
				   case 0:
				   case -1:
					break;

				   case 1:
					statmsg = "Sending signal to pid 1 not "
					          "allowed!";
					beep();
					break;

				   default:
					clrtoeol();
					killsig = getnumval("Signal [%d]: ",
						     15, statline);

					if ( kill(killpid, killsig) == -1)
					{
						statmsg = "Not possible to "
						     "send signal to this pid!";
						beep();
					}
				}

				if (!paused)
					alarm(3); /* set short timer */

				firstproc = 0;
				break;

			   /*
			   ** change interval timeout
			   */
			   case MINTERVAL:
				if (rawreadflag)
				{
					statmsg = "Not possible when viewing "
					          "raw file!";
					beep();
					break;
				}

				alarm(0);	/* stop the clock */

				interval = getnumval("New interval in seconds "
						     "(now %d): ",
						     interval, statline);

				if (interval)
				{
					if (!paused)
						alarm(3); /* set short timer */
				}
				else
				{
					statmsg = "No timer set; waiting for "
					          "manual trigger ('t').....";
				}

				firstproc = 0;
				break;

			   /*
			   ** focus on specific user
			   */
			   case MSELUSER:
				alarm(0);	/* stop the clock */
				echo();

				move(statline, 0);
				clrtoeol();
				printw("Username as regular expression "
				       "(enter=all users): ");

				procsel.username[0] = '\0';
				scanw("%255s\n", procsel.username);

				noecho();

				if (procsel.username[0]) /* data entered ? */
				{
					regex_t		userregex;
					int		u = 0;

					regcomp(&userregex, procsel.username,
								    REG_NOSUB);

					while ( (pwd = getpwent()))
					{
						if (regexec(&userregex,
						    pwd->pw_name, 0, NULL, 0))
							continue;

						if (u < MAXUSERSEL-1)
						{
							procsel.userid[u] =
								pwd->pw_uid;
							u++;
						}
					}
					endpwent();

					procsel.userid[u] = USERSTUB;

					if (u == 0)
					{
						statmsg = "No user-names "
						    "matching this pattern!";
						beep();
					}
				}
				else
				{
					procsel.userid[0] = USERSTUB;
				}

				if (interval && !paused && !rawreadflag)
					alarm(3);  /* set short timer */

				firstproc = 0;
				break;

			   /*
			   ** focus on specific process-name
			   */
			   case MSELPROC:
				alarm(0);	/* stop the clock */
				echo();

				move(statline, 0);
				clrtoeol();
				printw("Process-name as regular "
				       "expression (enter=no specific name): ");

				procsel.procnamesz  = 0;
				procsel.procname[0] = '\0';

				scanw("%63s\n", procsel.procname);
				procsel.procnamesz = strlen(procsel.procname);

				if (procsel.procnamesz)
					regcomp(&procsel.procregex,
					         procsel.procname, REG_NOSUB);

				noecho();

				move(statline, 0);

				if (interval && !paused && !rawreadflag)
					alarm(3);  /* set short timer */

				firstproc = 0;
				break;

			   /*
			   ** toggle pause-state
			   */
			   case MPAUSE:
				if (paused)
				{
					paused=0;
					clrtoeol();
					refresh();

					if (!rawreadflag)
						alarm(1);
				}
				else
				{
					paused=1;
					clrtoeol();
					refresh();
					alarm(0);	/* stop the clock */
				}
				break;

			   /*
			   ** toggle between modified processes and
			   ** all processes
			   */
			   case MALLPROC:
				if (rawreadflag)
				{
					statmsg = "Process-list from raw file "
					          "will be shown anyhow!";
					break;
				}

				if (deviatonly)
				{
					deviatonly=0;
					statmsg = "All processes will be "
					          "shown/accumulated......";
				}
				else
				{
					deviatonly=1;
					statmsg = "Only active processes will"
					          " be shown/accumulated.....";
				}

				if (interval && !paused && !rawreadflag)
					alarm(3);  /* set short timer */

				firstproc = 0;
				break;

			   /*
			   ** toggle average or total values
			   */
			   case MAVGVAL:
				if (avgval)
					avgval=0;
				else
					avgval=1;
				break;

			   /*
			   ** system-statistics lines:
			   **	         toggle fixed or variable
			   */
			   case MSYSFIXED:
				if (fixedhead)
				{
					fixedhead=0;
					statmsg = "Only active system-resources"
					          " will be shown ......";
				}
				else
				{
					fixedhead=1;
					statmsg = "Also inactive "
					  "system-resources will be shown.....";
				}

				firstproc = 0;
				break;

			   /*
			   ** system-statistics lines:
			   **	         toggle no or all active disk
			   */
			   case MSYSLIMIT:
				alarm(0);	/* stop the clock */

				maxcpulines =
				  getnumval("Maximum lines for per-cpu "
				            "statistics (now %d): ",
				            maxcpulines, statline);

				maxdsklines =
				  getnumval("Maximum lines for disk "
				            "statistics (now %d): ",
				            maxdsklines, statline);

				maxintlines =
				  getnumval("Maximum lines for interface "
				            "statistics (now %d): ",
					    maxintlines, statline);

				if (interval && !paused && !rawreadflag)
					alarm(3);  /* set short timer */

				firstproc = 0;
				break;

			   /*
			   ** reset statistics 
			   */
			   case MRESET:
				getalarm(0);	/* restart the clock */
				paused = 0;
				return lastchar;

			   /*
			   ** show version info
			   */
			   case MVERSION:
				statmsg = getversion();
				break;

			   /*
			   ** handle forward
			   */
			   case MLISTFW:
				if (alistsz-firstproc > plistsz)
					firstproc += plistsz;
				break;

			   /*
			   ** handle backward
			   */
			   case MLISTBW:
				if (firstproc >= plistsz)
					firstproc -= plistsz;
				break;

			   /*
			   ** handle screen resize
			   */
			   case KEY_RESIZE:
				statmsg = "Window has been resized....";
				break;

			   /*
			   ** unknown key-stroke
			   */
			   default:
			        beep();
			}
		}
		else	/* no screen */
		{
			return '\0';
		}
	}
}

/*
** accumulate all processes per user in new list
*/
static int
cumusers(struct pstat *curprocs, struct pstat *curusers, int numprocs)
{
	register int	i, numusers;

	/*
	** sort list of active processes in order of uid (increasing)
	*/
	qsort(curprocs, numprocs, sizeof(struct pstat), compusr);

	/*
	** accumulate all processes per user in the new list
	*/
	for (numusers=i=0; i < numprocs; i++, curprocs++)
	{
		if ( curusers->gen.ruid != curprocs->gen.ruid )
		{
			if (curusers->gen.pid)
			{
				numusers++;
				curusers++;
			}
			curusers->gen.ruid = curprocs->gen.ruid;
		}

		curusers->gen.pid++;		/* misuse as counter */

		curusers->gen.nthr   += curprocs->gen.nthr;
		curusers->cpu.utime  += curprocs->cpu.utime;
		curusers->cpu.stime  += curprocs->cpu.stime;

		curusers->dsk.rio    += curprocs->dsk.rio;
		curusers->dsk.wio    += curprocs->dsk.wio;
			
		curusers->net.tcpsnd += curprocs->net.tcpsnd;
		curusers->net.tcprcv += curprocs->net.tcprcv;
		curusers->net.udpsnd += curprocs->net.udpsnd;
		curusers->net.udprcv += curprocs->net.udprcv;
		curusers->net.rawsnd += curprocs->net.rawsnd;
		curusers->net.rawrcv += curprocs->net.rawrcv;

		if (curprocs->gen.state != 'E')
		{
			curusers->mem.rmem   += curprocs->mem.rmem;
			curusers->mem.vmem   += curprocs->mem.vmem;
			curusers->mem.rgrow  += curprocs->mem.rgrow;
			curusers->mem.vgrow  += curprocs->mem.vgrow;
		}
	}

	if (curusers->gen.pid)
		numusers++;

	return numusers;
}

/*
** accumulate all processes with the same name (i.e. same program)
** into a new list
*/
static int
cumprocs(struct pstat *curprocs, struct pstat *curprogs, int numprocs)
{
	register int	i, numprogs;

	/*
	** sort list of active processes in order of process-name
	*/
	qsort(curprocs, numprocs, sizeof(struct pstat), compnam);

	/*
	** accumulate all processes with same name in the new list
	*/
	for (numprogs=i=0; i < numprocs; i++, curprocs++)
	{
		if ( strcmp(curprogs->gen.name, curprocs->gen.name) != 0)
		{
			if (curprogs->gen.pid)
			{
				numprogs++;
				curprogs++;
			}
			strcpy(curprogs->gen.name, curprocs->gen.name);
		}

		curprogs->gen.pid++;		/* misuse as counter */

		curprogs->gen.nthr   += curprocs->gen.nthr;
		curprogs->cpu.utime  += curprocs->cpu.utime;
		curprogs->cpu.stime  += curprocs->cpu.stime;

		curprogs->dsk.rio    += curprocs->dsk.rio;
		curprogs->dsk.wio    += curprocs->dsk.wio;
			
		curprogs->net.tcpsnd += curprocs->net.tcpsnd;
		curprogs->net.tcprcv += curprocs->net.tcprcv;
		curprogs->net.udpsnd += curprocs->net.udpsnd;
		curprogs->net.udprcv += curprocs->net.udprcv;
		curprogs->net.rawsnd += curprocs->net.rawsnd;
		curprogs->net.rawrcv += curprocs->net.rawrcv;

		if (curprocs->gen.state != 'E')
		{
			curprogs->mem.rmem   += curprocs->mem.rmem;
			curprogs->mem.vmem   += curprocs->mem.vmem;
			curprogs->mem.rgrow  += curprocs->mem.rgrow;
			curprogs->mem.vgrow  += curprocs->mem.vgrow;
		}
	}

	if (curprogs->gen.pid)
		numprogs++;

	return numprogs;
}

/*
** get a numerical value from the user and verify 
*/
static long
getnumval(char *ask, long valuenow, int statline)
{
	char numval[16];
	long retval;

	echo();
	move(statline, 0);
	clrtoeol();
	printw(ask, valuenow);

	numval[0] = 0;
	scanw("%15s", numval);

	move(statline, 0);
	noecho();

	if (numval[0])  /* data entered ? */
	{
		if ( numeric(numval) )
		{
			retval = atol(numval);
		}
		else
		{
			beep();
			clrtoeol();
			printw("Value not numeric (current value kept)!");
			refresh();
			sleep(2);
			retval = valuenow;
		}
	}
	else
	{
		retval = valuenow;
	}

	return retval;
}

/*
** generic print-function which checks if printf should be used
** (to file or pipe) or curses (to screen)
*/
void
printg(const char *format, ...)
{
	va_list	args;

	va_start(args, format);

	if (screen)
		vwprintw(stdscr, (char *) format, args);
	else
		vprintf(format, args);

	va_end  (args);
}

/*
** show help information in interactive mode
*/
static struct helptext {
	char *helpline;
	char helparg;
} helptext[] = {
	{"Figures shown for active processes:\n", 		' '},
	{"\t'%c' - generic info (default)\n",			MPROCGEN},
	{"\t'%c' - memory details\n",				MPROCMEM},
	{"\t'%c' - disk details\n",				MPROCDSK},
	{"\t'%c' - network details\n",				MPROCNET},
	{"\t'%c' - scheduling and thread-group info\n",		MPROCSCH},
	{"\t'%c' - various info (user/group, date/time)\n",	MPROCVAR},
	{"\t'%c' - full command-line per process\n",		MPROCARG},
	{"\n",							' '},
	{"Accumulated figures:\n",				' '},
	{"\t'%c' - total resource consumption per user\n", 	MCUMUSER},
	{"\t'%c' - total resource consumption per program (i.e. same "
	 "process name)\n",					MCUMPROC},
	{"\n",							' '},
	{"Sort list of active processes by:\n",			' '},
	{"\t'%c' - cpu activity (default)\n",			MSORTCPU},
	{"\t'%c' - memory consumption\n",			MSORTMEM},
	{"\t'%c' - disk activity\n",				MSORTDSK},
	{"\t'%c' - network activity\n",				MSORTNET},
	{"\n",							' '},
	{"Screen-handling:\n",					' '},
	{"\t^F  - show next     page in the process-list (forward)\n",	' '},
	{"\t^B  - show previous page in the process-list (backward)\n", ' '},
	{"\n",							' '},
	{"Miscellaneous commands:\n",				' '},
	{"\t'%c' - change interval-timer (0 = only manual trigger)\n",
								MINTERVAL},
	{"\t'%c' - manual trigger to finish interval\n",	MSAMPNEXT},
	{"\t'%c' - show previous interval again (raw file viewing)\n",
								MSAMPPREV},
	{"\t'%c' - reset counters to zero (or rewind for raw file viewing)\n",
								MRESET},
	{"\n",							' '},
	{"\t'%c' - focus on specific user name    (regular expression)\n",
								MSELUSER},
	{"\t'%c' - focus on specific process name (regular expression)\n",
								MSELPROC},
	{"\n",							' '},
	{"\t'%c' - active processes only (default) or all processes (toggle)\n",
								MALLPROC},
	{"\t'%c' - pause-button to freeze current sample            (toggle)\n",
								MPAUSE},
	{"\t'%c' - fixate on static range of header-lines           (toggle)\n",
								MSYSFIXED},
	{"\t'%c' - show average-per-second i.s.o. total values      (toggle)\n",
								MAVGVAL},
	{"\t'%c' - limited lines for per-cpu, disk and interface resources\n",
								MSYSLIMIT},
	{"\t'%c' - kill a process (i.e. send a signal)\n",	MKILLPROC},
	{"\n",							' '},
	{"\t'%c' - version-information\n",			MVERSION},
	{"\t'%c' - help-information\n",				MHELP1},
	{"\t'%c' - help-information\n",				MHELP2},
	{"\t'%c' - quit this program\n",			MQUIT},
};

static int helplines = sizeof(helptext)/sizeof(struct helptext);

static void
showhelp(int helpline)
{
	int	winlines = LINES-helpline, lin;
	WINDOW	*helpwin;

	/*
	** create a new window for the help-info in which scrolling is
	** allowed
	*/
	helpwin = newwin(winlines, COLS, helpline, 0);
	scrollok(helpwin, 1);

	/*
	** show help-lines 
	*/
	for (lin=0; lin < helplines; lin++)
	{
		wprintw(helpwin, helptext[lin].helpline, helptext[lin].helparg);

		/*
		** when the window is full, start paging interactively
		*/
		if (lin >= winlines-2)
		{
			wmove    (helpwin, winlines-1, 0);
			wclrtoeol(helpwin);
			wprintw  (helpwin, "Press any key for next line or "
			                   "'q' to leave help .......");

			if (wgetch(helpwin) == 'q')
			{
				delwin(helpwin);
				return;
			}

			wmove  (helpwin, winlines-1, 0);
		}
	}

	wmove    (helpwin, winlines-1, 0);
	wclrtoeol(helpwin);
	wprintw  (helpwin, "End of help - press any key to continue....");
	(void) wgetch(helpwin);
	delwin   (helpwin);
}

/*
** function to be called to print error-messages
*/
void
generic_error(const char *format, ...)
{
	va_list	args;

	va_start(args, format);
	vfprintf(stderr, format, args);
	va_end  (args);
}

/*
** function to be called when the program stops
*/
void
generic_end(void)
{
	endwin();
}

/*
** function to be called when usage-info is required
*/
void
generic_usage(void)
{
	printf("\t  -%c  show general process-info (default)\n",
			MPROCGEN);
	printf("\t  -%c  show memory-related process-info\n",
			MPROCMEM);
	printf("\t  -%c  show disk-related process-info\n",
			MPROCDSK);
	printf("\t  -%c  show network-related process-info\n",
			MPROCNET);
	printf("\t  -%c  show scheduling-related process-info\n",
			MPROCSCH);
	printf("\t  -%c  show various process-info (user/group, date/time)\n",
			MPROCVAR);
	printf("\t  -%c  show command-line per process\n",
			MPROCARG);
	printf("\t  -%c  show totals per user\n",
			MCUMUSER);
	printf("\t  -%c  show totals per program (i.e. same process name)\n",
			MCUMPROC);
	printf("\t  -%c  sort by cpu-consumption (default)\n",
			MSORTCPU);
	printf("\t  -%c  sort by memory-consumption\n",
			MSORTMEM);
	printf("\t  -%c  sort by disk-activity\n",
			MSORTDSK);
	printf("\t  -%c  sort by network-activity\n",
			MSORTNET);
	printf("\t  -%c  show fixed number of system-statistics\n",
			MSYSFIXED);
	printf("\t  -%c  limited lines for system-resources\n",
			MSYSLIMIT);
	printf("\t  -%c  show average-per-second i.s.o. total values\n",
			MAVGVAL);
}

/*
** functions to handle a particular tag in the .atoprc file
*/
void
do_username(char *val)
{
	struct passwd	*pwd;

	strncpy(procsel.username, val, sizeof procsel.username -1);
	procsel.username[sizeof procsel.username -1] = 0;

	if (procsel.username[0])
	{
		regex_t		userregex;
		int		u = 0;

		regcomp(&userregex, procsel.username, REG_NOSUB);

		while ( (pwd = getpwent()))
		{
			if (regexec(&userregex, pwd->pw_name, 0, NULL, 0))
				continue;

			if (u < MAXUSERSEL-1)
			{
				procsel.userid[u] = pwd->pw_uid;
				u++;
			}
		}
		endpwent();

		procsel.userid[u] = USERSTUB;

		if (u == 0)
		{
			fprintf(stderr,
			        ".atoprc: user-names matching %s do not "
				"exist\n", val);
			exit(1);
		}
	}
	else
	{
		procsel.userid[0] = USERSTUB;
	}
}

void
do_procname(char *val)
{
	strncpy(procsel.procname, val, sizeof procsel.procname -1);
	procsel.procnamesz = strlen(procsel.procname);

	if (procsel.procnamesz)
		regcomp(&procsel.procregex, procsel.procname, REG_NOSUB);
}

void
do_maxcpu(char *val)
{
	if (numeric(val))
	{
		maxcpulines = atoi(val);
	}
	else
	{
		fprintf(stderr, ".atoprc: maxcpu value not numeric\n");
		exit(1);
	}
}

void
do_maxdisk(char *val)
{
	if (numeric(val))
	{
		maxdsklines = atoi(val);
	}
	else
	{
		fprintf(stderr, ".atoprc: maxdisk value not numeric\n");
		exit(1);
	}
}

void
do_maxintf(char *val)
{
	if (numeric(val))
	{
		maxintlines = atoi(val);
	}
	else
	{
		fprintf(stderr, ".atoprc: maxintf value not numeric\n");
		exit(1);
	}
}

void
do_flags(char *val)
{
	int	i;

	for (i=0; val[i]; i++)
	{
		switch (val[i])
		{
		   case '-':
			break;

		   case MSORTCPU:
			curcompar = compcpu;
			sortorder = "CPU";
			break;

		   case MSORTMEM:
			curcompar = compmem;
			sortorder = "MEM";
			break;

		   case MSORTDSK:
			curcompar = compdsk;
			sortorder = "DSK";
			break;

		   case MSORTNET:
			curcompar = compnet;
			sortorder = "NET";
			break;

		   case MPROCGEN:
			showtype  = MPROCGEN;
			curcompar = compcpu;
			sortorder = "CPU";
			break;

		   case MPROCMEM:
			showtype  = MPROCMEM;
			curcompar = compmem;
			sortorder = "MEM";
			break;

		   case MPROCDSK:
			showtype  = MPROCDSK;
			curcompar = compdsk;
			sortorder = "DSK";
			break;

		   case MPROCNET:
			showtype  = MPROCNET;
			curcompar = compnet;
			sortorder = "NET";
			break;

		   case MPROCVAR:
			showtype  = MPROCVAR;
			break;

		   case MPROCSCH:
			showtype  = MPROCSCH;
			curcompar = compcpu;
			sortorder = "CPU";
			break;

		   case MPROCARG:
			showtype  = MPROCARG;
			break;

		   case MCUMUSER:
			showtype  = MCUMUSER;
			break;

		   case MCUMPROC:
			showtype  = MCUMPROC;
			break;

		   case MALLPROC:
			deviatonly  = 0;
			break;

		   case MAVGVAL:
			avgval=1;
			break;

		   case MSYSFIXED:
			fixedhead=1;
			break;
		}
	}
}