| |
1 /** |
| |
2 * @file internal.h Internal definitions and includes |
| |
3 * @ingroup core |
| |
4 * |
| |
5 * purple |
| |
6 * |
| |
7 * Purple is the legal property of its developers, whose names are too numerous |
| |
8 * to list here. Please refer to the COPYRIGHT file distributed with this |
| |
9 * source distribution. |
| |
10 * |
| |
11 * This program is free software; you can redistribute it and/or modify |
| |
12 * it under the terms of the GNU General Public License as published by |
| |
13 * the Free Software Foundation; either version 2 of the License, or |
| |
14 * (at your option) any later version. |
| |
15 * |
| |
16 * This program is distributed in the hope that it will be useful, |
| |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| |
19 * GNU General Public License for more details. |
| |
20 * |
| |
21 * You should have received a copy of the GNU General Public License |
| |
22 * along with this program; if not, write to the Free Software |
| |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| |
24 */ |
| |
25 #ifndef _PURPLE_INTERNAL_H_ |
| |
26 #define _PURPLE_INTERNAL_H_ |
| |
27 |
| |
28 #ifdef HAVE_CONFIG_H |
| |
29 # include <config.h> |
| |
30 #endif |
| |
31 |
| |
32 /* |
| |
33 * If we're using NLS, make sure gettext works. If not, then define |
| |
34 * dummy macros in place of the normal gettext macros. |
| |
35 * |
| |
36 * Also, the perl XS config.h file sometimes defines _ So we need to |
| |
37 * make sure _ isn't already defined before trying to define it. |
| |
38 * |
| |
39 * The Singular/Plural/Number ngettext dummy definition below was |
| |
40 * taken from an email to the texinfo mailing list by Manuel Guerrero. |
| |
41 * Thank you Manuel, and thank you Alex's good friend Google. |
| |
42 */ |
| |
43 #ifdef ENABLE_NLS |
| |
44 # include <locale.h> |
| |
45 # include <libintl.h> |
| |
46 # define _(String) ((const char *)dgettext(PACKAGE, String)) |
| |
47 # ifdef gettext_noop |
| |
48 # define N_(String) gettext_noop (String) |
| |
49 # else |
| |
50 # define N_(String) (String) |
| |
51 # endif |
| |
52 #else |
| |
53 # include <locale.h> |
| |
54 # define N_(String) (String) |
| |
55 # ifndef _ |
| |
56 # define _(String) ((const char *)String) |
| |
57 # endif |
| |
58 # define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural)) |
| |
59 # define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural)) |
| |
60 #endif |
| |
61 |
| |
62 #ifdef HAVE_ENDIAN_H |
| |
63 # include <endian.h> |
| |
64 #endif |
| |
65 |
| |
66 #define MSG_LEN 2048 |
| |
67 /* The above should normally be the same as BUF_LEN, |
| |
68 * but just so we're explicitly asking for the max message |
| |
69 * length. */ |
| |
70 #define BUF_LEN MSG_LEN |
| |
71 #define BUF_LONG BUF_LEN * 2 |
| |
72 |
| |
73 #include <sys/stat.h> |
| |
74 #include <sys/types.h> |
| |
75 #ifndef _WIN32 |
| |
76 #include <sys/time.h> |
| |
77 #include <sys/wait.h> |
| |
78 #endif |
| |
79 #include <ctype.h> |
| |
80 #include <errno.h> |
| |
81 #include <fcntl.h> |
| |
82 #include <math.h> |
| |
83 #include <stdio.h> |
| |
84 #include <stdlib.h> |
| |
85 #include <string.h> |
| |
86 #include <time.h> |
| |
87 |
| |
88 #ifdef HAVE_ICONV |
| |
89 #include <iconv.h> |
| |
90 #endif |
| |
91 |
| |
92 #ifdef HAVE_LANGINFO_CODESET |
| |
93 #include <langinfo.h> |
| |
94 #endif |
| |
95 |
| |
96 #ifdef PURPLE_PLUGINS |
| |
97 # include <gmodule.h> |
| |
98 # ifndef _WIN32 |
| |
99 # include <dlfcn.h> |
| |
100 # endif |
| |
101 #endif |
| |
102 |
| |
103 #ifndef _WIN32 |
| |
104 # include <netinet/in.h> |
| |
105 # include <sys/socket.h> |
| |
106 # include <arpa/inet.h> |
| |
107 # include <sys/un.h> |
| |
108 # include <sys/utsname.h> |
| |
109 # include <netdb.h> |
| |
110 # include <signal.h> |
| |
111 # include <unistd.h> |
| |
112 #endif |
| |
113 |
| |
114 #ifndef MAXPATHLEN |
| |
115 # define MAXPATHLEN 1024 |
| |
116 #endif |
| |
117 |
| |
118 #ifndef HOST_NAME_MAX |
| |
119 # define HOST_NAME_MAX 255 |
| |
120 #endif |
| |
121 |
| |
122 #define PATHSIZE 1024 |
| |
123 |
| |
124 #include <glib.h> |
| |
125 #if !GLIB_CHECK_VERSION(2,4,0) |
| |
126 # define G_MAXUINT32 ((guint32) 0xffffffff) |
| |
127 #endif |
| |
128 |
| |
129 #if GLIB_CHECK_VERSION(2,6,0) |
| |
130 # include <glib/gstdio.h> |
| |
131 #endif |
| |
132 |
| |
133 #if !GLIB_CHECK_VERSION(2,6,0) |
| |
134 # define g_freopen freopen |
| |
135 # define g_fopen fopen |
| |
136 # define g_rmdir rmdir |
| |
137 # define g_remove remove |
| |
138 # define g_unlink unlink |
| |
139 # define g_lstat lstat |
| |
140 # define g_stat stat |
| |
141 # define g_mkdir mkdir |
| |
142 # define g_rename rename |
| |
143 # define g_open open |
| |
144 #endif |
| |
145 |
| |
146 #if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32 |
| |
147 # define g_access access |
| |
148 #endif |
| |
149 |
| |
150 #if !GLIB_CHECK_VERSION(2,10,0) |
| |
151 # define g_slice_new(type) g_new(type, 1) |
| |
152 # define g_slice_new0(type) g_new0(type, 1) |
| |
153 # define g_slice_free(type, mem) g_free(mem) |
| |
154 #endif |
| |
155 |
| |
156 #ifdef _WIN32 |
| |
157 #include "win32dep.h" |
| |
158 #endif |
| |
159 |
| |
160 /* ugly ugly ugly */ |
| |
161 /* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT |
| |
162 * are only defined in Glib >= 2.4 */ |
| |
163 #ifndef G_GINT64_MODIFIER |
| |
164 # if GLIB_SIZEOF_LONG == 8 |
| |
165 # define G_GINT64_MODIFIER "l" |
| |
166 # else |
| |
167 # define G_GINT64_MODIFIER "ll" |
| |
168 # endif |
| |
169 #endif |
| |
170 |
| |
171 #ifndef G_GSIZE_FORMAT |
| |
172 # if GLIB_SIZEOF_LONG == 8 |
| |
173 # define G_GSIZE_FORMAT "lu" |
| |
174 # else |
| |
175 # define G_GSIZE_FORMAT "u" |
| |
176 # endif |
| |
177 #endif |
| |
178 |
| |
179 /* Safer ways to work with static buffers. When using non-static |
| |
180 * buffers, either use g_strdup_* functions (preferred) or use |
| |
181 * g_strlcpy/g_strlcpy directly. */ |
| |
182 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest)) |
| |
183 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest)) |
| |
184 |
| |
185 #define PURPLE_WEBSITE "http://pidgin.im/" |
| |
186 |
| |
187 #endif /* _PURPLE_INTERNAL_H_ */ |