Embed version info in prop format

This commit is contained in:
topjohnwu
2022-06-19 00:43:27 -07:00
parent db1f5b0397
commit 3c75f474c6
6 changed files with 73 additions and 51 deletions
+15 -3
View File
@@ -338,12 +338,19 @@ void file_readline(bool trim, FILE *fp, const function<bool(string_view)> &fn) {
if (!fn(start))
break;
}
fclose(fp);
free(buf);
}
void parse_prop_file(const char *file, const function<bool(string_view, string_view)> &fn) {
file_readline(true, file, [&](string_view line_view) -> bool {
void file_readline(bool trim, const char *file, const function<bool(string_view)> &fn) {
if (auto fp = open_file(file, "re"))
file_readline(trim, fp.get(), fn);
}
void file_readline(const char *file, const function<bool(string_view)> &fn) {
file_readline(false, file, fn);
}
void parse_prop_file(FILE *fp, const function<bool(string_view, string_view)> &fn) {
file_readline(true, fp, [&](string_view line_view) -> bool {
char *line = (char *) line_view.data();
if (line[0] == '#')
return true;
@@ -355,6 +362,11 @@ void parse_prop_file(const char *file, const function<bool(string_view, string_v
});
}
void parse_prop_file(const char *file, const function<bool(string_view, string_view)> &fn) {
if (auto fp = open_file(file, "re"))
parse_prop_file(fp.get(), fn);
}
// Original source: https://android.googlesource.com/platform/bionic/+/master/libc/bionic/mntent.cpp
// License: AOSP, full copyright notice please check original source
static struct mntent *compat_getmntent_r(FILE *fp, struct mntent *e, char *buf, int buf_len) {