myserver-commit
[Top][All Lists]
Advanced

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

[myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-417


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-417-g92e2115
Date: Wed, 26 Jan 2011 17:44:18 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  92e2115543b195ac931ab214ef792ebe5325a1d6 (commit)
       via  252124f913643007cd89a3c90a4317c74c4496fa (commit)
      from  c03b56017c67e5ef01346d919ed7953963074fd2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 92e2115543b195ac931ab214ef792ebe5325a1d6
Author: Giuseppe Scrivano <address@hidden>
Date:   Wed Jan 26 18:44:49 2011 +0100

    tests: Add tests for the string utils module.

diff --git a/myserver/tests/Makefile.am b/myserver/tests/Makefile.am
index 3353b7a..36db091 100644
--- a/myserver/tests/Makefile.am
+++ b/myserver/tests/Makefile.am
@@ -75,6 +75,7 @@ test_suite_SOURCES =          main.cpp                        
        \
                        test_socket_pair.cpp                    \
                        test_socket_stream_creator.cpp          \
                        test_ssl_socket.cpp                     \
+                       test_stringutils.cpp \
                        test_thread.cpp                         \
                        test_unix_socket.cpp                    \
                        test_url.cpp                            \
diff --git a/myserver/tests/test_stringutils.cpp 
b/myserver/tests/test_stringutils.cpp
new file mode 100644
index 0000000..8bdb6bc
--- /dev/null
+++ b/myserver/tests/test_stringutils.cpp
@@ -0,0 +1,169 @@
+/*
+  MyServer
+  Copyright (C) 2008, 2009, 2010, 2011 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "myserver.h"
+#include "include/base/string/stringutils.h"
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <include/base/file/files_utility.h>
+#include <string.h>
+
+#include <string>
+
+using namespace std;
+
+class TestStringUtils : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE ( TestStringUtils );
+  CPPUNIT_TEST (testTranslateEscapeString);
+  CPPUNIT_TEST (testHexToInt);
+  CPPUNIT_TEST (testHexVal);
+  CPPUNIT_TEST (testTrim);
+  CPPUNIT_TEST (testTrimLeft);
+  CPPUNIT_TEST (testTrimRight);
+  CPPUNIT_TEST (testGetTime);
+  CPPUNIT_TEST (testGetRFC822GMTTime);
+  CPPUNIT_TEST_SUITE_END ();
+
+public:
+  void setUp () {}
+  void tearDown () {}
+
+  void testTrim ()
+  {
+    char buffer[1024];
+#define TEST_TRIM(A, B, C)                      \
+    strcpy (buffer, A);                         \
+    trim (buffer, B);                           \
+    CPPUNIT_ASSERT (! strcmp (buffer, C));
+
+    TEST_TRIM ("hello ", " ", "hello");
+    TEST_TRIM ("hello ", "o ", "hell");
+    TEST_TRIM (" hello ", " ", "hello");
+
+#undef TEST_TRIM
+  }
+
+  void testTrimLeft ()
+  {
+    char buffer[1024];
+#define TEST_TRIM(A, B, C)                          \
+    strcpy (buffer, A);                             \
+    CPPUNIT_ASSERT (! strcmp (trimLeft (buffer, B).c_str (), C));
+
+    TEST_TRIM ("hello ", " ", "hello ");
+    TEST_TRIM ("hello ", "o ", "hello ");
+    TEST_TRIM (" hello ", " ", "hello ");
+
+#undef TEST_TRIM
+  }
+
+  void testTrimRight ()
+  {
+    char buffer[1024];
+#define TEST_TRIM(A, B, C)                                          \
+    strcpy (buffer, A);                                             \
+    CPPUNIT_ASSERT (! strcmp (trimRight (buffer, B).c_str (), C));
+
+    TEST_TRIM ("hello ", " ", "hello");
+    TEST_TRIM ("  hello ", "o ", "  hell");
+    TEST_TRIM (" hello ", " ", " hello");
+
+#undef TEST_TRIM
+  }
+
+  void testGetRFC822GMTTime ()
+  {
+    time_t epoch = 0;
+    string out;
+    const char* ret = getRFC822GMTTime (epoch, out);
+    CPPUNIT_ASSERT (! strcasecmp (ret, "Thu, 1 Jan 1970 00:00:00 GMT"));
+    CPPUNIT_ASSERT (! strcasecmp (out.c_str (), "Thu, 1 Jan 1970 00:00:00 
GMT"));
+
+    ret = getRFC822GMTTime (1009972800, out);
+    CPPUNIT_ASSERT (! strcasecmp (ret, "Wed, 2 Jan 2002 12:00:00 GMT"));
+    CPPUNIT_ASSERT (! strcasecmp (out.c_str (), "Wed, 2 Jan 2002 12:00:00 
GMT"));
+  }
+
+  void testGetTime ()
+  {
+    string out;
+    time_t epoch = 0;
+    const char* ret = getRFC822LocalTime (epoch, out);
+
+    CPPUNIT_ASSERT_EQUAL (getTime (ret), epoch);
+  }
+
+  void testHexVal ()
+  {
+    CPPUNIT_ASSERT_EQUAL (hexVal ('A'), 10);
+    CPPUNIT_ASSERT_EQUAL (hexVal ('a'), 10);
+    CPPUNIT_ASSERT_EQUAL (hexVal ('B'), 11);
+    CPPUNIT_ASSERT_EQUAL (hexVal ('b'), 11);
+    CPPUNIT_ASSERT_EQUAL (hexVal ('1'), 1);
+    CPPUNIT_ASSERT_EQUAL (hexVal ('9'), 9);
+    CPPUNIT_ASSERT_EQUAL (hexVal ('0'), 0);
+  }
+
+  void testHexToInt ()
+  {
+    CPPUNIT_ASSERT_EQUAL (hexToInt ("A"), 10);
+    CPPUNIT_ASSERT_EQUAL (hexToInt ("a"), 10);
+    CPPUNIT_ASSERT_EQUAL (hexToInt ("1"), 1);
+    CPPUNIT_ASSERT_EQUAL (hexToInt ("10"), 1 << 4);
+    CPPUNIT_ASSERT_EQUAL (hexToInt ("1A"), (1 << 4) + 10);
+    CPPUNIT_ASSERT_EQUAL (hexToInt ("Aa"), (10 << 4) + 10);
+  }
+
+  void testTranslateEscapeString ()
+  {
+    char buffer[1024];
+    strcpy (buffer, "%20");
+    translateEscapeString (buffer);
+    CPPUNIT_ASSERT (translateSingleEscapeString ("%20", " "));
+    CPPUNIT_ASSERT (translateSingleEscapeString ("+", " "));
+    CPPUNIT_ASSERT (translateSingleEscapeString ("foo%20", "foo "));
+    CPPUNIT_ASSERT (translateSingleEscapeString ("foo+", "foo "));
+    CPPUNIT_ASSERT (translateSingleEscapeString ("fooo+", "fooo "));
+    CPPUNIT_ASSERT (translateSingleEscapeString ("%301%323%34", "01234"));
+  }
+
+private:
+  bool translateSingleEscapeString (char const *in, char const *desired)
+  {
+    char *buffer = gnulib::strdup (in);
+    if (! buffer)
+      return false;
+
+    translateEscapeString (buffer);
+    bool ret = ! strcmp (buffer, desired);
+    free (buffer);
+
+    if (! ret)
+      return false;
+
+    string strBuffer (in);
+    translateEscapeString (strBuffer);
+    ret = ! strcmp (strBuffer.c_str (), desired);
+
+    return ret;
+  }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION ( TestStringUtils );



commit 252124f913643007cd89a3c90a4317c74c4496fa
Author: Giuseppe Scrivano <address@hidden>
Date:   Wed Jan 26 18:44:32 2011 +0100

    time functions don't accept a len parameter anymore.

diff --git a/myserver/include/base/string/stringutils.h 
b/myserver/include/base/string/stringutils.h
index 7b6b766..4480991 100644
--- a/myserver/include/base/string/stringutils.h
+++ b/myserver/include/base/string/stringutils.h
@@ -27,27 +27,27 @@
 
 using namespace std;
 
-const char *getRFC822GMTTime (char* out,int len);
-const char *getRFC822GMTTime (const time_t,char* out,int len);
-const char *getRFC822LocalTime (char* out,int len);
-const char *getRFC822LocalTime (const time_t,char* out,int len);
+const char *getRFC822GMTTime (char* out);
+const char *getRFC822GMTTime (const time_t,char* out);
+const char *getRFC822LocalTime (char* out);
+const char *getRFC822LocalTime (const time_t,char* out);
 
-const char *getRFC822GMTTime (string& out,int len);
-const char *getRFC822GMTTime (const time_t, string& out, int len);
-const char *getRFC822LocalTime (string& out,int len);
-const char *getRFC822LocalTime (const time_t, string &out,int len);
+const char *getRFC822GMTTime (string& out);
+const char *getRFC822GMTTime (const time_t, string& out);
+const char *getRFC822LocalTime (string& out);
+const char *getRFC822LocalTime (const time_t, string &out);
 
 int getCharInString (const char*,const char*,int max);
 
-const char* getLocalLogFormatDate (const time_t t, char* out, int len);
-const char* getGMTLogFormatDate (const time_t t, char* out, int len);
-const char* getLocalLogFormatDate (char* out, int len);
-const char* getGMTLogFormatDate (char* out, int len);
+const char* getLocalLogFormatDate (const time_t t, char* out);
+const char* getGMTLogFormatDate (const time_t t, char* out);
+const char* getLocalLogFormatDate (char* out);
+const char* getGMTLogFormatDate (char* out);
 
-const char* getLocalLogFormatDate (const time_t t, string& out, int len);
-const char* getGMTLogFormatDate (const time_t t, string& out, int len);
-const char* getLocalLogFormatDate (string& out, int len);
-const char* getGMTLogFormatDate (string& out, int len);
+const char* getLocalLogFormatDate (const time_t t, string& out);
+const char* getGMTLogFormatDate (const time_t t, string& out);
+const char* getLocalLogFormatDate (string& out);
+const char* getGMTLogFormatDate (string& out);
 
 time_t getTime (const char* str);
 inline time_t getTime (string const& str){ return getTime (str.c_str ()); }
@@ -62,7 +62,7 @@ void translateEscapeString (char *TargetStr);
 void translateEscapeString (string& TargetStr);
 
 int hexToInt (const char *str);
-inline time_t hexToInt (string const& str){ return hexToInt (str.c_str ()); }
+inline int hexToInt (string const& str){ return hexToInt (str.c_str ()); }
 
 int getEndLine (const char* str, int max);
 inline int getEndLine (string const& str, int max)
diff --git a/myserver/src/base/string/stringutils.cpp 
b/myserver/src/base/string/stringutils.cpp
index e1f06de..b2eb044 100644
--- a/myserver/src/base/string/stringutils.cpp
+++ b/myserver/src/base/string/stringutils.cpp
@@ -43,21 +43,21 @@
   This function format current time to the RFC 822 format and output
   it to a string.
  */
-const char *getRFC822GMTTime (string& out,int len)
+const char *getRFC822GMTTime (string& out)
 {
   time_t ltime;
   time ( &ltime );
-  return getRFC822GMTTime (ltime, out, len);
+  return getRFC822GMTTime (ltime, out);
 }
 
 /*!
   This function format current time to the RFC 822 format and output
   it to a string.
  */
-const char *getRFC822GMTTime (const time_t t, string& out, int len)
+const char *getRFC822GMTTime (const time_t t, string& out)
 {
   char buff[32];
-  getRFC822GMTTime (t, buff, 32);
+  getRFC822GMTTime (t, buff);
   out.assign (buff);
   return out.c_str ();
 }
@@ -66,21 +66,21 @@ const char *getRFC822GMTTime (const time_t t, string& out, 
int len)
   This function format current time to the RFC 822 format and output
   it to a string.
  */
-const char *getRFC822LocalTime (string& out,int len)
+const char *getRFC822LocalTime (string& out)
 {
   time_t ltime;
   time (&ltime);
-  return getRFC822LocalTime (ltime, out, len);
+  return getRFC822LocalTime (ltime, out);
 }
 
 /*!
   This function format current time to the RFC 822 format and output
   it to a string.
  */
-const char *getRFC822LocalTime (const time_t t, string &out,int len)
+const char *getRFC822LocalTime (const time_t t, string &out)
 {
   char buff[32];
-  getRFC822LocalTime (t, buff, 32);
+  getRFC822LocalTime (t, buff);
   out.assign (buff);
   return out.c_str ();
 }
@@ -88,23 +88,24 @@ const char *getRFC822LocalTime (const time_t t, string 
&out,int len)
 /*!
   This function format current time to the RFC 822 format.
  */
-const char *getRFC822GMTTime (char* out, int len)
+const char *getRFC822GMTTime (char* out)
 {
   time_t ltime;
   time (&ltime);
-  return getRFC822GMTTime (ltime, out, len);
+  return getRFC822GMTTime (ltime, out);
 }
 
 /*!
   This function formats a time to the RFC 822 format.
  */
-const char *getRFC822GMTTime (const time_t ltime, char* out, int /*!len*/)
+const char *getRFC822GMTTime (const time_t ltime, char* out)
 {
   char *asct;
+  char buffer[32];
   u_long ind = 0;
   tm* gmTime = gmtime (&ltime);
   gmTime->tm_year += 1900;
-  asct= asctime (gmTime);
+  asct = asctime_r (gmTime, buffer);
   out[ind++]= asct[0];
   out[ind++]= asct[1];
   out[ind++]= asct[2];
@@ -152,6 +153,7 @@ time_t getTime (const char* str)
   int c = 0;
   int i;
   tm t;
+  memset (&t, 0, sizeof (t));
   for (i = 0; i < 30; i++)
     {
       if (str[c] == ',')
@@ -317,25 +319,26 @@ time_t getTime (const char* str)
 /*!
   This function format current time to the RFC 822 format.
  */
-const char *getRFC822LocalTime (char* out, int len)
+const char *getRFC822LocalTime (char* out)
 {
   time_t ltime;
   time (&ltime);
-  return getRFC822LocalTime (ltime, out, len);
+  return getRFC822LocalTime (ltime, out);
 }
 /*!
   This function formats a time to the RFC 822 format.
  */
-const char *getRFC822LocalTime (const time_t ltime, char* out, int /*!len*/)
+const char *getRFC822LocalTime (const time_t ltime, char* out)
 {
   char *asct;
   tm result;
   u_long ind = 0;
+  char buffer[32];
 
   myserver_localtime (&ltime, &result);
 
   result.tm_year += 1900;
-  asct = asctime (&result);
+  asct = asctime_r (&result, buffer);
   out[ind++] = asct[0];
   out[ind++] = asct[1];
   out[ind++] = asct[2];
@@ -377,31 +380,31 @@ const char *getRFC822LocalTime (const time_t ltime, char* 
out, int /*!len*/)
 /*!
   Get the local time string.
  */
-const char* getLocalLogFormatDate (char* out, int len)
+const char* getLocalLogFormatDate (char* out)
 {
   time_t ltime;
   time (&ltime);
-  return getLocalLogFormatDate (ltime, out, len);
+  return getLocalLogFormatDate (ltime, out);
 }
 
 /*!
   Get the GMT time string.
  */
-const char* getGMTLogFormatDate (char* out, int len)
+const char* getGMTLogFormatDate (char* out)
 {
   time_t ltime;
   time (&ltime);
-  return getGMTLogFormatDate (ltime, out, len);
+  return getGMTLogFormatDate (ltime, out);
 }
 
 
 /*!
   Get the local time string.
  */
-const char* getLocalLogFormatDate (const time_t t, string& out, int len)
+const char* getLocalLogFormatDate (const time_t t, string& out)
 {
   char buff[32];
-  getLocalLogFormatDate (t, buff, len);
+  getLocalLogFormatDate (t, buff);
   out.assign (buff);
   return out.c_str ();
 }
@@ -409,20 +412,20 @@ const char* getLocalLogFormatDate (const time_t t, 
string& out, int len)
 /*!
   Get the GMT time string.
  */
-const char* getGMTLogFormatDate (const time_t t, string& out, int len)
+const char* getGMTLogFormatDate (const time_t t, string& out)
 {
   char buff[32];
-  getGMTLogFormatDate (t, buff, len);
+  getGMTLogFormatDate (t, buff);
   out.assign (buff);
   return out.c_str ();
 }
 /*!
   Get the local time string.
  */
-const char* getLocalLogFormatDate (string& out, int len)
+const char* getLocalLogFormatDate (string& out)
 {
   char buff[32];
-  getLocalLogFormatDate (buff, len);
+  getLocalLogFormatDate (buff);
   out.assign (buff);
   return out.c_str ();
 }
@@ -430,10 +433,10 @@ const char* getLocalLogFormatDate (string& out, int len)
 /*!
   Get the GMT time string.
  */
-const char* getGMTLogFormatDate (string& out, int len)
+const char* getGMTLogFormatDate (string& out)
 {
   char buff[32];
-  getGMTLogFormatDate (buff, len);
+  getGMTLogFormatDate (buff);
   out.assign (buff);
   return out.c_str ();
 }
@@ -442,19 +445,19 @@ const char* getGMTLogFormatDate (string& out, int len)
   Get a string in the format "day/month/year:hour:minute:second offset"
   for the local zone.
  */
-const char* getLocalLogFormatDate (const time_t t, char* out, int len)
+const char* getLocalLogFormatDate (const time_t t, char* out)
 {
   int offset = 0;
   time_t ltime;
   time (&ltime);
   char *asct;
   tm gmTime;
-  myserver_localtime (&ltime, &gmTime );
-  if (len < 25)
-    return 0;
+  char buffer[32];
+
+  myserver_localtime (&ltime, &gmTime);
 
   gmTime.tm_year += 1900;
-  asct = asctime (&gmTime);
+  asct = asctime_r (&gmTime, buffer);
   out[0] = asct[8] != ' ' ? asct[8] : '0';
   out[1] = asct[9];
   out[2] = '/';
@@ -511,20 +514,18 @@ const char* getLocalLogFormatDate (const time_t t, char* 
out, int len)
   Get a string in the format "day/month/year:hour:minute:second offset"
   for the GMT zone.
  */
-const char* getGMTLogFormatDate (const time_t t, char* out, int len)
+const char* getGMTLogFormatDate (const time_t t, char* out)
 {
   time_t ltime;
   time (&ltime);
   char *asct;
   tm result;
+  char buffer[32];
 
   myserver_localtime ( &ltime, &result );
 
-  if (len < 25)
-    return 0;
-
   result.tm_year += 1900;
-  asct = asctime (&result);
+  asct = asctime_r (&result, buffer);
   out[0] = asct[8] != ' ' ? asct[8] : '0';
   out[1] = asct[9];
   out[2] = '/';
@@ -662,7 +663,10 @@ void gotoNextLine (char** cmd)
       i = i + 3;                                                        \
     }                                                                   \
   else if (str[i] == '+')                                               \
-    str[j] = ' ';                                                       \
+    {                                                                   \
+      str[j] = ' ';                                                     \
+      i++;                                                              \
+    }                                                                   \
   else                                                                  \
     str[j] = str[i++];                                                  \
                                                                         \
diff --git a/myserver/src/http_handler/http_dir/http_dir.cpp 
b/myserver/src/http_handler/http_dir/http_dir.cpp
index dfdc99d..5b67a38 100644
--- a/myserver/src/http_handler/http_dir/http_dir.cpp
+++ b/myserver/src/http_handler/http_dir/http_dir.cpp
@@ -251,7 +251,7 @@ void HttpDir::generateElement (MemBuf &out,
       break;
 
     case 't':
-      getRFC822GMTTime (file.time_write, fileTime, 32);
+      getRFC822GMTTime (file.time_write, fileTime);
       out << "<td>";
       out << fileTime ;
       out << "</td>\r\n";
diff --git a/myserver/src/http_handler/http_file/http_file.cpp 
b/myserver/src/http_handler/http_file/http_file.cpp
index 3721075..b9365fc 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -235,7 +235,7 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
       if (lastMT == -1)
         return td->http->raiseHTTPError (500);
 
-      getRFC822GMTTime (lastMT, tmpTime, 32);
+      getRFC822GMTTime (lastMT, tmpTime);
       td->response.setValue ("last-modified", tmpTime.c_str ());
 
       HttpRequestHeader::Entry *ifModifiedSince =
diff --git a/myserver/src/log/log_manager.cpp b/myserver/src/log/log_manager.cpp
index fab1941..4249aea 100644
--- a/myserver/src/log/log_manager.cpp
+++ b/myserver/src/log/log_manager.cpp
@@ -653,7 +653,7 @@ LogManager::log (const void* owner, const string & type, 
LoggingLevel level,
           char time[38];
           int len;
           time[0] = '[';
-          getRFC822GMTTime (&time[1], 32);
+          getRFC822GMTTime (&time[1]);
           len = strlen (time);
           time[len + 0] = ']';
           time[len + 1] = ' ';
diff --git a/myserver/src/log/stream/file_stream.cpp 
b/myserver/src/log/stream/file_stream.cpp
index 56c38e2..f8d85e6 100644
--- a/myserver/src/log/stream/file_stream.cpp
+++ b/myserver/src/log/stream/file_stream.cpp
@@ -79,7 +79,7 @@ FileStream::makeNewFileName (string oldFileName)
   FilesUtility::splitPath (oldFileName, filedir, filename);
   FilesUtility::getFileExt (ext, filename);
 
-  getRFC822LocalTime (time, 32);
+  getRFC822LocalTime (time);
   time = trim (time.substr (5, 32));
 
   for (int i = 0; i < static_cast<int>(time.length ()); i++)
diff --git a/myserver/src/protocol/control/control_protocol.cpp 
b/myserver/src/protocol/control/control_protocol.cpp
index f7f0c0a..b3cbc6c 100644
--- a/myserver/src/protocol/control/control_protocol.cpp
+++ b/myserver/src/protocol/control/control_protocol.cpp
@@ -452,7 +452,7 @@ int ControlProtocol::addToLog (int retCode, ConnectionPtr 
con, char *buffer,
                                int bufferSize, ControlHeader &header)
 {
   string time;
-  getRFC822GMTTime (time, 32);
+  getRFC822GMTTime (time);
   gnulib::snprintf (buffer, bufferSize, "%s [%s] %s:%s:%s - %s - %i",
                     con->getIpAddr (), time.c_str (), header.getCommand (),
                     header.getVersion (), header.getOptions (),
diff --git a/myserver/src/protocol/ftp/ftp.cpp 
b/myserver/src/protocol/ftp/ftp.cpp
index eb7cbc9..c1e8a4d 100644
--- a/myserver/src/protocol/ftp/ftp.cpp
+++ b/myserver/src/protocol/ftp/ftp.cpp
@@ -434,7 +434,7 @@ void Ftp::logAccess (int nReplyCode, const std::string & 
sCustomText)
   string time;
   char msgCode[12];
   sprintf (msgCode, "%i", nReplyCode);
-  getLocalLogFormatDate (time, 32);
+  getLocalLogFormatDate (time);
 
   td.auxiliaryBuffer->setLength (0);
   *td.auxiliaryBuffer << time
@@ -1769,7 +1769,7 @@ Ftp::list (const std::string & sParam /*= ""*/ )
           perm[9] = guestMask & MYSERVER_PERMISSION_EXECUTE ? 'x' : '-';
 
           string date;
-          const char *datePtr = getRFC822LocalTime (fd.time_write, date, 32);
+          const char *datePtr = getRFC822LocalTime (fd.time_write, date);
 
           char dateFtpFormat[13];
 
@@ -1855,7 +1855,7 @@ Ftp::list (const std::string & sParam /*= ""*/ )
           perm[9] = guestMask & MYSERVER_PERMISSION_EXECUTE ? 'x' : '-';
 
           string date;
-          const char *datePtr = getRFC822LocalTime (fd.time_write, date, 32);
+          const char *datePtr = getRFC822LocalTime (fd.time_write, date);
 
           char dateFtpFormat[13];
 
diff --git a/myserver/src/protocol/http/env/env.cpp 
b/myserver/src/protocol/http/env/env.cpp
index 782e112..7a15572 100644
--- a/myserver/src/protocol/http/env/env.cpp
+++ b/myserver/src/protocol/http/env/env.cpp
@@ -177,11 +177,11 @@ void Env::buildEnvironmentString (HttpThreadContext* td, 
char *cgiEnv,
   memCgi << td->request.uri.c_str ();
 
   memCgi << end_str << "DATE_GMT=";
-  getRFC822GMTTime (strTmp, 32);
+  getRFC822GMTTime (strTmp);
   memCgi << strTmp;
 
   memCgi << end_str << "DATE_LOCAL=";
-  getRFC822LocalTime (strTmp, 32);
+  getRFC822LocalTime (strTmp);
   memCgi << strTmp;
 
   memCgi << end_str << "DOCUMENT_ROOT=";
diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index 02fbdc8..a930120 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -123,7 +123,7 @@ int Http::optionsHTTPRESOURCE (string& filename, bool 
yetmapped)
       if (ret != 200)
         return raiseHTTPError (ret);
 
-      getRFC822GMTTime (time, 32);
+      getRFC822GMTTime (time);
       td->auxiliaryBuffer->setLength (0);
       *td->auxiliaryBuffer << "HTTP/1.1 200 OK\r\n";
       *td->auxiliaryBuffer << "Date: " << time;
@@ -163,7 +163,7 @@ int Http::traceHTTPRESOURCE (string& filename, bool 
yetmapped)
         return raiseHTTPError (ret);
 
       tmp.intToStr (contentLength, tmpStr, 12);
-      getRFC822GMTTime (time, 32);
+      getRFC822GMTTime (time);
 
       td->auxiliaryBuffer->setLength (0);
       *td->auxiliaryBuffer << "HTTP/1.1 200 OK\r\n";
@@ -771,7 +771,7 @@ int Http::logHTTPaccess ()
 
       *td->auxiliaryBuffer << " [";
 
-      getLocalLogFormatDate (time, 32);
+      getLocalLogFormatDate (time);
       *td->auxiliaryBuffer << time << "] \"";
 
       if (td->request.cmd.length ())
@@ -1289,7 +1289,7 @@ int Http::requestAuthorization ()
     }
 
   *td->auxiliaryBuffer << "Date: ";
-  getRFC822GMTTime (time, 32);
+  getRFC822GMTTime (time);
   *td->auxiliaryBuffer << time << "\r\n\r\n";
 
   if (td->connection->socket->send (td->auxiliaryBuffer->getBuffer (),
@@ -1477,7 +1477,7 @@ Internal Server Error\n\
   *td->auxiliaryBuffer << tmp;
   *td->auxiliaryBuffer << "\r\n";
   *td->auxiliaryBuffer << "Date: ";
-  getRFC822GMTTime (time, 32);
+  getRFC822GMTTime (time);
   *td->auxiliaryBuffer << time;
   *td->auxiliaryBuffer << "\r\n\r\n";
 
@@ -1657,7 +1657,7 @@ int Http::sendHTTPRedirect (const char *newURL)
     *td->auxiliaryBuffer << "Connection: close\r\n";
 
   *td->auxiliaryBuffer << "Date: ";
-  getRFC822GMTTime (time, 32);
+  getRFC822GMTTime (time);
   *td->auxiliaryBuffer << time
           << "\r\n\r\n";
   td->connection->socket->send (td->auxiliaryBuffer->getBuffer (),
@@ -1683,7 +1683,7 @@ int Http::sendHTTPNonModified ()
   else
     *td->auxiliaryBuffer << "Connection: close\r\n";
 
-  getRFC822GMTTime (time, 32);
+  getRFC822GMTTime (time);
 
   *td->auxiliaryBuffer << "Date: " << time << "\r\n\r\n";
 

-----------------------------------------------------------------------

Summary of changes:
 myserver/include/base/string/stringutils.h         |   34 ++--
 myserver/src/base/string/stringutils.cpp           |   82 +++++-----
 myserver/src/http_handler/http_dir/http_dir.cpp    |    2 +-
 myserver/src/http_handler/http_file/http_file.cpp  |    2 +-
 myserver/src/log/log_manager.cpp                   |    2 +-
 myserver/src/log/stream/file_stream.cpp            |    2 +-
 myserver/src/protocol/control/control_protocol.cpp |    2 +-
 myserver/src/protocol/ftp/ftp.cpp                  |    6 +-
 myserver/src/protocol/http/env/env.cpp             |    4 +-
 myserver/src/protocol/http/http.cpp                |   14 +-
 myserver/tests/Makefile.am                         |    1 +
 myserver/tests/test_stringutils.cpp                |  169 ++++++++++++++++++++
 12 files changed, 247 insertions(+), 73 deletions(-)
 create mode 100644 myserver/tests/test_stringutils.cpp


hooks/post-receive
-- 
GNU MyServer



reply via email to

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