--- as_uuid.cpp 2003/01/17 17:22:58 1.4
+++ as_uuid.cpp 2003/01/21 14:41:15 1.5
@@ -1,3 +1,34 @@
+//
+// OSSP asgui - Accounting system graphical user interface
+// Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/)
+// Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/)
+// Copyright (c) 2002-2003 Ralf S. Engelschall <rse@engelschall.com>
+// Copyright (c) 2002-2003 Michael Schloh von Bennewitz <michael@schloh.com>
+//
+// This file is part of OSSP asgui, an accounting system graphical user
+// interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
+//
+// Permission to use, copy, modify, and distribute this software for
+// any purpose with or without fee is hereby granted, provided that
+// the above copyright notice and this permission notice appear in all
+// copies.
+//
+// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+// IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+//
+// as_uuidgen.cpp: ISO C++ implementation
+//
+
/*
* as_uuidgen.c --- generate a DCE-compatible uuid
*
@@ -15,12 +46,7 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
-#include "as_uuidgen.h"
-
-/* Include whatever autoconf found */
-#ifdef HAVE_CONFIG_H
-#include "ac_config.h"
-#endif
+#include "as_uuid.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -53,7 +79,7 @@
#endif /* HAVE_NET_IF_H */
-static int get_random_fd(void)
+static int Uuid::get_random_fd(void)
{
struct timeval tv;
static int fd = -2;
@@ -73,12 +99,11 @@
return fd;
}
-
/*
* Generate a series of random bytes. Use /dev/urandom if possible,
* and if not, use srandom/random.
*/
-static void get_random_bytes(void *buf, int nbytes)
+static void Uuid::get_random_bytes(void *buf, int nbytes)
{
int i, fd = get_random_fd();
int lose_counter = 0;
@@ -110,7 +135,7 @@
/*
* Get the ethernet hardware address, if we can find it...
*/
-static int get_node_id(unsigned char *node_id)
+static int Uuid::get_node_id(unsigned char *node_id)
{
#if 0 // FIXME: Fix this broken code some other day
#ifdef HAVE_NET_IF_H
@@ -171,7 +196,7 @@
/* Assume that the gettimeofday() has microsecond granularity */
#define MAX_ADJUSTMENT 10
-static int get_clock(__u32 *clock_high, __u32 *clock_low, __u16 *ret_clock_seq)
+static int Uuid::get_clock(__u32 *clock_high, __u32 *clock_low, __u16 *ret_clock_seq)
{
static int adjustment = 0;
static struct timeval last = {0, 0};
@@ -213,7 +238,7 @@
return 0;
}
-void uuid_generate_time(uuid_t out)
+void Uuid::uuid_generate_time(uuid_t out)
{
static unsigned char node_id[6];
static int has_init = 0;
@@ -240,7 +265,7 @@
uuid_pack(&uu, out);
}
-void uuid_generate_random(uuid_t out)
+void Uuid::uuid_generate_random(uuid_t out)
{
uuid_t buf;
struct uuid uu;
@@ -259,7 +284,7 @@
* /dev/urandom is available, since otherwise we won't have
* high-quality randomness.
*/
-void uuid_generate(uuid_t out)
+void Uuid::uuid_generate(uuid_t out)
{
if (get_random_fd() >= 0)
uuid_generate_random(out);
@@ -267,7 +292,7 @@
uuid_generate_time(out);
}
-void uuid_pack(const struct uuid *uu, uuid_t ptr)
+void Uuid::uuid_pack(const struct uuid *uu, uuid_t ptr)
{
__u32 tmp;
unsigned char *out = ptr;
@@ -299,7 +324,7 @@
memcpy(out+10, uu->node, 6);
}
-void uuid_unpack(const uuid_t in, struct uuid *uu)
+void Uuid::uuid_unpack(const uuid_t in, struct uuid *uu)
{
const __u8 *ptr = in;
__u32 tmp;
@@ -325,7 +350,7 @@
memcpy(uu->node, ptr, 6);
}
-void uuid_unparse(const uuid_t uu, char *out)
+void Uuid::uuid_unparse(const uuid_t uu, char *out)
{
struct uuid uuid;
|