Mercurial > pidgin
comparison src/network.c @ 1:2846a03bda67
[gaim-migrate @ 10]
The other missing files :)
committer: Tailor Script <tailor@pidgin.im>
| author | Rob Flynn <gaim@robflynn.com> |
|---|---|
| date | Thu, 23 Mar 2000 03:13:54 +0000 |
| parents | |
| children | b9e90a914e20 |
comparison
equal
deleted
inserted
replaced
| 0:a5ace2e037bc | 1:2846a03bda67 |
|---|---|
| 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) { | |
| 60 quad_addr=strdup(inet_ntoa(sin.sin_addr)); | |
| 61 if (proxy_connect(fd, (struct sockaddr *)&sin, sizeof(sin)) > -1) { | |
| 62 return fd; | |
| 63 } | |
| 64 } | |
| 65 return -1; | |
| 66 } | |
| 67 |
