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. 46f541486d


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 46f541486dec795c35892089564e39e7b897853e
Date: Sat, 08 Aug 2009 10:48:42 +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  46f541486dec795c35892089564e39e7b897853e (commit)
      from  5d93aeb906b5f2e25ee8dd030d665b89dd4f5cb9 (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 46f541486dec795c35892089564e39e7b897853e
Author: Giuseppe Scrivano <address@hidden>
Date:   Sat Aug 8 12:47:59 2009 +0200

    Refactoring, removed unused #include's and code cleaning.

diff --git a/myserver/src/base/file/files_utility.cpp 
b/myserver/src/base/file/files_utility.cpp
index 8af35ca..03eba95 100644
--- a/myserver/src/base/file/files_utility.cpp
+++ b/myserver/src/base/file/files_utility.cpp
@@ -29,16 +29,16 @@ extern "C"
 #ifndef WIN32
 extern "C"
 {
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <time.h>
+# include <fcntl.h>
+# include <unistd.h>
+# include <sys/types.h>
+# include <errno.h>
+# include <stdio.h>
+# include <fcntl.h>
+# include <stdlib.h>
+# include <string.h>
+# include <math.h>
+# include <time.h>
 }
 #endif
 
@@ -51,7 +51,7 @@ using namespace std;
 string FilesUtility::tmpPath;
 
 /*!
- *Constructor body.
+ * Constructor body.
  */
 FilesUtility::FilesUtility()
 {
@@ -59,100 +59,100 @@ FilesUtility::FilesUtility()
 }
 
 /*!
- *This funtion iterates through every character of the path
- *The first IF tries to clear out the bars, if it finds one,
- *just advances one character and starts the cycle again
- *The second IF tries to find at least two dots.
- *if it finds only 1, does nothing,
- *WIN32 if it finds 2 or more rec=rec-(number of dots -1)
+ * This funtion iterates through every character of the path
+ * The first IF tries to clear out the bars, if it finds one,
+ * just advances one character and starts the cycle again
+ * The second IF tries to find at least two dots.
+ * if it finds only 1, does nothing,
+ * WIN32 if it finds 2 or more rec=rec-(number of dots -1)
  * *NIX if it finds 2, decrements rec, if it finds more,
- *increments it considering it's a name if it ends with
- *something else other then a bar of a NULL,
- *then it's a path of the form "/...qwerty/" that should be considered rec++
- *The last ELSE, catches the rest and advances to the next bar.
- *Return the recursion of the path.
- *\param path The file name.
+ * increments it considering it's a name if it ends with
+ * something else other then a bar of a NULL,
+ * then it's a path of the form "/...qwerty/" that should be considered rec++
+ * The last ELSE, catches the rest and advances to the next bar.
+ * Return the recursion of the path.
+ * \param path The file name.
  */
-int FilesUtility::getPathRecursionLevel(const char* path)
+int FilesUtility::getPathRecursionLevel (const char* path)
 {
   const char *lpath = path;
   int rec = 0;
 #ifdef WIN32
   int temp;
 #endif
-  while(*lpath != 0)
+  while (*lpath != 0)
   {
-  /* ".." decreases the recursion level.  */
-    if( (*lpath == '\\') || (*lpath == '/') )
-    {
-      lpath++;
-      continue;
-    }
-
-    if(*lpath=='.')
-    {
-      lpath++;
-#ifdef WIN32//--------------------------------
-      temp = 0;
-      while(*lpath == '.')
-      {
-        lpath++;
-        temp++;
-      }
-      if( (*lpath == '\\') || (*lpath == '/') || (*lpath == 0))
-        rec -= temp;
-      else
+    /* ".." decreases the recursion level.  */
+    if ((*lpath == '\\') || (*lpath == '/'))
       {
         lpath++;
-        while( (*lpath != '\\') && (*lpath != '/') && (*lpath != 0))
-          lpath++;
-        rec++;
+        continue;
       }
-#else    //--------------------------------
-      if(*lpath == '.')
+
+    if (*lpath=='.')
       {
         lpath++;
-        if( (*lpath == '\\') || (*lpath == '/') || (*lpath == 0))
-          rec--;
+#ifdef WIN32
+        temp = 0;
+        while (*lpath == '.')
+          {
+            lpath++;
+            temp++;
+          }
+        if ((*lpath == '\\') || (*lpath == '/') || (*lpath == 0))
+          rec -= temp;
         else
-        {
-          while( (*lpath != '\\') && (*lpath != '/') && (*lpath != 0))
+          {
             lpath++;
-          rec++;
-        }
+            while ((*lpath != '\\') && (*lpath != '/') && (*lpath != 0))
+              lpath++;
+            rec++;
+          }
+#else
+        if (*lpath == '.')
+          {
+            lpath++;
+            if ((*lpath == '\\') || (*lpath == '/') || (*lpath == 0))
+              rec--;
+            else
+              {
+                while ((*lpath != '\\') && (*lpath != '/') && (*lpath != 0))
+                  lpath++;
+                rec++;
+              }
+          }
+#endif
       }
-#endif    //--------------------------------
-    }
     else
-    {
-      while( (*lpath != '\\') && (*lpath != '/') && (*lpath != 0))
-        lpath++;
-      rec++;
-    }
+      {
+        while( (*lpath != '\\') && (*lpath != '/') && (*lpath != 0))
+          lpath++;
+        rec++;
+      }
   }
   return rec;
 }
 
 
 /*!
- *Rename the file [BEFORE] to [AFTER]. Returns 0 on success.
- *\param before The old file name.
- *\param after The new file name.
+ * Rename the file [BEFORE] to [AFTER]. Returns 0 on success.
+ * \param before The old file name.
+ * \param after The new file name.
  */
-int FilesUtility::renameFile(const char* before, const char* after)
+int FilesUtility::renameFile (const char* before, const char* after)
 {
 #ifdef WIN32
-  return MoveFile(before, after) ? 0 : 1;
+  return MoveFile (before, after) ? 0 : 1;
 #else
-  return rename(before, after);
+  return rename (before, after);
 #endif
 }
 
 /*!
- *Copy the file from [SRC] to [DEST]. Returns 0 on success.
- *\param src The source file name.
- *\param dest The destination file name.
- *\param overwrite Overwrite the dest file if already exists?
+ * Copy the file from [SRC] to [DEST]. Returns 0 on success.
+ * \param src The source file name.
+ * \param dest The destination file name.
+ * \param overwrite Overwrite the dest file if already exists?
  */
 int FilesUtility::copyFile (const char* src, const char* dest, int overwrite)
 {
@@ -183,9 +183,9 @@ int FilesUtility::copyFile (const char* src, const char* 
dest, int overwrite)
 }
 
 /*!
- *Copy the file from [SRC] to [DEST]. Returns 0 on success.
- *\param src The source File.
- *\param dest The destination File.
+ * Copy the file from [SRC] to [DEST]. Returns 0 on success.
+ * \param src The source File.
+ * \param dest The destination File.
  */
 int FilesUtility::copyFile (File& src, File& dest)
 {
@@ -216,9 +216,9 @@ int FilesUtility::copyFile (File& src, File& dest)
 }
 
 /*!
- *Delete an existing file passing the path.
- *Return a non-null value on errors.
- *\param filename The file to delete.
+ * Delete an existing file passing the path.
+ * Return a non-null value on errors.
+ * \param filename The file to delete.
  */
 int FilesUtility::deleteFile (const char *filename)
 {
@@ -237,13 +237,13 @@ int FilesUtility::deleteFile (const char *filename)
 }
 
 /*!
- *Returns a non-null value if the path is a directory.
- *\param filename The path to check.
+ * Returns a non-null value if the path is a directory.
+ * \param filename The path to check.
  */
-int FilesUtility::isDirectory(const char *filename)
+int FilesUtility::isDirectory (const char *filename)
 {
 #ifdef WIN32
-  u_long fa = GetFileAttributes(filename);
+  u_long fa = GetFileAttributes (filename);
   if(fa != INVALID_FILE_ATTRIBUTES)
     return(fa & FILE_ATTRIBUTE_DIRECTORY)?1:0;
   else
@@ -259,8 +259,8 @@ int FilesUtility::isDirectory(const char *filename)
 }
 
 /*!
- *Returns a non-null value if the given path is a link.
- *\param filename The path to check.
+ * Returns a non-null value if the given path is a link.
+ * \param filename The path to check.
  */
 int FilesUtility::isLink(const char* filename)
 {
@@ -278,110 +278,105 @@ int FilesUtility::isLink(const char* filename)
 }
 
 /*!
- *Returns a non-null value if the given path is a valid file.
- *\param filename The path to check.
+ * Returns a non-null value if the given path is a valid file.
+ * \param filename The path to check.
  */
 int FilesUtility::fileExists(const char* filename)
 {
 #ifdef WIN32
-  /*! OpenFile is obsolete
-  OFSTRUCT of;
-  int ret = OpenFile(filename, &of, OF_EXIST);
-  return (ret != HFILE_ERROR)?1:0;*/
-  HANDLE hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ,
-                       NULL, OPEN_EXISTING,
-                       FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
-                       NULL);
+  HANDLE hFile = CreateFile (filename, GENERIC_READ, FILE_SHARE_READ,
+                             NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL
+                             | FILE_FLAG_BACKUP_SEMANTICS, NULL);
 
   int nRet = hFile != INVALID_HANDLE_VALUE ? 1 : 0;
-  CloseHandle(hFile);
+  CloseHandle (hFile);
   return nRet;
 #else
-  struct stat F_Stats;
-  int ret = stat(filename, &F_Stats);
+  struct stat fstats;
+  int ret = stat (filename, &fstats);
   if(ret < 0)
     return 0;
   /*! Return 1 if it is a regular file or a directory.  */
-  return (S_ISREG(F_Stats.st_mode) | S_ISDIR(F_Stats.st_mode))? 1 : 0;
+  return (S_ISREG (fstats.st_mode) | S_ISDIR(fstats.st_mode))? 1 : 0;
 #endif
 }
 
 /*!
- *Returns the time of the last modify to the file.
- *Returns -1 on errors.
- *\param filename The path to check.
+ * Returns the time of the last modify to the file.
+ * Returns -1 on errors.
+ * \param filename The path to check.
  */
