From: Arran Cudbard-Bell Date: Sun, 3 Dec 2017 01:07:29 +0000 (+0000) Subject: Peek at strerror without poping it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b40099b806dfabcde18ef2c36bc42124fe00697;p=thirdparty%2Ffreeradius-server.git Peek at strerror without poping it --- diff --git a/src/include/fr_log.h b/src/include/fr_log.h index 60904add549..82c8631e2b2 100644 --- a/src/include/fr_log.h +++ b/src/include/fr_log.h @@ -42,6 +42,7 @@ 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)); diff --git a/src/lib/util/strerror.c b/src/lib/util/strerror.c index 0872391356f..1e5010bd18f 100644 --- a/src/lib/util/strerror.c +++ b/src/lib/util/strerror.c @@ -229,6 +229,24 @@ char const *fr_strerror(void) return entry->msg; } +/** Get the last library error + * + * @return library error or zero length string. + */ +char const *fr_strerror_peek(void) +{ + fr_log_buffer_t *buffer; + fr_log_entry_t *entry; + + buffer = fr_strerror_buffer; + if (!buffer) return ""; + + entry = fr_cursor_head(&buffer->cursor); + if (!entry) return ""; + + return entry->msg; +} + /** Pop the last library error * * Return the first message added to the error stack using #fr_strerror_printf