From 7c759b961521ecae451b113eaa7531f9c77b0079 Mon Sep 17 00:00:00 2001 From: "Bernhard R. Link" Date: Sun, 4 Oct 2009 14:03:25 +0200 Subject: add ssh_set_error_oom and ssh_set_error_invalid Signed-off-by: Andreas Schneider --- include/libssh/priv.h | 2 ++ libssh/error.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 5dc3889d..bea4c343 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -123,6 +123,8 @@ int ssh_config_parse_file(ssh_options opt, const char *filename); /* errors.c */ void ssh_set_error(void *error, int code, const char *descr, ...) PRINTF_ATTRIBUTE(3, 4); +void ssh_set_error_oom(void *); +void ssh_set_error_invalid(void *, const char *); /* in crypt.c */ uint32_t packet_decrypt_len(ssh_session session,char *crypted); diff --git a/libssh/error.c b/libssh/error.c index 392e7414..f44bf492 100644 --- a/libssh/error.c +++ b/libssh/error.c @@ -41,7 +41,7 @@ * * @brief Registers an error with a description. * - * @param error The class of error. + * @param error The place to store the error. * * @param code The class of error. * @@ -58,6 +58,35 @@ void ssh_set_error(void *error, int code, const char *descr, ...) { err->error_code = code; } +/** + * @internal + * + * @brief Registers an out of memory error + * + * @param error The place to store the error. + * + */ +void ssh_set_error_oom(void *error) { + struct error_struct *err = error; + + strcpy(err->error_buffer, "Out of memory"); + err->error_code = SSH_FATAL; +} + +/** + * @internal + * + * @brief Registers an out of memory error + * + * @param error The place to store the error. + * + * @param function The function the error happened in. + * + */ +void ssh_set_error_invalid(void *error, const char *function) { + ssh_set_error(error, SSH_FATAL, "Invalid argument in %s", function); +} + /** * @brief Retrieve the error text message from the last error. * -- cgit