Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/smshex_r.../opt/saltstac.../salt/include
File: gdbm.h
/* gdbm.h - The include file for dbm users. -*- c -*- */
[0] Fix | Delete
[1] Fix | Delete
/* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson.
[2] Fix | Delete
Copyright (C) 1990-2022 Free Software Foundation, Inc.
[3] Fix | Delete
[4] Fix | Delete
GDBM is free software; you can redistribute it and/or modify
[5] Fix | Delete
it under the terms of the GNU General Public License as published by
[6] Fix | Delete
the Free Software Foundation; either version 2, or (at your option)
[7] Fix | Delete
any later version.
[8] Fix | Delete
[9] Fix | Delete
GDBM is distributed in the hope that it will be useful,
[10] Fix | Delete
but WITHOUT ANY WARRANTY; without even the implied warranty of
[11] Fix | Delete
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[12] Fix | Delete
GNU General Public License for more details.
[13] Fix | Delete
[14] Fix | Delete
You should have received a copy of the GNU General Public License
[15] Fix | Delete
along with GDBM. If not, see <http://www.gnu.org/licenses/>.
[16] Fix | Delete
[17] Fix | Delete
You may contact the author by:
[18] Fix | Delete
e-mail: phil@cs.wwu.edu
[19] Fix | Delete
us-mail: Philip A. Nelson
[20] Fix | Delete
Computer Science Department
[21] Fix | Delete
Western Washington University
[22] Fix | Delete
Bellingham, WA 98226
[23] Fix | Delete
[24] Fix | Delete
*************************************************************************/
[25] Fix | Delete
[26] Fix | Delete
/* Protection for multiple includes. */
[27] Fix | Delete
#ifndef _GDBM_H_
[28] Fix | Delete
# define _GDBM_H_
[29] Fix | Delete
[30] Fix | Delete
# include <stdio.h>
[31] Fix | Delete
# include <sys/types.h>
[32] Fix | Delete
[33] Fix | Delete
/* GDBM C++ support */
[34] Fix | Delete
# if defined(__cplusplus) || defined(c_plusplus)
[35] Fix | Delete
extern "C" {
[36] Fix | Delete
# endif
[37] Fix | Delete
[38] Fix | Delete
/* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
[39] Fix | Delete
can create the database. */
[40] Fix | Delete
# define GDBM_READER 0 /* A reader. */
[41] Fix | Delete
# define GDBM_WRITER 1 /* A writer. */
[42] Fix | Delete
# define GDBM_WRCREAT 2 /* A writer. Create the db if needed. */
[43] Fix | Delete
# define GDBM_NEWDB 3 /* A writer. Always create a new db. */
[44] Fix | Delete
# define GDBM_OPENMASK 7 /* Mask for the above. */
[45] Fix | Delete
[46] Fix | Delete
# define GDBM_FAST 0x0010 /* Write fast! => No fsyncs. OBSOLETE. */
[47] Fix | Delete
# define GDBM_SYNC 0x0020 /* Sync operations to the disk. */
[48] Fix | Delete
# define GDBM_NOLOCK 0x0040 /* Don't do file locking operations. */
[49] Fix | Delete
# define GDBM_NOMMAP 0x0080 /* Don't use mmap(). */
[50] Fix | Delete
# define GDBM_CLOEXEC 0x0100 /* Close the underlying fd on exec(3) */
[51] Fix | Delete
# define GDBM_BSEXACT 0x0200 /* Don't adjust block_size. Bail out with
[52] Fix | Delete
GDBM_BLOCK_SIZE_ERROR error if unable to
[53] Fix | Delete
set it. */
[54] Fix | Delete
# define GDBM_CLOERROR 0x0400 /* Only for gdbm_fd_open: close fd on error. */
[55] Fix | Delete
# define GDBM_XVERIFY 0x0800 /* Additional consistency checks. */
[56] Fix | Delete
# define GDBM_PREREAD 0x1000 /* Enable pre-fault reading of mmapped regions. */
[57] Fix | Delete
# define GDBM_NUMSYNC 0x2000 /* Enable the numsync extension */
[58] Fix | Delete
[59] Fix | Delete
[60] Fix | Delete
/* Parameters to gdbm_store for simple insertion or replacement in the
[61] Fix | Delete
case that the key is already in the database. */
[62] Fix | Delete
# define GDBM_INSERT 0 /* Never replace old data with new. */
[63] Fix | Delete
# define GDBM_REPLACE 1 /* Always replace old data with new. */
[64] Fix | Delete
[65] Fix | Delete
/* Parameters to gdbm_setopt, specifying the type of operation to perform. */
[66] Fix | Delete
# define GDBM_SETCACHESIZE 1 /* Set the cache size. */
[67] Fix | Delete
# define GDBM_FASTMODE 2 /* Toggle fast mode. OBSOLETE. */
[68] Fix | Delete
# define GDBM_SETSYNCMODE 3 /* Turn on or off sync operations. */
[69] Fix | Delete
# define GDBM_SETCENTFREE 4 /* Keep all free blocks in the header. */
[70] Fix | Delete
# define GDBM_SETCOALESCEBLKS 5 /* Attempt to coalesce free blocks. */
[71] Fix | Delete
# define GDBM_SETMAXMAPSIZE 6 /* Set maximum mapped memory size */
[72] Fix | Delete
# define GDBM_SETMMAP 7 /* Toggle mmap mode */
[73] Fix | Delete
[74] Fix | Delete
/* Compatibility defines: */
[75] Fix | Delete
# define GDBM_CACHESIZE GDBM_SETCACHESIZE
[76] Fix | Delete
# define GDBM_SYNCMODE GDBM_SETSYNCMODE
[77] Fix | Delete
# define GDBM_CENTFREE GDBM_SETCENTFREE
[78] Fix | Delete
# define GDBM_COALESCEBLKS GDBM_SETCOALESCEBLKS
[79] Fix | Delete
[80] Fix | Delete
# define GDBM_GETFLAGS 8 /* Get gdbm_open flags */
[81] Fix | Delete
# define GDBM_GETMMAP 9 /* Get mmap status */
[82] Fix | Delete
# define GDBM_GETCACHESIZE 10 /* Get current cache side */
[83] Fix | Delete
# define GDBM_GETSYNCMODE 11 /* Get synch mode */
[84] Fix | Delete
# define GDBM_GETCENTFREE 12 /* Get "centfree" status */
[85] Fix | Delete
# define GDBM_GETCOALESCEBLKS 13 /* Get free block coalesce status */
[86] Fix | Delete
# define GDBM_GETMAXMAPSIZE 14 /* Get maximum mapped memory size */
[87] Fix | Delete
# define GDBM_GETDBNAME 15 /* Return database file name */
[88] Fix | Delete
# define GDBM_GETBLOCKSIZE 16 /* Return block size */
[89] Fix | Delete
# define GDBM_GETDBFORMAT 17 /* Return the database format */
[90] Fix | Delete
# define GDBM_GETDIRDEPTH 18 /* Directory depth: number of initial (most
[91] Fix | Delete
significant) bits in hash interpreted as
[92] Fix | Delete
index to the directory. */
[93] Fix | Delete
# define GDBM_GETBUCKETSIZE 19 /* Get number of elements per bucket */
[94] Fix | Delete
# define GDBM_GETCACHEAUTO 20 /* Get the value of cache auto-adjustment */
[95] Fix | Delete
# define GDBM_SETCACHEAUTO 21 /* Set the value of cache auto-adjustment */
[96] Fix | Delete
[97] Fix | Delete
# define GDBM_CACHE_AUTO 0
[98] Fix | Delete
[99] Fix | Delete
typedef unsigned long long int gdbm_count_t;
[100] Fix | Delete
[101] Fix | Delete
/* The data and key structure. */
[102] Fix | Delete
typedef struct
[103] Fix | Delete
{
[104] Fix | Delete
char *dptr;
[105] Fix | Delete
int dsize;
[106] Fix | Delete
} datum;
[107] Fix | Delete
[108] Fix | Delete
/* A pointer to the GDBM file. */
[109] Fix | Delete
typedef struct gdbm_file_info *GDBM_FILE;
[110] Fix | Delete
[111] Fix | Delete
/* External variable, the gdbm build release string. */
[112] Fix | Delete
extern const char *gdbm_version;
[113] Fix | Delete
[114] Fix | Delete
# define GDBM_VERSION_MAJOR 1
[115] Fix | Delete
# define GDBM_VERSION_MINOR 23
[116] Fix | Delete
# define GDBM_VERSION_PATCH 0
[117] Fix | Delete
[118] Fix | Delete
extern int const gdbm_version_number[3];
[119] Fix | Delete
[120] Fix | Delete
/* GDBM external functions. */
[121] Fix | Delete
[122] Fix | Delete
extern GDBM_FILE gdbm_fd_open (int fd, const char *file_name, int block_size,
[123] Fix | Delete
int flags, void (*fatal_func) (const char *));
[124] Fix | Delete
extern GDBM_FILE gdbm_open (const char *, int, int, int,
[125] Fix | Delete
void (*)(const char *));
[126] Fix | Delete
extern int gdbm_close (GDBM_FILE);
[127] Fix | Delete
extern int gdbm_store (GDBM_FILE, datum, datum, int);
[128] Fix | Delete
extern datum gdbm_fetch (GDBM_FILE, datum);
[129] Fix | Delete
extern int gdbm_delete (GDBM_FILE, datum);
[130] Fix | Delete
extern datum gdbm_firstkey (GDBM_FILE);
[131] Fix | Delete
extern datum gdbm_nextkey (GDBM_FILE, datum);
[132] Fix | Delete
extern int gdbm_reorganize (GDBM_FILE);
[133] Fix | Delete
[134] Fix | Delete
extern int gdbm_sync (GDBM_FILE);
[135] Fix | Delete
extern int gdbm_failure_atomic (GDBM_FILE, const char *, const char *);
[136] Fix | Delete
[137] Fix | Delete
extern int gdbm_convert (GDBM_FILE dbf, int flag);
[138] Fix | Delete
[139] Fix | Delete
enum gdbm_latest_snapshot_status
[140] Fix | Delete
{
[141] Fix | Delete
GDBM_SNAPSHOT_OK, /* Selected the right snapshot. */
[142] Fix | Delete
GDBM_SNAPSHOT_BAD, /* Neither snapshot is readable. */
[143] Fix | Delete
GDBM_SNAPSHOT_ERR, /* Error selecting snapshot. Inspect errno. */
[144] Fix | Delete
GDBM_SNAPSHOT_SAME, /* Snapshot numsync and dates are the same. */
[145] Fix | Delete
GDBM_SNAPSHOT_SUSPICIOUS /* Selected snapshot is unreliable: numsyncs
[146] Fix | Delete
differ by more than 1. */
[147] Fix | Delete
};
[148] Fix | Delete
extern int gdbm_latest_snapshot (const char *, const char *, const char **);
[149] Fix | Delete
extern int gdbm_exists (GDBM_FILE, datum);
[150] Fix | Delete
extern int gdbm_setopt (GDBM_FILE, int, void *, int);
[151] Fix | Delete
extern int gdbm_fdesc (GDBM_FILE);
[152] Fix | Delete
[153] Fix | Delete
extern int gdbm_export (GDBM_FILE, const char *, int, int);
[154] Fix | Delete
extern int gdbm_export_to_file (GDBM_FILE dbf, FILE *fp);
[155] Fix | Delete
[156] Fix | Delete
extern int gdbm_import (GDBM_FILE, const char *, int);
[157] Fix | Delete
extern int gdbm_import_from_file (GDBM_FILE dbf, FILE *fp, int flag);
[158] Fix | Delete
[159] Fix | Delete
extern int gdbm_count (GDBM_FILE dbf, gdbm_count_t *pcount);
[160] Fix | Delete
extern int gdbm_bucket_count (GDBM_FILE dbf, size_t *pcount);
[161] Fix | Delete
[162] Fix | Delete
extern int gdbm_avail_verify (GDBM_FILE dbf);
[163] Fix | Delete
[164] Fix | Delete
typedef struct gdbm_recovery_s
[165] Fix | Delete
{
[166] Fix | Delete
/* Input members.
[167] Fix | Delete
These are initialized before call to gdbm_recover. The flags argument
[168] Fix | Delete
specifies which of them are initialized. */
[169] Fix | Delete
void (*errfun) (void *data, char const *fmt, ...);
[170] Fix | Delete
void *data;
[171] Fix | Delete
[172] Fix | Delete
size_t max_failed_keys;
[173] Fix | Delete
size_t max_failed_buckets;
[174] Fix | Delete
size_t max_failures;
[175] Fix | Delete
[176] Fix | Delete
/* Output members.
[177] Fix | Delete
The gdbm_recover function fills these before returning. */
[178] Fix | Delete
size_t recovered_keys;
[179] Fix | Delete
size_t recovered_buckets;
[180] Fix | Delete
size_t failed_keys;
[181] Fix | Delete
size_t failed_buckets;
[182] Fix | Delete
size_t duplicate_keys;
[183] Fix | Delete
char *backup_name;
[184] Fix | Delete
} gdbm_recovery;
[185] Fix | Delete
[186] Fix | Delete
#define GDBM_RCVR_DEFAULT 0x00 /* Default settings */
[187] Fix | Delete
#define GDBM_RCVR_ERRFUN 0x01 /* errfun is initialized */
[188] Fix | Delete
#define GDBM_RCVR_MAX_FAILED_KEYS 0x02 /* max_failed_keys is initialized */
[189] Fix | Delete
#define GDBM_RCVR_MAX_FAILED_BUCKETS 0x04 /* max_failed_buckets is initialized */
[190] Fix | Delete
#define GDBM_RCVR_MAX_FAILURES 0x08 /* max_failures is initialized */
[191] Fix | Delete
#define GDBM_RCVR_BACKUP 0x10 /* Keep backup copy of the
[192] Fix | Delete
original database on success */
[193] Fix | Delete
#define GDBM_RCVR_FORCE 0x20 /* Force recovery by skipping the
[194] Fix | Delete
check pass */
[195] Fix | Delete
[196] Fix | Delete
extern int gdbm_recover (GDBM_FILE dbf, gdbm_recovery *rcvr, int flags);
[197] Fix | Delete
[198] Fix | Delete
[199] Fix | Delete
#define GDBM_DUMP_FMT_BINARY 0
[200] Fix | Delete
#define GDBM_DUMP_FMT_ASCII 1
[201] Fix | Delete
[202] Fix | Delete
#define GDBM_META_MASK_MODE 0x01
[203] Fix | Delete
#define GDBM_META_MASK_OWNER 0x02
[204] Fix | Delete
[205] Fix | Delete
extern int gdbm_dump (GDBM_FILE, const char *, int fmt, int open_flags,
[206] Fix | Delete
int mode);
[207] Fix | Delete
extern int gdbm_dump_to_file (GDBM_FILE, FILE *, int fmt);
[208] Fix | Delete
[209] Fix | Delete
extern int gdbm_load (GDBM_FILE *, const char *, int replace,
[210] Fix | Delete
int meta_flags,
[211] Fix | Delete
unsigned long *line);
[212] Fix | Delete
extern int gdbm_load_from_file (GDBM_FILE *, FILE *, int replace,
[213] Fix | Delete
int meta_flags,
[214] Fix | Delete
unsigned long *line);
[215] Fix | Delete
[216] Fix | Delete
extern int gdbm_copy_meta (GDBM_FILE dst, GDBM_FILE src);
[217] Fix | Delete
[218] Fix | Delete
enum
[219] Fix | Delete
{
[220] Fix | Delete
GDBM_NO_ERROR = 0,
[221] Fix | Delete
GDBM_MALLOC_ERROR = 1,
[222] Fix | Delete
GDBM_BLOCK_SIZE_ERROR = 2,
[223] Fix | Delete
GDBM_FILE_OPEN_ERROR = 3,
[224] Fix | Delete
GDBM_FILE_WRITE_ERROR = 4,
[225] Fix | Delete
GDBM_FILE_SEEK_ERROR = 5,
[226] Fix | Delete
GDBM_FILE_READ_ERROR = 6,
[227] Fix | Delete
GDBM_BAD_MAGIC_NUMBER = 7,
[228] Fix | Delete
GDBM_EMPTY_DATABASE = 8,
[229] Fix | Delete
GDBM_CANT_BE_READER = 9,
[230] Fix | Delete
GDBM_CANT_BE_WRITER = 10,
[231] Fix | Delete
GDBM_READER_CANT_DELETE = 11,
[232] Fix | Delete
GDBM_READER_CANT_STORE = 12,
[233] Fix | Delete
GDBM_READER_CANT_REORGANIZE = 13,
[234] Fix | Delete
GDBM_UNKNOWN_ERROR = 14,
[235] Fix | Delete
GDBM_ITEM_NOT_FOUND = 15,
[236] Fix | Delete
GDBM_REORGANIZE_FAILED = 16,
[237] Fix | Delete
GDBM_CANNOT_REPLACE = 17,
[238] Fix | Delete
GDBM_MALFORMED_DATA = 18,
[239] Fix | Delete
GDBM_ILLEGAL_DATA = GDBM_MALFORMED_DATA,
[240] Fix | Delete
GDBM_OPT_ALREADY_SET = 19,
[241] Fix | Delete
GDBM_OPT_BADVAL = 20,
[242] Fix | Delete
GDBM_OPT_ILLEGAL = GDBM_OPT_BADVAL,
[243] Fix | Delete
GDBM_BYTE_SWAPPED = 21,
[244] Fix | Delete
GDBM_BAD_FILE_OFFSET = 22,
[245] Fix | Delete
GDBM_BAD_OPEN_FLAGS = 23,
[246] Fix | Delete
GDBM_FILE_STAT_ERROR = 24,
[247] Fix | Delete
GDBM_FILE_EOF = 25,
[248] Fix | Delete
GDBM_NO_DBNAME = 26,
[249] Fix | Delete
GDBM_ERR_FILE_OWNER = 27,
[250] Fix | Delete
GDBM_ERR_FILE_MODE = 28,
[251] Fix | Delete
GDBM_NEED_RECOVERY = 29,
[252] Fix | Delete
GDBM_BACKUP_FAILED = 30,
[253] Fix | Delete
GDBM_DIR_OVERFLOW = 31,
[254] Fix | Delete
GDBM_BAD_BUCKET = 32,
[255] Fix | Delete
GDBM_BAD_HEADER = 33,
[256] Fix | Delete
GDBM_BAD_AVAIL = 34,
[257] Fix | Delete
GDBM_BAD_HASH_TABLE = 35,
[258] Fix | Delete
GDBM_BAD_DIR_ENTRY = 36,
[259] Fix | Delete
GDBM_FILE_CLOSE_ERROR = 37,
[260] Fix | Delete
GDBM_FILE_SYNC_ERROR = 38,
[261] Fix | Delete
GDBM_FILE_TRUNCATE_ERROR = 39,
[262] Fix | Delete
GDBM_BUCKET_CACHE_CORRUPTED = 40,
[263] Fix | Delete
GDBM_BAD_HASH_ENTRY = 41,
[264] Fix | Delete
GDBM_ERR_SNAPSHOT_CLONE = 42,
[265] Fix | Delete
GDBM_ERR_REALPATH = 43,
[266] Fix | Delete
GDBM_ERR_USAGE = 44
[267] Fix | Delete
};
[268] Fix | Delete
[269] Fix | Delete
# define _GDBM_MIN_ERRNO 0
[270] Fix | Delete
# define _GDBM_MAX_ERRNO GDBM_ERR_USAGE
[271] Fix | Delete
[272] Fix | Delete
/* This one was never used and will be removed in the future */
[273] Fix | Delete
# define GDBM_UNKNOWN_UPDATE GDBM_UNKNOWN_ERROR
[274] Fix | Delete
[275] Fix | Delete
typedef int gdbm_error;
[276] Fix | Delete
extern int *gdbm_errno_location (void);
[277] Fix | Delete
#define gdbm_errno (*gdbm_errno_location ())
[278] Fix | Delete
extern const char * const gdbm_errlist[];
[279] Fix | Delete
extern int const gdbm_syserr[];
[280] Fix | Delete
[281] Fix | Delete
extern gdbm_error gdbm_last_errno (GDBM_FILE dbf);
[282] Fix | Delete
extern int gdbm_last_syserr (GDBM_FILE dbf);
[283] Fix | Delete
extern void gdbm_set_errno (GDBM_FILE dbf, gdbm_error ec, int fatal);
[284] Fix | Delete
extern void gdbm_clear_error (GDBM_FILE dbf);
[285] Fix | Delete
extern int gdbm_needs_recovery (GDBM_FILE dbf);
[286] Fix | Delete
extern int gdbm_check_syserr (gdbm_error n);
[287] Fix | Delete
[288] Fix | Delete
/* extra prototypes */
[289] Fix | Delete
[290] Fix | Delete
extern const char *gdbm_strerror (gdbm_error);
[291] Fix | Delete
extern const char *gdbm_db_strerror (GDBM_FILE dbf);
[292] Fix | Delete
[293] Fix | Delete
extern int gdbm_version_cmp (int const a[], int const b[]);
[294] Fix | Delete
[295] Fix | Delete
#if 0
[296] Fix | Delete
# define GDBM_DEBUG_ENABLE 1
[297] Fix | Delete
[298] Fix | Delete
typedef void (*gdbm_debug_printer_t) (char const *, ...);
[299] Fix | Delete
extern gdbm_debug_printer_t gdbm_debug_printer;
[300] Fix | Delete
extern int gdbm_debug_flags;
[301] Fix | Delete
[302] Fix | Delete
# define GDBM_DEBUG_ERR 0x00000001
[303] Fix | Delete
# define GDBM_DEBUG_OPEN 0x00000002
[304] Fix | Delete
# define GDBM_DEBUG_READ 0x00000004
[305] Fix | Delete
# define GDBM_DEBUG_STORE 0x00000008
[306] Fix | Delete
# define GDBM_DEBUG_LOOKUP 0x00000010
[307] Fix | Delete
[308] Fix | Delete
# define GDBM_DEBUG_ALL 0xffffffff
[309] Fix | Delete
[310] Fix | Delete
extern int gdbm_debug_token (char const *tok);
[311] Fix | Delete
extern void gdbm_debug_parse_state (int (*f) (void *, int, char const *),
[312] Fix | Delete
void *d);
[313] Fix | Delete
[314] Fix | Delete
extern void gdbm_debug_datum (datum dat, char const *pfx);
[315] Fix | Delete
#endif
[316] Fix | Delete
[317] Fix | Delete
/* Cache statistics */
[318] Fix | Delete
struct gdbm_cache_stat
[319] Fix | Delete
{
[320] Fix | Delete
off_t adr;
[321] Fix | Delete
size_t hits;
[322] Fix | Delete
};
[323] Fix | Delete
[324] Fix | Delete
void gdbm_get_cache_stats (GDBM_FILE dbf,
[325] Fix | Delete
size_t *access_count,
[326] Fix | Delete
size_t *cache_hits,
[327] Fix | Delete
size_t *cache_count,
[328] Fix | Delete
struct gdbm_cache_stat *bstat,
[329] Fix | Delete
size_t nstat);
[330] Fix | Delete
[331] Fix | Delete
# if defined(__cplusplus) || defined(c_plusplus)
[332] Fix | Delete
}
[333] Fix | Delete
# endif
[334] Fix | Delete
[335] Fix | Delete
#endif
[336] Fix | Delete
[337] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function