1
0
mirror of https://github.com/termux/termux-packages synced 2024-06-13 14:16:42 +00:00
termux-packages/packages/libelf/error.h
Fredrik Fornwall 66aea0b5df libelf: Keep the libelf part of elfutils
While all of elfutils does not build with clang, the libelf part does
and is needed by ltrace. So keep libelf as a package and let it replace
elfutils for now.
2018-08-17 21:32:56 +02:00

26 lines
861 B
C

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
/* program_invocation_short_name GNU extension - http://linux.die.net/man/3/program_invocation_short_name */
extern char* __progname;
#define program_invocation_short_name __progname
/* error(3) GNU extension - http://man7.org/linux/man-pages/man3/error.3.html */
unsigned int error_message_count;
static inline void error(int status, int errnum, const char* format, ...) {
error_message_count++;
va_list myargs;
va_start(myargs, format);
vfprintf(stderr, format, myargs);
va_end(myargs);
exit(status);
}
/* strchrnul(3) GNU extension - http://man7.org/linux/man-pages/man3/strchr.3.html */
static inline char* strchrnul(char const* s, int c)
{
char* result = strchr(s, c);
return (result == NULL) ? (char*)(s + strlen(s)) : result;
}