gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash/cygnal ChangeLog Makefile.am cygnal.cpp A...


From: Rob Savoye
Subject: [Gnash-commit] gnash/cygnal ChangeLog Makefile.am cygnal.cpp A...
Date: Fri, 28 Mar 2008 21:47:47 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    08/03/28 21:47:47

Modified files:
        cygnal         : ChangeLog Makefile.am cygnal.cpp 
Removed files:
        cygnal         : Aspect.hpp buffer.cpp buffer.h cque.cpp cque.h 
                         handler.cpp handler.h http.cpp http.h 
                         netstats.cpp netstats.h statistics.cpp 
                         statistics.h 

Log message:
                * Makefile.am: Don't build libcygnal anymore, it's been made
                gnash/libnet, so it's code can be shared with Gnash for the 
client
                side of all protocols.
                * cygnal.cpp: Add -n option to turn on network debugging. Remove
                unused code. Move rtmp handler to libnet/rtmp.cpp.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/ChangeLog?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/Makefile.am?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/cygnal.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/Aspect.hpp?cvsroot=gnash&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/buffer.cpp?cvsroot=gnash&r1=1.7&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/buffer.h?cvsroot=gnash&r1=1.5&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/cque.cpp?cvsroot=gnash&r1=1.6&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/cque.h?cvsroot=gnash&r1=1.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/handler.cpp?cvsroot=gnash&r1=1.8&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/handler.h?cvsroot=gnash&r1=1.5&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.cpp?cvsroot=gnash&r1=1.26&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.h?cvsroot=gnash&r1=1.20&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/netstats.cpp?cvsroot=gnash&r1=1.11&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/netstats.h?cvsroot=gnash&r1=1.7&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/statistics.cpp?cvsroot=gnash&r1=1.8&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/statistics.h?cvsroot=gnash&r1=1.8&r2=0

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/cygnal/ChangeLog,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- ChangeLog   26 Mar 2008 00:02:02 -0000      1.15
+++ ChangeLog   28 Mar 2008 21:47:44 -0000      1.16
@@ -1,3 +1,12 @@
+2008-03-28  Rob Savoye  <address@hidden>
+
+       * Makefile.am: Don't build libcygnal anymore, it's been made
+       gnash/libnet, so it's code can be shared with Gnash for the client
+       side of all protocols.
+       * cygnal.cpp: Add -n option to turn on network debugging. Remove
+       unused code. Move rtmp handler to libnet/rtmp.cpp.
+
+
 2008-03-25  Rob Savoye  <address@hidden>
 
        * buffer.{h,cpp}: Use more fime grained ifdef for statistics

Index: Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/cygnal/Makefile.am,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- Makefile.am 17 Mar 2008 00:09:17 -0000      1.13
+++ Makefile.am 28 Mar 2008 21:47:44 -0000      1.14
@@ -33,11 +33,10 @@
 
 AM_CPPFLAGS = # -Wall
 
-## WARNING: make sure GLIB_LIBS appears first
-## See: http://lists.gnu.org/archive/html/gnash-dev/2006-07/msg00076.html
 AM_LDFLAGS = \
        ../libbase/libgnashbase.la \
        ../server/libgnashserver.la \
+       ../libnet/libgnashnet.la \
        ../libamf/libgnashamf.la \
        $(LIBLTDL) \
        $(GLIB_LIBS) \
@@ -50,6 +49,7 @@
 
 INCLUDES = -I.. \
         -I$(top_srcdir)        \
+        -I$(top_srcdir)/libnet \
         -I$(top_srcdir)/libamf \
         -I$(top_srcdir)/libbase \
         -I$(top_srcdir)/server \
@@ -60,38 +60,16 @@
        $(BOOST_CFLAGS) \
        $(PTHREAD_CFLAGS)
 
-noinst_LTLIBRARIES = libcygnal.la
-
-libcygnal_la_LIBADD = $(AM_LDFLAGS)
+# noinst_LTLIBRARIES = libcygnal.la
+# libcygnal_la_LIBADD = $(AM_LDFLAGS)
 
 noinst_HEADERS = \
-       buffer.h \
-       cque.h \
-       handler.h \
-       http.h \
-       netstats.h \
-       stream.h \
-       statistics.h \
        crc.h
-#      transcode.h
-#      flash.h
-
-
-libcygnal_la_SOURCES = \
-       buffer.cpp \
-       cque.cpp \
-       handler.cpp \
-       http.cpp \
-       alloc.cpp \
-       netstats.cpp \
-       stream.cpp \
-       statistics.cpp \
-       crc.cpp
 
 bin_PROGRAMS = cygnal
 
-cygnal_SOURCES = cygnal.cpp
-cygnal_LDADD = $(AM_LDFLAGS) libcygnal.la
+cygnal_SOURCES = cygnal.cpp crc.cpp
+cygnal_LDADD = $(AM_LDFLAGS)
 
 # Rebuild with GCC 4.x Mudflap support
 mudflap:

Index: cygnal.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/cygnal.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- cygnal.cpp  26 Mar 2008 00:02:02 -0000      1.29
+++ cygnal.cpp  28 Mar 2008 21:47:45 -0000      1.30
@@ -55,7 +55,7 @@
 #include "limits.h"
 #include "netstats.h"
 #include "statistics.h"
-#include "stream.h"
+//#include "stream.h"
 #include "gmemory.h"
 #include "arg_parser.h"
 
@@ -92,6 +92,9 @@
 // The rcfile is loaded and parsed here:
 CRcInitFile& crcfile = CRcInitFile::getDefaultInstance();
 
+// Toggles very verbose debugging info from the network Network class
+static bool netdebug = false;
+
 static struct sigaction  act;
 
 // The next few global variables have to be global because Boost
@@ -111,8 +114,8 @@
 static int port_offset = 0;
 
 // Keep a list of all active network connections
-namespace cygnal {
-  map<int, Handler *> handlers;
+namespace gnash {
+extern map<int, Handler *> handlers;
 }
 
 // Admin commands are small
@@ -136,7 +139,8 @@
         { 'V', "version",       Arg_parser::no  },
         { 'p', "port-offset",   Arg_parser::yes },
         { 'v', "verbose",       Arg_parser::no  },
-        { 'd', "dump",          Arg_parser::no  }
+        { 'd', "dump",          Arg_parser::no  },
+        { 'n', "netdebug",      Arg_parser::no  }
         };
 
     Arg_parser parser(argc, argv, opts);
@@ -184,6 +188,9 @@
              port_offset = parser.argument<int>(i);
              crcfile.setPortOffset(port_offset);
              break;
+         case 'n':
+             netdebug = true;
+             break;
          case 'd':
              crcfile.dump();
              exit(0);
@@ -210,76 +217,37 @@
 #endif
 
 #if 1
-    // Incomming connection handler
-    Handler::thread_params_t conn_data;
-    conn_data.port = port_offset + gnash::RTMPT;
-    conn_data.filespec = docroot;
-//    conn_data.handle = &handlers;
-    boost::thread conn_handler(boost::bind(&connection_handler, &conn_data));
-#endif
-    
-#if 0
-    int retries = 10;
-    // Run forever
-    while (retries > 0) {
+    // Incomming connection handler for port 80, HTTP and RTMPT. As port 80 
requires
+    // root access, cygnal supports a "port offset" for debugging and 
development of
+    // the server. Since this port offset changes the constant to test for 
which protocol,
+    // we pass the info to the start thread so it knows which handler to 
invoke.
        Handler::thread_params_t http_data;
-       http_data.netfd = 0;
        http_data.port = port_offset + gnash::RTMPT;
+    http_data.netfd = 0;
        http_data.filespec = docroot;
-       Handler *hand = new Handler;
-       http_data.handle = &hand;
-       cerr << "Adding handler: " << (void *)hand << endl;
-       handlers.push_back(hand);
-       hand->createServer(http_data.port);
-       hand->start(&http_data);
-       cerr << "Removing handler: " << (void *)hand << endl;
-       handlers.remove(hand);
-       delete hand;
-    }
+    boost::thread http_thread(boost::bind(&connection_handler, &http_data));
+#endif
+    
+#if 1
+    // Incomming connection handler for port 1935, RTMP. As RTMP is not a 
priviledged port,
+    // we just open it without an offset.
+    Handler::thread_params_t rtmp_data;
+    rtmp_data.port = gnash::RTMP;
+    rtmp_data.netfd = 0;
+    rtmp_data.filespec = docroot;
+    boost::thread rtmp_thread(boost::bind(&connection_handler, &rtmp_data));
 #endif
     
     // wait for the thread to finish
 //    adminhandler.join();    
-    conn_handler.join();    
-    log_debug (_("All done I think..."));
+//     http_thread.join();
+    rtmp_thread.join();
+    log_debug (_("Cygnal done..."));
     
     return(0);
 }
 
 #if 0
-static void
-rtmp_thread(struct thread_params *conndata)
-{
-    GNASH_REPORT_FUNCTION;
-    int retries = 0;
-    RTMPproto proto;
-    
-    Statistics st;
-    st.setFileType(NetStats::RTMP);
-
-    log_debug("Param port is: %d", conndata->port);
-    
-    proto.createServer(RTMP);
-    while (retries++ < thread_retries) {
-       log_debug(_("%s: Thread for RTMP port looping..."), 
__PRETTY_FUNCTION__);
-       proto.newConnection(true);
-       st.startClock();
-       proto.handShakeWait();
-       proto.handShakeResponse();
-       proto.serverFinish();
-       
-       // Keep track of the network statistics
-       st.stopClock();
-       log_debug (_("Bytes read: %d"), proto.getBytesIn());
-       log_debug (_("Bytes written: %d"), proto.getBytesOut());
-       st.setBytes(proto.getBytesIn() + proto.getBytesOut());
-       st.addStats();
-       proto.resetBytesIn();
-       proto.resetBytesOut();  
-
-       st.dump();
-    }    
-}
 
 static void
 ssl_thread(struct thread_params *conndata)
@@ -309,24 +277,6 @@
 }
 #endif
 
-#if 0
-static void
-stream_thread(struct thread_params *params)
-{
-    GNASH_REPORT_FUNCTION;
-    
-    //struct stat stats;
-    //struct thread_params loadfile;
-    
-    log_debug ("%s: %s", __PRETTY_FUNCTION__, params->filespec);
-    
-    Stream str;
-    str.open(params->filespec, params->netfd);
-    str.play();
-//    ::close(params->netfd);
-}
-#endif
-
 // Trap Control-C so we can cleanly exit
 static void
 cntrlc_handler (int /*sig*/)
@@ -478,31 +428,25 @@
     int fd = 0;
 //    list<Handler *> *handlers = reinterpret_cast<list<Handler *> 
*>(args->handle);
 
+    log_debug("Starting Connection Handler for fd #%d, port %hd", args->netfd, 
args->port);
     Network net;
-//     net.toggleDebug(true);
+    if (netdebug) {
+       net.toggleDebug(true);
+    }
     fd = net.createServer(args->port);
-    // Run forever
+    // FIXME: this runs forever, we probably want a cleaner way to test for 
the end of time.
     do {
        Handler *hand = new Handler;
-       hand->toggleDebug(true); // FIXME: too verbose
+       hand->setPort(args->port);
+       if (netdebug) {
+           hand->toggleDebug(true);
+       }
        args->netfd = hand->newConnection(true, fd);
        args->handle = hand;
-       log_debug("Adding handler: %x for fd #%d",
-                 (void *)hand, args->netfd);
-#if 0
-       map<int, Handler *>::iterator hit = handlers.find(args->netfd);
-       if ((*hit).second) {
-           log_debug("Removing handle %x for fd #%d: ",
-                     (void *)hand), args->netfd;
-           handlers.erase(args->netfd);
-       }
-#endif
+       log_debug("Adding handler: %x for fd #%d", (void *)hand, args->netfd);
        handlers[args->netfd] = hand;
        hand->start(args);
-
-//     handlers.remove(hand);
-//     delete hand;
-       log_debug("Restarting loop...");
+       log_debug("Restarting loop for next connection for port %d...", 
args->port);
     } while(1);
 } // end of connection_handler
 

