error.c   error.c 
skipping to change at line 44 skipping to change at line 44
/** /**
* @addtogroup ssh_error * @addtogroup ssh_error
* @{ * @{
*/ */
/** /**
* @internal * @internal
* *
* @brief Registers an error with a description. * @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. * @param code The class of error.
* *
* @param descr The description, which can be a format string. * @param descr The description, which can be a format string.
* *
* @param ... The arguments for the format string. * @param ... The arguments for the format string.
*/ */
void ssh_set_error(void *error, int code, const char *descr, ...) { void ssh_set_error(void *error, int code, const char *descr, ...) {
struct error_struct *err = error; struct error_struct *err = error;
va_list va; va_list va;
va_start(va, descr); va_start(va, descr);
vsnprintf(err->error_buffer, ERROR_BUFFERLEN, descr, va); vsnprintf(err->error_buffer, ERROR_BUFFERLEN, descr, va);
va_end(va); va_end(va);
err->error_code = code; 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 invalid argument 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. * @brief Retrieve the error text message from the last error.
* *
* @param error The SSH session pointer. * @param error The SSH session pointer.
* *
* @return A static string describing the error. * @return A static string describing the error.
*/ */
const char *ssh_get_error(void *error) { const char *ssh_get_error(void *error) {
struct error_struct *err = error; struct error_struct *err = error;
return err->error_buffer; return err->error_buffer;
} }
/** /**
* @brief Retrieve the error code from the last error. * @brief Retrieve the error code from the last error.
* *
* @param error The SSH session pointer. * @param error The SSH session pointer.
* *
* \return SSH_NO_ERROR No error occured\n * \return SSH_NO_ERROR No error occurred\n
* SSH_REQUEST_DENIED The last request was denied but situation is * SSH_REQUEST_DENIED The last request was denied but situation is
* recoverable\n * recoverable\n
* SSH_FATAL A fatal error occured. This could be an unexp ected * SSH_FATAL A fatal error occurred. This could be an unex pected
* disconnection\n * disconnection\n
* *
* \nOther error codes are internal but can be considered same than * Other error codes are internal but can be considered same than
* SSH_FATAL. * SSH_FATAL.
*/ */
int ssh_get_error_code(void *error) { int ssh_get_error_code(void *error) {
struct error_struct *err = error; struct error_struct *err = error;
return err->error_code; return err->error_code;
} }
/** @} */ /** @} */
/* vim: set ts=2 sw=2 et cindent: */ /* vim: set ts=2 sw=2 et cindent: */
 End of changes. 5 change blocks. 
4 lines changed or deleted 33 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/