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 */
13extern 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) */
17extern int    log_level;
18#ifdef nostrip //Modified by Silver to shrink code
19void _log(const char *func, const char *file, int line, const char *format, ...)
20     __attribute__ ((format (printf, 4, 5)));
21void _warn(const char *func, const char *file, int line, const char *format, ...)
22     __attribute__ ((format (printf, 4, 5)));
23void _fatal(const char *func, const char *file, int line, const char *format, ...)
24     __attribute__ ((format (printf, 4, 5))) __attribute__ ((noreturn));
25
26#define log(format, args...) \
27	_log(__FUNCTION__,__FILE__,__LINE__, format , ## args)
28#define warn(format, args...) \
29	_warn(__FUNCTION__,__FILE__,__LINE__, format , ## args)
30#define fatal(format, args...) \
31	_fatal(__FUNCTION__,__FILE__,__LINE__, format , ## args)
32#else
33#define log(format, args...)
34#define warn(format, args...)
35#define fatal(format, args...)
36#endif
37
38int file2fd(const char *path, const char *mode, int fd);
39
40/* signal to pipe delivery implementation */
41
42/* create a signal pipe, returns 0 for success, -1 with errno for failure */
43int sigpipe_create();
44
45/* generic handler for signals, writes signal number to pipe */
46void sigpipe_handler(int signum);
47
48/* assign a signal number to the pipe */
49void sigpipe_assign(int signum);
50
51/* return the signal pipe read file descriptor for select(2) */
52int sigpipe_fd();
53
54/* read and return the pending signal from the pipe */
55int sigpipe_read();
56
57void sigpipe_close();
58
59#endif /* INC_UTIL_H */
60