libsmbios_c library
Macros | Functions
token.h File Reference
#include "smbios_c/compat.h"
#include "smbios_c/types.h"
Include dependency graph for token.h:

Go to the source code of this file.

Macros

#define TOKEN_TYPE_D4   0xD4
 
#define TOKEN_TYPE_D5   0xD5
 
#define TOKEN_TYPE_D6   0xD6
 
#define TOKEN_TYPE_DA   0xDA
 

Functions

LIBSMBIOS_C_DLL_SPEC const char * token_strerror ()
 Returns string describing the last error condition.
 
LIBSMBIOS_C_DLL_SPEC int token_get_type (u16 id)
 Return token type.
 
LIBSMBIOS_C_DLL_SPEC bool token_is_bool (u16 id)
 Check if a token is a boolean-type token.
 
LIBSMBIOS_C_DLL_SPEC int token_is_active (u16 id)
 Check if a boolean token is currently set.
 
LIBSMBIOS_C_DLL_SPEC int token_activate (u16 id)
 Activate a boolean token.
 
LIBSMBIOS_C_DLL_SPEC bool token_is_string (u16 id)
 Check if a token is a string-type token.
 
LIBSMBIOS_C_DLL_SPEC char * token_get_string (u16 id, size_t *len)
 Get a new buffer containing the token string value.
 
LIBSMBIOS_C_DLL_SPEC int token_set_string (u16 id, const char *value, size_t size)
 Set a string token value.
 
LIBSMBIOS_C_DLL_SPEC void token_string_free (char *)
 Free allocated memory.
 
LIBSMBIOS_C_DLL_SPEC const struct smbios_struct * token_get_smbios_struct (u16 id)
 Get a pointer to the smbios struct containing this token.
 
LIBSMBIOS_C_DLL_SPEC const void * token_get_ptr (u16 id)
 Get a pointer to the actual token structure.
 
LIBSMBIOS_C_DLL_SPEC int token_try_password (u16 id, const char *pass_ascii, const char *pass_scancode)
 For tokens that are password protected, check password.
 

Macro Definition Documentation

◆ TOKEN_TYPE_D4

#define TOKEN_TYPE_D4   0xD4

◆ TOKEN_TYPE_D5

#define TOKEN_TYPE_D5   0xD5

◆ TOKEN_TYPE_D6

#define TOKEN_TYPE_D6   0xD6

◆ TOKEN_TYPE_DA

#define TOKEN_TYPE_DA   0xDA

Function Documentation

◆ token_activate()

LIBSMBIOS_C_DLL_SPEC int token_activate ( u16  id)

Activate a boolean token.

Returns
0 on success, <0 on failure.

◆ token_get_ptr()

LIBSMBIOS_C_DLL_SPEC const void * token_get_ptr ( u16  id)

Get a pointer to the actual token structure.

◆ token_get_smbios_struct()

LIBSMBIOS_C_DLL_SPEC const struct smbios_struct * token_get_smbios_struct ( u16  id)

Get a pointer to the smbios struct containing this token.

◆ token_get_string()

LIBSMBIOS_C_DLL_SPEC char * token_get_string ( u16  id,
size_t *  len 
)

Get a new buffer containing the token string value.

Parameters
idtoken id to get
lenpointer to size_t where final string size will be stored. Size does not include final '\0', but may not always be equal to strlen() if cmos has embedded '\0' chars. You must use token_free_string() to free this buffer, or memory will leak.
Returns
pointer to allocated buffer (note: use token_free_string() to free this value). 0 on failure.

◆ token_get_type()

LIBSMBIOS_C_DLL_SPEC int token_get_type ( u16  id)

Return token type.

tokens can be 0xD4, 0xD5, 0xD6, or 0xDA tokens, depending on the smbios table structure they come from.

◆ token_is_active()

LIBSMBIOS_C_DLL_SPEC int token_is_active ( u16  id)

Check if a boolean token is currently set.

Returns
-1 on error, 0 == false, 1 == true

◆ token_is_bool()

LIBSMBIOS_C_DLL_SPEC bool token_is_bool ( u16  id)

Check if a token is a boolean-type token.

Returns
true if token is bool, false if otherwise

◆ token_is_string()

LIBSMBIOS_C_DLL_SPEC bool token_is_string ( u16  id)

Check if a token is a string-type token.

Returns
true if token is a string, false otherwise.

◆ token_set_string()

LIBSMBIOS_C_DLL_SPEC int token_set_string ( u16  id,
const char *  value,
size_t  size 
)

Set a string token value.

Parameters
idtoken id
valuepointer to new token buffer
sizesize of the buffer
Returns
0 on success, <0 on failure.

◆ token_strerror()

LIBSMBIOS_C_DLL_SPEC const char * token_strerror ( )

Returns string describing the last error condition.

Can return 0. The buffer used is guaranteed to be valid until the next call to any token_* function. Copy the contents if you need it longer.

◆ token_string_free()

LIBSMBIOS_C_DLL_SPEC void token_string_free ( char *  )

Free allocated memory.

Use this to free any memory buffer pointers that you get from this module. For example, token_get_string(...)

◆ token_try_password()

LIBSMBIOS_C_DLL_SPEC int token_try_password ( u16  id,
const char *  pass_ascii,
const char *  pass_scancode 
)

For tokens that are password protected, check password.