Licensing Information
Open Source Used In Cisco FXOS 1.1(4) 974
goto fail;
}
memcpy(p, &rec, sizeof(rec));
memcpy(p+sizeof(rec), key.dptr, key.dsize);
memcpy(p+sizeof(rec)+key.dsize, dbuf.dptr, dbuf.dsize);
if (tdb_write(tdb, rec_ptr, p, sizeof(rec)+key.dsize+dbuf.dsize) == -1)
goto fail;
free(p);
p = NULL;
/* and point the top of the hash chain at it */
if (ofs_write(tdb, offset, &rec_ptr) == -1) goto fail;
tdb_unlock(tdb, BUCKET(hash));
return 0;
fail:
#if TDB_DEBUG
printf("store failed for hash 0x%08x in bucket %u\n", hash, BUCKET(hash));
#endif
if (p) free(p);
tdb_unlock(tdb, BUCKET(hash));
return -1;
}
/* open the database, creating it if necessary
The open_flags and mode are passed straight to the open call on the database
file. A flags value of O_WRONLY is invalid
The hash size is advisory, use zero for a default value.
return is NULL on error
*/
TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode)
{
TDB_CONTEXT tdb, *ret;
struct stat st;
memset(&tdb, 0, sizeof(tdb));
tdb.fd = -1;
tdb.name = NULL;