From 8c4d2ca60968377bbfa587ec0dd7bfd17e5baae8 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 30 Jul 2001 17:46:07 +0000 Subject: [PATCH] Encryption basically works. Removed system specific files becuase they are now part of Mingw32/CPD --- complus/ChangeLog | 15 + complus/Makefile.am | 29 +- complus/WINE-AUTHORS | 331 ---------------- complus/WINE-LICENSE | 26 -- complus/basetsd.h | 160 -------- complus/debug.c | 40 ++ complus/gpgcom.c | 543 ++++++++++++++++++++++++++ complus/gpgcom.idl | 62 +++ complus/gpgcom.rc | 22 ++ complus/gpgcom.tlb | Bin 0 -> 18596 bytes complus/guiddef.h | 95 ----- complus/ignupg.c | 202 ---------- complus/ignupg.h | 68 ---- complus/igpgme.c | 903 +++++++++++++++++++++++++++++++++++++++++++ complus/igpgme.h | 162 ++++++++ complus/main.c | 285 -------------- complus/main.h | 5 - complus/obj_base.h | 800 -------------------------------------- complus/wtypes.h | 272 ------------- 19 files changed, 1768 insertions(+), 2252 deletions(-) create mode 100644 complus/ChangeLog delete mode 100644 complus/WINE-AUTHORS delete mode 100644 complus/WINE-LICENSE delete mode 100644 complus/basetsd.h create mode 100644 complus/debug.c create mode 100644 complus/gpgcom.c create mode 100644 complus/gpgcom.idl create mode 100644 complus/gpgcom.rc create mode 100644 complus/gpgcom.tlb delete mode 100644 complus/guiddef.h delete mode 100644 complus/ignupg.c delete mode 100644 complus/ignupg.h create mode 100644 complus/igpgme.c create mode 100644 complus/igpgme.h delete mode 100644 complus/main.c delete mode 100644 complus/obj_base.h delete mode 100644 complus/wtypes.h diff --git a/complus/ChangeLog b/complus/ChangeLog new file mode 100644 index 0000000..fe34a66 --- /dev/null +++ b/complus/ChangeLog @@ -0,0 +1,15 @@ +2001-07-30 Werner Koch + + Encryption basically works. + + + Copyright 2001 g10 Code GmbH + + This file is free software; as a special exception the author gives + unlimited permission to copy and/or distribute it, with or without + modifications, as long as this notice is preserved. + + This file is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, to the extent permitted by law; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + \ No newline at end of file diff --git a/complus/Makefile.am b/complus/Makefile.am index ae05e45..9da5b4b 100644 --- a/complus/Makefile.am +++ b/complus/Makefile.am @@ -19,18 +19,31 @@ ## Process this file with automake to produce Makefile.in -EXTRA_DIST = WINE-LICENSE WINE-AUTHORS +# Because there is no free IDL compiler for OLE, we have to distribute +# a binary typelibrary. To generate a new one, copy the idl file to a +# system with an install MIDL and run the command +# midl /nocpp gpgcom.idl +# Sorry, there is no other way yet. +EXTRA_DIST = gpgcom.idl gpgcom.tlb gpgcom.rc -# No need to install this becuase we are cross-compiling anyway. -noinst_PROGRAMS = gpgcom +# No need to install this because we are cross-compiling anyway. +noinst_PROGRAMS = gpgcom tgpgcom INCLUDES = -I$(top_srcdir)/jnlib -LDADD = -L ../jnlib -ljnlib +LDADD = ../gpgme/libgpgme.la -L ../jnlib -ljnlib -lole32 -loleaut32 +gpgcom_LDADD = gpgcom_res.o $(LDADD) -comheaders = obj_base.h basetsd.h guiddef.h wtypes.h +gpgcom_SOURCES = gpgcom.c main.h \ + debug.c utf8.c \ + igpgme.h igpgme.c -gpgcom_SOURCES = main.c main.h \ - $(comheaders) \ - ignupg.c ignupg.h +tgpgcom_SOURCES = tgpgcom.c\ + debug.c \ + igpgme.h +#regtlb_SOURCES = regtlb.c +#guidgen_SOURCES = guidgen.c + +gpgcom_res.o: gpgcom.rc + mingw32 windres $< gpgcom_res.o diff --git a/complus/WINE-AUTHORS b/complus/WINE-AUTHORS deleted file mode 100644 index be51ca5..0000000 --- a/complus/WINE-AUTHORS +++ /dev/null @@ -1,331 +0,0 @@ -@c This file is processed by GNU's TeXinfo -@c If you modify it or move it to another location, make sure that -@c TeXinfo works (type `make' in directory documentation). - -@c This is a list of the Wine authors and copyright holders. - -Wine is available thanks to the work of: -James Abbatiello, -Michael Abd-El-Malek, -Howard Abrams, -Mark G. Adams, -Bruno Afonso, -Samir Al-Battran, -Guy Albertelli, -Gustavo Junior Alves, -Bob Amstadt, -Dag Asheim, -Jim Aston, -Martin Ayotte, -Viktor Babrian, -Karl Backström, -Bradley Baetz, -Peter Bajusz, -Andre Malafaya Baptista, -Aaron Barnes, -Jean-Claude Batista, -Marcel Baur, -Francis Beaudet, -Tom Bech, -Matthew Becker, -Georg Beyerle, -Ross Biro, -Dennis Björklund, -Zygo Blaxell, -Martin Boehme, -Francois Boisvert, -Pim Bollen, -Uwe Bonnes, -Peter Bortas, -Noel Borthwick, -Erik Bos, -Fons Botman, -Sylvain Bouchard, -Frederic Boulanger, -Justin Bradford, -John Brezak, -Andrew Bulhak, -John Burton, -Jonathan Buzzard, -Jose Marcos López Caravaca, -Eddie Carpenter, -Niels de Carpentier, -Mike Castle, -Ron Cemer, -Gordon Chaffee, -Gael de Chalendar, -Jimen Ching, -Geoff Clare, -Robert 'Admiral' Coeyman, -Richard Cohen, -Jean-Claude Cote, -Stephen Crowley, -Pascal Cuoq, -David A. Cuthbert, -Brian Joseph Czapiga, -Ulrich Czekalla, -Huw D. M. Davies, -Moses DeJong, -Petar Djukic, -Roman Dolejsi, -Frans van Dorsselaer, -Rikhardur Egilsson, -Morten Eriksen, -Chris Faherty, -Carsten Fallesen, -Paul Falstad, -David Faure, -Wesley Filardo, -Claus Fischer, -Olaf Flebbe, -Chad Fraleigh, -Matthew Francis, -Philippe Froidevaux, -Peter Galbavy, -Peter Ganten, -Ramon Garcia, -Jeff Garzik, -Julio Cesar Gazquez, -Klaas van Gend, -Abey George, -Brian Gerst, -Matthew Ghio, -Jody Goldberg, -David Golding, -François Gouget, -Hans de Graaff, -David Grant, -Albert den Haan, -Jess Haas, -Robert W Hall, -Noomen Hamza, -Charles M. Hannum, -Adrian Harvey, -John Harvey, -James Hatheway, -Kalevi J Hautaniemi, -Bill Hawes, -Lars Heete, -Cameron Heide, -Bernd Herd, -Theodore S. Hetke, -Haithem Hmida, -Jochen Hoenicke, -Henning Hoffmann, -Kevin Holbrook, -Nick Holloway, -Onno Hovers, -Jeffrey Hsu, -Peter Hunnisett, -Miguel de Icaza, -Jukka Iivonen, -Kostya Ivanov, -Serge Ivanov, -Lee Jaekil, -Gautam Jain, -Niels Kristian Bech Jensen, -Rajeev Jhangiani, -Bill Jin, -Jeff Johann, -Alexandre Julliard, -Bang Jun-Young, -James Juran, -Achim Kaiser, -Alexander Kanavin, -Jukka Kangas, -Pavel Kankovsky, -Michael Karcher, -Niclas Karlsson, -Jochen Karrer, -Don Kelly, -Andreas Kirschbaum, -Rein Klazes, -Albrecht Kleine, -Dietmar Kling, -Eric Kohl, -Jon Konrath, -Alex Korobka, -Zoltan Kovacs, -Greg Kreider, -Anand Kumria, -Ove Kåven, -Scott A. Laird, -David Lee Lambert, -Stephen Langasek, -Sean Langley, -Dan Langlois, -Alexander Larsson, -David Lassonde, -Stefan Leichter, -Karl Lessard, -Pascal Lessard, -Andrew Lewycky, -John Li, -Weisheng Li, -Xiang Li, -Per Lindström, -Brian Litzinger, -Juergen Lock, -Martin von Loewis, -Michiel van Loon, -Richard A Lough, -Alexander V. Lukyanov, -Jiuming Luo, -Stephane Lussier, -David Luyer, -José Marcos López, -Kenneth MacDonald, -Peter MacDonald, -Pierre Mageau, -William Magro, -Juergen Marquardt, -Ricardo Massaro, -Keith Matthews, -Joerg Mayer, -Michael McCormack, -Jason McMullan, -Caolan McNamara, -Marcus Meissner, -Graham Menhennitt, -David Metcalfe, -Toufic Milan, -Paul Millar, -Bruce Milner, -Steffen Moeller, -Andreas Mohr, -Slava Monich, -James Moody, -Chris Morgan, -Kai Morich, -Richard Mortimer, -Vasudev Mulchandani, -Rick Mutzke, -Philippe De Muyter, -Itai Nahshon, -Jonathan Naylor, -Tim Newsome, -Thuy Nguyen, -Kristian Nielsen, -Damien O'Neill, -Henrik Olsen, -Gerard Patel, -Michael Patra, -Murali Pattathe, -Dimitrie O. Paun, -Bernd Paysan, -Brad Pepers, -Jim Peterson, -Gerald Pfeifer, -Dave Pickles, -Ian Pilcher, -Brian Pirie, -Michael Poole, -Eric Pouech, -Robert Pouliot, -Vahid Pourlotfali, -Chad Powell, -Joseph Pranevich, -Alex Priem, -Paul Quinn, -Pete Ratzlaff, -Ron Record, -Petter Reinholdtsen, -Keith Reynolds, -Slaven Rezic, -John Richardson, -Rick Richardson, -Douglas Ridgway, -Robert Riggs, -Bernhard Rosenkraenzer, -Matthew Robertson, -Pavel Roskin, -Herbert Rosmanith, -Lilia Roumiantseva, -Johannes Ruscheinski, -Adam Sacarny, -Ivan de Saedeleer, -Thomas Sandford, -Constantine Sapuntzakis, -Pablo Saratxaga, -Carl van Schaik, -Daniel Schepler, -Christian Schlaile, -Peter Schlaile, -Ulrich Schmid, -Bernd Schmidt, -Ian Schmidt, -Juergen Schmied, -Ingo Schneider, -Victor Schneider, -John Sheets, -Yngvi Sigurjonsson, -Stephen Simmons, -Jesper Skov, -Rick Sladkey, -William Smith, -Jaroslaw Piotr Sobieszek, -Patrick Spinler, -Sylvain St-Germain, -Gavriel State, -Sheri Steeves, -Norman Stevens, -Dominik Strasser, -Patrik Stridvall, -Vadim Strizhevsky, -Bertho Stultiens, -Abraham Sudhakar, -Charles Suprin, -James Sutherland, -Erik Svendsen, -Tristan Tarrant, -Andrew Taylor, -Joshua Thielen, -Dirk Thierbach, -Jean-Louis Thirot, -Duncan C Thomson, -Adrian Thurston, -Goran Thyni, -Steve Tibbett, -Dmitry Timoshkov, -Jimmy Tirtawangsa, -Jon Tombs, -Linus Torvalds, -Luc Tourangeau, -Jeff Tranter, -Gregory Trubetskoy, -Petri Tuomola, -Sergey Turchanov, -Lionel Ulmer, -Moshe Vainer, -Michael Veksler, -Sven Verdoolaege, -Todd Vierling, -Erez Volk, -Jerome Vouillon, -Duc Vuong, -Ronan Waide, -Martin Walker, -Owen Wang, -Eric Warnke, -Leigh Wedding, -Randy Weems, -Manfred Weichel, -Ulrich Weigand, -Morten Welinder, -Jeremy White, -Len White, -Lawson Whitney, -Jan Willamowius, -Carl Williams, -Eric Williams, -Cliff Wright, -Karl Guenter Wuensch, -Eric Youngdale, -James Youngman, -Nikita V. Youshchenko, -Mikolaj Zalewski, -John Zero, -Yuxi Zhang, -Nathan Zorich, -Luiz Otavio L. Zorzella, -and Per Ångström. diff --git a/complus/WINE-LICENSE b/complus/WINE-LICENSE deleted file mode 100644 index f3478fe..0000000 --- a/complus/WINE-LICENSE +++ /dev/null @@ -1,26 +0,0 @@ -This is the license file as it appeared in the CVS version of -Wine at cvs@rhlx01.fht-esslingen.de:/home/wine as of 2000-12-04 -where only AUTHORS has been renamed to WINE-AUTHORS. It applies -to the header files establishing the COM+ framework - -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -Copyright (c) 1993-2000 the Wine project authors (see the file WINE-AUTHORS -for a complete list) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/complus/basetsd.h b/complus/basetsd.h deleted file mode 100644 index 866c9b8..0000000 --- a/complus/basetsd.h +++ /dev/null @@ -1,160 +0,0 @@ -/* basetsd.h - Compilers that uses ILP32, LP64 or P64 type models - for both Win32 and Win64 are supported by this file. - - Copyright (c) 1993-2000 the Wine project authors (see the file WINE-AUTHORS - for a complete list) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __WINE_BASETSD_H -#define __WINE_BASETSD_H - -#ifdef __cplusplus -extern "C" { -#endif /* defined(__cplusplus) */ - -/* - * Win32 was easy to implement under Unix since most (all?) 32-bit - * Unices uses the same type model (ILP32) as Win32, where int, long - * and pointer are 32-bit. - * - * Win64, however, will cause some problems when implemented under Unix. - * Linux/{Alpha, Sparc64} and most (all?) other 64-bit Unices uses - * the LP64 type model where int is 32-bit and long and pointer are - * 64-bit. Win64 on the other hand uses the P64 (sometimes called LLP64) - * type model where int and long are 32 bit and pointer is 64-bit. - */ - -/* Type model indepent typedefs */ - -typedef char __int8; -typedef unsigned char __uint8; - -typedef short __int16; -typedef unsigned short __uint16; - -typedef int __int32; -typedef unsigned int __uint32; - -typedef long long __int64; -typedef unsigned long long __uint64; - -#if defined(_WIN64) - -typedef __uint32 __ptr32; -typedef void *__ptr64; - -#else /* FIXME: defined(_WIN32) */ - -typedef void *__ptr32; -typedef __uint64 __ptr64; - -#endif - -/* Always signed and 32 bit wide */ - -typedef __int32 LONG32; -typedef __int32 INT32; - -typedef LONG32 *PLONG32; -typedef INT32 *PINT32; - -/* Always unsigned and 32 bit wide */ - -typedef __uint32 ULONG32; -typedef __uint32 DWORD32; -typedef __uint32 UINT32; - -typedef ULONG32 *PULONG32; -typedef DWORD32 *PDWORD32; -typedef UINT32 *PUINT32; - -/* Always signed and 64 bit wide */ - -typedef __int64 LONG64; -typedef __int64 INT64; - -typedef LONG64 *PLONG64; -typedef INT64 *PINT64; - -/* Always unsigned and 64 bit wide */ - -typedef __uint64 ULONG64; -typedef __uint64 DWORD64; -typedef __uint64 UINT64; - -typedef ULONG64 *PULONG64; -typedef DWORD64 *PDWORD64; -typedef UINT64 *PUINT64; - -/* Win32 or Win64 dependent typedef/defines. */ - -#ifdef _WIN64 - -typedef __int64 INT_PTR, *PINT_PTR; -typedef __uint64 UINT_PTR, *PUINT_PTR; - -#define MAXINT_PTR 0x7fffffffffffffff -#define MININT_PTR 0x8000000000000000 -#define MAXUINT_PTR 0xffffffffffffffff - -typedef __int32 HALF_PTR, *PHALF_PTR; -typedef __int32 UHALF_PTR, *PUHALF_PTR; - -#define MAXHALF_PTR 0x7fffffff -#define MINHALF_PTR 0x80000000 -#define MAXUHALF_PTR 0xffffffff - -typedef __int64 LONG_PTR, *PLONG_PTR; -typedef __uint64 ULONG_PTR, *PULONG_PTR; -typedef __uint64 DWORD_PTR, *PDWORD_PTR; - -#else /* FIXME: defined(_WIN32) */ - -typedef __int32 INT_PTR, *PINT_PTR; -typedef __uint32 UINT_PTR, *PUINT_PTR; - -#define MAXINT_PTR 0x7fffffff -#define MININT_PTR 0x80000000 -#define MAXUINT_PTR 0xffffffff - -typedef __int16 HALF_PTR, *PHALF_PTR; -typedef __uint16 UHALF_PTR, *PUHALF_PTR; - -#define MAXUHALF_PTR 0xffff -#define MAXHALF_PTR 0x7fff -#define MINHALF_PTR 0x8000 - -typedef __int32 LONG_PTR, *PLONG_PTR; -typedef __uint32 ULONG_PTR, *PULONG_PTR; -typedef __uint32 DWORD_PTR, *PDWORD_PTR; - -#endif /* defined(_WIN64) || defined(_WIN32) */ - -typedef INT_PTR SSIZE_T, *PSSIZE_T; -typedef UINT_PTR SIZE_T, *PSIZE_T; - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* defined(__cplusplus) */ - -#endif /* !defined(__WINE_BASETSD_H) */ - - - diff --git a/complus/debug.c b/complus/debug.c new file mode 100644 index 0000000..d7cb0a0 --- /dev/null +++ b/complus/debug.c @@ -0,0 +1,40 @@ +/* debug.c - COM+ debug helpers + * Copyright (C) 2001 g10 Code GmbH + * + * This file is part of GPGME. + * + * GPGME 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 2 of the License, or + * (at your option) any later version. + * + * GPGME 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include + + +const char * +debugstr_guid (const GUID *id) +{ + static char str[100]; + + if (!id) + return "(null)"; + sprintf( str, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + id->Data1, id->Data2, id->Data3, + id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], + id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); + return str; +} + diff --git a/complus/gpgcom.c b/complus/gpgcom.c new file mode 100644 index 0000000..acea982 --- /dev/null +++ b/complus/gpgcom.c @@ -0,0 +1,543 @@ +/* gpgcom.c - COM+ component to access GnuPG + * Copyright (C) 2001 g10 Code GmbH + * + * This file is part of GPGME. + * + * GPGME 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 2 of the License, or + * (at your option) any later version. + * + * GPGME 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "argparse.h" + +#include "main.h" +#include "igpgme.h" + +static void register_server (void); +static void unregister_server (void); +static void enter_complus (void); + + +enum cmd_and_opt_values { aNull = 0, + oQuiet = 'q', + oVerbose = 'v', + + oNoVerbose = 500, + oOptions, + oDebug, + oDebugAll, + oNoGreeting, + oNoOptions, + oHomedir, + oGPGBinary, + oRegServer, + oUnregServer, + oEmbedding, +aTest }; + + +static ARGPARSE_OPTS opts[] = { + + { 301, NULL, 0, N_("@Options:\n ") }, + + { oVerbose, "verbose", 0, N_("verbose") }, + { oQuiet, "quiet", 0, N_("be somewhat more quiet") }, + { oOptions, "options" , 2, N_("read options from file")}, + { oDebug, "debug" ,4|16, N_("set debugging flags")}, + { oDebugAll, "debug-all" ,0, N_("enable full debugging")}, + { oGPGBinary, "gpg-program", 2 , "" }, + { oRegServer, "RegServer" , 0, "" }, + { oUnregServer, "UnregServer" , 0, "" }, + { oEmbedding, "Embedding" , 0, "" }, +{0} }; + + + + +static const char * +my_strusage( int level ) +{ + const char *p; + switch( level ) { + case 11: p = "gpgcom"; + break; + case 13: p = VERSION; break; + /*case 17: p = PRINTABLE_OS_NAME; break;*/ + case 19: p = + _("Please report bugs to .\n"); + break; + case 1: + case 40: p = + _("Usage: gpgcom [options] (-h for help)"); + break; + case 41: p = + _("Syntax: gpgcom [options]\n" + "GnuPG COM+ component\n"); + break; + + default: p = NULL; + } + return p; +} + + +int +main (int argc, char **argv ) +{ + ARGPARSE_ARGS pargs; + int orig_argc; + char **orig_argv; + FILE *configfp = NULL; + char *configname = NULL; + unsigned configlineno; + int parse_debug = 0; + int default_config =1; + int greeting = 0; + int nogreeting = 0; + int action = 0; + + set_strusage( my_strusage ); + /*log_set_name ("gpa"); not yet implemented in logging.c */ + + opt.homedir = getenv("GNUPGHOME"); + if( !opt.homedir || !*opt.homedir ) { + #ifdef HAVE_DRIVE_LETTERS + opt.homedir = "c:/gnupg"; + #else + opt.homedir = "~/.gnupg"; + #endif + } + + /* check whether we have a config file on the commandline */ + orig_argc = argc; + orig_argv = argv; + pargs.argc = &argc; + pargs.argv = &argv; + pargs.flags= 1|(1<<6); /* do not remove the args, ignore version */ + while( arg_parse( &pargs, opts) ) { + if( pargs.r_opt == oDebug || pargs.r_opt == oDebugAll ) + parse_debug++; + else if( pargs.r_opt == oOptions ) { + /* yes there is one, so we do not try the default one, but + * read the option file when it is encountered at the commandline + */ + default_config = 0; + } + else if( pargs.r_opt == oNoOptions ) + default_config = 0; /* --no-options */ + else if( pargs.r_opt == oHomedir ) + opt.homedir = pargs.r.ret_str; + } + + if( default_config ) + configname = make_filename(opt.homedir, "gpgme.conf", NULL ); + + + argc = orig_argc; + argv = orig_argv; + pargs.argc = &argc; + pargs.argv = &argv; + pargs.flags= 1 | (1<<5); /* do not remove the args, allow one dash */ + next_pass: + if( configname ) { + configlineno = 0; + configfp = fopen( configname, "r" ); + if( !configfp ) { + if( default_config ) { + if( parse_debug ) + log_info(_("NOTE: no default option file `%s'\n"), + configname ); + } + else { + log_error(_("option file `%s': %s\n"), + configname, strerror(errno) ); + exit(2); + } + free(configname); configname = NULL; + } + if( parse_debug && configname ) + log_info(_("reading options from `%s'\n"), configname ); + default_config = 0; + } + + while( optfile_parse( configfp, configname, &configlineno, + &pargs, opts) ) { + switch( pargs.r_opt ) { + case oQuiet: opt.quiet = 1; break; + case oVerbose: opt.verbose++; break; + + case oDebug: opt.debug |= pargs.r.ret_ulong; break; + case oDebugAll: opt.debug = ~0; break; + + case oOptions: + /* config files may not be nested (silently ignore them) */ + if( !configfp ) { + free(configname); + configname = xstrdup(pargs.r.ret_str); + goto next_pass; + } + break; + case oNoGreeting: nogreeting = 1; break; + case oNoVerbose: opt.verbose = 0; break; + case oNoOptions: break; /* no-options */ + case oHomedir: opt.homedir = pargs.r.ret_str; break; + case oGPGBinary: break; + + case oRegServer: action = 1; break; + case oUnregServer: action = 2; break; + case oEmbedding: action = 3; break; + + default : pargs.err = configfp? 1:2; break; + } + } + if( configfp ) { + fclose( configfp ); + configfp = NULL; + free(configname); configname = NULL; + goto next_pass; + } + free( configname ); configname = NULL; + if( log_get_errorcount(0) ) + exit(2); + if( nogreeting ) + greeting = 0; + + if( greeting ) { + fprintf(stderr, "%s %s; %s\n", + strusage(11), strusage(13), strusage(14) ); + fprintf(stderr, "%s\n", strusage(15) ); + } + #ifdef IS_DEVELOPMENT_VERSION + log_info("NOTE: this is a development version!\n"); + #endif + + if ( action == 1 ) + register_server (); + else if (action == 2 ) + unregister_server (); + else if (action == 3 ) + enter_complus (); + else { + fprintf (stderr, "This is a COM+ component with no user interface.\n" + "gpgme --help will give you a list of options\n" ); + exit (1); + } + + return 0; +} + + +static void +register_progid ( const char *name ) +{ + HKEY hk = 0; + char buf[500]; + + /* Create a ProgID entry to point to the ClassID */ + sprintf (buf, "%.400s", name); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + sprintf (buf, "g10 Code's GnuPG made easy COMponent" ); + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, 0)) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + sprintf (buf, "%.400s\\CLSID", name); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + sprintf (buf, "%.100s", debugstr_guid (&CLSID_Gpgme) ); + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; +} + + +static void +register_typelib (void) +{ + ITypeLib *pTypeLib; + HRESULT hr; + char name[500]; + wchar_t *wname; + size_t n; + + if ( !GetModuleFileNameA (0, name, sizeof (name)-10) ) { + fprintf (stderr,"GetModuleFileName() failed: %d\n", + (int)GetLastError()); + exit (1); + } + n = mbstowcs (NULL, name, strlen(name)+1); + wname = xmalloc ((n+1)*sizeof *wname); + mbstowcs (wname, name, strlen (name)+1); + + hr = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED); + if (hr) + fprintf (stderr, "CoInitializeEx() failed: hr=%lu\n", hr); + + hr = LoadTypeLibEx (wname, REGKIND_REGISTER, &pTypeLib); + if (hr) + fprintf (stderr, "LoadTypeLibEx() failed: hr=%lx\n", hr); + + ITypeLib_Release (pTypeLib); + CoUninitialize (); + free (wname); +} + +static void +unregister_typelib (void) +{ + UnRegisterTypeLib (&TLBID_Gpgcom, 1, 0, LANG_NEUTRAL, SYS_WIN32); +} + +static void +register_server () +{ + HKEY hk = 0; + char buf[500]; + + + register_typelib (); + + /* Create a key for the CLSID */ + sprintf (buf, "CLSID\\%.100s", debugstr_guid (&CLSID_Gpgme) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + /* Store our class name as default value */ + strcpy (buf, "Gpgme"); + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + + /* Set the application ID */ + sprintf (buf, "%.100s", debugstr_guid (&APPID_Gpgcom) ); + if (RegSetValueExA (hk, "AppID", 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + /* Create the LocalServer32 subkey under the CLSID key */ + sprintf (buf, "CLSID\\%.100s\\LocalServer32", + debugstr_guid (&CLSID_Gpgme) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + /* retrieve the module name and add it under the key */ + if ( !GetModuleFileNameA (0, buf, sizeof (buf)-10) ) { + fprintf (stderr,"GetModuleFileName() failed\n"); + exit (1); + } + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + /* Create the ProgID subkey under the CLSID key */ + sprintf (buf, "CLSID\\%.100s\\ProgID", + debugstr_guid (&CLSID_Gpgme) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + if (RegSetValueExA (hk, 0, 0, REG_SZ, "Gpgcom.Gpgme.1", 0)) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + /* Create the VersionIndependentProgID subkey under the CLSID key */ + sprintf (buf, "CLSID\\%.100s\\VersionIndependentProgID", + debugstr_guid (&CLSID_Gpgme) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + if (RegSetValueExA (hk, 0, 0, REG_SZ, "Gpgcom.Gpgme", 0)) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + + /* Create a key to store AppID info */ + sprintf (buf, "AppID\\%.100s", debugstr_guid (&APPID_Gpgcom) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + /* Store the name as default value */ + strcpy (buf, "Gpgcom"); + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + register_progid ("Gpgcom.Gpgme"); + register_progid ("Gpgcom.Gpgme.1"); + + /* Create a convenience cross reference to the AppID */ + sprintf (buf, "AppID\\gpgcom.exe"); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + sprintf (buf, "%.100s", debugstr_guid (&APPID_Gpgcom) ); + if (RegSetValueExA (hk, "AppID", 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + fprintf (stderr,"*** Component registered\n"); +} + +static void +unregister_server () +{ + char buf[500]; + + unregister_typelib (); + sprintf (buf, "CLSID\\%.100s\\LocalServer32", + debugstr_guid (&CLSID_Gpgme) ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "CLSID\\%.100s\\ProgID", debugstr_guid (&CLSID_Gpgme) ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "CLSID\\%.100s", debugstr_guid (&CLSID_Gpgme) ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "Gpgcom.Gpgme.1\\CLSID"); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + sprintf (buf, "Gpgcom.Gpgme.1"); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "Gpgcom.Gpgme\\CLSID"); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + sprintf (buf, "Gpgcom.Gpgme"); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + + sprintf (buf, "AppID\\%.100s", debugstr_guid (&APPID_Gpgcom) ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "AppID\\gpgcom.exe" ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + fprintf (stderr,"*** component unregistered\n"); +} + + +static void +enter_complus () +{ + HANDLE running; + DWORD reg; + IClassFactory *factory; + CLSID clsid; + HRESULT hr; + + fprintf (stderr,"*** enter enter_complus()\n"); + CoInitializeEx (NULL, COINIT_MULTITHREADED); + running = CreateEvent (NULL, FALSE, FALSE, NULL ); + fprintf (stderr,"*** CoInitialize() done; event=%lx\n", (unsigned long)running ); + + factory = igpgme_factory_new ( &clsid ); + fprintf (stderr,"*** igpgme_factory_new() done; got=%p\n", factory ); + hr = CoRegisterClassObject (&clsid, (IUnknown*)factory, + CLSCTX_LOCAL_SERVER, + REGCLS_SUSPENDED|REGCLS_MULTIPLEUSE, ® ); + if (hr) { + fprintf (stderr, "CoRegisterClassObject() failed: hr=%lx\n", hr); + exit (1); + } + hr = CoResumeClassObjects (); + if (hr) + fprintf (stderr, "CoRegisterClassObject() failed: hr=%lx\n", hr); + fprintf (stderr,"*** class object registered; waiting\n" ); + + WaitForSingleObject ( running, INFINITE ); + fprintf (stderr,"*** shutting down\n" ); + CloseHandle (running); + CoRevokeClassObject ( reg ); + fprintf (stderr,"*** class object revoked\n" ); + igpgme_factory_release (factory); + fprintf (stderr,"*** factory released\n" ); + CoUninitialize (); + fprintf (stderr,"*** leave enter_complus()\n" ); +} + diff --git a/complus/gpgcom.idl b/complus/gpgcom.idl new file mode 100644 index 0000000..654eec0 --- /dev/null +++ b/complus/gpgcom.idl @@ -0,0 +1,62 @@ +/* ignupg.idl - Interface definition for the COM+ class GnuPG + * Copyright (C) 2001 g10 Code GmbH + * + * This file is part of GPGME. + * + * GPGME 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 2 of the License, or + * (at your option) any later version. + * + * GPGME 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +import "unknwn.idl"; +import "oaidl.idl"; + + +[ object, uuid(3811fd50-7f72-11d5-8c9e-0080ad190cd5), dual] +interface IGpgme : IDispatch +{ + HRESULT GetVersion([out] BSTR *retval); + HRESULT GetEngineInfo([out] BSTR *retval); + HRESULT Cancel(void); + [propput] HRESULT Armor([in] BOOL flag); + [propget] HRESULT Armor([out, retval] BOOL *retval); + [propput] HRESULT Textmode([in] BOOL flag); + [propget] HRESULT Textmode([out, retval] BOOL *retval); + [propput] HRESULT Plaintext([in] VARIANT val); + [propget] HRESULT Plaintext([out, retval] VARIANT *retval); + [propput] HRESULT Ciphertext([in] VARIANT val); + [propget] HRESULT Ciphertext([out,retval] VARIANT *retval); + HRESULT ClearRecipients(void); + HRESULT AddRecipient([in] BSTR name, + [in, optional, defaultvalue(-1)] signed short trust); + HRESULT ResetSignKeys(void); + HRESULT AddSignKey([in] BSTR name); + HRESULT Encrypt(void); + HRESULT Sign([in,optional,defaultvalue(0)] signed short signmode); + HRESULT SignEncrypt([in,optional,defaultvalue(0)] signed short signmode); + +}; + + +[ uuid(3811fd48-7f72-11d5-8c9e-0080ad190cd5), + helpstring("g10Code.gpgcom, type library"), + version(1.0) ] +library GpgcomLib +{ + [ uuid(3811fd40-7f72-11d5-8c9e-0080ad190cd5) ] + coclass Gpgcom + { + [default] interface IGpgme; + } +}; diff --git a/complus/gpgcom.rc b/complus/gpgcom.rc new file mode 100644 index 0000000..d9ac566 --- /dev/null +++ b/complus/gpgcom.rc @@ -0,0 +1,22 @@ +/* gpgcom.rc - Resource file for gpgcom + * Copyright (C) 2001 g10 Code GmbH + * + * This file is part of GPGME. + * + * GPGME 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 2 of the License, or + * (at your option) any later version. + * + * GPGME 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +1 TYPELIB "gpgcom.tlb" + diff --git a/complus/gpgcom.tlb b/complus/gpgcom.tlb new file mode 100644 index 0000000000000000000000000000000000000000..ae3d1627d3bfd8d9902ebb95ef3afdc55c328f55 GIT binary patch literal 18596 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 -#include -#include -#include -#include -#include -#include -#include - -#define INITGUID -#include "ignupg.h" - -/* - * Declare the interface implementation structures - */ -typedef struct IGnuPGImpl IGnuPGImpl; -typedef struct IClassFactoryImpl IClassFactoryImpl; - - -struct IGnuPGImpl { - /* IUnknown required stuff */ - ICOM_VFIELD (IGnuPG); - DWORD ref; - /* Our stuff */ - int foo; -}; - - -struct IClassFactoryImpl { - /* IUnknown fields */ - ICOM_VFIELD(IClassFactory); - DWORD ref; -}; - - - -/********************************************************** - ************** IGnuPG Implementation ******************* - **********************************************************/ - -static HRESULT WINAPI -IGnuPGImpl_QueryInterface (IGnuPG *iface, REFIID refiid, LPVOID *obj) -{ - ICOM_THIS (IGnuPGImpl,iface); - - fprintf (stderr,"(%p)->QueryInterface(%s,%p)\n", - This, "debugstr_guid(refiid)", obj); - if ( IsEqualGUID (&IID_IUnknown, refiid) - || !IsEqualGUID (&IID_IGnuPG, refiid) ) { - *obj = iface; - return 0; - } - *obj = NULL; - return E_NOINTERFACE; -} - - -static ULONG WINAPI -IGnuPGImpl_AddRef (IGnuPG *iface) -{ - ICOM_THIS (IGnuPGImpl,iface); - - return ++This->ref; -} - - -static ULONG WINAPI -IGnuPGImpl_Release (IGnuPG *iface) -{ - ICOM_THIS (IGnuPGImpl,iface); - - if (--This->ref) - return This->ref; - - HeapFree(GetProcessHeap(),0,iface); - return 0; -} - - - - -static ICOM_VTABLE(IGnuPG) gnupg_vtbl = -{ - /* IUnknow methods */ - ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE - IGnuPGImpl_QueryInterface, - IGnuPGImpl_AddRef, - IGnuPGImpl_Release, - /* Our methods */ - -}; - - - -/*************************************************************** - ****************** GnuPG Factory **************************** - ***************************************************************/ - -static HRESULT WINAPI -GnuPGFactory_QueryInterface (IClassFactory *iface, REFIID refiid, LPVOID *obj) -{ - /*ICOM_THIS(IClassFactoryImpl,iface);*/ - return E_NOINTERFACE; -} - -static ULONG WINAPI -GnuPGFactory_AddRef (IClassFactory *iface) -{ - ICOM_THIS(IClassFactoryImpl,iface); - return ++(This->ref); -} - -static ULONG WINAPI -GnuPGFactory_Release (IClassFactory *iface) -{ - ICOM_THIS(IClassFactoryImpl,iface); - return --(This->ref); -} - -static HRESULT WINAPI -GnuPGFactory_CreateInstance (IClassFactory *iface, IUnknown *outer, - REFIID refiid, LPVOID *r_obj ) -{ - /*ICOM_THIS(IClassFactoryImpl,iface);*/ - - if ( IsEqualGUID (&IID_IGnuPG, refiid) ) { - IGnuPGImpl *obj; - - obj = HeapAlloc (GetProcessHeap(), 0, sizeof *obj ); - if ( !obj) - return E_OUTOFMEMORY; - - ICOM_VTBL(obj) = &gnupg_vtbl; - obj->ref = 1; - *r_obj = obj; - return 0; - } - *r_obj = NULL; - return E_NOINTERFACE; -} - -static HRESULT WINAPI -GnuPGFactory_LockServer (IClassFactory *iface, BOOL dolock ) -{ - /*ICOM_THIS(IClassFactoryImpl,iface);*/ - return 0; -} - -static ICOM_VTABLE(IClassFactory) gnupg_factory_vtbl = { - ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE - GnuPGFactory_QueryInterface, - GnuPGFactory_AddRef, - GnuPGFactory_Release, - GnuPGFactory_CreateInstance, - GnuPGFactory_LockServer -}; -static IClassFactoryImpl GnuPG_CF = {&gnupg_factory_vtbl, 1 }; - - -IClassFactory * -gnupg_factory_new ( CLSID *r_clsid ) -{ - *r_clsid = CLSID_GnuPG; - IClassFactory_AddRef((IClassFactory*)&GnuPG_CF); - return (IClassFactory*)&GnuPG_CF; -} - -void -gnupg_factory_release ( IClassFactory *factory ) -{ - /* it's static - nothing to do */ -} - - - - - - - - - diff --git a/complus/ignupg.h b/complus/ignupg.h deleted file mode 100644 index e9cf9a6..0000000 --- a/complus/ignupg.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ignupg.h - COM+ class IGnuPG - * Copyright (C) 2000 Werner Koch (dd9jn) - * - * This file is part of GPGME. - * - * GPGME 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 2 of the License, or - * (at your option) any later version. - * - * GPGME 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#ifndef IGNUPG_H -#define IGNUPG_H 1 - -#include "obj_base.h" - -DEFINE_GUID(CLSID_GnuPG, 0x42424242, 0x62e8, 0x11cf, - 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); -DEFINE_GUID(IID_IGnuPG, 0x24242424, 0x4981, 0x11CE, - 0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60); -typedef struct IGnuPG IGnuPG; - - - -#define ICOM_INTERFACE IGnuPG - -#define IGnuPG_METHODS \ - ICOM_METHOD1(HRESULT,Initialize, REFIID,) \ - ICOM_METHOD1(HRESULT,EnumDevices, LPVOID,) - -#define IGnuPG_IMETHODS \ - IUnknown_IMETHODS \ - IGnuPG_METHODS - -ICOM_DEFINE(IGnuPG,IUnknown) -#undef ICOM_INTERFACE - - -/*** IUnknown methods ***/ -#define IGnuPG_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) -#define IGnuPG_AddRef(p) ICOM_CALL (AddRef,p) -#define IGnuPG_Release(p) ICOM_CALL (Release,p) -/*** IGnuPG methods ***/ -#define IGnuPG_Initialize(p,a) ICOM_CALL1(Initialize,p,a) -#define IGnuPG_EnumDevices(p,a,b) ICOM_CALL2(EnumDevice,p,a,b) - - -#endif /*IGNUPG_H*/ - - - - - - - - - - - diff --git a/complus/igpgme.c b/complus/igpgme.c new file mode 100644 index 0000000..5983ce8 --- /dev/null +++ b/complus/igpgme.c @@ -0,0 +1,903 @@ +/* igpgme.c - COM+ class IGpgme + * Copyright (C) 2001 g10 Code GmbH + * + * This file is part of GPGME. + * + * GPGME 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 2 of the License, or + * (at your option) any later version. + * + * GPGME 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../gpgme/gpgme.h" + +/* FIXME: Put them into an extra header */ +void *_gpgme_malloc (size_t n ); +void *_gpgme_calloc (size_t n, size_t m ); +void *_gpgme_realloc (void *p, size_t n); +char *_gpgme_strdup (const char *p); +void _gpgme_free ( void *a ); + + + +#define INITGUID +#include "igpgme.h" + +/* + * Declare the interface implementation structures + */ +typedef struct IGpgmeImpl IGpgmeImpl; +typedef struct IClassFactoryImpl IClassFactoryImpl; + + +struct IGpgmeImpl { + /* IUnknown required stuff */ + ICOM_VFIELD (IGpgme); + DWORD ref; + /* Delegation to IDispatch */ + struct { + IUnknown *disp; + ITypeInfo *tinfo; + } std_disp; + /* Our stuff */ + GpgmeCtx mainctx; + GpgmeData plaintext; + int plaintext_given_as_bstr; + GpgmeData ciphertext; + int ciphertext_is_armored; + GpgmeRecipients rset; +}; + + +struct IClassFactoryImpl { + /* IUnknown fields */ + ICOM_VFIELD(IClassFactory); + DWORD ref; +}; + +/********************************************************** + ************** helper functions ************************ + *********************************************************/ +static HRESULT +map_gpgme_error (GpgmeError err) +{ + HRESULT hr; + + if (!err) + return 0; + if ( err < 0 || err > 0x1000 ) { + fprintf (stderr,"*** GpgmeError `%s' mapped to GPGME_General_Error\n", + gpgme_strerror (err) ); + err = GPGME_General_Error; + } + hr = MAKE_HRESULT (SEVERITY_ERROR, FACILITY_ITF, 0x1000 + err); + fprintf (stderr,"*** GpgmeError `%s' mapped to %lx\n", + gpgme_strerror (err), (unsigned long)hr ); + return hr; +} + + +/********************************************************** + ************** IGpgme Implementation ******************* + *********************************************************/ + +static HRESULT WINAPI +m_IGpgme_QueryInterface (IGpgme *iface, REFIID refiid, LPVOID *obj) +{ + ICOM_THIS (IGpgmeImpl,iface); + + /*fprintf (stderr,"*** m_IGpgme_QueryInterface(%p,%s)", + This, debugstr_guid(refiid));*/ + if ( IsEqualGUID (&IID_IUnknown, refiid) + || IsEqualGUID (&IID_IGpgme, refiid) ) { + *obj = This; + IGpgme_AddRef (iface); + fprintf (stderr," -> got %p\n", *obj); + return 0; + } + else if ( IsEqualGUID (&IID_IDispatch, refiid) ) { + HRESULT hr = IDispatch_QueryInterface (This->std_disp.disp, + refiid, obj); + /*fprintf (stderr," -> delegated, hr=%lx, got %p\n", + hr, hr? NULL: *obj);*/ + return hr; + } + /*fprintf (stderr," -> none\n");*/ + *obj = NULL; + return E_NOINTERFACE; +} + + +static ULONG WINAPI +m_IGpgme_AddRef (IGpgme *iface) +{ + ICOM_THIS (IGpgmeImpl,iface); + + return ++This->ref; +} + + +static ULONG WINAPI +m_IGpgme_Release (IGpgme *iface) +{ + ICOM_THIS (IGpgmeImpl,iface); + + if (--This->ref) + return This->ref; + + gpgme_release (This->mainctx); This->mainctx = NULL; + gpgme_data_release (This->plaintext); This->plaintext = NULL; + gpgme_data_release (This->ciphertext); This->ciphertext = NULL; + gpgme_recipients_release (This->rset); This->rset = NULL; + if (This->std_disp.disp) + IDispatch_Release (This->std_disp.disp); + if (This->std_disp.tinfo) + ITypeInfo_Release (This->std_disp.tinfo); + HeapFree(GetProcessHeap(),0,iface); + return 0; +} + + +static HRESULT WINAPI +m_stub_IDispatch_GetTypeInfoCount (IGpgme *iface, unsigned int *pctinfo) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_stub_IDispatch_GetTypeInfo (IGpgme *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_stub_IDispatch_GetIDsOfNames (IGpgme *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_stub_IDispatch_Invoke (IGpgme *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, + DISPPARAMS *pDispParams, VARIANT *pVarResult, + EXCEPINFO *pExepInfo, UINT *puArgErr) +{ + return E_NOTIMPL; +} + + + +static HRESULT WINAPI +m_IGpgme_GetVersion (IGpgme *iface, BSTR *retvat) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_IGpgme_GetEngineInfo (IGpgme *iface, BSTR *retval) +{ + return E_NOTIMPL; +} + + +static HRESULT WINAPI +m_IGpgme_Cancel (IGpgme *iface) +{ + return E_NOTIMPL; +} + + +static HRESULT WINAPI +m_IGpgme_SetArmor (IGpgme *iface, BOOL yes) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + gpgme_set_armor (This->mainctx, yes); + return 0; +} + +static HRESULT WINAPI +m_IGpgme_GetArmor (IGpgme *iface, BOOL *retval) +{ + ICOM_THIS (IGpgmeImpl,iface); + + *retval = gpgme_get_armor (This->mainctx); + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_SetTextmode (IGpgme *iface, BOOL yes) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + gpgme_set_textmode (This->mainctx, yes); + return 0; +} + +static HRESULT WINAPI +m_IGpgme_GetTextmode (IGpgme *iface, BOOL *retval) +{ + return E_NOTIMPL; +} + + +/* + * Put the data from VAL into a a Gpgme data object, which is passed by + * reference. Valid types of the Variant are: BSTR, SAFEARRAY of BYTE and + * SAFEARRAY of VARIANTS of signed or unsigned integers. + */ +static HRESULT WINAPI +set_data_from_variant (GpgmeData *data, VARIANT val, int *given_as_bstr) +{ + GpgmeError err = 0; + HRESULT hr; + unsigned char *buf; + SAFEARRAY *array; + size_t len; + int i; + + if ( val.vt == VT_BSTR) { + len = bstrtoutf8 (val.u.bstrVal, NULL, 0); + buf = _gpgme_malloc (len); + if (!buf) + return E_OUTOFMEMORY; + + if (bstrtoutf8 (val.u.bstrVal, buf, len) < 0) { + fprintf (stderr,"problem with bstrtoutf8\n"); + _gpgme_free (buf); + return E_FAIL; + } + + fprintf (stderr,"Got a BSTR (utf8):"); + for (i=0; i < len; i++) + fprintf (stderr, " %0X", buf[i] ); + putc ('\n', stderr); + gpgme_data_release (*data); *data = NULL; + err = gpgme_data_new_from_mem (data, buf, len, 0 /*no need to copy*/ ); + if (!err && given_as_bstr) + *given_as_bstr = 1; + } + else if ( val.vt == (VT_ARRAY|VT_UI1)) { + array = val.u.parray; + + fprintf (stderr,"Got an ARRAY of bytes:"); + hr = SafeArrayAccessData (array, (void**)&buf); + if (hr) { + fprintf (stderr,"*** SafeArrayAccessData failed: hr=%lx\n", hr); + return hr; + } + len = array->rgsabound[0].cElements; + for (i=0; i < len; i++) + fprintf (stderr, " %0X", buf[i] ); + putc ('\n', stderr); + + gpgme_data_release (*data); *data = NULL; + err = gpgme_data_new_from_mem (data, buf, len, 1 ); + SafeArrayUnaccessData (array); + if (given_as_bstr) + *given_as_bstr = 0; + } + else if ( val.vt == (VT_ARRAY|VT_VARIANT)) { + VARIANT *vp; + array = val.u.parray; + + fprintf (stderr,"Got an ARRAY of VARIANTS:"); + hr = SafeArrayAccessData (array, (void**)&vp); + if (hr) { + fprintf (stderr,"*** SafeArrayAccessData failed: hr=%lx\n", hr); + return hr; + } + len = array->rgsabound[0].cElements; + /* allocate the array using the gpgme allocator so that we can + * later use a new without the copy set*/ + buf = _gpgme_malloc (len); + if (!buf) { + SafeArrayUnaccessData (array); + return E_OUTOFMEMORY; + } + /* coerce all array elements into rawtext */ + for (i=0; i < len; i++) { + switch (vp[i].vt) { + case VT_I1: buf[i] = (BYTE)vp[i].u.cVal; break; + case VT_I2: buf[i] = ((UINT)vp[i].u.iVal) & 0xff; break; + case VT_I4: buf[i] = ((ULONG)vp[i].u.lVal) & 0xff; break; + case VT_INT: buf[i] = ((UINT)vp[i].u.intVal) & 0xff; break; + case VT_UI1: buf[i] = vp[i].u.bVal; break; + case VT_UI2: buf[i] = vp[i].u.uiVal & 0xff; break; + case VT_UI4: buf[i] = vp[i].u.ulVal & 0xff; break; + case VT_UINT: buf[i] = vp[i].u.uintVal & 0xff; break; + default: + fprintf (stderr, "Invalid value in array as pos %d\n", i); + _gpgme_free (buf); + SafeArrayUnaccessData (array); + return E_INVALIDARG; + } + } + + for (i=0; i < len; i++) + fprintf (stderr, " %0X", buf[i] ); + putc ('\n', stderr); + + gpgme_data_release (*data); *data = NULL; + err = gpgme_data_new_from_mem (data, buf, len, 0); + SafeArrayUnaccessData (array); + if (given_as_bstr) + *given_as_bstr = 0; + } + else { + fprintf (stderr, "Got a variant type = %d (0x%x)\n", + (int)val.vt, (int)val.vt ); + return E_INVALIDARG; /* not a safearray of bytes */ + } + return map_gpgme_error (err); +} + + +static HRESULT WINAPI +set_data_to_variant (GpgmeData data, VARIANT *retval, int use_bstr) +{ + GpgmeError err; + HRESULT hr; + SAFEARRAY *array; + char *p; + size_t nread, len; + int i; + + /* Get some info on the data */ + err = gpgme_data_rewind (data); + if (err ) { + fprintf (stderr, "*** gpgme_data_rewind failed: %d\n", err); + return map_gpgme_error (err); + } + err = gpgme_data_read (data, NULL, 0, &nread); + if (err && err != GPGME_EOF ) { + fprintf (stderr, "*** gpgme_data_read [length] failed: %d\n", err); + return map_gpgme_error (err); + } + len = nread; /*(eof returns a length of 0)*/ + fprintf (stderr,"*** %d bytes are availabe\n", (int)len); + + /* convert it to the target data type */ + if (use_bstr) { + BSTR bs; + unsigned char *helpbuf; + + fprintf (stderr," using BSTR\n"); + /* It is easier to allocate some helper storage */ + helpbuf = _gpgme_malloc (len); + if (!helpbuf) + return E_OUTOFMEMORY; + err = gpgme_data_read (data, helpbuf, len, &nread); + if (err ) { + _gpgme_free (helpbuf); + fprintf (stderr, "*** gpgme_data_read [data] failed: %d\n", err); + return map_gpgme_error (err); + } + + bs = SysAllocStringLen (NULL, len+1); + if (!bs) { + _gpgme_free (helpbuf); + return E_OUTOFMEMORY; + } + + for (i=0, p=helpbuf; i < len; i++, p++) + bs[i] = *p; + bs[i] = 0; + _gpgme_free (helpbuf); + + /* Ready */ + VariantInit (retval); + retval->vt = VT_BSTR; + retval->u.bstrVal = bs; + } +#if 0 + else if (use_byte_array) { + array = SafeArrayCreateVector (VT_UI1, 0, len); + if (!array) + return E_OUTOFMEMORY; + + p = NULL; + hr = SafeArrayAccessData (array, (void**)&p); + if (hr) { + fprintf (stderr,"*** SafeArrayAccessData failed: hr=%lx\n", hr); + SafeArrayDestroyData (array); + SafeArrayDestroy (array); + return hr; + } + if (len) { + err = gpgme_data_read (data, p, len, &nread); + if (err ) { + SafeArrayUnaccessData (array); + SafeArrayDestroyData (array); + SafeArrayDestroy (array); + fprintf (stderr, "*** gpgme_data_read [data] failed: %d\n", + err); + return map_gpgme_error (err); + } + } + SafeArrayUnaccessData (array); + + /* pass the data to the caller */ + VariantInit (retval); + retval->vt = (VT_ARRAY|VT_UI1); + retval->u.parray = array; + } +#endif + else { /* Create an array of variants of bytes */ + VARIANT *v; + unsigned char *helpbuf; + + /* It is easier to allocate some helper storage */ + helpbuf = _gpgme_malloc (len); + if (!helpbuf) + return E_OUTOFMEMORY; + err = gpgme_data_read (data, helpbuf, len, &nread); + if (err ) { + _gpgme_free (helpbuf); + fprintf (stderr, "*** gpgme_data_read [data] failed: %d\n", err); + return map_gpgme_error (err); + } + + /* The create the array */ + array = SafeArrayCreateVector (VT_VARIANT, 0, len); + if (!array) { + _gpgme_free (helpbuf); + return E_OUTOFMEMORY; + } + + v = NULL; + hr = SafeArrayAccessData (array, (void**)&v); + if (hr) { + fprintf (stderr,"*** SafeArrayAccessData failed: hr=%lx\n", hr); + _gpgme_free (helpbuf); + SafeArrayDestroyData (array); + SafeArrayDestroy (array); + return hr; + } + + for (p=helpbuf; len; len--, v++) { + VariantInit (v); + v->vt = VT_UI1; + v->u.bVal = *p; + } + SafeArrayUnaccessData (array); + _gpgme_free (helpbuf); + + /* pass the data to the caller */ + VariantInit (retval); + retval->vt = (VT_ARRAY|VT_VARIANT); + retval->u.parray = array; + } + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_SetPlaintext (IGpgme *iface, VARIANT val) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + return set_data_from_variant (&This->plaintext, val, + &This->plaintext_given_as_bstr); +} + + +static HRESULT WINAPI +m_IGpgme_GetPlaintext (IGpgme *iface, VARIANT *retval) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + return set_data_to_variant (This->plaintext, retval, + This->plaintext_given_as_bstr); +} + +static HRESULT WINAPI +m_IGpgme_SetCiphertext (IGpgme *iface, VARIANT val) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + return set_data_from_variant (&This->ciphertext, val, NULL); +} + +static HRESULT WINAPI +m_IGpgme_GetCiphertext (IGpgme *iface, VARIANT *retval) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + return set_data_to_variant (This->ciphertext, retval, + This->ciphertext_is_armored); +} + +static HRESULT WINAPI +m_IGpgme_ClearRecipients (IGpgme *iface) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + gpgme_recipients_release (This->rset); This->rset = NULL; + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_AddRecipient (IGpgme *iface, BSTR name, signed short int trust) +{ + GpgmeError err; + int n; + char *p; + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p, %d)\n", This, (int)trust); + if (!This->rset) { + err = gpgme_recipients_new (&This->rset); + if (err) + return map_gpgme_error (err); + } + + n = bstrtoutf8 (name, NULL, 0); + p = HeapAlloc (GetProcessHeap(), 0, n ); + if (!p) { + fprintf (stderr,"HeapAlloc failed: ec=%d\n", (int)GetLastError () ); + return E_OUTOFMEMORY; + } + if (bstrtoutf8 (name, p, n) < 0) { + fprintf (stderr,"problem with bstrtoutf8\n"); + HeapFree (GetProcessHeap(), 0, p); + return E_FAIL; + } + fprintf (stderr,"*** adding name `%s'\n", p); + err = gpgme_recipients_add_name (This->rset, p); + HeapFree (GetProcessHeap(), 0, p); + return map_gpgme_error (err); +} + +static HRESULT WINAPI +m_IGpgme_ResetSignKeys (IGpgme *iface) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_IGpgme_AddSignKey (IGpgme *iface, BSTR name) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_IGpgme_Encrypt (IGpgme *iface) +{ + GpgmeError err; + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + gpgme_data_release (This->ciphertext); + err = gpgme_data_new (&This->ciphertext); + if (err) + return map_gpgme_error (err); + + + This->ciphertext_is_armored = gpgme_get_armor (This->mainctx); + err = gpgme_op_encrypt (This->mainctx, This->rset, + This->plaintext, This->ciphertext); +#if 0 + if (!err ) { + char buf[100]; + size_t nread; + + err = gpgme_data_rewind ( This->ciphertext ); + if (err ) + fprintf (stderr, "*** gpgme_data_rewind failed: %d\n", err); + while ( !(err = gpgme_data_read ( This->ciphertext, + buf, 100, &nread )) ) { + fwrite ( buf, nread, 1, stderr ); + } + if (err != GPGME_EOF) + fprintf (stderr, "*** gpgme_data_read failed: %d\n", err); + err = 0; + } +#endif + + return map_gpgme_error (err); +} + +static HRESULT WINAPI +m_IGpgme_Sign (IGpgme *iface, short int signmode) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_IGpgme_SignEncrypt (IGpgme *iface, short int signmode) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + + return E_NOTIMPL; +} + +#if 0 +static HRESULT WINAPI +m_IGpgme_SetKeylistMode( GpgmeCtx c, BOOL mode ) +{ + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_SetPassphraseCB (GpgmeCtx c, + GpgmePassphraseCb cb, void *cb_value) +{ + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_SetProgressCB (GpgmeCtx c, GpgmeProgressCb cb, void *cb_value) +{ + return E_NOTIMPL; +} + + +static HRESULT WINAPI +m_IGpgme_SignersClear (GpgmeCtx c) +{ + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_SignersAdd (GpgmeCtx c, const GpgmeKey key) +{ + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_SignersEnum (const GpgmeCtx c, int seq) +{ + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_GetSigStatus(GpgmeCtx c, int idx, + GpgmeSigStat *r_stat, time_t *r_created ); +{ + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_GetSigKey (GpgmeCtx c, int idx, GpgmeKey *r_key); +{ + return 0; +} + +static HRESULT WINAPI +m_IGpgme_GetNotation(IGpgme *c, BSTR *retval) +{ + return 0; +} +#endif + + +static ICOM_VTABLE(IGpgme) igpgme_vtbl = +{ + /* IUnknown methods */ + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + m_IGpgme_QueryInterface, + m_IGpgme_AddRef, + m_IGpgme_Release, + /* IDispatch methods */ + m_stub_IDispatch_GetTypeInfoCount, + m_stub_IDispatch_GetTypeInfo, + m_stub_IDispatch_GetIDsOfNames, + m_stub_IDispatch_Invoke, + /* Our methods */ + m_IGpgme_GetVersion, + m_IGpgme_GetEngineInfo, + m_IGpgme_Cancel, + m_IGpgme_SetArmor, + m_IGpgme_GetArmor, + m_IGpgme_SetTextmode, + m_IGpgme_GetTextmode, + m_IGpgme_SetPlaintext, + m_IGpgme_GetPlaintext, + m_IGpgme_SetCiphertext, + m_IGpgme_GetCiphertext, + m_IGpgme_ClearRecipients, + m_IGpgme_AddRecipient, + m_IGpgme_ResetSignKeys, + m_IGpgme_AddSignKey, + m_IGpgme_Encrypt, + m_IGpgme_Sign, + m_IGpgme_SignEncrypt, +/* m_IGpgme_SetKeylistMode, + * m_IGpgme_SetPassphraseCB, + * m_IGpgme_SetProgressCB, + * m_IGpgme_SignersClear, + * m_IGpgme_SignersAdd, + * m_IGpgme_SignersEnum, + * m_IGpgme_GetSigStatus, + * m_IGpgme_GetSigKey, + * m_IGpgme_GetNotation + */ +}; + + + +/*************************************************************** + ****************** Gpgme Factory **************************** + ***************************************************************/ + +static HRESULT WINAPI +m_GpgmeFactory_QueryInterface (IClassFactory *iface, + REFIID refiid, LPVOID *obj) +{ + ICOM_THIS (IClassFactoryImpl,iface); + + /*fprintf (stderr,"*** m_GpgmeFactory_QueryInterface(%p,%s)", + This, debugstr_guid(refiid));*/ + if ( IsEqualGUID (&IID_IUnknown, refiid) + || IsEqualGUID (&IID_IClassFactory, refiid) ) { + *obj = This; + /*fprintf (stderr," -> got %p\n", obj);*/ + return 0; + } + *obj = NULL; + /*fprintf (stderr," -> none\n");*/ + return E_NOINTERFACE; +} + +static ULONG WINAPI +m_GpgmeFactory_AddRef (IClassFactory *iface) +{ + ICOM_THIS(IClassFactoryImpl,iface); + return ++(This->ref); +} + +static ULONG WINAPI +m_GpgmeFactory_Release (IClassFactory *iface) +{ + ICOM_THIS(IClassFactoryImpl,iface); + return --(This->ref); +} + +static HRESULT WINAPI +m_GpgmeFactory_CreateInstance (IClassFactory *iface, IUnknown *outer, + REFIID refiid, LPVOID *r_obj ) +{ + /*ICOM_THIS(IClassFactoryImpl,iface);*/ + + fprintf (stderr,"*** m_GpgmeFactory_CreateInstance(%s)", + debugstr_guid(refiid) ); + if ( IsEqualGUID (&IID_IUnknown, refiid) + || IsEqualGUID (&IID_IGpgme, refiid) ) { + IGpgmeImpl *obj; + GpgmeCtx ctx; + GpgmeError err; + + + err = gpgme_new (&ctx); + if (err) { + fprintf (stderr," -> gpgme_new failed: %s\n", gpgme_strerror (err)); + return E_OUTOFMEMORY; + } + + obj = HeapAlloc (GetProcessHeap(), 0, sizeof *obj ); + if ( !obj) { + fprintf (stderr," -> out of core\n"); + gpgme_release (ctx); + return E_OUTOFMEMORY; + } + memset (obj, 0, sizeof *obj); + + ICOM_VTBL(obj) = &igpgme_vtbl; + obj->ref = 1; + obj->mainctx = ctx; + { /* Fixme: need to release some stuff on error */ + HRESULT hr; + ITypeLib *pTypeLib; + + hr = LoadRegTypeLib (&TLBID_Gpgcom, 1, 0, LANG_NEUTRAL, &pTypeLib); + if (hr) { + fprintf (stderr," -> LoadRegTypeLib failed: %lx\n", hr); + return hr; + } + hr = ITypeLib_GetTypeInfoOfGuid (pTypeLib, &IID_IGpgme, + &obj->std_disp.tinfo); + ITypeLib_Release (pTypeLib); + if (hr) { + fprintf (stderr," -> GetTypeInfoOfGuid failed: %lx\n", hr); + return hr; + } + hr = CreateStdDispatch ((IUnknown*)obj, obj, obj->std_disp.tinfo, + &obj->std_disp.disp); + if (hr) { + fprintf (stderr," -> CreateStdDispatch failed: %lx\n", hr); + return hr; + } + } + + *r_obj = obj; + fprintf (stderr," -> created %p\n", obj ); + return 0; + } + fprintf (stderr," -> no interface\n" ); + *r_obj = NULL; + return E_NOINTERFACE; +} + +static HRESULT WINAPI +m_GpgmeFactory_LockServer (IClassFactory *iface, BOOL dolock ) +{ + /*ICOM_THIS(IClassFactoryImpl,iface);*/ + return 0; +} + +static ICOM_VTABLE(IClassFactory) igpgme_factory_vtbl = { + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + m_GpgmeFactory_QueryInterface, + m_GpgmeFactory_AddRef, + m_GpgmeFactory_Release, + m_GpgmeFactory_CreateInstance, + m_GpgmeFactory_LockServer +}; +static IClassFactoryImpl igpgme_CF = {&igpgme_factory_vtbl, 1 }; + + +IClassFactory * +igpgme_factory_new ( CLSID *r_clsid ) +{ + *r_clsid = CLSID_Gpgme; + IClassFactory_AddRef((IClassFactory*)&igpgme_CF); + return (IClassFactory*)&igpgme_CF; +} + +void +igpgme_factory_release ( IClassFactory *factory ) +{ + /* it's static - nothing to do */ +} diff --git a/complus/igpgme.h b/complus/igpgme.h new file mode 100644 index 0000000..35ce91d --- /dev/null +++ b/complus/igpgme.h @@ -0,0 +1,162 @@ +/* igpgme.h - COM+ class IGpgme + * Copyright (C) 2001 g10 Code GmbH + * + * This file is part of GPGME. + * + * GPGME 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 2 of the License, or + * (at your option) any later version. + * + * GPGME 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef IGPGME_H +#define IGPGME_H 1 + +#include + +DEFINE_GUID(CLSID_Gpgme, 0x3811fd40, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +#if 0 +DEFINE_GUID(CLSID_GpgmeData, 0x3811fd41, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +DEFINE_GUID(CLSID_GpgmeKey, 0x3811fd42, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +DEFINE_GUID(CLSID_GpgmeRSet, 0x3811fd43, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +#endif + +DEFINE_GUID(TLBID_Gpgcom, 0x3811fd48, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +DEFINE_GUID(APPID_Gpgcom, 0x3811fd4f, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); + + +DEFINE_GUID(IID_IGpgme, 0x3811fd50, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); + +typedef struct IGpgme IGpgme; + +IClassFactory *igpgme_factory_new( CLSID *r_clsid ); +void igpgme_factory_release ( IClassFactory *factory ); + + +/******************************************** + ***** The IGpgme interface ***************** + ********************************************/ + +#define ICOM_INTERFACE IGpgme + +#define IGpgme_METHODS \ + ICOM_METHOD1(HRESULT,GetVersion, BSTR*,) \ + ICOM_METHOD1(HRESULT,GetEngineInfo, BSTR*,) \ + ICOM_METHOD(HRESULT,Cancel) \ + ICOM_METHOD1(HRESULT,SetArmor,BOOL,) \ + ICOM_METHOD1(HRESULT,GetArmor,BOOL*,) \ + ICOM_METHOD1(HRESULT,SetTextmode,BOOL,) \ + ICOM_METHOD1(HRESULT,GetTextmode,BOOL*,) \ + ICOM_METHOD1(HRESULT,SetPlaintext,VARIANT,) \ + ICOM_METHOD1(HRESULT,GetPlaintext,VARIANT*,) \ + ICOM_METHOD1(HRESULT,SetCiphertext,VARIANT,) \ + ICOM_METHOD1(HRESULT,GetCiphertext,VARIANT*,) \ + ICOM_METHOD(HRESULT,ClearRecipients) \ + ICOM_METHOD2(HRESULT,AddRecipient,BSTR,,signed short int,) \ + ICOM_METHOD(HRESULT,ResetSignKeys) \ + ICOM_METHOD1(HRESULT,AddSignKey,BSTR,) \ + ICOM_METHOD(HRESULT,Encrypt) \ + ICOM_METHOD1(HRESULT,Sign,signed short int,) \ + ICOM_METHOD1(HRESULT,SignEncrypt,signed short int,) + +#if 0 + ICOM_METHOD1(HRESULT,SetKeylistMode,) + ICOM_METHOD1(HRESULT,SetPassphraseCB,) + ICOM_METHOD1(HRESULT,SetProgressCB,) + ICOM_METHOD1(HRESULT,SignersClear,) + ICOM_METHOD1(HRESULT,SignersAdd,) + ICOM_METHOD1(HRESULT,SignersEnum,) + ICOM_METHOD1(HRESULT,GetSigStatus,) + ICOM_METHOD1(HRESULT,GetNotation,) +#endif + +#define IGpgme_IMETHODS \ + IDispatch_IMETHODS \ + IGpgme_METHODS + +ICOM_DEFINE(IGpgme,IDispatch) +#undef ICOM_INTERFACE + + +/*** IUnknown methods ***/ +#define IGpgme_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) +#define IGpgme_AddRef(p) ICOM_CALL (AddRef,p) +#define IGpgme_Release(p) ICOM_CALL (Release,p) +/*** IGpgme methods ***/ +#define IGpgme_GetVersion(p,r) ICOM_CALL1(GetVersion,p,r) +#define IGpgme_GetEngineInfo(p,r) ICOM_CALL1(GetEngineInfo,p,r) +#define IGpgme_Cancel(p,a) ICOM_CALL1(Cancel,p,a) +#define IGpgme_SetArmor(p,a) ICOM_CALL1(SetArmor,p,a) +#define IGpgme_GetArmor(p,a) ICOM_CALL1(GetArmor,p,a) +#define IGpgme_SetTextmode(p,a) ICOM_CALL1(SetTextmode,p,a) +#define IGpgme_GetTextmode(p,a) ICOM_CALL1(GetTextmode,p,a) +#define IGpgme_SetPlaintext(p,a) ICOM_CALL1(SetPlaintext,p,a) +#define IGpgme_GetPlaintext(p,a) ICOM_CALL1(GetPlaintext,p,a) +#define IGpgme_SetCiphertext(p,a) ICOM_CALL1(SetCiphertext,p,a) +#define IGpgme_GetCiphertext(p,a) ICOM_CALL1(GetCiphertext,p,a) +#define IGpgme_ClearRecipients(p) ICOM_CALL (ClearRecipients,p) +#define IGpgme_AddRecipient(p,a,b) ICOM_CALL2(AddRecipient,p,a,b) +#define IGpgme_ResetSignKeys(p) ICOM_CALL (ResetSignKeys,p) +#define IGpgme_AddSignKey(p,a) ICOM_CALL (AddSignKey,p,a) +#define IGpgme_Encrypt(p) ICOM_CALL (Encrypt,p) +#define IGpgme_Sign(p,a) ICOM_CALL (Sign,p,a) +#define IGpgme_SignEncrypt(p,a) ICOM_CALL (SignEncrypt,p,a) +#if 0 +#define IGpgme_SetKeylistMode(p,a) ICOM_CALL1(SetKeylistMode,p,a) +#define IGpgme_SetPassphraseCB(p,a) ICOM_CALL1(SetPassphraseCB,p,a) +#define IGpgme_SetProgressCB(p,a) ICOM_CALL1(SetProgressCB,p,a) +#define IGpgme_SignersClear(p,a) ICOM_CALL1(SignersClear,p,a) +#define IGpgme_SignersAdd(p,a) ICOM_CALL1(SignersAdd,p,a) +#define IGpgme_SignersEnum(p,a) ICOM_CALL1(SignersEnum,p,a) +#define IGpgme_GetSigStatus(p,a) ICOM_CALL1(GetSigStatus,p,a) +#define IGpgme_GetSigKey(p,a) ICOM_CALL1(GetSigKey,p,a) +#define IGpgme_GetNotation(p,a) ICOM_CALL1(GetNotation,p,a) +#endif + + +#if 0 +/******************************************** + ***** The IGpgmeKey interface ************** + ********************************************/ + +#define ICOM_INTERFACE IGpgmeKey + +#define IGpgmeKey_METHODS \ + ICOM_METHOD1(HRESULT,GetVersion, BSTR,) \ + ICOM_METHOD1(HRESULT,GetEngineInfo, BSTR,) + + +#define IGpgmeKey_IMETHODS \ + IUnknown_IMETHODS \ + IGpgmeKey_METHODS + +ICOM_DEFINE(IGpgmeKey,IUnknown) +#undef ICOM_INTERFACE + +/*** IUnknown methods ***/ +#define IGpgmeKey_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) +#define IGpgmeKey_AddRef(p) ICOM_CALL (AddRef,p) +#define IGpgmeKey_Release(p) ICOM_CALL (Release,p) +/*** IGpgmeKey methods ***/ +#define IGpgmeKey_GetVersion(p,r) ICOM_CALL1(GetVersion,p,r) +#define IGpgmeKey_GetEngineInfo(p,r) ICOM_CALL1(GetEngineInfo,p,r) +#endif + +#endif /*IGPGME_H*/ + diff --git a/complus/main.c b/complus/main.c deleted file mode 100644 index 519d2bc..0000000 --- a/complus/main.c +++ /dev/null @@ -1,285 +0,0 @@ -/* main.c - COM+ component to access GnuPG - * Copyright (C) 2000 Werner Koch (dd9jn) - * - * This file is part of GPGME. - * - * GPGME 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 2 of the License, or - * (at your option) any later version. - * - * GPGME 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "obj_base.h" - -#include "argparse.h" - -#include "main.h" - - -static void register_server (void); -static void unregister_server (void); -static void enter_complus (void); - - -enum cmd_and_opt_values { aNull = 0, - oQuiet = 'q', - oVerbose = 'v', - - oNoVerbose = 500, - oOptions, - oDebug, - oDebugAll, - oNoGreeting, - oNoOptions, - oHomedir, - oGPGBinary, - oRegServer, - oUnregServer, - oEmbedding, -aTest }; - - -static ARGPARSE_OPTS opts[] = { - - { 301, NULL, 0, N_("@Options:\n ") }, - - { oVerbose, "verbose", 0, N_("verbose") }, - { oQuiet, "quiet", 0, N_("be somewhat more quiet") }, - { oOptions, "options" , 2, N_("read options from file")}, - { oDebug, "debug" ,4|16, N_("set debugging flags")}, - { oDebugAll, "debug-all" ,0, N_("enable full debugging")}, - { oGPGBinary, "gpg-program", 2 , "@" }, - { oRegServer, "RegServer" , 0, "@" }, - { oUnregServer, "UnregServer" , 0, "@" }, - { oEmbedding, "Embedding" , 0, "@" }, -{0} }; - - - - -static const char * -my_strusage( int level ) -{ - const char *p; - switch( level ) { - case 11: p = "gpgme"; - break; - case 13: p = VERSION; break; - /*case 17: p = PRINTABLE_OS_NAME; break;*/ - case 19: p = - _("Please report bugs to .\n"); - break; - case 1: - case 40: p = - _("Usage: gpgme [options] (-h for help)"); - break; - case 41: p = - _("Syntax: gpgme [options]\n" - "GnuPG COM+ component\n"); - break; - - default: p = NULL; - } - return p; -} - - -int -main (int argc, char **argv ) -{ - ARGPARSE_ARGS pargs; - int orig_argc; - char **orig_argv; - FILE *configfp = NULL; - char *configname = NULL; - unsigned configlineno; - int parse_debug = 0; - int default_config =1; - int greeting = 0; - int nogreeting = 0; - int action = 0; - - set_strusage( my_strusage ); - /*log_set_name ("gpa"); not yet implemented in logging.c */ - - opt.homedir = getenv("GNUPGHOME"); - if( !opt.homedir || !*opt.homedir ) { - #ifdef HAVE_DRIVE_LETTERS - opt.homedir = "c:/gnupg"; - #else - opt.homedir = "~/.gnupg"; - #endif - } - - /* check whether we have a config file on the commandline */ - orig_argc = argc; - orig_argv = argv; - pargs.argc = &argc; - pargs.argv = &argv; - pargs.flags= 1|(1<<6); /* do not remove the args, ignore version */ - while( arg_parse( &pargs, opts) ) { - if( pargs.r_opt == oDebug || pargs.r_opt == oDebugAll ) - parse_debug++; - else if( pargs.r_opt == oOptions ) { - /* yes there is one, so we do not try the default one, but - * read the option file when it is encountered at the commandline - */ - default_config = 0; - } - else if( pargs.r_opt == oNoOptions ) - default_config = 0; /* --no-options */ - else if( pargs.r_opt == oHomedir ) - opt.homedir = pargs.r.ret_str; - } - - if( default_config ) - configname = make_filename(opt.homedir, "gpgme.conf", NULL ); - - - argc = orig_argc; - argv = orig_argv; - pargs.argc = &argc; - pargs.argv = &argv; - pargs.flags= 1 | (1<<5); /* do not remove the args, allow one dash */ - next_pass: - if( configname ) { - configlineno = 0; - configfp = fopen( configname, "r" ); - if( !configfp ) { - if( default_config ) { - if( parse_debug ) - log_info(_("NOTE: no default option file `%s'\n"), - configname ); - } - else { - log_error(_("option file `%s': %s\n"), - configname, strerror(errno) ); - exit(2); - } - free(configname); configname = NULL; - } - if( parse_debug && configname ) - log_info(_("reading options from `%s'\n"), configname ); - default_config = 0; - } - - while( optfile_parse( configfp, configname, &configlineno, - &pargs, opts) ) { - switch( pargs.r_opt ) { - case oQuiet: opt.quiet = 1; break; - case oVerbose: opt.verbose++; break; - - case oDebug: opt.debug |= pargs.r.ret_ulong; break; - case oDebugAll: opt.debug = ~0; break; - - case oOptions: - /* config files may not be nested (silently ignore them) */ - if( !configfp ) { - free(configname); - configname = xstrdup(pargs.r.ret_str); - goto next_pass; - } - break; - case oNoGreeting: nogreeting = 1; break; - case oNoVerbose: opt.verbose = 0; break; - case oNoOptions: break; /* no-options */ - case oHomedir: opt.homedir = pargs.r.ret_str; break; - case oGPGBinary: break; - - case oRegServer: action = 1; break; - case oUnregServer: action = 2; break; - case oEmbedding: action = 3; break; - - default : pargs.err = configfp? 1:2; break; - } - } - if( configfp ) { - fclose( configfp ); - configfp = NULL; - free(configname); configname = NULL; - goto next_pass; - } - free( configname ); configname = NULL; - if( log_get_errorcount(0) ) - exit(2); - if( nogreeting ) - greeting = 0; - - if( greeting ) { - fprintf(stderr, "%s %s; %s\n", - strusage(11), strusage(13), strusage(14) ); - fprintf(stderr, "%s\n", strusage(15) ); - } - #ifdef IS_DEVELOPMENT_VERSION - log_info("NOTE: this is a development version!\n"); - #endif - - if ( action == 1 ) - register_server (); - else if (action == 2 ) - unregister_server (); - else if (action == 3 ) - enter_complus (); - else { - fprintf (stderr, "This is a COM+ component with no user interface.\n" - "gpgme --help will give you a list of options\n" ); - exit (1); - } - - return 0; -} - -static void -register_server () -{ -} - -static void -unregister_server () -{ -} - -static void -enter_complus () -{ - HANDLE running; - int reg; - IClassFactory *factory; - CLSID clsid; - - CoInitializeEx (NULL, COINIT_MULTITHREADED); - running = CreateEvent (NULL, FALSE, FALSE, NULL ); - - factory = gnupg_factory_new ( &clsid ); - CoRegisterClassObject (&clsid, (IUnknown*)factory, - CLSCTX_LOCAL_SERVER, - REGCLS_SUSPENDED|REGCLS_MULTIPLEUSE, ® ); - CoResumeClassObjects (); - - WaitForSingleObject ( running, INFINITE ); - CloseHandle (running); - CoRevokeClassObject ( reg ); - gnupg_factory_release (factory); - CoUninitialize (); -} - - diff --git a/complus/main.h b/complus/main.h index 472b8cd..7e48ad4 100644 --- a/complus/main.h +++ b/complus/main.h @@ -38,11 +38,6 @@ struct { } opt; -/*-- ignupg.c --*/ -IClassFactory *gnupg_factory_new ( CLSID *r_clsid ); -void gnupg_factory_release ( IClassFactory *factory ); - - #endif /* COMPLUS_MAIN_H */ diff --git a/complus/obj_base.h b/complus/obj_base.h deleted file mode 100644 index 8707ae9..0000000 --- a/complus/obj_base.h +++ /dev/null @@ -1,800 +0,0 @@ -/* obj_base.h - This file defines the macros and types necessary to - define COM interfaces, and the three most basic COM interfaces: - IUnknown, IMalloc and IClassFactory. - - Copyright (c) 1993-2000 the Wine project authors (see the file WINE-AUTHORS - for a complete list) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __WINE_WINE_OBJ_BASE_H -#define __WINE_WINE_OBJ_BASE_H - -/* check these values! */ -#define E_NOINTERFACE 0x80040002 -#define E_OUTOFMEMORY 0x8007000E - -/***************************************************************************** - * define ICOM_MSVTABLE_COMPAT - * to implement the microsoft com vtable compatibility workaround for g++. - * - * NOTE: Turning this option on will produce a winelib that is incompatible - * with the binary emulator. - * - * If the compiler supports the com_interface attribute, leave this off, and - * define the ICOM_USE_COM_INTERFACE_ATTRIBUTE macro below. This may also - * require the addition of the -vtable-thunks option for g++. - * - * If you aren't interested in Winelib C++ compatibility at all, leave both - * options off. - * - * The preferable method for using ICOM_USE_COM_INTERFACE_ATTRIBUTE macro - * would be to define it only for your Winelib application. This allows you - * to have both binary and Winelib compatibility for C and C++ at the same - * time :) - */ -/* #define ICOM_MSVTABLE_COMPAT 1 */ -/* #define ICOM_USE_COM_INTERFACE_ATTRIBUTE 1 */ - -/***************************************************************************** - * Defines the basic types - */ -#include "wtypes.h" -#include "guiddef.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifndef NONAMELESSSTRUCT -#define LISet32(li, v) ((li).HighPart = (v) < 0 ? -1 : 0, (li).LowPart = (v)) -#define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v)) -#else -#define LISet32(li, v) ((li).s.HighPart = (v) < 0 ? -1 : 0, (li).s.LowPart = (v)) -#define ULISet32(li, v) ((li).s.HighPart = 0, (li).s.LowPart = (v)) -#endif - -/***************************************************************************** - * GUID API - */ -HRESULT WINAPI StringFromCLSID16(REFCLSID id, LPOLESTR16*); -HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR*); - -HRESULT WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *); -HRESULT WINAPI CLSIDFromString(LPCOLESTR, CLSID *); - -HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid); -HRESULT WINAPI CLSIDFromProgID(LPCOLESTR progid, LPCLSID riid); - -HRESULT WINAPI ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *lplpszProgID); - - -INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax); - - -/***************************************************************************** - * Macros to define a COM interface - */ -/* - * The goal of the following set of definitions is to provide a way to use the same - * header file definitions to provide both a C interface and a C++ object oriented - * interface to COM interfaces. The type of interface is selected automatically - * depending on the language but it is always possible to get the C interface in C++ - * by defining CINTERFACE. - * - * It is based on the following assumptions: - * - all COM interfaces derive from IUnknown, this should not be a problem. - * - the header file only defines the interface, the actual fields are defined - * separately in the C file implementing the interface. - * - * The natural approach to this problem would be to make sure we get a C++ class and - * virtual methods in C++ and a structure with a table of pointer to functions in C. - * Unfortunately the layout of the virtual table is compiler specific, the layout of - * g++ virtual tables is not the same as that of an egcs virtual table which is not the - * same as that generated by Visual C+. There are workarounds to make the virtual tables - * compatible via padding but unfortunately the one which is imposed to the WINE emulator - * by the Windows binaries, i.e. the Visual C++ one, is the most compact of all. - * - * So the solution I finally adopted does not use virtual tables. Instead I use inline - * non virtual methods that dereference the method pointer themselves and perform the call. - * - * Let's take Direct3D as an example: - * - * #define ICOM_INTERFACE IDirect3D - * #define IDirect3D_METHODS \ - * ICOM_METHOD1(HRESULT,Initialize, REFIID,) \ - * ICOM_METHOD2(HRESULT,EnumDevices, LPD3DENUMDEVICESCALLBACK,, LPVOID,) \ - * ICOM_METHOD2(HRESULT,CreateLight, LPDIRECT3DLIGHT*,, IUnknown*,) \ - * ICOM_METHOD2(HRESULT,CreateMaterial,LPDIRECT3DMATERIAL*,, IUnknown*,) \ - * ICOM_METHOD2(HRESULT,CreateViewport,LPDIRECT3DVIEWPORT*,, IUnknown*,) \ - * ICOM_METHOD2(HRESULT,FindDevice, LPD3DFINDDEVICESEARCH,, LPD3DFINDDEVICERESULT,) - * #define IDirect3D_IMETHODS \ - * IUnknown_IMETHODS \ - * IDirect3D_METHODS - * ICOM_DEFINE(IDirect3D,IUnknown) - * #undef ICOM_INTERFACE - * - * #ifdef ICOM_CINTERFACE - * // *** IUnknown methods *** // - * #define IDirect3D_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) - * #define IDirect3D_AddRef(p) ICOM_CALL (AddRef,p) - * #define IDirect3D_Release(p) ICOM_CALL (Release,p) - * // *** IDirect3D methods *** // - * #define IDirect3D_Initialize(p,a) ICOM_CALL1(Initialize,p,a) - * #define IDirect3D_EnumDevices(p,a,b) ICOM_CALL2(EnumDevice,p,a,b) - * #define IDirect3D_CreateLight(p,a,b) ICOM_CALL2(CreateLight,p,a,b) - * #define IDirect3D_CreateMaterial(p,a,b) ICOM_CALL2(CreateMaterial,p,a,b) - * #define IDirect3D_CreateViewport(p,a,b) ICOM_CALL2(CreateViewport,p,a,b) - * #define IDirect3D_FindDevice(p,a,b) ICOM_CALL2(FindDevice,p,a,b) - * #endif - * - * Comments: - * - The ICOM_INTERFACE macro is used in the ICOM_METHOD macros to define the type of the 'this' - * pointer. Defining this macro here saves us the trouble of having to repeat the interface - * name everywhere. Note however that because of the way macros work, a macro like ICOM_METHOD1 - * cannot use 'ICOM_INTERFACE##_VTABLE' because this would give 'ICOM_INTERFACE_VTABLE' and not - * 'IDirect3D_VTABLE'. - * - ICOM_METHODS defines the methods specific to this interface. It is then aggregated with the - * inherited methods to form ICOM_IMETHODS. - * - ICOM_IMETHODS defines the list of methods that are inheritable from this interface. It must - * be written manually (rather than using a macro to generate the equivalent code) to avoid - * macro recursion (which compilers don't like). - * - The ICOM_DEFINE finally declares all the structures necessary for the interface. We have to - * explicitly use the interface name for macro expansion reasons again. - * Inherited methods are inherited in C by using the IDirect3D_METHODS macro and the parent's - * Xxx_IMETHODS macro. In C++ we need only use the IDirect3D_METHODS since method inheritance - * is taken care of by the language. - * - In C++ the ICOM_METHOD macros generate a function prototype and a call to a function pointer - * method. This means using once 't1 p1, t2 p2, ...' and once 'p1, p2' without the types. The - * only way I found to handle this is to have one ICOM_METHOD macro per number of parameters and - * to have it take only the type information (with const if necessary) as parameters. - * The 'undef ICOM_INTERFACE' is here to remind you that using ICOM_INTERFACE in the following - * macros will not work. This time it's because the ICOM_CALL macro expansion is done only once - * the 'IDirect3D_Xxx' macro is expanded. And by that time ICOM_INTERFACE will be long gone - * anyway. - * - You may have noticed the double commas after each parameter type. This allows you to put the - * name of that parameter which I think is good for documentation. It is not required and since - * I did not know what to put there for this example (I could only find doc about IDirect3D2), - * I left them blank. - * - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access - * to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate - * the inherited method definitions there. This time I could have used a trick to use only one - * macro whatever the number of parameters but I prefered to have it work the same way as above. - * - You probably have noticed that we don't define the fields we need to actually implement this - * interface: reference count, pointer to other resources and miscellaneous fields. That's - * because these interfaces are just that: interfaces. They may be implemented more than once, in - * different contexts and sometimes not even in Wine. Thus it would not make sense to impose - * that the interface contains some specific fields. - * - * - * In C this gives: - * typedef struct IDirect3DVtbl IDirect3DVtbl; - * struct IDirect3D { - * IDirect3DVtbl* lpVtbl; - * }; - * struct IDirect3DVtbl { - * HRESULT (*fnQueryInterface)(IDirect3D* me, REFIID riid, LPVOID* ppvObj); - * ULONG (*fnQueryInterface)(IDirect3D* me); - * ULONG (*fnQueryInterface)(IDirect3D* me); - * HRESULT (*fnInitialize)(IDirect3D* me, REFIID a); - * HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b); - * HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b); - * HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b); - * HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b); - * HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b); - * }; - * - * #ifdef ICOM_CINTERFACE - * // *** IUnknown methods *** // - * #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->fnQueryInterface(p,a,b) - * #define IDirect3D_AddRef(p) (p)->lpVtbl->fnAddRef(p) - * #define IDirect3D_Release(p) (p)->lpVtbl->fnRelease(p) - * // *** IDirect3D methods *** // - * #define IDirect3D_Initialize(p,a) (p)->lpVtbl->fnInitialize(p,a) - * #define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->fnEnumDevice(p,a,b) - * #define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->fnCreateLight(p,a,b) - * #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->fnCreateMaterial(p,a,b) - * #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->fnCreateViewport(p,a,b) - * #define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->fnFindDevice(p,a,b) - * #endif - * - * Comments: - * - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing - * the user needs to know to use the interface. Of course the structure we will define to - * implement this interface will have more fields but the first one will match this pointer. - * - The code generated by ICOM_DEFINE defines both the structure representing the interface and - * the structure for the jump table. ICOM_DEFINE uses the parent's Xxx_IMETHODS macro to - * automatically repeat the prototypes of all the inherited methods and then uses IDirect3D_METHODS - * to define the IDirect3D methods. - * - Each method is declared as a pointer to function field in the jump table. The implementation - * will fill this jump table with appropriate values, probably using a static variable, and - * initialize the lpVtbl field to point to this variable. - * - The IDirect3D_Xxx macros then just derefence the lpVtbl pointer and use the function pointer - * corresponding to the macro name. This emulates the behavior of a virtual table and should be - * just as fast. - * - This C code should be quite compatible with the Windows headers both for code that uses COM - * interfaces and for code implementing a COM interface. - * - * - * And in C++ (with gcc's g++): - * - * typedef struct IDirect3D: public IUnknown { - * private: HRESULT (*fnInitialize)(IDirect3D* me, REFIID a); - * public: inline HRESULT Initialize(REFIID a) { return ((IDirect3D*)t.lpVtbl)->fnInitialize(this,a); }; - * private: HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b); - * public: inline HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b) - * { return ((IDirect3D*)t.lpVtbl)->fnEnumDevices(this,a,b); }; - * private: HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b); - * public: inline HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b) - * { return ((IDirect3D*)t.lpVtbl)->fnCreateLight(this,a,b); }; - * private: HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b); - * public: inline HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b) - * { return ((IDirect3D*)t.lpVtbl)->fnCreateMaterial(this,a,b); }; - * private: HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b); - * public: inline HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b) - * { return ((IDirect3D*)t.lpVtbl)->fnCreateViewport(this,a,b); }; - * private: HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b); - * public: inline HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b) - * { return ((IDirect3D*)t.lpVtbl)->fnFindDevice(this,a,b); }; - * }; - * - * Comments: - * - In C++ IDirect3D does double duty as both the virtual/jump table and as the interface - * definition. The reason for this is to avoid having to duplicate the mehod definitions: once - * to have the function pointers in the jump table and once to have the methods in the interface - * class. Here one macro can generate both. This means though that the first pointer, t.lpVtbl - * defined in IUnknown, must be interpreted as the jump table pointer if we interpret the - * structure as the the interface class, and as the function pointer to the QueryInterface - * method, t.fnQueryInterface, if we interpret the structure as the jump table. Fortunately this - * gymnastic is entirely taken care of in the header of IUnknown. - * - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions. - * - Since IDirect3D does double duty, each ICOM_METHOD macro defines both a function pointer and - * a non-vritual inline method which dereferences it and calls it. This way this method behaves - * just like a virtual method but does not create a true C++ virtual table which would break the - * structure layout. If you look at the implementation of these methods you'll notice that they - * would not work for void functions. We have to return something and fortunately this seems to - * be what all the COM methods do (otherwise we would need another set of macros). - * - Note how the ICOM_METHOD generates both function prototypes mixing types and formal parameter - * names and the method invocation using only the formal parameter name. This is the reason why - * we need different macros to handle different numbers of parameters. - * - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE - * macro is defined in which case we would not be here. - * - This C++ code works well for code that just uses COM interfaces. But it will not work with - * C++ code implement a COM interface. That's because such code assumes the interface methods - * are declared as virtual C++ methods which is not the case here. - * - * - * Implementing a COM interface. - * - * This continues the above example. This example assumes that the implementation is in C. - * - * typedef struct _IDirect3D { - * void* lpVtbl; - * // ... - * - * } _IDirect3D; - * - * static ICOM_VTABLE(IDirect3D) d3dvt; - * - * // implement the IDirect3D methods here - * - * int IDirect3D_fnQueryInterface(IDirect3D* me) - * { - * ICOM_THIS(IDirect3D,me); - * // ... - * } - * - * // ... - * - * static ICOM_VTABLE(IDirect3D) d3dvt = { - * ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE - * IDirect3D_fnQueryInterface, - * IDirect3D_fnAdd, - * IDirect3D_fnAdd2, - * IDirect3D_fnInitialize, - * IDirect3D_fnSetWidth - * }; - * - * Comments: - * - We first define what the interface really contains. This is th e_IDirect3D structure. The - * first field must of course be the virtual table pointer. Everything else is free. - * - Then we predeclare our static virtual table variable, we will need its address in some - * methods to initialize the virtual table pointer of the returned interface objects. - * - Then we implement the interface methods. To match what has been declared in the header file - * they must take a pointer to a IDirect3D structure and we must cast it to an _IDirect3D so that - * we can manipulate the fields. This is performed by the ICOM_THIS macro. - * - Finally we initialize the virtual table. - */ - - -#define ICOM_VTABLE(iface) iface##Vtbl -#define ICOM_VFIELD(iface) ICOM_VTABLE(iface)* lpVtbl -#define ICOM_VTBL(iface) (iface)->lpVtbl - - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define ICOM_CINTERFACE 1 -#endif - -#ifndef ICOM_CINTERFACE -/* C++ interface */ - -#define ICOM_METHOD(ret,xfn) \ - public: virtual ret CALLBACK (xfn)(void) = 0; -#define ICOM_METHOD1(ret,xfn,ta,na) \ - public: virtual ret CALLBACK (xfn)(ta a) = 0; -#define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b) = 0; -#define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c) = 0; -#define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d) = 0; -#define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e) = 0; -#define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f) = 0; -#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) = 0; -#define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) = 0; -#define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i) = 0; -#define ICOM_METHOD10(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j) = 0; -#define ICOM_METHOD11(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \ - public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k) = 0; - - -#define ICOM_VMETHOD(xfn) \ - public: virtual void CALLBACK (xfn)(void) = 0; -#define ICOM_VMETHOD1(xfn,ta,na) \ - public: virtual void CALLBACK (xfn)(ta a) = 0; -#define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \ - public: virtual void CALLBACK (xfn)(ta a,tb b) = 0; -#define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \ - public: virtual void CALLBACK (xfn)(ta a,tb b,tc c) = 0; -#define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \ - public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d) = 0; -#define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \ - public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e) = 0; -#define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \ - public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f) = 0; -#define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ - public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) = 0; -#define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \ - public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) = 0; -#define ICOM_VMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \ - public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i) = 0; -#define ICOM_VMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \ - public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i, tj j) = 0; -#define ICOM_VMETHOD11(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \ - public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i, tj j, tk k) = 0; - - -#ifdef ICOM_USE_COM_INTERFACE_ATTRIBUTE - -#define ICOM_DEFINE(iface,ibase) \ - typedef struct iface: public ibase { \ - iface##_METHODS \ - } __attribute__ ((com_interface)); - -#else - -#define ICOM_DEFINE(iface,ibase) \ - typedef struct iface: public ibase { \ - iface##_METHODS \ - }; - -#endif /* ICOM_USE_COM_INTERFACE_ATTRIBUTE */ - -#define ICOM_CALL(xfn, p) (p)->xfn() -#define ICOM_CALL1(xfn, p,a) (p)->xfn(a) -#define ICOM_CALL2(xfn, p,a,b) (p)->xfn(a,b) -#define ICOM_CALL3(xfn, p,a,b,c) (p)->xfn(a,b,c) -#define ICOM_CALL4(xfn, p,a,b,c,d) (p)->xfn(a,b,c,d) -#define ICOM_CALL5(xfn, p,a,b,c,d,e) (p)->xfn(a,b,c,d,e) -#define ICOM_CALL6(xfn, p,a,b,c,d,e,f) (p)->xfn(a,b,c,d,e,f) -#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) (p)->xfn(a,b,c,d,e,f,g) -#define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) (p)->xfn(a,b,c,d,e,f,g,h) -#define ICOM_CALL9(xfn, p,a,b,c,d,e,f,g,h,i) (p)->xfn(a,b,c,d,e,f,g,h,i) -#define ICOM_CALL10(xfn, p,a,b,c,d,e,f,g,h,i,j) (p)->xfn(a,b,c,d,e,f,g,h,i,j) -#define ICOM_CALL11(xfn, p,a,b,c,d,e,f,g,h,i,j,k) (p)->xfn(a,b,c,d,e,f,g,h,i,j,k) - - -#else -/* C interface */ - - -#ifdef __WINE__ - -#define ICOM_METHOD(ret,xfn) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me); -#define ICOM_METHOD1(ret,xfn,ta,na) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a); -#define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b); -#define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); -#define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); -#define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); -#define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); -#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); -#define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); -#define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i); -#define ICOM_METHOD10(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j); -#define ICOM_METHOD11(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \ - ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k); - -#define ICOM_VMETHOD(xfn) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me); -#define ICOM_VMETHOD1(xfn,ta,na) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a); -#define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b); -#define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); -#define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); -#define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); -#define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); -#define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); -#define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,nh) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); -#define ICOM_VMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ni) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i); -#define ICOM_VMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,nj) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j); -#define ICOM_VMETHOD11(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,nk) \ - void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k); - -#define ICOM_CALL(xfn, p) ICOM_VTBL(p)->fn##xfn(p) -#define ICOM_CALL1(xfn, p,a) ICOM_VTBL(p)->fn##xfn(p,a) -#define ICOM_CALL2(xfn, p,a,b) ICOM_VTBL(p)->fn##xfn(p,a,b) -#define ICOM_CALL3(xfn, p,a,b,c) ICOM_VTBL(p)->fn##xfn(p,a,b,c) -#define ICOM_CALL4(xfn, p,a,b,c,d) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d) -#define ICOM_CALL5(xfn, p,a,b,c,d,e) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e) -#define ICOM_CALL6(xfn, p,a,b,c,d,e,f) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f) -#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g) -#define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g,h) -#define ICOM_CALL9(xfn, p,a,b,c,d,e,f,g,h,i) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g,h,i) -#define ICOM_CALL10(xfn, p,a,b,c,d,e,f,g,h,i,j) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g,h,i,j) -#define ICOM_CALL11(xfn, p,a,b,c,d,e,f,g,h,i,j,k) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g,h,i,j,k) - -#else - -/* WINELIB case */ - -#define ICOM_METHOD(ret,xfn) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me); -#define ICOM_METHOD1(ret,xfn,ta,na) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a); -#define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b); -#define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); -#define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); -#define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); -#define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); -#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); -#define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); -#define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i); -#define ICOM_METHOD10(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j); -#define ICOM_METHOD11(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \ - ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k); - -#define ICOM_VMETHOD(xfn) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me); -#define ICOM_VMETHOD1(xfn,ta,na) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a); -#define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b); -#define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); -#define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); -#define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); -#define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); -#define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); -#define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,nh) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); -#define ICOM_VMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ni) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i); -#define ICOM_VMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,nj) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j); -#define ICOM_VMETHOD11(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,nk) \ - void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k); - -#define ICOM_CVMETHOD(xfn) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me); -#define ICOM_CVMETHOD1(xfn,ta,na) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a); -#define ICOM_CVMETHOD2(xfn,ta,na,tb,nb) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b); -#define ICOM_CVMETHOD3(xfn,ta,na,tb,nb,tc,nc) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c); -#define ICOM_CVMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d); -#define ICOM_CVMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); -#define ICOM_CVMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); -#define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); -#define ICOM_CVMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); - -#define ICOM_CVMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i); -#define ICOM_CVMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j); -#define ICOM_CVMETHOD11(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \ - void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k); - -#define ICOM_CALL(xfn, p) ICOM_VTBL(p)->xfn(p) -#define ICOM_CALL1(xfn, p,a) ICOM_VTBL(p)->xfn(p,a) -#define ICOM_CALL2(xfn, p,a,b) ICOM_VTBL(p)->xfn(p,a,b) -#define ICOM_CALL3(xfn, p,a,b,c) ICOM_VTBL(p)->xfn(p,a,b,c) -#define ICOM_CALL4(xfn, p,a,b,c,d) ICOM_VTBL(p)->xfn(p,a,b,c,d) -#define ICOM_CALL5(xfn, p,a,b,c,d,e) ICOM_VTBL(p)->xfn(p,a,b,c,d,e) -#define ICOM_CALL6(xfn, p,a,b,c,d,e,f) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f) -#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g) -#define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g,h) -#define ICOM_CALL9(xfn, p,a,b,c,d,e,f,g,h,i) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g,h,i) -#define ICOM_CALL10(xfn, p,a,b,c,d,e,f,g,h,i,j) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g,h,i,j) -#define ICOM_CALL11(xfn, p,a,b,c,d,e,f,g,h,i,j,k) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g,h,i,j,k) - -#endif /* __WINE__ */ - -#ifdef ICOM_MSVTABLE_COMPAT -#define ICOM_DEFINE(iface,ibase) \ - typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \ - struct iface { \ - const ICOM_VFIELD(iface); \ - }; \ - struct ICOM_VTABLE(iface) { \ - long dummyRTTI1; \ - long dummyRTTI2; \ - ibase##_IMETHODS \ - iface##_METHODS \ - }; -#define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 0,0, - -#else -#define ICOM_DEFINE(iface,ibase) \ - typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \ - struct iface { \ - const ICOM_VFIELD(iface); \ - }; \ - struct ICOM_VTABLE(iface) { \ - ibase##_IMETHODS \ - iface##_METHODS \ - }; -#define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE -#endif /* ICOM_MSVTABLE_COMPAT */ - - -#define ICOM_THIS(impl,iface) impl* const This=(impl*)iface -#define ICOM_CTHIS(impl,iface) const impl* const This=(const impl*)iface - -#endif - - -/***************************************************************************** - * Predeclare the interfaces - */ -DEFINE_OLEGUID(IID_IClassFactory, 0x00000001L, 0, 0); -typedef struct IClassFactory IClassFactory, *LPCLASSFACTORY; - -DEFINE_OLEGUID(IID_IMalloc, 0x00000002L, 0, 0); -typedef struct IMalloc IMalloc,*LPMALLOC; - -DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0); -typedef struct IUnknown IUnknown, *LPUNKNOWN; - - -/***************************************************************************** - * IUnknown interface - */ -#define ICOM_INTERFACE IUnknown -#define IUnknown_IMETHODS \ - ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj) \ - ICOM_METHOD (ULONG,AddRef) \ - ICOM_METHOD (ULONG,Release) -#ifdef ICOM_CINTERFACE -typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown); -struct IUnknown { - ICOM_VFIELD(IUnknown); -#if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE) -} __attribute__ ((com_interface)); -#else -}; -#endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */ - -struct ICOM_VTABLE(IUnknown) { -#ifdef ICOM_MSVTABLE_COMPAT - long dummyRTTI1; - long dummyRTTI2; -#endif /* ICOM_MSVTABLE_COMPAT */ - -#else /* ICOM_CINTERFACE */ -struct IUnknown { - -#endif /* ICOM_CINTERFACE */ - - ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj) - ICOM_METHOD (ULONG,AddRef) - ICOM_METHOD (ULONG,Release) -#if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE) -} __attribute__ ((com_interface)); -#else -}; -#endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */ - -#undef ICOM_INTERFACE - -/*** IUnknown methods ***/ -#define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) -#define IUnknown_AddRef(p) ICOM_CALL (AddRef,p) -#define IUnknown_Release(p) ICOM_CALL (Release,p) - -/***************************************************************************** - * IClassFactory interface - */ -#define ICOM_INTERFACE IClassFactory -#define IClassFactory_METHODS \ - ICOM_METHOD3(HRESULT,CreateInstance, LPUNKNOWN,pUnkOuter, REFIID,riid, LPVOID*,ppvObject) \ - ICOM_METHOD1(HRESULT,LockServer, BOOL,fLock) -#define IClassFactory_IMETHODS \ - IUnknown_IMETHODS \ - IClassFactory_METHODS -ICOM_DEFINE(IClassFactory,IUnknown) -#undef ICOM_INTERFACE - -/*** IUnknown methods ***/ -#define IClassFactory_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) -#define IClassFactory_AddRef(p) ICOM_CALL (AddRef,p) -#define IClassFactory_Release(p) ICOM_CALL (Release,p) -/*** IClassFactory methods ***/ -#define IClassFactory_CreateInstance(p,a,b,c) ICOM_CALL3(CreateInstance,p,a,b,c) -#define IClassFactory_LockServer(p,a) ICOM_CALL1(LockServer,p,a) - - -/***************************************************************************** - * IMalloc interface - */ -#define ICOM_INTERFACE IMalloc -#define IMalloc_METHODS \ - ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb) \ - ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb) \ - ICOM_VMETHOD1( Free, LPVOID,pv) \ - ICOM_METHOD1(DWORD, GetSize, LPVOID,pv) \ - ICOM_METHOD1(INT, DidAlloc, LPVOID,pv) \ - ICOM_METHOD (VOID, HeapMinimize) -#define IMalloc_IMETHODS \ - IUnknown_IMETHODS \ - IMalloc_METHODS -ICOM_DEFINE(IMalloc,IUnknown) -#undef ICOM_INTERFACE - -/*** IUnknown methods ***/ -#define IMalloc_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) -#define IMalloc_AddRef(p) ICOM_CALL (AddRef,p) -#define IMalloc_Release(p) ICOM_CALL (Release,p) -/*** IMalloc32 methods ***/ -#define IMalloc_Alloc(p,a) ICOM_CALL1(Alloc,p,a) -#define IMalloc_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b) -#define IMalloc_Free(p,a) ICOM_CALL1(Free,p,a) -#define IMalloc_GetSize(p,a) ICOM_CALL1(GetSize,p,a) -#define IMalloc_DidAlloc(p,a) ICOM_CALL1(DidAlloc,p,a) -#define IMalloc_HeapMinimize(p) ICOM_CALL (HeapMinimize,p) - - -HRESULT WINAPI CoGetMalloc(DWORD dwMemContext,LPMALLOC* lpMalloc); - -LPVOID WINAPI CoTaskMemAlloc(ULONG size); - -void WINAPI CoTaskMemFree(LPVOID ptr); - -/* FIXME: unimplemented */ -LPVOID WINAPI CoTaskMemRealloc(LPVOID ptr, ULONG size); - - -/***************************************************************************** - * Additional API - */ - -HRESULT WINAPI CoCreateGuid(GUID* pguid); - -HINSTANCE WINAPI CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree); - -void WINAPI CoFreeAllLibraries(void); - -void WINAPI CoFreeLibrary(HINSTANCE hLibrary); - -void WINAPI CoFreeUnusedLibraries(void); - -HRESULT WINAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv); - -HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved, REFIID iid, LPVOID *ppv); - -HRESULT WINAPI CoInitialize(LPVOID lpReserved); -HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit); - -void WINAPI CoUninitialize(void); - -typedef enum tagCOINIT -{ - COINIT_APARTMENTTHREADED = 0x2, /* Apartment model */ - COINIT_MULTITHREADED = 0x0, /* OLE calls objects on any thread */ - COINIT_DISABLE_OLE1DDE = 0x4, /* Don't use DDE for Ole1 support */ - COINIT_SPEED_OVER_MEMORY = 0x8 /* Trade memory for speed */ -} COINIT; - - -/* FIXME: not implemented */ -BOOL WINAPI CoIsOle1Class(REFCLSID rclsid); - -HRESULT WINAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases); - -/* class registration flags; passed to CoRegisterClassObject */ -typedef enum tagREGCLS -{ - REGCLS_SINGLEUSE = 0, - REGCLS_MULTIPLEUSE = 1, - REGCLS_MULTI_SEPARATE = 2, - REGCLS_SUSPENDED = 4 -} REGCLS; - -HRESULT WINAPI CoResumeClassObjects (void); -HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid,LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,LPDWORD lpdwRegister); - -HRESULT WINAPI CoRevokeClassObject(DWORD dwRegister); - -/***************************************************************************** - * COM Server dll - exports - */ -HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv); -HRESULT WINAPI DllCanUnloadNow(void); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* __WINE_WINE_OBJ_BASE_H */ diff --git a/complus/wtypes.h b/complus/wtypes.h deleted file mode 100644 index bff3f30..0000000 --- a/complus/wtypes.h +++ /dev/null @@ -1,272 +0,0 @@ -/* wtypes.h - Defines the basic types used by COM interfaces. - - Copyright (c) 1993-2000 the Wine project authors (see the file WINE-AUTHORS - for a complete list) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __WINE_WTYPES_H -#define __WINE_WTYPES_H - -#include "basetsd.h" -#include "guiddef.h" -/*#include "rpc.h"*/ -/*#include "rpcndr.h"*/ - -typedef WORD CLIPFORMAT, *LPCLIPFORMAT; - -/* FIXME: does not belong here */ -typedef CHAR OLECHAR16; -typedef LPSTR LPOLESTR16; -typedef LPCSTR LPCOLESTR16; -typedef OLECHAR16 *BSTR16; -typedef BSTR16 *LPBSTR16; -#define OLESTR16(x) x - -typedef WCHAR OLECHAR; -typedef LPWSTR LPOLESTR; -typedef LPCWSTR LPCOLESTR; -typedef OLECHAR *BSTR; -typedef BSTR *LPBSTR; - -/* -#ifndef _DWORDLONG_ -#define _DWORDLONG_ -typedef __uint64 DWORDLONG, *PDWORDLONG; -#endif - -#ifndef _ULONGLONG_ -#define _ULONGLONG_ -typedef __int64 LONGLONG, *PLONGLONG; -typedef __uint64 ULONGLONG, *PULONGLONG; -#endif -*/ - -#define OLESTR(x) L##x - -typedef enum tagDVASPECT -{ - DVASPECT_CONTENT = 1, - DVASPECT_THUMBNAIL = 2, - DVASPECT_ICON = 4, - DVASPECT_DOCPRINT = 8 -} DVASPECT; - -typedef enum tagSTGC -{ - STGC_DEFAULT = 0, - STGC_OVERWRITE = 1, - STGC_ONLYIFCURRENT = 2, - STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4, - STGC_CONSOLIDATE = 8 -} STGC; - -typedef enum tagSTGMOVE -{ - STGMOVE_MOVE = 0, - STGMOVE_COPY = 1, - STGMOVE_SHALLOWCOPY = 2 -} STGMOVE; - - -typedef struct _COAUTHIDENTITY -{ - USHORT* User; - ULONG UserLength; - USHORT* Domain; - ULONG DomainLength; - USHORT* Password; - ULONG PasswordLength; - ULONG Flags; -} COAUTHIDENTITY; - -typedef struct _COAUTHINFO -{ - DWORD dwAuthnSvc; - DWORD dwAuthzSvc; - LPWSTR pwszServerPrincName; - DWORD dwAuthnLevel; - DWORD dwImpersonationLevel; - COAUTHIDENTITY* pAuthIdentityData; - DWORD dwCapabilities; -} COAUTHINFO; - -typedef struct _COSERVERINFO -{ - DWORD dwReserved1; - LPWSTR pwszName; - COAUTHINFO* pAuthInfo; - DWORD dwReserved2; -} COSERVERINFO; - -typedef enum tagCLSCTX -{ - CLSCTX_INPROC_SERVER = 0x1, - CLSCTX_INPROC_HANDLER = 0x2, - CLSCTX_LOCAL_SERVER = 0x4, - CLSCTX_INPROC_SERVER16 = 0x8, - CLSCTX_REMOTE_SERVER = 0x10, - CLSCTX_INPROC_HANDLER16 = 0x20, - CLSCTX_INPROC_SERVERX86 = 0x40, - CLSCTX_INPROC_HANDLERX86 = 0x80, - CLSCTX_ESERVER_HANDLER = 0x100 -} CLSCTX; - -#define CLSCTX_INPROC (CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER) -#define CLSCTX_ALL (CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER) -#define CLSCTX_SERVER (CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER) - -typedef enum tagMSHLFLAGS -{ - MSHLFLAGS_NORMAL = 0, - MSHLFLAGS_TABLESTRONG = 1, - MSHLFLAGS_TABLEWEAK = 2, - MSHLFLAGS_NOPING = 4 -} MSHLFLAGS; - -typedef enum tagMSHCTX -{ - MSHCTX_LOCAL = 0, - MSHCTX_NOSHAREDMEM = 1, - MSHCTX_DIFFERENTMACHINE = 2, - MSHCTX_INPROC = 3 -} MSHCTX; - -typedef unsigned short VARTYPE; - -typedef ULONG PROPID; - -/* -#ifndef _tagBLOB_DEFINED -#define _tagBLOB_DEFINED -#define _BLOB_DEFINED -#define _LPBLOB_DEFINED -typedef struct tagBLOB -{ - ULONG cbSize; - BYTE *pBlobData; -} BLOB, *LPBLOB; -#endif -*/ - -#ifndef _tagCY_DEFINED -#define _tagCY_DEFINED - -typedef union tagCY { - struct { -#ifdef BIG_ENDIAN - LONG Hi; - LONG Lo; -#else /* defined(BIG_ENDIAN) */ - ULONG Lo; - LONG Hi; -#endif /* defined(BIG_ENDIAN) */ - } DUMMYSTRUCTNAME; - LONGLONG int64; -} CY; - -#endif /* _tagCY_DEFINED */ - -/* - * 0 == FALSE and -1 == TRUE - */ -#define VARIANT_TRUE ((VARIANT_BOOL)0xFFFF) -#define VARIANT_FALSE ((VARIANT_BOOL)0x0000) -typedef short VARIANT_BOOL,_VARIANT_BOOL; - -typedef struct tagCLIPDATA -{ - ULONG cbSize; - long ulClipFmt; - BYTE *pClipData; -} CLIPDATA; - -/* Macro to calculate the size of the above pClipData */ -#define CBPCLIPDATA(clipdata) ( (clipdata).cbSize - sizeof((clipdata).ulClipFmt) ) - -typedef LONG SCODE; - -/* -#ifndef _FILETIME_ -#define _FILETIME_ -*/ -/* 64 bit number of 100 nanoseconds intervals since January 1, 1601 */ -/* -typedef struct -{ - DWORD dwLowDateTime; - DWORD dwHighDateTime; -} FILETIME, *LPFILETIME; -#endif -*/ - -#ifndef _SECURITY_DEFINED -#define _SECURITY_DEFINED - -/* -typedef struct { - BYTE Value[6]; -} SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY; - -typedef struct _SID { - BYTE Revision; - BYTE SubAuthorityCount; - SID_IDENTIFIER_AUTHORITY IdentifierAuthority; - DWORD SubAuthority[1]; -} SID,*PSID; -*/ -/* - * ACL - */ -/* -typedef struct _ACL { - BYTE AclRevision; - BYTE Sbz1; - WORD AclSize; - WORD AceCount; - WORD Sbz2; -} ACL, *PACL; - -typedef DWORD SECURITY_INFORMATION; -typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL; -typedef DWORD ACCESS_MASK, *PACCESS_MASK; - -typedef PVOID PGENERIC_MAPPING; -*/ -/* The security descriptor structure */ -/* -typedef struct { - BYTE Revision; - BYTE Sbz1; - SECURITY_DESCRIPTOR_CONTROL Control; - PSID Owner; - PSID Group; - PACL Sacl; - PACL Dacl; -} SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR; -*/ -#endif /* _SECURITY_DEFINED */ - -#ifndef _ROTFLAGS_DEFINED -#define _ROTFLAGS_DEFINED -#define ROTFLAGS_REGISTRATIONKEEPSALIVE 0x1 -#define ROTFLAGS_ALLOWANYCLIENT 0x2 -#endif /* !defined(_ROTFLAGS_DEFINED) */ - -#endif /* __WINE_WTYPES_H */ -- 2.26.2