From e80c87c9bd02de852fa2d13467774617035ea184 Mon Sep 17 00:00:00 2001 From: vysheng Date: Mon, 11 Nov 2013 22:35:31 +0400 Subject: [PATCH] Fixed bug in read config --- config.sample | 26 +++++++++++++------------- main.c | 9 +++------ mtproto-client.c | 2 +- queries.c | 2 +- structures.c | 6 ++++-- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/config.sample b/config.sample index 4415c46..588090f 100644 --- a/config.sample +++ b/config.sample @@ -1,22 +1,22 @@ # This is my real config # Feel free to edit it -default_profile = "tele2" +default_profile = "tele2"; mts = { - test = false - config_directory = ".telegram/mts" - msg_num = true -} + test = false; + config_directory = ".telegram/mts"; + msg_num = true; +}; tele2 = { - test = false - config_directory = ".telegram/tele2" - msg_num = true -} + test = false; + config_directory = ".telegram/tele2"; + msg_num = true; +}; test = { - test = true - config_directory = ".telegram/test" - msg_num = true -} + test = true; + config_directory = ".telegram/test"; + msg_num = true; +}; diff --git a/main.c b/main.c index 4fbc5fb..7873210 100644 --- a/main.c +++ b/main.c @@ -44,6 +44,7 @@ #include "loop.h" #include "mtproto-client.h" +#include "interface.h" #define PROGNAME "telegram-client" #define VERSION "0.01" @@ -162,7 +163,7 @@ void running_for_first_time (void) { assert (asprintf (&config_filename, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, CONFIG_FILE) >= 0); config_filename = make_full_path (config_filename); - struct stat *config_file_stat = NULL; + static struct stat config_file_stat; int config_file_fd; char *config_directory = get_config_directory (); //char *downloads_directory = get_downloads_directory (); @@ -172,17 +173,13 @@ void running_for_first_time (void) { } // see if config file is there - if (stat (config_filename, config_file_stat) != 0) { + if (stat (config_filename, &config_file_stat) != 0) { // config file missing, so touch it config_file_fd = open (config_filename, O_CREAT | O_RDWR, 0600); if (config_file_fd == -1) { perror ("open[config_file]"); exit (EXIT_FAILURE); } - if (fchmod (config_file_fd, CONFIG_DIRECTORY_MODE) != 0) { - perror ("fchmod[" CONFIG_FILE "]"); - exit (EXIT_FAILURE); - } if (write (config_file_fd, DEFAULT_CONFIG_CONTENTS, strlen (DEFAULT_CONFIG_CONTENTS)) <= 0) { perror ("write[config_file]"); exit (EXIT_FAILURE); diff --git a/mtproto-client.c b/mtproto-client.c index c538e44..8435e34 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -1207,7 +1207,7 @@ void work_rpc_result (struct connection *c UU, long long msg_id UU) { } } -#define MAX_PACKED_SIZE (1 << 20) +#define MAX_PACKED_SIZE (1 << 24) void work_packed (struct connection *c, long long msg_id) { assert (fetch_int () == CODE_gzip_packed); static int in_gzip; diff --git a/queries.c b/queries.c index 61664b8..33c2166 100644 --- a/queries.c +++ b/queries.c @@ -179,7 +179,7 @@ void query_error (long long id) { } } -#define MAX_PACKED_SIZE (1 << 20) +#define MAX_PACKED_SIZE (1 << 24) static int packed_buffer[MAX_PACKED_SIZE / 4]; void query_result (long long id UU) { diff --git a/structures.c b/structures.c index bad5cc3..2e7788f 100644 --- a/structures.c +++ b/structures.c @@ -456,8 +456,10 @@ void fetch_photo_size (struct photo_size *S) { S->size = fetch_int (); } else { S->size = prefetch_strlen (); - S->data = malloc (S->size); - memcpy (S->data, fetch_str (S->size), S->size); +// S->data = malloc (S->size); +// assert (S->data); + fetch_str (S->size); +// memcpy (S->data, fetch_str (S->size), S->size); } } }