/
util.h
60 lines (52 loc) · 2.65 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2018-2018 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef BAREOS_LIB_UTIL_H_
#define BAREOS_LIB_UTIL_H_
#include "lib/ascii_control_characters.h"
class QualifiedResourceNameTypeConverter;
void EscapeString(PoolMem &snew, char *old, int len);
bool IsBufZero(char *buf, int len);
void lcase(char *str);
void BashSpaces(char *str);
void BashSpaces(PoolMem &pm);
void UnbashSpaces(char *str);
void UnbashSpaces(PoolMem &pm);
bool GetNameAndResourceTypeAndVersionFromHello(const std::string &input,
std::string &name,
std::string &r_type_str,
BareosVersionNumber &version);
const char* IndentMultilineString(PoolMem &resultbuffer, const char *multilinestring, const char *separator);
char *encode_time(utime_t time, char *buf);
bool ConvertTimeoutToTimespec(timespec &timeout, int timeout_in_seconds);
char *encode_mode(mode_t mode, char *buf);
int DoShellExpansion(char *name, int name_len);
void JobstatusToAscii(int JobStatus, char *msg, int maxlen);
void JobstatusToAsciiGui(int JobStatus, char *msg, int maxlen);
int RunProgram(char *prog, int wait, POOLMEM *&results);
int RunProgramFullOutput(char *prog, int wait, POOLMEM *&results);
char *action_on_purge_to_string(int aop, PoolMem &ret);
const char *job_type_to_str(int type);
const char *job_status_to_str(int stat);
const char *job_level_to_str(int level);
const char *volume_status_to_str(const char *status);
void MakeSessionKey(char *key, char *seed, int mode);
void EncodeSessionKey(char *encode, char *session, char *key, int maxlen);
void DecodeSessionKey(char *decode, char *session, char *key, int maxlen);
POOLMEM *edit_job_codes(JobControlRecord *jcr, char *omsg, char *imsg, const char *to, job_code_callback_t job_code_callback = NULL);
void SetWorkingDirectory(char *wd);
const char *last_path_separator(const char *str);
#endif // BAREOS_LIB_UTIL_H_