Index: Aspect.hpp
===================================================================
RCS file: Aspect.hpp
diff -N Aspect.hpp
--- Aspect.hpp  3 Oct 2007 15:29:16 -0000       1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,135 +0,0 @@
-// 
-// Copyright (C) 2007 Free Software Foundation, Inc.
-//
-// This file is part of GNU Cygnal.
-// 
-// 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
-//
-
-/**    \file Aspect.hpp
- *     \brief An aspect is a hook for augmenting the behavior of a class at 
compile time.
- */
-
-#pragma once
-#ifndef __Aspect_hpp___
-#define __Aspect_hpp___
-
-namespace aspect {
-
-       //--------------------------------------------------
-       // Base null aspect classes for specialization
-
-       /// Base Null_Aspect class for class that would otherwise be ordinary 
classes (no template)
-       template< class Owner >
-       class Null_Aspect_0 
-       {} ;
-
-       /// Base Null_Aspect class for class that would otherwise have a single 
template parameter
-       template< class T, class Owner >
-       class Null_Aspect_1
-       {} ;
-
-       /// Base Null_Aspect class for class that would otherwise have two 
template parameters
-       template< class T1, class T2, class Owner >
-       class Null_Aspect_2
-       {} ;
-
-       //--------------------------------------------------
-       /**     \class Null_Aspect_Base
-        *
-        *      Specializations of null aspect templates, required to create 
hook points, do not inherit from their generic template.
-        *      This class provides such a base.
-        *      In order that null templates may derive from it, it does not 
define any data.
-        *
-        *      This base is needed to provide a null definition of the hooks 
provided by other add-in classes within this module.
-        *      The first one of these is \c set_owner(), needed for an aspect 
to gain access its owner's internal data.
-        *      When other add-ins are defined, put a null function definition 
here for each function in the add-in.
-        */
-       template< class Owner >
-       class Null_Aspect_Base
-       {
-       public:
-               /// The owner type is the class of which this class is an 
aspect.
-               typedef Owner owner_type ;
-
-               /// For the null aspect set_owner does nothing.
-               inline void set_owner( Owner * ) {}
-       } ;
-
-       //--------------------------------------------------
-       /** \class Aspect_Has_Access_To_Owner
-        *      \brief Base class for aspects that require access to their 
owner.
-        *
-        *      Not all aspects require access to their owner class.
-        *      Universally, null aspects don't, because the operations they 
define don't do anything.
-        *      Access to an owner requires storing a pointer, so a null aspect 
couldn't have one anyway,
-        *              since a null aspect must not define storage (otherwise 
it's not null).
-        */
-       template< class Owner >
-       class Aspect_Has_Access_To_Owner
-       {
-               /// This class is a wrapper around a pointer to its owner.
-               Owner * the_owner ;
-
-       public:
-               /// Default constructor
-               Aspect_Has_Access_To_Owner()
-                       : the_owner( 0 ) {}
-
-               /// Accessor to owner
-               inline Owner * owner() const { return the_owner ; }
-
-               /// Owner must be set after construction, because 'this' isn't 
known before the aspect instance is constructed.
-               inline void set_owner( Owner * x ) { the_owner = x ; }
-       } ;
-
-       //--------------------------------------------------
-       /** \class Aspect_Has_Const_Access_To_Owner
-        *      \brief Base class for aspects that require read access to their 
owner, but not write access.
-        *
-        *      Not all aspects require access to their owner class.
-        *      Universally, null aspects don't, because the operations they 
define don't do anything.
-        *      Access to an owner requires storing a pointer, so a null aspect 
couldn't have one anyway,
-        *              since a null aspect must not define storage (otherwise 
it's not null).
-        */
-       template< class Owner >
-       class Aspect_Has_Const_Access_To_Owner
-       {
-               /// This class is a wrapper around a pointer to its owner.
-               const Owner * the_owner ;
-
-       public:
-               /// Default constructor
-               Aspect_Has_Const_Access_To_Owner( const Owner * x )
-                       : the_owner( x ) {}
-
-               /// Accessor to owner
-               inline const Owner * owner() const { return the_owner ; }
-       } ;
-
-       //--------------------------------------------------
-       /**
-        */
-} // end namespace aspect
-
-
-// This should move to config.h, perhaps
-#ifdef _MSC_VER
-// Disable the warning about "'this' uses in base member initializer list
-#      pragma warning(disable:4355)
-#else
-#endif
-
-#endif // end of inclusion protection

