OpenVPN
status.h
Go to the documentation of this file.
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.
7 *
8 * Copyright (C) 2002-2024 OpenVPN Inc <sales@openvpn.net>
9 *
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.
13 *
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.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24#ifndef STATUS_H
25#define STATUS_H
26
27#include "interval.h"
28
29/*
30 * virtual function interface for status output
31 */
33 void *arg;
34 unsigned int flags_default;
35 void (*func) (void *arg, const unsigned int flags, const char *str);
36};
37
38static inline void
39virtual_output_print(const struct virtual_output *vo, const unsigned int flags, const char *str)
40{
41 (*vo->func)(vo->arg, flags, str);
42}
43
44/*
45 * printf-style interface for inputting/outputting status info
46 */
47
49{
50#define STATUS_OUTPUT_READ (1<<0)
51#define STATUS_OUTPUT_WRITE (1<<1)
52 unsigned int flags;
53
54 char *filename;
55 int fd;
57 const struct virtual_output *vout;
58
60
62
63 bool errors;
64};
65
66struct status_output *status_open(const char *filename,
67 const int refresh_freq,
68 const int msglevel,
69 const struct virtual_output *vout,
70 const unsigned int flags);
71
72bool status_trigger(struct status_output *so);
73
74void status_reset(struct status_output *so);
75
76void status_flush(struct status_output *so);
77
78bool status_close(struct status_output *so);
79
80void status_printf(struct status_output *so, const char *format, ...)
81#ifdef __GNUC__
82#if __USE_MINGW_ANSI_STDIO
83__attribute__ ((format(gnu_printf, 2, 3)))
84#else
85__attribute__ ((format(__printf__, 2, 3)))
86#endif
87#endif
88;
89
90bool status_read(struct status_output *so, struct buffer *buf);
91
92static inline unsigned int
94{
95 if (so)
96 {
97 return so->flags;
98 }
99 else
100 {
101 return 0;
102 }
103}
104
105#endif /* ifndef STATUS_H */
static unsigned int status_rw_flags(const struct status_output *so)
Definition status.h:93
static void virtual_output_print(const struct virtual_output *vo, const unsigned int flags, const char *str)
Definition status.h:39
bool status_trigger(struct status_output *so)
Definition status.c:133
void status_printf(struct status_output *so, const char *format,...)
Definition status.c:222
bool status_read(struct status_output *so, struct buffer *buf)
Definition status.c:268
struct status_output * status_open(const char *filename, const int refresh_freq, const int msglevel, const struct virtual_output *vout, const unsigned int flags)
Definition status.c:61
void status_flush(struct status_output *so)
Definition status.c:157
void status_reset(struct status_output *so)
Definition status.c:148
bool status_close(struct status_output *so)
Definition status.c:188
Wrapper structure for dynamically allocated memory.
Definition buffer.h:61
struct buffer read_buf
Definition status.h:59
const struct virtual_output * vout
Definition status.h:57
bool errors
Definition status.h:63
struct event_timeout et
Definition status.h:61
int msglevel
Definition status.h:56
unsigned int flags
Definition status.h:52
char * filename
Definition status.h:54
unsigned int flags_default
Definition status.h:34
void * arg
Definition status.h:33
void(* func)(void *arg, const unsigned int flags, const char *str)
Definition status.h:35
__attribute__((unused))
Definition test.c:42