Make libgloox to work correctly with gcc2.

This commit is contained in:
Barrett17 2015-06-25 11:26:48 +00:00
parent 2c2b808875
commit 23285141b3
7 changed files with 186 additions and 4 deletions

View File

@ -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__

View File

@ -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 <arpa/nameser.h> header file. */
#define HAVE_ARPA_NAMESER_H 1
/* Define to 1 if you have the <dlfcn.h> 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 <errno.h> 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 <inttypes.h> 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 <memory.h> 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 <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> 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

View File

@ -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 */

View File

@ -25,6 +25,10 @@
#include <cctype>
#include <algorithm>
#if defined(__HAIKU__) && __GNUC__ < 4
#include <ctype.h>
#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 )

View File

@ -45,7 +45,7 @@
# include <windns.h>
#endif
#ifdef __HAIKU__
#if defined(__HAIKU__)
#include <string.h>
#endif

View File

@ -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<const char*, std::string>( "s5b", XMLNS_BYTESTREAMS ) );
if( streamTypes & FTTypeIBB )
sm.insert( std::make_pair<const char*, std::string>( "ibb", XMLNS_IBB ) );
if( streamTypes & FTTypeOOB )
sm.insert( std::make_pair<const char*, std::string>( "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() );

View File

@ -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<char>( value % base + '0' ) );
output.insert((0, 1, static_cast<char>( value % base + '0' ) );
value /= base;
}
return sign + output;
}
#endif
/**
* Converts an int to its string representation.