libpurple/win32/libc_interface.c

Wed, 25 Oct 2023 20:26:35 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Wed, 25 Oct 2023 20:26:35 -0500
changeset 42410
563e7a17c220
parent 42371
c0c022adabf7
child 43086
de9a870ce36e
permissions
-rw-r--r--

Fix possible clash of config headers

Both GLib and GStreamer have a config file called `config.h` and use the `HAVE_CONFIG_H` macro to conditionally include them.

Normally, this works out fine, but if they are subprojects, we may accidentally trigger including a different `config.h`. This is normally harmless, but it causes a bunch of warnings because we define `GETTEXT_PACKAGE` on the command-line, and it won't match the one in a different project.

However, we only include this file in source files, not headers, and it's always created, so there's no need to conditionally include it or define the macro. We can also rename it so it can't clash with other instances as well.

Testing Done:
Compiled with subprojects and stopped seeing many warnings about `GETTEXT_PACKAGE` and other generic variables being re-defined due to GStreamer's `config.h`.

Reviewed at https://reviews.imfreedom.org/r/2707/

3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
2 * purple
17666
9c32c365b852 Pretend that WSAEINPROGRESS is EAGAIN (for our purposes, I think they are equivalent). I think this might help #485. References #485.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
3 *
5913
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
4 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
5 *
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
6 * This program is free software; you can redistribute it and/or modify
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
7 * it under the terms of the GNU General Public License as published by
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
9 * (at your option) any later version.
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
10 *
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
11 * This program is distributed in the hope that it will be useful,
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
14 * GNU General Public License for more details.
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
15 *
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
16 * You should have received a copy of the GNU General Public License
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
17 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18553
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
5913
4d016c00bb36 [gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents: 5474
diff changeset
19 *
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
20 */
35892
02bf3200b9cb cross-win32: make use of WIN32_LEAN_AND_MEAN define
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35855
diff changeset
21
42410
563e7a17c220 Fix possible clash of config headers
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42371
diff changeset
22 #include <purpleconfig.h>
35892
02bf3200b9cb cross-win32: make use of WIN32_LEAN_AND_MEAN define
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35855
diff changeset
23
39373
47667f5c6696 libpurple: Include 'glib/gi18n-lib.h' instead of 'libintl.h'
Mike Ruprecht <cmaiku@gmail.com>
parents: 39020
diff changeset
24 #include <glib/gi18n-lib.h>
8244
014ff38feea9 [gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents: 6425
diff changeset
25 #include <winsock2.h>
014ff38feea9 [gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents: 6425
diff changeset
26 #include <ws2tcpip.h>
3777
a3f8adc4c3e0 [gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents: 3712
diff changeset
27 #include <io.h>
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
28 #include <stdlib.h>
3777
a3f8adc4c3e0 [gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents: 3712
diff changeset
29 #include <stdio.h>
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
30 #include <errno.h>
3777
a3f8adc4c3e0 [gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents: 3712
diff changeset
31 #include <sys/timeb.h>
4905
1464e05926f0 [gaim-migrate @ 5239]
Herman Bloggs <herman@bluedigits.com>
parents: 4193
diff changeset
32 #include <sys/stat.h>
3777
a3f8adc4c3e0 [gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents: 3712
diff changeset
33 #include <time.h>
10589
4e10236e06d4 [gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents: 9611
diff changeset
34 #include <glib.h>
6425
3e86c949c98a [gaim-migrate @ 6933]
Herman Bloggs <herman@bluedigits.com>
parents: 5913
diff changeset
35 #include "debug.h"
3777
a3f8adc4c3e0 [gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents: 3712
diff changeset
36 #include "libc_internal.h"
38688
79304d0f6d43 Fix mingw32 compilation
Daniel Kamil Kozar <dkk089@gmail.com>
parents: 38259
diff changeset
37 #include "util.h"
25333
182125d7b7fc Fix from the QuteCom folks to compile with Glib < 2.8.5 with MSVC. Fixes #7761. Also some minor cleanup from me.
Daniel Atallah <datallah@pidgin.im>
parents: 24843
diff changeset
38 #include <glib/gstdio.h>
38604
9ad76b0d9de7 win32/libc_interface: Add missing util.h include for purple_strequal()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
39 #include "util.h"
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
40
25333
182125d7b7fc Fix from the QuteCom folks to compile with Glib < 2.8.5 with MSVC. Fixes #7761. Also some minor cleanup from me.
Daniel Atallah <datallah@pidgin.im>
parents: 24843
diff changeset
41 #ifndef S_ISDIR
182125d7b7fc Fix from the QuteCom folks to compile with Glib < 2.8.5 with MSVC. Fixes #7761. Also some minor cleanup from me.
Daniel Atallah <datallah@pidgin.im>
parents: 24843
diff changeset
42 # define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR)
182125d7b7fc Fix from the QuteCom folks to compile with Glib < 2.8.5 with MSVC. Fixes #7761. Also some minor cleanup from me.
Daniel Atallah <datallah@pidgin.im>
parents: 24843
diff changeset
43 #endif
21771
0df7285a6164 Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents: 21635
diff changeset
44
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
45 /* fcntl.h */
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
46 /* This is not a full implementation of fcntl. Update as needed.. */
20239
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
47 int wpurple_fcntl(int socket, int command, ...) {
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
48
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
49 switch( command ) {
20239
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
50 case F_GETFL:
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
51 return 0;
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
52
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
53 case F_SETFL:
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
54 {
20239
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
55 va_list args;
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
56 int val;
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
57 int ret=0;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
58
20239
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
59 va_start(args, command);
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
60 val = va_arg(args, int);
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
61 va_end(args);
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
62
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
63 switch( val ) {
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
64 case O_NONBLOCK:
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
65 {
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
66 u_long imode=1;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
67 ret = ioctlsocket(socket, FIONBIO, &imode);
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
68 break;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
69 }
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
70 case 0:
20239
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
71 {
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
72 u_long imode=0;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
73 ret = ioctlsocket(socket, FIONBIO, &imode);
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
74 break;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
75 }
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
76 default:
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
77 errno = EINVAL;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
78 return -1;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
79 }/*end switch*/
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
80 if( ret == SOCKET_ERROR ) {
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
81 errno = WSAGetLastError();
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
82 return -1;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
83 }
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
84 return 0;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
85 }
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
86 default:
40765
a5381c20e802 Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40668
diff changeset
87 purple_debug_warning("wpurple", "wpurple_fcntl: Unsupported command");
3712
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
88 return -1;
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
89 }/*end switch*/
d926a65b5f89 [gaim-migrate @ 3845]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
90 }

mercurial