Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/feature-uuid into 
lp:zorba.

Requested reviews:
  Rodolfo Ochoa (rodolfo-ochoa)
  Matthias Brantner (matthias-brantner)
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/feature-uuid/+merge/118268

Replaced UUID with thin layer over native platform implementation.
-- 
https://code.launchpad.net/~zorba-coders/zorba/feature-uuid/+merge/118268
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'CMakeCompiler.txt'
--- CMakeCompiler.txt	2012-07-24 08:48:48 +0000
+++ CMakeCompiler.txt	2012-08-05 16:45:25 +0000
@@ -234,3 +234,13 @@
     ENDIF (NOT CMAKE_C_FLAGS MATCHES "-fvisibility")
   ENDIF ( ZORBA_GNUCOMPILER_MAJOR_VERSION GREATER 3 )
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
+
+IF (APPLE)
+  # Needed for CFUUID*() functions in util/uuid.c.
+  SET(CMAKE_SHARED_LINKER_FLAGS "-framework CoreFoundation ${CMAKE_SHARED_LINKER_FLAGS}")
+ELSEIF (WIN32)
+  SET(requiredlibs ${requiredlibs} "Rpcrt4")
+ELSEIF (ZORBA_HAVE_UUID_H)
+  # Needed for uuid_generate() function in util/uuid.c.
+  SET(CMAKE_SHARED_LINKER_FLAGS "-luuid ${CMAKE_SHARED_LINKER_FLAGS}")
+ENDIF (ZORBA_HAVE_UUID_H)

=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2012-07-24 08:48:48 +0000
+++ CMakeLists.txt	2012-08-05 16:45:25 +0000
@@ -101,6 +101,7 @@
   CHECK_INCLUDE_FILES ("execinfo.h"                   ZORBA_HAVE_EXECINFO_H)
 ENDIF (NOT APPLE OR ${CMAKE_SYSTEM_VERSION} VERSION_GREATER "10.4")
 CHECK_INCLUDE_FILE_CXX ("FlexLexer.h"               ZORBA_HAVE_FLEXLEXER_H)
+CHECK_INCLUDE_FILES ("uuid/uuid.h"                  ZORBA_HAVE_UUID_H)
 
 CHECK_FUNCTION_EXISTS (strtof                     ZORBA_HAVE_STRTOF_FUNCTION)
 CHECK_FUNCTION_EXISTS (strtoll                    ZORBA_HAVE_STRTOLL_FUNCTION)

=== modified file 'include/zorba/config.h.cmake'
--- include/zorba/config.h.cmake	2012-07-24 08:48:48 +0000
+++ include/zorba/config.h.cmake	2012-08-05 16:45:25 +0000
@@ -52,6 +52,7 @@
 #cmakedefine ZORBA_HAVE_SYS_TYPES_H
 #cmakedefine ZORBA_HAVE_USTRING_H
 #cmakedefine ZORBA_HAVE_UTYPES_H
+#cmakedefine ZORBA_HAVE_UUID_H
 
 // Platform functions
 #cmakedefine ZORBA_HAVE_CLOCKGETTIME_FUNCTION

=== modified file 'src/runtime/random/random_impl.cpp'
--- src/runtime/random/random_impl.cpp	2012-07-24 08:48:48 +0000
+++ src/runtime/random/random_impl.cpp	2012-08-05 16:45:25 +0000
@@ -15,6 +15,14 @@
  */
 #include "stdafx.h"
 
+#include <sstream>
+
+#ifdef WIN32
+# include <Winsock2.h>
+#else
+# include <arpa/inet.h>
+#endif /* WIN32 */
+
 #include "system/globalenv.h"
 
 #include "runtime/random/random.h"
@@ -27,7 +35,7 @@
 #include <zorba/util/time.h>
 #include <limits>
 
