From 64f8a1e15d8fc3343ef44fdbadbe6c5dd350c89a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 4 Jan 2022 22:09:23 -0800 Subject: reorg --- src/teliva.c | 34 +++++++++++++++++----------------- 1 file 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 */ -- cgit 1.4.1-2-gfad0