mirror of
https://github.com/upa/mscp.git
synced 2026-02-21 06:34:43 +08:00
refactor error message-related functions
split message print fuctions (mpr_*), strerrno, and mscp_get/set_error into print.c/h and strerrno.c/h. ToDo: revise usages of priv_set_errv and pr_* functions.
This commit is contained in:
33
src/strerrno.h
Normal file
33
src/strerrno.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
#ifndef _STRERRNO_
|
||||
#define _STRERRNO_
|
||||
|
||||
#include <libgen.h> /* basename() */
|
||||
|
||||
/**
|
||||
* strerrno() returns error message string corresponding to errno.
|
||||
* strerrno() is thread safe.
|
||||
*/
|
||||
const char *strerrno(void);
|
||||
|
||||
/**
|
||||
* priv_set_err() sets an error message into a private buffer. This
|
||||
* error message set by priv_set_err() can be accessed via
|
||||
* priv_get_err(). priv_*_err functions are not thread safe.
|
||||
*/
|
||||
void priv_set_err(const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* priv_set_errv(), a wrapper for priv_set_err(), just adds filename,
|
||||
* line, and function name to the error message.
|
||||
*/
|
||||
#define priv_set_errv(fmt, ...) \
|
||||
priv_set_err("[%s:%d:%s] " fmt "\0", \
|
||||
basename(__FILE__), __LINE__, __func__, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* priv_get_err() gets the error message sotred in a private buffer.
|
||||
*/
|
||||
const char *priv_get_err();
|
||||
|
||||
#endif /* _STRERRNO_ */
|
||||
Reference in New Issue
Block a user