[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash libbase/network.h libbase/network.cpp Cha...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash libbase/network.h libbase/network.cpp Cha... |
Date: |
Tue, 18 Mar 2008 15:15:13 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 08/03/18 15:15:13
Modified files:
libbase : network.h network.cpp
. : ChangeLog
Log message:
* libbase/network.{h,cpp}: Define NETBUFSIZE here instead of in
cygnal/buffer. Define "byte_t" typedef for raw data, change all
methods to use byte_t.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/network.h?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/network.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5961&r2=1.5962
Patches:
Index: libbase/network.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/network.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- libbase/network.h 21 Jan 2008 20:55:45 -0000 1.22
+++ libbase/network.h 18 Mar 2008 15:15:13 -0000 1.23
@@ -22,10 +22,6 @@
#include "gnashconfig.h"
#endif
-#include "tu_config.h"
-
-#include <string>
-
#if !defined(HAVE_WINSOCK_H) || defined(__OS2__)
# include <netinet/in.h>
# include <arpa/inet.h>
@@ -37,7 +33,9 @@
# include <io.h>
#endif
+#include <boost/cstdint.hpp>
#include <cassert>
+#include <string>
namespace gnash {
@@ -57,8 +55,13 @@
typedef int socklen_t;
#endif
-class DSOEXPORT Network {
+// Adjust for the constant size
+const size_t NETBUFSIZE = 1024;
+
+class Network {
public:
+ typedef boost::uint8_t byte_t;
+
Network();
~Network();
@@ -72,28 +75,26 @@
bool newConnection(bool block);
// Connect to a named pipe
- bool connectSocket(const char *sock);
+ bool connectSocket(const std::string &sock);
// Create a client connection to a tcp/ip server
bool createClient(void);
bool createClient(short port);
- bool createClient(const char *hostname);
- bool createClient(const char *hostname, short port);
+ bool createClient(const std::string &hostname);
+ bool createClient(const std::string &hostname, short port);
// Read from the connection
- int readNet(char *buffer, int nbytes);
- int readNet(char *buffer, int nbytes, int timeout);
- int readNet(int fd, char *buffer, int nbytes);
- int readNet(int fd, char *buffer, int nbytes, int timeout);
+ int readNet(byte_t *buffer, int nbytes);
+ int readNet(byte_t *buffer, int nbytes, int timeout);
+ int readNet(int fd, byte_t *buffer, int nbytes);
+ int readNet(int fd, byte_t *buffer, int nbytes, int timeout);
// Write to the connection
- int writeNet(const std::string& buffer);
- int writeNet(char const *buffer);
- int writeNet(char const *buffer, int nbytes);
- int writeNet(const unsigned char *buffer, int nbytes);
- int writeNet(int fd, char const *buffer);
- int writeNet(int fd, char const *buffer, int nbytes);
- int writeNet(int fd, char const *buffer, int nbytes, int timeout);
+ int writeNet(const std::string &buffer);
+ int writeNet(const byte_t *buffer, int nbytes);
+// int writeNet(int fd, const byte_t *buffer);
+ int writeNet(int fd, const byte_t *buffer, int nbytes);
+ int writeNet(int fd, const byte_t *buffer, int nbytes, int timeout);
// Close the connection
bool closeNet();
Index: libbase/network.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/network.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- libbase/network.cpp 19 Feb 2008 19:20:50 -0000 1.34
+++ libbase/network.cpp 18 Mar 2008 15:15:13 -0000 1.35
@@ -1,4 +1,3 @@
-// network.cpp: TCP/IP support, for Gnash.
//
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
//
@@ -304,7 +303,7 @@
// Connect to a named pipe
bool
-Network::connectSocket(const char *sockname)
+Network::connectSocket(const string &sockname)
{
// GNASH_REPORT_FUNCTION;
@@ -316,7 +315,7 @@
addr.sun_family = AF_UNIX;
// socket names must be 108 bytes or less as specifiec in sys/un.h.
- strncpy(addr.sun_path, sockname, 100);
+ strncpy(addr.sun_path, sockname.c_str(), 100);
_sockfd = ::socket(AF_UNIX, SOCK_STREAM, 0);
if (_sockfd < 0)
@@ -411,7 +410,7 @@
}
bool
-Network::createClient(const char *hostname)
+Network::createClient(const string &hostname)
{
// GNASH_REPORT_FUNCTION;
@@ -419,7 +418,7 @@
}
bool
-Network::createClient(const char *hostname, short port)
+Network::createClient(const string &hostname, short port)
{
// GNASH_REPORT_FUNCTION;
@@ -443,7 +442,7 @@
memset(&sock_in, 0, sizeof(struct sockaddr_in));
memset(&thishostname, 0, MAXHOSTNAMELEN);
- if (strlen(hostname) == 0) {
+ if (hostname.size() == 0) {
if (gethostname(thishostname, MAXHOSTNAMELEN) == 0) {
log_debug(_("The hostname for this machine is %s"), thishostname);
} else {
@@ -451,7 +450,7 @@
return false;
}
}
- const struct hostent *hent = ::gethostbyname(hostname);
+ const struct hostent *hent = ::gethostbyname(hostname.c_str());
if (hent > 0) {
::memcpy(&sock_in.sin_addr, hent->h_addr, hent->h_length);
}
@@ -640,25 +639,25 @@
// Read from the connection
int
-Network::readNet(char *buffer, int nbytes)
+Network::readNet(byte_t *buffer, int nbytes)
{
return readNet(_sockfd, buffer, nbytes, _timeout);
}
int
-Network::readNet(char *buffer, int nbytes, int timeout)
+Network::readNet(byte_t *buffer, int nbytes, int timeout)
{
return readNet(_sockfd, buffer, nbytes, timeout);
}
int
-Network::readNet(int fd, char *buffer, int nbytes)
+Network::readNet(int fd, byte_t *buffer, int nbytes)
{
return readNet(fd, buffer, nbytes, _timeout);
}
int
-Network::readNet(int fd, char *buffer, int nbytes, int timeout)
+Network::readNet(int fd, byte_t *buffer, int nbytes, int timeout)
{
fd_set fdset;
int ret = -1;
@@ -672,7 +671,7 @@
+ static_cast<double>(tp.tv_usec*1e-6);
}
#endif
- if (fd > 0) {
+ if (fd > 2) {
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
@@ -703,19 +702,14 @@
if (_debug) {
log_debug (_("read %d bytes from fd %d"), ret, fd);
}
+#if 1
+ if (ret) {
+ log_debug (_("%s: Read packet data from fd %d (%d bytes): \n%s"),
+ __FUNCTION__, fd, ret, hexify(buffer, ret, true));
}
-
-#if 0
- unsigned char *hexint;
- hexint = new unsigned char[(nbytes + 3) *3];
-
- hexify(hexint, (unsigned char *)buffer, ret, true);
- log_debug (_("%s: Read packet data from fd %d: \n%s"),
- __FUNCTION__, fd, (char *)hexint);
-// hexify(hexint, (unsigned char *)buffer, ret, false);
-// log_debug (_("%s: The packet data is: 0x%s"), __FUNCTION__, (char
*)hexint);
- delete hexint;
#endif
+ }
+
return ret;
}
@@ -724,47 +718,42 @@
int
Network::writeNet(const std::string& buffer)
{
- return writeNet(buffer.c_str(), buffer.size());
+ return writeNet(reinterpret_cast<const byte_t *>(buffer.c_str()),
buffer.size());
}
int
-Network::writeNet(char const *buffer)
+Network::writeNet(const byte_t *buffer, int nbytes)
{
- return writeNet(buffer, strlen(buffer));
+return writeNet(_sockfd, buffer, nbytes, _timeout);
}
-int
-Network::writeNet(char const *buffer, int nbytes)
-{
- return writeNet(_sockfd, buffer, nbytes, _timeout);
-}
-
-int
-Network::writeNet(const unsigned char *buffer, int nbytes)
-{
- return writeNet(_sockfd, (const char*)buffer, nbytes, _timeout);
-}
+// int
+// Network::writeNet(const byte_t *buffer, int nbytes)
+// {
+// return writeNet(_sockfd, buffer, nbytes, _timeout);
+// }
-int
-Network::writeNet(int fd, char const *buffer)
-{
- return writeNet(fd, buffer, strlen(buffer), _timeout);
-}
+// int
+// Network::writeNet(int fd, const byte_t *buffer)
+// {
+// return writeNet(fd, buffer, strlen(buffer), _timeout);
+// }
int
-Network::writeNet(int fd, char const *buffer, int nbytes)
+Network::writeNet(int fd, const byte_t *buffer, int nbytes)
{
return writeNet(fd, buffer, nbytes, _timeout);
}
int
-Network::writeNet(int fd, char const *buffer, int nbytes, int timeout)
+Network::writeNet(int fd, const byte_t *buffer, int nbytes, int timeout)
{
fd_set fdset;
int ret = -1;
struct timeval tval;
- const char *bufptr = buffer;
+ // We need a writable, and not const point for byte arithmetic.
+ byte_t *bufptr = const_cast<byte_t *>(buffer);
#ifdef NET_TIMING
// If we are debugging the tcp/ip timings, get the initial time.
@@ -773,7 +762,7 @@
gettimeofday(&starttime, 0);
}
#endif
- if (fd) {
+ if (fd > 2) {
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
@@ -825,6 +814,12 @@
// return ret;
}
}
+#if 1
+ if (ret) {
+ log_debug (_("%s: Wrote packet data to fd %d: \n%s"),
+ __FUNCTION__, fd, hexify(buffer, ret, true));
+ }
+#endif
}
#ifdef NET_TIMING
@@ -841,18 +836,6 @@
}
#endif
-#if 0
- unsigned char *hexint;
- hexint = new unsigned char[(nbytes + 3) *3];
-
- hexify(hexint, (unsigned char *)buffer, nbytes, true);
- log_debug (_("%s: Wrote packet data to fd %d: \n%s"),
- __FUNCTION__, fd, (char *)hexint);
-// hexify(hexint, (unsigned char *)buffer, ret, false);
-// log_debug (_("%s: Read packet data from fd %d: 0x%s"),
-// __FUNCTION__, fd, (char *)hexint);
- delete hexint;
-#endif
return ret;
}
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5961
retrieving revision 1.5962
diff -u -b -r1.5961 -r1.5962
--- ChangeLog 18 Mar 2008 15:11:53 -0000 1.5961
+++ ChangeLog 18 Mar 2008 15:15:13 -0000 1.5962
@@ -1,3 +1,9 @@
+2008-03-18 Rob Savoye <address@hidden>
+
+ * libbase/network.{h,cpp}: Define NETBUFSIZE here instead of in
+ cygnal/buffer. Define "byte_t" typedef for raw data, change all
+ methods to use byte_t.
+
2008-03-18 Benjamin Wolsey <address@hidden>
* testsuite/actionscript.all/array.cpp: tests for non-integer and
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash libbase/network.h libbase/network.cpp Cha...,
Rob Savoye <=