1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-02 01:17:52 +03:00

error: Use macros for error functions.

This commit is contained in:
Andreas Schneider
2011-09-17 10:28:39 +02:00
parent afa56e0102
commit c19c638d74
8 changed files with 137 additions and 105 deletions

View File

@@ -48,14 +48,24 @@
*
* @param ... The arguments for the format string.
*/
void ssh_set_error(void *error, int code, const char *descr, ...) {
struct ssh_common_struct *err = error;
va_list va;
va_start(va, descr);
vsnprintf(err->error.error_buffer, ERROR_BUFFERLEN, descr, va);
va_end(va);
err->error.error_code = code;
ssh_log_common(err,SSH_LOG_RARE,"Error : %s",err->error.error_buffer);
void _ssh_set_error(void *error,
int code,
const char *function,
const char *descr, ...)
{
struct ssh_common_struct *err = error;
va_list va;
va_start(va, descr);
vsnprintf(err->error.error_buffer, ERROR_BUFFERLEN, descr, va);
va_end(va);
err->error.error_code = code;
ssh_log_common(err,
SSH_LOG_WARN,
function,
"Error: %s",
err->error.error_buffer);
}
/**
@@ -66,11 +76,13 @@ void ssh_set_error(void *error, int code, const char *descr, ...) {
* @param error The place to store the error.
*
*/
void ssh_set_error_oom(void *error) {
struct error_struct *err = error;
void _ssh_set_error_oom(void *error, const char *function)
{
struct error_struct *err = error;
strcpy(err->error_buffer, "Out of memory");
err->error_code = SSH_FATAL;
snprintf(err->error_buffer, sizeof(err->error_buffer),
"%s: Out of memory", function);
err->error_code = SSH_FATAL;
}
/**
@@ -83,8 +95,10 @@ void ssh_set_error_oom(void *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);
void _ssh_set_error_invalid(void *error, const char *function)
{
_ssh_set_error(error, SSH_FATAL, function,
"Invalid argument in %s", function);
}
/**