-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility.h
61 lines (53 loc) · 1.42 KB
/
utility.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* utility.h
* SolutionBuilder
*
* Created by Kyle Weicht on 2/1/2012.
* Copyright (c) 2012 Kyle Weicht. All rights reserved.
*/
#ifndef __SolutionBuilder_utility_h__
#define __SolutionBuilder_utility_h__
/* C headers */
/* C++ headers */
/* External headers */
/* Internal headers */
/*******************************************************************\
External Constants And types
\*******************************************************************/
/*******************************************************************\
External variables
\*******************************************************************/
/*******************************************************************\
External functions
\*******************************************************************/
void GenerateGUID(char guid[39])
{
guid[0] = '{';
guid[37] = '}';
guid[38] = '\0';
char* writePos = guid+1;
int writeIndex = 1;
while(*writePos != '}')
{
if (writeIndex == 9 || writeIndex == 14 || writeIndex == 19 || writeIndex == 24)
{
*writePos = '-';
}
else
{
char digit = rand()%16;
if(digit < 10)
{
digit += '0';
}
else
{
digit = (digit-10)+'A';
}
*writePos = digit;
}
++writeIndex;
++writePos;
}
}
#endif /* include guard */