diff --git a/auto-static.c b/auto-static.c index 8e678da..5e7d844 100644 --- a/auto-static.c +++ b/auto-static.c @@ -1,3 +1,23 @@ +/* + This file is part of tgl-library + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Copyright Vitaly Valtman 2014 +*/ + int skip_double (void) { if (in_ptr + 2 <= in_end) { in_ptr += 2; diff --git a/auto.h b/auto.h index 0c1695e..375da58 100644 --- a/auto.h +++ b/auto.h @@ -1,3 +1,22 @@ +/* + This file is part of tgl-library + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Copyright Vitaly Valtman 2014 +*/ #ifndef __AUTO_H__ #define __AUTO_H__ diff --git a/binlog.c b/binlog.c index 16b47f4..a0fe378 100644 --- a/binlog.c +++ b/binlog.c @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H diff --git a/binlog.h b/binlog.h index 0e60a95..dc1e225 100644 --- a/binlog.h +++ b/binlog.h @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifndef __BINLOG_H__ #define __BINLOG_H__ diff --git a/generate.c b/generate.c index e4313f3..ac7e118 100644 --- a/generate.c +++ b/generate.c @@ -1,3 +1,26 @@ +/* + This file is part of tgl-libary/generate + + Tgl-library/generate is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + Tgl-library/generate is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this tgl-library/generate. If not, see . + + Copyright Vitaly Valtman 2014 + + It is derivative work of VK/KittenPHP-DB-Engine (https://github.com/vk-com/kphp-kdb/) + Copyright 2012-2013 Vkontakte Ltd + 2012-2013 Vitaliy Valtman +*/ + #include #include #include diff --git a/generate.h b/generate.h index 240faa4..be5bc94 100644 --- a/generate.h +++ b/generate.h @@ -1,3 +1,26 @@ +/* + This file is part of tgl-libary/generate + + Tgl-library/generate is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + Tgl-library/generate is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this tgl-library/generate. If not, see . + + Copyright Vitaly Valtman 2014 + + It is derivative work of VK/KittenPHP-DB-Engine (https://github.com/vk-com/kphp-kdb/) + Copyright 2012-2013 Vkontakte Ltd + 2012-2013 Vitaliy Valtman +*/ + #ifndef __GENERATE_H__ #define __GENERATE_H__ diff --git a/interface.c b/interface.c index 78c1b21..d6fa261 100644 --- a/interface.c +++ b/interface.c @@ -1,20 +1,20 @@ /* - This file is part of telegram-client. + This file is part of telegram-cli. - Telegram-client is free software: you can redistribute it and/or modify + Telegram-cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + Telegram-cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + along with this telegram-cli. If not, see . - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H diff --git a/interface.h b/interface.h index e52ec0d..975341a 100644 --- a/interface.h +++ b/interface.h @@ -1,20 +1,20 @@ /* - This file is part of telegram-client. + This file is part of telegram-cli. - Telegram-client is free software: you can redistribute it and/or modify + Telegram-cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + Telegram-cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + along with this telegram-cli. If not, see . - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifndef __INTERFACE_H__ #define __INTERFACE_H__ diff --git a/loop.c b/loop.c index fb38823..4cb0212 100644 --- a/loop.c +++ b/loop.c @@ -1,20 +1,20 @@ /* - This file is part of telegram-client. + This file is part of telegram-cli. - Telegram-client is free software: you can redistribute it and/or modify + Telegram-cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + Telegram-cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + along with this telegram-cli. If not, see . - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H diff --git a/loop.h b/loop.h index 6f7c7e4..8e1c938 100644 --- a/loop.h +++ b/loop.h @@ -1,20 +1,20 @@ /* - This file is part of telegram-client. + This file is part of telegram-cli. - Telegram-client is free software: you can redistribute it and/or modify + Telegram-cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + Telegram-cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + along with this telegram-cli. If not, see . - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifndef __LOOP_H__ #define __LOOP_H__ diff --git a/lua-tg.c b/lua-tg.c index 17abfc3..1a08729 100644 --- a/lua-tg.c +++ b/lua-tg.c @@ -1,3 +1,22 @@ +/* + This file is part of telegram-cli. + + Telegram-cli is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + Telegram-cli is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this telegram-cli. If not, see . + + Copyright Vitaly Valtman 2013-2014 +*/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/lua-tg.h b/lua-tg.h index 353ceef..65346a6 100644 --- a/lua-tg.h +++ b/lua-tg.h @@ -1,3 +1,21 @@ +/* + This file is part of telegram-cli. + + Telegram-cli is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + Telegram-cli is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this telegram-cli. If not, see . + + Copyright Vitaly Valtman 2013-2014 +*/ #ifndef __LUA_TG_H__ #define __LUA_TG_H__ diff --git a/main.c b/main.c index 1a2c413..c2dcae0 100644 --- a/main.c +++ b/main.c @@ -1,20 +1,20 @@ /* - This file is part of telegram-client. + This file is part of telegram-cli. - Telegram-client is free software: you can redistribute it and/or modify + Telegram-cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + Telegram-cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + along with this telegram-cli. If not, see . - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H @@ -519,6 +519,9 @@ int main (int argc, char **argv) { running_for_first_time (); parse_config (); + tgl_set_rsa_key ("/etc/ " PROG_NAME "/server.pub"); + tgl_set_rsa_key ("tg-server.pub"); + get_terminal_attributes (); diff --git a/mtproto-client.c b/mtproto-client.c index 51a4f50..6357a40 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -1,21 +1,22 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Copyright Nikolay Durov, Andrey Lopatin 2012-2013 - Copyright Vitaly Valtman 2013 + Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H @@ -45,7 +46,7 @@ #include #include -#include "telegram.h" +//#include "telegram.h" #include "include.h" #include "queries.h" //#include "loop.h" @@ -1086,21 +1087,26 @@ static int rpc_close (struct connection *c) { #define RANDSEED_PASSWORD_FILENAME NULL #define RANDSEED_PASSWORD_LENGTH 0 -void tglmp_on_start (const char *key) { +void tglmp_on_start (void) { tgl_prng_seed (RANDSEED_PASSWORD_FILENAME, RANDSEED_PASSWORD_LENGTH); - if (key) { + int i; + int ok = 0; + for (i = 0; i < tgl_state.rsa_key_num; i++) { + char *key = tgl_state.rsa_key_list[i]; if (rsa_load_public_key (key) < 0) { - perror ("rsa_load_public_key"); - exit (1); - } - } else { - if (rsa_load_public_key (TG_SERVER_PUBKEY_FILENAME) < 0 - && rsa_load_public_key ("/etc/" PROG_NAME "/server.pub") < 0) { - perror ("rsa_load_public_key"); - exit (1); + vlogprintf (E_WARNING, "Can not load key %s\n", key); + } else { + ok = 1; + break; } } + + if (!ok) { + vlogprintf (E_ERROR, "No pubic keys found\n"); + exit (1); + } + pk_fingerprint = tgl_do_compute_rsa_key_fingerprint (pubKey); } diff --git a/mtproto-client.h b/mtproto-client.h index 77e573c..eb4d4cf 100644 --- a/mtproto-client.h +++ b/mtproto-client.h @@ -1,21 +1,22 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Copyright Nikolay Durov, Andrey Lopatin 2012-2013 - Copyright Vitaly Valtman 2013 + Vitaly Valtman 2013-2014 */ #ifndef __MTPROTO_CLIENT_H__ #define __MTPROTO_CLIENT_H__ @@ -51,6 +52,6 @@ int tglmp_check_DH_params (BIGNUM *p, int g); struct tgl_dc *tglmp_alloc_dc (int id, char *ip, int port); void tgln_insert_msg_id (struct tgl_session *S, long long id); -void tglmp_on_start (const char *key); +void tglmp_on_start (void); void tgl_dc_authorize (struct tgl_dc *DC); #endif diff --git a/mtproto-common.c b/mtproto-common.c index 5f02ae1..53332f2 100644 --- a/mtproto-common.c +++ b/mtproto-common.c @@ -1,21 +1,22 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Copyright Nikolay Durov, Andrey Lopatin 2012-2013 - Copyright Vitaly Valtman 2013 + Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H diff --git a/mtproto-common.h b/mtproto-common.h index 37e9d01..b74c66d 100644 --- a/mtproto-common.h +++ b/mtproto-common.h @@ -1,21 +1,22 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Copyright Nikolay Durov, Andrey Lopatin 2012-2013 - Copyright Vitaly Valtman 2013 + Vitaly Valtman 2013-2014 */ #ifndef __MTPROTO_COMMON_H__ #define __MTPROTO_COMMON_H__ diff --git a/net.c b/net.c index 0ab60f7..ba20b13 100644 --- a/net.c +++ b/net.c @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H diff --git a/net.h b/net.h index 667bd7c..c128d44 100644 --- a/net.h +++ b/net.h @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifndef __NET_H__ #define __NET_H__ diff --git a/no-preview.h b/no-preview.h index ee6bc7e..50d1274 100644 --- a/no-preview.h +++ b/no-preview.h @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ // Just sample jpg file 90x90 diff --git a/queries.c b/queries.c index 2a40968..c4433a6 100644 --- a/queries.c +++ b/queries.c @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H @@ -37,7 +38,7 @@ #include "queries.h" #include "tree.h" #include "mtproto-common.h" -#include "telegram.h" +//#include "telegram.h" #include "loop.h" #include "structures.h" //#include "interface.h" diff --git a/queries.h b/queries.h index 91b0588..407b34b 100644 --- a/queries.h +++ b/queries.h @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ //#include "net.h" #ifndef __QUERIES_H__ diff --git a/structures.c b/structures.c index d70ba3c..6055775 100644 --- a/structures.c +++ b/structures.c @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H @@ -25,7 +26,7 @@ #include #include "structures.h" #include "mtproto-common.h" -#include "telegram.h" +//#include "telegram.h" #include "tree.h" #include "loop.h" #include @@ -38,6 +39,9 @@ #define sha1 SHA1 +#ifndef TGL_MAX_PEER_NUM +# define TGL_MAX_PEER_NUM 100000 +#endif static int id_cmp (struct tgl_message *M1, struct tgl_message *M2); #define peer_cmp(a,b) (tgl_cmp_peer_id (a->id, b->id)) diff --git a/structures.h b/structures.h index 2e6117a..9b0002e 100644 --- a/structures.h +++ b/structures.h @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifndef __STRUCTURES_H__ #define __STRUCTURES_H__ diff --git a/telegram.h b/telegram.h index 5f78cd4..49b16a4 100644 --- a/telegram.h +++ b/telegram.h @@ -1,22 +1,21 @@ /* - This file is part of telegram-client. + This file is part of telegram-cli. - Telegram-client is free software: you can redistribute it and/or modify + Telegram-cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + Telegram-cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + along with this telegram-cli. If not, see . - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ -#define TGL_MAX_PEER_NUM 100000 #ifndef PROG_NAME #define PROG_NAME "telegram-cli" diff --git a/tgl-fetch.h b/tgl-fetch.h index 18e8ed1..3cc5998 100644 --- a/tgl-fetch.h +++ b/tgl-fetch.h @@ -1,3 +1,22 @@ +/* + This file is part of tgl-library + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Copyright Vitaly Valtman 2014 +*/ #ifndef __TGL_FETCH_H__ #define __TGL_FETCH_H__ diff --git a/tgl-inner.h b/tgl-inner.h index 75e829c..a5b4892 100644 --- a/tgl-inner.h +++ b/tgl-inner.h @@ -1,3 +1,23 @@ +/* + This file is part of tgl-library + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Copyright Vitaly Valtman 2014 +*/ + #ifndef __TGL_INNER_H__ #define __TGL_INNER_H__ diff --git a/tgl-layout.h b/tgl-layout.h index 5a830c7..5cd9800 100644 --- a/tgl-layout.h +++ b/tgl-layout.h @@ -1,3 +1,22 @@ +/* + This file is part of tgl-library + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Copyright Vitaly Valtman 2014 +*/ #ifndef __TGL_LAYOUT_H__ #define __TGL_LAYOUT_H__ diff --git a/tgl.c b/tgl.c index 403f698..c6bc345 100644 --- a/tgl.c +++ b/tgl.c @@ -1,3 +1,23 @@ +/* + This file is part of tgl-library + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Copyright Vitaly Valtman 2014 +*/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -36,7 +56,8 @@ void tgl_set_callback (struct tgl_update_callback *cb) { } void tgl_set_rsa_key (const char *key) { - tgl_state.rsa_key = tstrdup (key); + assert (tgl_state.rsa_key_num < TGL_MAX_RSA_KEYS_NUM); + tgl_state.rsa_key_list[tgl_state.rsa_key_num ++] = tstrdup (key); } void tgl_init (void) { @@ -48,7 +69,7 @@ void tgl_init (void) { if (!tgl_state.callback.create_print_name) { tgl_state.callback.create_print_name = tgls_default_create_print_name; } - tglmp_on_start (tgl_state.rsa_key); + tglmp_on_start (); } int tgl_authorized_dc (struct tgl_dc *DC) { diff --git a/tgl.h b/tgl.h index 34ff6ae..2cc16b8 100644 --- a/tgl.h +++ b/tgl.h @@ -1,3 +1,22 @@ +/* + This file is part of tgl-library + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Copyright Vitaly Valtman 2014 +*/ #ifndef __TGL_H__ #define __TGL_H__ @@ -95,6 +114,7 @@ struct tgl_net_methods { #define TGL_LOCK_DIFF 1 +#define TGL_MAX_RSA_KEYS_NUM 10 // Do not modify this structure, unless you know what you do struct tgl_state { int our_id; // ID of logged in user @@ -130,7 +150,8 @@ struct tgl_state { struct tgl_net_methods *net_methods; struct event_base *ev_base; - char *rsa_key; + char *rsa_key_list[TGL_MAX_RSA_KEYS_NUM]; + int rsa_key_num; struct bignum_ctx *BN_ctx; struct tgl_allocator allocator; diff --git a/tl-parser.c b/tl-parser.c index 9b48b46..4c99121 100644 --- a/tl-parser.c +++ b/tl-parser.c @@ -1,25 +1,25 @@ /* - This file is part of VK/KittenPHP-DB-Engine. + This file is part of tgl-libary/tlc - VK/KittenPHP-DB-Engine is free software: you can redistribute it and/or modify + Tgl-library/tlc is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - VK/KittenPHP-DB-Engine is distributed in the hope that it will be useful, + Tgl-library/tlc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VK/KittenPHP-DB-Engine. If not, see . + along with this tgl-library/tlc. If not, see . - This program is released under the GPL with the additional exemption - that compiling, linking, and/or using OpenSSL is allowed. - You are free to remove this exemption from derived works. + Copyright Vitaly Valtman 2014 + It is derivative work of VK/KittenPHP-DB-Engine (https://github.com/vk-com/kphp-kdb/) Copyright 2012-2013 Vkontakte Ltd 2012-2013 Vitaliy Valtman + */ #define _FILE_OFFSET_BITS 64 diff --git a/tl-parser.h b/tl-parser.h index d6d4ddf..faa142b 100644 --- a/tl-parser.h +++ b/tl-parser.h @@ -1,25 +1,25 @@ /* - This file is part of VK/KittenPHP-DB-Engine. + This file is part of tgl-libary/tlc - VK/KittenPHP-DB-Engine is free software: you can redistribute it and/or modify + Tgl-library/tlc is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - VK/KittenPHP-DB-Engine is distributed in the hope that it will be useful, + Tgl-library/tlc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VK/KittenPHP-DB-Engine. If not, see . + along with this tgl-library/tlc. If not, see . - This program is released under the GPL with the additional exemption - that compiling, linking, and/or using OpenSSL is allowed. - You are free to remove this exemption from derived works. + Copyright Vitaly Valtman 2014 + It is derivative work of VK/KittenPHP-DB-Engine (https://github.com/vk-com/kphp-kdb/) Copyright 2012-2013 Vkontakte Ltd 2012-2013 Vitaliy Valtman + */ #ifndef __TL_PARSER_NEW_H__ diff --git a/tlc.c b/tlc.c index a72e2e7..451e612 100644 --- a/tlc.c +++ b/tlc.c @@ -1,25 +1,25 @@ /* - This file is part of VK/KittenPHP-DB-Engine. + This file is part of tgl-libary/tlc - VK/KittenPHP-DB-Engine is free software: you can redistribute it and/or modify + Tgl-library/tlc is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - VK/KittenPHP-DB-Engine is distributed in the hope that it will be useful, + Tgl-library/tlc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VK/KittenPHP-DB-Engine. If not, see . + along with this tgl-library/tlc. If not, see . - This program is released under the GPL with the additional exemption - that compiling, linking, and/or using OpenSSL is allowed. - You are free to remove this exemption from derived works. + Copyright Vitaly Valtman 2014 + It is derivative work of VK/KittenPHP-DB-Engine (https://github.com/vk-com/kphp-kdb/) Copyright 2012-2013 Vkontakte Ltd 2012-2013 Vitaliy Valtman + */ #include diff --git a/tools.c b/tools.c index ff86041..8b2a50c 100644 --- a/tools.c +++ b/tools.c @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifdef HAVE_CONFIG_H diff --git a/tree.h b/tree.h index fdd1515..2f1c284 100644 --- a/tree.h +++ b/tree.h @@ -1,20 +1,21 @@ -/* - This file is part of telegram-client. +/* + This file is part of tgl-library - Telegram-client is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - Telegram-client is distributed in the hope that it will be useful, + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this telegram-client. If not, see . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Copyright Vitaly Valtman 2013 + Copyright Vitaly Valtman 2013-2014 */ #ifndef __TREE_H__ #define __TREE_H__ diff --git a/updates.c b/updates.c index 3c2de30..a3039c0 100644 --- a/updates.c +++ b/updates.c @@ -1,3 +1,22 @@ +/* + This file is part of tgl-library + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Copyright Vitaly Valtman 2013-2014 +*/ #include "tgl.h" #include "updates.h" #include "mtproto-common.h" diff --git a/updates.h b/updates.h index 3348716..8b28be9 100644 --- a/updates.h +++ b/updates.h @@ -1,3 +1,23 @@ +/* + This file is part of tgl-library + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Copyright Vitaly Valtman 2013-2014 +*/ + #ifndef __UPDATES_H__ #define __UPDATES_H__ struct connection;