libjf API reference guide

Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

jf_utils.h File Reference

#include <jf/jf_config.h>
#include <jf/jf_defines.h>
#include <jf/jf_wrappers.h>
#include <jf/jf_errors.h>

Go to the source code of this file.

Defines

#define JF_TRACE_MODULE   JF_TRACE_MOD_LIB_UTILS
#define MAX(a, b)   (a>b ? a : b)
#define MIN(a, b)   (a<b ? a : b)

Functions

unsigned long jf_magnitude (unsigned long v)
int jf_path_is_absolute (const char *path)
int jf_stream_size (FILE *stream, jf_offset_t *size)
int jf_stream_sync (FILE *stream, jf_word_t policy)
int jf_stream_truncate (FILE *stream, jf_offset_t size)
int jf_translate_CRLF_NL (byte_t *data, jf_word_t *size)
int jf_translate_NL_CRLF (const byte_t *in_data, jf_word_t in_size, byte_t **out_data, jf_word_t *out_size)

Variables

const char * jf_feature_cache_stress
const char * jf_feature_crash_simul
const char * jf_feature_debug
const char * jf_feature_extra_check


Define Documentation

#define JF_TRACE_MODULE   JF_TRACE_MOD_LIB_UTILS
 

Definition at line 46 of file jf_utils.h.

#define MAX a,
 )     (a>b ? a : b)
 

Definition at line 51 of file jf_utils.h.

#define MIN a,
 )     (a<b ? a : b)
 

Definition at line 54 of file jf_utils.h.


Function Documentation

unsigned long jf_magnitude unsigned long  v  ) 
 

Compute the magnitude of an integer number m(0) = 0 m(1) = 1 m(2) = 2 m(3) = m(4) = 3 m(5) = m(6) = m(7) = m(8) = 4 ...

Parameters:
v IN value
Returns:
magnitude of v
Definition at line 171 of file jf_utils.c.

int jf_path_is_absolute const char *  path  ) 
 

Check if path is absolute. NOTE: path must NOT be NULL.
At this time this is a useless function, but I don't remove it because it might be useful in the future.

Parameters:
path IN path must be checked
Returns:
a boolean value
Definition at line 386 of file jf_utils.c.

References JF_PATH_SEPARATOR.

int jf_stream_size FILE *  stream,
jf_offset_t size
 

Retrieve the size of a stream

Parameters:
stream IN/OUT file stream must be sized
size OUT total stream length
Returns:
a reason code
Definition at line 253 of file jf_utils.c.

References CATCH, fseeko, ftello, jf_offset_t, JF_RC_FFLUSH_ERROR, JF_RC_FILENO_ERROR, JF_RC_FSEEK_ERROR, JF_RC_FSTAT_ERROR, JF_RC_FTELL_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, and THROW.

Referenced by jf_journal_load(), and jf_journal_util_join().

int jf_stream_sync FILE *  stream,
jf_word_t  policy
 

Synchronize a standard C stream using the desired policy

Parameters:
stream IN/OUT stream must be synchronized
policy IN synchronization specifications: it may be one of the following values: JF_JOURNAL_PROP_SYNC_FAST JF_JOURNAL_PROP_SYNC_SAFE
Returns:
a reason code
Definition at line 324 of file jf_utils.c.

References CATCH, JF_JOURNAL_PROP_SYNC_SAFE, JF_RC_FDATASYNC_ERROR, JF_RC_FFLUSH_ERROR, JF_RC_FSYNC_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_NULL_OBJECT, JF_RC_OK, JF_TRACE, jf_word_t, and THROW.

Referenced by bench_00_sio_run(), bench_01_sio_run(), bench_02_sio_run(), bench_03_sio_run(), bench_X1_sio_pre(), jf_journal_close_detach_file(), jf_journal_rotate(), and jf_journal_sync().

int jf_stream_truncate FILE *  stream,
jf_offset_t  size
 

Truncate a stream shortening (enlarging) it

Parameters:
stream IN/OUT file stream must be truncated
size IN new size the stream must have
Returns:
a reason code
Definition at line 204 of file jf_utils.c.

References CATCH, jf_offset_t, JF_RC_FFLUSH_ERROR, JF_RC_FILENO_ERROR, JF_RC_FTRUNCATE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, and THROW.

Referenced by jf_journal_cold_recovery_prep_pool(), and jf_journal_rollback_int().

int jf_translate_CRLF_NL byte_t data,
jf_word_t size
 

Translate a string from CRLF format ("\r\n") to NL format ("\n")

Parameters:
data IN/OUT array of byte must be translated (it's not necessary the null terminator char)
size IN/OUT size of the byte array before and after conversion
Returns:
a reason code
Definition at line 120 of file jf_utils.c.

References byte_t, CATCH, FALSE, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, THROW, and TRUE.

Referenced by jf_journal_get_byte_data().

int jf_translate_NL_CRLF const byte_t in_data,
jf_word_t  in_size,
byte_t **  out_data,
jf_word_t out_size
 

Translate a string from NL format ("\n") to CRLF format ("\r\n")

Parameters:
in_data IN array of byte must be translated (it's not necessary the null terminator char)
in_size IN size of the input byte array
out_data OUT translated byte array; NOTE: it MUST be released by caller with "free" function
out_size OUT size of the output byte array
Returns:
a reason code
Definition at line 65 of file jf_utils.c.

References byte_t, CATCH, JF_RC_INTERNAL_ERROR, JF_RC_MALLOC_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, and THROW.

Referenced by jf_journal_add_byte_data().


Variable Documentation

const char* jf_feature_cache_stress
 

This constant is used to define the symbol jf_feature_cache_stress in the resulting object/library; you can establish if the "--enable-cache-stress" feature was used at build time inspecting library with this command: strings libjf.so | grep 'jf_feature.*=' Definition at line 57 of file jf_utils.c.

const char* jf_feature_crash_simul
 

This constant is used to define the symbol jf_feature_crash_simul in the resulting object/library; you can establish if the "--enable-crash-simul" feature was used at build time inspecting library with this command: strings libjf.so | grep 'jf_feature.*=' Definition at line 54 of file jf_utils.c.

const char* jf_feature_debug
 

This constant is used to define the symbol jf_feature_debug in the resulting object/library; you can establish if the "--enable-debug" feature was used at build time inspecting library with this command: strings libjf.so | grep 'jf_feature.*=' Definition at line 51 of file jf_utils.c.

const char* jf_feature_extra_check
 

This constant is used to define the symbol jf_feature_extra_check in the resulting object/library; you can establish if the "--enable-extra-check" feature was used at build time inspecting library with this command: strings libjf.so | grep 'jf_feature.*=' Definition at line 60 of file jf_utils.c.


Copyright 2005 © Tiian