Mercurial > pidgin
comparison src/ft.c @ 6269:0a902bd3e170
[gaim-migrate @ 6766]
I'm going to be boiled alive for this.. Changing
gaim_xfers_get_local_system_ip() to use a static buffer that it returns
instead of a g_strdup()'d copy of the buffer... but that's rarely of use,
because I don't think the IP will be changing often enough where this will
screw up code :P Also, fixed a function's name, because I broke compiling
again.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 22 Jul 2003 08:22:08 +0000 |
parents | 084e1f6610a8 |
children | 16fcc379e484 |
comparison
equal
deleted
inserted
replaced
6268:084e1f6610a8 | 6269:0a902bd3e170 |
---|---|
43 xfer->type = type; | 43 xfer->type = type; |
44 xfer->account = account; | 44 xfer->account = account; |
45 xfer->who = g_strdup(who); | 45 xfer->who = g_strdup(who); |
46 xfer->ui_ops = gaim_get_xfer_ui_ops(); | 46 xfer->ui_ops = gaim_get_xfer_ui_ops(); |
47 | 47 |
48 xfer->local_ip = gaim_xfers_get_ip_for_account(account); | 48 xfer->local_ip = g_strdup(gaim_xfers_get_ip_for_account(account)); |
49 | 49 |
50 ui_ops = gaim_xfer_get_ui_ops(xfer); | 50 ui_ops = gaim_xfer_get_ui_ops(xfer); |
51 | 51 |
52 if (ui_ops != NULL && ui_ops->new_xfer != NULL) | 52 if (ui_ops != NULL && ui_ops->new_xfer != NULL) |
53 ui_ops->new_xfer(xfer); | 53 ui_ops->new_xfer(xfer); |
721 return NULL; | 721 return NULL; |
722 | 722 |
723 return ip; | 723 return ip; |
724 } | 724 } |
725 | 725 |
726 char * | 726 const char * |
727 gaim_xfers_get_local_system_ip(void) | 727 gaim_xfers_get_local_system_ip(void) |
728 { | 728 { |
729 struct hostent *host; | 729 struct hostent *host; |
730 char localhost[129]; | 730 char localhost[129]; |
731 long unsigned add; | 731 long unsigned add; |
732 char ip[46]; | 732 static char ip[46]; |
733 | 733 |
734 if (gethostname(localhost, 128) < 0) | 734 if (gethostname(localhost, 128) < 0) |
735 return NULL; | 735 return NULL; |
736 | 736 |
737 if ((host = gethostbyname(localhost)) == NULL) | 737 if ((host = gethostbyname(localhost)) == NULL) |
740 memcpy(&add, host->h_addr_list[0], 4); | 740 memcpy(&add, host->h_addr_list[0], 4); |
741 add = htonl(add); | 741 add = htonl(add); |
742 | 742 |
743 g_snprintf(ip, 11, "%lu", add); | 743 g_snprintf(ip, 11, "%lu", add); |
744 | 744 |
745 return g_strdup(ip); | 745 return ip; |
746 } | 746 } |
747 | 747 |
748 char * | 748 const char * |
749 gaim_xfers_get_ip_for_account(const GaimAccount *account) | 749 gaim_xfers_get_ip_for_account(const GaimAccount *account) |
750 { | 750 { |
751 g_return_val_if_fail(account != NULL, NULL); | 751 g_return_val_if_fail(account != NULL, NULL); |
752 | 752 |
753 if (gaim_account_get_public_ip(account) != NULL) | 753 if (gaim_account_get_public_ip(account) != NULL) |
754 return g_strdup(gaim_account_get_public_ip(account)); | 754 return gaim_account_get_public_ip(account); |
755 else if (gaim_xfers_get_local_ip() != NULL) | 755 else if (gaim_xfers_get_local_ip() != NULL) |
756 return g_strdup(gaim_xfers_get_local_ip()); | 756 return gaim_xfers_get_local_ip(); |
757 else | 757 else |
758 return gaim_xfers_get_local_system_ip(); | 758 return gaim_xfers_get_local_system_ip(); |
759 } | 759 } |
760 | 760 |
761 void | 761 void |