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 # ifndef __APPLE_CC__
51 # define __APPLE_CC__ 0
52 # endif
53 # include <libintl.h>
54 # define _(String) ((const char *)dgettext(PACKAGE, String))
55 # ifdef gettext_noop
56 # define N_(String) gettext_noop (String)
57 # else
58 # define N_(String) (String)
59 # endif
60 #else
61 # include <locale.h>
62 # define N_(String) (String)
63 # ifndef _
64 # define _(String) ((const char *)String)
65 # endif
66 # define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
67 # define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
68 #endif
69 
70 #ifdef HAVE_ENDIAN_H
71 # include <endian.h>
72 #endif
73 
74 #define MSG_LEN 2048
75 /* The above should normally be the same as BUF_LEN,
76  * but just so we're explicitly asking for the max message
77  * length. */
78 #define BUF_LEN MSG_LEN
79 #define BUF_LONG BUF_LEN * 2
80 
81 #include <sys/stat.h>
82 #include <sys/types.h>
83 #ifndef _WIN32
84 #include <sys/time.h>
85 #include <sys/wait.h>
86 #include <sys/time.h>
87 #endif
88 #include <ctype.h>
89 #include <errno.h>
90 #include <fcntl.h>
91 #include <math.h>
92 #include <stdio.h>
93 #include <stdlib.h>
94 #include <string.h>
95 #include <time.h>
96 
97 #ifdef HAVE_ICONV
98 #include <iconv.h>
99 #endif
100 
101 #ifdef HAVE_LANGINFO_CODESET
102 #include <langinfo.h>
103 #endif
104 
105 #include <gmodule.h>
106 
107 #ifdef PURPLE_PLUGINS
108 # ifdef HAVE_DLFCN_H
109 # include <dlfcn.h>
110 # endif
111 #endif
112 
113 #ifndef _WIN32
114 # include <netinet/in.h>
115 # include <sys/socket.h>
116 # include <arpa/inet.h>
117 # include <sys/un.h>
118 # include <sys/utsname.h>
119 # include <netdb.h>
120 # include <signal.h>
121 # include <unistd.h>
122 #endif
123 
124 #ifndef HOST_NAME_MAX
125 # define HOST_NAME_MAX 255
126 #endif
127 
128 #include <glib.h>
129 
130 /* This wasn't introduced until Glib 2.14 :( */
131 #ifndef G_MAXSSIZE
132 # if GLIB_SIZEOF_LONG == 8
133 # define G_MAXSSIZE ((gssize) 0x7fffffffffffffff)
134 # else
135 # define G_MAXSSIZE ((gssize) 0x7fffffff)
136 # endif
137 #endif
138 
139 #include <glib/gstdio.h>
140 
141 #ifdef _WIN32
142 #include "win32dep.h"
143 #endif
144 
145 #ifdef HAVE_CONFIG_H
146 #if SIZEOF_TIME_T == 4
147 # define PURPLE_TIME_T_MODIFIER "lu"
148 #elif SIZEOF_TIME_T == 8
149 # define PURPLE_TIME_T_MODIFIER "zu"
150 #else
151 #error Unknown size of time_t
152 #endif
153 #endif
154 
155 #include <glib-object.h>
156 
157 #if !GLIB_CHECK_VERSION(2, 32, 0)
158 
159 #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
160 #define G_GNUC_END_IGNORE_DEPRECATIONS
161 
162 #endif /* 2.32.0 */
163 
164 #ifdef __clang__
165 
166 #undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS
167 #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
168  _Pragma ("clang diagnostic push") \
169  _Pragma ("clang diagnostic ignored \"-Wdeprecated-declarations\"")
170 
171 #undef G_GNUC_END_IGNORE_DEPRECATIONS
172 #define G_GNUC_END_IGNORE_DEPRECATIONS \
173  _Pragma ("clang diagnostic pop")
174 
175 #endif /* __clang__ */
176 
177 #ifdef __COVERITY__
178 
179 /* avoid TAINTED_SCALAR warning */
180 #undef g_utf8_next_char
181 #define g_utf8_next_char(p) (char *)((p) + 1)
182 
183 #endif
184 
185 /* Safer ways to work with static buffers. When using non-static
186  * buffers, either use g_strdup_* functions (preferred) or use
187  * g_strlcpy/g_strlcpy directly. */
188 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest))
189 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest))
190 
191 typedef union
192 {
193  struct sockaddr sa;
194  struct sockaddr_in in;
195  struct sockaddr_in6 in6;
196  struct sockaddr_storage storage;
198 
199 #define PURPLE_WEBSITE "http://pidgin.im/"
200 #define PURPLE_DEVEL_WEBSITE "http://developer.pidgin.im/"
201 
202 
203 /* INTERNAL FUNCTIONS */
204 
205 #include "account.h"
206 #include "connection.h"
207 
208 /* This is for the accounts code to notify the buddy icon code that
209  * it's done loading. We may want to replace this with a signal. */
210 void
211 _purple_buddy_icons_account_loaded_cb(void);
212 
213 /* This is for the buddy list to notify the buddy icon code that
214  * it's done loading. We may want to replace this with a signal. */
215 void
216 _purple_buddy_icons_blist_loaded_cb(void);
217 
218 /* This is for the purple_core_migrate() code to tell the buddy
219  * icon subsystem about the old icons directory so it can
220  * migrate any icons in use. */
221 void
222 _purple_buddy_icon_set_old_icons_dir(const char *dirname);
223 
241 void _purple_connection_new(PurpleAccount *account, gboolean regist,
242  const char *password);
255 void _purple_connection_new_unregister(PurpleAccount *account, const char *password,
256  PurpleAccountUnregistrationCb cb, void *user_data);
267 
275 gboolean
277 
278 #endif /* _PURPLE_INTERNAL_H_ */
Connection API.
gboolean _purple_network_set_common_socket_flags(int fd)
Sets most commonly used socket flags: O_NONBLOCK and FD_CLOEXEC.
Structure representing an account.
Definition: account.h:126
Account API.
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...
void _purple_connection_new_unregister(PurpleAccount *account, const char *password, PurpleAccountUnregistrationCb cb, void *user_data)
Tries to unregister the account on the server.
void _purple_connection_destroy(PurpleConnection *gc)
Disconnects and destroys a PurpleConnection.