OSSP CVS Repository

ossp - Check-in [3925]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3925
Date: 2003-Jan-21 15:41:15 (local)
2003-Jan-21 14:41:15 (UTC)
User:ms
Branch:
Comment: First cut at a UUID class.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/as_uuid.cpp      1.4 -> 1.5     42 inserted, 17 deleted
ossp-pkg/as/as-gui/as_uuid.h      added-> 1.1
ossp-pkg/as/as-gui/configure.in      1.16 -> 1.17     9 inserted, 0 deleted

ossp-pkg/as/as-gui/as_uuid.cpp 1.4 -> 1.5

--- 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;
 


ossp-pkg/as/as-gui/as_uuid.h -> 1.1

*** /dev/null    Sat Nov 23 05:53:03 2024
--- -    Sat Nov 23 05:53:15 2024
***************
*** 0 ****
--- 1,125 ----
+ //
+ //  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.h: ISO C++ interface
+ //
+ 
+ #ifndef UUIDGEN_H
+ #define UUIDGEN_H
+ 
+ #include "as_gui.h"
+ 
+ #ifdef HAVE_CONFIG_H
+ #include "ac_config.h"
+ #endif
+ 
+ #ifdef HAVE_CONFIG_H
+ #if (SIZEOF_CHAR == 1)
+ typedef unsigned char        __u8;
+ #else
+ ?==Error: Undefined 8 bit type
+ #endif // __u8
+ #if (SIZEOF_SHORT == 2)
+ typedef unsigned short       __u16;
+ #elif (SIZEOF_INT == 2)
+ typedef unsigned int         __u16;
+ #elif (SIZEOF_LONG == 2)
+ typedef unsigned long        __u16;
+ #else
+ ?==Error: Undefined 16 bit type
+ #endif // __u16
+ #if (SIZEOF_SHORT == 4)
+ typedef unsigned short       __u32;
+ #elif (SIZEOF_INT == 4)
+ typedef unsigned int         __u32;
+ #elif (SIZEOF_LONG == 4)
+ typedef unsigned long        __u32;
+ #else
+ ?==Error: Undefined 32 bit type
+ #endif // __u32
+ #if (SIZEOF_SHORT == 8)
+ typedef unsigned short       __u64;
+ #elif (SIZEOF_INT == 8)
+ typedef unsigned int         __u64;
+ #elif (SIZEOF_LONG == 8)
+ typedef unsigned long        __u64;
+ #elif (SIZEOF_LONG_LONG == 8)
+ typedef unsigned long long   __u64;
+ #else
+ ?==Error: Undefined 64 bit type
+ #endif // __u64
+ #endif // SIZEOF_INT
+ #else // HAVE_CONFIG_H
+ typedef unsigned char        __u8;
+ #if (4 == 8)
+ typedef unsigned int         __u64;
+ #elif (4 == 8)
+ typedef unsigned long        __u64;
+ #elif (8 == 8)
+ typedef unsigned long long   __u64;
+ #else
+ ?==Error: Undefined 64 bit type
+ #endif
+ 
+ #if (4 == 2)
+ typedef        unsigned int         __u16;
+ #elif (2 == 2)
+ typedef        unsigned short       __u16;
+ #else
+ ?==Error: Undefined 16 bit type
+ #endif
+ 
+ #if (4 == 4)
+ typedef        unsigned int         __u32;
+ #elif (4 == 4)
+ typedef        unsigned long        __u32;
+ #elif (2 == 4)
+ typedef        unsigned short       __u32;
+ #else
+ ?== Error: Undefined 32 bit type
+ #endif
+ #endif // HAVE_CONFIG_H
+ 
+ 
+ class Uuid
+ {
+ public:
+     static int get_random_fd(void);
+     static void get_random_bytes(void *, int);
+     static int get_node_id(unsigned char *);
+     static int get_clock(__u32 *, __u32 *, __u16 *);
+     void uuid_generate_time(uuid_t);
+     void uuid_generate_random(uuid_t);
+     void uuid_generate(uuid_t);
+     void uuid_pack(const struct uuid *, uuid_t);
+     void uuid_unpack(const uuid_t, struct uuid *);
+     void uuid_unparse(const uuid_t, char *);
+ private:
+ };
+ 
+ #endif // UUIDGEN_H


ossp-pkg/as/as-gui/configure.in 1.16 -> 1.17

--- configure.in 2003/01/17 17:22:58     1.16
+++ configure.in 2003/01/21 14:41:15     1.17
@@ -99,6 +99,15 @@
     LIBS="$LIBS -lX11 -lXext -lSM -lm"
 fi
 
+dnl Check data type sizes of particular architecture
+dnl Hack: We're really interested in the unsigned types,
+dnl       but they're the same size according to ISO C++
+AC_CHECK_SIZEOF(char)
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+
 dnl Check some X resources, typical of XFree86
 AC_CHECK_LIB(Xft, XftFreeTypeOpen, [LIBS="$LIBS -lXft"])
 AC_CHECK_LIB(Xrender, XRenderFindFormat, [LIBS="$LIBS -lXrender"])

CVSTrac 2.0.1