]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add cf_ wrapper for fr_canonicalize_error()
authorAlan T. DeKok <aland@freeradius.org>
Thu, 14 Dec 2023 00:01:33 +0000 (19:01 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 14 Dec 2023 00:42:57 +0000 (19:42 -0500)
src/lib/server/cf_util.c
src/lib/server/cf_util.h

index c92a3a0735afd528f9afced9ea605cdd69b9f8e0..60fedc7e3916b713447adcac79a6e39538ebfc17 100644 (file)
@@ -2339,3 +2339,17 @@ void cf_item_free_children(CONF_ITEM *ci)
                child = fr_dlist_talloc_free_item(&ci->children, child);
        }
 }
+
+void _cf_canonicalize_error(CONF_ITEM *ci, ssize_t slen, char const *msg, char const *str)
+{
+       char *spaces, *text;
+
+       fr_canonicalize_error(ci, &spaces, &text, slen, str);
+
+       cf_log_err(ci, "%s", msg);
+       cf_log_err(ci, "%s", text);
+       cf_log_perr(ci, "%s^", spaces);
+
+       talloc_free(spaces);
+       talloc_free(text);
+}
index 0b3f2923367bd93a9a8306e533a659546877255c..3eddaf0d77494ff664978758e6a7ff6c634183ab 100644 (file)
@@ -336,6 +336,10 @@ void               _cf_log_perr_by_child(fr_log_type_t type, CONF_SECTION const *parent, char
 
 #define                cf_debug(_cf) _cf_debug(CF_TO_ITEM(_cf))
 void           _cf_debug(CONF_ITEM const *ci);
+
+#define                cf_canonicalize_error(_ci, _slen, _msg, _str) _cf_canonicalize_error(CF_TO_ITEM(_ci), _slen, _msg, _str)
+void           _cf_canonicalize_error(CONF_ITEM *ci, ssize_t slen, char const *msg, char const *str);
+
 #ifdef __cplusplus
 }
 #endif