From: Arran Cudbard-Bell Date: Thu, 19 Jul 2018 02:53:25 +0000 (-0400) Subject: Break out more headers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56f13a767f1cf2259e925bbfdcb57b2ad4e92e0f;p=thirdparty%2Ffreeradius-server.git Break out more headers --- diff --git a/src/lib/io/control.c b/src/lib/io/control.c index a1e42065d3d..0842e1c72da 100644 --- a/src/lib/io/control.c +++ b/src/lib/io/control.c @@ -26,7 +26,8 @@ RCSID("$Id$") #include #include -#include +#include +#include #include #include diff --git a/src/lib/io/master.c b/src/lib/io/master.c index 49a0310ec0e..86a19267e16 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #define PR_CONNECTION_MAGIC (0x434f4e4e) diff --git a/src/lib/io/message.c b/src/lib/io/message.c index 2b2029134f2..a5f6b1b302d 100644 --- a/src/lib/io/message.c +++ b/src/lib/io/message.c @@ -25,7 +25,7 @@ RCSID("$Id$") #include -#include +#include #include diff --git a/src/lib/io/ring_buffer.c b/src/lib/io/ring_buffer.c index d0bfc9febd8..0a4f232718c 100644 --- a/src/lib/io/ring_buffer.c +++ b/src/lib/io/ring_buffer.c @@ -25,7 +25,7 @@ RCSID("$Id$") #include -#include +#include #include #include diff --git a/src/lib/io/schedule.c b/src/lib/io/schedule.c index a05de82a9d8..3908866aa35 100644 --- a/src/lib/io/schedule.c +++ b/src/lib/io/schedule.c @@ -29,6 +29,7 @@ RCSID("$Id$") #include #include #include +#include #ifdef HAVE_PTHREAD_H #include diff --git a/src/lib/tls/conf.c b/src/lib/tls/conf.c index 4f330f5bea6..52cfe2f895b 100644 --- a/src/lib/tls/conf.c +++ b/src/lib/tls/conf.c @@ -38,6 +38,7 @@ USES_APPLE_DEPRECATED_API /* OpenSSL API has been deprecated by Apple */ #include #include #include +#include #include /** Certificate formats diff --git a/src/lib/util/base.h b/src/lib/util/base.h index d303747f3ac..f0c182c96a5 100644 --- a/src/lib/util/base.h +++ b/src/lib/util/base.h @@ -50,6 +50,11 @@ RCSIDH(libradius_h, "$Id$") # include #endif +#include + +#include +#include +#include #include #include #include @@ -58,19 +63,22 @@ RCSIDH(libradius_h, "$Id$") #include #include -#include -#include #include #include #include #include +#include #include -#include + #include #include #include #include #include +#include + +#include +#include #ifdef SIZEOF_UNSIGNED_INT # if SIZEOF_UNSIGNED_INT != 4 @@ -96,56 +104,10 @@ typedef void (*sig_t)(int); # define FREE_MAGIC (0xF4EEF4EE) #endif -/* - * Printing functions. - */ -size_t fr_utf8_char(uint8_t const *str, ssize_t inlen); -ssize_t fr_utf8_str(uint8_t const *str, ssize_t inlen); -char const *fr_utf8_strchr(int *chr_len, char const *str, char const *chr); -size_t fr_snprint(char *out, size_t outlen, char const *in, ssize_t inlen, char quote); -size_t fr_snprint_len(char const *in, ssize_t inlen, char quote); -char *fr_asprint(TALLOC_CTX *ctx, char const *in, ssize_t inlen, char quote); -char *fr_vasprintf(TALLOC_CTX *ctx, char const *fmt, va_list ap); -char *fr_asprintf(TALLOC_CTX *ctx, char const *fmt, ...) CC_HINT(format (printf, 2, 3)); - -#define is_truncated(_ret, _max) ((_ret) >= (size_t)(_max)) -#define truncate_len(_ret, _max) (((_ret) >= (size_t)(_max)) ? (((size_t)(_max)) - 1) : _ret) - -/** Boilerplate for checking truncation - * - * If truncation has occurred, advance _p as far as possible without - * overrunning the output buffer, and \0 terminate. Then return the length - * of the buffer we would have needed to write the full value. - * - * If truncation has not occurred, advance _p by whatever the copy or print - * function returned. - */ -#define RETURN_IF_TRUNCATED(_p, _ret, _max) \ -do { \ - if (is_truncated(_ret, _max)) { \ - size_t _r = (_p - out) + _ret; \ - _p += truncate_len(_ret, _max); \ - *_p = '\0'; \ - return _r; \ - } \ - _p += _ret; \ -} while (0) - /* * Several handy miscellaneous functions. */ -int fr_set_signal(int sig, sig_t func); -int fr_talloc_link_ctx(TALLOC_CTX *parent, TALLOC_CTX *child); -int fr_unset_signal(int sig); -int rad_lockfd(int fd, int lock_len); -int rad_lockfd_nonblock(int fd, int lock_len); -int rad_unlockfd(int fd, int lock_len); -char *fr_abin2hex(TALLOC_CTX *ctx, uint8_t const *bin, size_t inlen); -size_t fr_bin2hex(char *hex, uint8_t const *bin, size_t inlen); -size_t fr_hex2bin(uint8_t *bin, size_t outlen, char const *hex, size_t inlen); -uint64_t fr_strtoull(char const *value, char **end); -int64_t fr_strtoll(char const *value, char **end); -char *fr_trim(char const *str, size_t size); + /** Check whether the string is all whitespace * @@ -216,31 +178,6 @@ static inline bool is_zero(char const *value) return true; } -int fr_nonblock(int fd); -int fr_blocking(int fd); -ssize_t fr_writev(int fd, struct iovec[], int iovcnt, struct timeval *timeout); - -ssize_t fr_utf8_to_ucs2(uint8_t *out, size_t outlen, char const *in, size_t inlen); -size_t fr_snprint_uint128(char *out, size_t outlen, uint128_t const num); -int fr_time_from_str(time_t *date, char const *date_str); -void fr_timeval_from_ms(struct timeval *out, uint64_t ms); -void fr_timeval_from_usec(struct timeval *out, uint64_t usec); -void fr_timeval_subtract(struct timeval *out, struct timeval const *end, struct timeval const *start); -void fr_timeval_add(struct timeval *out, struct timeval const *a, struct timeval const *b); -void fr_timeval_divide(struct timeval *out, struct timeval const *in, int divisor); - -int fr_timeval_cmp(struct timeval const *a, struct timeval const *b); -int fr_timeval_from_str(struct timeval *out, char const *in); -bool fr_timeval_isset(struct timeval const *tv); - -void fr_timespec_subtract(struct timespec *out, struct timespec const *end, struct timespec const *start); - -bool fr_multiply(uint64_t *result, uint64_t lhs, uint64_t rhs); -int fr_size_from_str(size_t *out, char const *str); -int8_t fr_pointer_cmp(void const *a, void const *b); -void fr_quick_sort(void const *to_sort[], int min_idx, int max_idx, fr_cmp_t cmp); -int fr_digest_cmp(uint8_t const *a, uint8_t const *b, size_t length) CC_HINT(nonnull); - /* * Define TALLOC_DEBUG to check overflows with talloc. * we can't use valgrind, because the memory used by @@ -282,49 +219,6 @@ void fr_rand_seed(void const *, size_t ); /* seed the random pool */ /* crypt wrapper from crypt.c */ int fr_crypt_check(char const *password, char const *reference_crypt); -/* - * FIFOs - */ -typedef struct fr_fifo_t fr_fifo_t; -typedef void (*fr_fifo_free_t)(void *); - -/** Creates a fifo that verifies elements are of a specific talloc type - * - * @param[in] _ctx to tie fifo lifetime to. - * If ctx is freed, fifo will free any nodes, calling the - * free function if set. - * @param[in] _max_entries Maximum number of entries. - * @param[in] _talloc_type of elements. - * @param[in] _node_free Optional function used to free data if tree nodes are - * deleted or replaced. - * @return - * - A new fifo on success. - * - NULL on failure. - */ -#define fr_fifo_talloc_create(_ctx, _talloc_type, _max_entries, _node_free) \ - _fr_fifo_create(_ctx, #_talloc_type, _max_entries, _node_free) - -/** Creates a fifo - * - * @param[in] _ctx to tie fifo lifetime to. - * If ctx is freed, fifo will free any nodes, calling the - * free function if set. - * @param[in] _max_entries Maximum number of entries. - * @param[in] _node_free Optional function used to free data if tree nodes are - * deleted or replaced. - * @return - * - A new fifo on success. - * - NULL on failure. - */ -#define fr_fifo_create(_ctx, _max_entries, _node_free) \ - _fr_fifo_create(_ctx, NULL, _max_entries, _node_free) - -fr_fifo_t *_fr_fifo_create(TALLOC_CTX *ctx, char const *type, int max_entries, fr_fifo_free_t free_node); -int fr_fifo_push(fr_fifo_t *fi, void *data); -void *fr_fifo_pop(fr_fifo_t *fi); -void *fr_fifo_peek(fr_fifo_t *fi); -unsigned int fr_fifo_num_elements(fr_fifo_t *fi); - /* * socket.c */ diff --git a/src/lib/util/fifo.c b/src/lib/util/fifo.c index cddc875fa7c..fbc926e3867 100644 --- a/src/lib/util/fifo.c +++ b/src/lib/util/fifo.c @@ -23,7 +23,10 @@ */ RCSID("$Id$") -#include +#include +#include + +#include "fifo.h" struct fr_fifo_t { unsigned int num; //!< How many elements exist in the fifo. diff --git a/src/lib/util/fifo.h b/src/lib/util/fifo.h new file mode 100644 index 00000000000..33587aa75a0 --- /dev/null +++ b/src/lib/util/fifo.h @@ -0,0 +1,67 @@ +#pragma once +/* + * This program 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 program 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 program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** Non-thread-safe fifo (FIFO) implementation + * + * @file src/lib/util/fifo.c + * + * @copyright 2005,2006 The FreeRADIUS server project + * @copyright 2005 Alan DeKok + */ +RCSIDH(fifo_h, "$Id$") + +#include + +typedef struct fr_fifo_t fr_fifo_t; +typedef void (*fr_fifo_free_t)(void *); + +/** Creates a fifo that verifies elements are of a specific talloc type + * + * @param[in] _ctx to tie fifo lifetime to. + * If ctx is freed, fifo will free any nodes, calling the + * free function if set. + * @param[in] _max_entries Maximum number of entries. + * @param[in] _talloc_type of elements. + * @param[in] _node_free Optional function used to free data if tree nodes are + * deleted or replaced. + * @return + * - A new fifo on success. + * - NULL on failure. + */ +#define fr_fifo_talloc_create(_ctx, _talloc_type, _max_entries, _node_free) \ + _fr_fifo_create(_ctx, #_talloc_type, _max_entries, _node_free) + +/** Creates a fifo + * + * @param[in] _ctx to tie fifo lifetime to. + * If ctx is freed, fifo will free any nodes, calling the + * free function if set. + * @param[in] _max_entries Maximum number of entries. + * @param[in] _node_free Optional function used to free data if tree nodes are + * deleted or replaced. + * @return + * - A new fifo on success. + * - NULL on failure. + */ +#define fr_fifo_create(_ctx, _max_entries, _node_free) \ + _fr_fifo_create(_ctx, NULL, _max_entries, _node_free) + +fr_fifo_t *_fr_fifo_create(TALLOC_CTX *ctx, char const *type, int max_entries, fr_fifo_free_t free_node); +int fr_fifo_push(fr_fifo_t *fi, void *data); +void *fr_fifo_pop(fr_fifo_t *fi); +void *fr_fifo_peek(fr_fifo_t *fi); +unsigned int fr_fifo_num_elements(fr_fifo_t *fi); diff --git a/src/lib/util/fring.h b/src/lib/util/fring.h index 569498ad6a7..1414230b7e2 100644 --- a/src/lib/util/fring.h +++ b/src/lib/util/fring.h @@ -21,6 +21,8 @@ * * @copyright 2015-2017 Arran Cudbard-Bell */ +RCSIDH(fring_h, "$Id$") + #include #include #include diff --git a/src/lib/util/log.c b/src/lib/util/log.c index 30c2830b07a..590d0af968f 100644 --- a/src/lib/util/log.c +++ b/src/lib/util/log.c @@ -37,7 +37,8 @@ RCSID("$Id$") #include -FILE *fr_log_fp = NULL; +FILE *fr_log_fp = NULL; +int fr_debug_lvl = 0; /** Canonicalize error strings, removing tabs, and generate spaces for error marker * diff --git a/src/lib/util/log.h b/src/lib/util/log.h index 042bec6fb6a..5e2cdd8bb84 100644 --- a/src/lib/util/log.h +++ b/src/lib/util/log.h @@ -32,19 +32,8 @@ extern FILE *fr_log_fp; * Error functions. */ void fr_printf_log(char const *, ...) CC_HINT(format (printf, 1, 2)); - -void fr_strerror_printf(char const *, ...) CC_HINT(format (printf, 1, 2)); -void fr_strerror_printf_push(char const *fmt, ...) CC_HINT(format (printf, 1, 2)); - -char const *fr_strerror(void); -char const *fr_strerror_peek(void); -char const *fr_strerror_pop(void); - -void fr_perror(char const *, ...) CC_HINT(format (printf, 1, 2)); -void fr_strerror_free(void); void fr_canonicalize_error(TALLOC_CTX *ctx, char **spaces, char **text, ssize_t slen, char const *msg); -char const *fr_syserror(int num); extern bool fr_reverse_lookups; /* do IP -> hostname lookups? */ extern bool fr_hostname_lookups; /* do hostname -> IP lookups? */ extern int fr_debug_lvl; /* 0 = no debugging information */ diff --git a/src/lib/util/misc.c b/src/lib/util/misc.c index 4e9ccf0dc83..275129b13d1 100644 --- a/src/lib/util/misc.c +++ b/src/lib/util/misc.c @@ -22,7 +22,7 @@ */ RCSID("$Id$") -#include +#include "misc.h" #include #include @@ -30,10 +30,17 @@ RCSID("$Id$") #include #include #include +#include +#include +#include +#include -#ifdef HAVE_DIRENT_H -#include +#include +#include +#include +#ifdef HAVE_DIRENT_H +# include /* * Some versions of Linux don't have closefrom(), but they will * have /proc. @@ -43,15 +50,15 @@ RCSID("$Id$") * OSX doesn't have closefrom() or /proc/self/fd, but it does * have /dev/fd */ -#ifdef __linux__ -#define CLOSEFROM_DIR "/proc/self/fd" -#elif defined(__APPLE__) -#define CLOSEFROM_DIR "/dev/fd" -#else -#undef HAVE_DIRENT_H +# ifdef __linux__ +# define CLOSEFROM_DIR "/proc/self/fd" +# elif defined(__APPLE__) +# define CLOSEFROM_DIR "/dev/fd" +# else +# undef HAVE_DIRENT_H +# endif #endif -#endif #define FR_PUT_LE16(a, val)\ do {\ @@ -59,8 +66,6 @@ RCSID("$Id$") a[0] = ((uint16_t) (val)) & 0xff;\ } while (0) -int fr_debug_lvl = 0; - static char const *months[] = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; diff --git a/src/lib/util/misc.h b/src/lib/util/misc.h new file mode 100644 index 00000000000..08f3a15a4cc --- /dev/null +++ b/src/lib/util/misc.h @@ -0,0 +1,69 @@ +#pragma once +/* + * 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 St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** Various miscellaneous utility functions + * + * @file src/lib/util/misc.h + * + * @copyright 2000,2006 The FreeRADIUS server project + */ +RCSIDH(misc_h, "$Id$") + +#include +#include +#include +#include + +typedef int8_t (*fr_cmp_t)(void const *a, void const *b); + +int fr_set_signal(int sig, sig_t func); +int fr_talloc_link_ctx(TALLOC_CTX *parent, TALLOC_CTX *child); +int fr_unset_signal(int sig); +int rad_lockfd(int fd, int lock_len); +int rad_lockfd_nonblock(int fd, int lock_len); +int rad_unlockfd(int fd, int lock_len); +char *fr_abin2hex(TALLOC_CTX *ctx, uint8_t const *bin, size_t inlen); +size_t fr_bin2hex(char *hex, uint8_t const *bin, size_t inlen); +size_t fr_hex2bin(uint8_t *bin, size_t outlen, char const *hex, size_t inlen); +uint64_t fr_strtoull(char const *value, char **end); +int64_t fr_strtoll(char const *value, char **end); +char *fr_trim(char const *str, size_t size); + +int fr_nonblock(int fd); +int fr_blocking(int fd); + +ssize_t fr_writev(int fd, struct iovec vector[], int iovcnt, struct timeval *timeout); +ssize_t fr_utf8_to_ucs2(uint8_t *out, size_t outlen, char const *in, size_t inlen); +size_t fr_snprint_uint128(char *out, size_t outlen, uint128_t const num); +int fr_time_from_str(time_t *date, char const *date_str); +void fr_timeval_from_ms(struct timeval *out, uint64_t ms); +void fr_timeval_from_usec(struct timeval *out, uint64_t usec); +void fr_timeval_subtract(struct timeval *out, struct timeval const *end, struct timeval const *start); +void fr_timeval_add(struct timeval *out, struct timeval const *a, struct timeval const *b); +void fr_timeval_divide(struct timeval *out, struct timeval const *in, int divisor); + +int fr_timeval_cmp(struct timeval const *a, struct timeval const *b); +int fr_timeval_from_str(struct timeval *out, char const *in); +bool fr_timeval_isset(struct timeval const *tv); + +void fr_timespec_subtract(struct timespec *out, struct timespec const *end, struct timespec const *start); + +bool fr_multiply(uint64_t *result, uint64_t lhs, uint64_t rhs); +int fr_size_from_str(size_t *out, char const *str); +int8_t fr_pointer_cmp(void const *a, void const *b); +void fr_quick_sort(void const *to_sort[], int min_idx, int max_idx, fr_cmp_t cmp); +int fr_digest_cmp(uint8_t const *a, uint8_t const *b, size_t length) CC_HINT(nonnull); diff --git a/src/lib/util/print.c b/src/lib/util/print.c index 7eace77c503..daf84cc69f1 100644 --- a/src/lib/util/print.c +++ b/src/lib/util/print.c @@ -22,8 +22,17 @@ */ RCSID("$Id$") -#include -#include +#include "print.h" + +#include +#include +#include + +#include +#include +#include +#include +#include /** Checks for utf-8, taken from http://www.w3.org/International/questions/qa-forms-utf-8 * diff --git a/src/lib/util/print.h b/src/lib/util/print.h new file mode 100644 index 00000000000..357414453de --- /dev/null +++ b/src/lib/util/print.h @@ -0,0 +1,58 @@ +#pragma once +/* + * 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 St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** Functions to produce and parse the FreeRADIUS presentation format + * + * @file src/lib/util/print.h + * + * @copyright 2000,2006 The FreeRADIUS server project + */ +RCSIDH(print_h, "$Id$") + +#include + +size_t fr_utf8_char(uint8_t const *str, ssize_t inlen); +ssize_t fr_utf8_str(uint8_t const *str, ssize_t inlen); +char const *fr_utf8_strchr(int *chr_len, char const *str, char const *chr); +size_t fr_snprint(char *out, size_t outlen, char const *in, ssize_t inlen, char quote); +size_t fr_snprint_len(char const *in, ssize_t inlen, char quote); +char *fr_asprint(TALLOC_CTX *ctx, char const *in, ssize_t inlen, char quote); +char *fr_vasprintf(TALLOC_CTX *ctx, char const *fmt, va_list ap); +char *fr_asprintf(TALLOC_CTX *ctx, char const *fmt, ...) CC_HINT(format (printf, 2, 3)); + +#define is_truncated(_ret, _max) ((_ret) >= (size_t)(_max)) +#define truncate_len(_ret, _max) (((_ret) >= (size_t)(_max)) ? (((size_t)(_max)) - 1) : _ret) + +/** Boilerplate for checking truncation + * + * If truncation has occurred, advance _p as far as possible without + * overrunning the output buffer, and \0 terminate. Then return the length + * of the buffer we would have needed to write the full value. + * + * If truncation has not occurred, advance _p by whatever the copy or print + * function returned. + */ +#define RETURN_IF_TRUNCATED(_p, _ret, _max) \ +do { \ + if (is_truncated(_ret, _max)) { \ + size_t _r = (_p - out) + _ret; \ + _p += truncate_len(_ret, _max); \ + *_p = '\0'; \ + return _r; \ + } \ + _p += _ret; \ +} while (0) diff --git a/src/lib/util/rbtree.c b/src/lib/util/rbtree.c index 8cbb26e1a5e..42a15d2141d 100644 --- a/src/lib/util/rbtree.c +++ b/src/lib/util/rbtree.c @@ -22,8 +22,11 @@ */ RCSID("$Id$") -#include +#include "rbtree.h" + #include +#include + #include /* Red-Black tree description */ diff --git a/src/lib/util/snprintf.h b/src/lib/util/snprintf.h index 2ac0a964986..8e9cafb2843 100644 --- a/src/lib/util/snprintf.h +++ b/src/lib/util/snprintf.h @@ -1,3 +1,4 @@ +#pragma once /* * This program is is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/lib/util/strerror.h b/src/lib/util/strerror.h new file mode 100644 index 00000000000..118c787eea9 --- /dev/null +++ b/src/lib/util/strerror.h @@ -0,0 +1,35 @@ +#pragma once +/* + * 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 St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** Support functions to allow libraries to provide errors to their callers + * + * @file src/lib/util/strerror.h + * + * @copyright 2017 The FreeRADIUS server project + * @copyright 2017 Arran Cudbard-Bell (a.cudbardb@freeradius.org) + */ +RCSIDH(strerror_h, "$Id$") + +void fr_strerror_printf(char const *, ...) CC_HINT(format (printf, 1, 2)); +void fr_strerror_printf_push(char const *fmt, ...) CC_HINT(format (printf, 1, 2)); + +char const *fr_strerror(void); +char const *fr_strerror_peek(void); +char const *fr_strerror_pop(void); + +void fr_perror(char const *, ...) CC_HINT(format (printf, 1, 2)); +void fr_strerror_free(void); diff --git a/src/lib/util/syserror.h b/src/lib/util/syserror.h new file mode 100644 index 00000000000..e4c54835484 --- /dev/null +++ b/src/lib/util/syserror.h @@ -0,0 +1,27 @@ +#pragma once +/* + * 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 St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** Support functions to allow libraries to get system errors in a threadsafe and easily debuggable way + * + * @file src/lib/util/syserror.c + * + * @copyright 2017 The FreeRADIUS server project + * @copyright 2017 Arran Cudbard-Bell (a.cudbardb@freeradius.org) + */ +RCSIDH(syserror_h, "$Id$") + +char const *fr_syserror(int num); diff --git a/src/lib/util/value.c b/src/lib/util/value.c index 4545c75279a..97c0bf29917 100644 --- a/src/lib/util/value.c +++ b/src/lib/util/value.c @@ -45,6 +45,7 @@ RCSID("$Id$") #include +#include #include #include diff --git a/src/lib/util/value.h b/src/lib/util/value.h index 31ae26da0d0..fd01a05b88d 100644 --- a/src/lib/util/value.h +++ b/src/lib/util/value.h @@ -32,6 +32,7 @@ extern "C" { #include #include #include +#include /* * Avoid circular type references.