-time_t FilesUtility::getLastModTime(const char *filename)
+time_t FilesUtility::getLastModTime (const char *filename)
 {
   int res;
 #ifdef WIN32
   struct _stat sf;
-  res = _stat(filename,&sf);
+  res = _stat (filename, &sf);
 #else
   struct stat sf;
-  res = stat(filename,&sf);
+  res = stat (filename,&sf);
 #endif
 
-  if(res == 0)
+  if (res == 0)
     return sf.st_mtime;
   else
-    return (-1);
+    return -1;
 }
 
 /*!
- *Returns the time of the file creation.
- *Returns -1 on errors.
- *\param filename The path to check.
+ * Returns the time of the file creation.
+ * Returns -1 on errors.
+ * \param filename The path to check.
  */
-time_t FilesUtility::getCreationTime(const char *filename)
+time_t FilesUtility::getCreationTime (const char *filename)
 {
   int res;
 #ifdef WIN32
   struct _stat sf;
-  res = _stat(filename, &sf);
+  res = _stat (filename, &sf);
 #else
   struct stat sf;
-  res = stat(filename, &sf);
+  res = stat (filename, &sf);
 #endif
-  if(res == 0)
+  if (res == 0)
     return sf.st_ctime;
   else
-    return (-1);
+    return -1;
 }
 
 /*!
- *Returns the time of the last access to the file.
- *Returns -1 on errors.
- *\param filename The path to check.
+ * Returns the time of the last access to the file.
+ * Returns -1 on errors.
+ * \param filename The path to check.
  */
-time_t FilesUtility::getLastAccTime(const char *filename)
+time_t FilesUtility::getLastAccTime (const char *filename)
 {
   int res;
 #ifdef WIN32
   struct _stat sf;
-  res = _stat(filename, &sf);
+  res = _stat (filename, &sf);
 #else
   struct stat sf;
-  res = stat(filename, &sf);
+  res = stat (filename, &sf);
 #endif
-  if(res == 0)
+  if (res == 0)
     return sf.st_atime;
   else
-    return (-1);
+    return -1;
 }
 
 /*!
- *Change the owner of the current file, use the value -1 for uid or gid
- *to do not change the value. Return 0 on success.
- *\param filename The path to the file to chown.
- *\param uid The user id.
- *\param gid the group id.
+ * Change the owner of the current file, use the value -1 for uid or gid
+ * to do not change the value. Return 0 on success.
+ * \param filename The path to the file to chown.
+ * \param uid The user id.
+ * \param gid the group id.
  */
 int FilesUtility::chown(const char* filename, string &uid, string &gid)
 {
 #ifndef WIN32
-  return ::chown(filename, Process::getUid (uid.c_str ()),
-                 Process::getGid (gid.c_str ())) ? 1 : 0;
+  return ::chown (filename, Process::getUid (uid.c_str ()),
+                  Process::getGid (gid.c_str ())) ? 1 : 0;
 #endif
   return 0;
 }
@@ -391,169 +386,155 @@ int FilesUtility::chown(const char* filename, string 
&uid, string &gid)
  *\param path The full path where get the filename length.
  *\param filename A pointer to the start of the file name.
  */
-int FilesUtility::getFilenameLength(const char *path, int *filename)
+int FilesUtility::getFilenameLength (const char *path, int *filename)
 {
-  int splitpoint, i, j;
-  i = 0;
-  j = 0;
+  int splitpoint, i = 0, j = 0;
   splitpoint = static_cast<int>(strlen(path) - 1);
   while ((splitpoint > 0) && (path[splitpoint] != '/'))
     splitpoint--;
   *filename = splitpoint + 1;
   return *filename;
-
 }
 
 /*!
- *Get the filename from a path.
- *Be sure that the filename buffer is at least getFilenameLength(...) bytes
- *before call this function.
- *\param path The full path to the file.
- *\param filename A buffer to fullfill with the file name.
+ * Get the filename from a path.
+ * Be sure that the filename buffer is at least getFilenameLength(...) bytes
+ * before call this function.
+ * \param path The full path to the file.
+ * \param filename A buffer to fullfill with the file name.
  */
-void FilesUtility::getFilename(const char *path, char *filename)
+void FilesUtility::getFilename (const char *path, char *filename)
 {
-  int splitpoint, i, j;
-  i = 0;
-  j = 0;
+  int splitpoint, i = 0, j = 0;
   splitpoint = static_cast<int>(strlen(path) - 1);
   while ((splitpoint > 0) && (path[splitpoint] != '/'))
     splitpoint--;
   if ((splitpoint == 0) && (path[splitpoint] != '/'))
-  {
-    strcpy(filename, path);
-  }
+    strcpy (filename, path);
   else
-  {
-    splitpoint++;
-    i=splitpoint;
-    while(path[i] != 0)
     {
-      filename[j] = path[i];
-      j++;
-      i++;
+      splitpoint++;
+      i=splitpoint;
+      while (path[i] != 0)
+        {
+          filename[j] = path[i];
+          j++;
+          i++;
+        }
+      filename[j] = 0;
     }
-    filename[j] = 0;
-  }
 }
 
 /*!
- *Get the filename from a path.
- *\param path The full path to the file.
- *\param filename A buffer to fullfill with the file name.
+ * Get the filename from a path.
+ * \param path The full path to the file.
+ * \param filename A buffer to fullfill with the file name.
  */
-void FilesUtility::getFilename(string const &path, string& filename)
+void FilesUtility::getFilename (string const &path, string& filename)
 {
-  u_long splitpoint = path.find_last_of("\\/");
-  if(splitpoint != string::npos)
-  {
+  u_long splitpoint = path.find_last_of ("\\/");
+  if (splitpoint != string::npos)
     filename = path.substr(splitpoint+1, path.length()-1);
-  }
   else
-    filename.assign("");
-
+    filename.assign ("");
 }
 
 /*!
- *Use this function before call splitPath to be sure that the buffers
- *dir and filename are bigger enough to contain the data.
- *\param path The full path to the file.
- *\param dir The directory part length of the path.
- *\param filename The length of the buffer needed to contain the file name.
+ * Use this function before call splitPath to be sure that the buffers
+ * dir and filename are bigger enough to contain the data.
+ * \param path The full path to the file.
+ * \param dir The directory part length of the path.
+ * \param filename The length of the buffer needed to contain the file name.
  */
-void FilesUtility::splitPathLength(const char *path, int *dir, int *filename)
+void FilesUtility::splitPathLength (const char *path, int *dir, int *filename)
 {
   int splitpoint = 0;
   int i = 0;
 
-  for(i = 0; path[i]; i++)
+  for (i = 0; path[i]; i++)
     if(path[i] == '/' || path[i] == '\\' )
       splitpoint = i;
 
-  if(dir)
-  {
+  if (dir)
     *dir = splitpoint + 2;
-  }
 
   if(filename)
-  {
     *filename = i - splitpoint + 2;
-  }
 }
 
 /*!
- *Splits a file path into a directory and filename.
- *Path is an input value while dir and filename are the output values.
- *\param path The full path to the file.
- *\param dir The directory part of the path.
- *\param filename A buffer to fullfill with the file name.
+ * Splits a file path into a directory and filename.
+ * Path is an input value while dir and filename are the output values.
+ * \param path The full path to the file.
+ * \param dir The directory part of the path.
+ * \param filename A buffer to fullfill with the file name.
  */
