op_fileio.h File Reference

#include "op_types.h"
#include <stdio.h>
Include dependency graph for op_fileio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FILE * op_try_open_file (char const *name, char const *mode)
FILE * op_open_file (char const *name, char const *mode)
u32 op_read_int_from_file (char const *filename, int fatal)
void op_close_file (FILE *fp)
void op_write_file (FILE *fp, void const *buf, size_t size)
void op_write_u32 (FILE *fp, u32 val)
void op_write_u64 (FILE *fp, u64 val)
void op_write_u8 (FILE *fp, u8 val)
char * op_get_line (FILE *fp)
unsigned long calc_crc32 (unsigned long crc, unsigned char *buf, size_t len)

Detailed Description

Reading from / writing to files

Remarks:
Copyright 2002 OProfile authors
Read the file COPYING
Author:
John Levon
Philippe Elie

Definition in file op_fileio.h.


Function Documentation

unsigned long calc_crc32 ( unsigned long  crc,
unsigned char *  buf,
size_t  len 
)

calc_crc32

Parameters:
crc current value
buf pointer to buffer
len Returns current crc computed from the crc argument and the characters in len characters in buf.

Definition at line 165 of file op_fileio.c.

void op_close_file ( FILE *  fp  ) 

op_close_file - close a file

Parameters:
fp file pointer

Closes a file pointer. A non-fatal error message is produced if the close fails.

Definition at line 52 of file op_fileio.c.

Referenced by op_cpu_freq_cpuinfo(), op_cpu_freq_sys_devices(), opd_get_ascii_maps(), opd_get_module_info(), opd_reread_module_info(), and read_tgid().

Here is the caller graph for this function:

char* op_get_line ( FILE *  fp  ) 

op_get_line - read an ASCII line from a file

Parameters:
fp file pointer

Get a line of ASCII text from a file. The file is read up to the first '' or '
'. A trailing '
' is deleted.

Returns the dynamically-allocated string containing that line. At the end of a file NULL will be returned. be returned.

The string returned must be free()d by the caller.

getline() is not a proper solution to replace this function

Definition at line 126 of file op_fileio.c.

References buf.

Referenced by _record_module_info(), get_mapping(), op_cpu_freq_cpuinfo(), op_cpu_freq_sys_devices(), opd_get_ascii_maps(), opd_get_module_info(), opd_reread_module_info(), read_events(), read_tgid(), and read_unit_masks().

Here is the caller graph for this function:

FILE* op_open_file ( char const *  name,
char const *  mode 
)

op_open_file - open a file

Parameters:
name file name
mode mode string

Open a file name. Failure to open is fatal.

Definition at line 46 of file op_fileio.c.

References op_do_open_file().

Here is the call graph for this function:

u32 op_read_int_from_file ( char const *  filename,
int  fatal 
)

op_read_int_from_file - parse an ASCII value from a file into an integer

Parameters:
filename name of file to parse integer value from
fatal non-zero if any error must be fatal

Reads an ASCII integer from the given file. If an error occur and fatal is zero (u32)-1 is returned else the value read in is returned.

Definition at line 95 of file op_fileio.c.

Referenced by opd_read_fs_int().

Here is the caller graph for this function:

FILE* op_try_open_file ( char const *  name,
char const *  mode 
)

op_try_open_file - open a file

Parameters:
name file name
mode mode string

Open a file name. Returns file handle or NULL on failure.

Definition at line 40 of file op_fileio.c.

References op_do_open_file().

Referenced by op_cpu_freq_cpuinfo(), op_cpu_freq_sys_devices(), opd_get_ascii_maps(), opd_get_module_info(), opd_reread_module_info(), and read_tgid().

Here is the call graph for this function:

Here is the caller graph for this function:

void op_write_file ( FILE *  fp,
void const *  buf,
size_t  size 
)

op_write_file - write to a file

Parameters:
fp file pointer
buf buffer
size nr. of bytes to write

Write size bytes of buffer buf to a file. Failure is fatal.

Definition at line 59 of file op_fileio.c.

Referenced by op_write_u32(), op_write_u64(), and op_write_u8().

Here is the caller graph for this function:

void op_write_u32 ( FILE *  fp,
u32  val 
)

op_write_u32 - write four bytes to a file

Parameters:
fp file pointer
val value to write

Write an unsigned four-byte value val to a file. Failure is fatal.

No byte-swapping is done.

Definition at line 83 of file op_fileio.c.

References op_write_file().

Here is the call graph for this function:

void op_write_u64 ( FILE *  fp,
u64  val 
)

op_write_u64 - write eight bytes to a file

Parameters:
fp file pointer
val value to write

Write an unsigned eight-byte value val to a file. Failure is fatal.

No byte-swapping is done.

Definition at line 89 of file op_fileio.c.

References op_write_file().

Here is the call graph for this function:

void op_write_u8 ( FILE *  fp,
u8  val 
)

op_write_u8 - write a byte to a file

Parameters:
fp file pointer
val value to write

Write an unsigned byte value val to a file. Failure is fatal.

Definition at line 77 of file op_fileio.c.

References op_write_file().

Here is the call graph for this function:


Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1