# HG changeset patch # User Christian Hammond # Date 1058844393 0 # Node ID 3565ee7a5dd3b5d9f63bfae4b08e0855007db66b # Parent 4fcfe659568a752f98279fada702c35badbdd8e8 [gaim-migrate @ 6760] Renamed gaim_xfer_init() to gaim_xfers_init(), and added a function for returning the system's local IP address. committer: Tailor Script diff -r 4fcfe659568a -r 3565ee7a5dd3 src/ft.c --- a/src/ft.c Tue Jul 22 00:37:49 2003 +0000 +++ b/src/ft.c Tue Jul 22 03:26:33 2003 +0000 @@ -51,6 +51,8 @@ if (ip != NULL && *ip != '\0') xfer->local_ip = g_strdup(ip); + else + xfer->local_ip = gaim_xfers_get_local_ip(); ui_ops = gaim_xfer_get_ui_ops(xfer); @@ -704,8 +706,33 @@ g_free(title); } +/************************************************************************** + * File Transfer Subsystem API + **************************************************************************/ +char * +gaim_xfers_get_local_ip(void) +{ + struct hostent *host; + char localhost[129]; + long unsigned add; + char ip[46]; + + if (gethostname(localhost, 128) < 0) + return NULL; + + if ((host = gethostbyname(localhost)) == NULL) + return NULL; + + memcpy(&add, host->h_addr_list[0], 4); + add = htonl(add); + + g_snprintf(ip, 11, "%lu", add); + + return g_strdup(ip); +} + void -gaim_xfer_init(void) +gaim_xfers_init(void) { gaim_prefs_add_none("/core/ft"); gaim_prefs_add_string("/core/ft/public_ip", ""); diff -r 4fcfe659568a -r 3565ee7a5dd3 src/ft.h --- a/src/ft.h Tue Jul 22 00:37:49 2003 +0000 +++ b/src/ft.h Tue Jul 22 03:26:33 2003 +0000 @@ -462,10 +462,27 @@ */ void gaim_xfer_error(GaimXferType type, const char *who, const char *msg); +/*@}*/ + +/**************************************************************************/ +/** @name File Transfer Subsystem API */ +/**************************************************************************/ +/*@{*/ + +/** + * Returns the IP address of the local system. + * + * @note The returned IP address must be g_free()'d when no longer + * in use. + * + * @return The local IP address. + */ +char *gaim_xfers_get_local_ip(void); + /** * Initializes the file transfer subsystem. */ -void gaim_xfer_init(void); +void gaim_xfers_init(void); /*@}*/ diff -r 4fcfe659568a -r 3565ee7a5dd3 src/main.c --- a/src/main.c Tue Jul 22 00:37:49 2003 +0000 +++ b/src/main.c Tue Jul 22 03:26:33 2003 +0000 @@ -507,7 +507,7 @@ gaim_gtk_blist_init(); gaim_gtk_conversation_init(); gaim_gtk_pounces_init(); - gaim_gtk_xfer_init(); + gaim_gtk_xfers_init(); } static void