r147 - in branches/work_302: . util

jls17 at arinside.org jls17 at arinside.org
Tue Sep 21 03:31:38 CDT 2010


Author: jls17
Date: Tue Sep 21 03:31:37 2010
New Revision: 147
URL: http://arinside.org/changeset/147

Log:
merged in changes from r143, r144 & r145; updated CMakeLists.txt to support 3.0.2 builds;

Added:
   branches/work_302/CMakeLists.txt
      - copied, changed from r145, trunk/CMakeLists.txt
   branches/work_302/config.h.in
      - copied unchanged from r145, trunk/config.h.in
Modified:
   branches/work_302/   (props changed)
   branches/work_302/COPYING
   branches/work_302/Main.cpp
   branches/work_302/RELEASE_NOTES.txt
   branches/work_302/WindowsUtil.cpp
   branches/work_302/WindowsUtil.h
   branches/work_302/stdafx.h
   branches/work_302/util/Util.cpp
   branches/work_302/util/Util.h

Copied and modified: branches/work_302/CMakeLists.txt (from r145, trunk/CMakeLists.txt)
==============================================================================
--- trunk/CMakeLists.txt	Wed Sep  1 16:34:30 2010	(r145, copy source)
+++ branches/work_302/CMakeLists.txt	Tue Sep 21 03:31:37 2010	(r147)
@@ -12,7 +12,11 @@
 use 'cmake -DAR_INCLUDE_PATH=/path/to/ars/api/dir'")
 ENDIF(NOT EXISTS ${AR_INCLUDE_PATH})
 
-INCLUDE_DIRECTORIES(${AR_INCLUDE_PATH}/include tinyxml/ tclap/ ./)
+if (NOT DEFINED ZLIB_INCLUDE_PATH)
+  SET(ZLIB_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/zlib")
+ENDIF(NOT DEFINED ZLIB_INCLUDE_PATH)
+
+INCLUDE_DIRECTORIES(${AR_INCLUDE_PATH}/include tinyxml/ tclap/ ./ ${ZLIB_INCLUDE_PATH}/include)
 
 INCLUDE (CheckIncludeFiles)
 CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
@@ -52,7 +56,7 @@
  tinyxml/tinyxml.cpp tinyxml/tinystr.cpp tinyxml/tinyxmlerror.cpp tinyxml/tinyxmlparser.cpp
  util/ImageRefItem.cpp util/FieldRefItem.cpp util/AppTimer.cpp util/Util.cpp util/MissingMenuRefItem.cpp
  util/BlackListItem.cpp
- AppConfig.cpp ARInside.cpp ConfigFile.cpp Main.cpp stdafx.cpp WindowsUtil.cpp
+ AppConfig.cpp ARInside.cpp ConfigFile.cpp gzstream.cpp Main.cpp stdafx.cpp WindowsUtil.cpp
 )
 SET (ARINSIDE_SRC_GIFS
  res/active_link.gif res/al_guide.gif res/application.gif res/ars_edit.gif res/chapter.gif res/disabled.gif
@@ -87,16 +91,23 @@
 
 IF(WIN32)
   SET(ARINSIDE_ARAPI_LIB arapi75 arapi71 arapi70)
+  SET(ZLIB_LIBNAMES zdll)
 ELSE(WIN32)
   SET(ARINSIDE_ARAPI_LIB ar)
+  SET(ZLIB_LIBNAMES z)
 ENDIF(WIN32)
 
 FIND_LIBRARY(ARS_API_LIB NAMES ${ARINSIDE_ARAPI_LIB} PATHS ${AR_INCLUDE_PATH}/lib)
+FIND_LIBRARY(ZLIB_LIB NAMES ${ZLIB_LIBNAMES} PATHS ${ZLIB_INCLUDE_PATH}/lib)
 
 IF (NOT ARS_API_LIB)
   MESSAGE(FATAL_ERROR "Could not find ${ARINSIDE_ARAPI_LIB} in '${AR_INCLUDE_PATH}/lib'! Please check or specify AR_INCLUDE_PATH variable")
 ENDIF (NOT ARS_API_LIB)
 
+IF (NOT ZLIB_LIB)
+  MESSAGE(FATAL_ERROR "Could not find ${ZLIB_LIBNAMES} in '${ZLIB_INCLUDE_PATH}/lib'! Please check or specify ZLIB_INCLUDE_PATH variable")
+ENDIF (NOT ZLIB_LIB)
+
 # now import resources
 IF(UNIX)
 	LINK_DIRECTORIES(${arinside_BINARY_DIR}/res)
@@ -126,6 +137,6 @@
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
 
 ADD_EXECUTABLE(arinside ${ARINSIDE_SRCS} ${ARINSIDE_RESOURCE_OBJECTS})
-TARGET_LINK_LIBRARIES(arinside ${ARS_API_LIB})
+TARGET_LINK_LIBRARIES(arinside ${ARS_API_LIB} ${ZLIB_LIB})
 
 #INSTALL(TARGETS arinside DESTINATION bin)

Modified: branches/work_302/COPYING
==============================================================================
--- branches/work_302/COPYING	Thu Sep  2 09:14:48 2010	(r146)
+++ branches/work_302/COPYING	Tue Sep 21 03:31:37 2010	(r147)
@@ -1,5 +1,5 @@
-ARInside -- Copyright (C) 2009 Stefan Nerlich
-=============================================
+ARInside -- Copyright (C) 2010 Stefan Nerlich, LJ Longwing, John Luthgers
+=========================================================================
 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 Version 2.

Modified: branches/work_302/Main.cpp
==============================================================================
--- branches/work_302/Main.cpp	Thu Sep  2 09:14:48 2010	(r146)
+++ branches/work_302/Main.cpp	Tue Sep 21 03:31:37 2010	(r147)
@@ -54,10 +54,13 @@
 	int tcp = 0;
 	int rpc = 0;
 
-	cout << "ARInside Version " << AppVersion << endl;
-	cout << "Copyright (c) 2009 Stefan Nerlich" << endl << endl;
+	cout << "ARInside Version " << AppVersion << endl << endl;
 
-	CmdLine cmd("ARInside -- http://arinside.org", ' ', AppVersion);
+	CmdLine cmd("ARInside -- http://arinside.org\n"
+		          "Copyright (C) 2010 Stefan Nerlich, LJ Longwing, John Luthgers\n"
+							"This program comes with ABSOLUTELY NO WARRANTY, is free software, and you are welcome to "
+							"redistribute it under certain conditions; see COPYING file for more details.", 
+							' ', AppVersion);
 
 	ValueArg<string> iniArg("i", "ini", "Application settings filename", true, "settings.ini", "string");
 	ValueArg<string> serverArg("s","server","ARSystem server",false,"","string");
@@ -103,22 +106,22 @@
 		LoadConfigFile(settingsIni, appConfig);
 
 		// override settings with values specified by the command line 
-		if (!server.empty() || appConfig.serverName.empty())
+		if (serverArg.isSet())
 			appConfig.serverName = server;
 
-		if (!output.empty() || appConfig.targetFolder.empty())
+		if (outputFolder.isSet())
 			appConfig.targetFolder = output;
 
-		if (!login.empty() || appConfig.userName.empty())
+		if (loginArg.isSet())
 			appConfig.userName = login;
 
-		if (!pwd.empty() || appConfig.password.empty())
+		if (pwdArg.isSet())
 			appConfig.password = pwd;
 
-		if (tcp > 0)
+		if (tcpArg.isSet())
 			appConfig.tcpPort = tcp;
 
-		if (rpc > 0)
+		if (rpcArg.isSet())
 			appConfig.rpcPort = rpc;
 
 		// special checks for server mode
@@ -127,7 +130,7 @@
 			string missingArgs;
 			unsigned int missingCount = 0;
 
-			if (appConfig.serverName.empty())
+			if (!appConfig.fileMode && appConfig.serverName.empty())
 			{
 				missingCount++;
 				missingArgs = "server / ServerName";
@@ -151,8 +154,22 @@
 			}
 		}
 
+		// validate the path of the target folder
+		if (appConfig.targetFolder.empty())
+		{
+			cout << "[ERR] Target folder setting is missing or not setup correctly!" << endl;
+			throw ExitException(1);
+		}
+		
+		string fullOutputPath = CWindowsUtil::GetRealPathName(appConfig.targetFolder);
+		if (CUtil::StrEndsWith(fullOutputPath, ":\\") || CUtil::StrEndsWith(fullOutputPath, ":/") || fullOutputPath == "/")
+		{
+			cout << "[ERR] The target directory points to the root of the device. This is not allowed!" << endl;
+			throw ExitException(1);
+		}
+
 		CWindowsUtil winUtil(appConfig);		
