|
|
1.1 root 1: static char ID[] = "@(#) stats.c: 1.1 3/16/82";
2:
3: #include <stdio.h>
4: #include "sdp.h"
5: #include "define3.h"
6:
7: #ifdef SHORT
8: #define ST01 "ST01 "
9: #define STAU "STAU "
10: #else
11: #define ST01 "ST01 -- attempt to take statistics on an unhoused enviroment\n%o\n",environ
12: #define STAU "%s","STAU -- audit failed in sdp_stats\n"
13: #endif
14:
15: #ifdef SWEET
16: #define PROLOG
17: #define EPILOG
18: #else
19: #define PROLOG if(aud_flag == AUDITON)\
20: aud_set() ;
21: #define EPILOG if( (aud_flag == AUDITON) && (aud_check() == ERROR) )\
22: {\
23: stats.uses = ERROR ;\
24: stats.faults = ERROR ;\
25: stats.writes = ERROR ;\
26: stats.maxuse = ERROR ;\
27: ERR_RET(STAU,stats) ; \
28: }\
29: if(hist_fp != NULL)\
30: fprintf(hist_fp,"ST\t%o\t%ld\t%ld\t%ld\t%d\n",environ,stats.uses,stats.faults,stats.writes,stats.maxuse) ;
31: #endif
32:
33: extern int aud_flag ;
34: extern FILE *hist_fp ;
35: extern struct ENVIRON *first_environ ;
36: extern FATAL() ;
37: extern struct LIBFILE *Glib_file ;
38:
39: struct STATS /* contains statistics */
40: sdp_stats(environ)
41: struct ENVIRON *environ ;
42: {
43: register struct ENVIRON *curr ;
44: register struct ENVIRON *next ;
45: struct STATS stats ;
46:
47: PROLOG
48: stats.uses = 0l ;
49: stats.faults = 0l ;
50: stats.writes = 0l ;
51: stats.maxuse = 0 ;
52:
53: for(curr=first_environ; curr!=NULL; curr=next)
54: {
55: next = curr->next_environ ;
56: if( (curr==environ) || (environ==NULL) )
57: {
58: stats.uses += (curr->stats).uses ;
59: stats.faults += (curr->stats).faults ;
60: stats.writes += (curr->stats).writes ;
61: stats.maxuse += (curr->stats).maxuse ;
62: stats.curuse += (curr->stats).curuse ;
63:
64: if(environ == curr)
65: break ;
66: }
67: }
68:
69: if( (curr == NULL) && (environ != NULL) )
70: {
71: stats.uses = ERROR ;
72: stats.faults = ERROR ;
73: stats.writes = ERROR ;
74: stats.maxuse = ERROR ;
75: ERR_RET(ST01,stats)
76: }
77:
78: EPILOG
79: return(stats) ;
80: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.