This commit was manufactured by cvs2svn to create tag 'gpgme-0-3-0'.
This commit is contained in:
parent
d08bc2364f
commit
be1c1d1c2b
12
tags/gpgme-0-3-0/.cvsignore
Normal file
12
tags/gpgme-0-3-0/.cvsignore
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
aclocal.m4
|
||||||
|
config.cache
|
||||||
|
config.h
|
||||||
|
config.h.in
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
configure
|
||||||
|
stamp-h
|
||||||
|
stamp-h.in
|
||||||
|
stamp-h1
|
23
tags/gpgme-0-3-0/AUTHORS
Normal file
23
tags/gpgme-0-3-0/AUTHORS
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Program: gpgme
|
||||||
|
Maintainer: wk@g10gnupg.org
|
||||||
|
|
||||||
|
|
||||||
|
FSF <gnu@gnu.org>
|
||||||
|
- Code taken from GnuPG 1.0: gpgme/w32-util.c, GnuPG 1.1: jnlib/.
|
||||||
|
|
||||||
|
g10 Code GmbH <code@g10code.com>
|
||||||
|
- All stuff since mid march 2001.
|
||||||
|
|
||||||
|
Werner Koch <wk@gnupg.org>
|
||||||
|
- Design and most stuff.
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
106
tags/gpgme-0-3-0/ChangeLog
Normal file
106
tags/gpgme-0-3-0/ChangeLog
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
2001-12-18 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* autogen.sh (libtool_vers): Bump to 1.4.
|
||||||
|
|
||||||
|
* configure.ac (LIBGPGME_LT_CURRENT): Increment.
|
||||||
|
(LIBGPGME_LT_AGE): Reset.
|
||||||
|
Improve comment.
|
||||||
|
Fix wrong comment character.
|
||||||
|
|
||||||
|
2001-12-18 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* acinclude.m4 (GNUPG_FIX_HDR_VERSION): Fixed for new automake.
|
||||||
|
|
||||||
|
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* configure.ac (GPG): Substitute this variable.
|
||||||
|
(GPGSM): Likewise.
|
||||||
|
|
||||||
|
2001-11-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* configure.ac (AC_CONFIG_FILES): Add tests/gpg/Makefile and
|
||||||
|
tests/gpgsm/Makefile.
|
||||||
|
|
||||||
|
2001-11-21 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* Makefile.am (gpgmeplug): New variable, set to gpgmeplug if
|
||||||
|
[BUILD_GPGMEPLUG].
|
||||||
|
* configure.ac (AC_CONFIG_FILES): Add gpgmeplug/Makefile.
|
||||||
|
Support --enable-gpgmeplug.
|
||||||
|
|
||||||
|
2001-11-21 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* autogen.sh: Tighten version dependencies.
|
||||||
|
|
||||||
|
2001-11-20 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* Makefile.am (SUBDIRS): Support building the assuan library
|
||||||
|
(currently if GPGSM_PATH is set)..
|
||||||
|
* configure.ac: Support building the assuan library.
|
||||||
|
* assuan: New directory, populated with the Assuan library
|
||||||
|
(copied from the newpg repository).
|
||||||
|
|
||||||
|
2001-11-20 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* configure.ac (NEED_GPGSM_VERSION): New variable. Treat it
|
||||||
|
similarly to NEED_GPG_VERSION.
|
||||||
|
* acconfig.h: Likewise.
|
||||||
|
|
||||||
|
2001-11-18 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* configure.in: Renamed to ...
|
||||||
|
* configure.ac: ... this. Update to autoconf 2.52. Lots of small
|
||||||
|
changes in the transition. Support --with-gpg=PATH and
|
||||||
|
--with-gpgsm=PATH options. Check if test suites can be run.
|
||||||
|
* acconfig.h: Add GPGSM_PATH.
|
||||||
|
* Makefile.am: New variable `tests', set to `tests' if
|
||||||
|
RUN_GPG_TESTS.
|
||||||
|
(SUBDIRS): Replace string `tests' with variable `tests'.
|
||||||
|
|
||||||
|
2001-10-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* autogen.sh: Invoke automake with `-a' (add missing files).
|
||||||
|
Do not invoke configure.
|
||||||
|
|
||||||
|
2001-09-17 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
Released 0.2.3.
|
||||||
|
|
||||||
|
* configure.in (NEED_GPG_VERSION): Set to 1.0.6. Incremented LT
|
||||||
|
current and age.
|
||||||
|
|
||||||
|
* Makefile.am (SUBDIRS): Add doc
|
||||||
|
|
||||||
|
2001-06-12 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
Released 0.2.2.
|
||||||
|
|
||||||
|
2001-04-05 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* configure.in (NEED_GPG_VERSION): Set to 1.0.4g
|
||||||
|
|
||||||
|
2001-04-02 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
Released 0.2.1.
|
||||||
|
|
||||||
|
Changed the copyright notices all over the place.
|
||||||
|
|
||||||
|
2001-02-28 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
Released 0.2.0.
|
||||||
|
|
||||||
|
2001-01-18 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* autogen.sh: Added option --build-w32.
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
196
tags/gpgme-0-3-0/INSTALL
Normal file
196
tags/gpgme-0-3-0/INSTALL
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
Installation Instructions for GPGME
|
||||||
|
===================================
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
Basic Installation
|
||||||
|
==================
|
||||||
|
|
||||||
|
These are generic installation instructions.
|
||||||
|
|
||||||
|
The `configure' shell script attempts to guess correct values for
|
||||||
|
various system-dependent variables used during compilation. It uses
|
||||||
|
those values to create a `Makefile' in each directory of the package.
|
||||||
|
It may also create one or more `.h' files containing system-dependent
|
||||||
|
definitions. Finally, it creates a shell script `config.status' that
|
||||||
|
you can run in the future to recreate the current configuration, a file
|
||||||
|
`config.cache' that saves the results of its tests to speed up
|
||||||
|
reconfiguring, and a file `config.log' containing compiler output
|
||||||
|
(useful mainly for debugging `configure').
|
||||||
|
|
||||||
|
If you need to do unusual things to compile the package, please try
|
||||||
|
to figure out how `configure' could check whether to do them, and mail
|
||||||
|
diffs or instructions to the address given in the `README' so they can
|
||||||
|
be considered for the next release. If at some point `config.cache'
|
||||||
|
contains results you don't want to keep, you may remove or edit it.
|
||||||
|
|
||||||
|
The file `configure.in' is used to create `configure' by a program
|
||||||
|
called `autoconf'. You only need `configure.in' if you want to change
|
||||||
|
it or regenerate `configure' using a newer version of `autoconf'.
|
||||||
|
|
||||||
|
The simplest way to compile this package is:
|
||||||
|
|
||||||
|
1. `cd' to the directory containing the package's source code and type
|
||||||
|
`./configure' to configure the package for your system. If you're
|
||||||
|
using `csh' on an old version of System V, you might need to type
|
||||||
|
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||||
|
`configure' itself.
|
||||||
|
|
||||||
|
Running `configure' takes awhile. While running, it prints some
|
||||||
|
messages telling which features it is checking for.
|
||||||
|
|
||||||
|
2. Type `make' to compile the package.
|
||||||
|
|
||||||
|
3. Optionally, type `make check' to run any self-tests that come with
|
||||||
|
the package.
|
||||||
|
|
||||||
|
4. Type `make install' to install the programs and any data files and
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
5. You can remove the program binaries and object files from the
|
||||||
|
source code directory by typing `make clean'. To also remove the
|
||||||
|
files that `configure' created (so you can compile the package for
|
||||||
|
a different kind of computer), type `make distclean'. There is
|
||||||
|
also a `make maintainer-clean' target, but that is intended mainly
|
||||||
|
for the package's developers. If you use it, you may have to get
|
||||||
|
all sorts of other programs in order to regenerate files that came
|
||||||
|
with the distribution.
|
||||||
|
|
||||||
|
Compilers and Options
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Some systems require unusual options for compilation or linking that
|
||||||
|
the `configure' script does not know about. You can give `configure'
|
||||||
|
initial values for variables by setting them in the environment. Using
|
||||||
|
a Bourne-compatible shell, you can do that on the command line like
|
||||||
|
this:
|
||||||
|
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||||
|
|
||||||
|
Or on systems that have the `env' program, you can do it like this:
|
||||||
|
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||||
|
|
||||||
|
Compiling For Multiple Architectures
|
||||||
|
====================================
|
||||||
|
|
||||||
|
You can compile the package for more than one kind of computer at the
|
||||||
|
same time, by placing the object files for each architecture in their
|
||||||
|
own directory. To do this, you must use a version of `make' that
|
||||||
|
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||||
|
directory where you want the object files and executables to go and run
|
||||||
|
the `configure' script. `configure' automatically checks for the
|
||||||
|
source code in the directory that `configure' is in and in `..'.
|
||||||
|
|
||||||
|
If you have to use a `make' that does not supports the `VPATH'
|
||||||
|
variable, you have to compile the package for one architecture at a time
|
||||||
|
in the source code directory. After you have installed the package for
|
||||||
|
one architecture, use `make distclean' before reconfiguring for another
|
||||||
|
architecture.
|
||||||
|
|
||||||
|
Installation Names
|
||||||
|
==================
|
||||||
|
|
||||||
|
By default, `make install' will install the package's files in
|
||||||
|
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||||
|
installation prefix other than `/usr/local' by giving `configure' the
|
||||||
|
option `--prefix=PATH'.
|
||||||
|
|
||||||
|
You can specify separate installation prefixes for
|
||||||
|
architecture-specific files and architecture-independent files. If you
|
||||||
|
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||||
|
PATH as the prefix for installing programs and libraries.
|
||||||
|
Documentation and other data files will still use the regular prefix.
|
||||||
|
|
||||||
|
In addition, if you use an unusual directory layout you can give
|
||||||
|
options like `--bindir=PATH' to specify different values for particular
|
||||||
|
kinds of files. Run `configure --help' for a list of the directories
|
||||||
|
you can set and what kinds of files go in them.
|
||||||
|
|
||||||
|
If the package supports it, you can cause programs to be installed
|
||||||
|
with an extra prefix or suffix on their names by giving `configure' the
|
||||||
|
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||||
|
|
||||||
|
Optional Features
|
||||||
|
=================
|
||||||
|
|
||||||
|
Some packages pay attention to `--enable-FEATURE' options to
|
||||||
|
`configure', where FEATURE indicates an optional part of the package.
|
||||||
|
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||||
|
is something like `gnu-as' or `x' (for the X Window System). The
|
||||||
|
`README' should mention any `--enable-' and `--with-' options that the
|
||||||
|
package recognizes.
|
||||||
|
|
||||||
|
For packages that use the X Window System, `configure' can usually
|
||||||
|
find the X include and library files automatically, but if it doesn't,
|
||||||
|
you can use the `configure' options `--x-includes=DIR' and
|
||||||
|
`--x-libraries=DIR' to specify their locations.
|
||||||
|
|
||||||
|
Specifying the System Type
|
||||||
|
==========================
|
||||||
|
|
||||||
|
There may be some features `configure' can not figure out
|
||||||
|
automatically, but needs to determine by the type of host the package
|
||||||
|
will run on. Usually `configure' can figure that out, but if it prints
|
||||||
|
a message saying it can not guess the host type, give it the
|
||||||
|
`--host=TYPE' option. TYPE can either be a short name for the system
|
||||||
|
type, such as `sun4', or a canonical name with three fields:
|
||||||
|
CPU-COMPANY-SYSTEM
|
||||||
|
|
||||||
|
See the file `config.sub' for the possible values of each field. If
|
||||||
|
`config.sub' isn't included in this package, then this package doesn't
|
||||||
|
need to know the host type.
|
||||||
|
|
||||||
|
If you are building compiler tools for cross-compiling, you can also
|
||||||
|
use the `--target=TYPE' option to select the type of system they will
|
||||||
|
produce code for and the `--build=TYPE' option to select the type of
|
||||||
|
system on which you are compiling the package.
|
||||||
|
|
||||||
|
Sharing Defaults
|
||||||
|
================
|
||||||
|
|
||||||
|
If you want to set default values for `configure' scripts to share,
|
||||||
|
you can create a site shell script called `config.site' that gives
|
||||||
|
default values for variables like `CC', `cache_file', and `prefix'.
|
||||||
|
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||||
|
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||||
|
`CONFIG_SITE' environment variable to the location of the site script.
|
||||||
|
A warning: not all `configure' scripts look for a site script.
|
||||||
|
|
||||||
|
Operation Controls
|
||||||
|
==================
|
||||||
|
|
||||||
|
`configure' recognizes the following options to control how it
|
||||||
|
operates.
|
||||||
|
|
||||||
|
`--cache-file=FILE'
|
||||||
|
Use and save the results of the tests in FILE instead of
|
||||||
|
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
||||||
|
debugging `configure'.
|
||||||
|
|
||||||
|
`--help'
|
||||||
|
Print a summary of the options to `configure', and exit.
|
||||||
|
|
||||||
|
`--quiet'
|
||||||
|
`--silent'
|
||||||
|
`-q'
|
||||||
|
Do not print messages saying which checks are being made. To
|
||||||
|
suppress all normal output, redirect it to `/dev/null' (any error
|
||||||
|
messages will still be shown).
|
||||||
|
|
||||||
|
`--srcdir=DIR'
|
||||||
|
Look for the package's source code in directory DIR. Usually
|
||||||
|
`configure' can determine that directory automatically.
|
||||||
|
|
||||||
|
`--version'
|
||||||
|
Print the version of Autoconf used to generate the `configure'
|
||||||
|
script, and exit.
|
||||||
|
|
||||||
|
`configure' also accepts some other, not widely useful, options.
|
54
tags/gpgme-0-3-0/Makefile.am
Normal file
54
tags/gpgme-0-3-0/Makefile.am
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
# 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
|
||||||
|
|
||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
EXTRA_DIST = README-alpha autogen.sh
|
||||||
|
|
||||||
|
if BUILD_ASSUAN
|
||||||
|
assuan = assuan
|
||||||
|
else
|
||||||
|
assuan =
|
||||||
|
endif
|
||||||
|
|
||||||
|
if BUILD_BONOBO
|
||||||
|
bonobo = bonobo
|
||||||
|
else
|
||||||
|
bonobo =
|
||||||
|
endif
|
||||||
|
|
||||||
|
if BUILD_COMPLUS
|
||||||
|
complus = complus
|
||||||
|
else
|
||||||
|
complus =
|
||||||
|
endif
|
||||||
|
|
||||||
|
if RUN_GPG_TESTS
|
||||||
|
tests = tests
|
||||||
|
else
|
||||||
|
tests =
|
||||||
|
endif
|
||||||
|
|
||||||
|
if BUILD_GPGMEPLUG
|
||||||
|
gpgmeplug = gpgmeplug
|
||||||
|
else
|
||||||
|
gpgmeplug =
|
||||||
|
endif
|
||||||
|
|
||||||
|
SUBDIRS = ${assuan} jnlib gpgme ${tests} doc ${bonobo} ${complus} ${gpgmeplug}
|
98
tags/gpgme-0-3-0/NEWS
Normal file
98
tags/gpgme-0-3-0/NEWS
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
Noteworthy changes in version 0.3.0 (2001-12-19)
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
* New interface gpgme_set_protocol() to set the protocol and thus the
|
||||||
|
crypto engine to be used by the context. Currently, the OpenPGP
|
||||||
|
and the CMS protocols are supported. They are specified by the new
|
||||||
|
preprocessor symbols GPGME_PROTOCOL_OpenPGP and GPGME_PROTOCOL_CMS.
|
||||||
|
A new context uses the OpenPGP engine by default.
|
||||||
|
|
||||||
|
* gpgme_get_engine_info() returns information for all crypto engines
|
||||||
|
compiled into the library. The XML format has changed. To
|
||||||
|
reliably get the version of a crypto engine, the <version> tag
|
||||||
|
after the appropriate <protocol> tag has to be looked for.
|
||||||
|
|
||||||
|
* New interface gpgme_engine_check_version(), obsoleting
|
||||||
|
gpgme_check_engine(). Check the version of all engines you are
|
||||||
|
supporting in your software.
|
||||||
|
|
||||||
|
* GpgmeKey lists the user ids in the order as they are returned by
|
||||||
|
GnuPG, first the primary key with index 0, then the sub-user ids.
|
||||||
|
|
||||||
|
* New operation gpgme_op_decrypt_verify() to decrypt and verify
|
||||||
|
signatures simultaneously.
|
||||||
|
|
||||||
|
* The new interface gpgme_op_keylist_end() terminates a pending
|
||||||
|
keylist operation. A keylist operation is also terminated when
|
||||||
|
gpgme_op_keylist_next() returns GPGME_EOF.
|
||||||
|
|
||||||
|
* GPGME can be compiled without GnuPG being installed (`--with-gpg=PATH'),
|
||||||
|
cross-compiled, or even compiled without support for GnuPG
|
||||||
|
(`--without-gpg').
|
||||||
|
|
||||||
|
* GPGME can be compiled with support for GpgSM (GnuPG for S/MIME,
|
||||||
|
`--with-gpgsm=PATH'). It is enabled by default if the `gpgsm' is found
|
||||||
|
in the path, but it can also be compiled without support for GpgSM
|
||||||
|
(`--without-gpgsm').
|
||||||
|
|
||||||
|
* CryptPlug modules for GPGME are included and can be enabled at
|
||||||
|
configure time (`--enable-gpgmeplug'). There is one module which
|
||||||
|
uses the GnuPG engine (`gpgmeplug') and one module which uses the
|
||||||
|
GpgSM engine (`gpgsmplug').
|
||||||
|
|
||||||
|
* Interface changes relative to the latest 0.2.x release:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
gpgme_key_get_as_xml CHANGED: Sub-user ids reversed in order.
|
||||||
|
gpgme_key_get_string_attr CHANGED: User ids reversed in order.
|
||||||
|
gpgme_key_get_ulong_attr CHANGED: User ids reversed in order.
|
||||||
|
gpgme_get_engine_info CHANGED: New format, extended content.
|
||||||
|
gpgme_engine_check_version NEW
|
||||||
|
gpgme_decrypt_verify_start NEW
|
||||||
|
gpgme_decrypt_verify NEW
|
||||||
|
gpgme_op_keylist_next NEW
|
||||||
|
gpgme_set_protocol NEW
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
Noteworthy changes in version 0.2.3 (2001-09-17)
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
* New function gpgme_get_op_info which can be used to get the micalg
|
||||||
|
parameter needed for MOSS.
|
||||||
|
|
||||||
|
* New functions gpgme_get_armor and gpgme_get_textmode.
|
||||||
|
|
||||||
|
* The usual bug fixes and some minor functionality improvements.
|
||||||
|
|
||||||
|
* Added a simple encryption component for MS-Windows; however the
|
||||||
|
build procedure might have some problems.
|
||||||
|
|
||||||
|
|
||||||
|
Noteworthy changes in version 0.2.2 (2001-06-12)
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
* Implemented a key cache.
|
||||||
|
|
||||||
|
* Fixed a race condition under W32 and some other bug fixes.
|
||||||
|
|
||||||
|
|
||||||
|
Noteworthy changes in version 0.2.1 (2001-04-02)
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
* Changed debug output and GPGME_DEBUG variable (gpgme/debug.c)
|
||||||
|
|
||||||
|
* Handle GnuPG's new key capabilities output and support revocation
|
||||||
|
et al. attributes
|
||||||
|
|
||||||
|
* Made the W32 support more robust.
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
46
tags/gpgme-0-3-0/README
Normal file
46
tags/gpgme-0-3-0/README
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
GPGME - GnuPG Made Easy
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
!!!! THIS IS WORK IN PROGRESS !!!
|
||||||
|
|
||||||
|
If you want to hack on it, start with one of the `tests/t-foo'
|
||||||
|
programs.
|
||||||
|
|
||||||
|
For support of the OpenPGP protocol (default), you need the latest CVS
|
||||||
|
version of GnuPG 1.0, see `http://www.gnupg.org/cvs-access.html'.
|
||||||
|
|
||||||
|
You need at least GnuPG 1.0.6, but don't use a 1.1.x version.
|
||||||
|
|
||||||
|
If configure can't find the `gpg' binary in your path, you can specify
|
||||||
|
the location with the --with-gpg=/path/to/gpg argument to configure.
|
||||||
|
|
||||||
|
For support of the CMS (Cryptographic Message Syntax) protocol, you
|
||||||
|
need the latest CVS version of GpgSM, module name `newpg' at
|
||||||
|
`:pserver:anoncvs@cvs.gnupg.org:/cvs/aegypten'.
|
||||||
|
|
||||||
|
You need at least GpgSM 0.0.0.
|
||||||
|
|
||||||
|
If configure can't find the `gpgsm' binary in your path, you can
|
||||||
|
specify the location with the --with-gpgsm=/path/to/gpgsm argument to
|
||||||
|
configure.
|
||||||
|
|
||||||
|
To enable the CryptPlug GPGME PlugIn for both protocols, use the
|
||||||
|
`--enable-gpgmeplug' option to the configure script. `gpgmeplug' is
|
||||||
|
experimental and you should not assume that it will stay with gpgme.
|
||||||
|
The plug-ins are not installed by `make install'.
|
||||||
|
|
||||||
|
Before building the CVS version following the generic install
|
||||||
|
instructions in `INSTALL', you need to set up the build scripts with
|
||||||
|
`./autogen.sh'. To build the W32 version, use `./autogen.sh
|
||||||
|
--build-w32'.
|
||||||
|
|
||||||
|
Please subscribe to the gnupg-devel@gnupg.org mailing list if you want
|
||||||
|
to do serious work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1
tags/gpgme-0-3-0/README-alpha
Normal file
1
tags/gpgme-0-3-0/README-alpha
Normal file
@ -0,0 +1 @@
|
|||||||
|
THIS IS WORK IN PROGRESS !!!!
|
21
tags/gpgme-0-3-0/THANKS
Normal file
21
tags/gpgme-0-3-0/THANKS
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
Alfons Hoogervorst alfons@proteus.demon.nl
|
||||||
|
Enno Cramer uebergeek@web.de
|
||||||
|
Jan-Oliver Wagner jan@intevation.de
|
||||||
|
Johannes Poehlmann jhp@caldera.de
|
||||||
|
Jose C. García Sogo jose@jaimedelamo.eu.org
|
||||||
|
Mark Mutz mutz@kde.org
|
||||||
|
Stéphane Corthésy stephane@sente.ch
|
||||||
|
Timo Schulz twoaday@freakmail.de
|
||||||
|
Tommy Reynolds reynolds@redhat.com
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
50
tags/gpgme-0-3-0/TODO
Normal file
50
tags/gpgme-0-3-0/TODO
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
* Implement posix-sema.c
|
||||||
|
|
||||||
|
* Allow to use GTK's main loop instead of the select stuff in
|
||||||
|
wait.c
|
||||||
|
|
||||||
|
* add locking to the key cache?
|
||||||
|
|
||||||
|
* Should --delete silently delete secret keys or is there a need for
|
||||||
|
another flag or a callback?
|
||||||
|
|
||||||
|
* GpgmeKey misses GPGME_ATTR_EXPIRE attribute
|
||||||
|
|
||||||
|
* Add ATTR to return the number of subkeys or uids.
|
||||||
|
|
||||||
|
* Return GPGME_Canceled when appropriate
|
||||||
|
|
||||||
|
* Factor out common code in _op_*_start functions.
|
||||||
|
|
||||||
|
* Move code common to all engines up from gpg to engine.
|
||||||
|
|
||||||
|
* Tests
|
||||||
|
** t-data
|
||||||
|
*** Test gpgme_data_release_and_get_mem.
|
||||||
|
*** Test gpgme_data_rewind for invalid types.
|
||||||
|
*** Test gpgme_data_read's readable feature.
|
||||||
|
|
||||||
|
* Build suite
|
||||||
|
** Make sure everything is cleaned correctly (esp. test area).
|
||||||
|
|
||||||
|
Bugs reported by Stephane Corthesy:
|
||||||
|
> - When returning a GpgmeKey GPGME_ATTR_COMMENT attribute, characters
|
||||||
|
> like ":" are not un-escaped, they are returned as \x3a
|
||||||
|
|
||||||
|
> BTW, here's another bug: it it not possible to retrieve fingerprints
|
||||||
|
> for subkeys
|
||||||
|
|
||||||
|
> In GpgmeRecipients, would it be possible to provide a function which
|
||||||
|
> would return the validity assigned to a name contained in the
|
||||||
|
> GpgmeRecipients instance?
|
||||||
|
|
||||||
|
> - There is an inconsistent behaviour: if we pass three times an
|
||||||
|
> invalid (but non empty) passphrase, return code is GPGME_No_Data, but
|
||||||
|
> if we pass three times an empty (and invalid) passphrase, we get
|
||||||
|
> GPGME_No_Passphrase.
|
||||||
|
|
||||||
|
> passphrase callback. If I use the same GpgmeContext as the one which
|
||||||
|
> is currently asking for a passphrase, my app crashes: the r_hd in
|
||||||
|
> the
|
||||||
|
> callback has become invalid; if I use a brand new one, the callback
|
||||||
|
> is called recursively, when I ask to enumerate keys.
|
65
tags/gpgme-0-3-0/acconfig.h
Normal file
65
tags/gpgme-0-3-0/acconfig.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/* acconfig.h - used by autoheader to make config.h.in
|
||||||
|
* 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 GPGME_CONFIG_H
|
||||||
|
#define GPGME_CONFIG_H
|
||||||
|
|
||||||
|
/* need this, because some autoconf tests rely on this (e.g. stpcpy)
|
||||||
|
* and it should be used for new programs */
|
||||||
|
#define _GNU_SOURCE 1
|
||||||
|
/* To allow the use of gpgme in multithreaded programs we have to use
|
||||||
|
* special features from the library.
|
||||||
|
* IMPORTANT: gpgme is not yet fully reentrant and you should use it
|
||||||
|
* only from one thread. */
|
||||||
|
#define _REENTRANT 1
|
||||||
|
|
||||||
|
@TOP@
|
||||||
|
|
||||||
|
/* defined if we run on some of the PCDOS like systems (DOS, Windoze. OS/2)
|
||||||
|
* with special properties like no file modes */
|
||||||
|
#undef HAVE_DOSISH_SYSTEM
|
||||||
|
/* defined if the filesystem uses driver letters */
|
||||||
|
#undef HAVE_DRIVE_LETTERS
|
||||||
|
/* Some systems have a mkdir that takes a single argument. */
|
||||||
|
#undef MKDIR_TAKES_ONE_ARG
|
||||||
|
|
||||||
|
/* Path to the GnuPG binary. */
|
||||||
|
#undef GPG_PATH
|
||||||
|
/* Min. needed GnuPG version. */
|
||||||
|
#undef NEED_GPG_VERSION
|
||||||
|
|
||||||
|
/* Path to the GpgSM binary. */
|
||||||
|
#undef GPGSM_PATH
|
||||||
|
/* Min. needed GpgSM version. */
|
||||||
|
#undef NEED_GPGSM_VERSION
|
||||||
|
|
||||||
|
/* Stuff needed by jnlib. */
|
||||||
|
#undef HAVE_BYTE_TYPEDEF
|
||||||
|
#undef HAVE_USHORT_TYPEDEF
|
||||||
|
#undef HAVE_ULONG_TYPEDEF
|
||||||
|
#undef HAVE_U16_TYPEDEF
|
||||||
|
#undef HAVE_U32_TYPEDEF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@BOTTOM@
|
||||||
|
|
||||||
|
/* not yet needed #include "gpgme-defs.h"*/
|
||||||
|
|
||||||
|
#endif /*GPGME_CONFIG_H*/
|
57
tags/gpgme-0-3-0/acinclude.m4
Normal file
57
tags/gpgme-0-3-0/acinclude.m4
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
dnl Macros to configure gpgme
|
||||||
|
|
||||||
|
|
||||||
|
dnl GNUPG_FIX_HDR_VERSION(FILE, NAME)
|
||||||
|
dnl Make the version number in gcrypt/gcrypt.h the same as the one here.
|
||||||
|
dnl (this is easier than to have a .in file just for one substitution)
|
||||||
|
dnl We must use a temp file in the current directory because make distcheck
|
||||||
|
dnl install all sourcefiles RO.
|
||||||
|
dnl (wk 2001-12-18)
|
||||||
|
AC_DEFUN(GNUPG_FIX_HDR_VERSION,
|
||||||
|
[ sed "s/^#define $2 \".*/#define $2 \"$VERSION\"/" $srcdir/$1 > fixhdr.tmp
|
||||||
|
if cmp -s $srcdir/$1 fixhdr.tmp 2>/dev/null; then
|
||||||
|
rm -f fixhdr.tmp
|
||||||
|
else
|
||||||
|
rm -f $srcdir/$1
|
||||||
|
if mv fixhdr.tmp $srcdir/$1 ; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR([[
|
||||||
|
***
|
||||||
|
*** Failed to fix the version string macro $2 in $1.
|
||||||
|
*** The old file has been saved as fixhdr.tmp
|
||||||
|
***]])
|
||||||
|
fi
|
||||||
|
AC_MSG_WARN([fixed the $2 macro in $1])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
|
||||||
|
dnl Check whether a typedef exists and create a #define $2 if it exists
|
||||||
|
dnl
|
||||||
|
AC_DEFUN(GNUPG_CHECK_TYPEDEF,
|
||||||
|
[ AC_MSG_CHECKING(for $1 typedef)
|
||||||
|
AC_CACHE_VAL(gnupg_cv_typedef_$1,
|
||||||
|
[AC_TRY_COMPILE([#include <stdlib.h>
|
||||||
|
#include <sys/types.h>], [
|
||||||
|
#undef $1
|
||||||
|
int a = sizeof($1);
|
||||||
|
], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
|
||||||
|
AC_MSG_RESULT($gnupg_cv_typedef_$1)
|
||||||
|
if test "$gnupg_cv_typedef_$1" = yes; then
|
||||||
|
AC_DEFINE($2)
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
tags/gpgme-0-3-0/assuan/.cvsignore
Normal file
2
tags/gpgme-0-3-0/assuan/.cvsignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Makefile.in Makefile .deps
|
||||||
|
assuan-errors.c
|
101
tags/gpgme-0-3-0/assuan/ChangeLog
Normal file
101
tags/gpgme-0-3-0/assuan/ChangeLog
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* assuan-connect.c (assuan_pipe_connect): New argument
|
||||||
|
FD_CHILD_LIST. Don't close those fds.
|
||||||
|
* assuan.h: Likewise for prototype.
|
||||||
|
|
||||||
|
2001-12-14 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* assuan-listen.c (assuan_close_input_fd): New.
|
||||||
|
(assuan_close_output_fd): New.
|
||||||
|
* assuan-handler.c (std_handler_reset): Always close them after a
|
||||||
|
reset command.
|
||||||
|
(std_handler_bye): Likewise.
|
||||||
|
|
||||||
|
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use
|
||||||
|
it to save the length of the attic line.
|
||||||
|
Rediddle the code a bit to make it more clear what happens.
|
||||||
|
|
||||||
|
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* assuan-defs.h (LINELENGTH): Define as ASSUAN_LINELENGTH.
|
||||||
|
assuan.h: Define ASSUAN_LINELENGTH.
|
||||||
|
|
||||||
|
2001-12-13 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* assuan-buffer.c (assuan_read_line): Fix order of execution to
|
||||||
|
get correct return values.
|
||||||
|
|
||||||
|
2001-12-13 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* assuan-handler.c (assuan_get_active_fds): Fixed silly bug,
|
||||||
|
pretty obvious that nobody ever tested this function.
|
||||||
|
|
||||||
|
2001-12-12 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* assuan-connect.c (assuan_pipe_connect): Implemented the inital
|
||||||
|
handshake.
|
||||||
|
* assuan-client.c (read_from_server): Renamed to
|
||||||
|
(_assuan_read_from_server): this and made external.
|
||||||
|
|
||||||
|
* assuan-listen.c (assuan_set_hello_line): New.
|
||||||
|
(assuan_accept): Use a custom hello line is available.
|
||||||
|
|
||||||
|
* assuan-buffer.c (assuan_read_line): New.
|
||||||
|
(assuan_pending_line): New.
|
||||||
|
(_assuan_write_line): Renamed to ..
|
||||||
|
(assuan_write_line): this, made public and changed all callers.
|
||||||
|
|
||||||
|
2001-12-04 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* assuan-connect.c (assuan_pipe_connect): Add more error reporting.
|
||||||
|
* assuan-client.c: New.
|
||||||
|
|
||||||
|
* assuan-inquire.c: New.
|
||||||
|
* assuan-handler.c (process_request): Check for nested invocations.
|
||||||
|
|
||||||
|
2001-11-27 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* assuan-handler.c (assuan_register_input_notify): New.
|
||||||
|
(assuan_register_output_notify): New.
|
||||||
|
|
||||||
|
2001-11-26 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* assuan.h: Added more status codes.
|
||||||
|
|
||||||
|
2001-11-25 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* assuan-handler.c (assuan_register_bye_notify)
|
||||||
|
(assuan_register_reset_notify)
|
||||||
|
(assuan_register_cancel_notify): New and call them from the
|
||||||
|
standard handlers.
|
||||||
|
(assuan_process): Moved bulk of function to ..
|
||||||
|
(process_request): .. new.
|
||||||
|
(assuan_process_next): One shot version of above.
|
||||||
|
(assuan_get_active_fds): New.
|
||||||
|
|
||||||
|
2001-11-24 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* assuan-connect.c (assuan_get_pid): New.
|
||||||
|
|
||||||
|
* assuan-buffer.c (_assuan_read_line): Deal with reads of more
|
||||||
|
than a line.
|
||||||
|
* assuan-defs.h: Add space in the context for this.
|
||||||
|
|
||||||
|
|
||||||
|
***********************************************************
|
||||||
|
* Please note that Assuan is maintained as part of GnuPG. *
|
||||||
|
* You may find it source-copied in other packages. *
|
||||||
|
***********************************************************
|
||||||
|
|
||||||
|
Copyright 2001 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
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.
|
45
tags/gpgme-0-3-0/assuan/Makefile.am
Normal file
45
tags/gpgme-0-3-0/assuan/Makefile.am
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Assuan Makefile for test purposes
|
||||||
|
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is part of GnuPG.
|
||||||
|
#
|
||||||
|
# GnuPG 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.
|
||||||
|
#
|
||||||
|
# GnuPG 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
|
||||||
|
|
||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
EXTRA_DIST = mkerrors
|
||||||
|
INCLUDES = -I.. -I$(top_srcdir)/include
|
||||||
|
BUILT_SOURCES = assuan-errors.c
|
||||||
|
|
||||||
|
noinst_LIBRARIES = libassuan.a
|
||||||
|
|
||||||
|
|
||||||
|
#libassuan_a_LDFLAGS =
|
||||||
|
libassuan_a_SOURCES = \
|
||||||
|
assuan.h \
|
||||||
|
assuan-defs.h \
|
||||||
|
assuan-util.c \
|
||||||
|
assuan-errors.c \
|
||||||
|
assuan-buffer.c \
|
||||||
|
assuan-handler.c \
|
||||||
|
assuan-inquire.c \
|
||||||
|
assuan-listen.c \
|
||||||
|
assuan-connect.c \
|
||||||
|
assuan-client.c \
|
||||||
|
assuan-pipe-server.c
|
||||||
|
|
||||||
|
|
||||||
|
assuan-errors.c : assuan.h
|
||||||
|
$(srcdir)/mkerrors < $(srcdir)/assuan.h > assuan-errors.c
|
1
tags/gpgme-0-3-0/assuan/README.1st
Normal file
1
tags/gpgme-0-3-0/assuan/README.1st
Normal file
@ -0,0 +1 @@
|
|||||||
|
Please don't modify it here but in the copy which comes with GnuPG.
|
362
tags/gpgme-0-3-0/assuan/assuan-buffer.c
Normal file
362
tags/gpgme-0-3-0/assuan/assuan-buffer.c
Normal file
@ -0,0 +1,362 @@
|
|||||||
|
/* assuan-buffer.c - read and send data
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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 <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
writen ( int fd, const char *buffer, size_t length )
|
||||||
|
{
|
||||||
|
while (length)
|
||||||
|
{
|
||||||
|
int nwritten = write (fd, buffer, length);
|
||||||
|
|
||||||
|
if (nwritten < 0)
|
||||||
|
{
|
||||||
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
return -1; /* write error */
|
||||||
|
}
|
||||||
|
length -= nwritten;
|
||||||
|
buffer += nwritten;
|
||||||
|
}
|
||||||
|
return 0; /* okay */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read an entire line */
|
||||||
|
static int
|
||||||
|
readline (int fd, char *buf, size_t buflen, int *r_nread, int *eof)
|
||||||
|
{
|
||||||
|
size_t nleft = buflen;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
*eof = 0;
|
||||||
|
*r_nread = 0;
|
||||||
|
while (nleft > 0)
|
||||||
|
{
|
||||||
|
int n = read (fd, buf, nleft);
|
||||||
|
if (n < 0)
|
||||||
|
{
|
||||||
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
return -1; /* read error */
|
||||||
|
}
|
||||||
|
else if (!n)
|
||||||
|
{
|
||||||
|
*eof = 1;
|
||||||
|
break; /* allow incomplete lines */
|
||||||
|
}
|
||||||
|
p = buf;
|
||||||
|
nleft -= n;
|
||||||
|
buf += n;
|
||||||
|
*r_nread += n;
|
||||||
|
|
||||||
|
for (; n && *p != '\n'; n--, p++)
|
||||||
|
;
|
||||||
|
if (n)
|
||||||
|
break; /* at least one full line available - that's enough for now */
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_assuan_read_line (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
char *line = ctx->inbound.line;
|
||||||
|
int n, nread, atticlen;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (ctx->inbound.eof)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
atticlen = ctx->inbound.attic.linelen;
|
||||||
|
if (atticlen)
|
||||||
|
{
|
||||||
|
memcpy (line, ctx->inbound.attic.line, atticlen);
|
||||||
|
ctx->inbound.attic.linelen = 0;
|
||||||
|
for (n=0; n < atticlen && line[n] != '\n'; n++)
|
||||||
|
;
|
||||||
|
if (n < atticlen)
|
||||||
|
{
|
||||||
|
rc = 0; /* found another line in the attic */
|
||||||
|
nread = atticlen;
|
||||||
|
atticlen = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* read the rest */
|
||||||
|
assert (atticlen < LINELENGTH);
|
||||||
|
rc = readline (ctx->inbound.fd, line + atticlen,
|
||||||
|
LINELENGTH - atticlen, &nread, &ctx->inbound.eof);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rc = readline (ctx->inbound.fd, line, LINELENGTH,
|
||||||
|
&nread, &ctx->inbound.eof);
|
||||||
|
if (rc)
|
||||||
|
return ASSUAN_Read_Error;
|
||||||
|
if (!nread)
|
||||||
|
{
|
||||||
|
assert (ctx->inbound.eof);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->inbound.attic.pending = 0;
|
||||||
|
nread += atticlen;
|
||||||
|
for (n=0; n < nread; n++)
|
||||||
|
{
|
||||||
|
if (line[n] == '\n')
|
||||||
|
{
|
||||||
|
if (n+1 < nread)
|
||||||
|
{
|
||||||
|
char *s, *d;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
n++;
|
||||||
|
/* we have to copy the rest because the handlers are
|
||||||
|
allowed to modify the passed buffer */
|
||||||
|
for (d=ctx->inbound.attic.line, s=line+n, i=nread-n; i; i--)
|
||||||
|
{
|
||||||
|
if (*s=='\n')
|
||||||
|
ctx->inbound.attic.pending = 1;
|
||||||
|
*d++ = *s++;
|
||||||
|
}
|
||||||
|
ctx->inbound.attic.linelen = nread-n;
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
if (n && line[n-1] == '\r')
|
||||||
|
n--;
|
||||||
|
line[n] = 0;
|
||||||
|
ctx->inbound.linelen = n;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*line = 0;
|
||||||
|
ctx->inbound.linelen = 0;
|
||||||
|
return ctx->inbound.eof? ASSUAN_Line_Not_Terminated : ASSUAN_Line_Too_Long;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Read the next line from the client or server and return a pointer
|
||||||
|
to a buffer with holding that line. linelen returns the length of
|
||||||
|
the line. This buffer is valid until another read operation is
|
||||||
|
done on this buffer. The caller is allowed to modify this buffer.
|
||||||
|
He should only use the buffer if the function returns without an
|
||||||
|
error.
|
||||||
|
|
||||||
|
Returns: 0 on success or an assuan error code
|
||||||
|
See also: assuan_pending_line().
|
||||||
|
*/
|
||||||
|
AssuanError
|
||||||
|
assuan_read_line (ASSUAN_CONTEXT ctx, char **line, size_t *linelen)
|
||||||
|
{
|
||||||
|
AssuanError err;
|
||||||
|
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
|
||||||
|
err = _assuan_read_line (ctx);
|
||||||
|
*line = ctx->inbound.line;
|
||||||
|
*linelen = ctx->inbound.linelen;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Return true when a full line is pending for a read, without the need
|
||||||
|
for actual IO */
|
||||||
|
int
|
||||||
|
assuan_pending_line (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
return ctx && ctx->inbound.attic.pending;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AssuanError
|
||||||
|
assuan_write_line (ASSUAN_CONTEXT ctx, const char *line )
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
|
||||||
|
/* fixme: we should do some kind of line buffering */
|
||||||
|
rc = writen (ctx->outbound.fd, line, strlen(line));
|
||||||
|
if (rc)
|
||||||
|
rc = ASSUAN_Write_Error;
|
||||||
|
if (!rc)
|
||||||
|
{
|
||||||
|
rc = writen (ctx->outbound.fd, "\n", 1);
|
||||||
|
if (rc)
|
||||||
|
rc = ASSUAN_Write_Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Write out the data in buffer as datalines with line wrapping and
|
||||||
|
percent escaping. This fucntion is used for GNU's custom streams */
|
||||||
|
int
|
||||||
|
_assuan_cookie_write_data (void *cookie, const char *buffer, size_t size)
|
||||||
|
{
|
||||||
|
ASSUAN_CONTEXT ctx = cookie;
|
||||||
|
char *line;
|
||||||
|
size_t linelen;
|
||||||
|
|
||||||
|
if (ctx->outbound.data.error)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
line = ctx->outbound.data.line;
|
||||||
|
linelen = ctx->outbound.data.linelen;
|
||||||
|
line += linelen;
|
||||||
|
while (size)
|
||||||
|
{
|
||||||
|
/* insert data line header */
|
||||||
|
if (!linelen)
|
||||||
|
{
|
||||||
|
*line++ = 'D';
|
||||||
|
*line++ = ' ';
|
||||||
|
linelen += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy data, keep some space for the CRLF and to escape one character */
|
||||||
|
while (size && linelen < LINELENGTH-2-2)
|
||||||
|
{
|
||||||
|
if (*buffer == '%' || *buffer == '\r' || *buffer == '\n')
|
||||||
|
{
|
||||||
|
sprintf (line, "%%%02X", *(unsigned char*)buffer);
|
||||||
|
line += 3;
|
||||||
|
linelen += 3;
|
||||||
|
buffer++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*line++ = *buffer++;
|
||||||
|
linelen++;
|
||||||
|
}
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linelen >= LINELENGTH-2-2)
|
||||||
|
{
|
||||||
|
*line++ = '\n';
|
||||||
|
linelen++;
|
||||||
|
if (writen (ctx->outbound.fd, ctx->outbound.data.line, linelen))
|
||||||
|
{
|
||||||
|
ctx->outbound.data.error = ASSUAN_Write_Error;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
line = ctx->outbound.data.line;
|
||||||
|
linelen = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->outbound.data.linelen = linelen;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Write out any buffered data
|
||||||
|
This fucntion is used for GNU's custom streams */
|
||||||
|
int
|
||||||
|
_assuan_cookie_write_flush (void *cookie)
|
||||||
|
{
|
||||||
|
ASSUAN_CONTEXT ctx = cookie;
|
||||||
|
char *line;
|
||||||
|
size_t linelen;
|
||||||
|
|
||||||
|
if (ctx->outbound.data.error)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
line = ctx->outbound.data.line;
|
||||||
|
linelen = ctx->outbound.data.linelen;
|
||||||
|
line += linelen;
|
||||||
|
if (linelen)
|
||||||
|
{
|
||||||
|
*line++ = '\n';
|
||||||
|
linelen++;
|
||||||
|
if (writen (ctx->outbound.fd, ctx->outbound.data.line, linelen))
|
||||||
|
{
|
||||||
|
ctx->outbound.data.error = ASSUAN_Write_Error;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ctx->outbound.data.linelen = 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assuan_send_data:
|
||||||
|
* @ctx: An assuan context
|
||||||
|
* @buffer: Data to send or NULL to flush
|
||||||
|
* @length: length of the data to send/
|
||||||
|
*
|
||||||
|
* This function may be used by the server or the client to send data
|
||||||
|
* lines. The data will be escaped as required by the Assuan protocol
|
||||||
|
* and may get buffered until a line is full. To force sending the
|
||||||
|
* data out @buffer may be passed as NULL (in which case @length must
|
||||||
|
* also be 0); however when used by a client this flush operation does
|
||||||
|
* also send the terminating "END" command to terminate the reponse on
|
||||||
|
* a INQUIRE response. However, when assuan_transact() is used, this
|
||||||
|
* function takes care of sending END itself.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an error code
|
||||||
|
**/
|
||||||
|
|
||||||
|
AssuanError
|
||||||
|
assuan_send_data (ASSUAN_CONTEXT ctx, const void *buffer, size_t length)
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
if (!buffer && length)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
|
||||||
|
if (!buffer)
|
||||||
|
{ /* flush what we have */
|
||||||
|
_assuan_cookie_write_flush (ctx);
|
||||||
|
if (ctx->outbound.data.error)
|
||||||
|
return ctx->outbound.data.error;
|
||||||
|
if (!ctx->is_server)
|
||||||
|
return assuan_write_line (ctx, "END");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_assuan_cookie_write_data (ctx, buffer, length);
|
||||||
|
if (ctx->outbound.data.error)
|
||||||
|
return ctx->outbound.data.error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
180
tags/gpgme-0-3-0/assuan/assuan-client.c
Normal file
180
tags/gpgme-0-3-0/assuan/assuan-client.c
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
/* assuan-client.c - client functions
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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 <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
|
#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
|
||||||
|
*(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
|
||||||
|
#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
|
||||||
|
|
||||||
|
|
||||||
|
AssuanError
|
||||||
|
_assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off)
|
||||||
|
{
|
||||||
|
char *line;
|
||||||
|
int linelen;
|
||||||
|
AssuanError rc;
|
||||||
|
|
||||||
|
*okay = 0;
|
||||||
|
*off = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
rc = _assuan_read_line (ctx);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
line = ctx->inbound.line;
|
||||||
|
linelen = ctx->inbound.linelen;
|
||||||
|
}
|
||||||
|
while (*line == '#' || !linelen);
|
||||||
|
|
||||||
|
if (linelen >= 1
|
||||||
|
&& line[0] == 'D' && line[1] == ' ')
|
||||||
|
{
|
||||||
|
*okay = 2; /* data line */
|
||||||
|
*off = 2;
|
||||||
|
}
|
||||||
|
else if (linelen >= 2
|
||||||
|
&& line[0] == 'O' && line[1] == 'K'
|
||||||
|
&& (line[2] == '\0' || line[2] == ' '))
|
||||||
|
{
|
||||||
|
*okay = 1;
|
||||||
|
*off = 2;
|
||||||
|
}
|
||||||
|
else if (linelen >= 3
|
||||||
|
&& line[0] == 'E' && line[1] == 'R' && line[2] == 'R'
|
||||||
|
&& (line[3] == '\0' || line[3] == ' '))
|
||||||
|
{
|
||||||
|
*okay = 0;
|
||||||
|
*off = 3;
|
||||||
|
}
|
||||||
|
else if (linelen >= 7
|
||||||
|
&& line[0] == 'I' && line[1] == 'N' && line[2] == 'Q'
|
||||||
|
&& line[3] == 'U' && line[4] == 'I' && line[5] == 'R'
|
||||||
|
&& line[6] == 'E'
|
||||||
|
&& (line[7] == '\0' || line[7] == ' '))
|
||||||
|
{
|
||||||
|
*okay = 3;
|
||||||
|
*off = 7;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rc = ASSUAN_Invalid_Response;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assuan_transact:
|
||||||
|
* @ctx: The Assuan context
|
||||||
|
* @command: Coimmand line to be send to server
|
||||||
|
* @data_cb: Callback function for data lines
|
||||||
|
* @data_cb_arg: first argument passed to @data_cb
|
||||||
|
* @inquire_cb: Callback function for a inquire response
|
||||||
|
* @inquire_cb_arg: first argument passed to @inquire_cb
|
||||||
|
*
|
||||||
|
* FIXME: Write documentation
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or error code. The error code may be
|
||||||
|
* the one one returned by the server in error lines or from the
|
||||||
|
* callback functions.
|
||||||
|
**/
|
||||||
|
AssuanError
|
||||||
|
assuan_transact (ASSUAN_CONTEXT ctx,
|
||||||
|
const char *command,
|
||||||
|
AssuanError (*data_cb)(void *, const void *, size_t),
|
||||||
|
void *data_cb_arg,
|
||||||
|
AssuanError (*inquire_cb)(void*, const char *),
|
||||||
|
void *inquire_cb_arg)
|
||||||
|
{
|
||||||
|
int rc, okay, off;
|
||||||
|
unsigned char *line;
|
||||||
|
int linelen;
|
||||||
|
|
||||||
|
rc = assuan_write_line (ctx, command);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
again:
|
||||||
|
rc = _assuan_read_from_server (ctx, &okay, &off);
|
||||||
|
if (rc)
|
||||||
|
return rc; /* error reading from server */
|
||||||
|
|
||||||
|
line = ctx->inbound.line + off;
|
||||||
|
linelen = ctx->inbound.linelen - off;
|
||||||
|
|
||||||
|
if (!okay)
|
||||||
|
{
|
||||||
|
rc = atoi (line);
|
||||||
|
if (rc < 100)
|
||||||
|
rc = ASSUAN_Server_Fault;
|
||||||
|
}
|
||||||
|
else if (okay == 2)
|
||||||
|
{
|
||||||
|
if (!data_cb)
|
||||||
|
rc = ASSUAN_No_Data_Callback;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned char *s, *d;
|
||||||
|
|
||||||
|
for (s=d=line; linelen; linelen--)
|
||||||
|
{
|
||||||
|
if (*s == '%' && linelen > 2)
|
||||||
|
{ /* handle escaping */
|
||||||
|
s++;
|
||||||
|
*d++ = xtoi_2 (s);
|
||||||
|
s += 2;
|
||||||
|
linelen -= 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*d++ = *s++;
|
||||||
|
}
|
||||||
|
*d = 0; /* add a hidden string terminator */
|
||||||
|
rc = data_cb (data_cb_arg, line, d - line);
|
||||||
|
if (!rc)
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (okay == 3)
|
||||||
|
{
|
||||||
|
if (!inquire_cb)
|
||||||
|
{
|
||||||
|
assuan_write_line (ctx, "END"); /* get out of inquire mode */
|
||||||
|
_assuan_read_from_server (ctx, &okay, &off); /* dummy read */
|
||||||
|
rc = ASSUAN_No_Inquire_Callback;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rc = inquire_cb (inquire_cb_arg, line);
|
||||||
|
if (!rc)
|
||||||
|
rc = assuan_send_data (ctx, NULL, 0); /* flush and send END */
|
||||||
|
if (!rc)
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
246
tags/gpgme-0-3-0/assuan/assuan-connect.c
Normal file
246
tags/gpgme-0-3-0/assuan/assuan-connect.c
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
/* assuan-connect.c - Establish a connection (client)
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
|
#ifdef _POSIX_OPEN_MAX
|
||||||
|
#define MAX_OPEN_FDS _POSIX_OPEN_MAX
|
||||||
|
#else
|
||||||
|
#define MAX_OPEN_FDS 20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_JNLIB_LOGGING
|
||||||
|
#include "../jnlib/logging.h"
|
||||||
|
#define LOGERROR1(a,b) log_error ((a), (b))
|
||||||
|
#else
|
||||||
|
#define LOGERROR1(a,b) fprintf (stderr, (a), (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
writen ( int fd, const char *buffer, size_t length )
|
||||||
|
{
|
||||||
|
while (length)
|
||||||
|
{
|
||||||
|
int nwritten = write (fd, buffer, length);
|
||||||
|
|
||||||
|
if (nwritten < 0)
|
||||||
|
{
|
||||||
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
return -1; /* write error */
|
||||||
|
}
|
||||||
|
length -= nwritten;
|
||||||
|
buffer += nwritten;
|
||||||
|
}
|
||||||
|
return 0; /* okay */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Connect to a server over a pipe, creating the assuan context and
|
||||||
|
returning it in CTX. The server filename is NAME, the argument
|
||||||
|
vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file
|
||||||
|
descriptors not to close in the child. */
|
||||||
|
AssuanError
|
||||||
|
assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[],
|
||||||
|
int *fd_child_list)
|
||||||
|
{
|
||||||
|
static int fixed_signals = 0;
|
||||||
|
AssuanError err;
|
||||||
|
int rp[2];
|
||||||
|
int wp[2];
|
||||||
|
int fd[2];
|
||||||
|
|
||||||
|
if (!ctx || !name || !argv || !argv[0])
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
|
||||||
|
if (!fixed_signals)
|
||||||
|
{
|
||||||
|
struct sigaction act;
|
||||||
|
|
||||||
|
sigaction (SIGPIPE, NULL, &act);
|
||||||
|
if (act.sa_handler == SIG_DFL)
|
||||||
|
{
|
||||||
|
act.sa_handler = SIG_IGN;
|
||||||
|
sigemptyset (&act.sa_mask);
|
||||||
|
act.sa_flags = 0;
|
||||||
|
sigaction (SIGPIPE, &act, NULL);
|
||||||
|
}
|
||||||
|
fixed_signals = 1;
|
||||||
|
/* FIXME: This is not MT safe */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pipe (rp) < 0)
|
||||||
|
return ASSUAN_General_Error;
|
||||||
|
|
||||||
|
if (pipe (wp) < 0)
|
||||||
|
{
|
||||||
|
close (rp[0]);
|
||||||
|
close (rp[1]);
|
||||||
|
return ASSUAN_General_Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
fd[0] = rp[0]; /* Our inbound is read end of read pipe. */
|
||||||
|
fd[1] = wp[1]; /* Our outbound is write end of write pipe. */
|
||||||
|
|
||||||
|
err = assuan_init_pipe_server (ctx, fd); /* FIXME: Common code should be factored out. */
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
close (rp[0]);
|
||||||
|
close (rp[1]);
|
||||||
|
close (wp[0]);
|
||||||
|
close (wp[1]);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
(*ctx)->is_server = 0;
|
||||||
|
|
||||||
|
(*ctx)->pid = fork ();
|
||||||
|
if ((*ctx)->pid < 0)
|
||||||
|
{
|
||||||
|
close (rp[0]);
|
||||||
|
close (rp[1]);
|
||||||
|
close (wp[0]);
|
||||||
|
close (wp[1]);
|
||||||
|
assuan_deinit_pipe_server (*ctx); /* FIXME: Common code should be factored out. */
|
||||||
|
return ASSUAN_General_Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*ctx)->pid == 0)
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
char errbuf[512];
|
||||||
|
#ifdef HAVE_JNLIB_LOGGING
|
||||||
|
int log_fd = log_get_fd ();
|
||||||
|
#endif
|
||||||
|
/* close all files which will not be duped but keep stderr
|
||||||
|
and log_stream for now */
|
||||||
|
n = sysconf (_SC_OPEN_MAX);
|
||||||
|
if (n < 0)
|
||||||
|
n = MAX_OPEN_FDS;
|
||||||
|
for (i=0; i < n; i++)
|
||||||
|
{
|
||||||
|
int *fdp = fd_child_list;
|
||||||
|
|
||||||
|
if (fdp)
|
||||||
|
{
|
||||||
|
while (*fdp != -1 && *fdp != i)
|
||||||
|
fdp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(fdp && *fdp != -1)
|
||||||
|
&& i != fileno (stderr)
|
||||||
|
#ifdef HAVE_JNLIB_LOGGING
|
||||||
|
&& i != log_fd
|
||||||
|
#endif
|
||||||
|
&& i != rp[1] && i != wp[0])
|
||||||
|
close(i);
|
||||||
|
}
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
|
/* Dup handles and to stdin/stdout and exec */
|
||||||
|
if (rp[1] != STDOUT_FILENO)
|
||||||
|
{
|
||||||
|
if (dup2 (rp[1], STDOUT_FILENO) == -1)
|
||||||
|
{
|
||||||
|
LOGERROR1 ("dup2 failed in child: %s\n", strerror (errno));
|
||||||
|
_exit (4);
|
||||||
|
}
|
||||||
|
close (rp[1]);
|
||||||
|
}
|
||||||
|
if (wp[0] != STDIN_FILENO)
|
||||||
|
{
|
||||||
|
if (dup2 (wp[0], STDIN_FILENO) == -1)
|
||||||
|
{
|
||||||
|
LOGERROR1 ("dup2 failed in child: %s\n", strerror (errno));
|
||||||
|
_exit (4);
|
||||||
|
}
|
||||||
|
close (wp[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
execv (name, argv);
|
||||||
|
/* oops - use the pipe to tell the parent about it */
|
||||||
|
snprintf (errbuf, sizeof(errbuf)-1, "ERR %d can't exec `%s': %.50s\n",
|
||||||
|
ASSUAN_Problem_Starting_Server, name, strerror (errno));
|
||||||
|
errbuf[sizeof(errbuf)-1] = 0;
|
||||||
|
writen (1, errbuf, strlen (errbuf));
|
||||||
|
_exit (4);
|
||||||
|
}
|
||||||
|
|
||||||
|
close (rp[1]);
|
||||||
|
close (wp[0]);
|
||||||
|
|
||||||
|
/* initial handshake */
|
||||||
|
{
|
||||||
|
int okay, off;
|
||||||
|
|
||||||
|
err = _assuan_read_from_server (*ctx, &okay, &off);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
LOGERROR1 ("can't connect server: %s\n", assuan_strerror (err));
|
||||||
|
}
|
||||||
|
else if (okay != 1)
|
||||||
|
{
|
||||||
|
LOGERROR1 ("can't connect server: `%s'\n", (*ctx)->inbound.line);
|
||||||
|
err = ASSUAN_Connect_Failed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
if ((*ctx)->pid != -1)
|
||||||
|
waitpid ((*ctx)->pid, NULL, 0); /* FIXME Check return value. */
|
||||||
|
assuan_deinit_pipe_server (*ctx); /* FIXME: Common code should be factored out. */
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
assuan_pipe_disconnect (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
assuan_write_line (ctx, "BYE");
|
||||||
|
close (ctx->inbound.fd);
|
||||||
|
close (ctx->outbound.fd);
|
||||||
|
waitpid (ctx->pid, NULL, 0); /* FIXME Check return value. */
|
||||||
|
assuan_deinit_pipe_server (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
assuan_get_pid (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
return ctx ? ctx->pid : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
125
tags/gpgme-0-3-0/assuan/assuan-defs.h
Normal file
125
tags/gpgme-0-3-0/assuan/assuan-defs.h
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/* assuan-defs.c - Internal definitions to Assuan
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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 ASSUAN_DEFS_H
|
||||||
|
#define ASSUAN_DEFS_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include "assuan.h"
|
||||||
|
|
||||||
|
#define LINELENGTH ASSUAN_LINELENGTH
|
||||||
|
|
||||||
|
struct cmdtbl_s {
|
||||||
|
const char *name;
|
||||||
|
int cmd_id;
|
||||||
|
int (*handler)(ASSUAN_CONTEXT, char *line);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct assuan_context_s {
|
||||||
|
AssuanError err_no;
|
||||||
|
const char *err_str;
|
||||||
|
|
||||||
|
int is_server; /* set if this is context belongs to a server */
|
||||||
|
int in_inquire;
|
||||||
|
char *hello_line;
|
||||||
|
|
||||||
|
void *user_pointer; /* for assuan_[gs]et_pointer () */
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int fd;
|
||||||
|
int eof;
|
||||||
|
char line[LINELENGTH];
|
||||||
|
int linelen; /* w/o CR, LF - might not be the same as
|
||||||
|
strlen(line) due to embedded nuls. However a nul
|
||||||
|
is always written at this pos */
|
||||||
|
struct {
|
||||||
|
char line[LINELENGTH];
|
||||||
|
int linelen ;
|
||||||
|
int pending; /* i.e. at least one line is available in the attic */
|
||||||
|
} attic;
|
||||||
|
} inbound;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int fd;
|
||||||
|
struct {
|
||||||
|
FILE *fp;
|
||||||
|
char line[LINELENGTH];
|
||||||
|
int linelen;
|
||||||
|
int error;
|
||||||
|
} data;
|
||||||
|
} outbound;
|
||||||
|
|
||||||
|
int pipe_mode; /* We are in pipe mode, i.e. we can handle just one
|
||||||
|
connection and must terminate then */
|
||||||
|
pid_t pid; /* In pipe mode, the pid of the child server process. */
|
||||||
|
|
||||||
|
struct cmdtbl_s *cmdtbl;
|
||||||
|
size_t cmdtbl_used; /* used entries */
|
||||||
|
size_t cmdtbl_size; /* allocated size of table */
|
||||||
|
|
||||||
|
void (*bye_notify_fnc)(ASSUAN_CONTEXT);
|
||||||
|
void (*reset_notify_fnc)(ASSUAN_CONTEXT);
|
||||||
|
void (*cancel_notify_fnc)(ASSUAN_CONTEXT);
|
||||||
|
void (*input_notify_fnc)(ASSUAN_CONTEXT, const char *);
|
||||||
|
void (*output_notify_fnc)(ASSUAN_CONTEXT, const char *);
|
||||||
|
|
||||||
|
|
||||||
|
int input_fd; /* set by INPUT command */
|
||||||
|
int output_fd; /* set by OUTPUT command */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*-- assuan-handler.c --*/
|
||||||
|
int _assuan_register_std_commands (ASSUAN_CONTEXT ctx);
|
||||||
|
|
||||||
|
/*-- assuan-buffer.c --*/
|
||||||
|
int _assuan_read_line (ASSUAN_CONTEXT ctx);
|
||||||
|
int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size);
|
||||||
|
int _assuan_cookie_write_flush (void *cookie);
|
||||||
|
|
||||||
|
/*-- assuan-client.c --*/
|
||||||
|
AssuanError _assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off);
|
||||||
|
|
||||||
|
|
||||||
|
/*-- assuan-util.c --*/
|
||||||
|
void *_assuan_malloc (size_t n);
|
||||||
|
void *_assuan_calloc (size_t n, size_t m);
|
||||||
|
void *_assuan_realloc (void *p, size_t n);
|
||||||
|
void _assuan_free (void *p);
|
||||||
|
|
||||||
|
#define xtrymalloc(a) _assuan_malloc ((a))
|
||||||
|
#define xtrycalloc(a,b) _assuan_calloc ((a),(b))
|
||||||
|
#define xtryrealloc(a,b) _assuan_realloc((a),(b))
|
||||||
|
#define xfree(a) _assuan_free ((a))
|
||||||
|
|
||||||
|
#define set_error(c,e,t) assuan_set_error ((c), ASSUAN_ ## e, (t))
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*ASSUAN_DEFS_H*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
561
tags/gpgme-0-3-0/assuan/assuan-handler.c
Normal file
561
tags/gpgme-0-3-0/assuan/assuan-handler.c
Normal file
@ -0,0 +1,561 @@
|
|||||||
|
/* assuan-handler.c - dispatch commands
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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 <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
|
#define digitp(a) ((a) >= '0' && (a) <= '9')
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
dummy_handler (ASSUAN_CONTEXT ctx, char *line)
|
||||||
|
{
|
||||||
|
return set_error (ctx, Server_Fault, "no handler registered");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
std_handler_nop (ASSUAN_CONTEXT ctx, char *line)
|
||||||
|
{
|
||||||
|
return 0; /* okay */
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
std_handler_cancel (ASSUAN_CONTEXT ctx, char *line)
|
||||||
|
{
|
||||||
|
if (ctx->cancel_notify_fnc)
|
||||||
|
ctx->cancel_notify_fnc (ctx);
|
||||||
|
return set_error (ctx, Not_Implemented, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
std_handler_bye (ASSUAN_CONTEXT ctx, char *line)
|
||||||
|
{
|
||||||
|
if (ctx->bye_notify_fnc)
|
||||||
|
ctx->bye_notify_fnc (ctx);
|
||||||
|
assuan_close_input_fd (ctx);
|
||||||
|
assuan_close_output_fd (ctx);
|
||||||
|
return -1; /* pretty simple :-) */
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
std_handler_auth (ASSUAN_CONTEXT ctx, char *line)
|
||||||
|
{
|
||||||
|
return set_error (ctx, Not_Implemented, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
std_handler_reset (ASSUAN_CONTEXT ctx, char *line)
|
||||||
|
{
|
||||||
|
if (ctx->reset_notify_fnc)
|
||||||
|
ctx->reset_notify_fnc (ctx);
|
||||||
|
assuan_close_input_fd (ctx);
|
||||||
|
assuan_close_output_fd (ctx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
std_handler_end (ASSUAN_CONTEXT ctx, char *line)
|
||||||
|
{
|
||||||
|
return set_error (ctx, Not_Implemented, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
parse_cmd_input_output (ASSUAN_CONTEXT ctx, char *line, int *rfd)
|
||||||
|
{
|
||||||
|
char *endp;
|
||||||
|
|
||||||
|
if (strncmp (line, "FD=", 3))
|
||||||
|
return set_error (ctx, Syntax_Error, "FD=<n> expected");
|
||||||
|
line += 3;
|
||||||
|
if (!digitp (*line))
|
||||||
|
return set_error (ctx, Syntax_Error, "number required");
|
||||||
|
*rfd = strtoul (line, &endp, 10);
|
||||||
|
/* remove that argument so that a notify handler won't see it */
|
||||||
|
memset (line, ' ', endp? (endp-line):strlen(line));
|
||||||
|
|
||||||
|
if (*rfd == ctx->inbound.fd)
|
||||||
|
return set_error (ctx, Parameter_Conflict, "fd same as inbound fd");
|
||||||
|
if (*rfd == ctx->outbound.fd)
|
||||||
|
return set_error (ctx, Parameter_Conflict, "fd same as outbound fd");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Format is INPUT FD=<n> */
|
||||||
|
static int
|
||||||
|
std_handler_input (ASSUAN_CONTEXT ctx, char *line)
|
||||||
|
{
|
||||||
|
int rc, fd;
|
||||||
|
|
||||||
|
rc = parse_cmd_input_output (ctx, line, &fd);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
ctx->input_fd = fd;
|
||||||
|
if (ctx->input_notify_fnc)
|
||||||
|
ctx->input_notify_fnc (ctx, line);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Format is OUTPUT FD=<n> */
|
||||||
|
static int
|
||||||
|
std_handler_output (ASSUAN_CONTEXT ctx, char *line)
|
||||||
|
{
|
||||||
|
int rc, fd;
|
||||||
|
|
||||||
|
rc = parse_cmd_input_output (ctx, line, &fd);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
ctx->output_fd = fd;
|
||||||
|
if (ctx->output_notify_fnc)
|
||||||
|
ctx->output_notify_fnc (ctx, line);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* This is a table with the standard commands and handler for them.
|
||||||
|
The table is used to initialize a new context and assuciate strings
|
||||||
|
and handlers with cmd_ids */
|
||||||
|
static struct {
|
||||||
|
const char *name;
|
||||||
|
int cmd_id;
|
||||||
|
int (*handler)(ASSUAN_CONTEXT, char *line);
|
||||||
|
int always; /* always initialize this command */
|
||||||
|
} std_cmd_table[] = {
|
||||||
|
{ "NOP", ASSUAN_CMD_NOP, std_handler_nop, 1 },
|
||||||
|
{ "CANCEL", ASSUAN_CMD_CANCEL, std_handler_cancel, 1 },
|
||||||
|
{ "BYE", ASSUAN_CMD_BYE, std_handler_bye, 1 },
|
||||||
|
{ "AUTH", ASSUAN_CMD_AUTH, std_handler_auth, 1 },
|
||||||
|
{ "RESET", ASSUAN_CMD_RESET, std_handler_reset, 1 },
|
||||||
|
{ "END", ASSUAN_CMD_END, std_handler_end, 1 },
|
||||||
|
|
||||||
|
{ "INPUT", ASSUAN_CMD_INPUT, std_handler_input },
|
||||||
|
{ "OUTPUT", ASSUAN_CMD_OUTPUT, std_handler_output },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assuan_register_command:
|
||||||
|
* @ctx: the server context
|
||||||
|
* @cmd_id: An ID value for the command
|
||||||
|
* @cmd_name: A string with the command name
|
||||||
|
* @handler: The handler function to be called
|
||||||
|
*
|
||||||
|
* Register a handler to be used for a given command.
|
||||||
|
*
|
||||||
|
* The @cmd_name must be %NULL or an empty string for all @cmd_ids
|
||||||
|
* below %ASSUAN_CMD_USER because predefined values are used.
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
assuan_register_command (ASSUAN_CONTEXT ctx,
|
||||||
|
int cmd_id, const char *cmd_name,
|
||||||
|
int (*handler)(ASSUAN_CONTEXT, char *))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (cmd_name && !*cmd_name)
|
||||||
|
cmd_name = NULL;
|
||||||
|
|
||||||
|
if (cmd_id < ASSUAN_CMD_USER)
|
||||||
|
{
|
||||||
|
if (cmd_name)
|
||||||
|
return ASSUAN_Invalid_Value; /* must be NULL for these values*/
|
||||||
|
|
||||||
|
for (i=0; std_cmd_table[i].name; i++)
|
||||||
|
{
|
||||||
|
if (std_cmd_table[i].cmd_id == cmd_id)
|
||||||
|
{
|
||||||
|
cmd_name = std_cmd_table[i].name;
|
||||||
|
if (!handler)
|
||||||
|
handler = std_cmd_table[i].handler;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!std_cmd_table[i].name)
|
||||||
|
return ASSUAN_Invalid_Value; /* not a pre-registered one */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!handler)
|
||||||
|
handler = dummy_handler;
|
||||||
|
|
||||||
|
if (!cmd_name)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
|
||||||
|
/* fprintf (stderr, "DBG-assuan: registering %d as `%s'\n", cmd_id, cmd_name); */
|
||||||
|
|
||||||
|
if (!ctx->cmdtbl)
|
||||||
|
{
|
||||||
|
ctx->cmdtbl_size = 50;
|
||||||
|
ctx->cmdtbl = xtrycalloc ( ctx->cmdtbl_size, sizeof *ctx->cmdtbl);
|
||||||
|
if (!ctx->cmdtbl)
|
||||||
|
return ASSUAN_Out_Of_Core;
|
||||||
|
ctx->cmdtbl_used = 0;
|
||||||
|
}
|
||||||
|
else if (ctx->cmdtbl_used >= ctx->cmdtbl_size)
|
||||||
|
{
|
||||||
|
struct cmdtbl_s *x;
|
||||||
|
|
||||||
|
x = xtryrealloc ( ctx->cmdtbl, (ctx->cmdtbl_size+10) * sizeof *x);
|
||||||
|
if (!x)
|
||||||
|
return ASSUAN_Out_Of_Core;
|
||||||
|
ctx->cmdtbl = x;
|
||||||
|
ctx->cmdtbl_size += 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->cmdtbl[ctx->cmdtbl_used].name = cmd_name;
|
||||||
|
ctx->cmdtbl[ctx->cmdtbl_used].cmd_id = cmd_id;
|
||||||
|
ctx->cmdtbl[ctx->cmdtbl_used].handler = handler;
|
||||||
|
ctx->cmdtbl_used++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
assuan_register_bye_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT))
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
ctx->bye_notify_fnc = fnc;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
assuan_register_reset_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT))
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
ctx->reset_notify_fnc = fnc;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
assuan_register_cancel_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT))
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
ctx->cancel_notify_fnc = fnc;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
assuan_register_input_notify (ASSUAN_CONTEXT ctx,
|
||||||
|
void (*fnc)(ASSUAN_CONTEXT, const char *))
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
ctx->input_notify_fnc = fnc;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
assuan_register_output_notify (ASSUAN_CONTEXT ctx,
|
||||||
|
void (*fnc)(ASSUAN_CONTEXT, const char *))
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
ctx->output_notify_fnc = fnc;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Helper to register the standards commands */
|
||||||
|
int
|
||||||
|
_assuan_register_std_commands (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
int i, rc;
|
||||||
|
|
||||||
|
for (i=0; std_cmd_table[i].name; i++)
|
||||||
|
{
|
||||||
|
if (std_cmd_table[i].always)
|
||||||
|
{
|
||||||
|
rc = assuan_register_command (ctx, std_cmd_table[i].cmd_id,
|
||||||
|
NULL, NULL);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Process the special data lines. The "D " has already been removed
|
||||||
|
from the line. As all handlers this function may modify the line. */
|
||||||
|
static int
|
||||||
|
handle_data_line (ASSUAN_CONTEXT ctx, char *line, int linelen)
|
||||||
|
{
|
||||||
|
return set_error (ctx, Not_Implemented, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Parse the line, break out the command, find it in the command
|
||||||
|
table, remove leading and white spaces from the arguments, all the
|
||||||
|
handler with the argument line and return the error */
|
||||||
|
static int
|
||||||
|
dispatch_command (ASSUAN_CONTEXT ctx, char *line, int linelen)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
const char *s;
|
||||||
|
int shift, i;
|
||||||
|
|
||||||
|
if (*line == 'D' && line[1] == ' ') /* divert to special handler */
|
||||||
|
return handle_data_line (ctx, line+2, linelen-2);
|
||||||
|
|
||||||
|
for (p=line; *p && *p != ' ' && *p != '\t'; p++)
|
||||||
|
;
|
||||||
|
if (p==line)
|
||||||
|
return set_error (ctx, Invalid_Command, "leading white-space");
|
||||||
|
if (*p)
|
||||||
|
{ /* Skip over leading WS after the keyword */
|
||||||
|
*p++ = 0;
|
||||||
|
while ( *p == ' ' || *p == '\t')
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
shift = p - line;
|
||||||
|
|
||||||
|
for (i=0; (s=ctx->cmdtbl[i].name); i++)
|
||||||
|
if (!strcmp (line, s))
|
||||||
|
break;
|
||||||
|
if (!s)
|
||||||
|
return set_error (ctx, Unknown_Command, NULL);
|
||||||
|
line += shift;
|
||||||
|
linelen -= shift;
|
||||||
|
|
||||||
|
/* fprintf (stderr, "DBG-assuan: processing %s `%s'\n", s, line); */
|
||||||
|
return ctx->cmdtbl[i].handler (ctx, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
process_request (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (ctx->in_inquire)
|
||||||
|
return ASSUAN_Nested_Commands;
|
||||||
|
|
||||||
|
rc = _assuan_read_line (ctx);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
if (*ctx->inbound.line == '#' || !ctx->inbound.linelen)
|
||||||
|
return 0; /* comment line - ignore */
|
||||||
|
|
||||||
|
ctx->outbound.data.error = 0;
|
||||||
|
ctx->outbound.data.linelen = 0;
|
||||||
|
/* dispatch command and return reply */
|
||||||
|
rc = dispatch_command (ctx, ctx->inbound.line, ctx->inbound.linelen);
|
||||||
|
/* check from data write errors */
|
||||||
|
if (ctx->outbound.data.fp)
|
||||||
|
{ /* Flush the data lines */
|
||||||
|
fclose (ctx->outbound.data.fp);
|
||||||
|
ctx->outbound.data.fp = NULL;
|
||||||
|
if (!rc && ctx->outbound.data.error)
|
||||||
|
rc = ctx->outbound.data.error;
|
||||||
|
}
|
||||||
|
/* Error handling */
|
||||||
|
if (!rc)
|
||||||
|
{
|
||||||
|
rc = assuan_write_line (ctx, "OK");
|
||||||
|
}
|
||||||
|
else if (rc == -1)
|
||||||
|
{ /* No error checking because the peer may have already disconnect */
|
||||||
|
assuan_write_line (ctx, "OK closing connection");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char errline[256];
|
||||||
|
|
||||||
|
if (rc < 100)
|
||||||
|
sprintf (errline, "ERR %d server fault (%.50s)",
|
||||||
|
ASSUAN_Server_Fault, assuan_strerror (rc));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char *text = ctx->err_no == rc? ctx->err_str:NULL;
|
||||||
|
|
||||||
|
sprintf (errline, "ERR %d %.50s%s%.100s",
|
||||||
|
rc, assuan_strerror (rc), text? " - ":"", text?text:"");
|
||||||
|
}
|
||||||
|
rc = assuan_write_line (ctx, errline);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assuan_process:
|
||||||
|
* @ctx: assuan context
|
||||||
|
*
|
||||||
|
* This fucntion is used to handle the assuan protocol after a
|
||||||
|
* connection has been established using assuan_accept(). This is the
|
||||||
|
* main protocol handler.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an error code if the assuan operation
|
||||||
|
* failed. Note, that no error is returned for operational errors.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
assuan_process (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
do {
|
||||||
|
rc = process_request (ctx);
|
||||||
|
} while (!rc);
|
||||||
|
|
||||||
|
if (rc == -1)
|
||||||
|
rc = 0;
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assuan_process_next:
|
||||||
|
* @ctx: Assuan context
|
||||||
|
*
|
||||||
|
* Same as assuan_process() but the user has to provide the outer
|
||||||
|
* loop. He should loop as long as the return code is zero and stop
|
||||||
|
* otherwise; -1 is regular end.
|
||||||
|
*
|
||||||
|
* See also: assuan_get_active_fds()
|
||||||
|
* Return value: -1 for end of server, 0 on success or an error code
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
assuan_process_next (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
return process_request (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assuan_get_active_fds:
|
||||||
|
* @ctx: Assuan context
|
||||||
|
* @what: 0 for read fds, 1 for write fds
|
||||||
|
* @fdarray: Caller supplied array to store the FDs
|
||||||
|
* @fdarraysize: size of that array
|
||||||
|
*
|
||||||
|
* Return all active filedescriptors for the given context. This
|
||||||
|
* function can be used to select on the fds and call
|
||||||
|
* assuan_process_next() if there is an active one. The first fd in
|
||||||
|
* the array is the one used for the command connection.
|
||||||
|
*
|
||||||
|
* Note, that write FDs are not yet supported.
|
||||||
|
*
|
||||||
|
* Return value: number of FDs active and put into @fdarray or -1 on
|
||||||
|
* error which is most likely a too small fdarray.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
assuan_get_active_fds (ASSUAN_CONTEXT ctx, int what,
|
||||||
|
int *fdarray, int fdarraysize)
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (!ctx || fdarraysize < 2 || what < 0 || what > 1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!what)
|
||||||
|
{
|
||||||
|
if (ctx->inbound.fd != -1)
|
||||||
|
fdarray[n++] = ctx->inbound.fd;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ctx->outbound.fd != -1)
|
||||||
|
fdarray[n++] = ctx->outbound.fd;
|
||||||
|
if (ctx->outbound.data.fp)
|
||||||
|
fdarray[n++] = fileno (ctx->outbound.data.fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return a FP to be used for data output. The FILE pointer is valid
|
||||||
|
until the end of a handler. So a close is not needed. Assuan does
|
||||||
|
all the buffering needed to insert the status line as well as the
|
||||||
|
required line wappping and quoting for data lines.
|
||||||
|
|
||||||
|
We use GNU's custom streams here. There should be an alternative
|
||||||
|
implementaion for systems w/o a glibc, a simple implementation
|
||||||
|
could use a child process */
|
||||||
|
FILE *
|
||||||
|
assuan_get_data_fp (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
cookie_io_functions_t cookie_fnc;
|
||||||
|
|
||||||
|
if (ctx->outbound.data.fp)
|
||||||
|
return ctx->outbound.data.fp;
|
||||||
|
|
||||||
|
cookie_fnc.read = NULL;
|
||||||
|
cookie_fnc.write = _assuan_cookie_write_data;
|
||||||
|
cookie_fnc.seek = NULL;
|
||||||
|
cookie_fnc.close = _assuan_cookie_write_flush;
|
||||||
|
|
||||||
|
ctx->outbound.data.fp = fopencookie (ctx, "wb", cookie_fnc);
|
||||||
|
ctx->outbound.data.error = 0;
|
||||||
|
return ctx->outbound.data.fp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
assuan_write_status (ASSUAN_CONTEXT ctx, const char *keyword, const char *text)
|
||||||
|
{
|
||||||
|
char buffer[256];
|
||||||
|
char *helpbuf;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
|
if ( !ctx || !keyword)
|
||||||
|
return;
|
||||||
|
if (!text)
|
||||||
|
text = "";
|
||||||
|
|
||||||
|
n = 2 + strlen (keyword) + 1 + strlen (text) + 1;
|
||||||
|
if (n < sizeof (buffer))
|
||||||
|
{
|
||||||
|
strcpy (buffer, "S ");
|
||||||
|
strcat (buffer, keyword);
|
||||||
|
if (*text)
|
||||||
|
{
|
||||||
|
strcat (buffer, " ");
|
||||||
|
strcat (buffer, text);
|
||||||
|
}
|
||||||
|
assuan_write_line (ctx, buffer);
|
||||||
|
}
|
||||||
|
else if ( (helpbuf = xtrymalloc (n)) )
|
||||||
|
{
|
||||||
|
strcpy (helpbuf, "S ");
|
||||||
|
strcat (helpbuf, keyword);
|
||||||
|
if (*text)
|
||||||
|
{
|
||||||
|
strcat (helpbuf, " ");
|
||||||
|
strcat (helpbuf, text);
|
||||||
|
}
|
||||||
|
assuan_write_line (ctx, helpbuf);
|
||||||
|
xfree (helpbuf);
|
||||||
|
}
|
||||||
|
}
|
220
tags/gpgme-0-3-0/assuan/assuan-inquire.c
Normal file
220
tags/gpgme-0-3-0/assuan/assuan-inquire.c
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
/* assuan-inquire.c - handle inquire stuff
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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 <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
|
#define digitp(a) ((a) >= '0' && (a) <= '9')
|
||||||
|
#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
|
||||||
|
*(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
|
||||||
|
#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
|
||||||
|
|
||||||
|
|
||||||
|
struct membuf {
|
||||||
|
size_t len;
|
||||||
|
size_t size;
|
||||||
|
char *buf;
|
||||||
|
int out_of_core;
|
||||||
|
int too_large;
|
||||||
|
size_t maxlen;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* A simple implemnation of a dynamic buffer. Use init_membuf() to
|
||||||
|
create a buffer, put_membuf to append bytes and get_membuf to
|
||||||
|
release and return the buffer. Allocation errors are detected but
|
||||||
|
only returned at the final get_membuf(), this helps not to clutter
|
||||||
|
the code with out of core checks. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_membuf (struct membuf *mb, int initiallen, size_t maxlen)
|
||||||
|
{
|
||||||
|
mb->len = 0;
|
||||||
|
mb->size = initiallen;
|
||||||
|
mb->out_of_core = 0;
|
||||||
|
mb->too_large = 0;
|
||||||
|
mb->maxlen = maxlen;
|
||||||
|
mb->buf = xtrymalloc (initiallen);
|
||||||
|
if (!mb->buf)
|
||||||
|
mb->out_of_core = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
put_membuf (struct membuf *mb, const void *buf, size_t len)
|
||||||
|
{
|
||||||
|
if (mb->out_of_core || mb->too_large)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (mb->maxlen && mb->len + len > mb->maxlen)
|
||||||
|
{
|
||||||
|
mb->too_large = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mb->len + len >= mb->size)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
mb->size += len + 1024;
|
||||||
|
p = xtryrealloc (mb->buf, mb->size);
|
||||||
|
if (!p)
|
||||||
|
{
|
||||||
|
mb->out_of_core = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mb->buf = p;
|
||||||
|
}
|
||||||
|
memcpy (mb->buf + mb->len, buf, len);
|
||||||
|
mb->len += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
get_membuf (struct membuf *mb, size_t *len)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (mb->out_of_core || mb->too_large)
|
||||||
|
{
|
||||||
|
xfree (mb->buf);
|
||||||
|
mb->buf = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = mb->buf;
|
||||||
|
*len = mb->len;
|
||||||
|
mb->buf = NULL;
|
||||||
|
mb->out_of_core = 1; /* don't allow a reuse */
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_membuf (struct membuf *mb)
|
||||||
|
{
|
||||||
|
xfree (mb->buf);
|
||||||
|
mb->buf = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assuan_inquire:
|
||||||
|
* @ctx: An assuan context
|
||||||
|
* @keyword: The keyword used for the inquire
|
||||||
|
* @r_buffer: Returns an allocated buffer
|
||||||
|
* @r_length: Returns the length of this buffer
|
||||||
|
* @maxlen: If no 0, the size limit of the inquired data.
|
||||||
|
*
|
||||||
|
* A Server may use this to Send an inquire
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an ASSUAN error code
|
||||||
|
**/
|
||||||
|
AssuanError
|
||||||
|
assuan_inquire (ASSUAN_CONTEXT ctx, const char *keyword,
|
||||||
|
char **r_buffer, size_t *r_length, size_t maxlen)
|
||||||
|
{
|
||||||
|
AssuanError rc;
|
||||||
|
struct membuf mb;
|
||||||
|
char cmdbuf[100];
|
||||||
|
unsigned char *line, *p;
|
||||||
|
int linelen;
|
||||||
|
|
||||||
|
if (!ctx || !keyword || (10 + strlen (keyword) >= sizeof (cmdbuf))
|
||||||
|
|| !r_buffer || !r_length )
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
if (!ctx->is_server)
|
||||||
|
return ASSUAN_Not_A_Server;
|
||||||
|
if (ctx->in_inquire)
|
||||||
|
return ASSUAN_Nested_Commands;
|
||||||
|
|
||||||
|
ctx->in_inquire = 1;
|
||||||
|
init_membuf (&mb, maxlen? maxlen:1024, maxlen);
|
||||||
|
|
||||||
|
strcpy (stpcpy (cmdbuf, "INQUIRE "), keyword);
|
||||||
|
rc = assuan_write_line (ctx, cmdbuf);
|
||||||
|
if (rc)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
rc = _assuan_read_line (ctx);
|
||||||
|
if (rc)
|
||||||
|
goto leave;
|
||||||
|
line = ctx->inbound.line;
|
||||||
|
linelen = ctx->inbound.linelen;
|
||||||
|
}
|
||||||
|
while (*line == '#' || !linelen);
|
||||||
|
if (line[0] == 'E' && line[1] == 'N' && line[2] == 'D'
|
||||||
|
&& (!line[3] || line[3] == ' '))
|
||||||
|
break; /* END command received*/
|
||||||
|
if (line[0] != 'D' || line[1] != ' ')
|
||||||
|
{
|
||||||
|
rc = ASSUAN_Unexpected_Command;
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
if (linelen < 3)
|
||||||
|
continue;
|
||||||
|
line += 2;
|
||||||
|
linelen -= 2;
|
||||||
|
|
||||||
|
p = line;
|
||||||
|
while (linelen)
|
||||||
|
{
|
||||||
|
for (;linelen && *p != '%'; linelen--, p++)
|
||||||
|
;
|
||||||
|
put_membuf (&mb, line, p-line);
|
||||||
|
if (linelen > 2)
|
||||||
|
{ /* handle escaping */
|
||||||
|
unsigned char tmp[1];
|
||||||
|
p++;
|
||||||
|
*tmp = xtoi_2 (p);
|
||||||
|
p += 2;
|
||||||
|
linelen -= 3;
|
||||||
|
put_membuf (&mb, tmp, 1);
|
||||||
|
}
|
||||||
|
line = p;
|
||||||
|
}
|
||||||
|
if (mb.too_large)
|
||||||
|
{
|
||||||
|
rc = ASSUAN_Too_Much_Data;
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*r_buffer = get_membuf (&mb, r_length);
|
||||||
|
if (!*r_buffer)
|
||||||
|
rc = ASSUAN_Out_Of_Core;
|
||||||
|
|
||||||
|
leave:
|
||||||
|
free_membuf (&mb);
|
||||||
|
ctx->in_inquire = 0;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
134
tags/gpgme-0-3-0/assuan/assuan-listen.c
Normal file
134
tags/gpgme-0-3-0/assuan/assuan-listen.c
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
/* assuan-listen.c - Wait for a connection (server)
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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 <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
|
AssuanError
|
||||||
|
assuan_set_hello_line (ASSUAN_CONTEXT ctx, const char *line)
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
if (!line)
|
||||||
|
{
|
||||||
|
xfree (ctx->hello_line);
|
||||||
|
ctx->hello_line = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *buf = xtrymalloc (3+strlen(line)+1);
|
||||||
|
if (!buf)
|
||||||
|
return ASSUAN_Out_Of_Core;
|
||||||
|
strcpy (buf, "OK ");
|
||||||
|
strcpy (buf+3, line);
|
||||||
|
xfree (ctx->hello_line);
|
||||||
|
ctx->hello_line = buf;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assuan_accept:
|
||||||
|
* @ctx: context
|
||||||
|
*
|
||||||
|
* Cancel any existing connectiion and wait for a connection from a
|
||||||
|
* client. The initial handshake is performed which may include an
|
||||||
|
* initial authentication or encryption negotiation.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an error if the connection could for
|
||||||
|
* some reason not be established.
|
||||||
|
**/
|
||||||
|
AssuanError
|
||||||
|
assuan_accept (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
|
||||||
|
/* fixme: cancel existing connection */
|
||||||
|
if (ctx->pipe_mode > 1)
|
||||||
|
return -1; /* second invocation for pipemode -> terminate */
|
||||||
|
|
||||||
|
if (!ctx->pipe_mode)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* fixme: wait for request */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send the hello */
|
||||||
|
rc = assuan_write_line (ctx, ctx->hello_line? ctx->hello_line
|
||||||
|
: "OK Your orders please");
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
if (ctx->pipe_mode)
|
||||||
|
ctx->pipe_mode = 2;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
assuan_get_input_fd (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
return ctx? ctx->input_fd : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
assuan_get_output_fd (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
return ctx? ctx->output_fd : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Close the fd descriptor set by the command INPUT FD=n. We handle
|
||||||
|
this fd inside assuan so that we can do some initial checks */
|
||||||
|
AssuanError
|
||||||
|
assuan_close_input_fd (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
if (!ctx || ctx->input_fd == -1)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
close (ctx->input_fd);
|
||||||
|
ctx->input_fd = -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the fd descriptor set by the command OUTPUT FD=n. We handle
|
||||||
|
this fd inside assuan so that we can do some initial checks */
|
||||||
|
AssuanError
|
||||||
|
assuan_close_output_fd (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
if (!ctx || ctx->output_fd == -1)
|
||||||
|
return ASSUAN_Invalid_Value;
|
||||||
|
|
||||||
|
close (ctx->output_fd);
|
||||||
|
ctx->output_fd = -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
73
tags/gpgme-0-3-0/assuan/assuan-pipe-server.c
Normal file
73
tags/gpgme-0-3-0/assuan/assuan-pipe-server.c
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* assuan-pipe-server.c - Assuan server working over a pipe
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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 <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2])
|
||||||
|
{
|
||||||
|
ASSUAN_CONTEXT ctx;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
*r_ctx = NULL;
|
||||||
|
ctx = xtrycalloc (1, sizeof *ctx);
|
||||||
|
if (!ctx)
|
||||||
|
return ASSUAN_Out_Of_Core;
|
||||||
|
ctx->is_server = 1;
|
||||||
|
ctx->input_fd = -1;
|
||||||
|
ctx->output_fd = -1;
|
||||||
|
|
||||||
|
ctx->inbound.fd = filedes[0];
|
||||||
|
ctx->outbound.fd = filedes[1];
|
||||||
|
|
||||||
|
ctx->pipe_mode = 1;
|
||||||
|
|
||||||
|
rc = _assuan_register_std_commands (ctx);
|
||||||
|
if (rc)
|
||||||
|
xfree (ctx);
|
||||||
|
else
|
||||||
|
*r_ctx = ctx;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
assuan_deinit_pipe_server (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
if (ctx)
|
||||||
|
{
|
||||||
|
xfree (ctx->hello_line);
|
||||||
|
xfree (ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
98
tags/gpgme-0-3-0/assuan/assuan-util.c
Normal file
98
tags/gpgme-0-3-0/assuan/assuan-util.c
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/* assuan-util.c - Utility functions for Assuan
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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 <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "assuan-defs.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void *(*alloc_func)(size_t n) = malloc;
|
||||||
|
static void *(*realloc_func)(void *p, size_t n) = realloc;
|
||||||
|
static void (*free_func)(void*) = free;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
|
||||||
|
void *(*new_realloc_func)(void *p, size_t n),
|
||||||
|
void (*new_free_func)(void*) )
|
||||||
|
{
|
||||||
|
alloc_func = new_alloc_func;
|
||||||
|
realloc_func = new_realloc_func;
|
||||||
|
free_func = new_free_func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
_assuan_malloc (size_t n)
|
||||||
|
{
|
||||||
|
return alloc_func (n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
_assuan_realloc (void *a, size_t n)
|
||||||
|
{
|
||||||
|
return realloc_func (a, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
_assuan_calloc (size_t n, size_t m)
|
||||||
|
{
|
||||||
|
void *p = _assuan_malloc (n*m);
|
||||||
|
if (p)
|
||||||
|
memset (p, 0, n* m);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_assuan_free (void *p)
|
||||||
|
{
|
||||||
|
if (p)
|
||||||
|
free_func (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Store the error in the context so that the error sending function
|
||||||
|
can take out a descriptive text. Inside the assuan code, use the
|
||||||
|
macro set_error instead of this function. */
|
||||||
|
int
|
||||||
|
assuan_set_error (ASSUAN_CONTEXT ctx, int err, const char *text)
|
||||||
|
{
|
||||||
|
ctx->err_no = err;
|
||||||
|
ctx->err_str = text;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
assuan_set_pointer (ASSUAN_CONTEXT ctx, void *pointer)
|
||||||
|
{
|
||||||
|
if (ctx)
|
||||||
|
ctx->user_pointer = pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
assuan_get_pointer (ASSUAN_CONTEXT ctx)
|
||||||
|
{
|
||||||
|
return ctx? ctx->user_pointer : NULL;
|
||||||
|
}
|
||||||
|
|
193
tags/gpgme-0-3-0/assuan/assuan.h
Normal file
193
tags/gpgme-0-3-0/assuan/assuan.h
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
/* assuan.c - Definitions for the Assuna protocol
|
||||||
|
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of GnuPG.
|
||||||
|
*
|
||||||
|
* GnuPG 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.
|
||||||
|
*
|
||||||
|
* GnuPG 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 ASSUAN_H
|
||||||
|
#define ASSUAN_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#if 0
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ASSUAN_No_Error = 0,
|
||||||
|
ASSUAN_General_Error = 1,
|
||||||
|
ASSUAN_Out_Of_Core = 2,
|
||||||
|
ASSUAN_Invalid_Value = 3,
|
||||||
|
ASSUAN_Timeout = 4,
|
||||||
|
ASSUAN_Read_Error = 5,
|
||||||
|
ASSUAN_Write_Error = 6,
|
||||||
|
ASSUAN_Problem_Starting_Server = 7,
|
||||||
|
ASSUAN_Not_A_Server = 8,
|
||||||
|
ASSUAN_Not_A_Client = 9,
|
||||||
|
ASSUAN_Nested_Commands = 10,
|
||||||
|
ASSUAN_Invalid_Response = 11,
|
||||||
|
ASSUAN_No_Data_Callback = 12,
|
||||||
|
ASSUAN_No_Inquire_Callback = 13,
|
||||||
|
ASSUAN_Connect_Failed = 14,
|
||||||
|
|
||||||
|
/* error codes above 99 are meant as status codes */
|
||||||
|
ASSUAN_Not_Implemented = 100,
|
||||||
|
ASSUAN_Server_Fault = 101,
|
||||||
|
ASSUAN_Invalid_Command = 102,
|
||||||
|
ASSUAN_Unknown_Command = 103,
|
||||||
|
ASSUAN_Syntax_Error = 104,
|
||||||
|
ASSUAN_Parameter_Error = 105,
|
||||||
|
ASSUAN_Parameter_Conflict = 106,
|
||||||
|
ASSUAN_Line_Too_Long = 107,
|
||||||
|
ASSUAN_Line_Not_Terminated = 108,
|
||||||
|
ASSUAN_No_Input = 109,
|
||||||
|
ASSUAN_No_Output = 110,
|
||||||
|
ASSUAN_Canceled = 111,
|
||||||
|
ASSUAN_Unsupported_Algorithm = 112,
|
||||||
|
ASSUAN_Server_Resource_Problem = 113,
|
||||||
|
ASSUAN_Server_IO_Error = 114,
|
||||||
|
ASSUAN_Server_Bug = 115,
|
||||||
|
ASSUAN_No_Data_Available = 116,
|
||||||
|
ASSUAN_Invalid_Data = 117,
|
||||||
|
ASSUAN_Unexpected_Command = 118,
|
||||||
|
ASSUAN_Too_Much_Data = 119,
|
||||||
|
|
||||||
|
ASSUAN_Bad_Certificate = 201,
|
||||||
|
ASSUAN_Bad_Certificate_Path = 202,
|
||||||
|
ASSUAN_Missing_Certificate = 203,
|
||||||
|
ASSUAN_Bad_Signature = 204,
|
||||||
|
ASSUAN_No_Agent = 205,
|
||||||
|
ASSUAN_Agent_Error = 206,
|
||||||
|
ASSUAN_No_Public_Key = 207,
|
||||||
|
ASSUAN_No_Secret_Key = 208,
|
||||||
|
ASSUAN_Invalid_Name = 209,
|
||||||
|
|
||||||
|
ASSUAN_Cert_Revoked = 301,
|
||||||
|
ASSUAN_No_CRL_For_Cert = 302,
|
||||||
|
ASSUAN_CRL_Too_Old = 303,
|
||||||
|
|
||||||
|
} AssuanError;
|
||||||
|
|
||||||
|
/* This is a list of pre-registered ASSUAN commands */
|
||||||
|
typedef enum {
|
||||||
|
ASSUAN_CMD_NOP = 0,
|
||||||
|
ASSUAN_CMD_CANCEL, /* cancel the current request */
|
||||||
|
ASSUAN_CMD_BYE,
|
||||||
|
ASSUAN_CMD_AUTH,
|
||||||
|
ASSUAN_CMD_RESET,
|
||||||
|
ASSUAN_CMD_DATA,
|
||||||
|
ASSUAN_CMD_END,
|
||||||
|
ASSUAN_CMD_INPUT,
|
||||||
|
ASSUAN_CMD_OUTPUT,
|
||||||
|
|
||||||
|
ASSUAN_CMD_USER = 256 /* Other commands should be used with this offset*/
|
||||||
|
} AssuanCommand;
|
||||||
|
|
||||||
|
#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
|
||||||
|
|
||||||
|
struct assuan_context_s;
|
||||||
|
typedef struct assuan_context_s *ASSUAN_CONTEXT;
|
||||||
|
|
||||||
|
/*-- assuan-handler.c --*/
|
||||||
|
int assuan_register_command (ASSUAN_CONTEXT ctx,
|
||||||
|
int cmd_id, const char *cmd_string,
|
||||||
|
int (*handler)(ASSUAN_CONTEXT, char *));
|
||||||
|
int assuan_register_bye_notify (ASSUAN_CONTEXT ctx,
|
||||||
|
void (*fnc)(ASSUAN_CONTEXT));
|
||||||
|
int assuan_register_reset_notify (ASSUAN_CONTEXT ctx,
|
||||||
|
void (*fnc)(ASSUAN_CONTEXT));
|
||||||
|
int assuan_register_cancel_notify (ASSUAN_CONTEXT ctx,
|
||||||
|
void (*fnc)(ASSUAN_CONTEXT));
|
||||||
|
int assuan_register_input_notify (ASSUAN_CONTEXT ctx,
|
||||||
|
void (*fnc)(ASSUAN_CONTEXT, const char *));
|
||||||
|
int assuan_register_output_notify (ASSUAN_CONTEXT ctx,
|
||||||
|
void (*fnc)(ASSUAN_CONTEXT, const char *));
|
||||||
|
int assuan_process (ASSUAN_CONTEXT ctx);
|
||||||
|
int assuan_process_next (ASSUAN_CONTEXT ctx);
|
||||||
|
int assuan_get_active_fds (ASSUAN_CONTEXT ctx, int what,
|
||||||
|
int *fdarray, int fdarraysize);
|
||||||
|
|
||||||
|
|
||||||
|
FILE *assuan_get_data_fp (ASSUAN_CONTEXT ctx);
|
||||||
|
void assuan_write_status (ASSUAN_CONTEXT ctx,
|
||||||
|
const char *keyword, const char *text);
|
||||||
|
|
||||||
|
|
||||||
|
/*-- assuan-listen.c --*/
|
||||||
|
AssuanError assuan_set_hello_line (ASSUAN_CONTEXT ctx, const char *line);
|
||||||
|
AssuanError assuan_accept (ASSUAN_CONTEXT ctx);
|
||||||
|
int assuan_get_input_fd (ASSUAN_CONTEXT ctx);
|
||||||
|
int assuan_get_output_fd (ASSUAN_CONTEXT ctx);
|
||||||
|
AssuanError assuan_close_input_fd (ASSUAN_CONTEXT ctx);
|
||||||
|
AssuanError assuan_close_output_fd (ASSUAN_CONTEXT ctx);
|
||||||
|
|
||||||
|
|
||||||
|
/*-- assuan-pipe-server.c --*/
|
||||||
|
int assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2]);
|
||||||
|
void assuan_deinit_pipe_server (ASSUAN_CONTEXT ctx);
|
||||||
|
|
||||||
|
|
||||||
|
/*-- assuan-connect.c --*/
|
||||||
|
AssuanError assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name,
|
||||||
|
char *const argv[], int *fd_child_list);
|
||||||
|
void assuan_pipe_disconnect (ASSUAN_CONTEXT ctx);
|
||||||
|
pid_t assuan_get_pid (ASSUAN_CONTEXT ctx);
|
||||||
|
|
||||||
|
/*-- assuan-client.c --*/
|
||||||
|
AssuanError
|
||||||
|
assuan_transact (ASSUAN_CONTEXT ctx,
|
||||||
|
const char *command,
|
||||||
|
AssuanError (*data_cb)(void *, const void *, size_t),
|
||||||
|
void *data_cb_arg,
|
||||||
|
AssuanError (*inquire_cb)(void*, const char *),
|
||||||
|
void *inquire_cb_arg);
|
||||||
|
|
||||||
|
|
||||||
|
/*-- assuan-inquire.c --*/
|
||||||
|
AssuanError assuan_inquire (ASSUAN_CONTEXT ctx, const char *keyword,
|
||||||
|
char **r_buffer, size_t *r_length, size_t maxlen);
|
||||||
|
|
||||||
|
/*-- assuan-buffer.c --*/
|
||||||
|
AssuanError assuan_read_line (ASSUAN_CONTEXT ctx,
|
||||||
|
char **line, size_t *linelen);
|
||||||
|
int assuan_pending_line (ASSUAN_CONTEXT ctx);
|
||||||
|
AssuanError assuan_write_line (ASSUAN_CONTEXT ctx, const char *line );
|
||||||
|
AssuanError assuan_send_data (ASSUAN_CONTEXT ctx,
|
||||||
|
const void *buffer, size_t length);
|
||||||
|
|
||||||
|
|
||||||
|
/*-- assuan-util.c --*/
|
||||||
|
void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
|
||||||
|
void *(*new_realloc_func)(void *p, size_t n),
|
||||||
|
void (*new_free_func)(void*) );
|
||||||
|
int assuan_set_error (ASSUAN_CONTEXT ctx, int err, const char *text);
|
||||||
|
void assuan_set_pointer (ASSUAN_CONTEXT ctx, void *pointer);
|
||||||
|
void *assuan_get_pointer (ASSUAN_CONTEXT ctx);
|
||||||
|
|
||||||
|
|
||||||
|
/*-- assuan-errors.c (built) --*/
|
||||||
|
const char *assuan_strerror (AssuanError err);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /*ASSUAN_H*/
|
71
tags/gpgme-0-3-0/assuan/mkerrors
Executable file
71
tags/gpgme-0-3-0/assuan/mkerrors
Executable file
@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# mkerrors - Extract error strings from assuan.h
|
||||||
|
# and create C source for assuan_strerror
|
||||||
|
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is part of GnuPG.
|
||||||
|
#
|
||||||
|
# GnuPG 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.
|
||||||
|
#
|
||||||
|
# GnuPG 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
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
/* Generated automatically by mkerrors */
|
||||||
|
/* Do not edit! */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "assuan.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assuan_strerror:
|
||||||
|
* @err: Error code
|
||||||
|
*
|
||||||
|
* This function returns a textual representaion of the given
|
||||||
|
* errorcode. If this is an unknown value, a string with the value
|
||||||
|
* is returned (Beware: it is hold in a static buffer).
|
||||||
|
*
|
||||||
|
* Return value: String with the error description.
|
||||||
|
**/
|
||||||
|
const char *
|
||||||
|
assuan_strerror (AssuanError err)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
static char buf[25];
|
||||||
|
|
||||||
|
switch (err)
|
||||||
|
{
|
||||||
|
EOF
|
||||||
|
|
||||||
|
awk '
|
||||||
|
/ASSUAN_No_Error/ { okay=1 }
|
||||||
|
!okay {next}
|
||||||
|
/}/ { exit 0 }
|
||||||
|
/ASSUAN_[A-Za-z_]*/ { print_code($1) }
|
||||||
|
|
||||||
|
|
||||||
|
function print_code( s )
|
||||||
|
{
|
||||||
|
printf " case %s: s=\"", s ;
|
||||||
|
gsub(/_/, " ", s );
|
||||||
|
printf "%s\"; break;\n", tolower(substr(s,8));
|
||||||
|
}
|
||||||
|
'
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
default: sprintf (buf, "ec=%d", err ); s=buf; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
149
tags/gpgme-0-3-0/autogen.sh
Executable file
149
tags/gpgme-0-3-0/autogen.sh
Executable file
@ -0,0 +1,149 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Run this to generate all the initial makefiles, etc.
|
||||||
|
# It is only needed for the CVS version.
|
||||||
|
|
||||||
|
PGM=GPGME
|
||||||
|
lib_config_files=""
|
||||||
|
autoconf_vers=2.52
|
||||||
|
automake_vers=1.5
|
||||||
|
aclocal_vers=1.5
|
||||||
|
libtool_vers=1.4
|
||||||
|
|
||||||
|
DIE=no
|
||||||
|
if test "$1" = "--build-w32"; then
|
||||||
|
shift
|
||||||
|
target=i386--mingw32
|
||||||
|
if [ ! -f ./config.guess ]; then
|
||||||
|
echo "./config.guess not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
host=`./config.guess`
|
||||||
|
|
||||||
|
if ! mingw32 --version >/dev/null; then
|
||||||
|
echo "We need at least version 0.3 of MingW32/CPD" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f config.h ]; then
|
||||||
|
if grep HAVE_DOSISH_SYSTEM config.h | grep undef >/dev/null; then
|
||||||
|
echo "Pease run a 'make distclean' first" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
crossinstalldir=`mingw32 --install-dir`
|
||||||
|
crossbindir=`mingw32 --get-bindir 2>/dev/null` \
|
||||||
|
|| crossbindir="$crossinstalldir/bin"
|
||||||
|
crossdatadir=`mingw32 --get-datadir 2>/dev/null` \
|
||||||
|
|| crossdatadir="$crossinstalldir/share"
|
||||||
|
crosslibdir=`mingw32 --get-libdir 2>/dev/null` \
|
||||||
|
|| crosslibdir="$crossinstalldir/i386--mingw32/lib"
|
||||||
|
crossincdir=`mingw32 --get-includedir 2>/dev/null` \
|
||||||
|
|| crossincdir="$crossinstalldir/i386--mingw32/include"
|
||||||
|
CC=`mingw32 --get-path gcc`
|
||||||
|
CPP=`mingw32 --get-path cpp`
|
||||||
|
AR=`mingw32 --get-path ar`
|
||||||
|
RANLIB=`mingw32 --get-path ranlib`
|
||||||
|
export CC CPP AR RANLIB
|
||||||
|
|
||||||
|
disable_foo_tests=""
|
||||||
|
if [ -n "$lib_config_files" ]; then
|
||||||
|
for i in $lib_config_files; do
|
||||||
|
j=`echo $i | tr '[a-z-]' '[A-Z_]'`
|
||||||
|
eval "$j=${crossbindir}/$i"
|
||||||
|
export $j
|
||||||
|
disable_foo_tests="$disable_foo_tests --disable-`echo $i| \
|
||||||
|
sed 's,-config$,,'`-test"
|
||||||
|
if [ ! -f "${crossbindir}/$i" ]; then
|
||||||
|
echo "$i not installed for MingW32" >&2
|
||||||
|
DIE=yes
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
[ $DIE = yes ] && exit 1
|
||||||
|
|
||||||
|
./configure --host=${host} --target=${target} ${disable_foo_tests} \
|
||||||
|
--bindir=${crossbindir} --libdir=${crosslibdir} \
|
||||||
|
--datadir=${crossdatadir} --includedir=${crossincdir} \
|
||||||
|
--enable-maintainer-mode $*
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (autoconf --version) < /dev/null > /dev/null 2>&1 ; then
|
||||||
|
if (autoconf --version | awk 'NR==1 { if( $3 >= '$autoconf_vers') \
|
||||||
|
exit 1; exit 0; }');
|
||||||
|
then
|
||||||
|
echo "**Error**: "\`autoconf\'" is too old."
|
||||||
|
echo ' (version ' $autoconf_vers ' or newer is required)'
|
||||||
|
DIE="yes"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "**Error**: You must have "\`autoconf\'" installed to compile $PGM."
|
||||||
|
echo ' (version ' $autoconf_vers ' or newer is required)'
|
||||||
|
DIE="yes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (automake --version) < /dev/null > /dev/null 2>&1 ; then
|
||||||
|
if (automake --version | awk 'NR==1 { if( $4 >= '$automake_vers') \
|
||||||
|
exit 1; exit 0; }');
|
||||||
|
then
|
||||||
|
echo "**Error**: "\`automake\'" is too old."
|
||||||
|
echo ' (version ' $automake_vers ' or newer is required)'
|
||||||
|
DIE="yes"
|
||||||
|
fi
|
||||||
|
if (aclocal --version) < /dev/null > /dev/null 2>&1; then
|
||||||
|
if (aclocal --version | awk 'NR==1 { if( $4 >= '$aclocal_vers' ) \
|
||||||
|
exit 1; exit 0; }' );
|
||||||
|
then
|
||||||
|
echo "**Error**: "\`aclocal\'" is too old."
|
||||||
|
echo ' (version ' $aclocal_vers ' or newer is required)'
|
||||||
|
DIE="yes"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "**Error**: Missing "\`aclocal\'". The version of "\`automake\'
|
||||||
|
echo " installed doesn't appear recent enough."
|
||||||
|
DIE="yes"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "**Error**: You must have "\`automake\'" installed to compile $PGM."
|
||||||
|
echo ' (version ' $automake_vers ' or newer is required)'
|
||||||
|
DIE="yes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if (libtool --version) < /dev/null > /dev/null 2>&1 ; then
|
||||||
|
if (libtool --version | awk 'NR==1 { if( $4 >= '$libtool_vers') \
|
||||||
|
exit 1; exit 0; }');
|
||||||
|
then
|
||||||
|
echo "**Error**: "\`libtool\'" is too old."
|
||||||
|
echo ' (version ' $libtool_vers ' or newer is required)'
|
||||||
|
DIE="yes"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "**Error**: You must have "\`libtool\'" installed to compile $PGM."
|
||||||
|
echo ' (version ' $libtool_vers ' or newer is required)'
|
||||||
|
DIE="yes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$DIE" = "yes"; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running libtoolize... Ignore non-fatal messages."
|
||||||
|
echo "no" | libtoolize
|
||||||
|
|
||||||
|
|
||||||
|
echo "Running aclocal..."
|
||||||
|
aclocal
|
||||||
|
echo "Running autoheader..."
|
||||||
|
autoheader
|
||||||
|
echo "Running automake --gnu -a ..."
|
||||||
|
automake --gnu -a
|
||||||
|
echo "Running autoconf..."
|
||||||
|
autoconf
|
1
tags/gpgme-0-3-0/bonobo/.cvsignore
Normal file
1
tags/gpgme-0-3-0/bonobo/.cvsignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
Makefile.in Makefile .deps
|
30
tags/gpgme-0-3-0/bonobo/Makefile.am
Normal file
30
tags/gpgme-0-3-0/bonobo/Makefile.am
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
# 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
|
||||||
|
|
||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
bin_PROGRAMS = gpgme
|
||||||
|
|
||||||
|
INCLUDES = -I$(top_srcdir)/jnlib
|
||||||
|
LDADD = -L ../jnlib -ljnlib
|
||||||
|
|
||||||
|
gpgme_SOURCES = main.c main.h
|
||||||
|
|
||||||
|
|
||||||
|
|
20
tags/gpgme-0-3-0/bonobo/gpgme.c
Normal file
20
tags/gpgme-0-3-0/bonobo/gpgme.c
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/* gpgme - Bonbobo 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
|
||||||
|
*/
|
||||||
|
|
20
tags/gpgme-0-3-0/bonobo/main.c
Normal file
20
tags/gpgme-0-3-0/bonobo/main.c
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/* main.c - Bonbobo 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
|
||||||
|
*/
|
||||||
|
|
42
tags/gpgme-0-3-0/bonobo/main.h
Normal file
42
tags/gpgme-0-3-0/bonobo/main.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* main.h - GPGME Bonobo component
|
||||||
|
* 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 MAIN_H
|
||||||
|
#define MAIN_H
|
||||||
|
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int verbose;
|
||||||
|
int quiet;
|
||||||
|
unsigned int debug;
|
||||||
|
char *homedir;
|
||||||
|
} opt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* MAIN_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
tags/gpgme-0-3-0/complus/.cvsignore
Normal file
2
tags/gpgme-0-3-0/complus/.cvsignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.libs
|
||||||
|
Makefile.in Makefile .deps
|
15
tags/gpgme-0-3-0/complus/ChangeLog
Normal file
15
tags/gpgme-0-3-0/complus/ChangeLog
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
2001-07-30 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
49
tags/gpgme-0-3-0/complus/Makefile.am
Normal file
49
tags/gpgme-0-3-0/complus/Makefile.am
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
# 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
|
||||||
|
|
||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
# 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 vbtest.html vbtest.vbs README
|
||||||
|
|
||||||
|
# No need to install this because we are cross-compiling anyway.
|
||||||
|
noinst_PROGRAMS = gpgcom tgpgcom
|
||||||
|
|
||||||
|
INCLUDES = -I$(top_srcdir)/jnlib
|
||||||
|
LDADD = ../gpgme/libgpgme.la -L ../jnlib -ljnlib -lole32 -loleaut32
|
||||||
|
gpgcom_LDADD = gpgcom_res.o $(LDADD)
|
||||||
|
|
||||||
|
gpgcom_SOURCES = gpgcom.c main.h \
|
||||||
|
debug.c utf8.c \
|
||||||
|
igpgme.h igpgme.c
|
||||||
|
|
||||||
|
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
|
||||||
|
|
72
tags/gpgme-0-3-0/complus/README
Normal file
72
tags/gpgme-0-3-0/complus/README
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
How to install and use the Gpgcom Windows Component
|
||||||
|
===================================================
|
||||||
|
2001-07-31
|
||||||
|
|
||||||
|
|
||||||
|
Installation should be pretty easy:
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
* Get and install the latest GnuPG binary for windows
|
||||||
|
(ftp://ftp.gnupg.org/gcrypt/binary/gnupg-w32-1.0.6.zip)
|
||||||
|
|
||||||
|
* Check that you have an untampered version of this package by
|
||||||
|
comparing an MD5SUM against the one on the webpage or by checking
|
||||||
|
the signature of the package using "gpg --verify". See the
|
||||||
|
webpacge for details.
|
||||||
|
|
||||||
|
* Because you are reading this file, you probably have already
|
||||||
|
unpacked it distribution using a unzip utility :-). You should
|
||||||
|
find these files:
|
||||||
|
|
||||||
|
README - This file
|
||||||
|
gpgcom.exe - The Gpgcom server
|
||||||
|
vbtest.html - A Test webpage
|
||||||
|
vbtest.vbs - A VB script to be used with the cscript utility
|
||||||
|
|
||||||
|
* If you are updating Gpgcom, run the old Gpgcom like this:
|
||||||
|
|
||||||
|
c:\gnupg\gpgcom -UnregServer
|
||||||
|
|
||||||
|
(Replace c:\gnupg with the actually used path)
|
||||||
|
|
||||||
|
* Copy the file gpgcom.exe to a some location. C:\gnupg seems to be
|
||||||
|
a good choice.
|
||||||
|
|
||||||
|
* Register the component using this command:
|
||||||
|
|
||||||
|
c:\gnupg\gpgcom -RegServer
|
||||||
|
|
||||||
|
* Ready
|
||||||
|
|
||||||
|
Testing the installation:
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
* Make sure that you have a working GnuPG (gpg.exe) and that at least
|
||||||
|
one key is installed.
|
||||||
|
|
||||||
|
* Edit the vbtest.vbs script and replace "alice" in the line
|
||||||
|
|
||||||
|
gpg.AddRecipient "alice"
|
||||||
|
|
||||||
|
with a keyID or user name you have in your key ring.
|
||||||
|
|
||||||
|
* Run the test script:
|
||||||
|
|
||||||
|
cscript vbtest.vbs
|
||||||
|
|
||||||
|
and you should see a valid MIME message with the encrypted text.
|
||||||
|
|
||||||
|
|
||||||
|
Using Gpgcom
|
||||||
|
------------
|
||||||
|
|
||||||
|
Gpgcom currently support only encryption but will be extended to the
|
||||||
|
full range of operations GnuPG provides. The 2 examples should goive
|
||||||
|
yopu a hint on how to use it. We suggest that you always set armor to
|
||||||
|
true, so that the returned text is a string. If you don't use armor,
|
||||||
|
the "ciphertext" property will return an array with the binary
|
||||||
|
message.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
40
tags/gpgme-0-3-0/complus/debug.c
Normal file
40
tags/gpgme-0-3-0/complus/debug.c
Normal file
@ -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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ole2.h>
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
598
tags/gpgme-0-3-0/complus/example.c
Normal file
598
tags/gpgme-0-3-0/complus/example.c
Normal file
@ -0,0 +1,598 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 1999 Marcus Meissner
|
||||||
|
*/
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "winbase.h"
|
||||||
|
#include "winnls.h"
|
||||||
|
#include "mmsystem.h"
|
||||||
|
#include "winerror.h"
|
||||||
|
#include "debugtools.h"
|
||||||
|
|
||||||
|
#include "initguid.h"
|
||||||
|
#include "vfw.h"
|
||||||
|
|
||||||
|
DEFAULT_DEBUG_CHANNEL(avifile);
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj);
|
||||||
|
static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface);
|
||||||
|
static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface);
|
||||||
|
static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size);
|
||||||
|
static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam);
|
||||||
|
static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi);
|
||||||
|
static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size);
|
||||||
|
static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size);
|
||||||
|
static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface);
|
||||||
|
static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam);
|
||||||
|
|
||||||
|
struct ICOM_VTABLE(IAVIFile) iavift = {
|
||||||
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
||||||
|
IAVIFile_fnQueryInterface,
|
||||||
|
IAVIFile_fnAddRef,
|
||||||
|
IAVIFile_fnRelease,
|
||||||
|
IAVIFile_fnInfo,
|
||||||
|
IAVIFile_fnGetStream,
|
||||||
|
IAVIFile_fnCreateStream,
|
||||||
|
IAVIFile_fnWriteData,
|
||||||
|
IAVIFile_fnReadData,
|
||||||
|
IAVIFile_fnEndRecord,
|
||||||
|
IAVIFile_fnDeleteStream
|
||||||
|
};
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj);
|
||||||
|
static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface);
|
||||||
|
static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size);
|
||||||
|
static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size);
|
||||||
|
static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen);
|
||||||
|
|
||||||
|
struct ICOM_VTABLE(IAVIStream) iavist = {
|
||||||
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
||||||
|
IAVIStream_fnQueryInterface,
|
||||||
|
IAVIStream_fnAddRef,
|
||||||
|
IAVIStream_fnRelease,
|
||||||
|
IAVIStream_fnCreate,
|
||||||
|
IAVIStream_fnInfo,
|
||||||
|
IAVIStream_fnFindSample,
|
||||||
|
IAVIStream_fnReadFormat,
|
||||||
|
IAVIStream_fnSetFormat,
|
||||||
|
IAVIStream_fnRead,
|
||||||
|
IAVIStream_fnWrite,
|
||||||
|
IAVIStream_fnDelete,
|
||||||
|
IAVIStream_fnReadData,
|
||||||
|
IAVIStream_fnWriteData,
|
||||||
|
IAVIStream_fnSetInfo
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct IAVIStreamImpl {
|
||||||
|
/* IUnknown stuff */
|
||||||
|
ICOM_VFIELD(IAVIStream);
|
||||||
|
DWORD ref;
|
||||||
|
/* IAVIStream stuff */
|
||||||
|
LPVOID lpInputFormat;
|
||||||
|
DWORD inputformatsize;
|
||||||
|
BOOL iscompressing;
|
||||||
|
DWORD curframe;
|
||||||
|
|
||||||
|
/* Compressor stuff */
|
||||||
|
HIC hic;
|
||||||
|
LPVOID lpCompressFormat;
|
||||||
|
ICINFO icinfo;
|
||||||
|
DWORD compbufsize;
|
||||||
|
LPVOID compbuffer;
|
||||||
|
|
||||||
|
DWORD decompbufsize;
|
||||||
|
LPVOID decompbuffer;
|
||||||
|
LPVOID decompformat;
|
||||||
|
AVICOMPRESSOPTIONS aco;
|
||||||
|
|
||||||
|
LPVOID lpPrev; /* pointer to decompressed frame later */
|
||||||
|
LPVOID lpPrevFormat; /* pointer to decompressed info later */
|
||||||
|
} IAVIStreamImpl;
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIFileInit
|
||||||
|
*/
|
||||||
|
void WINAPI
|
||||||
|
AVIFileInit(void) {
|
||||||
|
FIXME("(),stub!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct IAVIFileImpl {
|
||||||
|
/* IUnknown stuff */
|
||||||
|
ICOM_VFIELD(IAVIFile);
|
||||||
|
DWORD ref;
|
||||||
|
/* IAVIFile stuff... */
|
||||||
|
} IAVIFileImpl;
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj) {
|
||||||
|
ICOM_THIS(IAVIFileImpl,iface);
|
||||||
|
|
||||||
|
TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
|
||||||
|
if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
|
||||||
|
!memcmp(&IID_IAVIFile,refiid,sizeof(IID_IAVIFile))
|
||||||
|
) {
|
||||||
|
*obj = iface;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
return OLE_E_ENUM_NOMORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface) {
|
||||||
|
ICOM_THIS(IAVIFileImpl,iface);
|
||||||
|
|
||||||
|
FIXME("(%p)->AddRef()\n",iface);
|
||||||
|
return ++(This->ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface) {
|
||||||
|
ICOM_THIS(IAVIFileImpl,iface);
|
||||||
|
|
||||||
|
FIXME("(%p)->Release()\n",iface);
|
||||||
|
if (!--(This->ref)) {
|
||||||
|
HeapFree(GetProcessHeap(),0,iface);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return This->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size) {
|
||||||
|
FIXME("(%p)->Info(%p,%ld)\n",iface,afi,size);
|
||||||
|
|
||||||
|
/* FIXME: fill out struct? */
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam) {
|
||||||
|
FIXME("(%p)->GetStream(%p,0x%08lx,%ld)\n",iface,avis,fccType,lParam);
|
||||||
|
/* FIXME: create interface etc. */
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi) {
|
||||||
|
ICOM_THIS(IAVIStreamImpl,iface);
|
||||||
|
char fcc[5];
|
||||||
|
IAVIStreamImpl *istream;
|
||||||
|
|
||||||
|
FIXME("(%p,%p,%p)\n",This,avis,asi);
|
||||||
|
istream = (IAVIStreamImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IAVIStreamImpl));
|
||||||
|
istream->ref = 1;
|
||||||
|
ICOM_VTBL(istream) = &iavist;
|
||||||
|
fcc[4]='\0';
|
||||||
|
memcpy(fcc,(char*)&(asi->fccType),4);
|
||||||
|
FIXME("\tfccType '%s'\n",fcc);
|
||||||
|
memcpy(fcc,(char*)&(asi->fccHandler),4);
|
||||||
|
FIXME("\tfccHandler '%s'\n",fcc);
|
||||||
|
FIXME("\tdwFlags 0x%08lx\n",asi->dwFlags);
|
||||||
|
FIXME("\tdwCaps 0x%08lx\n",asi->dwCaps);
|
||||||
|
FIXME("\tname '%s'\n",debugstr_w(asi->szName));
|
||||||
|
|
||||||
|
istream->curframe = 0;
|
||||||
|
*avis = (PAVISTREAM)istream;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size) {
|
||||||
|
FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",iface,ckid,lpData,size);
|
||||||
|
/* FIXME: write data to file */
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size) {
|
||||||
|
FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",iface,ckid,lpData,size);
|
||||||
|
/* FIXME: read at most size bytes from file */
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface) {
|
||||||
|
FIXME("(%p)->EndRecord()\n",iface);
|
||||||
|
/* FIXME: end record? */
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam) {
|
||||||
|
FIXME("(%p)->DeleteStream(0x%08lx,%ld)\n",iface,fccType,lParam);
|
||||||
|
/* FIXME: delete stream? */
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIFileOpenA
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIFileOpenA(
|
||||||
|
PAVIFILE * ppfile,LPCSTR szFile,UINT uMode,LPCLSID lpHandler
|
||||||
|
) {
|
||||||
|
IAVIFileImpl *iavi;
|
||||||
|
|
||||||
|
FIXME("(%p,%s,0x%08lx,%s),stub!\n",ppfile,szFile,(DWORD)uMode,debugstr_guid(lpHandler));
|
||||||
|
iavi = (IAVIFileImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IAVIFileImpl));
|
||||||
|
iavi->ref = 1;
|
||||||
|
ICOM_VTBL(iavi) = &iavift;
|
||||||
|
*ppfile = (LPVOID)iavi;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj) {
|
||||||
|
ICOM_THIS(IAVIStreamImpl,iface);
|
||||||
|
|
||||||
|
TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
|
||||||
|
if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
|
||||||
|
!memcmp(&IID_IAVIStream,refiid,sizeof(IID_IAVIStream))
|
||||||
|
) {
|
||||||
|
*obj = This;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
/* can return IGetFrame interface too */
|
||||||
|
return OLE_E_ENUM_NOMORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface) {
|
||||||
|
ICOM_THIS(IAVIStreamImpl,iface);
|
||||||
|
|
||||||
|
FIXME("(%p)->AddRef()\n",iface);
|
||||||
|
return ++(This->ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface) {
|
||||||
|
ICOM_THIS(IAVIStreamImpl,iface);
|
||||||
|
|
||||||
|
FIXME("(%p)->Release()\n",iface);
|
||||||
|
if (!--(This->ref)) {
|
||||||
|
HeapFree(GetProcessHeap(),0,This);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return This->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2) {
|
||||||
|
FIXME("(%p)->Create(0x%08lx,0x%08lx)\n",iface,lParam1,lParam2);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size) {
|
||||||
|
FIXME("(%p)->Info(%p,%ld)\n",iface,psi,size);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags) {
|
||||||
|
FIXME("(%p)->FindSample(%ld,0x%08lx)\n",iface,pos,flags);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize) {
|
||||||
|
FIXME("(%p)->ReadFormat(%ld,%p,%p)\n",iface,pos,format,formatsize);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* IAVIStream::SetFormat
|
||||||
|
*/
|
||||||
|
static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize) {
|
||||||
|
IAVIStreamImpl *as = (IAVIStreamImpl*)iface;
|
||||||
|
|
||||||
|
FIXME("(%p)->SetFormat(%ld,%p,%ld)\n",iface,pos,format,formatsize);
|
||||||
|
if (as->lpInputFormat) HeapFree(GetProcessHeap(),0,as->lpInputFormat);
|
||||||
|
as->inputformatsize = formatsize;
|
||||||
|
as->lpInputFormat = HeapAlloc(GetProcessHeap(),0,formatsize);
|
||||||
|
memcpy(as->lpInputFormat,format,formatsize);
|
||||||
|
if (as->iscompressing) {
|
||||||
|
int xsize;
|
||||||
|
/* Set up the Compressor part */
|
||||||
|
xsize = ICCompressGetFormatSize(as->hic,as->lpInputFormat);
|
||||||
|
as->lpCompressFormat = HeapAlloc(GetProcessHeap(),0,xsize);
|
||||||
|
ICCompressGetFormat(as->hic,as->lpInputFormat,as->lpCompressFormat);
|
||||||
|
ICCompressBegin(as->hic,as->lpInputFormat,as->lpCompressFormat);
|
||||||
|
as->compbufsize = ICCompressGetSize(as->hic,as->lpInputFormat,as->lpCompressFormat);
|
||||||
|
as->compbuffer = HeapAlloc(GetProcessHeap(),0,as->compbufsize);
|
||||||
|
|
||||||
|
/* Set up the Decompressor part (for prev frames?) */
|
||||||
|
xsize=ICDecompressGetFormatSize(as->hic,as->lpCompressFormat);
|
||||||
|
as->decompformat = HeapAlloc(GetProcessHeap(),0,xsize);
|
||||||
|
ICDecompressGetFormat(as->hic,as->lpCompressFormat,as->decompformat);
|
||||||
|
as->decompbufsize=((LPBITMAPINFOHEADER)as->decompbuffer)->biSizeImage;
|
||||||
|
as->decompbuffer = HeapReAlloc(GetProcessHeap(),0,as->decompbuffer,as->decompbufsize);
|
||||||
|
memset(as->decompbuffer,0xff,as->decompbufsize);
|
||||||
|
assert(HeapValidate(GetProcessHeap(),0,NULL));
|
||||||
|
|
||||||
|
ICDecompressGetFormat(as->hic,as->lpCompressFormat,as->decompformat);
|
||||||
|
ICDecompressBegin(as->hic,as->lpCompressFormat,as->decompformat);
|
||||||
|
as->lpPrev = as->lpPrevFormat = NULL;
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) {
|
||||||
|
FIXME("(%p)->Read(%ld,%ld,%p,%ld,%p,%p)\n",iface,start,samples,buffer,buffersize,bytesread,samplesread);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) {
|
||||||
|
IAVIStreamImpl *as = (IAVIStreamImpl*)iface;
|
||||||
|
DWORD ckid,xflags;
|
||||||
|
|
||||||
|
FIXME("(%p)->Write(%ld,%ld,%p,%ld,0x%08lx,%p,%p)\n",iface,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
|
||||||
|
|
||||||
|
ICCompress(
|
||||||
|
as->hic,flags,
|
||||||
|
as->lpCompressFormat,
|
||||||
|
as->compbuffer,
|
||||||
|
as->lpInputFormat,buffer,
|
||||||
|
&ckid,&xflags,
|
||||||
|
as->curframe,0xffffff/*framesize*/,as->aco.dwQuality,
|
||||||
|
as->lpPrevFormat,as->lpPrev
|
||||||
|
);
|
||||||
|
ICDecompress(
|
||||||
|
as->hic,
|
||||||
|
flags, /* FIXME: check */
|
||||||
|
as->lpCompressFormat,
|
||||||
|
as->compbuffer,
|
||||||
|
as->decompformat,
|
||||||
|
as->decompbuffer
|
||||||
|
);
|
||||||
|
/* We now have a prev format for the next compress ... */
|
||||||
|
as->lpPrevFormat = as->decompformat;
|
||||||
|
as->lpPrev = as->decompbuffer;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples) {
|
||||||
|
FIXME("(%p)->Delete(%ld,%ld)\n",iface,start,samples);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread) {
|
||||||
|
FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",iface,fcc,lp,lpread);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size) {
|
||||||
|
FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",iface,fcc,lp,size);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen) {
|
||||||
|
FIXME("(%p)->SetInfo(%p,%ld)\n",iface,info,infolen);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIFileCreateStreamA
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE iface,PAVISTREAM *ppavi,AVISTREAMINFOA * psi) {
|
||||||
|
AVISTREAMINFOW psiw;
|
||||||
|
|
||||||
|
/* Only the szName at the end is different */
|
||||||
|
memcpy(&psiw,psi,sizeof(*psi)-sizeof(psi->szName));
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, psi->szName, -1,
|
||||||
|
psiw.szName, sizeof(psiw.szName) / sizeof(WCHAR) );
|
||||||
|
return IAVIFile_CreateStream(iface,ppavi,&psiw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIFileCreateStreamW
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIFileCreateStreamW(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi) {
|
||||||
|
return IAVIFile_CreateStream(iface,avis,asi);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIFileGetStream
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIFileGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam) {
|
||||||
|
return IAVIFile_GetStream(iface,avis,fccType,lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIFileInfoA
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIFileInfoA(PAVIFILE iface,LPAVIFILEINFOA afi,LONG size) {
|
||||||
|
AVIFILEINFOW afiw;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
if (size < sizeof(AVIFILEINFOA))
|
||||||
|
return AVIERR_BADSIZE;
|
||||||
|
hres = IAVIFile_Info(iface,&afiw,sizeof(afiw));
|
||||||
|
memcpy(afi,&afiw,sizeof(*afi)-sizeof(afi->szFileType));
|
||||||
|
WideCharToMultiByte( CP_ACP, 0, afiw.szFileType, -1,
|
||||||
|
afi->szFileType, sizeof(afi->szFileType), NULL, NULL );
|
||||||
|
afi->szFileType[sizeof(afi->szFileType)-1] = 0;
|
||||||
|
return hres;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamInfoW
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIStreamInfoW(PAVISTREAM iface,AVISTREAMINFOW *asi,LONG
|
||||||
|
size) {
|
||||||
|
return IAVIFile_Info(iface,asi,size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamInfoA
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIStreamInfoA(PAVISTREAM iface,AVISTREAMINFOA *asi,LONG
|
||||||
|
size) {
|
||||||
|
AVISTREAMINFOW asiw;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
if (size<sizeof(AVISTREAMINFOA))
|
||||||
|
return AVIERR_BADSIZE;
|
||||||
|
hres = IAVIFile_Info(iface,&asiw,sizeof(asiw));
|
||||||
|
memcpy(asi,&asiw,sizeof(asiw)-sizeof(asiw.szName));
|
||||||
|
WideCharToMultiByte( CP_ACP, 0, asiw.szName, -1,
|
||||||
|
asi->szName, sizeof(asi->szName), NULL, NULL );
|
||||||
|
asi->szName[sizeof(asi->szName)-1] = 0;
|
||||||
|
return hres;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIFileInfoW
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIFileInfoW(PAVIFILE iface,LPAVIFILEINFOW afi,LONG size) {
|
||||||
|
return IAVIFile_Info(iface,afi,size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIMakeCompressedStream
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIMakeCompressedStream(PAVISTREAM *ppsCompressed,PAVISTREAM ppsSource,AVICOMPRESSOPTIONS *aco,CLSID *pclsidHandler) {
|
||||||
|
char fcc[5];
|
||||||
|
IAVIStreamImpl *as;
|
||||||
|
FIXME("(%p,%p,%p,%p)\n",ppsCompressed,ppsSource,aco,pclsidHandler);
|
||||||
|
fcc[4]='\0';
|
||||||
|
memcpy(fcc,&(aco->fccType),4);
|
||||||
|
FIXME("\tfccType: '%s'\n",fcc);
|
||||||
|
memcpy(fcc,&(aco->fccHandler),4);
|
||||||
|
FIXME("\tfccHandler: '%s'\n",fcc);
|
||||||
|
FIXME("\tdwFlags: 0x%08lx\n",aco->dwFlags);
|
||||||
|
|
||||||
|
/* we just create a duplicate for now */
|
||||||
|
IAVIStream_AddRef(ppsSource);
|
||||||
|
*ppsCompressed = ppsSource;
|
||||||
|
as = (IAVIStreamImpl*)ppsSource;
|
||||||
|
|
||||||
|
/* this is where the fun begins. Open a compressor and prepare it. */
|
||||||
|
as->hic = ICOpen(aco->fccType,aco->fccHandler,ICMODE_COMPRESS);
|
||||||
|
|
||||||
|
/* May happen. for instance if the codec is not able to compress */
|
||||||
|
if (!as->hic)
|
||||||
|
return AVIERR_UNSUPPORTED;
|
||||||
|
|
||||||
|
ICGetInfo(as->hic,&(as->icinfo),sizeof(ICINFO));
|
||||||
|
FIXME("Opened compressor: '%s' '%s'\n",debugstr_w(as->icinfo.szName),debugstr_w(as->icinfo.szDescription));
|
||||||
|
as->iscompressing = TRUE;
|
||||||
|
memcpy(&(as->aco),aco,sizeof(*aco));
|
||||||
|
if (as->icinfo.dwFlags & VIDCF_COMPRESSFRAMES) {
|
||||||
|
ICCOMPRESSFRAMES icf;
|
||||||
|
|
||||||
|
/* now what to fill in there ... Hmm */
|
||||||
|
memset(&icf,0,sizeof(icf));
|
||||||
|
icf.lDataRate = aco->dwBytesPerSecond;
|
||||||
|
icf.lQuality = aco->dwQuality;
|
||||||
|
icf.lKeyRate = aco->dwKeyFrameEvery;
|
||||||
|
|
||||||
|
icf.GetData = (void *)0xdead4242;
|
||||||
|
icf.PutData = (void *)0xdead4243;
|
||||||
|
ICSendMessage(as->hic,ICM_COMPRESS_FRAMES_INFO,(LPARAM)&icf,sizeof(icf));
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamSetFormat
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIStreamSetFormat(PAVISTREAM iface,LONG pos,LPVOID format,LONG formatsize) {
|
||||||
|
return IAVIStream_SetFormat(iface,pos,format,formatsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamReadFormat
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIStreamReadFormat(PAVISTREAM iface,LONG pos,LPVOID format,LONG *formatsize) {
|
||||||
|
return IAVIStream_ReadFormat(iface,pos,format,formatsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamWrite(
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIStreamWrite(PAVISTREAM iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) {
|
||||||
|
return IAVIStream_Write(iface,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamRead
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIStreamRead(PAVISTREAM iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) {
|
||||||
|
return IAVIStream_Read(iface,start,samples,buffer,buffersize,bytesread,samplesread);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamWriteData
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIStreamWriteData(PAVISTREAM iface,DWORD fcc,LPVOID lp,LONG size) {
|
||||||
|
return IAVIStream_WriteData(iface,fcc,lp,size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamReadData
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIStreamReadData(PAVISTREAM iface,DWORD fcc,LPVOID lp,LONG *lpread) {
|
||||||
|
return IAVIStream_ReadData(iface,fcc,lp,lpread);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamStart
|
||||||
|
*/
|
||||||
|
LONG WINAPI AVIStreamStart(PAVISTREAM iface) {
|
||||||
|
AVISTREAMINFOW si;
|
||||||
|
|
||||||
|
IAVIStream_Info(iface,&si,sizeof(si));
|
||||||
|
return si.dwStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamLength
|
||||||
|
*/
|
||||||
|
LONG WINAPI AVIStreamLength(PAVISTREAM iface) {
|
||||||
|
AVISTREAMINFOW si;
|
||||||
|
HRESULT ret;
|
||||||
|
|
||||||
|
ret = IAVIStream_Info(iface,&si,sizeof(si));
|
||||||
|
if (ret) /* error */
|
||||||
|
return 1;
|
||||||
|
return si.dwLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamRelease
|
||||||
|
*/
|
||||||
|
ULONG WINAPI AVIStreamRelease(PAVISTREAM iface) {
|
||||||
|
return IAVIStream_Release(iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamGetFrameOpen
|
||||||
|
*/
|
||||||
|
PGETFRAME WINAPI AVIStreamGetFrameOpen(PAVISTREAM iface,LPBITMAPINFOHEADER bmi) {
|
||||||
|
FIXME("(%p)->(%p),stub!\n",iface,bmi);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamGetFrame
|
||||||
|
*/
|
||||||
|
LPVOID WINAPI AVIStreamGetFrame(PGETFRAME pg,LONG pos) {
|
||||||
|
return IGetFrame_GetFrame(pg,pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIStreamGetFrameClose
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI AVIStreamGetFrameClose(PGETFRAME pg) {
|
||||||
|
if (pg) IGetFrame_Release(pg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIFileRelease
|
||||||
|
*/
|
||||||
|
ULONG WINAPI AVIFileRelease(PAVIFILE iface) {
|
||||||
|
return IAVIFile_Release(iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* AVIFileExit
|
||||||
|
*/
|
||||||
|
void WINAPI AVIFileExit(void) {
|
||||||
|
FIXME("(), stub.\n");
|
||||||
|
}
|
545
tags/gpgme-0-3-0/complus/gpgcom.c
Normal file
545
tags/gpgme-0-3-0/complus/gpgcom.c
Normal file
@ -0,0 +1,545 @@
|
|||||||
|
/* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <ole2.h>
|
||||||
|
|
||||||
|
#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 <gpgme-bugs@gnupg.org>.\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 );
|
||||||
|
|
||||||
|
igpgme_register_exit_event (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" );
|
||||||
|
igpgme_register_exit_event (NULL);
|
||||||
|
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" );
|
||||||
|
}
|
||||||
|
|
62
tags/gpgme-0-3-0/complus/gpgcom.idl
Normal file
62
tags/gpgme-0-3-0/complus/gpgcom.idl
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
};
|
22
tags/gpgme-0-3-0/complus/gpgcom.rc
Normal file
22
tags/gpgme-0-3-0/complus/gpgcom.rc
Normal file
@ -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"
|
||||||
|
|
BIN
tags/gpgme-0-3-0/complus/gpgcom.tlb
Normal file
BIN
tags/gpgme-0-3-0/complus/gpgcom.tlb
Normal file
Binary file not shown.
130
tags/gpgme-0-3-0/complus/guidgen.c
Normal file
130
tags/gpgme-0-3-0/complus/guidgen.c
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/* guidgen.c - Tool to create GUIDs
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "obj_base.h"
|
||||||
|
|
||||||
|
#include "argparse.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum cmd_and_opt_values { aNull = 0,
|
||||||
|
oVerbose = 'v',
|
||||||
|
|
||||||
|
aTest };
|
||||||
|
|
||||||
|
|
||||||
|
static ARGPARSE_OPTS opts[] = {
|
||||||
|
|
||||||
|
{ 301, NULL, 0, "@Options:\n " },
|
||||||
|
|
||||||
|
{ oVerbose, "verbose", 0, "verbose" },
|
||||||
|
{0} };
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
int verbose;
|
||||||
|
} opt;
|
||||||
|
|
||||||
|
|
||||||
|
static void create_guid (void);
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
my_strusage( int level )
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
switch( level ) {
|
||||||
|
case 11: p = "guidgen";
|
||||||
|
break;
|
||||||
|
case 13: p = VERSION; break;
|
||||||
|
/*case 17: p = PRINTABLE_OS_NAME; break;*/
|
||||||
|
case 19: p =
|
||||||
|
"Please report bugs to <gpgme-bugs@gnupg.org>.\n";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 40: p =
|
||||||
|
"Usage: guidgen [options] (-h for help)";
|
||||||
|
break;
|
||||||
|
case 41: p =
|
||||||
|
"Syntax: guidgen [options]\n"
|
||||||
|
"Generate GUIDs\n";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: p = NULL;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv )
|
||||||
|
{
|
||||||
|
ARGPARSE_ARGS pargs;
|
||||||
|
|
||||||
|
set_strusage( my_strusage );
|
||||||
|
/*log_set_name ("gpa"); not yet implemented in logging.c */
|
||||||
|
|
||||||
|
pargs.argc = &argc;
|
||||||
|
pargs.argv = &argv;
|
||||||
|
pargs.flags= 0;
|
||||||
|
while( arg_parse( &pargs, opts) ) {
|
||||||
|
switch( pargs.r_opt ) {
|
||||||
|
case oVerbose: opt.verbose++; break;
|
||||||
|
|
||||||
|
default : pargs.err = 2; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!argc)
|
||||||
|
create_guid();
|
||||||
|
else {
|
||||||
|
int n;
|
||||||
|
|
||||||
|
for (n = atoi (argv[0]); n > 0; n-- )
|
||||||
|
create_guid ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_guid ()
|
||||||
|
{
|
||||||
|
GUID guid, *id;
|
||||||
|
id = &guid;
|
||||||
|
if ( CoCreateGuid (id) ) {
|
||||||
|
fprintf (stderr,"failed to create GUID\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
printf( "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
|
||||||
|
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] );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
859
tags/gpgme-0-3-0/complus/igpgme.c
Normal file
859
tags/gpgme-0-3-0/complus/igpgme.c
Normal file
@ -0,0 +1,859 @@
|
|||||||
|
/* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
static HANDLE my_exit_event;
|
||||||
|
|
||||||
|
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);
|
||||||
|
{
|
||||||
|
ULONG count = CoReleaseServerProcess ();
|
||||||
|
if (!count && my_exit_event)
|
||||||
|
SetEvent (my_exit_event);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
gpgme_set_textmode (This->mainctx, yes);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI
|
||||||
|
m_IGpgme_GetTextmode (IGpgme *iface, BOOL *retval)
|
||||||
|
{
|
||||||
|
ICOM_THIS (IGpgmeImpl,iface);
|
||||||
|
|
||||||
|
*retval = gpgme_get_textmode (This->mainctx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
fprintf (stderr,"Got a BSTR (utf8):");
|
||||||
|
for (i=0; i < len; i++)
|
||||||
|
fprintf (stderr, " %0X", buf[i] );
|
||||||
|
putc ('\n', stderr);
|
||||||
|
#endif
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return set_data_from_variant (&This->ciphertext, val, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI
|
||||||
|
m_IGpgme_GetCiphertext (IGpgme *iface, VARIANT *retval)
|
||||||
|
{
|
||||||
|
ICOM_THIS (IGpgmeImpl,iface);
|
||||||
|
|
||||||
|
return set_data_to_variant (This->ciphertext, retval,
|
||||||
|
This->ciphertext_is_armored);
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI
|
||||||
|
m_IGpgme_ClearRecipients (IGpgme *iface)
|
||||||
|
{
|
||||||
|
ICOM_THIS (IGpgmeImpl,iface);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI
|
||||||
|
m_IGpgme_AddSignKey (IGpgme *iface, BSTR name)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI
|
||||||
|
m_IGpgme_Encrypt (IGpgme *iface)
|
||||||
|
{
|
||||||
|
GpgmeError err;
|
||||||
|
ICOM_THIS (IGpgmeImpl,iface);
|
||||||
|
|
||||||
|
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_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
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
****************** 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CoAddRefServerProcess ();
|
||||||
|
*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 )
|
||||||
|
{
|
||||||
|
if (dolock) {
|
||||||
|
CoAddRefServerProcess ();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ULONG count = CoReleaseServerProcess ();
|
||||||
|
if (!count && my_exit_event)
|
||||||
|
SetEvent (my_exit_event);
|
||||||
|
}
|
||||||
|
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 };
|
||||||
|
|
||||||
|
void
|
||||||
|
igpgme_register_exit_event (HANDLE ev)
|
||||||
|
{
|
||||||
|
my_exit_event = ev;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 */
|
||||||
|
}
|
163
tags/gpgme-0-3-0/complus/igpgme.h
Normal file
163
tags/gpgme-0-3-0/complus/igpgme.h
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
/* 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 <ole2.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
void igpgme_register_exit_event (HANDLE ev);
|
||||||
|
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*/
|
||||||
|
|
49
tags/gpgme-0-3-0/complus/main.h
Normal file
49
tags/gpgme-0-3-0/complus/main.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* main.h - GPGME COM+ component
|
||||||
|
* 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 COMPLUS_MAIN_H
|
||||||
|
#define COMPLUS_MAIN_H
|
||||||
|
|
||||||
|
#include "xmalloc.h"
|
||||||
|
#include "stringhelp.h"
|
||||||
|
#include "logging.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define _(a) (a)
|
||||||
|
#define N_(a) (a)
|
||||||
|
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int verbose;
|
||||||
|
int quiet;
|
||||||
|
unsigned int debug;
|
||||||
|
char *homedir;
|
||||||
|
} opt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* COMPLUS_MAIN_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
70
tags/gpgme-0-3-0/complus/regtlb.c
Normal file
70
tags/gpgme-0-3-0/complus/regtlb.c
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/* regtlb.c - Register a type library
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "xmalloc.h"
|
||||||
|
#include "oleauto.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
ITypeLib *pTypeLib;
|
||||||
|
wchar_t *fname;
|
||||||
|
HRESULT hr;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
|
if ( argc != 2 ) {
|
||||||
|
fprintf (stderr,"usage: regtlb foo.tlb\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = mbstowcs (NULL, argv[1], strlen(argv[1])+1);
|
||||||
|
fprintf (stderr, "need %d bytes\n", (int)n);
|
||||||
|
fname = xmalloc ((n+1)*sizeof *fname);
|
||||||
|
mbstowcs (fname, argv[1], strlen (argv[1])+1);
|
||||||
|
|
||||||
|
hr = CoInitializeEx (NULL, COINIT_MULTITHREADED);
|
||||||
|
if (hr)
|
||||||
|
fprintf (stderr, "CoInitializeEx() failed: hr=%lu\n", hr);
|
||||||
|
|
||||||
|
hr = LoadTypeLibEx (fname, REGKIND_REGISTER, &pTypeLib);
|
||||||
|
if (hr)
|
||||||
|
fprintf (stderr, "LoadTypeLibEx() failed: hr=%lx\n", hr);
|
||||||
|
|
||||||
|
ITypeLib_Release (pTypeLib);
|
||||||
|
|
||||||
|
CoUninitialize ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
157
tags/gpgme-0-3-0/complus/tgpgcom.c
Normal file
157
tags/gpgme-0-3-0/complus/tgpgcom.c
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/* tgpgcom.c - Test the IGpgme classes
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define INITGUID
|
||||||
|
#include "igpgme.h"
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
IUnknown *pUnknown = NULL;
|
||||||
|
IGpgme *pGpgme;
|
||||||
|
HRESULT hr;
|
||||||
|
BSTR bs;
|
||||||
|
|
||||||
|
hr = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
|
||||||
|
if (hr)
|
||||||
|
fprintf (stderr, "CoInitializeEx() failed: hr=%lu\n", hr);
|
||||||
|
|
||||||
|
fprintf (stderr, "system initialized\n");
|
||||||
|
hr = CoCreateInstance (&CLSID_Gpgme, NULL, CLSCTX_LOCAL_SERVER,
|
||||||
|
&IID_IUnknown, (void**)&pUnknown );
|
||||||
|
if (hr)
|
||||||
|
fprintf (stderr, "CoCreateInstance() failed: hr=%lx\n", hr);
|
||||||
|
if (!pUnknown)
|
||||||
|
exit (1);
|
||||||
|
|
||||||
|
fprintf (stderr,"got object %p - querying %s\n",
|
||||||
|
pUnknown, debugstr_guid(&IID_IGpgme));
|
||||||
|
hr = IGpgme_QueryInterface (pUnknown, &IID_IGpgme, (void**)&pGpgme);
|
||||||
|
if (hr) {
|
||||||
|
fprintf (stderr, "QueryInterface() failed: hr=%lx\n", hr);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
fprintf (stderr, "got interface %p\n", pGpgme);
|
||||||
|
|
||||||
|
hr = IGpgme_SetArmor (pGpgme, 1);
|
||||||
|
fprintf (stderr, "SetArmor returned %lx\n", hr);
|
||||||
|
|
||||||
|
hr = IGpgme_SetTextmode (pGpgme, 0);
|
||||||
|
fprintf (stderr, "SetTextmode returned %lx\n", hr);
|
||||||
|
|
||||||
|
hr = IGpgme_ClearRecipients (pGpgme);
|
||||||
|
fprintf (stderr, "ClearRecipients returned %lx\n", hr);
|
||||||
|
|
||||||
|
bs = SysAllocString (L"alice");
|
||||||
|
if (!bs)
|
||||||
|
fprintf (stderr, "SysAllocString failed: ec=%d\n", (int)GetLastError());
|
||||||
|
else {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=-4; i < 12; i++ )
|
||||||
|
fprintf (stderr," %02X", ((unsigned char*)bs)[i] );
|
||||||
|
putc ('\n', stderr);
|
||||||
|
}
|
||||||
|
hr = IGpgme_AddRecipient (pGpgme, bs, -1);
|
||||||
|
fprintf (stderr, "AddRecipients returned %lx\n", hr);
|
||||||
|
|
||||||
|
{
|
||||||
|
SAFEARRAY *sa;
|
||||||
|
VARIANT v;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
sa = SafeArrayCreateVector (VT_UI1, 0, 20);
|
||||||
|
if (!sa) {
|
||||||
|
fprintf (stderr, "SafeArrayCreateVector failed\n");
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = SafeArrayAccessData (sa, (void**)&p);
|
||||||
|
if (hr) {
|
||||||
|
fprintf (stderr,"SafeArrayAccessData failed: hr=%lx\n", hr);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (p, "=> Omnis enim res <=", 20 );
|
||||||
|
SafeArrayUnaccessData (sa);
|
||||||
|
|
||||||
|
VariantInit (&v);
|
||||||
|
v.vt = (VT_ARRAY|VT_UI1);
|
||||||
|
v.u.parray = sa;
|
||||||
|
|
||||||
|
hr = IGpgme_SetPlaintext (pGpgme, v );
|
||||||
|
fprintf (stderr, "SetPlaintext returned %lx\n", hr);
|
||||||
|
SafeArrayDestroyData (sa);
|
||||||
|
SafeArrayDestroy (sa);
|
||||||
|
|
||||||
|
VariantClear (&v);
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = IGpgme_Encrypt (pGpgme);
|
||||||
|
fprintf (stderr, "Encrypt returned %lx\n", hr);
|
||||||
|
|
||||||
|
{
|
||||||
|
VARIANT v;
|
||||||
|
|
||||||
|
hr = IGpgme_GetCiphertext (pGpgme, &v);
|
||||||
|
fprintf (stderr, "GetCiphertext returned %lx\n", hr);
|
||||||
|
if (!hr) {
|
||||||
|
if (v.vt != (VT_ARRAY|VT_UI1))
|
||||||
|
fprintf (stderr, "Invalid array typed returned\n");
|
||||||
|
else {
|
||||||
|
unsigned char *p;
|
||||||
|
|
||||||
|
hr = SafeArrayAccessData (v.u.parray, (void**)&p);
|
||||||
|
if (hr)
|
||||||
|
fprintf (stderr,"*** SafeArrayAccessData failed: %lx\n", hr);
|
||||||
|
else {
|
||||||
|
size_t arraysize = v.u.parray->rgsabound[0].cElements;
|
||||||
|
fprintf (stderr,"*** got %d bytes\n", (int)arraysize);
|
||||||
|
for (;arraysize; arraysize--, p++ )
|
||||||
|
putc (*p, stderr);
|
||||||
|
SafeArrayUnaccessData (v.u.parray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IGpgme_Release (pGpgme);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
CoUninitialize ();
|
||||||
|
fprintf (stderr, "system uninitialized\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
236
tags/gpgme-0-3-0/complus/utf8.c
Normal file
236
tags/gpgme-0-3-0/complus/utf8.c
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
/*
|
||||||
|
* UTF-8 support routines
|
||||||
|
*
|
||||||
|
* Copyright 2000 Alexandre Julliard
|
||||||
|
*
|
||||||
|
* Taken from WINE, so the usual WINE copyright applies:
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <ole2.h>
|
||||||
|
|
||||||
|
/* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */
|
||||||
|
static const char utf8_length[128] =
|
||||||
|
{
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80-0x8f */
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90-0x9f */
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xa0-0xaf */
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xb0-0xbf */
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xc0-0xcf */
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xd0-0xdf */
|
||||||
|
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 0xe0-0xef */
|
||||||
|
3,3,3,3,3,3,3,3,4,4,4,4,5,5,0,0 /* 0xf0-0xff */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* first byte mask depending on UTF-8 sequence length */
|
||||||
|
static const unsigned char utf8_mask[6] = { 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
|
||||||
|
|
||||||
|
/* minimum Unicode value depending on UTF-8 sequence length */
|
||||||
|
static const unsigned int utf8_minval[6] = { 0x0, 0x80, 0x800, 0x10000, 0x200000, 0x4000000 };
|
||||||
|
|
||||||
|
|
||||||
|
/* query necessary dst length for src string */
|
||||||
|
inline static int get_length_wcs_utf8( const WCHAR *src, unsigned int srclen )
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
for (len = 0; srclen; srclen--, src++, len++)
|
||||||
|
{
|
||||||
|
if (*src >= 0x80)
|
||||||
|
{
|
||||||
|
len++;
|
||||||
|
if (*src >= 0x800) len++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wide char to UTF-8 string conversion */
|
||||||
|
/* return -1 on dst buffer overflow */
|
||||||
|
int utf8_wcstombs( const WCHAR *src, int srclen, char *dst, int dstlen )
|
||||||
|
{
|
||||||
|
char *orig_dst = dst;
|
||||||
|
|
||||||
|
if (!dstlen) return get_length_wcs_utf8( src, srclen );
|
||||||
|
|
||||||
|
for (; srclen; srclen--, src++)
|
||||||
|
{
|
||||||
|
WCHAR ch = *src;
|
||||||
|
|
||||||
|
if (ch < 0x80) /* 0x00-0x7f: 1 byte */
|
||||||
|
{
|
||||||
|
if (!dstlen--) return -1; /* overflow */
|
||||||
|
*dst++ = ch;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */
|
||||||
|
{
|
||||||
|
if ((dstlen -= 2) < 0) return -1; /* overflow */
|
||||||
|
dst[1] = 0x80 | (ch & 0x3f);
|
||||||
|
ch >>= 6;
|
||||||
|
dst[0] = 0xc0 | ch;
|
||||||
|
dst += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 0x800-0xffff: 3 bytes */
|
||||||
|
|
||||||
|
if ((dstlen -= 3) < 0) return -1; /* overflow */
|
||||||
|
dst[2] = 0x80 | (ch & 0x3f);
|
||||||
|
ch >>= 6;
|
||||||
|
dst[1] = 0x80 | (ch & 0x3f);
|
||||||
|
ch >>= 6;
|
||||||
|
dst[0] = 0xe0 | ch;
|
||||||
|
dst += 3;
|
||||||
|
}
|
||||||
|
return dst - orig_dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* query necessary dst length for src string */
|
||||||
|
inline static int get_length_mbs_utf8( const unsigned char *src, int srclen )
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
const unsigned char *srcend = src + srclen;
|
||||||
|
|
||||||
|
for (ret = 0; src < srcend; ret++)
|
||||||
|
{
|
||||||
|
unsigned char ch = *src++;
|
||||||
|
if (ch < 0xc0) continue;
|
||||||
|
|
||||||
|
switch(utf8_length[ch-0x80])
|
||||||
|
{
|
||||||
|
case 5:
|
||||||
|
if (src >= srcend) return ret; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) continue;
|
||||||
|
src++;
|
||||||
|
case 4:
|
||||||
|
if (src >= srcend) return ret; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) continue;
|
||||||
|
src++;
|
||||||
|
case 3:
|
||||||
|
if (src >= srcend) return ret; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) continue;
|
||||||
|
src++;
|
||||||
|
case 2:
|
||||||
|
if (src >= srcend) return ret; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) continue;
|
||||||
|
src++;
|
||||||
|
case 1:
|
||||||
|
if (src >= srcend) return ret; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) continue;
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* UTF-8 to wide char string conversion */
|
||||||
|
/* return -1 on dst buffer overflow, -2 on invalid input char */
|
||||||
|
int utf8_mbstowcs( int flags, const char *src, int srclen, WCHAR *dst, int dstlen )
|
||||||
|
{
|
||||||
|
int len, count;
|
||||||
|
unsigned int res;
|
||||||
|
const char *srcend = src + srclen;
|
||||||
|
|
||||||
|
if (!dstlen) return get_length_mbs_utf8( src, srclen );
|
||||||
|
|
||||||
|
for (count = dstlen; count && (src < srcend); count--, dst++)
|
||||||
|
{
|
||||||
|
unsigned char ch = *src++;
|
||||||
|
if (ch < 0x80) /* special fast case for 7-bit ASCII */
|
||||||
|
{
|
||||||
|
*dst = ch;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
len = utf8_length[ch-0x80];
|
||||||
|
res = ch & utf8_mask[len];
|
||||||
|
|
||||||
|
switch(len)
|
||||||
|
{
|
||||||
|
case 5:
|
||||||
|
if (src >= srcend) goto done; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) goto bad;
|
||||||
|
res = (res << 6) | ch;
|
||||||
|
src++;
|
||||||
|
case 4:
|
||||||
|
if (src >= srcend) goto done; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) goto bad;
|
||||||
|
res = (res << 6) | ch;
|
||||||
|
src++;
|
||||||
|
case 3:
|
||||||
|
if (src >= srcend) goto done; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) goto bad;
|
||||||
|
res = (res << 6) | ch;
|
||||||
|
src++;
|
||||||
|
case 2:
|
||||||
|
if (src >= srcend) goto done; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) goto bad;
|
||||||
|
res = (res << 6) | ch;
|
||||||
|
src++;
|
||||||
|
case 1:
|
||||||
|
if (src >= srcend) goto done; /* ignore partial char */
|
||||||
|
if ((ch = *src ^ 0x80) >= 0x40) goto bad;
|
||||||
|
res = (res << 6) | ch;
|
||||||
|
src++;
|
||||||
|
if (res < utf8_minval[len]) goto bad;
|
||||||
|
if (res >= 0x10000) goto bad; /* FIXME: maybe we should do surrogates here */
|
||||||
|
*dst = res;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
bad:
|
||||||
|
if (flags & MB_ERR_INVALID_CHARS) return -2; /* bad char */
|
||||||
|
*dst = (WCHAR)'?';
|
||||||
|
}
|
||||||
|
if (src < srcend) return -1; /* overflow */
|
||||||
|
done:
|
||||||
|
return dstlen - count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
bstrtoutf8 ( BSTR src, char *dst, size_t dstlen )
|
||||||
|
{
|
||||||
|
size_t srclen, needed;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
srclen = src? SysStringLen (src): 0;
|
||||||
|
|
||||||
|
needed = srclen? (utf8_wcstombs (src, srclen, NULL, 0) + 1) : 1;
|
||||||
|
if (!dst || !dstlen)
|
||||||
|
return needed;
|
||||||
|
if (dstlen < needed)
|
||||||
|
return -1;
|
||||||
|
if (srclen) {
|
||||||
|
n = utf8_wcstombs (src, srclen, dst, dstlen);
|
||||||
|
if (n < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
n = 0;
|
||||||
|
dst[n] = 0;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
47
tags/gpgme-0-3-0/complus/vbtest.html
Normal file
47
tags/gpgme-0-3-0/complus/vbtest.html
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<html>
|
||||||
|
<head><title>g10 code - GPGCOM test</title>
|
||||||
|
|
||||||
|
<object id="gpg"
|
||||||
|
classid="CLSID:3811fd40-7f72-11d5-8c9e-0080ad190cd5">
|
||||||
|
</object>
|
||||||
|
|
||||||
|
<script language="VBScript">
|
||||||
|
Sub encrypt_text
|
||||||
|
On error resume next
|
||||||
|
Dim TheForm, plain
|
||||||
|
|
||||||
|
set TheForm = Document.forms ("MyForm")
|
||||||
|
gpg.armor = True
|
||||||
|
gpg.plaintext = TheForm.clear.value
|
||||||
|
gpg.ClearRecipients
|
||||||
|
gpg.AddRecipient TheForm.recp.value
|
||||||
|
Err.Clear
|
||||||
|
gpg.Encrypt
|
||||||
|
if Err <> 0 then
|
||||||
|
TheForm.encoded.value = "Error: " & CStr(Err.Number)
|
||||||
|
else
|
||||||
|
TheForm.encoded.value = gpg.ciphertext
|
||||||
|
end if
|
||||||
|
end sub
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Silly Gpgcom test page</h1>
|
||||||
|
|
||||||
|
<form id="MyForm">
|
||||||
|
<textarea name="clear" rows = 3 cols=40>Please enter the text here</textarea>
|
||||||
|
<p>
|
||||||
|
Encrypt for <input name="recp" value="alice">
|
||||||
|
<input type="button" name="MyAction" value="Encrypt"
|
||||||
|
language="VBScript" onclick="encrypt_text()">
|
||||||
|
<p>
|
||||||
|
<textarea name="encoded" rows=10 cols=75></textarea>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
39
tags/gpgme-0-3-0/complus/vbtest.vbs
Normal file
39
tags/gpgme-0-3-0/complus/vbtest.vbs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
' Demo script to generate a RFC2015 compliant message using Gpgcom
|
||||||
|
Dim gpg, body, crlf
|
||||||
|
|
||||||
|
crlf = chr(10) & chr(13)
|
||||||
|
|
||||||
|
' Create out Gpgcom object
|
||||||
|
set gpg = CreateObject("Gpgcom.Gpgme")
|
||||||
|
' We must use the ASCII armor and switch to textmode
|
||||||
|
gpg.armor = true
|
||||||
|
gpg.textmode = true
|
||||||
|
|
||||||
|
' Set the secret message
|
||||||
|
gpg.plaintext = "This is the secret message." 'or: InputBox('Enter message:")
|
||||||
|
|
||||||
|
' Set the Recipient. You may also use a keyID or an fingerprint
|
||||||
|
gpg.AddRecipient "alice"
|
||||||
|
|
||||||
|
' And encrypt the stuff
|
||||||
|
gpg.encrypt
|
||||||
|
|
||||||
|
' Build the MIME message
|
||||||
|
body = "Content-Type: multipart/encrypted; boundary="
|
||||||
|
body = body & Chr(34) & "=-=-=-=" & Chr(34) & crlf & " protocol=" & Chr(34)
|
||||||
|
body = body & "application/pgp-encrypted" & Chr(34) & crlf & crlf
|
||||||
|
body = body & "--=-=-=-=" & crlf
|
||||||
|
body = body & "Content-Type: application/pgp-encrypted" & crlf & crlf
|
||||||
|
body = body & "Version: 1" & crlf & crlf
|
||||||
|
body = body & "--=-=-=-=" & crlf
|
||||||
|
body = body & "Content-Type: application/octet-stream" & crlf & crlf
|
||||||
|
body = body & gpg.ciphertext
|
||||||
|
body = body & "--=-=-=-=--" & crlf
|
||||||
|
|
||||||
|
' And display it
|
||||||
|
Print body
|
||||||
|
|
||||||
|
' output function for the windows scripting host
|
||||||
|
sub Print(x)
|
||||||
|
WScript.Echo x
|
||||||
|
end sub
|
223
tags/gpgme-0-3-0/configure.ac
Normal file
223
tags/gpgme-0-3-0/configure.ac
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
# configure.in for GPGME
|
||||||
|
# Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# (Process this file with autoconf to produce a configure script.)
|
||||||
|
|
||||||
|
AC_INIT(gpgme, 0.2.3a, [gnupg-devel@gnupg.org])
|
||||||
|
AC_PREREQ(2.52)
|
||||||
|
AC_REVISION($Revision$)
|
||||||
|
|
||||||
|
AC_CONFIG_SRCDIR(gpgme/gpgme.h)
|
||||||
|
AM_CONFIG_HEADER(config.h)
|
||||||
|
AM_INIT_AUTOMAKE(gpgme, 0.3.0)
|
||||||
|
AM_MAINTAINER_MODE
|
||||||
|
|
||||||
|
AC_PROG_CC
|
||||||
|
|
||||||
|
# Version numbers (Remember to change them just before a release.)
|
||||||
|
# (Code changed: REVISION++)
|
||||||
|
# (Interfaces added/removed/changed: CURRENT++, REVISION=0)
|
||||||
|
# (Interfaces added: AGE++)
|
||||||
|
# (Interfaces removed: AGE=0)
|
||||||
|
# XXXX new functions
|
||||||
|
LIBGPGME_LT_CURRENT=5
|
||||||
|
LIBGPGME_LT_AGE=0
|
||||||
|
LIBGPGME_LT_REVISION=0
|
||||||
|
NEED_GPG_VERSION=1.0.6
|
||||||
|
NEED_GPGSM_VERSION=0.0.0
|
||||||
|
##############################################
|
||||||
|
|
||||||
|
AC_SUBST(LIBGPGME_LT_CURRENT)
|
||||||
|
AC_SUBST(LIBGPGME_LT_AGE)
|
||||||
|
AC_SUBST(LIBGPGME_LT_REVISION)
|
||||||
|
AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION")
|
||||||
|
AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION")
|
||||||
|
|
||||||
|
dnl Don't default to build static libs.
|
||||||
|
dnl AC_DISABLE_STATIC
|
||||||
|
AC_PROG_LIBTOOL
|
||||||
|
|
||||||
|
GPG_DEFAULT=no
|
||||||
|
GPGSM_DEFAULT=no
|
||||||
|
component_system=None
|
||||||
|
case "${target}" in
|
||||||
|
*-*-mingw32* | i?86-emx-os2 | i?86-*-os2*emx | i?86-*-msdosdjgpp* )
|
||||||
|
# special stuff for Windoze NT
|
||||||
|
# OS/2 with the EMX environment
|
||||||
|
# DOS with the DJGPP environment
|
||||||
|
AC_DEFINE(HAVE_DRIVE_LETTERS)
|
||||||
|
AC_DEFINE(HAVE_DOSISH_SYSTEM)
|
||||||
|
GPG_DEFAULT='c:\\gnupg\\gpg.exe'
|
||||||
|
GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe'
|
||||||
|
#component_system='COM+'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
dnl # XXX: Probably use exec-prefix here?
|
||||||
|
dnl GPG_DEFAULT='/usr/bin/gpg'
|
||||||
|
dnl GPGSM_DEFAULT='/usr/bin/gpgsm'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Checks for libraries.
|
||||||
|
dnl
|
||||||
|
|
||||||
|
dnl FIXME: check whether Bonobo is installed
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Checks for header files.
|
||||||
|
dnl
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Checks for typedefs and structures.
|
||||||
|
dnl
|
||||||
|
GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
|
||||||
|
GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
|
||||||
|
GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
|
||||||
|
GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
|
||||||
|
GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
|
||||||
|
|
||||||
|
# We should not use them in this software;
|
||||||
|
# However jnlib/types.h needs them - so we take the easy way.
|
||||||
|
AC_CHECK_SIZEOF(unsigned short)
|
||||||
|
AC_CHECK_SIZEOF(unsigned int)
|
||||||
|
AC_CHECK_SIZEOF(unsigned long)
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Checks for compiler features.
|
||||||
|
dnl
|
||||||
|
|
||||||
|
if test "$GCC" = yes; then
|
||||||
|
CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Checks for library functions.
|
||||||
|
dnl
|
||||||
|
dnl These are needed by libjnlib
|
||||||
|
AC_CHECK_FUNCS(memicmp stpcpy strlwr strtoul memmove stricmp)
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Checks for system services
|
||||||
|
dnl
|
||||||
|
|
||||||
|
NO_OVERRIDE=no
|
||||||
|
AC_ARG_WITH(gpg,
|
||||||
|
AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
|
||||||
|
GPG=$withval, NO_OVERRIDE=yes)
|
||||||
|
if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then
|
||||||
|
GPG=
|
||||||
|
NO_OVERRIDE=yes
|
||||||
|
if test "$cross_compiling" != "yes"; then
|
||||||
|
AC_PATH_PROG(GPG, gpg)
|
||||||
|
fi
|
||||||
|
if test -z "$GPG"; then
|
||||||
|
GPG="$GPG_DEFAULT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "$GPG" = no; then
|
||||||
|
if test "$NO_OVERRIDE" = "yes"; then
|
||||||
|
if test "$cross_compiling" != "yes"; then
|
||||||
|
AC_MSG_WARN([Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it])
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR([Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG")
|
||||||
|
AC_SUBST(GPG)
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL(RUN_GPG_TESTS,
|
||||||
|
[test "$cross_compiling" != "yes" && test -n "$GPG" && test -r "$GPG"])
|
||||||
|
AC_SUBST(GPG_PATH)
|
||||||
|
|
||||||
|
NO_OVERRIDE=no
|
||||||
|
AC_ARG_WITH(gpgsm,
|
||||||
|
AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]),
|
||||||
|
GPGSM=$withval, NO_OVERRIDE=yes)
|
||||||
|
if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then
|
||||||
|
GPGSM=
|
||||||
|
NO_OVERRIDE=yes
|
||||||
|
if test "$cross_compiling" != "yes"; then
|
||||||
|
AC_PATH_PROG(GPGSM, gpgsm)
|
||||||
|
fi
|
||||||
|
if test -z "$GPGSM"; then
|
||||||
|
GPGSM="$GPGSM_DEFAULT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "$GPGSM" = no; then
|
||||||
|
if test "$NO_OVERRIDE" = "yes"; then
|
||||||
|
if test "$cross_compiling" != "yes"; then
|
||||||
|
AC_MSG_WARN([Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it])
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR([Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM")
|
||||||
|
AC_SUBST(GPGSM)
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL(RUN_GPGSM_TESTS,
|
||||||
|
[test "$cross_compiling" != "yes" && test -n "$GPGSM" && test -r "$GPGSM"])
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Create config files
|
||||||
|
dnl
|
||||||
|
|
||||||
|
dnl FIXME: Only build if supported.
|
||||||
|
AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no")
|
||||||
|
|
||||||
|
AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+")
|
||||||
|
AM_CONDITIONAL(BUILD_BONOBO, test "$component_system" = "Bonobo")
|
||||||
|
|
||||||
|
GPGMEPLUG=no
|
||||||
|
AC_ARG_ENABLE(gpgmeplug,
|
||||||
|
AC_HELP_STRING([--enable-gpgmeplug], [build GPGME Crypt Plug-In]),
|
||||||
|
GPGMEPLUG=$enableval)
|
||||||
|
AM_CONDITIONAL(BUILD_GPGMEPLUG, test "$GPGMEPLUG" = "yes")
|
||||||
|
|
||||||
|
dnl Make the version number in gpgme/gpgme.h the same as the one here.
|
||||||
|
dnl (this is easier than to have a *.in file just for one substitution)
|
||||||
|
GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION)
|
||||||
|
|
||||||
|
dnl Substitution used for gpgme-config
|
||||||
|
GPGME_LIBS="-L${libdir} -lgpgme"
|
||||||
|
GPGME_CFLAGS=""
|
||||||
|
AC_SUBST(GPGME_LIBS)
|
||||||
|
AC_SUBST(GPGME_CFLAGS)
|
||||||
|
|
||||||
|
AC_CONFIG_FILES(Makefile assuan/Makefile jnlib/Makefile gpgme/Makefile
|
||||||
|
tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile
|
||||||
|
doc/Makefile
|
||||||
|
bonobo/Makefile complus/Makefile gpgmeplug/Makefile)
|
||||||
|
AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config)
|
||||||
|
AC_OUTPUT
|
||||||
|
|
||||||
|
echo "
|
||||||
|
GPGME v${VERSION} has been configured as follows:
|
||||||
|
|
||||||
|
GnuPG version: min. $NEED_GPG_VERSION
|
||||||
|
GnuPG path: $GPG
|
||||||
|
|
||||||
|
GpgSM version: min. $NEED_GPGSM_VERSION
|
||||||
|
GpgSM path: $GPGSM
|
||||||
|
|
||||||
|
GPGME CryptPlug: $GPGMEPLUG
|
||||||
|
"
|
1
tags/gpgme-0-3-0/doc/.cvsignore
Normal file
1
tags/gpgme-0-3-0/doc/.cvsignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
Makefile.in Makefile
|
27
tags/gpgme-0-3-0/doc/Makefile.am
Normal file
27
tags/gpgme-0-3-0/doc/Makefile.am
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# doc - Automake template
|
||||||
|
# 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
|
||||||
|
|
||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
EXTRA_DIST = gdoc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
681
tags/gpgme-0-3-0/doc/gdoc
Executable file
681
tags/gpgme-0-3-0/doc/gdoc
Executable file
@ -0,0 +1,681 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
|
||||||
|
## hacked to allow -tex option --nmav ##
|
||||||
|
## ##
|
||||||
|
## This software falls under the GNU Public License. Please read ##
|
||||||
|
## the COPYING file for more information ##
|
||||||
|
|
||||||
|
#
|
||||||
|
# This will read a 'c' file and scan for embedded comments in the
|
||||||
|
# style of gnome comments (+minor extensions - see below).
|
||||||
|
#
|
||||||
|
|
||||||
|
# Note: This only supports 'c'.
|
||||||
|
|
||||||
|
# usage:
|
||||||
|
# gdoc [ -docbook | -html | -text | -man ]
|
||||||
|
# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile
|
||||||
|
#
|
||||||
|
# Set output format using one of -docbook -html -text or -man. Default is man.
|
||||||
|
#
|
||||||
|
# -function funcname
|
||||||
|
# If set, then only generate documentation for the given function(s). All
|
||||||
|
# other functions are ignored.
|
||||||
|
#
|
||||||
|
# c files - list of 'c' files to process
|
||||||
|
#
|
||||||
|
# All output goes to stdout, with errors to stderr.
|
||||||
|
|
||||||
|
#
|
||||||
|
# format of comments.
|
||||||
|
# In the following table, (...)? signifies optional structure.
|
||||||
|
# (...)* signifies 0 or more structure elements
|
||||||
|
# /**
|
||||||
|
# * function_name(:)? (- short description)?
|
||||||
|
# (* @parameterx: (description of parameter x)?)*
|
||||||
|
# (* a blank line)?
|
||||||
|
# * (Description:)? (Description of function)?
|
||||||
|
# * (section header: (section description)? )*
|
||||||
|
# (*)?*/
|
||||||
|
#
|
||||||
|
# So .. the trivial example would be:
|
||||||
|
#
|
||||||
|
# /**
|
||||||
|
# * my_function
|
||||||
|
# **/
|
||||||
|
#
|
||||||
|
# If the Description: header tag is ommitted, then there must be a blank line
|
||||||
|
# after the last parameter specification.
|
||||||
|
# e.g.
|
||||||
|
# /**
|
||||||
|
# * my_function - does my stuff
|
||||||
|
# * @my_arg: its mine damnit
|
||||||
|
# *
|
||||||
|
# * Does my stuff explained.
|
||||||
|
# */
|
||||||
|
#
|
||||||
|
# or, could also use:
|
||||||
|
# /**
|
||||||
|
# * my_function - does my stuff
|
||||||
|
# * @my_arg: its mine damnit
|
||||||
|
# * Description: Does my stuff explained.
|
||||||
|
# */
|
||||||
|
# etc.
|
||||||
|
#
|
||||||
|
# All descriptions can be multiline, apart from the short function description.
|
||||||
|
#
|
||||||
|
# All descriptive text is further processed, scanning for the following special
|
||||||
|
# patterns, which are highlighted appropriately.
|
||||||
|
#
|
||||||
|
# 'funcname()' - function
|
||||||
|
# '$ENVVAR' - environmental variable
|
||||||
|
# '&struct_name' - name of a structure
|
||||||
|
# '@parameter' - name of a parameter
|
||||||
|
# '%CONST' - name of a constant.
|
||||||
|
|
||||||
|
# match expressions used to find embedded type information
|
||||||
|
$type_constant = "\\\%(\\w+)";
|
||||||
|
#$type_func = "(\\w+\\(\\))";
|
||||||
|
$type_func = "(\\(w||\\\\)+\\(\\))";
|
||||||
|
$type_param = "\\\@(\\w+)";
|
||||||
|
$type_struct = "\\\&(\\w+)";
|
||||||
|
$type_env = "(\\\$\\w+)";
|
||||||
|
|
||||||
|
|
||||||
|
# Output conversion substitutions.
|
||||||
|
# One for each output format
|
||||||
|
|
||||||
|
# these work fairly well
|
||||||
|
%highlights_html = ( $type_constant, "<i>\$1</i>",
|
||||||
|
$type_func, "<b>\$1</b>",
|
||||||
|
$type_struct, "<i>\$1</i>",
|
||||||
|
$type_param, "<tt><b>\$1</b></tt>" );
|
||||||
|
$blankline_html = "<p>";
|
||||||
|
|
||||||
|
%highlights_tex = ( $type_constant, "{\\\\it \$1}",
|
||||||
|
$type_func, "{\\\\bf \$1}",
|
||||||
|
$type_struct, "{\\\\it \$1}",
|
||||||
|
$type_param, "{\\\\bf \$1}" );
|
||||||
|
$blankline_tex = "\\par";
|
||||||
|
|
||||||
|
# sgml, docbook format
|
||||||
|
%highlights_sgml = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>",
|
||||||
|
$type_func, "<function>\$1</function>",
|
||||||
|
$type_struct, "<structname>\$1</structname>",
|
||||||
|
$type_env, "<envar>\$1</envar>",
|
||||||
|
$type_param, "<parameter>\$1</parameter>" );
|
||||||
|
$blankline_sgml = "</para><para>\n";
|
||||||
|
|
||||||
|
# these are pretty rough
|
||||||
|
%highlights_man = ( $type_constant, "\\n.I \\\"\$1\\\"\\n",
|
||||||
|
$type_func, "\\n.B \\\"\$1\\\"\\n",
|
||||||
|
$type_struct, "\\n.I \\\"\$1\\\"\\n",
|
||||||
|
$type_param."([\.\, ]*)\n?", "\\n.I \\\"\$1\$2\\\"\\n" );
|
||||||
|
$blankline_man = "";
|
||||||
|
|
||||||
|
# text-mode
|
||||||
|
%highlights_text = ( $type_constant, "\$1",
|
||||||
|
$type_func, "\$1",
|
||||||
|
$type_struct, "\$1",
|
||||||
|
$type_param, "\$1" );
|
||||||
|
$blankline_text = "";
|
||||||
|
|
||||||
|
|
||||||
|
sub usage {
|
||||||
|
print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man | -tex ]\n";
|
||||||
|
print " [ -function funcname [ -function funcname ...] ]\n";
|
||||||
|
print " c source file(s) > outputfile\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# read arguments
|
||||||
|
if ($#ARGV==-1) {
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
$verbose = 0;
|
||||||
|
$output_mode = "man";
|
||||||
|
%highlights = %highlights_man;
|
||||||
|
$blankline = $blankline_man;
|
||||||
|
$modulename = "API Documentation";
|
||||||
|
$function_only = 0;
|
||||||
|
while ($ARGV[0] =~ m/^-(.*)/) {
|
||||||
|
$cmd = shift @ARGV;
|
||||||
|
if ($cmd eq "-html") {
|
||||||
|
$output_mode = "html";
|
||||||
|
%highlights = %highlights_html;
|
||||||
|
$blankline = $blankline_html;
|
||||||
|
} elsif ($cmd eq "-man") {
|
||||||
|
$output_mode = "man";
|
||||||
|
%highlights = %highlights_man;
|
||||||
|
$blankline = $blankline_man;
|
||||||
|
} elsif ($cmd eq "-tex") {
|
||||||
|
$output_mode = "tex";
|
||||||
|
%highlights = %highlights_tex;
|
||||||
|
$blankline = $blankline_tex;
|
||||||
|
} elsif ($cmd eq "-text") {
|
||||||
|
$output_mode = "text";
|
||||||
|
%highlights = %highlights_text;
|
||||||
|
$blankline = $blankline_text;
|
||||||
|
} elsif ($cmd eq "-docbook") {
|
||||||
|
$output_mode = "sgml";
|
||||||
|
%highlights = %highlights_sgml;
|
||||||
|
$blankline = $blankline_sgml;
|
||||||
|
} elsif ($cmd eq "-module") { # not needed for sgml, inherits from calling document
|
||||||
|
$modulename = shift @ARGV;
|
||||||
|
} elsif ($cmd eq "-function") { # to only output specific functions
|
||||||
|
$function_only = 1;
|
||||||
|
$function = shift @ARGV;
|
||||||
|
$function_table{$function} = 1;
|
||||||
|
} elsif ($cmd eq "-v") {
|
||||||
|
$verbose = 1;
|
||||||
|
} elsif (($cmd eq "-h") || ($cmd eq "--help")) {
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# generate a sequence of code that will splice in highlighting information
|
||||||
|
# using the s// operator.
|
||||||
|
$dohighlight = "";
|
||||||
|
foreach $pattern (keys %highlights) {
|
||||||
|
# print "scanning pattern $pattern ($highlights{$pattern})\n";
|
||||||
|
$dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# dumps section contents to arrays/hashes intended for that purpose.
|
||||||
|
#
|
||||||
|
sub dump_section {
|
||||||
|
my $name = shift @_;
|
||||||
|
my $contents = join "\n", @_;
|
||||||
|
|
||||||
|
if ($name =~ m/$type_constant/) {
|
||||||
|
$name = $1;
|
||||||
|
# print STDERR "constant section '$1' = '$contents'\n";
|
||||||
|
$constants{$name} = $contents;
|
||||||
|
} elsif ($name =~ m/$type_param/) {
|
||||||
|
# print STDERR "parameter def '$1' = '$contents'\n";
|
||||||
|
$name = $1;
|
||||||
|
$parameters{$name} = $contents;
|
||||||
|
} else {
|
||||||
|
# print STDERR "other section '$name' = '$contents'\n";
|
||||||
|
$sections{$name} = $contents;
|
||||||
|
push @sectionlist, $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# output function
|
||||||
|
#
|
||||||
|
# parameters, a hash.
|
||||||
|
# function => "function name"
|
||||||
|
# parameterlist => @list of parameters
|
||||||
|
# parameters => %parameter descriptions
|
||||||
|
# sectionlist => @list of sections
|
||||||
|
# sections => %descriont descriptions
|
||||||
|
#
|
||||||
|
|
||||||
|
sub output_highlight {
|
||||||
|
my $contents = join "\n", @_;
|
||||||
|
my $line;
|
||||||
|
|
||||||
|
eval $dohighlight;
|
||||||
|
foreach $line (split "\n", $contents) {
|
||||||
|
if ($line eq ""){
|
||||||
|
print $lineprefix, $blankline;
|
||||||
|
} else {
|
||||||
|
print $lineprefix, $line;
|
||||||
|
}
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# output in html
|
||||||
|
sub output_html {
|
||||||
|
my %args = %{$_[0]};
|
||||||
|
my ($parameter, $section);
|
||||||
|
my $count;
|
||||||
|
print "\n\n<a name=\"". $args{'function'} . "\"> </a><h2>Function</h2>\n";
|
||||||
|
|
||||||
|
print "<i>".$args{'functiontype'}."</i>\n";
|
||||||
|
print "<b>".$args{'function'}."</b>\n";
|
||||||
|
print "(";
|
||||||
|
$count = 0;
|
||||||
|
foreach $parameter (@{$args{'parameterlist'}}) {
|
||||||
|
print "<i>".$args{'parametertypes'}{$parameter}."</i> <b>".$parameter."</b>\n";
|
||||||
|
if ($count != $#{$args{'parameterlist'}}) {
|
||||||
|
$count++;
|
||||||
|
print ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print ")\n";
|
||||||
|
|
||||||
|
print "<h3>Arguments</h3>\n";
|
||||||
|
print "<dl>\n";
|
||||||
|
foreach $parameter (@{$args{'parameterlist'}}) {
|
||||||
|
print "<dt><i>".$args{'parametertypes'}{$parameter}."</i> <b>".$parameter."</b>\n";
|
||||||
|
print "<dd>";
|
||||||
|
output_highlight($args{'parameters'}{$parameter});
|
||||||
|
}
|
||||||
|
print "</dl>\n";
|
||||||
|
foreach $section (@{$args{'sectionlist'}}) {
|
||||||
|
print "<h3>$section</h3>\n";
|
||||||
|
print "<ul>\n";
|
||||||
|
output_highlight($args{'sections'}{$section});
|
||||||
|
print "</ul>\n";
|
||||||
|
}
|
||||||
|
print "<hr>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# output in tex
|
||||||
|
sub output_tex {
|
||||||
|
my %args = %{$_[0]};
|
||||||
|
my ($parameter, $section);
|
||||||
|
my $count;
|
||||||
|
my $func = $args{'function'};
|
||||||
|
my $param;
|
||||||
|
my $param2;
|
||||||
|
my $sec;
|
||||||
|
my $check;
|
||||||
|
my $type;
|
||||||
|
|
||||||
|
$func =~ s/_/\\_/g;
|
||||||
|
|
||||||
|
print "\n\n\\subsection{". $func . "}\n\\label{" . $args{'function'} . "}\n";
|
||||||
|
|
||||||
|
$type = $args{'functiontype'};
|
||||||
|
$type =~ s/_/\\_/g;
|
||||||
|
|
||||||
|
print "{\\it ".$type."}\n";
|
||||||
|
print "{\\bf ".$func."}\n";
|
||||||
|
print "(\n";
|
||||||
|
$count = 0;
|
||||||
|
foreach $parameter (@{$args{'parameterlist'}}) {
|
||||||
|
$param = $args{'parametertypes'}{$parameter};
|
||||||
|
$param2 = $parameter;
|
||||||
|
$param =~ s/_/\\_/g;
|
||||||
|
$param2 =~ s/_/\\_/g;
|
||||||
|
|
||||||
|
print "{\\it ".$param."} {\\bf ".$param2."}\n";
|
||||||
|
if ($count != $#{$args{'parameterlist'}}) {
|
||||||
|
$count++;
|
||||||
|
print ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print ")\n";
|
||||||
|
|
||||||
|
print "\n{\\large{Arguments}}\n";
|
||||||
|
|
||||||
|
print "\\begin{itemize}\n";
|
||||||
|
$check=0;
|
||||||
|
foreach $parameter (@{$args{'parameterlist'}}) {
|
||||||
|
$param = $args{'parametertypes'}{$parameter};
|
||||||
|
$param =~ s/_/\\_/g;
|
||||||
|
$param2 = $parameter;
|
||||||
|
$param2 =~ s/_/\\_/g;
|
||||||
|
|
||||||
|
$check = 1;
|
||||||
|
print "\\item {\\it ".$param."} {\\bf ".$param2."}\n";
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
output_highlight($param{$parameter});
|
||||||
|
}
|
||||||
|
if ($check==0) {
|
||||||
|
print "\\item void\n";
|
||||||
|
}
|
||||||
|
print "\\end{itemize}\n";
|
||||||
|
|
||||||
|
foreach $section (@{$args{'sectionlist'}}) {
|
||||||
|
print "\n\\par{\\large{$section}}\\par\n";
|
||||||
|
print "\\begin{rmfamily}\n";
|
||||||
|
|
||||||
|
$sec = $args{'sections'}{$section};
|
||||||
|
$sec =~ s/_/\\_/g;
|
||||||
|
$sec =~ s/&/\\&/g;
|
||||||
|
output_highlight($sec);
|
||||||
|
print "\\end{rmfamily}\n";
|
||||||
|
}
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# output in sgml DocBook
|
||||||
|
sub output_sgml {
|
||||||
|
my %args = %{$_[0]};
|
||||||
|
my ($parameter, $section);
|
||||||
|
my $count;
|
||||||
|
my $id;
|
||||||
|
|
||||||
|
$id = $args{'module'}."-".$args{'function'};
|
||||||
|
$id =~ s/[^A-Za-z0-9]/-/g;
|
||||||
|
|
||||||
|
print "<refentry>\n";
|
||||||
|
print "<refmeta>\n";
|
||||||
|
print "<refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n";
|
||||||
|
print "</refmeta>\n";
|
||||||
|
print "<refnamediv>\n";
|
||||||
|
print " <refname>".$args{'function'}."</refname>\n";
|
||||||
|
print " <refpurpose>\n";
|
||||||
|
print " ".$args{'purpose'}."\n";
|
||||||
|
print " </refpurpose>\n";
|
||||||
|
print "</refnamediv>\n";
|
||||||
|
|
||||||
|
print "<refsynopsisdiv>\n";
|
||||||
|
print " <title>Synopsis</title>\n";
|
||||||
|
print " <funcsynopsis>\n";
|
||||||
|
print " <funcdef>".$args{'functiontype'}." ";
|
||||||
|
print "<function>".$args{'function'}." ";
|
||||||
|
print "</function></funcdef>\n";
|
||||||
|
|
||||||
|
# print "<refsect1>\n";
|
||||||
|
# print " <title>Synopsis</title>\n";
|
||||||
|
# print " <funcsynopsis>\n";
|
||||||
|
# print " <funcdef>".$args{'functiontype'}." ";
|
||||||
|
# print "<function>".$args{'function'}." ";
|
||||||
|
# print "</function></funcdef>\n";
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
if ($#{$args{'parameterlist'}} >= 0) {
|
||||||
|
foreach $parameter (@{$args{'parameterlist'}}) {
|
||||||
|
print " <paramdef>".$args{'parametertypes'}{$parameter};
|
||||||
|
print " <parameter>$parameter</parameter></paramdef>\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print " <void>\n";
|
||||||
|
}
|
||||||
|
print " </funcsynopsis>\n";
|
||||||
|
print "</refsynopsisdiv>\n";
|
||||||
|
# print "</refsect1>\n";
|
||||||
|
|
||||||
|
# print parameters
|
||||||
|
print "<refsect1>\n <title>Arguments</title>\n";
|
||||||
|
# print "<para>\nArguments\n";
|
||||||
|
if ($#{$args{'parameterlist'}} >= 0) {
|
||||||
|
print " <variablelist>\n";
|
||||||
|
foreach $parameter (@{$args{'parameterlist'}}) {
|
||||||
|
print " <varlistentry>\n <term><parameter>$parameter</parameter></term>\n";
|
||||||
|
print " <listitem>\n <para>\n";
|
||||||
|
$lineprefix=" ";
|
||||||
|
output_highlight($args{'parameters'}{$parameter});
|
||||||
|
print " </para>\n </listitem>\n </varlistentry>\n";
|
||||||
|
}
|
||||||
|
print " </variablelist>\n";
|
||||||
|
} else {
|
||||||
|
print " <para>\n None\n </para>\n";
|
||||||
|
}
|
||||||
|
print "</refsect1>\n";
|
||||||
|
|
||||||
|
# print out each section
|
||||||
|
$lineprefix=" ";
|
||||||
|
foreach $section (@{$args{'sectionlist'}}) {
|
||||||
|
print "<refsect1>\n <title>$section</title>\n <para>\n";
|
||||||
|
# print "<para>\n$section\n";
|
||||||
|
if ($section =~ m/EXAMPLE/i) {
|
||||||
|
print "<example><para>\n";
|
||||||
|
}
|
||||||
|
output_highlight($args{'sections'}{$section});
|
||||||
|
# print "</para>";
|
||||||
|
if ($section =~ m/EXAMPLE/i) {
|
||||||
|
print "</para></example>\n";
|
||||||
|
}
|
||||||
|
print " </para>\n</refsect1>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print "\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# output in man
|
||||||
|
sub output_man {
|
||||||
|
my %args = %{$_[0]};
|
||||||
|
my ($parameter, $section);
|
||||||
|
my $count;
|
||||||
|
|
||||||
|
print ".TH \"$args{'module'}\" \"$args{'function'}\" \"25 May 1998\" \"API Manual\" GNOME\n";
|
||||||
|
|
||||||
|
print ".SH Function\n";
|
||||||
|
|
||||||
|
print ".I \"".$args{'functiontype'}."\"\n";
|
||||||
|
print ".B \"".$args{'function'}."\"\n";
|
||||||
|
print "(\n";
|
||||||
|
$count = 0;
|
||||||
|
foreach $parameter (@{$args{'parameterlist'}}) {
|
||||||
|
print ".I \"".$args{'parametertypes'}{$parameter}."\"\n.B \"".$parameter."\"\n";
|
||||||
|
if ($count != $#{$args{'parameterlist'}}) {
|
||||||
|
$count++;
|
||||||
|
print ",\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print ")\n";
|
||||||
|
|
||||||
|
print ".SH Arguments\n";
|
||||||
|
foreach $parameter (@{$args{'parameterlist'}}) {
|
||||||
|
print ".IP \"".$args{'parametertypes'}{$parameter}." ".$parameter."\" 12\n";
|
||||||
|
output_highlight($args{'parameters'}{$parameter});
|
||||||
|
}
|
||||||
|
foreach $section (@{$args{'sectionlist'}}) {
|
||||||
|
print ".SH \"$section\"\n";
|
||||||
|
output_highlight($args{'sections'}{$section});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# output in text
|
||||||
|
sub output_text {
|
||||||
|
my %args = %{$_[0]};
|
||||||
|
my ($parameter, $section);
|
||||||
|
|
||||||
|
print "Function = ".$args{'function'}."\n";
|
||||||
|
print " return type: ".$args{'functiontype'}."\n\n";
|
||||||
|
foreach $parameter (@{$args{'parameterlist'}}) {
|
||||||
|
print " ".$args{'parametertypes'}{$parameter}." ".$parameter."\n";
|
||||||
|
print " -> ".$args{'parameters'}{$parameter}."\n";
|
||||||
|
}
|
||||||
|
foreach $section (@{$args{'sectionlist'}}) {
|
||||||
|
print " $section:\n";
|
||||||
|
print " -> ";
|
||||||
|
output_highlight($args{'sections'}{$section});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# generic output function - calls the right one based
|
||||||
|
# on current output mode.
|
||||||
|
sub output_function {
|
||||||
|
# output_html(@_);
|
||||||
|
eval "output_".$output_mode."(\@_);";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
# takes a function prototype and spits out all the details
|
||||||
|
# stored in the global arrays/hsahes.
|
||||||
|
sub dump_function {
|
||||||
|
my $prototype = shift @_;
|
||||||
|
|
||||||
|
if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
|
||||||
|
$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
|
||||||
|
$prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
|
||||||
|
$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
|
||||||
|
$prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/) {
|
||||||
|
$return_type = $1;
|
||||||
|
$function_name = $2;
|
||||||
|
$args = $3;
|
||||||
|
|
||||||
|
# print STDERR "ARGS = '$args'\n";
|
||||||
|
|
||||||
|
foreach $arg (split ',', $args) {
|
||||||
|
# strip leading/trailing spaces
|
||||||
|
$arg =~ s/^\s*//;
|
||||||
|
$arg =~ s/\s*$//;
|
||||||
|
# print STDERR "SCAN ARG: '$arg'\n";
|
||||||
|
@args = split('\s', $arg);
|
||||||
|
|
||||||
|
# print STDERR " -> @args\n";
|
||||||
|
$param = pop @args;
|
||||||
|
# print STDERR " -> @args\n";
|
||||||
|
if ($param =~ m/^(\*+)(.*)/) {
|
||||||
|
$param = $2;
|
||||||
|
push @args, $1;
|
||||||
|
}
|
||||||
|
$type = join " ", @args;
|
||||||
|
|
||||||
|
if ($parameters{$param} eq "") {
|
||||||
|
$parameters{$param} = "-- undescribed --";
|
||||||
|
print STDERR "Warning($lineno): Function parameter '$param' not described in '$function_name'\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
push @parameterlist, $param;
|
||||||
|
$parametertypes{$param} = $type;
|
||||||
|
|
||||||
|
# print STDERR "param = '$param', type = '$type'\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print STDERR "Error($lineno): cannot understand prototype: '$prototype'\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($function_only==0 || defined($function_table{$function_name})) {
|
||||||
|
output_function({'function' => $function_name,
|
||||||
|
'module' => $modulename,
|
||||||
|
'functiontype' => $return_type,
|
||||||
|
'parameterlist' => \@parameterlist,
|
||||||
|
'parameters' => \%parameters,
|
||||||
|
'parametertypes' => \%parametertypes,
|
||||||
|
'sectionlist' => \@sectionlist,
|
||||||
|
'sections' => \%sections,
|
||||||
|
'purpose' => $function_purpose
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# main
|
||||||
|
# states
|
||||||
|
# 0 - normal code
|
||||||
|
# 1 - looking for function name
|
||||||
|
# 2 - scanning field start.
|
||||||
|
# 3 - scanning prototype.
|
||||||
|
$state = 0;
|
||||||
|
$section = "";
|
||||||
|
|
||||||
|
$doc_special = "\@\%\$\&";
|
||||||
|
|
||||||
|
$doc_start = "^/\\*\\*\$";
|
||||||
|
$doc_end = "\\*/";
|
||||||
|
$doc_com = "\\s*\\*\\s*";
|
||||||
|
$doc_func = $doc_com."(\\w+):?";
|
||||||
|
$doc_sect = $doc_com."([".$doc_special."]?[\\w ]+):(.*)";
|
||||||
|
$doc_content = $doc_com."(.*)";
|
||||||
|
|
||||||
|
%constants = ();
|
||||||
|
%parameters = ();
|
||||||
|
@parameterlist = ();
|
||||||
|
%sections = ();
|
||||||
|
@sectionlist = ();
|
||||||
|
|
||||||
|
$contents = "";
|
||||||
|
$section_default = "Description"; # default section
|
||||||
|
$section = $section_default;
|
||||||
|
|
||||||
|
$lineno = 0;
|
||||||
|
foreach $file (@ARGV) {
|
||||||
|
if (!open(IN,"<$file")) {
|
||||||
|
print STDERR "Error: Cannot open file $file\n";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
while (<IN>) {
|
||||||
|
$lineno++;
|
||||||
|
|
||||||
|
if ($state == 0) {
|
||||||
|
if (/$doc_start/o) {
|
||||||
|
$state = 1; # next line is always the function name
|
||||||
|
}
|
||||||
|
} elsif ($state == 1) { # this line is the function name (always)
|
||||||
|
if (/$doc_func/o) {
|
||||||
|
$function = $1;
|
||||||
|
$state = 2;
|
||||||
|
if (/-(.*)/) {
|
||||||
|
$function_purpose = $1;
|
||||||
|
} else {
|
||||||
|
$function_purpose = "";
|
||||||
|
}
|
||||||
|
if ($verbose) {
|
||||||
|
print STDERR "Info($lineno): Scanning doc for $function\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print STDERR "WARN($lineno): Cannot understand $_ on line $lineno",
|
||||||
|
" - I thought it was a doc line\n";
|
||||||
|
$state = 0;
|
||||||
|
}
|
||||||
|
} elsif ($state == 2) { # look for head: lines, and include content
|
||||||
|
if (/$doc_sect/o) {
|
||||||
|
$newsection = $1;
|
||||||
|
$newcontents = $2;
|
||||||
|
|
||||||
|
if ($contents ne "") {
|
||||||
|
dump_section($section, $contents);
|
||||||
|
$section = $section_default;
|
||||||
|
}
|
||||||
|
|
||||||
|
$contents = $newcontents;
|
||||||
|
if ($contents ne "") {
|
||||||
|
$contents .= "\n";
|
||||||
|
}
|
||||||
|
$section = $newsection;
|
||||||
|
} elsif (/$doc_end/) {
|
||||||
|
|
||||||
|
if ($contents ne "") {
|
||||||
|
dump_section($section, $contents);
|
||||||
|
$section = $section_default;
|
||||||
|
$contents = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
# print STDERR "end of doc comment, looking for prototype\n";
|
||||||
|
$prototype = "";
|
||||||
|
$state = 3;
|
||||||
|
} elsif (/$doc_content/) {
|
||||||
|
# miguel-style comment kludge, look for blank lines after
|
||||||
|
# @parameter line to signify start of description
|
||||||
|
if ($1 eq "" && $section =~ m/^@/) {
|
||||||
|
dump_section($section, $contents);
|
||||||
|
$section = $section_default;
|
||||||
|
$contents = "";
|
||||||
|
} else {
|
||||||
|
$contents .= $1."\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
# i dont know - bad line? ignore.
|
||||||
|
print STDERR "WARNING($lineno): bad line: $_";
|
||||||
|
}
|
||||||
|
} elsif ($state == 3) { # scanning for function { (end of prototype)
|
||||||
|
if (m#\s*/\*\s+MACDOC\s*#io) {
|
||||||
|
# do nothing
|
||||||
|
}
|
||||||
|
elsif (/([^\{]*)/) {
|
||||||
|
$prototype .= $1;
|
||||||
|
}
|
||||||
|
if (/\{/) {
|
||||||
|
$prototype =~ s@/\*.*?\*/@@gos; # strip comments.
|
||||||
|
$prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
|
||||||
|
$prototype =~ s@^ +@@gos; # strip leading spaces
|
||||||
|
dump_function($prototype);
|
||||||
|
|
||||||
|
$function = "";
|
||||||
|
%constants = ();
|
||||||
|
%parameters = ();
|
||||||
|
%parametertypes = ();
|
||||||
|
@parameterlist = ();
|
||||||
|
%sections = ();
|
||||||
|
@sectionlist = ();
|
||||||
|
$prototype = "";
|
||||||
|
|
||||||
|
$state = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
90
tags/gpgme-0-3-0/gpgme.txt
Normal file
90
tags/gpgme-0-3-0/gpgme.txt
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
%%comments:
|
||||||
|
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.1 or
|
||||||
|
any later version published by the Free Software Foundation; with no
|
||||||
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license is included in the file COPYING.
|
||||||
|
|
||||||
|
%%name: GPGME
|
||||||
|
|
||||||
|
%%short-description: GnuPG Made Easy
|
||||||
|
|
||||||
|
%%full-description: GPGME is a library designed to make access to
|
||||||
|
GnuPG easier for applications. It provides a High-Level Crypto API
|
||||||
|
for encryption, decryption, signing, signature verification and key
|
||||||
|
management. Currently it uses GnuPG and GpgSM as its backends to
|
||||||
|
support OpenPGP and the Cryptographic Message Syntax.
|
||||||
|
|
||||||
|
%%category: security, libraries
|
||||||
|
|
||||||
|
%%license: GPL
|
||||||
|
%%license verified by:
|
||||||
|
%%license verified on:
|
||||||
|
|
||||||
|
%%maintainer: g10 Code GmbH <gpgme@g10code.com>
|
||||||
|
|
||||||
|
%%updated: 2001-12-19
|
||||||
|
|
||||||
|
%%keywords: encryption, public key, digital signature, GnuPG
|
||||||
|
|
||||||
|
%%interface:
|
||||||
|
|
||||||
|
%%programs:
|
||||||
|
|
||||||
|
%%GNU: no
|
||||||
|
|
||||||
|
%%web-page: http://www.gnupg.org/gpgme.html
|
||||||
|
|
||||||
|
%%support: paid extension/consulting from http://www.g10code.com
|
||||||
|
|
||||||
|
%%doc: English programmer reference in Texinfo, Postscript, HTML included
|
||||||
|
|
||||||
|
%%developers: Werner Koch <wk@gnupg.org>.
|
||||||
|
|
||||||
|
%%contributors:
|
||||||
|
|
||||||
|
%%sponsors:
|
||||||
|
|
||||||
|
%%source: ftp://ftp.gnupg.org/gcrypt/alpha/gpgme/
|
||||||
|
|
||||||
|
%%debian:
|
||||||
|
|
||||||
|
%%redhat:
|
||||||
|
|
||||||
|
%%repository: See http://www.gnupg.org/cvs-access.html
|
||||||
|
|
||||||
|
%%related:
|
||||||
|
|
||||||
|
%%source-language: C
|
||||||
|
|
||||||
|
%%supported-languages: C, C++
|
||||||
|
|
||||||
|
%%use-requirements: GnuPG 1.0.6, GpgSM 0.0.0
|
||||||
|
|
||||||
|
%%build-prerequisites:
|
||||||
|
|
||||||
|
%%weak-prerequisites:
|
||||||
|
|
||||||
|
%%source-prerequisites:
|
||||||
|
|
||||||
|
%%version: 0.3.0 released on 2001-12-19
|
||||||
|
|
||||||
|
%%announce-list: announce@gnupg.org announce-request@gnupg.org
|
||||||
|
|
||||||
|
%%announce-news:
|
||||||
|
|
||||||
|
%%help-list:
|
||||||
|
|
||||||
|
%%help-news:
|
||||||
|
|
||||||
|
%%dev-list: gnupg-devel@gnupg.org gnupg-devel-request@gnupg.org
|
||||||
|
|
||||||
|
%%dev-news:
|
||||||
|
|
||||||
|
%%bug-list:
|
||||||
|
|
||||||
|
%%bug-database:
|
||||||
|
|
||||||
|
%%entry written by: Werner Koch <wk@gnupg.org>
|
6
tags/gpgme-0-3-0/gpgme/.cvsignore
Normal file
6
tags/gpgme-0-3-0/gpgme/.cvsignore
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Makefile.in Makefile .deps .libs
|
||||||
|
*.lo *.la
|
||||||
|
errors.c
|
||||||
|
gpgme-config
|
||||||
|
status-table.h
|
||||||
|
|
844
tags/gpgme-0-3-0/gpgme/ChangeLog
Normal file
844
tags/gpgme-0-3-0/gpgme/ChangeLog
Normal file
@ -0,0 +1,844 @@
|
|||||||
|
2001-12-19 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_new): New variable CHILD_FDS.
|
||||||
|
Fill it with the servers fds, and pass it to assuan_pipe_connect.
|
||||||
|
|
||||||
|
2001-12-18 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* keylist.c (gpgme_op_keylist_end): New function.
|
||||||
|
* gpgme.h (gpgme_op_keylist_end): New prototype.
|
||||||
|
|
||||||
|
* engine.h (gpgme_engine_check_version): Move prototype to ...
|
||||||
|
* gpgme.h (gpgme_engine_check_version): ... here.
|
||||||
|
|
||||||
|
* genkey.c (gpgme_op_genkey_start): Remove unused variable.
|
||||||
|
|
||||||
|
2001-12-18 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* version.c (gpgme_get_engine_info): Reimplemented.
|
||||||
|
(gpgme_check_engine): Reimplemented.
|
||||||
|
(_gpgme_compare_versions): Return NULL if MY_VERSION is NULL.
|
||||||
|
|
||||||
|
* engine.c: Include `io.h'.
|
||||||
|
(gpgme_engine_get_info): New function.
|
||||||
|
* engine.h (gpgme_engine_check_version, _gpgme_engine_get_info):
|
||||||
|
Add prototype.
|
||||||
|
|
||||||
|
2001-12-18 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* rungpg.c (struct reap_s, reap_list, reap_list_lock): Moved to ...
|
||||||
|
* engine.c (struct reap_s, reap_list, reap_list_lock): ... here.
|
||||||
|
Include `time.h', `sys/types.h', `assert.h', and `sema.h'.
|
||||||
|
|
||||||
|
* rungpg.c (_gpgme_engine_add_child_to_reap_list): New function.
|
||||||
|
(do_reaping, _gpgme_gpg_housecleaning): Moved to ...
|
||||||
|
* engine.c (do_reaping, _gpgme_engine_housecleaning): ... here.
|
||||||
|
* rungpg.c (_gpgme_gpg_release): Replace code that is now in its
|
||||||
|
own function by call to _gpgme_engine_add_child_to_reap_list().
|
||||||
|
|
||||||
|
* wait.c: Include `engine.h'.
|
||||||
|
(run_idle): Call _gpgme_engine_housecleaning(), not
|
||||||
|
_gpgme_gpg_housecleaning().
|
||||||
|
|
||||||
|
2001-12-18 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* key.c (_gpgme_key_append_name): Append, not prepend, the uid.
|
||||||
|
Initialize the next field of the uid structure.
|
||||||
|
(gpgme_key_get_as_xml): Do not list last uid first.
|
||||||
|
|
||||||
|
2001-12-17 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New
|
||||||
|
function [!ENABLE_GPGSM].
|
||||||
|
|
||||||
|
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_op_verify): Put TEXT into
|
||||||
|
message_data, not SIG.
|
||||||
|
(_gpgme_gpgsm_op_sign): Use `--detached', not `--detach'.
|
||||||
|
|
||||||
|
* sign.c (sign_status_handler): Call
|
||||||
|
_gpgme_passphrase_status_handler early.
|
||||||
|
|
||||||
|
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c: Revert last change.
|
||||||
|
|
||||||
|
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (gpgsm_status_handler): Freeze the output file
|
||||||
|
handler when ending this operation, otherwise the wait function
|
||||||
|
will sit on it.
|
||||||
|
|
||||||
|
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (struct gpgsm_object_s): New member colon.attic.
|
||||||
|
(_gpgme_gpgsm_new): Initialize some more members.
|
||||||
|
(_gpgme_gpgsm_release): Free the colon line handler's attic line.
|
||||||
|
(gpgsm_status_handler): Rework the inline-data processing.
|
||||||
|
|
||||||
|
2001-12-13 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* rungpg.c (_gpgme_gpg_spawn): Do not add the fds to the child
|
||||||
|
list that are not dup'ed, for those the close-on-exec flag is set
|
||||||
|
now.
|
||||||
|
* version.c (_gpgme_get_program_version): Remove first entry in
|
||||||
|
CFD, as the close-on-exec flag is now set for this fd.
|
||||||
|
|
||||||
|
2001-12-13 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_op_encrypt): Do not add `armor'
|
||||||
|
option to `ENCRYPT'.
|
||||||
|
* engine-gpgsm.c (gpgsm_set_recipients): Free LINE when returning
|
||||||
|
successfully.
|
||||||
|
|
||||||
|
2001-12-13 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (close_notify_handler): New function.
|
||||||
|
(_gpgme_gpgsm_new): Manage the file descriptors a
|
||||||
|
bit differently. Do not set close-on-exec flags.
|
||||||
|
(_gpgme_gpgsm_op_decrypt): Do not set message_fd
|
||||||
|
to -1, this is done by the close handler.
|
||||||
|
(_gpgme_gpgsm_op_encrypt): Likewise.
|
||||||
|
(_gpgme_gpgsm_op_import): Likewise (also for output_fd).
|
||||||
|
(_gpgme_gpgsm_op_keylist): Likewise (also for input_fd and output_fd).
|
||||||
|
(_gpgme_gpgsm_op_sign): Likewise.
|
||||||
|
(_gpgme_gpgsm_op_verify): Likewise, but for output_fd.
|
||||||
|
|
||||||
|
* posix-io.c (_gpgme_io_pipe): Set the close-on-exec flag for the
|
||||||
|
non-inherited file descriptor index of the pipe.
|
||||||
|
|
||||||
|
2001-12-13 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New.
|
||||||
|
(gpgsm_status_handler): Pass datalines to a colon handler
|
||||||
|
* engine.c (_gpgme_engine_set_colon_line_handler): Set the colon
|
||||||
|
handler for gpgsm.
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_op_keylist): Allow NULL for
|
||||||
|
pattern.
|
||||||
|
(gpgsm_assuan_simple_command): Removed underscore from
|
||||||
|
assuan_write_line.
|
||||||
|
(_gpgme_gpgsm_start): Ditto.
|
||||||
|
(gpgsm_assuan_simple_command): Replaced interal Assuan read
|
||||||
|
function by the new assuan_read_line. Removed the use of the
|
||||||
|
internal header.
|
||||||
|
(gpgsm_status_handler): Ditto. Use the new assuan_pending_line.
|
||||||
|
(_gpgme_gpgsm_start): Use the documented way to get an fd from
|
||||||
|
assuan.
|
||||||
|
|
||||||
|
* keylist.c (keylist_colon_handler): Handle "crt" records
|
||||||
|
* key.h (gpgme_key_s): Add an x509 flag.
|
||||||
|
* key.c (parse_x509_user_id): New.
|
||||||
|
(_gpgme_key_append_name): Handle x.509 names.
|
||||||
|
|
||||||
|
2001-12-05 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (gpgsm_status_handler): Make it work with current
|
||||||
|
version of assuan.
|
||||||
|
|
||||||
|
2001-12-05 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (gpgsm_set_fd): Accept one more argument OPT.
|
||||||
|
(_gpgme_gpgsm_op_encrypt): Pass armor argument to gpgsm_set_fd for
|
||||||
|
output descriptor.
|
||||||
|
(_gpgme_gpgsm_op_sign): Likewise.
|
||||||
|
|
||||||
|
2001-12-05 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* keylist.c (gpgme_op_keylist_next): Set pending to 0 if EOF
|
||||||
|
occurs.
|
||||||
|
|
||||||
|
2001-11-26 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_op_sign): Fix stupid typo.
|
||||||
|
|
||||||
|
2001-11-24 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (gpgsm_status_handler): Don't break if bsearch fails.
|
||||||
|
Deal with assuan read line returning more than one line (for now).
|
||||||
|
|
||||||
|
2001-11-23 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_op_sign): Implement it according to
|
||||||
|
the current protocol definition.
|
||||||
|
|
||||||
|
2001-11-23 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_new): Set CLOEXEC flag for parent
|
||||||
|
ends of the pipe.
|
||||||
|
|
||||||
|
2001-11-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c: Include stdlib.h and string.h. Also include,
|
||||||
|
for now, rungpg.h and status-table.h.
|
||||||
|
(gpgsm_status_handler): Implement more of the status handler.
|
||||||
|
|
||||||
|
2001-11-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine.c (_gpgme_engine_op_decrypt): Implement CMS case.
|
||||||
|
(_gpgme_engine_op_delete): Likewise.
|
||||||
|
(_gpgme_engine_op_encrypt): Likewise.
|
||||||
|
(_gpgme_engine_op_export): Likewise.
|
||||||
|
(_gpgme_engine_op_genkey): Likewise.
|
||||||
|
(_gpgme_engine_op_keylist): Likewise.
|
||||||
|
(_gpgme_engine_op_sign): Likewise.
|
||||||
|
(_gpgme_engine_op_trustlist): Likewise.
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_op_encrypt): New function.
|
||||||
|
(gpgsm_assuan_simple_command): Likewise.
|
||||||
|
(gpgsm_set_recipients): Likewise.
|
||||||
|
(gpgsm_set_fd): Reimplement using gpgsm_assuan_simple_command.
|
||||||
|
(_gpgme_gpgsm_op_delete): New function.
|
||||||
|
(_gpgme_gpgsm_op_export): Likewise.
|
||||||
|
(_gpgme_gpgsm_op_genkey): Likewise.
|
||||||
|
(_gpgme_gpgsm_op_sign): Likewise.
|
||||||
|
(_gpgme_gpgsm_op_keylist): Likewise.
|
||||||
|
(_gpgme_gpgsm_op_trustlist): Likewise.
|
||||||
|
(_gpgme_gpgsm_release): Release command.
|
||||||
|
(_gpgme_gpgsm_op_decrypt): Allocate command.
|
||||||
|
(_gpgme_gpgsm_op_import): Likewise.
|
||||||
|
(gpgsm_status_handler): Also treat `ERR' strings as EOF.
|
||||||
|
|
||||||
|
2001-11-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* gpgme.h (gpgme_set_protocol): New prototype.
|
||||||
|
|
||||||
|
2001-11-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c (_gpgme_gpgsm_op_decrypt): New function.
|
||||||
|
(_gpgme_gpgsm_op_import): Likewise.
|
||||||
|
|
||||||
|
2001-11-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* engine-gpgsm.c: Shuffle around header inclusion a bit, to still
|
||||||
|
keep them seperate.
|
||||||
|
(_gpgme_set_status_handler) [!ENABLE_GPGSM]: New function.
|
||||||
|
|
||||||
|
2001-11-22 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* engine-gpgsm.c: Include more headers so that NULL and mk_error
|
||||||
|
is defined even with an undefined GPGSM_PATH.
|
||||||
|
|
||||||
|
2001-11-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* rungpg.c (gpg_inbound_handler, write_mem_data, write_cb_data,
|
||||||
|
gpg_outbound_handler): Moved to ...
|
||||||
|
* data.c (_gpgme_data_inbound_handler, write_mem_data,
|
||||||
|
write_cb_data, _gpgme_data_outbound_handler): ... here. Make the
|
||||||
|
_gpgme_* ones non-static.
|
||||||
|
* data.c: Include io.h.
|
||||||
|
|
||||||
|
* ops.h (_gpgme_data_inbound_handler): New prototype.
|
||||||
|
(_gpgme_data_outbound_handler): Likewise.
|
||||||
|
(_gpgme_gpg_spawn): Use these new functions.
|
||||||
|
|
||||||
|
* engine-gpgsm.h (_gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete,
|
||||||
|
_gpgme_gpgsm_op_encrypt, _gpgme_gpgsm_op_export,
|
||||||
|
_gpgme_gpgsm_op_genkey, _gpgme_gpgsm_op_import,
|
||||||
|
_gpgme_gpgsm_op_keylist, _gpgme_gpgsm_op_sign,
|
||||||
|
_gpgme_gpgsm_op_trustlist, _gpgme_gpgsm_op_verify,
|
||||||
|
_gpgme_gpgsm_start, _gpgme_gpgsm_set_status_handler): New prototype.
|
||||||
|
Include <rungpg.h> for status handler function.
|
||||||
|
|
||||||
|
* engine-gpgsm.c (struct gpgsm_object_s): New members input_fd,
|
||||||
|
input_data, output_fd, output_data, message_fd, message_data, command
|
||||||
|
and status.
|
||||||
|
(_gpgme_gpgsm_new): Open input, output and message pipes before
|
||||||
|
connecting to the client. Close server's ends afterwards.
|
||||||
|
(_gpgme_gpgsm_release): Close open file descriptors. Remove
|
||||||
|
server process from wait queue.
|
||||||
|
(_gpgme_gpgsm_op_verify, _gpgme_gpgsm_start,
|
||||||
|
_gpgme_gpgsm_set_status_handler, gpgms_status_handler): New function.
|
||||||
|
|
||||||
|
* engine.c (_gpgme_engine_start): Implement for GPGME_PROTOCOL_CMS.
|
||||||
|
(_gpgme_engine_set_status_handler): Likewise.
|
||||||
|
(_gpgme_engine_op_verify): Likewise.
|
||||||
|
|
||||||
|
2001-11-21 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* context.h: Do not include rungpg.h, but engine.h.
|
||||||
|
(struct gpgme_context_s): Replace member gpg with engine.
|
||||||
|
* gpgme.c (gpgme_release): Release engine, not gpg.
|
||||||
|
|
||||||
|
* recipient.c (_gpgme_append_gpg_args_from_recifgpients): Function
|
||||||
|
moved ...
|
||||||
|
* rungpg.c (_gpgme_append_gpg_args_from_recipients): ... here.
|
||||||
|
Make static, change order of arguments, and return an error value.
|
||||||
|
* ops.h (_gpgme_append_gpg_args_from_recipients): Removed prototype.
|
||||||
|
|
||||||
|
* rungpg.h (_gpgme_gpg_op_verify): Add prototype.
|
||||||
|
(_gpgme_gpg_op_encrypt): Likewise.
|
||||||
|
(_gpgme_gpg_op_decrypt): Likewise.
|
||||||
|
(_gpgme_gpg_op_delete): Likewise.
|
||||||
|
(_gpgme_gpg_op_export): Likewise.
|
||||||
|
(_gpgme_gpg_op_genkey): Likewise.
|
||||||
|
(_gpgme_gpg_op_import): Likewise.
|
||||||
|
(_gpgme_gpg_op_keylist): Likewise.
|
||||||
|
(_gpgme_gpg_op_sign): Likewise.
|
||||||
|
(_gpgme_gpg_op_trustlist): Likewise.
|
||||||
|
* rungpg.c (_gpgme_gpg_op_verify): New function.
|
||||||
|
(_gpgme_gpg_op_encrypt): Likewise.
|
||||||
|
(_gpgme_gpg_op_decrypt): Likewise.
|
||||||
|
(_gpgme_gpg_op_delete): Likewise.
|
||||||
|
(_gpgme_gpg_op_export): Likewise.
|
||||||
|
(_gpgme_gpg_op_genkey): Likewise.
|
||||||
|
(_gpgme_gpg_op_import): Likewise.
|
||||||
|
(_gpgme_gpg_op_keylist): Likewise.
|
||||||
|
(_gpgme_gpg_op_sign): Likewise.
|
||||||
|
(_gpgme_gpg_op_trustlist): Likewise.
|
||||||
|
|
||||||
|
* engine.h (_gpgme_engine_set_status_handler): Add prototype.
|
||||||
|
(_gpgme_engine_set_command_handler): Likewise.
|
||||||
|
(_gpgme_engine_set_colon_line_handler): Likewise.
|
||||||
|
(_gpgme_engine_op_decrypt): Likewise.
|
||||||
|
(_gpgme_engine_op_delete): Likewise.
|
||||||
|
(_gpgme_engine_op_encrypt): Likewise.
|
||||||
|
(_gpgme_engine_op_export): Likewise.
|
||||||
|
(_gpgme_engine_op_genkey): Likewise.
|
||||||
|
(_gpgme_engine_op_import): Likewise.
|
||||||
|
(_gpgme_engine_op_keylist): Likewise.
|
||||||
|
(_gpgme_engine_op_sign): Likewise.
|
||||||
|
(_gpgme_engine_op_trustlist): Likewise.
|
||||||
|
(_gpgme_engine_op_verify): Likewise.
|
||||||
|
(_gpgme_engine_start): Likewise.
|
||||||
|
* engine.c (_gpgme_engine_set_status_handler): New function.
|
||||||
|
(_gpgme_engine_set_command_handler): Likewise.
|
||||||
|
(_gpgme_engine_set_colon_line_handler): Likewise.
|
||||||
|
(_gpgme_engine_op_decrypt): Likewise.
|
||||||
|
(_gpgme_engine_op_delete): Likewise.
|
||||||
|
(_gpgme_engine_op_encrypt): Likewise.
|
||||||
|
(_gpgme_engine_op_export): Likewise.
|
||||||
|
(_gpgme_engine_op_genkey): Likewise.
|
||||||
|
(_gpgme_engine_op_import): Likewise.
|
||||||
|
(_gpgme_engine_op_keylist): Likewise.
|
||||||
|
(_gpgme_engine_op_sign): Likewise.
|
||||||
|
(_gpgme_engine_op_trustlist): Likewise.
|
||||||
|
(_gpgme_engine_op_verify): Likewise.
|
||||||
|
(_gpgme_engine_start): Likewise.
|
||||||
|
|
||||||
|
* verify.c (gpgme_op_verify_start): Reimplement in terms of above
|
||||||
|
functions.
|
||||||
|
* encrypt.c (gpgme_op_encrypt_start): Likewise.
|
||||||
|
* decrypt.c (_gpgme_decrypt_start): Likewise.
|
||||||
|
* passphrase.c (_gpgme_passphrase_start): Likewise.
|
||||||
|
* keylist.c (gpgme_op_keylist_start): Likewise.
|
||||||
|
|
||||||
|
2001-11-20 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* types.h: Add types EngineObject and GpgsmObject.
|
||||||
|
|
||||||
|
* Makefile.am (libgpgme_la_SOURCES): Add engine-gpgsm.h,
|
||||||
|
engine-gpgsm.c, engine.h and engine.c.
|
||||||
|
* engine.h: New file.
|
||||||
|
* engine.c: Likewise.
|
||||||
|
* engine-gpgsm.h: Likewise.
|
||||||
|
* engine-gpgsm.c: Likewise.
|
||||||
|
|
||||||
|
* rungpg.c (_gpgme_gpg_get_version): New function.
|
||||||
|
(_gpgme_gpg_check_version): Likewise.
|
||||||
|
* rungpg.h: Add prototypes for _gpgme_gpg_get_version and
|
||||||
|
_gpgme_gpg_check_version.
|
||||||
|
|
||||||
|
* version.c (compare_versions): Rename to ...
|
||||||
|
(_gpgme_compare_versions): ... this. Make non-static.
|
||||||
|
(gpgme_check_version): Use _gpgme_compare_versions rather than
|
||||||
|
compare_versions.
|
||||||
|
(gpgme_check_engine): Likewise.
|
||||||
|
* ops.h (_gpgme_get_program_version): Add prototype.
|
||||||
|
|
||||||
|
2001-11-20 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* Makefile.am (libgpgme_la_INCLUDES): Remove obsolete directive.
|
||||||
|
(AM_CPPFLAGS): New directive [BUILD_ASSUAN].
|
||||||
|
(libgpgme_la_LIBADD): Likewise.
|
||||||
|
|
||||||
|
2001-11-20 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* version.c: Remove global variables lineno and
|
||||||
|
tmp_engine_version.
|
||||||
|
(version_handler): Removed.
|
||||||
|
(_gpgme_get_program_version): New function.
|
||||||
|
(get_engine_info): Don't use context and version_handler,
|
||||||
|
but _gpgme_get_program_version.
|
||||||
|
* ops.h (_gpgme_get_program_version): Add prototype for
|
||||||
|
_gpgme_get_program_version (we expect to use it elsewhere soon).
|
||||||
|
|
||||||
|
2001-11-18 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* version.c (get_engine_info): If GnuPG is not available, return
|
||||||
|
an error message.
|
||||||
|
* posix-util.c (_gpgme_get_gpg_path): Allow GPG_PATH to be
|
||||||
|
undefined.
|
||||||
|
(_gpgme_get_gpgsm_path): New function.
|
||||||
|
* w32-util.c (find_program_in_registry): New static function.
|
||||||
|
(_gpgme_get_gpg_path): Allow GPG_PATH to be undefined. Rework
|
||||||
|
to use find_program_in_registry.
|
||||||
|
(_gpgme_get_gpgsm_path): New function.
|
||||||
|
(util.h): Prototype _gpgme_get_gpgsm_path).
|
||||||
|
* rungpg.c (_gpgme_gpg_spawn): Verify that _gpgme_get_gpg_path()
|
||||||
|
returns non-null.
|
||||||
|
|
||||||
|
2001-11-16 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* decrypt-verify.c: New file.
|
||||||
|
* Makefile.am (libgpgme_la_SOURCES): Add decrypt-verify.c.
|
||||||
|
* types.h: Add decrypt-verify types.
|
||||||
|
* ops.h: Likewise.
|
||||||
|
* context.h: Add result type for decrypt-verify.
|
||||||
|
* gpgme.h: Add decrypt-verify prototypes.
|
||||||
|
|
||||||
|
* decrypt.c (decrypt_status_handler): Renamed to ...
|
||||||
|
(_gpgme_decrypt_status_handler): ... this. Make non-static.
|
||||||
|
(_gpgme_decrypt_start): New function, derived from
|
||||||
|
gpgme_op_decrypt_start.
|
||||||
|
(gpgme_op_decrypt_start): Reimplement in terms of
|
||||||
|
_gpgme_decrypt_start.
|
||||||
|
(_gpgme_decrypt_result): New function to retrieve error value.
|
||||||
|
(gpgme_op_decrypt): Use _gpgme_decrypt_result.
|
||||||
|
* ops.h: Add prototypes for new functions.
|
||||||
|
|
||||||
|
* verify.c (verify_status_handler): Renamed to ...
|
||||||
|
(_gpgme_verify_status_handler): ... this. Make non-static.
|
||||||
|
(gpgme_op_verify_start): Use new function name.
|
||||||
|
(intersect_stati): Renamed to ...
|
||||||
|
(_gpgme_intersect_stati): ... this. Make non-static.
|
||||||
|
(gpgme_op_verify): Use new name.
|
||||||
|
* ops.h: Add prototypes for new functions.
|
||||||
|
|
||||||
|
2001-11-16 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* passphrase.c: New file.
|
||||||
|
* Makefile.am (libgpgme_la_SOURCES): Add passphrase.c.
|
||||||
|
* ops.h (_gpgme_passphrase_result): Add prototypes from
|
||||||
|
passphrase.c.
|
||||||
|
* types.h: Likewise.
|
||||||
|
* context.h: Add member passphrase to result.
|
||||||
|
* gpgme.c (_gpgme_release_result): Release passphrase member.
|
||||||
|
|
||||||
|
* decrypt.c: Some formatting and variable name changes (like
|
||||||
|
CTX instead C).
|
||||||
|
(struct decrypt_result_s): Remove members now found in
|
||||||
|
passphrase result.
|
||||||
|
(_gpgme_release_decrypt_result): Don't release removed members.
|
||||||
|
(decrypt_status_handler): Call _gpgme_passphrase_status_handler,
|
||||||
|
and don't handle the cases catched there.
|
||||||
|
(command_handler): Removed.
|
||||||
|
(gpgme_op_decrypt_start): Don't set command handler, but invoke
|
||||||
|
_gpgme_passphrase_start which does it.
|
||||||
|
(gpgme_op_decrypt): Invoke _gpgme_passphrase_result and drop the
|
||||||
|
cases covered by it.
|
||||||
|
|
||||||
|
* sign.c Some formatting and variable name changes (like
|
||||||
|
CTX instead C).
|
||||||
|
(struct sign_result_s): Remove members now found in
|
||||||
|
passphrase result.
|
||||||
|
(_gpgme_release_sign_result): Don't release removed members.
|
||||||
|
(sign_status_handler): Call _gpgme_passphrase_status_handler,
|
||||||
|
and don't handle the cases catched there.
|
||||||
|
(command_handler): Removed.
|
||||||
|
(gpgme_op_sign_start): Don't set command handler, but invoke
|
||||||
|
_gpgme_passphrase_start which does it.
|
||||||
|
(gpgme_op_sign): Invoke _gpgme_passphrase_result and drop the
|
||||||
|
cases covered by it.
|
||||||
|
|
||||||
|
2001-11-15 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* decrypt.c (command_handler): Fix last change.
|
||||||
|
|
||||||
|
2001-11-15 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* verify.c (_gpgme_release_verify_result): Rename RES to RESULT.
|
||||||
|
Rename R2 to NEXT_RESULT.
|
||||||
|
(intersect_stati): Rename RES to RESULT.
|
||||||
|
(gpgme_get_sig_status): Likewise. Do not check return_type, but
|
||||||
|
the member verify of result.
|
||||||
|
(gpgme_get_sig_key): Likewise.
|
||||||
|
|
||||||
|
* sign.c (_gpgme_release_sign_result): Rename RES to RESULT. If
|
||||||
|
RESULT is zero, return.
|
||||||
|
(sign_status_handler, command_handler): Do not check return_type,
|
||||||
|
but the member sign of result.
|
||||||
|
(gpgme_op_sign): Likewise. Drop assertion.
|
||||||
|
|
||||||
|
* encrypt.c (_gpgme_release_encrypt_result): Rename RES to RESULT.
|
||||||
|
If RESULT is zero, return.
|
||||||
|
(encrypt_status_handler): Do not check return_type, but the member
|
||||||
|
encrypt of result.
|
||||||
|
(gpgme_op_encrypt): Likewise. Drop assertion.
|
||||||
|
|
||||||
|
* decrypt.c (_gpgme_release_decrypt_result): Rename RES to RESULT.
|
||||||
|
(create_result_struct): Do not set result_type.
|
||||||
|
(command_handler, decrypt_status_handler): Do not check
|
||||||
|
return_type, but the member decrypt of result.
|
||||||
|
(gpgme_op_decrypt): Likewise. Drop assertion.
|
||||||
|
|
||||||
|
* context.h (enum ResultType): Removed.
|
||||||
|
(struct gpgme_context_s): Remove member result_type.
|
||||||
|
(struct result): Replaces union result.
|
||||||
|
* gpgme.c: Include string.h.
|
||||||
|
(_gpgme_release_result): Release all members of c->result, which
|
||||||
|
is now a struct. Zero out all members of the struct afterwards.
|
||||||
|
|
||||||
|
2001-11-11 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* rungpg.c (_gpgme_gpg_release): Release GPG->cmd.cb_data.
|
||||||
|
Release all members of the list GPG->arglist.
|
||||||
|
Reported by Michael Schmidt <mschmidt@cs.uni-sb.de>.
|
||||||
|
|
||||||
|
2001-11-02 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* rungpg.c (pipemode_copy): Change type of NBYTES to size_t.
|
||||||
|
|
||||||
|
* key.c: Include string.h.
|
||||||
|
* data.c: Likewise.
|
||||||
|
* recipient.c: Likewise.
|
||||||
|
|
||||||
|
2001-10-29 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* context.h: New member signers_len.
|
||||||
|
* signers.c (gpgme_signers_clear): Require that signers are
|
||||||
|
non-NULL with assertion. Use signers_len to determine how much
|
||||||
|
keys to release. Add documentation.
|
||||||
|
(gpgme_signers_add): Use signers_len to determine if the buffer is
|
||||||
|
large enough. Use xtryrealloc rather than xtrymalloc and copying.
|
||||||
|
Add documentation.
|
||||||
|
(gpgme_signers_enum): Use signers_len to determine if key is
|
||||||
|
available. Add documentation.
|
||||||
|
|
||||||
|
2001-10-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* data.c (_gpgme_data_append): Check if LENGTH is smaller than
|
||||||
|
ALLOC_CHUNK, not DH->length.
|
||||||
|
|
||||||
|
2001-10-17 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* gpgme.c (gpgme_set_protocol): Fix last change.
|
||||||
|
|
||||||
|
2001-10-15 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* gpgme.h (GpgmeProtocol): New.
|
||||||
|
* gpgme.c (gpgme_set_protocol): New.
|
||||||
|
|
||||||
|
2001-09-26 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* gpgme.c (gpgme_set_passphrase_cb): Ignore a NULL context.
|
||||||
|
(gpgme_set_progress_cb): Ditto. Suggested by Mark Mutz.
|
||||||
|
|
||||||
|
2001-09-17 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* keylist.c (finish_key): Shortcut for no tmp_key. Changed all
|
||||||
|
callers to use this function without a check for tmp_key.
|
||||||
|
|
||||||
|
* keylist.c (gpgme_op_keylist_next): Reset the key_cond after
|
||||||
|
emptying the queue. Bug reported by Stéphane Corthésy.
|
||||||
|
|
||||||
|
2001-09-12 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* data.c (gpgme_data_rewind): Allow rewind for callbacks.
|
||||||
|
|
||||||
|
2001-09-07 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* rungpg.h: Add NO_RECP.
|
||||||
|
* encrypt.c (encrypt_status_handler): Take on No_RECP.
|
||||||
|
(gpgme_op_encrypt): Better error return.
|
||||||
|
|
||||||
|
* verify.c (verify_status_handler): Take on NODATA.
|
||||||
|
|
||||||
|
2001-09-03 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* rungpg.h: Added STATUS_INV_RECP.
|
||||||
|
* gpgme.c (_gpgme_release_result): Add support for new
|
||||||
|
EncryptResult object.
|
||||||
|
* encrypt.c (append_xml_encinfo): New.
|
||||||
|
(encrypt_status_handler): Add some status parsing.
|
||||||
|
(_gpgme_release_encrypt_result): New.
|
||||||
|
|
||||||
|
2001-08-29 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* recipient.c (gpgme_recipients_release): Free the list. By Timo.
|
||||||
|
|
||||||
|
* keylist.c (keylist_colon_handler): Do a finish key if we receive
|
||||||
|
an EOF here. This is probably the reason for a lot of bugs
|
||||||
|
related to keylisting. It is so obvious. Kudos to Enno Cramer
|
||||||
|
for pointing that out.
|
||||||
|
|
||||||
|
2001-08-28 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* gpgme.c, gpgme.h (gpgme_get_op_info): New.
|
||||||
|
(_gpgme_set_op_info): New.
|
||||||
|
(_gpgme_release_result): Reset the op_info here.
|
||||||
|
* sign.c (append_xml_siginfo): New.
|
||||||
|
(sign_status_handler): Store the sig create information.
|
||||||
|
|
||||||
|
2001-07-31 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* encrypt.c (gpgme_op_encrypt): Hack to detect no valid recipients.
|
||||||
|
|
||||||
|
2001-07-30 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* gpgme.c (gpgme_get_armor,gpgme_get_textmode): New.
|
||||||
|
|
||||||
|
* rungpg.c (build_argv): Disable armor comments
|
||||||
|
* w32-io.c (build_commandline): Need to add quotes here
|
||||||
|
|
||||||
|
2001-07-24 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* data.c (gpgme_data_read): Add a a way to return the available bytes.
|
||||||
|
|
||||||
|
2001-07-23 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* util.c: Removed stpcpy() because we use the version from jnlib.
|
||||||
|
|
||||||
|
2001-07-19 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* mkstatus: Define the collating sequence for sort.
|
||||||
|
|
||||||
|
2001-06-26 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* rungpg.h: Add STATUS_UNEXPECTED as suggested by Timo.
|
||||||
|
|
||||||
|
2001-06-15 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* keylist.c (set_userid_flags): Fixed the assigned values. Kudos
|
||||||
|
to Timo for pointing this out.
|
||||||
|
|
||||||
|
2001-06-01 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* debug.c (_gpgme_debug_begin): Fixed a /tmp race. Noted by
|
||||||
|
Johannes Poehlmann.
|
||||||
|
|
||||||
|
2001-05-28 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* version.c (gpgme_check_engine): Stop version number parsing at
|
||||||
|
the opening angle and not the closing one. By Tommy Reynolds.
|
||||||
|
|
||||||
|
2001-05-01 José Carlos García Sogo <jose@jaimedelamo.eu.org>
|
||||||
|
|
||||||
|
* encrypt.c (gpgme_op_encrypt_start): Deleted the assert ( !c->gpg )
|
||||||
|
line, because it gave an error if another operation had been made
|
||||||
|
before using the same context.
|
||||||
|
|
||||||
|
* decrypt.c (gpgme_op_decrypt_start): The same as above. Also added
|
||||||
|
one line to release the gpg object in the context (if any).
|
||||||
|
|
||||||
|
2001-04-26 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* key.c, key.h (_gpgme_key_cache_init): New.
|
||||||
|
(_gpgme_key_cache_add): New.
|
||||||
|
(_gpgme_key_cache_get): New.
|
||||||
|
* version.c (do_subsystem_inits): Init the cache.
|
||||||
|
* keylist.c (finish_key): Put key into the cache
|
||||||
|
* verify.c (gpgme_get_sig_key): First look into the cache.
|
||||||
|
|
||||||
|
2001-04-19 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* keylist.c (parse_timestamp): Adjusted for the changed
|
||||||
|
--fixed-list-mode of gpg 1.0.4h.
|
||||||
|
|
||||||
|
2001-04-05 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* verify.c (gpgme_op_verify_start): Enabled pipemode for detached sigs.
|
||||||
|
|
||||||
|
2001-04-04 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* w32-io.c (_gpgme_io_select): Don't select on the writer if there
|
||||||
|
are still bytes pending. Timo found this not easy to track down
|
||||||
|
race condition.
|
||||||
|
|
||||||
|
2001-04-02 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* gpgme.h: Add GPGME_ATTR_KEY_{EXPIRED,DISABLED}.
|
||||||
|
* key.c (gpgme_key_get_ulong_attr): And return those attribs.
|
||||||
|
|
||||||
|
* verify.c (gpgme_get_sig_key): Set keyliosting mode depending on
|
||||||
|
the mode set in the current context. Suggested by Timo.
|
||||||
|
|
||||||
|
* key.c (gpgme_key_get_ulong_attr): Return can_certify and not
|
||||||
|
can_encrypt. By Timo.
|
||||||
|
|
||||||
|
2001-03-30 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* debug.c (debug_init): Allow to specify a debug file.
|
||||||
|
(_gpgme_debug_level): New.
|
||||||
|
|
||||||
|
* posix-io.c (_gpgme_io_read, _gpgme_io_write): Print output.
|
||||||
|
(_gpgme_io_select): Debug only with level > 2.
|
||||||
|
|
||||||
|
2001-03-15 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* rungpg.c: Included time.h.
|
||||||
|
|
||||||
|
* key.h: New keyflags for capabilities.
|
||||||
|
* keylist.c (set_mainkey_capability, set_subkey_capability): New.
|
||||||
|
(keylist_colon_handler): Parse them.
|
||||||
|
* gpgme.h: New attribute values for capabilties.
|
||||||
|
* key.c (gpgme_key_get_string_attr): Return them.
|
||||||
|
(capabilities_to_string): New.
|
||||||
|
(gpgme_key_get_ulong_attr): Return the global caps.
|
||||||
|
|
||||||
|
2001-03-14 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* w32-io.c (destroy_reader,destroy_writer): Fixed syntax error.
|
||||||
|
Thanks to Jan Oliver Wagner.
|
||||||
|
|
||||||
|
2001-03-13 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* context.h: Add invalid and revoke flags to user_id structure.
|
||||||
|
* keylist.c (gpgme_op_keylist_start): Use --fixed-list-mode.
|
||||||
|
(keylist_colon_handler): Adjust for that.
|
||||||
|
(set_userid_flags): New.
|
||||||
|
(set_mainkey_trust_info): Handle new key invalid flag
|
||||||
|
(set_subkey_trust_info): Ditto.
|
||||||
|
* gpgme.h: Add new attributes for key and user ID flags.
|
||||||
|
* key.c (_gpgme_key_append_name): Init these flags
|
||||||
|
(gpgme_key_get_as_xml): Print them.
|
||||||
|
(one_uid_as_xml): New helper for above.
|
||||||
|
(gpgme_key_get_string_attr, gpgme_key_get_ulong_attr):
|
||||||
|
Return the new attributes. Enhanced, so that subkey information
|
||||||
|
can be returned now.
|
||||||
|
|
||||||
|
2001-02-28 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* w32-io.c (destroy_reader): Set stop_me flag.
|
||||||
|
(writer,create_writer,destroy_writer,find_writer,kill_writer): New.
|
||||||
|
(_gpgme_io_write): Use a writer thread to avaoid blocking.
|
||||||
|
(_gpgme_io_close): Cleanup a writer thread
|
||||||
|
(_gpgme_io_select): Repalce tthe faked wait on writing by a real
|
||||||
|
waiting which is now possible due to the use of a writer thread.
|
||||||
|
|
||||||
|
2001-02-20 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* w32-io.c (destroy_reader,kill_reader): New.
|
||||||
|
(create_reader, reader): Add a new event to stop the thread.
|
||||||
|
(_gpgme_io_close): Kill the reader thread.
|
||||||
|
|
||||||
|
* posix-io.c (_gpgme_io_select): Handle frozen fds here.
|
||||||
|
* 32-io.c (_gpgme_io_select): Ditto. Removed a bunch of unused code.
|
||||||
|
|
||||||
|
* wait.c: Reworked the whole thing.
|
||||||
|
* rungpg.c (_gpgme_gpg_new): Init pid to -1.
|
||||||
|
(_gpgme_gpg_release): Remove the process from the wait queue.
|
||||||
|
|
||||||
|
2001-02-19 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* w32-io.c (_gpgme_io_set_close_notify): New.
|
||||||
|
(_gpgme_io_close): Do the notification.
|
||||||
|
|
||||||
|
* posix-io.c (_gpgme_io_select): Use a 1 sec timeout and not 200
|
||||||
|
microseconds.
|
||||||
|
|
||||||
|
* wait.c (remove_process): Don't close the fd here.
|
||||||
|
(do_select): Set the fd to -1 and remove the is_closed flag everywhere.
|
||||||
|
(_gpgme_wait_on_condition): Remove the assert on the queue and
|
||||||
|
break out if we could not find the queue. The whole thing should
|
||||||
|
be reworked.
|
||||||
|
|
||||||
|
* posix-io.c (_gpgme_io_set_close_notify): New.
|
||||||
|
(_gpgme_io_close): Do the notification.
|
||||||
|
|
||||||
|
* rungpg.c (close_notify_handler): New.
|
||||||
|
(_gpgme_gpg_new): Register a callback for the fd.
|
||||||
|
(_gpgme_gpg_set_colon_line_handler): Ditto.
|
||||||
|
(build_argv): Ditto
|
||||||
|
|
||||||
|
2001-02-13 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* rungpg.c (struct reap_s): Replaced pid_t by int.
|
||||||
|
|
||||||
|
* types.h: Add ulong typedef.
|
||||||
|
|
||||||
|
* rungpg.c (do_reaping,_gpgme_gpg_housecleaning): New.
|
||||||
|
(_gpgme_gpg_release): Reap children.
|
||||||
|
* io.h, posix-io.c (_gpgme_io_kill): New.
|
||||||
|
* w32-io.c (_gpgme_io_kill): New (dummy).
|
||||||
|
|
||||||
|
* keylist.c (gpgme_op_keylist_start): Cancel a pending request.
|
||||||
|
|
||||||
|
* posix-io.c (_gpgme_io_read): Add some debug output.
|
||||||
|
(_gpgme_io_write): Ditto.
|
||||||
|
(_gpgme_io_select): Increased the timeout.
|
||||||
|
|
||||||
|
2001-02-12 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
Enhanced the signature verification, so that it can how handle
|
||||||
|
more than one signature and is able to return more information on
|
||||||
|
the signatures.
|
||||||
|
* verify.c (gpgme_get_sig_key): New.
|
||||||
|
(gpgme_get_sig_status): New.
|
||||||
|
|
||||||
|
* gpgme.h: Add stdio.h.
|
||||||
|
(GpgmeSigStat): New status DIFF.
|
||||||
|
|
||||||
|
2001-02-01 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* w32-io.c (set_synchronize): Add EVENT_MODIFY_STATE. Add Debug
|
||||||
|
code to all Set/ResetEvent().
|
||||||
|
|
||||||
|
* rungpg.c (read_status): Check for end of stream only if we have
|
||||||
|
an r. By Timo.
|
||||||
|
|
||||||
|
2001-01-31 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* wait.c (_gpgme_wait_on_condition): Removed all exit code processing.
|
||||||
|
(propagate_term_results,clear_active_fds): Removed.
|
||||||
|
(count_active_fds): Renamed to ..
|
||||||
|
(count_active_and_thawed_fds): .. this and count only thawed fds.
|
||||||
|
|
||||||
|
* rungpg.c (gpg_colon_line_handler): Return colon.eof and not
|
||||||
|
status.eof ;-)
|
||||||
|
|
||||||
|
2001-01-30 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* w32-io.c (_gpgme_io_spawn): Use the supplied path arg.
|
||||||
|
|
||||||
|
* version.c (get_engine_info): Return better error information.
|
||||||
|
|
||||||
|
* posix-util.c, w32-util.c: New.
|
||||||
|
(_gpgme_get_gpg_path): New, suggested by Jan-Oliver.
|
||||||
|
* rungpg.c (_gpgme_gpg_spawn): Use new function to get GPG's path.
|
||||||
|
|
||||||
|
* signers.c (gpgme_signers_add): Ooops, one should test code and
|
||||||
|
not just write it; the newarr was not assigned. Thanks to José
|
||||||
|
for pointing this out. Hmmm, still not tested, why shoudl a coder
|
||||||
|
test his fix :-)
|
||||||
|
|
||||||
|
* w32-io.c: Does now use reader threads, so that we can use
|
||||||
|
WaitForMultipleObjects.
|
||||||
|
* sema.h, posix-sema.c, w32-sema.c: Support for Critcial sections.
|
||||||
|
Does currently only work for W32.
|
||||||
|
|
||||||
|
* debug.c, util.h : New. Changed all fprintfs to use this new
|
||||||
|
set of debugging functions.
|
||||||
|
|
||||||
|
2001-01-23 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* data.c (_gpgme_data_release_and_return_string): Fixed string
|
||||||
|
termination.
|
||||||
|
|
||||||
|
2001-01-22 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* delete.c: New.
|
||||||
|
|
||||||
|
* signers.c: New.
|
||||||
|
* key.c (gpgme_key_ref, gpgme_key_unref): New.
|
||||||
|
* sign.c (gpgme_op_sign_start): Allow the use of other keys.
|
||||||
|
|
||||||
|
* version.c (gpgme_get_engine_info,gpgme_check_engine): New.
|
||||||
|
* rungpg.c (_gpgme_gpg_set_simple_line_handler): New.
|
||||||
|
|
||||||
|
2001-01-05 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* data.c (gpgme_data_rewind): Allow to rewind data_type_none.
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
67
tags/gpgme-0-3-0/gpgme/Makefile.am
Normal file
67
tags/gpgme-0-3-0/gpgme/Makefile.am
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
# 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
|
||||||
|
|
||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
EXTRA_DIST = gpgme-config.in gpgme.m4 mkerrors mkstatus
|
||||||
|
BUILT_SOURCES = errors.c status-table.h
|
||||||
|
bin_SCRIPTS = gpgme-config
|
||||||
|
m4datadir = $(datadir)/aclocal
|
||||||
|
m4data_DATA = gpgme.m4
|
||||||
|
include_HEADERS = gpgme.h
|
||||||
|
lib_LTLIBRARIES = libgpgme.la
|
||||||
|
|
||||||
|
libgpgme_la_LDFLAGS = -version-info \
|
||||||
|
@LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@
|
||||||
|
if BUILD_ASSUAN
|
||||||
|
AM_CPPFLAGS = -I$(top_srcdir)/assuan
|
||||||
|
libgpgme_la_LIBADD = -L../assuan -lassuan
|
||||||
|
endif
|
||||||
|
|
||||||
|
libgpgme_la_SOURCES = \
|
||||||
|
gpgme.h types.h \
|
||||||
|
util.h util.c posix-util.c w32-util.c \
|
||||||
|
context.h ops.h \
|
||||||
|
data.c recipient.c signers.c \
|
||||||
|
wait.c wait.h \
|
||||||
|
encrypt.c \
|
||||||
|
decrypt.c \
|
||||||
|
decrypt-verify.c \
|
||||||
|
verify.c \
|
||||||
|
sign.c \
|
||||||
|
passphrase.c \
|
||||||
|
key.c key.h \
|
||||||
|
keylist.c \
|
||||||
|
trustlist.c \
|
||||||
|
import.c \
|
||||||
|
export.c \
|
||||||
|
genkey.c \
|
||||||
|
delete.c \
|
||||||
|
rungpg.c rungpg.h status-table.h \
|
||||||
|
engine-gpgsm.c engine-gpgsm.h \
|
||||||
|
engine.c engine.h \
|
||||||
|
sema.h posix-sema.c w32-sema.c \
|
||||||
|
syshdr.h io.h posix-io.c w32-io.c \
|
||||||
|
gpgme.c debug.c version.c errors.c
|
||||||
|
|
||||||
|
errors.c : gpgme.h
|
||||||
|
$(srcdir)/mkerrors < $(srcdir)/gpgme.h > errors.c
|
||||||
|
|
||||||
|
status-table.h : rungpg.h
|
||||||
|
$(srcdir)/mkstatus < $(srcdir)/rungpg.h > status-table.h
|
142
tags/gpgme-0-3-0/gpgme/context.h
Normal file
142
tags/gpgme-0-3-0/gpgme/context.h
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
/* context.h
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 CONTEXT_H
|
||||||
|
#define CONTEXT_H
|
||||||
|
|
||||||
|
#include "gpgme.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "engine.h"
|
||||||
|
|
||||||
|
struct key_queue_item_s {
|
||||||
|
struct key_queue_item_s *next;
|
||||||
|
GpgmeKey key;
|
||||||
|
};
|
||||||
|
struct trust_queue_item_s {
|
||||||
|
struct trust_queue_item_s *next;
|
||||||
|
GpgmeTrustItem item;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Currently we need it at several places, so we put the definition
|
||||||
|
* into this header file */
|
||||||
|
struct gpgme_context_s {
|
||||||
|
int initialized;
|
||||||
|
int pending; /* a gpg request is still pending */
|
||||||
|
|
||||||
|
int use_cms;
|
||||||
|
|
||||||
|
/* at some points we need to allocate memory but we are not
|
||||||
|
* able to handle a malloc problem at that point, so we set this
|
||||||
|
* flag to indicate this condition */
|
||||||
|
int out_of_core;
|
||||||
|
int cancel; /* cancel operation request */
|
||||||
|
|
||||||
|
|
||||||
|
EngineObject engine; /* The running engine process. */
|
||||||
|
|
||||||
|
int verbosity; /* level of verbosity to use */
|
||||||
|
int use_armor;
|
||||||
|
int use_textmode;
|
||||||
|
int keylist_mode;
|
||||||
|
|
||||||
|
int signers_len; /* The number of keys in signers. */
|
||||||
|
int signers_size; /* size of the following array */
|
||||||
|
GpgmeKey *signers;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
VerifyResult verify;
|
||||||
|
DecryptResult decrypt;
|
||||||
|
SignResult sign;
|
||||||
|
EncryptResult encrypt;
|
||||||
|
PassphraseResult passphrase;
|
||||||
|
} result;
|
||||||
|
|
||||||
|
GpgmeData notation; /* last signature notation */
|
||||||
|
GpgmeData op_info; /* last operation info */
|
||||||
|
|
||||||
|
GpgmeKey tmp_key; /* used by keylist.c */
|
||||||
|
volatile int key_cond; /* something new is available */
|
||||||
|
struct key_queue_item_s *key_queue;
|
||||||
|
struct trust_queue_item_s *trust_queue;
|
||||||
|
|
||||||
|
GpgmePassphraseCb passphrase_cb;
|
||||||
|
void *passphrase_cb_value;
|
||||||
|
|
||||||
|
GpgmeProgressCb progress_cb;
|
||||||
|
void *progress_cb_value;
|
||||||
|
|
||||||
|
GpgmeData help_data_1;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct gpgme_data_s {
|
||||||
|
size_t len;
|
||||||
|
const char *data;
|
||||||
|
GpgmeDataType type;
|
||||||
|
GpgmeDataMode mode;
|
||||||
|
|
||||||
|
int (*read_cb)( void *, char *, size_t, size_t *);
|
||||||
|
void *read_cb_value;
|
||||||
|
int read_cb_eof;
|
||||||
|
|
||||||
|
size_t readpos;
|
||||||
|
size_t writepos;
|
||||||
|
size_t private_len;
|
||||||
|
char *private_buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct user_id_s {
|
||||||
|
struct user_id_s *next;
|
||||||
|
unsigned int revoked:1;
|
||||||
|
unsigned int invalid:1;
|
||||||
|
GpgmeValidity validity;
|
||||||
|
const char *name_part; /* all 3 point into strings behind name */
|
||||||
|
const char *email_part; /* or to read-only strings */
|
||||||
|
const char *comment_part;
|
||||||
|
char name[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct gpgme_recipients_s {
|
||||||
|
struct user_id_s *list;
|
||||||
|
int checked; /* wether the recipients are all valid */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define fail_on_pending_request(c) \
|
||||||
|
do { \
|
||||||
|
if (!(c)) return GPGME_Invalid_Value; \
|
||||||
|
if ((c)->pending) return GPGME_Busy; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define wait_on_request_or_fail(c) \
|
||||||
|
do { \
|
||||||
|
if (!(c)) return GPGME_Invalid_Value;\
|
||||||
|
if (!(c)->pending) return GPGME_No_Request; \
|
||||||
|
gpgme_wait ((c), 1); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CONTEXT_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
920
tags/gpgme-0-3-0/gpgme/data.c
Normal file
920
tags/gpgme-0-3-0/gpgme/data.c
Normal file
@ -0,0 +1,920 @@
|
|||||||
|
/* data.c
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "syshdr.h"
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
#include "io.h"
|
||||||
|
|
||||||
|
#define ALLOC_CHUNK 1024
|
||||||
|
#define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
|
||||||
|
#define my_isxdigit(a) ( my_isdigit((a)) \
|
||||||
|
|| ((a) >= 'A' && (a) <= 'F') \
|
||||||
|
|| ((a) >= 'f' && (a) <= 'f') )
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_new:
|
||||||
|
* @r_dh: returns the new data object
|
||||||
|
*
|
||||||
|
* Create a new data object without any content.
|
||||||
|
*
|
||||||
|
* Return value: An error value or 0 on success
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_data_new ( GpgmeData *r_dh )
|
||||||
|
{
|
||||||
|
GpgmeData dh;
|
||||||
|
|
||||||
|
if (!r_dh)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
*r_dh = NULL;
|
||||||
|
dh = xtrycalloc ( 1, sizeof *dh );
|
||||||
|
if (!dh)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
dh->mode = GPGME_DATA_MODE_INOUT;
|
||||||
|
*r_dh = dh;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_new_from_mem:
|
||||||
|
* @r_dh: Returns a new data object.
|
||||||
|
* @buffer: Initialize with this.
|
||||||
|
* @size: Size of the buffer
|
||||||
|
* @copy: Flag wether a copy of the buffer should be used.
|
||||||
|
*
|
||||||
|
* Create a new data object and initialize with data
|
||||||
|
* from the memory. A @copy with value %TRUE creates a copy of the
|
||||||
|
* memory, a value of %FALSE uses the original memory of @buffer and the
|
||||||
|
* caller has to make sure that this buffer is valid until gpgme_release_data()
|
||||||
|
* is called.
|
||||||
|
*
|
||||||
|
* Return value: An error value or 0 for success.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_data_new_from_mem ( GpgmeData *r_dh,
|
||||||
|
const char *buffer, size_t size, int copy )
|
||||||
|
{
|
||||||
|
GpgmeData dh;
|
||||||
|
GpgmeError err;
|
||||||
|
|
||||||
|
if (!r_dh || !buffer)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
*r_dh = NULL;
|
||||||
|
err = gpgme_data_new ( &dh );
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
dh->len = size;
|
||||||
|
if (copy) {
|
||||||
|
dh->private_buffer = xtrymalloc ( size );
|
||||||
|
if ( !dh->private_buffer ) {
|
||||||
|
gpgme_data_release (dh);
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
}
|
||||||
|
dh->private_len = size;
|
||||||
|
memcpy (dh->private_buffer, buffer, size );
|
||||||
|
dh->data = dh->private_buffer;
|
||||||
|
dh->writepos = size;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dh->data = buffer;
|
||||||
|
}
|
||||||
|
dh->type = GPGME_DATA_TYPE_MEM;
|
||||||
|
|
||||||
|
*r_dh = dh;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_new_with_read_cb:
|
||||||
|
* @r_dh: returns the new data object
|
||||||
|
* @read_cb: callback function
|
||||||
|
* @read_cb_value: value passed to the callback function
|
||||||
|
*
|
||||||
|
* Create a new data object which is a wrapper around the callback function.
|
||||||
|
* The callback function is defined as:
|
||||||
|
* <literal>
|
||||||
|
* typedef int (*read_cb) (void *cb_value,
|
||||||
|
* char *buffer,
|
||||||
|
* size_t count,
|
||||||
|
* size_t *nread);
|
||||||
|
* </literal>
|
||||||
|
*
|
||||||
|
* The callback should return a maximium of @count bytes in @buffer
|
||||||
|
* and the number actually read in @nread. It may return 0 in @nread
|
||||||
|
* if there are no bytes currently available. To indicate EOF the
|
||||||
|
* function should return with an error code of %-1 and set @nread to
|
||||||
|
* 0. The callback may support passing %NULL for @buffer and @nread
|
||||||
|
* and %0 for count as an indication to reset its internal read
|
||||||
|
* pointer.
|
||||||
|
*
|
||||||
|
* Return value: An error value or 0 for success.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_data_new_with_read_cb ( GpgmeData *r_dh,
|
||||||
|
int (*read_cb)(void*,char *,size_t,size_t*),
|
||||||
|
void *read_cb_value )
|
||||||
|
{
|
||||||
|
GpgmeData dh;
|
||||||
|
GpgmeError err;
|
||||||
|
|
||||||
|
if (!r_dh || !read_cb)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
*r_dh = NULL;
|
||||||
|
err = gpgme_data_new ( &dh );
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
dh->type = GPGME_DATA_TYPE_CB;
|
||||||
|
dh->mode = GPGME_DATA_MODE_OUT;
|
||||||
|
dh->read_cb = read_cb;
|
||||||
|
dh->read_cb_value = read_cb_value;
|
||||||
|
|
||||||
|
*r_dh = dh;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_new_from_file:
|
||||||
|
* @r_dh: returns the new data object
|
||||||
|
* @fname: filename
|
||||||
|
* @copy: Flag, whether the file should be copied.
|
||||||
|
*
|
||||||
|
* Create a new data object and initialize it with the content of
|
||||||
|
* the file @file. If @copy is %True the file is immediately read in
|
||||||
|
* and closed. @copy of %False is not yet supportted.
|
||||||
|
*
|
||||||
|
* Return value: An error code or 0 on success. If the error code is
|
||||||
|
* %GPGME_File_Error, the OS error code is held in %errno.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_data_new_from_file ( GpgmeData *r_dh, const char *fname, int copy )
|
||||||
|
{
|
||||||
|
GpgmeData dh;
|
||||||
|
GpgmeError err;
|
||||||
|
struct stat st;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
if (!r_dh)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
*r_dh = NULL;
|
||||||
|
/* We only support copy for now - in future we might want to honor the
|
||||||
|
* copy flag and just store a file pointer */
|
||||||
|
if (!copy)
|
||||||
|
return mk_error (Not_Implemented);
|
||||||
|
if (!fname)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
err = gpgme_data_new ( &dh );
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
fp = fopen (fname, "rb");
|
||||||
|
if (!fp) {
|
||||||
|
int save_errno = errno;
|
||||||
|
gpgme_data_release (dh);
|
||||||
|
errno = save_errno;
|
||||||
|
return mk_error (File_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fstat(fileno(fp), &st) ) {
|
||||||
|
int save_errno = errno;
|
||||||
|
fclose (fp);
|
||||||
|
gpgme_data_release (dh);
|
||||||
|
errno = save_errno;
|
||||||
|
return mk_error (File_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We should check the length of the file and don't allow for to
|
||||||
|
* large files */
|
||||||
|
dh->private_buffer = xtrymalloc ( st.st_size );
|
||||||
|
if ( !dh->private_buffer ) {
|
||||||
|
fclose (fp);
|
||||||
|
gpgme_data_release (dh);
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
}
|
||||||
|
dh->private_len = st.st_size;
|
||||||
|
|
||||||
|
if ( fread ( dh->private_buffer, dh->private_len, 1, fp ) != 1 ) {
|
||||||
|
int save_errno = errno;
|
||||||
|
fclose (fp);
|
||||||
|
gpgme_data_release (dh);
|
||||||
|
errno = save_errno;
|
||||||
|
return mk_error (File_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (fp);
|
||||||
|
|
||||||
|
dh->len = dh->private_len;
|
||||||
|
dh->data = dh->private_buffer;
|
||||||
|
dh->writepos = dh->len;
|
||||||
|
dh->type = GPGME_DATA_TYPE_MEM;
|
||||||
|
|
||||||
|
*r_dh = dh;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_new_from_filepart:
|
||||||
|
* @r_dh: returns the new data object
|
||||||
|
* @fname: filename
|
||||||
|
* @fp: filepointer
|
||||||
|
* @offset: Start reading at this offset
|
||||||
|
* @length: Read this many bytes
|
||||||
|
*
|
||||||
|
* Create a new data object and initialize it with @length bytes
|
||||||
|
* starting at @offset of @file or @fp. Either a filename or an open
|
||||||
|
* filepointer may be given.
|
||||||
|
*
|
||||||
|
|
||||||
|
* Return value: An error code or 0 on success. If the error code is
|
||||||
|
* %GPGME_File_Error, the OS error code is held in %errno.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_data_new_from_filepart ( GpgmeData *r_dh, const char *fname, FILE *fp,
|
||||||
|
off_t offset, off_t length )
|
||||||
|
{
|
||||||
|
GpgmeData dh;
|
||||||
|
GpgmeError err;
|
||||||
|
|
||||||
|
if (!r_dh)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
*r_dh = NULL;
|
||||||
|
if ( fname && fp ) /* these are mutual exclusive */
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
if (!fname && !fp)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
if (!length)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
err = gpgme_data_new ( &dh );
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
if (!fp) {
|
||||||
|
fp = fopen (fname, "rb");
|
||||||
|
if (!fp) {
|
||||||
|
int save_errno = errno;
|
||||||
|
gpgme_data_release (dh);
|
||||||
|
errno = save_errno;
|
||||||
|
return mk_error (File_Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( fseek ( fp, (long)offset, SEEK_SET) ) {
|
||||||
|
int save_errno = errno;
|
||||||
|
if (fname)
|
||||||
|
fclose (fp);
|
||||||
|
gpgme_data_release (dh);
|
||||||
|
errno = save_errno;
|
||||||
|
return mk_error (File_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dh->private_buffer = xtrymalloc ( length );
|
||||||
|
if ( !dh->private_buffer ) {
|
||||||
|
if (fname)
|
||||||
|
fclose (fp);
|
||||||
|
gpgme_data_release (dh);
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
}
|
||||||
|
dh->private_len = length;
|
||||||
|
|
||||||
|
if ( fread ( dh->private_buffer, dh->private_len, 1, fp ) != 1 ) {
|
||||||
|
int save_errno = errno;
|
||||||
|
if (fname)
|
||||||
|
fclose (fp);
|
||||||
|
gpgme_data_release (dh);
|
||||||
|
errno = save_errno;
|
||||||
|
return mk_error (File_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fname)
|
||||||
|
fclose (fp);
|
||||||
|
|
||||||
|
dh->len = dh->private_len;
|
||||||
|
dh->data = dh->private_buffer;
|
||||||
|
dh->writepos = dh->len;
|
||||||
|
dh->type = GPGME_DATA_TYPE_MEM;
|
||||||
|
|
||||||
|
*r_dh = dh;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_release:
|
||||||
|
* @dh: Data object
|
||||||
|
*
|
||||||
|
* Release the data object @dh. @dh may be NULL in which case nothing
|
||||||
|
* happens.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_data_release ( GpgmeData dh )
|
||||||
|
{
|
||||||
|
if (dh) {
|
||||||
|
xfree (dh->private_buffer);
|
||||||
|
xfree (dh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Release the data object @dh. @dh may be NULL in which case nothing
|
||||||
|
* happens.
|
||||||
|
*
|
||||||
|
* Return value: An allocated memory object with the content of the
|
||||||
|
* data object. The function makes sure that the returned string can
|
||||||
|
* safely be accessed using the string fucntions.
|
||||||
|
**/
|
||||||
|
char *
|
||||||
|
_gpgme_data_release_and_return_string ( GpgmeData dh )
|
||||||
|
{
|
||||||
|
char *val = NULL;
|
||||||
|
|
||||||
|
if (dh) {
|
||||||
|
if ( _gpgme_data_append ( dh, "", 1 ) ) /* append EOS */
|
||||||
|
xfree (dh->private_buffer );
|
||||||
|
else {
|
||||||
|
val = dh->private_buffer;
|
||||||
|
if ( !val && dh->data ) {
|
||||||
|
val = xtrymalloc ( dh->len );
|
||||||
|
if ( val )
|
||||||
|
memcpy ( val, dh->data, dh->len );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xfree (dh);
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_release_and_get_mem:
|
||||||
|
* @dh: the data object
|
||||||
|
* @r_len: returns the length of the memory
|
||||||
|
*
|
||||||
|
* Release the data object @dh and return its content and the length
|
||||||
|
* of that content. The caller has to free this data. @dh maybe NULL
|
||||||
|
* in which case NULL is returned. If there is not enough memory for
|
||||||
|
* allocating the return value, NULL is returned and the object is
|
||||||
|
* released.
|
||||||
|
*
|
||||||
|
* Return value: a pointer to an allocated buffer of length @r_len.
|
||||||
|
**/
|
||||||
|
char *
|
||||||
|
gpgme_data_release_and_get_mem ( GpgmeData dh, size_t *r_len )
|
||||||
|
{
|
||||||
|
char *val = NULL;
|
||||||
|
|
||||||
|
if (r_len)
|
||||||
|
*r_len = 0;
|
||||||
|
if (dh) {
|
||||||
|
size_t len = dh->len;
|
||||||
|
val = dh->private_buffer;
|
||||||
|
if ( !val && dh->data ) {
|
||||||
|
val = xtrymalloc ( len );
|
||||||
|
if ( val )
|
||||||
|
memcpy ( val, dh->data, len );
|
||||||
|
}
|
||||||
|
xfree (dh);
|
||||||
|
if (val && r_len )
|
||||||
|
*r_len = len;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_get_type:
|
||||||
|
* @dh: the data object
|
||||||
|
*
|
||||||
|
* Get the type of the data object.
|
||||||
|
* Data types are prefixed with %GPGME_DATA_TYPE_
|
||||||
|
*
|
||||||
|
* Return value: the data type
|
||||||
|
**/
|
||||||
|
GpgmeDataType
|
||||||
|
gpgme_data_get_type ( GpgmeData dh )
|
||||||
|
{
|
||||||
|
if ( !dh || (!dh->data && !dh->read_cb))
|
||||||
|
return GPGME_DATA_TYPE_NONE;
|
||||||
|
|
||||||
|
return dh->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_data_set_mode ( GpgmeData dh, GpgmeDataMode mode )
|
||||||
|
{
|
||||||
|
assert (dh);
|
||||||
|
dh->mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GpgmeDataMode
|
||||||
|
_gpgme_data_get_mode ( GpgmeData dh )
|
||||||
|
{
|
||||||
|
assert (dh);
|
||||||
|
return dh->mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_rewind:
|
||||||
|
* @dh: the data object
|
||||||
|
*
|
||||||
|
* Prepare the data object in a way, that a gpgme_data_read() does start
|
||||||
|
* at the beginning of the data. This has to be done for all types
|
||||||
|
* of data objects.
|
||||||
|
*
|
||||||
|
* Return value: An error code or 0 on success
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_data_rewind ( GpgmeData dh )
|
||||||
|
{
|
||||||
|
if ( !dh )
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
if ( dh->type == GPGME_DATA_TYPE_NONE
|
||||||
|
|| dh->type == GPGME_DATA_TYPE_MEM ) {
|
||||||
|
dh->readpos = 0;
|
||||||
|
}
|
||||||
|
else if (dh->type == GPGME_DATA_TYPE_CB) {
|
||||||
|
dh->len = dh->readpos = 0;
|
||||||
|
dh->read_cb_eof = 0;
|
||||||
|
if ( dh->read_cb (dh->read_cb_value, NULL, 0, NULL) )
|
||||||
|
return mk_error (Not_Implemented);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return mk_error (General_Error);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_read:
|
||||||
|
* @dh: the data object
|
||||||
|
* @buffer: A buffer
|
||||||
|
* @length: The length of that bufer
|
||||||
|
* @nread: Returns the number of bytes actually read.
|
||||||
|
*
|
||||||
|
* Copy data from the current read position (which may be set by
|
||||||
|
* gpgme_data_rewind()) to the supplied @buffer, max. @length bytes
|
||||||
|
* are copied and the actual number of bytes are returned in @nread.
|
||||||
|
* If there are no more bytes available %GPGME_EOF is returned and @nread
|
||||||
|
* is set to 0.
|
||||||
|
*
|
||||||
|
* With a @buffer of NULL, the function does only return the number of
|
||||||
|
* bytes available and does not move the read pointer. This does only
|
||||||
|
* work for certain data types, all other will respond with an
|
||||||
|
* %GPGME_Invalid_Type.
|
||||||
|
*
|
||||||
|
* Return value: An error code or 0 on success, EOF is indcated by the
|
||||||
|
* error code GPGME_EOF.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_data_read ( GpgmeData dh, char *buffer, size_t length, size_t *nread )
|
||||||
|
{
|
||||||
|
size_t nbytes;
|
||||||
|
|
||||||
|
if ( !dh )
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
if (dh->type == GPGME_DATA_TYPE_MEM ) {
|
||||||
|
nbytes = dh->len - dh->readpos;
|
||||||
|
if ( !nbytes ) {
|
||||||
|
*nread = 0;
|
||||||
|
return mk_error(EOF);
|
||||||
|
}
|
||||||
|
if (!buffer) {
|
||||||
|
*nread = nbytes;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (nbytes > length)
|
||||||
|
nbytes = length;
|
||||||
|
memcpy ( buffer, dh->data + dh->readpos, nbytes );
|
||||||
|
*nread = nbytes;
|
||||||
|
dh->readpos += nbytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dh->type == GPGME_DATA_TYPE_CB) {
|
||||||
|
if (!buffer) {
|
||||||
|
*nread = 0;
|
||||||
|
return mk_error (Invalid_Type);
|
||||||
|
}
|
||||||
|
nbytes = dh->len - dh->readpos;
|
||||||
|
if ( nbytes ) {
|
||||||
|
/* we have unread data - return this */
|
||||||
|
if (nbytes > length)
|
||||||
|
nbytes = length;
|
||||||
|
memcpy ( buffer, dh->data + dh->readpos, nbytes );
|
||||||
|
*nread = nbytes;
|
||||||
|
dh->readpos += nbytes;
|
||||||
|
}
|
||||||
|
else { /* get the data from the callback */
|
||||||
|
if (!dh->read_cb || dh->read_cb_eof) {
|
||||||
|
*nread = 0;
|
||||||
|
return mk_error (EOF);
|
||||||
|
}
|
||||||
|
if (dh->read_cb (dh->read_cb_value, buffer, length, nread )) {
|
||||||
|
*nread = 0;
|
||||||
|
dh->read_cb_eof = 1;
|
||||||
|
return mk_error (EOF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return mk_error (General_Error);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_data_unread (GpgmeData dh, const char *buffer, size_t length )
|
||||||
|
{
|
||||||
|
if ( !dh )
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
if (dh->type == GPGME_DATA_TYPE_MEM ) {
|
||||||
|
/* check that we don't unread more than we have yet read */
|
||||||
|
if ( dh->readpos < length )
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
/* No need to use the buffer for this data type */
|
||||||
|
dh->readpos -= length;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return mk_error (General_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function does make sense when we know that it contains no nil chars.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
_gpgme_data_get_as_string ( GpgmeData dh )
|
||||||
|
{
|
||||||
|
char *val = NULL;
|
||||||
|
|
||||||
|
if (dh) {
|
||||||
|
val = xtrymalloc ( dh->len+1 );
|
||||||
|
if ( val ) {
|
||||||
|
memcpy ( val, dh->data, dh->len );
|
||||||
|
val[dh->len] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_data_write:
|
||||||
|
* @dh: the context
|
||||||
|
* @buffer: data to be written to the data object
|
||||||
|
* @length: length of this data
|
||||||
|
*
|
||||||
|
* Write the content of @buffer to the data object @dh at the current write
|
||||||
|
* position.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an error code
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_data_write ( GpgmeData dh, const char *buffer, size_t length )
|
||||||
|
{
|
||||||
|
if (!dh || !buffer)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
return _gpgme_data_append (dh, buffer, length );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_data_append ( GpgmeData dh, const char *buffer, size_t length )
|
||||||
|
{
|
||||||
|
assert (dh);
|
||||||
|
|
||||||
|
if ( dh->type == GPGME_DATA_TYPE_NONE ) {
|
||||||
|
/* convert it to a mem data type */
|
||||||
|
assert (!dh->private_buffer);
|
||||||
|
dh->type = GPGME_DATA_TYPE_MEM;
|
||||||
|
dh->private_len = length < ALLOC_CHUNK? ALLOC_CHUNK : length;
|
||||||
|
dh->private_buffer = xtrymalloc ( dh->private_len );
|
||||||
|
if (!dh->private_buffer) {
|
||||||
|
dh->private_len = 0;
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
}
|
||||||
|
dh->writepos = 0;
|
||||||
|
dh->data = dh->private_buffer;
|
||||||
|
}
|
||||||
|
else if ( dh->type != GPGME_DATA_TYPE_MEM )
|
||||||
|
return mk_error (Invalid_Type);
|
||||||
|
|
||||||
|
if ( dh->mode != GPGME_DATA_MODE_INOUT
|
||||||
|
&& dh->mode != GPGME_DATA_MODE_IN )
|
||||||
|
return mk_error (Invalid_Mode);
|
||||||
|
|
||||||
|
if ( !dh->private_buffer ) {
|
||||||
|
/* we have to copy it now */
|
||||||
|
assert (dh->data);
|
||||||
|
dh->private_len = dh->len+length;
|
||||||
|
if (dh->private_len < ALLOC_CHUNK)
|
||||||
|
dh->private_len = ALLOC_CHUNK;
|
||||||
|
dh->private_buffer = xtrymalloc ( dh->private_len );
|
||||||
|
if (!dh->private_buffer) {
|
||||||
|
dh->private_len = 0;
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
}
|
||||||
|
memcpy ( dh->private_buffer, dh->data, dh->len );
|
||||||
|
dh->writepos = dh->len;
|
||||||
|
dh->data = dh->private_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate more memory if needed */
|
||||||
|
if ( dh->writepos + length > dh->private_len ) {
|
||||||
|
char *p;
|
||||||
|
size_t newlen = dh->private_len
|
||||||
|
+ (length < ALLOC_CHUNK? ALLOC_CHUNK : length);
|
||||||
|
p = xtryrealloc ( dh->private_buffer, newlen );
|
||||||
|
if ( !p )
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
dh->private_buffer = p;
|
||||||
|
dh->private_len = newlen;
|
||||||
|
dh->data = dh->private_buffer;
|
||||||
|
assert ( !(dh->writepos + length > dh->private_len) );
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy ( dh->private_buffer + dh->writepos, buffer, length );
|
||||||
|
dh->writepos += length;
|
||||||
|
dh->len += length;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_data_append_string ( GpgmeData dh, const char *s )
|
||||||
|
{
|
||||||
|
return _gpgme_data_append ( dh, s, s? strlen(s):0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_data_append_for_xml ( GpgmeData dh,
|
||||||
|
const char *buffer, size_t len )
|
||||||
|
{
|
||||||
|
const char *text, *s;
|
||||||
|
size_t n;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
if ( !dh || !buffer )
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
do {
|
||||||
|
for (text=NULL, s=buffer, n=len; n && !text; s++, n-- ) {
|
||||||
|
if ( *s == '<' )
|
||||||
|
text = "<";
|
||||||
|
else if ( *s == '>' )
|
||||||
|
text = ">"; /* not sure whether this is really needed */
|
||||||
|
else if ( *s == '&' )
|
||||||
|
text = "&";
|
||||||
|
else if ( !*s )
|
||||||
|
text = "�";
|
||||||
|
}
|
||||||
|
if (text) {
|
||||||
|
s--; n++;
|
||||||
|
}
|
||||||
|
if (s != buffer)
|
||||||
|
rc = _gpgme_data_append ( dh, buffer, s-buffer );
|
||||||
|
if ( !rc && text) {
|
||||||
|
rc = _gpgme_data_append_string ( dh, text );
|
||||||
|
s++; n--;
|
||||||
|
}
|
||||||
|
buffer = s;
|
||||||
|
len = n;
|
||||||
|
} while ( !rc && len );
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Append a string to DATA and convert it so that the result will be
|
||||||
|
* valid XML.
|
||||||
|
*/
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_data_append_string_for_xml ( GpgmeData dh, const char *string )
|
||||||
|
{
|
||||||
|
return _gpgme_data_append_for_xml ( dh, string, strlen (string) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
hextobyte( const byte *s )
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if( *s >= '0' && *s <= '9' )
|
||||||
|
c = 16 * (*s - '0');
|
||||||
|
else if( *s >= 'A' && *s <= 'F' )
|
||||||
|
c = 16 * (10 + *s - 'A');
|
||||||
|
else if( *s >= 'a' && *s <= 'f' )
|
||||||
|
c = 16 * (10 + *s - 'a');
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
s++;
|
||||||
|
if( *s >= '0' && *s <= '9' )
|
||||||
|
c += *s - '0';
|
||||||
|
else if( *s >= 'A' && *s <= 'F' )
|
||||||
|
c += 10 + *s - 'A';
|
||||||
|
else if( *s >= 'a' && *s <= 'f' )
|
||||||
|
c += 10 + *s - 'a';
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Append a string with percent style (%XX) escape characters as XML
|
||||||
|
*/
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_data_append_percentstring_for_xml ( GpgmeData dh, const char *string )
|
||||||
|
{
|
||||||
|
const byte *s;
|
||||||
|
byte *buf, *d;
|
||||||
|
int val;
|
||||||
|
GpgmeError err;
|
||||||
|
|
||||||
|
d = buf = xtrymalloc ( strlen (string) );
|
||||||
|
for (s=string; *s; s++ ) {
|
||||||
|
if ( *s == '%' && (val=hextobyte (s+1)) != -1 ) {
|
||||||
|
*d++ = val;
|
||||||
|
s += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*d++ = *s;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = _gpgme_data_append_for_xml ( dh, buf, d - buf );
|
||||||
|
xfree (buf);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Functions to support the wait interface. */
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_data_inbound_handler (void *opaque, int pid, int fd)
|
||||||
|
{
|
||||||
|
GpgmeData dh = opaque;
|
||||||
|
GpgmeError err;
|
||||||
|
int nread;
|
||||||
|
char buf[200];
|
||||||
|
|
||||||
|
assert (_gpgme_data_get_mode (dh) == GPGME_DATA_MODE_IN);
|
||||||
|
|
||||||
|
nread = _gpgme_io_read (fd, buf, 200);
|
||||||
|
if (nread < 0)
|
||||||
|
{
|
||||||
|
DEBUG3 ("read_mem_data: read failed on fd %d (n=%d): %s",
|
||||||
|
fd, nread, strerror (errno) );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (!nread)
|
||||||
|
return 1; /* eof */
|
||||||
|
|
||||||
|
/* We could improve this with a GpgmeData function which takes
|
||||||
|
* the read function or provides a memory area for writing to it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
err = _gpgme_data_append (dh, buf, nread);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
DEBUG1 ("_gpgme_append_data failed: %s\n",
|
||||||
|
gpgme_strerror(err));
|
||||||
|
/* Fixme: we should close the pipe or read it to /dev/null in
|
||||||
|
* this case. Returnin EOF is not sufficient */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
write_mem_data (GpgmeData dh, int fd)
|
||||||
|
{
|
||||||
|
size_t nbytes;
|
||||||
|
int nwritten;
|
||||||
|
|
||||||
|
nbytes = dh->len - dh->readpos;
|
||||||
|
if (!nbytes)
|
||||||
|
{
|
||||||
|
_gpgme_io_close (fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: Arggg, the pipe blocks on large write request, although
|
||||||
|
* select told us that it is okay to write - need to figure out
|
||||||
|
* why this happens? Stevens says nothing about this problem (or
|
||||||
|
* is it my Linux kernel 2.4.0test1)
|
||||||
|
* To avoid that we have set the pipe to nonblocking.
|
||||||
|
*/
|
||||||
|
|
||||||
|
nwritten = _gpgme_io_write (fd, dh->data+dh->readpos, nbytes);
|
||||||
|
if (nwritten == -1 && errno == EAGAIN)
|
||||||
|
return 0;
|
||||||
|
if (nwritten < 1)
|
||||||
|
{
|
||||||
|
DEBUG3 ("write_mem_data(%d): write failed (n=%d): %s",
|
||||||
|
fd, nwritten, strerror (errno));
|
||||||
|
_gpgme_io_close (fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dh->readpos += nwritten;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
write_cb_data (GpgmeData dh, int fd)
|
||||||
|
{
|
||||||
|
size_t nbytes;
|
||||||
|
int err, nwritten;
|
||||||
|
char buffer[512];
|
||||||
|
|
||||||
|
err = gpgme_data_read (dh, buffer, DIM(buffer), &nbytes);
|
||||||
|
if (err == GPGME_EOF)
|
||||||
|
{
|
||||||
|
_gpgme_io_close (fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
nwritten = _gpgme_io_write (fd, buffer, nbytes);
|
||||||
|
if (nwritten == -1 && errno == EAGAIN )
|
||||||
|
return 0;
|
||||||
|
if (nwritten < 1)
|
||||||
|
{
|
||||||
|
DEBUG3 ("write_cb_data(%d): write failed (n=%d): %s",
|
||||||
|
fd, nwritten, strerror (errno));
|
||||||
|
_gpgme_io_close (fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nwritten < nbytes)
|
||||||
|
{
|
||||||
|
/* ugly, ugly: It does currently only for for MEM type data */
|
||||||
|
if (_gpgme_data_unread (dh, buffer + nwritten, nbytes - nwritten))
|
||||||
|
DEBUG1 ("wite_cb_data: unread of %d bytes failed\n",
|
||||||
|
nbytes - nwritten);
|
||||||
|
_gpgme_io_close (fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_data_outbound_handler (void *opaque, int pid, int fd)
|
||||||
|
{
|
||||||
|
GpgmeData dh = opaque;
|
||||||
|
|
||||||
|
assert (_gpgme_data_get_mode (dh) == GPGME_DATA_MODE_OUT);
|
||||||
|
switch (gpgme_data_get_type (dh))
|
||||||
|
{
|
||||||
|
case GPGME_DATA_TYPE_MEM:
|
||||||
|
if (write_mem_data (dh, fd))
|
||||||
|
return 1; /* ready */
|
||||||
|
break;
|
||||||
|
case GPGME_DATA_TYPE_CB:
|
||||||
|
if (write_cb_data (dh, fd))
|
||||||
|
return 1; /* ready */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
240
tags/gpgme-0-3-0/gpgme/debug.c
Normal file
240
tags/gpgme-0-3-0/gpgme/debug.c
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
/* debug.c
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#ifndef HAVE_DOSISH_SYSTEM
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#endif
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "sema.h"
|
||||||
|
|
||||||
|
DEFINE_STATIC_LOCK (debug_lock);
|
||||||
|
|
||||||
|
struct debug_control_s {
|
||||||
|
FILE *fp;
|
||||||
|
char fname[100];
|
||||||
|
};
|
||||||
|
|
||||||
|
static int debug_level = 0;
|
||||||
|
static FILE *errfp = NULL;
|
||||||
|
|
||||||
|
/****************
|
||||||
|
* remove leading and trailing white spaces
|
||||||
|
*/
|
||||||
|
static char *
|
||||||
|
trim_spaces( char *str )
|
||||||
|
{
|
||||||
|
char *string, *p, *mark;
|
||||||
|
|
||||||
|
string = str;
|
||||||
|
/* find first non space character */
|
||||||
|
for( p=string; *p && isspace( *(byte*)p ) ; p++ )
|
||||||
|
;
|
||||||
|
/* move characters */
|
||||||
|
for( (mark = NULL); (*string = *p); string++, p++ )
|
||||||
|
if( isspace( *(byte*)p ) ) {
|
||||||
|
if( !mark )
|
||||||
|
mark = string ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mark = NULL ;
|
||||||
|
if( mark )
|
||||||
|
*mark = '\0' ; /* remove trailing spaces */
|
||||||
|
|
||||||
|
return str ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
debug_init (void)
|
||||||
|
{
|
||||||
|
static volatile int initialized = 0;
|
||||||
|
|
||||||
|
if (initialized)
|
||||||
|
return;
|
||||||
|
LOCK (debug_lock);
|
||||||
|
if (!initialized) {
|
||||||
|
const char *e = getenv ("GPGME_DEBUG");
|
||||||
|
const char *s1, *s2;;
|
||||||
|
|
||||||
|
initialized = 1;
|
||||||
|
debug_level = 0;
|
||||||
|
errfp = stderr;
|
||||||
|
if (e) {
|
||||||
|
debug_level = atoi (e);
|
||||||
|
s1 = strchr (e, ':');
|
||||||
|
if (s1
|
||||||
|
#ifndef HAVE_DOSISH_SYSTEM
|
||||||
|
&& getuid () == geteuid ()
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
char *p;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
s1++;
|
||||||
|
if ( !(s2 = strchr (s1, ':')) )
|
||||||
|
s2 = s1 + strlen(s1);
|
||||||
|
p = xtrymalloc (s2-s1+1);
|
||||||
|
if (p) {
|
||||||
|
memcpy (p, s1, s2-s1);
|
||||||
|
p[s2-s1] = 0;
|
||||||
|
trim_spaces (p);
|
||||||
|
fp = fopen (p,"a");
|
||||||
|
if (fp) {
|
||||||
|
setvbuf (fp, NULL, _IOLBF, 0);
|
||||||
|
errfp = fp;
|
||||||
|
}
|
||||||
|
xfree (p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug_level > 0)
|
||||||
|
fprintf (errfp,"gpgme_debug: level=%d\n", debug_level);
|
||||||
|
}
|
||||||
|
UNLOCK (debug_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_debug_level ()
|
||||||
|
{
|
||||||
|
return debug_level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_debug (int level, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list arg_ptr ;
|
||||||
|
|
||||||
|
debug_init ();
|
||||||
|
if ( debug_level < level )
|
||||||
|
return;
|
||||||
|
|
||||||
|
va_start ( arg_ptr, format ) ;
|
||||||
|
LOCK (debug_lock);
|
||||||
|
vfprintf (errfp, format, arg_ptr) ;
|
||||||
|
va_end ( arg_ptr ) ;
|
||||||
|
if( format && *format && format[strlen(format)-1] != '\n' )
|
||||||
|
putc ('\n', errfp);
|
||||||
|
UNLOCK (debug_lock);
|
||||||
|
fflush (errfp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_debug_begin ( void **helper, int level, const char *text)
|
||||||
|
{
|
||||||
|
struct debug_control_s *ctl;
|
||||||
|
|
||||||
|
debug_init ();
|
||||||
|
|
||||||
|
*helper = NULL;
|
||||||
|
if ( debug_level < level )
|
||||||
|
return;
|
||||||
|
ctl = xtrycalloc (1, sizeof *ctl );
|
||||||
|
if (!ctl) {
|
||||||
|
_gpgme_debug (255, __FILE__ ":" STR2(__LINE__)": out of core");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Oh what a pitty that we don't have a asprintf or snprintf under
|
||||||
|
* Windoze. We definitely should write our own clib for W32! */
|
||||||
|
sprintf ( ctl->fname, "/tmp/gpgme_debug.%d.%p", getpid (), ctl );
|
||||||
|
#if defined (__GLIBC__) || defined (HAVE_DOSISH_SYSTEM)
|
||||||
|
ctl->fp = fopen (ctl->fname, "w+x");
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
int fd = open (ctl->fname, O_WRONLY|O_TRUNC|O_CREAT|O_EXCL,
|
||||||
|
S_IRUSR|S_IWUSR );
|
||||||
|
if (fd == -1)
|
||||||
|
ctl->fp = NULL;
|
||||||
|
else
|
||||||
|
ctl->fp = fdopen (fd, "w+");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (!ctl->fp) {
|
||||||
|
_gpgme_debug (255,__FILE__ ":" STR2(__LINE__)": failed to create `%s'",
|
||||||
|
ctl->fname );
|
||||||
|
xfree (ctl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*helper = ctl;
|
||||||
|
_gpgme_debug_add (helper, "%s", text );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_debug_enabled (void **helper)
|
||||||
|
{
|
||||||
|
return helper && *helper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_debug_add (void **helper, const char *format, ...)
|
||||||
|
{
|
||||||
|
struct debug_control_s *ctl = *helper;
|
||||||
|
va_list arg_ptr ;
|
||||||
|
|
||||||
|
if ( !*helper )
|
||||||
|
return;
|
||||||
|
|
||||||
|
va_start ( arg_ptr, format ) ;
|
||||||
|
vfprintf (ctl->fp, format, arg_ptr) ;
|
||||||
|
va_end ( arg_ptr ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_debug_end (void **helper, const char *text)
|
||||||
|
{
|
||||||
|
struct debug_control_s *ctl = *helper;
|
||||||
|
int c, last_c=EOF;
|
||||||
|
|
||||||
|
if ( !*helper )
|
||||||
|
return;
|
||||||
|
|
||||||
|
_gpgme_debug_add (helper, "%s", text );
|
||||||
|
fflush (ctl->fp); /* we need this for the buggy Windoze libc */
|
||||||
|
rewind (ctl->fp);
|
||||||
|
LOCK (debug_lock);
|
||||||
|
while ( (c=getc (ctl->fp)) != EOF ) {
|
||||||
|
putc (c, errfp);
|
||||||
|
last_c = c;
|
||||||
|
}
|
||||||
|
if (last_c != '\n')
|
||||||
|
putc ('\n', errfp);
|
||||||
|
UNLOCK (debug_lock);
|
||||||
|
|
||||||
|
fclose (ctl->fp);
|
||||||
|
remove (ctl->fname);
|
||||||
|
xfree (ctl);
|
||||||
|
*helper = NULL;
|
||||||
|
}
|
||||||
|
|
80
tags/gpgme-0-3-0/gpgme/decrypt-verify.c
Normal file
80
tags/gpgme-0-3-0/gpgme/decrypt-verify.c
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/* decrypt-verify.c - decrypt and verify functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
decrypt_verify_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
||||||
|
{
|
||||||
|
_gpgme_decrypt_status_handler (ctx, code, args);
|
||||||
|
_gpgme_verify_status_handler (ctx, code, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_decrypt_verify_start (GpgmeCtx ctx, GpgmeData ciph, GpgmeData plain)
|
||||||
|
{
|
||||||
|
return _gpgme_decrypt_start (ctx, ciph, plain,
|
||||||
|
decrypt_verify_status_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_decrypt_verify:
|
||||||
|
* @ctx: The context
|
||||||
|
* @in: ciphertext input
|
||||||
|
* @out: plaintext output
|
||||||
|
*
|
||||||
|
* This function decrypts @in to @out and performs a signature check.
|
||||||
|
* Other parameters are take from the context @c.
|
||||||
|
* The function does wait for the result.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an errorcode.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_decrypt_verify (GpgmeCtx ctx,
|
||||||
|
GpgmeData in, GpgmeData out,
|
||||||
|
GpgmeSigStat *r_stat)
|
||||||
|
{
|
||||||
|
GpgmeError err = gpgme_op_decrypt_verify_start (ctx, in, out);
|
||||||
|
if (!err)
|
||||||
|
{
|
||||||
|
gpgme_wait (ctx, 1);
|
||||||
|
if (!ctx->result.decrypt || !ctx->result.verify)
|
||||||
|
err = mk_error (General_Error);
|
||||||
|
else if (ctx->out_of_core)
|
||||||
|
err = mk_error (Out_Of_Core);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = _gpgme_decrypt_result (ctx);
|
||||||
|
if (! err)
|
||||||
|
*r_stat = _gpgme_intersect_stati (ctx->result.verify);
|
||||||
|
}
|
||||||
|
ctx->pending = 0;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
201
tags/gpgme-0-3-0/gpgme/decrypt.c
Normal file
201
tags/gpgme-0-3-0/gpgme/decrypt.c
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
/* decrypt.c - decrypt functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
struct decrypt_result_s
|
||||||
|
{
|
||||||
|
int okay;
|
||||||
|
int failed;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_release_decrypt_result (DecryptResult result)
|
||||||
|
{
|
||||||
|
if (!result)
|
||||||
|
return;
|
||||||
|
xfree (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GpgmeError
|
||||||
|
create_result_struct (GpgmeCtx ctx)
|
||||||
|
{
|
||||||
|
assert (!ctx->result.decrypt);
|
||||||
|
ctx->result.decrypt = xtrycalloc (1, sizeof *ctx->result.decrypt);
|
||||||
|
if (!ctx->result.decrypt)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_decrypt_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
||||||
|
{
|
||||||
|
_gpgme_passphrase_status_handler (ctx, code, args);
|
||||||
|
|
||||||
|
if (ctx->out_of_core)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (! ctx->result.decrypt)
|
||||||
|
{
|
||||||
|
if (create_result_struct (ctx))
|
||||||
|
{
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case STATUS_EOF:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATUS_DECRYPTION_OKAY:
|
||||||
|
ctx->result.decrypt->okay = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATUS_DECRYPTION_FAILED:
|
||||||
|
ctx->result.decrypt->failed = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* Ignore all other codes. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_decrypt_start (GpgmeCtx ctx, GpgmeData ciph, GpgmeData plain,
|
||||||
|
void *status_handler)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
fail_on_pending_request (ctx);
|
||||||
|
ctx->pending = 1;
|
||||||
|
|
||||||
|
_gpgme_release_result (ctx);
|
||||||
|
ctx->out_of_core = 0;
|
||||||
|
|
||||||
|
/* Create a process object. */
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS
|
||||||
|
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
/* Check the supplied data. */
|
||||||
|
if (!ciph || gpgme_data_get_type (ciph) == GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (No_Data);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
_gpgme_data_set_mode (ciph, GPGME_DATA_MODE_OUT);
|
||||||
|
|
||||||
|
if (gpgme_data_get_type (plain) != GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (Invalid_Value);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
_gpgme_data_set_mode (plain, GPGME_DATA_MODE_IN);
|
||||||
|
|
||||||
|
err = _gpgme_passphrase_start (ctx);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
_gpgme_engine_set_status_handler (ctx->engine, status_handler, ctx);
|
||||||
|
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||||
|
|
||||||
|
err = _gpgme_engine_op_decrypt (ctx->engine, ciph, plain);
|
||||||
|
|
||||||
|
if (!err) /* And kick off the process. */
|
||||||
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
ctx->pending = 0;
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_decrypt_start (GpgmeCtx ctx, GpgmeData ciph, GpgmeData plain)
|
||||||
|
{
|
||||||
|
return _gpgme_decrypt_start (ctx, ciph, plain,
|
||||||
|
_gpgme_decrypt_status_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_decrypt_result (GpgmeCtx ctx)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
if (!ctx->result.decrypt)
|
||||||
|
err = mk_error (General_Error);
|
||||||
|
else if (ctx->out_of_core)
|
||||||
|
err = mk_error (Out_Of_Core);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = _gpgme_passphrase_result (ctx);
|
||||||
|
if (! err)
|
||||||
|
{
|
||||||
|
if (ctx->result.decrypt->failed)
|
||||||
|
err = mk_error (Decryption_Failed);
|
||||||
|
else if (!ctx->result.decrypt->okay)
|
||||||
|
err = mk_error (No_Data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_decrypt:
|
||||||
|
* @ctx: The context
|
||||||
|
* @in: ciphertext input
|
||||||
|
* @out: plaintext output
|
||||||
|
*
|
||||||
|
* This function decrypts @in to @out.
|
||||||
|
* Other parameters are take from the context @ctx.
|
||||||
|
* The function does wait for the result.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an errorcode.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_decrypt (GpgmeCtx ctx, GpgmeData in, GpgmeData out)
|
||||||
|
{
|
||||||
|
GpgmeError err = gpgme_op_decrypt_start (ctx, in, out);
|
||||||
|
if (!err)
|
||||||
|
{
|
||||||
|
gpgme_wait (ctx, 1);
|
||||||
|
err = _gpgme_decrypt_result (ctx);
|
||||||
|
ctx->pending = 0;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
118
tags/gpgme-0-3-0/gpgme/delete.c
Normal file
118
tags/gpgme-0-3-0/gpgme/delete.c
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/* delete.c - delete a key
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
#include "key.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
||||||
|
{
|
||||||
|
if ( ctx->out_of_core )
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
case STATUS_EOF:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* ignore all other codes */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_delete_start (GpgmeCtx ctx, const GpgmeKey key, int allow_secret)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
fail_on_pending_request (ctx);
|
||||||
|
ctx->pending = 1;
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
{
|
||||||
|
err = mk_error (Invalid_Value);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->engine)
|
||||||
|
{
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS
|
||||||
|
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
_gpgme_engine_set_status_handler (ctx->engine, delete_status_handler, ctx);
|
||||||
|
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||||
|
|
||||||
|
err = _gpgme_engine_op_delete (ctx->engine, key, allow_secret);
|
||||||
|
if (!err)
|
||||||
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
ctx->pending = 0;
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_delete:
|
||||||
|
* @c: Context
|
||||||
|
* @key: A Key Object
|
||||||
|
* @allow_secret: Allow secret key delete
|
||||||
|
*
|
||||||
|
* Delete the give @key from the key database. To delete a secret
|
||||||
|
* along with the public key, @allow_secret must be true.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an error code.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_delete ( GpgmeCtx c, const GpgmeKey key, int allow_secret )
|
||||||
|
{
|
||||||
|
int rc = gpgme_op_delete_start ( c, key, allow_secret );
|
||||||
|
if ( !rc ) {
|
||||||
|
gpgme_wait (c, 1);
|
||||||
|
c->pending = 0;
|
||||||
|
/* FIXME: check for success */
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
246
tags/gpgme-0-3-0/gpgme/encrypt.c
Normal file
246
tags/gpgme-0-3-0/gpgme/encrypt.c
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
/* encrypt.c - encrypt functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
#define SKIP_TOKEN_OR_RETURN(a) do { \
|
||||||
|
while (*(a) && *(a) != ' ') (a)++; \
|
||||||
|
while (*(a) == ' ') (a)++; \
|
||||||
|
if (!*(a)) \
|
||||||
|
return; /* oops */ \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
struct encrypt_result_s
|
||||||
|
{
|
||||||
|
int no_recipients;
|
||||||
|
GpgmeData xmlinfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_release_encrypt_result (EncryptResult result)
|
||||||
|
{
|
||||||
|
if (!result)
|
||||||
|
return;
|
||||||
|
gpgme_data_release (result->xmlinfo);
|
||||||
|
xfree (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse the args and save the information
|
||||||
|
* in an XML structure.
|
||||||
|
* With args of NULL the xml structure is closed.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
append_xml_encinfo (GpgmeData *rdh, char *args)
|
||||||
|
{
|
||||||
|
GpgmeData dh;
|
||||||
|
char helpbuf[100];
|
||||||
|
|
||||||
|
if ( !*rdh ) {
|
||||||
|
if (gpgme_data_new (rdh)) {
|
||||||
|
return; /* fixme: We are ignoring out-of-core */
|
||||||
|
}
|
||||||
|
dh = *rdh;
|
||||||
|
_gpgme_data_append_string (dh, "<GnupgOperationInfo>\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dh = *rdh;
|
||||||
|
_gpgme_data_append_string (dh, " </encryption>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args) { /* just close the XML containter */
|
||||||
|
_gpgme_data_append_string (dh, "</GnupgOperationInfo>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gpgme_data_append_string (dh, " <encryption>\n"
|
||||||
|
" <error>\n"
|
||||||
|
" <invalidRecipient/>\n");
|
||||||
|
|
||||||
|
sprintf (helpbuf, " <reason>%d</reason>\n", atoi (args));
|
||||||
|
_gpgme_data_append_string (dh, helpbuf);
|
||||||
|
SKIP_TOKEN_OR_RETURN (args);
|
||||||
|
|
||||||
|
_gpgme_data_append_string (dh, " <name>");
|
||||||
|
_gpgme_data_append_percentstring_for_xml (dh, args);
|
||||||
|
_gpgme_data_append_string (dh, "</name>\n"
|
||||||
|
" </error>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
encrypt_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
||||||
|
{
|
||||||
|
if (ctx->out_of_core)
|
||||||
|
return;
|
||||||
|
if (!ctx->result.encrypt)
|
||||||
|
{
|
||||||
|
ctx->result.encrypt = xtrycalloc (1, sizeof *ctx->result.encrypt);
|
||||||
|
if (!ctx->result.encrypt)
|
||||||
|
{
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
case STATUS_EOF:
|
||||||
|
if (ctx->result.encrypt->xmlinfo) {
|
||||||
|
append_xml_encinfo (&ctx->result.encrypt->xmlinfo, NULL);
|
||||||
|
_gpgme_set_op_info (ctx, ctx->result.encrypt->xmlinfo);
|
||||||
|
ctx->result.encrypt->xmlinfo = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATUS_INV_RECP:
|
||||||
|
append_xml_encinfo (&ctx->result.encrypt->xmlinfo, args);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATUS_NO_RECP:
|
||||||
|
ctx->result.encrypt->no_recipients = 1; /* i.e. no usable ones */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_encrypt_start (GpgmeCtx ctx, GpgmeRecipients recp, GpgmeData plain,
|
||||||
|
GpgmeData ciph)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
fail_on_pending_request (ctx);
|
||||||
|
ctx->pending = 1;
|
||||||
|
|
||||||
|
_gpgme_release_result (ctx);
|
||||||
|
ctx->out_of_core = 0;
|
||||||
|
|
||||||
|
/* Do some checks. */
|
||||||
|
if (!gpgme_recipients_count (recp))
|
||||||
|
{
|
||||||
|
/* Fixme: In this case we should do symmentric encryption. */
|
||||||
|
err = mk_error (No_Recipients);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create an engine object. */
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS
|
||||||
|
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
_gpgme_engine_set_status_handler (ctx->engine, encrypt_status_handler, ctx);
|
||||||
|
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||||
|
|
||||||
|
/* Check the supplied data */
|
||||||
|
if (gpgme_data_get_type (plain) == GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (No_Data);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
_gpgme_data_set_mode (plain, GPGME_DATA_MODE_OUT);
|
||||||
|
if (!ciph || gpgme_data_get_type (ciph) != GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (Invalid_Value);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
_gpgme_data_set_mode (ciph, GPGME_DATA_MODE_IN);
|
||||||
|
|
||||||
|
err = _gpgme_engine_op_encrypt (ctx->engine, recp, plain, ciph, ctx->use_armor);
|
||||||
|
|
||||||
|
|
||||||
|
if (!err) /* And kick off the process. */
|
||||||
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
ctx->pending = 0;
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_encrypt:
|
||||||
|
* @c: The context
|
||||||
|
* @recp: A set of recipients
|
||||||
|
* @in: plaintext input
|
||||||
|
* @out: ciphertext output
|
||||||
|
*
|
||||||
|
* This function encrypts @in to @out for all recipients from
|
||||||
|
* @recp. Other parameters are take from the context @c.
|
||||||
|
* The function does wait for the result.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an errorcode.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_encrypt ( GpgmeCtx c, GpgmeRecipients recp,
|
||||||
|
GpgmeData in, GpgmeData out )
|
||||||
|
{
|
||||||
|
int err = gpgme_op_encrypt_start ( c, recp, in, out );
|
||||||
|
if ( !err ) {
|
||||||
|
gpgme_wait (c, 1);
|
||||||
|
if (!c->result.encrypt)
|
||||||
|
err = mk_error (General_Error);
|
||||||
|
else if (c->out_of_core)
|
||||||
|
err = mk_error (Out_Of_Core);
|
||||||
|
else {
|
||||||
|
if (c->result.encrypt->no_recipients)
|
||||||
|
err = mk_error (No_Recipients);
|
||||||
|
}
|
||||||
|
c->pending = 0;
|
||||||
|
/* Old gpg versions don't return status info for invalid
|
||||||
|
* recipients, so we simply check whether we got any output at
|
||||||
|
* all and if not assume that we don't have valid recipients
|
||||||
|
* */
|
||||||
|
if (!err && gpgme_data_get_type (out) == GPGME_DATA_TYPE_NONE)
|
||||||
|
err = mk_error (No_Recipients);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
826
tags/gpgme-0-3-0/gpgme/engine-gpgsm.c
Normal file
826
tags/gpgme-0-3-0/gpgme/engine-gpgsm.c
Normal file
@ -0,0 +1,826 @@
|
|||||||
|
/* engine-gpgsm.c - GpgSM engine
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* FIXME: Correct check? */
|
||||||
|
#ifdef GPGSM_PATH
|
||||||
|
#define ENABLE_GPGSM 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPGSM
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <fcntl.h> /* FIXME */
|
||||||
|
|
||||||
|
#include "rungpg.h"
|
||||||
|
#include "status-table.h"
|
||||||
|
|
||||||
|
#include "gpgme.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "ops.h"
|
||||||
|
#include "wait.h"
|
||||||
|
#include "io.h"
|
||||||
|
#include "key.h"
|
||||||
|
|
||||||
|
#include "engine-gpgsm.h"
|
||||||
|
|
||||||
|
#include "assuan.h"
|
||||||
|
|
||||||
|
#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
|
||||||
|
*(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
|
||||||
|
#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
|
||||||
|
|
||||||
|
|
||||||
|
struct gpgsm_object_s
|
||||||
|
{
|
||||||
|
ASSUAN_CONTEXT assuan_ctx;
|
||||||
|
|
||||||
|
/* Input, output etc are from the servers perspective. */
|
||||||
|
int input_fd;
|
||||||
|
int input_fd_server;
|
||||||
|
GpgmeData input_data;
|
||||||
|
int output_fd;
|
||||||
|
int output_fd_server;
|
||||||
|
GpgmeData output_data;
|
||||||
|
int message_fd;
|
||||||
|
int message_fd_server;
|
||||||
|
GpgmeData message_data;
|
||||||
|
|
||||||
|
char *command;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
GpgStatusHandler fnc;
|
||||||
|
void *fnc_value;
|
||||||
|
} status;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
GpgColonLineHandler fnc;
|
||||||
|
void *fnc_value;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned char *line;
|
||||||
|
int linesize;
|
||||||
|
int linelen;
|
||||||
|
} attic;
|
||||||
|
} colon;
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *
|
||||||
|
_gpgme_gpgsm_get_version (void)
|
||||||
|
{
|
||||||
|
static const char *gpgsm_version;
|
||||||
|
|
||||||
|
/* FIXME: Locking. */
|
||||||
|
if (!gpgsm_version)
|
||||||
|
gpgsm_version = _gpgme_get_program_version (_gpgme_get_gpgsm_path ());
|
||||||
|
|
||||||
|
return gpgsm_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_check_version (void)
|
||||||
|
{
|
||||||
|
return _gpgme_compare_versions (_gpgme_gpgsm_get_version (),
|
||||||
|
NEED_GPGSM_VERSION)
|
||||||
|
? 0 : mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
close_notify_handler (int fd, void *opaque)
|
||||||
|
{
|
||||||
|
GpgsmObject gpgsm = opaque;
|
||||||
|
|
||||||
|
assert (fd != -1);
|
||||||
|
if (gpgsm->input_fd == fd)
|
||||||
|
gpgsm->input_fd = -1;
|
||||||
|
else if (gpgsm->output_fd == fd)
|
||||||
|
gpgsm->output_fd = -1;
|
||||||
|
else if (gpgsm->message_fd == fd)
|
||||||
|
gpgsm->message_fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_new (GpgsmObject *r_gpgsm)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
GpgsmObject gpgsm;
|
||||||
|
char *argv[] = { "gpgsm", "--server", NULL };
|
||||||
|
int fds[2];
|
||||||
|
int child_fds[4];
|
||||||
|
|
||||||
|
*r_gpgsm = NULL;
|
||||||
|
gpgsm = xtrycalloc (1, sizeof *gpgsm);
|
||||||
|
if (!gpgsm)
|
||||||
|
{
|
||||||
|
err = mk_error (Out_Of_Core);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpgsm->input_fd = -1;
|
||||||
|
gpgsm->input_fd_server = -1;
|
||||||
|
gpgsm->output_fd = -1;
|
||||||
|
gpgsm->output_fd_server = -1;
|
||||||
|
gpgsm->message_fd = -1;
|
||||||
|
gpgsm->message_fd_server = -1;
|
||||||
|
|
||||||
|
gpgsm->status.fnc = 0;
|
||||||
|
gpgsm->colon.fnc = 0;
|
||||||
|
gpgsm->colon.attic.line = 0;
|
||||||
|
gpgsm->colon.attic.linesize = 0;
|
||||||
|
gpgsm->colon.attic.linelen = 0;
|
||||||
|
|
||||||
|
if (_gpgme_io_pipe (fds, 0) < 0)
|
||||||
|
{
|
||||||
|
err = mk_error (General_Error);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
gpgsm->input_fd = fds[1];
|
||||||
|
gpgsm->input_fd_server = fds[0];
|
||||||
|
|
||||||
|
if (_gpgme_io_pipe (fds, 1) < 0)
|
||||||
|
{
|
||||||
|
err = mk_error (General_Error);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
gpgsm->output_fd = fds[0];
|
||||||
|
gpgsm->output_fd_server = fds[1];
|
||||||
|
|
||||||
|
if (_gpgme_io_pipe (fds, 0) < 0)
|
||||||
|
{
|
||||||
|
err = mk_error (General_Error);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
gpgsm->message_fd = fds[1];
|
||||||
|
gpgsm->message_fd_server = fds[0];
|
||||||
|
|
||||||
|
child_fds[0] = gpgsm->input_fd_server;
|
||||||
|
child_fds[1] = gpgsm->output_fd_server;
|
||||||
|
child_fds[2] = gpgsm->message_fd_server;
|
||||||
|
child_fds[3] = -1;
|
||||||
|
err = assuan_pipe_connect (&gpgsm->assuan_ctx,
|
||||||
|
_gpgme_get_gpgsm_path (), argv, child_fds);
|
||||||
|
|
||||||
|
if (!err &&
|
||||||
|
(_gpgme_io_set_close_notify (gpgsm->input_fd,
|
||||||
|
close_notify_handler, gpgsm)
|
||||||
|
|| _gpgme_io_set_close_notify (gpgsm->output_fd,
|
||||||
|
close_notify_handler, gpgsm)
|
||||||
|
|| _gpgme_io_set_close_notify (gpgsm->message_fd,
|
||||||
|
close_notify_handler, gpgsm)))
|
||||||
|
{
|
||||||
|
err = mk_error (General_Error);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
leave:
|
||||||
|
/* Close the server ends of the pipes. Our ends are closed in
|
||||||
|
_gpgme_gpgsm_release. */
|
||||||
|
if (gpgsm->input_fd_server != -1)
|
||||||
|
_gpgme_io_close (gpgsm->input_fd_server);
|
||||||
|
if (gpgsm->output_fd_server != -1)
|
||||||
|
_gpgme_io_close (gpgsm->output_fd_server);
|
||||||
|
if (gpgsm->message_fd_server != -1)
|
||||||
|
_gpgme_io_close (gpgsm->message_fd_server);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
_gpgme_gpgsm_release (gpgsm);
|
||||||
|
else
|
||||||
|
*r_gpgsm = gpgsm;
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_gpgsm_release (GpgsmObject gpgsm)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
if (!gpgsm)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pid = assuan_get_pid (gpgsm->assuan_ctx);
|
||||||
|
if (pid != -1)
|
||||||
|
_gpgme_remove_proc_from_wait_queue (pid);
|
||||||
|
|
||||||
|
if (gpgsm->input_fd != -1)
|
||||||
|
_gpgme_io_close (gpgsm->input_fd);
|
||||||
|
if (gpgsm->output_fd != -1)
|
||||||
|
_gpgme_io_close (gpgsm->output_fd);
|
||||||
|
if (gpgsm->message_fd != -1)
|
||||||
|
_gpgme_io_close (gpgsm->message_fd);
|
||||||
|
|
||||||
|
assuan_pipe_disconnect (gpgsm->assuan_ctx);
|
||||||
|
|
||||||
|
xfree (gpgsm->colon.attic.line);
|
||||||
|
xfree (gpgsm->command);
|
||||||
|
xfree (gpgsm);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AssuanError
|
||||||
|
gpgsm_assuan_simple_command (ASSUAN_CONTEXT ctx, char *cmd)
|
||||||
|
{
|
||||||
|
AssuanError err;
|
||||||
|
char *line;
|
||||||
|
size_t linelen;
|
||||||
|
|
||||||
|
err = assuan_write_line (ctx, cmd);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
err = assuan_read_line (ctx, &line, &linelen);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
while (*line == '#' || !linelen);
|
||||||
|
|
||||||
|
if (linelen >= 2
|
||||||
|
&& line[0] == 'O' && line[1] == 'K'
|
||||||
|
&& (line[2] == '\0' || line[2] == ' '))
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return ASSUAN_General_Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define COMMANDLINELEN 40
|
||||||
|
static AssuanError
|
||||||
|
gpgsm_set_fd (ASSUAN_CONTEXT ctx, const char *which, int fd, const char *opt)
|
||||||
|
{
|
||||||
|
char line[COMMANDLINELEN];
|
||||||
|
|
||||||
|
if (opt)
|
||||||
|
snprintf (line, COMMANDLINELEN, "%s FD=%i %s", which, fd, opt);
|
||||||
|
else
|
||||||
|
snprintf (line, COMMANDLINELEN, "%s FD=%i", which, fd);
|
||||||
|
|
||||||
|
return gpgsm_assuan_simple_command (ctx, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_decrypt (GpgsmObject gpgsm, GpgmeData ciph, GpgmeData plain)
|
||||||
|
{
|
||||||
|
AssuanError err;
|
||||||
|
|
||||||
|
if (!gpgsm)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
gpgsm->command = xtrystrdup ("DECRYPT");
|
||||||
|
if (!gpgsm->command)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
|
gpgsm->input_data = ciph;
|
||||||
|
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error); /* FIXME */
|
||||||
|
gpgsm->output_data = plain;
|
||||||
|
err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, 0);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error); /* FIXME */
|
||||||
|
_gpgme_io_close (gpgsm->message_fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_delete (GpgsmObject gpgsm, GpgmeKey key, int allow_secret)
|
||||||
|
{
|
||||||
|
/* FIXME */
|
||||||
|
return mk_error (Not_Implemented);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AssuanError
|
||||||
|
gpgsm_set_recipients (ASSUAN_CONTEXT ctx, GpgmeRecipients recp)
|
||||||
|
{
|
||||||
|
AssuanError err;
|
||||||
|
char *line;
|
||||||
|
int linelen;
|
||||||
|
struct user_id_s *r;
|
||||||
|
|
||||||
|
linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */
|
||||||
|
line = xtrymalloc (10 + 40 + 1);
|
||||||
|
if (!line)
|
||||||
|
return ASSUAN_Out_Of_Core;
|
||||||
|
strcpy (line, "RECIPIENT ");
|
||||||
|
for (r = recp->list; r; r = r->next)
|
||||||
|
{
|
||||||
|
int newlen = 11 + strlen (r->name);
|
||||||
|
if (linelen < newlen)
|
||||||
|
{
|
||||||
|
char *newline = xtryrealloc (line, newlen);
|
||||||
|
if (! newline)
|
||||||
|
{
|
||||||
|
xfree (line);
|
||||||
|
return ASSUAN_Out_Of_Core;
|
||||||
|
}
|
||||||
|
line = newline;
|
||||||
|
linelen = newlen;
|
||||||
|
}
|
||||||
|
strcpy (&line[10], r->name);
|
||||||
|
|
||||||
|
err = gpgsm_assuan_simple_command (ctx, line);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
xfree (line);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xfree (line);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_encrypt (GpgsmObject gpgsm, GpgmeRecipients recp,
|
||||||
|
GpgmeData plain, GpgmeData ciph, int use_armor)
|
||||||
|
{
|
||||||
|
AssuanError err;
|
||||||
|
|
||||||
|
if (!gpgsm)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
gpgsm->command = xtrystrdup ("ENCRYPT");
|
||||||
|
if (!gpgsm->command)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
|
gpgsm->input_data = plain;
|
||||||
|
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error); /* FIXME */
|
||||||
|
gpgsm->output_data = ciph;
|
||||||
|
err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server,
|
||||||
|
use_armor ? "--armor" : 0);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error); /* FIXME */
|
||||||
|
_gpgme_io_close (gpgsm->message_fd);
|
||||||
|
|
||||||
|
err = gpgsm_set_recipients (gpgsm->assuan_ctx, recp);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp,
|
||||||
|
GpgmeData keydata, int use_armor)
|
||||||
|
{
|
||||||
|
/* FIXME */
|
||||||
|
return mk_error (Not_Implemented);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data, int use_armor)
|
||||||
|
{
|
||||||
|
/* FIXME */
|
||||||
|
return mk_error (Not_Implemented);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_import (GpgsmObject gpgsm, GpgmeData keydata)
|
||||||
|
{
|
||||||
|
AssuanError err;
|
||||||
|
|
||||||
|
if (!gpgsm)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
gpgsm->command = xtrystrdup ("IMPORT");
|
||||||
|
if (!gpgsm->command)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
|
gpgsm->input_data = keydata;
|
||||||
|
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error); /* FIXME */
|
||||||
|
_gpgme_io_close (gpgsm->output_fd);
|
||||||
|
_gpgme_io_close (gpgsm->message_fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_keylist (GpgsmObject gpgsm, const char *pattern,
|
||||||
|
int secret_only, int keylist_mode)
|
||||||
|
{
|
||||||
|
char *line;
|
||||||
|
|
||||||
|
if (!pattern)
|
||||||
|
pattern = "";
|
||||||
|
|
||||||
|
line = xtrymalloc (9 + strlen (pattern) + 1); /* "LISTKEYS " + p + '\0'. */
|
||||||
|
if (!line)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
strcpy (line, "LISTKEYS ");
|
||||||
|
strcpy (&line[9], pattern);
|
||||||
|
|
||||||
|
_gpgme_io_close (gpgsm->input_fd);
|
||||||
|
_gpgme_io_close (gpgsm->output_fd);
|
||||||
|
_gpgme_io_close (gpgsm->message_fd);
|
||||||
|
|
||||||
|
gpgsm->command = line;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_sign (GpgsmObject gpgsm, GpgmeData in, GpgmeData out,
|
||||||
|
GpgmeSigMode mode, int use_armor,
|
||||||
|
int use_textmode, GpgmeCtx ctx /* FIXME */)
|
||||||
|
{
|
||||||
|
AssuanError err;
|
||||||
|
|
||||||
|
if (!gpgsm)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
gpgsm->command = xtrystrdup (mode == GPGME_SIG_MODE_DETACH
|
||||||
|
? "SIGN --detached" : "SIGN");
|
||||||
|
if (!gpgsm->command)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
|
gpgsm->input_data = in;
|
||||||
|
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error); /* FIXME */
|
||||||
|
gpgsm->output_data = out;
|
||||||
|
err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server,
|
||||||
|
use_armor ? "--armor" : 0);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error); /* FIXME */
|
||||||
|
_gpgme_io_close (gpgsm->message_fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_trustlist (GpgsmObject gpgsm, const char *pattern)
|
||||||
|
{
|
||||||
|
/* FIXME */
|
||||||
|
return mk_error (Not_Implemented);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig, GpgmeData text)
|
||||||
|
{
|
||||||
|
AssuanError err;
|
||||||
|
|
||||||
|
if (!gpgsm)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
gpgsm->command = xtrystrdup ("VERIFY");
|
||||||
|
if (!gpgsm->command)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
|
gpgsm->input_data = sig;
|
||||||
|
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error); /* FIXME */
|
||||||
|
gpgsm->message_data = text;
|
||||||
|
err = gpgsm_set_fd (gpgsm->assuan_ctx, "MESSAGE", gpgsm->message_fd_server,
|
||||||
|
0);
|
||||||
|
if (err)
|
||||||
|
return mk_error (General_Error); /* FIXME */
|
||||||
|
_gpgme_io_close (gpgsm->output_fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
status_cmp (const void *ap, const void *bp)
|
||||||
|
{
|
||||||
|
const struct status_table_s *a = ap;
|
||||||
|
const struct status_table_s *b = bp;
|
||||||
|
|
||||||
|
return strcmp (a->name, b->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
gpgsm_status_handler (void *opaque, int pid, int fd)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
GpgsmObject gpgsm = opaque;
|
||||||
|
char *line;
|
||||||
|
size_t linelen;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
err = assuan_read_line (gpgsm->assuan_ctx, &line, &linelen);
|
||||||
|
|
||||||
|
if (err
|
||||||
|
|| (linelen >= 2
|
||||||
|
&& line[0] == 'O' && line[1] == 'K'
|
||||||
|
&& (line[2] == '\0' || line[2] == ' '))
|
||||||
|
|| (linelen >= 3
|
||||||
|
&& line[0] == 'E' && line[1] == 'R' && line[2] == 'R'
|
||||||
|
&& (line[3] == '\0' || line[3] == ' ')))
|
||||||
|
{
|
||||||
|
/* FIXME Save error somewhere. */
|
||||||
|
if (gpgsm->status.fnc)
|
||||||
|
gpgsm->status.fnc (gpgsm->status.fnc_value, STATUS_EOF, "");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linelen > 2
|
||||||
|
&& line[0] == 'D' && line[1] == ' '
|
||||||
|
&& gpgsm->colon.fnc)
|
||||||
|
{
|
||||||
|
/* We are using the colon handler even for plain inline data
|
||||||
|
- strange name for that function but for historic reasons
|
||||||
|
we keep it. */
|
||||||
|
/* FIXME We can't use this for binary data because we
|
||||||
|
assume this is a string. For the current usage of colon
|
||||||
|
output it is correct. */
|
||||||
|
unsigned char *src = line + 2;
|
||||||
|
unsigned char *end = line + linelen;
|
||||||
|
unsigned char *dst;
|
||||||
|
unsigned char **aline = &gpgsm->colon.attic.line;
|
||||||
|
int *alinelen = &gpgsm->colon.attic.linelen;
|
||||||
|
|
||||||
|
if (gpgsm->colon.attic.linesize
|
||||||
|
< *alinelen + linelen + 1)
|
||||||
|
{
|
||||||
|
unsigned char *newline = xtryrealloc (*aline,
|
||||||
|
*alinelen + linelen + 1);
|
||||||
|
if (!newline)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
*aline = newline;
|
||||||
|
gpgsm->colon.attic.linesize += linelen + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst = *aline + *alinelen;
|
||||||
|
|
||||||
|
while (src < end)
|
||||||
|
{
|
||||||
|
if (*src == '%' && src + 2 < end)
|
||||||
|
{
|
||||||
|
/* Handle escaped characters. */
|
||||||
|
++src;
|
||||||
|
*dst = xtoi_2 (src);
|
||||||
|
(*alinelen)++;
|
||||||
|
src += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*dst = *src++;
|
||||||
|
(*alinelen)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*dst == '\n')
|
||||||
|
{
|
||||||
|
/* Terminate the pending line, pass it to the colon
|
||||||
|
handler and reset it. */
|
||||||
|
|
||||||
|
if (*alinelen > 1 && *(dst - 1) == '\r')
|
||||||
|
dst--;
|
||||||
|
*dst = '\0';
|
||||||
|
|
||||||
|
/* FIXME How should we handle the return code? */
|
||||||
|
gpgsm->colon.fnc (gpgsm->colon.fnc_value, *aline);
|
||||||
|
dst = *aline;
|
||||||
|
*alinelen = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (linelen > 2
|
||||||
|
&& line[0] == 'S' && line[1] == ' ')
|
||||||
|
{
|
||||||
|
struct status_table_s t, *r;
|
||||||
|
char *rest;
|
||||||
|
|
||||||
|
rest = strchr (line + 2, ' ');
|
||||||
|
if (!rest)
|
||||||
|
rest = line + linelen; /* set to an empty string */
|
||||||
|
else
|
||||||
|
*rest++ = 0;
|
||||||
|
|
||||||
|
t.name = line + 2;
|
||||||
|
r = bsearch (&t, status_table, DIM(status_table) - 1,
|
||||||
|
sizeof t, status_cmp);
|
||||||
|
|
||||||
|
if (r)
|
||||||
|
{
|
||||||
|
if (gpgsm->status.fnc)
|
||||||
|
gpgsm->status.fnc (gpgsm->status.fnc_value, r->code, rest);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf (stderr, "[UNKNOWN STATUS]%s %s", t.name, rest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (assuan_pending_line (gpgsm->assuan_ctx));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_gpgsm_set_status_handler (GpgsmObject gpgsm,
|
||||||
|
GpgStatusHandler fnc, void *fnc_value)
|
||||||
|
{
|
||||||
|
assert (gpgsm);
|
||||||
|
|
||||||
|
gpgsm->status.fnc = fnc;
|
||||||
|
gpgsm->status.fnc_value = fnc_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_gpgsm_set_colon_line_handler (GpgsmObject gpgsm,
|
||||||
|
GpgColonLineHandler fnc, void *fnc_value)
|
||||||
|
{
|
||||||
|
assert (gpgsm);
|
||||||
|
|
||||||
|
gpgsm->colon.fnc = fnc;
|
||||||
|
gpgsm->colon.fnc_value = fnc_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_start (GpgsmObject gpgsm, void *opaque)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
pid_t pid;
|
||||||
|
int fdlist[5];
|
||||||
|
int nfds;
|
||||||
|
|
||||||
|
if (!gpgsm)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
pid = assuan_get_pid (gpgsm->assuan_ctx);
|
||||||
|
|
||||||
|
/* We need to know the fd used by assuan for reads. We do this by
|
||||||
|
using the assumption that the first returned fd from
|
||||||
|
assuan_get_active_fds() is always this one. */
|
||||||
|
nfds = assuan_get_active_fds (gpgsm->assuan_ctx, 0 /* read fds */,
|
||||||
|
fdlist, DIM (fdlist));
|
||||||
|
if (nfds < 1)
|
||||||
|
return mk_error (General_Error);
|
||||||
|
err = _gpgme_register_pipe_handler (opaque, gpgsm_status_handler, gpgsm, pid,
|
||||||
|
fdlist[0], 1);
|
||||||
|
|
||||||
|
|
||||||
|
if (gpgsm->input_fd != -1)
|
||||||
|
{
|
||||||
|
err = _gpgme_register_pipe_handler (opaque, _gpgme_data_outbound_handler,
|
||||||
|
gpgsm->input_data, pid,
|
||||||
|
gpgsm->input_fd, 0);
|
||||||
|
if (!err) /* FIXME Kludge around poll() problem. */
|
||||||
|
err = _gpgme_io_set_nonblocking (gpgsm->input_fd);
|
||||||
|
}
|
||||||
|
if (!err && gpgsm->output_fd != -1)
|
||||||
|
err = _gpgme_register_pipe_handler (opaque, _gpgme_data_inbound_handler,
|
||||||
|
gpgsm->output_data, pid,
|
||||||
|
gpgsm->output_fd, 1);
|
||||||
|
if (!err && gpgsm->message_fd != -1)
|
||||||
|
{
|
||||||
|
err = _gpgme_register_pipe_handler (opaque, _gpgme_data_outbound_handler,
|
||||||
|
gpgsm->message_data, pid,
|
||||||
|
gpgsm->message_fd, 0);
|
||||||
|
if (!err) /* FIXME Kludge around poll() problem. */
|
||||||
|
err = _gpgme_io_set_nonblocking (gpgsm->message_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!err)
|
||||||
|
err = assuan_write_line (gpgsm->assuan_ctx, gpgsm->command);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* ENABLE_GPGSM */
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#include "engine-gpgsm.h"
|
||||||
|
|
||||||
|
const char *
|
||||||
|
_gpgme_gpgsm_get_version (void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_check_version (void)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_new (GpgsmObject *r_gpgsm)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_gpgsm_release (GpgsmObject gpgsm)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_gpgsm_set_status_handler (GpgsmObject gpgsm,
|
||||||
|
GpgStatusHandler fnc, void *fnc_value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_decrypt (GpgsmObject gpgsm, GpgmeData ciph, GpgmeData plain)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_delete (GpgsmObject gpgsm, GpgmeKey key, int allow_secret)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_encrypt (GpgsmObject gpgsm, GpgmeRecipients recp,
|
||||||
|
GpgmeData plain, GpgmeData ciph, int use_armor)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp,
|
||||||
|
GpgmeData keydata, int use_armor)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data, int use_armor)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_import (GpgsmObject gpgsm, GpgmeData keydata)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_keylist (GpgsmObject gpgsm, const char *pattern,
|
||||||
|
int secret_only, int keylist_mode)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_sign (GpgsmObject gpgsm, GpgmeData in, GpgmeData out,
|
||||||
|
GpgmeSigMode mode, int use_armor,
|
||||||
|
int use_textmode, GpgmeCtx ctx /* FIXME */)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_trustlist (GpgsmObject gpgsm, const char *pattern)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig, GpgmeData text)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_gpgsm_set_colon_line_handler (GpgsmObject gpgsm,
|
||||||
|
GpgColonLineHandler fnc, void *fnc_value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_gpgsm_start (GpgsmObject gpgsm, void *opaque)
|
||||||
|
{
|
||||||
|
return mk_error (Invalid_Engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ! ENABLE_GPGSM */
|
65
tags/gpgme-0-3-0/gpgme/engine-gpgsm.h
Normal file
65
tags/gpgme-0-3-0/gpgme/engine-gpgsm.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/* engine-gpgsm.h - GPGME GpgSM engine calling functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 ENGINE_GPGSM_H
|
||||||
|
#define ENGINE_GPGSM_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
#include "rungpg.h" /* FIXME statusHandler */
|
||||||
|
|
||||||
|
const char *_gpgme_gpgsm_get_version (void);
|
||||||
|
GpgmeError _gpgme_gpgsm_check_version (void);
|
||||||
|
|
||||||
|
GpgmeError _gpgme_gpgsm_new (GpgsmObject *r_gpg);
|
||||||
|
void _gpgme_gpgsm_release (GpgsmObject gpg);
|
||||||
|
|
||||||
|
void _gpgme_gpgsm_set_status_handler (GpgsmObject gpgsm,
|
||||||
|
GpgStatusHandler fnc, void *fnc_value);
|
||||||
|
void _gpgme_gpgsm_set_colon_line_handler (GpgsmObject gpgsm,
|
||||||
|
GpgColonLineHandler fnc, void *fnc_value) ;
|
||||||
|
GpgmeError _gpgme_gpgsm_op_decrypt (GpgsmObject gpgsm, GpgmeData ciph,
|
||||||
|
GpgmeData plain);
|
||||||
|
GpgmeError _gpgme_gpgsm_op_delete (GpgsmObject gpgsm, GpgmeKey key,
|
||||||
|
int allow_secret);
|
||||||
|
GpgmeError _gpgme_gpgsm_op_encrypt (GpgsmObject gpgsm, GpgmeRecipients recp,
|
||||||
|
GpgmeData plain, GpgmeData ciph,
|
||||||
|
int use_armor);
|
||||||
|
GpgmeError _gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp,
|
||||||
|
GpgmeData keydata, int use_armor);
|
||||||
|
GpgmeError _gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data,
|
||||||
|
int use_armor);
|
||||||
|
GpgmeError _gpgme_gpgsm_op_import (GpgsmObject gpgsm, GpgmeData keydata);
|
||||||
|
GpgmeError _gpgme_gpgsm_op_keylist (GpgsmObject gpgsm, const char *pattern,
|
||||||
|
int secret_only, int keylist_mode);
|
||||||
|
GpgmeError _gpgme_gpgsm_op_sign (GpgsmObject gpgsm, GpgmeData in,
|
||||||
|
GpgmeData out,
|
||||||
|
GpgmeSigMode mode, int use_armor,
|
||||||
|
int use_textmode, GpgmeCtx ctx /* FIXME */);
|
||||||
|
GpgmeError _gpgme_gpgsm_op_trustlist (GpgsmObject gpgsm, const char *pattern);
|
||||||
|
GpgmeError _gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig,
|
||||||
|
GpgmeData text);
|
||||||
|
GpgmeError _gpgme_gpgsm_start (GpgsmObject gpgsm, void *opaque);
|
||||||
|
|
||||||
|
#endif /* ENGINE_GPGSM_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
589
tags/gpgme-0-3-0/gpgme/engine.c
Normal file
589
tags/gpgme-0-3-0/gpgme/engine.c
Normal file
@ -0,0 +1,589 @@
|
|||||||
|
/* engine.c
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "gpgme.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "sema.h"
|
||||||
|
#include "io.h"
|
||||||
|
|
||||||
|
#include "engine.h"
|
||||||
|
#include "rungpg.h"
|
||||||
|
#include "engine-gpgsm.h"
|
||||||
|
|
||||||
|
struct engine_object_s
|
||||||
|
{
|
||||||
|
GpgmeProtocol protocol;
|
||||||
|
|
||||||
|
const char *path;
|
||||||
|
const char *version;
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
GpgObject gpg;
|
||||||
|
GpgsmObject gpgsm;
|
||||||
|
} engine;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct reap_s
|
||||||
|
{
|
||||||
|
struct reap_s *next;
|
||||||
|
int pid;
|
||||||
|
time_t entered;
|
||||||
|
int term_send;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct reap_s *reap_list;
|
||||||
|
DEFINE_STATIC_LOCK (reap_list_lock);
|
||||||
|
|
||||||
|
/* Get the path of the engine for PROTOCOL. */
|
||||||
|
const char *
|
||||||
|
_gpgme_engine_get_path (GpgmeProtocol proto)
|
||||||
|
{
|
||||||
|
switch (proto)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_get_gpg_path ();
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_get_gpgsm_path ();
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the version number of the engine for PROTOCOL. */
|
||||||
|
const char *
|
||||||
|
_gpgme_engine_get_version (GpgmeProtocol proto)
|
||||||
|
{
|
||||||
|
switch (proto)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_get_version ();
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_get_version ();
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_engine_check_version (GpgmeProtocol proto)
|
||||||
|
{
|
||||||
|
switch (proto)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_check_version ();
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_check_version ();
|
||||||
|
default:
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
_gpgme_engine_get_info (GpgmeProtocol proto)
|
||||||
|
{
|
||||||
|
static const char fmt[] = " <engine>\n"
|
||||||
|
" <protocol>%s</protocol>\n"
|
||||||
|
" <version>%s</version>\n"
|
||||||
|
" <path>%s</path>\n"
|
||||||
|
" </engine>\n";
|
||||||
|
static const char *const strproto[3] = { "OpenPGP", "CMS", NULL };
|
||||||
|
static const char *engine_info[3]; /* FIXME: MAX_PROTO + 1*/
|
||||||
|
const char *path;
|
||||||
|
const char *version;
|
||||||
|
char *info;
|
||||||
|
|
||||||
|
if (proto > 2 /* FIXME MAX_PROTO */ || !strproto[proto])
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* FIXME: Make sure that only one instance does run. */
|
||||||
|
if (engine_info[proto])
|
||||||
|
return engine_info[proto];
|
||||||
|
|
||||||
|
path = _gpgme_engine_get_path (proto);
|
||||||
|
version = _gpgme_engine_get_version (proto);
|
||||||
|
|
||||||
|
if (!path || !version)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
info = xtrymalloc (strlen(fmt) + strlen(strproto[proto]) + strlen(path)
|
||||||
|
+ strlen (version) + 1);
|
||||||
|
if (!info)
|
||||||
|
info = " <engine>\n"
|
||||||
|
" <error>Out of core</error>\n"
|
||||||
|
" </engine>";
|
||||||
|
else
|
||||||
|
sprintf (info, fmt, strproto[proto], version, path);
|
||||||
|
engine_info[proto] = info;
|
||||||
|
|
||||||
|
return engine_info[proto];
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_new (GpgmeProtocol proto, EngineObject *r_engine)
|
||||||
|
{
|
||||||
|
EngineObject engine;
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
engine = xtrycalloc (1, sizeof *engine);
|
||||||
|
if (!engine)
|
||||||
|
{
|
||||||
|
err = mk_error (Out_Of_Core);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
engine->protocol = proto;
|
||||||
|
switch (proto)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
err =_gpgme_gpg_new (&engine->engine.gpg);
|
||||||
|
break;
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
err = _gpgme_gpgsm_new (&engine->engine.gpgsm);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
err = mk_error (Invalid_Value);
|
||||||
|
}
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
engine->path = _gpgme_engine_get_path (proto);
|
||||||
|
engine->version = _gpgme_engine_get_version (proto);
|
||||||
|
|
||||||
|
if (!engine->path || !engine->version)
|
||||||
|
{
|
||||||
|
err = mk_error (Invalid_Engine);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err)
|
||||||
|
_gpgme_engine_release (engine);
|
||||||
|
else
|
||||||
|
*r_engine = engine;
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_engine_release (EngineObject engine)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
_gpgme_gpg_release (engine->engine.gpg);
|
||||||
|
break;
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
_gpgme_gpgsm_release (engine->engine.gpgsm);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
xfree (engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_engine_set_verbosity (EngineObject engine, int verbosity)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
while (verbosity-- > 0)
|
||||||
|
_gpgme_gpg_add_arg (engine->engine.gpg, "--verbose");
|
||||||
|
break;
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
/* FIXME */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_engine_set_status_handler (EngineObject engine,
|
||||||
|
GpgStatusHandler fnc, void *fnc_value)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
_gpgme_gpg_set_status_handler (engine->engine.gpg, fnc, fnc_value);
|
||||||
|
break;
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
_gpgme_gpgsm_set_status_handler (engine->engine.gpgsm, fnc, fnc_value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_set_command_handler (EngineObject engine,
|
||||||
|
GpgCommandHandler fnc, void *fnc_value)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_set_command_handler (engine->engine.gpg, fnc, fnc_value);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
/* FIXME */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError _gpgme_engine_set_colon_line_handler (EngineObject engine,
|
||||||
|
GpgColonLineHandler fnc,
|
||||||
|
void *fnc_value)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_set_colon_line_handler (engine->engine.gpg,
|
||||||
|
fnc, fnc_value);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
_gpgme_gpgsm_set_colon_line_handler (engine->engine.gpgsm,
|
||||||
|
fnc, fnc_value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_decrypt (EngineObject engine, GpgmeData ciph, GpgmeData plain)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_decrypt (engine->engine.gpg, ciph, plain);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_decrypt (engine->engine.gpgsm, ciph, plain);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_delete (EngineObject engine, GpgmeKey key, int allow_secret)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_delete (engine->engine.gpg, key, allow_secret);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_delete (engine->engine.gpgsm, key, allow_secret);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_encrypt (EngineObject engine, GpgmeRecipients recp,
|
||||||
|
GpgmeData plain, GpgmeData ciph, int use_armor)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_encrypt (engine->engine.gpg, recp, plain, ciph,
|
||||||
|
use_armor);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_encrypt (engine->engine.gpgsm, recp, plain, ciph,
|
||||||
|
use_armor);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_export (EngineObject engine, GpgmeRecipients recp,
|
||||||
|
GpgmeData keydata, int use_armor)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_export (engine->engine.gpg, recp, keydata,
|
||||||
|
use_armor);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_export (engine->engine.gpgsm, recp, keydata,
|
||||||
|
use_armor);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_genkey (EngineObject engine, GpgmeData help_data, int use_armor)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_genkey (engine->engine.gpg, help_data, use_armor);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_genkey (engine->engine.gpgsm, help_data, use_armor);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_import (EngineObject engine, GpgmeData keydata)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_import (engine->engine.gpg, keydata);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_import (engine->engine.gpgsm, keydata);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_keylist (EngineObject engine, const char *pattern, int secret_only,
|
||||||
|
int keylist_mode)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_keylist (engine->engine.gpg, pattern, secret_only,
|
||||||
|
keylist_mode);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_keylist (engine->engine.gpgsm, pattern, secret_only,
|
||||||
|
keylist_mode);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_sign (EngineObject engine, GpgmeData in, GpgmeData out,
|
||||||
|
GpgmeSigMode mode, int use_armor,
|
||||||
|
int use_textmode, GpgmeCtx ctx /* FIXME */)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_sign (engine->engine.gpg, in, out, mode, use_armor,
|
||||||
|
use_textmode, ctx);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_sign (engine->engine.gpgsm, in, out, mode,
|
||||||
|
use_armor, use_textmode, ctx);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_trustlist (EngineObject engine, const char *pattern)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_trustlist (engine->engine.gpg, pattern);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_trustlist (engine->engine.gpgsm, pattern);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_op_verify (EngineObject engine, GpgmeData sig, GpgmeData text)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_op_verify (engine->engine.gpg, sig, text);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_op_verify (engine->engine.gpgsm, sig, text);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_engine_start (EngineObject engine, void *opaque)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (engine->protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return _gpgme_gpg_spawn (engine->engine.gpg, opaque);
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return _gpgme_gpgsm_start (engine->engine.gpgsm, opaque);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_engine_add_child_to_reap_list (void *buf, int buflen, pid_t pid)
|
||||||
|
{
|
||||||
|
/* Reuse the memory, so that we don't need to allocate another
|
||||||
|
memory block and to handle errors. */
|
||||||
|
struct reap_s *child = buf;
|
||||||
|
|
||||||
|
assert (buflen >= sizeof *child);
|
||||||
|
memset (child, 0, sizeof *child);
|
||||||
|
child->pid = pid;
|
||||||
|
child->entered = time (NULL);
|
||||||
|
LOCK(reap_list_lock);
|
||||||
|
child->next = reap_list;
|
||||||
|
reap_list = child;
|
||||||
|
UNLOCK(reap_list_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_reaping (void)
|
||||||
|
{
|
||||||
|
struct reap_s *r, *rlast;
|
||||||
|
static time_t last_check;
|
||||||
|
time_t cur_time = time (NULL);
|
||||||
|
|
||||||
|
/* A race does not matter here. */
|
||||||
|
if (!last_check)
|
||||||
|
last_check = time (NULL);
|
||||||
|
|
||||||
|
if (last_check >= cur_time)
|
||||||
|
return; /* We check only every second. */
|
||||||
|
|
||||||
|
/* Fixme: it would be nice if to have a TRYLOCK here. */
|
||||||
|
LOCK (reap_list_lock);
|
||||||
|
for (r = reap_list, rlast = NULL; r; rlast = r, r = r ? r->next : NULL)
|
||||||
|
{
|
||||||
|
int dummy1, dummy2;
|
||||||
|
|
||||||
|
if (_gpgme_io_waitpid (r->pid, 0, &dummy1, &dummy2))
|
||||||
|
{
|
||||||
|
/* The process has terminated - remove it from the queue. */
|
||||||
|
void *p = r;
|
||||||
|
if (!rlast)
|
||||||
|
{
|
||||||
|
reap_list = r->next;
|
||||||
|
r = reap_list;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rlast->next = r->next;
|
||||||
|
r = rlast;
|
||||||
|
}
|
||||||
|
xfree (p);
|
||||||
|
}
|
||||||
|
else if (!r->term_send)
|
||||||
|
{
|
||||||
|
if (r->entered + 1 >= cur_time)
|
||||||
|
{
|
||||||
|
_gpgme_io_kill (r->pid, 0);
|
||||||
|
r->term_send = 1;
|
||||||
|
r->entered = cur_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Give it 5 second before we are going to send the killer. */
|
||||||
|
if (r->entered + 5 >= cur_time)
|
||||||
|
{
|
||||||
|
_gpgme_io_kill (r->pid, 1);
|
||||||
|
r->entered = cur_time; /* Just in case we have to repeat it. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UNLOCK (reap_list_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_engine_housecleaning (void)
|
||||||
|
{
|
||||||
|
do_reaping ();
|
||||||
|
}
|
70
tags/gpgme-0-3-0/gpgme/engine.h
Normal file
70
tags/gpgme-0-3-0/gpgme/engine.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/* engine.h - GPGME engine calling functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 ENGINE_H
|
||||||
|
#define ENGINE_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
#include "rungpg.h"
|
||||||
|
|
||||||
|
const char *_gpgme_engine_get_path (GpgmeProtocol proto);
|
||||||
|
const char *_gpgme_engine_get_version (GpgmeProtocol proto);
|
||||||
|
const char * _gpgme_engine_get_info (GpgmeProtocol proto);
|
||||||
|
GpgmeError _gpgme_engine_new (GpgmeProtocol proto, EngineObject *r_engine);
|
||||||
|
void _gpgme_engine_release (EngineObject engine);
|
||||||
|
void _gpgme_engine_set_status_handler (EngineObject engine,
|
||||||
|
GpgStatusHandler fnc, void *fnc_value);
|
||||||
|
GpgmeError _gpgme_engine_set_command_handler (EngineObject engine,
|
||||||
|
GpgCommandHandler fnc,
|
||||||
|
void *fnc_value);
|
||||||
|
GpgmeError _gpgme_engine_set_colon_line_handler (EngineObject gpg,
|
||||||
|
GpgColonLineHandler fnc,
|
||||||
|
void *fnc_value);
|
||||||
|
void _gpgme_engine_set_verbosity (EngineObject engine, int verbosity);
|
||||||
|
GpgmeError _gpgme_engine_op_decrypt (EngineObject engine, GpgmeData ciph,
|
||||||
|
GpgmeData plain);
|
||||||
|
GpgmeError _gpgme_engine_op_delete (EngineObject engine, GpgmeKey key,
|
||||||
|
int allow_secret);
|
||||||
|
GpgmeError _gpgme_engine_op_encrypt (EngineObject engine, GpgmeRecipients recp,
|
||||||
|
GpgmeData plain, GpgmeData ciph,
|
||||||
|
int use_armor);
|
||||||
|
GpgmeError _gpgme_engine_op_export (EngineObject engine, GpgmeRecipients recp,
|
||||||
|
GpgmeData keydata, int use_armor);
|
||||||
|
GpgmeError _gpgme_engine_op_genkey (EngineObject engine, GpgmeData help_data,
|
||||||
|
int use_armor);
|
||||||
|
GpgmeError _gpgme_engine_op_import (EngineObject engine, GpgmeData keydata);
|
||||||
|
GpgmeError _gpgme_engine_op_keylist (EngineObject engine, const char *pattern,
|
||||||
|
int secret_only,
|
||||||
|
int keylist_mode);
|
||||||
|
GpgmeError _gpgme_engine_op_sign (EngineObject engine, GpgmeData in,
|
||||||
|
GpgmeData out, GpgmeSigMode mode,
|
||||||
|
int use_armor, int use_textmode,
|
||||||
|
GpgmeCtx ctx /* FIXME */);
|
||||||
|
GpgmeError _gpgme_engine_op_trustlist (EngineObject engine,
|
||||||
|
const char *pattern);
|
||||||
|
GpgmeError _gpgme_engine_op_verify (EngineObject engine, GpgmeData sig,
|
||||||
|
GpgmeData text);
|
||||||
|
GpgmeError _gpgme_engine_start (EngineObject engine, void *opaque);
|
||||||
|
|
||||||
|
void _gpgme_engine_add_child_to_reap_list (void *buf, int buflen, pid_t pid);
|
||||||
|
void _gpgme_engine_housecleaning (void);
|
||||||
|
|
||||||
|
#endif /* ENGINE_H */
|
105
tags/gpgme-0-3-0/gpgme/export.c
Normal file
105
tags/gpgme-0-3-0/gpgme/export.c
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/* export.c - encrypt functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
export_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
||||||
|
{
|
||||||
|
DEBUG2 ("export_status: code=%d args=`%s'\n", code, args );
|
||||||
|
/* FIXME: Need to do more */
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_export_start (GpgmeCtx ctx, GpgmeRecipients recp, GpgmeData keydata)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
fail_on_pending_request (ctx);
|
||||||
|
ctx->pending = 1;
|
||||||
|
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
|
||||||
|
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS
|
||||||
|
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
if (!keydata || gpgme_data_get_type (keydata) != GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (Invalid_Value);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
_gpgme_data_set_mode (keydata, GPGME_DATA_MODE_IN);
|
||||||
|
|
||||||
|
_gpgme_engine_set_status_handler (ctx->engine, export_status_handler, ctx);
|
||||||
|
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||||
|
|
||||||
|
err = _gpgme_engine_op_export (ctx->engine, recp, keydata, ctx->use_armor);
|
||||||
|
if (!err)
|
||||||
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
ctx->pending = 0;
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_export:
|
||||||
|
* @c: the context
|
||||||
|
* @recp: a list of recipients or NULL
|
||||||
|
* @keydata: Returns the keys
|
||||||
|
*
|
||||||
|
* This function can be used to extract public keys from the GnuPG key
|
||||||
|
* database either in armored (by using gpgme_set_armor()) or in plain
|
||||||
|
* binary form. The function expects a list of user IDs in @recp for
|
||||||
|
* whom the public keys are to be exportedkinit
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Return value: 0 for success or an error code
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_export ( GpgmeCtx c, GpgmeRecipients recp, GpgmeData keydata )
|
||||||
|
{
|
||||||
|
int rc = gpgme_op_export_start ( c, recp, keydata );
|
||||||
|
if ( !rc ) {
|
||||||
|
gpgme_wait (c, 1);
|
||||||
|
c->pending = 0;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
221
tags/gpgme-0-3-0/gpgme/genkey.c
Normal file
221
tags/gpgme-0-3-0/gpgme/genkey.c
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
/* genkey.c - key generation
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
genkey_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
||||||
|
{
|
||||||
|
if ( code == STATUS_PROGRESS && *args ) {
|
||||||
|
if (ctx->progress_cb) {
|
||||||
|
char *p;
|
||||||
|
int type=0, current=0, total=0;
|
||||||
|
|
||||||
|
if ( (p = strchr (args, ' ')) ) {
|
||||||
|
*p++ = 0;
|
||||||
|
if (*p) {
|
||||||
|
type = *(byte*)p;
|
||||||
|
if ( (p = strchr (p+1, ' ')) ) {
|
||||||
|
*p++ = 0;
|
||||||
|
if (*p) {
|
||||||
|
current = atoi (p);
|
||||||
|
if ( (p = strchr (p+1, ' ')) ) {
|
||||||
|
*p++ = 0;
|
||||||
|
total = atoi (p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( type != 'X' )
|
||||||
|
ctx->progress_cb ( ctx->progress_cb_value, args, type,
|
||||||
|
current, total );
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG2 ("genkey_status: code=%d args=`%s'\n", code, args );
|
||||||
|
/* FIXME: Need to do more */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_genkey:
|
||||||
|
* @c: the context
|
||||||
|
* @parms: XML string with the key parameters
|
||||||
|
* @pubkey: Returns the public key
|
||||||
|
* @seckey: Returns the secret key
|
||||||
|
*
|
||||||
|
* Generate a new key and store the key in the default keyrings if
|
||||||
|
* both @pubkey and @seckey are NULL. If @pubkey and @seckey are
|
||||||
|
* given, the newly created key will be returned in these data
|
||||||
|
* objects. This function just starts the gheneration and does not
|
||||||
|
* wait for completion.
|
||||||
|
*
|
||||||
|
* Here is an example on how @parms should be formatted; for deatils
|
||||||
|
* see the file doc/DETAILS from the GnuPG distribution.
|
||||||
|
*
|
||||||
|
* <literal>
|
||||||
|
* <![CDATA[
|
||||||
|
* <GnupgKeyParms format="internal">
|
||||||
|
* Key-Type: DSA
|
||||||
|
* Key-Length: 1024
|
||||||
|
* Subkey-Type: ELG-E
|
||||||
|
* Subkey-Length: 1024
|
||||||
|
* Name-Real: Joe Tester
|
||||||
|
* Name-Comment: with stupid passphrase
|
||||||
|
* Name-Email: joe@foo.bar
|
||||||
|
* Expire-Date: 0
|
||||||
|
* Passphrase: abc
|
||||||
|
* </GnupgKeyParms>
|
||||||
|
* ]]>
|
||||||
|
* </literal>
|
||||||
|
*
|
||||||
|
* Strings should be given in UTF-8 encoding. The format we support
|
||||||
|
* for now is only "internal". The content of the
|
||||||
|
* <GnupgKeyParms> container is passed verbatim to GnuPG.
|
||||||
|
* Control statements are not allowed.
|
||||||
|
*
|
||||||
|
* Return value: 0 for success or an error code
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_genkey_start (GpgmeCtx ctx, const char *parms,
|
||||||
|
GpgmeData pubkey, GpgmeData seckey)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
const char *s, *s2, *sx;
|
||||||
|
|
||||||
|
fail_on_pending_request (ctx);
|
||||||
|
ctx->pending = 1;
|
||||||
|
|
||||||
|
gpgme_data_release (ctx->help_data_1);
|
||||||
|
ctx->help_data_1 = NULL;
|
||||||
|
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS
|
||||||
|
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
/* We need a special mechanism to get the fd of a pipe here, so
|
||||||
|
* that we can use this for the %pubring and %secring parameters.
|
||||||
|
* We don't have this yet, so we implement only the adding to the
|
||||||
|
* standard keyrings */
|
||||||
|
if (pubkey || seckey)
|
||||||
|
{
|
||||||
|
err = mk_error (Not_Implemented);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pubkey && !seckey)
|
||||||
|
; /* okay: Add key to the keyrings */
|
||||||
|
else if (!pubkey || gpgme_data_get_type (pubkey) != GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (Invalid_Value);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
else if (!seckey || gpgme_data_get_type (seckey) != GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (Invalid_Value);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pubkey)
|
||||||
|
{
|
||||||
|
_gpgme_data_set_mode (pubkey, GPGME_DATA_MODE_IN);
|
||||||
|
_gpgme_data_set_mode (seckey, GPGME_DATA_MODE_IN);
|
||||||
|
/* FIXME: Need some more things here. */
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((parms = strstr (parms, "<GnupgKeyParms "))
|
||||||
|
&& (s = strchr (parms, '>'))
|
||||||
|
&& (sx = strstr (parms, "format=\"internal\""))
|
||||||
|
&& sx < s
|
||||||
|
&& (s2 = strstr (s+1, "</GnupgKeyParms>")))
|
||||||
|
{
|
||||||
|
/* FIXME: Check that there are no control statements inside. */
|
||||||
|
err = gpgme_data_new_from_mem (&ctx->help_data_1, s+1, s2-s-1, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
err = mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
_gpgme_data_set_mode (ctx->help_data_1, GPGME_DATA_MODE_OUT);
|
||||||
|
|
||||||
|
_gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx);
|
||||||
|
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||||
|
|
||||||
|
err = _gpgme_engine_op_genkey (ctx->engine, ctx->help_data_1, ctx->use_armor);
|
||||||
|
|
||||||
|
if (!err)
|
||||||
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
ctx->pending = 0;
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_genkey:
|
||||||
|
* @c: the context
|
||||||
|
* @parms: XML string with the key parameters
|
||||||
|
* @pubkey: Returns the public key
|
||||||
|
* @seckey: Returns the secret key
|
||||||
|
*
|
||||||
|
* Generate a new key and store the key in the default keyrings if both
|
||||||
|
* @pubkey and @seckey are NULL. If @pubkey and @seckey are given, the newly
|
||||||
|
* created key will be returned in these data objects.
|
||||||
|
* See gpgme_op_genkey_start() for a description of @parms.
|
||||||
|
*
|
||||||
|
* Return value: 0 for success or an error code
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_genkey( GpgmeCtx c, const char *parms,
|
||||||
|
GpgmeData pubkey, GpgmeData seckey )
|
||||||
|
{
|
||||||
|
int rc = gpgme_op_genkey_start ( c, parms, pubkey, seckey );
|
||||||
|
if ( !rc ) {
|
||||||
|
gpgme_wait (c, 1);
|
||||||
|
c->pending = 0;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
93
tags/gpgme-0-3-0/gpgme/gpgme-config.in
Normal file
93
tags/gpgme-0-3-0/gpgme/gpgme-config.in
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
exec_prefix_set=no
|
||||||
|
|
||||||
|
gpgme_libs="@GPGME_LIBS@"
|
||||||
|
gpgme_cflags="@GPGME_CFLAGS@"
|
||||||
|
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
cat <<EOF
|
||||||
|
Usage: gpgme-config [OPTIONS]
|
||||||
|
Options:
|
||||||
|
[--prefix[=DIR]]
|
||||||
|
[--exec-prefix[=DIR]]
|
||||||
|
[--version]
|
||||||
|
[--libs]
|
||||||
|
[--cflags]
|
||||||
|
EOF
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
usage 1 1>&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case "$1" in
|
||||||
|
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||||
|
*) optarg= ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
--prefix=*)
|
||||||
|
prefix=$optarg
|
||||||
|
if test $exec_prefix_set = no ; then
|
||||||
|
exec_prefix=$optarg
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
--prefix)
|
||||||
|
echo_prefix=yes
|
||||||
|
;;
|
||||||
|
--exec-prefix=*)
|
||||||
|
exec_prefix=$optarg
|
||||||
|
exec_prefix_set=yes
|
||||||
|
;;
|
||||||
|
--exec-prefix)
|
||||||
|
echo_exec_prefix=yes
|
||||||
|
;;
|
||||||
|
--version)
|
||||||
|
echo "@VERSION@"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--cflags)
|
||||||
|
echo_cflags=yes
|
||||||
|
;;
|
||||||
|
--libs)
|
||||||
|
echo_libs=yes
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage 1 1>&2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if test "$echo_prefix" = "yes"; then
|
||||||
|
echo $prefix
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$echo_exec_prefix" = "yes"; then
|
||||||
|
echo $exec_prefix
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$echo_cflags" = "yes"; then
|
||||||
|
if test "@includedir@" != "/usr/include" ; then
|
||||||
|
includes="-I@includedir@"
|
||||||
|
for i in $gpgme_cflags ; do
|
||||||
|
if test "$i" = "-I@includedir@" ; then
|
||||||
|
includes=""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo $includes $gpgme_cflags
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$echo_libs" = "yes"; then
|
||||||
|
echo ${gpgme_libs}
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
363
tags/gpgme-0-3-0/gpgme/gpgme.c
Normal file
363
tags/gpgme-0-3-0/gpgme/gpgme.c
Normal file
@ -0,0 +1,363 @@
|
|||||||
|
/* gpgme.c - GnuPG Made Easy
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
#define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
|
||||||
|
#define my_isxdigit(a) ( my_isdigit((a)) \
|
||||||
|
|| ((a) >= 'A' && (a) <= 'F') \
|
||||||
|
|| ((a) >= 'f' && (a) <= 'f') )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_new:
|
||||||
|
* @r_ctx: Returns the new context
|
||||||
|
*
|
||||||
|
* Create a new context to be used with most of the other GPGME
|
||||||
|
* functions. Use gpgme_release_contect() to release all resources
|
||||||
|
*
|
||||||
|
* Return value: An error code
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_new (GpgmeCtx *r_ctx)
|
||||||
|
{
|
||||||
|
GpgmeCtx c;
|
||||||
|
|
||||||
|
c = xtrycalloc ( 1, sizeof *c );
|
||||||
|
if (!c)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
c->verbosity = 1;
|
||||||
|
*r_ctx = c;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_release:
|
||||||
|
* @c: Context to be released.
|
||||||
|
*
|
||||||
|
* Release all resources associated with the given context.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_release (GpgmeCtx c)
|
||||||
|
{
|
||||||
|
if (!c)
|
||||||
|
return;
|
||||||
|
_gpgme_engine_release (c->engine);
|
||||||
|
_gpgme_release_result (c);
|
||||||
|
gpgme_key_release (c->tmp_key);
|
||||||
|
gpgme_data_release (c->help_data_1);
|
||||||
|
gpgme_data_release (c->notation);
|
||||||
|
gpgme_signers_clear (c);
|
||||||
|
if (c->signers)
|
||||||
|
xfree (c->signers);
|
||||||
|
/* FIXME: Release the key_queue. */
|
||||||
|
xfree (c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_release_result (GpgmeCtx c)
|
||||||
|
{
|
||||||
|
_gpgme_release_verify_result (c->result.verify);
|
||||||
|
_gpgme_release_decrypt_result (c->result.decrypt);
|
||||||
|
_gpgme_release_sign_result (c->result.sign);
|
||||||
|
_gpgme_release_encrypt_result (c->result.encrypt);
|
||||||
|
_gpgme_release_passphrase_result (c->result.passphrase);
|
||||||
|
memset (&c->result, 0, sizeof (c->result));
|
||||||
|
_gpgme_set_op_info (c, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_cancel:
|
||||||
|
* @c: the context
|
||||||
|
*
|
||||||
|
* Cancel the current operation. It is not guaranteed that it will work for
|
||||||
|
* all kinds of operations. It is especially useful in a passphrase callback
|
||||||
|
* to stop the system from asking another time for the passphrase.
|
||||||
|
**/
|
||||||
|
|
||||||
|
void
|
||||||
|
gpgme_cancel (GpgmeCtx c)
|
||||||
|
{
|
||||||
|
return_if_fail (c);
|
||||||
|
|
||||||
|
c->cancel = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_get_notation:
|
||||||
|
* @c: the context
|
||||||
|
*
|
||||||
|
* If there is notation data available from the last signature check,
|
||||||
|
* this function may be used to return this notation data as a string.
|
||||||
|
* The string is an XML represantaton of that data embedded in a
|
||||||
|
* %<notation> container.
|
||||||
|
*
|
||||||
|
* Return value: An XML string or NULL if no notation data is available.
|
||||||
|
**/
|
||||||
|
char *
|
||||||
|
gpgme_get_notation ( GpgmeCtx c )
|
||||||
|
{
|
||||||
|
if ( !c->notation )
|
||||||
|
return NULL;
|
||||||
|
return _gpgme_data_get_as_string ( c->notation );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_get_op_info:
|
||||||
|
* @c: the context
|
||||||
|
* @reserved:
|
||||||
|
*
|
||||||
|
* Return information about the last information. The caller has to
|
||||||
|
* free the string. NULL is returned if there is not previous
|
||||||
|
* operation available or the operation has not yet finished.
|
||||||
|
*
|
||||||
|
* Here is a sample information we return:
|
||||||
|
* <literal>
|
||||||
|
* <![CDATA[
|
||||||
|
* <GnupgOperationInfo>
|
||||||
|
* <signature>
|
||||||
|
* <detached/> <!-- or cleartext or standard -->
|
||||||
|
* <algo>17</algo>
|
||||||
|
* <hashalgo>2</hashalgo>
|
||||||
|
* <micalg>pgp-sha1</micalg>
|
||||||
|
* <sigclass>01</sigclass>
|
||||||
|
* <created>9222222</created>
|
||||||
|
* <fpr>121212121212121212</fpr>
|
||||||
|
* </signature>
|
||||||
|
* </GnupgOperationInfo>
|
||||||
|
* ]]>
|
||||||
|
* </literal>
|
||||||
|
* Return value: NULL for no info available or an XML string
|
||||||
|
**/
|
||||||
|
char *
|
||||||
|
gpgme_get_op_info ( GpgmeCtx c, int reserved )
|
||||||
|
{
|
||||||
|
if (!c || reserved)
|
||||||
|
return NULL; /*invalid value */
|
||||||
|
|
||||||
|
return _gpgme_data_get_as_string (c->op_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Store the data object with the operation info in the
|
||||||
|
* context. Caller should not use that object anymore.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_gpgme_set_op_info (GpgmeCtx c, GpgmeData info)
|
||||||
|
{
|
||||||
|
assert (c);
|
||||||
|
|
||||||
|
gpgme_data_release (c->op_info);
|
||||||
|
c->op_info = NULL;
|
||||||
|
|
||||||
|
if (info)
|
||||||
|
c->op_info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_set_protocol (GpgmeCtx c, GpgmeProtocol prot)
|
||||||
|
{
|
||||||
|
if (!c)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
switch (prot)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
c->use_cms = 0;
|
||||||
|
break;
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
c->use_cms = 1;
|
||||||
|
break;
|
||||||
|
case GPGME_PROTOCOL_AUTO:
|
||||||
|
return mk_error (Not_Implemented);
|
||||||
|
default:
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_set_armor:
|
||||||
|
* @c: the contect
|
||||||
|
* @yes: boolean value to set or clear that flag
|
||||||
|
*
|
||||||
|
* Enable or disable the use of an ascii armor for all output.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_set_armor ( GpgmeCtx c, int yes )
|
||||||
|
{
|
||||||
|
if ( !c )
|
||||||
|
return; /* oops */
|
||||||
|
c->use_armor = yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_get_armor:
|
||||||
|
* @c: the context
|
||||||
|
*
|
||||||
|
* Return the state of the armor flag which can be changed using
|
||||||
|
* gpgme_set_armor().
|
||||||
|
*
|
||||||
|
* Return value: Boolean whether armor mode is to be used.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
gpgme_get_armor (GpgmeCtx c)
|
||||||
|
{
|
||||||
|
return c && c->use_armor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_set_textmode:
|
||||||
|
* @c: the context
|
||||||
|
* @yes: boolean flag whether textmode should be enabled
|
||||||
|
*
|
||||||
|
* Enable or disable the use of the special textmode. Textmode is for example
|
||||||
|
* used for the RFC2015 signatures; note that the updated RFC 3156 mandates
|
||||||
|
* that the MUA does some preparations so that textmode is not anymore needed.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_set_textmode ( GpgmeCtx c, int yes )
|
||||||
|
{
|
||||||
|
if ( !c )
|
||||||
|
return; /* oops */
|
||||||
|
c->use_textmode = yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_get_textmode:
|
||||||
|
* @c: the context
|
||||||
|
*
|
||||||
|
* Return the state of the textmode flag which can be changed using
|
||||||
|
* gpgme_set_textmode().
|
||||||
|
*
|
||||||
|
* Return value: Boolean whether textmode is to be used.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
gpgme_get_textmode (GpgmeCtx c)
|
||||||
|
{
|
||||||
|
return c && c->use_textmode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_set_keylist_mode:
|
||||||
|
* @c: the context
|
||||||
|
* @mode: listing mode
|
||||||
|
*
|
||||||
|
* This function changes the default behaviour of the keylisting functions.
|
||||||
|
* Defines values for @mode are: %0 = normal, %1 = fast listing without
|
||||||
|
* information about key validity.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_set_keylist_mode ( GpgmeCtx c, int mode )
|
||||||
|
{
|
||||||
|
if (!c)
|
||||||
|
return;
|
||||||
|
c->keylist_mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_set_passphrase_cb:
|
||||||
|
* @c: the context
|
||||||
|
* @cb: A callback function
|
||||||
|
* @cb_value: The value passed to the callback function
|
||||||
|
*
|
||||||
|
* This function sets a callback function to be used to pass a passphrase
|
||||||
|
* to gpg. The preferred way to handle this is by using the gpg-agent, but
|
||||||
|
* because that beast is not ready for real use, you can use this passphrase
|
||||||
|
* thing.
|
||||||
|
*
|
||||||
|
* The callback function is defined as:
|
||||||
|
* <literal>
|
||||||
|
* typedef const char *(*GpgmePassphraseCb)(void*cb_value,
|
||||||
|
* const char *desc,
|
||||||
|
* void *r_hd);
|
||||||
|
* </literal>
|
||||||
|
* and called whenever gpgme needs a passphrase. DESC will have a nice
|
||||||
|
* text, to be used to prompt for the passphrase and R_HD is just a parameter
|
||||||
|
* to be used by the callback it self. Becuase the callback returns a const
|
||||||
|
* string, the callback might want to know when it can release resources
|
||||||
|
* assocated with that returned string; gpgme helps here by calling this
|
||||||
|
* passphrase callback with an DESC of %NULL as soon as it does not need
|
||||||
|
* the returned string anymore. The callback function might then choose
|
||||||
|
* to release resources depending on R_HD.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_set_passphrase_cb ( GpgmeCtx c, GpgmePassphraseCb cb, void *cb_value )
|
||||||
|
{
|
||||||
|
if (c)
|
||||||
|
{
|
||||||
|
c->passphrase_cb = cb;
|
||||||
|
c->passphrase_cb_value = cb_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_set_progress_cb:
|
||||||
|
* @c: the context
|
||||||
|
* @cb: A callback function
|
||||||
|
* @cb_value: The value passed to the callback function
|
||||||
|
*
|
||||||
|
* This function sets a callback function to be used as a progress indicator.
|
||||||
|
*
|
||||||
|
* The callback function is defined as:
|
||||||
|
* <literal>
|
||||||
|
* typedef void (*GpgmeProgressCb) (void*cb_value,
|
||||||
|
* const char *what, int type,
|
||||||
|
* int curretn, int total);
|
||||||
|
* </literal>
|
||||||
|
* For details on the progress events, see the entry for the PROGRESS
|
||||||
|
* status in the file doc/DETAILS of the GnuPG distribution.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_set_progress_cb ( GpgmeCtx c, GpgmeProgressCb cb, void *cb_value )
|
||||||
|
{
|
||||||
|
if (c)
|
||||||
|
{
|
||||||
|
c->progress_cb = cb;
|
||||||
|
c->progress_cb_value = cb_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
329
tags/gpgme-0-3-0/gpgme/gpgme.h
Normal file
329
tags/gpgme-0-3-0/gpgme/gpgme.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/* gpgme.h - GnuPG Made Easy
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 GPGME_H
|
||||||
|
#define GPGME_H
|
||||||
|
|
||||||
|
#include <stdio.h> /* for FILE * */
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
typedef long off_t;
|
||||||
|
#else
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#if 0 /* just to make Emacs auto-indent happy */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The version of this header should match the one of the library
|
||||||
|
* It should not be used by a program because gpgme_check_version(NULL)
|
||||||
|
* does return the same version. The purpose of this macro is to
|
||||||
|
* let autoconf (using the AM_PATH_GPGME macro) check that this
|
||||||
|
* header matches the installed library.
|
||||||
|
* Warning: Do not edit the next line. configure will do that for you! */
|
||||||
|
#define GPGME_VERSION "0.3.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct gpgme_context_s;
|
||||||
|
typedef struct gpgme_context_s *GpgmeCtx;
|
||||||
|
|
||||||
|
struct gpgme_data_s;
|
||||||
|
typedef struct gpgme_data_s *GpgmeData;
|
||||||
|
|
||||||
|
struct gpgme_recipients_s;
|
||||||
|
typedef struct gpgme_recipients_s *GpgmeRecipients;
|
||||||
|
|
||||||
|
struct gpgme_key_s;
|
||||||
|
typedef struct gpgme_key_s *GpgmeKey;
|
||||||
|
|
||||||
|
struct gpgme_trust_item_s;
|
||||||
|
typedef struct gpgme_trust_item_s *GpgmeTrustItem;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GPGME_EOF = -1,
|
||||||
|
GPGME_No_Error = 0,
|
||||||
|
GPGME_General_Error = 1,
|
||||||
|
GPGME_Out_Of_Core = 2,
|
||||||
|
GPGME_Invalid_Value = 3,
|
||||||
|
GPGME_Busy = 4,
|
||||||
|
GPGME_No_Request = 5,
|
||||||
|
GPGME_Exec_Error = 6,
|
||||||
|
GPGME_Too_Many_Procs = 7,
|
||||||
|
GPGME_Pipe_Error = 8,
|
||||||
|
GPGME_No_Recipients = 9,
|
||||||
|
GPGME_No_Data = 10,
|
||||||
|
GPGME_Conflict = 11,
|
||||||
|
GPGME_Not_Implemented = 12,
|
||||||
|
GPGME_Read_Error = 13,
|
||||||
|
GPGME_Write_Error = 14,
|
||||||
|
GPGME_Invalid_Type = 15,
|
||||||
|
GPGME_Invalid_Mode = 16,
|
||||||
|
GPGME_File_Error = 17, /* errno is set in this case */
|
||||||
|
GPGME_Decryption_Failed = 18,
|
||||||
|
GPGME_No_Passphrase = 19,
|
||||||
|
GPGME_Canceled = 20,
|
||||||
|
GPGME_Invalid_Key = 21,
|
||||||
|
GPGME_Invalid_Engine = 22
|
||||||
|
} GpgmeError;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GPGME_DATA_TYPE_NONE = 0,
|
||||||
|
GPGME_DATA_TYPE_MEM = 1,
|
||||||
|
GPGME_DATA_TYPE_FD = 2,
|
||||||
|
GPGME_DATA_TYPE_FILE = 3,
|
||||||
|
GPGME_DATA_TYPE_CB = 4
|
||||||
|
} GpgmeDataType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GPGME_SIG_STAT_NONE = 0,
|
||||||
|
GPGME_SIG_STAT_GOOD = 1,
|
||||||
|
GPGME_SIG_STAT_BAD = 2,
|
||||||
|
GPGME_SIG_STAT_NOKEY = 3,
|
||||||
|
GPGME_SIG_STAT_NOSIG = 4,
|
||||||
|
GPGME_SIG_STAT_ERROR = 5,
|
||||||
|
GPGME_SIG_STAT_DIFF = 6
|
||||||
|
} GpgmeSigStat;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GPGME_SIG_MODE_NORMAL = 0,
|
||||||
|
GPGME_SIG_MODE_DETACH = 1,
|
||||||
|
GPGME_SIG_MODE_CLEAR = 2
|
||||||
|
} GpgmeSigMode;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GPGME_ATTR_KEYID = 1,
|
||||||
|
GPGME_ATTR_FPR = 2,
|
||||||
|
GPGME_ATTR_ALGO = 3,
|
||||||
|
GPGME_ATTR_LEN = 4,
|
||||||
|
GPGME_ATTR_CREATED = 5,
|
||||||
|
GPGME_ATTR_EXPIRE = 6,
|
||||||
|
GPGME_ATTR_OTRUST = 7,
|
||||||
|
GPGME_ATTR_USERID = 8,
|
||||||
|
GPGME_ATTR_NAME = 9,
|
||||||
|
GPGME_ATTR_EMAIL = 10,
|
||||||
|
GPGME_ATTR_COMMENT = 11,
|
||||||
|
GPGME_ATTR_VALIDITY= 12,
|
||||||
|
GPGME_ATTR_LEVEL = 13,
|
||||||
|
GPGME_ATTR_TYPE = 14,
|
||||||
|
GPGME_ATTR_IS_SECRET= 15,
|
||||||
|
GPGME_ATTR_KEY_REVOKED = 16,
|
||||||
|
GPGME_ATTR_KEY_INVALID = 17,
|
||||||
|
GPGME_ATTR_UID_REVOKED = 18,
|
||||||
|
GPGME_ATTR_UID_INVALID = 19,
|
||||||
|
GPGME_ATTR_KEY_CAPS = 20,
|
||||||
|
GPGME_ATTR_CAN_ENCRYPT = 21,
|
||||||
|
GPGME_ATTR_CAN_SIGN = 22,
|
||||||
|
GPGME_ATTR_CAN_CERTIFY = 23,
|
||||||
|
GPGME_ATTR_KEY_EXPIRED = 24,
|
||||||
|
GPGME_ATTR_KEY_DISABLED= 25
|
||||||
|
} GpgmeAttr;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GPGME_VALIDITY_UNKNOWN = 0,
|
||||||
|
GPGME_VALIDITY_UNDEFINED = 1,
|
||||||
|
GPGME_VALIDITY_NEVER = 2,
|
||||||
|
GPGME_VALIDITY_MARGINAL = 3,
|
||||||
|
GPGME_VALIDITY_FULL = 4,
|
||||||
|
GPGME_VALIDITY_ULTIMATE = 5
|
||||||
|
} GpgmeValidity;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GPGME_PROTOCOL_OpenPGP = 0, /* default */
|
||||||
|
GPGME_PROTOCOL_CMS = 1,
|
||||||
|
GPGME_PROTOCOL_AUTO = 2
|
||||||
|
} GpgmeProtocol;
|
||||||
|
|
||||||
|
typedef const char *(*GpgmePassphraseCb)(void*,
|
||||||
|
const char *desc, void *r_hd);
|
||||||
|
typedef void (*GpgmeProgressCb)(void *opaque,
|
||||||
|
const char *what,
|
||||||
|
int type, int current, int total );
|
||||||
|
|
||||||
|
/* Context management */
|
||||||
|
GpgmeError gpgme_new (GpgmeCtx *r_ctx);
|
||||||
|
void gpgme_release (GpgmeCtx c);
|
||||||
|
void gpgme_cancel (GpgmeCtx c);
|
||||||
|
GpgmeCtx gpgme_wait (GpgmeCtx c, int hang);
|
||||||
|
|
||||||
|
char *gpgme_get_notation (GpgmeCtx c);
|
||||||
|
GpgmeError gpgme_set_protocol (GpgmeCtx c, GpgmeProtocol prot);
|
||||||
|
void gpgme_set_armor (GpgmeCtx c, int yes);
|
||||||
|
int gpgme_get_armor (GpgmeCtx c);
|
||||||
|
void gpgme_set_textmode (GpgmeCtx c, int yes);
|
||||||
|
int gpgme_get_textmode (GpgmeCtx c);
|
||||||
|
void gpgme_set_keylist_mode ( GpgmeCtx c, int mode );
|
||||||
|
void gpgme_set_passphrase_cb (GpgmeCtx c,
|
||||||
|
GpgmePassphraseCb cb, void *cb_value);
|
||||||
|
void gpgme_set_progress_cb (GpgmeCtx c, GpgmeProgressCb cb, void *cb_value);
|
||||||
|
|
||||||
|
void gpgme_signers_clear (GpgmeCtx c);
|
||||||
|
GpgmeError gpgme_signers_add (GpgmeCtx c, const GpgmeKey key);
|
||||||
|
GpgmeKey gpgme_signers_enum (const GpgmeCtx c, int seq);
|
||||||
|
|
||||||
|
const char *gpgme_get_sig_status (GpgmeCtx c, int idx,
|
||||||
|
GpgmeSigStat *r_stat, time_t *r_created );
|
||||||
|
GpgmeError gpgme_get_sig_key (GpgmeCtx c, int idx, GpgmeKey *r_key);
|
||||||
|
char *gpgme_get_op_info (GpgmeCtx c, int reserved);
|
||||||
|
|
||||||
|
|
||||||
|
/* Functions to handle recipients */
|
||||||
|
GpgmeError gpgme_recipients_new (GpgmeRecipients *r_rset);
|
||||||
|
void gpgme_recipients_release ( GpgmeRecipients rset);
|
||||||
|
GpgmeError gpgme_recipients_add_name (GpgmeRecipients rset,
|
||||||
|
const char *name);
|
||||||
|
GpgmeError gpgme_recipients_add_name_with_validity (GpgmeRecipients rset,
|
||||||
|
const char *name,
|
||||||
|
GpgmeValidity val );
|
||||||
|
unsigned int gpgme_recipients_count ( const GpgmeRecipients rset );
|
||||||
|
GpgmeError gpgme_recipients_enum_open (const GpgmeRecipients rset,void **ctx);
|
||||||
|
const char *gpgme_recipients_enum_read (const GpgmeRecipients rset,void **ctx);
|
||||||
|
GpgmeError gpgme_recipients_enum_close (const GpgmeRecipients rset,void **ctx);
|
||||||
|
|
||||||
|
|
||||||
|
/* Functions to handle data sources */
|
||||||
|
GpgmeError gpgme_data_new ( GpgmeData *r_dh );
|
||||||
|
GpgmeError gpgme_data_new_from_mem ( GpgmeData *r_dh,
|
||||||
|
const char *buffer, size_t size,
|
||||||
|
int copy );
|
||||||
|
GpgmeError gpgme_data_new_with_read_cb ( GpgmeData *r_dh,
|
||||||
|
int (*read_cb)(void*,char *,size_t,size_t*),
|
||||||
|
void *read_cb_value );
|
||||||
|
|
||||||
|
GpgmeError gpgme_data_new_from_file ( GpgmeData *r_dh,
|
||||||
|
const char *fname,
|
||||||
|
int copy );
|
||||||
|
GpgmeError gpgme_data_new_from_filepart ( GpgmeData *r_dh,
|
||||||
|
const char *fname, FILE *fp,
|
||||||
|
off_t offset, off_t length );
|
||||||
|
void gpgme_data_release ( GpgmeData dh );
|
||||||
|
char * gpgme_data_release_and_get_mem ( GpgmeData dh, size_t *r_len );
|
||||||
|
GpgmeDataType gpgme_data_get_type ( GpgmeData dh );
|
||||||
|
GpgmeError gpgme_data_rewind ( GpgmeData dh );
|
||||||
|
GpgmeError gpgme_data_read ( GpgmeData dh,
|
||||||
|
char *buffer, size_t length, size_t *nread );
|
||||||
|
GpgmeError gpgme_data_write ( GpgmeData dh,
|
||||||
|
const char *buffer, size_t length );
|
||||||
|
|
||||||
|
|
||||||
|
/* Key and trust functions */
|
||||||
|
void gpgme_key_ref (GpgmeKey key);
|
||||||
|
void gpgme_key_unref (GpgmeKey key);
|
||||||
|
void gpgme_key_release ( GpgmeKey key );
|
||||||
|
char *gpgme_key_get_as_xml ( GpgmeKey key );
|
||||||
|
const char *gpgme_key_get_string_attr ( GpgmeKey key, GpgmeAttr what,
|
||||||
|
const void *reserved, int idx );
|
||||||
|
unsigned long gpgme_key_get_ulong_attr ( GpgmeKey key, GpgmeAttr what,
|
||||||
|
const void *reserved, int idx );
|
||||||
|
|
||||||
|
void gpgme_trust_item_release ( GpgmeTrustItem item );
|
||||||
|
const char *gpgme_trust_item_get_string_attr ( GpgmeTrustItem item,
|
||||||
|
GpgmeAttr what,
|
||||||
|
const void *reserved, int idx );
|
||||||
|
int gpgme_trust_item_get_int_attr ( GpgmeTrustItem item, GpgmeAttr what,
|
||||||
|
const void *reserved, int idx );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Basic GnuPG functions */
|
||||||
|
GpgmeError gpgme_op_encrypt_start ( GpgmeCtx c,
|
||||||
|
GpgmeRecipients recp,
|
||||||
|
GpgmeData in, GpgmeData out );
|
||||||
|
GpgmeError gpgme_op_decrypt_start ( GpgmeCtx c,
|
||||||
|
GpgmeData ciph, GpgmeData plain );
|
||||||
|
GpgmeError gpgme_op_decrypt_verify_start (GpgmeCtx c,
|
||||||
|
GpgmeData ciph, GpgmeData plain);
|
||||||
|
GpgmeError gpgme_op_sign_start ( GpgmeCtx c,
|
||||||
|
GpgmeData in, GpgmeData out,
|
||||||
|
GpgmeSigMode mode );
|
||||||
|
GpgmeError gpgme_op_verify_start ( GpgmeCtx c,
|
||||||
|
GpgmeData sig, GpgmeData text );
|
||||||
|
GpgmeError gpgme_op_import_start ( GpgmeCtx c, GpgmeData keydata );
|
||||||
|
GpgmeError gpgme_op_export_start ( GpgmeCtx c, GpgmeRecipients recp,
|
||||||
|
GpgmeData keydata );
|
||||||
|
GpgmeError gpgme_op_genkey_start ( GpgmeCtx c, const char *parms,
|
||||||
|
GpgmeData pubkey, GpgmeData seckey );
|
||||||
|
GpgmeError gpgme_op_delete_start ( GpgmeCtx c, const GpgmeKey key,
|
||||||
|
int allow_secret );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Key management functions */
|
||||||
|
GpgmeError gpgme_op_keylist_start (GpgmeCtx ctx,
|
||||||
|
const char *pattern, int secret_only);
|
||||||
|
GpgmeError gpgme_op_keylist_next (GpgmeCtx ctx, GpgmeKey *r_key);
|
||||||
|
GpgmeError gpgme_op_keylist_end (GpgmeCtx ctx);
|
||||||
|
GpgmeError gpgme_op_trustlist_start (GpgmeCtx ctx,
|
||||||
|
const char *pattern, int max_level);
|
||||||
|
GpgmeError gpgme_op_trustlist_next (GpgmeCtx ctx, GpgmeTrustItem *r_item);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Convenience functions for normal usage */
|
||||||
|
GpgmeError gpgme_op_encrypt ( GpgmeCtx c, GpgmeRecipients recp,
|
||||||
|
GpgmeData in, GpgmeData out );
|
||||||
|
GpgmeError gpgme_op_decrypt ( GpgmeCtx c,
|
||||||
|
GpgmeData in, GpgmeData out );
|
||||||
|
GpgmeError gpgme_op_decrypt_verify (GpgmeCtx c,
|
||||||
|
GpgmeData in, GpgmeData out,
|
||||||
|
GpgmeSigStat *r_status);
|
||||||
|
GpgmeError gpgme_op_sign ( GpgmeCtx c, GpgmeData in, GpgmeData out,
|
||||||
|
GpgmeSigMode mode);
|
||||||
|
GpgmeError gpgme_op_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text,
|
||||||
|
GpgmeSigStat *r_status );
|
||||||
|
GpgmeError gpgme_op_import ( GpgmeCtx c, GpgmeData keydata );
|
||||||
|
GpgmeError gpgme_op_export ( GpgmeCtx c, GpgmeRecipients recp,
|
||||||
|
GpgmeData keydata );
|
||||||
|
GpgmeError gpgme_op_genkey ( GpgmeCtx c, const char *parms,
|
||||||
|
GpgmeData pubkey, GpgmeData seckey );
|
||||||
|
GpgmeError gpgme_op_delete ( GpgmeCtx c, const GpgmeKey key, int allow_secret);
|
||||||
|
|
||||||
|
|
||||||
|
/* miscellaneous functions */
|
||||||
|
const char *gpgme_check_version (const char *req_version);
|
||||||
|
GpgmeError gpgme_check_engine (void);
|
||||||
|
const char *gpgme_get_engine_info (void);
|
||||||
|
const char *gpgme_strerror (GpgmeError err);
|
||||||
|
void gpgme_register_idle (void (*fnc)(void));
|
||||||
|
|
||||||
|
/* Engine support functions. */
|
||||||
|
GpgmeError gpgme_engine_check_version (GpgmeProtocol proto);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* GPGME_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
170
tags/gpgme-0-3-0/gpgme/gpgme.m4
Normal file
170
tags/gpgme-0-3-0/gpgme/gpgme.m4
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
dnl Autoconf macros for libgpgme
|
||||||
|
dnl $Id$
|
||||||
|
|
||||||
|
# Configure paths for GPGME
|
||||||
|
# Shamelessly stolen from the one of XDELTA by Owen Taylor
|
||||||
|
# Werner Koch 2000-11-17
|
||||||
|
|
||||||
|
dnl AM_PATH_GPGME([MINIMUM-VERSION,
|
||||||
|
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
|
||||||
|
dnl Test for gpgme, and define GPGME_CFLAGS and GPGME_LIBS
|
||||||
|
dnl
|
||||||
|
AC_DEFUN(AM_PATH_GPGME,
|
||||||
|
[dnl
|
||||||
|
dnl Get the cflags and libraries from the gpgme-config script
|
||||||
|
dnl
|
||||||
|
AC_ARG_WITH(gpgme-prefix,
|
||||||
|
[ --with-gpgme-prefix=PFX Prefix where gpgme is installed (optional)],
|
||||||
|
gpgme_config_prefix="$withval", gpgme_config_prefix="")
|
||||||
|
AC_ARG_ENABLE(gpgmetest,
|
||||||
|
[ --disable-gpgmetest Do not try to compile and run a test gpgme program],
|
||||||
|
, enable_gpgmetest=yes)
|
||||||
|
|
||||||
|
if test x$gpgme_config_prefix != x ; then
|
||||||
|
gpgme_config_args="$gpgme_config_args --prefix=$gpgme_config_prefix"
|
||||||
|
if test x${GPGME_CONFIG+set} != xset ; then
|
||||||
|
GPGME_CONFIG=$gpgme_config_prefix/bin/gpgme-config
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
|
||||||
|
min_gpgme_version=ifelse([$1], ,1.0.0,$1)
|
||||||
|
AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
|
||||||
|
no_gpgme=""
|
||||||
|
if test "$GPGME_CONFIG" = "no" ; then
|
||||||
|
no_gpgme=yes
|
||||||
|
else
|
||||||
|
GPGME_CFLAGS=`$GPGME_CONFIG $gpgme_config_args --cflags`
|
||||||
|
GPGME_LIBS=`$GPGME_CONFIG $gpgme_config_args --libs`
|
||||||
|
gpgme_config_version=`$GPGME_CONFIG $gpgme_config_args --version`
|
||||||
|
if test "x$enable_gpgmetest" = "xyes" ; then
|
||||||
|
ac_save_CFLAGS="$CFLAGS"
|
||||||
|
ac_save_LIBS="$LIBS"
|
||||||
|
CFLAGS="$CFLAGS $GPGME_CFLAGS"
|
||||||
|
LIBS="$LIBS $GPGME_LIBS"
|
||||||
|
dnl
|
||||||
|
dnl Now check if the installed gpgme is sufficiently new. Also sanity
|
||||||
|
dnl checks the results of gpgme-config to some extent
|
||||||
|
dnl
|
||||||
|
rm -f conf.gpgmetest
|
||||||
|
AC_TRY_RUN([
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <gpgme.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
system ("touch conf.gpgmetest");
|
||||||
|
|
||||||
|
if( strcmp( gpgme_check_version(NULL), "$gpgme_config_version" ) )
|
||||||
|
{
|
||||||
|
printf("\n"
|
||||||
|
"*** 'gpgme-config --version' returned %s, but GPGME (%s) was found!\n",
|
||||||
|
"$gpgme_config_version", gpgme_check_version(NULL) );
|
||||||
|
printf(
|
||||||
|
"*** If gpgme-config was correct, then it is best to remove the old\n"
|
||||||
|
"*** version of GPGME. You may also be able to fix the error\n"
|
||||||
|
"*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"
|
||||||
|
"*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"
|
||||||
|
"*** required on your system.\n"
|
||||||
|
"*** If gpgme-config was wrong, set the environment variable GPGME_CONFIG\n"
|
||||||
|
"*** to point to the correct copy of gpgme-config, \n"
|
||||||
|
"*** and remove the file config.cache before re-running configure\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if ( strcmp(gpgme_check_version(NULL), GPGME_VERSION ) )
|
||||||
|
{
|
||||||
|
printf("\n*** GPGME header file (version %s) does not match\n",
|
||||||
|
GPGME_VERSION);
|
||||||
|
printf("*** library (version %s)\n", gpgme_check_version(NULL) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( gpgme_check_version( "$min_gpgme_version" ) )
|
||||||
|
return 0;
|
||||||
|
printf("no\n"
|
||||||
|
"*** An old version of GPGME (%s) was found.\n", gpgme_check_version(NULL) );
|
||||||
|
printf(
|
||||||
|
"*** You need a version of GPGME newer than %s.\n", "$min_gpgme_version" );
|
||||||
|
printf(
|
||||||
|
"*** The latest version of GPGME is always available at\n"
|
||||||
|
"*** ftp://ftp.gnupg.org/pub/gcrypt/alpha/gpgme/\n"
|
||||||
|
"*** \n"
|
||||||
|
"*** If you have already installed a sufficiently new version, this error\n"
|
||||||
|
"*** probably means that the wrong copy of the gpgme-config shell script is\n"
|
||||||
|
"*** being found. The easiest way to fix this is to remove the old version\n"
|
||||||
|
"*** of GPGME, but you can also set the GPGME_CONFIG environment to point to\n"
|
||||||
|
"*** the correct copy of gpgme-config. (In this case, you will have to\n"
|
||||||
|
"*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"
|
||||||
|
"*** so that the correct libraries are found at run-time).\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
],, no_gpgme=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||||
|
CFLAGS="$ac_save_CFLAGS"
|
||||||
|
LIBS="$ac_save_LIBS"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$no_gpgme" = x ; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
ifelse([$2], , :, [$2])
|
||||||
|
else
|
||||||
|
if test -f conf.gpgmetest ; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
if test "$GPGME_CONFIG" = "no" ; then
|
||||||
|
echo "*** The gpgme-config script installed by GPGME could not be found"
|
||||||
|
echo "*** If GPGME was installed in PREFIX, make sure PREFIX/bin is in"
|
||||||
|
echo "*** your path, or set the GPGME_CONFIG environment variable to the"
|
||||||
|
echo "*** full path to gpgme-config."
|
||||||
|
else
|
||||||
|
if test -f conf.gpgmetest ; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo "*** Could not run gpgme test program, checking why..."
|
||||||
|
CFLAGS="$CFLAGS $GPGME_CFLAGS"
|
||||||
|
LIBS="$LIBS $GPGME_LIBS"
|
||||||
|
AC_TRY_LINK([
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <gpgme.h>
|
||||||
|
], [ gpgme_check_version(NULL); return 0 ],
|
||||||
|
[
|
||||||
|
echo "*** The test program compiled, but did not run. This usually means"
|
||||||
|
echo "*** that the run-time linker is not finding GPGME or finding the wrong"
|
||||||
|
echo "*** version of GPGME. If it is not finding GPGME, you'll need to set your"
|
||||||
|
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
||||||
|
echo "*** to the installed location Also, make sure you have run ldconfig if"
|
||||||
|
echo "*** that is required on your system"
|
||||||
|
echo "***"
|
||||||
|
echo "*** If you have an old version installed, it is best to remove it,"
|
||||||
|
echo "*** although you may also be able to get things to work by"
|
||||||
|
echo "*** modifying LD_LIBRARY_PATH"
|
||||||
|
echo "***"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
echo "*** The test program failed to compile or link. See the file config.log"
|
||||||
|
echo "*** for the exact error that occured. This usually means GPGME was"
|
||||||
|
echo "*** incorrectly installed or that you have moved GPGME since it was"
|
||||||
|
echo "*** installed. In the latter case, you may want to edit the"
|
||||||
|
echo "*** gpgme-config script: $GPGME_CONFIG"
|
||||||
|
])
|
||||||
|
CFLAGS="$ac_save_CFLAGS"
|
||||||
|
LIBS="$ac_save_LIBS"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
GPGME_CFLAGS=""
|
||||||
|
GPGME_LIBS=""
|
||||||
|
ifelse([$3], , :, [$3])
|
||||||
|
fi
|
||||||
|
AC_SUBST(GPGME_CFLAGS)
|
||||||
|
AC_SUBST(GPGME_LIBS)
|
||||||
|
rm -f conf.gpgmetest
|
||||||
|
])
|
||||||
|
|
104
tags/gpgme-0-3-0/gpgme/import.c
Normal file
104
tags/gpgme-0-3-0/gpgme/import.c
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/* import.c - encrypt functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
import_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
||||||
|
{
|
||||||
|
DEBUG2 ("import_status: code=%d args=`%s'\n", code, args );
|
||||||
|
/* FIXME: We have to check here whether the import actually worked
|
||||||
|
* and maybe it is a good idea to save some statistics and provide
|
||||||
|
* a progress callback */
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_import_start (GpgmeCtx ctx, GpgmeData keydata)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
fail_on_pending_request (ctx);
|
||||||
|
ctx->pending = 1;
|
||||||
|
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS
|
||||||
|
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
/* Check the supplied data */
|
||||||
|
if (gpgme_data_get_type (keydata) == GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (No_Data);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
_gpgme_data_set_mode (keydata, GPGME_DATA_MODE_OUT);
|
||||||
|
|
||||||
|
_gpgme_engine_set_status_handler (ctx->engine, import_status_handler, ctx);
|
||||||
|
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||||
|
|
||||||
|
_gpgme_engine_op_import (ctx->engine, keydata);
|
||||||
|
|
||||||
|
if (!err)
|
||||||
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
ctx->pending = 0;
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_import:
|
||||||
|
* @c: Context
|
||||||
|
* @keydata: Data object
|
||||||
|
*
|
||||||
|
* Import all key material from @keydata into the key database.
|
||||||
|
*
|
||||||
|
* Return value: o on success or an error code.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_import ( GpgmeCtx c, GpgmeData keydata )
|
||||||
|
{
|
||||||
|
int rc = gpgme_op_import_start ( c, keydata );
|
||||||
|
if ( !rc ) {
|
||||||
|
gpgme_wait (c, 1);
|
||||||
|
c->pending = 0;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
71
tags/gpgme-0-3-0/gpgme/io.h
Normal file
71
tags/gpgme-0-3-0/gpgme/io.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/* io.h - I/O functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 IO_H
|
||||||
|
#define IO_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
struct spawn_fd_item_s {
|
||||||
|
int fd;
|
||||||
|
int dup_to;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct io_select_fd_s {
|
||||||
|
int fd;
|
||||||
|
int is_closed;
|
||||||
|
int for_read;
|
||||||
|
int for_write;
|
||||||
|
int signaled;
|
||||||
|
int frozen;
|
||||||
|
void *opaque;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* These function are either defined in posix-io.c or w32-io.c */
|
||||||
|
|
||||||
|
int _gpgme_io_read ( int fd, void *buffer, size_t count );
|
||||||
|
int _gpgme_io_write ( int fd, const void *buffer, size_t count );
|
||||||
|
int _gpgme_io_pipe ( int filedes[2], int inherit_idx );
|
||||||
|
int _gpgme_io_close ( int fd );
|
||||||
|
int _gpgme_io_set_close_notify (int fd,
|
||||||
|
void (*handler)(int, void*), void *value);
|
||||||
|
int _gpgme_io_set_nonblocking ( int fd );
|
||||||
|
int _gpgme_io_spawn ( const char *path, char **argv,
|
||||||
|
struct spawn_fd_item_s *fd_child_list,
|
||||||
|
struct spawn_fd_item_s *fd_parent_list );
|
||||||
|
int _gpgme_io_waitpid ( int pid, int hang, int *r_status, int *r_signal );
|
||||||
|
int _gpgme_io_kill ( int pid, int hard );
|
||||||
|
int _gpgme_io_select ( struct io_select_fd_s *fds, size_t nfds);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* IO_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
967
tags/gpgme-0-3-0/gpgme/key.c
Normal file
967
tags/gpgme-0-3-0/gpgme/key.c
Normal file
@ -0,0 +1,967 @@
|
|||||||
|
/* key.c - Key and keyList objects
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "ops.h"
|
||||||
|
#include "key.h"
|
||||||
|
|
||||||
|
#define ALLOC_CHUNK 1024
|
||||||
|
#define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
|
||||||
|
|
||||||
|
#if SIZEOF_UNSIGNED_INT < 4
|
||||||
|
#error unsigned int too short to be used as a hash value
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct key_cache_item_s {
|
||||||
|
struct key_cache_item_s *next;
|
||||||
|
GpgmeKey key;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int key_cache_initialized;
|
||||||
|
static struct key_cache_item_s **key_cache;
|
||||||
|
static size_t key_cache_size;
|
||||||
|
static size_t key_cache_max_chain_length;
|
||||||
|
static struct key_cache_item_s *key_cache_unused_items;
|
||||||
|
|
||||||
|
static int
|
||||||
|
hextobyte ( const byte *s )
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if ( *s >= '0' && *s <= '9' )
|
||||||
|
c = 16 * (*s - '0');
|
||||||
|
else if ( *s >= 'A' && *s <= 'F' )
|
||||||
|
c = 16 * (10 + *s - 'A');
|
||||||
|
else if ( *s >= 'a' && *s <= 'f' )
|
||||||
|
c = 16 * (10 + *s - 'a');
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
s++;
|
||||||
|
if ( *s >= '0' && *s <= '9' )
|
||||||
|
c += *s - '0';
|
||||||
|
else if ( *s >= 'A' && *s <= 'F' )
|
||||||
|
c += 10 + *s - 'A';
|
||||||
|
else if ( *s >= 'a' && *s <= 'f' )
|
||||||
|
c += 10 + *s - 'a';
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
hash_key (const char *fpr, unsigned int *rhash)
|
||||||
|
{
|
||||||
|
unsigned int hash;
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if ( !fpr ) return -1;
|
||||||
|
if ( (c = hextobyte(fpr)) == -1 ) return -1;
|
||||||
|
hash = c;
|
||||||
|
if ( (c = hextobyte(fpr+2)) == -1 ) return -1;
|
||||||
|
hash |= c << 8;
|
||||||
|
if ( (c = hextobyte(fpr+4)) == -1 ) return -1;
|
||||||
|
hash |= c << 16;
|
||||||
|
if ( (c = hextobyte(fpr+6)) == -1 ) return -1;
|
||||||
|
hash |= c << 24;
|
||||||
|
|
||||||
|
*rhash = hash;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_key_cache_init (void)
|
||||||
|
{
|
||||||
|
if (key_cache_initialized)
|
||||||
|
return;
|
||||||
|
key_cache_size = 503;
|
||||||
|
key_cache = xtrycalloc (key_cache_size, sizeof *key_cache);
|
||||||
|
if (!key_cache) {
|
||||||
|
key_cache_size = 0;
|
||||||
|
key_cache_initialized = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* The upper bound for our cache size is
|
||||||
|
* key_cache_max_chain_length * key_cache_size
|
||||||
|
*/
|
||||||
|
key_cache_max_chain_length = 10;
|
||||||
|
key_cache_initialized = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_key_cache_add (GpgmeKey key)
|
||||||
|
{
|
||||||
|
struct subkey_s *k;
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* FIXME: add locking */
|
||||||
|
if (!key_cache_initialized)
|
||||||
|
_gpgme_key_cache_init ();
|
||||||
|
if (!key_cache_size)
|
||||||
|
return; /* cache was not enabled */
|
||||||
|
|
||||||
|
/* put the key under each fingerprint into the cache. We use the
|
||||||
|
* first 4 digits to calculate the hash */
|
||||||
|
for (k=&key->keys; k; k = k->next ) {
|
||||||
|
size_t n;
|
||||||
|
unsigned int hash;
|
||||||
|
struct key_cache_item_s *item;
|
||||||
|
|
||||||
|
if ( hash_key (k->fingerprint, &hash) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
hash %= key_cache_size;
|
||||||
|
for (item=key_cache[hash],n=0; item; item = item->next, n++) {
|
||||||
|
struct subkey_s *k2;
|
||||||
|
if (item->key == key)
|
||||||
|
break; /* already in cache */
|
||||||
|
/* now do a deeper check */
|
||||||
|
for (k2=&item->key->keys; k2; k2 = k2->next ) {
|
||||||
|
if( k2->fingerprint
|
||||||
|
&& !strcmp (k->fingerprint, k2->fingerprint) ) {
|
||||||
|
/* okay, replace it with the new copy */
|
||||||
|
gpgme_key_unref (item->key);
|
||||||
|
item->key = key;
|
||||||
|
gpgme_key_ref (item->key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (n > key_cache_max_chain_length ) { /* remove the last entries */
|
||||||
|
struct key_cache_item_s *last = NULL;
|
||||||
|
|
||||||
|
for (item=key_cache[hash];
|
||||||
|
item && n < key_cache_max_chain_length;
|
||||||
|
last = item, item = item->next, n++ ) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
if (last) {
|
||||||
|
struct key_cache_item_s *next;
|
||||||
|
|
||||||
|
assert (last->next == item);
|
||||||
|
last->next = NULL;
|
||||||
|
for ( ;item; item=next) {
|
||||||
|
next = item->next;
|
||||||
|
gpgme_key_unref (item->key);
|
||||||
|
item->key = NULL;
|
||||||
|
item->next = key_cache_unused_items;
|
||||||
|
key_cache_unused_items = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
item = key_cache_unused_items;
|
||||||
|
if (item) {
|
||||||
|
key_cache_unused_items = item->next;
|
||||||
|
item->next = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item = xtrymalloc (sizeof *item);
|
||||||
|
if (!item)
|
||||||
|
return; /* out of core */
|
||||||
|
}
|
||||||
|
|
||||||
|
item->key = key;
|
||||||
|
gpgme_key_ref (key);
|
||||||
|
item->next = key_cache[hash];
|
||||||
|
key_cache[hash] = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GpgmeKey
|
||||||
|
_gpgme_key_cache_get (const char *fpr)
|
||||||
|
{
|
||||||
|
struct key_cache_item_s *item;
|
||||||
|
unsigned int hash;
|
||||||
|
|
||||||
|
if (!key_cache_size)
|
||||||
|
return NULL; /* cache not (yet) enabled */
|
||||||
|
|
||||||
|
if (hash_key (fpr, &hash))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
hash %= key_cache_size;
|
||||||
|
for (item=key_cache[hash]; item; item = item->next) {
|
||||||
|
struct subkey_s *k;
|
||||||
|
|
||||||
|
for (k=&item->key->keys; k; k = k->next ) {
|
||||||
|
if( k->fingerprint && !strcmp (k->fingerprint, fpr) ) {
|
||||||
|
gpgme_key_ref (item->key);
|
||||||
|
return item->key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
pkalgo_to_string ( int algo )
|
||||||
|
{
|
||||||
|
switch (algo) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3: return "RSA";
|
||||||
|
case 16:
|
||||||
|
case 20: return "ElG";
|
||||||
|
case 17: return "DSA";
|
||||||
|
default: return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static GpgmeError
|
||||||
|
key_new ( GpgmeKey *r_key, int secret )
|
||||||
|
{
|
||||||
|
GpgmeKey key;
|
||||||
|
|
||||||
|
*r_key = NULL;
|
||||||
|
key = xtrycalloc ( 1, sizeof *key );
|
||||||
|
if (!key)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
key->ref_count = 1;
|
||||||
|
*r_key = key;
|
||||||
|
if (secret)
|
||||||
|
key->secret = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_key_new ( GpgmeKey *r_key )
|
||||||
|
{
|
||||||
|
return key_new ( r_key, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_key_new_secret ( GpgmeKey *r_key )
|
||||||
|
{
|
||||||
|
return key_new ( r_key, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_key_ref:
|
||||||
|
* @key: Key object
|
||||||
|
*
|
||||||
|
* To safe memory the Key objects implement reference counting.
|
||||||
|
* Use this function to bump the reference counter.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_key_ref ( GpgmeKey key )
|
||||||
|
{
|
||||||
|
return_if_fail (key);
|
||||||
|
key->ref_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct subkey_s *
|
||||||
|
add_subkey (GpgmeKey key, int secret)
|
||||||
|
{
|
||||||
|
struct subkey_s *k, *kk;
|
||||||
|
|
||||||
|
k = xtrycalloc (1, sizeof *k);
|
||||||
|
if (!k)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if( !(kk=key->keys.next) )
|
||||||
|
key->keys.next = k;
|
||||||
|
else {
|
||||||
|
while ( kk->next )
|
||||||
|
kk = kk->next;
|
||||||
|
kk->next = k;
|
||||||
|
}
|
||||||
|
if (secret)
|
||||||
|
k->secret = 1;
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct subkey_s *
|
||||||
|
_gpgme_key_add_subkey (GpgmeKey key)
|
||||||
|
{
|
||||||
|
return add_subkey (key, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct subkey_s *
|
||||||
|
_gpgme_key_add_secret_subkey (GpgmeKey key)
|
||||||
|
{
|
||||||
|
return add_subkey (key, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_key_release:
|
||||||
|
* @key: Key Object or NULL
|
||||||
|
*
|
||||||
|
* Release the key object. Note, that this function may not do an
|
||||||
|
* actual release if there are other shallow copies of the objects.
|
||||||
|
* You have to call this function for every newly created key object
|
||||||
|
* as well as for every gpgme_key_ref() done on the key object.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_key_release ( GpgmeKey key )
|
||||||
|
{
|
||||||
|
struct user_id_s *u, *u2;
|
||||||
|
struct subkey_s *k, *k2;
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return;
|
||||||
|
|
||||||
|
assert (key->ref_count);
|
||||||
|
if ( --key->ref_count )
|
||||||
|
return;
|
||||||
|
|
||||||
|
xfree (key->keys.fingerprint);
|
||||||
|
for (k = key->keys.next; k; k = k2 ) {
|
||||||
|
k2 = k->next;
|
||||||
|
xfree (k->fingerprint);
|
||||||
|
xfree (k);
|
||||||
|
}
|
||||||
|
for (u = key->uids; u; u = u2 ) {
|
||||||
|
u2 = u->next;
|
||||||
|
xfree (u);
|
||||||
|
}
|
||||||
|
xfree (key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_key_unref:
|
||||||
|
* @key: Key Object
|
||||||
|
*
|
||||||
|
* This is an alias for gpgme_key_release().
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_key_unref (GpgmeKey key)
|
||||||
|
{
|
||||||
|
gpgme_key_release (key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *
|
||||||
|
set_user_id_part ( char *tail, const char *buf, size_t len )
|
||||||
|
{
|
||||||
|
while ( len && (buf[len-1] == ' ' || buf[len-1] == '\t') )
|
||||||
|
len--;
|
||||||
|
for ( ; len; len--)
|
||||||
|
*tail++ = *buf++;
|
||||||
|
*tail++ = 0;
|
||||||
|
return tail;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
parse_user_id ( struct user_id_s *uid, char *tail )
|
||||||
|
{
|
||||||
|
const char *s, *start=NULL;
|
||||||
|
int in_name = 0;
|
||||||
|
int in_email = 0;
|
||||||
|
int in_comment = 0;
|
||||||
|
|
||||||
|
for (s=uid->name; *s; s++ ) {
|
||||||
|
if ( in_email ) {
|
||||||
|
if ( *s == '<' )
|
||||||
|
in_email++; /* not legal but anyway */
|
||||||
|
else if (*s== '>') {
|
||||||
|
if ( !--in_email ) {
|
||||||
|
if (!uid->email_part) {
|
||||||
|
uid->email_part = tail;
|
||||||
|
tail = set_user_id_part ( tail, start, s-start );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( in_comment ) {
|
||||||
|
if ( *s == '(' )
|
||||||
|
in_comment++;
|
||||||
|
else if (*s== ')') {
|
||||||
|
if ( !--in_comment ) {
|
||||||
|
if (!uid->comment_part) {
|
||||||
|
uid->comment_part = tail;
|
||||||
|
tail = set_user_id_part ( tail, start, s-start );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( *s == '<' ) {
|
||||||
|
if ( in_name ) {
|
||||||
|
if ( !uid->name_part ) {
|
||||||
|
uid->name_part = tail;
|
||||||
|
tail = set_user_id_part (tail, start, s-start );
|
||||||
|
}
|
||||||
|
in_name = 0;
|
||||||
|
}
|
||||||
|
in_email = 1;
|
||||||
|
start = s+1;
|
||||||
|
}
|
||||||
|
else if ( *s == '(' ) {
|
||||||
|
if ( in_name ) {
|
||||||
|
if ( !uid->name_part ) {
|
||||||
|
uid->name_part = tail;
|
||||||
|
tail = set_user_id_part (tail, start, s-start );
|
||||||
|
}
|
||||||
|
in_name = 0;
|
||||||
|
}
|
||||||
|
in_comment = 1;
|
||||||
|
start = s+1;
|
||||||
|
}
|
||||||
|
else if ( !in_name && *s != ' ' && *s != '\t' ) {
|
||||||
|
in_name = 1;
|
||||||
|
start = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( in_name ) {
|
||||||
|
if ( !uid->name_part ) {
|
||||||
|
uid->name_part = tail;
|
||||||
|
tail = set_user_id_part (tail, start, s-start );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* let unused parts point to an EOS */
|
||||||
|
tail--;
|
||||||
|
if (!uid->name_part)
|
||||||
|
uid->name_part = tail;
|
||||||
|
if (!uid->email_part)
|
||||||
|
uid->email_part = tail;
|
||||||
|
if (!uid->comment_part)
|
||||||
|
uid->comment_part = tail;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parse_x509_user_id ( struct user_id_s *uid, char *tail )
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s=uid->name;
|
||||||
|
if (*s == '<' && s[strlen(s)-1] == '>')
|
||||||
|
uid->email_part = s;
|
||||||
|
|
||||||
|
/* let unused parts point to an EOS */
|
||||||
|
tail--;
|
||||||
|
if (!uid->name_part)
|
||||||
|
uid->name_part = tail;
|
||||||
|
if (!uid->email_part)
|
||||||
|
uid->email_part = tail;
|
||||||
|
if (!uid->comment_part)
|
||||||
|
uid->comment_part = tail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Take a name from the --with-colon listing, remove certain escape sequences
|
||||||
|
* sequences and put it into the list of UIDs
|
||||||
|
*/
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_key_append_name (GpgmeKey key, const char *s)
|
||||||
|
{
|
||||||
|
struct user_id_s *uid;
|
||||||
|
char *d;
|
||||||
|
|
||||||
|
assert (key);
|
||||||
|
/* We can malloc a buffer of the same length, because the converted
|
||||||
|
string will never be larger. Actually we allocate it twice the
|
||||||
|
size, so that we are able to store the parsed stuff there too. */
|
||||||
|
uid = xtrymalloc ( sizeof *uid + 2*strlen (s)+3);
|
||||||
|
if (!uid)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
uid->revoked = 0;
|
||||||
|
uid->invalid = 0;
|
||||||
|
uid->validity = 0;
|
||||||
|
uid->name_part = NULL;
|
||||||
|
uid->email_part = NULL;
|
||||||
|
uid->comment_part = NULL;
|
||||||
|
uid->next = NULL;
|
||||||
|
d = uid->name;
|
||||||
|
|
||||||
|
while (*s)
|
||||||
|
{
|
||||||
|
if (*s != '\\')
|
||||||
|
*d++ = *s++;
|
||||||
|
else if (s[1] == '\\')
|
||||||
|
{
|
||||||
|
s++;
|
||||||
|
*d++ = *s++;
|
||||||
|
}
|
||||||
|
else if (s[1] == 'n')
|
||||||
|
{
|
||||||
|
s += 2;
|
||||||
|
*d++ = '\n';
|
||||||
|
}
|
||||||
|
else if (s[1] == 'r')
|
||||||
|
{
|
||||||
|
s += 2;
|
||||||
|
*d++ = '\r';
|
||||||
|
}
|
||||||
|
else if (s[1] == 'v')
|
||||||
|
{
|
||||||
|
s += 2;
|
||||||
|
*d++ = '\v';
|
||||||
|
}
|
||||||
|
else if (s[1] == 'b')
|
||||||
|
{
|
||||||
|
s += 2;
|
||||||
|
*d++ = '\b';
|
||||||
|
}
|
||||||
|
else if (s[1] == '0')
|
||||||
|
{
|
||||||
|
/* Hmmm: no way to express this */
|
||||||
|
s += 2;
|
||||||
|
*d++ = '\\';
|
||||||
|
*d++ = '\0';
|
||||||
|
}
|
||||||
|
else if (s[1] == 'x' && my_isdigit (s[2]) && my_isdigit (s[3]))
|
||||||
|
{
|
||||||
|
unsigned int val = (s[2]-'0')*16 + (s[3]-'0');
|
||||||
|
if (!val)
|
||||||
|
{
|
||||||
|
*d++ = '\\';
|
||||||
|
*d++ = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*(byte*)d++ = val;
|
||||||
|
s += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* should not happen */
|
||||||
|
s++;
|
||||||
|
*d++ = '\\';
|
||||||
|
*d++ = *s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*d++ = 0;
|
||||||
|
if (key->x509)
|
||||||
|
parse_x509_user_id (uid, d);
|
||||||
|
else
|
||||||
|
parse_user_id (uid, d);
|
||||||
|
|
||||||
|
if (key->uids)
|
||||||
|
{
|
||||||
|
struct user_id_s *u = key->uids;
|
||||||
|
while (u->next)
|
||||||
|
u = u->next;
|
||||||
|
u->next = uid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
key->uids = uid;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_otag ( GpgmeData d, const char *tag )
|
||||||
|
{
|
||||||
|
_gpgme_data_append_string ( d, " <" );
|
||||||
|
_gpgme_data_append_string ( d, tag );
|
||||||
|
_gpgme_data_append_string ( d, ">" );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_ctag ( GpgmeData d, const char *tag )
|
||||||
|
{
|
||||||
|
_gpgme_data_append_string ( d, "</" );
|
||||||
|
_gpgme_data_append_string ( d, tag );
|
||||||
|
_gpgme_data_append_string ( d, ">\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_tag_and_string ( GpgmeData d, const char *tag, const char *string )
|
||||||
|
{
|
||||||
|
add_otag (d, tag);
|
||||||
|
_gpgme_data_append_string_for_xml ( d, string );
|
||||||
|
add_ctag (d, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_tag_and_uint ( GpgmeData d, const char *tag, unsigned int val )
|
||||||
|
{
|
||||||
|
char buf[30];
|
||||||
|
sprintf (buf, "%u", val );
|
||||||
|
add_tag_and_string ( d, tag, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_tag_and_time ( GpgmeData d, const char *tag, time_t val )
|
||||||
|
{
|
||||||
|
char buf[30];
|
||||||
|
|
||||||
|
if (!val || val == (time_t)-1 )
|
||||||
|
return;
|
||||||
|
sprintf (buf, "%lu", (unsigned long)val );
|
||||||
|
add_tag_and_string ( d, tag, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
one_uid_as_xml (GpgmeData d, struct user_id_s *u)
|
||||||
|
{
|
||||||
|
_gpgme_data_append_string (d, " <userid>\n");
|
||||||
|
if ( u->invalid )
|
||||||
|
_gpgme_data_append_string ( d, " <invalid/>\n");
|
||||||
|
if ( u->revoked )
|
||||||
|
_gpgme_data_append_string ( d, " <revoked/>\n");
|
||||||
|
add_tag_and_string ( d, "raw", u->name );
|
||||||
|
if ( *u->name_part )
|
||||||
|
add_tag_and_string ( d, "name", u->name_part );
|
||||||
|
if ( *u->email_part )
|
||||||
|
add_tag_and_string ( d, "email", u->email_part );
|
||||||
|
if ( *u->comment_part )
|
||||||
|
add_tag_and_string ( d, "comment", u->comment_part );
|
||||||
|
_gpgme_data_append_string (d, " </userid>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_key_get_as_xml:
|
||||||
|
* @key: Key object
|
||||||
|
*
|
||||||
|
* Return the key object as an XML string. The classer has to free
|
||||||
|
* that string.
|
||||||
|
*
|
||||||
|
* Return value: An XML string or NULL in case of a memory problem or
|
||||||
|
* a NULL passed as @key
|
||||||
|
**/
|
||||||
|
char *
|
||||||
|
gpgme_key_get_as_xml ( GpgmeKey key )
|
||||||
|
{
|
||||||
|
GpgmeData d;
|
||||||
|
struct user_id_s *u;
|
||||||
|
struct subkey_s *k;
|
||||||
|
|
||||||
|
if ( !key )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if ( gpgme_data_new ( &d ) )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
_gpgme_data_append_string ( d, "<GnupgKeyblock>\n"
|
||||||
|
" <mainkey>\n" );
|
||||||
|
if ( key->keys.secret )
|
||||||
|
_gpgme_data_append_string ( d, " <secret/>\n");
|
||||||
|
if ( key->keys.flags.invalid )
|
||||||
|
_gpgme_data_append_string ( d, " <invalid/>\n");
|
||||||
|
if ( key->keys.flags.revoked )
|
||||||
|
_gpgme_data_append_string ( d, " <revoked/>\n");
|
||||||
|
if ( key->keys.flags.expired )
|
||||||
|
_gpgme_data_append_string ( d, " <expired/>\n");
|
||||||
|
if ( key->keys.flags.disabled )
|
||||||
|
_gpgme_data_append_string ( d, " <disabled/>\n");
|
||||||
|
add_tag_and_string (d, "keyid", key->keys.keyid );
|
||||||
|
if (key->keys.fingerprint)
|
||||||
|
add_tag_and_string (d, "fpr", key->keys.fingerprint );
|
||||||
|
add_tag_and_uint (d, "algo", key->keys.key_algo );
|
||||||
|
add_tag_and_uint (d, "len", key->keys.key_len );
|
||||||
|
add_tag_and_time (d, "created", key->keys.timestamp );
|
||||||
|
/*add_tag_and_time (d, "expires", key->expires );*/
|
||||||
|
_gpgme_data_append_string (d, " </mainkey>\n");
|
||||||
|
|
||||||
|
/* Now the user IDs. */
|
||||||
|
for (u = key->uids; u; u = u->next)
|
||||||
|
one_uid_as_xml (d,u);
|
||||||
|
|
||||||
|
/* and now the subkeys */
|
||||||
|
for (k=key->keys.next; k; k = k->next ) {
|
||||||
|
_gpgme_data_append_string (d, " <subkey>\n");
|
||||||
|
if ( k->secret )
|
||||||
|
_gpgme_data_append_string ( d, " <secret/>\n");
|
||||||
|
if ( k->flags.invalid )
|
||||||
|
_gpgme_data_append_string ( d, " <invalid/>\n");
|
||||||
|
if ( k->flags.revoked )
|
||||||
|
_gpgme_data_append_string ( d, " <revoked/>\n");
|
||||||
|
if ( k->flags.expired )
|
||||||
|
_gpgme_data_append_string ( d, " <expired/>\n");
|
||||||
|
if ( k->flags.disabled )
|
||||||
|
_gpgme_data_append_string ( d, " <disabled/>\n");
|
||||||
|
add_tag_and_string (d, "keyid", k->keyid );
|
||||||
|
if (k->fingerprint)
|
||||||
|
add_tag_and_string (d, "fpr", k->fingerprint );
|
||||||
|
add_tag_and_uint (d, "algo", k->key_algo );
|
||||||
|
add_tag_and_uint (d, "len", k->key_len );
|
||||||
|
add_tag_and_time (d, "created", k->timestamp );
|
||||||
|
_gpgme_data_append_string (d, " </subkey>\n");
|
||||||
|
}
|
||||||
|
_gpgme_data_append_string ( d, "</GnupgKeyblock>\n" );
|
||||||
|
|
||||||
|
return _gpgme_data_release_and_return_string (d);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
capabilities_to_string (struct subkey_s *k)
|
||||||
|
{
|
||||||
|
static char *strings[8] = {
|
||||||
|
"",
|
||||||
|
"c",
|
||||||
|
"s",
|
||||||
|
"sc",
|
||||||
|
"e",
|
||||||
|
"ec",
|
||||||
|
"es",
|
||||||
|
"esc"
|
||||||
|
};
|
||||||
|
return strings[ (!!k->flags.can_encrypt << 2)
|
||||||
|
| (!!k->flags.can_sign << 1)
|
||||||
|
| (!!k->flags.can_certify ) ];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_key_get_string_attr:
|
||||||
|
* @key: Key Object
|
||||||
|
* @what: Attribute specifier
|
||||||
|
* @reserved: Must be 0
|
||||||
|
* @idx: Index counter
|
||||||
|
*
|
||||||
|
* Return a attribute as specified by @what and @idx. Note that not
|
||||||
|
* all attributes can be returned as a string, in which case NULL is
|
||||||
|
* returned. @idx is used to iterate through attributes which do have
|
||||||
|
* more than one instance (e.g. user IDs or sub keys).
|
||||||
|
*
|
||||||
|
* Return value: NULL or an const string which is only valid as long
|
||||||
|
* as the key object itself is valid.
|
||||||
|
**/
|
||||||
|
const char *
|
||||||
|
gpgme_key_get_string_attr ( GpgmeKey key, GpgmeAttr what,
|
||||||
|
const void *reserved, int idx )
|
||||||
|
{
|
||||||
|
const char *val = NULL;
|
||||||
|
struct subkey_s *k;
|
||||||
|
struct user_id_s *u;
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return NULL;
|
||||||
|
if (reserved)
|
||||||
|
return NULL;
|
||||||
|
if (idx < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
switch (what) {
|
||||||
|
case GPGME_ATTR_KEYID:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = k->keyid;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_FPR:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = k->fingerprint;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_ALGO:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = pkalgo_to_string (k->key_algo);
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_LEN:
|
||||||
|
case GPGME_ATTR_CREATED:
|
||||||
|
case GPGME_ATTR_EXPIRE:
|
||||||
|
break; /* use another get function */
|
||||||
|
case GPGME_ATTR_OTRUST:
|
||||||
|
val = "[fixme]";
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_USERID:
|
||||||
|
for (u=key->uids; u && idx; u=u->next, idx-- )
|
||||||
|
;
|
||||||
|
val = u? u->name : NULL;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_NAME:
|
||||||
|
for (u=key->uids; u && idx; u=u->next, idx-- )
|
||||||
|
;
|
||||||
|
val = u? u->name_part : NULL;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_EMAIL:
|
||||||
|
for (u=key->uids; u && idx; u=u->next, idx-- )
|
||||||
|
;
|
||||||
|
val = u? u->email_part : NULL;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_COMMENT:
|
||||||
|
for (u=key->uids; u && idx; u=u->next, idx-- )
|
||||||
|
;
|
||||||
|
val = u? u->comment_part : NULL;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_VALIDITY:
|
||||||
|
for (u=key->uids; u && idx; u=u->next, idx-- )
|
||||||
|
;
|
||||||
|
if (u) {
|
||||||
|
switch (u->validity) {
|
||||||
|
case GPGME_VALIDITY_UNKNOWN: val = "?"; break;
|
||||||
|
case GPGME_VALIDITY_UNDEFINED: val = "q"; break;
|
||||||
|
case GPGME_VALIDITY_NEVER: val = "n"; break;
|
||||||
|
case GPGME_VALIDITY_MARGINAL: val = "m"; break;
|
||||||
|
case GPGME_VALIDITY_FULL: val = "f"; break;
|
||||||
|
case GPGME_VALIDITY_ULTIMATE: val = "u"; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_LEVEL: /* not used here */
|
||||||
|
case GPGME_ATTR_TYPE:
|
||||||
|
case GPGME_ATTR_KEY_REVOKED:
|
||||||
|
case GPGME_ATTR_KEY_INVALID:
|
||||||
|
case GPGME_ATTR_KEY_EXPIRED:
|
||||||
|
case GPGME_ATTR_KEY_DISABLED:
|
||||||
|
case GPGME_ATTR_UID_REVOKED:
|
||||||
|
case GPGME_ATTR_UID_INVALID:
|
||||||
|
case GPGME_ATTR_CAN_ENCRYPT:
|
||||||
|
case GPGME_ATTR_CAN_SIGN:
|
||||||
|
case GPGME_ATTR_CAN_CERTIFY:
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_IS_SECRET:
|
||||||
|
if (key->secret)
|
||||||
|
val = "1";
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_KEY_CAPS:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = capabilities_to_string (k);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_key_get_ulong_attr:
|
||||||
|
* @key:
|
||||||
|
* @what:
|
||||||
|
* @reserved:
|
||||||
|
* @idx:
|
||||||
|
*
|
||||||
|
* Return a attribute as specified by @what and @idx. Note that not
|
||||||
|
* all attributes can be returned as an integer, in which case 0 is
|
||||||
|
* returned. @idx is used to iterate through attributes which do have
|
||||||
|
* more than one instance (e.g. user IDs or sub keys).
|
||||||
|
*
|
||||||
|
* See gpgme.h for a list of attributes.
|
||||||
|
*
|
||||||
|
* Return value: 0 or the requested value.
|
||||||
|
**/
|
||||||
|
unsigned long
|
||||||
|
gpgme_key_get_ulong_attr ( GpgmeKey key, GpgmeAttr what,
|
||||||
|
const void *reserved, int idx )
|
||||||
|
{
|
||||||
|
unsigned long val = 0;
|
||||||
|
struct subkey_s *k;
|
||||||
|
struct user_id_s *u;
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return 0;
|
||||||
|
if (reserved)
|
||||||
|
return 0;
|
||||||
|
if (idx < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (what) {
|
||||||
|
case GPGME_ATTR_ALGO:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = (unsigned long)k->key_algo;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_LEN:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = (unsigned long)k->key_len;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_CREATED:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = k->timestamp < 0? 0L:(unsigned long)k->timestamp;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_VALIDITY:
|
||||||
|
for (u=key->uids; u && idx; u=u->next, idx-- )
|
||||||
|
;
|
||||||
|
if (u)
|
||||||
|
val = u->validity;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_IS_SECRET:
|
||||||
|
val = !!key->secret;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_KEY_REVOKED:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = k->flags.revoked;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_KEY_INVALID:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = k->flags.invalid;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_KEY_EXPIRED:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = k->flags.expired;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_KEY_DISABLED:
|
||||||
|
for (k=&key->keys; k && idx; k=k->next, idx-- )
|
||||||
|
;
|
||||||
|
if (k)
|
||||||
|
val = k->flags.disabled;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_UID_REVOKED:
|
||||||
|
for (u=key->uids; u && idx; u=u->next, idx-- )
|
||||||
|
;
|
||||||
|
if (u)
|
||||||
|
val = u->revoked;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_UID_INVALID:
|
||||||
|
for (u=key->uids; u && idx; u=u->next, idx-- )
|
||||||
|
;
|
||||||
|
if (u)
|
||||||
|
val = u->invalid;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_CAN_ENCRYPT:
|
||||||
|
val = key->gloflags.can_certify;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_CAN_SIGN:
|
||||||
|
val = key->gloflags.can_sign;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_CAN_CERTIFY:
|
||||||
|
val = key->gloflags.can_encrypt;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
81
tags/gpgme-0-3-0/gpgme/key.h
Normal file
81
tags/gpgme-0-3-0/gpgme/key.h
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/* key.h
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 KEY_H
|
||||||
|
#define KEY_H
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include "types.h"
|
||||||
|
#include "context.h"
|
||||||
|
|
||||||
|
struct subkey_s {
|
||||||
|
struct subkey_s *next;
|
||||||
|
unsigned int secret:1;
|
||||||
|
struct {
|
||||||
|
unsigned int revoked:1 ;
|
||||||
|
unsigned int expired:1 ;
|
||||||
|
unsigned int disabled:1 ;
|
||||||
|
unsigned int invalid:1 ;
|
||||||
|
unsigned int can_encrypt:1;
|
||||||
|
unsigned int can_sign:1;
|
||||||
|
unsigned int can_certify:1;
|
||||||
|
} flags;
|
||||||
|
unsigned int key_algo;
|
||||||
|
unsigned int key_len;
|
||||||
|
char keyid[16+1];
|
||||||
|
char *fingerprint; /* malloced hex digits */
|
||||||
|
time_t timestamp; /* -1 for invalid, 0 for not available */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct gpgme_key_s {
|
||||||
|
struct {
|
||||||
|
unsigned int revoked:1 ;
|
||||||
|
unsigned int expired:1 ;
|
||||||
|
unsigned int disabled:1 ;
|
||||||
|
unsigned int invalid:1 ;
|
||||||
|
unsigned int can_encrypt:1;
|
||||||
|
unsigned int can_sign:1;
|
||||||
|
unsigned int can_certify:1;
|
||||||
|
} gloflags;
|
||||||
|
unsigned int ref_count;
|
||||||
|
unsigned int secret:1;
|
||||||
|
unsigned int x509:1;
|
||||||
|
struct subkey_s keys;
|
||||||
|
struct user_id_s *uids;
|
||||||
|
};
|
||||||
|
|
||||||
|
void _gpgme_key_cache_init (void);
|
||||||
|
void _gpgme_key_cache_add (GpgmeKey key);
|
||||||
|
GpgmeKey _gpgme_key_cache_get (const char *fpr);
|
||||||
|
|
||||||
|
|
||||||
|
struct subkey_s *_gpgme_key_add_subkey (GpgmeKey key);
|
||||||
|
struct subkey_s *_gpgme_key_add_secret_subkey (GpgmeKey key);
|
||||||
|
GpgmeError _gpgme_key_append_name ( GpgmeKey key, const char *s );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* KEY_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
516
tags/gpgme-0-3-0/gpgme/keylist.c
Normal file
516
tags/gpgme-0-3-0/gpgme/keylist.c
Normal file
@ -0,0 +1,516 @@
|
|||||||
|
/* keylist.c - key listing
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
#include "key.h"
|
||||||
|
|
||||||
|
#define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
|
||||||
|
|
||||||
|
static void finish_key ( GpgmeCtx ctx );
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
keylist_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
||||||
|
{
|
||||||
|
if ( ctx->out_of_core )
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
case STATUS_EOF:
|
||||||
|
finish_key (ctx);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* ignore all other codes */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static time_t
|
||||||
|
parse_timestamp ( char *p )
|
||||||
|
{
|
||||||
|
if (!*p )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return (time_t)strtoul (p, NULL, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_mainkey_trust_info ( GpgmeKey key, const char *s )
|
||||||
|
{
|
||||||
|
/* look at letters and stop at the first digit */
|
||||||
|
for (; *s && !my_isdigit (*s); s++ ) {
|
||||||
|
switch (*s) {
|
||||||
|
case 'e': key->keys.flags.expired = 1; break;
|
||||||
|
case 'r': key->keys.flags.revoked = 1; break;
|
||||||
|
case 'd': key->keys.flags.disabled = 1; break;
|
||||||
|
case 'i': key->keys.flags.invalid = 1; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_userid_flags ( GpgmeKey key, const char *s )
|
||||||
|
{
|
||||||
|
/* look at letters and stop at the first digit */
|
||||||
|
for (; *s && !my_isdigit (*s); s++ ) {
|
||||||
|
switch (*s) {
|
||||||
|
case 'r': key->uids->revoked = 1; break;
|
||||||
|
case 'i': key->uids->invalid = 1; break;
|
||||||
|
|
||||||
|
case 'n': key->uids->validity = GPGME_VALIDITY_NEVER; break;
|
||||||
|
case 'm': key->uids->validity = GPGME_VALIDITY_MARGINAL; break;
|
||||||
|
case 'f': key->uids->validity = GPGME_VALIDITY_FULL; break;
|
||||||
|
case 'u': key->uids->validity = GPGME_VALIDITY_ULTIMATE; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_subkey_trust_info ( struct subkey_s *k, const char *s )
|
||||||
|
{
|
||||||
|
/* look at letters and stop at the first digit */
|
||||||
|
for (; *s && !my_isdigit (*s); s++ ) {
|
||||||
|
switch (*s) {
|
||||||
|
case 'e': k->flags.expired = 1; break;
|
||||||
|
case 'r': k->flags.revoked = 1; break;
|
||||||
|
case 'd': k->flags.disabled = 1; break;
|
||||||
|
case 'i': k->flags.invalid = 1; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_mainkey_capability ( GpgmeKey key, const char *s )
|
||||||
|
{
|
||||||
|
for (; *s ; s++ ) {
|
||||||
|
switch (*s) {
|
||||||
|
case 'e': key->keys.flags.can_encrypt = 1; break;
|
||||||
|
case 's': key->keys.flags.can_sign = 1; break;
|
||||||
|
case 'c': key->keys.flags.can_certify = 1; break;
|
||||||
|
case 'E': key->gloflags.can_encrypt = 1; break;
|
||||||
|
case 'S': key->gloflags.can_sign = 1; break;
|
||||||
|
case 'C': key->gloflags.can_certify = 1; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_subkey_capability ( struct subkey_s *k, const char *s )
|
||||||
|
{
|
||||||
|
for (; *s; s++ ) {
|
||||||
|
switch (*s) {
|
||||||
|
case 'e': k->flags.can_encrypt = 1; break;
|
||||||
|
case 's': k->flags.can_sign = 1; break;
|
||||||
|
case 'c': k->flags.can_certify = 1; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Note: we are allowed to modify line */
|
||||||
|
static void
|
||||||
|
keylist_colon_handler ( GpgmeCtx ctx, char *line )
|
||||||
|
{
|
||||||
|
char *p, *pend;
|
||||||
|
int field = 0;
|
||||||
|
enum {
|
||||||
|
RT_NONE, RT_SIG, RT_UID, RT_SUB, RT_PUB, RT_FPR, RT_SSB, RT_SEC, RT_CRT
|
||||||
|
} rectype = RT_NONE;
|
||||||
|
GpgmeKey key = ctx->tmp_key;
|
||||||
|
int i;
|
||||||
|
const char *trust_info = NULL;
|
||||||
|
struct subkey_s *sk = NULL;
|
||||||
|
|
||||||
|
if ( ctx->out_of_core )
|
||||||
|
return;
|
||||||
|
if (!line) { /* EOF */
|
||||||
|
finish_key (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (p = line; p; p = pend) {
|
||||||
|
field++;
|
||||||
|
pend = strchr (p, ':');
|
||||||
|
if (pend)
|
||||||
|
*pend++ = 0;
|
||||||
|
|
||||||
|
if ( field == 1 ) {
|
||||||
|
if ( !strcmp ( p, "sig" ) )
|
||||||
|
rectype = RT_SIG;
|
||||||
|
else if ( !strcmp ( p, "uid" ) && key ) {
|
||||||
|
rectype = RT_UID;
|
||||||
|
key = ctx->tmp_key;
|
||||||
|
}
|
||||||
|
else if ( !strcmp (p, "sub") && key ) {
|
||||||
|
/* start a new subkey */
|
||||||
|
rectype = RT_SUB;
|
||||||
|
if ( !(sk = _gpgme_key_add_subkey (key)) ) {
|
||||||
|
ctx->out_of_core=1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( !strcmp (p, "ssb") && key ) {
|
||||||
|
/* start a new secret subkey */
|
||||||
|
rectype = RT_SSB;
|
||||||
|
if ( !(sk = _gpgme_key_add_secret_subkey (key)) ) {
|
||||||
|
ctx->out_of_core=1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( !strcmp (p, "pub") ) {
|
||||||
|
/* start a new keyblock */
|
||||||
|
if ( _gpgme_key_new ( &key ) ) {
|
||||||
|
ctx->out_of_core=1; /* the only kind of error we can get*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rectype = RT_PUB;
|
||||||
|
finish_key ( ctx );
|
||||||
|
assert ( !ctx->tmp_key );
|
||||||
|
ctx->tmp_key = key;
|
||||||
|
}
|
||||||
|
else if ( !strcmp (p, "sec") ) {
|
||||||
|
/* start a new keyblock */
|
||||||
|
if ( _gpgme_key_new_secret ( &key ) ) {
|
||||||
|
ctx->out_of_core=1; /*the only kind of error we can get*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rectype = RT_SEC;
|
||||||
|
finish_key ( ctx );
|
||||||
|
assert ( !ctx->tmp_key );
|
||||||
|
ctx->tmp_key = key;
|
||||||
|
}
|
||||||
|
else if ( !strcmp (p, "crt") ) {
|
||||||
|
/* start a new certificate */
|
||||||
|
if ( _gpgme_key_new ( &key ) ) {
|
||||||
|
ctx->out_of_core=1; /* the only kind of error we can get*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
key->x509 = 1;
|
||||||
|
rectype = RT_CRT;
|
||||||
|
finish_key ( ctx );
|
||||||
|
assert ( !ctx->tmp_key );
|
||||||
|
ctx->tmp_key = key;
|
||||||
|
}
|
||||||
|
else if ( !strcmp ( p, "fpr" ) && key )
|
||||||
|
rectype = RT_FPR;
|
||||||
|
else
|
||||||
|
rectype = RT_NONE;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ( rectype == RT_PUB || rectype == RT_SEC || rectype == RT_CRT)
|
||||||
|
{
|
||||||
|
switch (field) {
|
||||||
|
case 2: /* trust info */
|
||||||
|
trust_info = p;
|
||||||
|
set_mainkey_trust_info (key, trust_info);
|
||||||
|
break;
|
||||||
|
case 3: /* key length */
|
||||||
|
i = atoi (p);
|
||||||
|
if ( i > 1 ) /* ignore invalid values */
|
||||||
|
key->keys.key_len = i;
|
||||||
|
break;
|
||||||
|
case 4: /* pubkey algo */
|
||||||
|
i = atoi (p);
|
||||||
|
if ( i > 1 && i < 128 )
|
||||||
|
key->keys.key_algo = i;
|
||||||
|
break;
|
||||||
|
case 5: /* long keyid */
|
||||||
|
if ( strlen (p) == DIM(key->keys.keyid)-1 )
|
||||||
|
strcpy (key->keys.keyid, p);
|
||||||
|
break;
|
||||||
|
case 6: /* timestamp (seconds) */
|
||||||
|
key->keys.timestamp = parse_timestamp (p);
|
||||||
|
break;
|
||||||
|
case 7: /* valid for n days */
|
||||||
|
break;
|
||||||
|
case 8: /* X.509 serial number */
|
||||||
|
/* fixme: store it */
|
||||||
|
break;
|
||||||
|
case 9: /* ownertrust */
|
||||||
|
break;
|
||||||
|
case 10: /* not used for gpg due to --fixed-list-mode option
|
||||||
|
but gpgsm stores the issuer name */
|
||||||
|
/* fixme: store issuer name */
|
||||||
|
break;
|
||||||
|
case 11: /* signature class */
|
||||||
|
break;
|
||||||
|
case 12: /* capabilities */
|
||||||
|
set_mainkey_capability (key, p );
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
pend = NULL; /* we can stop here */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( (rectype == RT_SUB || rectype== RT_SSB) && sk ) {
|
||||||
|
switch (field) {
|
||||||
|
case 2: /* trust info */
|
||||||
|
set_subkey_trust_info ( sk, p);
|
||||||
|
break;
|
||||||
|
case 3: /* key length */
|
||||||
|
i = atoi (p);
|
||||||
|
if ( i > 1 ) /* ignore invalid values */
|
||||||
|
sk->key_len = i;
|
||||||
|
break;
|
||||||
|
case 4: /* pubkey algo */
|
||||||
|
i = atoi (p);
|
||||||
|
if ( i > 1 && i < 128 )
|
||||||
|
sk->key_algo = i;
|
||||||
|
break;
|
||||||
|
case 5: /* long keyid */
|
||||||
|
if ( strlen (p) == DIM(sk->keyid)-1 )
|
||||||
|
strcpy (sk->keyid, p);
|
||||||
|
break;
|
||||||
|
case 6: /* timestamp (seconds) */
|
||||||
|
sk->timestamp = parse_timestamp (p);
|
||||||
|
break;
|
||||||
|
case 7: /* valid for n days */
|
||||||
|
break;
|
||||||
|
case 8: /* reserved (LID) */
|
||||||
|
break;
|
||||||
|
case 9: /* ownertrust */
|
||||||
|
break;
|
||||||
|
case 10:/* user ID n/a for a subkey */
|
||||||
|
break;
|
||||||
|
case 11: /* signature class */
|
||||||
|
break;
|
||||||
|
case 12: /* capability */
|
||||||
|
set_subkey_capability ( sk, p );
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
pend = NULL; /* we can stop here */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( rectype == RT_UID ) {
|
||||||
|
switch (field) {
|
||||||
|
case 2: /* trust info */
|
||||||
|
trust_info = p; /*save for later */
|
||||||
|
break;
|
||||||
|
case 10: /* user ID */
|
||||||
|
if ( _gpgme_key_append_name ( key, p) )
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
else {
|
||||||
|
if (trust_info)
|
||||||
|
set_userid_flags (key, trust_info);
|
||||||
|
}
|
||||||
|
pend = NULL; /* we can stop here */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( rectype == RT_FPR ) {
|
||||||
|
switch (field) {
|
||||||
|
case 10: /* fingerprint (take only the first one)*/
|
||||||
|
if ( !key->keys.fingerprint && *p ) {
|
||||||
|
key->keys.fingerprint = xtrystrdup (p);
|
||||||
|
if ( !key->keys.fingerprint )
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
}
|
||||||
|
pend = NULL; /* that is all we want */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have read an entire key into ctx->tmp_key and should now finish
|
||||||
|
* it. It is assumed that this releases ctx->tmp_key.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
finish_key ( GpgmeCtx ctx )
|
||||||
|
{
|
||||||
|
GpgmeKey key = ctx->tmp_key;
|
||||||
|
struct key_queue_item_s *q, *q2;
|
||||||
|
|
||||||
|
if (key) {
|
||||||
|
ctx->tmp_key = NULL;
|
||||||
|
|
||||||
|
_gpgme_key_cache_add (key);
|
||||||
|
|
||||||
|
q = xtrymalloc ( sizeof *q );
|
||||||
|
if ( !q ) {
|
||||||
|
gpgme_key_release (key);
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
q->key = key;
|
||||||
|
q->next = NULL;
|
||||||
|
/* fixme: lock queue. Use a tail pointer? */
|
||||||
|
if ( !(q2 = ctx->key_queue) )
|
||||||
|
ctx->key_queue = q;
|
||||||
|
else {
|
||||||
|
for ( ; q2->next; q2 = q2->next )
|
||||||
|
;
|
||||||
|
q2->next = q;
|
||||||
|
}
|
||||||
|
ctx->key_cond = 1;
|
||||||
|
/* fixme: unlock queue */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_keylist_start:
|
||||||
|
* @c: context
|
||||||
|
* @pattern: a GnuPG user ID or NULL for all
|
||||||
|
* @secret_only: List only keys where the secret part is available
|
||||||
|
*
|
||||||
|
* Note that this function also cancels a pending key listing
|
||||||
|
* operaton. To actually retrieve the key, use
|
||||||
|
* gpgme_op_keylist_next().
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an errorcode.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_keylist_start (GpgmeCtx ctx, const char *pattern, int secret_only)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
if (!ctx)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
ctx->pending = 1;
|
||||||
|
|
||||||
|
_gpgme_release_result (ctx);
|
||||||
|
ctx->out_of_core = 0;
|
||||||
|
|
||||||
|
if (ctx->engine)
|
||||||
|
{
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
gpgme_key_release (ctx->tmp_key);
|
||||||
|
ctx->tmp_key = NULL;
|
||||||
|
/* Fixme: Release key_queue. */
|
||||||
|
|
||||||
|
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS
|
||||||
|
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
_gpgme_engine_set_status_handler (ctx->engine, keylist_status_handler, ctx);
|
||||||
|
err = _gpgme_engine_set_colon_line_handler (ctx->engine,
|
||||||
|
keylist_colon_handler, ctx);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||||
|
|
||||||
|
err = _gpgme_engine_op_keylist (ctx->engine, pattern, secret_only, ctx->keylist_mode);
|
||||||
|
|
||||||
|
if (!err) /* And kick off the process. */
|
||||||
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
ctx->pending = 0;
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_keylist_next:
|
||||||
|
* @c: Context
|
||||||
|
* @r_key: Returned key object
|
||||||
|
*
|
||||||
|
* Return the next key from the key listing started with
|
||||||
|
* gpgme_op_keylist_start(). The caller must free the key using
|
||||||
|
* gpgme_key_release(). If the last key has already been returned the
|
||||||
|
* last time the function was called, %GPGME_EOF is returned and the
|
||||||
|
* operation is finished.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success, %GPGME_EOF or another error code.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_keylist_next (GpgmeCtx ctx, GpgmeKey *r_key)
|
||||||
|
{
|
||||||
|
struct key_queue_item_s *queue_item;
|
||||||
|
|
||||||
|
if (!r_key)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
*r_key = NULL;
|
||||||
|
if (!ctx)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
if (!ctx->pending )
|
||||||
|
return mk_error (No_Request);
|
||||||
|
if (ctx->out_of_core)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
|
if (!ctx->key_queue)
|
||||||
|
{
|
||||||
|
_gpgme_wait_on_condition (ctx, 1, &ctx->key_cond);
|
||||||
|
if (ctx->out_of_core)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
if (!ctx->key_cond)
|
||||||
|
{
|
||||||
|
ctx->pending = 0;
|
||||||
|
return mk_error (EOF);
|
||||||
|
}
|
||||||
|
ctx->key_cond = 0;
|
||||||
|
assert (ctx->key_queue);
|
||||||
|
}
|
||||||
|
queue_item = ctx->key_queue;
|
||||||
|
ctx->key_queue = queue_item->next;
|
||||||
|
if (!ctx->key_queue)
|
||||||
|
ctx->key_cond = 0;
|
||||||
|
|
||||||
|
*r_key = queue_item->key;
|
||||||
|
xfree (queue_item);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_keylist_end:
|
||||||
|
* @c: Context
|
||||||
|
*
|
||||||
|
* Ends the keylist operation and allows to use the context for some
|
||||||
|
* other operation next.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_keylist_end (GpgmeCtx ctx)
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
if (!ctx->pending )
|
||||||
|
return mk_error (No_Request);
|
||||||
|
if (ctx->out_of_core)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
|
ctx->pending = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
84
tags/gpgme-0-3-0/gpgme/mkerrors
Executable file
84
tags/gpgme-0-3-0/gpgme/mkerrors
Executable file
@ -0,0 +1,84 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# mkerrors - Extract error strings from gpgme.h
|
||||||
|
# and create C source for gpgme_strerror
|
||||||
|
# Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
# 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
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
/* Generated automatically by mkerrors */
|
||||||
|
/* Do not edit! */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "gpgme.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_strerror:
|
||||||
|
* @err: Error code
|
||||||
|
*
|
||||||
|
* This function returns a textual representaion of the given
|
||||||
|
* errocode. If this is an unknown value, a string with the value
|
||||||
|
* is returned (which is hold in a static buffer).
|
||||||
|
*
|
||||||
|
* Return value: String with the error description.
|
||||||
|
**/
|
||||||
|
const char *
|
||||||
|
gpgme_strerror (GpgmeError err)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
static char buf[25];
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
EOF
|
||||||
|
|
||||||
|
awk '
|
||||||
|
/GPGME_No_Error/ { okay=1 }
|
||||||
|
!okay {next}
|
||||||
|
/}/ { exit 0 }
|
||||||
|
/GPGME_[A-Za-z_]*/ { print_code($1) }
|
||||||
|
|
||||||
|
|
||||||
|
function print_code( s )
|
||||||
|
{
|
||||||
|
printf " case %s: s=\"", s ;
|
||||||
|
gsub(/_/, " ", s );
|
||||||
|
printf "%s\"; break;\n", substr(s,7);
|
||||||
|
}
|
||||||
|
'
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
default: sprintf (buf, "ec=%d", err ); s=buf; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
61
tags/gpgme-0-3-0/gpgme/mkstatus
Executable file
61
tags/gpgme-0-3-0/gpgme/mkstatus
Executable file
@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# mkstatus - Extract error strings from rungpg.h
|
||||||
|
# and create a lookup table
|
||||||
|
# Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# resetting collate is important, so that the bsearch works properly
|
||||||
|
LC_ALL=C
|
||||||
|
LC_COLLATE=C
|
||||||
|
export LC_ALL LC_COLLATE
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
/* Generated automatically by mkstatus */
|
||||||
|
/* Do not edit! */
|
||||||
|
|
||||||
|
struct status_table_s {
|
||||||
|
const char *name;
|
||||||
|
GpgStatusCode code;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct status_table_s status_table[] =
|
||||||
|
{
|
||||||
|
EOF
|
||||||
|
|
||||||
|
awk '
|
||||||
|
/STATUS_ENTER/ { okay=1 }
|
||||||
|
!okay {next}
|
||||||
|
/}/ { exit 0 }
|
||||||
|
/STATUS_[A-Za-z_]*/ { printf " { \"%s\", %s },\n", substr($1,8), $1 }
|
||||||
|
' | sort
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
{NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
103
tags/gpgme-0-3-0/gpgme/ops.h
Normal file
103
tags/gpgme-0-3-0/gpgme/ops.h
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/* ops.h - internal operations stuff
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 OPS_H
|
||||||
|
#define OPS_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
#include "rungpg.h"
|
||||||
|
|
||||||
|
/*-- gpgme.c --*/
|
||||||
|
void _gpgme_release_result ( GpgmeCtx c );
|
||||||
|
void _gpgme_set_op_info (GpgmeCtx c, GpgmeData info);
|
||||||
|
|
||||||
|
/*-- wait.c --*/
|
||||||
|
GpgmeCtx _gpgme_wait_on_condition ( GpgmeCtx c,
|
||||||
|
int hang, volatile int *cond );
|
||||||
|
void _gpgme_freeze_fd ( int fd );
|
||||||
|
void _gpgme_thaw_fd ( int fd );
|
||||||
|
|
||||||
|
|
||||||
|
/*-- recipient.c --*/
|
||||||
|
int _gpgme_recipients_all_valid ( const GpgmeRecipients rset );
|
||||||
|
|
||||||
|
|
||||||
|
/*-- data.c --*/
|
||||||
|
char * _gpgme_data_release_and_return_string ( GpgmeData dh );
|
||||||
|
GpgmeDataMode _gpgme_data_get_mode ( GpgmeData dh );
|
||||||
|
void _gpgme_data_set_mode ( GpgmeData dh, GpgmeDataMode mode );
|
||||||
|
char * _gpgme_data_get_as_string ( GpgmeData dh );
|
||||||
|
GpgmeError _gpgme_data_append ( GpgmeData dh,
|
||||||
|
const char *buffer, size_t length );
|
||||||
|
GpgmeError _gpgme_data_append_string ( GpgmeData dh, const char *s );
|
||||||
|
GpgmeError _gpgme_data_append_string_for_xml ( GpgmeData dh,
|
||||||
|
const char *s);
|
||||||
|
GpgmeError _gpgme_data_append_for_xml ( GpgmeData dh,
|
||||||
|
const char *buffer,
|
||||||
|
size_t len );
|
||||||
|
GpgmeError _gpgme_data_append_percentstring_for_xml ( GpgmeData dh,
|
||||||
|
const char *string );
|
||||||
|
|
||||||
|
GpgmeError _gpgme_data_unread (GpgmeData dh,
|
||||||
|
const char *buffer, size_t length );
|
||||||
|
|
||||||
|
int _gpgme_data_inbound_handler (void *opaque, int pid, int fd);
|
||||||
|
int _gpgme_data_outbound_handler (void *opaque, int pid, int fd);
|
||||||
|
|
||||||
|
|
||||||
|
/*-- key.c --*/
|
||||||
|
GpgmeError _gpgme_key_new ( GpgmeKey *r_key );
|
||||||
|
GpgmeError _gpgme_key_new_secret ( GpgmeKey *r_key );
|
||||||
|
|
||||||
|
|
||||||
|
/*-- verify.c --*/
|
||||||
|
void _gpgme_release_verify_result (VerifyResult result);
|
||||||
|
GpgmeSigStat _gpgme_intersect_stati (VerifyResult result);
|
||||||
|
void _gpgme_verify_status_handler (GpgmeCtx ctx, GpgStatusCode code,
|
||||||
|
char *args);
|
||||||
|
|
||||||
|
/*-- decrypt.c --*/
|
||||||
|
void _gpgme_release_decrypt_result (DecryptResult result);
|
||||||
|
void _gpgme_decrypt_status_handler (GpgmeCtx ctx, GpgStatusCode code,
|
||||||
|
char *args);
|
||||||
|
GpgmeError _gpgme_decrypt_start (GpgmeCtx ctx, GpgmeData ciph, GpgmeData plain,
|
||||||
|
void *status_handler);
|
||||||
|
GpgmeError _gpgme_decrypt_result (GpgmeCtx ctx);
|
||||||
|
|
||||||
|
/*-- sign.c --*/
|
||||||
|
void _gpgme_release_sign_result ( SignResult res );
|
||||||
|
|
||||||
|
/*-- encrypt.c --*/
|
||||||
|
void _gpgme_release_encrypt_result ( EncryptResult res );
|
||||||
|
|
||||||
|
/*-- passphrase.c --*/
|
||||||
|
void _gpgme_release_passphrase_result (PassphraseResult result);
|
||||||
|
void _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgStatusCode code,
|
||||||
|
char *args);
|
||||||
|
GpgmeError _gpgme_passphrase_start (GpgmeCtx ctx);
|
||||||
|
GpgmeError _gpgme_passphrase_result (GpgmeCtx ctx);
|
||||||
|
|
||||||
|
/*-- version.c --*/
|
||||||
|
const char *_gpgme_compare_versions (const char *my_version,
|
||||||
|
const char *req_version);
|
||||||
|
char *_gpgme_get_program_version (const char *const path);
|
||||||
|
|
||||||
|
#endif /* OPS_H */
|
187
tags/gpgme-0-3-0/gpgme/passphrase.c
Normal file
187
tags/gpgme-0-3-0/gpgme/passphrase.c
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
/* passphrase.c - passphrase functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
struct passphrase_result_s
|
||||||
|
{
|
||||||
|
int no_passphrase;
|
||||||
|
void *last_pw_handle;
|
||||||
|
char *userid_hint;
|
||||||
|
char *passphrase_info;
|
||||||
|
int bad_passphrase;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_release_passphrase_result (PassphraseResult result)
|
||||||
|
{
|
||||||
|
if (!result)
|
||||||
|
return;
|
||||||
|
xfree (result->passphrase_info);
|
||||||
|
xfree (result->userid_hint);
|
||||||
|
xfree (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
||||||
|
{
|
||||||
|
if (ctx->out_of_core)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!ctx->result.passphrase)
|
||||||
|
{
|
||||||
|
ctx->result.passphrase = xtrycalloc (1, sizeof *ctx->result.passphrase);
|
||||||
|
if (!ctx->result.passphrase)
|
||||||
|
{
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case STATUS_USERID_HINT:
|
||||||
|
xfree (ctx->result.passphrase->userid_hint);
|
||||||
|
if (!(ctx->result.passphrase->userid_hint = xtrystrdup (args)) )
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATUS_BAD_PASSPHRASE:
|
||||||
|
ctx->result.passphrase->bad_passphrase++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATUS_GOOD_PASSPHRASE:
|
||||||
|
ctx->result.passphrase->bad_passphrase = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATUS_NEED_PASSPHRASE:
|
||||||
|
case STATUS_NEED_PASSPHRASE_SYM:
|
||||||
|
xfree (ctx->result.passphrase->passphrase_info);
|
||||||
|
ctx->result.passphrase->passphrase_info = xtrystrdup (args);
|
||||||
|
if (!ctx->result.passphrase->passphrase_info)
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATUS_MISSING_PASSPHRASE:
|
||||||
|
DEBUG0 ("missing passphrase - stop\n");;
|
||||||
|
ctx->result.passphrase->no_passphrase = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* Ignore all other codes. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
command_handler (void *opaque, GpgStatusCode code, const char *key)
|
||||||
|
{
|
||||||
|
GpgmeCtx ctx = opaque;
|
||||||
|
|
||||||
|
if (!ctx->result.passphrase)
|
||||||
|
{
|
||||||
|
ctx->result.passphrase = xtrycalloc (1, sizeof *ctx->result.passphrase);
|
||||||
|
if (!ctx->result.passphrase)
|
||||||
|
{
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!code)
|
||||||
|
{
|
||||||
|
/* We have been called for cleanup. */
|
||||||
|
if (ctx->passphrase_cb)
|
||||||
|
{
|
||||||
|
/* Fixme: Take the key in account. */
|
||||||
|
ctx->passphrase_cb (ctx->passphrase_cb_value, NULL,
|
||||||
|
&ctx->result.passphrase->last_pw_handle);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!key || !ctx->passphrase_cb)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (code == STATUS_GET_HIDDEN && !strcmp (key, "passphrase.enter"))
|
||||||
|
{
|
||||||
|
const char *userid_hint = ctx->result.passphrase->userid_hint;
|
||||||
|
const char *passphrase_info = ctx->result.passphrase->passphrase_info;
|
||||||
|
int bad_passphrase = ctx->result.passphrase->bad_passphrase;
|
||||||
|
char *buf;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
ctx->result.passphrase->bad_passphrase = 0;
|
||||||
|
if (!userid_hint)
|
||||||
|
userid_hint = "[User ID hint missing]";
|
||||||
|
if (!passphrase_info)
|
||||||
|
passphrase_info = "[passphrase info missing]";
|
||||||
|
buf = xtrymalloc (20 + strlen (userid_hint)
|
||||||
|
+ strlen (passphrase_info) + 3);
|
||||||
|
if (!buf)
|
||||||
|
{
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
sprintf (buf, "%s\n%s\n%s",
|
||||||
|
bad_passphrase ? "TRY_AGAIN":"ENTER",
|
||||||
|
userid_hint, passphrase_info);
|
||||||
|
|
||||||
|
s = ctx->passphrase_cb (ctx->passphrase_cb_value,
|
||||||
|
buf, &ctx->result.passphrase->last_pw_handle);
|
||||||
|
xfree (buf);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_passphrase_start (GpgmeCtx ctx)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
if (ctx->passphrase_cb)
|
||||||
|
err = _gpgme_engine_set_command_handler (ctx->engine, command_handler, ctx);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
_gpgme_passphrase_result (GpgmeCtx ctx)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
if (!ctx->result.passphrase)
|
||||||
|
err = mk_error (General_Error);
|
||||||
|
else if (ctx->out_of_core)
|
||||||
|
err = mk_error (Out_Of_Core);
|
||||||
|
else if (ctx->result.passphrase->no_passphrase)
|
||||||
|
err = mk_error (No_Passphrase);
|
||||||
|
return err;
|
||||||
|
}
|
356
tags/gpgme-0-3-0/gpgme/posix-io.c
Normal file
356
tags/gpgme-0-3-0/gpgme/posix-io.c
Normal file
@ -0,0 +1,356 @@
|
|||||||
|
/* posix-io.c - Posix I/O functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#ifndef HAVE_DOSISH_SYSTEM
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include "syshdr.h"
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "io.h"
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
void (*handler)(int,void*);
|
||||||
|
void *value;
|
||||||
|
} notify_table[256];
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_io_read ( int fd, void *buffer, size_t count )
|
||||||
|
{
|
||||||
|
int nread;
|
||||||
|
|
||||||
|
DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int)count );
|
||||||
|
do {
|
||||||
|
nread = read (fd, buffer, count);
|
||||||
|
} while (nread == -1 && errno == EINTR );
|
||||||
|
DEBUG2 ("fd %d: got %d bytes\n", fd, nread );
|
||||||
|
if ( nread > 0 ) {
|
||||||
|
_gpgme_debug (2, "fd %d: got `%.*s'\n", fd, nread, buffer );
|
||||||
|
}
|
||||||
|
return nread;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_io_write ( int fd, const void *buffer, size_t count )
|
||||||
|
{
|
||||||
|
int nwritten;
|
||||||
|
|
||||||
|
DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int)count );
|
||||||
|
_gpgme_debug (2, "fd %d: write `%.*s'\n", fd, (int)count, buffer );
|
||||||
|
do {
|
||||||
|
nwritten = write (fd, buffer, count);
|
||||||
|
} while (nwritten == -1 && errno == EINTR );
|
||||||
|
DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int)nwritten );
|
||||||
|
return nwritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_io_pipe (int filedes[2], int inherit_idx)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = pipe (filedes);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
/* FIXME: Should get the old flags first. */
|
||||||
|
err = fcntl (filedes[1 - inherit_idx], F_SETFD, FD_CLOEXEC);
|
||||||
|
if (err < 0)
|
||||||
|
{
|
||||||
|
close (filedes[0]);
|
||||||
|
close (filedes[1]);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_io_close ( int fd )
|
||||||
|
{
|
||||||
|
if ( fd == -1 )
|
||||||
|
return -1;
|
||||||
|
/* first call the notify handler */
|
||||||
|
DEBUG1 ("closing fd %d", fd );
|
||||||
|
if ( fd >= 0 && fd < DIM (notify_table) ) {
|
||||||
|
if (notify_table[fd].handler) {
|
||||||
|
notify_table[fd].handler (fd, notify_table[fd].value);
|
||||||
|
notify_table[fd].handler = NULL;
|
||||||
|
notify_table[fd].value = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* then do the close */
|
||||||
|
return close (fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value)
|
||||||
|
{
|
||||||
|
assert (fd != -1);
|
||||||
|
|
||||||
|
if ( fd < 0 || fd >= DIM (notify_table) )
|
||||||
|
return -1;
|
||||||
|
DEBUG1 ("set notification for fd %d", fd );
|
||||||
|
notify_table[fd].handler = handler;
|
||||||
|
notify_table[fd].value = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_io_set_nonblocking ( int fd )
|
||||||
|
{
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
flags = fcntl (fd, F_GETFL, 0);
|
||||||
|
if (flags == -1)
|
||||||
|
return -1;
|
||||||
|
flags |= O_NONBLOCK;
|
||||||
|
return fcntl (fd, F_SETFL, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_io_spawn ( const char *path, char **argv,
|
||||||
|
struct spawn_fd_item_s *fd_child_list,
|
||||||
|
struct spawn_fd_item_s *fd_parent_list )
|
||||||
|
{
|
||||||
|
static volatile int fixed_signals;
|
||||||
|
pid_t pid;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ( !fixed_signals ) {
|
||||||
|
struct sigaction act;
|
||||||
|
|
||||||
|
sigaction( SIGPIPE, NULL, &act );
|
||||||
|
if( act.sa_handler == SIG_DFL ) {
|
||||||
|
act.sa_handler = SIG_IGN;
|
||||||
|
sigemptyset( &act.sa_mask );
|
||||||
|
act.sa_flags = 0;
|
||||||
|
sigaction( SIGPIPE, &act, NULL);
|
||||||
|
}
|
||||||
|
fixed_signals = 1;
|
||||||
|
/* fixme: This is not really MT safe */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pid = fork ();
|
||||||
|
if (pid == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ( !pid ) { /* child */
|
||||||
|
int duped_stdin = 0;
|
||||||
|
int duped_stderr = 0;
|
||||||
|
|
||||||
|
/* first close all fds which will not be duped */
|
||||||
|
for (i=0; fd_child_list[i].fd != -1; i++ ) {
|
||||||
|
if (fd_child_list[i].dup_to == -1 )
|
||||||
|
close (fd_child_list[i].fd);
|
||||||
|
}
|
||||||
|
/* and now dup and close the rest */
|
||||||
|
for (i=0; fd_child_list[i].fd != -1; i++ ) {
|
||||||
|
if (fd_child_list[i].dup_to != -1 ) {
|
||||||
|
if ( dup2 (fd_child_list[i].fd,
|
||||||
|
fd_child_list[i].dup_to ) == -1 ) {
|
||||||
|
DEBUG1 ("dup2 failed in child: %s\n", strerror (errno));
|
||||||
|
_exit (8);
|
||||||
|
}
|
||||||
|
if ( fd_child_list[i].dup_to == 0 )
|
||||||
|
duped_stdin=1;
|
||||||
|
if ( fd_child_list[i].dup_to == 2 )
|
||||||
|
duped_stderr=1;
|
||||||
|
close (fd_child_list[i].fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !duped_stdin || !duped_stderr ) {
|
||||||
|
int fd = open ( "/dev/null", O_RDWR );
|
||||||
|
if ( fd == -1 ) {
|
||||||
|
DEBUG1 ("can't open `/dev/null': %s\n", strerror (errno) );
|
||||||
|
_exit (8);
|
||||||
|
}
|
||||||
|
/* Make sure that the process has a connected stdin */
|
||||||
|
if ( !duped_stdin ) {
|
||||||
|
if ( dup2 ( fd, 0 ) == -1 ) {
|
||||||
|
DEBUG1("dup2(/dev/null, 0) failed: %s\n",
|
||||||
|
strerror (errno) );
|
||||||
|
_exit (8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !duped_stderr ) {
|
||||||
|
if ( dup2 ( fd, 2 ) == -1 ) {
|
||||||
|
DEBUG1 ("dup2(dev/null, 2) failed: %s\n", strerror (errno));
|
||||||
|
_exit (8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close (fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
execv ( path, argv );
|
||||||
|
/* Hmm: in that case we could write a special status code to the
|
||||||
|
* status-pipe */
|
||||||
|
DEBUG1 ("exec of `%s' failed\n", path );
|
||||||
|
_exit (8);
|
||||||
|
} /* end child */
|
||||||
|
|
||||||
|
/* .dup_to is not used in the parent list */
|
||||||
|
for (i=0; fd_parent_list[i].fd != -1; i++ ) {
|
||||||
|
close (fd_parent_list[i].fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_io_waitpid ( int pid, int hang, int *r_status, int *r_signal )
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
*r_status = 0;
|
||||||
|
*r_signal = 0;
|
||||||
|
if ( waitpid ( pid, &status, hang? 0 : WNOHANG ) == pid ) {
|
||||||
|
if ( WIFSIGNALED (status) ) {
|
||||||
|
*r_status = 4; /* Need some value here */
|
||||||
|
*r_signal = WTERMSIG (status);
|
||||||
|
}
|
||||||
|
else if ( WIFEXITED (status) ) {
|
||||||
|
*r_status = WEXITSTATUS (status);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*r_status = 4; /* oops */
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_io_kill ( int pid, int hard )
|
||||||
|
{
|
||||||
|
return kill ( pid, hard? SIGKILL : SIGTERM );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Select on the list of fds.
|
||||||
|
* Returns: -1 = error
|
||||||
|
* 0 = timeout or nothing to select
|
||||||
|
* >0 = number of signaled fds
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
_gpgme_io_select ( struct io_select_fd_s *fds, size_t nfds )
|
||||||
|
{
|
||||||
|
static fd_set readfds;
|
||||||
|
static fd_set writefds;
|
||||||
|
int any, i, max_fd, n, count;
|
||||||
|
struct timeval timeout = { 1, 0 }; /* Use a 1s timeout */
|
||||||
|
void *dbg_help = NULL;
|
||||||
|
|
||||||
|
FD_ZERO ( &readfds );
|
||||||
|
FD_ZERO ( &writefds );
|
||||||
|
max_fd = 0;
|
||||||
|
|
||||||
|
if ( _gpgme_debug_level () > 2 )
|
||||||
|
DEBUG_BEGIN (dbg_help, "gpgme:select on [ ");
|
||||||
|
any = 0;
|
||||||
|
for ( i=0; i < nfds; i++ ) {
|
||||||
|
if ( fds[i].fd == -1 )
|
||||||
|
continue;
|
||||||
|
if ( fds[i].frozen ) {
|
||||||
|
DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd );
|
||||||
|
}
|
||||||
|
else if ( fds[i].for_read ) {
|
||||||
|
assert ( !FD_ISSET ( fds[i].fd, &readfds ) );
|
||||||
|
FD_SET ( fds[i].fd, &readfds );
|
||||||
|
if ( fds[i].fd > max_fd )
|
||||||
|
max_fd = fds[i].fd;
|
||||||
|
DEBUG_ADD1 (dbg_help, "r%d ", fds[i].fd );
|
||||||
|
any = 1;
|
||||||
|
}
|
||||||
|
else if ( fds[i].for_write ) {
|
||||||
|
assert ( !FD_ISSET ( fds[i].fd, &writefds ) );
|
||||||
|
FD_SET ( fds[i].fd, &writefds );
|
||||||
|
if ( fds[i].fd > max_fd )
|
||||||
|
max_fd = fds[i].fd;
|
||||||
|
DEBUG_ADD1 (dbg_help, "w%d ", fds[i].fd );
|
||||||
|
any = 1;
|
||||||
|
}
|
||||||
|
fds[i].signaled = 0;
|
||||||
|
}
|
||||||
|
DEBUG_END (dbg_help, "]" );
|
||||||
|
if ( !any )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
count = select ( max_fd+1, &readfds, &writefds, NULL, &timeout );
|
||||||
|
} while ( count < 0 && errno == EINTR);
|
||||||
|
if ( count < 0 ) {
|
||||||
|
DEBUG1 ("_gpgme_io_select failed: %s\n", strerror (errno) );
|
||||||
|
return -1; /* error */
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( _gpgme_debug_level () > 2 )
|
||||||
|
DEBUG_BEGIN (dbg_help, "select OK [ " );
|
||||||
|
if (DEBUG_ENABLED(dbg_help)) {
|
||||||
|
for (i=0; i <= max_fd; i++ ) {
|
||||||
|
if (FD_ISSET (i, &readfds) )
|
||||||
|
DEBUG_ADD1 (dbg_help, "r%d ", i );
|
||||||
|
if (FD_ISSET (i, &writefds) )
|
||||||
|
DEBUG_ADD1 (dbg_help, "w%d ", i );
|
||||||
|
}
|
||||||
|
DEBUG_END (dbg_help, "]" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* n is used to optimize it a little bit */
|
||||||
|
for ( n=count, i=0; i < nfds && n ; i++ ) {
|
||||||
|
if ( fds[i].fd == -1 )
|
||||||
|
;
|
||||||
|
else if ( fds[i].for_read ) {
|
||||||
|
if ( FD_ISSET ( fds[i].fd, &readfds ) ) {
|
||||||
|
fds[i].signaled = 1;
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( fds[i].for_write ) {
|
||||||
|
if ( FD_ISSET ( fds[i].fd, &writefds ) ) {
|
||||||
|
fds[i].signaled = 1;
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*!HAVE_DOSISH_SYSTEM*/
|
||||||
|
|
||||||
|
|
||||||
|
|
71
tags/gpgme-0-3-0/gpgme/posix-sema.c
Normal file
71
tags/gpgme-0-3-0/gpgme/posix-sema.c
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/* posix-sema.c
|
||||||
|
* Copyright (C) 2001 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#ifndef HAVE_DOSISH_SYSTEM
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include "syshdr.h"
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "sema.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_sema_subsystem_init ()
|
||||||
|
{
|
||||||
|
/* FIXME: Posix semaphore support has not yet been implemented */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_sema_cs_enter ( struct critsect_s *s )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_sema_cs_leave (struct critsect_s *s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_sema_cs_destroy ( struct critsect_s *s )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*!HAVE_DOSISH_SYSTEM*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
53
tags/gpgme-0-3-0/gpgme/posix-util.c
Normal file
53
tags/gpgme-0-3-0/gpgme/posix-util.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/* posix-util.c - Utility functions for Posix
|
||||||
|
* Copyright (C) 2001 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#ifndef HAVE_DOSISH_SYSTEM
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
const char *
|
||||||
|
_gpgme_get_gpg_path (void)
|
||||||
|
{
|
||||||
|
#ifdef GPG_PATH
|
||||||
|
return GPG_PATH;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
_gpgme_get_gpgsm_path (void)
|
||||||
|
{
|
||||||
|
#ifdef GPGSM_PATH
|
||||||
|
return GPGSM_PATH;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*!HAVE_DOSISH_SYSTEM*/
|
240
tags/gpgme-0-3-0/gpgme/recipient.c
Normal file
240
tags/gpgme-0-3-0/gpgme/recipient.c
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
/* recipient.c - mainatin recipient sets
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "rungpg.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_recipients_new:
|
||||||
|
* @r_rset: Returns the new object.
|
||||||
|
*
|
||||||
|
* Create a new uninitialized Reciepient set Object.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an error code.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_recipients_new (GpgmeRecipients *r_rset)
|
||||||
|
{
|
||||||
|
GpgmeRecipients rset;
|
||||||
|
|
||||||
|
rset = xtrycalloc ( 1, sizeof *rset );
|
||||||
|
if (!rset)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
*r_rset = rset;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_recipients_release:
|
||||||
|
* @rset: Recipient Set object
|
||||||
|
*
|
||||||
|
* Free the given object.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_recipients_release ( GpgmeRecipients rset )
|
||||||
|
{
|
||||||
|
if (rset) {
|
||||||
|
struct user_id_s *u, *u2;
|
||||||
|
|
||||||
|
for (u = rset->list; u; u = u2) {
|
||||||
|
u2 = u->next;
|
||||||
|
xfree(u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xfree ( rset );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_recipients_add_name:
|
||||||
|
* @rset: Recipient Set object
|
||||||
|
* @name: user name or keyID
|
||||||
|
*
|
||||||
|
* Add a name to the recipient Set.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an error code
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_recipients_add_name (GpgmeRecipients rset, const char *name )
|
||||||
|
{
|
||||||
|
return gpgme_recipients_add_name_with_validity (
|
||||||
|
rset, name, GPGME_VALIDITY_UNKNOWN
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_recipients_add_name_with_validity:
|
||||||
|
* @rset: Recipient Set object
|
||||||
|
* @name: user name or keyID
|
||||||
|
* @val: Validity value
|
||||||
|
*
|
||||||
|
* Same as gpgme_recipients_add_name() but with explictly given key
|
||||||
|
* validity. Use one of the constants
|
||||||
|
* %GPGME_VALIDITY_UNKNOWN, %GPGME_VALIDITY_UNDEFINED,
|
||||||
|
* %GPGME_VALIDITY_NEVER, %GPGME_VALIDITY_MARGINAL,
|
||||||
|
* %GPGME_VALIDITY_FULL, %GPGME_VALIDITY_ULTIMATE5
|
||||||
|
* for the validity. %GPGME_VALIDITY_UNKNOWN is implicitly used by
|
||||||
|
* gpgme_recipients_add_name().
|
||||||
|
*
|
||||||
|
* Return value: o on success or an error value.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_recipients_add_name_with_validity (GpgmeRecipients rset,
|
||||||
|
const char *name,
|
||||||
|
GpgmeValidity val )
|
||||||
|
{
|
||||||
|
struct user_id_s *r;
|
||||||
|
|
||||||
|
if (!name || !rset )
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
r = xtrymalloc ( sizeof *r + strlen (name) );
|
||||||
|
if (!r)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
r->validity = val;
|
||||||
|
r->name_part = "";
|
||||||
|
r->email_part = "";
|
||||||
|
r->comment_part = "";
|
||||||
|
strcpy (r->name, name );
|
||||||
|
r->next = rset->list;
|
||||||
|
rset->list = r;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_recipients_count:
|
||||||
|
* @rset: Recipient Set object
|
||||||
|
*
|
||||||
|
* Return value: The number of recipients in the set.
|
||||||
|
**/
|
||||||
|
unsigned int
|
||||||
|
gpgme_recipients_count ( const GpgmeRecipients rset )
|
||||||
|
{
|
||||||
|
struct user_id_s *r;
|
||||||
|
unsigned int count = 0;
|
||||||
|
|
||||||
|
if ( rset ) {
|
||||||
|
for (r=rset->list ; r; r = r->next )
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_recipients_enum_open:
|
||||||
|
* @rset: Recipient Set object
|
||||||
|
* @ctx: Enumerator
|
||||||
|
*
|
||||||
|
* Start an enumeration on the Recipient Set object. The caller must pass
|
||||||
|
* the address of a void pointer which is used as the enumerator object.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an error code.
|
||||||
|
*
|
||||||
|
* See also: gpgme_recipients_enum_read(), gpgme_recipients_enum_close().
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_recipients_enum_open ( const GpgmeRecipients rset, void **ctx )
|
||||||
|
{
|
||||||
|
if (!rset || !ctx)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
*ctx = rset->list;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_recipients_enum_read:
|
||||||
|
* @rset: Recipient Set object
|
||||||
|
* @ctx: Enumerator
|
||||||
|
*
|
||||||
|
* Return the name of the next user name from the given recipient
|
||||||
|
* set. This name is valid as along as the @rset is valid and until
|
||||||
|
* the next call to this function.
|
||||||
|
*
|
||||||
|
* Return value: name or NULL for no more names.
|
||||||
|
*
|
||||||
|
* See also: gpgme_recipients_enum_read(), gpgme_recipients_enum_close().
|
||||||
|
**/
|
||||||
|
const char *
|
||||||
|
gpgme_recipients_enum_read ( const GpgmeRecipients rset, void **ctx )
|
||||||
|
{
|
||||||
|
struct user_id_s *r;
|
||||||
|
|
||||||
|
if (!rset || !ctx)
|
||||||
|
return NULL; /* oops */
|
||||||
|
|
||||||
|
r = *ctx;
|
||||||
|
if ( r ) {
|
||||||
|
const char *s = r->name;
|
||||||
|
r = r->next;
|
||||||
|
*ctx = r;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_recipients_enum_close:
|
||||||
|
* @rset: Recipient Set object
|
||||||
|
* @ctx: Enumerator
|
||||||
|
*
|
||||||
|
* Release the enumerator @rset for this object.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or %GPGME_Invalid_Value;
|
||||||
|
*
|
||||||
|
* See also: gpgme_recipients_enum_read(), gpgme_recipients_enum_close().
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_recipients_enum_close ( const GpgmeRecipients rset, void **ctx )
|
||||||
|
{
|
||||||
|
if (!rset || !ctx)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
*ctx = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_gpgme_recipients_all_valid ( const GpgmeRecipients rset )
|
||||||
|
{
|
||||||
|
struct user_id_s *r;
|
||||||
|
|
||||||
|
assert (rset);
|
||||||
|
for (r=rset->list ; r; r = r->next ) {
|
||||||
|
if (r->validity != GPGME_VALIDITY_FULL
|
||||||
|
&& r->validity != GPGME_VALIDITY_ULTIMATE )
|
||||||
|
return 0; /*no*/
|
||||||
|
}
|
||||||
|
return 1; /*yes*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
1482
tags/gpgme-0-3-0/gpgme/rungpg.c
Normal file
1482
tags/gpgme-0-3-0/gpgme/rungpg.c
Normal file
File diff suppressed because it is too large
Load Diff
142
tags/gpgme-0-3-0/gpgme/rungpg.h
Normal file
142
tags/gpgme-0-3-0/gpgme/rungpg.h
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
/* rungpg.h - gpg calling functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 RUNGPG_H
|
||||||
|
#define RUNGPG_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
STATUS_EOF ,
|
||||||
|
/* mkstatus starts here */
|
||||||
|
STATUS_ENTER ,
|
||||||
|
STATUS_LEAVE ,
|
||||||
|
STATUS_ABORT ,
|
||||||
|
STATUS_GOODSIG ,
|
||||||
|
STATUS_BADSIG ,
|
||||||
|
STATUS_ERRSIG ,
|
||||||
|
STATUS_BADARMOR ,
|
||||||
|
STATUS_RSA_OR_IDEA ,
|
||||||
|
STATUS_SIGEXPIRED ,
|
||||||
|
STATUS_KEYREVOKED ,
|
||||||
|
STATUS_TRUST_UNDEFINED ,
|
||||||
|
STATUS_TRUST_NEVER ,
|
||||||
|
STATUS_TRUST_MARGINAL ,
|
||||||
|
STATUS_TRUST_FULLY ,
|
||||||
|
STATUS_TRUST_ULTIMATE ,
|
||||||
|
STATUS_SHM_INFO ,
|
||||||
|
STATUS_SHM_GET ,
|
||||||
|
STATUS_SHM_GET_BOOL ,
|
||||||
|
STATUS_SHM_GET_HIDDEN ,
|
||||||
|
STATUS_NEED_PASSPHRASE ,
|
||||||
|
STATUS_USERID_HINT ,
|
||||||
|
STATUS_UNEXPECTED ,
|
||||||
|
STATUS_VALIDSIG ,
|
||||||
|
STATUS_SIG_ID ,
|
||||||
|
STATUS_ENC_TO ,
|
||||||
|
STATUS_NODATA ,
|
||||||
|
STATUS_BAD_PASSPHRASE ,
|
||||||
|
STATUS_NO_PUBKEY ,
|
||||||
|
STATUS_NO_SECKEY ,
|
||||||
|
STATUS_NEED_PASSPHRASE_SYM,
|
||||||
|
STATUS_DECRYPTION_FAILED ,
|
||||||
|
STATUS_DECRYPTION_OKAY ,
|
||||||
|
STATUS_MISSING_PASSPHRASE ,
|
||||||
|
STATUS_GOOD_PASSPHRASE ,
|
||||||
|
STATUS_GOODMDC ,
|
||||||
|
STATUS_BADMDC ,
|
||||||
|
STATUS_ERRMDC ,
|
||||||
|
STATUS_IMPORTED ,
|
||||||
|
STATUS_IMPORT_RES ,
|
||||||
|
STATUS_FILE_START ,
|
||||||
|
STATUS_FILE_DONE ,
|
||||||
|
STATUS_FILE_ERROR ,
|
||||||
|
STATUS_BEGIN_DECRYPTION ,
|
||||||
|
STATUS_END_DECRYPTION ,
|
||||||
|
STATUS_BEGIN_ENCRYPTION ,
|
||||||
|
STATUS_END_ENCRYPTION ,
|
||||||
|
STATUS_DELETE_PROBLEM ,
|
||||||
|
STATUS_GET_BOOL ,
|
||||||
|
STATUS_GET_LINE ,
|
||||||
|
STATUS_GET_HIDDEN ,
|
||||||
|
STATUS_GOT_IT ,
|
||||||
|
STATUS_PROGRESS ,
|
||||||
|
STATUS_SIG_CREATED ,
|
||||||
|
STATUS_SESSION_KEY ,
|
||||||
|
STATUS_NOTATION_NAME ,
|
||||||
|
STATUS_NOTATION_DATA ,
|
||||||
|
STATUS_POLICY_URL ,
|
||||||
|
STATUS_BEGIN_STREAM ,
|
||||||
|
STATUS_END_STREAM ,
|
||||||
|
STATUS_INV_RECP ,
|
||||||
|
STATUS_NO_RECP
|
||||||
|
} GpgStatusCode;
|
||||||
|
|
||||||
|
typedef void (*GpgStatusHandler)( GpgmeCtx, GpgStatusCode code, char *args );
|
||||||
|
typedef void (*GpgColonLineHandler)( GpgmeCtx, char *line );
|
||||||
|
typedef const char *(*GpgCommandHandler)(void*, GpgStatusCode code,
|
||||||
|
const char *keyword);
|
||||||
|
|
||||||
|
const char *_gpgme_gpg_get_version (void);
|
||||||
|
GpgmeError _gpgme_gpg_check_version (void);
|
||||||
|
|
||||||
|
GpgmeError _gpgme_gpg_new ( GpgObject *r_gpg );
|
||||||
|
void _gpgme_gpg_release ( GpgObject gpg );
|
||||||
|
void _gpgme_gpg_housecleaning (void);
|
||||||
|
void _gpgme_gpg_enable_pipemode ( GpgObject gpg );
|
||||||
|
GpgmeError _gpgme_gpg_add_arg ( GpgObject gpg, const char *arg );
|
||||||
|
GpgmeError _gpgme_gpg_add_data ( GpgObject gpg, GpgmeData data, int dup_to );
|
||||||
|
GpgmeError _gpgme_gpg_add_pm_data ( GpgObject gpg, GpgmeData data, int what );
|
||||||
|
void _gpgme_gpg_set_status_handler ( GpgObject gpg,
|
||||||
|
GpgStatusHandler fnc,
|
||||||
|
void *fnc_value );
|
||||||
|
GpgmeError _gpgme_gpg_set_colon_line_handler ( GpgObject gpg,
|
||||||
|
GpgColonLineHandler fnc,
|
||||||
|
void *fnc_value );
|
||||||
|
GpgmeError _gpgme_gpg_set_simple_line_handler ( GpgObject gpg,
|
||||||
|
GpgColonLineHandler fnc,
|
||||||
|
void *fnc_value );
|
||||||
|
GpgmeError _gpgme_gpg_set_command_handler ( GpgObject gpg,
|
||||||
|
GpgCommandHandler fnc,
|
||||||
|
void *fnc_value );
|
||||||
|
|
||||||
|
GpgmeError _gpgme_gpg_op_decrypt (GpgObject gpg, GpgmeData ciph,
|
||||||
|
GpgmeData plain);
|
||||||
|
GpgmeError _gpgme_gpg_op_delete (GpgObject gpg, GpgmeKey key, int allow_secret);
|
||||||
|
GpgmeError _gpgme_gpg_op_encrypt (GpgObject gpg, GpgmeRecipients recp,
|
||||||
|
GpgmeData plain, GpgmeData ciph,
|
||||||
|
int use_armor);
|
||||||
|
GpgmeError _gpgme_gpg_op_export (GpgObject gpg, GpgmeRecipients recp,
|
||||||
|
GpgmeData keydata, int use_armor);
|
||||||
|
GpgmeError _gpgme_gpg_op_genkey (GpgObject gpg, GpgmeData help_data,
|
||||||
|
int use_armor);
|
||||||
|
GpgmeError _gpgme_gpg_op_import (GpgObject gpg, GpgmeData keydata);
|
||||||
|
GpgmeError _gpgme_gpg_op_keylist (GpgObject gpg, const char *pattern,
|
||||||
|
int secret_only, int keylist_mode);
|
||||||
|
GpgmeError _gpgme_gpg_op_sign (GpgObject gpg, GpgmeData in, GpgmeData out,
|
||||||
|
GpgmeSigMode mode, int use_armor,
|
||||||
|
int use_textmode, GpgmeCtx ctx /* FIXME */);
|
||||||
|
GpgmeError _gpgme_gpg_op_trustlist (GpgObject gpg, const char *pattern);
|
||||||
|
GpgmeError _gpgme_gpg_op_verify (GpgObject gpg, GpgmeData sig, GpgmeData text);
|
||||||
|
GpgmeError _gpgme_gpg_spawn (GpgObject gpg, void *opaque);
|
||||||
|
|
||||||
|
#endif /* RUNGPG_H */
|
63
tags/gpgme-0-3-0/gpgme/sema.h
Normal file
63
tags/gpgme-0-3-0/gpgme/sema.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/* sema.h - definitions for semaphores
|
||||||
|
* Copyright (C) 2001 Werner Koch (dd9jn)
|
||||||
|
* 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 SEMA_H
|
||||||
|
#define SEMA_H
|
||||||
|
|
||||||
|
struct critsect_s {
|
||||||
|
const char *name;
|
||||||
|
void *private;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define DEFINE_GLOBAL_LOCK(name) \
|
||||||
|
struct critsect_s name = { #name, NULL }
|
||||||
|
#define DEFINE_STATIC_LOCK(name) \
|
||||||
|
static struct critsect_s name = { #name, NULL }
|
||||||
|
|
||||||
|
#define DECLARE_LOCK(name) struct critsect_s name
|
||||||
|
#define INIT_LOCK(a) do { \
|
||||||
|
(a).name = #a; \
|
||||||
|
(a).private = NULL; \
|
||||||
|
} while (0)
|
||||||
|
#define DESTROY_LOCK(name) _gpgme_sema_cs_destroy (&(name))
|
||||||
|
|
||||||
|
|
||||||
|
#define LOCK(name) do { \
|
||||||
|
_gpgme_sema_cs_enter ( &(name) );\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define UNLOCK(name) do { \
|
||||||
|
_gpgme_sema_cs_leave ( &(name) );\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
void _gpgme_sema_subsystem_init (void);
|
||||||
|
void _gpgme_sema_cs_enter ( struct critsect_s *s );
|
||||||
|
void _gpgme_sema_cs_leave ( struct critsect_s *s );
|
||||||
|
void _gpgme_sema_cs_destroy ( struct critsect_s *s );
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SEMA_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
283
tags/gpgme-0-3-0/gpgme/sign.c
Normal file
283
tags/gpgme-0-3-0/gpgme/sign.c
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
/* sign.c - signing functions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
#define SKIP_TOKEN_OR_RETURN(a) do { \
|
||||||
|
while (*(a) && *(a) != ' ') (a)++; \
|
||||||
|
while (*(a) == ' ') (a)++; \
|
||||||
|
if (!*(a)) \
|
||||||
|
return; /* oops */ \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
struct sign_result_s
|
||||||
|
{
|
||||||
|
int okay;
|
||||||
|
GpgmeData xmlinfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_release_sign_result (SignResult result)
|
||||||
|
{
|
||||||
|
if (!result)
|
||||||
|
return;
|
||||||
|
gpgme_data_release (result->xmlinfo);
|
||||||
|
xfree (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse the args and save the information
|
||||||
|
* <type> <pubkey algo> <hash algo> <class> <timestamp> <key fpr>
|
||||||
|
* in an XML structure. With args of NULL the xml structure is closed.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
append_xml_siginfo (GpgmeData *rdh, char *args)
|
||||||
|
{
|
||||||
|
GpgmeData dh;
|
||||||
|
char helpbuf[100];
|
||||||
|
int i;
|
||||||
|
char *s;
|
||||||
|
unsigned long ul;
|
||||||
|
|
||||||
|
if (!*rdh)
|
||||||
|
{
|
||||||
|
if (gpgme_data_new (rdh))
|
||||||
|
{
|
||||||
|
return; /* fixme: We are ignoring out-of-core */
|
||||||
|
}
|
||||||
|
dh = *rdh;
|
||||||
|
_gpgme_data_append_string (dh, "<GnupgOperationInfo>\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dh = *rdh;
|
||||||
|
_gpgme_data_append_string (dh, " </signature>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args)
|
||||||
|
{
|
||||||
|
/* Just close the XML containter. */
|
||||||
|
_gpgme_data_append_string (dh, "</GnupgOperationInfo>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gpgme_data_append_string (dh, " <signature>\n");
|
||||||
|
|
||||||
|
_gpgme_data_append_string (dh,
|
||||||
|
*args == 'D' ? " <detached/>\n" :
|
||||||
|
*args == 'C' ? " <cleartext/>\n" :
|
||||||
|
*args == 'S' ? " <standard/>\n" : "");
|
||||||
|
SKIP_TOKEN_OR_RETURN (args);
|
||||||
|
|
||||||
|
sprintf (helpbuf, " <algo>%d</algo>\n", atoi (args));
|
||||||
|
_gpgme_data_append_string (dh, helpbuf);
|
||||||
|
SKIP_TOKEN_OR_RETURN (args);
|
||||||
|
|
||||||
|
i = atoi (args);
|
||||||
|
sprintf (helpbuf, " <hashalgo>%d</hashalgo>\n", atoi (args));
|
||||||
|
_gpgme_data_append_string (dh, helpbuf);
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 1: s = "pgp-md5"; break;
|
||||||
|
case 2: s = "pgp-sha1"; break;
|
||||||
|
case 3: s = "pgp-ripemd160"; break;
|
||||||
|
case 5: s = "pgp-md2"; break;
|
||||||
|
case 6: s = "pgp-tiger192"; break;
|
||||||
|
case 7: s = "pgp-haval-5-160"; break;
|
||||||
|
case 8: s = "pgp-sha256"; break;
|
||||||
|
case 9: s = "pgp-sha384"; break;
|
||||||
|
case 10: s = "pgp-sha512"; break;
|
||||||
|
default: s = "pgp-unknown"; break;
|
||||||
|
}
|
||||||
|
sprintf (helpbuf, " <micalg>%s</micalg>\n", s);
|
||||||
|
_gpgme_data_append_string (dh,helpbuf);
|
||||||
|
SKIP_TOKEN_OR_RETURN (args);
|
||||||
|
|
||||||
|
sprintf (helpbuf, " <sigclass>%.2s</sigclass>\n", args);
|
||||||
|
_gpgme_data_append_string (dh, helpbuf);
|
||||||
|
SKIP_TOKEN_OR_RETURN (args);
|
||||||
|
|
||||||
|
ul = strtoul (args, NULL, 10);
|
||||||
|
sprintf (helpbuf, " <created>%lu</created>\n", ul);
|
||||||
|
_gpgme_data_append_string (dh, helpbuf);
|
||||||
|
SKIP_TOKEN_OR_RETURN (args);
|
||||||
|
|
||||||
|
/* Count the length of the finperprint. */
|
||||||
|
for (i = 0; args[i] && args[i] != ' '; i++)
|
||||||
|
;
|
||||||
|
_gpgme_data_append_string (dh, " <fpr>");
|
||||||
|
_gpgme_data_append (dh, args, i);
|
||||||
|
_gpgme_data_append_string (dh, "</fpr>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sign_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
||||||
|
{
|
||||||
|
_gpgme_passphrase_status_handler (ctx, code, args);
|
||||||
|
|
||||||
|
if (ctx->out_of_core)
|
||||||
|
return;
|
||||||
|
if (!ctx->result.sign)
|
||||||
|
{
|
||||||
|
ctx->result.sign = xtrycalloc (1, sizeof *ctx->result.sign);
|
||||||
|
if (!ctx->result.sign)
|
||||||
|
{
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case STATUS_EOF:
|
||||||
|
if (ctx->result.sign->okay)
|
||||||
|
{
|
||||||
|
append_xml_siginfo (&ctx->result.sign->xmlinfo, NULL);
|
||||||
|
_gpgme_set_op_info (ctx, ctx->result.sign->xmlinfo);
|
||||||
|
ctx->result.sign->xmlinfo = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATUS_SIG_CREATED:
|
||||||
|
/* FIXME: We have no error return for multiple signatures. */
|
||||||
|
append_xml_siginfo (&ctx->result.sign->xmlinfo, args);
|
||||||
|
ctx->result.sign->okay =1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_sign_start (GpgmeCtx ctx, GpgmeData in, GpgmeData out,
|
||||||
|
GpgmeSigMode mode)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
fail_on_pending_request (ctx);
|
||||||
|
ctx->pending = 1;
|
||||||
|
|
||||||
|
_gpgme_release_result (ctx);
|
||||||
|
ctx->out_of_core = 0;
|
||||||
|
|
||||||
|
if (mode != GPGME_SIG_MODE_NORMAL
|
||||||
|
&& mode != GPGME_SIG_MODE_DETACH
|
||||||
|
&& mode != GPGME_SIG_MODE_CLEAR)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
/* Create a process object. */
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS
|
||||||
|
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
/* Check the supplied data. */
|
||||||
|
if (gpgme_data_get_type (in) == GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (No_Data);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
_gpgme_data_set_mode (in, GPGME_DATA_MODE_OUT);
|
||||||
|
if (!out || gpgme_data_get_type (out) != GPGME_DATA_TYPE_NONE)
|
||||||
|
{
|
||||||
|
err = mk_error (Invalid_Value);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
_gpgme_data_set_mode (out, GPGME_DATA_MODE_IN);
|
||||||
|
|
||||||
|
err = _gpgme_passphrase_start (ctx);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
_gpgme_engine_set_status_handler (ctx->engine, sign_status_handler, ctx);
|
||||||
|
_gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity);
|
||||||
|
|
||||||
|
_gpgme_engine_op_sign (ctx->engine, in, out, mode, ctx->use_armor,
|
||||||
|
ctx->use_textmode, ctx /* FIXME */);
|
||||||
|
|
||||||
|
/* And kick off the process. */
|
||||||
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
ctx->pending = 0;
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_sign:
|
||||||
|
* @ctx: The context
|
||||||
|
* @in: Data to be signed
|
||||||
|
* @out: Detached signature
|
||||||
|
* @mode: Signature creation mode
|
||||||
|
*
|
||||||
|
* Create a detached signature for @in and write it to @out.
|
||||||
|
* The data will be signed using either the default key or the ones
|
||||||
|
* defined through @ctx.
|
||||||
|
* The defined modes for signature create are:
|
||||||
|
* <literal>
|
||||||
|
* GPGME_SIG_MODE_NORMAL (or 0)
|
||||||
|
* GPGME_SIG_MODE_DETACH
|
||||||
|
* GPGME_SIG_MODE_CLEAR
|
||||||
|
* </literal>
|
||||||
|
* Note that the settings done by gpgme_set_armor() and gpgme_set_textmode()
|
||||||
|
* are ignore for @mode GPGME_SIG_MODE_CLEAR.
|
||||||
|
*
|
||||||
|
* Return value: 0 on success or an error code.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_sign (GpgmeCtx ctx, GpgmeData in, GpgmeData out, GpgmeSigMode mode)
|
||||||
|
{
|
||||||
|
GpgmeError err = gpgme_op_sign_start (ctx, in, out, mode);
|
||||||
|
if (!err)
|
||||||
|
{
|
||||||
|
gpgme_wait (ctx, 1);
|
||||||
|
if (!ctx->result.sign)
|
||||||
|
err = mk_error (General_Error);
|
||||||
|
else if (ctx->out_of_core)
|
||||||
|
err = mk_error (Out_Of_Core);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = _gpgme_passphrase_result (ctx);
|
||||||
|
if (! err)
|
||||||
|
{
|
||||||
|
if (!ctx->result.sign->okay)
|
||||||
|
err = mk_error (No_Data); /* Hmmm: choose a better error? */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx->pending = 0;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
120
tags/gpgme-0-3-0/gpgme/signers.c
Normal file
120
tags/gpgme-0-3-0/gpgme/signers.c
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/* signers.c - maintain signer sets
|
||||||
|
* Copyright (C) 2001 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "rungpg.h"
|
||||||
|
|
||||||
|
/* The signers are directly stored in the context.
|
||||||
|
* So this is quite different to a recipient set.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_signers_clear:
|
||||||
|
* @c: context to clear from signers
|
||||||
|
*
|
||||||
|
* Remove the list of signers from the context and release the
|
||||||
|
* references to the signers keys.
|
||||||
|
*
|
||||||
|
* Return value: The version string or NULL
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gpgme_signers_clear (GpgmeCtx c)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
return_if_fail (c);
|
||||||
|
|
||||||
|
if (!c->signers)
|
||||||
|
return;
|
||||||
|
for (i = 0; i < c->signers_len; i++)
|
||||||
|
{
|
||||||
|
assert (c->signers[i]);
|
||||||
|
gpgme_key_unref (c->signers[i]);
|
||||||
|
c->signers[i] = NULL;
|
||||||
|
}
|
||||||
|
c->signers_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_signers_add:
|
||||||
|
* @c: context to add signer to
|
||||||
|
* @key: key to add
|
||||||
|
*
|
||||||
|
* Add the key as a signer to the context. Acquires a reference to
|
||||||
|
* the key.
|
||||||
|
*
|
||||||
|
* Return value: NULL on success, or an error code.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_signers_add (GpgmeCtx c, const GpgmeKey key)
|
||||||
|
{
|
||||||
|
if (!c || !key)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
if (c->signers_len == c->signers_size)
|
||||||
|
{
|
||||||
|
GpgmeKey *newarr;
|
||||||
|
int n = c->signers_size + 5;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
newarr = xtryrealloc (c->signers, n * sizeof (*newarr));
|
||||||
|
if (!newarr)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
for (j = c->signers_size; j < n; j++)
|
||||||
|
newarr[j] = NULL;
|
||||||
|
c->signers = newarr;
|
||||||
|
c->signers_size = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpgme_key_ref (key);
|
||||||
|
c->signers[c->signers_len++] = key;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_signers_enum:
|
||||||
|
* @c: context to retrieve signer from
|
||||||
|
* @seq: index of key to retrieve
|
||||||
|
*
|
||||||
|
* Acquire a reference to the signers key with the specified index
|
||||||
|
* number in the context and return it to the caller.
|
||||||
|
*
|
||||||
|
* Return value: A GpgmeKey or NULL on failure.
|
||||||
|
**/
|
||||||
|
GpgmeKey
|
||||||
|
gpgme_signers_enum (const GpgmeCtx c, int seq )
|
||||||
|
{
|
||||||
|
return_null_if_fail (c);
|
||||||
|
return_null_if_fail (seq >= 0);
|
||||||
|
|
||||||
|
if (seq >= c->signers_len)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
gpgme_key_ref (c->signers[seq]);
|
||||||
|
return c->signers[seq];
|
||||||
|
}
|
40
tags/gpgme-0-3-0/gpgme/syshdr.h
Normal file
40
tags/gpgme-0-3-0/gpgme/syshdr.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* syshdr.h - System specfic header files
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 SYSHDR_H
|
||||||
|
#define SYSHDR_H
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_DOSISH_SYSTEM
|
||||||
|
#include <io.h>
|
||||||
|
#else
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SYSHDR_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
304
tags/gpgme-0-3-0/gpgme/trustlist.c
Normal file
304
tags/gpgme-0-3-0/gpgme/trustlist.c
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
/* trustlist.c - key listing
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
#define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
|
||||||
|
|
||||||
|
struct gpgme_trust_item_s {
|
||||||
|
int level;
|
||||||
|
char keyid[16+1];
|
||||||
|
int type;
|
||||||
|
char ot[2];
|
||||||
|
char val[2];
|
||||||
|
char *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static GpgmeTrustItem
|
||||||
|
trust_item_new (void)
|
||||||
|
{
|
||||||
|
GpgmeTrustItem item;
|
||||||
|
|
||||||
|
item = xtrycalloc (1, sizeof *item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
trustlist_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
||||||
|
{
|
||||||
|
if ( ctx->out_of_core )
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
case STATUS_EOF:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This handler is used to parse the output of --list-trust-path:
|
||||||
|
* Format:
|
||||||
|
* level:keyid:type:recno:ot:val:mc:cc:name:
|
||||||
|
* With TYPE = U for a user ID
|
||||||
|
* K for a key
|
||||||
|
* The RECNO is either the one of the dir record or the one of the uid record.
|
||||||
|
* OT is the the usual trust letter and only availabel on K lines.
|
||||||
|
* VAL is the calcualted validity
|
||||||
|
* MC is the marginal trust counter and only available on U lines
|
||||||
|
* CC is the same for the complete count
|
||||||
|
* NAME ist the username and only printed on U lines
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
trustlist_colon_handler ( GpgmeCtx ctx, char *line )
|
||||||
|
{
|
||||||
|
char *p, *pend;
|
||||||
|
int field = 0;
|
||||||
|
GpgmeTrustItem item = NULL;
|
||||||
|
struct trust_queue_item_s *q, *q2;
|
||||||
|
|
||||||
|
if ( ctx->out_of_core )
|
||||||
|
return;
|
||||||
|
if (!line)
|
||||||
|
return; /* EOF */
|
||||||
|
|
||||||
|
for (p = line; p; p = pend) {
|
||||||
|
field++;
|
||||||
|
pend = strchr (p, ':');
|
||||||
|
if (pend)
|
||||||
|
*pend++ = 0;
|
||||||
|
|
||||||
|
switch (field) {
|
||||||
|
case 1: /* level */
|
||||||
|
q = xtrymalloc ( sizeof *q );
|
||||||
|
if ( !q ) {
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
q->next = NULL;
|
||||||
|
q->item = item = trust_item_new ();
|
||||||
|
if (!q->item) {
|
||||||
|
xfree (q);
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* fixme: lock queue, keep a tail pointer */
|
||||||
|
if ( !(q2 = ctx->trust_queue) )
|
||||||
|
ctx->trust_queue = q;
|
||||||
|
else {
|
||||||
|
for ( ; q2->next; q2 = q2->next )
|
||||||
|
;
|
||||||
|
q2->next = q;
|
||||||
|
}
|
||||||
|
/* fixme: unlock queue */
|
||||||
|
item->level = atoi (p);
|
||||||
|
break;
|
||||||
|
case 2: /* long keyid */
|
||||||
|
if ( strlen (p) == DIM(item->keyid)-1 )
|
||||||
|
strcpy (item->keyid, p);
|
||||||
|
break;
|
||||||
|
case 3: /* type */
|
||||||
|
item->type = *p == 'K'? 1 : *p == 'U'? 2 : 0;
|
||||||
|
break;
|
||||||
|
case 5: /* owner trust */
|
||||||
|
item->ot[0] = *p;
|
||||||
|
item->ot[1] = 0;
|
||||||
|
break;
|
||||||
|
case 6: /* validity */
|
||||||
|
item->val[0] = *p;
|
||||||
|
item->val[1] = 0;
|
||||||
|
break;
|
||||||
|
case 9: /* user ID */
|
||||||
|
item->name = xtrystrdup (p);
|
||||||
|
if (!item->name)
|
||||||
|
ctx->out_of_core = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field)
|
||||||
|
ctx->key_cond = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_trustlist_start (GpgmeCtx ctx, const char *pattern, int max_level)
|
||||||
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
|
|
||||||
|
fail_on_pending_request (ctx);
|
||||||
|
if (!pattern || !*pattern)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
|
||||||
|
ctx->pending = 1;
|
||||||
|
|
||||||
|
_gpgme_release_result (ctx);
|
||||||
|
ctx->out_of_core = 0;
|
||||||
|
|
||||||
|
if (ctx->engine)
|
||||||
|
{
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS
|
||||||
|
: GPGME_PROTOCOL_OpenPGP, &ctx->engine);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
_gpgme_engine_set_status_handler (ctx->engine, trustlist_status_handler, ctx);
|
||||||
|
err = _gpgme_engine_set_colon_line_handler (ctx->engine,
|
||||||
|
trustlist_colon_handler, ctx);
|
||||||
|
if (err)
|
||||||
|
goto leave;
|
||||||
|
|
||||||
|
err =_gpgme_engine_op_trustlist (ctx->engine, pattern);
|
||||||
|
|
||||||
|
if (!err) /* And kick off the process. */
|
||||||
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
if (err) {
|
||||||
|
ctx->pending = 0;
|
||||||
|
_gpgme_engine_release (ctx->engine);
|
||||||
|
ctx->engine = NULL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_trustlist_next ( GpgmeCtx c, GpgmeTrustItem *r_item )
|
||||||
|
{
|
||||||
|
struct trust_queue_item_s *q;
|
||||||
|
|
||||||
|
if (!r_item)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
*r_item = NULL;
|
||||||
|
if (!c)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
if ( !c->pending )
|
||||||
|
return mk_error (No_Request);
|
||||||
|
if ( c->out_of_core )
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
|
if ( !c->trust_queue ) {
|
||||||
|
_gpgme_wait_on_condition (c, 1, &c->key_cond );
|
||||||
|
if ( c->out_of_core )
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
if ( !c->key_cond )
|
||||||
|
return mk_error (EOF);
|
||||||
|
c->key_cond = 0;
|
||||||
|
assert ( c->trust_queue );
|
||||||
|
}
|
||||||
|
q = c->trust_queue;
|
||||||
|
c->trust_queue = q->next;
|
||||||
|
|
||||||
|
*r_item = q->item;
|
||||||
|
xfree (q);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
gpgme_trust_item_release ( GpgmeTrustItem item )
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
return;
|
||||||
|
xfree (item->name);
|
||||||
|
xfree (item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gpgme_trust_item_get_string_attr ( GpgmeTrustItem item, GpgmeAttr what,
|
||||||
|
const void *reserved, int idx )
|
||||||
|
{
|
||||||
|
const char *val = NULL;
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
return NULL;
|
||||||
|
if (reserved)
|
||||||
|
return NULL;
|
||||||
|
if (idx)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
switch (what) {
|
||||||
|
case GPGME_ATTR_KEYID:
|
||||||
|
val = item->keyid;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_OTRUST:
|
||||||
|
val = item->ot;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_VALIDITY:
|
||||||
|
val = item->val;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_USERID:
|
||||||
|
val = item->name;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
gpgme_trust_item_get_int_attr ( GpgmeTrustItem item, GpgmeAttr what,
|
||||||
|
const void *reserved, int idx )
|
||||||
|
{
|
||||||
|
int val = 0;
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
return 0;
|
||||||
|
if (reserved)
|
||||||
|
return 0;
|
||||||
|
if (idx)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (what) {
|
||||||
|
case GPGME_ATTR_LEVEL:
|
||||||
|
val = item->level;
|
||||||
|
break;
|
||||||
|
case GPGME_ATTR_TYPE:
|
||||||
|
val = item->type;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
87
tags/gpgme-0-3-0/gpgme/types.h
Normal file
87
tags/gpgme-0-3-0/gpgme/types.h
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/* types.h - Some type definitions
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 TYPES_H
|
||||||
|
#define TYPES_H
|
||||||
|
|
||||||
|
#include "gpgme.h" /* external objects and prototypes */
|
||||||
|
|
||||||
|
#ifndef HAVE_BYTE_TYPEDEF
|
||||||
|
typedef unsigned char byte;
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_ULONG_TYPEDEF
|
||||||
|
typedef unsigned long ulong;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GPGME_DATA_MODE_NONE = 0,
|
||||||
|
GPGME_DATA_MODE_IN = 1,
|
||||||
|
GPGME_DATA_MODE_OUT = 2,
|
||||||
|
GPGME_DATA_MODE_INOUT = 3
|
||||||
|
} GpgmeDataMode;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Declaration of internal objects
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-- engine.c --*/
|
||||||
|
struct engine_object_s;
|
||||||
|
typedef struct engine_object_s *EngineObject;
|
||||||
|
|
||||||
|
/*-- engine-gpgsm.c --*/
|
||||||
|
struct gpgsm_object_s;
|
||||||
|
typedef struct gpgsm_object_s *GpgsmObject;
|
||||||
|
|
||||||
|
/*-- rungpg.c --*/
|
||||||
|
struct gpg_object_s;
|
||||||
|
typedef struct gpg_object_s *GpgObject;
|
||||||
|
|
||||||
|
/*-- verify.c --*/
|
||||||
|
struct verify_result_s;
|
||||||
|
typedef struct verify_result_s *VerifyResult;
|
||||||
|
|
||||||
|
/*-- decrypt.c --*/
|
||||||
|
struct decrypt_result_s;
|
||||||
|
typedef struct decrypt_result_s *DecryptResult;
|
||||||
|
|
||||||
|
/*-- sign.c --*/
|
||||||
|
struct sign_result_s;
|
||||||
|
typedef struct sign_result_s *SignResult;
|
||||||
|
|
||||||
|
/*-- encrypt.c --*/
|
||||||
|
struct encrypt_result_s;
|
||||||
|
typedef struct encrypt_result_s *EncryptResult;
|
||||||
|
|
||||||
|
/*-- passphrase.c --*/
|
||||||
|
struct passphrase_result_s;
|
||||||
|
typedef struct passphrase_result_s *PassphraseResult;
|
||||||
|
|
||||||
|
/*-- key.c --*/
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TYPES_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
66
tags/gpgme-0-3-0/gpgme/util.c
Normal file
66
tags/gpgme-0-3-0/gpgme/util.c
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* util.c
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
void *
|
||||||
|
_gpgme_malloc (size_t n )
|
||||||
|
{
|
||||||
|
return malloc (n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
_gpgme_calloc (size_t n, size_t m )
|
||||||
|
{
|
||||||
|
return calloc (n, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
_gpgme_realloc (void *p, size_t n)
|
||||||
|
{
|
||||||
|
return realloc (p, n );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *
|
||||||
|
_gpgme_strdup (const char *p)
|
||||||
|
{
|
||||||
|
return strdup (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
_gpgme_free ( void *a )
|
||||||
|
{
|
||||||
|
free (a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
132
tags/gpgme-0-3-0/gpgme/util.h
Normal file
132
tags/gpgme-0-3-0/gpgme/util.h
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/* util.h
|
||||||
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
|
* 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 UTIL_H
|
||||||
|
#define UTIL_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
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 xtrymalloc(a) _gpgme_malloc((a))
|
||||||
|
#define xtrycalloc(a,b) _gpgme_calloc((a),(b))
|
||||||
|
#define xtryrealloc(a,b) _gpgme_realloc((a),(b))
|
||||||
|
#define xtrystrdup(a) _gpgme_strdup((a))
|
||||||
|
#define xfree(a) _gpgme_free((a))
|
||||||
|
|
||||||
|
|
||||||
|
#define mk_error(a) ( GPGME_##a )
|
||||||
|
|
||||||
|
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
|
||||||
|
#define DIMof(type,member) DIM(((type *)0)->member)
|
||||||
|
#ifndef STR
|
||||||
|
#define STR(v) #v
|
||||||
|
#endif
|
||||||
|
#define STR2(v) STR(v)
|
||||||
|
|
||||||
|
|
||||||
|
void _gpgme_debug (int level, const char *format, ...);
|
||||||
|
int _gpgme_debug_level (void);
|
||||||
|
void _gpgme_debug_begin ( void **helper, int level, const char *text);
|
||||||
|
int _gpgme_debug_enabled ( void **helper );
|
||||||
|
void _gpgme_debug_add (void **helper, const char *format, ...);
|
||||||
|
void _gpgme_debug_end (void **helper, const char *text);
|
||||||
|
|
||||||
|
#define DEBUG0(x) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x )
|
||||||
|
#define DEBUG1(x,a) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__)": " x, (a) )
|
||||||
|
#define DEBUG2(x,a,b) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x, (a), (b) )
|
||||||
|
#define DEBUG3(x,a,b,c) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x, (a), (b), (c) )
|
||||||
|
#define DEBUG4(x,a,b,c,d) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x, (a), (b), (c), (d) )
|
||||||
|
#define DEBUG5(x,a,b,c,d,e) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x, (a), (b), (c), (d), (e) )
|
||||||
|
#define DEBUG6(x,a,b,c,d,e,f) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x, (a), (b), (c), (d), (e), (f) )
|
||||||
|
#define DEBUG7(x,a,b,c,d,e,f,g) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x, (a), (b), (c), (d), (e), (f), (g) )
|
||||||
|
#define DEBUG8(x,a,b,c,d,e,f,g,h) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x, (a), (b), (c), (d), (e), (f), (g), (h) )
|
||||||
|
#define DEBUG9(x,a,b,c,d,e,f,g,h,i) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x, (a), (b), (c), (d), (e), (f), (g), (h), (i) )
|
||||||
|
#define DEBUG10(x,a,b,c,d,e,f,g,h,i,j) _gpgme_debug (1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x, (a), (b), (c), (d), (e), (f), (g), (h), (i), (j) )
|
||||||
|
|
||||||
|
#define DEBUG_BEGIN(y,x) _gpgme_debug_begin (&(y), 1, __FILE__ ":" \
|
||||||
|
STR2 (__LINE__) ": " x )
|
||||||
|
#define DEBUG_ENABLED(y) _gpgme_debug_enabled(&(y))
|
||||||
|
#define DEBUG_ADD0(y,x) _gpgme_debug_add (&(y), (x), \
|
||||||
|
)
|
||||||
|
#define DEBUG_ADD1(y,x,a) _gpgme_debug_add (&(y), (x), \
|
||||||
|
(a) )
|
||||||
|
#define DEBUG_ADD2(y,x,a,b) _gpgme_debug_add (&(y), (x), \
|
||||||
|
(a), (b) )
|
||||||
|
#define DEBUG_ADD3(y,x,a,b,c) _gpgme_debug_add (&(y), (x), \
|
||||||
|
(a), (b), (c) )
|
||||||
|
#define DEBUG_ADD4(y,x,a,b,c,d) _gpgme_debug_add (&(y), (x), \
|
||||||
|
(a), (b), (c), (d) )
|
||||||
|
#define DEBUG_ADD5(y,x,a,b,c,d,e) _gpgme_debug_add (&(y), (x), \
|
||||||
|
(a), (b), (c), (d), (e) )
|
||||||
|
#define DEBUG_END(y,x) _gpgme_debug_end (&(y), (x) )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef HAVE_STPCPY
|
||||||
|
char *stpcpy (char *a, const char *b);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define return_if_fail(expr) do { \
|
||||||
|
if (!(expr)) { \
|
||||||
|
fprintf (stderr, "%s:%d: assertion `%s' failed", \
|
||||||
|
__FILE__, __LINE__, #expr ); \
|
||||||
|
return; \
|
||||||
|
} } while (0)
|
||||||
|
#define return_null_if_fail(expr) do { \
|
||||||
|
if (!(expr)) { \
|
||||||
|
fprintf (stderr, "%s:%d: assertion `%s' failed", \
|
||||||
|
__FILE__, __LINE__, #expr ); \
|
||||||
|
return NULL; \
|
||||||
|
} } while (0)
|
||||||
|
#define return_val_if_fail(expr,val) do { \
|
||||||
|
if (!(expr)) { \
|
||||||
|
fprintf (stderr, "%s:%d: assertion `%s' failed", \
|
||||||
|
__FILE__, __LINE__, #expr ); \
|
||||||
|
return (val); \
|
||||||
|
} } while (0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*-- {posix,w32}-util.c --*/
|
||||||
|
const char *_gpgme_get_gpg_path (void);
|
||||||
|
const char *_gpgme_get_gpgsm_path (void);
|
||||||
|
|
||||||
|
#endif /* UTIL_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user