new utillity for wine, genguid

Jonathan Wilson jonwil at tpgi.com.au
Tue Jul 22 07:27:55 CDT 2003


Basicly, its a console app that will generate GUIDs using CoCreateGUID. 
All output is to STDOUT. Will return 1 if there is an error, 0 if there 
is sucess.
Ouput is in one of 5 formats:
1.IMPLEMENT_OLECREATE macro definition
2.DEFINE_GUID macro definition
3.static const GUID definition
4.registry format {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
5.uuidgen.exe output format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

The makefile and stuff were just copied from /programs/expand.

Ideas (but not code) were taken from Microsoft guidgen.exe and 
uuidgen.exe programs (the source code to guidgen in particular was 
helpfull in explaining the right calls to make to ole32.dll)

configure.pat contains changes to configure.ac
programs.pat is the changes in /programs
genguid.c is the genguid program (goes in /programs/genguid).
Makefile.in is the makefile for genguid
.cvsignore is also for genguid

Feedback is appreciated (i.e. did I submit the patches correctly, is the 
code good, did I do the right thing with the licence headers, did I 
modify the configure script correctly etc etc), this is my first time 
submitting anything to WINE.
-------------- next part --------------
/*
 *  genguid utility for WINE
 *
 *  Copyright 2003 Jonathan Wilson
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include <objbase.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
	GUID m_guid;
	m_guid = GUID_NULL;
	int arg;
	HRESULT result;
	char *strfmt = "";
	if (argc < 2) {
		printf("usage: %s n\n",argv[0]);
		printf("n = format of output\n");
		printf("values are:\n");
		printf("1 = IMPLEMENT_OLECREATE defintion\n");
		printf("2 = DEFINE_GUID definition\n");
		printf("3 = static const GUID definition\n");
		printf("4 = registry format\n");
		printf("5 = uuidgen.exe format\n");
		return 1;
	}
	arg = atoi(argv[1]);
	if ((arg > 5) || (arg <= 0)) {
		printf("invalid argument\n");
		return 1;
	}
	if (CoInitialize(NULL) != S_OK)
	{
		printf("Unable to initalize OLE libraries\n");
		return 1;
	}
	result = CoCreateGuid(&m_guid);
	if (result != S_OK) {
		printf("Unable to create GUID\n");
		CoUninitialize();
		return 1;
	}
	switch (arg) {
	case 1:
	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";
	break;
	case 2:
	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";
	break;
	case 3:
	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";
	break;
	case 4:
	strfmt = "{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\n";
	break;
	case 5:
	strfmt = "%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X\r\n";
	break;
	}
	printf(strfmt,m_guid.Data1,m_guid.Data2,m_guid.Data3,m_guid.Data4[0],
	m_guid.Data4[1],m_guid.Data4[2],m_guid.Data4[3],m_guid.Data4[4],m_guid.Data4[5],
	m_guid.Data4[6],m_guid.Data4[7],m_guid.Data1,m_guid.Data2,m_guid.Data3,m_guid.Data4[0],
	m_guid.Data4[1],m_guid.Data4[2],m_guid.Data4[3],m_guid.Data4[4],m_guid.Data4[5],
	m_guid.Data4[6],m_guid.Data4[7]);
	CoUninitialize();
	return 0;
}
-------------- next part --------------
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR    = @srcdir@
VPATH     = @srcdir@
MODULE    = genguid.exe
APPMODE   = cui
IMPORTS   = ole32
EXTRALIBS = $(LIBUUID)

C_SRCS = genguid.c

@MAKE_PROG_RULES@

### Dependencies:
-------------- next part --------------
Makefile
genguid.exe.dbg.c
genguid.exe.spec.c
-------------- next part --------------
Index: Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/Makefile.in,v
retrieving revision 1.39
diff -u -r1.39 Makefile.in
--- Makefile.in	23 Jun 2003 19:51:21 -0000	1.39
+++ Makefile.in	22 Jul 2003 12:14:00 -0000
@@ -10,6 +10,7 @@
 	cmdlgtst \
 	control \
 	expand \
+	genguid \
 	notepad \
 	osversioncheck \
 	progman \
@@ -41,6 +42,7 @@
 	clock \
 	control \
 	expand \
+	genguid \
 	notepad \
 	progman \
 	regedit \
-------------- next part --------------
Index: configure.ac
===================================================================
RCS file: /home/wine/wine/configure.ac,v
retrieving revision 1.167
diff -u -r1.167 configure.ac
--- configure.ac	21 Jul 2003 22:01:07 -0000	1.167
+++ configure.ac	22 Jul 2003 12:13:56 -0000
@@ -1530,6 +1530,7 @@
 programs/cmdlgtst/Makefile
 programs/control/Makefile
 programs/expand/Makefile
+programs/genguid/Makefile
 programs/notepad/Makefile
 programs/osversioncheck/Makefile
 programs/progman/Makefile


More information about the wine-patches mailing list