您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ tdb_delete函数代码示例

51自学网 2021-06-03 08:43:03
  C++
这篇教程C++ tdb_delete函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中tdb_delete函数的典型用法代码示例。如果您正苦于以下问题:C++ tdb_delete函数的具体用法?C++ tdb_delete怎么用?C++ tdb_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了tdb_delete函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: delete_tdb

static void delete_tdb(char *keyname, size_t keylen){	TDB_DATA key;	if ((keyname == NULL) || (keylen == 0)) {		terror("need key");		return;	}	key.dptr = (unsigned char *)keyname;	key.dsize = keylen;	if (tdb_delete(tdb, key) != 0) {		terror("delete failed");	}}
开发者ID:DanilKorotenko,项目名称:samba,代码行数:16,


示例2: delete_tdb

static void delete_tdb(void){  char *k = get_token(1);  TDB_DATA key;  if (!k) {    help();    return;  }  key.dptr = k;  key.dsize = strlen(k)+1;  if (tdb_delete(tdb, key) != 0) {    terror("delete failed");  }}
开发者ID:simula67,项目名称:Thunar-1.3.0,代码行数:17,


示例3: delete_key

int delete_key(const unsigned char *key, DATABASE *db){	if( NULL == db || NULL == db->tdb)        return ERR_DB_INVALID;	TDB_DATA dkey;	dkey = string_to_tdb(key);    while( sem_wait(&db->sem) == -1 && errno == EINTR );	int err = tdb_delete(db->tdb, dkey);	free(dkey.dptr);	sem_post(&db->sem);	if (err)		return ERR_FAIL;    	return 0;}
开发者ID:songbin,项目名称:memPE,代码行数:17,


示例4: PyErr_TDB_RAISE_IF_CLOSED

static PyObject *obj_delete(PyTdbObject *self, PyObject *args){	TDB_DATA key;	PyObject *py_key;	int ret;	PyErr_TDB_RAISE_IF_CLOSED(self);	if (!PyArg_ParseTuple(args, "O", &py_key))		return NULL;	key = PyString_AsTDB_DATA(py_key);	if (!key.dptr)		return NULL;	ret = tdb_delete(self->ctx, key);	PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);	Py_RETURN_NONE;}
开发者ID:AIdrifter,项目名称:samba,代码行数:17,


示例5: gencache_del

BOOL gencache_del(const char *keystr){	int ret;	TDB_DATA keybuf;		/* fail completely if get null pointers passed */	SMB_ASSERT(keystr);	if (!gencache_init()) return False;			keybuf.dptr = strdup(keystr);	keybuf.dsize = strlen(keystr)+1;	DEBUG(10, ("Deleting cache entry (key = %s)/n", keystr));	ret = tdb_delete(cache, keybuf);		SAFE_FREE(keybuf.dptr);	return ret == 0;}
开发者ID:Nymphetaminer,项目名称:dsl-n55u,代码行数:18,


示例6: db_hash_delete

int db_hash_delete(struct db_hash_context *dh, uint8_t *keybuf, size_t keylen){	TDB_DATA key;	int ret;	key.dptr = keybuf;	key.dsize = keylen;	if (dh == NULL) {		return EINVAL;	}	ret = tdb_delete(dh->db, key);	if (ret != 0) {		ret = db_hash_map_tdb_error(dh);	}	return ret;}
开发者ID:Alexander--,项目名称:samba,代码行数:18,


示例7: delete_tdb

static void delete_tdb(char *keyname, size_t keylen){	TDB_DATA key;	enum TDB_ERROR ecode;	if ((keyname == NULL) || (keylen == 0)) {		terror(TDB_SUCCESS, "need key");		return;	}	key.dptr = (unsigned char *)keyname;	key.dsize = keylen;	ecode = tdb_delete(tdb, key);	if (ecode) {		terror(ecode, "delete failed");	}}
开发者ID:burito,项目名称:ccan,代码行数:18,


示例8: config_set

/*    set a configration variable.    Returns 0 on success */static int config_set(const char *name, char *value){	TDB_DATA data;	TDB_DATA key;	int ret;	key.dptr = name;	key.dsize = strlen(name)+1;		if (strcmp(value, "-") == 0) {		return tdb_delete(config_db, key);	}	data.dptr = value;	data.dsize = strlen(value)+1;  	ret = tdb_store(config_db, key, data, TDB_REPLACE);	return ret;}
开发者ID:SKAcz,项目名称:bics-current,代码行数:23,


示例9: yield_connection

BOOL yield_connection(connection_struct *conn, const char *name){	struct connections_key key;	TDB_DATA kbuf;	if (!tdb)		return False;	DEBUG(3,("Yielding connection to %s/n",name));	make_conn_key(conn, name, &kbuf, &key);	if (tdb_delete(tdb, kbuf) != 0) {		int dbg_lvl = (!conn && (tdb_error(tdb) == TDB_ERR_NOEXIST)) ? 3 : 0;		DEBUG(dbg_lvl,("yield_connection: tdb_delete for name %s failed with error %s./n",			name, tdb_errorstr(tdb) ));		return (False);	}	return(True);}
开发者ID:niubl,项目名称:camera_project,代码行数:21,


