tdb/include/tdb.h

説明を見る。
00001 #ifndef __TDB_H__
00002 #define __TDB_H__
00003 
00004 /* 
00005    Unix SMB/CIFS implementation.
00006 
00007    trivial database library
00008 
00009    Copyright (C) Andrew Tridgell 1999-2004
00010    
00011      ** NOTE! The following LGPL license applies to the tdb
00012      ** library. This does NOT imply that all of Samba is released
00013      ** under the LGPL
00014    
00015    This library is free software; you can redistribute it and/or
00016    modify it under the terms of the GNU Lesser General Public
00017    License as published by the Free Software Foundation; either
00018    version 2 of the License, or (at your option) any later version.
00019 
00020    This library is distributed in the hope that it will be useful,
00021    but WITHOUT ANY WARRANTY; without even the implied warranty of
00022    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023    Lesser General Public License for more details.
00024 
00025    You should have received a copy of the GNU Lesser General Public
00026    License along with this library; if not, write to the Free Software
00027    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 */
00029 
00030 #ifdef  __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 
00035 /* flags to tdb_store() */
00036 #define TDB_REPLACE 1
00037 #define TDB_INSERT 2
00038 #define TDB_MODIFY 3
00039 
00040 /* flags for tdb_open() */
00041 #define TDB_DEFAULT 0 /* just a readability place holder */
00042 #define TDB_CLEAR_IF_FIRST 1
00043 #define TDB_INTERNAL 2 /* don't store on disk */
00044 #define TDB_NOLOCK   4 /* don't do any locking */
00045 #define TDB_NOMMAP   8 /* don't use mmap */
00046 #define TDB_CONVERT 16 /* convert endian (internal use) */
00047 #define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */
00048 #define TDB_NOSYNC   64 /* don't use synchronous transactions */
00049 #define TDB_SEQNUM   128 /* maintain a sequence number */
00050 
00051 #define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret)
00052 
00053 /* error codes */
00054 enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, 
00055                 TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT,
00056                 TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY};
00057 
00058 /* debugging uses one of the following levels */
00059 enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, 
00060                       TDB_DEBUG_WARNING, TDB_DEBUG_TRACE};
00061 
00062 typedef struct TDB_DATA {
00063         char *dptr;
00064         size_t dsize;
00065 } TDB_DATA;
00066 
00067 #ifndef PRINTF_ATTRIBUTE
00068 #if (__GNUC__ >= 3)
00069 /** Use gcc attribute to check printf fns.  a1 is the 1-based index of
00070  * the parameter containing the format, and a2 the index of the first
00071  * argument. Note that some gcc 2.x versions don't handle this
00072  * properly **/
00073 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
00074 #else
00075 #define PRINTF_ATTRIBUTE(a1, a2)
00076 #endif
00077 #endif
00078 
00079 /* this is the context structure that is returned from a db open */
00080 typedef struct tdb_context TDB_CONTEXT;
00081 
00082 typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
00083 typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4);
00084 typedef unsigned int (*tdb_hash_func)(TDB_DATA *key);
00085 
00086 struct tdb_logging_context {
00087         tdb_log_func log_fn;
00088         void *log_private;
00089 };
00090 
00091 struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
00092                       int open_flags, mode_t mode);
00093 struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
00094                          int open_flags, mode_t mode,
00095                          const struct tdb_logging_context *log_ctx,
00096                          tdb_hash_func hash_fn);
00097 void tdb_set_max_dead(struct tdb_context *tdb, int max_dead);
00098 
00099 int tdb_reopen(struct tdb_context *tdb);
00100 int tdb_reopen_all(int parent_longlived);
00101 void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log_ctx);
00102 enum TDB_ERROR tdb_error(struct tdb_context *tdb);
00103 const char *tdb_errorstr(struct tdb_context *tdb);
00104 TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key);
00105 int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
00106                      int (*parser)(TDB_DATA key, TDB_DATA data,
00107                                    void *private_data),
00108                      void *private_data);
00109 int tdb_delete(struct tdb_context *tdb, TDB_DATA key);
00110 int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
00111 int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
00112 int tdb_close(struct tdb_context *tdb);
00113 TDB_DATA tdb_firstkey(struct tdb_context *tdb);
00114 TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key);
00115 int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *);
00116 int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *);
00117 int tdb_exists(struct tdb_context *tdb, TDB_DATA key);
00118 int tdb_lockall(struct tdb_context *tdb);
00119 int tdb_unlockall(struct tdb_context *tdb);
00120 int tdb_lockall_read(struct tdb_context *tdb);
00121 int tdb_unlockall_read(struct tdb_context *tdb);
00122 const char *tdb_name(struct tdb_context *tdb);
00123 int tdb_fd(struct tdb_context *tdb);
00124 tdb_log_func tdb_log_fn(struct tdb_context *tdb);
00125 void *tdb_get_logging_private(struct tdb_context *tdb);
00126 int tdb_transaction_start(struct tdb_context *tdb);
00127 int tdb_transaction_commit(struct tdb_context *tdb);
00128 int tdb_transaction_cancel(struct tdb_context *tdb);
00129 int tdb_transaction_recover(struct tdb_context *tdb);
00130 int tdb_get_seqnum(struct tdb_context *tdb);
00131 int tdb_hash_size(struct tdb_context *tdb);
00132 size_t tdb_map_size(struct tdb_context *tdb);
00133 int tdb_get_flags(struct tdb_context *tdb);
00134 
00135 /* Low level locking functions: use with care */
00136 int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key);
00137 int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key);
00138 int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key);
00139 int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key);
00140 
00141 void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *sigptr);
00142 
00143 /* Debug functions. Not used in production. */
00144 void tdb_dump_all(struct tdb_context *tdb);
00145 int tdb_printfreelist(struct tdb_context *tdb);
00146 int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
00147 
00148 extern TDB_DATA tdb_null;
00149 
00150 #ifdef  __cplusplus
00151 }
00152 #endif
00153 
00154 #endif /* tdb.h */

Sambaに対してSat Aug 29 21:23:27 2009に生成されました。  doxygen 1.4.7