-/*
+/*
Unix SMB/CIFS implementation.
tdb utility functions
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 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, see <http://www.gnu.org/licenses/>.
*/
int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval)
{
TDB_DATA key = string_term_tdb_data(keyval);
-
+
return tdb_chainlock(tdb, key);
}
int tdb_read_lock_bystring(struct tdb_context *tdb, const char *keyval)
{
TDB_DATA key = string_term_tdb_data(keyval);
-
+
return tdb_chainlock_read(tdb, key);
}
void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval)
{
TDB_DATA key = string_term_tdb_data(keyval);
-
+
tdb_chainunlock_read(tdb, key);
}
int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags)
{
TDB_DATA key = string_term_tdb_data(keystr);
-
+
return tdb_store(tdb, key, data, flags);
}
}
/****************************************************************************
- Delete an entry using a null terminated string key.
+ Delete an entry using a null terminated string key.
****************************************************************************/
int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr)
}
/****************************************************************************
- Atomic integer change. Returns old value. To create, set initial value in *oldval.
+ Atomic integer change. Returns old value. To create, set initial value in *oldval.
****************************************************************************/
int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val)
/* but not because it didn't exist */
goto err_out;
}
-
+
/* Start with 'old' value */
val = *oldval;
/* Increment value for storage and return next time */
val += change_val;
-
+
if (tdb_store_int32(tdb, keystr, val) != 0)
goto err_out;
}
/****************************************************************************
- Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval.
+ Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval.
****************************************************************************/
bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr, uint32_t *oldval, uint32_t change_val)
if (!tdb_fetch_uint32(tdb, keystr, &val)) {
/* It failed */
- if (tdb_error(tdb) != TDB_ERR_NOEXIST) {
+ if (tdb_error(tdb) != TDB_ERR_NOEXIST) {
/* and not because it didn't exist */
goto err_out;
}
/* get a new value to store */
val += change_val;
-
+
if (!tdb_store_uint32(tdb, keystr, val))
goto err_out;
int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr);
/****************************************************************************
- Atomic integer change. Returns old value. To create, set initial value in *oldval.
+ Atomic integer change. Returns old value. To create, set initial value in *oldval.
****************************************************************************/
int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val);
/****************************************************************************
- Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval.
+ Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval.
****************************************************************************/
bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr, uint32_t *oldval, uint32_t change_val);