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

Go to the source code of this file.

Macros

#define smbios_for_each_struct(struct_name)
 looping helper macro.
 
#define smbios_for_each_struct_type(struct_name, struct_type)
 looping helper macro.
 

Functions

LIBSMBIOS_C_DLL_SPEC struct smbios_struct * smbios_get_next_struct (const struct smbios_struct *cur)
 Function for looping over smbios table structures.
 
LIBSMBIOS_C_DLL_SPEC struct smbios_struct * smbios_get_next_struct_by_type (const struct smbios_struct *cur, u8 type)
 Function for looping over smbios table structures by type.
 
LIBSMBIOS_C_DLL_SPEC struct smbios_struct * smbios_get_next_struct_by_handle (const struct smbios_struct *cur, u16 handle)
 Function for looping over smbios table structures by handle.
 
LIBSMBIOS_C_DLL_SPEC void smbios_walk (void(*fn)(const struct smbios_struct *, void *userdata), void *userdata)
 Call a named function for each smbios structure.
 
LIBSMBIOS_C_DLL_SPEC u8 smbios_struct_get_type (const struct smbios_struct *)
 Returns the structure type of a given smbios structure.
 
LIBSMBIOS_C_DLL_SPEC u8 smbios_struct_get_length (const struct smbios_struct *)
 Returns the structure length of a given smbios structure.
 
LIBSMBIOS_C_DLL_SPEC u16 smbios_struct_get_handle (const struct smbios_struct *)
 Returns the structure handle of a given smbios structure.
 
LIBSMBIOS_C_DLL_SPEC int smbios_struct_get_data (const struct smbios_struct *s, void *dest, u8 offset, size_t len)
 Copy data out of the smbios structure.
 
LIBSMBIOS_C_DLL_SPEC const char * smbios_struct_get_string_from_offset (const struct smbios_struct *s, u8 offset)
 get string from smbios structure.
 
LIBSMBIOS_C_DLL_SPEC const char * smbios_struct_get_string_number (const struct smbios_struct *s, u8 which)
 get string from smbios structure.
 
LIBSMBIOS_C_DLL_SPEC char * smbios_strerror ()
 Returns string describing the last error condition.
 

Macro Definition Documentation

◆ smbios_for_each_struct

#define smbios_for_each_struct (   struct_name)
Value:
for( \
const struct smbios_struct *struct_name = smbios_get_next_struct(0);\
struct_name;\
struct_name = smbios_get_next_struct(struct_name)\
)
LIBSMBIOS_C_DLL_SPEC struct smbios_struct * smbios_get_next_struct(const struct smbios_struct *cur)
Function for looping over smbios table structures.

looping helper macro.

This macro makes it easy to loop over each structure in the smbios table

◆ smbios_for_each_struct_type

#define smbios_for_each_struct_type (   struct_name,
  struct_type 
)
Value:
for( \
const struct smbios_struct *struct_name = smbios_get_next_struct_by_type(0, struct_type);\
struct_name;\
struct_name = smbios_get_next_struct_by_type(struct_name, struct_type)\
)
LIBSMBIOS_C_DLL_SPEC struct smbios_struct * smbios_get_next_struct_by_type(const struct smbios_struct *cur, u8 type)
Function for looping over smbios table structures by type.

looping helper macro.

This macro makes it easy to loop over specific structure types in the smbios table

Function Documentation

◆ smbios_get_next_struct()

LIBSMBIOS_C_DLL_SPEC struct smbios_struct * smbios_get_next_struct ( const struct smbios_struct *  cur)

Function for looping over smbios table structures.

Returns a pointer to the next smbios structure. You can cast this structure to a specific smbios structure, or you can use the generic access methods to pull data out of the structure. Returns 0 on end of table.

Parameters
curpointer to current structure, or 0 to begin at the start of the table.
Returns
Pointer to next smbios structure. returns 0 on end of table.

◆ smbios_get_next_struct_by_handle()

LIBSMBIOS_C_DLL_SPEC struct smbios_struct * smbios_get_next_struct_by_handle ( const struct smbios_struct *  cur,
u16  handle 
)

Function for looping over smbios table structures by handle.

Returns a pointer to the next smbios structure with a given handle. You can cast this structure to a specific smbios structure, or you can use the generic access methods to pull data out of the structure. Returns 0 on end of table.

Parameters
curpointer to current structure, or 0 to begin at the start of the table.
handleonly return smbios structures matching handle
Returns
Pointer to next smbios structure. returns 0 on end of table.

◆ smbios_get_next_struct_by_type()

LIBSMBIOS_C_DLL_SPEC struct smbios_struct * smbios_get_next_struct_by_type ( const struct smbios_struct *  cur,
u8  type 
)

Function for looping over smbios table structures by type.

Returns a pointer to the next smbios structure with a given type. You can cast this structure to a specific smbios structure, or you can use the generic access methods to pull data out of the structure. Returns 0 on end of table.

Parameters
curpointer to current structure, or 0 to begin at the start of the table.
typeonly return smbios structures matching type
Returns
Pointer to next smbios structure. returns 0 on end of table.

◆ smbios_strerror()

LIBSMBIOS_C_DLL_SPEC char * smbios_strerror ( )

Returns string describing the last error condition.

Needs to be freed by caller

◆ smbios_struct_get_data()

LIBSMBIOS_C_DLL_SPEC int smbios_struct_get_data ( const struct smbios_struct *  s,
void *  dest,
u8  offset,
size_t  len 
)

Copy data out of the smbios structure.

Does bounds-checking to ensure that structure overflows do not happen.

Parameters
spointer to structure to access
destpointer to user-allocated buffer to fill
offsetoffset in structure
lenlength of data to copy into buffer
Returns
returns 0 on success, <0 on failure.

◆ smbios_struct_get_handle()

LIBSMBIOS_C_DLL_SPEC u16 smbios_struct_get_handle ( const struct smbios_struct *  )

Returns the structure handle of a given smbios structure.

◆ smbios_struct_get_length()

LIBSMBIOS_C_DLL_SPEC u8 smbios_struct_get_length ( const struct smbios_struct *  )

Returns the structure length of a given smbios structure.

◆ smbios_struct_get_string_from_offset()

LIBSMBIOS_C_DLL_SPEC const char * smbios_struct_get_string_from_offset ( const struct smbios_struct *  s,
u8  offset 
)

get string from smbios structure.

Most smbios structures have specific offsets that contain a string number. This function will look up the offset and retrieve the pointed-to string.

Parameters
spointer to smbios structure
offsetoffset containing string pointer
Returns
returns a pointer to the string, or 0 on failure.

◆ smbios_struct_get_string_number()

LIBSMBIOS_C_DLL_SPEC const char * smbios_struct_get_string_number ( const struct smbios_struct *  s,
u8  which 
)

get string from smbios structure.

Retrieves string N from the end of a smbios structure.

Parameters
spointer to smbios structure
whichstring number to return

◆ smbios_struct_get_type()

LIBSMBIOS_C_DLL_SPEC u8 smbios_struct_get_type ( const struct smbios_struct *  )

Returns the structure type of a given smbios structure.

◆ smbios_walk()

LIBSMBIOS_C_DLL_SPEC void smbios_walk ( void(*)(const struct smbios_struct *, void *userdata)  fn,
void *  userdata 
)

Call a named function for each smbios structure.

Calls the given function for each smbios table structure. Passes a pointer to the structure as well as the userdata pointer given.

Parameters
fnpointer to the function to call
userdataopaque pointer that will be passed to the funciton