add ssh_set_error_oom and ssh_set_error_invalid

Signed-off-by: Andreas Schneider <mail@cynapses.org>
This commit is contained in:
Bernhard R. Link
2009-10-04 14:03:25 +02:00
committed by Andreas Schneider
parent d54e9550da
commit 7c759b9615
2 changed files with 32 additions and 1 deletions

View File

@@ -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);

View File

@@ -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.
*