Thu, 06 Aug 2009 13:21:30 +0200
Remove seemingly declarations unnecessary according to Qt 4.5.2 headers.
1 //
2 // OSSP asgui - Accounting system graphical user interface
3 // Copyright (c) 2002-2009 The OSSP Project (http://www.ossp.org/)
4 // Copyright (c) 2002-2009 Ralf S. Engelschall <rse@engelschall.com>
5 // Copyright (c) 2002-2009 Michael Schloh von Bennewitz <michael@schloh.com>
6 // Copyright (c) 2002-2009 Cable & Wireless Telecommunications Services GmbH
7 //
8 // This file is part of OSSP asgui, an accounting system graphical user
9 // interface which can be found at http://asgui.europalab.com/.
10 //
11 // Permission to use, copy, modify, and distribute this software for
12 // any purpose with or without fee is hereby granted, provided that
13 // the above copyright notice and this permission notice appear in all
14 // copies.
15 //
16 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
17 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 // IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
20 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 // SUCH DAMAGE.
28 //
29 // as_uuid.cpp: ISO C++ implementation
30 //
32 // System headers
33 #include <string>
34 #include <sys/socket.h>
36 // Local headers
37 #include "as_uuid.h"
38 #include "as_rand.h"
40 // All of these are for detecting
41 // the MAC address in setMac()
42 #ifdef HAVE_UNISTD_H
43 #include <unistd.h>
44 #endif // HAVE_UNISTD_H
45 #ifdef HAVE_SYS_SOCKIO_H
46 #include <sys/sockio.h>
47 #endif // HAVE_SYS_SOCKIO_H
48 #ifdef HAVE_NET_IF_H
49 #include <net/if.h>
50 #endif // HAVE_NET_IF_H
51 #ifdef HAVE_NETINET_IN_H
52 #include <netinet/in.h>
53 #endif // HAVE_NETINET_IN_H
56 namespace AS {
58 //
59 // Generate a DCE standard UUID
60 //
61 void Uuid::genId(void)
62 {
63 Rand Temprand; // For random numbers
64 unsigned char szChardata[16]; // Intermediate data
66 // Generate random data and fill in our UUID member fields with it
67 Temprand.genData(szChardata, sizeof(szChardata));
68 setId(szChardata);
70 // Since we don't just want random data, lets take some clock sequences also
71 this->clock_seq = (this->clock_seq & 0x3FFF) | 0x8000;
72 this->time_hi_and_version = (this->time_hi_and_version & 0x0FFF) | 0x4000;
74 // In every case that we can, set the node ID to the real MAC address
75 setMac(this->node);
77 setString(); // Set the human readable string
78 }
80 //
81 // Helper method to set the UUID private member data
82 //
83 void Uuid::setId(const unsigned char *pkucData)
84 {
85 const U8 *pOctet = pkucData;
86 U32 Tmpdat;
88 Tmpdat = *pOctet++; // Tmpdat is our iterator
90 // Copy data chunks one octet at a time
91 Tmpdat = (Tmpdat << 8) | *pOctet++;
92 Tmpdat = (Tmpdat << 8) | *pOctet++;
93 Tmpdat = (Tmpdat << 8) | *pOctet++;
94 this->time_low = Tmpdat;
96 Tmpdat = *pOctet++;
97 Tmpdat = (Tmpdat << 8) | *pOctet++;
98 this->time_mid = Tmpdat;
100 Tmpdat = *pOctet++;
101 Tmpdat = (Tmpdat << 8) | *pOctet++;
102 this->time_hi_and_version = Tmpdat;
104 Tmpdat = *pOctet++;
105 Tmpdat = (Tmpdat << 8) | *pOctet++;
106 this->clock_seq = Tmpdat;
108 // Put in the MAC address
109 memcpy(this->node, pOctet, 6);
110 }
112 //
113 // Helper method to set up the MAC address node ID member data
114 //
115 int Uuid::setMac(unsigned char *pucNode)
116 {
117 return 0;
118 }
120 //
121 // Returns a formatted representation of a DCE standard UUID
122 //
123 std::string Uuid::getString(void)
124 {
125 return m_Fmtstr;
126 }
128 //
129 // Helper method to set the private formatted
130 // representation of a DCE standard UUID
131 //
132 void Uuid::setString(void)
133 {
134 char szTemp[48]; // To perform intermediate manipulation
136 sprintf(szTemp, // The DCE standard UUID format
137 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
138 this->time_low, this->time_mid, this->time_hi_and_version,
139 this->clock_seq >> 8, this->clock_seq & 0xFF,
140 node[0], node[1], node[2],
141 node[3], node[4], node[5]);
143 m_Fmtstr = szTemp; // Finally copy the temporary to our object
144 }
145 } // namespace AS