1 | /**************************************************************************
|
---|
2 | *
|
---|
3 | * filestats.h -- Functions for keeping stats on file accesses
|
---|
4 | * Copyright (C) 1994 Neil Sharman
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | *
|
---|
20 | * $Id: filestats.h 3745 2003-02-20 21:20:24Z mdewsnip $
|
---|
21 | *
|
---|
22 | **************************************************************************/
|
---|
23 |
|
---|
24 | #ifndef H_FILESTATS
|
---|
25 | #define H_FILESTATS
|
---|
26 |
|
---|
27 | #include "sysfuncs.h"
|
---|
28 |
|
---|
29 | typedef struct FileStats
|
---|
30 | {
|
---|
31 | unsigned long NumSeeks;
|
---|
32 | unsigned long NumReads;
|
---|
33 | unsigned long NumBytes;
|
---|
34 | }
|
---|
35 | FileStats;
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 | typedef struct
|
---|
40 | {
|
---|
41 | FILE *f;
|
---|
42 | char *pathname;
|
---|
43 | char *name;
|
---|
44 | FileStats Current;
|
---|
45 | FileStats Cumulative;
|
---|
46 | }
|
---|
47 | File;
|
---|
48 |
|
---|
49 | /* if magic is 0 no magic number is read or written */
|
---|
50 | File *Fopen (char *name, char *mode, unsigned long magic);
|
---|
51 |
|
---|
52 | size_t Fread (void *ptr, size_t size, size_t nitems, File * F);
|
---|
53 |
|
---|
54 | int Fseek (File * F, long offset, int ptrname);
|
---|
55 |
|
---|
56 | void Rewind (File * F);
|
---|
57 |
|
---|
58 | int Fclose (File * F);
|
---|
59 |
|
---|
60 | #define Getc(F) (F->Current.NumReads++, F->Current.NumBytes++, getc(F->f))
|
---|
61 |
|
---|
62 | /* This adds the Current file stats to the Cumulative stats and then zeros
|
---|
63 | the Current stats */
|
---|
64 | void ZeroFileStats (File * F);
|
---|
65 |
|
---|
66 |
|
---|
67 | #endif
|
---|