make 'forceexit' more fprintf-like, better error message when ioctl fails.

This commit is contained in:
Arnout Engelen
2008-12-31 15:40:48 +00:00
parent cddd1d2e6c
commit 22a28e973e
3 changed files with 55 additions and 60 deletions

View File

@@ -10,6 +10,7 @@
#include <signal.h>
#include <string>
#include <string.h>
#include <stdarg.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
@@ -200,24 +201,19 @@ void quit_cb (int i)
exit(0);
}
void forceExit(const char *msg)
{
forceExit (msg, NULL);
}
void forceExit(const char *msg, const char* msg2)
void forceExit(const char *msg, ...)
{
if ((!tracemode)&&(!DEBUG)){
exit_ui();
}
std::cerr << msg;
if (msg2 != NULL)
{
std::cerr << msg2;
}
va_list argp;
va_start(argp, msg);
vfprintf(stderr, msg, argp);
va_end(argp);
std::cerr << std::endl;
exit(0);
exit(0);
}
static void versiondisplay(void)

View File

@@ -47,8 +47,7 @@
#define PROGNAME_WIDTH 27
void forceExit(const char *msg);
void forceExit(const char *msg, const char* msg2);
void forceExit(const char *msg, ...);
class local_addr {
public:

View File

@@ -43,7 +43,7 @@ void getLocal (const char *device, bool tracemode)
}
strcpy(iFreq.ifr_name, device);
if(ioctl(sock, SIOCGIFADDR, &iFreq)<0){
forceExit("ioctl failed while establishing local IP for selected device ", device);
forceExit("ioctl failed while establishing local IP for selected device %s. You may specify the device on the command line.", device);
}
saddr=(struct sockaddr_in*)&iFreq.ifr_addr;
local_addrs = new local_addr (saddr->sin_addr.s_addr, local_addrs);