comparison src/network.c @ 8838:518455386538

[gaim-migrate @ 9604] -Fix the compile error in perl that was my fault -Rename a network.c function and change it's signature (is that work applicable in c?) -Make rendezvous crash when trying to sign on committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 28 Apr 2004 03:16:40 +0000
parents beb7be215db3
children 01c3db200c8f
comparison
equal deleted inserted replaced
8837:25206a0fb4e4 8838:518455386538
28 #include "debug.h" 28 #include "debug.h"
29 #include "account.h" 29 #include "account.h"
30 #include "network.h" 30 #include "network.h"
31 #include "prefs.h" 31 #include "prefs.h"
32 32
33 const unsigned char *
34 gaim_network_ip_atoi(const char *ip)
35 {
36 static unsigned char ret[4];
37 gchar delimiter = '.';
38 gchar **split;
39 int i;
40
41 g_return_val_if_fail(ip != NULL, NULL);
42
43 split = g_strsplit(ip, &delimiter, 4);
44 for (i = 0; split[i] != NULL; i++)
45 ret[i] = atoi(split[i]);
46 g_strfreev(split);
47
48 /* i should always be 4 */
49 if (i != 4)
50 return NULL;
51
52 return ret;
53 }
54
33 void 55 void
34 gaim_network_set_public_ip(const char *ip) 56 gaim_network_set_public_ip(const char *ip)
35 { 57 {
36 g_return_if_fail(ip != NULL); 58 g_return_if_fail(ip != NULL);
59
60 /* XXX - Ensure the IP address is valid */
37 61
38 gaim_prefs_set_string("/core/network/public_ip", ip); 62 gaim_prefs_set_string("/core/network/public_ip", ip);
39 } 63 }
40 64
41 const char * 65 const char *
67 return NULL; 91 return NULL;
68 } 92 }
69 93
70 tmp = inet_ntoa(addr.sin_addr); 94 tmp = inet_ntoa(addr.sin_addr);
71 strncpy(ip, tmp, sizeof(ip)); 95 strncpy(ip, tmp, sizeof(ip));
96
72 return ip; 97 return ip;
73 } 98 }
74 99
75 const char * 100 const char *
76 gaim_network_get_local_system_ip(int fd) 101 gaim_network_get_local_system_ip(int fd)
104 129
105 return ip; 130 return ip;
106 } 131 }
107 132
108 const char * 133 const char *
109 gaim_network_get_ip_for_account(const GaimAccount *account, int fd) 134 gaim_network_get_my_ip(int fd)
110 { 135 {
111 const char *ip = NULL; 136 const char *ip = NULL;
112 137
113 /* Check if the user specified an IP manually */ 138 /* Check if the user specified an IP manually */
114 if (!gaim_prefs_get_bool("/core/network/auto_ip")) { 139 if (!gaim_prefs_get_bool("/core/network/auto_ip")) {