-#include "util/uuid/uuid.h"
+#include "util/uuid.h"
 
 namespace zorba {
 
@@ -104,6 +112,7 @@
   store::Item_t    num;
   unsigned int     int_seed;
   long             walltime_millis;
+  uint32_t         time_low;
   zstring ltmp;
 
   RandomIteratorState* state;
@@ -125,11 +134,12 @@
     time::get_current_walltime( lCurrWallTime );
     walltime_millis = time::get_walltime_in_millis( lCurrWallTime );
 
-    uuid_t  u;
-    memset(&u, 0, sizeof(uuid_t));
-    uuid_create(&u);
-
-    walltime_millis += u.time_low;
+    uuid u;
+    uuid::create(&u);
+    time_low = ntohl(
+      (u.data[0] << 24) | (u.data[1] << 16) | (u.data[2] << 8) | u.data[3]
+    );
+    walltime_millis += time_low;
 
     int_seed = walltime_millis % std::numeric_limits<unsigned int>::max();
 
@@ -151,16 +161,16 @@
 UuidIterator::nextImpl(store::Item_t& result, PlanState& planState) const
 {
   store::Item_t item;
-  uuid_t  u;
+  uuid u;
   zstring uuidStr;
+  std::ostringstream oss;
 
   PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
-  memset(&u, 0, sizeof(uuid_t));
-
-  uuid_create(&u);
-  uuidStr = uuidToString(u);
+  uuid::create(&u);
+  oss << u;
+  uuidStr = oss.str();
 
   GENV_ITEMFACTORY->createString(result, uuidStr);
   STACK_PUSH(true, state);

=== modified file 'src/store/naive/simple_store.cpp'
--- src/store/naive/simple_store.cpp	2012-07-24 08:48:48 +0000
+++ src/store/naive/simple_store.cpp	2012-08-05 16:45:25 +0000
@@ -15,6 +15,8 @@
  */
 #include "stdafx.h"
 
+#include <sstream>
+
 #include "simple_store.h"
 #include "store_defs.h"
 
@@ -30,7 +32,7 @@
 #include "diagnostics/diagnostic.h"
 #include <zorba/diagnostic_list.h>
 
-#include "util/uuid/uuid.h"
+#include "util/uuid.h"
 #include "zorbautils/string_util.h"
 
 #ifdef ZORBA_WITH_JSON
@@ -288,9 +290,11 @@
     return theItemFactory->createAnyURI(result, id);
   }
 
-  uuid_t uuid;
-  uuid_create(&uuid);
-  zstring uuidStr = uuidToURI(uuid);
+  uuid u;
+  uuid::create(&u);
+  std::ostringstream oss;
+  oss << "urn:uuid:" << u;
+  zstring uuidStr = oss.str();
 
   assignReference(xmlNode, uuidStr);
 

=== modified file 'src/store/naive/store.cpp'
--- src/store/naive/store.cpp	2012-07-24 08:48:48 +0000
+++ src/store/naive/store.cpp	2012-08-05 16:45:25 +0000
@@ -58,7 +58,6 @@
 #include "tree_id_generator.h"
 
 #include "util/cxx_util.h"
-#include "util/uuid/uuid.h"
 #include "zorbautils/string_util.h"
 
 #ifndef ZORBA_NO_FULL_TEXT

=== modified file 'src/unit_tests/CMakeLists.txt'
--- src/unit_tests/CMakeLists.txt	2012-07-24 08:48:48 +0000
+++ src/unit_tests/CMakeLists.txt	2012-08-05 16:45:25 +0000
@@ -20,6 +20,7 @@
   test_json_parser.cpp
   test_string.cpp
   test_uri.cpp
+  test_uuid.cpp
   unit_tests.cpp
 )
 

=== added file 'src/unit_tests/test_uuid.cpp'
--- src/unit_tests/test_uuid.cpp	1970-01-01 00:00:00 +0000
+++ src/unit_tests/test_uuid.cpp	2012-08-05 16:45:25 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006-2010 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "stdafx.h"
+#include <iostream>
+
+#include "util/uuid.h"
+
+using namespace std;
+using namespace zorba;
+
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace zorba {
+namespace UnitTests {
+
+int test_uuid( int argc, char *argv[] ) {
+  uuid u;
+  uuid::create( &u );
+  cout << u << endl;
+  return 0;
+}
+
+} // namespace UnitTests
+} // namespace zorba
+
+/* vim:set et sw=2 ts=2: */

=== modified file 'src/unit_tests/unit_test_list.h'
--- src/unit_tests/unit_test_list.h	2012-07-24 08:48:48 +0000
+++ src/unit_tests/unit_test_list.h	2012-08-05 16:45:25 +0000
@@ -42,6 +42,7 @@
 #ifndef ZORBA_HAVE_UNIQUE_PTR
   int test_unique_ptr( int, char*[] );
 #endif /* ZORBA_HAVE_UNIQUE_PTR */
