internal.h
Go to the documentation of this file.
1
6 /* purple
7 *
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 */
26 #ifndef _PURPLE_INTERNAL_H_
27 #define _PURPLE_INTERNAL_H_
28
29 #ifdef HAVE_CONFIG_H
30 # include <config.h>
31 #endif
32
33 /* for SIOCGIFCONF in SKYOS */
34 #ifdef SKYOS
35 #include <net/sockios.h>
36 #endif
37 /*
38 * If we're using NLS, make sure gettext works. If not, then define
39 * dummy macros in place of the normal gettext macros.
40 *
41 * Also, the perl XS config.h file sometimes defines _ So we need to
42 * make sure _ isn't already defined before trying to define it.
43 *
44 * The Singular/Plural/Number ngettext dummy definition below was
45 * taken from an email to the texinfo mailing list by Manuel Guerrero.
46 * Thank you Manuel, and thank you Alex's good friend Google.
47 */
48 #ifdef ENABLE_NLS
49 # include <locale.h>
50 # include <libintl.h>
51 # define _(String) ((const char *)dgettext(PACKAGE, String))
52 # ifdef gettext_noop
53 # define N_(String) gettext_noop (String)
54 # else
55 # define N_(String) (String)
56 # endif
57 #else
58 # include <locale.h>
59 # define N_(String) (String)
60 # ifndef _
61 # define _(String) ((const char *)String)
62 # endif
63 # define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
64 # define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
65 #endif
66
67 #ifdef HAVE_ENDIAN_H
68 # include <endian.h>
69 #endif
70
71 #define MSG_LEN 2048
72 /* The above should normally be the same as BUF_LEN,
73 * but just so we're explicitly asking for the max message
74 * length. */
75 #define BUF_LEN MSG_LEN
76 #define BUF_LONG BUF_LEN * 2
77
78 #include <sys/stat.h>
79 #include <sys/types.h>
80 #ifndef _WIN32
81 #include <sys/time.h>
82 #include <sys/wait.h>
83 #include <sys/time.h>
84 #endif
85 #include <ctype.h>
86 #include <errno.h>
87 #include <fcntl.h>
88 #include <math.h>
89 #include <stdio.h>
90 #include <stdlib.h>
91 #include <string.h>
92 #include <time.h>
93
94 #ifdef HAVE_ICONV
95 #include <iconv.h>
96 #endif
97
98 #ifdef HAVE_LANGINFO_CODESET
99 #include <langinfo.h>
100 #endif
101
102 #include <gmodule.h>
103
104 #ifdef PURPLE_PLUGINS
105 # ifdef HAVE_DLFCN_H
106 # include <dlfcn.h>
107 # endif
108 #endif
109
110 #ifndef _WIN32
111 # include <netinet/in.h>
112 # include <sys/socket.h>
113 # include <arpa/inet.h>
114 # include <sys/un.h>
115 # include <sys/utsname.h>
116 # include <netdb.h>
117 # include <signal.h>
118 # include <unistd.h>
119 #endif
120
121 #ifndef HOST_NAME_MAX
122 # define HOST_NAME_MAX 255
123 #endif
124
125 #include <glib.h>
126
127 /* This wasn't introduced until Glib 2.14 :( */
128 #ifndef G_MAXSSIZE
129 # if GLIB_SIZEOF_LONG == 8
130 # define G_MAXSSIZE ((gssize) 0x7fffffffffffffff)
131 # else
132 # define G_MAXSSIZE ((gssize) 0x7fffffff)
133 # endif
134 #endif
135
136 #include <glib/gstdio.h>
137
138 #ifdef _WIN32
139 #include "win32dep.h"
140 #endif
141
142 #ifdef HAVE_CONFIG_H
143 #if SIZEOF_TIME_T == 4
144 # define PURPLE_TIME_T_MODIFIER "lu"
145 #elif SIZEOF_TIME_T == 8
146 # define PURPLE_TIME_T_MODIFIER "zu"
147 #else
148 #error Unknown size of time_t
149 #endif
150 #endif
151
152 #include <glib-object.h>
153
154 #if !GLIB_CHECK_VERSION(2, 32, 0)
155
156 #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
157 #define G_GNUC_END_IGNORE_DEPRECATIONS
158
159 #endif /* 2.32.0 */
160
161 #ifdef __clang__
162
163 #undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS
164 #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
165 _Pragma ("clang diagnostic push") \
166 _Pragma ("clang diagnostic ignored \"-Wdeprecated-declarations\"")
167
168 #undef G_GNUC_END_IGNORE_DEPRECATIONS
169 #define G_GNUC_END_IGNORE_DEPRECATIONS \
170 _Pragma ("clang diagnostic pop")
171
172 #endif /* __clang__ */
173
174 #ifdef __COVERITY__
175
176 /* avoid TAINTED_SCALAR warning */
177 #undef g_utf8_next_char
178 #define g_utf8_next_char(p) (char *)((p) + 1)
179
180 #endif
181
182 /* Safer ways to work with static buffers. When using non-static
183 * buffers, either use g_strdup_* functions (preferred) or use
184 * g_strlcpy/g_strlcpy directly. */
185 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest))
186 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest))
187
188 typedef union
189 {
190 struct sockaddr sa;
191 struct sockaddr_in in;
192 struct sockaddr_in6 in6;
193 struct sockaddr_storage storage;
194 } common_sockaddr_t;
195
196 #define PURPLE_WEBSITE "http://pidgin.im/"
197 #define PURPLE_DEVEL_WEBSITE "http://developer.pidgin.im/"
198
199
200 /* INTERNAL FUNCTIONS */
201
202 #include "account.h"
203 #include "connection.h"
204
205 /* This is for the accounts code to notify the buddy icon code that
206 * it's done loading. We may want to replace this with a signal. */
207 void
208 _purple_buddy_icons_account_loaded_cb(void);
209
210 /* This is for the buddy list to notify the buddy icon code that
211 * it's done loading. We may want to replace this with a signal. */
212 void
213 _purple_buddy_icons_blist_loaded_cb(void);
214
215 /* This is for the purple_core_migrate() code to tell the buddy
216 * icon subsystem about the old icons directory so it can
217 * migrate any icons in use. */
218 void
219 _purple_buddy_icon_set_old_icons_dir(const char *dirname);
220
238 void _purple_connection_new(PurpleAccount *account, gboolean regist,
239 const char *password);
252 void _purple_connection_new_unregister(PurpleAccount *account, const char *password,
253 PurpleAccountUnregistrationCb cb, void *user_data);
263 void _purple_connection_destroy(PurpleConnection *gc);
264
272 gboolean
273 _purple_network_set_common_socket_flags(int fd);
274
275 #endif /* _PURPLE_INTERNAL_H_ */
common_sockaddr_t
Definition: internal.h:188
connection.h
Connection API.
_purple_network_set_common_socket_flags
gboolean _purple_network_set_common_socket_flags(int fd)
Sets most commonly used socket flags: O_NONBLOCK and FD_CLOEXEC.
_PurpleAccount
Structure representing an account.
Definition: account.h:169
account.h
Account API.
_purple_connection_new
void _purple_connection_new(PurpleAccount *account, gboolean regist, const char *password)
Creates a connection to the specified account and either connects or attempts to register a new accou...
_PurpleConnection
Definition: connection.h:245
_purple_connection_new_unregister
void _purple_connection_new_unregister(PurpleAccount *account, const char *password, PurpleAccountUnregistrationCb cb, void *user_data)
Tries to unregister the account on the server.
_purple_connection_destroy
void _purple_connection_destroy(PurpleConnection *gc)
Disconnects and destroys a PurpleConnection.