Commit 4b4a2053 authored by V V's avatar V V

commented binlog code1

parent aabdd3d6
...@@ -7,14 +7,12 @@ test_dc1 = { ...@@ -7,14 +7,12 @@ test_dc1 = {
config_directory = ".telegram/test_dc1"; config_directory = ".telegram/test_dc1";
test = true; test = true;
msg_num = true; msg_num = true;
binlog_enabled = true;
}; };
binlog = { binlog = {
config_directory = ".telegram/binlog"; config_directory = ".telegram/binlog";
test = false; test = false;
msg_num = true; msg_num = true;
binlog_enabled = true;
log_level = 2; log_level = 2;
}; };
...@@ -22,7 +20,6 @@ binlog_mts = { ...@@ -22,7 +20,6 @@ binlog_mts = {
config_directory = ".telegram/binlog_mts"; config_directory = ".telegram/binlog_mts";
test = false; test = false;
msg_num = true; msg_num = true;
binlog_enabled = true;
log_level = 2; log_level = 2;
}; };
...@@ -30,7 +27,6 @@ mega = { ...@@ -30,7 +27,6 @@ mega = {
config_directory = ".telegram/mega"; config_directory = ".telegram/mega";
test = false; test = false;
msg_num = true; msg_num = true;
binlog_enabled = true;
log_level = 2; log_level = 2;
}; };
...@@ -55,12 +51,11 @@ test = { ...@@ -55,12 +51,11 @@ test = {
test1 = { test1 = {
config_directory = ".telegram/test1"; config_directory = ".telegram/test1";
msg_num = true; msg_num = true;
binlog_enabled = true;
}; };
test2 = { test2 = {
config_directory = ".telegram/test2"; config_directory = ".telegram/test2";
msg_num = true; msg_num = true;
binlog_enabled = true; pfs_enabled = true;
}; };
...@@ -111,6 +111,7 @@ int permanent_peer_id_mode; ...@@ -111,6 +111,7 @@ int permanent_peer_id_mode;
int disable_colors; int disable_colors;
extern int alert_sound; extern int alert_sound;
extern int binlog_read; extern int binlog_read;
extern char *home_directory;
int safe_quit; int safe_quit;
...@@ -1589,6 +1590,9 @@ void do_clear (struct command *command, int arg_num, struct arg args[], struct i ...@@ -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 (binlog_file_name);
tfree_str (lua_file); tfree_str (lua_file);
tfree_str (python_file); tfree_str (python_file);
if (home_directory) {
tfree_str (home_directory);
}
clear_history (); clear_history ();
event_free (term_ev); event_free (term_ev);
struct event_base *ev_base = TLS->ev_base; struct event_base *ev_base = TLS->ev_base;
......
...@@ -121,6 +121,7 @@ int alert_sound; ...@@ -121,6 +121,7 @@ int alert_sound;
int exit_code; int exit_code;
int permanent_msg_id_mode; int permanent_msg_id_mode;
int permanent_peer_id_mode; int permanent_peer_id_mode;
char *home_directory;
struct tgl_state *TLS; struct tgl_state *TLS;
...@@ -167,11 +168,11 @@ int str_empty (char *str) { ...@@ -167,11 +168,11 @@ int str_empty (char *str) {
} }
char *get_home_directory (void) { char *get_home_directory (void) {
static char *home_directory = NULL; if (home_directory) { return home_directory; }
home_directory = getenv("TELEGRAM_HOME"); 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"); 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; struct passwd *current_passwd;
uid_t user_id; uid_t user_id;
setpwent (); setpwent ();
...@@ -372,9 +373,13 @@ void parse_config (void) { ...@@ -372,9 +373,13 @@ void parse_config (void) {
if (!python_file) { if (!python_file) {
parse_config_val (&conf, &python_file, "python_script", 0, config_directory); parse_config_val (&conf, &python_file, "python_script", 0, config_directory);
} }
#if 0
strcpy (buf + l, "binlog_enabled"); strcpy (buf + l, "binlog_enabled");
config_lookup_bool (&conf, buf, &binlog_enabled); config_lookup_bool (&conf, buf, &binlog_enabled);
#else
binlog_enabled = 0;
#endif
int pfs_enabled = 0; int pfs_enabled = 0;
strcpy (buf + l, "pfs_enabled"); strcpy (buf + l, "pfs_enabled");
...@@ -415,7 +420,7 @@ void parse_config (void) { ...@@ -415,7 +420,7 @@ void parse_config (void) {
printf ("libconfig not enabled\n"); printf ("libconfig not enabled\n");
} }
tasprintf (&downloads_directory, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, DOWNLOADS_DIRECTORY); tasprintf (&downloads_directory, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, DOWNLOADS_DIRECTORY);
if (binlog_enabled) { if (binlog_enabled) {
tasprintf (&binlog_file_name, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, BINLOG_FILE); tasprintf (&binlog_file_name, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, BINLOG_FILE);
tgl_set_binlog_mode (TLS, 1); tgl_set_binlog_mode (TLS, 1);
...@@ -451,8 +456,10 @@ void usage (void) { ...@@ -451,8 +456,10 @@ void usage (void) {
printf (" --config/-c config file name\n"); printf (" --config/-c config file name\n");
printf (" --profile/-p use specified profile\n"); printf (" --profile/-p use specified profile\n");
#else #else
#if 0
printf (" --enable-binlog/-B enable binlog\n"); printf (" --enable-binlog/-B enable binlog\n");
#endif #endif
#endif
printf (" --log-level/-l log level\n"); printf (" --log-level/-l log level\n");
printf (" --sync-from-start/-f during authorization fetch all messages since registration\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"); printf (" --disable-auto-accept/-E disable auto accept of encrypted chats\n");
...@@ -605,7 +612,9 @@ void args_parse (int argc, char **argv) { ...@@ -605,7 +612,9 @@ void args_parse (int argc, char **argv) {
{"config", required_argument, 0, 'c'}, {"config", required_argument, 0, 'c'},
{"profile", required_argument, 0, 'p'}, {"profile", required_argument, 0, 'p'},
#else #else
#if 0
{"enable-binlog", no_argument, 0, 'B'}, {"enable-binlog", no_argument, 0, 'B'},
#endif
#endif #endif
{"log-level", required_argument, 0, 'l'}, {"log-level", required_argument, 0, 'l'},
{"sync-from-start", no_argument, 0, 'f'}, {"sync-from-start", no_argument, 0, 'f'},
...@@ -647,7 +656,9 @@ void args_parse (int argc, char **argv) { ...@@ -647,7 +656,9 @@ void args_parse (int argc, char **argv) {
#ifdef HAVE_LIBCONFIG #ifdef HAVE_LIBCONFIG
"c:p:" "c:p:"
#else #else
#if 0
"B" "B"
#endif
#endif #endif
#ifdef USE_LUA #ifdef USE_LUA
"s:" "s:"
...@@ -694,9 +705,11 @@ void args_parse (int argc, char **argv) { ...@@ -694,9 +705,11 @@ void args_parse (int argc, char **argv) {
assert (strlen (prefix) <= 100); assert (strlen (prefix) <= 100);
break; break;
#else #else
#if 0
case 'B': case 'B':
binlog_enabled = 1; binlog_enabled = 1;
break; break;
#endif
#endif #endif
case 'l': case 'l':
log_level = atoi (optarg); log_level = atoi (optarg);
......
Subproject commit f8fd296f7cecf6d0ea3a4a7c8d6a9b0fc9ee99e8 Subproject commit 5b18232e9ba1ec696843710b851120a2653cc801
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment