netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
dbif.h
Go to the documentation of this file.
1/*
2 Copyright (C) Joerg Lenneis 2003
3 Copyright (C) Frank Lahm 2009
4 All Rights Reserved. See COPYING.
5 */
6
56
57#ifndef CNID_DBD_DBIF_H
58#define CNID_DBD_DBIF_H 1
59
60#include <stdbool.h>
61#include <stdint.h>
62
63#include <db.h>
64
65#include <atalk/adouble.h>
66
67#include "db_param.h"
68
69#define DBIF_DB_CNT 4
70
71#define DBIF_CNID 0
72#define DBIF_IDX_DEVINO 1
73#define DBIF_IDX_DIDNAME 2
74#define DBIF_IDX_NAME 3
75
76#define LOCKFILENAME "lock"
77#define LOCK_FREE 0
78#define LOCK_UNLOCK 1
79#define LOCK_EXCL 2
80#define LOCK_SHRD 3
81
82/* Structures */
83 typedef struct {
84 char *name;
85 DB *db;
86 uint32_t flags;
87 uint32_t openflags;
88 DBTYPE type;
89} db_table;
90
91 typedef struct {
92 DB_ENV *db_env;
93 struct db_param db_param;
94 DB_TXN *db_txn;
95 DBC *db_cur;
96 char *db_envhome;
97 char *db_filename;
98 FILE *db_errlog;
99 db_table db_table[DBIF_DB_CNT];
100} DBD;
101
102 DBD *dbif_init(const char *envhome, const char *dbname);
103 int dbif_env_open(DBD *dbd, struct db_param *dbp, uint32_t dbenv_oflags);
104 int dbif_open(DBD *dbd, struct db_param *dbp, int reindex);
105 int dbif_close(DBD *dbd);
106 int dbif_env_remove(const char *path);
107
108 int dbif_get(DBD *, const int, DBT *, DBT *, uint32_t);
109 int dbif_pget(DBD *, const int, DBT *, DBT *, DBT *, uint32_t);
110 int dbif_put(DBD *, const int, DBT *, DBT *, uint32_t);
111 int dbif_del(DBD *, const int, DBT *, uint32_t);
112 int dbif_count(DBD *, const int, uint32_t *);
113 int dbif_search(DBD *dbd, DBT *key, char *resbuf,
114 uint32_t offset, bool *more);
115 int dbif_copy_rootinfokey(DBD *srcdbd, DBD *destdbd);
116 int dbif_txn_begin(DBD *);
117 int dbif_txn_commit(DBD *);
118 int dbif_txn_abort(DBD *);
119 int dbif_txn_close(DBD *dbd, int ret);
120 int dbif_txn_checkpoint(DBD *, uint32_t, uint32_t, uint32_t);
121
122 int dbif_dump(DBD *dbd, int dumpindexes);
123 int dbif_idwalk(DBD *dbd, cnid_t *cnid, int close);
124#endif
adouble.h
Part of Netatalk's AppleDouble implementatation.
cnid_t
uint32_t cnid_t
Definition adouble.h:156
db_param.h
dbif_dump
int dbif_dump(DBD *dbd, int dumpindexes)
Definition dbif.c:1280
dbif_env_open
int dbif_env_open(DBD *dbd, struct db_param *dbp, uint32_t dbenv_oflags)
Definition dbif.c:415
dbif_txn_commit
int dbif_txn_commit(DBD *)
Definition dbif.c:1140
dbif_txn_close
int dbif_txn_close(DBD *dbd, int ret)
Close a transaction based on ret code.
Definition dbif.c:1198
dbif_idwalk
int dbif_idwalk(DBD *dbd, cnid_t *cnid, int close)
Iterates over dbd, returning cnids.
Definition dbif.c:1466
dbif_search
int dbif_search(DBD *dbd, DBT *key, char *resbuf, uint32_t offset, bool *more)
Paginated substring cursor scan over the name index.
Definition dbif.c:1014
dbif_env_remove
int dbif_env_remove(const char *path)
Definition dbif.c:800
dbif_del
int dbif_del(DBD *, const int, DBT *, uint32_t)
Definition dbif.c:934
dbif_count
int dbif_count(DBD *, const int, uint32_t *)
Definition dbif.c:1234
dbif_copy_rootinfokey
int dbif_copy_rootinfokey(DBD *srcdbd, DBD *destdbd)
Definition dbif.c:1252
dbif_close
int dbif_close(DBD *dbd)
Definition dbif.c:765
dbif_pget
int dbif_pget(DBD *, const int, DBT *, DBT *, DBT *, uint32_t)
dbif_put
int dbif_put(DBD *, const int, DBT *, DBT *, uint32_t)
Definition dbif.c:905
dbif_txn_abort
int dbif_txn_abort(DBD *)
Definition dbif.c:1165
dbif_init
DBD * dbif_init(const char *envhome, const char *dbname)
Definition dbif.c:362
dbif_txn_begin
int dbif_txn_begin(DBD *)
Definition dbif.c:1115
dbif_get
int dbif_get(DBD *, const int, DBT *, DBT *, uint32_t)
Definition dbif.c:883
dbif_open
int dbif_open(DBD *dbd, struct db_param *dbp, int reindex)
Definition dbif.c:549
DBIF_DB_CNT
#define DBIF_DB_CNT
Definition dbif.h:69
dbif_txn_checkpoint
int dbif_txn_checkpoint(DBD *, uint32_t, uint32_t, uint32_t)
Definition dbif.c:1219
dbd
static DBD * dbd
Definition etc/cnid_dbd/main.c:45
dbp
static struct db_param * dbp
Definition etc/cnid_dbd/main.c:49
key
#define key
Definition hash.c:37
DBD
Definition dbif.h:91
DBD::db_txn
DB_TXN * db_txn
Definition dbif.h:94
DBD::db_errlog
FILE * db_errlog
Definition dbif.h:98
DBD::db_env
DB_ENV * db_env
Definition dbif.h:92
DBD::db_param
struct db_param db_param
Definition dbif.h:93
DBD::db_cur
DBC * db_cur
Definition dbif.h:95
DBD::db_envhome
char * db_envhome
Definition dbif.h:96
DBD::db_table
db_table db_table[DBIF_DB_CNT]
Definition dbif.h:99
DBD::db_filename
char * db_filename
Definition dbif.h:97
db_param
Definition db_param.h:22
db_table
Definition dbif.h:83
db_table::openflags
uint32_t openflags
Definition dbif.h:87
db_table::type
DBTYPE type
Definition dbif.h:88
db_table::flags
uint32_t flags
Definition dbif.h:86
db_table::name
char * name
Definition dbif.h:84
db_table::db
DB * db
Definition dbif.h:85
path
Definition include/atalk/directory.h:123