[3745] | 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 | **************************************************************************/
|
---|
| 21 |
|
---|
| 22 | #ifndef H_FILESTATS
|
---|
| 23 | #define H_FILESTATS
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | typedef struct FileStats
|
---|
| 27 | {
|
---|
| 28 | unsigned long NumSeeks;
|
---|
| 29 | unsigned long NumReads;
|
---|
| 30 | unsigned long NumBytes;
|
---|
| 31 | }
|
---|
| 32 | FileStats;
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | typedef struct
|
---|
| 37 | {
|
---|
| 38 | FILE *f;
|
---|
| 39 | char *pathname;
|
---|
| 40 | char *name;
|
---|
| 41 | FileStats Current;
|
---|
| 42 | FileStats Cumulative;
|
---|
| 43 | }
|
---|
| 44 | File;
|
---|
| 45 |
|
---|
| 46 | /* if magic is 0 no magic number is read or written */
|
---|
| 47 | File *Fopen (char *name, char *mode, unsigned long magic);
|
---|
| 48 |
|
---|
| 49 | size_t Fread (void *ptr, size_t size, size_t nitems, File * F);
|
---|
| 50 |
|
---|
| 51 | int Fseek (File * F, long offset, int ptrname);
|
---|
| 52 |
|
---|
| 53 | void Rewind (File * F);
|
---|
| 54 |
|
---|
| 55 | int Fclose (File * F);
|
---|
| 56 |
|
---|
| 57 | #define Getc(F) (F->Current.NumReads++, F->Current.NumBytes++, getc(F->f))
|
---|
| 58 |
|
---|
| 59 | /* This adds the Current file stats to the Cumulative stats and then zeros
|
---|
| 60 | the Current stats */
|
---|
| 61 | void ZeroFileStats (File * F);
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | #endif
|
---|