main.cpp 1.31 KB
Newer Older
jcaceres's avatar
jcaceres committed
1
#include "MainDialog.h"
jcaceres's avatar
jcaceres committed
2
3
4
5
6

#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
jcaceres's avatar
jcaceres committed
7

jcaceres's avatar
jcaceres committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

// dotted integer from hostname
QString *
IPv4Addr (char *namebuf)
{
	struct hostent *hp;
	unsigned int addr = 0;
	struct sockaddr_in dest;
	memset (&dest, 0, sizeof (dest));
	hp = gethostbyname (namebuf);
	if (!hp)
		addr = inet_addr (namebuf);
	if ((!hp) && (addr == INADDR_NONE))
	{
		perror ("IPv4Addr, unable to resolve.");
		exit (1);
	}
	if (hp != NULL)
		memcpy (&(dest.sin_addr), hp->h_addr, hp->h_length);
	else
		dest.sin_addr.s_addr = addr;
	if (hp)
		dest.sin_family = hp->h_addrtype;
	else
		dest.sin_family = AF_INET;
	QString *s = new QString (inet_ntoa (dest.sin_addr));
	return s;
}
36

jcaceres's avatar
jcaceres committed
37
#include <qapplication.h>
jcaceres's avatar
jcaceres committed
38
#include <qtextstream.h>
jcaceres's avatar
jcaceres committed
39
40
41
42
43
44
45
/****************************************************************************
 * MAIN
 ***************************************************************************/

int
main (int argc, char **argv)
{
46
	//create application object
jcaceres's avatar
jcaceres committed
47
48
	QApplication a (argc, argv);
	StreamBD s;
jcaceres's avatar
jcaceres committed
49
50
	// Parse the command line.  If the arguments are invalid,
	// usage instructions will be printed.  Streambd will exit.
jcaceres's avatar
jcaceres committed
51
	if (s.ParseCommandLine (argc, argv) == 0)
jcaceres's avatar
jcaceres committed
52
		return 0;
jcaceres's avatar
jcaceres committed
53
	MainDialog m;
jcaceres's avatar
jcaceres committed
54
55
	a.setMainWidget (&m);
	if (s.args->gui) m.show ();
jcaceres's avatar
jcaceres committed
56
57
58
	m.init (&s);
	a.processEvents ();
	return a.exec ();
jcaceres's avatar
jcaceres committed
59
}
60
61