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 #  ifndef __APPLE_CC__
00051 #    define __APPLE_CC__ 0
00052 #  endif
00053 #  include <libintl.h>
00054 #  define _(String) ((const char *)dgettext(PACKAGE, String))
00055 #  ifdef gettext_noop
00056 #    define N_(String) gettext_noop (String)
00057 #  else
00058 #    define N_(String) (String)
00059 #  endif
00060 #else
00061 #  include <locale.h>
00062 #  define N_(String) (String)
00063 #  ifndef _
00064 #    define _(String) ((const char *)String)
00065 #  endif
00066 #  define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
00067 #  define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
00068 #endif
00069 
00070 #ifdef HAVE_ENDIAN_H
00071 # include <endian.h>
00072 #endif
00073 
00074 #define MSG_LEN 2048
00075 /* The above should normally be the same as BUF_LEN,
00076  * but just so we're explicitly asking for the max message
00077  * length. */
00078 #define BUF_LEN MSG_LEN
00079 #define BUF_LONG BUF_LEN * 2
00080 
00081 #include <sys/stat.h>
00082 #include <sys/types.h>
00083 #ifndef _WIN32
00084 #include <sys/time.h>
00085 #include <sys/wait.h>
00086 #include <sys/time.h>
00087 #endif
00088 #include <ctype.h>
00089 #include <errno.h>
00090 #include <fcntl.h>
00091 #include <math.h>
00092 #include <stdio.h>
00093 #include <stdlib.h>
00094 #include <string.h>
00095 #include <time.h>
00096 
00097 #ifdef HAVE_ICONV
00098 #include <iconv.h>
00099 #endif
00100 
00101 #ifdef HAVE_LANGINFO_CODESET
00102 #include <langinfo.h>
00103 #endif
00104 
00105 #include <gmodule.h>
00106 
00107 #ifdef PURPLE_PLUGINS
00108 # ifdef HAVE_DLFCN_H
00109 #  include <dlfcn.h>
00110 # endif
00111 #endif
00112 
00113 #ifndef _WIN32
00114 # include <netinet/in.h>
00115 # include <sys/socket.h>
00116 # include <arpa/inet.h>
00117 # include <sys/un.h>
00118 # include <sys/utsname.h>
00119 # include <netdb.h>
00120 # include <signal.h>
00121 # include <unistd.h>
00122 #endif
00123 
00124 #ifndef HOST_NAME_MAX
00125 # define HOST_NAME_MAX 255
00126 #endif
00127 
00128 #include <glib.h>
00129 
00130 /* This wasn't introduced until Glib 2.14 :( */
00131 #ifndef G_MAXSSIZE
00132 #   if GLIB_SIZEOF_LONG == 8
00133 #       define G_MAXSSIZE ((gssize) 0x7fffffffffffffff)
00134 #   else
00135 #       define G_MAXSSIZE ((gssize) 0x7fffffff)
00136 #   endif
00137 #endif
00138 
00139 #include <glib/gstdio.h>
00140 
00141 #ifdef _WIN32
00142 #include "win32dep.h"
00143 #endif
00144 
00145 #ifdef HAVE_CONFIG_H
00146 #if SIZEOF_TIME_T == 4
00147 #   define PURPLE_TIME_T_MODIFIER "lu"
00148 #elif SIZEOF_TIME_T == 8
00149 #   define PURPLE_TIME_T_MODIFIER "zu"
00150 #else
00151 #error Unknown size of time_t
00152 #endif
00153 #endif
00154 
00155 #include <glib-object.h>
00156 
00157 #if !GLIB_CHECK_VERSION(2, 32, 0)
00158 
00159 #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
00160 #define G_GNUC_END_IGNORE_DEPRECATIONS
00161 
00162 #endif /* 2.32.0 */
00163 
00164 #ifdef __clang__
00165 
00166 #undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS
00167 #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
00168     _Pragma ("clang diagnostic push") \
00169     _Pragma ("clang diagnostic ignored \"-Wdeprecated-declarations\"")
00170 
00171 #undef G_GNUC_END_IGNORE_DEPRECATIONS
00172 #define G_GNUC_END_IGNORE_DEPRECATIONS \
00173     _Pragma ("clang diagnostic pop")
00174 
00175 #endif /* __clang__ */
00176 
00177 #ifdef __COVERITY__
00178 
00179 /* avoid TAINTED_SCALAR warning */
00180 #undef g_utf8_next_char
00181 #define g_utf8_next_char(p) (char *)((p) + 1)
00182 
00183 #endif
00184 
00185 /* Safer ways to work with static buffers. When using non-static
00186  * buffers, either use g_strdup_* functions (preferred) or use
00187  * g_strlcpy/g_strlcpy directly. */
00188 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest))
00189 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest))
00190 
00191 typedef union
00192 {
00193     struct sockaddr sa;
00194     struct sockaddr_in in;
00195     struct sockaddr_in6 in6;
00196     struct sockaddr_storage storage;
00197 } common_sockaddr_t;
00198 
00199 #define PURPLE_WEBSITE "http://pidgin.im/"
00200 #define PURPLE_DEVEL_WEBSITE "http://developer.pidgin.im/"
00201 
00202 
00203 /* INTERNAL FUNCTIONS */
00204 
00205 #include "account.h"
00206 #include "connection.h"
00207 
00208 /* This is for the accounts code to notify the buddy icon code that
00209  * it's done loading.  We may want to replace this with a signal. */
00210 void
00211 _purple_buddy_icons_account_loaded_cb(void);
00212 
00213 /* This is for the buddy list to notify the buddy icon code that
00214  * it's done loading.  We may want to replace this with a signal. */
00215 void
00216 _purple_buddy_icons_blist_loaded_cb(void);
00217 
00218 /* This is for the purple_core_migrate() code to tell the buddy
00219  * icon subsystem about the old icons directory so it can
00220  * migrate any icons in use. */
00221 void
00222 _purple_buddy_icon_set_old_icons_dir(const char *dirname);
00223 
00241 void _purple_connection_new(PurpleAccount *account, gboolean regist,
00242                             const char *password);
00255 void _purple_connection_new_unregister(PurpleAccount *account, const char *password,
00256                                        PurpleAccountUnregistrationCb cb, void *user_data);
00266 void _purple_connection_destroy(PurpleConnection *gc);
00267 
00275 gboolean
00276 _purple_network_set_common_socket_flags(int fd);
00277 
00278 #endif /* _PURPLE_INTERNAL_H_ */