taskrambler  0.1.9
Web server and task management solution.
version3.c File Reference
#include <sys/types.h>
#include <openssl/md5.h>
#include <arpa/inet.h>
#include "class.h"
#include "uuid.h"
+ Include dependency graph for version3.c:

Go to the source code of this file.

Functions

void _uuidFormat3or5 (Uuid uuid, unsigned char hash[16], int version)
 
Uuid uuidVersion3 (const unsigned char *name, size_t nname, Uuid nsid)
 

Detailed Description

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file version3.c.

Function Documentation

void _uuidFormat3or5 ( Uuid  uuid,
unsigned char  hash[16],
int  version 
)

Definition at line 36 of file _format3or5.c.

Referenced by uuidVersion3().

37 {
38  /* convert UUID to local byte order */
39  memcpy((uuid->uuid).value, hash, 16);
40 
41  (uuid->uuid).elements.time_low =
42  ntohl((uuid->uuid).elements.time_low);
43  (uuid->uuid).elements.time_mid =
44  ntohs((uuid->uuid).elements.time_mid);
45  (uuid->uuid).elements.time_hi_version =
46  ntohs((uuid->uuid).elements.time_hi_version);
47 
48  /* put in the variant and version bits */
49  (uuid->uuid).elements.time_hi_version &= 0x0FFF;
50  (uuid->uuid).elements.time_hi_version |= (version << 12);
51  (uuid->uuid).elements.clk_seq_hi_res &= 0x3F;
52  (uuid->uuid).elements.clk_seq_hi_res |= 0x80;
53 }

+ Here is the caller graph for this function:

Uuid uuidVersion3 ( const unsigned char *  name,
size_t  nname,
Uuid  nsid 
)

Definition at line 39 of file version3.c.

References _uuidFormat3or5(), and clone.

Referenced by main(), and userIndexUuid().

40 {
41  MD5_CTX ctx;
42  unsigned char hash[16];
43  Uuid net_nsid = clone(nsid);
44  Uuid uuid = new(Uuid);
45 
46  /*
47  * put the namespace id into network byte order.
48  */
49  (net_nsid->uuid).elements.time_low =
50  htonl((net_nsid->uuid).elements.time_low);
51  (net_nsid->uuid).elements.time_mid =
52  htons((net_nsid->uuid).elements.time_mid);
53  (net_nsid->uuid).elements.time_hi_version =
54  htons((net_nsid->uuid).elements.time_hi_version);
55 
56  /*
57  * generate the MD5
58  */
59  MD5_Init(&ctx);
60  MD5_Update(&ctx, (net_nsid->uuid).value, 16);
61  MD5_Update(&ctx, name, nname);
62  MD5_Final(hash, &ctx);
63 
64  delete(net_nsid);
65 
66  _uuidFormat3or5(uuid, hash, 3);
67 
68  return uuid;
69 }
void _uuidFormat3or5(Uuid uuid, unsigned char hash[16], int version)
Definition: _format3or5.c:36
#define clone(object)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: