[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_1-43-g
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_1-43-g43a210f |
Date: |
Tue, 09 Feb 2010 23:59:54 +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 43a210fc80d47a4dd91d60963851009af14ce686 (commit)
from ae0ca1765d0a274fc25ceae00c15893ee15421db (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 43a210fc80d47a4dd91d60963851009af14ce686
Author: Giuseppe Scrivano <address@hidden>
Date: Wed Feb 10 01:00:19 2010 +0100
Remove legacy code for files handling. Use new gnulib modules.
diff --git a/myserver/bootstrap.conf b/myserver/bootstrap.conf
index 9741cc5..02a2797 100644
--- a/myserver/bootstrap.conf
+++ b/myserver/bootstrap.conf
@@ -27,9 +27,11 @@ accept
argp
bind
chdir-long
+close
crypto/md5
crypto/sha1
connect
+fsync
getcwd
gethostname
getsockname
@@ -40,9 +42,14 @@ listen
malloc
mktime
nproc
+open
pipe
+read-file
+readlink
recv
regex
+remove
+rename
select
send
setsockopt
@@ -51,6 +58,7 @@ snprintf
socket
sysexits
unlink
+write
"
gnulib_extra_files="
diff --git a/myserver/include/base/hash_map/hash_map.h
b/myserver/include/base/hash_map/hash_map.h
index ddecd19..cac8a13 100644
--- a/myserver/include/base/hash_map/hash_map.h
+++ b/myserver/include/base/hash_map/hash_map.h
@@ -30,6 +30,8 @@
# include <vector>
# include <string>
+# undef remove
+
using namespace std;
//hashmap Hash-Key-Value Struct
diff --git a/myserver/include/connections_scheduler/connections_scheduler.h
b/myserver/include/connections_scheduler/connections_scheduler.h
index fb900cd..6e79569 100644
--- a/myserver/include/connections_scheduler/connections_scheduler.h
+++ b/myserver/include/connections_scheduler/connections_scheduler.h
@@ -29,6 +29,8 @@
# include <include/base/thread/thread.h>
# include <include/base/socket_pair/socket_pair.h>
+# undef remove
+
# include <list>
# include <queue>
diff --git a/myserver/include/filter/stream.h b/myserver/include/filter/stream.h
index 3c03800..e56289c 100644
--- a/myserver/include/filter/stream.h
+++ b/myserver/include/filter/stream.h
@@ -28,11 +28,7 @@ typedef u_int Handle;
typedef int Handle;
# endif
-# ifdef WIN32
-typedef HANDLE FileHandle;
-# else
typedef int FileHandle;
-# endif
/*!
*Abstract class to handle virtual data streams.
diff --git a/myserver/include/log/log_manager.h
b/myserver/include/log/log_manager.h
index a66f807..99cca17 100644
--- a/myserver/include/log/log_manager.h
+++ b/myserver/include/log/log_manager.h
@@ -34,6 +34,8 @@
using namespace std;
+# undef remove
+
class LogManager
{
public:
diff --git a/myserver/src/base/file/file.cpp b/myserver/src/base/file/file.cpp
index 3af69b1..53a62ee 100644
--- a/myserver/src/base/file/file.cpp
+++ b/myserver/src/base/file/file.cpp
@@ -22,34 +22,30 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>.
#include <include/base/string/stringutils.h>
#include <include/base/file/files_utility.h>
-#ifndef WIN32
extern "C"
{
-# include <fcntl.h>
-# include <unistd.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-# include <errno.h>
-# include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <time.h>
+
+#ifdef SENDFILE
# include <fcntl.h>
# include <stdlib.h>
-# include <string.h>
-# include <math.h>
-# include <time.h>
-
-# ifdef SENDFILE
-# include <fcntl.h>
-# include <stdlib.h>
-# include <stdio.h>
-# include <sys/sendfile.h>
-# include <sys/stat.h>
-# include <sys/types.h>
-# include <unistd.h>
-# endif
-
-
-}
+# include <stdio.h>
+# include <sys/sendfile.h>
+# include <sys/stat.h>
+# include <sys/types.h>
+# include <unistd.h>
#endif
+}
#include <string>
#include <sstream>
@@ -100,13 +96,9 @@ int File::writeToFile (const char* buffer, u_long
buffersize, u_long* nbw)
*nbw = 0;
return 1;
}
-#ifdef WIN32
- int ret = WriteFile (handle, buffer, buffersize, nbw, NULL);
- return (!ret);
-#else
- *nbw = ::write (handle, buffer, buffersize);
+
+ *nbw = ::write (handle, buffer, buffersize);
return (*nbw == buffersize) ? 0 : 1 ;
-#endif
}
/*!
@@ -115,7 +107,7 @@ int File::writeToFile (const char* buffer, u_long
buffersize, u_long* nbw)
*\param opt Specify how open the file.
*/
File::File (char *nfilename, int opt)
- : handle ((FileHandle)-1)
+ : handle ((FileHandle) -1)
{
openFile (nfilename, opt);
}
@@ -126,18 +118,11 @@ File::File (char *nfilename, int opt)
*/
int File::truncate (u_long size)
{
-#ifdef WIN32
- if (seek (size))
- return 1;
-
- return !SetEndOfFile (handle);
-#else
int err = ftruncate (handle, size);
if (err)
return err;
return seek (size);
-#endif
}
/*!
@@ -150,72 +135,12 @@ int File::truncate (u_long size)
int File::openFile (const char* nfilename,u_long opt)
{
long ret = 0;
-
- filename.assign (nfilename);
-#ifdef WIN32
- u_long creationFlag = 0;
- u_long openFlag = 0;
- u_long attributeFlag = 0;
- SECURITY_ATTRIBUTES sa = {0};
- sa.nLength = sizeof (sa);
-
- if (opt & File::NO_INHERIT)
- sa.bInheritHandle = FALSE;
- else
- sa.bInheritHandle = TRUE;
-
- sa.lpSecurityDescriptor = NULL;
-
- if (opt & File::FILE_OPEN_ALWAYS)
- creationFlag |= OPEN_ALWAYS;
- if (opt & File::OPEN_IF_EXISTS)
- creationFlag |= OPEN_EXISTING;
- if (opt & File::FILE_CREATE_ALWAYS)
- creationFlag |= CREATE_ALWAYS;
-
- if (opt & File::READ)
- openFlag |= GENERIC_READ;
- if (opt & File::WRITE)
- openFlag |= GENERIC_WRITE;
-
- if (opt & File::TEMPORARY)
- {
- openFlag |= FILE_ATTRIBUTE_TEMPORARY;
- attributeFlag |= FILE_FLAG_DELETE_ON_CLOSE;
- }
- if (opt & File::HIDDEN)
- openFlag|= FILE_ATTRIBUTE_HIDDEN;
-
- if (attributeFlag == 0)
- attributeFlag = FILE_ATTRIBUTE_NORMAL;
-
- handle = CreateFile (filename.c_str (), openFlag,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- &sa, creationFlag, attributeFlag, NULL);
-
- if (handle == INVALID_HANDLE_VALUE)
- {
- filename.clear ();
- return 1;
- }
- else
- {
- if (opt & File::APPEND)
- ret = seek (getFileSize ());
- else
- ret = seek (0);
-
- if (ret)
- {
- close ();
- filename.clear ();
- return 1;
- }
- }
-#else
struct stat fStats;
int flags;
+
+ filename.assign (nfilename);
+
if ((opt & File::READ) && (opt & File::WRITE))
flags = O_RDWR;
else if (opt & File::READ)
@@ -244,9 +169,6 @@ int File::openFile (const char* nfilename,u_long opt)
unlink (filename.c_str ()); /* It will be removed on close. */
return handle < 0;
-#endif
-
- return 0;
}
/*!
@@ -320,18 +242,13 @@ int File::createTemporaryFile (const char* filename)
int File::close ()
{
int ret = 0;
- if (handle != (FileHandle) -1)
+ if (handle != -1)
{
-#ifdef WIN32
- ret = !FlushFileBuffers (handle);
- ret |= !CloseHandle (handle);
-#else
ret = fsync (handle);
ret |= ::close (handle);
-#endif
- }
+ }
filename.clear ();
- handle = (FileHandle) -1;
+ handle = -1;
return ret;
}
@@ -342,20 +259,12 @@ int File::close ()
u_long File::getFileSize ()
{
u_long ret;
-#ifdef WIN32
- ret = GetFileSize (handle, NULL);
- if (ret != INVALID_FILE_SIZE)
- return ret;
- else
- return (u_long)-1;
-#else
struct stat fStats;
ret = fstat (handle, &fStats);
if (ret)
return (u_long)(-1);
else
return fStats.st_size;
-#endif
}
/*!
@@ -365,13 +274,8 @@ u_long File::getFileSize ()
int File::seek (u_long initialByte)
{
u_long ret;
-#ifdef WIN32
- ret = SetFilePointer (handle, initialByte, NULL, FILE_BEGIN);
- return (ret == INVALID_SET_FILE_POINTER) ? 1 : 0;
-#else
ret = lseek (handle, initialByte, SEEK_SET);
return (ret != initialByte ) ? 1 : 0;
-#endif
}
/*!
@@ -381,11 +285,7 @@ int File::seek (u_long initialByte)
*/
u_long File::getSeek ()
{
-#ifdef WIN32
- return SetFilePointer (handle, 0, NULL, FILE_CURRENT);
-#else
return lseek (handle, 0, SEEK_CUR);
-#endif
}
/*!
@@ -430,13 +330,9 @@ int File::write (const char* buffer, u_long len, u_long
*nbw)
*/
int File::read (char* buffer, u_long buffersize, u_long* nbr)
{
-#ifdef WIN32
- return !ReadFile (handle, buffer, buffersize, nbr, NULL);
-#else
int ret = ::read (handle, buffer, buffersize);
*nbr = (u_long) ret;
return (ret == -1);
-#endif
}
/*!
diff --git a/myserver/src/base/file/files_utility.cpp
b/myserver/src/base/file/files_utility.cpp
index 58c8d67..ca18a92 100644
--- a/myserver/src/base/file/files_utility.cpp
+++ b/myserver/src/base/file/files_utility.cpp
@@ -142,11 +142,7 @@ int FilesUtility::getPathRecursionLevel (const char* path)
*/
int FilesUtility::renameFile (const char* before, const char* after)
{
-#ifdef WIN32
- return MoveFile (before, after) ? 0 : 1;
-#else
return rename (before, after);
-#endif
}
/*!
@@ -157,9 +153,6 @@ int FilesUtility::renameFile (const char* before, const
char* after)
*/
int FilesUtility::copyFile (const char* src, const char* dest, int overwrite)
{
-#ifdef WIN32
- return CopyFile (src, dest, overwrite ? FALSE : TRUE) ? 0 : 1;
-#else
File srcFile;
File destFile;
char buffer[4096];
@@ -181,7 +174,6 @@ int FilesUtility::copyFile (const char* src, const char*
dest, int overwrite)
destFile.close ();
return ret;
-#endif
}
/*!
@@ -225,16 +217,11 @@ int FilesUtility::copyFile (File& src, File& dest)
int FilesUtility::deleteFile (const char *filename)
{
int ret;
-#ifdef WIN32
- ret = DeleteFile (filename);
- if (ret)
- return 0;
-#else
ret = remove (filename);
if (ret && errno == ENOENT)
ret = 0;
-#endif
+
return ret;
}
diff --git a/myserver/src/connections_scheduler/connections_scheduler.cpp
b/myserver/src/connections_scheduler/connections_scheduler.cpp
index aeed1fd..d360185 100644
--- a/myserver/src/connections_scheduler/connections_scheduler.cpp
+++ b/myserver/src/connections_scheduler/connections_scheduler.cpp
@@ -17,6 +17,8 @@
#include "myserver.h"
+#undef remove
+
#include <include/connections_scheduler/connections_scheduler.h>
#include <include/server/server.h>
diff --git a/myserver/src/log/log_manager.cpp b/myserver/src/log/log_manager.cpp
index 104a389..e47baf1 100644
--- a/myserver/src/log/log_manager.cpp
+++ b/myserver/src/log/log_manager.cpp
@@ -16,6 +16,9 @@
*/
#include "myserver.h"
+
+#undef remove
+
#include <include/log/log_manager.h>
#include <include/server/server.h>
diff --git a/myserver/tests/test_hashmap.cpp b/myserver/tests/test_hashmap.cpp
index c21c07e..ee17730 100644
--- a/myserver/tests/test_hashmap.cpp
+++ b/myserver/tests/test_hashmap.cpp
@@ -16,7 +16,11 @@
*/
#include "myserver.h"
+
+#undef remove
+
#include <include/base/hash_map/hash_map.h>
+
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
@@ -78,10 +82,8 @@ public:
CPPUNIT_ASSERT_EQUAL (map->empty (), true);
map->put ((char*)"key", 0);
CPPUNIT_ASSERT_EQUAL (map->empty (), false);
-
}
-
void testPut ()
{
map->put ((char*)"one", 1);
-----------------------------------------------------------------------
Summary of changes:
myserver/bootstrap.conf | 8 +
myserver/include/base/hash_map/hash_map.h | 2 +
.../connections_scheduler/connections_scheduler.h | 2 +
myserver/include/filter/stream.h | 4 -
myserver/include/log/log_manager.h | 2 +
myserver/src/base/file/file.cpp | 160 ++++----------------
myserver/src/base/file/files_utility.cpp | 15 +--
.../connections_scheduler.cpp | 2 +
myserver/src/log/log_manager.cpp | 3 +
myserver/tests/test_hashmap.cpp | 6 +-
10 files changed, 52 insertions(+), 152 deletions(-)
hooks/post-receive
--
GNU MyServer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_1-43-g43a210f,
Giuseppe Scrivano <=