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