OpenVPN 3 Core Library
Loading...
Searching...
No Matches
logrotate.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
#ifndef OPENVPN_COMMON_LOGROTATE_H
13
#define OPENVPN_COMMON_LOGROTATE_H
14
15
#include <stdio.h>
// for rename()
16
17
#include <
openvpn/common/to_string.hpp
>
18
19
namespace
openvpn
{
20
inline
void
log_rotate
(
const
std::string &fn,
const
int
max_versions)
21
{
22
for
(
int
i = max_versions - 1; i >= 0; --i)
23
{
24
std::string src;
25
if
(i)
26
src = fn +
'.'
+
to_string
(i);
27
else
28
src = fn;
29
std::string dest = fn +
'.'
+
to_string
(i + 1);
30
::rename(src.c_str(), dest.c_str());
31
}
32
}
33
}
// namespace openvpn
34
35
#endif
openvpn
Support deferred server-side state creation when client connects.
Definition
ovpncli.cpp:95
openvpn::to_string
std::string to_string(T value)
Definition
to_string.hpp:33
openvpn::log_rotate
void log_rotate(const std::string &fn, const int max_versions)
Definition
logrotate.hpp:20
to_string.hpp
openvpn
common
logrotate.hpp
Generated by
1.9.8