|
1 | | -// |
2 | | -// Created by lukashutak on 21/03/18. |
3 | | -// |
| 1 | +/** |
| 2 | + * \file src/core/utils.h |
| 3 | + * \author Lukas Hutak <[email protected]> |
| 4 | + * \brief Internal core utilities (header file) |
| 5 | + * \date 2018 |
| 6 | + */ |
4 | 7 |
|
| 8 | +/* Copyright (C) 2018 CESNET, z.s.p.o. |
| 9 | + * |
| 10 | + * Redistribution and use in source and binary forms, with or without |
| 11 | + * modification, are permitted provided that the following conditions |
| 12 | + * are met: |
| 13 | + * 1. Redistributions of source code must retain the above copyright |
| 14 | + * notice, this list of conditions and the following disclaimer. |
| 15 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | + * notice, this list of conditions and the following disclaimer in |
| 17 | + * the documentation and/or other materials provided with the |
| 18 | + * distribution. |
| 19 | + * 3. Neither the name of the Company nor the names of its contributors |
| 20 | + * may be used to endorse or promote products derived from this |
| 21 | + * software without specific prior written permission. |
| 22 | + * |
| 23 | + * ALTERNATIVELY, provided that this notice is retained in full, this |
| 24 | + * product may be distributed under the terms of the GNU General Public |
| 25 | + * License (GPL) version 2 or later, in which case the provisions |
| 26 | + * of the GPL apply INSTEAD OF those given above. |
| 27 | + * |
| 28 | + * This software is provided ``as is'', and any express or implied |
| 29 | + * warranties, including, but not limited to, the implied warranties of |
| 30 | + * merchantability and fitness for a particular purpose are disclaimed. |
| 31 | + * In no event shall the company or contributors be liable for any |
| 32 | + * direct, indirect, incidental, special, exemplary, or consequential |
| 33 | + * damages (including, but not limited to, procurement of substitute |
| 34 | + * goods or services; loss of use, data, or profits; or business |
| 35 | + * interruption) however caused and on any theory of liability, whether |
| 36 | + * in contract, strict liability, or tort (including negligence or |
| 37 | + * otherwise) arising in any way out of the use of this software, even |
| 38 | + * if advised of the possibility of such damage. |
| 39 | + * |
| 40 | + */ |
5 | 41 | #ifndef IPFIXCOL_UTILS_H |
6 | 42 | #define IPFIXCOL_UTILS_H |
7 | 43 |
|
| 44 | +#ifdef __cplusplus |
| 45 | +extern "C" { |
| 46 | +#endif |
8 | 47 |
|
9 | | -#include <string.h> |
10 | | - |
11 | | -/** Size of an error buffer message */ |
12 | | -#define IPX_STRERROR_SIZE 128 |
13 | | - |
14 | | -/** |
15 | | - * \def ipx_strerror |
16 | | - * \brief Re-entrant strerror wrapper |
17 | | - * |
18 | | - * Main purpose is to solve issues with different strerror_r definitions. |
19 | | - * \warning The function is defined as a macro that creates a local buffer for an error message. |
20 | | - * Therefore, it cannot be called multiple times at the same scope. |
21 | | - * \code{.c} |
22 | | - * const char *err_str; |
23 | | - * ipx_strerror(errno, err_str); |
24 | | - * printf("ERROR: %s\n", err_str); |
25 | | - * \endcode |
26 | | - * \param[in] errnum An error code |
27 | | - * \param[out] buffer Pointer to the local buffer |
28 | | - */ |
29 | | -#define ipx_strerror(errnum, buffer) \ |
30 | | - char ipx_strerror_buffer[IPX_STRERROR_SIZE]; \ |
31 | | - (buffer) = _Generic((&strerror_r), \ |
32 | | - char *(*)(int, char *, size_t): /* GNU-specific */ \ |
33 | | - strerror_r((errnum), ipx_strerror_buffer, IPX_STRERROR_SIZE), \ |
34 | | - int (*)(int, char *, size_t): /* XSI-compliant */ \ |
35 | | - (strerror_r((errnum), ipx_strerror_buffer, IPX_STRERROR_SIZE) >= 0 \ |
36 | | - ? ipx_strerror_buffer \ |
37 | | - : "Unknown error (strerror_r failed!)") \ |
38 | | - ) |
| 48 | +#include <ipfixcol2.h> |
39 | 49 |
|
40 | | -#endif //IPFIXCOL_UTILS_H |
| 50 | +#ifdef __cplusplus |
| 51 | +} |
| 52 | +#endif |
| 53 | +#endif // IPFIXCOL_UTILS_H |
0 commit comments