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 #include <gmodule.h>
00097 
00098 #ifdef PURPLE_PLUGINS
00099 # ifndef _WIN32
00100 #  include <dlfcn.h>
00101 # endif
00102 #endif
00103 
00104 #ifndef _WIN32
00105 # include <netinet/in.h>
00106 # include <sys/socket.h>
00107 # include <arpa/inet.h>
00108 # include <sys/un.h>
00109 # include <sys/utsname.h>
00110 # include <netdb.h>
00111 # include <signal.h>
00112 # include <unistd.h>
00113 #endif
00114 
00115 /* MAXPATHLEN should only be used with readlink() on glib < 2.4.0.  For
00116  * anything else, use g_file_read_link() or other dynamic functions.  This is
00117  * important because Hurd has no hard limits on path length. */
00118 #if !GLIB_CHECK_VERSION(2,4,0)
00119 # ifndef MAXPATHLEN
00120 #  ifdef PATH_MAX
00121 #   define MAXPATHLEN PATH_MAX
00122 #  else
00123 #   define MAXPATHLEN 1024
00124 #  endif
00125 # endif
00126 #endif
00127 
00128 #ifndef HOST_NAME_MAX
00129 # define HOST_NAME_MAX 255
00130 #endif
00131 
00132 #include <glib.h>
00133 #if !GLIB_CHECK_VERSION(2,4,0)
00134 #   define G_MAXUINT32 ((guint32) 0xffffffff)
00135 #endif
00136 
00137 #if GLIB_CHECK_VERSION(2,6,0)
00138 #   include <glib/gstdio.h>
00139 #endif
00140 
00141 #if !GLIB_CHECK_VERSION(2,6,0)
00142 #   define g_freopen freopen
00143 #   define g_fopen fopen
00144 #   define g_rmdir rmdir
00145 #   define g_remove remove
00146 #   define g_unlink unlink
00147 #   define g_lstat lstat
00148 #   define g_stat stat
00149 #   define g_mkdir mkdir
00150 #   define g_rename rename
00151 #   define g_open open
00152 #endif
00153 
00154 #if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32
00155 #   define g_access access
00156 #endif
00157 
00158 #if !GLIB_CHECK_VERSION(2,10,0)
00159 #   define g_slice_new(type) g_new(type, 1)
00160 #   define g_slice_new0(type) g_new0(type, 1)
00161 #   define g_slice_free(type, mem) g_free(mem)
00162 #endif
00163 
00164 #ifdef _WIN32
00165 #include "win32dep.h"
00166 #endif
00167 
00168 /* ugly ugly ugly */
00169 /* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT
00170  * are only defined in Glib >= 2.4 */
00171 #ifndef G_GINT64_MODIFIER
00172 #   if GLIB_SIZEOF_LONG == 8
00173 #       define G_GINT64_MODIFIER "l"
00174 #   else
00175 #       define G_GINT64_MODIFIER "ll"
00176 #   endif
00177 #endif
00178 
00179 #ifndef G_GSIZE_FORMAT
00180 #   if GLIB_SIZEOF_LONG == 8
00181 #       define G_GSIZE_FORMAT "lu"
00182 #   else
00183 #       define G_GSIZE_FORMAT "u"
00184 #   endif
00185 #endif
00186 
00187 #ifndef G_GNUC_NULL_TERMINATED
00188 #   if     __GNUC__ >= 4
00189 #       define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
00190 #   else
00191 #       define G_GNUC_NULL_TERMINATED
00192 #   endif
00193 #endif
00194 
00195 /* Safer ways to work with static buffers. When using non-static
00196  * buffers, either use g_strdup_* functions (preferred) or use
00197  * g_strlcpy/g_strlcpy directly. */
00198 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest))
00199 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest))
00200 
00201 #define PURPLE_WEBSITE "http://pidgin.im/"
00202 #define PURPLE_DEVEL_WEBSITE "http://developer.pidgin.im/"
00203 
00204 /* This is for the accounts code to notify the buddy icon code that
00205  * it's done loading.  We may want to replace this with a signal. */
00206 void
00207 _purple_buddy_icons_account_loaded_cb(void);
00208 
00209 /* This is for the buddy list 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_blist_loaded_cb(void);
00213 
00214 /* This is for the purple_core_migrate() code to tell the buddy
00215  * icon subsystem about the old icons directory so it can
00216  * migrate any icons in use. */
00217 void
00218 _purple_buddy_icon_set_old_icons_dir(const char *dirname);
00219 
00220 #endif /* _PURPLE_INTERNAL_H_ */