Skip to content

Commit 9efad0f

Browse files
author
vvaltman
committed
fixes
1 parent f3636ce commit 9efad0f

11 files changed

+182
-98
lines changed

‎config.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
/* Define to 1 if you have the `edit' library (-ledit). */
3131
#undef HAVE_LIBEDIT
3232

33+
/* Define to 1 if you have the `event' library (-levent). */
34+
#undef HAVE_LIBEVENT
35+
3336
/* Define to 1 if you have the `m' library (-lm). */
3437
#undef HAVE_LIBM
3538

‎configure

+45
Original file line numberDiff line numberDiff line change
@@ -3424,6 +3424,51 @@ _ACEOF
34243424

34253425
fi
34263426

3427+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for event_base_new in -levent" >&5
3428+
$as_echo_n "checking for event_base_new in -levent... " >&6; }
3429+
if ${ac_cv_lib_event_event_base_new+:} false; then :
3430+
$as_echo_n "(cached) " >&6
3431+
else
3432+
ac_check_lib_save_LIBS=$LIBS
3433+
LIBS="-levent $LIBS"
3434+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3435+
/* end confdefs.h. */
3436+
3437+
/* Override any GCC internal prototype to avoid an error.
3438+
Use char because int might match the return type of a GCC
3439+
builtin and then its argument prototype would still apply. */
3440+
#ifdef __cplusplus
3441+
extern "C"
3442+
#endif
3443+
char event_base_new ();
3444+
int
3445+
main ()
3446+
{
3447+
return event_base_new ();
3448+
;
3449+
return 0;
3450+
}
3451+
_ACEOF
3452+
if ac_fn_c_try_link "$LINENO"; then :
3453+
ac_cv_lib_event_event_base_new=yes
3454+
else
3455+
ac_cv_lib_event_event_base_new=no
3456+
fi
3457+
rm -f core conftest.err conftest.$ac_objext \
3458+
conftest$ac_exeext conftest.$ac_ext
3459+
LIBS=$ac_check_lib_save_LIBS
3460+
fi
3461+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_event_event_base_new" >&5
3462+
$as_echo "$ac_cv_lib_event_event_base_new" >&6; }
3463+
if test "x$ac_cv_lib_event_event_base_new" = xyes; then :
3464+
cat >>confdefs.h <<_ACEOF
3465+
#define HAVE_LIBEVENT 1
3466+
_ACEOF
3467+
3468+
LIBS="-levent $LIBS"
3469+
3470+
fi
3471+
34273472
EXTRA_LIBS=""
34283473

34293474
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_save_prompt in -lreadline" >&5

‎configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ AC_SEARCH_LIBS([clock_gettime], [rt])
1818
AC_SEARCH_LIBS([backtrace], [execinfo])
1919
AC_CHECK_LIB([z], [inflate])
2020
AC_CHECK_LIB([crypto], [AES_set_encrypt_key])
21+
AC_CHECK_LIB([event], [event_base_new])
2122
EXTRA_LIBS=""
2223

