Imported Upstream version 1.0.28
[platform/upstream/alsa-utils.git] / alsactl / alsactl.h
1 extern int debugflag;
2 extern int force_restore;
3 extern int ignore_nocards;
4 extern int do_lock;
5 extern int use_syslog;
6 extern char *command;
7 extern char *statefile;
8 extern char *lockfile;
9
10 void info_(const char *fcn, long line, const char *fmt, ...);
11 void error_(const char *fcn, long line, const char *fmt, ...);
12 void cerror_(const char *fcn, long line, int cond, const char *fmt, ...);
13 void dbg_(const char *fcn, long line, const char *fmt, ...);
14
15 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
16 #define info(...) do { info_(__FUNCTION__, __LINE__, __VA_ARGS__); } while (0)
17 #define error(...) do { error_(__FUNCTION__, __LINE__, __VA_ARGS__); } while (0)
18 #define cerror(cond, ...) do { cerror_(__FUNCTION__, __LINE__, (cond) != 0, __VA_ARGS__); } while (0)
19 #define dbg(...) do { dbg_(__FUNCTION__, __LINE__, __VA_ARGS__); } while (0)
20 #else
21 #define info(args...) do { info_(__FUNCTION__, __LINE__, ##args); }  while (0)
22 #define error(args...) do { error_(__FUNCTION__, __LINE__, ##args); }  while (0)
23 #define cerror(cond, ...) do { error_(__FUNCTION__, __LINE__, (cond) != 0, ##args); } while (0)
24 #define dbg(args...) do { dbg_(__FUNCTION__, __LINE__, ##args); }  while (0)
25 #endif  
26
27 int init(const char *file, const char *cardname);
28 int state_lock(const char *file, int lock, int timeout);
29 int save_state(const char *file, const char *cardname);
30 int load_state(const char *file, const char *initfile, const char *cardname,
31                int do_init);
32 int power(const char *argv[], int argc);
33 int state_daemon(const char *file, const char *cardname, int period,
34                  const char *pidfile);
35 int state_daemon_kill(const char *pidfile, const char *cmd);
36
37 /* utils */
38
39 int file_map(const char *filename, char **buf, size_t *bufsize);
40 void file_unmap(void *buf, size_t bufsize);
41 size_t line_width(const char *buf, size_t bufsize, size_t pos);
42 void initfailed(int cardnumber, const char *reason, int exitcode);
43
44 static inline int hextodigit(int c)
45 {
46         if (c >= '0' && c <= '9')
47                 c -= '0';
48         else if (c >= 'a' && c <= 'f')
49                 c = c - 'a' + 10;
50         else if (c >= 'A' && c <= 'F')
51                 c = c - 'A' + 10;
52         else
53                 return -1;
54         return c;
55 }
56
57 #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a)[0])