[de0c3c]: dae / opd_util.h Maximize Restore History

Download this file

opd_util.h    111 lines (91 with data), 3.2 kB

  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
/* $Id: opd_util.h,v 1.27 2002/05/02 02:19:08 movement Exp $ */
/* COPYRIGHT (C) 2000 THE VICTORIA UNIVERSITY OF MANCHESTER and John Levon
* 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 of the License, 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.
*/
#ifndef OPD_UTIL_H
#define OPD_UTIL_H
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#include <popt.h>
#include "../util/misc.h"
#include "../op_user.h"
/* this char replaces '/' in sample filenames */
#define OPD_MANGLE_CHAR '}'
#define FALSE 0
#define TRUE 1
#define streq(a,b) (!strcmp((a), (b)))
#define OPD_MAGIC "DAE\n"
#define OPD_VERSION 0x6
/* header of the sample files */
struct opd_header {
u8 magic[4];
u32 version;
u8 is_kernel;
u32 ctr_event;
u32 ctr_um;
/* ctr number, used for sanity checking */
u32 ctr;
u32 cpu_type;
u32 ctr_count;
double cpu_speed;
time_t mtime;
int separate_samples;
/* binary compatibility reserve */
u32 reserved1[20];
};
struct opd_fentry {
u32 count;
};
#ifdef __cplusplus
extern "C" {
#endif
char* opd_mangle_filename(const char* filename, const char * app_name);
#define opd_try_open_file(n,m) opd_do_open_file((n), (m), 0)
#define opd_open_file(n,m) opd_do_open_file((n), (m), 1)
FILE *opd_do_open_file(const char *name, const char *mode, int fatal);
void opd_close_file(FILE *fp);
#define opd_try_read_file(f,b,s) opd_do_read_file((f), (b), (s), 0);
#define opd_read_file(f,b,s) opd_do_read_file((f), (b), (s), 1);
void opd_do_read_file(FILE *fp, void *buf, size_t size, int fatal);
u8 opd_read_u8(FILE *fp);
u16 opd_read_u16_he(FILE *fp);
u32 opd_read_u32_he(FILE *fp);
u32 opd_read_int_from_file(const char *filename);
void opd_write_file(FILE *fp, const void *buf, size_t size);
void opd_write_u8(FILE *fp, u8 val);
void opd_write_u16_he(FILE *fp, u16 val);
void opd_write_u32_he(FILE *fp, u32 val);
#define opd_try_open_device(n) opd_open_device((n), 0)
fd_t opd_open_device(const char *name, int fatal);
void opd_close_device(fd_t devfd);
ssize_t opd_read_device(fd_t devfd, void *buf, size_t size, int seek);
off_t opd_get_fsize(const char *file, int fatal);
time_t opd_get_mtime(const char *file);
pid_t opd_read_lock_file(const char * file);
int opd_write_lock_file(const char * file);
char *opd_get_time(void);
char *opd_get_line(FILE *fp);
int opd_move_regular_file(const char *new_dir, const char *old_dir,
const char *name);
#ifdef __cplusplus
}
#endif
#endif /* OPD_UTIL_H */