Index: buffer.cpp
===================================================================
RCS file: buffer.cpp
diff -N buffer.cpp
--- buffer.cpp  26 Mar 2008 00:02:02 -0000      1.7
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,200 +0,0 @@
-// 
-//   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
-//
-
-#include <boost/cstdint.hpp>
-#include "buffer.h"
-#include "log.h"
-#include "network.h"
-
-using namespace std;
-using namespace gnash;
-
-namespace cygnal
-{
-
-void *
-Buffer::init(size_t nbytes)
-{
-//    GNASH_REPORT_FUNCTION;
-    if (_ptr == 0) {
-        _ptr = new Network::byte_t[nbytes];
-        _nbytes = nbytes;
-        // this could be a performance hit, but for debugging we leave it in 
so we get
-        // easier to ready hex dumps in GDB,
-        empty();
-    }
-
-#ifdef USE_STATS_BUFFERS
-    clock_gettime (CLOCK_REALTIME, &_stamp);
-#endif
-    return _ptr;
-}
-
-Buffer::Buffer() 
-{
-//    GNASH_REPORT_FUNCTION;
-    _ptr = 0;
-    _nbytes = gnash::NETBUFSIZE;
-    init(gnash::NETBUFSIZE);
-}
-    
-// Create with a size other than the default
-Buffer::Buffer(size_t nbytes)
-{
-//    GNASH_REPORT_FUNCTION;
-    _ptr = 0;
-    _nbytes = nbytes;
-    init(nbytes);
-}
-
-// Delete the allocate memory
-Buffer::~Buffer()
-{
-//    GNASH_REPORT_FUNCTION;
-    if (_ptr) {
-#ifdef USE_STATS_BUFFERS
-       struct timespec now;
-       clock_gettime (CLOCK_REALTIME, &now);
-       log_debug("Buffer %x (%d) stayed in queue for %f seconds",
-                 (void *)_ptr, _nbytes,
-                 (float)((now.tv_sec - _stamp.tv_sec) + ((now.tv_nsec - 
_stamp.tv_nsec)/1e9)));
-#endif
-        delete[] _ptr;
-        _ptr = 0;
-        _nbytes = 0;
-    }
-}
-
-// Put data into the buffer
-void
-Buffer::copy(Network::byte_t *data, size_t nbytes)
-{    
-//    GNASH_REPORT_FUNCTION;
-    std::copy(data, data + nbytes, _ptr);
-}
-
-void
-Buffer::copy(string &str)
-{    
-//    GNASH_REPORT_FUNCTION;
-    std::copy(str.begin(), str.end(), _ptr);
-}
-
-// make ourselves be able to be copied.
-Buffer &
-Buffer::operator=(Buffer *buf)
-{
-//    GNASH_REPORT_FUNCTION;
-    if (buf->size() != _nbytes) {
-         resize(buf->size());
-    }
-    
-    std::copy(buf->reference(), buf->reference() + _nbytes, _ptr);
-
-    return *this;
-}
-
-Buffer &
-Buffer::operator=(Buffer &buf)
-{
-//    GNASH_REPORT_FUNCTION;
-    if (buf.size() != _nbytes) {
-         resize(buf.size());
-    }
-    
-    std::copy(buf.reference(), buf.reference() + _nbytes, _ptr);
-
-    return *this;
-}
-
-// Check to see if two Buffer objects are identical
-bool
-Buffer::operator==(Buffer *buf)
-{ 
-//    GNASH_REPORT_FUNCTION;
-   if (buf->size() == _nbytes) {
-        if (memcmp(buf->reference(), _ptr, _nbytes) == 0)  {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-Buffer::operator==(Buffer &buf)
-{
-//    GNASH_REPORT_FUNCTION;
-    if (buf.size() == _nbytes){
-        if (memcmp(buf.reference(), _ptr, _nbytes) == 0)  {
-            return true;
-        }
-    }
-    return false;
-}
-
-// Just reset to having no data, but still having storage
-void
-Buffer::empty()
-{
-//    GNASH_REPORT_FUNCTION;
-    if (_ptr) {
-        memset(_ptr, 0, _nbytes);
-    }
-}
-
-// Resize the buffer that holds the data
-void *
-Buffer::resize(size_t nbytes)
-{
-//    GNASH_REPORT_FUNCTION;
-    // Allocate a new memory block
-    Network::byte_t *tmp = new Network::byte_t[nbytes];
-    // And copy ourselves into it
-    if (nbytes > _nbytes) {
-        std::copy(_ptr, _ptr + _nbytes, tmp);
-    }
-    
-    if (nbytes < _nbytes) {
-        std::copy(_ptr, _ptr + nbytes, tmp);
-    }
-
-    _nbytes = nbytes;
-
-    // Delete the old block, it's unused now
-    delete[] _ptr;
-
-    // Make the memeory block use the new space
-    _ptr = tmp;
-
-    return tmp;
-}
-
-void
-Buffer::dump()
-{
-    cerr << "Buffer is " << _nbytes << " bytes at " << (void *)_ptr << endl;
-    cerr << gnash::hexify((unsigned char *)_ptr, _nbytes, true) << endl;
-}
-
-} // end of cygnal namespace
-
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:

Index: buffer.h
===================================================================
RCS file: buffer.h
diff -N buffer.h
--- buffer.h    26 Mar 2008 00:02:02 -0000      1.5
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,85 +0,0 @@
-// 
-//   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
-//
-
-#ifndef __BUFFER_H__
-#define __BUFFER_H__ 1
-
-#include <boost/cstdint.hpp>
-#include <string>
-#include <time.h>
-
-#include "network.h"
-
-// _definst_ is the default instance name
-namespace cygnal
-{
-
-class Buffer 
-{
-public:
-    Buffer();
-    // Create with a size other than the default
-    Buffer(size_t nbytes);
-    
-    // Delete the allocate memory
-    ~Buffer();
-    void empty();
-
-    // Resize the buffer that holds the data
-    void *resize(size_t nbytes);
-
-    // Put data into the buffer
-    void copy(gnash::Network::byte_t *data, size_t nbytes);
-    void copy(gnash::Network::byte_t *data) { copy(data, _nbytes); };
-    void copy(std::string &str);
-    
-    // Accessors
-    gnash::Network::byte_t *reference() { return _ptr; }
-    size_t size() { return _nbytes; }
-    void setSize(size_t nbytes) { _nbytes = nbytes; };
-    
-    // make ourselves be able to be copied.
-    Buffer &operator=(Buffer *buf);
-    Buffer &operator=(Buffer &buf);
-
-    // Test against other buffers
-    bool operator==(Buffer *buf);
-    bool operator==(Buffer &buf);
-
-    gnash::Network::byte_t operator[](int x) { return _ptr[x]; };
-    
-    // debug stuff, not need for running Cygnal
-    void dump();
-private:
-    void *init(size_t nbytes);
-    gnash::Network::byte_t *_ptr;
-    int         _nbytes;
-#ifdef USE_STATS_BUFFERS
-    struct timespec _stamp;    // used for timing how long data stays in the 
queue.
-#endif
-};
-
-
-} // end of cygnal namespace
-
-#endif // end of __BUFFER_H__
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:

Index: cque.cpp
===================================================================
RCS file: cque.cpp
diff -N cque.cpp
--- cque.cpp    26 Mar 2008 00:02:02 -0000      1.6
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,263 +0,0 @@
-// 
-//   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 <string>
-#include <vector>
-#include <deque>
-#include <time.h>
-
-#include "log.h"
-#include "gmemory.h"
-#include "buffer.h"
-#include "cque.h"
-
-using namespace gnash;
-using namespace std;
-using namespace boost;
-
-
-namespace cygnal
-{
-
-CQue::CQue()
-{
-//    GNASH_REPORT_FUNCTION;
-    _stats.totalbytes = 0;
-    _stats.totalin = 0;
-    _stats.totalout = 0;
-    clock_gettime (CLOCK_REALTIME, &_stats.start);
-    _name = "default";
-}
-
-CQue::~CQue()
-{
-//    GNASH_REPORT_FUNCTION;
-//    clear();
-#if 0
-    deque<Buffer *>::iterator it;
-    boost::mutex::scoped_lock lock(_mutex);
-    for (it = _que.begin(); it != _que.end(); it++) {
-       Buffer *ptr = *(it);
-       delete ptr;
-    }
-#endif
-}
-
-// Wait for a condition variable to trigger
-void
-CQue::wait()
-{
-//    GNASH_REPORT_FUNCTION;
-    boost::mutex::scoped_lock lk(_cond_mutex);
-    _cond.wait(lk);
-//    log_debug("wait mutex released for \"%s\"", _name);
-}
-
-// Notify a condition variable to trigger
-void
-CQue::notify()
-{
-//    GNASH_REPORT_FUNCTION;
-    _cond.notify_one();
-//    log_debug("wait mutex triggered for \"%s\"", _name);
-}
-
-size_t
-CQue::size()
-{
-//    GNASH_REPORT_FUNCTION;
-    boost::mutex::scoped_lock lock(_mutex);
-    return _que.size();
-}
-
-bool
-CQue::push(Buffer *data)
-{
-//    GNASH_REPORT_FUNCTION;
-    boost::mutex::scoped_lock lock(_mutex);
-    _que.push_back(data);
-#ifdef USE_STATS_QUEUE
-    _stats.totalbytes += data->size();
-    _stats.totalin++;
-#endif
-    return true;
-}
-
-// Push data
-bool
-CQue::push(gnash::Network::byte_t *data, int nbytes)
-{
-//    GNASH_REPORT_FUNCTION;
-    Buffer *buf = new Buffer;
-    std::copy(data, data + nbytes, buf->reference());
-    return push(buf);
-}
-
-
-// Pop the first date element off the FIFO
-Buffer *
-CQue::pop()
-{
-//    GNASH_REPORT_FUNCTION;
-    Buffer *buf = 0;
-    boost::mutex::scoped_lock lock(_mutex);
-    if (_que.size()) {
-        buf = _que.front();
-        _que.pop_front();
-#ifdef USE_STATS_QUEUE
-       _stats.totalout++;
-#endif
-    }
-    return buf;
-}
-
-// Peek at the first data element without removing it
-Buffer *
-CQue::peek()
-{
-//    GNASH_REPORT_FUNCTION;
-    boost::mutex::scoped_lock lock(_mutex);
-    if (_que.size()) {
-        return _que.front();
-    }
-    return 0;  
-}
-
-// Return the size of the queues
-void
-CQue::clear()
-{
-//    GNASH_REPORT_FUNCTION;
-    boost::mutex::scoped_lock lock(_mutex);
-    _que.clear();
-}
-
-// Remove a range of elements
-void
-CQue::remove(Buffer *begin, Buffer *end)
-{
-    GNASH_REPORT_FUNCTION;
-    deque<Buffer *>::iterator it;
-    deque<Buffer *>::iterator start;
-    deque<Buffer *>::iterator stop;
-    boost::mutex::scoped_lock lock(_mutex);
-    Buffer *ptr;
-    for (it = _que.begin(); it != _que.end(); it++) {
-       ptr = *(it);
-       if (ptr->reference() == begin->reference()) {
-           start = it;
-       }
-       if (ptr->reference() == end->reference()) {
-           stop = it;
-           break;
-       }
-    }
-    _que.erase(start, stop);
-}
-
-// Remove an element
-void
-CQue::remove(Buffer *element)
-{
-    GNASH_REPORT_FUNCTION;
-    deque<Buffer *>::iterator it;
-    boost::mutex::scoped_lock lock(_mutex);
-    for (it = _que.begin(); it != _que.end(); it++) {
-       Buffer *ptr = *(it);
-       if (ptr->reference() == element->reference()) {
-           _que.erase(it);
-       }
-    }
-}
-
-// Merge sucessive buffers into one single larger buffer. This is for some
-// protocols, than have very long headers.
-Buffer *
-CQue::merge(Buffer *begin)
-{
-    GNASH_REPORT_FUNCTION;
-    int totalsize = 0;
-    deque<Buffer *>::iterator it;
-    vector<deque<Buffer *>::iterator> elements;
-    vector<deque<Buffer *>::iterator>::iterator eit;
-    boost::mutex::scoped_lock lock(_mutex);
-    for (it = _que.begin(); it != _que.end(); it++) {
-       Buffer *ptr = *(it);
-       if (totalsize > 0) {
-           totalsize += ptr->size();
-           elements.push_back(it);
-           if (ptr->size() < gnash::NETBUFSIZE) {
-               Buffer *newbuf = new Buffer(totalsize);
-               Network::byte_t *tmp = newbuf->reference();
-               Buffer *buf;
-//             _que.insert(elements.begin(), newbuf);
-               for (eit = elements.begin(); eit != elements.end(); eit++) {
-                   deque<Buffer *>::iterator ita = *(eit);
-                   buf = *(ita);
-                   std::copy(buf->reference(), buf->reference() + buf->size(), 
tmp);
-                   tmp += buf->size();
-                   _que.erase(ita);
-               }
-               _que.push_back(newbuf);
-               return newbuf;
-           }
-           continue;
-       }
-       if (ptr->reference() == begin->reference()) {
-           totalsize = ptr->size();
-           elements.push_back(it);
-       }
-    }
-    return 0;
-}
-
-// Dump internal data.
-void
-CQue::dump()
-{
-//    GNASH_REPORT_FUNCTION;
-    deque<Buffer *>::iterator it;
-    boost::mutex::scoped_lock lock(_mutex);
-    cerr << endl << "CQue \"" << _name << "\" has "<< _que.size() << " 
buffers." << endl;
-    for (it = _que.begin(); it != _que.end(); it++) {
-       Buffer *ptr = *(it);
-        ptr->dump();
-    }
-#ifdef USE_STATS_QUEUE
-    struct timespec now;
-    clock_gettime (CLOCK_REALTIME, &now);
-    cerr << "Que lifespan is " <<
-       (float)((now.tv_sec - _stats.start.tv_sec) + ((now.tv_nsec - 
_stats.start.tv_nsec)/1e9)) << " seconds" << endl;
-    cerr << "Total number of bytes is " << _stats.totalbytes << " bytes" << 
endl;
-    cerr << "Total number of packets pushed to queue is: " << _stats.totalin 
<< endl;
-    cerr << "Total number of packets popped from queue is: " << 
_stats.totalout << endl;
-#endif
-}
-
-} // end of cygnal namespace
-
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
-

Index: cque.h
===================================================================
RCS file: cque.h
diff -N cque.h
--- cque.h      26 Mar 2008 00:02:02 -0000      1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,100 +0,0 @@
-// 
-//   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
-//
-
-#ifndef __CQUE_H__
-#define __CQUE_H__ 1
-
-#include <boost/cstdint.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/condition.hpp>
-#include <deque>
-#include <time.h>
-
-#include "buffer.h"
-#include "network.h"
-
-// _definst_ is the default instance name
-namespace cygnal
-{
-
-class CQue {
-public:
-#ifdef USE_STATS_QUEUE
-    typedef struct {
-       struct timespec start;
-       int             totalbytes;
-       int             totalin;
-       int             totalout;
-    } que_stats_t;
-#endif
-    CQue();
-    CQue(const std::string &str) { _name = str; };
-    ~CQue();
-    // Push data onto the que
-    bool push(gnash::Network::byte_t *data, int nbytes);
-    bool push(Buffer *data);
-    // Pop the first date element off the que
-    Buffer *pop();
-    // Peek at the first date element witjhout removing it from the que
-    Buffer *peek();
-    // Get the number of elements in the que
-    size_t size();
-    // Wait for a condition variable to trigger
-    void wait();
-    // Notify a condition variable to trigger
-    void notify();
-    // Empty the que of all data. 
-    void clear();
-    // Remove a range of elements
-    void remove(Buffer *begin, Buffer *end);
-//     // Remove an element
-//    void remove(Buffer *it);
-    void remove(Buffer *it);
-    // Merge sucessive buffers into one single larger buffer. This is for some
-    // protocols, than have very long headers.
-    Buffer *merge(Buffer *begin);
-    
-    // Dump the data to the terminal
-    void dump();
-    que_stats_t *stats() { return &_stats; };
-    void setName(const std::string &str) { _name = str; }
-private:
-    // an optional name for the queue, only used for debugging messages to 
make them unique
-    std::string _name;
-    // The queue itself
-    std::deque<Buffer *> _que;
-    // A condition variable used to signal the other thread when the que has 
data
-    boost::condition   _cond;
-    // This is the mutex used by the condition variable. It needs to be 
separate from the
-    // one used to lock access to the que.
-    boost::mutex       _cond_mutex;
-    // This is the mutex that control access to the que.
-    boost::mutex       _mutex;
-#ifdef USE_STATS_QUEUE
-    que_stats_t                _stats;
-#endif
-};
-    
-} // end of cygnal namespace
-
-#endif // end of __CQUE_H__
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:

Index: handler.cpp
===================================================================
RCS file: handler.cpp
diff -N handler.cpp
--- handler.cpp 26 Mar 2008 00:02:03 -0000      1.8
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,276 +0,0 @@
-// 
-//   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 <boost/thread/thread.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/bind.hpp>
-#include <algorithm>
-#include <string>
-#include <deque>
-#include <list>
-#include <map>
-
-#include "log.h"
-#include "network.h"
-#include "buffer.h"
-
-#include "http.h"
-
-using namespace gnash;
-using namespace std;
-using namespace boost;
-
-namespace cygnal
-{
-
-extern map<int, Handler *> handlers;
-
-Handler::Handler()
-    : _die(false), _netfd(0)
-{
-//    GNASH_REPORT_FUNCTION;
-}
-
-Handler::~Handler()
-{
-//    GNASH_REPORT_FUNCTION;
-    closeConnection();
-    _die = true;
-    notifyout();
-    notifyin();
-}
-
-bool
-Handler::push(Buffer *data, fifo_e direction)
-{
-//    GNASH_REPORT_FUNCTION;
-    if (direction == Handler::OUTGOING) {
-       _outgoing.push(data);
-       return true;
-    }
-    if (direction == Handler::INCOMING) {
-       _incoming.push(data);
-       return true;
-    }
-    
-    return false;
-}
-
-// Push bytes on the outgoing FIFO
-bool
-Handler::push(gnash::Network::byte_t *data, int nbytes, fifo_e direction)
-{
-//    GNASH_REPORT_FUNCTION;
-    Buffer *ptr = new Buffer;
-    ptr->copy(data, nbytes);
-    return push(ptr, direction);
-}
-
-// Pop the first date element off the FIFO
-Buffer *
-Handler::pop(fifo_e direction)
-{
-//    GNASH_REPORT_FUNCTION;
-    Buffer *buf;
-    
-    if (direction == Handler::OUTGOING) {
-       if (_outgoing.size()) {
-           buf = _outgoing.pop();
-           return buf; 
-       }
-    }
-    if (direction == Handler::INCOMING) {
-       if (_incoming.size()) {
-           buf = _incoming.pop();
-           return buf; 
-       }
-    }
-
-    return buf;
-}
-
-// Peek at the first data element without removing it
-Buffer *
-Handler::peek(fifo_e direction)
-{
-//    GNASH_REPORT_FUNCTION;
-    if (direction == Handler::OUTGOING) {
-       if (_outgoing.size()) {
-           return _outgoing.peek();
-       }
-    }
-    if (direction == Handler::INCOMING) {
-       if (_incoming.size()) {
-           return _incoming.peek();
-       }
-    }    
-    return 0;
-}
-
-// Return the size of the queues
-size_t
-Handler::size(fifo_e direction)
-{
-//    GNASH_REPORT_FUNCTION;
-    if (direction == Handler::OUTGOING) {
-       return _outgoing.size();
-    }
-    if (direction == Handler::INCOMING) {
-       return _incoming.size();
-    }
-    
-    return 0;                  // we should never actually get to here
-}
-
-// Return the size of the queues
-void
-Handler::clear(fifo_e direction)
-{
-//    GNASH_REPORT_FUNCTION;
-    if (direction == Handler::OUTGOING) {
-       _outgoing.clear();
-    }
-    if (direction == Handler::INCOMING) {
-       _incoming.clear();
-    }    
-}
-
-// Dump internal data.
-void
-Handler::dump()
-{
-//    GNASH_REPORT_FUNCTION;
-    _incoming.dump();
-    _outgoing.dump();    
-}
-
-// start the two thread handlers for the queues
-bool
-Handler::start(thread_params_t *args)
-{
-    GNASH_REPORT_FUNCTION;
-//    Handler *hand = reinterpret_cast<Handler *>(args->handle);
-    
-    _incoming.setName("Incoming");
-    _outgoing.setName("Outgoing");
-    
-    log_debug(_("Starting Handlers for port %d, pid %d"),
-             args->port, getpid());
-//     newConnection(true);
-    
-    boost::thread handler(boost::bind(&httphandler, args));
-    boost::thread outport(boost::bind(&netout_handler, args));
-    boost::thread inport(boost::bind(&netin_handler, args));
-// We don't want to wait for the threads to complete, we
-// want to return to the main program so it can spawn another
-// thread for the next incoming connection.    
-//     inport.join();    
-//     outport.join();
-//     handler.join();
-//     if (_die) {
-//     log_debug("Handler done...");
-//     }
-    return true;
-}
-    
-extern "C" {
-void
-netin_handler(Handler::thread_params_t *args)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    Handler *hand = reinterpret_cast<Handler *>(args->handle);
-
-    do {
-       Buffer *buf = new Buffer;
-       size_t ret = hand->readNet(args->netfd, buf->reference(), buf->size(), 
1);
-       if ((ret > 0) && (ret != string::npos)) {
-           if (ret != buf->size()) {
-               buf->resize(ret);
-           }
-           hand->push(buf);
-           hand->notify();
-       } else {
-           log_debug("no more data for fd #%d, exiting...", args->netfd);
-           hand->die();
-           break;
-       }
-    } while (!hand->timetodie());
-    log_debug("Net In handler done for fd #%d...", args->netfd);
-    hand->notify();
-    hand->closeNet(args->netfd);
-    hand->clearall();
-//    cerr << "Removing handler: " << (void *)hand << endl;
-//    handlers.remove(hand);
-//     delete hand;
-//    hand->dump();
-}
-
-void
-netout_handler(Handler::thread_params_t *args)
-{
-//    GNASH_REPORT_FUNCTION;
-    int ret;
-    Handler *hand = reinterpret_cast<Handler *>(args->handle);
-    do {
-       // Don't look for any more packets in the que cause we're done
-       if (hand->timetodie()) {
-           break;
-       }
-       hand->waitout();
-       while (hand->outsize()) {
-           Buffer *buf = hand->popout();
-//         log_debug("FIXME: got data in Outgoing que");
-//         buf->dump();
-//         ret = hand->writeNet(buf->reference(), buf->size(), 15);
-//         if (buf->size() != gnash::NETBUFSIZE) {
-//                     log_debug("Got smaller packet, size %d", buf->size());  
        
-//         }
-           ret = hand->writeNet(args->netfd, buf);
-           delete buf;
-       }
-    } while (ret > 0);
-    hand->die();
-    log_debug("Net Out handler done for fd #%d...", args->netfd);
-    hand->notifyin();
-    hand->closeNet(args->netfd);
-#if 0
-    map<int, Handler *>::iterator hit = handlers.find(args->netfd);
-    if ((*hit).second) {
-       log_debug("Removing handle %x for fd #%d: ",
-                 (void *)hand), args->netfd;
-       handlers.erase(args->netfd);
-    }
-#endif
-    delete hand;
-}
-    
-} // end of extern C
-
-} // end of cygnal namespace
-
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
-

Index: handler.h
===================================================================
RCS file: handler.h
diff -N handler.h
--- handler.h   26 Mar 2008 00:02:03 -0000      1.5
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,163 +0,0 @@
-// 
-//   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
-//
-
-#ifndef __HANDLER_H__
-#define __HANDLER_H__ 1
-
-#include <boost/cstdint.hpp>
-//#include <boost/thread/condition.hpp>
-#include <string>
-#include <deque>
-
-#include "log.h"
-#include "network.h"
-#include "buffer.h"
-#include "cque.h"
-#include "network.h"
-
-// _definst_ is the default instance name
-namespace cygnal
-{
-
-
-class Handler : public gnash::Network
-{
-public:
-    Handler();
-    ~Handler();
-
-    typedef enum {
-       UNKNOWN,
-       STATUS,
-       POLL,
-       HELP,
-       INTERVAL,
-       QUIT,
-    } admin_cmd_e;
-    // This is used to pass parameters to a thread using boost::bind
-    typedef struct {
-       int netfd;
-       int port;
-       void *handle;
-       std::string filespec;
-    } thread_params_t ;
-    
-    // Specify which queue should be used
-    typedef enum { INCOMING, OUTGOING } fifo_e;
-    
-    // Push bytes on the incoming FIFO, which is the default
-    bool push(Buffer *data)
-       { return _incoming.push(data); };
-    bool push(Buffer *data, fifo_e direction);
-    bool push(gnash::Network::byte_t *data, int nbytes, fifo_e direction);
-    bool push(gnash::Network::byte_t *data, int nbytes)
-       { return _incoming.push(data, nbytes); };
-    bool pushin(gnash::Network::byte_t *data, int nbytes)
-       { return _incoming.push(data, nbytes); };
-    bool pushin(Buffer *data)
-       { return _incoming.push(data); };
-    
-    // Push bytes on the incoming FIFO, which must be specified
-    bool pushout(gnash::Network::byte_t *data, int nbytes)
-       { return _outgoing.push(data, nbytes); };
-    bool pushout(Buffer *data)
-       { return _outgoing.push(data); };
-    
-    // Pop the first date element off the incoming FIFO
-    Buffer *pop() { return _incoming.pop(); };
-    Buffer *pop(fifo_e direction);
-    Buffer *popin()
-       { return _incoming.pop(); };
-    // Pop the first date element off the outgoing FIFO
-    Buffer *popout()
-       { return _outgoing.pop(); };
-    
-    // Peek at the first data element without removing it
-    Buffer *peek() { return _incoming.peek(); };
-    Buffer *peek(fifo_e direction);
-    Buffer *peekin()
-       { return _incoming.peek(); };
-    // Pop the first date element off the outgoing FIFO
-    Buffer *peekout()
-       { return _outgoing.peek(); };    
-
-    // Removes all the buffers from the queues
-    void clear() { _incoming.clear(); };
-    void clear(fifo_e direction);
-    void clearin() { _incoming.clear(); };
-    void clearout() { _outgoing.clear(); };
-    void clearall() { _outgoing.clear(); _incoming.clear(); };
-    
-    // Return the size of the queues, default to the incoming queue
-    size_t size(fifo_e direction);
-    size_t size() { return _incoming.size(); };
-    size_t insize() { return _incoming.size(); };
-    size_t outsize() { return _outgoing.size(); };
-
-    // Notify the other thread a message is in the que
-    void notify() { _incoming.notify(); };
-    void notifyin() { _incoming.notify(); };
-    void notifyout() { _outgoing.notify(); };
-
-    // Wait for a message from the other thread
-    void wait() { _incoming.wait(); };
-    void waitin() { _incoming.wait(); };
-    void waitout() { _outgoing.wait(); };
-
-    // start the two thread handlers for the queues
-    bool start(thread_params_t *args);
-
-    // Take a buffer and write it to the network
-    int writeNet(int fd, Buffer *buf)
-       { return Network::writeNet(fd, buf->reference(), buf->size()); };
-    
-    int writeNet(Buffer *buf)
-       { return Network::writeNet(buf->reference(), buf->size()); };
-    
-    // Dump internal data.
-    void dump();
-#ifdef USE_STATS_QUEUE
-    CQue::que_stats_t *statsin()  { return _incoming.stats(); };
-    CQue::que_stats_t *statsout() { return _outgoing.stats(); };
-#endif
-    void die() { _die = true; _outgoing.notify(); };
-    bool timetodie() { return _die; };
-    
-private:
-    bool _die;
-    int _netfd;
-    CQue _incoming;
-    CQue _outgoing;
-};
-
-// This is the thread for all incoming network connections, which
-// has to be in C.
-extern "C" {
-    void netin_handler(Handler::thread_params_t *args);
-    void netout_handler(Handler::thread_params_t *args);
-    void start_handler(Handler::thread_params_t *args);
-}
-
-} // end of cygnal namespace
-
-#endif // end of __HANDLER_H__
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:

Index: http.cpp
===================================================================
RCS file: http.cpp
diff -N http.cpp
--- http.cpp    26 Mar 2008 00:02:03 -0000      1.26
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,1336 +0,0 @@
-// http.cpp:  HyperText Transport Protocol handler for Cygnal, for Gnash.
-// 
-//   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 <boost/thread/mutex.hpp>
-#include <boost/date_time/gregorian/gregorian.hpp>
-//#include <boost/date_time/local_time/local_time.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-//#include <boost/date_time/time_zone_base.hpp>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string>
-#include <iostream>
-#include <cstring>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <algorithm>
-
-#include "http.h"
-#include "log.h"
-#include "network.h"
-#include "handler.h"
-
-using namespace gnash;
-using namespace std;
-
-static boost::mutex stl_mutex;
-
-namespace cygnal
-{
-
-extern map<int, Handler *> handlers;
-
-// FIXME, this seems too small to me.  --gnu
-static const int readsize = 1024;
-
-HTTP::HTTP() 
-    : _filesize(0),
-      _port(80),
-      _keepalive(true),
-      _handler(0),
-      _clientid(0),
-      _index(0)
-{
-//    GNASH_REPORT_FUNCTION;
-//    struct status_codes *status = new struct status_codes;
-    
-//    _status_codes(CONTINUE, status);
-}
-
-HTTP::HTTP(Handler *hand) 
-    : _filesize(0), _port(80), _keepalive(false)
-{
-//    GNASH_REPORT_FUNCTION;
-    _handler = hand;
-}
-
-HTTP::~HTTP()
-{
-//    GNASH_REPORT_FUNCTION;
-}
-
-bool
-HTTP::clearHeader()
-{
-    _header.str("");
-    _body.str("");
-    _charset.clear();
-    _connections.clear();
-    _language.clear();
-    _encoding.clear();
-    _te.clear();
-    _accept.clear();
-    _filesize = 0;
-    _clientid = 0;
-    _index = 0;
-    return true;
-}
-
-HTTP &
-HTTP::operator = (HTTP& /*obj*/)
-{
-    GNASH_REPORT_FUNCTION;
-//    this = obj;
-    // TODO: FIXME !
-    return *this; 
-}
-
-bool
-HTTP::waitForGetRequest(Network& /*net*/)
-{
-    GNASH_REPORT_FUNCTION;
-    return false;              // FIXME: this should be finished
-}
-
-bool
-HTTP::waitForGetRequest()
-{
-    GNASH_REPORT_FUNCTION;
-
-//     Network::byte_t buffer[readsize+1];
-//     const char *ptr = reinterpret_cast<const char *>(buffer);
-//     memset(buffer, 0, readsize+1);
-    
-//    _handler->wait();
-    Buffer *buf = _handler->pop();
-
-    if (buf == 0) {
-       log_debug("Que empty, net connection dropped");
-       return false;
-    }
-    
-    clearHeader();
-    extractCommand(buf);    
-    extractAccept(buf);
-    extractMethod(buf);
-    extractReferer(buf);
-    extractHost(buf);
-    extractAgent(buf);
-    extractLanguage(buf);
-    extractCharset(buf);
-    extractConnection(buf);
-    extractKeepAlive(buf);
-    extractEncoding(buf);
-    extractTE(buf);
-//    dump();
-    
-    _filespec = _url;
-    if (!_url.empty()) {
-       return true;
-    }
-    return false;
-}
-
-bool
-HTTP::formatHeader(http_status_e type)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    formatHeader(_filesize, type);
-    return true;
-}
-
-
-bool
-HTTP::formatHeader(int filesize, http_status_e type)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    _header << "HTTP/1.1 200 OK" << "\r\n";
-    formatDate();
-    formatServer();
-//     if (type == NONE) {
-//     formatConnection("close"); // this is the default for HTTP 1.1
-//     }
-//     _header << "Accept-Ranges: bytes" << "\r\n";
-    formatLastModified();
-    formatEtag("24103b9-1c54-ec8632c0"); // FIXME: borrowed from tcpdump
-    formatAcceptRanges("bytes");
-    formatContentLength(filesize);
-    formatKeepAlive("timeout=15, max=100");
-    formatConnection("Keep-Alive");
-    formatContentType();
-    // All HTTP messages are followed by a blank line.
-    terminateHeader();
-    return true;
-}
-
-bool
-HTTP::formatErrorResponse(http_status_e code)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    // First build the message body, so we know how to set Content-Length
-    _body << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">" << "\r\n";
-    _body << "<html><head>" << "\r\n";
-    _body << "<title>" << code << " Not Found</title>" << "\r\n";
-    _body << "</head><body>" << "\r\n";
-    _body << "<h1>Not Found</h1>" << "\r\n";
-    _body << "<p>The requested URL " << _filespec << " was not found on this 
server.</p>" << "\r\n";
-    _body << "<hr>" << "\r\n";
-    _body << "<address>Cygnal (GNU/Linux) Server at localhost Port " << _port 
<< " </address>" << "\r\n";
-    _body << "</body></html>" << "\r\n";
-    _body << "\r\n";
-
-    // First build the header
-    _header << "HTTP/1.1 " << code << " Not Found" << "\r\n";
-    formatDate();
-    formatServer();
-    _filesize = _body.str().size();
-    formatContentLength(_filesize);
-    formatConnection("close");
-    formatContentType(HTTP::HTML);
-    return true;
-}
-
-bool
-HTTP::formatDate()
-{
-//    GNASH_REPORT_FUNCTION;
-    boost::posix_time::ptime now = 
boost::posix_time::second_clock::local_time();
-    
-//    cout <<  now.time_of_day() << "\r\n";
-    
-    boost::gregorian::date d(now.date());
-//     boost::gregorian::date d(boost::gregorian::day_clock::local_day());
-//     cout << boost::posix_time::to_simple_string(now) << "\r\n";
-//     cout << d.day_of_week() << "\r\n";
-//     cout << d.day() << "\r\n";
-//     cout << d.year() << "\r\n";
-//     cout << d.month() << "\r\n";
-    
-//    boost::date_time::time_zone_ptr zone(new posix_time_zone("MST"));
-//    boost::date_time::time_zone_base b(now "MST");
-//    cout << zone.dst_zone_abbrev() << "\r\n";
-
-    _header << "Date: " << d.day_of_week();
-    _header << ", " << d.day();
-    _header << " "  << d.month();
-    _header << " "  << d.year();
-    _header << " "  << now.time_of_day();
-    _header << " GMT" << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatServer()
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Server: Cygnal (GNU/Linux)" << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatServer(const string &data)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Server: " << data << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatMethod(const string &data)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Method: " << data << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatReferer(const string &refer)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Referer: " << refer << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatConnection(const string &options)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Connection: " << options << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatKeepAlive(const string &options)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Keep-Alive: " << options << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatContentType()
-{
-    return formatContentType(_filetype);
-}
-
-bool
-HTTP::formatContentType(filetype_e filetype)
-{
-//    GNASH_REPORT_FUNCTION;
-    
-    switch (filetype) {
-      case HTML:
-         _header << "Content-Type: text/html" << "\r\n";
-//       _header << "Content-Type: text/html; charset=UTF-8" << "\r\n";
-         break;
-      case SWF:
-         _header << "Content-Type: application/x-shockwave-flash" << "\r\n";
-//       _header << "Content-Type: application/futuresplash" << "\r\n";
-         break;
-      case VIDEO:
-         _header << "Content-Type: video/flv" << "\r\n";
-         break;
-      case MP3:
-         _header << "Content-Type: audio/mpeg" << "\r\n";
-         break;
-      case FCS:
-         _header << "Content-Type: application/x-fcs" << "\r\n";
-         break;
-      default:
-         _header << "Content-Type: text/html" << "\r\n";
-//       _header << "Content-Type: text/html; charset=UTF-8" << "\r\n";
-    }
-    return true;
-}
-
-bool
-HTTP::formatContentLength()
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Content-Length: " << _filesize << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatContentLength(int filesize)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Content-Length: " << filesize << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatHost(const string &host)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Host: " << host << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatAgent(const string &agent)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "User-Agent: " << agent << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatAcceptRanges(const string &range)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Accept-Ranges: " << range << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatEtag(const string &tag)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Etag: " << tag << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatLastModified(const string &date)
-{
-    _header << "Last-Modified: " << date << "\r\n";
-}
-
-bool
-HTTP::formatLastModified()
-{
-//    GNASH_REPORT_FUNCTION;
-    boost::posix_time::ptime now = 
boost::posix_time::second_clock::local_time();
-    stringstream date;
-    
-    boost::gregorian::date d(now.date());
-    
-    date << d.day_of_week();
-    date << ", " << d.day();
-    date << " "  << d.month();
-    date << " "  << d.year();
-    date << " "  << now.time_of_day();
-    date << " GMT";
-
-    return formatLastModified(date.str());
-}
-
-bool
-HTTP::formatLanguage(const string &lang)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    // For some browsers this appears to also be Content-Language
-    _header << "Accept-Language: " << lang << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatCharset(const string &set)
-{
-//    GNASH_REPORT_FUNCTION;
-    // For some browsers this appears to also be Content-Charset
-    _header << "Accept-Charset: " << set << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatEncoding(const string &code)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "Accept-Encoding: " << code << "\r\n";
-    return true;
-}
-
-bool
-HTTP::formatTE(const string &te)
-{
-//    GNASH_REPORT_FUNCTION;
-    _header << "TE: " << te << "\r\n";
-    return true;
-}
-
-bool
-HTTP::sendGetReply(http_status_e code)
-{
-    GNASH_REPORT_FUNCTION;
-    
-    formatHeader(_filesize, code);
-//    int ret = Network::writeNet(_header.str());
-    Buffer *buf = new Buffer;
-//    Network::byte_t *ptr = (Network::byte_t *)_body.str().c_str();
-//     buf->copy(ptr, _body.str().size());
-//    _handler->dump();
-    if (_header.str().size()) {
-       buf->resize(_header.str().size());
-       string str = _header.str();
-       buf->copy(str);
-       _handler->pushout(buf);
-       _handler->notifyout();
-        log_debug (_("Sent GET Reply"));
-       return true; // Default to true
-    } else {
-       clearHeader();
-       log_debug (_("Couldn't send GET Reply, no header data"));
-    }
-    
-    return false;
-}
-
-bool
-HTTP::sendPostReply(rtmpt_cmd_e code)
-{
-    GNASH_REPORT_FUNCTION;
-
-    _header << "HTTP/1.1 200 OK" << "\r\n";
-    formatDate();
-    formatServer();
-    formatContentType(HTTP::FCS);
-    // All HTTP messages are followed by a blank line.
-    terminateHeader();
-    return true;
-
-#if 0
-    formatHeader(_filesize, code);
-    Buffer *buf = new Buffer;
-    if (_header.str().size()) {
-       buf->resize(_header.str().size());
-       string str = _header.str();
-       buf->copy(str);
-       _handler->pushout(buf);
-       _handler->notifyout();
-        log_debug (_("Sent GET Reply"));
-       return true; // Default to true
-    } else {
-       clearHeader();
-       log_debug (_("Couldn't send POST Reply, no header data"));
-    }
-#endif
-    return false;
-}
-
-bool
-HTTP::formatRequest(const string &url, http_method_e req)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    _header.str("");
-
-    _header << req << " " << url << "HTTP/1.1" << "\r\n";
-    _header << "User-Agent: Opera/9.01 (X11; Linux i686; U; en)" << "\r\n";
-    _header << "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";
-
-    _header << "Accept-Language: en" << "\r\n";
-    _header << "Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1" << "\r\n";
-    
-    _header << "Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0" << 
"\r\n";
-    _header << "Referer: " << url << "\r\n";
-
-    _header << "Connection: Keep-Alive, TE" << "\r\n";
-    _header << "TE: deflate, gzip, chunked, identity, trailers" << "\r\n";
-    return true;
-}
-// bool
-// HTTP::sendGetReply(Network &net)
-// {
-//     GNASH_REPORT_FUNCTION;    
-// }
-
-// This is what a GET request looks like.
-// GET 
/software/gnash/tests/flvplayer2.swf?file=http://localhost:4080/software/gnash/tests/lulutest.flv
 HTTP/1.1
