feat|perf: generic&efficient desktop&config parser

This commit is contained in:
2025-06-10 23:44:09 +02:00
parent d13ebfff4e
commit 22c3f7c896
10 changed files with 178 additions and 88 deletions

17
include/desktop.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef DESKTOPH_
#define DESKTOPH_
#include <stdbool.h>
#include <stdio.h>
#include "macros.h"
struct status {
bool finish;
int ret;
};
int read_desktop(FILE* fd, void* ctx, struct status (*cb)(void* ctx, char* NULLABLE table,
char* key, char* value));
#endif

12
include/macros.h Normal file
View File

@@ -0,0 +1,12 @@
// Do we just replace the compiler with clang??
#if defined(__clang__)
#define NULLABLE _Nullable
#else
#define NULLABLE
#endif
#if defined(__clang__)
#define NNULLABLE _Nonnull
#else
#define NNULLABLE
#endif

View File

@@ -3,6 +3,7 @@
#include <sys/types.h>
#include "macros.h"
#include "util.h"
enum session_type {
@@ -12,9 +13,9 @@ enum session_type {
};
struct session {
char* name;
char* exec;
char* tryexec;
char* NNULLABLE name;
char* NNULLABLE exec;
char* NULLABLE tryexec;
enum session_type type;
};