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 #include <sys/time.h>
00084 #endif
00085 #include <ctype.h>
00086 #include <errno.h>
00087 #include <fcntl.h>
00088 #include <math.h>
00089 #include <stdio.h>
00090 #include <stdlib.h>
00091 #include <string.h>
00092 #include <time.h>
00093 
00094 #ifdef HAVE_ICONV
00095 #include <iconv.h>
00096 #endif
00097 
00098 #ifdef HAVE_LANGINFO_CODESET
00099 #include <langinfo.h>
00100 #endif
00101 
00102 #include <gmodule.h>
00103 
00104 #ifdef PURPLE_PLUGINS
00105 # ifdef HAVE_DLFCN_H
00106 #  include <dlfcn.h>
00107 # endif
00108 #endif
00109 
00110 #ifndef _WIN32
00111 # include <netinet/in.h>
00112 # include <sys/socket.h>
00113 # include <arpa/inet.h>
00114 # include <sys/un.h>
00115 # include <sys/utsname.h>
00116 # include <netdb.h>
00117 # include <signal.h>
00118 # include <unistd.h>
00119 #endif
00120 
00121 /* MAXPATHLEN should only be used with readlink() on glib < 2.4.0.  For
00122  * anything else, use g_file_read_link() or other dynamic functions.  This is
00123  * important because Hurd has no hard limits on path length. */
00124 #if !GLIB_CHECK_VERSION(2,4,0)
00125 # ifndef MAXPATHLEN
00126 #  ifdef PATH_MAX
00127 #   define MAXPATHLEN PATH_MAX
00128 #  else
00129 #   define MAXPATHLEN 1024
00130 #  endif
00131 # endif
00132 #endif
00133 
00134 #ifndef HOST_NAME_MAX
00135 # define HOST_NAME_MAX 255
00136 #endif
00137 
00138 #include <glib.h>
00139 #if !GLIB_CHECK_VERSION(2,4,0)
00140 #   define G_MAXUINT32 ((guint32) 0xffffffff)
00141 #endif
00142 
00143 #ifndef G_MAXSIZE
00144 #   if GLIB_SIZEOF_LONG == 8
00145 #       define G_MAXSIZE ((gsize) 0xffffffffffffffff)
00146 #   else
00147 #       define G_MAXSIZE ((gsize) 0xffffffff)
00148 #   endif
00149 #endif
00150 
00151 #ifndef G_MAXSSIZE
00152 #   if GLIB_SIZEOF_LONG == 8
00153 #       define G_MAXSSIZE ((gssize) 0x7fffffffffffffff)
00154 #   else
00155 #       define G_MAXSSIZE ((gssize) 0x7fffffff)
00156 #   endif
00157 #endif
00158 
00159 #if GLIB_CHECK_VERSION(2,6,0)
00160 #   include <glib/gstdio.h>
00161 #endif
00162 
00163 #if !GLIB_CHECK_VERSION(2,6,0)
00164 #   define g_freopen freopen
00165 #   define g_fopen fopen
00166 #   define g_rmdir rmdir
00167 #   define g_remove remove
00168 #   define g_unlink unlink
00169 #   define g_lstat lstat
00170 #   define g_stat stat
00171 #   define g_mkdir mkdir
00172 #   define g_rename rename
00173 #   define g_open open
00174 #endif
00175 
00176 #if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32
00177 #   define g_access access
00178 #endif
00179 
00180 #if !GLIB_CHECK_VERSION(2,10,0)
00181 #   define g_slice_new(type) g_new(type, 1)
00182 #   define g_slice_new0(type) g_new0(type, 1)
00183 #   define g_slice_free(type, mem) g_free(mem)
00184 #endif
00185 
00186 #ifdef _WIN32
00187 #include "win32dep.h"
00188 #endif
00189 
00190 /* ugly ugly ugly */
00191 /* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT
00192  * are only defined in Glib >= 2.4 */
00193 #ifndef G_GINT64_MODIFIER
00194 #   if GLIB_SIZEOF_LONG == 8
00195 #       define G_GINT64_MODIFIER "l"
00196 #   else
00197 #       define G_GINT64_MODIFIER "ll"
00198 #   endif
00199 #endif
00200 
00201 #ifndef G_GSIZE_MODIFIER
00202 #   if GLIB_SIZEOF_LONG == 8
00203 #       define G_GSIZE_MODIFIER "l"
00204 #   else
00205 #       define G_GSIZE_MODIFIER ""
00206 #   endif
00207 #endif
00208 
00209 #ifndef G_GSIZE_FORMAT
00210 #   if GLIB_SIZEOF_LONG == 8
00211 #       define G_GSIZE_FORMAT "lu"
00212 #   else
00213 #       define G_GSIZE_FORMAT "u"
00214 #   endif
00215 #endif
00216 
00217 #ifndef G_GSSIZE_FORMAT
00218 #   if GLIB_SIZEOF_LONG == 8
00219 #       define G_GSSIZE_FORMAT "li"
00220 #   else
00221 #       define G_GSSIZE_FORMAT "i"
00222 #   endif
00223 #endif
00224 
00225 #ifndef G_GNUC_NULL_TERMINATED
00226 #   if     __GNUC__ >= 4
00227 #       define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
00228 #   else
00229 #       define G_GNUC_NULL_TERMINATED
00230 #   endif
00231 #endif
00232 
00233 #ifdef HAVE_CONFIG_H
00234 #if SIZEOF_TIME_T == 4
00235 #   define PURPLE_TIME_T_MODIFIER "lu"
00236 #elif SIZEOF_TIME_T == 8
00237 #   define PURPLE_TIME_T_MODIFIER "zu"
00238 #else
00239 #error Unknown size of time_t
00240 #endif
00241 #endif
00242 
00243 #include <glib-object.h>
00244 
00245 #ifndef G_DEFINE_TYPE
00246 #define G_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) \
00247 \
00248 static void     type_name##_init              (TypeName        *self); \
00249 static void     type_name##_class_init        (TypeName##Class *klass); \
00250 static gpointer type_name##_parent_class = NULL; \
00251 static void     type_name##_class_intern_init (gpointer klass) \
00252 { \
00253   type_name##_parent_class = g_type_class_peek_parent (klass); \
00254   type_name##_class_init ((TypeName##Class*) klass); \
00255 } \
00256 \
00257 GType \
00258 type_name##_get_type (void) \
00259 { \
00260   static GType g_define_type_id = 0; \
00261   if (G_UNLIKELY (g_define_type_id == 0)) \
00262     { \
00263       g_define_type_id = \
00264         g_type_register_static_simple (TYPE_PARENT, \
00265                                        g_intern_static_string (#TypeName), \
00266                                        sizeof (TypeName##Class), \
00267                                        (GClassInitFunc)type_name##_class_intern_init, \
00268                                        sizeof (TypeName), \
00269                                        (GInstanceInitFunc)type_name##_init, \
00270                                        (GTypeFlags) 0); \
00271     }                   \
00272   return g_define_type_id;      \
00273 } /* closes type_name##_get_type() */
00274 
00275 #endif
00276 
00277 /* Safer ways to work with static buffers. When using non-static
00278  * buffers, either use g_strdup_* functions (preferred) or use
00279  * g_strlcpy/g_strlcpy directly. */
00280 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest))
00281 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest))
00282 
00283 #define PURPLE_WEBSITE "http://pidgin.im/"
00284 #define PURPLE_DEVEL_WEBSITE "http://developer.pidgin.im/"
00285 
00286 
00287 /* INTERNAL FUNCTIONS */
00288 
00289 #include "account.h"
00290 #include "connection.h"
00291 
00292 /* This is for the accounts code to notify the buddy icon code that
00293  * it's done loading.  We may want to replace this with a signal. */
00294 void
00295 _purple_buddy_icons_account_loaded_cb(void);
00296 
00297 /* This is for the buddy list to notify the buddy icon code that
00298  * it's done loading.  We may want to replace this with a signal. */
00299 void
00300 _purple_buddy_icons_blist_loaded_cb(void);
00301 
00302 /* This is for the purple_core_migrate() code to tell the buddy
00303  * icon subsystem about the old icons directory so it can
00304  * migrate any icons in use. */
00305 void
00306 _purple_buddy_icon_set_old_icons_dir(const char *dirname);
00307 
00325 void _purple_connection_new(PurpleAccount *account, gboolean regist,
00326                             const char *password);
00339 void _purple_connection_new_unregister(PurpleAccount *account, const char *password,
00340                                        PurpleAccountUnregistrationCb cb, void *user_data);
00350 void _purple_connection_destroy(PurpleConnection *gc);
00351 
00352 #endif /* _PURPLE_INTERNAL_H_ */
Generated on Mon Jul 9 15:54:44 2012 for pidgin by  doxygen 1.6.3