Permalink
Browse files

Replace the full ejabberd_zlib into a simple exmpp_compress interface…

… (EJAB-991)
  • Loading branch information...
1 parent adc4a7f commit d1f1958dd42cad712debc3ad9af53c7c41add0d9 @badlop badlop committed Sep 2, 2011
View
@@ -12,8 +12,6 @@ To compile ejabberd you need:
Avoid R14A and R14B.
- exmpp 0.9.6 or higher
- OpenSSL 0.9.8 or higher, for STARTTLS, SASL and SSL encryption.
- - Zlib 1.2.3 or higher, for Stream Compression support
- (XEP-0138). Optional.
- Erlang mysql library. Optional. MySQL authentication/storage.
- Erlang pgsql library. Optional. PostgreSQL authentication/storage.
- PAM library. Optional. For Pluggable Authentication Modules (PAM).
View
@@ -318,7 +318,6 @@
Don't use R14A or R14B because \footahref{http://www.erlang.org/cgi-bin/ezmlm-cgi/4/54598}{they have a bug}.
\item exmpp 0.9.6 or higher
\item OpenSSL 0.9.8 or higher, for STARTTLS, SASL and SSL encryption.
-\item Zlib 1.2.3 or higher, for Stream Compression support (\xepref{0138}). Optional.
\item Erlang mysql library. Optional. For MySQL authentication or storage. See section \ref{compilemysql}.
\item Erlang pgsql library. Optional. For PostgreSQL authentication or storage. See section \ref{compilepgsql}.
\item PAM library. Optional. For Pluggable Authentication Modules (PAM). See section \ref{pam}.
@@ -524,7 +523,6 @@
\item \footahref{http://support.process-one.net/doc/display/EXMPP}{exmpp 0.9.5 or higher}
\item \footahref{http://www.slproweb.com/products/Win32OpenSSL.html}{Shining Light OpenSSL 0.9.8d or higher}
(to enable SSL connections)
-\item \footahref{http://www.zlib.net/}{Zlib 1.2.3 or higher}
\end{itemize}
@@ -535,8 +533,6 @@
\begin{enumerate}
\item Install Erlang emulator (for example, into \verb|C:\sdk\erl5.6.5|).
\item Install OpenSSL in \verb|C:\sdk\OpenSSL| and add \verb|C:\sdk\OpenSSL\lib\VC| to your path or copy the binaries to your system directory.
-\item Install ZLib in \verb|C:\sdk\gnuWin32|. Copy
- \verb|C:\sdk\GnuWin32\bin\zlib1.dll| to your system directory.
\item Make sure the you can access Erlang binaries from your path. For example: \verb|set PATH=%PATH%;"C:\sdk\erl5.6.5\bin"|
\item Depending on how you end up actually installing the library you might need to check and tweak the paths in the file configure.erl.
\item While in the directory \verb|ejabberd\src| run:
View
@@ -72,7 +72,7 @@ endif
prefix = @prefix@
exec_prefix = @exec_prefix@
-SUBDIRS = stun @mod_pubsub@ @mod_muc@ @mod_proxy65@ @eldap@ @pam@ @web@ @tls@ @odbc@ @ejabberd_zlib@
+SUBDIRS = stun @mod_pubsub@ @mod_muc@ @mod_proxy65@ @eldap@ @pam@ @web@ @tls@ @odbc@
ERLSHLIBS =
ERLBEHAVS = cyrsasl.erl gen_mod.erl p1_fsm.erl
SOURCES_ALL = $(wildcard *.erl)
View
@@ -69,9 +69,6 @@ release : build release_clean
mkdir $(SRC_DIR)\tls
copy tls\*.erl $(SRC_DIR)\tls
copy tls\*.c $(SRC_DIR)\tls
- mkdir $(SRC_DIR)\ejabberd_zlib
- copy ejabberd_zlib\*.erl $(SRC_DIR)\ejabberd_zlib
- copy ejabberd_zlib\*.c $(SRC_DIR)\ejabberd_zlib
mkdir $(SRC_DIR)\web
copy web\*.erl $(SRC_DIR)\web
mkdir $(SRC_DIR)\odbc
@@ -103,8 +100,6 @@ all-recursive :
nmake -nologo -f Makefile.win32
cd ..\tls
nmake -nologo -f Makefile.win32
- cd ..\ejabberd_zlib
- nmake -nologo -f Makefile.win32
cd ..\web
nmake -nologo -f Makefile.win32
cd ..\odbc
@@ -142,8 +137,6 @@ clean-recursive :
nmake -nologo -f Makefile.win32 clean
cd ..\tls
nmake -nologo -f Makefile.win32 clean
- cd ..\ejabberd_zlib
- nmake -nologo -f Makefile.win32 clean
cd ..\web
nmake -nologo -f Makefile.win32 clean
cd ..\odbc
View
@@ -1,39 +1,3 @@
-AC_DEFUN([AM_WITH_ZLIB],
-[ AC_ARG_WITH(zlib,
- [AC_HELP_STRING([--with-zlib=PREFIX], [prefix where zlib is installed])])
-
-if test x"$ejabberd_zlib" != x; then
- ZLIB_CFLAGS=
- ZLIB_LIBS=
- if test x"$with_zlib" != x; then
- ZLIB_CFLAGS="-I$with_zlib/include"
- ZLIB_LIBS="-L$with_zlib/lib"
- fi
-
- AC_CHECK_LIB(z, gzgets,
- [ ZLIB_LIBS="$ZLIB_LIBS -lz"
- zlib_found=yes ],
- [ zlib_found=no ],
- "$ZLIB_LIBS")
- if test $zlib_found = no; then
- AC_MSG_ERROR([Could not find development files of zlib library. Install them or disable `ejabberd_zlib' with: --disable-ejabberd_zlib])
- fi
- zlib_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ZLIB_CFLAGS"
- zlib_save_CPPFLAGS="$CFLAGS"
- CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS"
- AC_CHECK_HEADERS(zlib.h, , zlib_found=no)
- if test $zlib_found = no; then
- AC_MSG_ERROR([Could not find zlib.h. Install it or disable `ejabberd_zlib' with: --disable-ejabberd_zlib])
- fi
- CFLAGS="$zlib_save_CFLAGS"
- CPPFLAGS="$zlib_save_CPPFLAGS"
-
- AC_SUBST(ZLIB_CFLAGS)
- AC_SUBST(ZLIB_LIBS)
-fi
-])
-
AC_DEFUN([AM_WITH_PAM],
[ AC_ARG_WITH(pam,
[AC_HELP_STRING([--with-pam=PREFIX], [prefix where PAM is installed])])
View
@@ -36,10 +36,6 @@ AC_MOD_ENABLE(odbc, no)
AC_MOD_ENABLE(tls, yes)
AC_MOD_ENABLE(web, yes)
-AC_MOD_ENABLE(ejabberd_zlib, yes)
-#locating zlib
-AM_WITH_ZLIB
-
AC_MOD_ENABLE(pam, no)
#locating PAM
AM_WITH_PAM
@@ -107,8 +103,7 @@ AC_CONFIG_FILES([Makefile
$make_web
stun/Makefile
$make_tls
- $make_odbc
- $make_ejabberd_zlib])
+ $make_odbc])
#openssl
AM_WITH_OPENSSL
# If ssl is kerberized it need krb5.h
View
@@ -48,7 +48,6 @@
ejabberd_update,
ejabberd_web_admin,
ejabberd_web,
- ejabberd_zlib,
ejd2odbc,
eldap,
eldap_filter,
View
@@ -0,0 +1,99 @@
+%%%----------------------------------------------------------------------
+%%% File : ejabberd_zlib.erl
+%%% Author : Alexey Shchepin <alexey@process-one.net>
+%%% Purpose : Interface to exmpp_compress
+%%% Created : 19 Jan 2006 by Alexey Shchepin <alexey@process-one.net>
+%%%
+%%%
+%%% ejabberd, Copyright (C) 2002-2011 ProcessOne
+%%%
+%%% This program is free software; you can redistribute it and/or
+%%% modify it under the terms of the GNU General Public License as
+%%% published by the Free Software Foundation; either version 2 of the
+%%% License, or (at your option) any later version.
+%%%
+%%% This program is distributed in the hope that it will be useful,
+%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%%% General Public License for more details.
+%%%
+%%% You should have received a copy of the GNU General Public License
+%%% along with this program; if not, write to the Free Software
+%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+%%% 02111-1307 USA
+%%%
+%%%----------------------------------------------------------------------
+
+-module(ejabberd_zlib).
+-author('alexey@process-one.net').
+
+-export([start/0, start_link/0,
+ enable_zlib/2, disable_zlib/1,
+ send/2,
+ recv/2, recv/3, recv_data/2,
+ setopts/2,
+ get_sockmod/1,
+ sockname/1, peername/1,
+ controlling_process/2,
+ close/1]).
+
+-define(DEFLATE, 1).
+-define(INFLATE, 2).
+
+start() ->
+ exmpp_compress:start().
+
+start_link() ->
+ exmpp_compress:start_link().
+
+
+enable_zlib(SockMod, Socket) ->
+ try
+ ZlibSock = exmpp_compress:enable_compression({SockMod, Socket},
+ [{compress_method, zlib}]),
+ {ok, ZlibSock}
+ catch
+ Exception ->
+ {error, Exception}
+ end.
+
+disable_zlib(ZlibSock) ->
+ exmpp_compress:disable_compression(ZlibSock).
+
+recv(Socket, Length) ->
+ recv(Socket, Length, infinity).
+recv(ZlibSock, _Length, Timeout) ->
+ exmpp_compress:recv(ZlibSock, Timeout).
+
+recv_data(ZlibSock, Packet) ->
+ exmpp_compress:recv_data(ZlibSock, Packet).
+
+send(ZlibSock, Packet) ->
+ exmpp_compress:send(ZlibSock, Packet).
+
+
+setopts(ZlibSock, Opts) ->
+ exmpp_compress:setopts(ZlibSock, Opts).
+
+%% Copied from exmpp/src/core/exmpp_compress.erl
+-record(compress_socket, {socket,
+ packet_mode = binary,
+ port
+ }).
+
+get_sockmod(#compress_socket{socket = {SockMod, _Port}}) ->
+ SockMod.
+
+sockname(ZlibSock) ->
+ exmpp_compress:sockname(ZlibSock).
+
+peername(ZlibSock) ->
+ exmpp_compress:peername(ZlibSock).
+
+controlling_process(ZlibSock, Pid) ->
+ exmpp_compress:controlling_process(ZlibSock, Pid).
+
+close(ZlibSock) ->
+ exmpp_compress:close(ZlibSock).
+
+
@@ -1,81 +0,0 @@
-CC = @CC@
-CFLAGS = @CFLAGS@
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-
-ZLIB_CFLAGS = @ZLIB_CFLAGS@
-ZLIB_LIBS = @ZLIB_LIBS@
-
-ERLANG_CFLAGS = @ERLANG_CFLAGS@
-ERLANG_LIBS = @ERLANG_LIBS@
-
-# Assume Linux-style dynamic library flags
-DYNAMIC_LIB_CFLAGS = -fpic -shared
-ifeq ($(shell uname),Darwin)
- DYNAMIC_LIB_CFLAGS = -fPIC -bundle -flat_namespace -undefined suppress
-endif
-ifeq ($(shell uname),SunOs)
- DYNAMIC_LIB_CFLAGS = -KPIC -G -z text
-endif
-
-EFLAGS += -I ..
-EFLAGS += -pz ..
-
-# make debug=true to compile Erlang module with debug informations.
-ifdef debug
- EFLAGS+=+debug_info +export_all
-endif
-
-ERLSHLIBS = ../ejabberd_zlib_drv.so
-OUTDIR = ..
-SOURCES = $(wildcard *.erl)
-BEAMS = $(addprefix $(OUTDIR)/,$(SOURCES:.erl=.beam))
-
-all: $(BEAMS) $(ERLSHLIBS)
-
-$(OUTDIR)/%.beam: %.erl
- @ERLC@ -W $(EFLAGS) -o $(OUTDIR) $<
-
-#all: $(ERLSHLIBS)
-# erl -s make all report "{outdir, \"..\"}" -noinput -s erlang halt
-
-$(ERLSHLIBS): ../%.so: %.c
- $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \
- $(subst ../,,$(subst .so,.c,$@)) \
- $(LIBS) \
- $(ZLIB_LIBS) \
- $(ZLIB_CFLAGS) \
- $(ERLANG_LIBS) \
- $(ERLANG_CFLAGS) \
- -o $@ \
- $(DYNAMIC_LIB_CFLAGS)
-
-clean:
- rm -f $(BEAMS) $(ERLSHLIBS)
-
-distclean: clean
- rm -f Makefile
-
-TAGS:
- etags *.erl
-
-
-DEVDOCDIR=../../doc/devdoc
-DDTDIR=..
-HTMLS = $(SOURCES:%.erl=../../doc/devdoc/%.html)
-ERLHTMLS = $(SOURCES:%.erl=../../doc/devdoc/%.erl.html)
-SVGS = $(SOURCES:%.erl=../../doc/devdoc/%.svg)
-
-devdoc: $(HTMLS) $(ERLHTMLS) $(SVGS)
-
-$(DEVDOCDIR)/%.erl.html: %.erl
- @ERL@ -noshell -pa $(DEVDOCDIR) -run escobar_run file $< $(DDTDIR) -s init stop
-
-$(DEVDOCDIR)/%.html: %.erl
- @ERL@ -noshell -run edoc_run file $< \
- '[{dir,"$(DDTDIR)"},{packages,false},{todo,true},{private,true},{def,{vsn,"$(VSN)"}},{stylesheet,"process-one.css"},{overview,"overview.edoc"}]' -s init stop
-
-$(DEVDOCDIR)/%.svg: %.erl
- @ERL@ -noshell -pa $(DEVDOCDIR) -run funrelg dir $< $(DDTDIR) -s init stop
-
@@ -1,36 +0,0 @@
-
-include ..\Makefile.inc
-
-EFLAGS = -I .. -pz ..
-
-OUTDIR = ..
-BEAMS = ..\ejabberd_zlib.beam
-
-SOURCE = ejabberd_zlib_drv.c
-OBJECT = ejabberd_zlib_drv.o
-DLL = $(OUTDIR)\ejabberd_zlib_drv.dll
-
-ALL : $(DLL) $(BEAMS)
-
-CLEAN :
- -@erase $(DLL)
- -@erase $(OUTDIR)\ejabberd_zlib_drv.exp
- -@erase $(OUTDIR)\ejabberd_zlib_drv.lib
- -@erase $(OBJECT)
- -@erase $(BEAMS)
-
-$(OUTDIR)\ejabberd_zlib.beam : ejabberd_zlib.erl
- erlc -W $(EFLAGS) -o $(OUTDIR) ejabberd_zlib.erl
-
-CC=cl.exe
-CC_FLAGS=-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -MD -Ox -I"$(ERLANG_DIR)\usr\include" -I"$(EI_DIR)\include" -I"$(ZLIB_DIR)\include"
-
-LD=link.exe
-LD_FLAGS=-release -nologo -incremental:no -dll "$(EI_DIR)\lib\ei_md.lib" "$(EI_DIR)\lib\erl_interface_md.lib" "$(ZLIB_LIB)" MSVCRT.LIB kernel32.lib advapi32.lib gdi32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib
-
-$(DLL) : $(OBJECT)
- $(LD) $(LD_FLAGS) -out:$(DLL) $(OBJECT)
-
-$(OBJECT) : $(SOURCE)
- $(CC) $(CC_FLAGS) -c -Fo$(OBJECT) $(SOURCE)
-
Oops, something went wrong.

0 comments on commit d1f1958

Please sign in to comment.