1 /* 2 BAREOS® - Backup Archiving REcovery Open Sourced 3 4 Copyright (C) 2018-2020 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 #include "lib/message.h" 26 27 class BareosSocket; 28 class ConfigurationParser; 29 class QualifiedResourceNameTypeConverter; 30 enum class BareosVersionNumber : uint32_t; 31 32 void EscapeString(PoolMem& snew, const char* old, int len); 33 bool IsBufZero(char* buf, int len); 34 void lcase(char* str); 35 void BashSpaces(char* str); 36 void BashSpaces(std::string& str); 37 void BashSpaces(PoolMem& pm); 38 void UnbashSpaces(char* str); 39 void UnbashSpaces(PoolMem& pm); 40 bool GetNameAndResourceTypeAndVersionFromHello(const std::string& input, 41 std::string& name, 42 std::string& r_type_str, 43 BareosVersionNumber& version); 44 const char* IndentMultilineString(PoolMem& resultbuffer, 45 const char* multilinestring, 46 const char* separator); 47 char* encode_time(utime_t time, char* buf); 48 bool ConvertTimeoutToTimespec(timespec& timeout, int timeout_in_seconds); 49 char* encode_mode(mode_t mode, char* buf); 50 int DoShellExpansion(char* name, int name_len); 51 void JobstatusToAscii(int JobStatus, char* msg, int maxlen); 52 void JobstatusToAsciiGui(int JobStatus, char* msg, int maxlen); 53 int RunProgram(char* prog, int wait, POOLMEM*& results); 54 int RunProgramFullOutput(char* prog, int wait, POOLMEM*& results); 55 char* action_on_purge_to_string(int aop, PoolMem& ret); 56 const char* job_type_to_str(int type); 57 const char* job_status_to_str(int stat); 58 const char* job_level_to_str(int level); 59 const char* volume_status_to_str(const char* status); 60 void MakeSessionKey(char* key, char* seed, int mode); 61 void EncodeSessionKey(char* encode, char* session, char* key, int maxlen); 62 void DecodeSessionKey(char* decode, char* session, char* key, int maxlen); 63 POOLMEM* edit_job_codes(JobControlRecord* jcr, 64 char* omsg, 65 const char* imsg, 66 const char* to, 67 job_code_callback_t job_code_callback = NULL); 68 void SetWorkingDirectory(const char* wd); 69 const char* last_path_separator(const char* str); 70 void SortCaseInsensitive(std::vector<std::string>& v); 71 std::string getenv_std_string(std::string env_var); 72 void StringToLowerCase(std::string& s); 73 void StringToLowerCase(std::string& out, const std::string& in); 74 75 #endif // BAREOS_LIB_UTIL_H_ 76