- Main Page
- Classes
- Files

- File List
- File Members

# libacpi.h File Reference

libacpi structures More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes
struct | fan_t
| fan data More...
struct | battery_t
| information found about battery More...
struct | thermal_t
| information about thermal zone More...
struct | adapter_t
| information about ac adapater More...
struct | global_t
| global acpi structure More...
## Defines
#define | PROC_ACPI "/proc/acpi/"
#define | LINE_MAX 256
#define | MAX_NAME 512
#define | MAX_BUF 1024
#define | MAX_ITEMS 10
## Enumerations
enum | { ITEM_EXCEED = -5, DISABLED = -4, NOT_PRESENT = -3, ALLOC_ERR = -2, NOT_SUPPORTED = -1, SUCCESS }
enum | power_state_t { P_AC, P_BATT, P_ERR }
enum | thermal_state_t { T_CRIT, T_HOT, T_PASS, T_ACT, T_OK, T_ERR }
enum | charge_state_t { C_CHARGE, C_DISCHARGE, C_CHARGED, C_NOINFO, C_ERR }
enum | batt_state_t { B_HIGH, B_MED, B_LOW, B_CRIT, B_HARD_CRIT, B_ERR }
enum | thermal_mode_t { CO_ACT, CO_PASS, CO_CRIT, CO_ERR }
enum | fan_state_t { F_ON, F_OFF, F_ERR }
| fan states More...
## Functions
int | init_acpi_batt (global_t *globals)
int | init_acpi_acadapt (global_t *globals)
int | init_acpi_thermal (global_t *globals)
int | init_acpi_fan (global_t *globals)
int | check_acpi_support (void)
int | read_acpi_batt (const int num)
void | read_acpi_acstate (global_t *globals)
int | read_acpi_zone (const int num, global_t *globals)
int | read_acpi_fan (const int num)
## Variables
battery_t | batteries [MAX_ITEMS]
thermal_t | thermals [MAX_ITEMS]
fan_t | fans [MAX_ITEMS]

## Detailed Description

libacpi structures

Definition in file libacpi.h.

## Define Documentation

#define LINE_MAX 256

Definition at line 15 of file libacpi.h.

#define MAX_BUF 1024

Definition at line 17 of file libacpi.h.

#define MAX_ITEMS 10

Definition at line 18 of file libacpi.h.

Referenced by init_acpi_batt(), init_acpi_fan(), init_acpi_thermal(), read_acpi_batt(), read_acpi_fan(), and read_acpi_zone().

#define MAX_NAME 512

Definition at line 16 of file libacpi.h.

Referenced by init_acpi_acadapt(), init_acpi_batt(), init_acpi_fan(), and init_acpi_thermal().

#define PROC_ACPI "/proc/acpi/"

Definition at line 14 of file libacpi.h.

Referenced by init_acpi_acadapt(), init_acpi_batt(), init_acpi_fan(), and init_acpi_thermal().

## Enumeration Type Documentation

anonymous enum

Enumerator:

  ITEM_EXCEED | maximum item count reached
  DISABLED | feature is disabled
  NOT_PRESENT | something is not present
  ALLOC_ERR | an error occurred while allocating space
  NOT_SUPPORTED | a feature is not supported
  SUCCESS | everything was fine

Definition at line 24 of file libacpi.h.

enum batt_state_t

Enumerator:

  B_HIGH | remaining battery life is high
  B_MED | remaining battery life is medium
  B_LOW | remaining battery life is low
  B_CRIT | remaining battery life is critical
  B_HARD_CRIT | remaining battery life is hard critical, you have a few minutes to charge
  B_ERR | some error occurred while reading the battery state

Definition at line 72 of file libacpi.h.

enum charge_state_t

Enumerator:

  C_CHARGE | battery is currently charging
  C_DISCHARGE | battery is currently discharging
  C_CHARGED | battery is charged
  C_NOINFO | hardware doesn't give information about the state
  C_ERR | some error occurred while reading the charge state

Definition at line 60 of file libacpi.h.

enum fan_state_t

fan states

Enumerator:

  F_ON | fan is on
  F_OFF | fan is off
  F_ERR | some error occurred with this fan

Definition at line 96 of file libacpi.h.

enum power_state_t

Enumerator:

  P_AC | if computer runs on AC
  P_BATT | if computer runs on battery
  P_ERR | no information can be found

Definition at line 37 of file libacpi.h.

enum thermal_mode_t

Enumerator:

  CO_ACT | fans will be turned after the temperature passes a critical point
  CO_PASS | devices will be put in a lower power state after a critical point
  CO_CRIT | system goes into suspend to disk if possible after a critical temperature
  CO_ERR | some error occurred while reading the cooling mode

Definition at line 85 of file libacpi.h.

enum thermal_state_t

Enumerator:

  T_CRIT | zone reports critical temperature, will cause system to go to S4
  T_HOT | zone reports high temperature, will cause system to shutdown immediately
  T_PASS | zone is on passive cooling
  T_ACT | zone is on active cooling, more power consumption
  T_OK | zone is ok
  T_ERR | some error occurred while reading the state of the zone

Definition at line 47 of file libacpi.h.

## Function Documentation

