1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-02 00:22:11 +03:00

Remove unused tdb_search_keys()

This commit is contained in:
Volker Lendecke
2009-01-19 00:04:33 +01:00
parent eaec865148
commit fe9dd8710d
2 changed files with 0 additions and 78 deletions

View File

@ -25,13 +25,6 @@
#include "talloc.h" /* for tdb_wrap_open() */
#include "../libcli/util/ntstatus.h" /* for map_nt_error_from_tdb() */
/* single node of a list returned by tdb_search_keys */
typedef struct keys_node
{
struct keys_node *prev, *next;
TDB_DATA node_key;
} TDB_LIST_NODE;
struct tdb_wrap {
struct tdb_context *tdb;
const char *name;
@ -52,9 +45,6 @@ TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize);
TDB_DATA string_tdb_data(const char *string);
TDB_DATA string_term_tdb_data(const char *string);
TDB_LIST_NODE *tdb_search_keys(struct tdb_context*, const char*);
void tdb_search_list_free(TDB_LIST_NODE*);
int tdb_chainlock_with_timeout( struct tdb_context *tdb, TDB_DATA key,
unsigned int timeout);
int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval);

View File

@ -422,74 +422,6 @@ TDB_CONTEXT *tdb_open_log(const char *name, int hash_size, int tdb_flags,
return tdb;
}
/**
* Search across the whole tdb for keys that match the given pattern
* return the result as a list of keys
*
* @param tdb pointer to opened tdb file context
* @param pattern searching pattern used by fnmatch(3) functions
*
* @return list of keys found by looking up with given pattern
**/
TDB_LIST_NODE *tdb_search_keys(TDB_CONTEXT *tdb, const char* pattern)
{
TDB_DATA key, next;
TDB_LIST_NODE *list = NULL;
TDB_LIST_NODE *rec = NULL;
for (key = tdb_firstkey(tdb); key.dptr; key = next) {
/* duplicate key string to ensure null-termination */
char *key_str = SMB_STRNDUP((const char *)key.dptr, key.dsize);
if (!key_str) {
DEBUG(0, ("tdb_search_keys: strndup() failed!\n"));
smb_panic("strndup failed!\n");
}
DEBUG(18, ("checking %s for match to pattern %s\n", key_str, pattern));
next = tdb_nextkey(tdb, key);
/* do the pattern checking */
if (fnmatch(pattern, key_str, 0) == 0) {
rec = SMB_MALLOC_P(TDB_LIST_NODE);
ZERO_STRUCTP(rec);
rec->node_key = key;
DLIST_ADD_END(list, rec, TDB_LIST_NODE *);
DEBUG(18, ("checking %s matched pattern %s\n", key_str, pattern));
} else {
free(key.dptr);
}
/* free duplicated key string */
free(key_str);
}
return list;
}
/**
* Free the list returned by tdb_search_keys
*
* @param node list of results found by tdb_search_keys
**/
void tdb_search_list_free(TDB_LIST_NODE* node)
{
TDB_LIST_NODE *next_node;
while (node) {
next_node = node->next;
SAFE_FREE(node->node_key.dptr);
SAFE_FREE(node);
node = next_node;
};
}
/****************************************************************************
tdb_store, wrapped in a transaction. This way we make sure that a process
that dies within writing does not leave a corrupt tdb behind.