-		CARInside arInside(appConfig);;
+		CARInside arInside(appConfig);
 
 		//Delete existing files
 		if(appConfig.bDeleteExistingFiles)
@@ -162,6 +179,8 @@
 		}
 
 		//Create the target directory specified in the configuration files
+		//TODO: CreateAppDirectory returns false if the directory already exists .. this should be changed so
+		//      we can check if there is something going wrong and stop the process!!
 		winUtil.CreateAppDirectory();
 
 		if(arInside.ValidateTargetDir(appConfig.targetFolder) == 0)
@@ -213,6 +232,8 @@
 		}			
 		else
 		{
+			// TODO: ValidateTargetDir returns 0 on success. On error there is no information about the error
+			// at all .. only "whoops, cant create directory" .. hell yes, and now? where is my glass sphere...
 			cout << "Failed to create target directory: " << appConfig.targetFolder << endl;
 			result = AR_RETURN_ERROR;
 		}
@@ -237,7 +258,7 @@
 	}
 	catch(AppException &e)
 	{
-		cout << endl << "AppException: " << e.typeDescription() << endl << "Description: " << e.error();	
+		cout << endl << "AppException: " << e.typeDescription() << endl << "Description: " << e.error() << endl;	
 	}
 	catch (ArgException &e)
 	{ 
@@ -271,7 +292,7 @@
 		config.readInto<int>(cfg.maxRetrieve, "MaxRetrieve", 0);
 		config.readInto<string>(cfg.companyName, "CompanyName", "");
 		config.readInto<string>(cfg.companyUrl, "CompanyUrl", "");
-		config.readInto<string>(cfg.targetFolder, "TargetFolder", "DefaultOutputFolder");
+		config.readInto<string>(cfg.targetFolder, "TargetFolder", "");
 		config.readInto<bool>(cfg.fileMode, "FileMode", false);
 		config.readInto<string>(cfg.objListXML, "ObjListXML", "");
 		config.readInto<bool>(cfg.oldNaming, "OldNaming", false);

Modified: branches/work_302/RELEASE_NOTES.txt
==============================================================================
--- branches/work_302/RELEASE_NOTES.txt	Thu Sep  2 09:14:48 2010	(r146)
+++ branches/work_302/RELEASE_NOTES.txt	Tue Sep 21 03:31:37 2010	(r147)
@@ -4,6 +4,26 @@
 E - Enhancement
 D - Defect fixed
 
+2010-09-01
+[3.0.1]
+E - All command line options except ini (-i) are now optional (all settings are configurable within the ini file)
+E - New command line option "-o" to specify the output directory
+E - All objects are now loaded with the ARGetMultiple-functions to improve performance
+E - Internal object and memory usage optimized
+E - You can now blacklist images
+E - Now the filename/URL of the pages is generated by the object name instead of a consecutive number
+    (you can use the OldNaming setting to enabled the old file naming) 
+E - Added linux & SunOS platform support
+E - Program stops if TargetFolder points to the root directory [#64]
+
+D - No attachment fields were listed for attachment pool [#82]
+D - Server informations were displayed incorrectly (wrong value for wrong server info)
+D - Rare crash while decoding qualifier fixed [#78]
+D - fixed: Loading of groups using server version 6.3
+D - fixed: crashing during "Checking filter references" using server version 6.3
+D - fixed: crash while documenting schema details using server version 6.3 (was caused by audit documentation)
+D - fixed: objects with leading space(s) weren't listed currectly (crashed in some cases)
+
 2010-03-01
 [3.0.0]
 N - This is the first OpenSource release of ARInside

Modified: branches/work_302/WindowsUtil.cpp
==============================================================================
--- branches/work_302/WindowsUtil.cpp	Thu Sep  2 09:14:48 2010	(r146)
+++ branches/work_302/WindowsUtil.cpp	Tue Sep 21 03:31:37 2010	(r147)
@@ -17,6 +17,7 @@
 #include "stdafx.h"
 #include "resource.h"
 #include "WindowsUtil.h"
+#include "AppException.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -24,6 +25,8 @@
 #ifdef WIN32
 #include <windows.h>
 #include <direct.h>
+#else
+#include <errno.h>
 #endif // WIN32
 
 CWindowsUtil::CWindowsUtil(AppConfig &appConfig)
@@ -205,3 +208,32 @@
 
 	return 0;
 }
+
+string CWindowsUtil::GetRealPathName(const std::string &path)
+{
+#ifdef WIN32
+	char buffer[MAX_PATH]; buffer[0] = 0;
+	LPSTR *filePos = NULL;
+
+	DWORD len = GetFullPathName(path.c_str(), MAX_PATH, buffer, filePos);
+	if (len > MAX_PATH || len == 0)
+	{
+		stringstream tmp;
+		tmp << "Error: could not retrieve the full output path! (" << GetLastError() << ")";
+		throw AppException(tmp.str(), "filesystem");			
+	}
+#else
+	// NOTE: realpath doesn't return the full path under SunOS if a relativ path is specified.
+	char buffer[PATH_MAX]; buffer[0] = 0;
+	char *p;
+	p = realpath(path.c_str(), buffer);
+	if (p == NULL)
+	{
+		if (errno == ENOENT) return path;
+		stringstream tmp;
+		tmp << strerror(errno) << ": " << path;
+		throw AppException(tmp.str(), "filesystem");			
+	}
+#endif
+	return buffer;
+}

Modified: branches/work_302/WindowsUtil.h
==============================================================================
--- branches/work_302/WindowsUtil.h	Thu Sep  2 09:14:48 2010	(r146)
+++ branches/work_302/WindowsUtil.h	Tue Sep 21 03:31:37 2010	(r147)
@@ -26,6 +26,7 @@
 	void Load();
 	bool CreateAppDirectory();
 	int CreateSubDirectory(string name);
+	static std::string GetRealPathName(const std::string &path);
 
 private:
 	void LoadFromResource(unsigned int res, string fileName, string path);

Copied: branches/work_302/config.h.in (from r145, trunk/config.h.in)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/work_302/config.h.in	Tue Sep 21 03:31:37 2010	(r147, copy of r145, trunk/config.h.in)
@@ -0,0 +1,18 @@
+//Copyright (C) 2010 John Luthgers | jls17
+//
+//This file is part of ARInside.
+//
+//    ARInside 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, version 2 of the License.
+//
+//    ARInside 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 ARInside.  If not, see <http://www.gnu.org/licenses/>.
+
+#cmakedefine HAVE_UNISTD_H
+#cmakedefine HAVE_STRINGS_H

Modified: branches/work_302/stdafx.h
==============================================================================
--- branches/work_302/stdafx.h	Thu Sep  2 09:14:48 2010	(r146)
+++ branches/work_302/stdafx.h	Tue Sep 21 03:31:37 2010	(r147)
@@ -25,6 +25,7 @@
 #include <vector>
 #include <time.h>
 #include <stdlib.h> // JLS17_LINUX
+#include <stdio.h>
 
 #include "util/Util.h"
 

Modified: branches/work_302/util/Util.cpp
==============================================================================
--- branches/work_302/util/Util.cpp	Thu Sep  2 09:14:48 2010	(r146)
+++ branches/work_302/util/Util.cpp	Tue Sep 21 03:31:37 2010	(r147)
@@ -150,3 +150,9 @@
 
 	return buffer;
 }
+
+bool CUtil::StrEndsWith(const std::string &str, const std::string &search)
+{
+	if (search.size() > str.size()) return false;
+	return equal(str.end() - search.size(), str.end(), search.begin());
+}

Modified: branches/work_302/util/Util.h
==============================================================================
--- branches/work_302/util/Util.h	Thu Sep  2 09:14:48 2010	(r146)
+++ branches/work_302/util/Util.h	Tue Sep 21 03:31:37 2010	(r147)
@@ -40,6 +40,7 @@
 	static string ClearSpaces(const string &strIn);
 	static string String2Comp(string strIn);
 	static string StrReplace(const std::string &search, const std::string &replace, std::string searchin);
+	static bool StrEndsWith(const std::string &str, const std::string &search);
 	//static int SplitString(const string& input, const string& delimiter, vector<string>& results, bool includeEmpties);	
 
 	static int SplitString(const std::string& input_record, std::vector<std::string>& colv);


More information about the arinside-src mailing list