libt3key
Data Structures | Macros | Typedefs | Enumerations | Functions
Functions, constants and enums.

Data Structures

struct  t3_key_node_t
 A structure which is part of a singly linked list and contains a single key definition. More...
 
struct  t3_key_string_list_t
 A structure which is part of a singly linked list and contains a single string. More...
 

Macros

#define T3_KEY_VERSION
 The version of libt3key encoded as a single integer. More...
 

Typedefs

typedef char t3_bool
 A boolean type that does not clash with C++ or C99 bool. More...
 

Enumerations

enum  { t3_false, t3_true }
 Values for t3_bool, a boolean type that does not clash with C++ or C99 bool. More...
 

Functions

void t3_key_free_map (const t3_key_node_t *list)
 Free a key map. More...
 
void t3_key_free_names (const t3_key_string_list_t *list)
 Free a map names list. More...
 
char * t3_key_get_best_map_name (const char *term, int *error)
 Get name of best map from database. More...
 
const t3_key_string_list_tt3_key_get_map_names (const char *term, int *error)
 Get map names from database. More...
 
const t3_key_node_tt3_key_get_named_node (const t3_key_node_t *map, const char *name)
 Get a named node from a map. More...
 
long t3_key_get_version (void)
 Get the value of T3_KEY_VERSION corresponding to the actual used library. More...
 
const t3_key_node_tt3_key_load_map (const char *term, const char *map_name, int *error)
 Load a key map from database. More...
 
const char * t3_key_strerror (int error)
 Get a string description for an error code. More...
 

Error codes (libt3key specific)

#define T3_ERR_INVALID_FORMAT
 Error code: invalid key-database file format. More...
 
#define T3_ERR_TERMINFO_UNKNOWN
 Error code: Required terminfo key not found in terminfo database. More...
 
#define T3_ERR_NOMAP
 Error code: Key database contains no maps. More...
 
#define T3_ERR_TRUNCATED_DB
 Error code: Key database is truncated. More...
 
#define T3_ERR_READ_ERROR
 Error code: Error reading key database. More...
 
#define T3_ERR_WRONG_VERSION
 Error code: Key database is of an unsupported version. More...
 

Error codes (T3 generic)

#define T3_ERR_SUCCESS
 Error code: success.
 
#define T3_ERR_ERRNO
 Error code: see errno. More...
 
#define T3_ERR_EOF
 Error code: end of file reached. More...
 
#define T3_ERR_UNKNOWN
 Error code: unkown error. More...
 
#define T3_ERR_BAD_ARG
 Error code: bad argument. More...
 
#define T3_ERR_OUT_OF_MEMORY
 Error code: out of memory. More...
 
#define T3_ERR_TERMINFODB_NOT_FOUND
 Error code: no information found for the terminal in the terminfo database. More...
 
#define T3_ERR_HARDCOPY_TERMINAL
 Error code: the file descriptor is a hard-copy terminal. More...
 
#define T3_ERR_TERMINAL_TOO_LIMITED
 Error code: terminal provides too limited possibilities for the library to function. More...
 
#define T3_ERR_NO_TERM
 Error code: no terminal given and TERM environment variable not set. More...
 
#define T3_ERR_INTERNAL
 Error code: internal error in the library. More...
 
#define T3_WARN_MIN
 Warning code: the smallest value returned as warning. More...
 

Detailed Description

Macro Definition Documentation

◆ T3_ERR_BAD_ARG

#define T3_ERR_BAD_ARG

Error code: bad argument.

◆ T3_ERR_EOF

#define T3_ERR_EOF

Error code: end of file reached.

◆ T3_ERR_ERRNO

#define T3_ERR_ERRNO

Error code: see errno.

◆ T3_ERR_HARDCOPY_TERMINAL

#define T3_ERR_HARDCOPY_TERMINAL

Error code: the file descriptor is a hard-copy terminal.

◆ T3_ERR_INTERNAL

#define T3_ERR_INTERNAL

Error code: internal error in the library.

◆ T3_ERR_INVALID_FORMAT

#define T3_ERR_INVALID_FORMAT

Error code: invalid key-database file format.

◆ T3_ERR_NO_TERM

#define T3_ERR_NO_TERM

Error code: no terminal given and TERM environment variable not set.

◆ T3_ERR_NOMAP

#define T3_ERR_NOMAP

Error code: Key database contains no maps.

◆ T3_ERR_OUT_OF_MEMORY

#define T3_ERR_OUT_OF_MEMORY

Error code: out of memory.

◆ T3_ERR_READ_ERROR

