From: Christian Couder Date: Mon, 08 Aug 2016 21:03:34 GMT Subject: [PATCH v10 37/40] usage: add get_error_routine() and get_warn_routine() Message-ID: <20160808210337.5038-38-chriscool@tuxfamily.org> In-Reply-To: <20160808210337.5038-1-chriscool@tuxfamily.org> Let's make it possible to get the current error_routine and warn_routine, so that we can store them before using set_error_routine() or set_warn_routine() to use new ones. This way we will be able put back the original routines, when we are done with using new ones. Signed-off-by: Christian Couder --- git-compat-util.h | 2 ++ usage.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/git-compat-util.h b/git-compat-util.h index c7a51f8..de04df1 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -440,7 +440,9 @@ static inline int const_error(void) extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params)); extern void set_error_routine(void (*routine)(const char *err, va_list params)); +extern void (*get_error_routine(void))(const char *err, va_list params); extern void set_warn_routine(void (*routine)(const char *warn, va_list params)); +extern void (*get_warn_routine(void))(const char *warn, va_list params); extern void set_die_is_recursing_routine(int (*routine)(void)); extern void set_error_handle(FILE *); diff --git a/usage.c b/usage.c index 67e5526..2fd3045 100644 --- a/usage.c +++ b/usage.c @@ -70,11 +70,21 @@ void set_error_routine(void (*routine)(const char *err, va_list params)) error_routine = routine; } +void (*get_error_routine(void))(const char *err, va_list params) +{ + return error_routine; +} + void set_warn_routine(void (*routine)(const char *warn, va_list params)) { warn_routine = routine; } +void (*get_warn_routine(void))(const char *warn, va_list params) +{ + return warn_routine; +} + void set_die_is_recursing_routine(int (*routine)(void)) { die_is_recursing = routine; -- 2.9.2.614.g4980f51