Compare commits
14 Commits
wip-fbsd-p
...
0.8.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2093aac817 | ||
|
|
29fa1bf27e | ||
|
|
f364ed184b | ||
|
|
40c9fe22b3 | ||
|
|
c33c0a6998 | ||
|
|
92e674e412 | ||
|
|
9f82aac8ce | ||
|
|
a3f1b83f3a | ||
|
|
b23104f920 | ||
|
|
057f9068c6 | ||
|
|
3231214344 | ||
|
|
55efc601cb | ||
|
|
dcbf3fb4d5 | ||
|
|
e2acd98612 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -22,9 +22,8 @@ autom4te.cache
|
||||
.sconsign*
|
||||
src/*.o
|
||||
examples/*.o
|
||||
tests/*.o
|
||||
tests/check_parser
|
||||
*.a
|
||||
*.pc
|
||||
*.tar.gz
|
||||
*.zip
|
||||
docs/html
|
||||
@@ -35,10 +34,15 @@ examples/active
|
||||
examples/roster
|
||||
examples/bot
|
||||
test_stamp
|
||||
test-suite.log
|
||||
tests/*.o
|
||||
tests/*.log
|
||||
tests/*.trs
|
||||
tests/check_parser
|
||||
tests/test_base64
|
||||
tests/test_ctx
|
||||
tests/test_hash
|
||||
tests/test_jid
|
||||
tests/test_sasl
|
||||
tests/test_sock
|
||||
m4/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
TBA
|
||||
0.8.7
|
||||
- SCRAM-SHA-1 authentication mechanism
|
||||
- pkg-config support
|
||||
|
||||
0.8.5
|
||||
- libtoolize to generate .so
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
AM_CFLAGS = -g -Wall
|
||||
|
||||
PARSER_CFLAGS=@PARSER_CFLAGS@
|
||||
@@ -35,6 +36,8 @@ endif
|
||||
include_HEADERS = strophe.h
|
||||
noinst_HEADERS = strophepp.h
|
||||
|
||||
pkgconfig_DATA = libstrophe.pc
|
||||
|
||||
EXTRA_DIST = docs
|
||||
|
||||
## Examples
|
||||
@@ -60,3 +63,4 @@ tests_check_parser_SOURCES = tests/check_parser.c tests/test.h
|
||||
tests_check_parser_CFLAGS = @check_CFLAGS@ $(PARSER_CFLAGS) $(STROPHE_FLAGS) \
|
||||
-I$(top_srcdir)/src
|
||||
tests_check_parser_LDADD = @check_LIBS@ $(STROPHE_LIBS)
|
||||
tests_check_parser_LDFLAGS = -static
|
||||
|
||||
68
configure.ac
68
configure.ac
@@ -1,4 +1,5 @@
|
||||
AC_INIT([libstrophe], [0.8.7], [jack@metajack.im])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AM_INIT_AUTOMAKE([foreign])
|
||||
LT_INIT([dlopen])
|
||||
|
||||
@@ -11,7 +12,15 @@ AS_CASE([$host_os],
|
||||
[freebsd*], [PLATFORM="freebsd"],
|
||||
[PLATFORM="nix"])
|
||||
|
||||
PKG_CHECK_MODULES([openssl], [openssl], [], [AC_MSG_ERROR([openssl not found; openssl required])])
|
||||
PKG_CHECK_MODULES([openssl], [openssl], [PC_REQUIRES+=(openssl)],
|
||||
[AC_CHECK_HEADER([openssl/ssl.h],
|
||||
[
|
||||
openssl_LIBS="-lssl -lcrypto"
|
||||
PC_LIBS+=($openssl_LIBS)
|
||||
],
|
||||
[AC_MSG_ERROR([openssl not found; openssl required])]
|
||||
)])
|
||||
|
||||
PKG_CHECK_MODULES([check], [check >= 0.9.4], [], [AC_MSG_WARN([libcheck not found; unit tests will not be compilable])])
|
||||
|
||||
AC_ARG_WITH([libxml2],
|
||||
@@ -21,18 +30,35 @@ AC_ARG_WITH([libxml2],
|
||||
|
||||
if test "x$with_libxml2" != xno; then
|
||||
PKG_CHECK_MODULES([libxml2], [libxml-2.0 >= 2.7],
|
||||
[with_libxml2=yes], [dummy=1])
|
||||
if test "x$with_libxml2" != xyes; then
|
||||
old_CFLAGS=$CFLAGS
|
||||
CFLAGS="-I${includedir}/libxml2"
|
||||
AC_CHECK_HEADER([libxml/parser.h],
|
||||
[with_libxml2=yes; libxml2_CFLAGS="-I${includedir}/libxml2"; libxml2_LIBS="-lxml2"],
|
||||
[AC_MSG_ERROR([libxml2 not found.])])
|
||||
CFLAGS=$old_CFLAGS
|
||||
fi
|
||||
[
|
||||
with_libxml2=yes
|
||||
PC_REQUIRES+=(libxml-2.0)
|
||||
],
|
||||
[
|
||||
old_CFLAGS=$CFLAGS
|
||||
CFLAGS="-I${includedir}/libxml2"
|
||||
AC_CHECK_HEADER([libxml/parser.h],
|
||||
[
|
||||
with_libxml2=yes
|
||||
libxml2_CFLAGS="-I${includedir}/libxml2"
|
||||
libxml2_LIBS="-lxml2"
|
||||
PC_LIBS+=($libxml2_LIBS)
|
||||
PC_CFLAGS+=($libxml2_CFLAGS)
|
||||
],
|
||||
[AC_MSG_ERROR([libxml2 not found.])])
|
||||
CFLAGS=$old_CFLAGS
|
||||
])
|
||||
else
|
||||
PKG_CHECK_MODULES([expat], [expat >= 2.0.0], [],
|
||||
[AC_CHECK_HEADER(expat.h, [expat_LIBS="-lexpat"], [AC_MSG_ERROR([expat not found; expat required.])])])
|
||||
PKG_CHECK_MODULES([expat], [expat >= 2.0.0],
|
||||
[PC_REQUIRES+=(expat)],
|
||||
[AC_CHECK_HEADER([expat.h],
|
||||
[
|
||||
expat_LIBS="-lexpat"
|
||||
PC_LIBS+=($expat_LIBS)
|
||||
],
|
||||
[AC_MSG_ERROR([expat not found; expat required.])]
|
||||
)
|
||||
])
|
||||
fi
|
||||
|
||||
if test "x$with_libxml2" = xyes; then
|
||||
@@ -53,16 +79,30 @@ AC_SEARCH_LIBS([socket], [socket])
|
||||
if test "x$PLATFORM" != xfreebsd; then
|
||||
AC_CHECK_LIB([resolv], [res_query], [],
|
||||
[AC_CHECK_LIB([resolv], [__res_query], [],
|
||||
[AC_MSG_ERROR([libresolv not found; libresolv required. ])])])
|
||||
[AC_MSG_ERROR([libresolv not found; libresolv required.])])])
|
||||
PC_LIBS+=(-lresolv)
|
||||
else
|
||||
AC_MSG_NOTICE([skipping libresolv checks for freebsd])
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADERS([arpa/nameser_compat.h])
|
||||
|
||||
|
||||
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
|
||||
[AC_ARG_WITH([pkgconfigdir],
|
||||
[AS_HELP_STRING([--with-pkgconfigdir],
|
||||
[install directory for libstrophe.pc pkg-config file])],
|
||||
[],[with_pkgconfigdir='$(libdir)/pkgconfig'])
|
||||
AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
|
||||
|
||||
AM_CONDITIONAL([PARSER_EXPAT], [test x$with_parser != xlibxml2])
|
||||
|
||||
AC_SUBST([PC_REQUIRES], [${PC_REQUIRES[[@]]}])
|
||||
AC_SUBST([PC_CFLAGS], [${PC_CFLAGS[[@]]}])
|
||||
AC_SUBST([PC_LIBS], [${PC_LIBS[[@]]}])
|
||||
|
||||
AC_SUBST(PARSER_NAME)
|
||||
AC_SUBST(PARSER_CFLAGS)
|
||||
AC_SUBST(PARSER_LIBS)
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_FILES([Makefile libstrophe.pc])
|
||||
AC_OUTPUT
|
||||
|
||||
14
libstrophe.pc.in
Normal file
14
libstrophe.pc.in
Normal file
@@ -0,0 +1,14 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: libstrophe
|
||||
Description: A simple, lightweight C library for writing XMPP clients
|
||||
URL: http://strophe.im/libstrophe/
|
||||
Version: @VERSION@
|
||||
Requires:
|
||||
Requires.private: @PC_REQUIRES@
|
||||
Libs: -L${libdir} -lstrophe
|
||||
Libs.private: @PC_LIBS@
|
||||
Cflags: -I${includedir} @PC_CFLAGS@
|
||||
@@ -8,12 +8,24 @@ License: MIT/GPLv3
|
||||
URL: http://strophe.im/libstrophe/
|
||||
Source0: libstrophe_git.tar.gz
|
||||
|
||||
BuildRequires: automake
|
||||
BuildRequires: libtool
|
||||
BuildRequires: openssl-devel
|
||||
BuildRequires: expat-devel
|
||||
Requires: expat
|
||||
Requires: expat
|
||||
|
||||
%description
|
||||
XMPP library in C
|
||||
|
||||
%package devel
|
||||
Summary: Headers and libraries for building apps that use libstrophe
|
||||
Group: Development/Libraries
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
This package contains headers and libraries required to build applications that
|
||||
use the strophe XMPP library.
|
||||
|
||||
%prep
|
||||
%setup -n libstrophe
|
||||
./bootstrap.sh
|
||||
@@ -25,8 +37,21 @@ make %{?_smp_mflags}
|
||||
%install
|
||||
make install DESTDIR=%{buildroot}
|
||||
|
||||
%post -p /sbin/ldconfig
|
||||
|
||||
%postun -p /sbin/ldconfig
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%{_libdir}/libstrophe.so*
|
||||
%doc
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root,-)
|
||||
%{_libdir}/libstrophe.a
|
||||
%{_libdir}/libstrophe.la
|
||||
%{_libdir}/pkgconfig/libstrophe.pc
|
||||
%{_includedir}/strophe.h
|
||||
%doc
|
||||
|
||||
%changelog
|
||||
|
||||
@@ -250,12 +250,13 @@ const char * hash_iter_next(hash_iterator_t *iter)
|
||||
{
|
||||
hash_t *table = iter->table;
|
||||
hashentry_t *entry = iter->entry;
|
||||
int i = iter->index + 1;
|
||||
int i;
|
||||
|
||||
/* advance until we find the next entry */
|
||||
if (entry != NULL) entry = entry->next;
|
||||
if (entry == NULL) {
|
||||
/* we're off the end of list, search for a new entry */
|
||||
i = iter->index + 1;
|
||||
while (i < iter->table->length) {
|
||||
entry = table->entries[i];
|
||||
if (entry != NULL) {
|
||||
@@ -266,7 +267,7 @@ const char * hash_iter_next(hash_iterator_t *iter)
|
||||
}
|
||||
}
|
||||
|
||||
if ((entry == NULL) || (i >= table->length)) {
|
||||
if (entry == NULL) {
|
||||
/* no more keys! */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
29
src/sha1.c
29
src/sha1.c
@@ -90,19 +90,14 @@ A million repetitions of "a"
|
||||
|
||||
#include "sha1.h"
|
||||
|
||||
static uint32_t host_to_be(uint32_t i);
|
||||
static void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]);
|
||||
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
/* blk0() and blk() perform the initial expand. */
|
||||
/* I got the idea of expanding during the round function from SSLeay */
|
||||
/* FIXME: can we do this in an endian-proof way? */
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define blk0(i) block->l[i]
|
||||
#else
|
||||
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|
||||
|(rol(block->l[i],8)&0x00FF00FF))
|
||||
#endif
|
||||
#define blk0(i) (block->l[i] = host_to_be(block->l[i]))
|
||||
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
|
||||
^block->l[(i+2)&15]^block->l[i&15],1))
|
||||
|
||||
@@ -127,6 +122,26 @@ void SHAPrintContext(SHA1_CTX *context, char *msg){
|
||||
}
|
||||
#endif /* VERBOSE */
|
||||
|
||||
static uint32_t host_to_be(uint32_t i)
|
||||
{
|
||||
#define le_to_be(i) ((rol((i),24) & 0xFF00FF00) | (rol((i),8) & 0x00FF00FF))
|
||||
#if defined(__BIG_ENDIAN__) || \
|
||||
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
|
||||
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
return i;
|
||||
#elif defined(__LITTLE_ENDIAN__) || \
|
||||
(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
|
||||
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||
return le_to_be(i);
|
||||
#else /* fallback to run-time check */
|
||||
static const union {
|
||||
uint32_t u;
|
||||
unsigned char c;
|
||||
} check = {1};
|
||||
return check.c ? le_to_be(i) : i;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
||||
static void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user