Mon, 11 Sep 2000 08:57:13 +0000
[gaim-migrate @ 888]
no more daemons
| 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 | ||
|
349
6f7d28b0f98d
[gaim-migrate @ 359]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
26
diff
changeset
|
22 | #ifdef HAVE_CONFIG_H |
|
6f7d28b0f98d
[gaim-migrate @ 359]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
26
diff
changeset
|
23 | #include "../config.h" |
|
6f7d28b0f98d
[gaim-migrate @ 359]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
26
diff
changeset
|
24 | #endif |
| 1 | 25 | #include <netdb.h> |
| 26 | #include <gtk/gtk.h> | |
| 27 | #include <unistd.h> | |
| 28 | #include <errno.h> | |
| 29 | #include <netinet/in.h> | |
| 30 | #include <arpa/inet.h> | |
| 31 | #include <string.h> | |
| 32 | #include <stdlib.h> | |
| 33 | #include <stdio.h> | |
| 34 | #include <time.h> | |
| 35 | #include <sys/socket.h> | |
| 36 | #include "gaim.h" | |
| 37 | #include "proxy.h" | |
| 38 | #include "gnome_applet_mgr.h" | |
| 39 | ||
| 40 | unsigned int *get_address(char *hostname) | |
| 41 | { | |
| 42 | struct hostent *hp; | |
| 43 | unsigned int *sin=NULL; | |
| 44 | if ((hp = proxy_gethostbyname(hostname))) { | |
| 45 | sin = (unsigned int *)g_new0(struct sockaddr_in, 1); | |
| 46 | memcpy(sin, hp->h_addr, hp->h_length); | |
| 47 | } | |
| 48 | return sin; | |
| 49 | } | |
| 50 | ||
| 51 | int connect_address(unsigned int addy, unsigned short port) | |
| 52 | { | |
| 53 | int fd; | |
| 54 | struct sockaddr_in sin; | |
| 55 | ||
| 56 | sin.sin_addr.s_addr = addy; | |
| 57 | sin.sin_family = AF_INET; | |
| 58 | sin.sin_port = htons(port); | |
| 59 | ||
| 60 | fd = socket(AF_INET, SOCK_STREAM, 0); | |
| 61 | ||
| 62 | if (fd > -1) { | |
| 26 | 63 | if (quad_addr) |
| 64 | g_free (quad_addr); | |
| 65 | ||
| 66 | quad_addr=g_strdup(inet_ntoa(sin.sin_addr)); | |
| 1 | 67 | if (proxy_connect(fd, (struct sockaddr *)&sin, sizeof(sin)) > -1) { |
| 68 | return fd; | |
| 69 | } | |
| 70 | } | |
| 71 | return -1; | |
| 72 | } | |
| 73 |