Fixed bug in read config
This commit is contained in:
parent
65edc1789b
commit
e80c87c9bd
@ -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;
|
||||
};
|
||||
|
9
main.c
9
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);
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user