Functions
Import and Export Group

The Import and Export Group contains the APIs for reading and writing records to a file in cdb_dump or db_dump format. More...

Functions

int mdbm_cdbdump_to_file (kvpair kv, FILE *fp)
 Export API: Use cdb_dump format to write a key/value pair to file opened with fopen. More...
 
int mdbm_cdbdump_trailer_and_close (FILE *fp)
 Export API: Finalize and close a file written in cdb_dump format and opened with fopen. More...
 
int mdbm_cdbdump_add_record (kvpair kv, uint32_t *datasize, char **bufptr, uint32_t *bufsize, uint32_t buf_offset)
 Export API: Use cdb_dump format to write a key/value pair to a malloc'd buffer. More...
 
int mdbm_dbdump_to_file (kvpair kv, FILE *fp)
 Export API: Use db_dump format to write a key/value pair to a file opened with fopen. More...
 
int mdbm_dbdump_trailer_and_close (FILE *fp)
 Export API: Finalize and close a file written in db_dump format and opened with fopen. More...
 
int mdbm_dbdump_add_record (kvpair kv, uint32_t *datasize, char **bufptr, uint32_t *bufsize, uint32_t buf_offset)
 Export API: Use db_dump format to write a key/value pair to a malloc'd buffer. More...
 
int mdbm_dbdump_export_header (MDBM *db, FILE *fp)
 Export API: Write the DBdump header to FILE. More...
 
int mdbm_dbdump_import_header (FILE *fp, int *pgsize, int *pgcount, int *large, uint32_t *lineno)
 Import API: Read the DBdump header from FILE Function will set, if available at the beginning of the file pointed to by "fp", the following parameter values: More...
 
int mdbm_dbdump_import (MDBM *db, FILE *fp, const char *input_file, int store_flag, uint32_t *lineno)
 Import API: Read data from FILE into MDBM, using DBdump format. More...
 
int mdbm_cdbdump_import (MDBM *db, FILE *fp, const char *input_file, int store_flag)
 Import API: Read data from FILE into MDBM, using Cdb format. More...
 

Detailed Description

The Import and Export Group contains the APIs for reading and writing records to a file in cdb_dump or db_dump format.

Utility functions for converting from MDBM files into a textual representation. These functions generate data in one of 2 formats:

Function Documentation

int mdbm_cdbdump_to_file ( kvpair  kv,
FILE *  fp 
)

Export API: Use cdb_dump format to write a key/value pair to file opened with fopen.

Parameters
[in]kvKey+Value pair
[in,out]fpFILE pointer (return value of fopen)
Returns
Dump kvpair to file status
Return values
-1Error, and errno is set
0Success
int mdbm_cdbdump_trailer_and_close ( FILE *  fp)

Export API: Finalize and close a file written in cdb_dump format and opened with fopen.

Adds newline character as the file "trailer" and closes the file.

Parameters
[in,out]fpFILE pointer (return value of fopen)
Returns
Dump trailer to file status
Return values
-1Error, and errno is set
0Success
int mdbm_cdbdump_add_record ( kvpair  kv,
uint32_t *  datasize,
char **  bufptr,
uint32_t *  bufsize,
uint32_t  buf_offset 
)

Export API: Use cdb_dump format to write a key/value pair to a malloc'd buffer.

Parameters
[in]kvKey+Value pair
[in,out]datasizeSize of cdb_dump data to be added added to bufptr
[in,out]bufptrmalloc'd buffer. bufptr may be realloc'd if datasize is greater than bufsize
[in]bufsizeSize of malloc'd buffer
[in]buf_offsetOffset in bufptr to start writing data
Returns
Add record status
Return values
-1Error, and errno is set
0Success
int mdbm_dbdump_to_file ( kvpair  kv,
FILE *  fp 
)

Export API: Use db_dump format to write a key/value pair to a file opened with fopen.

Parameters
[in]kvKey+Value pair
[in,out]fpFILE pointer (return value of fopen)
Returns
Dump to file status
Return values
-1Error, and errno is set
0Success
int mdbm_dbdump_trailer_and_close ( FILE *  fp)

Export API: Finalize and close a file written in db_dump format and opened with fopen.

No trailer written: just closes the file (using fclose).

Parameters
[in,out]fpFILE pointer (return value of fopen)
Returns
Dump trailer status
Return values
-1Error, and errno is set
0Success
int mdbm_dbdump_add_record ( kvpair  kv,
uint32_t *  datasize,
char **  bufptr,
uint32_t *  bufsize,
uint32_t  buf_offset 
)

Export API: Use db_dump format to write a key/value pair to a malloc'd buffer.

mdbm_dbdump_add_record may realloc bufptr.

Parameters
[in]kvKey+Value pair
[in,out]datasizeSize of db_dump data to be added added to bufptr
[in,out]bufptrmalloc'd buffer. bufptr may be realloc'd if datasize is greater than bufsize
[in]bufsizeSize of malloc'd buffer
[in]buf_offsetOffset in bufptr to start writing data
Returns
Dump add record status
Return values
-1Error, and errno is set
0Success
int mdbm_dbdump_export_header ( MDBM db,
FILE *  fp 
)

Export API: Write the DBdump header to FILE.

Parameters
[in,out]dbhandle of MDBM whose data is being exported
[in]fpfile handle/pointer to read from
int mdbm_dbdump_import_header ( FILE *  fp,
int *  pgsize,
int *  pgcount,
int *  large,
uint32_t *  lineno 
)

Import API: Read the DBdump header from FILE Function will set, if available at the beginning of the file pointed to by "fp", the following parameter values:

Parameters
[in]fpfile handle/pointer to read from
[out]pgsizepage-size read from "fp"
[out]pgcountpage-count read from "fp"
[out]largelarge-object-support
[out]linenoThe line number following the header (for tracking progress)
int mdbm_dbdump_import ( MDBM db,
FILE *  fp,
const char *  input_file,
int  store_flag,
uint32_t *  lineno 
)

Import API: Read data from FILE into MDBM, using DBdump format.

MDBM locking and unlocking is done one record at a time based on locking set up when the MDBM was opened.

Parameters
[in,out]dbhandle of MDBM into which data is being imported
[in]fpfile handle/pointer to read from
[in]input_filename of the file pointed to by "fp".
[in]store_flagMDBM_INSERT | MDBM_REPLACE | MDBM_INSERT_DUP | MDBM_MODIFY
[in,out]linenocurrent line number, keep track of the current line number to generate meaningful error messages. Precondition: set to 1 or pass line number previously set by mdbm_dbdump_import_header. Postcondition: lineno will hold the last line number read successfully.
int mdbm_cdbdump_import ( MDBM db,
FILE *  fp,
const char *  input_file,
int  store_flag 
)

Import API: Read data from FILE into MDBM, using Cdb format.

MDBM locking and unlocking is done one record at a time based on locking set up when the MDBM was opened.

Parameters
[in,out]dbhandle of MDBM into which data is being imported
[in]fpfile handle/pointer to read from
[in]input_filename of the file pointed to by "fp".
[in]store_flagMDBM_INSERT | MDBM_REPLACE | MDBM_INSERT_DUP | MDBM_MODIFY