VILLA(3)
β¨ NAME β¨
Villa β the advanced API of QDBM, and this is the manual page VILLA(3). π
πΈ SYNOPSIS πΈ
okay bestie, first things first, you gotta pull in the headers:
#include <depot.h>
#include <cabin.h>
#include <villa.h>
#include <stdlib.h>
and here's the comparing-function type, she's the blueprint for how you want your keys sorted:
typedef int(*VLCFUNC)(const char *aptr, int asiz, const char *bptr, int bsiz);
and now the whole cast of characters, every single one of them:
VILLA *vlopen(const char *name, int omode, VLCFUNC cmp);
int vlclose(VILLA *villa);
int vlput(VILLA *villa, const char *kbuf, int ksiz, const char *vbuf, int vsiz, int dmode);
int vlout(VILLA *villa, const char *kbuf, int ksiz);
char *vlget(VILLA *villa, const char *kbuf, int ksiz, int *sp);
int vlvsiz(VILLA *villa, const char *kbuf, int ksiz);
int vlvnum(VILLA *villa, const char *kbuf, int ksiz);
int vlputlist(VILLA *villa, const char *kbuf, int ksiz, const CBLIST *vals);
int vloutlist(VILLA *villa, const char *kbuf, int ksiz);
CBLIST *vlgetlist(VILLA *villa, const char *kbuf, int ksiz);
char *vlgetcat(VILLA *villa, const char *kbuf, int ksiz, int *sp);
int vlcurfirst(VILLA *villa);
int vlcurlast(VILLA *villa);
int vlcurprev(VILLA *villa);
int vlcurnext(VILLA *villa);
int vlcurjump(VILLA *villa, const char *kbuf, int ksiz, int jmode);
char *vlcurkey(VILLA *villa, int *sp);
char *vlcurval(VILLA *villa, int *sp);
int vlcurput(VILLA *villa, const char *vbuf, int vsiz, int cpmode);
int vlcurout(VILLA *villa);
void vlsettuning(VILLA *villa, int lrecmax, int nidxmax, int lcnum, int ncnum);
int vlsetfbpsiz(VILLA *villa, int size);
int vlsync(VILLA *villa);
int vloptimize(VILLA *villa);
char *vlname(VILLA *villa);
int vlfsiz(VILLA *villa);
int vllnum(VILLA *villa);
int vlnnum(VILLA *villa);
int vlrnum(VILLA *villa);
int vlwritable(VILLA *villa);
int vlfatalerror(VILLA *villa);
int vlinode(VILLA *villa);
time_t vlmtime(VILLA *villa);
int vltranbegin(VILLA *villa);
int vltrancommit(VILLA *villa);
int vltranabort(VILLA *villa);
int vlremove(const char *name);
int vlrepair(const char *name, VLCFUNC cmp);
int vlexportdb(VILLA *villa, const char *name);
int vlimportdb(VILLA *villa, const char *name);
π DESCRIPTION π
Villa is the advanced API of QDBM, periodt. She gives you routines for managing a database file that's a B+ tree π³. Every record gets stored sorted, in an order that you define. ikr, main character energy.
Now, with hash databases, the retrieving method is provided only as complete accord β like, exact match or nothing, no in-between. But with Villa? You can retrieve records specified by range β¨. A cursor is what you use to walk through each record in order. And yes, you can store records with duplicating keys in a database, no problem. On top of all that, the transaction mechanism means you can commit or abort operations on a database in a lump β all together, bestie π .
Villa is implemented based on Depot and Cabin. A database file of Villa is actual one of Depot, fr fr. The processing speed of retrieving and storing is slower than Depot, but the size of a database is smaller. That's the trade, and it's lowkey a good one.
In order to use Villa, you should include depot.h, cabin.h, villa.h and stdlib.h in the source files. Usually, the following description will be near the beginning of a source file.
#include <depot.h>
#include <cabin.h>
#include <villa.h>
#include <stdlib.h>
A pointer to VILLA is used as a database handle. It is like that some file I/O routines of stdio.h use a pointer to FILE. A database handle is opened with the function vlopen and closed with vlclose. You should not refer directly to any member of the handle π. If a fatal error occurs in a database, any access method via the handle except vlclose will not work and will return error status. Although a process is allowed to use multiple database handles at the same time, handles of the same database file should not be used. π«
Before the cursor is used, it should be initialized by one of vlcurfirst, vlcurlast or vlcurjump. Also, after storing or deleting a record with functions except for vlcurput and vlcurout, the cursor should be initialized. Don't forget, she gets moody π.
Villa also assigns the external variable dpecode with the error code. The function dperrmsg is used in order to get the message of the error code.
π the comparing function (VLCFUNC) π
You can define a comparing function to specify the order of records. The function should be the following type.
typedef int(*VLCFUNC)(const char *aptr, int asiz, const char *bptr, int bsiz);
aptrspecifies the pointer to the region of one key.asizspecifies the size of the region of one key.bptrspecifies the pointer to the region of the other key.bsizspecifies the size of the region of the other key.
The return value is positive if the former is big, negative if the latter is big, and 0 if both are equivalent. That's the whole vibe check β.
π¦ vlopen β get a database handle
The function vlopen is used in order to get a database handle.
VILLA *vlopen(const char *name, int omode, VLCFUNC cmp);
namespecifies the name of a database file.omodespecifies the connection mode:VL_OWRITERas a writer,VL_OREADERas a reader. If the mode isVL_OWRITER, the following may be added by bitwise or:VL_OCREAT, which means it creates a new database if not exist;VL_OTRUNC, which means it creates a new database regardless if one exists;VL_OZCOMP, which means leaves in the database are compressed;VL_OYCOMP, which means leaves in the database are compressed with LZO;VL_OXCOMP, which means leaves in the database are compressed with BZIP2. Both ofVL_OREADERandVL_OWRITERcan be added to by bitwise or:VL_ONOLCK, which means it opens a database file without file locking, orVL_OLCKNB, which means locking is performed without blocking.cmpspecifies the comparing function:VL_CMPLEXcomparing keys in lexical order,VL_CMPINTcomparing keys as objects ofintin native byte order,VL_CMPNUMcomparing keys as numbers of big endian,VL_CMPDECcomparing keys as decimal strings. Any function based on the declaration of the typeVLCFUNCcan be assigned to the comparing function. The comparing function should be kept same in the life of a database. π«Ά
The return value is the database handle or NULL if it is not successful.
While connecting as a writer, an exclusive lock is invoked to the database file. While connecting as a reader, a shared lock is invoked to the database file. The thread blocks until the lock is achieved π΄.
VL_OZCOMP,VL_OYCOMP, andVL_OXCOMPare available only if QDBM was built each with ZLIB, LZO, and BZIP2 enabled. IfVL_ONOLCKis used, the application is responsible for exclusion control. No cap. π
π vlclose β close that handle
The function vlclose is used in order to close a database handle.
int vlclose(VILLA *villa);
villaspecifies a database handle.
If successful, the return value is true, else, it is false. Because the region of a closed handle is released, it becomes impossible to use the handle. Updating a database is assured to be written when the handle is closed.
If a writer opens a database but does not close it appropriately, the database will be broken π. If the transaction is activated and not committed, it is aborted.
π vlput β store a record
The function vlput is used in order to store a record.
int vlput(VILLA *villa, const char *kbuf, int ksiz, const char *vbuf, int vsiz, int dmode);
villaspecifies a database handle connected as a writer.kbufspecifies the pointer to the region of a key.ksizspecifies the size of the region of the key. If it is negative, the size is assigned withstrlen(kbuf).vbufspecifies the pointer to the region of a value.vsizspecifies the size of the region of the value. If it is negative, the size is assigned withstrlen(vbuf).dmodespecifies behavior when the key overlaps, by the following values:VL_DOVER, which means the specified value overwrites the existing oneVL_DKEEP, which means the existing value is keptVL_DCAT, which means the specified value is concatenated at the end of the existing valueVL_DDUP, which means duplication of keys is allowed and the specified value is added as the last oneVL_DDUPR, which means duplication of keys is allowed and the specified value is added as the first one
If successful, the return value is true, else, it is false.
The cursor becomes unavailable due to updating database. like, gone. bye. π
π§ vlout β delete a record
The function vlout is used in order to delete a record.
int vlout(VILLA *villa, const char *kbuf, int ksiz);
villaspecifies a database handle connected as a writer.kbufspecifies the pointer to the region of a key.ksizspecifies the size of the region of the key. If it is negative, the size is assigned withstrlen(kbuf).
If successful, the return value is true, else, it is false. False is returned when no record corresponds to the specified key. When the key of duplicated records is specified, the first record of the same key is deleted.
The cursor becomes unavailable due to updating database.
π vlget β retrieve a record
The function vlget is used in order to retrieve a record.
char *vlget(VILLA *villa, const char *kbuf, int ksiz, int *sp);
villaspecifies a database handle.kbufspecifies the pointer to the region of a key.ksizspecifies the size of the region of the key. If it is negative, the size is assigned withstrlen(kbuf).spspecifies the pointer to a variable to which the size of the region of the return value is assigned. If it isNULL, it is not used.
If successful, the return value is the pointer to the region of the value of the corresponding record, else, it is NULL. NULL is returned when no record corresponds to the specified key. When the key of duplicated records is specified, the value of the first record of the same key is selected.
Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string β¨.
Because the region of the return value is allocated with themalloccall, it should be released with thefreecall if it is no longer in use. don't leak bestie, that's not the vibe π
The function vlvsiz is used in order to get the size of the value of a record.
So like, vlvsiz is your girl for finding out how big a value is before you commit, y'know? π
int vlvsiz(VILLA *villa, const char *kbuf, int ksiz);
villaβ the database handle, obvs.kbufβ pointer to the region of a key. Like, the actual key bytes.ksizβ the size of that key region. And if it's negative? Bestie, the size gets assigned withstrlen(kbuf). Convenient.- Returns β if it worked, you get the size of the value of the corresponding record. If it didn't, you get
-1. And if multiple records correspond, you get the size of the first one. Periodt.
Then there's vlvnum, which is literally just "how many records match this key" energy. π’
int vlvnum(VILLA *villa, const char *kbuf, int ksiz);
villaβ database handle.kbufβ pointer to the region of a key.ksizβ size of the key region. Negative?strlen(kbuf)steps in. πββοΈ- Returns β the number of corresponding records. And if no record corresponds, you get
0. Not-1, notNULL, just0. Slay.
Okay so vlputlist is the one that stores plural records for a key. Plural. Multiple. A whole squad of values. π
int vlputlist(VILLA *villa, const char *kbuf, int ksiz, const CBLIST *vals);
villaβ a database handle connected as a writer. Important, she has to have write access.kbufβ pointer to the region of a key.ksizβ size of the key region, and yes, if it's negative it'sstrlen(kbuf)again.valsβ a list handle of values. And heads up: the list should not be empty. Like, don't even try it.- Returns β true if it worked, false if it didn't.
- > β οΈ The cursor becomes unavailable due to updating the database. She's gone, babes.
vloutlist deletes all the records for a key. All of them. Scorched earth. ποΈ
int vloutlist(VILLA *villa, const char *kbuf, int ksiz);
villaβ database handle connected as a writer.kbufβ pointer to the region of a key.ksizβ size of the key region; negative meansstrlen(kbuf), you know the drill.- Returns β true on success, false otherwise. And it returns false when no record corresponds to the specified key. So false doesn't always mean "something broke," sometimes it means "girl, there was nothing there."
- > β οΈ Cursor becomes unavailable due to updating the database. Again. She cannot come to the phone right now.
vlgetlist is the retrieve-values-of-all-records-for-a-key function. The collector. πΈ
CBLIST *vlgetlist(VILLA *villa, const char *kbuf, int ksiz);
villaβ database handle.kbufβ pointer to the region of a key.ksizβ size of the key region. Negative βstrlen(kbuf).- Returns β on success, a list handle of the values of the corresponding records. On failure,
NULL. AndNULLis also what you get when no record corresponds to the specified key. - > π Because the handle of the return value is opened with the function
cblistopen, it should be closed with the functioncblistcloseif it is no longer in use. Do not forget this. Memory leaks are not cute.
vlgetcat gives you all those values but concatenated. One big blob. String energy. π§΅
char *vlgetcat(VILLA *villa, const char *kbuf, int ksiz, int *sp);
villaβ database handle.kbufβ pointer to the region of a key.ksizβ size of the key region; if negative,strlen(kbuf).spβ pointer to a variable that gets the size of the region of the return value assigned to it. If it'sNULL, it's just not used. No biggie.- Returns β on success, a pointer to the region of the concatenated values of the corresponding record. Otherwise
NULL. AndNULLshows up when no record corresponds to the specified key. - > β¨ Because an additional zero code is appended at the end of the region of the return value, you can treat it as a character string. So yes, it's string-able.
- > π But because the region of the return value is allocated with the
malloccall, it should be released with thefreecall if it is no longer in use. Free your girl or she haunts you.
Now we're in cursor territory, and honestly? Main character energy. π
vlcurfirst moves the cursor to the first record.
int vlcurfirst(VILLA *villa);
villaβ database handle.- Returns β true on success, false otherwise. False is returned if there is no record in the database.
vlcurlast moves the cursor to the last record.
int vlcurlast(VILLA *villa);
villaβ database handle.- Returns β true on success, else false. False if there is no record in the database.
vlcurprev moves the cursor to the previous record.
int vlcurprev(VILLA *villa);
villaβ database handle.- Returns β true on success, else false. False is returned if there is no previous record.
vlcurnext moves the cursor to the next record.
int vlcurnext(VILLA *villa);
villaβ database handle.- Returns β true on success, else false. False is returned if there is no next record.
vlcurjump is the β¨fancyβ¨ one β it moves the cursor to a position around a record. Not exactly on it, around it. Vibe check.
int vlcurjump(VILLA *villa, const char *kbuf, int ksiz, int jmode);
villaβ database handle.kbufβ pointer to the region of a key.ksizβ size of the key region; if it's negative, the size is assigned withstrlen(kbuf).jmodeβ the detail adjustment, and there are two moods:VL_JFORWARDβ the cursor is set to the first record of the same key, and the cursor is set to the next substitute if a completely matching record does not exist.VL_JBACKWARDβ the cursor is set to the last record of the same key, and the cursor is set to the previous substitute if a completely matching record does not exist.
- Returns β true on success, else false. False is returned if there is no record corresponding the condition.
vlcurkey grabs the key of whatever record the cursor is sitting on. π
char *vlcurkey(VILLA *villa, int *sp);
villaβ database handle.spβ pointer to a variable that gets the size of the region of the return value. If it'sNULL, it is not used.- Returns β on success, a pointer to the region of the key of the corresponding record, else
NULL. AndNULLis returned when no record corresponds to the cursor. - > β¨ An additional zero code is appended at the end of the region of the return value, so you can treat the return value as a character string.
- > π And because the region of the return value is allocated with the
malloccall, it should be released with thefreecall if it is no longer in use. Release her.
vlcurval grabs the value of the record where the cursor is. The twin to vlcurkey, but make it value. π
char *vlcurval(VILLA *villa, int *sp);
villaβ database handle.spβ pointer to a variable to which the size of the region of the return value is assigned. If it'sNULL, it is not used.- Returns β on success, a pointer to the region of the value of the corresponding record, else
NULL.NULLis returned when no record corresponds to the cursor. - > β¨ Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string.
- > π Because the region of the return value is allocated with the
malloccall, it should be released with thefreecall if it is no longer in use.
vlcurput inserts a record around the cursor. She's flexible like that. π
int vlcurput(VILLA *villa, const char *vbuf, int vsiz, int cpmode);
villaβ a database handle connected as a writer.vbufβ pointer to the region of a value.vsizβ size of the region of the value. If it is negative, the size is assigned withstrlen(vbuf).cpmodeβ detail adjustment, three options, pick your fighter:VL_CPCURRENTβ the value of the current record is overwritten.VL_CPBEFOREβ a new record is inserted before the current record.VL_CPCAFTERβ a new record is inserted after the current record.
Wait, no, hold on β the original says VL_CPAFTER. Let me not do her dirty: it's VL_CPAFTER β a new record is inserted after the current record. My bad bestie, typo brain. π
- Returns β true on success, else false. False is returned when no record corresponds to the cursor.
- > β¨ After insertion, the cursor is moved to the inserted record. She follows the new girl.
vlcurout deletes the record where the cursor is. Bye. π
int vlcurout(VILLA *villa);
villaβ a database handle connected as a writer.- Returns β true on success, else false. False is returned when no record corresponds to the cursor.
- > β¨ After deletion, the cursor is moved to the next record if possible.
vlsettuning is the performance-glow-up function. She's giving optimization. π₯
void vlsettuning(VILLA *villa, int lrecmax, int nidxmax, int lcnum, int ncnum);
villaβ database handle.lrecmaxβ the max number of records in a leaf node of B+ tree. If it is not more than0, the default value is specified.nidxmaxβ the max number of indexes in a non-leaf node of B+ tree. If it is not more than0, the default value is specified.lcnumβ the max number of caching leaf nodes. If it is not more than0, the default value is specified.ncnumβ the max number of caching non-leaf nodes. If it is not more than0, the default value is specified.- The default setting is equivalent to
vlsettuning(49, 192, 1024, 512). Those are the numbers, memorize them, they're iconic. β - > β οΈ Because tuning parameters are not saved in a database, you should specify them every time you open a database. Every. Single. Time. No shortcuts.
And vlsetfbpsiz is the one that sets the size of the free block pool of a database handle.
int vlsetfbpsiz(VILLA *villa, int size);
villaβ a database handle that's connected as a writer, bestie, that part matters πsizeβ the size of the free block pool of a database
Successful? You get true. Not successful? false. The default size of the free block pool is 256. And here's the tea: if the size is greater, the space efficiency of overwriting values is improved β but the time efficiency is sacrificed. so you're trading speed for packing, pick your struggle π
The function vlsync is used in order to synchronize updating contents with the file and the device.
int vlsync(VILLA *villa);
villaβ a database handle connected as a writer
If successful, the return value is true, else, it is false. This function is useful when another process uses the connected database file. π«Ά
Do NOT use this while the transaction is activated. like, literally don't π
The function vloptimize is used in order to optimize a database.
int vloptimize(VILLA *villa);
villaβ a database handle connected as a writer
If successful, the return value is true, else, it is false. So here's the situation: in an alternating succession of deleting and storing with overwrite or concatenate, dispensable regions accumulate π¬ This function is useful to do away with them. glow-up for your database, honestly β¨
Also should not be used while the transaction is activated. periodt.
The function vlname is used in order to get the name of a database.
char *vlname(VILLA *villa);
villaβ a database handle (any handle, not just a writer, slay)
If successful, the return value is the pointer to the region of the name of the database, else, it is NULL. And because the region of the return value is allocated with the malloc call, it should be released with the free call if it is no longer in use. don't forget the free, bestie, that's a leak π
The function vlfsiz is used in order to get the size of a database file.
int vlfsiz(VILLA *villa);
villaβ a database handle
If successful, the return value is the size of the database file, else, it is -1. Heads up though: because of the I/O buffer, the return value may be less than the hard size. it's giving "close enough" π¦
The function vllnum is used in order to get the number of the leaf nodes of B+ tree.
int vllnum(VILLA *villa);
villaβ a database handle
If successful, the return value is the number of the leaf nodes, else, it is -1. counting leaves like it's a cute lil plant πΈ
The function vlnnum is used in order to get the number of the non-leaf nodes of B+ tree.
int vlnnum(VILLA *villa);
villaβ a database handle
If successful, the return value is the number of the non-leaf nodes, else, it is -1. the non-leaf ones, the backbone, the main character energy π
The function vlrnum is used in order to get the number of the records stored in a database.
int vlrnum(VILLA *villa);
villaβ a database handle
If successful, the return value is the number of the records stored in the database, else, it is -1. π₯
The function vlwritable is used in order to check whether a database handle is a writer or not.
int vlwritable(VILLA *villa);
villaβ a database handle
The return value is true if the handle is a writer, false if not. vibe check for your handle π
The function vlfatalerror is used in order to check whether a database has a fatal error or not.
int vlfatalerror(VILLA *villa);
villaβ a database handle
The return value is true if the database has a fatal error, false if not. praying it's false fr fr π
The function vlinode is used in order to get the inode number of a database file.
int vlinode(VILLA *villa);
villaβ a database handle
The return value is the inode number of the database file. β
The function vlmtime is used in order to get the last modified time of a database.
time_t vlmtime(VILLA *villa);
villaβ a database handle
The return value is the last modified time of the database. when was the last time it ate? π
The function vltranbegin is used in order to begin the transaction.
int vltranbegin(VILLA *villa);
villaβ a database handle connected as a writer
If successful, the return value is true, else, it is false.
Because this function does not perform mutual exclusion control in multi-thread, the application is responsible for it. that's on you, bestie π Only one transaction can be activated with a database handle at the same time.
The function vltrancommit is used in order to commit the transaction.
int vltrancommit(VILLA *villa);
villaβ a database handle connected as a writer
If successful, the return value is true, else, it is false. Updating a database in the transaction is fixed when it is committed successfully. commit it, don't ghost it π
The function vltranabort is used in order to abort the transaction.
int vltranabort(VILLA *villa);
villaβ a database handle connected as a writer
If successful, the return value is true, else, it is false. Updating a database in the transaction is discarded when it is aborted. The state of the database is rollbacked to before transaction. we love a good undo button π§
The function vlremove is used in order to remove a database file.
int vlremove(const char *name);
nameβ the name of a database file
If successful, the return value is true, else, it is false. bye bye database ππ
The function vlrepair is used in order to repair a broken database file.
int vlrepair(const char *name, VLCFUNC cmp);
nameβ the name of a database filecmpβ the comparing function of the database file
If successful, the return value is true, else, it is false.
There is no guarantee that all records in a repaired database file correspond to the original or expected state. no cap, it's a repair not a resurrection π
The function vlexportdb is used in order to dump all records as endian independent data.
int vlexportdb(VILLA *villa, const char *name);
villaβ a database handlenameβ the name of an output file
If successful, the return value is true, else, it is false. taking your data on a little trip, endian independent so it travels cute π
The function vlimportdb is used in order to load all records from endian independent data.
int vlimportdb(VILLA *villa, const char *name);
villaβ a database handle connected as a writer. The database of the handle must be empty.nameβ the name of an input file
If successful, the return value is true, else, it is false. empty database only, she does not share π
If QDBM was built with POSIX thread enabled, the global variable dpecode is treated as thread specific data, and functions of Villa are reentrant. In that case, they are thread-safe as long as a handle is not accessed by threads at the same time, on the assumption that errno, malloc, and so on are thread-safe. β¨ threading tea, iykyk β¨
π¦ VISTA, THE EXTENDED EDITION π¦
Vista is the extended API of Villa. To compensate for the defect that Villa can not handle a file whose size is more than 2GB, Vista does not use Depot but Curia for handling its internal database. While Vista provides data structure and operations of B+ tree as with Villa, its database is realized as a directory. π
In order to use Vista, you should include vista.h instead of villa.h. Because Vista is implemented by overriding symbols of Villa, it can be used as with Villa. That is, Signatures of Villa and Vista is all the same. However, as its adverse effect, modules using Vista can not use Depot nor Villa.
that last bit is the catch, bestie β Vista modules can't touch Depot or Villa, so choose your side π
πΈ SEE ALSO πΈ
and that's the whole page, bestie!! π«Ά this was VILLA(3), from the Man Page section, dated 2004-04-22 β yes it's vintage, and it still ate ππ
π¦ where this page comes from
- debian bookworm: libqdbm-dev 1.8.78-12+b1 Β· LGPL-2.1-or-later
- debian trixie: libqdbm-dev 1.8.78-13+b3 Β· LGPL-2.1-or-later
- fedora 43: qdbm-devel 1.8.78-71.fc43 Β· LGPL-2.1-or-later
- fedora 43: qdbm-devel 1.8.78-71.fc43 Β· LGPL-2.1-or-later
- fedora 44: qdbm-devel 1.8.78-75.fc44 Β· LGPL-2.1-or-later
- fedora 44: qdbm-devel 1.8.78-75.fc44 Β· LGPL-2.1-or-later
- ubuntu jammy: libqdbm-dev 1.8.78-11build3 Β· LGPL-2.1-or-later
- ubuntu noble: libqdbm-dev 1.8.78-12.1build2 Β· LGPL-2.1-or-later
- ubuntu questing: libqdbm-dev 1.8.78-13build2
- ubuntu resolute: libqdbm-dev 1.8.78-15 Β· LGPL-2.1-or-later
- ubuntu stonking: libqdbm-dev 1.8.78-16build1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms