diff --git a/config.sample b/config.sample index dffcc44..9e0c60d 100644 --- a/config.sample +++ b/config.sample @@ -7,14 +7,12 @@ test_dc1 = { config_directory = ".telegram/test_dc1"; test = true; msg_num = true; - binlog_enabled = true; }; binlog = { config_directory = ".telegram/binlog"; test = false; msg_num = true; - binlog_enabled = true; log_level = 2; }; @@ -22,7 +20,6 @@ binlog_mts = { config_directory = ".telegram/binlog_mts"; test = false; msg_num = true; - binlog_enabled = true; log_level = 2; }; @@ -30,7 +27,6 @@ mega = { config_directory = ".telegram/mega"; test = false; msg_num = true; - binlog_enabled = true; log_level = 2; }; @@ -55,12 +51,11 @@ test = { test1 = { config_directory = ".telegram/test1"; msg_num = true; - binlog_enabled = true; }; test2 = { config_directory = ".telegram/test2"; msg_num = true; - binlog_enabled = true; + pfs_enabled = true; }; diff --git a/interface.c b/interface.c index 7b6f2dd..df49bdc 100644 --- a/interface.c +++ b/interface.c @@ -111,6 +111,7 @@ int permanent_peer_id_mode; int disable_colors; extern int alert_sound; extern int binlog_read; +extern char *home_directory; int safe_quit; @@ -1589,6 +1590,9 @@ void do_clear (struct command *command, int arg_num, struct arg args[], struct i tfree_str (binlog_file_name); tfree_str (lua_file); tfree_str (python_file); + if (home_directory) { + tfree_str (home_directory); + } clear_history (); event_free (term_ev); struct event_base *ev_base = TLS->ev_base; diff --git a/main.c b/main.c index fe6a632..4776f07 100644 --- a/main.c +++ b/main.c @@ -121,6 +121,7 @@ int alert_sound; int exit_code; int permanent_msg_id_mode; int permanent_peer_id_mode; +char *home_directory; struct tgl_state *TLS; @@ -167,11 +168,11 @@ int str_empty (char *str) { } char *get_home_directory (void) { - static char *home_directory = NULL; + if (home_directory) { return home_directory; } home_directory = getenv("TELEGRAM_HOME"); - if (!str_empty (home_directory)) { return tstrdup (home_directory); } + if (!str_empty (home_directory)) { return home_directory = tstrdup (home_directory); } home_directory = getenv("HOME"); - if (!str_empty (home_directory)) { return tstrdup (home_directory); } + if (!str_empty (home_directory)) { return home_directory = tstrdup (home_directory); } struct passwd *current_passwd; uid_t user_id; setpwent (); @@ -372,9 +373,13 @@ void parse_config (void) { if (!python_file) { parse_config_val (&conf, &python_file, "python_script", 0, config_directory); } - + + #if 0 strcpy (buf + l, "binlog_enabled"); config_lookup_bool (&conf, buf, &binlog_enabled); + #else + binlog_enabled = 0; + #endif int pfs_enabled = 0; strcpy (buf + l, "pfs_enabled"); @@ -415,7 +420,7 @@ void parse_config (void) { printf ("libconfig not enabled\n"); } tasprintf (&downloads_directory, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, DOWNLOADS_DIRECTORY); - + if (binlog_enabled) { tasprintf (&binlog_file_name, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, BINLOG_FILE); tgl_set_binlog_mode (TLS, 1); @@ -451,8 +456,10 @@ void usage (void) { printf (" --config/-c config file name\n"); printf (" --profile/-p use specified profile\n"); #else + #if 0 printf (" --enable-binlog/-B enable binlog\n"); #endif + #endif printf (" --log-level/-l log level\n"); printf (" --sync-from-start/-f during authorization fetch all messages since registration\n"); printf (" --disable-auto-accept/-E disable auto accept of encrypted chats\n"); @@ -605,7 +612,9 @@ void args_parse (int argc, char **argv) { {"config", required_argument, 0, 'c'}, {"profile", required_argument, 0, 'p'}, #else + #if 0 {"enable-binlog", no_argument, 0, 'B'}, + #endif #endif {"log-level", required_argument, 0, 'l'}, {"sync-from-start", no_argument, 0, 'f'}, @@ -647,7 +656,9 @@ void args_parse (int argc, char **argv) { #ifdef HAVE_LIBCONFIG "c:p:" #else + #if 0 "B" + #endif #endif #ifdef USE_LUA "s:" @@ -694,9 +705,11 @@ void args_parse (int argc, char **argv) { assert (strlen (prefix) <= 100); break; #else + #if 0 case 'B': binlog_enabled = 1; break; + #endif #endif case 'l': log_level = atoi (optarg); diff --git a/tgl b/tgl index f8fd296..5b18232 160000 --- a/tgl +++ b/tgl @@ -1 +1 @@ -Subproject commit f8fd296f7cecf6d0ea3a4a7c8d6a9b0fc9ee99e8 +Subproject commit 5b18232e9ba1ec696843710b851120a2653cc801