1
|
1 /*
|
|
2 * gaim
|
|
3 *
|
|
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
|
|
5 *
|
|
6 * This program is free software; you can redistribute it and/or modify
|
|
7 * it under the terms of the GNU General Public License as published by
|
|
8 * the Free Software Foundation; either version 2 of the License, or
|
|
9 * (at your option) any later version.
|
|
10 *
|
|
11 * This program is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 * GNU General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with this program; if not, write to the Free Software
|
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 *
|
|
20 */
|
|
21
|
|
22 #include <netdb.h>
|
|
23 #include <gtk/gtk.h>
|
|
24 #include <unistd.h>
|
|
25 #include <errno.h>
|
|
26 #include <netinet/in.h>
|
|
27 #include <arpa/inet.h>
|
|
28 #include <string.h>
|
|
29 #include <stdlib.h>
|
|
30 #include <stdio.h>
|
|
31 #include <time.h>
|
|
32 #include <sys/socket.h>
|
|
33 #include "gaim.h"
|
|
34 #include "proxy.h"
|
|
35 #include "gnome_applet_mgr.h"
|
|
36
|
|
37 unsigned int *get_address(char *hostname)
|
|
38 {
|
|
39 struct hostent *hp;
|
|
40 unsigned int *sin=NULL;
|
|
41 if ((hp = proxy_gethostbyname(hostname))) {
|
|
42 sin = (unsigned int *)g_new0(struct sockaddr_in, 1);
|
|
43 memcpy(sin, hp->h_addr, hp->h_length);
|
|
44 }
|
|
45 return sin;
|
|
46 }
|
|
47
|
|
48 int connect_address(unsigned int addy, unsigned short port)
|
|
49 {
|
|
50 int fd;
|
|
51 struct sockaddr_in sin;
|
|
52
|
|
53 sin.sin_addr.s_addr = addy;
|
|
54 sin.sin_family = AF_INET;
|
|
55 sin.sin_port = htons(port);
|
|
56
|
|
57 fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
58
|
|
59 if (fd > -1) {
|
26
|
60 if (quad_addr)
|
|
61 g_free (quad_addr);
|
|
62
|
|
63 quad_addr=g_strdup(inet_ntoa(sin.sin_addr));
|
1
|
64 if (proxy_connect(fd, (struct sockaddr *)&sin, sizeof(sin)) > -1) {
|
|
65 return fd;
|
|
66 }
|
|
67 }
|
|
68 return -1;
|
|
69 }
|
|
70
|