#define T3_ERR_READ_ERROR

Error code: Error reading key database.

◆ T3_ERR_TERMINAL_TOO_LIMITED

#define T3_ERR_TERMINAL_TOO_LIMITED

Error code: terminal provides too limited possibilities for the library to function.

◆ T3_ERR_TERMINFO_UNKNOWN

#define T3_ERR_TERMINFO_UNKNOWN

Error code: Required terminfo key not found in terminfo database.

◆ T3_ERR_TERMINFODB_NOT_FOUND

#define T3_ERR_TERMINFODB_NOT_FOUND

Error code: no information found for the terminal in the terminfo database.

◆ T3_ERR_TRUNCATED_DB

#define T3_ERR_TRUNCATED_DB

Error code: Key database is truncated.

◆ T3_ERR_UNKNOWN

#define T3_ERR_UNKNOWN

Error code: unkown error.

◆ T3_ERR_WRONG_VERSION

#define T3_ERR_WRONG_VERSION

Error code: Key database is of an unsupported version.

◆ T3_KEY_VERSION

#define T3_KEY_VERSION

The version of libt3key encoded as a single integer.

The least significant 8 bits represent the patch level. The second 8 bits represent the minor version. The third 8 bits represent the major version.

At runtime, the value of T3_KEY_VERSION can be retrieved by calling t3_key_get_version.

◆ T3_WARN_MIN

#define T3_WARN_MIN

Warning code: the smallest value returned as warning.

Typedef Documentation

◆ t3_bool

typedef char t3_bool

A boolean type that does not clash with C++ or C99 bool.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Values for t3_bool, a boolean type that does not clash with C++ or C99 bool.

Enumerator
t3_false 

False.

t3_true 

True.

Function Documentation

◆ t3_key_free_map()

void t3_key_free_map ( const t3_key_node_t list)

Free a key map.

Parameters
listThe list of keys to free.

◆ t3_key_free_names()

void t3_key_free_names ( const t3_key_string_list_t list)

Free a map names list.

Parameters
listThe list of map names to free.

◆ t3_key_get_best_map_name()

char* t3_key_get_best_map_name ( const char *  term,
int *  error 
)

Get name of best map from database.

Parameters
termThe terminal name to use to find the key database.
errorLocation to store the error code.
Returns
NULL on failure, the name of the best map on success.

If term is NULL, the environment variable TERM is used to retrieve the terminal name. The name is allocated using malloc.

◆ t3_key_get_map_names()

const t3_key_string_list_t* t3_key_get_map_names ( const char *  term,
int *  error 
)

Get map names from database.

Parameters
termThe terminal name to use to find the key database.
errorLocation to store the error code.
Returns
NULL on failure, a list of t3_key_string_list_t structures on success.

If term is NULL, the environment variable TERM is used to retrieve the terminal name.

◆ t3_key_get_named_node()

const t3_key_node_t* t3_key_get_named_node ( const t3_key_node_t map,
const char *  name 
)

Get a named node from a map.

Parameters
mapThe map to search.
nameThe name of the node to search for, or NULL to continue the last search.
Returns
The t3_key_node_t with the given name, or NULL if no such node exists.

Multiple nodes may exist with the same name. To retrieve all of them, t3_key_get_named_node may be called multiple times. The second and later calls must use the returned value as the map parameter, and pass NULL as name.

◆ t3_key_get_version()

long t3_key_get_version ( void  )

Get the value of T3_KEY_VERSION corresponding to the actual used library.

Returns
The value of T3_KEY_VERSION.

This function can be useful to determine at runtime what version of the library was linked to the program. Although currently there are no known uses for this information, future library additions may prompt library users to want to operate differently depending on the available features.

◆ t3_key_load_map()

const t3_key_node_t* t3_key_load_map ( const char *  term,
const char *  map_name,
int *  error 
)

Load a key map from database.

Parameters
termThe terminal name to use to find the key database.
map_nameName of the map to load for the terminal.
errorLocation to store the error code.
Returns
NULL on failure, a list of t3_key_node_t structures on success.

If term is NULL, the environment variable TERM is used to retrieve the terminal name. The map_name parameter indicates which map to load. If map_name is NULL, the map indicated by best in the database is used.

Before calling this function, you must ensure that the terminfo database has been initialised by calling one of setupterm, initscr, newterm, setterm, or the t3_term_init function.

◆ t3_key_strerror()

const char* t3_key_strerror ( int  error)

Get a string description for an error code.

Parameters
errorThe error code returned by a function in libt3key.
Returns
An internationalized string description for the error code.