示例10: indexes

/*  delete a record from the database, not updating indexes (used for deleting  index records)*/int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn){	void *data = ldb_module_get_private(module);	struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);	TDB_DATA tdb_key;	int ret;	tdb_key = ltdb_key(module, dn);	if (!tdb_key.dptr) {		return LDB_ERR_OTHER;	}	ret = tdb_delete(ltdb->tdb, tdb_key);	talloc_free(tdb_key.dptr);	if (ret != 0) {		ret = ltdb_err_map(tdb_error(ltdb->tdb));	}	return ret;}
开发者ID:DanilKorotenko,项目名称:samba,代码行数:25,


示例11: modify_traverse

static int modify_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,			   void *state){#if CULL_PROB	if (random() % CULL_PROB == 0) {		tdb_delete(tdb, key);	}#endif#if TRAVERSE_MOD_PROB	if (random() % TRAVERSE_MOD_PROB == 0) {		addrec_db();	}#endif#if TRAVERSE_ABORT_PROB	if (random() % TRAVERSE_ABORT_PROB == 0)		return 1;#endif	return 0;}
开发者ID:burito,项目名称:ccan,代码行数:22,


示例12: session_yield

/* called when a session is destroyed */void session_yield(user_struct *vuser){	TDB_DATA dbuf;	struct sessionid sessionid;	struct in_addr *client_ip;	TDB_DATA key;	if (!tdb) return;	if (!vuser->session_keystr) {		return;	}	key.dptr = vuser->session_keystr;	key.dsize = strlen(vuser->session_keystr)+1;	dbuf = tdb_fetch(tdb, key);	if (dbuf.dsize != sizeof(sessionid))		return;	memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));	client_ip = interpret_addr2(sessionid.ip_addr);	SAFE_FREE(dbuf.dptr);	if (lp_utmp()) {		sys_utmp_yield(sessionid.username, sessionid.hostname, 			       client_ip,			       sessionid.id_str, sessionid.id_num);	}	smb_pam_close_session(sessionid.username, sessionid.id_str, sessionid.hostname);	tdb_delete(tdb, key);}
开发者ID:cmtsij,项目名称:Vizio_XWR100_GPL,代码行数:38,


示例13: do_delete_fn

static int do_delete_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf,                     void *state){    return tdb_delete(the_tdb, key);}
开发者ID:DanilKorotenko,项目名称:samba,代码行数:5,


示例14: ctdb_ltdb_store_server

//.........这里部分代码省略.........store:	/*	 * The VACUUM_MIGRATED flag is only set temporarily for	 * the above logic when the record was retrieved by a	 * VACUUM_MIGRATE call and should not be stored in the	 * database.	 *	 * The VACUUM_MIGRATE call is triggered by a vacuum fetch,	 * and there are two cases in which the corresponding record	 * is stored in the local database:	 * 1. The record has been migrated with data in the past	 *    (the MIGRATED_WITH_DATA record flag is set).	 * 2. The record has been filled with data again since it	 *    had been submitted in the VACUUM_FETCH message to the	 *    lmaster.	 * For such records it is important to not store the	 * VACUUM_MIGRATED flag in the database.	 */	header->flags &= ~CTDB_REC_FLAG_VACUUM_MIGRATED;	/*	 * Similarly, clear the AUTOMATIC flag which should not enter	 * the local database copy since this would require client	 * modifications to clear the flag when the client stores	 * the record.	 */	header->flags &= ~CTDB_REC_FLAG_AUTOMATIC;	rec.dsize = sizeof(*header) + data.dsize;	rec.dptr = talloc_size(ctdb, rec.dsize);	CTDB_NO_MEMORY(ctdb, rec.dptr);	memcpy(rec.dptr, header, sizeof(*header));	memcpy(rec.dptr + sizeof(*header), data.dptr, data.dsize);	/* Databases with seqnum updates enabled only get their seqnum	   changes when/if we modify the data */	if (ctdb_db->seqnum_update != NULL) {		TDB_DATA old;		old = tdb_fetch(ctdb_db->ltdb->tdb, key);		if ( (old.dsize == rec.dsize)		&& !memcmp(old.dptr+sizeof(struct ctdb_ltdb_header),			  rec.dptr+sizeof(struct ctdb_ltdb_header),			  rec.dsize-sizeof(struct ctdb_ltdb_header)) ) {			tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM);			seqnum_suppressed = true;		}		if (old.dptr) free(old.dptr);	}	DEBUG(DEBUG_DEBUG, (__location__ " db[%s]: %s record: hash[0x%08x]/n",			    ctdb_db->db_name,			    keep?"storing":"deleting",			    ctdb_hash(&key)));	if (keep) {		ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, TDB_REPLACE);	} else {		ret = tdb_delete(ctdb_db->ltdb->tdb, key);	}	if (ret != 0) {		int lvl = DEBUG_ERR;		if (keep == false &&		    tdb_error(ctdb_db->ltdb->tdb) == TDB_ERR_NOEXIST)		{			lvl = DEBUG_DEBUG;		}		DEBUG(lvl, (__location__ " db[%s]: Failed to %s record: "			    "%d - %s/n",			    ctdb_db->db_name,			    keep?"store":"delete", ret,			    tdb_errorstr(ctdb_db->ltdb->tdb)));		schedule_for_deletion = false;		remove_from_delete_queue = false;	}	if (seqnum_suppressed) {		tdb_add_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM);	}	talloc_free(rec.dptr);	if (schedule_for_deletion) {		int ret2;		ret2 = ctdb_local_schedule_for_deletion(ctdb_db, header, key);		if (ret2 != 0) {			DEBUG(DEBUG_ERR, (__location__ " ctdb_local_schedule_for_deletion failed./n"));		}	}	if (remove_from_delete_queue) {		ctdb_local_remove_from_delete_queue(ctdb_db, header, key);	}	return ret;}
开发者ID:hef,项目名称:samba,代码行数:101,


