[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash Makefile.am configure.ac ChangeLog libbas...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash Makefile.am configure.ac ChangeLog libbas... |
Date: |
Fri, 28 Mar 2008 21:30:29 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 08/03/28 21:30:28
Modified files:
. : Makefile.am configure.ac ChangeLog
libbase : Makefile.am gmemory.h log.cpp memory.cpp
server : Makefile.am
server/asobj : Makefile.am xmlsocket.cpp
server/parser : Makefile.am
server/vm : Makefile.am
libnet : Makefile.am buffer.cpp buffer.h cque.cpp cque.h
cqueue.cpp cqueue.h handler.cpp handler.h
http.cpp http.h netstats.cpp netstats.h
rtmp.cpp rtmp.h statistics.cpp statistics.h
Added files:
libnet : lirc.cpp lirc.h
testsuite/libnet.all: Makefile.am test_buffer.cpp test_cque.cpp
test_crc.cpp test_handler.cpp
test_http.cpp
Removed files:
libbase : lirc.cpp network.cpp network.h
Log message:
* testsuite/Makefile.am: Add libnet.all to SUIBDIRS.
* configure.ac: Add libnet and testsuite/libnet.all.
* Makefile.am: Build libnet after libamf.
* libbase/lirc.{h,cpp}: Move to libnet.
* server/asobj/xmlsocket.cpp: Include network.h.
* libbase/Makefile.am: Add libnet to cflags and libs.
* server/Makefile.am, server/asobj/Makefile.am:
server/vm/Makefile.am: Add libnet to cflags and libs.
* utilities/Makefile.am: Add libnet to cflags and libs.
* gui/Makefile.am: Add libnet to cflags and libs.
* cygnal/Makefile.am: Move libcygnal.la files to new libnet. Use
libnet now instead of libcygnal.la.
* libnet: New directory for networking and protocols.
* libbase/network.{h,cpp}: Move to libnet.
* libbase/Makefile.am: Remove network.*.
*
cygnal/buffer.{h,cpp},cque.{h,cpp},handler.{h,cpp},http.{h,cpp},
network.{h,cpp},rtmp.{h,cpp},netstats.{h,cpp},statistics.{h,cpp},
cque.{h,cpp}: Move to libnet so they can be shared with Gnash.
*
libnet/buffer.{h,cpp},cque.{h,cpp},handler.{h,cpp},http.{h,cpp},
network.{h,cpp},rtmp.{h,cpp},netstats.{h,cpp},statistics.{h,cpp},
cque.{h,cpp}: Moved from cygnal so they can be shared.
* testsuite/libnet.all: New directory for networking and
protocol
test cases.
*
testsuite/libnet.all/{test_buffer.cpp,test_cque.cpp,test_crc.cpp,
test_handler.cpp,test_http.cpp: Moved from
cygnal/testsuite/cygnal.all.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/Makefile.am?cvsroot=gnash&r1=1.108&r2=1.109
http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&r1=1.499&r2=1.500
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6063&r2=1.6064
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Makefile.am?cvsroot=gnash&r1=1.103&r2=1.104
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/gmemory.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/log.cpp?cvsroot=gnash&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/memory.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/lirc.cpp?cvsroot=gnash&r1=1.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/network.cpp?cvsroot=gnash&r1=1.40&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/network.h?cvsroot=gnash&r1=1.26&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Makefile.am?cvsroot=gnash&r1=1.139&r2=1.140
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Makefile.am?cvsroot=gnash&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlsocket.cpp?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/Makefile.am?cvsroot=gnash&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/Makefile.am?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/Makefile.am?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/buffer.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/buffer.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/cque.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/cque.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/cqueue.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/cqueue.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/handler.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/handler.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/http.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/http.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/netstats.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/netstats.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/rtmp.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/rtmp.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/statistics.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/statistics.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/lirc.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/lirc.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libnet.all/Makefile.am?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libnet.all/test_buffer.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libnet.all/test_cque.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libnet.all/test_crc.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libnet.all/test_handler.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libnet.all/test_http.cpp?cvsroot=gnash&rev=1.1
Patches:
Index: Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/Makefile.am,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -b -r1.108 -r1.109
--- Makefile.am 11 Mar 2008 09:55:14 -0000 1.108
+++ Makefile.am 28 Mar 2008 21:30:15 -0000 1.109
@@ -45,6 +45,7 @@
libbase \
libgeometry \
libamf \
+ libnet \
libmedia \
server \
backend \
@@ -305,6 +306,9 @@
@if test -n "$(SECURITY_LIST)" ; then \
echo " Security features enables are: $(SECURITY_LIST)"; \
fi
+ @if test -n "$(STATISTICS_LIST)" ; then \
+ echo " Statistics features enables are: $(STATISTICS_LIST)"; \
+ fi
if KPARTS
@echo " KPARTS (KDE) plugin enabled"
@echo " KPARTS plugin install dir: $(KDE_PLUGINDIR)"
Index: configure.ac
===================================================================
RCS file: /sources/gnash/gnash/configure.ac,v
retrieving revision 1.499
retrieving revision 1.500
diff -u -b -r1.499 -r1.500
--- configure.ac 26 Mar 2008 16:41:37 -0000 1.499
+++ configure.ac 28 Mar 2008 21:30:16 -0000 1.500
@@ -1950,6 +1950,7 @@
server/asobj/Makefile
server/vm/Makefile
server/parser/Makefile
+libnet/Makefile
libamf/Makefile
backend/Makefile
utilities/Makefile
@@ -1970,6 +1971,7 @@
testsuite/movies.all/Makefile
testsuite/server/Makefile
testsuite/libamf.all/Makefile
+testsuite/libnet.all/Makefile
gui/Makefile
gui/Info.plist
extensions/Makefile
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6063
retrieving revision 1.6064
diff -u -b -r1.6063 -r1.6064
--- ChangeLog 28 Mar 2008 17:16:10 -0000 1.6063
+++ ChangeLog 28 Mar 2008 21:30:16 -0000 1.6064
@@ -1,3 +1,34 @@
+2008-03-27 Rob Savoye <address@hidden>
+
+ * testsuite/Makefile.am: Add libnet.all to SUIBDIRS.
+ * configure.ac: Add libnet and testsuite/libnet.all.
+ * Makefile.am: Build libnet after libamf.
+ * libbase/lirc.{h,cpp}: Move to libnet.
+ * server/asobj/xmlsocket.cpp: Include network.h.
+
+ * libbase/Makefile.am: Add libnet to cflags and libs.
+ * server/Makefile.am, server/asobj/Makefile.am:
+ server/vm/Makefile.am: Add libnet to cflags and libs.
+ * utilities/Makefile.am: Add libnet to cflags and libs.
+ * gui/Makefile.am: Add libnet to cflags and libs.
+ * cygnal/Makefile.am: Move libcygnal.la files to new libnet. Use
+ libnet now instead of libcygnal.la.
+
+ * libnet: New directory for networking and protocols.
+ * libbase/network.{h,cpp}: Move to libnet.
+ * libbase/Makefile.am: Remove network.*.
+ * cygnal/buffer.{h,cpp},cque.{h,cpp},handler.{h,cpp},http.{h,cpp},
+ network.{h,cpp},rtmp.{h,cpp},netstats.{h,cpp},statistics.{h,cpp},
+ cque.{h,cpp}: Move to libnet so they can be shared with Gnash.
+ * libnet/buffer.{h,cpp},cque.{h,cpp},handler.{h,cpp},http.{h,cpp},
+ network.{h,cpp},rtmp.{h,cpp},netstats.{h,cpp},statistics.{h,cpp},
+ cque.{h,cpp}: Moved from cygnal so they can be shared.
+ * testsuite/libnet.all: New directory for networking and protocol
+ test cases.
+ * testsuite/libnet.all/{test_buffer.cpp,test_cque.cpp,test_crc.cpp,
+ test_handler.cpp,test_http.cpp: Moved from cygnal/testsuite/cygnal.all.
+ * libamf/rtmp.{h,cpp}: Move to libnet.
+
2008-03-28 Sandro Santilli <address@hidden>
* server/swf_function.cpp (call operator): esplicit args override
@@ -133,6 +164,7 @@
* libbase/zlib_adapter.h: drop gnashconfig.h where it's not needed,
replace tu_config.h with dsodefs.h.
+>>>>>>> 1.6063
2008-03-27 Benjamin Wolsey <address@hidden>
* server/vm/ASHandlers.{cpp,h}: const correct guessEncoding,
Index: libbase/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libbase/Makefile.am,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -b -r1.103 -r1.104
--- libbase/Makefile.am 28 Mar 2008 16:23:07 -0000 1.103
+++ libbase/Makefile.am 28 Mar 2008 21:30:17 -0000 1.104
@@ -33,6 +33,7 @@
libgnashbase_la_CPPFLAGS = -DPLUGINSDIR=\"$(pluginsdir)\" \
-I.. -I$(srcdir) \
-I$(top_srcdir) \
+ -I$(top_srcdir)/libnet \
-I$(top_srcdir)/libamf \
-I$(top_srcdir)/server \
-I$(top_srcdir)/server/swf \
@@ -80,10 +81,8 @@
extension.cpp \
image.cpp \
jpeg.cpp \
- lirc.cpp \
log.cpp \
memory.cpp \
- network.cpp \
rc.cpp \
shm.cpp \
sharedlib.cpp \
@@ -116,8 +115,6 @@
image.h \
jpeg.h \
gmemory.h \
- network.h \
- lirc.h \
log.h \
ogl.h \
rc.h \
Index: libbase/gmemory.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/gmemory.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- libbase/gmemory.h 28 Mar 2008 12:22:45 -0000 1.6
+++ libbase/gmemory.h 28 Mar 2008 21:30:18 -0000 1.7
@@ -88,6 +88,7 @@
void dump(struct mallinfo *x);
void dump(struct small_mallinfo *x);
void dump();
+ void dumpCSV();
private:
bool _collecting;
// For data logging, we want to store as little as possible
Index: libbase/log.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/log.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- libbase/log.cpp 28 Mar 2008 15:22:07 -0000 1.71
+++ libbase/log.cpp 28 Mar 2008 21:30:19 -0000 1.72
@@ -28,6 +28,7 @@
#include <iomanip> // for std::setfill
#include <string>
#include <boost/format.hpp>
+#include <pthread.h>
#if defined(_WIN32) && defined(WIN32)
// Required for SYSTEMTIME definitions
@@ -101,7 +102,7 @@
strftime (buf, sizeof(buf), "%H:%M:%S", localtime (&t));
std::stringstream ss;
- ss << getpid() << "] " << buf;
+ ss << pthread_self() << "] " << buf;
return ss.str();
}
Index: libbase/memory.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/memory.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libbase/memory.cpp 23 Mar 2008 23:57:58 -0000 1.4
+++ libbase/memory.cpp 28 Mar 2008 21:30:19 -0000 1.5
@@ -65,7 +65,7 @@
{
// GNASH_REPORT_FUNCTION;
if (_info) {
- delete _info;
+ delete[] _info;
}
_index = 0;
_size = 0;
@@ -89,8 +89,7 @@
// GNASH_REPORT_FUNCTION;
_collecting = true;
if (_info == 0) {
- log_debug("Allocating buffer for %d data samples",
- DATALOG_SIZE);
+ log_debug("Allocating buffer for %d data samples", DATALOG_SIZE);
_info = new struct small_mallinfo[DATALOG_SIZE];
reset();
}
@@ -352,6 +351,24 @@
}
}
+void
+Memory::dumpCSV()
+{
+// GNASH_REPORT_FUNCTION;
+
+ struct small_mallinfo *ptr;
+ cerr << "linenum,seconds,nanoseconds,arena,allocated,freed" << endl;
+ for (int i=0; i<_index; i++) {
+ ptr = _info + i;
+ cerr << ptr->line << ","
+ << ptr->stamp.tv_sec << ","
+ << ptr->stamp.tv_nsec << ","
+ << ptr->arena << ","
+ << ptr->uordblks << ","
+ << ptr->fordblks << endl;
+ }
+}
+
} // end of gnash namespace
#endif // end of HAVE_MALLINFO
Index: server/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/Makefile.am,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -b -r1.139 -r1.140
--- server/Makefile.am 22 Feb 2008 14:20:47 -0000 1.139
+++ server/Makefile.am 28 Mar 2008 21:30:22 -0000 1.140
@@ -28,6 +28,7 @@
# Only enable if we're configured with --enable-mp3
AM_CPPFLAGS = \
+ -I$(top_srcdir)/libnet \
-I$(top_srcdir)/backend \
-I$(top_srcdir)/server/swf \
-I$(top_srcdir)/server/asobj \
@@ -187,6 +188,8 @@
libgnashserver_la_LIBADD = \
$(top_builddir)/libbase/libgnashbase.la \
+ $(top_builddir)/libamf/libgnashamf.la \
+ $(top_builddir)/libnet/libgnashnet.la \
$(top_builddir)/libmedia/libgnashmedia.la \
$(top_builddir)/server/asobj/libgnashasobjs.la \
$(top_builddir)/server/parser/libgnashparser.la \
Index: server/asobj/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Makefile.am,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- server/asobj/Makefile.am 5 Mar 2008 03:56:01 -0000 1.50
+++ server/asobj/Makefile.am 28 Mar 2008 21:30:23 -0000 1.51
@@ -21,6 +21,7 @@
noinst_LTLIBRARIES = libgnashasobjs.la
AM_CPPFLAGS = \
+ -I$(top_srcdir)/libnet \
-I$(top_srcdir)/backend \
-I$(top_srcdir)/server \
-I$(top_srcdir)/server/swf \
@@ -101,7 +102,7 @@
DropShadowFilter_as.h \
Error.h \
GMath.h \
- Global.h \
+ Global.h\
GlowFilter_as.h \
GradientBevelFilter_as.h \
GradientGlowFilter_as.h \
Index: server/asobj/xmlsocket.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlsocket.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/asobj/xmlsocket.cpp 19 Feb 2008 19:20:56 -0000 1.43
+++ server/asobj/xmlsocket.cpp 28 Mar 2008 21:30:23 -0000 1.44
@@ -21,6 +21,7 @@
#include "gnashconfig.h"
#endif
+#include "network.h"
#include "utility.h"
#include "xml.h"
#include "xmlsocket.h"
Index: server/parser/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/parser/Makefile.am,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- server/parser/Makefile.am 5 Mar 2008 03:56:02 -0000 1.44
+++ server/parser/Makefile.am 28 Mar 2008 21:30:23 -0000 1.45
@@ -26,6 +26,7 @@
# rendering calls from the parser (see https://savannah.gnu.org/task/?5837)
#
AM_CPPFLAGS = \
+ -I$(top_srcdir)/libnet \
-I$(top_srcdir)/backend \
-I$(top_srcdir)/server \
-I$(top_srcdir)/server/swf \
Index: server/vm/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/vm/Makefile.am,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/vm/Makefile.am 22 Mar 2008 02:26:53 -0000 1.20
+++ server/vm/Makefile.am 28 Mar 2008 21:30:23 -0000 1.21
@@ -21,6 +21,7 @@
noinst_LTLIBRARIES = libgnashvm.la
AM_CPPFLAGS = \
+ -I$(top_srcdir)/libnet \
-I$(top_srcdir)/backend \
-I$(top_srcdir)/server \
-I$(top_srcdir)/server/asobj \
Index: libnet/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libnet/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/Makefile.am 28 Mar 2008 03:30:21 -0000 1.1
+++ libnet/Makefile.am 28 Mar 2008 21:30:24 -0000 1.2
@@ -49,9 +49,11 @@
noinst_HEADERS = \
buffer.h \
cque.h \
+ lirc.h \
handler.h \
http.h \
network.h \
+ netstats.h \
rtmp.h \
statistics.h
@@ -59,8 +61,10 @@
buffer.cpp \
cque.cpp \
handler.cpp \
+ lirc.cpp \
http.cpp \
network.cpp \
+ netstats.cpp \
rtmp.cpp \
statistics.cpp
Index: libnet/buffer.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/buffer.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/buffer.cpp 28 Mar 2008 03:30:21 -0000 1.1
+++ libnet/buffer.cpp 28 Mar 2008 21:30:24 -0000 1.2
@@ -24,7 +24,7 @@
using namespace std;
using namespace gnash;
-namespace cygnal
+namespace gnash
{
void *
@@ -203,7 +203,7 @@
cerr << gnash::hexify((unsigned char *)_ptr, _nbytes, true) << endl;
}
-} // end of cygnal namespace
+} // end of gnash namespace
// local Variables:
Index: libnet/buffer.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/buffer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/buffer.h 28 Mar 2008 03:30:21 -0000 1.1
+++ libnet/buffer.h 28 Mar 2008 21:30:24 -0000 1.2
@@ -26,7 +26,7 @@
#include "network.h"
// _definst_ is the default instance name
-namespace cygnal
+namespace gnash
{
class Buffer
@@ -77,7 +77,7 @@
};
-} // end of cygnal namespace
+} // end of gnash namespace
#endif // end of __BUFFER_H__
Index: libnet/cque.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/cque.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/cque.cpp 28 Mar 2008 03:30:21 -0000 1.1
+++ libnet/cque.cpp 28 Mar 2008 21:30:24 -0000 1.2
@@ -35,7 +35,7 @@
using namespace boost;
-namespace cygnal
+namespace gnash
{
CQue::CQue()
@@ -253,7 +253,7 @@
#endif
}
-} // end of cygnal namespace
+} // end of gnash namespace
// local Variables:
Index: libnet/cque.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/cque.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/cque.h 28 Mar 2008 03:30:21 -0000 1.1
+++ libnet/cque.h 28 Mar 2008 21:30:24 -0000 1.2
@@ -29,7 +29,7 @@
#include "network.h"
// _definst_ is the default instance name
-namespace cygnal
+namespace gnash
{
class CQue {
@@ -90,7 +90,7 @@
#endif
};
-} // end of cygnal namespace
+} // end of gnash namespace
#endif // end of __CQUE_H__
Index: libnet/cqueue.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/cqueue.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/cqueue.cpp 28 Mar 2008 03:30:22 -0000 1.1
+++ libnet/cqueue.cpp 28 Mar 2008 21:30:25 -0000 1.2
@@ -35,7 +35,7 @@
using namespace std;
using namespace boost;
-namespace cygnal
+namespace gnash
{
CQueue::CQueue()
@@ -107,7 +107,7 @@
// GNASH_REPORT_FUNCTION;
}
-} // end of cygnal namespace
+} // end of gnash namespace
// local Variables:
Index: libnet/cqueue.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/cqueue.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/cqueue.h 28 Mar 2008 03:30:22 -0000 1.1
+++ libnet/cqueue.h 28 Mar 2008 21:30:25 -0000 1.2
@@ -17,10 +17,6 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
#ifndef __CQUEUE_H__
#define __CQUEUE_H__ 1
@@ -34,7 +30,7 @@
#include <vector>
#include "log.h"
-namespace cygnal
+namespace gnash
{
class CQueue
@@ -62,7 +58,7 @@
};
-} // end of cygnal namespace
+} // end of gnash namespace
#endif // end of __CQUEUE_H__
Index: libnet/handler.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/handler.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/handler.cpp 28 Mar 2008 03:30:22 -0000 1.1
+++ libnet/handler.cpp 28 Mar 2008 21:30:25 -0000 1.2
@@ -40,10 +40,10 @@
using namespace std;
using namespace boost;
-namespace cygnal
+namespace gnash
{
-extern map<int, Handler *> handlers;
+map<int, Handler *> handlers;
Handler::Handler()
: _die(false), _netfd(0)
@@ -284,7 +284,7 @@
} // end of extern C
-} // end of cygnal namespace
+} // end of gnash namespace
// local Variables:
Index: libnet/handler.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/handler.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/handler.h 28 Mar 2008 03:30:22 -0000 1.1
+++ libnet/handler.h 28 Mar 2008 21:30:25 -0000 1.2
@@ -31,7 +31,7 @@
#include "network.h"
// _definst_ is the default instance name
-namespace cygnal
+namespace gnash
{
@@ -153,7 +153,7 @@
void start_handler(Handler::thread_params_t *args);
}
-} // end of cygnal namespace
+} // end of gnash namespace
#endif // end of __HANDLER_H__
Index: libnet/http.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/http.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/http.cpp 28 Mar 2008 03:30:22 -0000 1.1
+++ libnet/http.cpp 28 Mar 2008 21:30:25 -0000 1.2
@@ -46,7 +46,7 @@
static boost::mutex stl_mutex;
-namespace cygnal
+namespace gnash
{
extern map<int, Handler *> handlers;
@@ -1328,7 +1328,7 @@
} // end of extern C
-} // end of cygnal namespace
+} // end of gnash namespace
// local Variables:
Index: libnet/http.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/http.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/http.h 28 Mar 2008 03:30:22 -0000 1.1
+++ libnet/http.h 28 Mar 2008 21:30:26 -0000 1.2
@@ -19,10 +19,6 @@
#ifndef _HTTP_H_
#define _HTTP_H_
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
#include <string>
#include <map>
#include <vector>
@@ -31,7 +27,7 @@
#include "handler.h"
#include "network.h"
-namespace cygnal
+namespace gnash
{
class HTTP
@@ -292,7 +288,7 @@
}
-} // end of cygnal namespace
+} // end of gnash namespace
// end of _HTTP_H_
#endif
Index: libnet/netstats.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/netstats.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/netstats.cpp 28 Mar 2008 03:30:23 -0000 1.1
+++ libnet/netstats.cpp 28 Mar 2008 21:30:26 -0000 1.2
@@ -28,7 +28,7 @@
using namespace gnash;
using namespace boost::posix_time;
-namespace cygnal {
+namespace gnash {
NetStats::NetStats()
{
@@ -67,7 +67,7 @@
return *this;
}
-} // end of cygnal namespace
+} // end of gnash namespace
// local Variables:
// mode: C++
Index: libnet/netstats.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/netstats.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/netstats.h 28 Mar 2008 03:30:23 -0000 1.1
+++ libnet/netstats.h 28 Mar 2008 21:30:26 -0000 1.2
@@ -19,10 +19,6 @@
#ifndef __NETSTATS_H__
#define __NETSTATS_H__
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
//include all types plus i/o
#include <boost/date_time/posix_time/posix_time.hpp>
#include <string>
@@ -53,7 +49,7 @@
//
// samples are taken every 3 seconds, or the interval supplied in
Client::setInterval()
-namespace cygnal
+namespace gnash
{
class NetStats {
@@ -115,7 +111,7 @@
filetypes_e _type;
};
-} // end of cygnal namespace
+} // end of gnash namespace
#endif // __NETSTATS_H__
Index: libnet/rtmp.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/rtmp.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/rtmp.cpp 28 Mar 2008 03:30:23 -0000 1.1
+++ libnet/rtmp.cpp 28 Mar 2008 21:30:26 -0000 1.2
@@ -37,7 +37,7 @@
using namespace gnash;
using namespace std;
-namespace cygnal
+namespace gnash
{
extern map<int, Handler *> handlers;
@@ -512,7 +512,7 @@
}
}
-} // end of cygnal namespace
+} // end of gnash namespace
// local Variables:
// mode: C++
Index: libnet/rtmp.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/rtmp.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/rtmp.h 28 Mar 2008 03:30:23 -0000 1.1
+++ libnet/rtmp.h 28 Mar 2008 21:30:26 -0000 1.2
@@ -18,12 +18,6 @@
#ifndef _RTMP_H_
#define _RTMP_H_
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-#include "tu_config.h"
-
#include <boost/cstdint.hpp>
#include <vector>
@@ -31,7 +25,7 @@
#include "handler.h"
#include "network.h"
-namespace cygnal
+namespace gnash
{
#define RTMP_HANDSHAKE 0x3
@@ -154,7 +148,7 @@
// This is the thread for all incoming RTMP connections
void rtmp_handler(Handler::thread_params_t *args);
-} // end of cygnal namespace
+} // end of gnash namespace
// end of _RTMP_H_
#endif
Index: libnet/statistics.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/statistics.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/statistics.cpp 28 Mar 2008 03:30:23 -0000 1.1
+++ libnet/statistics.cpp 28 Mar 2008 21:30:26 -0000 1.2
@@ -73,7 +73,7 @@
"VIDEO"
};
-namespace cygnal
+namespace gnash
{
Statistics::Statistics() {
@@ -129,7 +129,7 @@
}
}
-} // end of cygnal namespace
+} // end of gnash namespace
// local Variables:
// mode: C++
Index: libnet/statistics.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/statistics.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libnet/statistics.h 28 Mar 2008 03:30:23 -0000 1.1
+++ libnet/statistics.h 28 Mar 2008 21:30:27 -0000 1.2
@@ -19,17 +19,13 @@
#ifndef __STATISTICS_H__
#define __STATISTICS_H__
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
#include <sys/time.h>
#include <network.h>
#include <list>
#include "netstats.h"
-namespace cygnal
+namespace gnash
{
class Statistics : public NetStats {
@@ -85,7 +81,7 @@
std::vector<std::string> _filespec;
};
-} // end of cygnal namespace
+} // end of gnash namespace
#endif // __STATISTICS_H__
Index: libnet/lirc.cpp
===================================================================
RCS file: libnet/lirc.cpp
diff -N libnet/lirc.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libnet/lirc.cpp 28 Mar 2008 21:30:26 -0000 1.1
@@ -0,0 +1,137 @@
+//
+// Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+//
+// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#include <string>
+
+#include <iostream>
+#include "gnash.h"
+#include "network.h"
+#include "log.h"
+#include "lirc.h"
+
+using namespace std;
+
+namespace gnash {
+
+// this number camne from the lirc irw program. If this size works for
+// them, it should work for us.
+const int LIRC_PACKET_SIZE = 128;
+const int TIMEOUT = 10;
+const int BUTTONSIZE = 10;
+
+Lirc::Lirc()
+ : _sockname("/tmp/lircd"), _button(0)
+{
+// GNASH_REPORT_FUNCTION;
+ _button = new char[BUTTONSIZE];
+}
+
+Lirc::~Lirc()
+{
+// GNASH_REPORT_FUNCTION;
+ if (_button != 0) {
+ delete _button;
+ }
+ closeNet();
+}
+
+bool
+Lirc::init()
+{
+// GNASH_REPORT_FUNCTION;
+ return connectSocket(_sockname);
+}
+
+bool
+Lirc::init(const char *sockpath)
+{
+// GNASH_REPORT_FUNCTION;
+ _connected = connectSocket(sockpath);
+ return _connected;
+}
+
+// Whenever lircd receives a IR signal it will broadcast the
+// following string to each client:
+// <code> <repeat count> <button name> <remote control name>
+// 0000000000000003 1 PREV LIRCEMU
+// 0000000000000006 1 NEXT LIRCEMU
+// 0000000000000012 1 A LIRCEMU
+
+gnash::key::code
+Lirc::getKey()
+{
+// GNASH_REPORT_FUNCTION;
+ key::code key;
+
+ byte_t buf[LIRC_PACKET_SIZE];
+ memset(buf, 0, LIRC_PACKET_SIZE);
+
+ // read the data if there is any
+ readNet(buf, LIRC_PACKET_SIZE, TIMEOUT);
+
+ string packet = reinterpret_cast<char *>(buf);
+ string::size_type space1 = packet.find(" ") +1;
+ string::size_type space2 = packet.find(" ", space1) + 1;
+ string::size_type space3 = packet.find(" ", space2) +1;
+
+ string code_str = packet.substr(0, space1);
+ string count_str = packet.substr(space1, space2-space1);
+ string button_str = packet.substr(space2,space3-space2);
+ string control_str = packet.substr(space3);
+
+ if (button_str[0] > 'A' && button_str[0] < 'Z') {
+ cerr << "Character: " << button_str << endl;
+ key = (gnash::key::code)button_str[0];
+ }
+
+ return key;
+}
+
+const char *
+Lirc::getButton()
+{
+// GNASH_REPORT_FUNCTION;
+
+ byte_t buf[LIRC_PACKET_SIZE];
+ memset(buf, 0, LIRC_PACKET_SIZE);
+
+ // read the data if there is any
+ readNet(buf, LIRC_PACKET_SIZE, TIMEOUT);
+
+ string packet = reinterpret_cast<char *>(buf);
+ string::size_type space1 = packet.find(" ") + 1;
+ string::size_type space2 = packet.find(" ", space1) + 1;
+ string::size_type space3 = packet.find(" ", space2) + 1;
+
+ string button_str = packet.substr(space2, space3-space2-1);
+
+ memset(_button, 0, BUTTONSIZE);
+ strncpy(_button, button_str.c_str(), BUTTONSIZE);
+ return _button;
+}
+
+} // end of gnash namespace
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
Index: libnet/lirc.h
===================================================================
RCS file: libnet/lirc.h
diff -N libnet/lirc.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libnet/lirc.h 28 Mar 2008 21:30:26 -0000 1.1
@@ -0,0 +1,51 @@
+//
+// Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+//
+// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifndef __LIRC_H__
+#define __LIRC_H__
+
+#include "gnash.h"
+#include "network.h"
+
+namespace gnash {
+
+class DSOEXPORT Lirc : public Network {
+public:
+ Lirc();
+ ~Lirc();
+ bool init();
+ bool init(const char *sockpath);
+
+ // Whenever lircd receives a IR signal it will broadcast the
+ // following string to each client:
+ // <code> <repeat count> <button name> <remote control name>
+ gnash::key::code getKey();
+ const char *getButton();
+ private:
+ const char *_sockname;
+ char *_button;
+};
+
+} // end of gnash namespace
+
+// __LIRC_H__
+#endif
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
Index: testsuite/libnet.all/Makefile.am
===================================================================
RCS file: testsuite/libnet.all/Makefile.am
diff -N testsuite/libnet.all/Makefile.am
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/libnet.all/Makefile.am 28 Mar 2008 21:30:27 -0000 1.1
@@ -0,0 +1,94 @@
+#
+# Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+#
+# 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+## Process this file with automake to generate Makefile.in
+
+AUTOMAKE_OPTIONS = dejagnu
+
+AM_CPPFLAGS = # -Wall
+
+AM_LDFLAGS = \
+ $(top_builddir)/libbase/libgnashbase.la \
+ $(top_builddir)/libamf/libgnashamf.la \
+ $(top_builddir)/libnet/libgnashnet.la \
+ $(BOOST_LIBS) \
+ $(PTHREAD_LIBS)
+
+localedir = $(datadir)/locale
+
+INCLUDES = -I.. \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/libnet \
+ -I$(top_srcdir)/libamf \
+ -I$(top_srcdir)/libbase \
+ -I$(top_srcdir)/cygnal \
+ -I$(top_srcdir)/server \
+ -DLOCALEDIR=\"$(localedir)\" \
+ $(BOOST_CFLAGS) \
+ $(PTHREAD_CFLAGS)
+
+check_PROGRAMS = \
+ test_buffer \
+ test_cque \
+ test_handler \
+ test_http
+
+test_http_SOURCES = test_http.cpp
+test_http_LDADD = $(AM_LDFLAGS)
+test_http_DEPENDENCIES = site-update
+
+test_cque_SOURCES = test_cque.cpp
+test_cque_LDADD = $(AM_LDFLAGS)
+test_cque_DEPENDENCIES = site-update
+
+test_handler_SOURCES = test_handler.cpp
+test_handler_LDADD = $(AM_LDFLAGS)
+test_handler_DEPENDENCIES = site-update
+
+test_buffer_SOURCES = test_buffer.cpp
+test_buffer_LDADD = $(AM_LDFLAGS)
+test_buffer_DEPENDENCIES = site-update
+
+# Rebuild with GCC 4.x Mudflap support
+mudflap:
+ @echo "Rebuilding with GCC Mudflap support"
+ $(MAKE) CXXFLAGS="$(CXXFLAGS) $(MUDFLAP_OPT)" LIBS="$(LIBS)
$(MUDFLAP_LIB)"
+
+TEST_DRIVERS = ../simple.exp
+
+CLEANFILES = \
+ site.exp.bak \
+ testrun.*
+
+check-DEJAGNU: site-update
+ @runtest=$(RUNTEST); \
+ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+ $$runtest $(RUNTESTFLAGS) $(TEST_DRIVERS); true; \
+ else \
+ echo "WARNING: could not find \`runtest'" 1>&2; \
+ for i in "$(check_PROGRAMS)"; do \
+ $(SHELL) $$i; \
+ done; \
+ fi
+
+site-update: site.exp
+ @rm -fr site.exp.bak
+ @cp site.exp site.exp.bak
+ @sed -e '/testcases/d' site.exp.bak > site.exp
+ @echo "# This is a list of the pre-compiled testcases" >> site.exp
+ @echo "set testcases \"$(check_PROGRAMS)\"" >> site.exp
Index: testsuite/libnet.all/test_buffer.cpp
===================================================================
RCS file: testsuite/libnet.all/test_buffer.cpp
diff -N testsuite/libnet.all/test_buffer.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/libnet.all/test_buffer.cpp 28 Mar 2008 21:30:27 -0000
1.1
@@ -0,0 +1,111 @@
+//
+// Copyright (C) 2008 Free Software Foundation, Inc.
+//
+// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#include <regex.h>
+#include <cstdio>
+#include <cerrno>
+#include <iostream>
+#include <fstream>
+#include <cstring>
+#include <vector>
+#include <boost/cstdint.hpp>
+
+#ifdef HAVE_DEJAGNU_H
+#include "dejagnu.h"
+#else
+#include "check.h"
+#endif
+
+#include "log.h"
+#include "network.h"
+#include "gmemory.h"
+#include "buffer.h"
+
+using namespace std;
+using namespace gnash;
+using namespace boost;
+
+TestState runtest;
+LogFile& dbglogfile = LogFile::getDefaultInstance();
+
+int
+main (int /*argc*/, char** /*argv*/) {
+ gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+ dbglogfile.setVerbosity();
+ // We use the Memory profiling class to check the malloc buffers
+ // in the kernel to make sure the allocations and frees happen
+ // the way we expect them too. There is no real other way to tell.
+ Memory mem;
+ mem.startStats();
+
+ Buffer buf;
+ mem.addStats(__LINE__); // take a sample
+
+ if (buf.size() == gnash::NETBUFSIZE) {
+ runtest.pass ("Buffer::size()");
+ } else {
+ runtest.fail ("Buffer::size()");
+ }
+
+ mem.addStats(__LINE__); // take a sample
+ buf.resize(112);
+ mem.addStats(__LINE__); // take a sample
+
+ if ((buf.size() == 112) && (mem.diffStats() == -16)) {
+ runtest.pass ("Buffer::resize()");
+ } else {
+ runtest.fail ("Buffer::resize()");
+ }
+ mem.addStats(__LINE__); // take a sample
+
+// buf.dump();
+ mem.addStats(__LINE__); // take a sample
+ buf.empty(); //empty just nukes the contents
+ if ((buf.size() == 112) && (mem.diffStats() == 0)) {
+ runtest.pass ("Buffer::empty()");
+ } else {
+ runtest.fail ("Buffer::empty()");
+ }
+
+ // populate the buffer
+ boost::uint8_t *ptr = buf.reference();
+ for (size_t i=1; i< buf.size(); i++) {
+ ptr[i] = i;
+ }
+
+ Buffer buf2;
+ if (buf2 == buf) {
+ runtest.fail ("Buffer::operator==");
+ } else {
+ runtest.pass ("Buffer::operator==");
+ }
+
+ buf2 = buf;
+ if (buf2 == buf) {
+ runtest.pass ("Buffer::operator=");
+ } else {
+ runtest.fail ("Buffer::operator=");
+ }
+
+// mem.analyze();
+}
+
Index: testsuite/libnet.all/test_cque.cpp
===================================================================
RCS file: testsuite/libnet.all/test_cque.cpp
diff -N testsuite/libnet.all/test_cque.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/libnet.all/test_cque.cpp 28 Mar 2008 21:30:27 -0000 1.1
@@ -0,0 +1,163 @@
+//
+// Copyright (C) 2008 Free Software Foundation, Inc.
+//
+// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#ifdef HAVE_STDARG_H
+#include <cstdarg>
+#endif
+
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <regex.h>
+#include <cstdio>
+#include <cerrno>
+#include <iostream>
+#include <fstream>
+#include <cstring>
+#include <vector>
+#include <boost/cstdint.hpp>
+
+#ifdef HAVE_DEJAGNU_H
+#include "dejagnu.h"
+#else
+#include "check.h"
+#endif
+
+#include "log.h"
+#include "network.h"
+#include "cque.h"
+
+using namespace std;
+using namespace gnash;
+using namespace boost;
+
+TestState runtest;
+//LogFile& dbglogfile = LogFile::getDefaultInstance();
+
+int
+main (int /*argc*/, char** /*argv*/) {
+ gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+ dbglogfile.setVerbosity();
+
+ CQue que;
+
+ Buffer buf;
+ // populate the buffer
+ boost::uint8_t *ptr = buf.reference();
+ for (size_t i=1; i< buf.size(); i++) {
+ ptr[i] = i+' ';
+ }
+
+ boost::uint8_t *test = new uint8_t[6];
+ memcpy(test, "hell", 4);
+
+ // Push one buffer on the fifo. The default is the incoming fifo,
+ // which is the one where data flows from the network to the queue.
+ que.push(&buf);
+ if (que.size() == 1) {
+ runtest.pass ("CQue::push(Buffer *)");
+ } else {
+ runtest.fail ("CQue::push(Buffer *)");
+ }
+
+ // Test push. When dumpimg, the second address should be different than
the first,
+ // as well as the size. The outgoing queue should be uneffected.
+ Buffer buf1;
+ buf1.resize(112);
+ que.push(&buf1);
+ if (que.size() == 2) {
+ runtest.pass ("CQue::pushin(Buffer *)");
+ } else {
+ runtest.fail ("CQue::pushin(Buffer *)");
+ }
+
+ // Nuke the array
+ que.clear();
+ if (que.size() == 0) {
+ runtest.pass ("CQue::clearall()");
+ } else {
+ runtest.fail ("CQue::clearall()");
+ }
+
+
+ que.push(&buf);
+ Buffer *buf2 = que.peek();
+ if ((buf2 == &buf) && (que.size() == 1)) {
+ runtest.pass ("CQue::peek()");
+ } else {
+ runtest.fail ("CQue::peek()");
+ }
+
+ Buffer *buf3 = que.peek();
+ if ((buf3 == &buf) && (que.size() == 1)) {
+ runtest.pass ("CQue::pop()");
+ } else {
+ runtest.fail ("CQue::pop()");
+ }
+
+ que.push(&buf1);
+ que.push(&buf1);
+ size_t firstsize = que.size();
+ que.remove(&buf);
+ if (que.size() == firstsize - 1) {
+ runtest.pass ("CQue::remove()");
+ } else {
+ runtest.fail ("CQue::remove()");
+ }
+
+ // Make some test buffers
+ Buffer merge1, merge2, merge3;
+ size_t i;
+ ptr = merge1.reference();
+ for (i=0; i< gnash::NETBUFSIZE; i++) {
+ ptr[i] = i*'A';
+ }
+ que.push(&merge1);
+
+ ptr = merge2.reference();
+ for (i=0; i<gnash::NETBUFSIZE; i++) {
+ ptr[i] = i+'a';
+ }
+ que.push(&merge2);
+
+ merge3.resize(96);
+ ptr = merge3.reference();
+ for (i=0; i<96; i++) {
+ ptr[i] = i+' ';
+ }
+ que.push(&merge3);
+
+ // A merge gives us one big buffer where there were several buffers
+ Buffer *foo = que.merge(&merge1);
+ if (foo->size() == (gnash::NETBUFSIZE * 2) + 96) {
+ runtest.pass ("CQue::merge()");
+ } else {
+ runtest.fail ("CQue::merge()");
+ }
+
+ que.pop();
+
+ que.dump();
+}
+
Index: testsuite/libnet.all/test_crc.cpp
===================================================================
RCS file: testsuite/libnet.all/test_crc.cpp
diff -N testsuite/libnet.all/test_crc.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/libnet.all/test_crc.cpp 28 Mar 2008 21:30:27 -0000 1.1
@@ -0,0 +1,101 @@
+//
+// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//
+// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+//
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#ifdef HAVE_STDARG_H
+#include <cstdarg>
+#endif
+
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <regex.h>
+#include <cstdio>
+#include <cerrno>
+#include <iostream>
+#include <fstream>
+#include <string>
+
+#ifdef HAVE_DEJAGNU_H
+#include "dejagnu.h"
+#else
+#include "check.h"
+#endif
+
+#include "log.h"
+#include "crc.h"
+
+using namespace std;
+using namespace gnash;
+
+TestState runtest;
+LogFile& dbglogfile = LogFile::getDefaultInstance();
+
+int
+main (int /*argc*/, char** /*argv*/) {
+ CRcInitFile& crc = CRcInitFile::getDefaultInstance();
+
+ gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+ dbglogfile.setVerbosity();
+
+ // Parse the test config file
+ if (crc.parseFile("cygnalrc")) {
+ runtest.pass ("crc.parseFile()");
+ } else {
+ runtest.fail ("crc.parseFile()");
+ }
+
+ if (crc.useActionDump()) {
+ runtest.fail ("useActionDump");
+ } else {
+ runtest.pass ("useActionDump");
+ }
+
+ if (crc.useParserDump()) {
+ runtest.fail ("useParserDump");
+ } else {
+ runtest.pass ("useParserDump");
+ }
+
+ if (crc.verbosityLevel() == 11) {
+ runtest.pass ("verbosityLevel");
+ } else {
+ runtest.fail ("verbosityLevel");
+ }
+
+ if (crc.getDebugLog() == "/tmp/cygnal-dbg.log") {
+ runtest.pass ("getDebugLog");
+ } else {
+ runtest.fail ("getDebugLog");
+ }
+
+ if (crc.getPortOffset() == 4000) {
+ runtest.pass ("getPortOffset");
+ } else {
+ runtest.fail ("getPortOffset");
+ }
+
+ crc.dump();
+}
+
Index: testsuite/libnet.all/test_handler.cpp
===================================================================
RCS file: testsuite/libnet.all/test_handler.cpp
diff -N testsuite/libnet.all/test_handler.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/libnet.all/test_handler.cpp 28 Mar 2008 21:30:27 -0000
1.1
@@ -0,0 +1,129 @@
+//
+// Copyright (C) 2008 Free Software Foundation, Inc.
+//
+// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#ifdef HAVE_STDARG_H
+#include <cstdarg>
+#endif
+
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <regex.h>
+#include <cstdio>
+#include <cerrno>
+#include <iostream>
+#include <fstream>
+#include <cstring>
+#include <vector>
+#include <boost/cstdint.hpp>
+
+#ifdef HAVE_DEJAGNU_H
+#include "dejagnu.h"
+#else
+#include "check.h"
+#endif
+
+#include "log.h"
+#include "handler.h"
+
+using namespace std;
+using namespace gnash;
+using namespace boost;
+
+TestState runtest;
+LogFile& dbglogfile = LogFile::getDefaultInstance();
+
+int
+main (int /*argc*/, char** /*argv*/) {
+ gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+ dbglogfile.setVerbosity();
+
+ Handler que;
+
+ Buffer buf;
+ boost::uint8_t *test = new uint8_t[6];
+ memcpy(test, "hell", 4);
+
+ // Push one buffer on the fifo. The default is the incoming fifo,
+ // which is the one where data flows from the network to the queue.
+ que.push(&buf);
+ if ((que.size() == 1) && (que.outsize() == 0)) {
+ runtest.pass ("Handler::push(Buffer *)");
+ } else {
+ runtest.fail ("Handler::push(Buffer *)");
+ }
+
+ // Push one buffer on the outgoing fifo. The default is the incoming fifo,
+ // The outgoing fifo is where data flows from the queu to the network. As
+ // we can explicitly specufy which queue we write to, we test that here.
+ que.pushout(&buf);
+ if ((que.size() == 1) && (que.outsize() == 1)) {
+ runtest.pass ("Handler::pushout(Buffer *)");
+ } else {
+ runtest.fail ("Handler::pushout(Buffer *)");
+ }
+
+ // Test pushin. When dumpimg, the second address should be different than
the first,
+ // as well as the size. The outgoing queue should be uneffected.
+ Buffer buf1;
+ buf1.resize(112);
+ que.pushin(&buf1);
+ if ((que.size() == 2) && (que.outsize() == 1)) {
+ runtest.pass ("Handler::pushin(Buffer *)");
+ } else {
+ runtest.fail ("Handler::pushin(Buffer *)");
+ }
+
+ // Nuke the array
+ que.clearall();
+ if ((que.size() == 0) && (que.outsize() == 0)) {
+ runtest.pass ("Handler::clearall()");
+ } else {
+ runtest.fail ("Handler::clearall()");
+ }
+
+ // populate the buffer
+ boost::uint8_t *ptr = buf.reference();
+ for (size_t i=1; i< buf.size(); i++) {
+ ptr[i] = i;
+ }
+
+ que.push(&buf);
+ Buffer *buf2 = que.peek();
+ if ((buf2 == &buf) && (que.size() == 1)) {
+ runtest.pass ("Handler::peek()");
+ } else {
+ runtest.fail ("Handler::peek()");
+ }
+
+ Buffer *buf3 = que.peek();
+ if ((buf3 == &buf) && (que.size() == 1)) {
+ runtest.pass ("Handler::pop()");
+ } else {
+ runtest.fail ("Handler::pop()");
+ }
+
+// que.dump();
+}
+
Index: testsuite/libnet.all/test_http.cpp
===================================================================
RCS file: testsuite/libnet.all/test_http.cpp
diff -N testsuite/libnet.all/test_http.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/libnet.all/test_http.cpp 28 Mar 2008 21:30:28 -0000 1.1
@@ -0,0 +1,477 @@
+ //
+// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//
+// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#ifdef HAVE_DEJAGNU_H
+
+#include <string>
+
+#include <unistd.h>
+#ifdef HAVE_GETOPT_H
+# include <getopt.h>
+#endif
+
+#ifndef __GNUC__
+extern int optind, getopt(int, char *const *, const char *);
+#endif
+
+#include <sys/types.h>
+#include <iostream>
+#include <string>
+#include <vector>
+#include <regex.h>
+
+#include "log.h"
+#include "http.h"
+#include "dejagnu.h"
+#include "network.h"
+
+using namespace gnash;
+using namespace std;
+
+static void usage (void);
+
+static TestState runtest;
+
+LogFile& dbglogfile = LogFile::getDefaultInstance();
+
+int
+main(int argc, char *argv[])
+{
+ int c;
+
+ while ((c = getopt (argc, argv, "hdvsm:")) != -1) {
+ switch (c) {
+ case 'h':
+ usage ();
+ break;
+
+ case 'v':
+ dbglogfile.setVerbosity();
+ break;
+
+ default:
+ usage ();
+ break;
+ }
+ }
+
+ HTTP http;
+
+ http.clearHeader();
+ http.formatDate();
+// cerr << "FIXME: " << http.getHeader() << endl;
+
+ regex_t regex_pat;
+
+ // Check the Date field
+ // The date should look something like this:
+ // Date: Mon, 10 Dec 2007 GMT
+ regcomp (®ex_pat, "Date: [A-Z][a-z]*, [0-9]* [A-Z][a-z]* [0-9]* [0-9:]*
*GMT$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatDate()");
+ cerr << http.getHeader().c_str() << endl;
+ } else {
+ runtest.pass ("HTTP::formatDate()");
+ }
+ regfree(®ex_pat);
+
+ // Check the Content-Length field
+ http.clearHeader();
+ http.formatContentLength(12345);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Content-Length: [0-9]*$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatContentLength()");
+ } else {
+ runtest.pass ("HTTP::formatContentLength()");
+ }
+ regfree(®ex_pat);
+
+
+ // Check the Connection field
+// bool formatConnection(const char *data);
+ http.clearHeader();
+ const char *data = "Keep-Alive";
+ http.formatConnection(data);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Connection: [A-za-z-]*",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatConnection()");
+ } else {
+ runtest.pass ("HTTP::formatConnection()");
+ }
+ regfree(®ex_pat);
+
+ // Check the Server field
+ http.clearHeader();
+ http.formatServer();
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Server: Cygnal (GNU/Linux)$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatServer()");
+ } else {
+ runtest.pass ("HTTP::formatServer()");
+ }
+ regfree(®ex_pat);
+
+ // Check the Host field
+// bool formatHost(const char *data);
+ http.clearHeader();
+ data = "localhost:4080";
+ http.formatHost(data);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Host: [A-za-z-]*:[0-9]*$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatHost()");
+ } else {
+ runtest.pass ("HTTP::formatHost()");
+ }
+ regfree(®ex_pat);
+
+// Check the Language field
+// bool formatLanguage(const char *data);
+ http.clearHeader();
+ data = "en-US,en;q=0.9";
+ http.formatLanguage(data);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Accept-Language: en-US,en;q=0.9$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatLanguage()");
+ } else {
+ runtest.pass ("HTTP::formatLanguage()");
+ }
+ regfree(®ex_pat);
+
+// bool formatCharset(const char *data);
+// Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r
+ http.clearHeader();
+ data = "iso-8859-1, utf-8, utf-16, *;q=0.1";
+ http.formatCharset(data);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Accept-Charset: iso-8859-1.*$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatCharset()");
+ } else {
+ runtest.pass ("HTTP::formatCharset()");
+ }
+ regfree(®ex_pat);
+
+// bool formatEncoding(const char *data);
+ http.clearHeader();
+ data = "deflate, gzip, x-gzip, identity, *;q=0";
+ http.formatEncoding(data);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Accept-Encoding: deflate, gzip.*$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatEncoding()");
+ } else {
+ runtest.pass ("HTTP::formatEncoding()");
+ }
+ regfree(®ex_pat);
+
+
+// bool formatTE(const char *data);
+ http.clearHeader();
+ data = "deflate, gzip, chunked, identity, trailers";
+ http.formatTE(data);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "TE: deflate, gzip,.*$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatTE()");
+ } else {
+ runtest.pass ("HTTP::formatTE()");
+ }
+ regfree(®ex_pat);
+
+// bool formatAgent(const char *data);
+ http.clearHeader();
+ data = "Gnash 0.8.1-cvs (X11; Linux i686; U; en)";
+ http.formatAgent(data);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "User-Agent: Gnash 0.8.1-cvs.*$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatAgent()");
+ } else {
+ runtest.pass ("HTTP::formatAgent()");
+ }
+ regfree(®ex_pat);
+
+ // Check the Content Type field. First we check with a
+ // specified field, then next to see if the default works.
+// bool formatContentType();
+ http.clearHeader();
+ http.formatContentType(HTTP::SWF);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Content-Type: application/x-shockwave-flash.*$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatContentType(type)");
+ } else {
+ runtest.pass ("HTTP::formatContentType(type)");
+ }
+ regfree(®ex_pat);
+
+ http.clearHeader();
+ http.formatContentType();
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Content-Type: text/html.*$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatContentType()");
+ } else {
+ runtest.pass ("HTTP::formatContenType()");
+ }
+ regfree(®ex_pat);
+
+// bool formatReferer(const char *data);
+ http.clearHeader();
+ data = "http://localhost/software/gnash/tests/index.html";
+ http.formatReferer(data);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "Referer: http://localhost.*index.html.*$",
+ REG_NOSUB|REG_NEWLINE);
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatReferer()");
+ } else {
+ runtest.pass ("HTTP::formatReferer()");
+ }
+ regfree(®ex_pat);
+
+ // Check formatHeader()
+ http.clearHeader();
+ http.formatHeader(HTTP::LIFE_IS_GOOD);
+// cerr << "FIXME: " << http.getHeader() << endl;
+ regcomp (®ex_pat, "HTTP/1.1 200
OK.*Date:.*Connection:.*-Length.*-Type:.*$",
+ REG_NOSUB); // note that we do want to look for NL
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatHeader(port)");
+ } else {
+ runtest.pass ("HTTP::formatheader(port)");
+ }
+ regfree(®ex_pat);
+
+ // Check the Server field
+ http.clearHeader();
+ http.formatErrorResponse(HTTP::NOT_FOUND);
+// cerr << "FIXME: " << http.getHeader() << endl;
+// cerr << "FIXME: " << http.getBody() << endl;
+ regcomp (®ex_pat,
"Date:.*Server:.*Content-Length:.*Connection:.*Content-Type:.*$",
+ REG_NOSUB); // note that we do want to look for NL
+ if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
+ runtest.fail ("HTTP::formatErrorResponse(header)");
+ } else {
+ runtest.pass ("HTTP::formatErrorResponse(header)");
+ }
+ regfree(®ex_pat);
+ regcomp (®ex_pat, "DOCTYPE.*<title>404 Not Found</title>.*$",
+ REG_NOSUB); // note that we do want to look for NL
+ if (regexec (®ex_pat, http.getBody().c_str(), 0, (regmatch_t *)0, 0)) {
+ runtest.fail ("HTTP::formatErrorResponse(body)");
+ } else {
+ runtest.pass ("HTTP::formatErrorResponse(body)");
+ }
+ regfree(®ex_pat);
+
+ //
+ // Decoding tests for HTTP
+ //
+ http.clearHeader();
+ Network::byte_t *buffer = (Network::byte_t *)"GET
/software/gnash/tests/flvplayer.swf?file=http://localhost/software/gnash/tests/Ouray_Ice_Festival_Climbing_Competition.flv
HTTP/1.1\r\n"
+"User-Agent: Gnash/0.8.1-cvs (X11; Linux i686; U; en)\r\n"
+"Host: localhost:4080\r\n"
+"Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png,
image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\n"
+"Accept-Language: en-US,en;q=0.9\r\n"
+"Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\n"
+"Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0\r\n"
+"If-Modified-Since: Mon, 10 Dec 2007 02:26:31 GMT\r\n"
+"If-None-Match: \"4cc434-e266-52ff63c0\"\r\n"
+"Connection: Keep-Alive, TE\r\n"
+"Referer: http://localhost/software/gnash/tests/index.html\r\n"
+"TE: deflate, gzip, chunked, identity, trailers\r\n"
+"\r\n";
+
+// GET /software/gnash/tests/ HTTP/1.1
+// Host: localhost:4080
+// User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.5)
Gecko/20070718 Fedora/2.0.0.5-1.fc7 Firefox/2.0.0.5
+// Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
+// Accept-Language: en-us,en;q=0.5
+// Accept-Encoding: gzip,deflate
+// Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
+// Keep-Alive: 300
+// Connection: keep-alive
+
+// User Agent: Lynx/2.8.6rel.2 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.8b
+
+// Some browsers have a different synatax, of course, to keep things
+// interesting.
+ Network::byte_t *buffer2 = (Network::byte_t *)"GET
/software/gnash/tests/flvplayer.swf?file=http://localhost/software/gnash/tests/Ouray_Ice_Festival_Climbing_Competition.flv
HTTP/1.1\r\n)"
+"Content-Language: en-US,en;q=0.9\r\n"
+"Content-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\n"
+"Content-Encoding: deflate, gzip, x-gzip, identity, *;q=0\r\n";
+// http.extractMethod(buffer);
+ string result;
+ result = http.extractReferer(buffer);
+ if (result == "http://localhost/software/gnash/tests/index.html") {
+ runtest.fail ("HTTP::extractReferer()");
+ } else {
+ runtest.pass ("HTTP::extractReferer()");
+ }
+ result = http.extractHost(buffer);
+ if (result == "localhost:4080") {
+ runtest.fail ("HTTP::extractHost()");
+ } else {
+ runtest.pass ("HTTP::extractHost()");
+ }
+
+ result = http.extractAgent(buffer);
+ if (result == "Gnash/0.8.1-cvs (X11; Linux i686; U; en)") {
+ runtest.fail ("HTTP::extractAgent()");
+ } else {
+ runtest.pass ("HTTP::extractAgent()");
+ }
+
+ int count;
+ count = http.extractLanguage(buffer);
+ std::vector<std::string> language = http.getLanguage();
+ if ((count > 2) &&
+ (language[0] == "en-US") &&
+ (language[1] == "en")) {
+ runtest.fail ("HTTP::extractLanguage(Accept-)");
+ } else {
+ runtest.pass ("HTTP::extractLanguage(Accept-)");
+ }
+ count = http.extractLanguage(buffer2);
+ language = http.getLanguage();
+ if ((count == 2) &&
+ (language[0] == "en-US") &&
+ (language[1] == "en")) {
+ runtest.fail ("HTTP::extractLanguage(Content-)");
+ } else {
+ runtest.pass ("HTTP::extractLanguage(Content-)");
+ }
+
+ result = reinterpret_cast<const char *>(http.extractCharset(buffer));
+ std::vector<std::string> charsets = http.getCharset();
+ if ((count == 3) &&
+ (charsets[0] == "iso-8859-1") &&
+ (charsets[1] == "utf-8") &&
+ (charsets[2] == "utf-16")) {
+ runtest.fail ("HTTP::extractCharset(Accept-)");
+ } else {
+ runtest.pass ("HTTP::extractCharset(Accept-)");
+ }
+ count = http.extractCharset(buffer2);
+ charsets = http.getCharset();
+ if ((count == 3) &&
+ (charsets[0] == "iso-8859-1") &&
+ (charsets[1] == "utf-8") &&
+ (charsets[2] == "utf-16")) {
+ runtest.fail ("HTTP::extractCharset(Content-)");
+ } else {
+ runtest.pass ("HTTP::extractCharset(Content-)");
+ }
+
+ count = http.extractConnection(buffer);
+ std::vector<std::string> connections = http.getConnection();
+ if ((count == 2) &&
+ (connections[0] == "Keep-Alive") &&
+ (connections[1] == "TE")) {
+ runtest.pass ("HTTP::extractConnection()");
+ } else {
+ runtest.fail ("HTTP::extractConnection()");
+ }
+
+ count = http.extractEncoding(buffer);
+ std::vector<std::string> encoding = http.getEncoding();
+ if ((count == 4) &&
+ (encoding[0] == "deflate") &&
+ (encoding[1] == "gzip") &&
+ (encoding[2] == "chunked") &&
+ (encoding[3] == "identity")) {
+ runtest.fail ("HTTP::extractEncoding(Accept-)");
+ } else{
+ runtest.pass ("HTTP::extractEncoding(Accept-)");
+ }
+
+ count = http.extractTE(buffer);
+ std::vector<std::string> te = http.getTE();
+ if ((count == 5) &&
+ (te[0] == "deflate") &&
+ (te[1] == "gzip") &&
+ (te[2] == "chunked") &&
+ (te[3] == "identity") &&
+ (te[4] == "trailers")) {
+ runtest.pass ("HTTP::extractTE()");
+ } else {
+ runtest.fail ("HTTP::extractTE()");
+ }
+
+// http.formatHeader(666, RTMP);
+// http.formatRequest("http://localhost:4080", HTTP::GET);
+
+// bool formatMethod(const char *data);
+
+
+// void *out = amf_obj.encodeNumber(*num);
+
+// if (memcmp(out, buf, 9) == 0) {
+// runtest.pass("Encoded AMF Number");
+// } else {
+// runtest.fail("Encoded AMF Number");
+// }
+
+// delete num;
+
+
+ if (dbglogfile.getVerbosity() > 0) {
+ http.dump();
+ }
+}
+static void
+usage (void)
+{
+ cerr << "This program tests HTTP protocol support." << endl;
+ cerr << "Usage: test_http [hv]" << endl;
+ cerr << "-h\tHelp" << endl;
+ cerr << "-v\tVerbose" << endl;
+ exit (-1);
+}
+
+#else // no DejaGnu support
+
+int
+main(int /*argc*/, char /* *argv[]*/)
+{
+ // nop
+ return 0;
+}
+
+#endif
Index: libbase/lirc.cpp
===================================================================
RCS file: libbase/lirc.cpp
diff -N libbase/lirc.cpp
--- libbase/lirc.cpp 18 Mar 2008 15:24:08 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,137 +0,0 @@
-//
-// Copyright (C) 2007, 2008 Free Software Foundation, Inc.
-//
-// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-#include <string>
-
-#include <iostream>
-#include "gnash.h"
-#include "network.h"
-#include "log.h"
-#include "lirc.h"
-
-using namespace std;
-
-namespace gnash {
-
-// this number camne from the lirc irw program. If this size works for
-// them, it should work for us.
-const int LIRC_PACKET_SIZE = 128;
-const int TIMEOUT = 10;
-const int BUTTONSIZE = 10;
-
-Lirc::Lirc()
- : _sockname("/tmp/lircd"), _button(0)
-{
-// GNASH_REPORT_FUNCTION;
- _button = new char[BUTTONSIZE];
-}
-
-Lirc::~Lirc()
-{
-// GNASH_REPORT_FUNCTION;
- if (_button != 0) {
- delete _button;
- }
- closeNet();
-}
-
-bool
-Lirc::init()
-{
-// GNASH_REPORT_FUNCTION;
- return connectSocket(_sockname);
-}
-
-bool
-Lirc::init(const char *sockpath)
-{
-// GNASH_REPORT_FUNCTION;
- _connected = connectSocket(sockpath);
- return _connected;
-}
-
-// Whenever lircd receives a IR signal it will broadcast the
-// following string to each client:
-// <code> <repeat count> <button name> <remote control name>
-// 0000000000000003 1 PREV LIRCEMU
-// 0000000000000006 1 NEXT LIRCEMU
-// 0000000000000012 1 A LIRCEMU
-
-gnash::key::code
-Lirc::getKey()
-{
-// GNASH_REPORT_FUNCTION;
- key::code key;
-
- byte_t buf[LIRC_PACKET_SIZE];
- memset(buf, 0, LIRC_PACKET_SIZE);
-
- // read the data if there is any
- readNet(buf, LIRC_PACKET_SIZE, TIMEOUT);
-
- string packet = reinterpret_cast<char *>(buf);
- string::size_type space1 = packet.find(" ") +1;
- string::size_type space2 = packet.find(" ", space1) + 1;
- string::size_type space3 = packet.find(" ", space2) +1;
-
- string code_str = packet.substr(0, space1);
- string count_str = packet.substr(space1, space2-space1);
- string button_str = packet.substr(space2,space3-space2);
- string control_str = packet.substr(space3);
-
- if (button_str[0] > 'A' && button_str[0] < 'Z') {
- cerr << "Character: " << button_str << endl;
- key = (gnash::key::code)button_str[0];
- }
-
- return key;
-}
-
-const char *
-Lirc::getButton()
-{
-// GNASH_REPORT_FUNCTION;
-
- byte_t buf[LIRC_PACKET_SIZE];
- memset(buf, 0, LIRC_PACKET_SIZE);
-
- // read the data if there is any
- readNet(buf, LIRC_PACKET_SIZE, TIMEOUT);
-
- string packet = reinterpret_cast<char *>(buf);
- string::size_type space1 = packet.find(" ") + 1;
- string::size_type space2 = packet.find(" ", space1) + 1;
- string::size_type space3 = packet.find(" ", space2) + 1;
-
- string button_str = packet.substr(space2, space3-space2-1);
-
- memset(_button, 0, BUTTONSIZE);
- strncpy(_button, button_str.c_str(), BUTTONSIZE);
- return _button;
-}
-
-} // end of gnash namespace
-
-// Local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
Index: libbase/network.cpp
===================================================================
RCS file: libbase/network.cpp
diff -N libbase/network.cpp
--- libbase/network.cpp 25 Mar 2008 23:51:54 -0000 1.40
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,907 +0,0 @@
-//
-// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-//
-// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-#include "utility.h"
-#include "log.h"
-#include "network.h"
-
-#include <sys/types.h>
-#include <cstring>
-#include <cstdio>
-#include <cerrno>
-#include <fcntl.h>
-#if defined(HAVE_WINSOCK_H) && !defined(__OS2__)
-# include <winsock2.h>
-# include <windows.h>
-# include <sys/stat.h>
-# include <io.h>
-# include <ws2tcpip.h>
-#else
-# include <sys/time.h>
-# include <unistd.h>
-# include <sys/select.h>
-# include <netinet/in.h>
-# include <arpa/inet.h>
-# include <sys/socket.h>
-# include <sys/un.h>
-# include <netdb.h>
-# include <sys/param.h>
-# include <sys/select.h>
-#endif
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
-
-using namespace std;
-
-namespace gnash {
-
-static const char *DEFAULTPROTO = "tcp";
-static const short DEFAULTPORT = RTMP;
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-Network::Network()
- :
- _ipaddr(INADDR_ANY),
- _sockfd(0),
- _listenfd(0),
- _port(0),
- _connected(false),
- _debug(false),
- _timeout(0)
-{
-// GNASH_REPORT_FUNCTION;
-#if defined(HAVE_WINSOCK_H) && !defined(__OS2__)
- WORD wVersionRequested;
- WSADATA wsaData;
- wVersionRequested = MAKEWORD(1, 1); // Windows Sockets 1.1
- if (WSAStartup( wVersionRequested, &wsaData ) != 0) {
- log_error(_("Could not find a usable WinSock DLL"));
- exit(1);
- }
-#endif
-
-}
-
-Network::~Network()
-{
-// GNASH_REPORT_FUNCTION;
-#if defined(HAVE_WINSOCK_H) && !defined(__OS2__)
- WSACleanup();
-#else
- closeNet();
-#endif
-}
-
-// Description: Create a tcp/ip network server. This creates a server
-// that listens for incoming socket connections. This
-// supports IP aliasing on the host, and will sequntially
-// look for IP address to bind this port to.
-int
-Network::createServer(void)
-{
-// GNASH_REPORT_FUNCTION;
-
- return createServer(DEFAULTPORT);
-}
-
-// FIXME: Should also support IPv6 (AF_INET6)
-int
-Network::createServer(short port)
-{
- GNASH_REPORT_FUNCTION;
-
- struct protoent *ppe;
- struct sockaddr_in sock_in;
- int on, type;
- int retries = 0;
- in_addr_t nodeaddr;
-
-#if 0
- if (port < 1024) {
- log_error(_("Can't connect to privileged port #%d"), port);
- return -1;
- }
-#endif
-
- if (_listenfd >= 2) {
- log_debug("already connected to port %hd", port);
- return _listenfd;
- }
-
- const struct hostent *host = gethostbyname("localhost");
- struct in_addr *thisaddr = reinterpret_cast<struct in_addr
*>(host->h_addr_list[0]);
- _ipaddr = thisaddr->s_addr;
- memset(&sock_in, 0, sizeof(sock_in));
-
-#if 0
- // Accept incoming connections only on our IP number
- sock_in.sin_addr.s_addr = thisaddr->s_addr;
-#else
- // Accept incoming connections on any IP number
- sock_in.sin_addr.s_addr = INADDR_ANY;
-#endif
-
- _ipaddr = sock_in.sin_addr.s_addr;
- sock_in.sin_family = AF_INET;
- sock_in.sin_port = htons(port);
-
- if ((ppe = getprotobyname(DEFAULTPROTO)) == 0) {
- log_error(_("unable to get protocol entry for %s"),
- DEFAULTPROTO);
- return -1;
- }
-
- // set protocol type
- if ( strcmp(DEFAULTPROTO, "udp") == 0) {
- type = SOCK_DGRAM;
- } else {
- type = SOCK_STREAM;
- }
-
- // Get a file descriptor for this socket connection
- _listenfd = socket(PF_INET, type, ppe->p_proto);
-
- // error, wasn't able to create a socket
- if (_listenfd < 0) {
- log_error(_("unable to create socket: %s"), strerror(errno));
- return -1;
- }
-
- on = 1;
- if (setsockopt(_listenfd, SOL_SOCKET, SO_REUSEADDR,
- (char *)&on, sizeof(on)) < 0) {
- log_error(_("setsockopt SO_REUSEADDR failed"));
- return -1;
- }
-
- retries = 0;
-
- nodeaddr = inet_lnaof(*thisaddr);
- while (retries < 5) {
- if (bind(_listenfd, reinterpret_cast<struct sockaddr *>(&sock_in),
- sizeof(sock_in)) == -1) {
- log_error(_("unable to bind to port %hd: %s"),
- port, strerror(errno));
-// inet_ntoa(sock_in.sin_addr), strerror(errno));
- retries++;
- }
-
- if (_debug) {
-// char ascip[INET_ADDRSTRLEN];
-// inet_ntop(sock_in.sin_family, &_ipaddr, ascip, INET_ADDRSTRLEN);
- char *ascip = ::inet_ntoa(sock_in.sin_addr);
- log_debug(_("Server bound to service on %s, port %hd, using fd
#%d"),
- ascip, ntohs(sock_in.sin_port),
- _listenfd);
- }
-
- if (type == SOCK_STREAM && listen(_listenfd, 5) < 0) {
- log_error(_("unable to listen on port: %hd: %s "),
- port, strerror(errno));
- return -1;
- }
-
- // We have a socket created
- _port = port;
- return _listenfd;
- }
- return -1;
-}
-
-// Description: Accept a new network connection for the port we have
-// created a server for.
-// The default is to block.
-int
-Network::newConnection(void)
-{
-// GNASH_REPORT_FUNCTION;
-
- return newConnection(true, _listenfd);
-}
-
-int
-Network::newConnection(int fd)
-{
-// GNASH_REPORT_FUNCTION;
-
- return newConnection(true, fd);
-}
-
-int
-Network::newConnection(bool block)
-{
-// GNASH_REPORT_FUNCTION;
-
- return newConnection(block, _listenfd);
-}
-
-int
-Network::newConnection(bool block, int fd)
-{
- GNASH_REPORT_FUNCTION;
-
- struct sockaddr newfsin;
- socklen_t alen;
- int ret;
- struct timeval tval;
- fd_set fdset;
- int retries = 3;
-
- alen = sizeof(struct sockaddr_in);
-
- if (fd <= 2) {
- return -1;
- }
- if (_debug) {
- log_debug(_("Trying to accept net traffic on fd #%d"),
- fd);
- }
-
- while (retries--) {
- // We use select to wait for the read file descriptor to be
- // active, which means there is a client waiting to connect.
- FD_ZERO(&fdset);
- // also return on any input from stdin
-// if (_console) {
-// FD_SET(fileno(stdin), &fdset);
-// }
- FD_SET(fd, &fdset);
-
- // Reset the timeout value, since select modifies it on return. To
- // block, set the timeout to zero.
- tval.tv_sec = 1;
- tval.tv_usec = 0;
-
- if (block) {
- ret = select(fd+1, &fdset, NULL, NULL, NULL);
- } else {
- ret = select(fd+1, &fdset, NULL, NULL, &tval);
- }
-
- if (FD_ISSET(0, &fdset)) {
- if (_debug) {
- log_debug(_("There is data at the console for stdin"));
- }
- return 1;
- }
-
- // If interupted by a system call, try again
- if (ret == -1 && errno == EINTR) {
- log_debug(_("The accept() socket for fd #%d was interupted by a
system call"), fd);
- }
-
- if (ret == -1) {
- log_debug(_("The accept() socket for fd #%d never was available
for writing"),
- fd);
- return -1;
- }
-
- if (ret == 0) {
- if (_debug) {
- log_debug(_("The accept() socket for fd #%d timed out waiting
to write"),
- fd);
- }
- }
- }
-
-#ifndef HAVE_WINSOCK_H
- fcntl(_listenfd, F_SETFL, O_NONBLOCK); // Don't let accept() block
-#endif
- _sockfd = accept(fd, &newfsin, &alen);
-
- if (_sockfd < 0) {
- log_error(_("unable to accept: %s"), strerror(errno));
- return -1;
- }
-
- if (_debug) {
- log_debug(_("Accepting tcp/ip connection on fd #%d"), _sockfd);
- }
-
- return _sockfd;
-}
-
-#ifdef _WIN32
-/* from sys/socket.h */
-typedef unsigned short sa_family_t;
-
-/* from sys/un.h */
-#define UNIX_PATH_MAX 108
-
-struct sockaddr_un {
- sa_family_t sun_family; /* AF_UNIX */
- char sun_path[UNIX_PATH_MAX]; /* pathname */
-};
-
-#endif /* _WIN32 */
-
-// Connect to a named pipe
-bool
-Network::connectSocket(const string &sockname)
-{
-// GNASH_REPORT_FUNCTION;
-
- struct sockaddr_un addr;
- fd_set fdset;
- struct timeval tval;
- int ret;
- int retries;
-
- addr.sun_family = AF_UNIX;
- // socket names must be 108 bytes or less as specifiec in sys/un.h.
- strncpy(addr.sun_path, sockname.c_str(), 100);
-
- _sockfd = ::socket(AF_UNIX, SOCK_STREAM, 0);
- if (_sockfd < 0)
- {
- log_error(_("unable to create socket: %s"), strerror(errno));
- _sockfd = -1;
- return false;
- }
-
- retries = 2;
- while (retries-- > 0) {
- // We use select to wait for the read file descriptor to be
- // active, which means there is a client waiting to connect.
- FD_ZERO(&fdset);
- FD_SET(_sockfd, &fdset);
-
- // Reset the timeout value, since select modifies it on return. To
- // block, set the timeout to zero.
- tval.tv_sec = 5;
- tval.tv_usec = 0;
-
- ret = ::select(_sockfd+1, &fdset, NULL, NULL, &tval);
-
- // If interupted by a system call, try again
- if (ret == -1 && errno == EINTR)
- {
- log_debug(_("The connect() socket for fd %d was interupted by
a system call"),
- _sockfd);
- continue;
- }
-
- if (ret == -1)
- {
- log_debug(_("The connect() socket for fd %d never was
available for writing"),
- _sockfd);
-#ifdef HAVE_WINSOCK_H
- ::shutdown(_sockfd, 0); // FIXME: was SHUT_BOTH
-#else
- ::shutdown(_sockfd, SHUT_RDWR);
-#endif
- _sockfd = -1;
- return false;
- }
- if (ret == 0) {
- log_error(_("The connect() socket for fd %d timed out waiting to
write"),
- _sockfd);
- continue;
- }
-
- if (ret > 0) {
- ret = ::connect(_sockfd, reinterpret_cast<struct sockaddr
*>(&addr), sizeof(addr));
- if (ret == 0) {
- log_debug(_("\tsocket name %s for fd %d"), sockname, _sockfd);
- _connected = true;
- assert(_sockfd > 0);
- return true;
- }
- if (ret == -1) {
- log_error(_("The connect() socket for fd %d never was
available for writing"),
- _sockfd);
- _sockfd = -1;
- assert(!_connected);
- return false;
- }
- }
- }
-
-
-#ifndef HAVE_WINSOCK_H
- fcntl(_sockfd, F_SETFL, O_NONBLOCK);
-#endif
-
- _connected = true;
- assert(_sockfd > 0);
- return true;
-}
-
-// Create a client connection to a tcp/ip based service
-bool
-Network::createClient(void)
-{
-// GNASH_REPORT_FUNCTION;
-
- return createClient("localhost", RTMP);
-}
-bool
-Network::createClient(short /* port */)
-{
-// GNASH_REPORT_FUNCTION;
-
- return false;
-}
-
-bool
-Network::createClient(const string &hostname)
-{
-// GNASH_REPORT_FUNCTION;
-
- return createClient(hostname, RTMP);
-}
-
-bool
-Network::createClient(const string &hostname, short port)
-{
- GNASH_REPORT_FUNCTION;
-
- struct sockaddr_in sock_in;
- fd_set fdset;
- struct timeval tval;
- int ret;
- int retries;
- char thishostname[MAXHOSTNAMELEN];
- struct protoent *proto;
-
- assert( ! connected() );
-
- if (port < 1024) {
- log_error(_("Can't connect to privileged port %hd"), port);
- _connected = false;
- return false;
- }
-
- log_debug(_("%s: to host %s at port %d"), __FUNCTION__, hostname, port);
-
- memset(&sock_in, 0, sizeof(struct sockaddr_in));
- memset(&thishostname, 0, MAXHOSTNAMELEN);
- if (hostname.size() == 0) {
- if (gethostname(thishostname, MAXHOSTNAMELEN) == 0) {
- log_debug(_("The hostname for this machine is %s"), thishostname);
- } else {
- log_debug(_("Couldn't get the hostname for this machine"));
- return false;
- }
- }
- const struct hostent *hent = ::gethostbyname(hostname.c_str());
- if (hent > 0) {
- ::memcpy(&sock_in.sin_addr, hent->h_addr, hent->h_length);
- }
- sock_in.sin_family = AF_INET;
- sock_in.sin_port = ntohs(static_cast<short>(port));
-
-#if 0
- char ascip[INET_ADDRSTRLEN];
- inet_ntop(sock_in.sin_family, &sock_in.sin_addr.s_addr, ascip,
INET_ADDRSTRLEN);
- log_debug(_("The IP address for this client socket is %s"), ascip);
-#endif
-
- proto = ::getprotobyname("TCP");
-
- _sockfd = ::socket(PF_INET, SOCK_STREAM, proto->p_proto);
- if (_sockfd < 0)
- {
- log_error(_("unable to create socket: %s"), strerror(errno));
- _sockfd = -1;
- return false;
- }
-
- retries = 2;
- while (retries-- > 0) {
- // We use select to wait for the read file descriptor to be
- // active, which means there is a client waiting to connect.
- FD_ZERO(&fdset);
- FD_SET(_sockfd, &fdset);
-
- // Reset the timeout value, since select modifies it on return. To
- // block, set the timeout to zero.
- tval.tv_sec = 5;
- tval.tv_usec = 0;
-
- ret = ::select(_sockfd+1, &fdset, NULL, NULL, &tval);
-
- // If interupted by a system call, try again
- if (ret == -1 && errno == EINTR)
- {
- log_debug(_("The connect() socket for fd %d was interupted by
a system call"),
- _sockfd);
- continue;
- }
-
- if (ret == -1)
- {
- log_debug(_("The connect() socket for fd %d never was
available for writing"),
- _sockfd);
-#ifdef HAVE_WINSOCK_H
- ::shutdown(_sockfd, 0); // FIXME: was SHUT_BOTH
-#else
- ::shutdown(_sockfd, SHUT_RDWR);
-#endif
- _sockfd = -1;
- return false;
- }
- if (ret == 0) {
- log_error(_("The connect() socket for fd %d timed out waiting to
write"),
- _sockfd);
- continue;
- }
-
- if (ret > 0) {
- ret = ::connect(_sockfd, reinterpret_cast<struct sockaddr
*>(&sock_in), sizeof(sock_in));
- if (ret == 0) {
- char *ascip = ::inet_ntoa(sock_in.sin_addr);
-// char ascip[INET_ADDRSTRLEN];
-// inet_ntop(sock_in.sin_family, &sock_in.sin_addr.s_addr, ascip,
INET_ADDRSTRLEN);
- log_debug(_("\tport %d at IP %s for fd %d"), port,
- ascip, _sockfd);
- _connected = true;
- assert(_sockfd > 0);
- return true;
- }
- if (ret == -1) {
- log_error(_("The connect() socket for fd %d never was
available for writing"),
- _sockfd);
- _sockfd = -1;
- assert(!_connected);
- return false;
- }
- }
- }
- // ::close(_sockfd);
- // return false;
-
- printf("\tConnected at port %d on IP %s for fd #%d", port,
- ::inet_ntoa(sock_in.sin_addr), _sockfd);
-
-#ifndef HAVE_WINSOCK_H
- fcntl(_sockfd, F_SETFL, O_NONBLOCK);
-#endif
-
- _connected = true;
- assert(_sockfd > 0);
- return true;
-}
-
-bool
-Network::closeNet()
-{
- GNASH_REPORT_FUNCTION;
-
- if ((_sockfd > 0) && (_connected)) {
- closeNet(_sockfd);
- _sockfd = 0;
- _connected = false;
- }
-
- return false;
-}
-
-bool
-Network::closeNet(int sockfd)
-{
- GNASH_REPORT_FUNCTION;
-
- int retries = 0;
-
- // If we can't close the socket, other processes must be
- // locked on it, so we wait a second, and try again. After a
- // few tries, we give up, cause there must be something
- // wrong.
-
- if (sockfd <= 0) {
- return true;
- }
-
- while (retries < 3) {
- if (sockfd) {
- // Shutdown the socket connection
-#if 0
- if (shutdown(sockfd, SHUT_RDWR) < 0) {
- if (errno != ENOTCONN) {
- cerr << "WARNING: Unable to shutdown socket for fd #"
- << sockfd << strerror(errno) << endl;
- } else {
- cerr << "The socket using fd #" << sockfd
- << " has been shut down successfully." << endl;
- return true;
- }
- }
-#endif
- if (::close(sockfd) < 0) {
- // If we have a bad file descriptor, it's because
- // this got closed already, usually by another
- // thread being paranoid.
- if (errno != EBADF) {
- log_error(_("Unable to close the socket for fd #%d: %s"),
- sockfd, strerror(errno));
- }
-#ifndef HAVE_WINSOCK_H
- sleep(1);
-#endif
- retries++;
- } else {
- log_debug(_("Closed the socket on fd #%d"), sockfd);
- return true;
- }
- }
- }
- return false;
-}
-// Description: Close an open socket connection.
-bool
-Network::closeConnection(void)
-{
-// GNASH_REPORT_FUNCTION;
-
- closeConnection(_sockfd);
- _sockfd = 0;
- closeConnection(_listenfd);
- _listenfd = 0;
- _connected = false;
-
- return false;
-}
-
-bool
-Network::closeConnection(int fd)
-{
- GNASH_REPORT_FUNCTION;
-
- if (fd > 0) {
- ::close(fd);
- log_debug("%s: Closed fd #%d", __FUNCTION__, fd);
-// closeNet(fd);
- }
-
- return false;
-}
-
-// Read from the connection
-int
-Network::readNet(byte_t *buffer, int nbytes)
-{
- return readNet(_sockfd, buffer, nbytes, _timeout);
-}
-
-int
-Network::readNet(byte_t *buffer, int nbytes, int timeout)
-{
- return readNet(_sockfd, buffer, nbytes, timeout);
-}
-
-int
-Network::readNet(int fd, byte_t *buffer, int nbytes)
-{
- return readNet(fd, buffer, nbytes, _timeout);
-}
-
-int
-Network::readNet(int fd, byte_t *buffer, int nbytes, int timeout)
-{
- fd_set fdset;
- int ret = -1;
- struct timeval tval;
-
-#ifdef NET_TIMING
- if (_timing_debug)
- {
- gettimeofday(&tp, NULL);
- read_start_time = static_cast<double>(tp.tv_sec)
- + static_cast<double>(tp.tv_usec*1e-6);
- }
-#endif
- if (fd > 2) {
- FD_ZERO(&fdset);
- FD_SET(fd, &fdset);
-
- if (timeout == 0) {
- ret = select(fd+1, &fdset, NULL, NULL, NULL);
- } else {
- tval.tv_sec = timeout;
- tval.tv_usec = 0;
- ret = select(fd+1, &fdset, NULL, NULL, &tval);
- }
-
- // If interupted by a system call, try again
- if (ret == -1 && errno == EINTR) {
- log_error (_("The socket for fd %d was interupted by a system
call"), fd);
- }
-
- if (ret == -1) {
- log_error (_("The socket for fd %d was never available for
reading"), fd);
- return -1;
- }
-
- if (ret == 0) {
- log_debug (_("The socket for fd %d timed out waiting to read"),
fd);
- return 0;
- }
-
- ret = read(fd, buffer, nbytes);
- if (_debug) {
- log_debug (_("read %d bytes from fd %d"), ret, fd);
- }
-#if 0
- if (ret) {
- log_debug (_("%s: Read packet data from fd %d (%d bytes): \n%s"),
- __FUNCTION__, fd, ret, hexify(buffer, ret, true));
- }
-#endif
- }
-
- return ret;
-
-}
-
-// Write to the connection
-int
-Network::writeNet(const std::string& buffer)
-{
- return writeNet(reinterpret_cast<const byte_t *>(buffer.c_str()),
buffer.size());
-}
-
-int
-Network::writeNet(const byte_t *buffer, int nbytes)
-{
- return writeNet(_sockfd, buffer, nbytes, _timeout);
-}
-
-// int
-// Network::writeNet(const byte_t *buffer, int nbytes)
-// {
-// return writeNet(_sockfd, buffer, nbytes, _timeout);
-// }
-
-// int
-// Network::writeNet(int fd, const byte_t *buffer)
-// {
-// return writeNet(fd, buffer, strlen(buffer), _timeout);
-// }
-
-int
-Network::writeNet(int fd, const byte_t *buffer, int nbytes)
-{
- return writeNet(fd, buffer, nbytes, _timeout);
-}
-
-int
-Network::writeNet(int fd, const byte_t *buffer, int nbytes, int timeout)
-{
- fd_set fdset;
- int ret = -1;
- struct timeval tval;
-
- // We need a writable, and not const point for byte arithmetic.
- byte_t *bufptr = const_cast<byte_t *>(buffer);
-
-#ifdef NET_TIMING
- // If we are debugging the tcp/ip timings, get the initial time.
- if (_timing_debug)
- {
- gettimeofday(&starttime, 0);
- }
-#endif
- if (fd > 2) {
- FD_ZERO(&fdset);
- FD_SET(fd, &fdset);
-
- // Reset the timeout value, since select modifies it on return
- if (timeout <= 0) {
- timeout = 5;
- }
- tval.tv_sec = timeout;
- tval.tv_usec = 0;
- ret = select(fd+1, NULL, &fdset, NULL, &tval);
-
- // If interupted by a system call, try again
- if (ret == -1 && errno == EINTR) {
- log_error (_("The socket for fd %d was interupted by a system
call"), fd);
- }
-
- if (ret == -1) {
- log_error (_("The socket for fd %d was never available for
writing"), fd);
- }
-
- if (ret == 0) {
- log_debug (_("The socket for fd %d timed out waiting to write"),
fd);
- return 0;
- }
-
- ret = write(fd, bufptr, nbytes);
-
- if (ret == 0) {
- log_error (_("Wrote zero out of %d bytes to fd %d: %s"),
- nbytes, fd, strerror(errno));
- return ret;
- }
- if (ret < 0) {
- log_error (_("Couldn't write %d bytes to fd %d: %s"),
- nbytes, fd, strerror(errno));
- return ret;
- }
- if (ret > 0) {
- bufptr += ret;
- if (ret != nbytes) {
- if (_debug) {
- log_debug (_("wrote %d bytes to fd %d, expected %d"),
- ret, fd, nbytes);
- }
- } else {
- if (_debug) {
- log_debug (_("wrote %d bytes to fd %d"),
- ret, fd);
- }
-// return ret;
- }
- }
-#if 0
- if (ret) {
- log_debug (_("%s: Wrote packet data to fd %d: \n%s"),
- __FUNCTION__, fd, hexify(buffer, ret, true));
- }
-#endif
- }
-
-#ifdef NET_TIMING
- if (_timing_debug)
- {
- gettimeofday(&endtime, 0);
-
- if ((endtime.tv_sec - starttime.tv_sec) &&
- endtime.tv_usec - starttime.tv_usec)
- {
- log_debug (_("took %d usec to write (%d bytes)"),
- endtime.tv_usec - starttime.tv_usec, bytes_written);
- }
- }
-#endif
-
-
- return ret;
-}
-
-void
-Network::toggleDebug(bool val)
-{
- // Turn on our own debugging
- _debug = val;
-
- // Turn on debugging for the utility methods
- // recursive on all control paths,
- // function will cause runtime stack overflow
-
- // toggleDebug(true);
-}
-
-
-} // end of gnash namespace
-
-// Local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
Index: libbase/network.h
===================================================================
RCS file: libbase/network.h
diff -N libbase/network.h
--- libbase/network.h 25 Mar 2008 23:51:54 -0000 1.26
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,159 +0,0 @@
-//
-// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-//
-// 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-#ifndef __NETWORK_H__
-#define __NETWORK_H__
-
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-#if !defined(HAVE_WINSOCK_H) || defined(__OS2__)
-# include <netinet/in.h>
-# include <arpa/inet.h>
-#else
-# include <winsock2.h>
-# include <windows.h>
-# include <fcntl.h>
-# include <sys/stat.h>
-# include <io.h>
-#endif
-
-#include "dsodefs.h" //For DSOEXPORT.
-#include <boost/cstdint.hpp>
-#include <cassert>
-#include <string>
-
-namespace gnash {
-
-// Define the ports for the RTMP protocols
-const short ADMIN = 1111;
-const short RTMP = 1935;
-const short RTMPT = 80;
-const short RTMPTS = 443;
-
-#ifdef __OS2__
- typedef int socklen_t;
- #define SHUT_RDWR 0x2
-#endif
-
-#if defined(HAVE_WINSOCK_H) && !defined(__OS2__)
- typedef long in_addr_t;
-# define inet_lnaof(x) inet_addr(inet_ntoa(x))
- typedef int socklen_t;
-#endif
-
-// Adjust for the constant size
-const size_t NETBUFSIZE = 1024;
-
-class Network {
-public:
- typedef boost::uint8_t byte_t;
-
- DSOEXPORT Network();
- DSOEXPORT ~Network();
-
- // Create a new server. After creating it, then you have to wait
- // for an incoming connection.
- int createServer(void);
- DSOEXPORT int createServer(short port);
-
- // Accept a client connection for the current server.
- int newConnection(void);
- int newConnection(int fd);
- int newConnection(bool block, int fd);
- DSOEXPORT int newConnection(bool block);
-
- // Connect to a named pipe
- bool connectSocket(const std::string &sock);
-
- // Create a client connection to a tcp/ip server
- bool createClient(void);
- bool createClient(short port);
- bool createClient(const std::string &hostname);
- DSOEXPORT bool createClient(const std::string &hostname, short port);
-
- // Read from the connection
- int readNet(byte_t *buffer, int nbytes);
- DSOEXPORT int readNet(byte_t *buffer, int nbytes, int timeout);
- int readNet(int fd, byte_t *buffer, int nbytes);
- int readNet(int fd, byte_t *buffer, int nbytes, int timeout);
-
- // Write to the connection
- int writeNet(const std::string &buffer);
- DSOEXPORT int writeNet(const byte_t *buffer, int nbytes);
-// int writeNet(int fd, const byte_t *buffer);
- int writeNet(int fd, const byte_t *buffer, int nbytes);
- int writeNet(int fd, const byte_t *buffer, int nbytes, int timeout);
-
- // Close the connection
- DSOEXPORT bool closeNet();
- bool closeNet(int fd);
- DSOEXPORT bool closeConnection();
- bool closeConnection(int fd);
-
- // Change the debug flag
- void toggleDebug(bool val);
-
- bool send(const char *str);
-
- // Accessors for testing
- bool connected()
- {
- assert ( ( _connected && _sockfd > 0 ) || ( ! _connected && _sockfd <=
0 ) );
- return _connected;
- };
-
- void setFileFd(int x) { _sockfd = x; };
- int getFileFd() const { return _sockfd; };
- int getListenFd() const { return _listenfd; };
- void setListenFd(int x) { _listenfd = x; };
- short getPort() const { return _port; };
- const std::string& getURL() const { return _url; }
- const std::string& getProtocol() const { return _protocol; }
- const std::string& getHost() const { return _host; }
- const std::string& getPortStr() const { return _portstr; }
- const std::string& getPath() const { return _path; }
- int getTimeout() const { return _timeout; }
-
- // Network is not copiable !
- //Network &operator = (Network &net) {}
-
- protected:
- in_addr_t _ipaddr;
- int _sockfd; // the file descriptor used for reading and
writing
- int _listenfd; // the file descriptor used to listen for new
connections
- short _port;
- std::string _portstr;
- std::string _url;
- std::string _protocol;
- std::string _host;
- std::string _path;
- bool _connected;
- bool _debug;
- int _timeout;
-};
-
-} // end of gnash namespace
-
-// __NETWORK_H__
-#endif
-
-// Local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash Makefile.am configure.ac ChangeLog libbas...,
Rob Savoye <=