]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Peek at strerror without poping it
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 3 Dec 2017 01:07:29 +0000 (01:07 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 3 Dec 2017 01:07:29 +0000 (01:07 +0000)
src/include/fr_log.h
src/lib/util/strerror.c

index 60904add549bb99a63f4eab9d046663b4b322b08..82c8631e2b2d96f21b3a9e86a22c50f39df10632 100644 (file)
@@ -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));
index 0872391356f9b6e7d4f92377747e49f339527d8f..1e5010bd18fef917428f69584c5354a00eb74d44 100644 (file)
@@ -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