示例15: main

int main(int argc, char *argv[]){	unsigned int i;	struct tdb_context *tdb;	int flags[] = { TDB_DEFAULT, TDB_NOMMAP,			TDB_CONVERT,			TDB_NOMMAP|TDB_CONVERT };	if (sizeof(off_t) <= 4) {		plan_tests(1);		pass("No 64 bit off_t");		return exit_status();	}	plan_tests(sizeof(flags) / sizeof(flags[0]) * 14);	for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {		off_t old_size;		TDB_DATA k, d;		struct hash_info h;		struct tdb_used_record rec;		tdb_off_t off;		tdb = tdb_open("run-64-bit-tdb.tdb", flags[i],			       O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);		ok1(tdb);		if (!tdb)			continue;		old_size = tdb->file->map_size;		/* This makes a sparse file */		ok1(ftruncate(tdb->file->fd, 0xFFFFFFF0) == 0);		ok1(add_free_record(tdb, old_size, 0xFFFFFFF0 - old_size,				    TDB_LOCK_WAIT, false) == TDB_SUCCESS);		/* Now add a little record past the 4G barrier. */		ok1(tdb_expand_file(tdb, 100) == TDB_SUCCESS);		ok1(add_free_record(tdb, 0xFFFFFFF0, 100, TDB_LOCK_WAIT, false)		    == TDB_SUCCESS);		ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);		/* Test allocation path. */		k = tdb_mkdata("key", 4);		d = tdb_mkdata("data", 5);		ok1(tdb_store(tdb, k, d, TDB_INSERT) == 0);		ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);		/* Make sure it put it at end as we expected. */		off = find_and_lock(tdb, k, F_RDLCK, &h, &rec, NULL);		ok1(off >= 0xFFFFFFF0);		tdb_unlock_hashes(tdb, h.hlock_start, h.hlock_range, F_RDLCK);		ok1(tdb_fetch(tdb, k, &d) == 0);		ok1(d.dsize == 5);		ok1(strcmp((char *)d.dptr, "data") == 0);		free(d.dptr);		ok1(tdb_delete(tdb, k) == 0);		ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);		tdb_close(tdb);	}	/* We might get messages about mmap failing, so don't test	 * tap_log_messages */	return exit_status();}
开发者ID:atlant2011,项目名称:samba,代码行数:68,


示例16: brl_close

void brl_close(SMB_DEV_T dev, SMB_INO_T ino, pid_t pid, int tid, int fnum){	TDB_DATA kbuf, dbuf;	int count, i, j, dcount=0;	struct lock_struct *locks;	kbuf = locking_key(dev,ino);	dbuf.dptr = NULL;	tdb_chainlock(tdb, kbuf);	dbuf = tdb_fetch(tdb, kbuf);	if (!dbuf.dptr) goto fail;	/* there are existing locks - remove any for this fnum */	locks = (struct lock_struct *)dbuf.dptr;	count = dbuf.dsize / sizeof(*locks);	for (i=0; i<count; i++) {		struct lock_struct *lock = &locks[i];		if (lock->context.tid == tid &&		    lock->context.pid == pid &&		    lock->fnum == fnum) {			/* Send unlock messages to any pending waiters that overlap. */			for (j=0; j<count; j++) {				struct lock_struct *pend_lock = &locks[j];				/* Ignore our own or non-pending locks. */				if (pend_lock->lock_type != PENDING_LOCK)					continue;				if (pend_lock->context.tid == tid &&				    pend_lock->context.pid == pid &&				    pend_lock->fnum == fnum)					continue;				/* We could send specific lock info here... */				if (brl_pending_overlap(lock, pend_lock))					message_send_pid(pend_lock->context.pid,							MSG_SMB_UNLOCK,							NULL, 0, True);			}			/* found it - delete it */			if (count > 1 && i < count-1) {				memmove(&locks[i], &locks[i+1], 					sizeof(*locks)*((count-1) - i));			}			count--;			i--;			dcount++;		}	}	if (count == 0) {		tdb_delete(tdb, kbuf);	} else if (count < (dbuf.dsize / sizeof(*locks))) {		dbuf.dsize -= dcount * sizeof(*locks);		tdb_store(tdb, kbuf, dbuf, TDB_REPLACE);	}	/* we didn't find it */ fail:	SAFE_FREE(dbuf.dptr);	tdb_chainunlock(tdb, kbuf);}
开发者ID:jophxy,项目名称:samba,代码行数:69,


