ref: 7ac411976ba25a99ef02199e86c42abd8917c5a1
parent: e77a9ee2c4394d395f89ffb007a9a83a6b049dbb
author: cancel <cancel@cancel.fm>
date: Wed Jan 15 12:50:06 EST 2020
Cleanup naming
--- a/sysmisc.c
+++ b/sysmisc.c
@@ -339,36 +339,36 @@
return err;
}
-char const *prefs_save_error_string(Prefs_save_error error) {
+char const *ezconf_write_error_string(Ezconf_write_error error) {
switch (error) {
- case Prefs_save_ok:
+ case Ezconf_write_ok:
return "No error";
- case Prefs_save_oom:
+ case Ezconf_write_oom:
return "Out of memory";
- case Prefs_save_no_home:
+ case Ezconf_write_no_home:
return "Unable to resolve $XDG_CONFIG_HOME or $HOME";
- case Prefs_save_mkdir_failed:
+ case Ezconf_write_mkdir_failed:
return "Unable to create $XDG_CONFIG_HOME or $HOME/.config directory";
- case Prefs_save_conf_dir_not_dir:
+ case Ezconf_write_conf_dir_not_dir:
return "Config directory path is not a directory";
- case Prefs_save_old_temp_file_stuck:
+ case Ezconf_write_old_temp_file_stuck:
return "Unable to remove old orca.conf.tmp file";
- case Prefs_save_temp_file_perm_denied:
+ case Ezconf_write_temp_file_perm_denied:
return "Permission denied for config directory";
- case Prefs_save_temp_open_failed:
+ case Ezconf_write_temp_open_failed:
return "Unable to open orca.conf.tmp for writing";
- case Prefs_save_temp_fsync_failed:
+ case Ezconf_write_temp_fsync_failed:
return "fsync() reported an when writing temp file.\n"
"Refusing to continue.";
- case Prefs_save_temp_close_failed:
+ case Ezconf_write_temp_close_failed:
return "Unable to close temp file";
- case Prefs_save_rename_failed:
+ case Ezconf_write_rename_failed:
return "Unable to rename orca.conf.tmp to orca.conf";
- case Prefs_save_line_too_long:
+ case Ezconf_write_line_too_long:
return "Line in file is too long";
- case Prefs_save_existing_read_error:
+ case Ezconf_write_existing_read_error:
return "Error when reading existing configuration file";
- case Prefs_save_unknown_error:
+ case Ezconf_write_unknown_error:
break;
}
return "Unknown";
@@ -396,31 +396,31 @@
*ezcw = (Ezconf_write){0};
ezcw->opts = opts;
ezcw->optscount = optscount;
- Prefs_save_error error = Prefs_save_unknown_error;
+ Ezconf_write_error error = Ezconf_write_unknown_error;
switch (conf_save_start(&ezcw->save)) {
case Conf_save_start_ok:
- error = Prefs_save_ok;
+ error = Ezconf_write_ok;
break;
case Conf_save_start_alloc_failed:
- error = Prefs_save_oom;
+ error = Ezconf_write_oom;
break;
case Conf_save_start_no_home:
- error = Prefs_save_no_home;
+ error = Ezconf_write_no_home;
break;
case Conf_save_start_mkdir_failed:
- error = Prefs_save_mkdir_failed;
+ error = Ezconf_write_mkdir_failed;
break;
case Conf_save_start_conf_dir_not_dir:
- error = Prefs_save_conf_dir_not_dir;
+ error = Ezconf_write_conf_dir_not_dir;
break;
case Conf_save_start_old_temp_file_stuck:
- error = Prefs_save_old_temp_file_stuck;
+ error = Ezconf_write_old_temp_file_stuck;
break;
case Conf_save_start_temp_file_perm_denied:
- error = Prefs_save_temp_file_perm_denied;
+ error = Ezconf_write_temp_file_perm_denied;
break;
case Conf_save_start_temp_file_open_failed:
- error = Prefs_save_temp_open_failed;
+ error = Ezconf_write_temp_open_failed;
break;
}
ezcw->error = error;
@@ -480,10 +480,10 @@
case Conf_read_eof:
goto end_original;
case Conf_read_buffer_too_small:
- ezcw->error = Prefs_save_line_too_long;
+ ezcw->error = Ezconf_write_line_too_long;
goto cancel;
case Conf_read_io_error:
- ezcw->error = Prefs_save_existing_read_error;
+ ezcw->error = Ezconf_write_existing_read_error;
goto cancel;
}
}
@@ -526,19 +526,19 @@
ezcw->stateflags = 0;
return false;
commit:;
- Prefs_save_error error = Prefs_save_unknown_error;
+ Ezconf_write_error error = Ezconf_write_unknown_error;
switch (conf_save_commit(&ezcw->save)) {
case Conf_save_commit_ok:
- error = Prefs_save_ok;
+ error = Ezconf_write_ok;
break;
case Conf_save_commit_temp_fsync_failed:
- error = Prefs_save_temp_fsync_failed;
+ error = Ezconf_write_temp_fsync_failed;
break;
case Conf_save_commit_temp_close_failed:
- error = Prefs_save_temp_close_failed;
+ error = Ezconf_write_temp_close_failed;
break;
case Conf_save_commit_rename_failed:
- error = Prefs_save_rename_failed;
+ error = Ezconf_write_rename_failed;
break;
}
ezcw->error = error;
--- a/sysmisc.h
+++ b/sysmisc.h
@@ -77,25 +77,6 @@
// Finishes. Do not call this with a zeroed `*p`. Afterwards, `*p` will be
// zeroed.
-typedef enum {
- Prefs_save_ok = 0,
- Prefs_save_oom,
- Prefs_save_no_home,
- Prefs_save_mkdir_failed,
- Prefs_save_conf_dir_not_dir,
- Prefs_save_old_temp_file_stuck,
- Prefs_save_temp_file_perm_denied,
- Prefs_save_temp_open_failed,
- Prefs_save_temp_fsync_failed,
- Prefs_save_temp_close_failed,
- Prefs_save_rename_failed,
- Prefs_save_line_too_long,
- Prefs_save_existing_read_error,
- Prefs_save_unknown_error,
-} Prefs_save_error;
-
-char const *prefs_save_error_string(Prefs_save_error error);
-
// Just playing around with this design
typedef struct {
FILE *file;
@@ -108,6 +89,25 @@
bool ezconf_read_step(Ezconf_read *ezcr, char const *const *names,
Usz nameslen);
+typedef enum {
+ Ezconf_write_ok = 0,
+ Ezconf_write_oom,
+ Ezconf_write_no_home,
+ Ezconf_write_mkdir_failed,
+ Ezconf_write_conf_dir_not_dir,
+ Ezconf_write_old_temp_file_stuck,
+ Ezconf_write_temp_file_perm_denied,
+ Ezconf_write_temp_open_failed,
+ Ezconf_write_temp_fsync_failed,
+ Ezconf_write_temp_close_failed,
+ Ezconf_write_rename_failed,
+ Ezconf_write_line_too_long,
+ Ezconf_write_existing_read_error,
+ Ezconf_write_unknown_error,
+} Ezconf_write_error;
+
+char const *ezconf_write_error_string(Ezconf_write_error error);
+
typedef struct {
char const *name;
intptr_t id;
@@ -119,7 +119,7 @@
Confopt_w *opts;
size_t optscount;
intptr_t optid;
- Prefs_save_error error;
+ Ezconf_write_error error;
U32 stateflags;
} Ezconf_write;
--- a/tui_main.c
+++ b/tui_main.c
@@ -2443,7 +2443,7 @@
}
osofree(midi_output_device_name);
if (ez.error) {
- char const *msg = prefs_save_error_string(ez.error);
+ char const *msg = ezconf_write_error_string(ez.error);
qmsg_printf_push("Config Error",
"Error when writing configuration file:\n%s", msg);
}