mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 10:35:26 +00:00
Rename Array to Vector
Finally get rid of the C style vector, rename the template class to its proper name
This commit is contained in:
parent
b6965105b7
commit
8745c7884e
@ -24,7 +24,7 @@
|
|||||||
#include "flags.h"
|
#include "flags.h"
|
||||||
|
|
||||||
static char buf[PATH_MAX], buf2[PATH_MAX];
|
static char buf[PATH_MAX], buf2[PATH_MAX];
|
||||||
static Array<CharArray> module_list;
|
static Vector<CharArray> module_list;
|
||||||
|
|
||||||
static int bind_mount(const char *from, const char *to);
|
static int bind_mount(const char *from, const char *to);
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ private:
|
|||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
node_entry *parent;
|
node_entry *parent;
|
||||||
Array<node_entry *> children;
|
Vector<node_entry *> children;
|
||||||
|
|
||||||
node_entry(const char *, const char *, uint8_t type);
|
node_entry(const char *, const char *, uint8_t type);
|
||||||
bool is_root();
|
bool is_root();
|
||||||
@ -478,8 +478,8 @@ static void install_apk(const char *apk) {
|
|||||||
static bool check_data() {
|
static bool check_data() {
|
||||||
bool mnt = false;
|
bool mnt = false;
|
||||||
bool data = false;
|
bool data = false;
|
||||||
Array<CharArray> mounts;
|
Vector<CharArray> mounts;
|
||||||
file_to_array("/proc/mounts", mounts);
|
file_to_vector("/proc/mounts", mounts);
|
||||||
for (auto &line : mounts) {
|
for (auto &line : mounts) {
|
||||||
if (line.contains(" /data ") && !line.contains("tmpfs"))
|
if (line.contains(" /data ") && !line.contains("tmpfs"))
|
||||||
mnt = true;
|
mnt = true;
|
||||||
@ -705,8 +705,8 @@ void startup() {
|
|||||||
xmkdir(BLOCKDIR, 0755);
|
xmkdir(BLOCKDIR, 0755);
|
||||||
|
|
||||||
LOGI("* Mounting mirrors");
|
LOGI("* Mounting mirrors");
|
||||||
Array<CharArray> mounts;
|
Vector<CharArray> mounts;
|
||||||
file_to_array("/proc/mounts", mounts);
|
file_to_vector("/proc/mounts", mounts);
|
||||||
bool system_as_root = false;
|
bool system_as_root = false;
|
||||||
for (auto &line : mounts) {
|
for (auto &line : mounts) {
|
||||||
if (line.contains(" /system_root ")) {
|
if (line.contains(" /system_root ")) {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "flags.h"
|
#include "flags.h"
|
||||||
|
|
||||||
bool log_daemon_started = false;
|
bool log_daemon_started = false;
|
||||||
static Array<const char *> log_cmd, clear_cmd;
|
static Vector<const char *> log_cmd, clear_cmd;
|
||||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -56,7 +56,7 @@ cpio_entry::~cpio_entry() {
|
|||||||
|
|
||||||
// Define the way to sort cpio_entry
|
// Define the way to sort cpio_entry
|
||||||
template<>
|
template<>
|
||||||
int(*Array<cpio_entry*>::_cmp)(cpio_entry*&, cpio_entry*&) = [](auto a, auto b) -> int {
|
int(*Vector<cpio_entry*>::_cmp)(cpio_entry*&, cpio_entry*&) = [](auto a, auto b) -> int {
|
||||||
if (a == b) return 0;
|
if (a == b) return 0;
|
||||||
if (a == nullptr) return 1;
|
if (a == nullptr) return 1;
|
||||||
if (b == nullptr) return -1;
|
if (b == nullptr) return -1;
|
||||||
@ -148,7 +148,7 @@ void cpio::insert(cpio_entry *e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpio::insert(Array<cpio_entry *> &arr) {
|
void cpio::insert(Vector<cpio_entry *> &arr) {
|
||||||
for (auto &e : arr)
|
for (auto &e : arr)
|
||||||
insert(e);
|
insert(e);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "array.h"
|
#include "Vector.h"
|
||||||
#include "CharArray.h"
|
#include "CharArray.h"
|
||||||
|
|
||||||
struct cpio_newc_header {
|
struct cpio_newc_header {
|
||||||
@ -57,14 +57,14 @@ public:
|
|||||||
void makedir(mode_t mode, const char *name);
|
void makedir(mode_t mode, const char *name);
|
||||||
void ln(const char *target, const char *name);
|
void ln(const char *target, const char *name);
|
||||||
void add(mode_t mode, const char *name, const char *file);
|
void add(mode_t mode, const char *name, const char *file);
|
||||||
void insert(Array<cpio_entry *> &arr);
|
void insert(Vector<cpio_entry *> &arr);
|
||||||
bool mv(const char *from, const char *to);
|
bool mv(const char *from, const char *to);
|
||||||
void extract();
|
void extract();
|
||||||
bool extract(const char *name, const char *file);
|
bool extract(const char *name, const char *file);
|
||||||
void sort();
|
void sort();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Array<cpio_entry *> arr;
|
Vector<cpio_entry *> arr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "magiskboot.h"
|
#include "magiskboot.h"
|
||||||
#include "array.h"
|
|
||||||
#include "cpio.h"
|
#include "cpio.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ public:
|
|||||||
int test();
|
int test();
|
||||||
char * sha1();
|
char * sha1();
|
||||||
void restore();
|
void restore();
|
||||||
void backup(Array<cpio_entry*> &bak, const char *orig, const char *sha1);
|
void backup(Vector<cpio_entry*> &bak, const char *orig, const char *sha1);
|
||||||
};
|
};
|
||||||
|
|
||||||
void magisk_cpio::patch(bool keepverity, bool keepforceencrypt) {
|
void magisk_cpio::patch(bool keepverity, bool keepforceencrypt) {
|
||||||
@ -110,7 +109,7 @@ void magisk_cpio::restore() {
|
|||||||
rm("magisk", true);
|
rm("magisk", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void magisk_cpio::backup(Array<cpio_entry*> &bak, const char *orig, const char *sha1) {
|
void magisk_cpio::backup(Vector<cpio_entry*> &bak, const char *orig, const char *sha1) {
|
||||||
cpio_entry *m, *n, *rem, *cksm;
|
cpio_entry *m, *n, *rem, *cksm;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
@ -230,13 +229,13 @@ int cpio_commands(int argc, char *argv[]) {
|
|||||||
free(sha1);
|
free(sha1);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (cmdc >= 2 && strcmp(cmdv[0], "backup") == 0) {
|
} else if (cmdc >= 2 && strcmp(cmdv[0], "backup") == 0) {
|
||||||
Array<cpio_entry*> bak;
|
Vector<cpio_entry*> bak;
|
||||||
cpio.backup(bak, cmdv[1], cmdv[2]);
|
cpio.backup(bak, cmdv[1], cmdv[2]);
|
||||||
cpio.insert(bak);
|
cpio.insert(bak);
|
||||||
} else if (cmdc >= 4 && strcmp(cmdv[0], "magisk") == 0) {
|
} else if (cmdc >= 4 && strcmp(cmdv[0], "magisk") == 0) {
|
||||||
cpio.patch(strcmp(cmdv[2], "true") == 0, strcmp(cmdv[3], "true") == 0);
|
cpio.patch(strcmp(cmdv[2], "true") == 0, strcmp(cmdv[3], "true") == 0);
|
||||||
|
|
||||||
Array<cpio_entry*> bak;
|
Vector<cpio_entry*> bak;
|
||||||
cpio.backup(bak, cmdv[1], cmdv[4]);
|
cpio.backup(bak, cmdv[1], cmdv[4]);
|
||||||
|
|
||||||
auto e = new cpio_entry();
|
auto e = new cpio_entry();
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
Array<CharArray> hide_list;
|
Vector<CharArray> hide_list;
|
||||||
|
|
||||||
static const char *prop_key[] =
|
static const char *prop_key[] =
|
||||||
{ "ro.boot.vbmeta.device_state", "ro.boot.verifiedbootstate", "ro.boot.flash.locked",
|
{ "ro.boot.vbmeta.device_state", "ro.boot.verifiedbootstate", "ro.boot.flash.locked",
|
||||||
@ -232,8 +232,8 @@ bool init_list() {
|
|||||||
|
|
||||||
// Migrate old hide list into database
|
// Migrate old hide list into database
|
||||||
if (access(LEGACY_LIST, R_OK) == 0) {
|
if (access(LEGACY_LIST, R_OK) == 0) {
|
||||||
Array<CharArray> tmp;
|
Vector<CharArray> tmp;
|
||||||
file_to_array(LEGACY_LIST, tmp);
|
file_to_vector(LEGACY_LIST, tmp);
|
||||||
for (auto &s : tmp)
|
for (auto &s : tmp)
|
||||||
add_list(db, s);
|
add_list(db, s);
|
||||||
unlink(LEGACY_LIST);
|
unlink(LEGACY_LIST);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
#include "array.h"
|
#include "Vector.h"
|
||||||
#include "CharArray.h"
|
#include "CharArray.h"
|
||||||
|
|
||||||
#define TERM_THREAD SIGUSR1
|
#define TERM_THREAD SIGUSR1
|
||||||
@ -30,7 +30,7 @@ bool init_list();
|
|||||||
|
|
||||||
extern int hide_enabled;
|
extern int hide_enabled;
|
||||||
extern pthread_mutex_t list_lock;
|
extern pthread_mutex_t list_lock;
|
||||||
extern Array<CharArray> hide_list;
|
extern Vector<CharArray> hide_list;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LAUNCH_MAGISKHIDE,
|
LAUNCH_MAGISKHIDE,
|
||||||
|
@ -63,7 +63,7 @@ static void hide_daemon(int pid) {
|
|||||||
LOGD("hide_daemon: start unmount for pid=[%d]\n", pid);
|
LOGD("hide_daemon: start unmount for pid=[%d]\n", pid);
|
||||||
|
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
Array<CharArray> mounts;
|
Vector<CharArray> mounts;
|
||||||
|
|
||||||
manage_selinux();
|
manage_selinux();
|
||||||
clean_magisk_props();
|
clean_magisk_props();
|
||||||
@ -72,7 +72,7 @@ static void hide_daemon(int pid) {
|
|||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), "/proc/%d/mounts", pid);
|
snprintf(buffer, sizeof(buffer), "/proc/%d/mounts", pid);
|
||||||
file_to_array(buffer, mounts);
|
file_to_vector(buffer, mounts);
|
||||||
|
|
||||||
// Unmount dummy skeletons and /sbin links
|
// Unmount dummy skeletons and /sbin links
|
||||||
for (auto &s : mounts) {
|
for (auto &s : mounts) {
|
||||||
@ -85,7 +85,7 @@ static void hide_daemon(int pid) {
|
|||||||
|
|
||||||
// Re-read mount infos
|
// Re-read mount infos
|
||||||
snprintf(buffer, sizeof(buffer), "/proc/%d/mounts", pid);
|
snprintf(buffer, sizeof(buffer), "/proc/%d/mounts", pid);
|
||||||
file_to_array(buffer, mounts);
|
file_to_vector(buffer, mounts);
|
||||||
|
|
||||||
// Unmount everything under /system, /vendor, and loop mounts
|
// Unmount everything under /system, /vendor, and loop mounts
|
||||||
for (auto &s : mounts) {
|
for (auto &s : mounts) {
|
||||||
|
@ -92,7 +92,7 @@ static const char *type_msg_5 =
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_bracket(char *tok, char *&stmt, Array<const char *> *vec) {
|
static int parse_bracket(char *tok, char *&stmt, Vector<const char *> *vec) {
|
||||||
if (tok == nullptr || tok[0] != '{') {
|
if (tok == nullptr || tok[0] != '{') {
|
||||||
// Not in a bracket
|
// Not in a bracket
|
||||||
vec->push_back(tok);
|
vec->push_back(tok);
|
||||||
@ -134,10 +134,10 @@ static int parse_pattern_1(int action, const char *action_str, char *stmt) {
|
|||||||
|
|
||||||
int state = 0;
|
int state = 0;
|
||||||
char *cur, *cls;
|
char *cur, *cls;
|
||||||
Array<const char*> source, target, permission;
|
Vector<const char*> source, target, permission;
|
||||||
while ((cur = strtok_r(nullptr, " ", &stmt)) != nullptr) {
|
while ((cur = strtok_r(nullptr, " ", &stmt)) != nullptr) {
|
||||||
if (cur[0] == '*') cur = ALL;
|
if (cur[0] == '*') cur = ALL;
|
||||||
Array<const char *> *vec;
|
Vector<const char *> *vec;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case 0:
|
||||||
vec = &source;
|
vec = &source;
|
||||||
@ -191,10 +191,10 @@ static int parse_pattern_2(int action, const char *action_str, char *stmt) {
|
|||||||
|
|
||||||
int state = 0;
|
int state = 0;
|
||||||
char *cur, *range;
|
char *cur, *range;
|
||||||
Array<const char *> source, target, classes;
|
Vector<const char *> source, target, classes;
|
||||||
while ((cur = strtok_r(nullptr, " ", &stmt)) != nullptr) {
|
while ((cur = strtok_r(nullptr, " ", &stmt)) != nullptr) {
|
||||||
if (cur[0] == '*') cur = ALL;
|
if (cur[0] == '*') cur = ALL;
|
||||||
Array<const char *> *vec;
|
Vector<const char *> *vec;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case 0:
|
||||||
vec = &source;
|
vec = &source;
|
||||||
@ -251,7 +251,7 @@ static int parse_pattern_3(int action, const char *action_str, char* stmt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *cur;
|
char *cur;
|
||||||
Array<const char *> domains;
|
Vector<const char *> domains;
|
||||||
while ((cur = strtok_r(nullptr, " {}", &stmt)) != nullptr) {
|
while ((cur = strtok_r(nullptr, " {}", &stmt)) != nullptr) {
|
||||||
if (cur[0] == '*') cur = ALL;
|
if (cur[0] == '*') cur = ALL;
|
||||||
domains.push_back(cur);
|
domains.push_back(cur);
|
||||||
@ -280,10 +280,10 @@ static int parse_pattern_4(int action, const char *action_str, char *stmt) {
|
|||||||
|
|
||||||
int state = 0;
|
int state = 0;
|
||||||
char *cur;
|
char *cur;
|
||||||
Array<const char *> classes, attribute;
|
Vector<const char *> classes, attribute;
|
||||||
while ((cur = strtok_r(nullptr, " ", &stmt)) != nullptr) {
|
while ((cur = strtok_r(nullptr, " ", &stmt)) != nullptr) {
|
||||||
if (cur[0] == '*') cur = ALL;
|
if (cur[0] == '*') cur = ALL;
|
||||||
Array<const char *> *vec;
|
Vector<const char *> *vec;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case 0:
|
||||||
vec = &classes;
|
vec = &classes;
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include "_resetprop.h"
|
#include "_resetprop.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "array.h"
|
|
||||||
|
|
||||||
/* ***********************************************************************
|
/* ***********************************************************************
|
||||||
* Auto generated header and constant definitions compiled from
|
* Auto generated header and constant definitions compiled from
|
||||||
@ -114,7 +113,7 @@ static bool prop_encode(pb_ostream_t *stream, const pb_field_t *field, void * co
|
|||||||
PersistentProperties_PersistentPropertyRecord prop = {};
|
PersistentProperties_PersistentPropertyRecord prop = {};
|
||||||
prop.name.funcs.encode = name_encode;
|
prop.name.funcs.encode = name_encode;
|
||||||
prop.has_value = true;
|
prop.has_value = true;
|
||||||
Array<prop_t> &prop_list = *(Array<prop_t> *) *arg;
|
Vector<prop_t> &prop_list = *(Vector<prop_t> *) *arg;
|
||||||
for (auto &p : prop_list) {
|
for (auto &p : prop_list) {
|
||||||
if (!pb_encode_tag_for_field(stream, field))
|
if (!pb_encode_tag_for_field(stream, field))
|
||||||
return false;
|
return false;
|
||||||
@ -209,7 +208,7 @@ CharArray persist_getprop(const char *name) {
|
|||||||
|
|
||||||
bool persist_deleteprop(const char *name) {
|
bool persist_deleteprop(const char *name) {
|
||||||
if (use_pb) {
|
if (use_pb) {
|
||||||
Array<prop_t> prop_list;
|
Vector<prop_t> prop_list;
|
||||||
read_cb_t read_cb(collect_props, &prop_list);
|
read_cb_t read_cb(collect_props, &prop_list);
|
||||||
persist_getprop(&read_cb);
|
persist_getprop(&read_cb);
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include "resetprop.h"
|
#include "resetprop.h"
|
||||||
#include "_resetprop.h"
|
#include "_resetprop.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "array.h"
|
|
||||||
#include "flags.h"
|
#include "flags.h"
|
||||||
|
|
||||||
bool use_pb = false;
|
bool use_pb = false;
|
||||||
@ -77,7 +76,7 @@ illegal:
|
|||||||
|
|
||||||
// Define the way to sort prop_t
|
// Define the way to sort prop_t
|
||||||
template<>
|
template<>
|
||||||
int(*Array<prop_t>::_cmp)(prop_t&, prop_t&) = [](auto a, auto b) -> int {
|
int(*Vector<prop_t>::_cmp)(prop_t&, prop_t&) = [](auto a, auto b) -> int {
|
||||||
return strcmp(a.name, b.name);
|
return strcmp(a.name, b.name);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -90,12 +89,12 @@ static void read_props(const prop_info *pi, void *read_cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void collect_props(const char *name, const char *value, void *v_plist) {
|
void collect_props(const char *name, const char *value, void *v_plist) {
|
||||||
Array<prop_t> &prop_list = *static_cast<Array<prop_t> *>(v_plist);
|
Vector<prop_t> &prop_list = *static_cast<Vector<prop_t> *>(v_plist);
|
||||||
prop_list.push_back(prop_t(name, value));
|
prop_list.push_back(prop_t(name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void collect_unique_props(const char *name, const char *value, void *v_plist) {
|
static void collect_unique_props(const char *name, const char *value, void *v_plist) {
|
||||||
Array<prop_t> &prop_list = *static_cast<Array<prop_t> *>(v_plist);
|
Vector<prop_t> &prop_list = *static_cast<Vector<prop_t> *>(v_plist);
|
||||||
for (auto &prop : prop_list) {
|
for (auto &prop : prop_list) {
|
||||||
if (strcmp(name, prop.name) == 0)
|
if (strcmp(name, prop.name) == 0)
|
||||||
return;
|
return;
|
||||||
@ -113,7 +112,7 @@ static int init_resetprop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void print_props(bool persist) {
|
static void print_props(bool persist) {
|
||||||
Array<prop_t> prop_list;
|
Vector<prop_t> prop_list;
|
||||||
getprop(collect_props, &prop_list, persist);
|
getprop(collect_props, &prop_list, persist);
|
||||||
prop_list.sort();
|
prop_list.sort();
|
||||||
for (auto &prop : prop_list)
|
for (auto &prop : prop_list)
|
||||||
|
@ -388,7 +388,7 @@ void write_zero(int fd, size_t size) {
|
|||||||
lseek(fd, pos + size, SEEK_SET);
|
lseek(fd, pos + size, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_to_array(const char *filename, Array<CharArray> &arr) {
|
int file_to_vector(const char *filename, Vector<CharArray> &arr) {
|
||||||
if (access(filename, R_OK) != 0)
|
if (access(filename, R_OK) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
char *line = nullptr;
|
char *line = nullptr;
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
#include "cpputils.h"
|
#include "cpputils.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class Array {
|
class Vector {
|
||||||
public:
|
public:
|
||||||
Array() : _data(0), _size(0), _capacity(0) {}
|
Vector() : _data(0), _size(0), _capacity(0) {}
|
||||||
~Array() { delete []_data; }
|
~Vector() { delete []_data; }
|
||||||
|
|
||||||
class iterator {
|
class iterator {
|
||||||
friend class Array;
|
friend class Vector;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
iterator(T* n= 0): _node(n) {}
|
iterator(T* n= 0): _node(n) {}
|
||||||
@ -67,7 +67,7 @@ public:
|
|||||||
T* _node;
|
T* _node;
|
||||||
};
|
};
|
||||||
|
|
||||||
Array &operator=(const Array& a) {
|
Vector &operator=(const Vector& a) {
|
||||||
delete [] _data;
|
delete [] _data;
|
||||||
_data = nullptr;
|
_data = nullptr;
|
||||||
_size = a._size;
|
_size = a._size;
|
||||||
@ -80,7 +80,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array &operator=(Array&& a) {
|
Vector &operator=(Vector&& a) {
|
||||||
delete [] _data;
|
delete [] _data;
|
||||||
_size = a._size;
|
_size = a._size;
|
||||||
_capacity = a._capacity;
|
_capacity = a._capacity;
|
||||||
@ -188,4 +188,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
int(* Array<T>::_cmp)(T&, T&) = nullptr;
|
int(* Vector<T>::_cmp)(T&, T&) = nullptr;
|
@ -13,14 +13,13 @@
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#include "array.h"
|
#include "Vector.h"
|
||||||
#include "CharArray.h"
|
#include "CharArray.h"
|
||||||
#include "cpputils.h"
|
#include "cpputils.h"
|
||||||
|
|
||||||
int file_to_array(const char *filename, Array<CharArray> &arr);
|
int file_to_vector(const char *filename, Vector<CharArray> &arr);
|
||||||
char *strdup2(const char *s, size_t *size = nullptr);
|
char *strdup2(const char *s, size_t *size = nullptr);
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -29,7 +28,7 @@ extern "C" {
|
|||||||
#define UID_SYSTEM (get_system_uid())
|
#define UID_SYSTEM (get_system_uid())
|
||||||
#define UID_RADIO (get_radio_uid())
|
#define UID_RADIO (get_radio_uid())
|
||||||
|
|
||||||
// xwrap.c
|
// xwrap.cpp
|
||||||
|
|
||||||
FILE *xfopen(const char *pathname, const char *mode);
|
FILE *xfopen(const char *pathname, const char *mode);
|
||||||
FILE *xfdopen(int fd, const char *mode);
|
FILE *xfdopen(int fd, const char *mode);
|
||||||
@ -85,7 +84,7 @@ ssize_t xsendfile(int out_fd, int in_fd, off_t *offset, size_t count);
|
|||||||
pid_t xfork();
|
pid_t xfork();
|
||||||
int xpoll(struct pollfd *fds, nfds_t nfds, int timeout);
|
int xpoll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||||
|
|
||||||
// misc.c
|
// misc.cpp
|
||||||
|
|
||||||
unsigned get_shell_uid();
|
unsigned get_shell_uid();
|
||||||
unsigned get_system_uid();
|
unsigned get_system_uid();
|
||||||
@ -108,7 +107,7 @@ ssize_t __getline(char **lineptr, size_t *n, FILE *stream);
|
|||||||
ssize_t __getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
|
ssize_t __getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
|
||||||
int __fsetxattr(int fd, const char *name, const void *value, size_t size, int flags);
|
int __fsetxattr(int fd, const char *name, const void *value, size_t size, int flags);
|
||||||
|
|
||||||
// file.c
|
// file.cpp
|
||||||
|
|
||||||
#define align(p, a) (((p) + (a) - 1) / (a) * (a))
|
#define align(p, a) (((p) + (a) - 1) / (a) * (a))
|
||||||
#define align_off(p, a) (align(p, a) - (p))
|
#define align_off(p, a) (align(p, a) - (p))
|
||||||
|
@ -240,7 +240,7 @@ int exec_array(int err, int *fd, void (*cb)(void), const char *argv[]) {
|
|||||||
|
|
||||||
static int v_exec_command(int err, int *fd, void (*cb)(void), const char *argv0, va_list argv) {
|
static int v_exec_command(int err, int *fd, void (*cb)(void), const char *argv0, va_list argv) {
|
||||||
// Collect va_list into vector
|
// Collect va_list into vector
|
||||||
Array<const char *> args;
|
Vector<const char *> args;
|
||||||
args.push_back(argv0);
|
args.push_back(argv0);
|
||||||
for (const char *arg = va_arg(argv, char*); arg; arg = va_arg(argv, char*))
|
for (const char *arg = va_arg(argv, char*); arg; arg = va_arg(argv, char*))
|
||||||
args.push_back(arg);
|
args.push_back(arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user