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

Go to the source code of this file.

Functions

void _uuidFormat3or5 (Uuid uuid, unsigned char hash[16], int version)
 
Uuid uuidVersion5 (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 version5.c.

Function Documentation

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

Definition at line 36 of file _format3or5.c.

Referenced by uuidVersion5().

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 uuidVersion5 ( const unsigned char *  name,
size_t  nname,
Uuid  nsid 
)

Definition at line 39 of file version5.c.

References _uuidFormat3or5(), and clone.

Referenced by main().

40 {
41  SHA_CTX ctx;
42  unsigned char hash[20];
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  SHA1_Init(&ctx);
60  SHA1_Update(&ctx, (net_nsid->uuid).value, 16);
61  SHA1_Update(&ctx, name, nname);
62  SHA1_Final(hash, &ctx);
63 
64  delete(net_nsid);
65 
66  _uuidFormat3or5(uuid, hash, 5);
67 
68  return uuid;
69 }
#define clone(object)
void _uuidFormat3or5(Uuid uuid, unsigned char hash[16], int version)
Definition: _format3or5.c:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function: