internal.h

Go to the documentation of this file.
00001 
00025 #ifndef _PURPLE_INTERNAL_H_
00026 #define _PURPLE_INTERNAL_H_
00027 
00028 #ifdef HAVE_CONFIG_H
00029 # include <config.h>
00030 #endif
00031 
00032 /*
00033  * If we're using NLS, make sure gettext works.  If not, then define
00034  * dummy macros in place of the normal gettext macros.
00035  *
00036  * Also, the perl XS config.h file sometimes defines _  So we need to
00037  * make sure _ isn't already defined before trying to define it.
00038  *
00039  * The Singular/Plural/Number ngettext dummy definition below was
00040  * taken from an email to the texinfo mailing list by Manuel Guerrero.
00041  * Thank you Manuel, and thank you Alex's good friend Google.
00042  */
00043 #ifdef ENABLE_NLS
00044 #  include <locale.h>
00045 #  include <libintl.h>
00046 #  define _(String) ((const char *)dgettext(PACKAGE, String))
00047 #  ifdef gettext_noop
00048 #    define N_(String) gettext_noop (String)
00049 #  else
00050 #    define N_(String) (String)
00051 #  endif
00052 #else
00053 #  include <locale.h>
00054 #  define N_(String) (String)
00055 #  ifndef _
00056 #    define _(String) ((const char *)String)
00057 #  endif
00058 #  define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
00059 #  define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
00060 #endif
00061 
00062 #ifdef HAVE_ENDIAN_H
00063 # include <endian.h>
00064 #endif
00065 
00066 #define MSG_LEN 2048
00067 /* The above should normally be the same as BUF_LEN,
00068  * but just so we're explicitly asking for the max message
00069  * length. */
00070 #define BUF_LEN MSG_LEN
00071 #define BUF_LONG BUF_LEN * 2
00072 
00073 #include <sys/stat.h>
00074 #include <sys/types.h>
00075 #ifndef _WIN32
00076 #include <sys/time.h>
00077 #include <sys/wait.h>
00078 #endif
00079 #include <ctype.h>
00080 #include <errno.h>
00081 #include <fcntl.h>
00082 #include <math.h>
00083 #include <stdio.h>
00084 #include <stdlib.h>
00085 #include <string.h>
00086 #include <time.h>
00087 
00088 #ifdef HAVE_ICONV
00089 #include <iconv.h>
00090 #endif
00091 
00092 #ifdef HAVE_LANGINFO_CODESET
00093 #include <langinfo.h>
00094 #endif
00095 
00096 #ifdef PURPLE_PLUGINS
00097 # include <gmodule.h>
00098 # ifndef _WIN32
00099 #  include <dlfcn.h>
00100 # endif
00101 #endif
00102 
00103 #ifndef _WIN32
00104 # include <netinet/in.h>
00105 # include <sys/socket.h>
00106 # include <arpa/inet.h>
00107 # include <sys/un.h>
00108 # include <sys/utsname.h>
00109 # include <netdb.h>
00110 # include <signal.h>
00111 # include <unistd.h>
00112 #endif
00113 
00114 #ifndef MAXPATHLEN
00115 # define MAXPATHLEN 1024
00116 #endif
00117 
00118 #ifndef HOST_NAME_MAX
00119 # define HOST_NAME_MAX 255
00120 #endif
00121 
00122 #define PATHSIZE 1024
00123 
00124 #include <glib.h>
00125 #if !GLIB_CHECK_VERSION(2,4,0)
00126 #   define G_MAXUINT32 ((guint32) 0xffffffff)
00127 #endif
00128 
00129 #if GLIB_CHECK_VERSION(2,6,0)
00130 #   include <glib/gstdio.h>
00131 #endif
00132 
00133 #if !GLIB_CHECK_VERSION(2,6,0)
00134 #   define g_freopen freopen
00135 #   define g_fopen fopen
00136 #   define g_rmdir rmdir
00137 #   define g_remove remove
00138 #   define g_unlink unlink
00139 #   define g_lstat lstat
00140 #   define g_stat stat
00141 #   define g_mkdir mkdir
00142 #   define g_rename rename
00143 #   define g_open open
00144 #endif
00145 
00146 #if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32
00147 #   define g_access access
00148 #endif
00149 
00150 #if !GLIB_CHECK_VERSION(2,10,0)
00151 #   define g_slice_new(type) g_new(type, 1)
00152 #   define g_slice_new0(type) g_new0(type, 1)
00153 #   define g_slice_free(type, mem) g_free(mem)
00154 #endif
00155 
00156 #ifdef _WIN32
00157 #include "win32dep.h"
00158 #endif
00159 
00160 /* ugly ugly ugly */
00161 /* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT
00162  * are only defined in Glib >= 2.4 */
00163 #ifndef G_GINT64_MODIFIER
00164 #   if GLIB_SIZEOF_LONG == 8
00165 #       define G_GINT64_MODIFIER "l"
00166 #   else
00167 #       define G_GINT64_MODIFIER "ll"
00168 #   endif
00169 #endif
00170 
00171 #ifndef G_GSIZE_FORMAT
00172 #   if GLIB_SIZEOF_LONG == 8
00173 #       define G_GSIZE_FORMAT "lu"
00174 #   else
00175 #       define G_GSIZE_FORMAT "u"
00176 #   endif
00177 #endif
00178 
00179 /* Safer ways to work with static buffers. When using non-static
00180  * buffers, either use g_strdup_* functions (preferred) or use
00181  * g_strlcpy/g_strlcpy directly. */
00182 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest))
00183 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest))
00184 
00185 #define PURPLE_WEBSITE "http://pidgin.im/"
00186 #define PURPLE_DEVEL_WEBSITE "http://developer.pidgin.im/"
00187 
00188 /* This is for the accounts code to notify the buddy icon code that
00189  * it's done loading.  We may want to replace this with a signal. */
00190 void
00191 _purple_buddy_icons_account_loaded_cb(void);
00192 
00193 /* This is for the buddy list to notify the buddy icon code that
00194  * it's done loading.  We may want to replace this with a signal. */
00195 void
00196 _purple_buddy_icons_blist_loaded_cb(void);
00197 
00198 /* This is for the purple_core_migrate() code to tell the buddy
00199  * icon subsystem about the old icons directory so it can
00200  * migrate any icons in use. */
00201 void
00202 _purple_buddy_icon_set_old_icons_dir(const char *dirname);
00203 
00204 #endif /* _PURPLE_INTERNAL_H_ */