+  int test_uuid( int, char*[] );
 #ifndef ZORBA_HAVE_UNORDERED_MAP
   int test_unordered_map( int, char*[] );
 #endif /* ZORBA_HAVE_UNORDERED_MAP */

=== modified file 'src/unit_tests/unit_tests.cpp'
--- src/unit_tests/unit_tests.cpp	2012-07-24 08:48:48 +0000
+++ src/unit_tests/unit_tests.cpp	2012-08-05 16:45:25 +0000
@@ -53,6 +53,7 @@
 #ifndef ZORBA_HAVE_UNIQUE_PTR
   libunittests["unique_ptr"] = test_unique_ptr;
 #endif /* ZORBA_HAVE_UNIQUE_PTR */
+  libunittests["uuid"] = test_uuid;
 #ifndef ZORBA_HAVE_UNORDERED_MAP
   libunittests["unordered_map"] = test_unordered_map;
 #endif /* ZORBA_HAVE_UNORDERED_MAP */

=== modified file 'src/util/CMakeLists.txt'
--- src/util/CMakeLists.txt	2012-07-25 23:20:47 +0000
+++ src/util/CMakeLists.txt	2012-08-05 16:45:25 +0000
@@ -29,11 +29,10 @@
   unicode_categories.cpp
   uri_util.cpp
   utf8_util.cpp
+  uuid.cpp
   xml_util.cpp
   fx/fxcharheap.cpp
   string/empty_rep_base.cpp
-  uuid/sysdep.cpp
-  uuid/uuid.cpp
   http_util.h
   http_util.cpp)
 

