1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef _UTILS_H
6#define _UTILS_H
7
8#include <string>
9#include <vector>
10#include "ScopedFd.h"
11
12class StringVectorToCharArray {
13public:
14 StringVectorToCharArray(const std::vector<std::string>& vs) {
15 for (auto& v : vs) {
16 array.push_back(const_cast<char*>(v.c_str()));
17 }
18 array.push_back(nullptr);
19 }
20 char** get() { return array.data(); }
21
22private:
23 std::vector<char*> array;
24};
25
26ssize_t read_to_end(const ScopedFd& fd, size_t offset, void* buf, size_t size);
27uint32_t crc32(uint32_t crc, unsigned char* buf, size_t len);
28size_t page_size();
29size_t ceil_page_size(size_t sz) ;
30
31bool has_effective_caps();
32bool running_under_rr();
33const char* tmp_dir();
34
35const char* ptrace_cmd_name(int request);
36
37#endif /*end #ifndef _UTILS_H*/
38