From 23285141b3c28c9d0a040092f2fa89ec943a8e45 Mon Sep 17 00:00:00 2001 From: Barrett17 Date: Thu, 25 Jun 2015 11:26:48 +0000 Subject: [PATCH] Make libgloox to work correctly with gcc2. --- libs/libgloox/config.h | 4 +- libs/libgloox/config.h.unix.gcc2 | 130 ++++++++++++++++++ .../{config.h.unix => config.h.unix.gcc4} | 2 +- libs/libgloox/connectionbosh.cpp | 8 ++ libs/libgloox/dns.cpp | 2 +- libs/libgloox/siprofileft.cpp | 10 ++ libs/libgloox/util.h | 34 ++++- 7 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 libs/libgloox/config.h.unix.gcc2 rename libs/libgloox/{config.h.unix => config.h.unix.gcc4} (99%) diff --git a/libs/libgloox/config.h b/libs/libgloox/config.h index 20046e8..0935771 100644 --- a/libs/libgloox/config.h +++ b/libs/libgloox/config.h @@ -20,8 +20,10 @@ # include "../config.h.win" #elif defined( __SYMBIAN32__ ) # include "../config.h.symbian" +#elif defined(__HAIKU__) && __GNUC__ < 4 +# include "config.h.unix.gcc2" // run ./configure to create config.h.unix #else -# include "config.h.unix" // run ./configure to create config.h.unix +# include "config.h.unix.gcc4" #endif #endif // CONFIG_H__ diff --git a/libs/libgloox/config.h.unix.gcc2 b/libs/libgloox/config.h.unix.gcc2 new file mode 100644 index 0000000..096171e --- /dev/null +++ b/libs/libgloox/config.h.unix.gcc2 @@ -0,0 +1,130 @@ +/* config.h.unix. Generated from config.h.unix.in by configure. */ +/* config.h.unix.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_NAMESER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dn_skipname' function. */ +/* #undef HAVE_DN_SKIPNAME */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if GCC atomic builtins are available */ +/* #undef HAVE_GCC_ATOMIC_BUILTINS */ + +/* Define to 1 if you have the `getaddrinfo' function. */ +/* #undef HAVE_GETADDRINFO */ + +/* Define to 1 if you want TLS support (GnuTLS). Undefine HAVE_OPENSSL. */ +/* #undef HAVE_GNUTLS */ + +/* Define to 1 if you have GnuTLS 2.12.0 or above. */ +/* #undef HAVE_GNUTLS_SESSION_CHANNEL_BINDING */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `bind' library (-lbind). */ +/* #undef HAVE_LIBBIND */ + +/* Define to 1 if you want IDN support. */ +/* #undef HAVE_LIBIDN */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#define HAVE_LIBSOCKET 1 + +/* enable mdns support */ +/* #undef HAVE_MDNS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you want TLS support (OpenSSL). Undefine HAVE_GNUTLS. */ +#define HAVE_OPENSSL 1 + +/* Define if you have POSIX threads libraries and header files. */ +#define HAVE_PTHREAD 1 + +/* Define to 1 if you have the `res_query' function. */ +/* #undef HAVE_RES_QUERY */ + +/* Define to 1 if you have the `res_querydomain' function. */ +/* #undef HAVE_RES_QUERYDOMAIN */ + +/* Define to 1 if you have the `setsockopt' function. */ +/* #undef HAVE_SETSOCKOPT */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you want Stream Compression support. */ +#define HAVE_ZLIB 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "gloox" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "js@camaya.net" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "gloox" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "gloox 1.0.13" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "gloox" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.0.13" + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef PTHREAD_CREATE_JOINABLE */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +//#define VERSION "1.0.13" + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif diff --git a/libs/libgloox/config.h.unix b/libs/libgloox/config.h.unix.gcc4 similarity index 99% rename from libs/libgloox/config.h.unix rename to libs/libgloox/config.h.unix.gcc4 index 4464741..7eabb4c 100644 --- a/libs/libgloox/config.h.unix +++ b/libs/libgloox/config.h.unix.gcc4 @@ -118,7 +118,7 @@ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "1.0.13" +//#define VERSION "1.0.13" /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ diff --git a/libs/libgloox/connectionbosh.cpp b/libs/libgloox/connectionbosh.cpp index 58b9961..5f7b76f 100644 --- a/libs/libgloox/connectionbosh.cpp +++ b/libs/libgloox/connectionbosh.cpp @@ -25,6 +25,10 @@ #include #include +#if defined(__HAIKU__) && __GNUC__ < 4 +#include +#endif + namespace gloox { @@ -305,7 +309,11 @@ namespace gloox bool ci_equal( char ch1, char ch2 ) { + #if defined(__HAIKU__) && __GNUC__ < 4 + return toupper( (unsigned char)ch1 ) == toupper( (unsigned char)ch2 ); + #else return std::toupper( (unsigned char)ch1 ) == std::toupper( (unsigned char)ch2 ); + #endif } std::string::size_type ci_find( const std::string& str1, const std::string& str2 ) diff --git a/libs/libgloox/dns.cpp b/libs/libgloox/dns.cpp index 5831f4a..9cfc55d 100644 --- a/libs/libgloox/dns.cpp +++ b/libs/libgloox/dns.cpp @@ -45,7 +45,7 @@ # include #endif -#ifdef __HAIKU__ +#if defined(__HAIKU__) #include #endif diff --git a/libs/libgloox/siprofileft.cpp b/libs/libgloox/siprofileft.cpp index 765cb41..b372567 100644 --- a/libs/libgloox/siprofileft.cpp +++ b/libs/libgloox/siprofileft.cpp @@ -83,12 +83,22 @@ namespace gloox DataForm df( TypeForm ); DataFormField* dff = df.addField( DataFormField::TypeListSingle, "stream-method" ); StringMultiMap sm; + + #if defined(__HAIKU__) && __GNUC__ < 4 + if( streamTypes & FTTypeS5B ) + sm.insert( std::make_pair( "s5b", XMLNS_BYTESTREAMS ) ); + if( streamTypes & FTTypeIBB ) + sm.insert( std::make_pair( "ibb", XMLNS_IBB ) ); + if( streamTypes & FTTypeOOB ) + sm.insert( std::make_pair( "oob", XMLNS_IQ_OOB ) ); + #else if( streamTypes & FTTypeS5B ) sm.insert( std::make_pair( "s5b", XMLNS_BYTESTREAMS ) ); if( streamTypes & FTTypeIBB ) sm.insert( std::make_pair( "ibb", XMLNS_IBB ) ); if( streamTypes & FTTypeOOB ) sm.insert( std::make_pair( "oob", XMLNS_IQ_OOB ) ); + #endif dff->setOptions( sm ); feature->addChild( df.tag() ); diff --git a/libs/libgloox/util.h b/libs/libgloox/util.h index d6dae97..8bebc99 100644 --- a/libs/libgloox/util.h +++ b/libs/libgloox/util.h @@ -247,6 +247,36 @@ namespace gloox * @param base The integer's base. * @return The long int's string represenation. */ + + // NOTE this is the 1.0 version of the function downgraded. + // TODO investigate on how to make the new one working. + #if defined(__HAIKU__) && __GNUC__ < 4 + static inline const std::string long2string( long int value, const int base = 10 ) + { + int add = 0; + if( base < 2 || base > 16 || value == 0 ) + return "0"; + else if( value < 0 ) + { + ++add; + value = -value; + } + int len = (int)( log( (double)( value ? value : 1 ) ) / log( (double)base ) ) + 1; + const char digits[] = "0123456789ABCDEF"; + char* num = (char*)calloc( len + 1 + add, sizeof( char ) ); + num[len--] = '\0'; + if( add ) + num[0] = '-'; + while( value && len > -1 ) + { + num[len-- + add] = digits[(int)( value % base )]; + value /= base; + } + const std::string result( num ); + free( num ); + return result; + } + #else static inline const std::string long2string( long int value, const int base = 10 ) { if( base < 2 || base > 16 || value == 0 ) @@ -263,12 +293,14 @@ namespace gloox while( output.empty() || value > 0 ) { - output.insert( 0, 1, static_cast( value % base + '0' ) ); + + output.insert((0, 1, static_cast( value % base + '0' ) ); value /= base; } return sign + output; } + #endif /** * Converts an int to its string representation.