style: remove all block comments from header files

This commit is contained in:
2025-12-28 04:01:46 +00:00
parent dc522d5912
commit c927e23f23
38 changed files with 167 additions and 1481 deletions
-23
View File
@@ -12,7 +12,6 @@
#include <string.h>
#include <ctype.h>
/* Default color values (dark modern theme) */
#define DEFAULT_PANEL_BG "#1a1a2e"
#define DEFAULT_PANEL_FG "#e0e0e0"
#define DEFAULT_WS_ACTIVE "#4a90d9"
@@ -27,7 +26,6 @@
#define DEFAULT_NOTIFICATION_BG "#2a2a3e"
#define DEFAULT_NOTIFICATION_FG "#ffffff"
/* ========== Configuration creation/destruction ========== */
Config *config_create(void)
{
@@ -39,7 +37,6 @@ Config *config_create(void)
void config_destroy(Config *cfg)
{
if (cfg != NULL) {
/* Securely wipe API keys before freeing */
secure_wipe(cfg->openrouter_api_key, sizeof(cfg->openrouter_api_key));
secure_wipe(cfg->exa_api_key, sizeof(cfg->exa_api_key));
dwn_free(cfg);
@@ -52,41 +49,34 @@ void config_set_defaults(Config *cfg)
return;
}
/* General */
strncpy(cfg->terminal, "xfce4-terminal", sizeof(cfg->terminal) - 1);
strncpy(cfg->launcher, "dmenu_run", sizeof(cfg->launcher) - 1);
strncpy(cfg->file_manager, "thunar", sizeof(cfg->file_manager) - 1);
cfg->focus_mode = FOCUS_CLICK;
cfg->show_decorations = true;
/* Appearance */
cfg->border_width = DEFAULT_BORDER_WIDTH;
cfg->title_height = DEFAULT_TITLE_HEIGHT;
cfg->panel_height = DEFAULT_PANEL_HEIGHT;
cfg->gap = DEFAULT_GAP;
strncpy(cfg->font_name, "fixed", sizeof(cfg->font_name) - 1);
/* Layout */
cfg->default_master_ratio = 0.55f;
cfg->default_master_count = 1;
cfg->default_layout = LAYOUT_TILING;
/* Panels */
cfg->top_panel_enabled = true;
cfg->bottom_panel_enabled = true;
/* AI (disabled by default, enabled if API key found) */
cfg->openrouter_api_key[0] = '\0';
cfg->exa_api_key[0] = '\0';
strncpy(cfg->ai_model, "google/gemini-2.0-flash-exp:free", sizeof(cfg->ai_model) - 1);
cfg->ai_enabled = false;
/* Paths */
strncpy(cfg->config_path, "~/.config/dwn/config", sizeof(cfg->config_path) - 1);
strncpy(cfg->log_path, "~/.local/share/dwn/dwn.log", sizeof(cfg->log_path) - 1);
}
/* ========== INI Parser ========== */
typedef struct {
Config *cfg;
@@ -181,12 +171,10 @@ bool config_parse_ini(const char *path, ConfigCallback callback, void *user_data
while (fgets(line, sizeof(line), f) != NULL) {
char *trimmed = str_trim(line);
/* Skip empty lines and comments */
if (trimmed[0] == '\0' || trimmed[0] == '#' || trimmed[0] == ';') {
continue;
}
/* Section header */
if (trimmed[0] == '[') {
char *end = strchr(trimmed, ']');
if (end != NULL) {
@@ -196,14 +184,12 @@ bool config_parse_ini(const char *path, ConfigCallback callback, void *user_data
continue;
}
/* Key = value */
char *equals = strchr(trimmed, '=');
if (equals != NULL) {
*equals = '\0';
char *key = str_trim(trimmed);
char *value = str_trim(equals + 1);
/* Remove quotes from value */
size_t vlen = strlen(value);
if (vlen >= 2 && ((value[0] == '"' && value[vlen-1] == '"') ||
(value[0] == '\'' && value[vlen-1] == '\''))) {
@@ -219,7 +205,6 @@ bool config_parse_ini(const char *path, ConfigCallback callback, void *user_data
return true;
}
/* ========== Load configuration ========== */
bool config_load(Config *cfg, const char *path)
{
@@ -227,16 +212,13 @@ bool config_load(Config *cfg, const char *path)
return false;
}
/* Set defaults first */
config_set_defaults(cfg);
/* Determine config path */
const char *config_path = path;
if (config_path == NULL) {
config_path = cfg->config_path;
}
/* Parse config file first (environment variables override below) */
ParseContext ctx = { .cfg = cfg };
char *expanded = expand_path(config_path);
@@ -249,7 +231,6 @@ bool config_load(Config *cfg, const char *path)
dwn_free(expanded);
/* Check for API keys in environment (override config file) */
const char *openrouter_key = getenv("OPENROUTER_API_KEY");
if (openrouter_key != NULL && openrouter_key[0] != '\0') {
strncpy(cfg->openrouter_api_key, openrouter_key, sizeof(cfg->openrouter_api_key) - 1);
@@ -262,7 +243,6 @@ bool config_load(Config *cfg, const char *path)
strncpy(cfg->exa_api_key, exa_key, sizeof(cfg->exa_api_key) - 1);
}
/* Log AI status */
if (cfg->ai_enabled) {
LOG_INFO("AI features enabled");
}
@@ -275,13 +255,11 @@ bool config_reload(Config *cfg)
if (cfg == NULL) {
return false;
}
/* Securely wipe existing API keys before reloading */
secure_wipe(cfg->openrouter_api_key, sizeof(cfg->openrouter_api_key));
secure_wipe(cfg->exa_api_key, sizeof(cfg->exa_api_key));
return config_load(cfg, cfg->config_path);
}
/* ========== Getters ========== */
const char *config_get_terminal(void)
{
@@ -339,7 +317,6 @@ const ColorScheme *config_get_colors(void)
return NULL;
}
/* Initialize colors (must be called after display is open) */
void config_init_colors(Config *cfg)
{
if (cfg == NULL || dwn == NULL || dwn->display == NULL) {