-// User-Agent: Opera/9.01 (X11; Linux i686; U; en)
-// Host: localhost:4080
-// Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, 
image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
-// Accept-Language: en
-// Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1
-// Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0
-// Referer: http://localhost/software/gnash/tests/
-// Connection: Keep-Alive, TE
-// TE: deflate, gzip, chunked, identity, trailers
-int
-HTTP::extractAccept(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end, length, pos;
-    string pattern = "Accept: ";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        return -1;
-    }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-       end = body.find("\n", start);
-//         return "error";
-    }
-
-    length = end-start-pattern.size();
-    start = start+pattern.size();
-    pos = start;
-    while (pos <= end) {
-       pos = (body.find(",", start) + 2);
-       if (pos <= start) {
-           return _encoding.size();
-       }
-       if ((pos == string::npos) || (pos > end)) {
-           length = end - start;
-       } else {
-           length = pos - start - 2;
-       }
-       string substr = body.substr(start, length);
-//     printf("FIXME: \"%s\"\n", substr.c_str());
-       _accept.push_back(substr);
-       start = pos;
-    }
-
-    return _accept.size();
-}
-
-/// These methods extract data from an RTMPT message. RTMP is an
-/// extension to HTTP that adds commands to manipulate the
-/// connection's persistance.
-//
-/// The URL to be opened has the following form:
-/// http://server/<comand>/[<client>/]<index>
-/// <command>
-///    denotes the RTMPT request type, "OPEN", "SEND", "IDLE", "CLOSE")
-/// <client>
-///    specifies the id of the client that performs the requests
-///    (only sent for established sessions)
-/// <index>
-///    is a consecutive number that seems to be used to detect missing packages
-HTTP::rtmpt_cmd_e
-HTTP::extractRTMPT(gnash::Network::byte_t *data)
-{
-    GNASH_REPORT_FUNCTION;
-
-    string body = reinterpret_cast<const char *>(data);
-    string tmp, cid, indx;
-    HTTP::rtmpt_cmd_e cmd;
-
-    // force the case to make comparisons easier
-    std::transform(body.begin(), body.end(), body.begin(), 
-               (int(*)(int)) toupper);
-    string::size_type start, end;
-
-    // Extract the command first
-    start = body.find("OPEN", 0);
-    if (start != string::npos) {
-        cmd = HTTP::OPEN;
-    }
-    start = body.find("SEND", 0);
-    if (start != string::npos) {
-        cmd = HTTP::SEND;
-    }
-    start = body.find("IDLE", 0);
-    if (start != string::npos) {
-        cmd = HTTP::IDLE;
-    }
-    start = body.find("CLOSE", 0);
-    if (start != string::npos) {
-        cmd = HTTP::CLOSE;
-    }
-
-    // Extract the optional client id
-    start = body.find("/", start+1);
-    if (start != string::npos) {
-       end = body.find("/", start+1);
-       if (end != string::npos) {
-           indx = body.substr(end, body.size());
-           cid = body.substr(start, (end-start));
-       } else {
-           cid = body.substr(start, body.size());
-       }
-    }
-
-    _index = strtol(indx.c_str(), NULL, 0);
-    _clientid = strtol(cid.c_str(), NULL, 0);
-    end =  body.find("\r\n", start);
-//     if (end != string::npos) {
-//         cmd = HTTP::CLOSE;
-//     }
-
-    return cmd;
-}
-
-HTTP::http_method_e
-HTTP::extractCommand(gnash::Network::byte_t *data)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    string body = reinterpret_cast<const char *>(data);
-    HTTP::http_method_e cmd;
-
-    // force the case to make comparisons easier
-//     std::transform(body.begin(), body.end(), body.begin(), 
-//                (int(*)(int)) toupper);
-    string::size_type start, end;
-
-    // Extract the command
-    start = body.find("GET", 0);
-    if (start != string::npos) {
-        cmd = HTTP::GET;
-    }
-    start = body.find("POST", 0);
-    if (start != string::npos) {
-        cmd = HTTP::POST;
-    }
-    start = body.find("HEAD", 0);
-    if (start != string::npos) {
-        cmd = HTTP::HEAD;
-    }
-    start = body.find("CONNECT", 0);
-    if (start != string::npos) {
-        cmd = HTTP::CONNECT;
-    }
-    start = body.find("TRACE", 0);
-    if (start != string::npos) {
-        cmd = HTTP::TRACE;
-    }
-    start = body.find("OPTIONS", 0);
-    if (start != string::npos) {
-        cmd = HTTP::OPTIONS;
-    }
-    start = body.find("PUT", 0);
-    if (start != string::npos) {
-        cmd = HTTP::PUT;
-    }
-    start = body.find("DELETE", 0);
-    if (start != string::npos) {
-        cmd = HTTP::DELETE;
-    }
-
-    _command = cmd;
-    return cmd;
-}
-
-string &
-HTTP::extractAcceptRanges(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end, length, pos;
-    string pattern = "Accept-Ranges: ";
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        _acceptranges = "error";
-        return _acceptranges;
-    }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-        _acceptranges = "error";
-        return _acceptranges;
-    }
-    
-    _acceptranges = body.substr(start+pattern.size(), end-start-1);
-    return _acceptranges;    
-}
-
-string &
-HTTP::extractMethod(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    boost::mutex::scoped_lock lock(stl_mutex);
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end;
-    int length;
-
-    length = body.size();
-    start = body.find(" ", 0);
-    if (start == string::npos) {
-        _method = "error";
-        return _method;
-    }
-    _method = body.substr(0, start);
-    end = body.find(" ", start+1);
-    if (end == string::npos) {
-        _method = "error";
-        return _method;
-    }
-    _url = body.substr(start+1, end-start-1);
-    _version = body.substr(end+1, length);
-
-    end = _url.find("?", 0);
-//    _filespec = _url.substr(start+1, end);
-    return _method;
-}
-
-string &
-HTTP::extractReferer(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end;
-    string pattern = "Referer: ";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-       _referer = "error";
-       return _referer;
-    }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-       _referer = "error";
-        return _referer;
-    }
-    
-    _referer = body.substr(start+pattern.size(), end-start-1);
-    return _referer;
-}
-
-int
-HTTP::extractConnection(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end, length, pos;
-    string pattern = "Connection: ";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        return -1;
-    }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-       end = body.find("\n", start);
-//         return "error";
-    }
-
-    length = end-start-pattern.size();
-    start = start+pattern.size();
-    string _connection = body.substr(start, length);
-    pos = start;
-    while (pos <= end) {
-       pos = (body.find(",", start) + 2);
-       if (pos <= start) {
-           return _encoding.size();
-       }
-       if ((pos == string::npos) || (pos > end)) {
-           length = end - start;
-       } else {
-           length = pos - start - 2;
-       }
-       string substr = body.substr(start, length);
-//     printf("FIXME: \"%s\"\n", substr.c_str());
-       _connections.push_back(substr);
-       // Opera uses upper case first letters, Firefox doesn't.
-       if ((substr == "Keep-Alive") || (substr == "keep-alive")) {
-           _keepalive = true;
-       }
-       start = pos;
-    }
-
-    return _connections.size();
-}
-
-int
-HTTP::extractKeepAlive(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end, length, pos;
-    string pattern = "Keep-Alive: ";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        return -1;
-    }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-       end = body.find("\n", start);
-//         return "error";
-    }
-
-    length = end-start-pattern.size();
-    start = start+pattern.size();
-    string _connection = body.substr(start, length);
-    pos = start;
-    while (pos <= end) {
-       pos = (body.find(",", start) + 2);
-       if (pos <= start) {
-           return _encoding.size();
-       }
-       if ((pos == string::npos) || (pos > end)) {
-           length = end - start;
-       } else {
-           length = pos - start - 2;
-       }
-       string substr = body.substr(start, length);
-//     printf("FIXME: \"%s\"\n", substr.c_str());
-       _kalive.push_back(substr);
-       _keepalive = true;      // if we get this header setting, we want to 
keep alive
-       start = pos;
-    }
-
-    return _connections.size();
-}
-
-string &
-HTTP::extractHost(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end;
-    string pattern = "Host: ";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        _host = "error"; 
-        return _host;
-   }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-        _host = "error"; 
-        return _host;
-    }
-    
-    _host = body.substr(start+pattern.size(), end-start-1);
-    return _host;
-}
-
-string &
-HTTP::extractAgent(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end;
-    string pattern = "User-Agent: ";
-    _agent = "error";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        return _agent;
-    }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-        return _agent;
-    }
-    
-    _agent = body.substr(start+pattern.size(), end-start-1);
-    return _agent;
-}
-
-int
-HTTP::extractLanguage(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end, length, pos, terminate;
-    // match both Accept-Language and Content-Language
-    string pattern = "-Language: ";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        return -1;
-    }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-       end = body.find("\n", start);
-//        return "error";
-    }
-    length = end-start-pattern.size();
-    start = start+pattern.size();
-    pos = start;
-    terminate = (body.find(";", start));
-    if (terminate == string::npos) {
-       terminate = end;
-    }
-    
-    while (pos <= end) {
-       pos = (body.find(",", start));
-       if (pos <= start) {
-           return _encoding.size();
-       }
-       if ((pos == string::npos) || (pos >= terminate)) {
-           length = terminate - start;
-       } else {
-           length = pos - start;
-       }
-       string substr = body.substr(start, length);
-//     printf("FIXME: \"%s\"\n", substr.c_str());
-       _language.push_back(substr);
-       start = pos + 1;
-    }
-    
-//    _language = body.substr(start+pattern.size(), end-start-1);
-    return _language.size();
-}
-
-int
-HTTP::extractCharset(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end, length, pos, terminate;
-// match both Accept-Charset and Content-Charset
-    string pattern = "-Charset: ";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        return -1;
-    }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-       end = body.find("\n", start);
-//        return "error";
-    }
-    
-    length = end-start-pattern.size();
-    start = start+pattern.size();
-    string _connection = body.substr(start, length);
-    pos = start;
-    terminate = (body.find(";", start));
-    if (terminate == string::npos) {
-       terminate = end;
-    }
-    while (pos <= end) {
-       pos = (body.find(",", start) + 2);
-       if (pos <= start) {
-           return _encoding.size();
-       }
-       if ((pos == string::npos) || (pos >= terminate)) {
-           length = terminate - start;
-       } else {
-           length = pos - start - 2;
-       }
-       string substr = body.substr(start, length);
-//     printf("FIXME: \"%s\"\n", substr.c_str());
-       _charset.push_back(substr);
-       start = pos;
-    }
-//    _charset = body.substr(start+pattern.size(), end-start-1);
-    return _charset.size();
-}
-
-int
-HTTP::extractEncoding(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end, length, pos, terminate;
-    // match both Accept-Encoding and Content-Encoding
-    string pattern = "-Encoding: ";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        return -1;
-    }
-    end =  body.find("\r\n", start);
-    if (end == string::npos) {
-       end = body.find("\n", start);
-//        return "error";
-    }
-    
-   length = end-start-pattern.size();
-    start = start+pattern.size();
-    string _connection = body.substr(start, length);
-    pos = start;
-    // Drop anything after a ';' character
-    terminate = (body.find(";", start));
-    if (terminate == string::npos) {
-       terminate = end;
-    }
-    while (pos <= end) {
-       pos = (body.find(",", start) + 2);
-       if (pos <= start) {
-           return _encoding.size();
-       }
-       if ((pos == string::npos) || (pos >= terminate)) {
-           length = terminate - start;
-       } else {
-           length = pos - start - 2;
-       }
-       string substr = body.substr(start, length);
-//     printf("FIXME: \"%s\"\n", substr.c_str());
-       _encoding.push_back(substr);
-       start = pos;
-    }
-
-//    _encoding = body.substr(start+pattern.size(), end-start-1);
-    return _encoding.size();
-}
-
-int
-HTTP::extractTE(Network::byte_t *data) {
-//    GNASH_REPORT_FUNCTION;
-    
-    string body = reinterpret_cast<const char *>(data);
-    string::size_type start, end, length, pos;
-    string pattern = "TE: ";
-    
-    start = body.find(pattern, 0);
-    if (start == string::npos) {
-        return -1;
-    }
-    end = body.find("\r\n", start);
-    if (end == string::npos) {
-       end = body.find("\n", start);
-//        return "error";
-    }
-    
-    length = end-start-pattern.size();
-    start = start+pattern.size();
-    pos = start;
-    while (pos <= end) {
-       pos = (body.find(",", start));
-       if (pos <= start) {
-           return _encoding.size();
-       }
-       if ((pos == string::npos) || (pos >= end)) {
-           length = end - start;
-       } else {
-           length = pos - start;
-       }
-       string substr = body.substr(start, length);
-//     printf("FIXME: \"%s\"\n", substr.c_str());
-       _te.push_back(substr);
-       start = pos + 2;
-    }
-    return _te.size();
-}
-
-// Get the file type, so we know how to set the
-// Content-type in the header.
-HTTP::filetype_e
-HTTP::getFileStats(std::string &filespec)
-{
-//    GNASH_REPORT_FUNCTION;    
-    bool try_again = true;
-    string actual_filespec = filespec;
-    struct stat st;
-
-    while (try_again) {
-       try_again = false;
-//     cerr << "Trying to open " << actual_filespec << "\r\n";
-       if (stat(actual_filespec.c_str(), &st) == 0) {
-           // If it's a directory, then we emulate what apache
-           // does, which is to load the index.html file in that
-           // directry if it exists.
-           if (S_ISDIR(st.st_mode)) {
-               log_debug("%s is a directory\n", actual_filespec.c_str());
-               if (actual_filespec[actual_filespec.size()-1] != '/') {
-                   actual_filespec += '/';
-               }
-               actual_filespec += "index.html";
-               try_again = true;
-               continue;
-           } else {            // not a directory
-               log_debug("%s is not a directory\n", actual_filespec.c_str());
-               _filespec = actual_filespec;
-               string::size_type pos;
-               pos = filespec.rfind(".");
-               if (pos != string::npos) {
-                   string suffix = filespec.substr(pos, filespec.size());
-                   if (suffix == "html") {
-                       _filetype = HTML;
-                       log_debug("HTML content found");
-                   }
-                   if (suffix == "swf") {
-                       _filetype = SWF;
-                       log_debug("SWF content found");
-                   }
-                   if (suffix == "flv") {
-                       _filetype = VIDEO;
-                       log_debug("FLV content found");
-                   }
-                   if (suffix == "mp3") {
-                       _filetype = AUDIO;
-                       log_debug("MP3 content found");
-                   }
-               }
-           }
-       } else {
-           _filetype = HTTP::ERROR;
-       } // end of stat()
-    } // end of try_waiting
-
-    _filesize = st.st_size;
-    return _filetype;
-}
-
-void
-HTTP::dump() {
-//    GNASH_REPORT_FUNCTION;
-    
-    boost::mutex::scoped_lock lock(stl_mutex);
-    vector<string>::iterator it;
-    
-    log_debug (_("==== The HTTP header breaks down as follows: ===="));
-    log_debug (_("Filespec: %s"), _filespec.c_str());
-    log_debug (_("URL: %s"), _url.c_str());
-    log_debug (_("Version: %s"), _version.c_str());
-    for (it = _accept.begin(); it != _accept.end(); it++) {
-        log_debug("Accept param: \"%s\"", (*(it)).c_str());
-    }
-    log_debug (_("Method: %s"), _method.c_str());
-    log_debug (_("Referer: %s"), _referer.c_str());
-    log_debug (_("Connections:"));
-    for (it = _connections.begin(); it != _connections.end(); it++) {
-        log_debug("Connection param is: \"%s\"", (*(it)).c_str());
-    }
-    log_debug (_("Host: %s"), _host.c_str());
-    log_debug (_("User Agent: %s"), _agent.c_str());
-    for (it = _language.begin(); it != _language.end(); it++) {
-        log_debug("Language param: \"%s\"", (*(it)).c_str());
-    }
-    for (it = _charset.begin(); it != _charset.end(); it++) {
-        log_debug("Charset param: \"%s\"", (*(it)).c_str());
-    }
-    for (it = _encoding.begin(); it != _encoding.end(); it++) {
-        log_debug("Encodings param: \"%s\"", (*(it)).c_str());
-    }
-    for (it = _te.begin(); it != _te.end(); it++) {
-        log_debug("TE param: \"%s\"", (*(it)).c_str());
-    }
-
-    // Dump the RTMPT fields
-    log_debug("RTMPT optional index is: ", _index);
-    log_debug("RTMPT optional client ID is: ", _clientid);
-    log_debug (_("==== ==== ===="));
-}
-
-extern "C" {
-void
-httphandler(Handler::thread_params_t *args)
-{
-    GNASH_REPORT_FUNCTION;
-    int retries = 10;
-//    struct thread_params thread_data;
-    string url, filespec, parameters;
-    string::size_type pos;
-    Handler *hand = reinterpret_cast<Handler *>(args->handle);
-    HTTP www;
-    www.setHandler(hand);
-
-    string docroot = args->filespec;
-    
-    while (!hand->timetodie()) {       
-       log_debug(_("Waiting for GET request on fd #%d..."), args->netfd);
-       hand->wait();
-       // This thread is the last to wake up when the browser
-       // closes the network connection. When browsers do this
-       // varies, elinks and lynx are very forgiving to a more
-       // flexible HTTP protocol, which Firefox/Mozilla & Opera
-       // are much pickier, and will hang or fail to load if
-       // you aren't careful.
-       if (hand->timetodie()) {
-           log_debug("Not waiting no more, no more for fd #%d...", 
args->netfd);
-#if 1
-    map<int, Handler *>::iterator hit = handlers.find(args->netfd);
-    if ((*hit).second) {
-       log_debug("Removing handle %x for fd #%d",
-                 (void *)hand), args->netfd;
-       handlers.erase(args->netfd);
-    }
-#endif
-
-           return;
-       }
-#ifdef USE_STATISTICS
-       struct timespec start;
-       clock_gettime (CLOCK_REALTIME, &start);
-#endif
-       
-//     conndata->statistics->setFileType(NetStats::RTMPT);
-//     conndata->statistics->startClock();
-//     args->netfd = www.getFileFd();
-       if (!www.waitForGetRequest()) {
-           hand->die();
-           hand->notifyin();
-           hand->clearout();
-           hand->notifyout();
-           log_debug("Net HTTP done for fd #%d...", args->netfd);
-//         hand->closeNet(args->netfd);
-           return;
-       }
-       url = docroot;
-       url += www.getURL();
-       pos = url.find("?");
-       filespec = url.substr(0, pos);
-       parameters = url.substr(pos + 1, url.size());
-       // Get the file size for the HTTP header
-       
-       if (www.getFileStats(filespec) == HTTP::ERROR) {
-           www.formatErrorResponse(HTTP::NOT_FOUND);
-       }
-       www.sendGetReply(HTTP::LIFE_IS_GOOD);
-//     strcpy(thread_data.filespec, filespec.c_str());
-//     thread_data.statistics = conndata->statistics;
-       
-       // Keep track of the network statistics
-//     conndata->statistics->stopClock();
-//     log_debug (_("Bytes read: %d"), www.getBytesIn());
-//     log_debug (_("Bytes written: %d"), www.getBytesOut());
-//     st.setBytes(www.getBytesIn() + www.getBytesOut());
-//     conndata->statistics->addStats();
-       
-       if (filespec[filespec.size()-1] == '/') {
-           filespec += "/index.html";
-       }
-       if (url != docroot) {
-           log_debug (_("File to load is: %s"), filespec.c_str());
-           log_debug (_("Parameters are: %s"), parameters.c_str());
-           struct stat st;
-           int filefd, ret;
-#ifdef USE_STATISTICS
-           struct timespec start;
-           clock_gettime (CLOCK_REALTIME, &start);
-#endif
-           if (stat(filespec.c_str(), &st) == 0) {
-               filefd = ::open(filespec.c_str(), O_RDONLY);
-               log_debug (_("File \"%s\" is %lld bytes in size, disk fd #%d"), 
filespec,
-                          st.st_size, filefd);
-               do {
-                   Buffer *buf = new Buffer;
-                   ret = read(filefd, buf->reference(), buf->size());
-                   if (ret == 0) { // the file is done
-                       delete buf;
-                       break;
-                   }
-                   if (ret != buf->size()) {
-                       buf->resize(ret);
-//                     log_debug("Got last data block from disk file, size 
%d", buf->size());
-                   }
-//                 log_debug("Read %d bytes from %s.", ret, filespec);
-#if 1
-                   hand->pushout(buf);
-                   hand->notifyout();
-#else
-                   // Don't bother with the outgoing que
-                   if (ret > 0) {
-                       ret = hand->writeNet(buf);
-                   }
-                   delete buf;
-#endif
-               } while(ret > 0);
-               log_debug("Done transferring %s to net fd #%d",
-                         filespec, args->netfd);
-               ::close(filefd); // close the disk file
-               // See if this is a persistant connection
-//             if (!www.keepAlive()) {
-//                 log_debug("Keep-Alive is off", www.keepAlive());
-// //              hand->closeConnection();
-//             }
-#ifdef USE_STATISTICS
-               struct timespec end;
-               clock_gettime (CLOCK_REALTIME, &end);
-               log_debug("Read %d bytes from \"%s\" in %f seconds",
-                         st.st_size, filespec,
-                         (float)((end.tv_sec - start.tv_sec) + ((end.tv_nsec - 
start.tv_nsec)/1e9)));
-#endif
-           }
-
-//         memset(args->filespec, 0, 256);
-//         memcpy(->filespec, filespec.c_str(), filespec.size());
-//         boost::thread sendthr(boost::bind(&stream_thread, args));
-//         sendthr.join();
-       }
-#ifdef USE_STATISTICS
-       struct timespec end;
-       clock_gettime (CLOCK_REALTIME, &end);
-       log_debug("Processing time for GET request was %f seconds",
-                 (float)((end.tv_sec - start.tv_sec) + ((end.tv_nsec - 
start.tv_nsec)/1e9)));
-#endif
-//     conndata->statistics->dump();
-//    }
-    } // end of while retries
-    
-    log_debug("httphandler all done now finally...");
-    
-} // end of httphandler
-    
-} // end of extern C
-
-} // end of cygnal namespace
-
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:

Index: http.h
===================================================================
RCS file: http.h
diff -N http.h
--- http.h      26 Mar 2008 00:02:03 -0000      1.20
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,304 +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
-//
-
-#ifndef _HTTP_H_
-#define _HTTP_H_
-
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-#include <string>
-#include <map>
-#include <vector>
-
-#include "handler.h"
-#include "network.h"
-
-namespace cygnal
-{
-    
-class HTTP
-{
-public:
-// as defined by the W3: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
-    typedef enum {
-        // 1xx: Informational - Request received, continuing process
-        CONTINUE = 100,
-        SWITCHPROTOCOLS = 101,
-        // 2xx: Success - The action was successfully received,
-        // understood, and accepted
-        OK = 200,
-        CREATED = 201,
-        ACCEPTED = 202,
-        NON_AUTHORITATIVE = 203,
-        NO_CONTENT = 204,
-        RESET_CONTENT = 205,
-        PARTIAL_CONTENT = 206,
-        // 3xx: Redirection - Further action must be taken in order to
-        // complete the request
-        MULTIPLE_CHOICES = 300,
-        MOVED_PERMANENTLY = 301,
-        FOUND = 302,
-        SEE_OTHER = 303,
-        NOT_MODIFIED = 304,
-        USE_PROXY = 305,
-        TEMPORARY_REDIRECT = 307,
-        // 4xx: Client Error - The request contains bad syntax or
-        // cannot be fulfilled
-        BAD_REQUEST = 400,
-        UNAUTHORIZED = 401,
-        PAYMENT_REQUIRED = 402,
-        FORBIDDEN = 403,
-        NOT_FOUND = 404,
-        METHOD_NOT_ALLOWED = 405,
-        NOT_ACCEPTABLE = 406,
-        PROXY_AUTHENTICATION_REQUIRED = 407,
-        REQUEST_TIMEOUT = 408,
-        CONFLICT = 409,
-        GONE = 410,
-        LENGTH_REQUIRED = 411,
-        PRECONDITION_FAILED = 412,
-        REQUEST_ENTITY_TOO_LARGE = 413,
-        REQUEST_URI_TOO_LARGE = 414,
-        UNSUPPORTED_MEDIA_TYPE = 415,
-        REQUESTED_RANGE_NOT_SATISFIABLE = 416,
-        EXPECTATION_FAILED = 417,
-        // 5xx: Server Error - The server failed to fulfill an apparently 
valid request
-        INTERNAL_SERVER_ERROR = 500,
-        NOT_IMPLEMENTED = 501,
-        BAD_GATEWAY = 502,
-        SERVICE_UNAVAILABLE = 503,
-        GATEWAY_TIMEOUT = 504,
-        HTTP_VERSION_NOT_SUPPORTED = 505,
-       // Gnash/Cygnal extensions for internal use
-       LIFE_IS_GOOD = 1234,
-       CLOSEPIPE = 1235
-    } http_status_e;
-    typedef enum {
-        OPTIONS,
-        GET,
-        HEAD,
-        POST,
-        PUT,
-        DELETE,
-        TRACE,
-        CONNECT
-    } http_method_e;
-    typedef enum {
-       OPEN,
-       SEND,
-       IDLE,
-       CLOSE
-    } rtmpt_cmd_e;
-    struct status_codes {
-        const char *code;
-        const char *msg;
-    };
-    typedef enum {
-       ERROR = -1,
-       NONE = 0,
-       HTML,
-       SWF,
-       VIDEO,
-       AUDIO,
-       MP3,
-       FCS,
-       OSCP
-    } filetype_e;
-    HTTP();
-    HTTP(Handler *hand);
-    ~HTTP();
-    bool waitForGetRequest();
-    bool waitForGetRequest(gnash::Network &net);
-    
-    // Handle the GET request response
-    bool sendGetReply(http_status_e code);
-    bool sendPostReply(rtmpt_cmd_e code);
-//    bool sendGetReply(Network &net);
-
-    // Make copies of ourself
-    HTTP &operator = (HTTP &obj);
-
-    // These methods extract data from an RTMPT message. RTMP is an
-    // extension to HTTP that adds commands to manipulate the
-    // connection's persistance.
-    rtmpt_cmd_e extractRTMPT(gnash::Network::byte_t *data);
-    rtmpt_cmd_e extractRTMPT(Buffer *data)
-       { return extractRTMPT(data->reference()); };
-
-    // These methods extract the fields in the HTTP header.
-    // These all return the number of items found, or 0
-    http_method_e extractCommand(gnash::Network::byte_t *data);
-    http_method_e extractCommand(Buffer *data)
-       { return extractCommand(data->reference()); };
-    int extractAccept(gnash::Network::byte_t *data);
-    int extractAccept(Buffer *data)
-       { return extractAccept(data->reference()); };
-    std::string &extractAcceptRanges(gnash::Network::byte_t *data);
-    std::string &extractAcceptRanges(Buffer *data)
-       { return extractAcceptRanges(data->reference()); };
-    int extractLanguage(gnash::Network::byte_t *data);
-    int extractLanguage(Buffer *data)
-       { return extractLanguage(data->reference()); };
-    int extractCharset(gnash::Network::byte_t *data);
-    int extractCharset(Buffer *data)
-       { return extractCharset(data->reference()); };
-    int extractEncoding(gnash::Network::byte_t *data);
-    int extractEncoding(Buffer *data)
-       { return extractEncoding(data->reference()); };
-    int extractTE(gnash::Network::byte_t *data);
-    int extractTE(Buffer *data)
-       { return extractTE(data->reference()); };
-    int extractConnection(gnash::Network::byte_t *data);
-    int extractConnection(Buffer *data)
-       { return extractConnection(data->reference()); };
-    int extractKeepAlive(gnash::Network::byte_t *data);
-    int extractKeepAlive(Buffer *data)
-       { return extractConnection(data->reference()); };
-
-    // These return the string that was found for this field.
-    std::string &extractMethod(gnash::Network::byte_t *data);
-    std::string &extractMethod(Buffer *data)
-       { return extractMethod(data->reference()); };
-    std::string &extractReferer(gnash::Network::byte_t *data);
-    std::string &extractReferer(Buffer *data)
-       { return extractReferer(data->reference()); };
-    std::string &extractHost(gnash::Network::byte_t *data);
-    std::string &extractHost(Buffer *data)
-       { return extractHost(data->reference()); };
-    std::string &extractAgent(gnash::Network::byte_t *data);
-    std::string &extractAgent(Buffer *data)
-       { return extractAgent(data->reference()); };
-
-    // These methods add data to the fields in the HTTP header.
-    // These return true if OK, false if error.
-    bool clearHeader();
-    bool formatHeader(int filesize, http_status_e type);
-    bool formatHeader(http_status_e type);
-    bool formatRequest(const std::string &url, http_method_e req);
-    bool formatMethod(const std::string &data);
-    bool formatDate();
-    bool formatServer();
-    bool formatServer(const std::string &data);
-    bool formatReferer(const std::string &data);
-    bool formatConnection(const std::string &data);
-    bool formatKeepAlive(const std::string &data);
-    bool formatContentLength();
-    bool formatContentLength(int filesize);
-    bool formatContentType();
-    bool formatContentType(filetype_e type);
-    bool formatHost(const std::string &data);
-    bool formatAgent(const std::string &data);
-    bool formatAcceptRanges(const std::string &data);
-    bool formatLastModified();
-    bool formatLastModified(const std::string &data);
-    bool formatEtag(const std::string &data);
-    bool formatLanguage(const std::string &data);
-    bool formatCharset(const std::string &data);
-    bool formatEncoding(const std::string &data);
-    bool formatTE(const std::string &data);
-
-    bool formatErrorResponse(http_status_e err);
-    
-    // All HTTP messages are terminated with a blank line
-    void terminateHeader() { _header << "\r\n"; };
-    
-    // Return the header that's been built up.
-    std::string getHeader() { return _header.str(); };
-
-    // Return the body that's been built up.
-    std::string getBody() { return _body.str(); };
-
-    // Get the file type, so we know how to set the
-    // Content-type in the header.
-//    filetype_e getFileType(std::string &filespec);
-    filetype_e getFileStats(std::string &filespec);
-    void dump();
-
-    // These accessors are used mostly just for debugging.
-    bool keepAlive() { return _keepalive; }
-    int getFileSize() { return _filesize; }
-    std::string &getFilespec() { return _filespec; }
-    std::string &getURL() { return _url; }
-    std::map<int, struct status_codes *> getStatusCodes()
-       { return _status_codes; }
-    std::string getVersion() { return _version; }
-    std::string getMethod() { return _method; }
-    std::string getReferer() { return _referer; }
-    std::vector<std::string> getLanguage() { return _language;  }
-    std::vector<std::string> getConnection() { return _connections; }
-    std::vector<std::string> getKeepAlive() { return _kalive; }
-    std::vector<std::string> getTE() { return _te; }
-    std::vector<std::string> getCharset() { return _charset; }
-    std::vector<std::string> getEncoding() { return _encoding; }
-
-    int         getHostPort(){ return _port; }
-    std::string getHost() { return _host; }
-    std::string getUserAgent() { return _agent; }
-
-    void setHandler(Handler *hand) { _handler = hand; };
-private:
-    std::stringstream _header;
-    std::stringstream _body;
-    std::string _command;
-    filetype_e  _filetype;
-    std::string _filespec;
-    int         _filesize;
-    std::string _url;
-    std::map<int, struct status_codes *> _status_codes;
-    std::string _version;
-    std::string _method;
-    std::string _referer;
-    std::string _host;
-    int         _port;
-    std::string _agent;
-    std::string _acceptranges;
-    std::vector<std::string> _connections;
-    std::vector<std::string> _language;
-    std::vector<std::string> _charset;
-    std::vector<std::string> _encoding;
-    std::vector<std::string> _te;
-    std::vector<std::string> _accept;
-    std::vector<std::string> _kalive;
-    // Connection parameters we care about
-    bool       _keepalive;
-    Handler     *_handler;
-    // These two field hold the data from an RTMPT message
-    int                _clientid;
-    int                _index;
-//    bool     _te;
-};  
-
-// This is the thread for all incoming HTTP connections, which
-// has to be in C.
-extern "C" {
-    void httphandler(Handler::thread_params_t *args);
-}
-
-
-} // end of cygnal namespace
-
-// end of _HTTP_H_
-#endif
-
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:

Index: netstats.cpp
===================================================================
RCS file: netstats.cpp
diff -N netstats.cpp
--- netstats.cpp        26 Mar 2008 00:02:03 -0000      1.11
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,75 +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 <boost/date_time/date.hpp>
-#include "netstats.h"
-#include "log.h"
-
-using namespace gnash;
-using namespace boost::posix_time;
-
-namespace cygnal {
-
-NetStats::NetStats()
-{
-//    GNASH_REPORT_FUNCTION;
-}
-
-NetStats::~NetStats()
-{
-//    GNASH_REPORT_FUNCTION;    
-}
-
-boost::posix_time::ptime
-NetStats::startClock()
-{
-//    GNASH_REPORT_FUNCTION;
-
-    _starttime = boost::posix_time::microsec_clock::local_time();
-    return _stoptime;
-}
-
-boost::posix_time::ptime
-NetStats::stopClock()
-{
-//    GNASH_REPORT_FUNCTION;
-    
-    _stoptime = boost::posix_time::microsec_clock::local_time();
-    return _stoptime;
-}
-
-NetStats &
-NetStats::operator = (NetStats &stats) {
-    _starttime = stats.getStartTime();
-    _stoptime = stats.getStopTime();
-    _bytes = stats.getBytes();
-    _type = stats.getFileType();
-    return *this;
-}
-
-} // end of cygnal namespace
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:

Index: netstats.h
===================================================================
RCS file: netstats.h
diff -N netstats.h
--- netstats.h  26 Mar 2008 00:02:03 -0000      1.7
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,125 +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 __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>
-
-// This is what the ActionScript 'Client' class returns:
-//
-// bytes_in            Total number of bytes received.
-// bytes_out           Total number of bytes sent.
-// msg_in              Total number of RTMP messages received.
-// msg_out             Total number of RTMP messages sent.
-// msg_dropped         Total number of dropped RTMP messages.
-// ping_rtt            Length of time the client takes to respond to a ping 
message.
-// audio_queue_msgs    Current number of audio messages in the queue waiting 
to be delivered to the client.
-// video_queue_msgs    Current number of video messages in the queue waiting 
to be delivered to the client.
-// so_queue_msgs       Current number of shared object messages in the queue 
waiting to be delivered to the client.
-// data_queue_msgs     Current number of data messages in the queue waiting to 
be delivered to the client.
-// dropped_audio_msgs  Number of audio messages that were dropped.
-// dropped_video_msgs  Number of video messages that were dropped.
-// audio_queue_bytes   Total size of all audio messages (in bytes) in the 
queue waiting to be delivered to the client.
-// video_queue_bytes   Total size of all video messages (in bytes) in the 
queue waiting to be delivered to the client.
-// so_queue_bytes      Total size of all shared object messages (in bytes) in 
the queue waiting to be delivered to the client.
-// data_queue_bytes    Total size of all data messages (in bytes) in the queue 
waiting to be delivered to the client.
-// dropped_audio_bytes Total size of all audio messages (in bytes) that were 
dropped.
-// dropped_video_bytes Total size of all video messages (in bytes) that were 
dropped.
-// bw_out              Current upstream (client to server) bandwidth for this 
client.
-// bw_in               Current downstream (server to client) bandwidth for 
this client.
-// client_id           A unique ID issued by the server for this client.
-//
-// samples are taken every 3 seconds, or the interval supplied in 
Client::setInterval()
-
-namespace cygnal 
-{
-
-class NetStats {
-public:
-    NetStats();
-    ~NetStats();
-    typedef enum {
-        NO_CODEC,
-        OGG,
-        THEORA,
-       DIRAC,
-       SNOW,
-        MP3,
-        MPEG4,
-       H264,
-       H263,
-        FLV,
-        VP6,
-        VP7
-    } codec_e;
-    typedef enum {
-        NO_FILETYPE,
-        HTTP,
-        RTMP,
-        RTMPT,
-        RTMPTS,
-        SWF,
-        SWF6,
-        SWF7,
-        SWF8,
-        SWF9,
-        AUDIO,
-        VIDEO
-    } filetypes_e;
-    // start the clock counting down
-    boost::posix_time::ptime startClock();
-    // stop the clock from counting down
-    boost::posix_time::ptime stopClock();
-    
-    // Accessors to set to the private data
-    void setStartTime(boost::posix_time::ptime x) { _starttime = x; };
-    void setStopTime(boost::posix_time::ptime x) { _stoptime = x; };
-    void setBytes(int x) { _bytes = x; };
-    void setFileType(filetypes_e x) { _type = x; };
-    // Accumulate the byts transferred
-    int addBytes(int x) { _bytes += x; return _bytes; };
-    
-    // Accessors to get to the private data
-    int getBytes() { return _bytes; };
-    filetypes_e getFileType() { return _type; };
-    boost::posix_time::ptime getStartTime() { return _starttime; };
-    boost::posix_time::ptime getStopTime() { return _stoptime; };
-    boost::posix_time::time_duration getTimeSpan() { return _stoptime - 
_starttime; };
-    NetStats &operator = (NetStats &stats);
-private:
-    boost::posix_time::ptime _starttime;
-    boost::posix_time::ptime _stoptime;
-    int                      _bytes;
-    filetypes_e              _type;
-};
- 
-} // end of cygnal namespace
-
-#endif // __NETSTATS_H__
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:

Index: statistics.cpp
===================================================================
RCS file: statistics.cpp
diff -N statistics.cpp
--- statistics.cpp      26 Mar 2008 00:02:03 -0000      1.8
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,137 +0,0 @@
-// statistics.cpp:  Network performance stats for Cygnal, for Gnash.
-// 
-//   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 <boost/thread/mutex.hpp>
-#include <string>
-#include <list>
-#include <iostream>
-
-#include "log.h"
-#include "netstats.h"
-#include "statistics.h"
-
-using namespace gnash;
-using namespace std;
-
-static boost::mutex io_mutex;
-
-// The string versions of the codec, used for debugging. If you add
-// another enum type to codec_e, you have to add the string
-// representation here or you'll get the wrong output.
-const char *codec_names[] = {
-    "NO_CODEC",
-    "Ogg",
-    "Theora",
-    "Dirac",
-    "Snow",
-    "MP3",
-    "MPEG4",
-    "H264",
-    "H263",
-    "FLV",
-    "VP6",
-    "VP7"
-};
-
-// The string versions of the file type, used for debugging. If you add
-// another enum type to filetypes_e, you have to add the string
-// representation here or you'll get the wrong output.
-const char *filetype_names[] = {
-        "NO_FILETYPE",
-       "HTTP",
-        "RTMP",
-        "RTMPT",
-        "RTMPTS",
-        "SWF",
-        "SWF5",
-        "SWF6",
-        "SWF7",
-        "SWF8",
-        "SWF9",
-        "AUDIO",
-        "VIDEO"
-};
-
-namespace cygnal 
-{
-
-Statistics::Statistics() {
-}
-
-Statistics::~Statistics() {
-    dump();
-}
-
-float
-Statistics::getFPS() {
-       return 0.0; // TODO: FIXME !
-}
-
-int
-Statistics::getBitRate() {
-
-    return (getStartTime() - getStopTime()).seconds() / getBytes();
-}
-
-int
-Statistics::addStats() {
-    NetStats *st = new NetStats;
-
-    st->setStartTime(getStartTime());
-    st->setStopTime(getStopTime());
-    st->setBytes(getBytes());
-    st->setFileType(getFileType());
-    
-    boost::mutex::scoped_lock lock(io_mutex);
-    _netstats.push_back(st);
-    
-    return _netstats.size();
-}
-
-void
-Statistics::dump() {   
-    boost::mutex::scoped_lock lock(io_mutex);
-    list<NetStats *>::iterator it;
-
-    for (it = _netstats.begin(); it != _netstats.end(); it++) {
-        NetStats *stats = (*it);
-        if (stats->getFileType() <= VIDEO) {
-            log_debug (_("Stream type is: %s"), 
filetype_names[stats->getFileType()]);
-        }
-//         if (((stats->getFileType() == VIDEO) || (stats->getFileType() == 
AUDIO)) &&
-//             stats->getCodec() <= VP7) {
-//             log_debug (_("Stream codec is: %s"), 
codec_names[stats->getCodec()]);
-//         }
-        log_debug (_("%d bytes were transfered in %s seconds"),
-                stats->getBytes(),
-                 to_simple_string(stats->getTimeSpan()).c_str());
-    }
-}
-
-} // end of cygnal namespace
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:

Index: statistics.h
===================================================================
RCS file: statistics.h
diff -N statistics.h
--- statistics.h        26 Mar 2008 00:02:03 -0000      1.8
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,95 +0,0 @@
-// 
-//   Copyright (C) 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 __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 
-{
-
-class Statistics : public NetStats {
-public:
-    Statistics();
-    ~Statistics();
-    typedef enum {
-        NO_BROWSER,
-        MOZILLA,
-        FIREFOX,
-        OPERA,
-        KONQUEROR,
-        GALEON,
-        EPIPHANY,
-        SAFARI,
-        IE
-    } browser_e;
-    typedef enum {
-        NO_OSTYPE,
-        LINUX,
-        BSDS,
-        DARWIN,
-        WIN32,
-        SOLARIS
-    } ostype_e;
-
-    // Add a sample
-    int addStats();
-    
-    // these make calculations on the collected network data.
-    float getFPS();
-    int getBitRate();
-    
-    // Accessors
-    void setIPaddr(in_addr_t x) { _ipaddr = x; };
-    void setBrowser(browser_e x) { _browser = x; } ;
-    void setOS(ostype_e x) { _os = x; } ;
-    in_addr_t getIPaddr() { return _ipaddr; };
-    browser_e getBrowser() { return _browser; };
-    ostype_e getOS() { return _os; };
-    
-//    void setFilespec(std::string &x) { _filespec = x; } ;
-//    std::string &getFilespec() { return _filespec; };
-    // Dump the collected network statistics in a human readable form.
-    void dump();
-    void clear();
-private:
-    in_addr_t           _ipaddr;
-    browser_e           _browser;
-    ostype_e            _os;
-    std::list<NetStats *> _netstats;
-    boost::uint32_t     _msg_count;
-    std::vector<std::string> _filespec;
-};
- 
-} // end of cygnal namespace
-
-#endif // __STATISTICS_H__
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]