=== removed directory 'src/util/uuid'
=== added file 'src/util/uuid.cpp'
--- src/util/uuid.cpp	1970-01-01 00:00:00 +0000
+++ src/util/uuid.cpp	2012-08-05 16:45:25 +0000
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/config.h>
+
+#ifdef _WIN32
+# include <Winsock2.h>                  /* for ntohl(3) */
+#else
+# include <arpa/inet.h>                 /* for ntohl(3) */
+#endif /* WIN32 */
+
+#include <cstdio>                       /* for sprintf(3) */
+
+#if defined( __APPLE__ )
+# include <cstring>                     /* for memcpy(3) */
+# include <CoreFoundation/CoreFoundation.h>
+#elif defined( ZORBA_HAVE_UUID_H )
+# include <uuid/uuid.h>
+#elif defined( _WIN32 )
+# include <Rpc.h>
+#else
+# error "Unsupported operating system for generating UUIDs"
+#endif
+
+#include "uuid.h"
+
+using namespace std;
+
+namespace zorba {
+
+///////////////////////////////////////////////////////////////////////////////
+
+void uuid::create( uuid *result ) {
+#if defined( __APPLE__ )
+  CFUUIDRef uuid_ref = CFUUIDCreate( NULL );
+  CFUUIDBytes uuid_bytes = CFUUIDGetUUIDBytes( uuid_ref );
+  CFRelease( uuid_ref );
+  ::memcpy( result->data, &uuid_bytes, sizeof result->data );
+#elif defined( ZORBA_HAVE_UUID_H )
+  uuid_generate( result->data );
+#elif defined( _WIN32 )
+  UuidCreateSequential( (UUID*)result->data );
+#endif /* _WIN32 */
+}
+
+uuid::variant uuid::get_variant() const {
+  value_type const octet8 = data[8];
+  if ( (octet8 & 0x80u) == 0x00u )
+    return ncs;
+  if ( (octet8 & 0xC0u) == 0x80u )
+    return rfc4122;
+  if ( (octet8 & 0xE0u) == 0xC0u )
+    return microsoft;
+  return future;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+ostream& operator<<( ostream &os, uuid const &u ) {
+  uint32_t const time_low = ntohl(
+    (u.data[0] << 24) | (u.data[1] << 16) | (u.data[2] << 8) | u.data[3]
+  );
+  uint16_t const time_mid = ntohs( (u.data[4] << 8) | u.data[5] );
+  uint16_t const time_hi_and_version = ntohs( (u.data[6] << 8) | u.data[7] );
+  uint8_t const clock_seq_hi_and_reserved = u.data[8];
+  uint8_t const clock_seq_low = u.data[9];
+  uuid::value_type const *const node = u.data + 10;
+  char buf[37];
+  sprintf(
+    buf, "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
+    time_low, time_mid, time_hi_and_version, clock_seq_hi_and_reserved,
+    clock_seq_low, node[0], node[1], node[2], node[3], node[4], node[5]
+  );
+  return os << buf;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+} // namespace zorba
+
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
+/* vim:set et sw=2 ts=2: */

=== added file 'src/util/uuid.h'
--- src/util/uuid.h	1970-01-01 00:00:00 +0000
+++ src/util/uuid.h	2012-08-05 16:45:25 +0000
@@ -0,0 +1,249 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+#ifndef ZORBA_UUID_H
+#define ZORBA_UUID_H
+
+#include <algorithm>
+#include <iostream>
+#include <sys/types.h>
+
+#include "zorbatypes/zstring.h"
+
+namespace zorba {
+
+///////////////////////////////////////////////////////////////////////////////
+
+/**
+ * A %uuid contains the raw bytes for a UUID.  Note that this is intentially a
+ * \c struct with no constructors, no destructor, and no user-defined
+ * assignment operators so that it remains a POD.
+ */
+struct uuid {
+  typedef uint8_t value_type;
+  typedef value_type& reference;
+  typedef value_type const& const_reference;
+  typedef value_type* pointer;
+  typedef value_type const* const_pointer;
+  typedef std::size_t size_type;
+  typedef std::ptrdiff_t difference_type;
+
+  typedef pointer iterator;
+  typedef const_pointer const_iterator;
+
+  enum variant {
+    ncs,                                ///< NCS backward compatibility
+    rfc4122,                            ///< RFC 4122
+    microsoft,                          ///< Microsoft compatibility
+    future                              ///< Reserved for future use
+  };
+
+  enum version {
+    unknown,
+    time_based          = 0x10,
+    dce_security        = 0x20,
+    name_based_md5      = 0x30,
+    random_number_based = 0x40,
+    name_based_sha1     = 0x50
+  };
+
+  /**
+   * The raw UUID data.
+   */
+  value_type data[16];
+
+  /**
+   * Creates a UUID.  The variant and version of the UUID created is
+   * platform-dependent.
+   *
+   * @param result A pointer to the result.
+   */
+  static void create( uuid *result );
+
+  /**
+   * Creates an iterator to the beginning of the data.
+   *
+   * @return Returns said iterator.
+   */
+  iterator begin() {
+    return data;
+  }
+
+  /**
+   * Creates a const_iterator to the beginning of the data.
+   *
+   * @return Returns said iterator.
+   */
+  const_iterator begin() const {
+    return data;
+  }
+
+  /**
+   * Creates an iterator to one past the end of the data.
+   *
+   * @return Returns said iterator.
+   */
+  iterator end() {
+    return data + size();
+  }
+
+  /**
+   * Creates a const_iterator to one past the end of the data.
+   *
+   * @return Returns said iterator.
+   */
+  const_iterator end() const {
+    return data + size();
+  }
+
+  /**
+   * Gets the size of the UUID data.
+   *
+   * @return Always returns 16.
+   */
+  size_type size() const {
+    return sizeof( data );
+  }
+
+  /**
+   * Swaps this UUID's data with that of another.
+   *
+   * @param that The other UUID to swap data with.
+   */
+  void swap( uuid &that ) {
+    std::swap_ranges( begin(), end(), that.begin() );
+  }
+
+  /**
+   * Gets the variant of this UUID.
+   *
+   * @return Returns said variant.
+   */
+  variant get_variant() const;
+
+  /**
+   * Gets the version of this UUID.
+   *
+   * @return Returns said version.
+   */
+  version get_version() const {
+    return static_cast<version>( data[6] & 0xF0u );
+  }
+};
+
+////////// Functions //////////////////////////////////////////////////////////
+
+/**
+ * Swaps two UUIDs' data.
+ *
+ * @param u1 The first UUID.
+ * @param u2 The second UUID.
+ */
+inline void swap( uuid &u1, uuid &u2 ) {
+  u1.swap( u2 );
+}
+
+/**
+ * Compares two UUIDs for equality.
+ *
+ * @param u1 The first UUID.
+ * @param u2 The second UUID.
+ * @return Returns \c true only if the two UUIDs are equal.
+ */
+inline bool operator==( uuid const &u1, uuid const &u2 ) {
+  return std::equal( u1.begin(), u1.end(), u2.begin() );
+}
+
+/**
+ * Compares two UUIDs for inequality.
+ *
+ * @param u1 The first UUID.
+ * @param u2 The second UUID.
+ * @return Returns \c true only if the two UUIDs are not equal.
+ */
+inline bool operator!=( uuid const &u1, uuid const &u2 ) {
+  return !(u1 == u2);
+}
+
+/**
+ * Compares two UUIDs for less-than.
+ *
+ * @param u1 The first UUID.
+ * @param u2 The second UUID.
+ * @return Returns \c true only if the first UUID is less than the second.
+ */
+inline bool operator<( uuid const &u1, uuid const &u2 ) {
+  return std::lexicographical_compare(
+    u1.begin(), u1.end(), u2.begin(), u2.end()
+  );
+}
+
+/**
+ * Compares two UUIDs for less-than-or-equal-to.
+ *
+ * @param u1 The first UUID.
+ * @param u2 The second UUID.
+ * @return Returns \c true only if the first UUID is less than or equal to the
+ * second.
+ */
+inline bool operator<=( uuid const &u1, uuid const &u2 ) {
+  return !(u2 < u1);
+}
+
+/**
+ * Compares two UUIDs for greater-than.
+ *
+ * @param u1 The first UUID.
+ * @param u2 The second UUID.
+ * @return Returns \c true only if the first UUID is greater than the second.
+ */
+inline bool operator>( uuid const &u1, uuid const &u2 ) {
+  return u2 < u1;
+}
+
+/**
+ * Compares two UUIDs for greater-than-or-equal-to.
+ *
+ * @param u1 The first UUID.
+ * @param u2 The second UUID.
+ * @return Returns \c true only if the first UUID is greater than or equal to
+ * the second.
+ */
+inline bool operator>=( uuid const &u1, uuid const &u2 ) {
+  return !(u1 < u2);
+}
+
+/**
+ * Emits the given UUID to the given ostream in canonical UUID format.
+ *
+ * @param os The ostream to emit to.
+ * @param u The UUID to emit.
+ * @return Returns \a os.
+ */
+std::ostream& operator<<( std::ostream &os, uuid const &u );
+
+///////////////////////////////////////////////////////////////////////////////
+
+} // namespace zorba
+
+#endif /* ZORBA_UUID_H */
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
+/* vim:set et sw=2 ts=2: */

=== removed file 'src/util/uuid/sysdep.cpp'
--- src/util/uuid/sysdep.cpp	2012-07-24 08:48:48 +0000
+++ src/util/uuid/sysdep.cpp	1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "stdafx.h"
-
-#include "sysdep.h"
-
-namespace zorba {
-/* system dependent call to get the current system time. Returned as
-   100ns ticks since UUID epoch, but resolution may be less than
-   100ns. */
-#ifdef WIN32
-
-void get_system_time(xs_unsignedLong *uuid_time)
-{
-  ULARGE_INTEGER time;
-
-  /* NT keeps time in FILETIME format which is 100ns ticks since
-  Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
-  The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
-  + 18 years and 5 leap days, meaning P6653D*/
-  GetSystemTimeAsFileTime((FILETIME *)&time);
-  time.QuadPart +=  (xs_unsignedLong) (1000*1000*10)       // seconds
-                  * (xs_unsignedLong) (60 * 60 * 24)       // days
-                  * (xs_unsignedLong) (17+30+31+365*18+5); // 6653 of days
-  *uuid_time = time.QuadPart;
-}
-
-#else
-
-void get_system_time(xs_unsignedLong *uuid_time)
-{
-  struct timeval tp;
-
-  gettimeofday(&tp, (struct timezone *)0);
-
-  /* Offset between UUID formatted times and Unix formatted times.
-  UUID UTC base time is October 15, 1582.
-  Unix base time is January 1, 1970, meaning P141427D*/
-  *uuid_time = ((xs_unsignedLong)tp.tv_sec * 10000000)
-      + ((xs_unsignedLong)tp.tv_usec * 10)
-      + I64(0x01B21DD213814000);
-}
-
-#endif
-}/*namespace zorba*/
-/* vim:set et sw=2 ts=2: */

=== removed file 'src/util/uuid/sysdep.h'
--- src/util/uuid/sysdep.h	2012-07-24 08:48:48 +0000
+++ src/util/uuid/sysdep.h	1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ZORBA_UTIL_UUID_SYSDEP_H
-#define ZORBA_UTIL_UUID_SYSDEP_H
-
-#include "zorbatypes/schema_types.h"
-
-#ifdef WIN32
-  #include <windows.h>
-#else
-  #include <sys/types.h>
-  #include <sys/time.h>
-#endif
-
-/* Set the following to a calls to get and release a global lock */
-#define LOCK
-#define UNLOCK
-
-// /* Set this to what your compiler uses for 64-bit data type */
-#ifdef WIN32
-  #define unsigned64_t unsigned __int64
-  #define I64(C) C
-#else
-  #define unsigned64_t unsigned long long
-  #define I64(C) C##LL
-#endif
-
-namespace zorba {
-
-/* set the following to the number of 100ns ticks of the actual
-resolution of your system's clock */
-#define UUIDS_PER_TICK 1024
-
-typedef struct {
-  char nodeID[6];
-} uuid_node_t;
-
-void get_system_time(xs_unsignedLong *uuid_time);
-
-}/*namespace zorba*/
-
-#endif /* ZORBA_UTIL_UUID_SYSDEP_H */
-/* vim:set et sw=2 ts=2: */

=== removed file 'src/util/uuid/uuid.cpp'
--- src/util/uuid/uuid.cpp	2012-07-24 08:48:48 +0000
+++ src/util/uuid/uuid.cpp	1970-01-01 00:00:00 +0000
@@ -1,297 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "stdafx.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "util/uuid/sysdep.h"
-#include "util/uuid/uuid.h"
-#include "util/fs_util.h"
-
-namespace zorba {
-
-/* various forward declarations */
-static int read_state(xs_short *clockseq, xs_unsignedLong *timestamp,
-    uuid_node_t *node);
-static void write_state(xs_short clockseq, xs_unsignedLong timestamp,
-    uuid_node_t node);
-static void format_uuid_v1(uuid_t *uuid, xs_short clockseq,
-    xs_unsignedLong timestamp, uuid_node_t node);
-static void get_current_time(xs_unsignedLong *timestamp);
-static xs_short true_random(void);
-
-int uuid_create(uuid_t *uuid)
-{
-  xs_unsignedLong timestamp, last_time;
-  xs_short clockseq;
-  uuid_node_t node;
-  memset(&node, 0, sizeof(uuid_node_t));
-  uuid_node_t last_node;
-  memset(&last_node, 0, sizeof(uuid_node_t));
-  int f;
-
-  //acquire system-wide lock so we're alone
-  LOCK;
-  //get time, node ID, saved state from non-volatile storage
-  get_current_time(&timestamp);
-//   get_ieee_node_identifier(&node);
-  f = read_state(&clockseq, &last_time, &last_node);
-
-  //if no NV state, or if clock went backwards, or node ID
-  //changed (e.g., new network card) change clockseq
-  if (!f || memcmp(&node, &last_node, sizeof node))
-    clockseq = true_random();
-  else if (timestamp < last_time)
-    clockseq++;
-
-  //save the state for next time
-  write_state(clockseq, timestamp, node);
-
-  UNLOCK;
-
-  //stuff fields into the UUID
-  format_uuid_v1(uuid, clockseq, timestamp, node);
-  return 1;
-}
-
-/* format_uuid_v1 -- make a UUID from the timestamp, clockseq,
-                     and node ID */
-void format_uuid_v1(uuid_t* uuid, xs_short clock_seq,
-                    xs_unsignedLong timestamp, uuid_node_t node)
-{
-  //Construct a version 1 uuid with the information we've gathered plus a few constants.
-  uuid->time_low = (xs_unsignedInt)(timestamp & 0xFFFFFFFF);
-  uuid->time_mid = (xs_unsignedShort)((timestamp >> 32) & 0xFFFF);
-  uuid->time_hi_and_version =(xs_unsignedShort)((timestamp >> 48) & 0x0FFF);
-  uuid->time_hi_and_version |= (1 << 12);
-  uuid->clock_seq_low = clock_seq & 0xFF;
-  uuid->clock_seq_hi_and_reserved = (clock_seq & 0x3F00) >> 8;
-  uuid->clock_seq_hi_and_reserved |= 0x80;
-  memcpy(&uuid->node, &node, sizeof uuid->node);
-}
-
-/* data type for UUID generator persistent state */
-typedef struct {
-  xs_unsignedLong ts;   // saved timestamp
-  uuid_node_t     node; // saved node ID
-  xs_short        cs;   // saved clock sequence
-} uuid_state;
-
-static uuid_state st;
-
-zstring get_tmp_state_name()
-{
-  zstring lTmpFileName;
-#ifdef ZORBA_WITH_FILE_ACCESS
-  fs::get_temp_file<zstring>(&lTmpFileName);
-  lTmpFileName = lTmpFileName.substr(0, lTmpFileName.find_last_of(fs::dir_separator) + 1);
-#endif
-  return lTmpFileName += "state";
-}
-
-//read_state -- read UUID generator state from non-volatile store
-int read_state(xs_short *clockseq, xs_unsignedLong *timestamp,
-               uuid_node_t *node)
-{
-  static int inited = 0;
-  FILE *fp = 0;
-
-  //only need to read state once per boot
-  if (!inited) {
-#ifdef WIN32
-    errno_t err = fopen_s( &fp, get_tmp_state_name().c_str(), "rb");
-    if ( err != 0)
-      return 0;
-#else
-    fp = fopen(get_tmp_state_name().c_str(), "rb");
-    if (fp == NULL)
-      return 0;
-#endif
-
-    size_t lReadLength = fread(&st, sizeof st, 1, fp);
-    fclose(fp);
-    if (lReadLength == 0)
-      return 0;
-    inited = 1;
-  }
-  *clockseq = st.cs;
-  *timestamp = st.ts;
-  *node = st.node;
-  return 1;
-}
-
-// write_state -- save UUID generator state back to non-volatile storage
-void write_state(xs_short clockseq, xs_unsignedLong timestamp,
-                 uuid_node_t node)
-{
-  volatile static bool inited = false;
-  static xs_unsignedLong next_save;
-  FILE* fp = 0;
-
-  if (!inited) {
-    next_save = timestamp;
-    inited = 1;
-  }
-
-  //always save state to volatile shared state
-  st.cs = clockseq;
-  st.ts = timestamp;
-  st.node = node;
-  if (timestamp >= next_save) {
-#ifdef WIN32
-    errno_t err = fopen_s( &fp, get_tmp_state_name().c_str(), "wb");
-    if ( err != 0)
-      return ;
-#else
-    fp = fopen(get_tmp_state_name().c_str(), "wb");
-    if (fp == NULL)
-      return ;
-#endif
-    fwrite(&st, sizeof st, 1, fp);
-    fclose(fp);
-    //schedule next save for 10 seconds from now
-    next_save = timestamp + (10 * 10 * 1000 * 1000);
-  }
-}
-
-// get-current_time -- get time as 60-bit 100ns ticks since UUID epoch.
-// Compensate for the fact that real clock resolution is less than 100ns.
-void get_current_time(xs_unsignedLong *timestamp)
-{
-  static int inited = 0;
-  static xs_unsignedLong time_last;
-  static xs_short uuids_this_tick;
-  xs_unsignedLong time_now;
-
-  if (!inited) {
-    get_system_time(&time_now);
-    uuids_this_tick = UUIDS_PER_TICK;
-    inited = 1;
-  }
-
-  for ( ; ; ) {
-    get_system_time(&time_now);
-
-    //if clock reading changed since last UUID generated
-    if (time_last != time_now) {
-      //reset count of uuids gen'd with this clock reading
-      uuids_this_tick = 0;
-      time_last = time_now;
-      break;
-    }
-    if (uuids_this_tick < UUIDS_PER_TICK) {
-      uuids_this_tick++;
-      break;
-    }
-  //going too fast for our clock; spin
-  }
-  // add the count of uuids to low order bits of the clock reading
-  *timestamp = time_now + uuids_this_tick;
-}
-
-// true_random -- this does not generate a crypto-quality random number.
-static xs_short true_random(void)
-{
-  static int inited = 0;
-  xs_unsignedLong time_now;
-
-  if (!inited) {
-    get_system_time(&time_now);
-    time_now = time_now / UUIDS_PER_TICK;
-    srand((unsigned int)
-          (((time_now >> 32) ^ time_now) & 0xffffffff));
-    inited = 1;
-  }
-
-  return rand();
-}
-
-uuid_t NameSpace_DNS = { // 6ba7b810-9dad-11d1-80b4-00c04fd430c8
-  0x6ba7b810,
-  0x9dad,
-  0x11d1,
-  0x80,
-  0xb4,
-  {
-    0x00, (unsigned char)0xc0,
-    0x4f, (unsigned char)0xd4,
-    0x30, (unsigned char)0xc8
-  }
-};
-
-/* uuidToString -- transform a UUID to a string*/
-zstring uuidToString(const uuid_t& u)
-{
-  char lBuffer[174];
-  sprintf(lBuffer, "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-9300a64ac3cd", u.time_low, u.time_mid,
-          u.time_hi_and_version, u.clock_seq_hi_and_reserved,
-          u.clock_seq_low);
-
-  zstring lResult = lBuffer;
-  return lResult;
-}
-
-/* uuidToString -- transform a UUID to a uri*/
-zstring uuidToURI(const uuid_t& u)
-{
-  char lBuffer[200];
-  sprintf(lBuffer, "urn:uuid:%8.8x-%4.4x-%4.4x-%2.2x%2.2x-9300a64ac3cd", u.time_low, u.time_mid,
-          u.time_hi_and_version, u.clock_seq_hi_and_reserved,
-          u.clock_seq_low);
-
-  zstring lResult = lBuffer;
-  return lResult;
-}
-
-/*
-//This appendix lists the name space IDs for some potentially
-//interesting namespaces, as initialized C structures and in the
-//string representation defined above.
-
-// Name string is a URL
-uuid_t NameSpace_URL = { // 6ba7b811-9dad-11d1-80b4-00c04fd430c8
-  0x6ba7b811,
-  0x9dad,
-  0x11d1,
-  0x80,
-  0xb4,
-  {0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-};
-
-// Name string is an ISO OID
-uuid_t NameSpace_OID = { // 6ba7b812-9dad-11d1-80b4-00c04fd430c8
-  0x6ba7b812,
-  0x9dad,
-  0x11d1,
-  0x80,
-  0xb4,
-  {0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-};
-
-// Name string is an X.500 DN (in DER or a text output format)
-uuid_t NameSpace_X500 = { // 6ba7b814-9dad-11d1-80b4-00c04fd430c8
-  0x6ba7b814,
-  0x9dad,
-  0x11d1,
-  0x80,
-  0xb4,
-  {0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-};
-*/
-}
-/* vim:set et sw=2 ts=2: */

=== removed file 'src/util/uuid/uuid.h'
--- src/util/uuid/uuid.h	2012-07-24 08:48:48 +0000
+++ src/util/uuid/uuid.h	1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright 2006-2008 The FLWOR Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ZORBA_UTIL_UUID_H
-#define ZORBA_UTIL_UUID_H
-
-#undef uuid_t
-
-namespace zorba {
-
-typedef struct {
-  xs_unsignedInt    time_low;
-  xs_unsignedShort  time_mid;
-  xs_unsignedShort  time_hi_and_version;
-  xs_unsignedByte   clock_seq_hi_and_reserved;
-  xs_unsignedByte   clock_seq_low;
-  xs_byte           node[6];
-} uuid_t;
-
-/* uuid_create -- generate a UUID */
-int uuid_create(uuid_t * uuid);
-
-/* uuidToString -- transform a UUID to a string */
-zstring uuidToString(const uuid_t& uuid);
-
-/* uuidToURI -- transform a UUID to a URI-formatted string */
-zstring uuidToURI(const uuid_t& uuid);
-
-} // namespace zorba
-#endif /* ZORBA_UTIL_UUID_H */
-/* vim:set et sw=2 ts=2: */

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to