-void FilesUtility::splitPath(const char *path, char *dir, char *filename)
+void FilesUtility::splitPath (const char *path, char *dir, char *filename)
 {
   int splitpoint = 0;
   int i = 0;
 
-  for(i = 0; path[i]; i++)
-    if(path[i] == '/' || path[i] == '\\' )
+  for (i = 0; path[i]; i++)
+    if (path[i] == '/' || path[i] == '\\' )
       splitpoint = i;
 
-  if(dir)
+  if (dir)
   {
-    if(splitpoint)
-    {
-      memcpy(dir, path, splitpoint);
-      dir[splitpoint] = '/';
-      dir[splitpoint + 1] = '\0';
-    }
+    if (splitpoint)
+      {
+        memcpy (dir, path, splitpoint);
+        dir[splitpoint] = '/';
+        dir[splitpoint + 1] = '\0';
+      }
     else
       dir[0] = '\0';
   }
 
-  if(filename)
-  {
-    memcpy(filename, path + splitpoint + (splitpoint ? 1 : 0), i - splitpoint 
- (splitpoint ? 1 : 0));
-    filename[i - splitpoint - (splitpoint ? 1 : 0)] = '\0';
-  }
+  if (filename)
+    {
+      memcpy(filename, path + splitpoint + (splitpoint ? 1 : 0),
+             i - splitpoint - (splitpoint ? 1 : 0));
+      filename[i - splitpoint - (splitpoint ? 1 : 0)] = '\0';
+    }
 }
 
 /*!
- *Split a path in a dir and a filename.
- *\param path The full path to the file.
- *\param dir The directory part of the path.
- *\param filename A buffer to fullfill with the file name.
+ * Split a path in a dir and a filename.
+ * \param path The full path to the file.
+ * \param dir The directory part of the path.
+ * \param filename A buffer to fullfill with the file name.
  */
-void FilesUtility::splitPath(string const &path, string& dir, string& filename)
+void FilesUtility::splitPath (string const &path, string& dir, string& 
filename)
 {
   u_long splitpoint;
-  u_long len = path.length();
-  splitpoint = path.find_last_of("\\/");
-  if(splitpoint != string::npos)
-  {
-    char lastDirChar;
-    dir  = path.substr(0, splitpoint);
-
-    lastDirChar = dir[dir.length() - 1];
+  u_long len = path.length ();
+  splitpoint = path.find_last_of ("\\/");
+  if (splitpoint != string::npos)
+    {
+      char lastDirChar;
+      dir  = path.substr (0, splitpoint);
 
-    if(lastDirChar != '\\' && lastDirChar != '/')
-      dir.append("/");
+      lastDirChar = dir[dir.length() - 1];
 
+      if (lastDirChar != '\\' && lastDirChar != '/')
+        dir.append ("/");
 
-    filename = path.substr(splitpoint+1, len-1);
-  }
+      filename = path.substr (splitpoint + 1, len - 1);
+    }
   else
-  {
-    filename  = path;
-    dir.assign("");
-  }
+    {
+      filename  = path;
+      dir.assign("");
+    }
 }
 
 /*!
- *Get the file extension passing its path.
- *Save in ext all the bytes afer the last dot(.) in filename.
- *\param ext The buffer to fullfill with the file extension.
- *\param filename The path to the file.
+ * Get the file extension passing its path.
+ * Save in ext all the bytes afer the last dot(.) in filename.
+ * \param ext The buffer to fullfill with the file extension.
+ * \param filename The path to the file.
  */
-void FilesUtility::getFileExt(char* ext, const char* filename)
+void FilesUtility::getFileExt (char* ext, const char* filename)
 {
   int nDot;
   nDot = static_cast<int>(strlen(filename) - 1);
@@ -562,93 +543,87 @@ void FilesUtility::getFileExt(char* ext, const char* 
filename)
     nDot--;
 
   if (nDot > 0)
-    strcpy(ext, filename + nDot + 1);
+    strcpy (ext, filename + nDot + 1);
   else
     ext[0] = 0;
 }
 
 /*!
- *Get the file extension passing its path.
- *Save in ext all the bytes afer the last dot(.) in filename.
- *\param ext The buffer to fullfill with the file extension.
- *\param filename The path to the file.
+ * Get the file extension passing its path.
+ * Save in ext all the bytes afer the last dot(.) in filename.
+ * \param ext The buffer to fullfill with the file extension.
+ * \param filename The path to the file.
  */
-void FilesUtility::getFileExt(string& ext, string const &filename)
+void FilesUtility::getFileExt (string& ext, string const &filename)
 {
-  u_long pos = filename.find_last_of('.');
-  if(pos != string::npos)
-  {
-    ext = filename.substr(pos+1, filename.length()-1);
-  }
+  u_long pos = filename.find_last_of ('.');
+  if (pos != string::npos)
+    ext = filename.substr (pos + 1, filename.length () - 1);
   else
-  {
-    ext.assign("");
-  }
-
+    ext.assign ("");
 }
 
 /*!
- *Get the file path in the short form of the specified file
- *Return -1 on errors.
- *\param filePath The path to use.
- *\param out The buffer where write.
- *\param buffersize The buffer length.
+ * Get the file path in the short form of the specified file.
+ * Return -1 on errors.
+ * \param filePath The path to use.
+ * \param out The buffer where write.
+ * \param buffersize The buffer length.
  */