示例17: brl_unlock

BOOL brl_unlock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,		uint16 smbpid, pid_t pid, uint16 tid,		br_off start, br_off size,		BOOL remove_pending_locks_only){	TDB_DATA kbuf, dbuf;	int count, i, j;	struct lock_struct *locks;	struct lock_context context;	kbuf = locking_key(dev,ino);	dbuf.dptr = NULL;	tdb_chainlock(tdb, kbuf);	dbuf = tdb_fetch(tdb, kbuf);	if (!dbuf.dptr) {		DEBUG(10,("brl_unlock: tdb_fetch failed !/n"));		goto fail;	}	context.smbpid = smbpid;	context.pid = pid;	context.tid = tid;	/* there are existing locks - find a match */	locks = (struct lock_struct *)dbuf.dptr;	count = dbuf.dsize / sizeof(*locks);#if ZERO_ZERO	for (i=0; i<count; i++) {		struct lock_struct *lock = &locks[i];		if (lock->lock_type == WRITE_LOCK &&		    brl_same_context(&lock->context, &context) &&		    lock->fnum == fnum &&		    lock->start == start &&		    lock->size == size) {			/* found it - delete it */			if (count == 1) {				tdb_delete(tdb, kbuf);			} else {				if (i < count-1) {					memmove(&locks[i], &locks[i+1], 						sizeof(*locks)*((count-1) - i));				}				dbuf.dsize -= sizeof(*locks);				tdb_store(tdb, kbuf, dbuf, TDB_REPLACE);			}			SAFE_FREE(dbuf.dptr);			tdb_chainunlock(tdb, kbuf);			return True;		}	}#endif	locks = (struct lock_struct *)dbuf.dptr;	count = dbuf.dsize / sizeof(*locks);	for (i=0; i<count; i++) {		struct lock_struct *lock = &locks[i];		if (brl_same_context(&lock->context, &context) &&				lock->fnum == fnum &&				lock->start == start &&				lock->size == size) {			if (remove_pending_locks_only && lock->lock_type != PENDING_LOCK)				continue;			if (lock->lock_type != PENDING_LOCK) {				/* Send unlock messages to any pending waiters that overlap. */				for (j=0; j<count; j++) {					struct lock_struct *pend_lock = &locks[j];					/* Ignore non-pending locks. */					if (pend_lock->lock_type != PENDING_LOCK)						continue;					/* We could send specific lock info here... */					if (brl_pending_overlap(lock, pend_lock)) {						DEBUG(10,("brl_unlock: sending unlock message to pid %u/n",									(unsigned int)pend_lock->context.pid ));						message_send_pid(pend_lock->context.pid,								MSG_SMB_UNLOCK,								NULL, 0, True);					}				}			}			/* found it - delete it */			if (count == 1) {				tdb_delete(tdb, kbuf);			} else {				if (i < count-1) {					memmove(&locks[i], &locks[i+1], 						sizeof(*locks)*((count-1) - i));				}//.........这里部分代码省略.........
开发者ID:jophxy,项目名称:samba,代码行数:101,


示例18: esp_input

/* * ESP input processing, called (eventually) through the protocol switch. */intesp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff){	struct auth_hash *esph = (struct auth_hash *) tdb->tdb_authalgxform;	struct enc_xform *espx = (struct enc_xform *) tdb->tdb_encalgxform;	struct tdb_crypto *tc;	int plen, alen, hlen;	struct m_tag *mtag;	u_int32_t btsx;	struct cryptodesc *crde = NULL, *crda = NULL;	struct cryptop *crp;	/* Determine the ESP header length */	if (tdb->tdb_flags & TDBF_NOREPLAY)		hlen = sizeof(u_int32_t) + tdb->tdb_ivlen; /* "old" ESP */	else		hlen = 2 * sizeof(u_int32_t) + tdb->tdb_ivlen; /* "new" ESP */	if (esph)		alen = AH_HMAC_HASHLEN;	else		alen = 0;	plen = m->m_pkthdr.len - (skip + hlen + alen);	if (plen <= 0) {		DPRINTF(("esp_input: invalid payload length/n"));		espstat.esps_badilen++;		m_freem(m);		return EINVAL;	}	if (espx) {		/*		 * Verify payload length is multiple of encryption algorithm		 * block size.		 */		if (plen & (espx->blocksize - 1)) {			DPRINTF(("esp_input(): payload of %d octets not a multiple of %d octets, SA %s/%08x/n", plen, espx->blocksize, ipsp_address(tdb->tdb_dst), ntohl(tdb->tdb_spi)));			espstat.esps_badilen++;			m_freem(m);			return EINVAL;		}	}	/* Replay window checking, if appropriate -- no value commitment. */	if ((tdb->tdb_wnd > 0) && (!(tdb->tdb_flags & TDBF_NOREPLAY))) {		m_copydata(m, skip + sizeof(u_int32_t), sizeof(u_int32_t),		    (unsigned char *) &btsx);		btsx = ntohl(btsx);		switch (checkreplaywindow32(btsx, 0, &(tdb->tdb_rpl),		    tdb->tdb_wnd, &(tdb->tdb_bitmap), 0)) {		case 0: /* All's well */			break;		case 1:			m_freem(m);			DPRINTF(("esp_input(): replay counter wrapped for SA %s/%08x/n", ipsp_address(tdb->tdb_dst), ntohl(tdb->tdb_spi)));			espstat.esps_wrap++;			return EACCES;		case 2:		case 3:			DPRINTF(("esp_input(): duplicate packet received in SA %s/%08x/n", ipsp_address(tdb->tdb_dst), ntohl(tdb->tdb_spi)));			m_freem(m);			return EACCES;		default:			m_freem(m);			DPRINTF(("esp_input(): bogus value from checkreplaywindow32() in SA %s/%08x/n", ipsp_address(tdb->tdb_dst), ntohl(tdb->tdb_spi)));			espstat.esps_replay++;			return EACCES;		}	}	/* Update the counters */	tdb->tdb_cur_bytes += m->m_pkthdr.len - skip - hlen - alen;	espstat.esps_ibytes += m->m_pkthdr.len - skip - hlen - alen;	/* Hard expiration */	if ((tdb->tdb_flags & TDBF_BYTES) &&	    (tdb->tdb_cur_bytes >= tdb->tdb_exp_bytes))	{		pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_HARD);		tdb_delete(tdb);		m_freem(m);		return ENXIO;	}	/* Notify on soft expiration */	if ((tdb->tdb_flags & TDBF_SOFT_BYTES) &&	    (tdb->tdb_cur_bytes >= tdb->tdb_soft_bytes)) {		pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_SOFT);		tdb->tdb_flags &= ~TDBF_SOFT_BYTES;       /* Turn off checking */	}#ifdef notyet//.........这里部分代码省略.........
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:101,


