IDZEBRA  2.2.7
Macros | Functions
cfile.c File Reference
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <yaz/yaz-util.h>
#include <yaz/snprintf.h>
#include <idzebra/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

◆ EXTRA_CHECK

#define EXTRA_CHECK   0

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

Definition at line 34 of file cfile.c.

Function Documentation

◆ alloc_bucket()

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

◆ cf_close()

int cf_close ( CFile  cf)

◆ cf_hash()

static int cf_hash ( CFile  cf,
zint  no 
)
static

Definition at line 190 of file cfile.c.

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

Referenced by cf_lookup_hash(), and cf_new_hash().

◆ cf_lookup()

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

Definition at line 434 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().

◆ cf_lookup_flat()

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

Definition at line 309 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().

◆ cf_lookup_hash()

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

◆ cf_moveto_flat()

static int cf_moveto_flat ( CFile  cf)
static

◆ cf_new()

zint cf_new ( CFile  cf,
zint  no 
)

◆ cf_new_flat()

static zint cf_new_flat ( CFile  cf,
zint  no 
)
static

Definition at line 441 of file cfile.c.

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

Referenced by cf_new().

◆ cf_new_hash()

static zint cf_new_hash ( CFile  cf,
zint  no 
)
static

◆ cf_open()

CFile cf_open ( MFile  mf,
MFile_area  area,
const char *  fname,
int  block_size,
int  wflag,
int *  firstp 
)

◆ cf_read()

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 542 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().

◆ cf_write()

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 579 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().

◆ cf_write_flat()

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

◆ flush_bucket()

static int flush_bucket ( CFile  cf,
int  no_to_flush 
)
static

◆ get_bucket()

static struct CFile_hash_bucket* get_bucket ( CFile  cf,
zint  block_no,
int  hno 
)
static

◆ new_bucket()

static struct CFile_hash_bucket* new_bucket ( CFile  cf,
zint block_nop,
int  hno 
)
static

◆ read_head()

static int read_head ( CFile  cf)
static

◆ release_bucket()

static void release_bucket ( CFile  cf,
struct CFile_hash_bucket p 
)
static

◆ write_head()

static int write_head ( CFile  cf)
static