-int FilesUtility::getShortFileName(char *filePath, char *out, int buffersize)
+int FilesUtility::getShortFileName (char *filePath, char *out, int buffersize)
 {
 #ifdef WIN32
-  int ret = GetShortPathName(filePath, out, buffersize);
-  if(!ret)
+  int ret = GetShortPathName (filePath, out, buffersize);
+  if (!ret)
     return -1;
   return 0;
 #else
-  strncpy(out, filePath, buffersize);
+  strncpy (out, filePath, buffersize);
   return 0;
 #endif
 }
 
 /*!
- *Complete the path of the file.
- *Return non-zero on errors.
- *\param fileName The buffer to use.
- *\param size The new buffer size.
- *\param dontRealloc Don't realloc a new buffer.
+ * Complete the path of the file.
+ * Return non-zero on errors.
+ * \param fileName The buffer to use.
+ * \param size The new buffer size.
+ * \param dontRealloc Don't realloc a new buffer.
  */
-int FilesUtility::completePath(char **fileName,int *size, int dontRealloc)
+int FilesUtility::completePath (char **fileName, int *size, int dontRealloc)
 {
-  if((fileName == 0) ||( *fileName==0))
+  if (!fileName || !(*fileName))
     return -1;
 #ifdef WIN32
   char *buffer;
-  int bufferLen = strlen(*fileName) + 1;
+  int bufferLen = strlen (*fileName) + 1;
   int bufferNewLen;
-  auto_ptr<char> bufferAutoPtr( new char[bufferLen] );
+  auto_ptr<char> bufferAutoPtr (new char[bufferLen]);
 
-  buffer = bufferAutoPtr.get();
+  buffer = bufferAutoPtr.get ();
 
-  strcpy(buffer, *fileName);
-  bufferNewLen = GetFullPathName(buffer, 0, *fileName, 0) + 1;
-  if(bufferNewLen == 0)
-  {
+  strcpy (buffer, *fileName);
+  bufferNewLen = GetFullPathName (buffer, 0, *fileName, 0) + 1;
+  if (bufferNewLen == 0)
     return -1;
-  }
-  if(dontRealloc)
-  {
-    if(*size < bufferNewLen )
-      return -1;
-  }
+
+  if (dontRealloc)
+    {
+      if (*size < bufferNewLen )
+        return -1;
+    }
   else
-  {
-    delete [] (*fileName);
-    *fileName = new char[bufferNewLen];
-    if(*fileName == 0)
     {
-      *size = 0;
-      return -1;
+      delete [] (*fileName);
+      *fileName = new char[bufferNewLen];
+      if (*fileName == 0)
+        {
+          *size = 0;
+          return -1;
+        }
+      *size = bufferNewLen;
     }
-    *size = bufferNewLen;
-  }
-  if(GetFullPathName(buffer, bufferNewLen, *fileName, 0) == 0)
+  if (GetFullPathName (buffer, bufferNewLen, *fileName, 0) == 0)
     return -1;
 
   return 0;
@@ -657,121 +632,116 @@ int FilesUtility::completePath(char **fileName,int 
*size, int dontRealloc)
   int bufferLen;
   int bufferNewLen;
   /* We assume that path starting with / are yet completed.  */
-  if((*fileName)[0]=='/')
+  if ((*fileName)[0]=='/')
     return 0;
-  bufferLen = strlen(*fileName) + 1;
-
-  auto_ptr<char> bufferAutoPtr( new char[bufferLen] );
-
-  buffer = bufferAutoPtr.get();
+  bufferLen = strlen (*fileName) + 1;
 
+  auto_ptr<char> bufferAutoPtr (new char[bufferLen]);
 
-  strcpy(buffer, *fileName);
+  buffer = bufferAutoPtr.get ();
+  strcpy (buffer, *fileName);
   bufferNewLen =  getdefaultwdlen() +  bufferLen + 1 ;
-  if(dontRealloc)
-  {
-    if(*size < bufferNewLen )
-      return -1;
-  }
+  if (dontRealloc)
+    {
+      if (*size < bufferNewLen )
+        return -1;
+    }
   else
-  {
-    delete [] (*fileName);
-    *fileName = new char[bufferNewLen];
-    if(*fileName == 0)
     {
-      *size = 0;
-      return -1;
+      delete [] (*fileName);
+      *fileName = new char[bufferNewLen];
+      if (*fileName == 0)
+        {
+          *size = 0;
+          return -1;
+        }
+      *size = bufferNewLen;
     }
-    *size = bufferNewLen;
-  }
-  sprintf(*fileName, "%s/%s", getdefaultwd(0, 0), buffer );
-
+  sprintf (*fileName, "%s/%s", getdefaultwd (0, 0), buffer);
   return 0;
 #endif
 }
 
 /*!
- *Complete the path of the file.
- *Return non-zero on errors.
- *\param fileName The file name to complete.
+ * Complete the path of the file.
+ * Return non-zero on errors.
+ * \param fileName The file name to complete.
  */