示例19: main

int main(int argc, char *argv[]){	unsigned int i, j;	int num;	struct trav_data td;	TDB_DATA k;	struct tdb_context *tdb;	union tdb_attribute seed_attr;	enum TDB_ERROR ecode;	int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP,			TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT,			TDB_NOMMAP|TDB_CONVERT };	seed_attr.base.attr = TDB_ATTRIBUTE_SEED;	seed_attr.base.next = &tap_log_attr;	seed_attr.seed.seed = 6334326220117065685ULL;	plan_tests(sizeof(flags) / sizeof(flags[0])		   * (NUM_RECORDS*6 + (NUM_RECORDS-1)*3 + 22) + 1);	for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {		tdb = tdb_open("run-traverse.tdb", flags[i],			       O_RDWR|O_CREAT|O_TRUNC, 0600, &seed_attr);		ok1(tdb);		if (!tdb)			continue;		ok1(tdb_firstkey(tdb, &k) == TDB_ERR_NOEXIST);		/* One entry... */		k.dptr = (unsigned char *)&num;		k.dsize = sizeof(num);		num = 0;		ok1(tdb_store(tdb, k, k, TDB_INSERT) == 0);		ok1(tdb_firstkey(tdb, &k) == TDB_SUCCESS);		ok1(k.dsize == sizeof(num));		ok1(memcmp(k.dptr, &num, sizeof(num)) == 0);		ok1(tdb_nextkey(tdb, &k) == TDB_ERR_NOEXIST);		/* Two entries. */		k.dptr = (unsigned char *)&num;		k.dsize = sizeof(num);		num = 1;		ok1(tdb_store(tdb, k, k, TDB_INSERT) == 0);		ok1(tdb_firstkey(tdb, &k) == TDB_SUCCESS);		ok1(k.dsize == sizeof(num));		memcpy(&num, k.dptr, sizeof(num));		ok1(num == 0 || num == 1);		ok1(tdb_nextkey(tdb, &k) == TDB_SUCCESS);		ok1(k.dsize == sizeof(j));		memcpy(&j, k.dptr, sizeof(j));		ok1(j == 0 || j == 1);		ok1(j != num);		ok1(tdb_nextkey(tdb, &k) == TDB_ERR_NOEXIST);		/* Clean up. */		k.dptr = (unsigned char *)&num;		k.dsize = sizeof(num);		num = 0;		ok1(tdb_delete(tdb, k) == 0);		num = 1;		ok1(tdb_delete(tdb, k) == 0);		/* Now lots of records. */		ok1(store_records(tdb));		td.calls = 0;		num = tdb_traverse(tdb, trav, &td);		ok1(num == NUM_RECORDS);		ok1(td.calls == NUM_RECORDS);		/* Simple loop should match tdb_traverse */		for (j = 0, ecode = tdb_firstkey(tdb, &k); j < td.calls; j++) {			int val;			ok1(ecode == TDB_SUCCESS);			ok1(k.dsize == sizeof(val));			memcpy(&val, k.dptr, k.dsize);			ok1(td.records[j] == val);			ecode = tdb_nextkey(tdb, &k);		}		/* But arbitrary orderings should work too. */		for (j = td.calls-1; j > 0; j--) {			k.dptr = (unsigned char *)&td.records[j-1];			k.dsize = sizeof(td.records[j-1]);			k = dup_key(k);			ok1(tdb_nextkey(tdb, &k) == TDB_SUCCESS);			ok1(k.dsize == sizeof(td.records[j]));			ok1(memcmp(k.dptr, &td.records[j], k.dsize) == 0);			free(k.dptr);		}		/* Even delete should work. */		for (j = 0, ecode = tdb_firstkey(tdb, &k);		     ecode != TDB_ERR_NOEXIST;		     j++) {			ok1(ecode == TDB_SUCCESS);			ok1(k.dsize == 4);			ok1(tdb_delete(tdb, k) == 0);//.........这里部分代码省略.........
开发者ID:Arkhont,项目名称:samba,代码行数:101,


示例20: tdb_traverse_delete_fn

int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf,                     void *state){    return tdb_delete(the_tdb, key);}
开发者ID:gojdic,项目名称:samba,代码行数:5,


示例21: tdb_delete_bystring

int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr){	TDB_DATA key = string_term_tdb_data(keystr);	return tdb_delete(tdb, key);}
开发者ID:gojdic,项目名称:samba,代码行数:6,


