mirror of
https://github.com/vale981/yabar
synced 2025-03-04 17:11:38 -05:00
Introduce new function for warning handling of internal blocks
This commit is contained in:
parent
e96cc9ae72
commit
d682dd6c8d
1 changed files with 18 additions and 1 deletions
|
@ -50,7 +50,7 @@ struct reserved_blk ya_reserved_blks[YA_INTERNAL_LEN] = {
|
|||
|
||||
#include <stdarg.h>
|
||||
|
||||
/* generic function to print error messages from blocks */
|
||||
/* generic function to print error messages from blocks and exit */
|
||||
void ya_block_error(ya_block_t *blk, char *error_msg, ...) {
|
||||
va_list args;
|
||||
if(blk == NULL)
|
||||
|
@ -71,6 +71,23 @@ void ya_block_error(ya_block_t *blk, char *error_msg, ...) {
|
|||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
/* generic function to print warning messages from blocks (non-fatal) */
|
||||
void ya_block_warning(ya_block_t *blk, char *error_msg, ...) {
|
||||
va_list args;
|
||||
if(blk == NULL)
|
||||
return;
|
||||
|
||||
fprintf(stderr, "W: %s.%s: ", blk->bar->name, blk->name);
|
||||
va_start(args, error_msg);
|
||||
fprintf(stderr, error_msg, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
FILE* ya_fopen(char* fpath, ya_block_t *blk) {
|
||||
FILE* tfile = fopen(fpath, "r");
|
||||
if (tfile == NULL)
|
||||
|
|
Loading…
Add table
Reference in a new issue