2 extern int force_restore;
3 extern int ignore_nocards;
7 extern char *statefile;
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, ...);
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)
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)
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,
32 int power(const char *argv[], int argc);
33 int state_daemon(const char *file, const char *cardname, int period,
35 int state_daemon_kill(const char *pidfile, const char *cmd);
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);
44 static inline int hextodigit(int c)
46 if (c >= '0' && c <= '9')
48 else if (c >= 'a' && c <= 'f')
50 else if (c >= 'A' && c <= 'F')
57 #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a)[0])