示例22: main

//.........这里部分代码省略.........	if (transaction && (ecode = tdb_transaction_start(tdb)))		errx(1, "starting transaction: %s", tdb_errorstr(ecode));	i = 0;	gettimeofday(&start, NULL);	if (tdb_traverse(tdb, count_record, &i) != num)		errx(1, "Traverse returned wrong number of records");	if (i != (num - 1) * (num / 2))		errx(1, "Traverse tallied to %u", i);	gettimeofday(&stop, NULL);	if (transaction && (ecode = tdb_transaction_commit(tdb)))		errx(1, "committing transaction: %s", tdb_errorstr(ecode));	printf(" %zu ns (%zu bytes)/n",	       normalize(&start, &stop, num), file_size());	if (tdb_check(tdb, NULL, NULL))		errx(1, "tdb_check failed!");	if (summary) {		char *sumstr = NULL;		tdb_summary(tdb, TDB_SUMMARY_HISTOGRAMS, &sumstr);		printf("%s/n", sumstr);		free(sumstr);	}	if (do_stats)		dump_and_clear_stats(&tdb, flags, &log);	if (++stage == stopat)		exit(0);	/* Delete 1000 records (not in order). */	printf("Deleting %u records: ", num); fflush(stdout);	if (transaction && (ecode = tdb_transaction_start(tdb)))		errx(1, "starting transaction: %s", tdb_errorstr(ecode));	gettimeofday(&start, NULL);	for (j = 0; j < num; j++) {		i = (j + 100003) % num;		if ((ecode = tdb_delete(tdb, key)) != TDB_SUCCESS)			errx(1, "Deleting key %u in tdb: %s",			     i, tdb_errorstr(ecode));	}	gettimeofday(&stop, NULL);	if (transaction && (ecode = tdb_transaction_commit(tdb)))		errx(1, "committing transaction: %s", tdb_errorstr(ecode));	printf(" %zu ns (%zu bytes)/n",	       normalize(&start, &stop, num), file_size());	if (tdb_check(tdb, NULL, NULL))		errx(1, "tdb_check failed!");	if (summary) {		char *sumstr = NULL;		tdb_summary(tdb, TDB_SUMMARY_HISTOGRAMS, &sumstr);		printf("%s/n", sumstr);		free(sumstr);	}	if (do_stats)		dump_and_clear_stats(&tdb, flags, &log);	if (++stage == stopat)		exit(0);	/* Re-add 1000 records (not in order). */	printf("Re-adding %u records: ", num); fflush(stdout);	if (transaction && (ecode = tdb_transaction_start(tdb)))		errx(1, "starting transaction: %s", tdb_errorstr(ecode));	gettimeofday(&start, NULL);	for (j = 0; j < num; j++) {		i = (j + 100003) % num;		if ((ecode = tdb_store(tdb, key, data, TDB_INSERT)) != 0)			errx(1, "Inserting key %u in tdb: %s",			     i, tdb_errorstr(ecode));	}
开发者ID:atlant2011,项目名称:samba,代码行数:67,


示例23: main

