From 8bf17481fbd360094c04d25023986b38e57205bc Mon Sep 17 00:00:00 2001 From: jhurst Date: Tue, 20 May 2008 22:40:09 +0000 Subject: [PATCH] version reorg, precedence patch for stat check --- configure.ac | 10 ++++++++++ src/AS_DCP.cpp | 4 +--- src/AS_DCP.h | 13 ++----------- src/KM_fileio.cpp | 4 ++-- src/asdcp-test.cpp | 5 +---- src/h__Writer.cpp | 34 +++++++++++++++++++++++++++++++--- 6 files changed, 47 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index e41af9c..f65642f 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,17 @@ AC_PREREQ([2.59]) # If you change this, you should update the libtool version number specified # in src/Makefile.am. Read # for suggestions on doing so. + +# The version number consists of three segments: major, API minor, and +# implementation minor. Whenever a change is made to AS_DCP.h, the API minor +# version will increment. Changes made to the internal implementation will +# result in the incrementing of the implementation minor version. +# +# For example, if asdcplib version 1.0.0 were modified to accomodate changes +# in file format, and if no changes were made to AS_DCP.h, the new version would be +# 1.0.1. If changes were also required in AS_DCP.h, the new version would be 1.1.1. AC_INIT([asdcplib], [1.3.19], [asdcplib@cinecert.com]) + AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([src/KM_error.h]) #AC_CONFIG_HEADER([src/config.h]) diff --git a/src/AS_DCP.cpp b/src/AS_DCP.cpp index 10d5c66..9bb8dd5 100755 --- a/src/AS_DCP.cpp +++ b/src/AS_DCP.cpp @@ -35,9 +35,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. const char* ASDCP::Version() { - static char ver[16]; - snprintf(ver, 16, "%u.%u.%u", VERSION_MAJOR, VERSION_APIMINOR, VERSION_IMPMINOR); - return ver; + return PACKAGE_VERSION; } diff --git a/src/AS_DCP.h b/src/AS_DCP.h index e03557a..bda4c13 100755 --- a/src/AS_DCP.h +++ b/src/AS_DCP.h @@ -146,17 +146,8 @@ typedef unsigned int ui32_t; // All library components are defined in the namespace ASDCP // namespace ASDCP { - // The version number consists of three segments: major, API minor, and - // implementation minor. Whenever a change is made to AS_DCP.h, the API minor - // version will increment. Changes made to the internal implementation will - // result in the incrementing of the implementation minor version. - - // For example, if asdcplib version 1.0.0 were modified to accomodate changes - // in file format, and if no changes were made to AS_DCP.h, the new version would be - // 1.0.1. If changes were also required in AS_DCP.h, the new version would be 1.1.1. - const ui32_t VERSION_MAJOR = 1; - const ui32_t VERSION_APIMINOR = 3; - const ui32_t VERSION_IMPMINOR = 19; + // + // The version number declaration and explanation have moved to ../configure.ac const char* Version(); // UUIDs are passed around as strings of UUIDlen bytes diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp index 5a56c44..918a852 100644 --- a/src/KM_fileio.cpp +++ b/src/KM_fileio.cpp @@ -103,7 +103,7 @@ do_stat(const char* path, fstat_t* stat_info) if ( stat(path, stat_info) == -1L ) result = Kumu::RESULT_FILEOPEN; - if ( stat_info->st_mode & (S_IFREG|S_IFLNK|S_IFDIR) == 0 ) + if ( (stat_info->st_mode & (S_IFREG|S_IFLNK|S_IFDIR)) == 0 ) result = Kumu::RESULT_FILEOPEN; #endif @@ -123,7 +123,7 @@ do_fstat(HANDLE handle, fstat_t* stat_info) if ( fstat(handle, stat_info) == -1L ) result = Kumu::RESULT_FILEOPEN; - if ( stat_info->st_mode & (S_IFREG|S_IFLNK|S_IFDIR) == 0 ) + if ( (stat_info->st_mode & (S_IFREG|S_IFLNK|S_IFDIR)) == 0 ) result = Kumu::RESULT_FILEOPEN; return result; diff --git a/src/asdcp-test.cpp b/src/asdcp-test.cpp index c77cd89..daa8b4f 100755 --- a/src/asdcp-test.cpp +++ b/src/asdcp-test.cpp @@ -83,10 +83,7 @@ public: memcpy(ProductUUID, default_ProductUUID_Data, UUIDlen); CompanyName = "WidgetCo"; ProductName = "asdcp-test"; - - char s_buf[128]; - snprintf(s_buf, 128, "%u.%u.%u", VERSION_MAJOR, VERSION_APIMINOR, VERSION_IMPMINOR); - ProductVersion = s_buf; + ProductVersion = ASDCP::Version(); } } s_MyInfo; diff --git a/src/h__Writer.cpp b/src/h__Writer.cpp index 4517966..fb66b68 100755 --- a/src/h__Writer.cpp +++ b/src/h__Writer.cpp @@ -41,6 +41,31 @@ using namespace ASDCP::MXF; #endif +static std::vector +version_split(const char* str) +{ + std::vector result; + + const char* pstr = str; + const char* r = strchr(pstr, '.'); + + while ( r != 0 ) + { + assert(r >= pstr); + if ( r > pstr ) + result.push_back(atoi(pstr)); + + pstr = r + 1; + r = strchr(pstr, '.'); + } + + if( strlen(pstr) > 0 ) + result.push_back(atoi(pstr)); + + assert(result.size() == 3); + return result; +} + // ASDCP::h__Writer::h__Writer() : @@ -124,9 +149,12 @@ ASDCP::h__Writer::InitHeader() Ident->VersionString = m_Info.ProductVersion.c_str(); Ident->ProductUID.Set(m_Info.ProductUUID); Ident->Platform = ASDCP_PLATFORM; - Ident->ToolkitVersion.Major = VERSION_MAJOR; - Ident->ToolkitVersion.Minor = VERSION_APIMINOR; - Ident->ToolkitVersion.Patch = VERSION_IMPMINOR; + + std::vector version = version_split(Version()); + + Ident->ToolkitVersion.Major = version[0]; + Ident->ToolkitVersion.Minor = version[1]; + Ident->ToolkitVersion.Patch = version[2]; Ident->ToolkitVersion.Build = ASDCP_BUILD_NUMBER; Ident->ToolkitVersion.Release = VersionType::RL_RELEASE; } -- 2.30.2