Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
e80c87c9
Commit
e80c87c9
authored
Nov 11, 2013
by
vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in read config
parent
65edc178
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
23 deletions
+22
-23
config.sample
config.sample
+13
-13
main.c
main.c
+3
-6
mtproto-client.c
mtproto-client.c
+1
-1
queries.c
queries.c
+1
-1
structures.c
structures.c
+4
-2
No files found.
config.sample
View file @
e80c87c9
# This is my real config
# This is my real config
# Feel free to edit it
# Feel free to edit it
default_profile = "tele2"
default_profile = "tele2"
;
mts = {
mts = {
test = false
test = false
;
config_directory = ".telegram/mts"
config_directory = ".telegram/mts"
;
msg_num = true
msg_num = true
;
}
}
;
tele2 = {
tele2 = {
test = false
test = false
;
config_directory = ".telegram/tele2"
config_directory = ".telegram/tele2"
;
msg_num = true
msg_num = true
;
}
}
;
test = {
test = {
test = true
test = true
;
config_directory = ".telegram/test"
config_directory = ".telegram/test"
;
msg_num = true
msg_num = true
;
}
}
;
main.c
View file @
e80c87c9
...
@@ -44,6 +44,7 @@
...
@@ -44,6 +44,7 @@
#include "loop.h"
#include "loop.h"
#include "mtproto-client.h"
#include "mtproto-client.h"
#include "interface.h"
#define PROGNAME "telegram-client"
#define PROGNAME "telegram-client"
#define VERSION "0.01"
#define VERSION "0.01"
...
@@ -162,7 +163,7 @@ void running_for_first_time (void) {
...
@@ -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
);
assert
(
asprintf
(
&
config_filename
,
"%s/%s/%s"
,
get_home_directory
(),
CONFIG_DIRECTORY
,
CONFIG_FILE
)
>=
0
);
config_filename
=
make_full_path
(
config_filename
);
config_filename
=
make_full_path
(
config_filename
);
st
ruct
stat
*
config_file_stat
=
NULL
;
st
atic
struct
stat
config_file_stat
;
int
config_file_fd
;
int
config_file_fd
;
char
*
config_directory
=
get_config_directory
();
char
*
config_directory
=
get_config_directory
();
//char *downloads_directory = get_downloads_directory ();
//char *downloads_directory = get_downloads_directory ();
...
@@ -172,17 +173,13 @@ void running_for_first_time (void) {
...
@@ -172,17 +173,13 @@ void running_for_first_time (void) {
}
}
// see if config file is there
// 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 missing, so touch it
config_file_fd
=
open
(
config_filename
,
O_CREAT
|
O_RDWR
,
0600
);
config_file_fd
=
open
(
config_filename
,
O_CREAT
|
O_RDWR
,
0600
);
if
(
config_file_fd
==
-
1
)
{
if
(
config_file_fd
==
-
1
)
{
perror
(
"open[config_file]"
);
perror
(
"open[config_file]"
);
exit
(
EXIT_FAILURE
);
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
)
{
if
(
write
(
config_file_fd
,
DEFAULT_CONFIG_CONTENTS
,
strlen
(
DEFAULT_CONFIG_CONTENTS
))
<=
0
)
{
perror
(
"write[config_file]"
);
perror
(
"write[config_file]"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
...
mtproto-client.c
View file @
e80c87c9
...
@@ -1207,7 +1207,7 @@ void work_rpc_result (struct connection *c UU, long long msg_id UU) {
...
@@ -1207,7 +1207,7 @@ void work_rpc_result (struct connection *c UU, long long msg_id UU) {
}
}
}
}
#define MAX_PACKED_SIZE (1 << 2
0
)
#define MAX_PACKED_SIZE (1 << 2
4
)
void
work_packed
(
struct
connection
*
c
,
long
long
msg_id
)
{
void
work_packed
(
struct
connection
*
c
,
long
long
msg_id
)
{
assert
(
fetch_int
()
==
CODE_gzip_packed
);
assert
(
fetch_int
()
==
CODE_gzip_packed
);
static
int
in_gzip
;
static
int
in_gzip
;
...
...
queries.c
View file @
e80c87c9
...
@@ -179,7 +179,7 @@ void query_error (long long id) {
...
@@ -179,7 +179,7 @@ void query_error (long long id) {
}
}
}
}
#define MAX_PACKED_SIZE (1 << 2
0
)
#define MAX_PACKED_SIZE (1 << 2
4
)
static
int
packed_buffer
[
MAX_PACKED_SIZE
/
4
];
static
int
packed_buffer
[
MAX_PACKED_SIZE
/
4
];
void
query_result
(
long
long
id
UU
)
{
void
query_result
(
long
long
id
UU
)
{
...
...
structures.c
View file @
e80c87c9
...
@@ -456,8 +456,10 @@ void fetch_photo_size (struct photo_size *S) {
...
@@ -456,8 +456,10 @@ void fetch_photo_size (struct photo_size *S) {
S
->
size
=
fetch_int
();
S
->
size
=
fetch_int
();
}
else
{
}
else
{
S
->
size
=
prefetch_strlen
();
S
->
size
=
prefetch_strlen
();
S
->
data
=
malloc
(
S
->
size
);
// S->data = malloc (S->size);
memcpy
(
S
->
data
,
fetch_str
(
S
->
size
),
S
->
size
);
// assert (S->data);
fetch_str
(
S
->
size
);
// memcpy (S->data, fetch_str (S->size), S->size);
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment