ReactOS 0.4.15-dev-7906-g1b85a5f
genguid.c
Go to the documentation of this file.
1/*
2 * genguid utility for WINE and ReactOS
3 *
4 * Copyright 2003 Jonathan Wilson
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21#include <objbase.h>
22#include <stdio.h>
23
24int main(int argc, char *argv[])
25{
26 GUID m_guid = GUID_NULL;
27 int arg;
29 char *strfmt = "";
30 if (argc < 2) {
31 printf("usage: %s n\n",argv[0]);
32 printf("n = format of output\n");
33 printf("values are:\n");
34 printf("1 = IMPLEMENT_OLECREATE defintion\n");
35 printf("2 = DEFINE_GUID definition\n");
36 printf("3 = static const GUID definition\n");
37 printf("4 = registry format\n");
38 printf("5 = uuidgen.exe format\n");
39 return 1;
40 }
41 arg = atoi(argv[1]);
42 if ((arg > 5) || (arg <= 0)) {
43 printf("invalid argument\n");
44 return 1;
45 }
46 if (CoInitialize(NULL) != S_OK)
47 {
48 printf("Unable to initialize OLE libraries\n");
49 return 1;
50 }
51 result = CoCreateGuid(&m_guid);
52 if (result != S_OK) {
53 printf("Unable to create GUID\n");
55 return 1;
56 }
57 switch (arg) {
58 case 1:
59 strfmt = "// {%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\nIMPLEMENT_OLECREATE(<<class>>, <<external_name>>, \r\n0x%lx, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x);\r\n";
60 break;
61 case 2:
62 strfmt = "// {%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\nDEFINE_GUID(<<name>>, \r\n0x%lx, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x);\r\n";
63 break;
64 case 3:
65 strfmt = "// {%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\nstatic const GUID <<name>> = \r\n{ 0x%lx, 0x%x, 0x%x, { 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x } };\r\n";
66 break;
67 case 4:
68 strfmt = "{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\n";
69 break;
70 case 5:
71 strfmt = "%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X\r\n";
72 break;
73 }
74 printf(strfmt,m_guid.Data1,m_guid.Data2,m_guid.Data3,m_guid.Data4[0],
75 m_guid.Data4[1],m_guid.Data4[2],m_guid.Data4[3],m_guid.Data4[4],m_guid.Data4[5],
76 m_guid.Data4[6],m_guid.Data4[7],m_guid.Data1,m_guid.Data2,m_guid.Data3,m_guid.Data4[0],
77 m_guid.Data4[1],m_guid.Data4[2],m_guid.Data4[3],m_guid.Data4[4],m_guid.Data4[5],
78 m_guid.Data4[6],m_guid.Data4[7]);
80 return 0;
81}
82
83
static int argc
Definition: ServiceArgs.c:12
#define NULL
Definition: types.h:112
HRESULT WINAPI CoCreateGuid(GUID *pguid)
Definition: compobj.c:2206
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
int main()
Definition: test.c:6
#define printf
Definition: freeldr.h:93
GLuint64EXT * result
Definition: glext.h:11304
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define S_OK
Definition: intsafe.h:52
#define GUID_NULL
Definition: ks.h:106
static void strfmt(const char *str, char *strout)
Definition: text.c:617
#define argv
Definition: mplay32.c:18
void * arg
Definition: msvc.h:10