summaryrefslogtreecommitdiffstats
path: root/src/common/properties.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/properties.h')
-rw-r--r--src/common/properties.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/common/properties.h b/src/common/properties.h
new file mode 100644
index 0000000..789a757
--- /dev/null
+++ b/src/common/properties.h
@@ -0,0 +1,47 @@
+#pragma once
+
+#include "fastfetch.h"
+
+typedef struct FFpropquery {
+ const char* start;
+ FFstrbuf* buffer;
+} FFpropquery;
+
+bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer);
+bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries);
+bool ffParsePropFileHomeValues(const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
+bool ffParsePropFileListValues(const FFlist* list, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
+
+bool ffParsePropLinePointer(const char** line, const char* start, FFstrbuf* buffer);
+
+static inline bool ffParsePropLine(const char* line, const char* start, FFstrbuf* buffer) {
+ return ffParsePropLinePointer(&line, start, buffer);
+}
+
+static inline bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer) {
+ return ffParsePropFileValues(filename, 1, (FFpropquery[]) { { start, buffer } });
+}
+
+static inline bool ffParsePropFileHome(const char* relativeFile, const char* start, FFstrbuf* buffer) {
+ return ffParsePropFileHomeValues(relativeFile, 1, (FFpropquery[]) { { start, buffer } });
+}
+
+static inline bool ffParsePropFileList(const FFlist* list, const char* relativeFile, const char* start, FFstrbuf* buffer) {
+ return ffParsePropFileListValues(list, relativeFile, 1, (FFpropquery[]) { { start, buffer } });
+}
+
+static inline bool ffParsePropFileConfigValues(const char* relativeFile, uint32_t numQueries, FFpropquery* queries) {
+ return ffParsePropFileListValues(&instance.state.platform.configDirs, relativeFile, numQueries, queries);
+}
+
+static inline bool ffParsePropFileConfig(const char* relativeFile, const char* start, FFstrbuf* buffer) {
+ return ffParsePropFileConfigValues(relativeFile, 1, (FFpropquery[]) { { start, buffer } });
+}
+
+static inline bool ffParsePropFileDataValues(const char* relativeFile, uint32_t numQueries, FFpropquery* queries) {
+ return ffParsePropFileListValues(&instance.state.platform.dataDirs, relativeFile, numQueries, queries);
+}
+
+static inline bool ffParsePropFileData(const char* relativeFile, const char* start, FFstrbuf* buffer) {
+ return ffParsePropFileDataValues(relativeFile, 1, (FFpropquery[]) { { start, buffer } });
+}