1#ifndef _LNSTAT_H 2#define _LNSTAT_H 3 4#include <limits.h> 5 6#define LNSTAT_VERSION "0.02 041002" 7 8#define PROC_NET_STAT "/proc/net/stat" 9 10#define LNSTAT_MAX_FILES 32 11#define LNSTAT_MAX_FIELDS_PER_LINE 32 12#define LNSTAT_MAX_FIELD_NAME_LEN 32 13 14struct lnstat_file; 15 16struct lnstat_field { 17 struct lnstat_file *file; 18 unsigned int num; /* field number in line */ 19 char name[LNSTAT_MAX_FIELD_NAME_LEN+1]; 20 unsigned long values[2]; /* two buffers for values */ 21 unsigned long result; 22}; 23 24struct lnstat_file { 25 struct lnstat_file *next; 26 char path[PATH_MAX+1]; 27 char basename[NAME_MAX+1]; 28 struct timeval last_read; /* last time of read */ 29 struct timeval interval; /* interval */ 30 int compat; /* 1 == backwards compat mode */ 31 FILE *fp; 32 unsigned int num_fields; /* number of fields */ 33 struct lnstat_field fields[LNSTAT_MAX_FIELDS_PER_LINE]; 34}; 35 36 37struct lnstat_file *lnstat_scan_dir(const char *path, const int num_req_files, 38 const char **req_files); 39int lnstat_update(struct lnstat_file *lnstat_files); 40int lnstat_dump(FILE *outfd, struct lnstat_file *lnstat_files); 41struct lnstat_field *lnstat_find_field(struct lnstat_file *lnstat_files, 42 const char *name); 43#endif /* _LNSTAT_H */ 44