about summary refs log tree commit diff stats
path: root/src/teliva.c
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-01-04 22:09:23 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-01-04 22:09:23 -0800
commit64f8a1e15d8fc3343ef44fdbadbe6c5dd350c89a (patch)
tree4915f13b883ccfee3b4e52a25dec1ed3a180ce24 /src/teliva.c
parent4798d97a15cbb9653a7b00e549bec02dc2c8be63 (diff)
downloadteliva-64f8a1e15d8fc3343ef44fdbadbe6c5dd350c89a.tar.gz
reorg
Diffstat (limited to 'src/teliva.c')
-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 */