include/util_tdb.h

ソースコードを見る。

データ構造

struct  keys_node
struct  tdb_wrap

型定義

typedef int BOOL
typedef keys_node TDB_LIST_NODE

関数

TDB_LIST_NODEtdb_search_keys (struct tdb_context *, const char *)
 Search across the whole tdb for keys that match the given pattern return the result as a list of keys
void tdb_search_list_free (TDB_LIST_NODE *)
 Free the list returned by tdb_search_keys
int32_t tdb_change_int32_atomic (struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val)
int tdb_lock_bystring (struct tdb_context *tdb, const char *keyval)
int tdb_lock_bystring_with_timeout (TDB_CONTEXT *tdb, const char *keyval, int timeout)
void tdb_unlock_bystring (struct tdb_context *tdb, const char *keyval)
int tdb_read_lock_bystring_with_timeout (TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout)
void tdb_read_unlock_bystring (TDB_CONTEXT *tdb, const char *keyval)
int32_t tdb_fetch_int32 (struct tdb_context *tdb, const char *keystr)
int tdb_store_uint32 (struct tdb_context *tdb, const char *keystr, uint32_t value)
int tdb_store_int32 (struct tdb_context *tdb, const char *keystr, int32_t v)
int tdb_fetch_uint32 (struct tdb_context *tdb, const char *keystr, uint32_t *value)
int tdb_traverse_delete_fn (struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
int tdb_store_bystring (struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags)
TDB_DATA tdb_fetch_bystring (struct tdb_context *tdb, const char *keystr)
int tdb_delete_bystring (struct tdb_context *tdb, const char *keystr)
tdb_contexttdb_open_log (const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode)
int tdb_unpack (char *buf, int bufsize, const char *fmt,...)
size_t tdb_pack (char *buf, int bufsize, const char *fmt,...)
TDB_DATA make_tdb_data (const char *dptr, size_t dsize)
TDB_DATA string_tdb_data (const char *string)
int tdb_trans_store (struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
int tdb_change_uint32_atomic (TDB_CONTEXT *tdb, const char *keystr, uint32 *oldval, uint32 change_val)
int tdb_chainlock_with_timeout (TDB_CONTEXT *tdb, TDB_DATA key, unsigned int timeout)


型定義

typedef int BOOL

util_tdb.h27 行で定義されています。

typedef struct keys_node TDB_LIST_NODE


関数

TDB_LIST_NODE* tdb_search_keys ( TDB_CONTEXT tdb,
const char *  pattern 
)

Search across the whole tdb for keys that match the given pattern return the result as a list of keys

引数:
tdb pointer to opened tdb file context
pattern searching pattern used by fnmatch(3) functions
戻り値:
list of keys found by looking up with given pattern

util_tdb.c714 行で定義されています。

参照先 TDB_DATA::dptrTDB_DATA::dsizelist()keys_node::node_keysmb_panic()tdbtdb_firstkey()tdb_nextkey().

参照元 gencache_iterate()secrets_trusted_domains().

00715 {
00716         TDB_DATA key, next;
00717         TDB_LIST_NODE *list = NULL;
00718         TDB_LIST_NODE *rec = NULL;
00719         
00720         for (key = tdb_firstkey(tdb); key.dptr; key = next) {
00721                 /* duplicate key string to ensure null-termination */
00722                 char *key_str = (char*) SMB_STRNDUP(key.dptr, key.dsize);
00723                 if (!key_str) {
00724                         DEBUG(0, ("tdb_search_keys: strndup() failed!\n"));
00725                         smb_panic("strndup failed!\n");
00726                 }
00727                 
00728                 DEBUG(18, ("checking %s for match to pattern %s\n", key_str, pattern));
00729                 
00730                 next = tdb_nextkey(tdb, key);
00731 
00732                 /* do the pattern checking */
00733                 if (fnmatch(pattern, key_str, 0) == 0) {
00734                         rec = SMB_MALLOC_P(TDB_LIST_NODE);
00735                         ZERO_STRUCTP(rec);
00736 
00737                         rec->node_key = key;
00738         
00739                         DLIST_ADD_END(list, rec, TDB_LIST_NODE *);
00740                 
00741                         DEBUG(18, ("checking %s matched pattern %s\n", key_str, pattern));
00742                 } else {
00743                         free(key.dptr);
00744                 }
00745                 
00746                 /* free duplicated key string */
00747                 free(key_str);
00748         }
00749         
00750         return list;
00751 
00752 }

void tdb_search_list_free ( TDB_LIST_NODE node  ) 

Free the list returned by tdb_search_keys

引数:
node list of results found by tdb_search_keys

util_tdb.c760 行で定義されています。

参照先 TDB_DATA::dptrkeys_node::nextkeys_node::node_key.

参照元 gencache_iterate()secrets_trusted_domains().

00761 {
00762         TDB_LIST_NODE *next_node;
00763         
00764         while (node) {
00765                 next_node = node->next;
00766                 SAFE_FREE(node->node_key.dptr);
00767                 SAFE_FREE(node);
00768                 node = next_node;
00769         };
00770 }

int32_t tdb_change_int32_atomic ( struct tdb_context tdb,
const char *  keystr,
int32_t *  oldval,
int32_t  change_val 
)

参照元 get_rand_seed()print_job_delete1()print_job_start().

int tdb_lock_bystring ( struct tdb_context tdb,
const char *  keyval 
)

util_tdb.c111 行で定義されています。

参照先 make_tdb_data()tdbtdb_chainlock().

参照元 gencache_lock_entry()init_account_policy()init_group_mapping()init_idmap_tdb()notify_lock()print_backend_init()secrets_lock_trust_account_password()share_info_db_init()tdb_change_int32_atomic()tdb_change_uint32_atomic()tdbsam_convert()update_c_setprinter().

00112 {
00113         TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
00114         
00115         return tdb_chainlock(tdb, key);
00116 }

int tdb_lock_bystring_with_timeout ( TDB_CONTEXT tdb,
const char *  keyval,
int  timeout 
)

util_tdb.c118 行で定義されています。

参照先 make_tdb_data()tdbtdb_chainlock_with_timeout().

参照元 allocate_print_jobid()get_num_records_hook()make_way_for_eventlogs()print_notify_deregister_pid()print_notify_register_pid()print_queue_update_with_lock()py_tdb_hnd_lock_bystring()secrets_named_mutex()tdbsam_rename_sam_account()write_eventlog_tdb().

00120 {
00121         TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
00122         
00123         return tdb_chainlock_with_timeout(tdb, key, timeout);
00124 }

void tdb_unlock_bystring ( struct tdb_context tdb,
const char *  keyval 
)

util_tdb.c130 行で定義されています。

参照先 make_tdb_data()tdbtdb_chainunlock().

参照元 gencache_unlock_entry()get_num_records_hook()init_account_policy()init_group_mapping()init_idmap_tdb()make_way_for_eventlogs()notify_unlock()print_backend_init()print_queue_update_with_lock()py_tdb_hnd_unlock_bystring()secrets_lock_trust_account_password()secrets_named_mutex_release()share_info_db_init()tdb_change_int32_atomic()tdb_change_uint32_atomic()tdbsam_convert()tdbsam_rename_sam_account()update_c_setprinter()write_eventlog_tdb().

00131 {
00132         TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
00133 
00134         tdb_chainunlock(tdb, key);
00135 }

int tdb_read_lock_bystring_with_timeout ( TDB_CONTEXT tdb,
const char *  keyval,
unsigned int  timeout 
)

util_tdb.c141 行で定義されています。

参照先 make_tdb_data()tdbtdb_chainlock_with_timeout_internal().

参照元 print_notify_pid_list().

00142 {
00143         TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
00144         
00145         return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_RDLCK);
00146 }

void tdb_read_unlock_bystring ( TDB_CONTEXT tdb,
const char *  keyval 
)

util_tdb.c152 行で定義されています。

参照先 make_tdb_data()tdbtdb_chainunlock_read().

参照元 print_notify_pid_list().

00153 {
00154         TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
00155         
00156         tdb_chainunlock_read(tdb, key);
00157 }

int32_t tdb_fetch_int32 ( struct tdb_context tdb,
const char *  keystr 
)

util_tdb.c187 行で定義されています。

参照先 tdbtdb_fetch_int32_byblob().

参照元 elog_tdb_size()get_c_setprinter()get_num_records_hook()get_queue_status()getservicebyname()idmap_tdb_alloc_init()idmap_tdb_allocate_id()idmap_tdb_convert()idmap_tdb_get_hwm()idmap_tdb_open_db()init_group_mapping()init_idmap_tdb()lang_tdb_init()make_way_for_eventlogs()nt_printing_init()print_backend_init()print_cache_expired()process_usershare_file()regdb_init()share_info_db_init()tdb_change_int32_atomic()tdbsam_open()update_c_setprinter()write_eventlog_tdb().

00188 {
00189         return tdb_fetch_int32_byblob(tdb, keystr, strlen(keystr) + 1);
00190 }

int tdb_store_uint32 ( struct tdb_context tdb,
const char *  keystr,
uint32_t  value 
)

参照元 account_policy_set()init_account_policy()initialize_winbindd_cache()print_queue_update()print_queue_update_internal()tdb_change_uint32_atomic().

int tdb_store_int32 ( struct tdb_context tdb,
const char *  keystr,
int32_t  v 
)

参照元 elog_init_tdb()hash_a_service()idmap_tdb_alloc_init()idmap_tdb_convert()idmap_tdb_open_db()idmap_tdb_set_hwm()init_group_mapping()init_idmap_tdb()initialise_wins()lang_tdb_init()nt_printing_init()print_backend_init()print_cache_flush()print_queue_update_internal()share_info_db_init()sync_eventlog_params()tdb_change_int32_atomic()tdbsam_convert()update_c_setprinter()write_eventlog_tdb().

int tdb_fetch_uint32 ( struct tdb_context tdb,
const char *  keystr,
uint32_t *  value 
)

参照元 account_policy_get()allocate_print_jobid()init_account_policy()initialize_winbindd_cache()print_cache_expired()tdb_change_uint32_atomic().

int tdb_traverse_delete_fn ( struct tdb_context the_tdb,
TDB_DATA  key,
TDB_DATA  dbuf,
void *  state 
)

util_tdb.c697 行で定義されています。

参照先 tdb_delete().

参照元 init_group_mapping()load_msg()print_backend_init()share_info_db_init().

00699 {
00700     return tdb_delete(the_tdb, key);
00701 }

int tdb_store_bystring ( struct tdb_context tdb,
const char *  keystr,
TDB_DATA  data,
int  flags 
)

util_tdb.c287 行で定義されています。

参照先 make_tdb_data()tdbtdb_store().

参照元 cache_mangled_name()do_winbind_offline()netsamlogon_cache_store()notify_save()open_schannel_session_store()regdb_store_values()secrets_store_schannel_session_info()stat_cache_add()store_cache_seqnum()test_one().

00288 {
00289         TDB_DATA key = make_tdb_data(keystr, strlen(keystr)+1);
00290         
00291         return tdb_store(tdb, key, data, flags);
00292 }

TDB_DATA tdb_fetch_bystring ( struct tdb_context tdb,
const char *  keystr 
)

util_tdb.c299 行で定義されています。

参照先 make_tdb_data()tdbtdb_fetch().

参照元 check_cache()do_winbind_offline()fetch_cache_seqnum()get_printer_notify_pid_list()notify_load()open_schannel_session_store()regdb_fetch_keys()regdb_fetch_values()secrets_restore_schannel_session_info()set_global_winbindd_state_offline()stat_cache_lookup()test_one().

00300 {
00301         TDB_DATA key = make_tdb_data(keystr, strlen(keystr)+1);
00302 
00303         return tdb_fetch(tdb, key);
00304 }

int tdb_delete_bystring ( struct tdb_context tdb,
const char *  keystr 
)

util_tdb.c310 行で定義されています。

参照先 make_tdb_data()tdbtdb_delete().

参照元 do_winbind_online()free_service_byindex()get_printer_notify_pid_list()notify_save()regdb_store_keys()secrets_restore_schannel_session_info()set_global_winbindd_state_online()stat_cache_delete()stat_cache_lookup().

00311 {
00312         TDB_DATA key = make_tdb_data(keystr, strlen(keystr)+1);
00313 
00314         return tdb_delete(tdb, key);
00315 }

struct tdb_context* tdb_open_log ( const char *  name,
int  hash_size,
int  tdb_flags,
int  open_flags,
mode_t  mode 
)

util_tdb.c673 行で定義されています。

参照先 tdb_logging_context::log_fntdb_logging_context::log_privatetdbtdb_log()tdb_open_ex().

参照元 _reg_perfcount_get_counter_data()_reg_perfcount_init_data_block_perf()brl_init()conn_tdb_ctx()do_daemon_stack_trace()do_winbind_offline()do_winbind_online()elog_init_tdb()gencache_init()idmap_cache_init()idmap_tdb_convert()idmap_tdb_open_db()init_account_policy()init_group_mapping()init_wcache()initialise_wins()lang_tdb_init()locking_init()login_cache_init()main()message_init()net_idmap_dump()net_status_sessions()net_status_shares()net_status_shares_parseable()netsamlogon_cache_init()netsamlogon_clear_cached_user()nt_printing_init()open_schannel_session_store()pjobid_to_rap()posix_locking_init()receive_unexpected()reg_perfcount_get_base_index()reg_perfcount_get_counter_help()reg_perfcount_get_counter_names()reg_perfcount_get_perf_data_block()regdb_init()regdb_open()secrets_init()send_message()send_repl_message()send_sync_message()session_init()share_info_db_init()status_page()tdbsam_new_rid()tdbsam_open()unexpected_packet()wcache_flush_cache().

00675 {
00676         TDB_CONTEXT *tdb;
00677         struct tdb_logging_context log_ctx;
00678 
00679         if (!lp_use_mmap())
00680                 tdb_flags |= TDB_NOMMAP;
00681 
00682         log_ctx.log_fn = tdb_log;
00683         log_ctx.log_private = NULL;
00684 
00685         tdb = tdb_open_ex(name, hash_size, tdb_flags, 
00686                           open_flags, mode, &log_ctx, NULL);
00687         if (!tdb)
00688                 return NULL;
00689 
00690         return tdb;
00691 }

int tdb_unpack ( char *  buf,
int  bufsize,
const char *  fmt,
  ... 
)

util_tdb.c539 行で定義されています。

参照先 clen.

参照元 enum_group_mapping()get_a_printer_2()get_a_printer_driver_3()get_eventlog_record()get_group_map_from_gid()get_group_map_from_ntname()get_group_map_from_sid()get_ntforms()get_stored_queue_info()init_sam_from_buffer_v0()init_sam_from_buffer_v1()init_sam_from_buffer_v2()init_sam_from_buffer_v3()login_cache_read()make_way_for_eventlogs()notify2_unpack_msg()print_queue_receive()regdb_fetch_keys()regdb_unpack_values()secrets_restore_schannel_session_info()tdb_sid_unpack()tdb_trusted_dom_pass_unpack()unpack_devicemode()unpack_pjob()unpack_values()wins_record_to_name_record().

00540 {
00541         va_list ap;
00542         uint8 *bt;
00543         uint16 *w;
00544         uint32 *d;
00545         int len;
00546         int *i;
00547         void **p;
00548         char *s, **b;
00549         char c;
00550         char *buf0 = buf;
00551         const char *fmt0 = fmt;
00552         int bufsize0 = bufsize;
00553 
00554         va_start(ap, fmt);
00555         
00556         while (*fmt) {
00557                 switch ((c=*fmt++)) {
00558                 case 'b':
00559                         len = 1;
00560                         bt = va_arg(ap, uint8 *);
00561                         if (bufsize < len)
00562                                 goto no_space;
00563                         *bt = SVAL(buf, 0);
00564                         break;
00565                 case 'w':
00566                         len = 2;
00567                         w = va_arg(ap, uint16 *);
00568                         if (bufsize < len)
00569                                 goto no_space;
00570                         *w = SVAL(buf, 0);
00571                         break;
00572                 case 'd':
00573                         len = 4;
00574                         d = va_arg(ap, uint32 *);
00575                         if (bufsize < len)
00576                                 goto no_space;
00577                         *d = IVAL(buf, 0);
00578                         break;
00579                 case 'p':
00580                         len = 4;
00581                         p = va_arg(ap, void **);
00582                         if (bufsize < len)
00583                                 goto no_space;
00584                         /* 
00585                          * This isn't a real pointer - only a token (1 or 0)
00586                          * to mark the fact a pointer is present.
00587                          */
00588 
00589                         *p = (void *)(IVAL(buf, 0) ? (void *)1 : NULL);
00590                         break;
00591                 case 'P':
00592                         s = va_arg(ap,char *);
00593                         len = strlen(buf) + 1;
00594                         if (bufsize < len || len > sizeof(pstring))
00595                                 goto no_space;
00596                         memcpy(s, buf, len);
00597                         break;
00598                 case 'f':
00599                         s = va_arg(ap,char *);
00600                         len = strlen(buf) + 1;
00601                         if (bufsize < len || len > sizeof(fstring))
00602                                 goto no_space;
00603                         memcpy(s, buf, len);
00604                         break;
00605                 case 'B':
00606                         i = va_arg(ap, int *);
00607                         b = va_arg(ap, char **);
00608                         len = 4;
00609                         if (bufsize < len)
00610                                 goto no_space;
00611                         *i = IVAL(buf, 0);
00612                         if (! *i) {
00613                                 *b = NULL;
00614                                 break;
00615                         }
00616                         len += *i;
00617                         if (bufsize < len)
00618                                 goto no_space;
00619                         *b = (char *)SMB_MALLOC(*i);
00620                         if (! *b)
00621                                 goto no_space;
00622                         memcpy(*b, buf+4, *i);
00623                         break;
00624                 default:
00625                         DEBUG(0,("Unknown tdb_unpack format %c in %s\n", 
00626                                  c, fmt));
00627 
00628                         len = 0;
00629                         break;
00630                 }
00631 
00632                 buf += len;
00633                 bufsize -= len;
00634         }
00635 
00636         va_end(ap);
00637 
00638         DEBUG(18,("tdb_unpack(%s, %d) -> %d\n", 
00639                  fmt0, bufsize0, (int)PTR_DIFF(buf, buf0)));
00640 
00641         return PTR_DIFF(buf, buf0);
00642 
00643  no_space:
00644         return -1;
00645 }

size_t tdb_pack ( char *  buf,
int  bufsize,
const char *  fmt,
  ... 
)

util_tdb.c489 行で定義されています。

参照先 resulttdb_pack_va().

参照元 add_a_printer_driver_3()add_mapping_entry()flatten_message()init_buffer_from_sam_v3()login_cache_write()name_record_to_wins_record()pack_devicemode()pack_values()pjob_store()print_queue_update()regdb_pack_values()regdb_store_keys_internal()secrets_store_schannel_session_info()store_queue_struct()tdb_sid_pack()tdb_trusted_dom_pass_pack()update_a_printer_2()write_eventlog_tdb()write_ntforms().

00490 {
00491         va_list ap;
00492         size_t result;
00493 
00494         va_start(ap, fmt);
00495         result = tdb_pack_va(buf, bufsize, fmt, ap);
00496         va_end(ap);
00497         return result;
00498 }

TDB_DATA make_tdb_data ( const char *  dptr,
size_t  dsize 
)

util_tdb.c46 行で定義されています。

参照先 TDB_DATA::dptrTDB_DATA::dsize.

参照元 cache_store_response()secrets_store()string_tdb_data()tdb_delete_bystring()tdb_fetch_bystring()tdb_fetch_int32_byblob()tdb_fetch_uint32_byblob()tdb_lock_bystring()tdb_lock_bystring_with_timeout()tdb_read_lock_bystring_with_timeout()tdb_read_unlock_bystring()tdb_store_bystring()tdb_store_int32_byblob()tdb_store_uint32_byblob()tdb_unlock_bystring()wcache_cached_creds_exist()wcache_remove_oldest_cached_creds().

00047 {
00048         TDB_DATA ret;
00049         ret.dptr = CONST_DISCARD(char *, dptr);
00050         ret.dsize = dsize;
00051         return ret;
00052 }

TDB_DATA string_tdb_data ( const char *  string  ) 

util_tdb.c54 行で定義されています。

参照先 make_tdb_data().

参照元 add_to_jobs_changed()cache_cleanup_response()cache_retrieve_response()cache_store_response()get_jobs_changed_data()get_queue_status()get_stored_queue_info()netsamlogon_clear_cached_user()remove_from_jobs_changed()secrets_delete()secrets_fetch()secrets_store()store_queue_struct()wcache_remove_oldest_cached_creds().

00055 {
00056         return make_tdb_data(string, strlen(string));
00057 }

int tdb_trans_store ( struct tdb_context tdb,
TDB_DATA  key,
TDB_DATA  dbuf,
int  flag 
)

util_tdb.c777 行で定義されています。

参照先 smb_panic()tdbtdb_store()tdb_transaction_cancel()tdb_transaction_commit()tdb_transaction_start().

参照元 secrets_store().

00779 {
00780         int res;
00781 
00782         if ((res = tdb_transaction_start(tdb)) != 0) {
00783                 DEBUG(5, ("tdb_transaction_start failed\n"));
00784                 return res;
00785         }
00786 
00787         if ((res = tdb_store(tdb, key, dbuf, flag)) != 0) {
00788                 DEBUG(10, ("tdb_store failed\n"));
00789                 if (tdb_transaction_cancel(tdb) != 0) {
00790                         smb_panic("Cancelling transaction failed\n");
00791                 }
00792                 return res;
00793         }
00794 
00795         if ((res = tdb_transaction_commit(tdb)) != 0) {
00796                 DEBUG(5, ("tdb_transaction_commit failed\n"));
00797         }
00798 
00799         return res;
00800 }

int tdb_change_uint32_atomic ( TDB_CONTEXT tdb,
const char *  keystr,
uint32 *  oldval,
uint32  change_val 
)

util_tdb.c362 行で定義されています。

参照先 tdbTDB_ERR_NOEXISTtdb_error()tdb_fetch_uint32()tdb_lock_bystring()tdb_store_uint32()tdb_unlock_bystring().

参照元 idmap_tdb_allocate_id()tdbsam_new_rid().

00363 {
00364         uint32 val;
00365         BOOL ret = False;
00366 
00367         if (tdb_lock_bystring(tdb, keystr) == -1)
00368                 return False;
00369 
00370         if (!tdb_fetch_uint32(tdb, keystr, &val)) {
00371                 /* It failed */
00372                 if (tdb_error(tdb) != TDB_ERR_NOEXIST) { 
00373                         /* and not because it didn't exist */
00374                         goto err_out;
00375                 }
00376 
00377                 /* Start with 'old' value */
00378                 val = *oldval;
00379 
00380         } else {
00381                 /* it worked, set return value (oldval) to tdb data */
00382                 *oldval = val;
00383 
00384         }
00385 
00386         /* get a new value to store */
00387         val += change_val;
00388                 
00389         if (!tdb_store_uint32(tdb, keystr, val))
00390                 goto err_out;
00391 
00392         ret = True;
00393 
00394   err_out:
00395 
00396         tdb_unlock_bystring(tdb, keystr);
00397         return ret;
00398 }

int tdb_chainlock_with_timeout ( TDB_CONTEXT tdb,
TDB_DATA  key,
unsigned int  timeout 
)

util_tdb.c102 行で定義されています。

参照先 tdbtdb_chainlock_with_timeout_internal().

参照元 message_send_pid_internal()remove_from_jobs_changed()tdb_lock_bystring_with_timeout().

00103 {
00104         return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_WRLCK);
00105 }


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