big svn cleanup
[anytun.git] / src / openvpn / status.h
blobbe3c3f3b8572a9e441288418ab42ce9bcc31cd86
1 /*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single TCP/UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
8 * Copyright (C) 2002-2005 OpenVPN Solutions LLC <info@openvpn.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program (see the file COPYING included with this
21 * distribution); if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef STATUS_H
26 #define STATUS_H
28 #include "interval.h"
31 * virtual function interface for status output
33 struct virtual_output {
34 void *arg;
35 unsigned int flags_default;
36 void (*func) (void *arg, const unsigned int flags, const char *str);
39 static inline void
40 virtual_output_print (const struct virtual_output *vo, const unsigned int flags, const char *str)
42 (*vo->func) (vo->arg, flags, str);
46 * printf-style interface for inputting/outputting status info
49 struct status_output
51 # define STATUS_OUTPUT_READ (1<<0)
52 # define STATUS_OUTPUT_WRITE (1<<1)
53 unsigned int flags;
55 char *filename;
56 int fd;
57 int msglevel;
58 const struct virtual_output *vout;
60 struct buffer read_buf;
62 struct event_timeout et;
64 bool errors;
67 struct status_output *status_open (const char *filename,
68 const int refresh_freq,
69 const int msglevel,
70 const struct virtual_output *vout,
71 const unsigned int flags);
73 bool status_trigger_tv (struct status_output *so, struct timeval *tv);
74 bool status_trigger (struct status_output *so);
75 void status_reset (struct status_output *so);
76 void status_flush (struct status_output *so);
77 bool status_close (struct status_output *so);
78 void status_printf (struct status_output *so, const char *format, ...)
79 #ifdef __GNUC__
80 __attribute__ ((format (printf, 2, 3)))
81 #endif
84 bool status_read (struct status_output *so, struct buffer *buf);
86 static inline unsigned int
87 status_rw_flags (const struct status_output *so)
89 if (so)
90 return so->flags;
91 else
92 return 0;
95 #endif