mirror of
https://github.com/samba-team/samba.git
synced 2025-01-20 14:03:59 +03:00
bbe275e95b
two places i found where it was appropriate to _use_ that third argument, in locking.c and brlock.c! there was a static traverse_function and i removed the static variable, typecast it to a void*, passed it to tdb_traverse and re-cast it back to the traverse_function inside the tdb_traverse function. this makes the use of tdb_traverse() reentrant, which is never going to happen, i know, i just don't like to see statics lying about when there's no need for them. as i had to do in samba-tng, all uses of tdb_traverse modified to take the new void* state argument. 2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient. i don't know how the other samba team members would react if i deleted rpcclient from cvs main. damn, that code's so old, it's unreal. 20 rpcclient commands, instead of about 70 in SAMBA_TNG. (This used to be commit 49d7f0afbc1c5425d53019e234d54ddf205c8e9a)
79 lines
2.6 KiB
C
79 lines
2.6 KiB
C
/*
|
|
Unix SMB/Netbios implementation.
|
|
Version 3.0
|
|
Samba database functions
|
|
Copyright (C) Andrew Tridgell 1999
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*/
|
|
|
|
typedef unsigned tdb_len;
|
|
typedef unsigned tdb_off;
|
|
|
|
#define TDB_MAGIC_FOOD "TDB file\n"
|
|
|
|
/* this is stored at the front of every database */
|
|
struct tdb_header {
|
|
char magic_food[32]; /* for /etc/magic */
|
|
unsigned version; /* version of the code */
|
|
unsigned hash_size; /* number of hash entries */
|
|
};
|
|
|
|
typedef struct {
|
|
char *dptr;
|
|
size_t dsize;
|
|
} TDB_DATA;
|
|
|
|
/* this is the context structure that is returned from a db open */
|
|
typedef struct {
|
|
char *name; /* the name of the database */
|
|
void *map_ptr; /* where it is currently mapped */
|
|
int fd; /* open file descriptor for the database */
|
|
tdb_len map_size; /* how much space has been mapped */
|
|
int read_only; /* opened read-only */
|
|
int *locked; /* set if we have a chain locked */
|
|
int ecode; /* error code for last tdb error */
|
|
struct tdb_header header; /* a cached copy of the header */
|
|
} TDB_CONTEXT;
|
|
|
|
/* flags to tdb_store() */
|
|
#define TDB_REPLACE 1
|
|
#define TDB_INSERT 2
|
|
|
|
/* flags for tdb_open() */
|
|
#define TDB_CLEAR_IF_FIRST 1
|
|
|
|
/* error codes */
|
|
enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
|
|
TDB_ERR_OOM, TDB_ERR_EXISTS};
|
|
|
|
#if STANDALONE
|
|
TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags,
|
|
int open_flags, mode_t mode);
|
|
char *tdb_error(TDB_CONTEXT *tdb);
|
|
int tdb_writelock(TDB_CONTEXT *tdb);
|
|
int tdb_writeunlock(TDB_CONTEXT *tdb);
|
|
TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key);
|
|
int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key);
|
|
int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
|
|
int tdb_close(TDB_CONTEXT *tdb);
|
|
TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb);
|
|
TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key);
|
|
int tdb_traverse(TDB_CONTEXT *tdb,
|
|
int (*fn)(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state),
|
|
void *state);
|
|
int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key);
|
|
#endif
|