IDZEBRA 2.2.11
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

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_bucket * alloc_bucket (CFile cf, zint block_no, int hno)
static struct CFile_hash_bucket * get_bucket (CFile cf, zint block_no, int hno)
static struct CFile_hash_bucket * new_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
int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf)
 writes block to commit area
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()

◆ cf_close()

◆ cf_hash()

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

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

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

◆ cf_moveto_flat()

◆ cf_new()

◆ cf_new_flat()

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

◆ cf_open()

◆ 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()

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

◆ flush_bucket()

◆ get_bucket()

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

◆ new_bucket()

◆ read_head()

int read_head ( CFile cf)
static

◆ release_bucket()

◆ write_head()

int write_head ( CFile cf)
static