OSDN Git Service

Fix no pic
[uclinux-h8/uClinux-dist.git] / user / pptp / util.h
1 /* util.h ....... error message utilities.
2  *                C. Scott Ananian <cananian@alumni.princeton.edu>
3  *
4  * $Id: util.h,v 1.6 2005/03/10 01:18:20 quozl Exp $
5  */
6
7 #ifndef INC_UTIL_H
8 #define INC_UTIL_H
9
10 /* log_string is an identifier for this pptp process, passed from
11    command line using --log-string=X, and included with every log message.
12    Useful for people with multiple pptp sessions open at a time */
13 extern char * log_string;
14
15 /* log_level sets the logging verbosity. Values range from 0 (errors only)
16    to 1 (errors and warnings) to 2 (high verbosity, for debugging) */
17 extern int    log_level;
18
19 void _debuglog(const char *func, const char *file, int line, const char *format, ...)
20      __attribute__ ((format (printf, 4, 5)));
21 void _log(const char *func, const char *file, int line, const char *format, ...)
22      __attribute__ ((format (printf, 4, 5)));
23 void _warn(const char *func, const char *file, int line, const char *format, ...)
24      __attribute__ ((format (printf, 4, 5)));
25 void _fatal(const char *func, const char *file, int line, const char *format, ...)
26      __attribute__ ((format (printf, 4, 5))) __attribute__ ((noreturn));
27
28 #ifdef DEBUG
29 #define debuglog(format, args...) \
30         _debuglog(__FUNCTION__,__FILE__,__LINE__, format , ## args)
31 #define log(format, args...) \
32         _log(__FUNCTION__,__FILE__,__LINE__, format , ## args)
33 #define warn(format, args...) \
34         _warn(__FUNCTION__,__FILE__,__LINE__, format , ## args)
35 #define fatal(format, args...) \
36         _fatal(__FUNCTION__,__FILE__,__LINE__, format , ## args)
37 #else
38 #define debuglog(format, args...) \
39         do { } while (0)
40 #define log(format, args...) \
41         _log(NULL,NULL,0, format , ## args)
42 #define warn(format, args...) \
43         _warn(NULL,NULL,0, format , ## args)
44 #define fatal(format, args...) \
45         _fatal(NULL,NULL,0, format , ## args)
46 #endif
47
48 int file2fd(const char *path, const char *mode, int fd);
49
50 /* signal to pipe delivery implementation */
51
52 /* create a signal pipe, returns 0 for success, -1 with errno for failure */
53 int sigpipe_create();
54
55 /* generic handler for signals, writes signal number to pipe */
56 void sigpipe_handler(int signum);
57
58 /* assign a signal number to the pipe */
59 void sigpipe_assign(int signum);
60
61 /* return the signal pipe read file descriptor for select(2) */
62 int sigpipe_fd();
63
64 /* read and return the pending signal from the pipe */
65 int sigpipe_read();
66
67 void sigpipe_close();
68
69 #endif /* INC_UTIL_H */