int check_acpi_support | ( | void |  | ) |

Checks if the system does support ACPI or not

Returns:
  SUCCESS if the system supports ACPI or, NOT_SUPPORTED

Definition at line 127 of file libacpi.c.

References NOT_SUPPORTED, and SUCCESS.

int init_acpi_acadapt | ( | global_t * | globals | ) |

Finds existing ac adapter and fills the adapt structure with the paths of the important to parse files

Parameters:

  | globals | pointer to global acpi structure

Definition at line 211 of file libacpi.c.

References global_t::adapt, ALLOC_ERR, delete_list(), dir_list(), MAX_NAME, adapter_t::name, NOT_SUPPORTED, PROC_ACPI, read_acpi_acstate(), adapter_t::state_file, SUCCESS, and list_t::top.

Here is the call graph for this function:

int init_acpi_batt | ( | global_t * | globals | ) |

Finds existing batteries and fills the corresponding batteries structures with the paths of the important to parse files

Parameters:

  | globals | pointer to global acpi structure

Definition at line 139 of file libacpi.c.

References battery_t::alarm_file, ALLOC_ERR, global_t::batt_count, batteries, delete_list(), dir_list(), battery_t::info_file, ITEM_EXCEED, MAX_ITEMS, MAX_NAME, battery_t::name, NOT_SUPPORTED, PROC_ACPI, battery_t::state_file, SUCCESS, and list_t::top.

Here is the call graph for this function:

int init_acpi_fan | ( | global_t * | globals | ) |

Finds existing fans and fills corresponding fan structures with the paths of the important to parse files for fan information

Parameters:

  | globals | pointer to global acpi structure

Definition at line 264 of file libacpi.c.

References ALLOC_ERR, delete_list(), dir_list(), global_t::fan_count, fans, ITEM_EXCEED, MAX_ITEMS, MAX_NAME, fan_t::name, NOT_SUPPORTED, PROC_ACPI, fan_t::state_file, SUCCESS, and list_t::top.

Here is the call graph for this function:

int init_acpi_thermal | ( | global_t * | globals | ) |

Finds existing thermal zones and fills corresponding thermal structures with the paths of the important to parse files for thermal information

Parameters:

  | globals | pointer to global acpi structure

Definition at line 298 of file libacpi.c.

References ALLOC_ERR, thermal_t::cooling_file, delete_list(), dir_list(), thermal_t::freq_file, ITEM_EXCEED, MAX_ITEMS, MAX_NAME, thermal_t::name, NOT_SUPPORTED, PROC_ACPI, thermal_t::state_file, SUCCESS, thermal_t::temp_file, global_t::thermal_count, thermals, list_t::top, and thermal_t::trips_file.

Here is the call graph for this function:

void read_acpi_acstate | ( | global_t * | globals | ) |

Looks up if the ac adapter is plugged in or not and sets the values in a struct

Parameters:

  | globals | pointer to the global acpi structure

Definition at line 190 of file libacpi.c.

References adapter_t::ac_state, global_t::adapt, P_AC, P_BATT, P_ERR, and adapter_t::state_file.

Referenced by init_acpi_acadapt().

Here is the caller graph for this function:

int read_acpi_batt | ( | const int | num | ) |

Gathers all information of a given battery and filling a struct with it

Parameters:

  | num | number of battery

Definition at line 608 of file libacpi.c.

References ITEM_EXCEED, MAX_ITEMS, and SUCCESS.

int read_acpi_fan | ( | const int | num | ) |

Gathers all information about given fan and sets the corresponding values in a struct

Parameters:

  | num | number for the fan to read

Definition at line 230 of file libacpi.c.

References F_ERR, F_OFF, F_ON, fan_t::fan_state, fans, ITEM_EXCEED, MAX_ITEMS, NOT_SUPPORTED, fan_t::state_file, and SUCCESS.

int read_acpi_zone | ( | const int | num,
|  | global_t * | globals |
| ) |  |  |

Gathers all information of a given thermal zone and sets the corresponding values in a struct

Parameters:

  | num | zone
  | globals | pointer to global acpi struct, needed if there is just one zone

Definition at line 359 of file libacpi.c.

References CO_ERR, thermal_t::cooling_file, DISABLED, thermal_t::freq_file, thermal_t::frequency, ITEM_EXCEED, MAX_ITEMS, NOT_SUPPORTED, thermal_t::state_file, SUCCESS, T_ERR, thermal_t::temp_file, global_t::temperature, thermal_t::temperature, thermal_t::therm_mode, thermal_t::therm_state, global_t::thermal_count, and thermals.

## Variable Documentation

battery_t batteries[MAX_ITEMS]

Array for existing batteries, loop until globals->battery_count

Definition at line 186 of file libacpi.h.

Referenced by init_acpi_batt().

fan_t fans[MAX_ITEMS]

Array for existing fans, loop until globals->fan_count

Definition at line 196 of file libacpi.h.

Referenced by init_acpi_fan(), and read_acpi_fan().

thermal_t thermals[MAX_ITEMS]

Array for existing thermal zones, loop until globals->thermal_count

Definition at line 191 of file libacpi.h.

Referenced by init_acpi_thermal(), and read_acpi_zone().