aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/teliva.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/teliva.c b/src/teliva.c
index 99f472e..f230ef0 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -1187,6 +1187,23 @@ void initialize_trustedL() {
lua_gc(trustedL, LUA_GCRESTART, 0);
}
+static const char* user_configuration_filename() {
+ const char* home = getenv("HOME");
+ if (home == NULL) {
+ endwin();
+ fprintf(stderr, "$HOME is not set; unclear where to save permissions.\n");
+ abort();
+ }
+ static char config_filename[1024] = {0};
+ memset(config_filename, '\0', 1024);
+ const char* config_home = getenv("XDG_CONFIG_HOME");
+ if (config_home == NULL)
+ snprintf(config_filename, 1024, "%s/.teliva", home);
+ else
+ snprintf(config_filename, 1024, "%s/.teliva", config_home);
+ return config_filename;
+}
+
int file_operation_permitted(const char* filename, const char* mode) {
int oldtop = lua_gettop(trustedL);
lua_getglobal(trustedL, "file_operation_permitted");
@@ -1354,23 +1371,6 @@ static void permissions_view() {
}
}
-static const char* user_configuration_filename() {
- const char* home = getenv("HOME");
- if (home == NULL) {
- endwin();
- fprintf(stderr, "$HOME is not set; unclear where to save permissions.\n");
- abort();
- }
- static char config_filename[1024] = {0};
- memset(config_filename, '\0', 1024);
- const char* config_home = getenv("XDG_CONFIG_HOME");
- if (config_home == NULL)
- snprintf(config_filename, 1024, "%s/.teliva", home);
- else
- snprintf(config_filename, 1024, "%s/.teliva", config_home);
- return config_filename;
-}
-
static void save_permissions_to_user_configuration(lua_State* L) {
const char* rcfilename = user_configuration_filename();
FILE* in = fopen(rcfilename, "r"); /* can be NULL when rcfile doesn't exist */