-int FilesUtility::completePath(string &fileName)
+int FilesUtility::completePath (string &fileName)
 {
 #ifdef WIN32
   char *buffer;
   int bufferLen;
 
-  bufferLen = GetFullPathName(fileName.c_str(), 0, buffer, 0) + 1;
-  if(bufferLen == 0)
+  bufferLen = GetFullPathName (fileName.c_str (), 0, buffer, 0) + 1;
+  if (!bufferLen)
     return -1;
 
-  auto_ptr<char> bufferAutoPtr( new char[bufferLen] );
+  auto_ptr<char> bufferAutoPtr (new char[bufferLen]);
 
-  buffer = bufferAutoPtr.get();
+  buffer = bufferAutoPtr.get ();
 
-  if(GetFullPathName(fileName.c_str(), bufferLen, buffer, 0) == 0)
+  if (GetFullPathName(fileName.c_str (), bufferLen, buffer, 0) == 0)
     return -1;
 
-  fileName.assign(buffer);
+  fileName.assign (buffer);
 
   return 0;
 #else
   ostringstream stream;
-  /* We assume that path starting with / are yet completed. */
-  if(fileName[0] != '/')
-  {
-    stream << getdefaultwd(0, 0) << "/" <<  fileName.c_str();
-    fileName.assign(stream.str());
-  }
-
+  /* Assume that path starting with / are absolute paths.  */
+  if (fileName[0] != '/')
+    {
+      stream << getdefaultwd (0, 0) << "/" <<  fileName.c_str ();
+      fileName.assign (stream.str ());
+    }
   return 0;
 #endif
 }
 
 /*!
- *Create a new directory.
- *Return non-zero on errors.
- *\param path The path to the directory to create.
+ * Create a new directory.
+ * Return non-zero on errors.
+ * \param path The path to the directory to create.
  */
 int FilesUtility::mkdir (const char *path)
 {
 #ifdef WIN32
-  return CreateDirectory(path, NULL)?0:-1;
+  return CreateDirectory (path, NULL) ? 0 : -1;
 #else
-  return ::mkdir(path, S_IRUSR | S_IWUSR);
+  return ::mkdir (path, S_IRUSR | S_IWUSR);
 #endif
 }
 
-
 /*!
- *Delete a directory.
- *Return non-zero on errors.
- *\param path The directory to remove.
+ * Delete a directory.
+ * Return non-zero on errors.
+ * \param path The directory to remove.
  */
 int FilesUtility::rmdir (const char *path)
 {
 #ifdef WIN32
-  return RemoveDirectory(path)?0:-1;
+  return RemoveDirectory (path) ? 0 : -1;
 #else
-  return ::rmdir(path);
+  return ::rmdir (path);
 #endif
 }
 
 /*!
- *Set the temporary path to a default one.
+ * Set the temporary path to a default one.
  */
-void FilesUtility::resetTmpPath()
+void FilesUtility::resetTmpPath ()
 {
 #ifdef WIN32
   const char *tmpDir = getenv ("TMPDIR");
   if (tmpDir)
     tmpPath.assign (tmpDir);
   else
-  {
-    TCHAR lpPathBuffer[MAX_PATH];
-    GetTempPath (MAX_PATH, lpPathBuffer);
-    tmpPath.assign (lpPathBuffer);
-  }
+    {
+      TCHAR lpPathBuffer[MAX_PATH];
+      GetTempPath (MAX_PATH, lpPathBuffer);
+      tmpPath.assign (lpPathBuffer);
+    }
 #else
   const char *tmpDir = getenv ("TMPDIR");
 
@@ -782,7 +752,6 @@ void FilesUtility::resetTmpPath()
 
   if (tmpDir == NULL)
     tmpDir = "/tmp";
-
   tmpPath.assign (tmpDir);
 #endif
 }
diff --git a/myserver/src/http_handler/http_dir/http_dir.cpp 
b/myserver/src/http_handler/http_dir/http_dir.cpp
index aadc0b8..9d2d919 100644
--- a/myserver/src/http_handler/http_dir/http_dir.cpp
+++ b/myserver/src/http_handler/http_dir/http_dir.cpp
@@ -25,14 +25,12 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 
 extern "C" 
 {
-#ifdef WIN32
-#include <direct.h>
 #include <errno.h>
-#endif
 
-#ifndef WIN32
-#include <string.h>
-#include <errno.h>
+#ifdef WIN32
+# include <direct.h>
+#else
+# include <string.h>
 #endif
 }
 
@@ -52,7 +50,8 @@ using namespace std;
 /*!
  * Compare two HttpDir::FileStruct by their filename.
  */
-bool HttpDir::compareFileStructByName (HttpDir::FileStruct i, 
HttpDir::FileStruct j)
+bool HttpDir::compareFileStructByName (HttpDir::FileStruct i,
+                                       HttpDir::FileStruct j)
 {
   return stringcmpi (i.name, j.name) < 0 ? true : false;
 }
