Thu, 28 Apr 2005 01:06:31 +0000
[gaim-migrate @ 12582]
Rename create_prpl_icon to gaim_gtk_create_prpl_icon, remove some dead
code from gtkconv, and use G_MODULE_BIND_LOCAL - this breaks perl plugins,
and should be added to the list of things that need fixing to save perl.
Semi-fix the raw plugin too, but only if your filesystem is being friendly
in where it puts stuff.
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for the ZOpenPort function. | |
| 3 | * | |
| 4 | * Created by: Robert French | |
| 5 | * | |
| 6 | * $Source$ | |
| 10867 | 7 | * $Author: thekingant $ |
| 2086 | 8 | * |
| 9 | * Copyright (c) 1987 by the Massachusetts Institute of Technology. | |
| 10 | * For copying and distribution information, see the file | |
| 11 | * "mit-copyright.h". | |
| 12 | */ | |
| 13 | /* $Header$ */ | |
| 14 | ||
| 15 | #ifndef lint | |
| 16 | static char rcsid_ZOpenPort_c[] = "$Header$"; | |
| 17 | #endif | |
| 18 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
7475
diff
changeset
|
19 | #include "internal.h" |
| 10867 | 20 | #ifdef WIN32 |
| 21 | #include <winsock2.h> | |
| 22 | #else | |
| 2086 | 23 | #include <sys/socket.h> |
| 10867 | 24 | #endif |
| 2086 | 25 | |
| 26 | Code_t ZOpenPort(port) | |
|
7475
987384816492
[gaim-migrate @ 8088]
Mark Doliner <markdoliner@pidgin.im>
parents:
2086
diff
changeset
|
27 | unsigned short *port; |
| 2086 | 28 | { |
| 29 | struct sockaddr_in bindin; | |
| 30 | int len; | |
| 31 | ||
| 32 | (void) ZClosePort(); | |
| 33 | ||
| 34 | if ((__Zephyr_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { | |
| 35 | __Zephyr_fd = -1; | |
| 36 | return (errno); | |
| 37 | } | |
| 38 | ||
| 39 | #ifdef SO_BSDCOMPAT | |
| 40 | { | |
| 41 | int on = 1; | |
| 42 | ||
| 43 | setsockopt(__Zephyr_fd, SOL_SOCKET, SO_BSDCOMPAT, (char *)&on, | |
| 44 | sizeof(on)); | |
| 45 | } | |
| 46 | #endif | |
| 47 | ||
| 48 | bindin.sin_family = AF_INET; | |
| 49 | ||
| 50 | if (port && *port) | |
| 51 | bindin.sin_port = *port; | |
| 52 | else | |
| 53 | bindin.sin_port = 0; | |
| 54 | ||
| 55 | bindin.sin_addr.s_addr = INADDR_ANY; | |
| 56 | ||
| 57 | if (bind(__Zephyr_fd, (struct sockaddr *)&bindin, sizeof(bindin)) < 0) { | |
| 58 | if (errno == EADDRINUSE && port && *port) | |
| 59 | return (ZERR_PORTINUSE); | |
| 60 | else | |
| 61 | return (errno); | |
| 62 | } | |
| 63 | ||
| 64 | if (!bindin.sin_port) { | |
| 65 | len = sizeof(bindin); | |
| 66 | if (getsockname(__Zephyr_fd, (struct sockaddr *)&bindin, &len)) | |
| 67 | return (errno); | |
| 68 | } | |
| 69 | ||
| 70 | __Zephyr_port = bindin.sin_port; | |
| 71 | __Zephyr_open = 1; | |
| 72 | ||
| 73 | if (port) | |
| 74 | *port = bindin.sin_port; | |
| 75 | ||
| 76 | return (ZERR_NONE); | |
| 77 | } |