int main(int argc, char *argv[]){	struct tdb_context *tdb;	TDB_DATA key, orig_data, data;	uint32_t hashval;	tdb_off_t rec_ptr;	struct tdb_record rec;	int ret;	plan_tests(24);	tdb = tdb_open_ex("run-36-file.tdb", 1024, TDB_CLEAR_IF_FIRST,			  O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);	ok1(tdb);	tdb->methods = &large_io_methods;	key.dsize = strlen("hi");	key.dptr = (void *)"hi";	orig_data.dsize = strlen("world");	orig_data.dptr = (void *)"world";	/* Enlarge the file (internally multiplies by 2). */	ret = tdb_expand(tdb, 1500000000);#ifdef HAVE_INCOHERENT_MMAP	/* This can fail due to mmap failure on 32 bit systems. */	if (ret == -1) {		/* These should now fail. */		ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == -1);		data = tdb_fetch(tdb, key);		ok1(data.dptr == NULL);		ok1(tdb_traverse(tdb, test_traverse, &orig_data) == -1);		ok1(tdb_delete(tdb, key) == -1);		ok1(tdb_traverse(tdb, test_traverse, NULL) == -1);		/* Skip the rest... */		for (ret = 0; ret < 24 - 6; ret++)			ok1(1);		tdb_close(tdb);		return exit_status();	}#endif	ok1(ret == 0);	/* Put an entry in, and check it. */	ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == 0);	data = tdb_fetch(tdb, key);	ok1(data.dsize == strlen("world"));	ok1(memcmp(data.dptr, "world", strlen("world")) == 0);	free(data.dptr);	/* That currently fills at the end, make sure that's true. */	hashval = tdb->hash_fn(&key);	rec_ptr = tdb_find_lock_hash(tdb, key, hashval, F_RDLCK, &rec);	ok1(rec_ptr);	ok1(rec_ptr > 2U*1024*1024*1024);	tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK);	/* Traverse must work. */	ok1(tdb_traverse(tdb, test_traverse, &orig_data) == 1);	/* Delete should work. */	ok1(tdb_delete(tdb, key) == 0);	ok1(tdb_traverse(tdb, test_traverse, NULL) == 0);	/* Transactions should work. */	ok1(tdb_transaction_start(tdb) == 0);	ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == 0);	data = tdb_fetch(tdb, key);	ok1(data.dsize == strlen("world"));	ok1(memcmp(data.dptr, "world", strlen("world")) == 0);	free(data.dptr);	ok1(tdb_transaction_commit(tdb) == 0);	ok1(tdb_traverse(tdb, test_traverse, &orig_data) == 1);	tdb_close(tdb);	return exit_status();}
开发者ID:AIdrifter,项目名称:samba,代码行数:80,


示例24: esp_output

//.........这里部分代码省略.........#endif /* INET */#ifdef INET6	case AF_INET6:		/* Check for IPv6 maximum packet size violations. */		if (skip + hlen + rlen + padding + alen > IPV6_MAXPACKET) {			DPRINTF(("esp_output(): packet in SA %s/%08x got too "			    "big/n", ipsp_address(tdb->tdb_dst),			    ntohl(tdb->tdb_spi)));			m_freem(m);			espstat.esps_toobig++;			return EMSGSIZE;		}		break;#endif /* INET6 */	default:		DPRINTF(("esp_output(): unknown/unsupported protocol "		    "family %d, SA %s/%08x/n", tdb->tdb_dst.sa.sa_family		    , ipsp_address(tdb->tdb_dst), ntohl(tdb->tdb_spi)));		m_freem(m);		espstat.esps_nopf++;		return EPFNOSUPPORT;	}	/* Update the counters. */	tdb->tdb_cur_bytes += m->m_pkthdr.len - skip;	espstat.esps_obytes += m->m_pkthdr.len - skip;	/* Hard byte expiration. */	if (tdb->tdb_flags & TDBF_BYTES &&	    tdb->tdb_cur_bytes >= tdb->tdb_exp_bytes) {		pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_HARD);		tdb_delete(tdb);		m_freem(m);		return EINVAL;	}	/* Soft byte expiration. */	if (tdb->tdb_flags & TDBF_SOFT_BYTES &&	    tdb->tdb_cur_bytes >= tdb->tdb_soft_bytes) {		pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_SOFT);		tdb->tdb_flags &= ~TDBF_SOFT_BYTES;    /* Turn off checking. */	}	/*	 * Loop through mbuf chain; if we find a readonly mbuf,	 * replace the rest of the chain.	 */	mo = NULL;	mi = m;	while (mi != NULL && !M_READONLY(mi)) {		mo = mi;		mi = mi->m_next;	}	if (mi != NULL)	{		/* Replace the rest of the mbuf chain. */		struct mbuf *n = m_copym2(mi, 0, M_COPYALL, M_DONTWAIT);		if (n == NULL) {			DPRINTF(("esp_output(): bad mbuf chain, SA %s/%08x/n",			    ipsp_address(tdb->tdb_dst), ntohl(tdb->tdb_spi)));			espstat.esps_hdrops++;			m_freem(m);			return ENOBUFS;
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:67,


示例25: make_way_for_eventlogs

static bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32_t needed,				    bool whack_by_date ){	int32_t start_record, i, new_start;	int32_t end_record;	int32_t reclen, tresv1, trecnum, timegen, timewr;	int nbytes, len, Retention, MaxSize;	TDB_DATA key, ret;	time_t current_time, exp_time;	/* discard some eventlogs */	/* read eventlogs from oldest_entry -- there can't be any discontinuity in recnos,	   although records not necessarily guaranteed to have successive times */	/* */	/* lock */	tdb_lock_bystring_with_timeout( the_tdb, EVT_NEXT_RECORD, 1 );	/* read */	end_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD );	start_record = tdb_fetch_int32( the_tdb, EVT_OLDEST_ENTRY );	Retention = tdb_fetch_int32( the_tdb, EVT_RETENTION );	MaxSize = tdb_fetch_int32( the_tdb, EVT_MAXSIZE );	time( &current_time );	/* calculate ... */	exp_time = current_time - Retention;	/* discard older than exp_time */	/* todo - check for sanity in next_record */	nbytes = 0;	DEBUG( 3,	       ( "MaxSize [%d] Retention [%d] Current Time [%u]  exp_time [%u]/n",		 MaxSize, Retention, (unsigned int)current_time, (unsigned int)exp_time ) );	DEBUG( 3,	       ( "Start Record [%u] End Record [%u]/n",		(unsigned int)start_record,		(unsigned int)end_record ));	for ( i = start_record; i < end_record; i++ ) {		/* read a record, add the amt to nbytes */		key.dsize = sizeof(int32_t);		key.dptr = (unsigned char *)&i;		ret = tdb_fetch( the_tdb, key );		if ( ret.dsize == 0 ) {			DEBUG( 8,			       ( "Can't find a record for the key, record [%d]/n",				 i ) );			tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD );			return False;		}		nbytes += ret.dsize;	/* note this includes overhead */		len = tdb_unpack( ret.dptr, ret.dsize, "ddddd", &reclen,				  &tresv1, &trecnum, &timegen, &timewr );		if (len == -1) {			DEBUG( 10,("make_way_for_eventlogs: tdb_unpack failed./n"));			tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD );			SAFE_FREE( ret.dptr );			return False;		}		DEBUG( 8,		       ( "read record %u, record size is [%d], total so far [%d]/n",			 (unsigned int)i, reclen, nbytes ) );		SAFE_FREE( ret.dptr );		/* note that other servers may just stop writing records when the size limit		   is reached, and there are no records older than 'retention'. This doesn't		   like a very useful thing to do, so instead we whack (as in sleeps with the		   fishes) just enough records to fit the what we need.  This behavior could		   be changed to 'match', if the need arises. */		if ( !whack_by_date && ( nbytes >= needed ) )			break;	/* done */		if ( whack_by_date && ( timegen >= exp_time ) )			break;	/* done */	}	DEBUG( 3,	       ( "nbytes [%d] needed [%d] start_record is [%u], should be set to [%u]/n",		 nbytes, needed, (unsigned int)start_record, (unsigned int)i ) );	/* todo - remove eventlog entries here and set starting record to start_record... */	new_start = i;	if ( start_record != new_start ) {		for ( i = start_record; i < new_start; i++ ) {			key.dsize = sizeof(int32_t);			key.dptr = (unsigned char *)&i;			tdb_delete( the_tdb, key );		}		tdb_store_int32( the_tdb, EVT_OLDEST_ENTRY, new_start );	}	tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD );	return True;}
开发者ID:gojdic,项目名称:samba,代码行数:98,