@@ -61,7 +60,8 @@ bool HttpDir::compareFileStructByName (HttpDir::FileStruct i, 
HttpDir::FileStruc
  * Compare two HttpDir::FileStruct by their last modified file time.
  */
 
-bool HttpDir::compareFileStructByTime (HttpDir::FileStruct i, 
HttpDir::FileStruct j)
+bool HttpDir::compareFileStructByTime (HttpDir::FileStruct i,
+                                       HttpDir::FileStruct j)
 {
   return i.time_write < j.time_write;
 }
@@ -69,29 +69,30 @@ bool HttpDir::compareFileStructByTime (HttpDir::FileStruct 
i, HttpDir::FileStruc
 /*!
  * Compare two HttpDir::FileStruct by their file size.
  */
-bool HttpDir::compareFileStructBySize (HttpDir::FileStruct i, 
HttpDir::FileStruct j)
+bool HttpDir::compareFileStructBySize (HttpDir::FileStruct i,
+                                       HttpDir::FileStruct j)
 {
   return i.size < j.size;
 }
 
 /*!
- *Constructor for the class.
+ * Constructor for the class.
  */
-HttpDir::HttpDir()
+HttpDir::HttpDir ()
 {
 
 }
 
 /*!
- *Destroy the object.
+ * Destroy the object.
  */
-HttpDir::~HttpDir()
+HttpDir::~HttpDir ()
 {
 
 }
 
 /*!
- *Load the static elements.
+ * Load the static elements.
  */
 int HttpDir::load ()
 {
@@ -99,7 +100,7 @@ int HttpDir::load ()
 }
 
 /*!
- *Unload the static elements.
+ * Unload the static elements.
  */
 int HttpDir::unLoad ()
 {
@@ -107,12 +108,12 @@ int HttpDir::unLoad ()
 }
 
 /*!
- *Get a formatted dobule representation of BYTES right shifted by POWER.
- *\param bytes Number of bytes.
- *\param power Power of 2.
- *\return the double representation for BYTES>>POWER.
+  *Get a formatted dobule representation of BYTES right shifted by POWER.
+ * \param bytes Number of bytes.
+ * \param power Power of 2.
+ * \return the double representation for BYTES>>POWER.
  */
-double HttpDir::formatBytes(u_long bytes, u_int power)
+double HttpDir::formatBytes (u_long bytes, u_int power)
 {
   /* u_long can be 32 bits.  Don't do a right shift that is bigger than
    * its size.  */
@@ -129,11 +130,11 @@ double HttpDir::formatBytes(u_long bytes, u_int power)
 
 
 /*!
- *Fullfill the string out with a formatted representation for bytes.
- *\param bytes Size to format.
- *\param out Out string. 
+ * Fullfill the string out with a formatted representation for bytes.
+ * \param bytes Size to format.
+ * \param out Out string. 
  */
-void HttpDir::getFormattedSize(u_long bytes, string & out)
+void HttpDir::getFormattedSize (u_long bytes, string & out)
 {
   const string symbols[] = {"TB", "GB", "MB", "KB", "bytes"};
   const u_int powers[] = {40, 30, 20, 10, 0};
@@ -163,11 +164,11 @@ void HttpDir::getFormattedSize(u_long bytes, string & out)
 }
 
 /*!
- *Generate the HTML header for the results table.
- *\param out Buffer where write it.
- *\param sortType How elements are sorted.
- *\param sortReverse True if element are in reverse order.
- *\param formatString Decide which fields show.
+ * Generate the HTML header for the results table.
+ * \param out Buffer where write it.
+ * \param sortType How elements are sorted.
+ * \param sortReverse True if element are in reverse order.
+ * \param formatString Decide which fields show.
  */
 void HttpDir::generateHeader (MemBuf &out, char sortType, bool sortReverse,
                               const char* formatString)
@@ -214,11 +215,11 @@ void HttpDir::generateHeader (MemBuf &out, char sortType, 
bool sortReverse,
 }
 
 /*!
- *Generate the HTML code for an element in the result table.
- *\param out Buffer where write the HTML.
- *\param file Structure with information on the element.
- *\param linkPrefix Prefix to use for the generated links.
- *\param formatString Specify which element show.
+ * Generate the HTML code for an element in the result table.
+ * \param out Buffer where write the HTML.
+ * \param file Structure with information on the element.
+ * \param linkPrefix Prefix to use for the generated links.
+ * \param formatString Specify which element show.
  */
 void HttpDir::generateElement (MemBuf &out, 
                                FileStruct &file, 
@@ -282,12 +283,12 @@ void HttpDir::generateElement (MemBuf &out,
 
 
 /*!
- *Browse a directory printing its contents in an HTML file.
- *\param td The current thread context.
- *\param directory Directory to show.
- *\param cgi not used.
- *\param execute not used.
- *\param onlyHeader Specify if send only the HTTP header.
+ * Browse a directory printing its contents in an HTML file.
+ * \param td The current thread context.
+ * \param directory Directory to show.
+ * \param cgi not used.
+ * \param execute not used.
+ * \param onlyHeader Specify if send only the HTTP header.
 */
 int HttpDir::send(HttpThreadContext* td,
                   const char* directory, const char* cgi, 
@@ -454,8 +455,8 @@ int HttpDir::send(HttpThreadContext* td,
   }
 
   /*
-   *With the current code we build the HTML TABLE to indicize the
-   *files in the directory.
+   * With the current code we build the HTML TABLE to indicize the
+   * files in the directory.
    */
   td->secondaryBuffer->setLength(0);
   *td->secondaryBuffer << "<table width=\"100%\">\r\n" ;
@@ -646,17 +647,17 @@ int HttpDir::send(HttpThreadContext* td,
 }
 
 /*!
- *Format a string to html.
- *\param in String to convert.
- *\param out HTML converted string.
+ * Format a string to html.
+ * \param in String to convert.
+ * \param out HTML converted string.
  */
 void HttpDir::formatHtml(string& in, string& out)
 {
   string::size_type pos = 0;
   out.assign(in);
   /*
-   *Replace characters in the ranges 32-65 91-96 123-126 160-255
-   *with "&#CODE;".
+   * Replace characters in the ranges 32-65 91-96 123-126 160-255
+   * with "&#CODE;".
    */
   for(pos = 0; out[pos] != '\0'; pos++)
   {
diff --git a/myserver/src/http_handler/http_file/http_file.cpp 
b/myserver/src/http_handler/http_file/http_file.cpp
index cfde37b..539d951 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -31,11 +31,11 @@ using namespace std;
 extern "C" 
 {
 #ifdef WIN32
-#include <direct.h>
-#include <errno.h>
+# include <direct.h>
+# include <errno.h>
 #else
-#include <string.h>
-#include <errno.h>
+# include <string.h>
+# include <errno.h>
 #endif
 }
 
@@ -369,10 +369,10 @@ int HttpFile::send (HttpThreadContext* td,
     if (td->mime)
       {
         if (td->mime &&
-            Server::getInstance()->getFiltersFactory()->chain (&chain,
-                                                               
td->mime->filters,
-                                                               &memStream,
-                                                               &nbw))
+            Server::getInstance ()->getFiltersFactory ()->chain (&chain,
+                                                                 
td->mime->filters,
+                                                                 &memStream,
+                                                                 &nbw))
           {
             file->close ();
             delete file;
diff --git a/myserver/src/protocol/protocol.cpp 
b/myserver/src/protocol/protocol.cpp
index ab6ce81..106d613 100755
--- a/myserver/src/protocol/protocol.cpp
+++ b/myserver/src/protocol/protocol.cpp
@@ -15,66 +15,56 @@ 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 <include/protocol/protocol.h>
-#include <include/base/xml/xml_parser.h>
-
 
 /*!
- *Load the protocol. Called once at runtime.
+ * Load the protocol. Called once at runtime.
  */
-int Protocol::loadProtocol(XmlParser* /*languageParser*/)
+int Protocol::loadProtocol (XmlParser* /*languageParser*/)
 {
   return 1;
 }
 
 /*!
- *Unload the protocol. Called once.
+ * Unload the protocol. Called once.
  */
-int Protocol::unLoadProtocol(XmlParser* /*languageParser*/)
+int Protocol::unLoadProtocol (XmlParser* /*languageParser*/)
 {
   return 1;
 }
 
 /*!
- *Control the connection.
+ * Control the connection.
  */
-int Protocol::controlConnection(ConnectionPtr /*a*/,char* /*b1*/,
-                                char* /*b2*/,int /*bs1*/,int /*bs2*/,
-                                u_long /*nbtr*/,u_long /*id*/)
+int Protocol::controlConnection (ConnectionPtr /*a*/,char* /*b1*/,
+                                 char* /*b2*/,int /*bs1*/,int /*bs2*/,
+                                 u_long /*nbtr*/,u_long /*id*/)
 {
-  /*!
-   *Returns value are:
-   *0 to delete the connection from the active connections list
-   *1 to keep the connection active and clear the connectionBuffer
-   *2 if the header is incomplete and to save it in a temporary buffer
-   *3 if the header is incomplete without save it in a temporary buffer
-   */
   return 0;
 }
 
 /*!
- *Returns the name of the protocol. If an out buffer is 
- *defined fullfill it with the name too.
+ * Returns the name of the protocol. If an out buffer is 
+ * defined fullfill it with the name too.
  */
-char* Protocol::registerName(char* /*out*/,int /*len*/)
+char* Protocol::registerName (char* /*out*/,int /*len*/)
 {
   return 0;
 }
 
 /*!
- *Constructor for the class protocol.
+ * Constructor for the class protocol.
  */
-Protocol::Protocol()
+Protocol::Protocol ()
 {
   protocolOptions = 0;
   protocolPrefix.assign ("");
 }
 
 /*!
- *Destroy the object.
+ * Destroy the object.
  */
-Protocol::~Protocol()
+Protocol::~Protocol ()
 {
 
 }
diff --git a/myserver/src/protocol/protocol_buffer.cpp 
b/myserver/src/protocol/protocol_buffer.cpp
index 5e70c30..10a0d67 100644
--- a/myserver/src/protocol/protocol_buffer.cpp
+++ b/myserver/src/protocol/protocol_buffer.cpp
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2007, 2009 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
@@ -15,7 +15,6 @@ 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 "stdafx.h"
 #include <include/protocol/protocol_buffer.h>
 
 /*!
diff --git a/myserver/src/protocol/protocols_manager.cpp 
b/myserver/src/protocol/protocols_manager.cpp
index bd76c48..7bc933d 100755
--- a/myserver/src/protocol/protocols_manager.cpp
+++ b/myserver/src/protocol/protocols_manager.cpp
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 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
@@ -17,50 +17,44 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 
 
 #include <include/protocol/protocols_manager.h>
-#include <include/base/xml/xml_parser.h>
-#include <include/server/server.h>
 #include <string>
 #include <algorithm>
 #include <cctype> 
 
-
-
 /*!
- *Class constructor.
+ * Class constructor.
  */
-ProtocolsManager::ProtocolsManager() 
+ProtocolsManager::ProtocolsManager ()
 {
 
 }
 
 /*!
- *Class destructor.
+ * Class destructor.
  */
-ProtocolsManager::~ProtocolsManager()
+ProtocolsManager::~ProtocolsManager ()
 {
 
 }
 
 /*!
- *Return a protocol by its name.
+ * Return a protocol by its name.
  */
-Protocol* ProtocolsManager::getProtocol(string& name)
+Protocol* ProtocolsManager::getProtocol (string& name)
 {
-  return staticProtocols.get(name);
+  return staticProtocols.get (name);
 }
 
 /*!
- *Add a static protocol to the list.
+ * Add a static protocol to the list.
  */
-void ProtocolsManager::addProtocol(string& name, Protocol* protocol)
+void ProtocolsManager::addProtocol (string& name, Protocol* protocol)
 {
-  std::transform(name.begin(),
-                 name.end(),
-                 name.begin(),
-                 static_cast < int(*)(int) > (tolower) );
+  std::transform (name.begin (), name.end (), name.begin (),
+                  static_cast < int(*)(int) > (tolower));
 
-  staticProtocols.put(name, protocol);
-  staticProtocolsList.push_back(protocol);
+  staticProtocols.put (name, protocol);
+  staticProtocolsList.push_back (protocol);
 }
 
 

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

Summary of changes:
 myserver/src/base/file/files_utility.cpp          |  639 ++++++++++-----------
 myserver/src/http_handler/http_dir/http_dir.cpp   |   95 ++--
 myserver/src/http_handler/http_file/http_file.cpp |   16 +-
 myserver/src/protocol/protocol.cpp                |   40 +-
 myserver/src/protocol/protocol_buffer.cpp         |    3 +-
 myserver/src/protocol/protocols_manager.cpp       |   34 +-
 6 files changed, 390 insertions(+), 437 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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