2324
AC_CHECK_LIB([readline], [rl_save_prompt],

‎generate.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -942,12 +942,12 @@ void usage (void) {
942942
void logprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
943943
void logprintf (const char *format __attribute__ ((unused)), ...) {
944944
}
945-
945+
/*
946946
void hexdump (int *in_ptr, int *in_end) {
947947
int *ptr = in_ptr;
948948
while (ptr < in_end) { printf (" %08x", *(ptr ++)); }
949949
printf ("\n");
950-
}
950+
}*/
951951

952952
#ifdef HAVE_EXECINFO_H
953953
void print_backtrace (void) {

‎interface.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1514,13 +1514,13 @@ void print_end (void) {
15141514
prompt_was = 0;
15151515
}
15161516

1517-
void hexdump (int *in_ptr, int *in_end) {
1517+
/*void hexdump (int *in_ptr, int *in_end) {
15181518
print_start ();
15191519
int *ptr = in_ptr;
15201520
while (ptr < in_end) { printf (" %08x", *(ptr ++)); }
15211521
printf ("\n");
15221522
print_end ();
1523-
}
1523+
}*/
15241524

15251525
void logprintf (const char *format, ...) {
15261526
int x = 0;

‎interface.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void logprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)))
5050
} while (0);\
5151

5252

53-
void hexdump (int *in_ptr, int *in_end);
53+
//void hexdump (int *in_ptr, int *in_end);
5454

5555
struct tgl_message;
5656
void print_message (struct tgl_message *M);

‎queries.c

+11-8
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
#define PATH_MAX 4096
6262
#endif
6363

64-
int want_dc_num;
64+
//int want_dc_num;
6565
char *get_downloads_directory (void);
6666
//extern int offline_mode;
6767

@@ -80,7 +80,7 @@ static void out_peer_id (tgl_peer_id_t id);
8080

8181
#define memcmp8(a,b) memcmp ((a), (b), 8)
8282
DEFINE_TREE (query, struct query *, memcmp8, 0) ;
83-
struct tree_query *queries_tree;
83+
static struct tree_query *queries_tree;
8484

8585
struct query *tglq_query_get (long long id) {
8686
return tree_lookup_query (queries_tree, (void *)&id);
@@ -208,7 +208,7 @@ void tglq_query_error (long long id) {
208208
static int packed_buffer[MAX_PACKED_SIZE / 4];
209209

210210
void tglq_query_result (long long id UU) {
211-
vlogprintf (E_DEBUG, "result for query #%lld\n", id);
211+
vlogprintf (E_DEBUG, "result for query #%lld. Size %ld bytes\n", id, 4 * (in_end - in_ptr));
212212
/*if (verbosity >= 4) {
213213
logprintf ( "result: ");
214214
hexdump_in ();
@@ -221,6 +221,7 @@ void tglq_query_result (long long id UU) {
221221
int l = prefetch_strlen ();
222222
char *s = fetch_str (l);
223223
int total_out = tgl_inflate (s, l, packed_buffer, MAX_PACKED_SIZE);
224+
vlogprintf (E_DEBUG, "inflated %d bytes\n", total_out);
224225
end = in_ptr;
225226
eend = in_end;
226227
//assert (total_out % 4 == 0);
@@ -246,6 +247,7 @@ void tglq_query_result (long long id UU) {
246247
if (q->methods && q->methods->on_answer) {
247248
if (q->methods->type) {
248249
int *save = in_ptr;
250+
vlogprintf (E_DEBUG, "in_ptr = %p, end_ptr = %p\n", in_ptr, in_end);
249251
if (skip_type_any (q->methods->type) < 0) {
250252
vlogprintf (E_ERROR, "Skipped %ld int out of %ld (type %s)\n", in_ptr - save, in_end - save, q->methods->type->type->id);
251253
assert (0);
@@ -269,8 +271,8 @@ void tglq_query_result (long long id UU) {
269271
}
270272

271273

272-
int max_chat_size;
273-
int max_bcast_size;
274+
//int max_chat_size;
275+
//int max_bcast_size;
274276
//int want_dc_num;
275277
//int new_dc_num;
276278
//extern struct dc *DC_list[];
@@ -337,11 +339,12 @@ static int help_get_config_on_answer (struct query *q UU) {
337339
for (i = 0; i < n; i++) {
338340
fetch_dc_option ();
339341
}
340-
max_chat_size = fetch_int ();
342+
int max_chat_size = fetch_int ();
343+
int max_bcast_size = 0;
341344
if (op == CODE_config) {
342345
max_bcast_size = fetch_int ();
343346
}
344-
vlogprintf (E_DEBUG, "chat_size = %d\n", max_chat_size);
347+
vlogprintf (E_DEBUG, "chat_size = %d, bcast_size = %d\n", max_chat_size, max_bcast_size);
345348

346349
if (q->callback) {
347350
((void (*)(void *, int))(q->callback))(q->callback_extra, 1);
@@ -447,7 +450,7 @@ static struct query_methods phone_call_methods = {
447450
void tgl_do_phone_call (const char *user, const char *hash,void (*callback)(void *callback_extra, int success), void *callback_extra) {
448451
vlogprintf (E_DEBUG, "calling user\n");
449452
//suser = tstrdup (user);
450-
want_dc_num = 0;
453+
//want_dc_num = 0;
451454
clear_packet ();
452455
tgl_do_insert_header ();
453456
out_int (CODE_auth_send_call);

‎tgl.c

+1
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ int tgl_signed_dc (struct dc *DC) {
6060
assert (DC);
6161
return DC->has_auth;
6262
}
63+

‎tgl.h

+7-12
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,14 @@ struct bingnum_ctx;
3333
#define TGL_UPDATE_ACCESS_HASH 16384
3434

3535
struct tgl_allocator {
36-
void *(*talloc)(size_t size);
37-
void *(*trealloc)(void *ptr, size_t old_size, size_t size);
38-
void *(*talloc0)(size_t size);
39-
char *(*tstrdup)(const char *s);
40-
char *(*tstrndup)(const char *s, size_t n);
41-
void (*tfree)(void *ptr, int size);
42-
void (*tfree_str)(void *ptr);
43-
void (*tfree_secure)(void *ptr, int size);
44-
int (*tasprintf)(char **res, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
45-
int (*tsnprintf)(char *buf, int len, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
46-
void (*tcheck)(void);
47-
void (*texists)(void *ptr, int size);
36+
void *(*alloc)(size_t size);
37+
void *(*realloc)(void *ptr, size_t old_size, size_t size);
38+
void (*free)(void *ptr, int size);
39+
void (*check)(void);
40+
void (*exists)(void *ptr, int size);
4841
};
42+
extern struct tgl_allocator tgl_allocator_release;
43+
extern struct tgl_allocator tgl_allocator_debug;
4944

5045
struct tgl_update_callback {
5146
void (*new_msg)(struct tgl_message *M);

0 commit comments

Comments
 (0)