usb_moded 0.86.0+mer64
usb_moded-common.h
Go to the documentation of this file.
1
26
27#ifndef USB_MODED_COMMON_H_
28# define USB_MODED_COMMON_H_
29
30# include <stdio.h>
31# include <stdbool.h>
32# include <glib.h>
33
34/* ========================================================================= *
35 * Types
36 * ========================================================================= */
37
46
47typedef enum {
48 CABLE_STATE_UNKNOWN,
49 CABLE_STATE_DISCONNECTED,
50 CABLE_STATE_CHARGER_CONNECTED,
51 CABLE_STATE_PC_CONNECTED,
52 CABLE_STATE_NUMOF
53} cable_state_t;
54
55typedef enum waitres_t
56{
57 WAIT_FAILED,
58 WAIT_READY,
59 WAIT_TIMEOUT,
60} waitres_t;
61
62/* ========================================================================= *
63 * Prototypes
64 * ========================================================================= */
65
66/* ------------------------------------------------------------------------- *
67 * CABLE_STATE
68 * ------------------------------------------------------------------------- */
69
70const char *cable_state_repr(cable_state_t state);
71
72/* ------------------------------------------------------------------------- *
73 * COMMON
74 * ------------------------------------------------------------------------- */
75
76const char *common_map_mode_to_hardware (const char *internal_mode);
77const char *common_map_mode_to_external (const char *internal_mode);
82void common_acquire_wakelock (const char *wakelock_name);
83void common_release_wakelock (const char *wakelock_name);
84int common_system_ (const char *file, int line, const char *func, const char *command);
85FILE *common_popen_ (const char *file, int line, const char *func, const char *command, const char *type);
86waitres_t common_wait (unsigned tot_ms, bool (*ready_cb)(void *aptr), void *aptr);
87bool common_msleep_ (const char *file, int line, const char *func, unsigned msec);
88bool common_modename_is_internal (const char *modename);
89bool common_modename_is_static (const char *modename);
90int common_valid_mode (const char *mode);
91gchar *common_get_mode_list (mode_list_type_t type, uid_t uid);
92
93/* ========================================================================= *
94 * Macros
95 * ========================================================================= */
96
97# define common_system(command) common_system_(__FILE__,__LINE__,__FUNCTION__,(command))
98# define common_popen(command, type) common_popen_(__FILE__,__LINE__,__FUNCTION__,(command),(type))
99# define common_msleep(msec) common_msleep_(__FILE__,__LINE__,__FUNCTION__,(msec))
100# define common_sleep(sec) common_msleep_(__FILE__,__LINE__,__FUNCTION__,(sec)*1000)
101
102/* ========================================================================= *
103 * Constants
104 * ========================================================================= */
105# define UID_UNKNOWN ((uid_t)-1)
106
107#endif /* USB_MODED_COMMON_H_ */
void common_release_wakelock(const char *wakelock_name)
int common_valid_mode(const char *mode)
int common_system_(const char *file, int line, const char *func, const char *command)
void common_send_available_modes_signal(void)
FILE * common_popen_(const char *file, int line, const char *func, const char *command, const char *type)
void common_send_whitelisted_modes_signal(void)
void common_send_hidden_modes_signal(void)
gchar * common_get_mode_list(mode_list_type_t type, uid_t uid)
bool common_modename_is_internal(const char *modename)
void common_acquire_wakelock(const char *wakelock_name)
bool common_msleep_(const char *file, int line, const char *func, unsigned msec)
bool common_modename_is_static(const char *modename)
mode_list_type_t
@ AVAILABLE_MODES_LIST
@ SUPPORTED_MODES_LIST
void common_send_supported_modes_signal(void)