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