diff options
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | liberror.h | 18 | ||||
| -rw-r--r-- | liberror_copy_error.3 | 2 | ||||
| -rw-r--r-- | liberror_end.3 | 2 | ||||
| -rw-r--r-- | liberror_free_error.3 | 2 | ||||
| -rw-r--r-- | liberror_get_error.3 | 2 | ||||
| -rw-r--r-- | liberror_pop_error.3 | 52 | ||||
| -rw-r--r-- | liberror_print_bactrace.3 | 2 | ||||
| -rw-r--r-- | liberror_print_error.3 | 2 | ||||
| -rw-r--r-- | liberror_reset_error.3 | 2 | ||||
| -rw-r--r-- | liberror_save_backtrace.3 | 2 | ||||
| -rw-r--r-- | liberror_set_error.3 | 2 | ||||
| -rw-r--r-- | liberror_set_error_errno.3 | 2 | ||||
| -rw-r--r-- | liberror_set_error_existing.3 | 61 | ||||
| -rw-r--r-- | liberror_start.3 | 4 | ||||
| -rw-r--r-- | pop_error.c | 14 | ||||
| -rw-r--r-- | set_error_existing.c | 17 | 
17 files changed, 189 insertions, 1 deletions
| @@ -23,12 +23,14 @@ OBJ =\  	free_error.o\  	get_error.o\  	internal.o\ +	pop_error.o\  	print_backtrace.o\  	print_error.o\  	reset_error.o\  	save_backtrace.o\  	set_error.o\  	set_error_errno.o\ +	set_error_existing.o\  	start.o  MAN0 =\ @@ -39,12 +41,14 @@ MAN3 =\  	liberror_end.3\  	liberror_free_error.3\  	liberror_get_error.3\ +	liberror_pop_error.3\  	liberror_print_backtrace.3\  	liberror_print_error.3\  	liberror_reset_error.3\  	liberror_save_backtrace.3\  	liberror_set_error.3\  	liberror_set_error_errno.3\ +	liberror_set_error_existing.3\  	liberror_start.3  MAN7 =\ @@ -354,6 +354,24 @@ void liberror_set_error(const char[256], const char[64], const char[64], long lo  void liberror_set_error_errno(const char[256], const char[64], int);  /** + * Remove the current error and, if the + * specified error is non-`NULL`, replace it + * with the the specified error + *  + * @param  error  The error to set as the current error, must not + *                be the pointer returned by liberror_get_error() + *                for any thread, including the current thread, + *                the function will copy and deallocate this error + */ +void liberror_set_error_existing(struct liberror_error *); + +/** + * Remove the current error and, if the error + * has a cause, replace it with its cause + */ +void liberror_pop_error(void); + +/**   * The an error, its backtrace, and its   * cause (recursively)   *  diff --git a/liberror_copy_error.3 b/liberror_copy_error.3 index 2bdf7a0..44d4999 100644 --- a/liberror_copy_error.3 +++ b/liberror_copy_error.3 @@ -49,10 +49,12 @@ None.  .BR liberror_end (3),  .BR liberror_free_error (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_print_error (3),  .BR liberror_reset_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error (3),  .BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_end.3 b/liberror_end.3 index bad6fbb..f32c692 100644 --- a/liberror_end.3 +++ b/liberror_end.3 @@ -41,10 +41,12 @@ None.  .BR liberror_copy_error (3),  .BR liberror_free_error (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_print_error (3),  .BR liberror_reset_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error (3),  .BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_free_error.3 b/liberror_free_error.3 index 9786e7f..10d7007 100644 --- a/liberror_free_error.3 +++ b/liberror_free_error.3 @@ -40,10 +40,12 @@ None.  .BR liberror_copy_error (3),  .BR liberror_end (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_print_error (3),  .BR liberror_reset_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error (3),  .BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_get_error.3 b/liberror_get_error.3 index aee173d..8059ada 100644 --- a/liberror_get_error.3 +++ b/liberror_get_error.3 @@ -48,10 +48,12 @@ None.  .BR liberror_copy_error (3),  .BR liberror_end (3),  .BR liberror_free_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_print_error (3),  .BR liberror_reset_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error (3),  .BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_pop_error.3 b/liberror_pop_error.3 new file mode 100644 index 0000000..61bcfbb --- /dev/null +++ b/liberror_pop_error.3 @@ -0,0 +1,52 @@ +.TH LIBERROR_POP_ERROR 3 2020-06-09 liberror +.SH NAME +liberror_pop_error \- replaces the current error with its cause +.SH SYNOPSIS +.nf +#include <liberror.h> + +void liberror_pop_error(void); +.fi +.PP +Link with +.IR \-lerror . +.SH DESCRIPTION +The +.BR liberror_pop_error () +function assigns the causal error for the +current error set for the calling thread +to the thread. If the thread does not have +an error set, nothing will happen. If the +thread's error does not have a cause, it +will be reset without a replacement. +.SH RETURN VALUE +None. +.SH ERRORS +Failure to pop the error is impossible. +.I errno +will not be changed. +.SH EXAMPLES +None. +.SH APPLICATION USAGE +None. +.SH RATIONALE +None. +.SH FUTURE DIRECTIONS +None. +.SH NOTES +None. +.SH SEE ALSO +.BR liberror (7), +.BR liberror.h (0), +.BR liberror_copy_error (3), +.BR liberror_end (3), +.BR liberror_free_error (3), +.BR liberror_get_error (3), +.BR liberror_print_backtrace (3), +.BR liberror_print_error (3), +.BR liberror_reset_error (3), +.BR liberror_save_backtrace (3), +.BR liberror_set_error (3), +.BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3), +.BR liberror_start (3) diff --git a/liberror_print_bactrace.3 b/liberror_print_bactrace.3 index d8fb1ef..72a90d7 100644 --- a/liberror_print_bactrace.3 +++ b/liberror_print_bactrace.3 @@ -56,9 +56,11 @@ None.  .BR liberror_end (3),  .BR liberror_free_error (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_error (3),  .BR liberror_reset_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error (3),  .BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_print_error.3 b/liberror_print_error.3 index e6d390d..2a9f9d3 100644 --- a/liberror_print_error.3 +++ b/liberror_print_error.3 @@ -84,9 +84,11 @@ None.  .BR liberror_end (3),  .BR liberror_free_error (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_reset_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error (3),  .BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_reset_error.3 b/liberror_reset_error.3 index 05050e8..0ed5d32 100644 --- a/liberror_reset_error.3 +++ b/liberror_reset_error.3 @@ -44,9 +44,11 @@ None.  .BR liberror_end (3),  .BR liberror_free_error (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_print_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error (3),  .BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_save_backtrace.3 b/liberror_save_backtrace.3 index 371e5d2..cb7f94f 100644 --- a/liberror_save_backtrace.3 +++ b/liberror_save_backtrace.3 @@ -63,9 +63,11 @@ None.  .BR liberror_end (3),  .BR liberror_free_error (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_print_error (3),  .BR liberror_reset_error (3),  .BR liberror_set_error (3),  .BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_set_error.3 b/liberror_set_error.3 index 23d4629..f2d74b0 100644 --- a/liberror_set_error.3 +++ b/liberror_set_error.3 @@ -96,9 +96,11 @@ None.  .BR liberror_end (3),  .BR liberror_free_error (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_print_error (3),  .BR liberror_reset_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_set_error_errno.3 b/liberror_set_error_errno.3 index 1d68e90..e7f677b 100644 --- a/liberror_set_error_errno.3 +++ b/liberror_set_error_errno.3 @@ -42,9 +42,11 @@ None.  .BR liberror_end (3),  .BR liberror_free_error (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_print_error (3),  .BR liberror_reset_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error (3), +.BR liberror_set_error_existing (3),  .BR liberror_start (3) diff --git a/liberror_set_error_existing.3 b/liberror_set_error_existing.3 new file mode 100644 index 0000000..30c726d --- /dev/null +++ b/liberror_set_error_existing.3 @@ -0,0 +1,61 @@ +.TH LIBERROR_SET_ERROR_EXISTING 3 2020-06-09 liberror +.SH NAME +liberror_set_error_existing \- set the current error for the thread to a saved error +.SH SYNOPSIS +.nf +#include <liberror.h> + +void liberror_set_error_existing(struct liberror_error *\fIerror\fP); +.fi +.PP +Link with +.IR \-lerror . +.SH DESCRIPTION +The +.BR liberror_set_error_existing () +function assigns the error specified in the +.I error +parameter to the thread. If +.I error +is +.BR NULL , +the current error will be removed without being +replaces. +.PP +The pointer for the specified error will become +invalid. The pointer for the specified error +.B must not +be the pointer returned by the +.BR liberror_get_error (3) +function. +.SH RETURN VALUE +None. +.SH ERRORS +Failure to set the error is impossible. +.I errno +will not be changed. +.SH EXAMPLES +None. +.SH APPLICATION USAGE +None. +.SH RATIONALE +None. +.SH FUTURE DIRECTIONS +None. +.SH NOTES +None. +.SH SEE ALSO +.BR liberror (7), +.BR liberror.h (0), +.BR liberror_copy_error (3), +.BR liberror_end (3), +.BR liberror_free_error (3), +.BR liberror_get_error (3), +.BR liberror_pop_error (3), +.BR liberror_print_backtrace (3), +.BR liberror_print_error (3), +.BR liberror_reset_error (3), +.BR liberror_save_backtrace (3), +.BR liberror_set_error (3), +.BR liberror_set_error_errno (3), +.BR liberror_start (3) diff --git a/liberror_start.3 b/liberror_start.3 index e4a09cd..8d4c240 100644 --- a/liberror_start.3 +++ b/liberror_start.3 @@ -45,9 +45,11 @@ None.  .BR liberror_end (3),  .BR liberror_free_error (3),  .BR liberror_get_error (3), +.BR liberror_pop_error (3),  .BR liberror_print_backtrace (3),  .BR liberror_print_error (3),  .BR liberror_reset_error (3),  .BR liberror_save_backtrace (3),  .BR liberror_set_error (3), -.BR liberror_set_error_errno (3) +.BR liberror_set_error_errno (3), +.BR liberror_set_error_existing (3) diff --git a/pop_error.c b/pop_error.c new file mode 100644 index 0000000..9f830a0 --- /dev/null +++ b/pop_error.c @@ -0,0 +1,14 @@ +/* See LICENSE file for copyright and license details. */ +#include "internal.h" + + +void +liberror_pop_error(void) +{ +	struct liberror_error *cause; +	if (liberror_have_error_) { +		cause = liberror_error_.cause; +		liberror_error_.cause = NULL; +		liberror_set_error_existing(cause); +	} +} diff --git a/set_error_existing.c b/set_error_existing.c new file mode 100644 index 0000000..db6d6f1 --- /dev/null +++ b/set_error_existing.c @@ -0,0 +1,17 @@ +/* See LICENSE file for copyright and license details. */ +#include "internal.h" + + +void +liberror_set_error_existing(struct liberror_error *error) +{ +	liberror_reset_error(); +	if (error) { +		liberror_have_error_ = 1; +		memcpy(&liberror_error_, error, sizeof(*error)); +		if (error->dynamically_allocated) { +			liberror_error_.dynamically_allocated = 0; +			free(error); +		} +	} +} | 
