| 1 | /* |
| 2 | This file is part of Mtproto-proxy Library. |
| 3 | |
| 4 | Mtproto-proxy Library is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU Lesser General Public License as published by |
| 6 | the Free Software Foundation, either version 2 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | Mtproto-proxy Library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public License |
| 15 | along with Mtproto-proxy Library. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
| 17 | Copyright 2009-2012 Vkontakte Ltd |
| 18 | 2009-2012 Nikolai Durov |
| 19 | 2009-2012 Andrey Lopatin |
| 20 | 2012 Anton Maydell |
| 21 | |
| 22 | Copyright 2014 Telegram Messenger Inc |
| 23 | 2014 Anton Maydell |
| 24 | */ |
| 25 | |
| 26 | #pragma once |
| 27 | |
| 28 | #include <stddef.h> |
| 29 | #include <sys/types.h> |
| 30 | |
| 31 | extern int verbosity; |
| 32 | extern const char *logname; |
| 33 | |
| 34 | void reopen_logs (void); |
| 35 | void reopen_logs_ext (int slave_mode); |
| 36 | int hexdump (const void *start, const void *end); |
| 37 | |
| 38 | extern double reindex_speed; |
| 39 | |
| 40 | // safely writes buf to fd, considering write speed limit |
| 41 | void kdb_write (int fd, const void *buf, long long count, const char *filename); |
| 42 | |
| 43 | // write message with timestamp and pid, safe to call inside handler |
| 44 | int kwrite (int fd, const void *buf, int count); |
| 45 | |
| 46 | // print message with timestamp |
| 47 | void kprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2))); |
| 48 | #define vkprintf(verbosity_level, format, ...) do { \ |
| 49 | if ((verbosity_level) > verbosity) { \ |
| 50 | break; \ |
| 51 | } \ |
| 52 | kprintf ((format), ##__VA_ARGS__); \ |
| 53 | } while (0) |
| 54 | |
| 55 | void nck_write (int fd, const void *data, size_t len); |
| 56 | void nck_pwrite (int fd, const void *data, size_t len, off_t offset); |
| 57 | |