diff options
author | Bernhard R. Link <brlink@debian.org> | 2009-10-04 14:03:25 +0200 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-10-05 00:02:43 +0200 |
commit | 7c759b961521ecae451b113eaa7531f9c77b0079 (patch) | |
tree | a8e4e3d780d6f4ce6c3e045bb1edb16fa7ea78ef | |
parent | d54e9550da59465d9a795c885e18199122b57ba5 (diff) | |
download | libssh-7c759b961521ecae451b113eaa7531f9c77b0079.tar.gz libssh-7c759b961521ecae451b113eaa7531f9c77b0079.tar.xz libssh-7c759b961521ecae451b113eaa7531f9c77b0079.zip |
add ssh_set_error_oom and ssh_set_error_invalid
Signed-off-by: Andreas Schneider <mail@cynapses.org>
-rw-r--r-- | include/libssh/priv.h | 2 | ||||
-rw-r--r-- | libssh/error.c | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 5dc3889..bea4c34 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 392e741..f44bf49 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. * @@ -59,6 +59,35 @@ void ssh_set_error(void *error, int code, const char *descr, ...) { } /** + * @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. * * @param error The SSH session pointer. |