示例26: namecache_fetch

BOOL namecache_fetch(const char *name, int name_type, struct in_addr **ip_list,		     int *num_names){	TDB_DATA key, value;	struct nc_value *data = NULL;	time_t now;	int i;	*ip_list = NULL;	*num_names = 0;	if (!enable_namecache)		return False;	/* Read value */	key = namecache_key(name, name_type);	value = tdb_fetch(namecache_tdb, key);		if (!value.dptr) {		DEBUG(5, ("namecache_fetch: %s#%02x not found/n",			  name, name_type));		goto done;	}	data = (struct nc_value *)value.dptr;	/* Check expiry time */	now = time(NULL);	if (now > data->expiry) {		DEBUG(5, ("namecache_fetch: entry for %s#%02x expired/n",			  name, name_type));		tdb_delete(namecache_tdb, key);		SAFE_FREE(value.dptr);		value = tdb_null;		goto done;	}	if ((data->expiry - now) > lp_name_cache_timeout()) {		/* Someone may have changed the system time on us */		DEBUG(5, ("namecache_fetch: entry for %s#%02x has bad expiry/n",			  name, name_type));		tdb_delete(namecache_tdb, key);		SAFE_FREE(value.dptr);		value = tdb_null;		goto done;	}	/* Extract and return namelist */	DEBUG(5, ("namecache_fetch: returning %d address%s for %s#%02x: ",		  data->count, data->count == 1 ? "" : "es", name, name_type));	if (data->count) {		*ip_list = (struct in_addr *)malloc(			sizeof(struct in_addr) * data->count);				memcpy(*ip_list, data->ip_list, sizeof(struct in_addr) * data->count);				*num_names = data->count;				for (i = 0; i < *num_names; i++)			DEBUGADD(5, ("%s%s", inet_ntoa((*ip_list)[i]),				     i == (*num_names - 1) ? "" : ", "));	}	DEBUGADD(5, ("/n"));done:	SAFE_FREE(key.dptr);	SAFE_FREE(value.dptr);	return value.dsize > 0;}
开发者ID:livebox,项目名称:livebox2,代码行数:88,


示例27: do_delete_fn

static int do_delete_fn(TDB_CONTEXT *context, TDB_DATA key, TDB_DATA dbuf,                     void *state){    return tdb_delete(context, key);}
开发者ID:simula67,项目名称:Thunar-1.3.0,代码行数:5,



注:本文中的tdb_delete函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ tdb_error函数代码示例
C++ tdb_close函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。