IDZEBRA  2.1.2
Macros | Functions
cfile.c File Reference
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <idzebra/util.h>
#include <yaz/yaz-util.h>
#include "mfile.h"
#include "cfile.h"

Go to the source code of this file.

Macros

#define EXTRA_CHECK   0
 set to 1 if extra commit/shadow check is to be performed More...
 

Functions

static int write_head (CFile cf)
 
static int read_head (CFile cf)
 
CFile cf_open (MFile mf, MFile_area area, const char *fname, int block_size, int wflag, int *firstp)
 
static int cf_hash (CFile cf, zint no)
 
static void release_bucket (CFile cf, struct CFile_hash_bucket *p)
 
static int flush_bucket (CFile cf, int no_to_flush)
 
static struct CFile_hash_bucketalloc_bucket (CFile cf, zint block_no, int hno)
 
static struct CFile_hash_bucketget_bucket (CFile cf, zint block_no, int hno)
 
static struct CFile_hash_bucketnew_bucket (CFile cf, zint *block_nop, int hno)
 
static int cf_lookup_flat (CFile cf, zint no, zint *vno)
 
static int cf_lookup_hash (CFile cf, zint no, zint *vno)
 
static int cf_write_flat (CFile cf, zint no, zint vno)
 
static int cf_moveto_flat (CFile cf)
 
static int cf_lookup (CFile cf, zint no, zint *vno)
 
static zint cf_new_flat (CFile cf, zint no)
 
static zint cf_new_hash (CFile cf, zint no)
 
zint cf_new (CFile cf, zint no)
 
int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf)
 reads block from commit area More...
 
int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf)
 writes block to commit area More...
 
int cf_close (CFile cf)
 

Macro Definition Documentation

#define EXTRA_CHECK   0

set to 1 if extra commit/shadow check is to be performed

Definition at line 33 of file cfile.c.

Function Documentation

static struct CFile_hash_bucket* alloc_bucket ( CFile  cf,
zint  block_no,
int  hno 
)
static
int cf_close ( CFile  cf)
static int cf_hash ( CFile  cf,
zint  no 
)
static

Definition at line 189 of file cfile.c.

References CFile_head::hash_size, and CFile_struct::head.

Referenced by cf_lookup_hash(), and cf_new_hash().

static int cf_lookup ( CFile  cf,
zint  no,
zint vno 
)
static

Definition at line 433 of file cfile.c.

References cf_lookup_flat(), cf_lookup_hash(), CFile_struct::head, and CFile_head::state.

Referenced by cf_read(), and cf_write().

static int cf_lookup_flat ( CFile  cf,
zint  no,
zint vno 
)
static

Definition at line 308 of file cfile.c.

References HASH_BSIZE, CFile_struct::hash_mf, CFile_struct::head, mf_read(), and CFile_head::next_bucket.

Referenced by cf_lookup().

static int cf_lookup_hash ( CFile  cf,
zint  no,
zint vno 
)
static
static int cf_moveto_flat ( CFile  cf)
static
zint cf_new ( CFile  cf,
zint  no 
)
static zint cf_new_flat ( CFile  cf,
zint  no 
)
static

Definition at line 440 of file cfile.c.

References cf_write_flat(), CFile_struct::head, and CFile_head::next_block.

Referenced by cf_new().

static zint cf_new_hash ( CFile  cf,
zint  no 
)
static
CFile cf_open ( MFile  mf,
MFile_area  area,
const char *  fname,
int  block_size,
int  wflag,
int *  firstp 
)
int cf_read ( CFile  cf,
zint  no,
int  offset,
int  nbytes,
void *  buf 
)

reads block from commit area

Parameters
cfcommit file
noblock number
offsetoffset in block
nbytesnumber of bytes to read
bufbuffer for content (if read was succesful)
Return values
0block could not be fully read
1block could be read
-1error

Definition at line 541 of file cfile.c.

References CFile_struct::block_mf, cf_lookup(), mf_read(), CFile_struct::mutex, zebra_mutex_lock(), zebra_mutex_unlock(), and ZINT_FORMAT.

Referenced by bf_read2().

int cf_write ( CFile  cf,
zint  no,
int  offset,
int  nbytes,
const void *  buf 
)

writes block to commit area

Parameters
cfcommit file
noblock number
offsetoffset in block
nbytesnumber of bytes to be written
bufbuffer to be written
Return values
0block written
-1error

Definition at line 578 of file cfile.c.

References CFile_struct::block_mf, cf_lookup(), cf_new(), CFile_struct::iobuf, mf_read(), mf_write(), CFile_struct::mutex, CFile_struct::rmf, zebra_mutex_lock(), and zebra_mutex_unlock().

Referenced by bf_write2().

static int cf_write_flat ( CFile  cf,
zint  no,
zint  vno 
)
static
static int flush_bucket ( CFile  cf,
int  no_to_flush 
)
static
static struct CFile_hash_bucket* get_bucket ( CFile  cf,
zint  block_no,
int  hno 
)
static
static struct CFile_hash_bucket* new_bucket ( CFile  cf,
zint block_nop,
int  hno 
)
static
static int read_head ( CFile  cf)
static
static void release_bucket ( CFile  cf,
struct CFile_hash_bucket p 
)
static
static int write_head ( CFile  cf)
static