libacpi: libacpi.c File Reference

- Main Page
- Classes
- Files

- File List
- File Members

# libacpi.c File Reference

`#include <stdio.h>`
`#include <stdlib.h>`
`#include <unistd.h>`
`#include <string.h>`
`#include <dirent.h>`
`#include <ctype.h>`
`#include <stddef.h>`
`#include "libacpi.h"`
`#include "list.h"`

Include dependency graph for libacpi.c:

Go to the source code of this file.

## Classes
struct | acpi_value_t
## Functions
int | check_acpi_support (void)
int | init_acpi_batt (global_t *globals)
void | read_acpi_acstate (global_t *globals)
int | init_acpi_acadapt (global_t *globals)
int | read_acpi_fan (const int num)
int | init_acpi_fan (global_t *globals)
int | init_acpi_thermal (global_t *globals)
int | read_acpi_zone (const int num, global_t *globals)
int | read_acpi_batt (const int num)

## 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, thermal_t::temperature, global_t::temperature, thermal_t::therm_mode, thermal_t::therm_state, global_t::thermal_count, and thermals.