mirror of
https://github.com/yarrick/iodine.git
synced 2024-12-22 21:33:33 +02:00
added proper warn/warnx/err/errx
This commit is contained in:
parent
adc80adff7
commit
b43e97aeb0
3 changed files with 49 additions and 7 deletions
44
src/common.c
44
src/common.c
|
@ -222,5 +222,49 @@ inet_aton(const char *cp, struct in_addr *inp)
|
|||
inp->s_addr = inet_addr(cp);
|
||||
return inp->s_addr != INADDR_ANY;
|
||||
}
|
||||
|
||||
void
|
||||
warn(const char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
||||
va_start(list, fmt);
|
||||
if (fmt) fprintf(stderr, fmt, list);
|
||||
fprintf(stderr, "%s\n", strerror(errno));
|
||||
va_end(list);
|
||||
}
|
||||
|
||||
void
|
||||
warnx(const char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
||||
va_start(list, fmt);
|
||||
if (fmt) fprintf(stderr, fmt, list);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(list);
|
||||
}
|
||||
|
||||
void
|
||||
err(int eval, const char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
||||
va_start(list, fmt);
|
||||
warn(fmt, list);
|
||||
va_end(list);
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
void
|
||||
errx(int eval, const char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
||||
va_start(list, fmt);
|
||||
warnx(fmt, list);
|
||||
va_end(list);
|
||||
exit(eval);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -77,6 +77,11 @@ int check_topdomain(char *);
|
|||
|
||||
#ifdef WINDOWS32
|
||||
int inet_aton(const char *cp, struct in_addr *inp);
|
||||
|
||||
void err(int eval, const char *fmt, ...);
|
||||
void warn(const char *fmt, ...);
|
||||
void errx(int eval, const char *fmt, ...);
|
||||
void warnx(const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,13 +19,6 @@
|
|||
|
||||
typedef unsigned int in_addr_t;
|
||||
|
||||
/* Bad err.h fix */
|
||||
#define warn printf
|
||||
#define warnx printf
|
||||
#define err(a, b, ...) do{printf("%s ", strerror(errno)); \
|
||||
printf(b, ## __VA_ARGS__); exit(a);}while(0)
|
||||
#define errx(a, b, ...) do{printf(b, ## __VA_ARGS__); exit(a);}while(0)
|
||||
|
||||
#include <windows.h>
|
||||
#include <windns.h>
|
||||
#include <winsock.h>
|
||||
|
|
Loading…
Reference in a new issue