reshuffling of dlls
[reactos.git] / reactos / dll / directx / dsound / dxroslayer / getguidfromstring.c
1 /*
2 * ReactOS emulation layer betwin wine and windows api for directx
3 * convort string to GUID
4 *
5 * Copyright 2004 Magnus Olsen
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 *
22 * TODO:
23 * soucre clean
24 * Rewrite so it use unicode instead for asc or find how windows convert it
25 */
26
27 #include "config.h"
28 #include "wine/port.h"
29
30 #include <assert.h>
31 #include <stdarg.h>
32 #include <stdio.h>
33 #include <sys/types.h>
34 #include <sys/fcntl.h>
35 #ifdef HAVE_UNISTD_H
36 # include <unistd.h>
37 #endif
38 #include <stdlib.h>
39 #include <string.h>
40 #include <math.h>
41
42 #define NONAMELESSSTRUCT
43 #define NONAMELESSUNION
44 #include "windef.h"
45 #include "winbase.h"
46 #include "winreg.h"
47 #include "winuser.h"
48 #include "wingdi.h"
49 #include "winuser.h"
50 #include "winerror.h"
51 #include "mmsystem.h"
52 #include "winternl.h"
53 #include "mmddk.h"
54 #include "wine/windef16.h"
55 #include "wine/winbase16.h"
56 #include "wine/debug.h"
57 #include "dsound.h"
58 #include "dsdriver.h"
59 #include "dxros_layer.h"
60 #include "dsconf.h"
61 #include "windows.h"
62
63 WINE_DEFAULT_DEBUG_CHANNEL(dsound);
64
65
66
67 void dxGetGuidFromString( char *in_str, GUID *guid )
68 {
69 unsigned long c=0;
70 int i;
71
72 // this string hex converter need to be rewrite or find uhow windows convort a string
73 // to GUID
74
75 for (i=1;i<9;i++)
76 {
77 if (in_str[i]>='0' && in_str[i]<='9')
78 {
79 c=c * 16 + (in_str[i] - 48);
80 }
81 else if (in_str[i]>='A' && in_str[i]<='F')
82 {
83 c=c * 16 + (in_str[i] - 55);
84 }
85 }
86 guid->Data1 = c;
87 c=0;
88
89 for (i=9;i<14;i++)
90 {
91 if (in_str[i]>='0' && in_str[i]<='9')
92 {
93 c=c * 16 + (in_str[i] - 48);
94 }
95 else if (in_str[i]>='A' && in_str[i]<='F')
96 {
97 c=c * 16 + (in_str[i] - 55);
98 }
99 }
100
101 guid->Data2 = (short) c;
102 c=0;
103
104 for (i=14;i<19;i++)
105 {
106 if (in_str[i]>='0' && in_str[i]<='9') c=c * 16 + (in_str[i] - 48);
107 else if (in_str[i]>='A' && in_str[i]<='F') c=c * 16 + (in_str[i] - 55);
108 }
109 guid->Data3 = (short) c;
110 c=0;
111
112 for (i=20;i<22;i++)
113 {
114 if (in_str[i]>='0' && in_str[i]<='9') c=c * 16 + (in_str[i] - 48);
115 else if (in_str[i]>='A' && in_str[i]<='F') c=c * 16 + (in_str[i] - 55);
116 }
117 guid->Data4[0] = (BYTE) c;
118 c=0;
119
120 for (i=22;i<24;i++)
121 {
122 if (in_str[i]>='0' && in_str[i]<='9') c=c * 16 + (in_str[i] - 48);
123 else if (in_str[i]>='A' && in_str[i]<='F') c=c * 16 + (in_str[i] - 55);
124 }
125 guid->Data4[1] = (BYTE) c;
126 c=0;
127
128
129 for (i=25;i<27;i++)
130 {
131 if (in_str[i]>='0' && in_str[i]<='9') c=c * 16 + (in_str[i] - 48);
132 else if (in_str[i]>='A' && in_str[i]<='F') c=c * 16 + (in_str[i] - 55);
133 }
134 guid->Data4[2] = (BYTE) c;
135 c=0;
136
137 for (i=27;i<29;i++)
138 {
139 if (in_str[i]>='0' && in_str[i]<='9') c=c * 16 + (in_str[i] - 48);
140 else if (in_str[i]>='A' && in_str[i]<='F') c=c * 16 + (in_str[i] - 55);
141 }
142 guid->Data4[3] = (BYTE) c;
143 c=0;
144
145 for (i=29;i<31;i++)
146 {
147 if (in_str[i]>='0' && in_str[i]<='9') c=c * 16 + (in_str[i] - 48);
148 else if (in_str[i]>='A' && in_str[i]<='F') c=c * 16 + (in_str[i] - 55);
149 }
150 guid->Data4[4] = (BYTE) c;
151 c=0;
152
153 for (i=31;i<33;i++)
154 {
155 if (in_str[i]>='0' && in_str[i]<='9') c=c * 16 + (in_str[i] - 48);
156 else if (in_str[i]>='A' && in_str[i]<='F') c=c * 16 + (in_str[i] - 55);
157 }
158 guid->Data4[5] = (BYTE) c;
159 c=0;
160
161 for (i=33;i<35;i++)
162 {
163 if (in_str[i]>='0' && in_str[i]<='9') c=c * 16 + (in_str[i] - 48);
164 else if (in_str[i]>='A' && in_str[i]<='F') c=c * 16 + (in_str[i] - 55);
165 }
166 guid->Data4[6] = (BYTE) c;
167 c=0;
168
169 for (i=35;i<37;i++)
170 {
171 if (in_str[i]>='0' && in_str[i]<='9') c=c * 16 + (in_str[i] - 48);
172 else if (in_str[i]>='A' && in_str[i]<='F') c=c * 16 + (in_str[i] - 55);
173 }
174 guid->Data4[7] = (BYTE) c;
175 c=0;
176 }