| 1 | /* |
| 2 | Authors: |
| 3 | Pavel Březina <[email protected]> |
| 4 | |
| 5 | Copyright (C) 2017 Red Hat |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 3 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #ifndef _COMMON_H_ |
| 22 | #define _COMMON_H_cxx . . $ `src/common/common.h:22:9`! |
| 23 | |
| 24 | #include "config.h"cxx . . $ `<file>/config.h`/ |
| 25 | |
| 26 | #include <stdlib.h> |
| 27 | #include <stdarg.h> |
| 28 | |
| 29 | #include "errno_t.h"cxx . . $ `<file>/src/common/errno_t.h`/ |
| 30 | #include "gettext.h"cxx . . $ `<file>/src/common/gettext.h`/ |
| 31 | #include "authselect.h"cxx . . $ `<file>/include/authselect.h`/ |
| 32 | |
| 33 | #define _cxx . . $ `src/common/common.h:33:9`!(s) gettextcxx . . $ `<external>/9900141763895812947/libintl.h:109:10`!(s) |
| 34 | |
| 35 | /* Wrappers around malloc and realloc to allocate zero-filled |
| 36 | * memory and provide type safety. */ |
| 37 | |
| 38 | #define malloc_zerocxx . . $ `src/common/common.h:38:9`!(type) \ |
| 39 | (type *) calloc(1, sizeof(type)) |
| 40 | |
| 41 | #define malloc_zero_arraycxx . . $ `src/common/common.h:41:9`!(type, num) \ |
| 42 | (type *) calloc((num), sizeof(type)) |
| 43 | |
| 44 | #ifdef HAVE_REALLOCARRAYcxx . . $ `config.h:42:9`! |
| 45 | #define realloc_arraycxx . . $ `src/common/common.h:45:9`!(ptr, type, num) \ |
| 46 | (type *) reallocarray((ptr), (num), sizeof(type)) |
| 47 | #else |
| 48 | #define realloc_array(ptr, type, num) \ |
| 49 | (type *) realloc((ptr), sizeof(type)*(num)) |
| 50 | #endif |
| 51 | |
| 52 | /* Debugging facility. */ |
| 53 | |
| 54 | void set_debug_fncxx . . $ set_debug_fn(10083e02f417e2d6).(authselect_debug_fncxx . . $ authselect_debug_fn# fn, void *pvt); |
| 55 | |
| 56 | void debugcxx . . $ debug(3ee750ffb8c500e3).(enum authselect_debugcxx . . $ authselect_debug# level, |
| 57 | const char *file, |
| 58 | unsigned long line, |
| 59 | const char *function, |
| 60 | const char *fmt, |
| 61 | ...); |
| 62 | |
| 63 | #define INFOcxx . . $ `src/common/common.h:63:9`!(fmt, ...) \ |
| 64 | debug(AUTHSELECT_INFO, __FILE__, __LINE__, __FUNCTION__, \ |
| 65 | gettextcxx . . $ `<external>/9900141763895812947/libintl.h:109:10`!(fmt), ## __VA_ARGS__) |
| 66 | |
| 67 | #define WARNcxx . . $ `src/common/common.h:67:9`!(fmt, ...) \ |
| 68 | debug(AUTHSELECT_WARNING, __FILE__, __LINE__, __FUNCTION__, \ |
| 69 | gettextcxx . . $ `<external>/9900141763895812947/libintl.h:109:10`!(fmt), ## __VA_ARGS__) |
| 70 | |
| 71 | #define ERRORcxx . . $ `src/common/common.h:71:9`!(fmt, ...) \ |
| 72 | debug(AUTHSELECT_ERROR, __FILE__, __LINE__, __FUNCTION__, \ |
| 73 | gettextcxx . . $ `<external>/9900141763895812947/libintl.h:109:10`!(fmt), ## __VA_ARGS__) |
| 74 | |
| 75 | /* Wrapper around aprintf to simplify error handling. */ |
| 76 | char *formatcxx . . $ format(a849077ff1b8d812).(const char *fmt, ...); |
| 77 | char *vaformatcxx . . $ vaformat(db813db1ba4aba5a).(const char *fmt, va_listcxx . . $ va_list# va); |
| 78 | |
| 79 | #endif /* _COMMON_H_ */ |