Magisk/native/jni/resetprop/_resetprop.h

58 lines
1.2 KiB
C
Raw Normal View History

2018-04-28 20:22:42 +08:00
/* resetprop.h - Internal struct definitions
*/
#ifndef MAGISK_PROPS_H
#define MAGISK_PROPS_H
2018-11-07 02:10:38 -05:00
#include <CharArray.h>
2018-07-14 04:34:48 +08:00
#include "resetprop/private/system_properties.h"
2018-04-28 20:22:42 +08:00
#include "logging.h"
struct prop_t {
char *name;
char value[PROP_VALUE_MAX];
2018-11-02 23:56:15 -04:00
prop_t() = default;
prop_t(const char *name) {
this->name = strdup(name);
2018-11-05 14:37:47 -05:00
value[0] = '\0';
2018-11-02 23:56:15 -04:00
}
prop_t(const char *name, const char *value) {
this->name = strdup(name);
strcpy(this->value, value);
}
prop_t& operator= (prop_t&& prop) {
if (this != &prop) {
free(name);
name = prop.name;
strcpy(value, prop.value);
prop.name = nullptr;
}
return *this;
};
~prop_t() {
free(name);
}
2018-04-28 20:22:42 +08:00
};
struct read_cb_t {
2018-11-02 23:56:15 -04:00
void (*cb)(const char *, const char *, void *);
void *arg;
2018-11-05 14:37:47 -05:00
read_cb_t(void (*cb)(const char *, const char *, void *) = nullptr, void *arg = nullptr)
2018-11-02 23:56:15 -04:00
: cb(cb), arg(arg) {}
void exec(const char *name, const char *value) {
cb(name, value, arg);
}
2018-04-28 20:22:42 +08:00
};
2018-11-02 23:56:15 -04:00
#define PERSISTENT_PROPERTY_DIR "/data/property"
extern bool use_pb;
2018-11-07 02:10:38 -05:00
CharArray persist_getprop(const char *name);
2018-11-05 14:37:47 -05:00
void persist_getprop(read_cb_t *read_cb);
2018-04-28 20:22:42 +08:00
bool persist_deleteprop(const char *name);
2018-11-02 23:56:15 -04:00
void collect_props(const char *name, const char *value, void *v_plist);
2018-04-28 20:22:42 +08:00
#endif //MAGISK_PROPS_H