#ifndef CONFIG_H #define CONFIG_H #include #include #define CFG_MAX 512 /* * Per-project hook override loaded from a [project:] section. * Up to CFG_MAX_PROJECT_OVERRIDES overrides are supported. */ #define CFG_MAX_PROJECT_OVERRIDES 64 #define CFG_PROJECT_NAME_LEN 128 typedef struct { char name[CFG_PROJECT_NAME_LEN]; /* project name, e.g. "myproject" */ char post_build_hook[CFG_MAX]; /* hook command for this project */ } GProjectOverride; typedef struct { char git_url[CFG_MAX]; char git_user[256]; char git_token[256]; char git_password[256]; char default_target[128]; char clone_dir[CFG_MAX]; bool log_enabled; char log_dir[CFG_MAX]; /* Post-build hook run after every successful make invocation. * The hook is executed with the repo directory as its CWD. * An empty string means "no hook". */ char post_build_hook[CFG_MAX]; /* Per-project hook overrides from [project:] sections. */ GProjectOverride project_overrides[CFG_MAX_PROJECT_OVERRIDES]; int project_override_count; } GConfig; /* * Return the effective post-build hook for a given project name. * Checks [project:] overrides first; falls back to the global hook. * Returns a pointer into cfg — do not free. */ const char *config_hook_for(const GConfig *cfg, const char *project); void config_defaults(GConfig *cfg); int config_load(GConfig *cfg, const char *path); int config_save(const GConfig *cfg, const char *path); int config_init(const char *path, bool force); void config_show(const GConfig *cfg); void config_get_path(char *out, size_t n); char *expand_tilde(const char *in, char *out, size_t n); #endif /* CONFIG_H */