internal.h

Go to the documentation of this file.
00001 
00006 /* purple
00007  *
00008  * Purple is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  */
00026 #ifndef _PURPLE_INTERNAL_H_
00027 #define _PURPLE_INTERNAL_H_
00028 
00029 #ifdef HAVE_CONFIG_H
00030 # include <config.h>
00031 #endif
00032 
00033 /* for SIOCGIFCONF  in SKYOS */
00034 #ifdef SKYOS
00035 #include <net/sockios.h>
00036 #endif
00037 /*
00038  * If we're using NLS, make sure gettext works.  If not, then define
00039  * dummy macros in place of the normal gettext macros.
00040  *
00041  * Also, the perl XS config.h file sometimes defines _  So we need to
00042  * make sure _ isn't already defined before trying to define it.
00043  *
00044  * The Singular/Plural/Number ngettext dummy definition below was
00045  * taken from an email to the texinfo mailing list by Manuel Guerrero.
00046  * Thank you Manuel, and thank you Alex's good friend Google.
00047  */
00048 #ifdef ENABLE_NLS
00049 #  include <locale.h>
00050 #  include <libintl.h>
00051 #  define _(String) ((const char *)dgettext(PACKAGE, String))
00052 #  ifdef gettext_noop
00053 #    define N_(String) gettext_noop (String)
00054 #  else
00055 #    define N_(String) (String)
00056 #  endif
00057 #else
00058 #  include <locale.h>
00059 #  define N_(String) (String)
00060 #  ifndef _
00061 #    define _(String) ((const char *)String)
00062 #  endif
00063 #  define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
00064 #  define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
00065 #endif
00066 
00067 #ifdef HAVE_ENDIAN_H
00068 # include <endian.h>
00069 #endif
00070 
00071 #define MSG_LEN 2048
00072 /* The above should normally be the same as BUF_LEN,
00073  * but just so we're explicitly asking for the max message
00074  * length. */
00075 #define BUF_LEN MSG_LEN
00076 #define BUF_LONG BUF_LEN * 2
00077 
00078 #include <sys/stat.h>
00079 #include <sys/types.h>
00080 #ifndef _WIN32
00081 #include <sys/time.h>
00082 #include <sys/wait.h>
00083 #endif
00084 #include <ctype.h>
00085 #include <errno.h>
00086 #include <fcntl.h>
00087 #include <math.h>
00088 #include <stdio.h>
00089 #include <stdlib.h>
00090 #include <string.h>
00091 #include <time.h>
00092 
00093 #ifdef HAVE_ICONV
00094 #include <iconv.h>
00095 #endif
00096 
00097 #ifdef HAVE_LANGINFO_CODESET
00098 #include <langinfo.h>
00099 #endif
00100 
00101 #include <gmodule.h>
00102 
00103 #ifdef PURPLE_PLUGINS
00104 # ifndef _WIN32
00105 #  include <dlfcn.h>
00106 # endif
00107 #endif
00108 
00109 #ifndef _WIN32
00110 # include <netinet/in.h>
00111 # include <sys/socket.h>
00112 # include <arpa/inet.h>
00113 # include <sys/un.h>
00114 # include <sys/utsname.h>
00115 # include <netdb.h>
00116 # include <signal.h>
00117 # include <unistd.h>
00118 #endif
00119 
00120 /* MAXPATHLEN should only be used with readlink() on glib < 2.4.0.  For
00121  * anything else, use g_file_read_link() or other dynamic functions.  This is
00122  * important because Hurd has no hard limits on path length. */
00123 #if !GLIB_CHECK_VERSION(2,4,0)
00124 # ifndef MAXPATHLEN
00125 #  ifdef PATH_MAX
00126 #   define MAXPATHLEN PATH_MAX
00127 #  else
00128 #   define MAXPATHLEN 1024
00129 #  endif
00130 # endif
00131 #endif
00132 
00133 #ifndef HOST_NAME_MAX
00134 # define HOST_NAME_MAX 255
00135 #endif
00136 
00137 #include <glib.h>
00138 #if !GLIB_CHECK_VERSION(2,4,0)
00139 #   define G_MAXUINT32 ((guint32) 0xffffffff)
00140 #endif
00141 
00142 #if GLIB_CHECK_VERSION(2,6,0)
00143 #   include <glib/gstdio.h>
00144 #endif
00145 
00146 #if !GLIB_CHECK_VERSION(2,6,0)
00147 #   define g_freopen freopen
00148 #   define g_fopen fopen
00149 #   define g_rmdir rmdir
00150 #   define g_remove remove
00151 #   define g_unlink unlink
00152 #   define g_lstat lstat
00153 #   define g_stat stat
00154 #   define g_mkdir mkdir
00155 #   define g_rename rename
00156 #   define g_open open
00157 #endif
00158 
00159 #if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32
00160 #   define g_access access
00161 #endif
00162 
00163 #if !GLIB_CHECK_VERSION(2,10,0)
00164 #   define g_slice_new(type) g_new(type, 1)
00165 #   define g_slice_new0(type) g_new0(type, 1)
00166 #   define g_slice_free(type, mem) g_free(mem)
00167 #endif
00168 
00169 #ifdef _WIN32
00170 #include "win32dep.h"
00171 #endif
00172 
00173 /* ugly ugly ugly */
00174 /* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT
00175  * are only defined in Glib >= 2.4 */
00176 #ifndef G_GINT64_MODIFIER
00177 #   if GLIB_SIZEOF_LONG == 8
00178 #       define G_GINT64_MODIFIER "l"
00179 #   else
00180 #       define G_GINT64_MODIFIER "ll"
00181 #   endif
00182 #endif
00183 
00184 #ifndef G_GSIZE_FORMAT
00185 #   if GLIB_SIZEOF_LONG == 8
00186 #       define G_GSIZE_FORMAT "lu"
00187 #   else
00188 #       define G_GSIZE_FORMAT "u"
00189 #   endif
00190 #endif
00191 
00192 #ifndef G_GNUC_NULL_TERMINATED
00193 #   if     __GNUC__ >= 4
00194 #       define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
00195 #   else
00196 #       define G_GNUC_NULL_TERMINATED
00197 #   endif
00198 #endif
00199 
00200 /* Safer ways to work with static buffers. When using non-static
00201  * buffers, either use g_strdup_* functions (preferred) or use
00202  * g_strlcpy/g_strlcpy directly. */
00203 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest))
00204 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest))
00205 
00206 #define PURPLE_WEBSITE "http://pidgin.im/"
00207 #define PURPLE_DEVEL_WEBSITE "http://developer.pidgin.im/"
00208 
00209 /* This is for the accounts code to notify the buddy icon code that
00210  * it's done loading.  We may want to replace this with a signal. */
00211 void
00212 _purple_buddy_icons_account_loaded_cb(void);
00213 
00214 /* This is for the buddy list to notify the buddy icon code that
00215  * it's done loading.  We may want to replace this with a signal. */
00216 void
00217 _purple_buddy_icons_blist_loaded_cb(void);
00218 
00219 /* This is for the purple_core_migrate() code to tell the buddy
00220  * icon subsystem about the old icons directory so it can
00221  * migrate any icons in use. */
00222 void
00223 _purple_buddy_icon_set_old_icons_dir(const char *dirname);
00224 
00225 #endif /* _PURPLE_INTERNAL_H_ */