taskrambler  0.1.9
Web server and task management solution.
uuid.h File Reference
#include <stdint.h>
#include <sys/types.h>
#include <uuid/uuid.h>
#include "class.h"
#include "commons.h"
+ Include dependency graph for uuid.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef char UuidString[37]
 

Functions

 CLASS (Uuid)
 
Uuid uuidVersion1 ()
 
Uuid uuidVersion3 (const unsigned char *, size_t, Uuid)
 
Uuid uuidVersion5 (const unsigned char *, size_t, Uuid)
 
void uuidUnparse (Uuid, UuidString)
 
Uuid uuidParse (const UuidString)
 
int uuidCompare (Uuid, Uuid)
 

Variables

Uuid uuidZero
 

Detailed Description

ways to create uuid variant 5. For uuid of variant 1 I use the implementation delivered with the core utils. But this is wrapped in here, so that the rest of the code can use only this implementation...this additionally has the advantage that we can implement version 1 here too for systems where the coreutils implementation is not available.

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 uuid.h.

Typedef Documentation

typedef char UuidString[37]

Definition at line 40 of file uuid.h.

Function Documentation

CLASS ( Uuid  )

Definition at line 42 of file uuid.h.

42  {
43  union {
44  uuid_t value;
45  struct {
46  uint32_t time_low;
47  uint16_t time_mid;
48  uint16_t time_hi_version;
49  uint8_t clk_seq_hi_res;
50  uint8_t clk_seq_low;
51  unsigned char node[6];
52  } elements;
53  } uuid;
54 };
int uuidCompare ( Uuid  ,
Uuid   
)

Definition at line 30 of file compare.c.

Referenced by controllerSignupCreate(), controllerUserCreate(), controllerUserUpdate(), and main().

31 {
32  return uuid_compare((uuid1->uuid).value, (uuid2->uuid).value);
33 }

+ Here is the caller graph for this function:

Uuid uuidParse ( const UuidString  )

Definition at line 30 of file uuid/parse.c.

Referenced by applicationCtor(), controllerUserRead(), and main().

31 {
32  Uuid uuid = new(Uuid);
33  uuid_parse(uuid_str, (uuid->uuid).value);
34 
35  return uuid;
36 }

+ Here is the caller graph for this function:

void uuidUnparse ( Uuid  ,
UuidString   
)

Definition at line 30 of file unparse.c.

Referenced by main().

31 {
32  uuid_unparse((uuid->uuid).value, uuid_str);
33 }

+ Here is the caller graph for this function:

Uuid uuidVersion1 ( )

Definition at line 30 of file version1.c.

Referenced by main().

31 {
32  Uuid uuid = new(Uuid);
33  uuid_generate((uuid->uuid).value);
34 
35  return uuid;
36 }

+ Here is the caller graph for this function:

Uuid uuidVersion3 ( const unsigned char *  ,
size_t  ,
Uuid   
)

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:

Uuid uuidVersion5 ( const unsigned char *  ,
size_t  ,
Uuid   
)

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:

Variable Documentation