Skip to content

Commit

Permalink
no error.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy J Fontaine committed Mar 11, 2019
1 parent 6f45f77 commit e991e05
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef _ERROR_H_
#define _ERROR_H_

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

static unsigned int error_message_count = 0;

static inline void error(int status, int errnum, const char* format, ...)
{
va_list ap;
fprintf(stderr, "%s: ", program_invocation_name);
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
if (errnum)
fprintf(stderr, ": %s", strerror(errnum));
fprintf(stderr, "\n");
error_message_count++;
if (status)
exit(status);
}

#endif /* _ERROR_H_ */

0 comments on commit e991e05

Please sign in to comment.