Compare commits

..

2 Commits

Author SHA1 Message Date
Ben Kibbey
fff2049c1b Fix crash with built-in [v]asprintf().
* src/vasprintf.c (__gpgme_vasprintf): Copy the va_list.
--
Not sure why it needs to be done. Maybe because of dereferencing the
pointer while doing va_copy() int_vasprintf()? If we remove the
_BSD_VA_LIST stuff and pass a regular va_list all is fine.
2014-10-16 19:32:13 -04:00
Ben Kibbey
aea2c168fc Add gpgme_set_global_malloc_hooks().
* configure.ac: Remove check for vasprintf().
* doc/gpgme.texi: Add documentation.
* src/gpgme.h.in (gpgme_malloc_hooks,gpgme_malloc_hooks_t): New.
* src/gpgme.h.in (gpgme_set_global_malloc_hooks): New prototype.
* src/mem.c, src/mem.h: New.
* src/gpgme.c (gpgme_set_global_malloc_hooks): New.
* src/gpgme.def, src/libgpgme.vers: Add gpgme_set_global_malloc_hooks.
* src/vasprintf.c (vasprintf): Rename to _gpgme_vasprintf().
* src/vasprintf.c (asprintf): Rename to _gpgme_asprintf().
* src/Makefile.am: Add mem.c, mem.h and vasprintf.c to main_sources.
* src/assuan-support.c, src/ath-pthread.c, src/conversion.c,
src/data-compat.c, src/data-identify.c, src/data-mem.c, src/data.c,
src/debug.c, src/decrypt.c, src/dirinfo.c, src/encrypt.c,
src/engine-assuan.c, src/engine-g13.c, src/engine-gpg.c,
src/engine-gpgconf.c, src/engine-gpgsm.c, src/engine-spawn.c,
src/engine-uiserver.c, src/engine.c, src/export.c, src/genkey.c,
src/get-env.c, src/gpgme-w32spawn.c, src/gpgme.c, src/import.c,
src/key.c, src/keylist.c, src/op-support.c, src/passphrase.c,
src/posix-io.c, src/posix-util.c, src/progress.c, src/setenv.c,
src/sig-notation.c, src/sign.c, src/signers.c, src/trust-item.c,
src/trustlist.c, src/util.h, src/verify.c, src/version.c,
src/vfs-create.c, src/vfs-mount.c, src/w32-ce.c, src/w32-ce.h,
src/w32-glib-io.c, src/w32-io.c, src/w32-sema.c, src/w32-util.c,
src/wait-global.c, src/wait.c:
Change allocation functions: free() to _gpgme_free(), malloc() to
_gpgme_malloc(), calloc() to _gpgme_calloc(), realloc() to
_gpgme_realloc() and strdup() to _gpgme_strdup().

--
Mostly borrowed from libassuan for custom memory handling. This changes
vasprintf.c to implement _gpgme_asprintf() and _gpgme_vasprintf() and
will always use the built-in vasprintf() even when provided by the OS.
2014-10-15 21:34:10 -04:00
815 changed files with 17544 additions and 132518 deletions

46
.gitignore vendored
View File

@ -1,55 +1,13 @@
# GnuPG exclusions
/aclocal.m4
/autom4te.cache
/config.h.in
/configure
/config.h
/config.log
/config.status
/conf/config.h.in
/conf/config.h
/libtool
/VERSION
Makefile.in
Makefile
stamp-h1
*.o
*.lo
# Hidden files
*~
# Byte compiled Python
*.py[cod]
__pycache__
# C extensions
*.so
# Packages
*.egg
*.egg-info
build
eggs
parts
develop-eggs
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
nosetests.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Assorted Apple crap
default.profraw
.DS_Store
._.DS_Store

53
AUTHORS
View File

@ -1,49 +1,21 @@
Package: gpgme
Homepage: https://gnupg.org/software/gpgme/
Download: https://gnupg.org/ftp/gcrypt/gpgme/
Homepage: http://www.gnupg.org/related_software/gpgme/
Download: ftp://ftp.gnupg.org/gcrypt/gpgme/
Repository: git://git.gnupg.org/gpgme.git
Maintainer: Werner Koch <wk@gnupg.org>
Bug reports: https://bugs.gnupg.org
Bug reports: http://bugs.gnupg.org (use category "gpgme")
Security related bug reports: security@gnupg.org
License (software): LGPL-2.1-or-later
License (manual+tools): GPL-3.0-or-later
License (software): LGPLv2.1+
License (manual+tools): GPLv3+
GPGME is free software. See the files COPYING.LESSER and COPYING for
copying conditions, , and LICENSES for notices about contributions
that require these additional notices to be distributed. License
copyright years may be listed using range notation, e.g., 2000-2013,
indicating that every year in the range, inclusive, is a copyrightable
year that would otherwise be listed individually.
List of Copyright holders
=========================
Copyright (C) 1991-2013 Free Software Foundation, Inc.
Copyright (C) 2000-2001 Werner Koch
Copyright (C) 2001-2023 g10 Code GmbH
Copyright (C) 2002 Klarälvdalens Datakonsult AB
Copyright (C) 2004-2008 Igor Belyi
Copyright (C) 2002 John Goerzen
Copyright (c) 2009 Dave Gamble
Copyright (C) 2014, 2015 Martin Albrecht
Copyright (C) 2015, 2018 Ben McGinnes
Copyright (C) 2015, 2016, 2018
Bundesamt für Sicherheit in der Informationstechnik
Copyright (C) 2016 Intevation GmbH
Authors info
============
FSF <gnu@gnu.org>
- Code taken from GnuPG 1.0: src/w32-util.c.
- Other from FSF projects: src/setenv.c, src/vasprintf.c,
src/stpcpy.c, src/w32-ce.c.
g10 Code GmbH <code@g10code.com>
- All stuff since mid March 2001.
- All stuff since mid march 2001.
Werner Koch <wk@gnupg.org>
- Design and most stuff.
@ -58,20 +30,7 @@ Authors with a DCO
Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2014-09-24:878ul9w4j8.fsf@alice.fifthhorseman.net:
Colin Watson <cjwatson@debian.org>
2017-09-16:20170916031428.uypfrdojquvjteor@riva.ucam.org:
Tobias Mueller <muelli@cryptobitch.de>
2016-11-23:1479937342.11180.3.camel@cryptobitch.de:
Ben McGinnes <ben@adversary.org>
2017-12-16:20171216002102.l6aejk5xdp6xhtfi@adversary.org:
Jacob Adams <tookmund@gmail.com>
2018-06-03:ad5141df-b6cc-6c2a-59df-b2f18f7160fd@gmail.com:
Guillaume LE VAILLANT <glv@posteo.net>
2018-10-11:20181011113825.76f9752a@yamatai:
Copyright 2001, 2002, 2012, 2013 g10 Code GmbH

View File

@ -1,38 +0,0 @@
Additional license notices for GPGME. -*- org -*-
This file contains the copying permission notices for various files in
the GPGME distribution which are not covered by the GNU Lesser
General Public License (LGPL) or the GNU General Public License (GPL).
These notices all require that a copy of the notice be included
in the accompanying documentation and be distributed with binary
distributions of the code, so be sure to include this file along
with any binary distributions derived from the GNU C Library.
* MIT License
For files:
- cJSON.c, cJSON.h
#+begin_quote
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining
a opy of this software and associated documentation files (the
"Software"), to eal in the Software without restriction, including
without limitation the ights 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 AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING ROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#+end_quote

View File

@ -15,32 +15,18 @@
# Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <https://gnu.org/licenses/>.
# SPDX-License-Identifier: LGPL-2.1-or-later
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
## Process this file with automake to produce Makefile.in
# Location of the released tarball archives. This is prefixed by
# the variable RELEASE_ARCHIVE in ~/.gnupg-autogen.rc. For example:
# RELEASE_ARCHIVE=user@host:archive/tarballs
RELEASE_ARCHIVE_SUFFIX = gpgme
# The variable RELEASE_SIGNKEY in ~/.gnupg-autogen.rc is used
# to specify the key for signing. For example:
# RELEASE_SIGNKEY=D8692123C4065DEA5E0F3AB5249B39D24F25E3B6
# Autoconf flags
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = dist-bzip2
DISTCHECK_CONFIGURE_FLAGS =
EXTRA_DIST = autogen.sh autogen.rc gpgme.spec.in \
ChangeLog-2011 m4/ChangeLog-2011 \
build-aux/libtool-patch.sed \
conf/whatisthis VERSION LICENSES
EXTRA_DIST = autogen.sh autogen.rc gpgme.spec.in \
ChangeLog-2011 m4/ChangeLog-2011 contrib/ChangeLog-2011
# This artificial line is to put a dependency to conf/config.h for 'all'
BUILT_SOURCES = conf/config.h
if RUN_GPG_TESTS
tests = tests
@ -50,29 +36,17 @@ endif
SUBDIRS = src ${tests} doc lang
# Fix the version of the spec file.
# Fix the version of the spec file and create a file named VERSION
# to be used for patch's Prereq: feature.
dist-hook: gen-ChangeLog
@set -e; \
sed -e 's/@pkg_version@/$(PACKAGE_VERSION)/g' \
sed -e 's/@pkg_version@/$(VERSION)/g' \
$(top_srcdir)/gpgme.spec.in > $(distdir)/gpgme.spec
echo "$(VERSION)" > $(distdir)/VERSION
distcheck-hook:
set -e; ( \
pref="#+macro: gpgme_" ;\
reldate="$$(date -u +%Y-%m-%d)" ;\
echo "$${pref}ver $(PACKAGE_VERSION)" ;\
echo "$${pref}date $${reldate}" ;\
list='$(DIST_ARCHIVES)'; for i in $$list; do \
case "$$i" in *.tar.bz2) \
echo "$${pref}size $$(wc -c <$$i|awk '{print int($$1/1024)}')k" ;\
echo "$${pref}sha1 $$(sha1sum <$$i|cut -d' ' -f1)" ;\
echo "$${pref}sha2 $$(sha256sum <$$i|cut -d' ' -f1)" ;;\
esac;\
done ) | tee $(distdir).swdb
.PHONY: gen-ChangeLog release sign-release
gen_start_date = 2011-12-01T00:00:00
.PHONY: gen-ChangeLog
gen-ChangeLog:
if test -d $(top_srcdir)/.git; then \
(cd $(top_srcdir) && \
@ -83,62 +57,3 @@ gen-ChangeLog:
rm -f $(distdir)/ChangeLog; \
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
fi
# Macro to help the release target.
RELEASE_NAME = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
release:
+(set -e;\
if [ "$(abs_top_builddir)" = "$(abs_top_srcdir)" ]; then \
echo "error: build directory must not be the source directory" >&2;\
exit 2;\
fi ;\
echo "/* Build started at $$(date -uIseconds) */" ;\
cd $(top_srcdir); \
./autogen.sh --force; \
cd $(abs_top_builddir); \
rm -rf dist; mkdir dist ; cd dist ; \
$(abs_top_srcdir)/configure --enable-maintainer-mode; \
$(MAKE) distcheck; \
echo "/* Build finished at $$(date -uIseconds) */" ;\
echo "/*" ;\
echo " * Please run the final step interactively:" ;\
echo " * make sign-release" ;\
echo " */" ;\
) 2>&1 | tee "$(RELEASE_NAME).buildlog"
sign-release:
+(set -e; \
test $$(pwd | sed 's,.*/,,') = dist || cd dist; \
x=$$(grep '^RELEASE_ARCHIVE=' $$HOME/.gnupg-autogen.rc|cut -d= -f2);\
if [ -z "$$x" ]; then \
echo "error: RELEASE_ARCHIVE missing in ~/.gnupg-autogen.rc">&2; \
exit 2;\
fi;\
myarchive="$$x/$(RELEASE_ARCHIVE_SUFFIX)";\
x=$$(grep '^RELEASE_SIGNKEY=' $$HOME/.gnupg-autogen.rc|cut -d= -f2);\
if [ -z "$$x" ]; then \
echo "error: RELEASE_SIGNKEY missing in ~/.gnupg-autogen.rc">&2; \
exit 2;\
fi;\
mysignkey="$$x";\
files1="$(RELEASE_NAME).tar.bz2" ;\
files2="$(RELEASE_NAME).tar.bz2.sig \
$(RELEASE_NAME).swdb \
$(RELEASE_NAME).buildlog" ;\
echo "/* Signing the source tarball ..." ;\
gpg -sbu $$mysignkey $(RELEASE_NAME).tar.bz2 ;\
cat $(RELEASE_NAME).swdb >swdb.snippet;\
echo >>swdb.snippet ;\
sha1sum $${files1} >>swdb.snippet ;\
cat "../$(RELEASE_NAME).buildlog" swdb.snippet \
| gzip >$(RELEASE_NAME).buildlog ;\
echo "Copying to local archive ..." ;\
scp -p $${files1} $${files2} $$myarchive/ || true;\
echo "Uploading documentation ..." ;\
$(MAKE) -C doc online; \
echo '/*' ;\
echo ' * All done; for checksums see dist/swdb.snippet' ;\
echo ' */' ;\
)

1276
NEWS

File diff suppressed because it is too large Load Diff

61
README
View File

@ -1,7 +1,7 @@
GPGME - GnuPG Made Easy
---------------------------
GPGME - GnuPG Made Easy
---------------------------
Copyright 2001-2023 g10 Code GmbH
Copyright 2004, 2006, 2010, 2012, 2013, 2014 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
@ -22,12 +22,12 @@ to public key crypto engines like GnuPG or GpgSM easier for
applications. GPGME provides a high-level crypto API for encryption,
decryption, signing, signature verification and key management.
GPGME comes with language bindings for Common Lisp, C++, QT, Python2,
and Python 3.
GPGME uses GnuPG as its backend to support OpenPGP and the
GPGME uses GnuPG and GpgSM as its backends to support OpenPGP and the
Cryptographic Message Syntax (CMS).
GPGME runs best on GNU/Linux or *BSD systems. Other Unices may
require small portability fixes, please send us your patches.
See the files COPYING, COPYING.LESSER, and each file for copyright and
warranty information. The file AUTHORS has a list of authors and
useful web and mail addresses.
@ -41,14 +41,16 @@ See the file INSTALL for generic installation instructions.
Check that you have unmodified sources. See below on how to do this.
Don't skip it - this is an important step!
To build GPGME, you need to install libgpg-error (>= 1.36) and
Libassuan (>= 2.4.2).
To build GPGME, you need to install libgpg-error (>= 1.11) and
Libassuan (>= 2.0.2).
For support of the OpenPGP and the CMS protocols, you should use at
least GnuPG version 2.2.41 or 2.4.3, available at:
https://gnupg.org/ftp/gcrypt/gnupg/.
For support of the OpenPGP protocol (default), you should use the
latest version of GnuPG (>= 1.4) , available at:
ftp://ftp.gnupg.org/gcrypt/gnupg/. For support of the CMS
(Cryptographic Message Syntax) protocol and lot of other features, you
need a GnuPG version >= 2.0.
For building the Git version of GPGME please see the file README.GIT
For building the GIT version of GPGME please see the file README.GIT
for more information.
@ -62,33 +64,24 @@ following ways:
a) If you have a trusted Version of GnuPG installed, you can simply check
the supplied signature:
$ gpg --verify gpgme-x.y.z.tar.gz.sig gpgme-x.y.z.tar.gz
$ gpg --verify gpgme-x.y.z.tar.gz.sig
This checks that the detached signature gpgme-x.y.z.tar.gz.sig is
indeed a a signature of gpgme-x.y.z.tar.gz. The key used to create
this signature is at least one of:
this signature is either of:
rsa2048 2011-01-12 [expires: 2019-12-31]
Key fingerprint = D869 2123 C406 5DEA 5E0F 3AB5 249B 39D2 4F25 E3B6
Werner Koch (dist sig)
"pub 2048R/4F25E3B6 2011-01-12 Werner Koch (dist sig)"
"pub 1024D/87978569 1999-05-13
Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de>
Marcus Brinkmann <mb@g10code.com>"
rsa2048 2014-10-29 [expires: 2019-12-31]
Key fingerprint = 46CC 7308 65BB 5C78 EBAB ADCF 0437 6F3E E085 6959
David Shaw (GnuPG Release Signing Key) <dshaw 'at' jabberwocky.com>
If you do not have this key, you can get it from any keyserver. You
have to make sure that this is really the key and not a faked one.
You can do this by comparing the output of:
rsa2048 2014-10-29 [expires: 2020-10-30]
Key fingerprint = 031E C253 6E58 0D8E A286 A9F2 2071 B08A 33BD 3F06
NIIBE Yutaka (GnuPG Release Key) <gniibe 'at' fsij.org>
$ gpg --fingerprint 0x4F25E3B6
rsa3072 2017-03-17 [expires: 2027-03-15]
Key fingerprint = 5B80 C575 4298 F0CB 55D8 ED6A BCEF 7E29 4B09 2E28
Andre Heinecke (Release Signing Key)
The keys are available at <https://gnupg.org/signature_key.html>
and in released GnuPG tarballs in the file g10/distsigkey.gpg .
You have to make sure that these are really the desired keys and
not faked one. You should do this by comparing the fingerprints
with the fingerprints published elsewhere.
with the fingerprint published elsewhere.
b) If you don't have any of the above programs, you have to verify
the SHA1 checksum:
@ -108,7 +101,7 @@ Documentation
For information how to use the library you can read the info manual,
which is also a reference book, in the doc/ directory. The programs
in the tests/ directory may also prove useful.
in the tests/gpg/ directory may also prove useful.
Please subscribe to the gnupg-devel@gnupg.org mailing list if you want
to do serious work.

6
THANKS
View File

@ -5,7 +5,7 @@ want to thank them for their help. If we forgot you, please let us
know.
Adriaan de Groot adridg@cs.kun.nl
Albrecht Dreß albrecht.dress@arcor.de
Albrecht Dreß albrecht.dress@arcor.de
Alfons Hoogervorst alfons@proteus.demon.nl
Daniel Mueller daniel@danm.de
Enno Cramer uebergeek@web.de
@ -13,13 +13,13 @@ Frank Heckenbach frank@g-n-u.de
Igor Belyi gpgme@katehok.ac93.org
Jan-Oliver Wagner jan@intevation.de
Johannes Poehlmann jhp@caldera.de
Jose C. García Sogo jose@jaimedelamo.eu.org
Jose C. García Sogo jose@jaimedelamo.eu.org
Leo Gaspard ekleog@gmail.com
Mark Mutz mutz@kde.org
Miguel Coca mcoca@gnu.org
Noel Torres envite@rolamasao.org
Patrick Spendrin patrick.spendrin@kdab.com
Stéphane Corthésy stephane@sente.ch
Stéphane Corthésy stephane@sente.ch
Timo Schulz twoaday@freakmail.de
Tommy Reynolds reynolds@redhat.com
W. Trevor King wking@tremily.us

522
TODO
View File

@ -1,254 +1,58 @@
#+TITLE: TODO List
Hey Emacs, this is -*- org -*- mode!
* IMPORTANT!
:PROPERTIES:
:CUSTOM_ID: dev-gnupg-org
:END:
There was a nine year gap (2009 to 2018) between edits of this file,
so it is likely that much of the old information in it is wrong or
no longer applicable.
Bugs, feature requests and other development related work will be
tracked through the [[https://dev.gnupg.org/][dev.gnupg.org]] site.
* Documentation
:PROPERTIES:
:CUSTOM_ID: documentation
:END:
** Document all the new stuff.
:PROPERTIES:
:CUSTOM_ID: more-docs-is-better
:END:
*** TODO Fix this TODO list.
:PROPERTIES:
:CUSTOM_ID: fix-todo
:END:
Clean up the current TODO list. Include properties as relevant (so
if someone does make a PDF or HTML version the TOC will work).
Also check to see if some of these ancient things can be removed
(e.g. do we really need to fix things that were broken in GPG
1.3.x? I'm thinking not so much).
**** DONE fix TODO items
CLOSED: [2018-03-04 Sun 08:55]
:PROPERTIES:
:CUSTOM_ID: fix-todo-items
:END:
Adjust todo items so each can now be referenced by custom-id and
checked off as necessary.
** TODO Document validity and trust issues.
:PROPERTIES:
:CUSTOM_ID: valid-trust-issues
:END:
** In gpgme.texi: Register callbacks under the right letter in the index.
:PROPERTIES:
:CUSTOM_ID: gpgme-texi
:END:
* Document all the new stuff.
* Fix the remaining UI Server problems:
:PROPERTIES:
:CUSTOM_ID: ui-server-fix
:END:
** VERIFY --silent support.
:PROPERTIES:
:CUSTOM_ID: verify-silent
:END:
** ENCRYPT/DECRYPT/VERIFY/SIGN reset the engine, shouldn't be done with UISERVER?
:PROPERTIES:
:CUSTOM_ID: reset-engine-not-ui
:END:
* IMPORTANT
:PROPERTIES:
:CUSTOM_ID: important-stuff-really
:END:
** When using descriptor passing, we need to set the fd to blocking before
:PROPERTIES:
:CUSTOM_ID: set-fd-blocking
:END:
issuing simple commands, because we are mixing synchronous
issueing simple commands, because we are mixing synchronous
commands into potentially asynchronous operations.
** Might want to implement nonblock for w32 native backend!
:PROPERTIES:
:CUSTOM_ID: nonblock-win32
:END:
Right now we block reading the next line with assuan.
** Might want to implement nonblock for w32 native backend! Right now,
we block reading the next line with assuan.
* Before release:
:PROPERTIES:
:CUSTOM_ID: pre-release
:END:
** CANCELLED Some gpg tests fail with gpg 1.3.4-cvs (gpg/t-keylist-sig)
CLOSED: [2018-03-09 Fri 08:16]
:PROPERTIES:
:CUSTOM_ID: gpg-1-3-4-really
:END:
- State "CANCELLED" from "TODO" [2018-03-09 Fri 08:16] \\
WON'T FIX — too old or no longer applies.
** Some gpg tests fail with gpg 1.3.4-cvs (gpg/t-keylist-sig)
The test is currently disabled there and in gpg/t-import.
** When gpg supports it, write binary subpackets directly,
:PROPERTIES:
:CUSTOM_ID: binary-subpackets
:END:
and parse SUBPACKET status lines.
* ABI's to break:
:PROPERTIES:
:CUSTOM_ID: abi-breakage-apparently-on-purpose
:END:
** Old opassuan interface.
:PROPERTIES:
:CUSTOM_ID: old-opassuan
:END:
** Implementation: Remove support for old style error codes in
:PROPERTIES:
:CUSTOM_ID: remove-old-error-codes
:END:
conversion.c::_gpgme_map_gnupg_error.
** gpgme_edit_cb_t: Add "processed" return argument
:PROPERTIES:
:CUSTOM_ID: add-processed-return
:END:
(see edit.c::command_handler).
** I/O and User Data could be made extensible. But this can be done
:PROPERTIES:
:CUSTOM_ID: add-io-user-data
:END:
without breaking the ABI hopefully.
** All enums should be replaced by ints and simple macros for
:PROPERTIES:
:CUSTOM_ID: enums-should-be-ints
:END:
maximum compatibility.
** Compatibility interfaces that can be removed in future versions:
:PROPERTIES:
:CUSTOM_ID: compat-interfaces-to-go
:END:
*** gpgme_data_new_from_filepart
:PROPERTIES:
:CUSTOM_ID: gpgme-data-new-from-filepart
:END:
*** gpgme_data_new_from_file
:PROPERTIES:
:CUSTOM_ID: gpgme-data-new-from-file
:END:
*** gpgme_data_new_with_read_cb
:PROPERTIES:
:CUSTOM_ID: gpgme-data-new-with-read-cb
:END:
*** gpgme_data_rewind
:PROPERTIES:
:CUSTOM_ID: gpgme-data-rewind
:END:
*** gpgme_op_import_ext
:PROPERTIES:
:CUSTOM_ID: gpgme-op-import-ext
:END:
*** gpgme_get_sig_key
:PROPERTIES:
:CUSTOM_ID: gpgme-get-sig-key
:END:
*** gpgme_get_sig_ulong_attr
:PROPERTIES:
:CUSTOM_ID: gpgme-get-sig-ulong-attr
:END:
*** gpgme_get_sig_string_attr
:PROPERTIES:
:CUSTOM_ID: gpgme-get-sig-string-attr
:END:
*** GPGME_SIG_STAT_*
:PROPERTIES:
:CUSTOM_ID: gpgme-sig-stat
:END:
*** gpgme_get_sig_status
:PROPERTIES:
:CUSTOM_ID: gpgme-get-sig-status
:END:
*** gpgme_trust_item_release
:PROPERTIES:
:CUSTOM_ID: gpgme-trust-item-release
:END:
*** gpgme_trust_item_get_string_attr
:PROPERTIES:
:CUSTOM_ID: gpgme-trust-item-get-string-attr
:END:
*** gpgme_trust_item_get_ulong_attr
:PROPERTIES:
:CUSTOM_ID: gpgme-trust-item-get-ulong-attr
:END:
*** gpgme_attr_t
:PROPERTIES:
:CUSTOM_ID: gpgme-attr-t
:END:
*** All Gpgme* typedefs.
:PROPERTIES:
:CUSTOM_ID: all-gpgme-typedefs
:END:
* Thread support:
:PROPERTIES:
:CUSTOM_ID: threads
:END:
** When GNU Pth supports sendmsg/recvmsg, wrap them properly.
:PROPERTIES:
:CUSTOM_ID: wrap-oth
:END:
** Without timegm (3) support our ISO time parser is not thread safe.
:PROPERTIES:
:CUSTOM_ID: time-threads
:END:
There is a configure time warning, though.
* New features:
:PROPERTIES:
:CUSTOM_ID: new-features
:END:
** Flow control for data objects.
:PROPERTIES:
:CUSTOM_ID: flow-control-is-not-a-euphemism-for-an-s-bend
:END:
Currently, gpgme_data_t objects are assumed to be blocking. To
break this assumption, we need either (A) a way for an user I/O
callback to store the current operation in a continuation that can
@ -257,99 +61,49 @@ Hey Emacs, this is -*- org -*- mode!
respective event loop. or (B) a way for gpgme data objects to be
associated with a waitable object, that can be registered with the
user event loop. Neither is particularly simple.
** Extended notation support. When gpg supports arbitrary binary
:PROPERTIES:
:CUSTOM_ID: extended-notation
:END:
notation data, provide a user interface for that.
** notification system
:PROPERTIES:
:CUSTOM_ID: notification-system
:END:
We need a simple notification system, probably a simple callback
with a string and some optional arguments. This is for example
required to notify an application of a changed smartcard, The
application can then do whatever is required. There are other
usages too. This notification system should be independent of any
usages too. This notfication system should be independent of any
contextes of course.
Not sure whether this is still required. GPGME_PROTOCOL_ASSUAN is
sufficient for this.
** --learn-code support
:PROPERTIES:
:CUSTOM_ID: learn-code
:END:
This might be integrated with import. we still need to work out how
to learn a card when gpg and gpgsm have support for smartcards. In
GPA we currently invoke gpg directly.
** Might need a stat() for data objects and use it for length param to gpg.
:PROPERTIES:
:CUSTOM_ID: stat-data
:END:
** Implement support for photo ids.
:PROPERTIES:
:CUSTOM_ID: photo-id
:END:
** Allow selection of subkeys
:PROPERTIES:
:CUSTOM_ID: subkey-selection
:END:
** Allow to return time stamps in ISO format
:PROPERTIES:
:CUSTOM_ID: iso-format-datetime
:END:
This allows us to handle years later than 2037 properly. With the
time_t interface they are all mapped to 2037-12-31
This allows us to handle years later than 2037 properly. With the
time_t interface they are all mapped to 2037-12-31
** New features requested by our dear users, but rejected or left for
:PROPERTIES:
:CUSTOM_ID: feature-requests
:END:
later consideration:
*** Allow to export secret keys.
:PROPERTIES:
:CUSTOM_ID: export-secret-keys
:END:
Rejected because this is conceptually flawed. Secret keys on a
smart card can not be exported, for example.
May eventually e supproted with a keywrapping system.
*** Selecting the key ring, setting the version or comment in output.
:PROPERTIES:
:CUSTOM_ID: select-keyring-version
:END:
Rejected because the naive implementation is engine specific, the
configuration is part of the engine's configuration or readily
worked around in a different way
*** Selecting the symmetric cipher.
:PROPERTIES:
:CUSTOM_ID: symmetric-cipher-selection
:END:
*** Exchanging keys with key servers.
:PROPERTIES:
:CUSTOM_ID: key-server-exchange
:END:
* Documentation
** Document validity and trust issues.
** In gpgme.texi: Register callbacks under the right letter in the index.
* Engines
:PROPERTIES:
:CUSTOM_ID: engines
:END:
** Do not create/destroy engines, but create engine and then reset it.
:PROPERTIES:
:CUSTOM_ID: reset-engine-is-not-quite-just-ignition
:END:
Internally the reset operation still spawns a new engine process,
but this can be replaced with a reset later. Also, be very sure to
release everything properly at a reset and at an error. Think hard
@ -358,255 +112,85 @@ Hey Emacs, this is -*- org -*- mode!
Note that we need support in gpgsm to set include-certs to default
as RESET does not reset it, also for no_encrypt_to and probably
other options.
** Optimize the case where a data object has an underlying fd we can pass
:PROPERTIES:
:CUSTOM_ID: optimus-data-cousin-of-optimus-prime
:END:
directly to the engine. This will be automatic with socket I/O and
descriptor passing.
** Move code common to all engines up from gpg to engine.
:PROPERTIES:
:CUSTOM_ID: move-code-common-to-engines-out-of-gpg
:END:
** engine operations can return General Error on unknown protocol
:PROPERTIES:
:CUSTOM_ID: general-error-looking-to-be-court-martialled
:END:
(it's an internal error, as select_protocol checks already).
** When server mode is implemented properly, more care has to be taken to
:PROPERTIES:
:CUSTOM_ID: server-mode
:END:
release all resources on error (for example to free assuan_cmd).
** op_import_keys and op_export_keys have a limit in the number of keys.
:PROPERTIES:
:CUSTOM_ID: import-export-problems
:END:
** op_import_keys and op_export_keys have a limit ion the number of keys.
This is because we pass them in gpg via the command line and gpgsm
via an assuan control line. We should pipe them instead and maybe
change gpg/gpgsm to not put them in memory.
* GPG breakage:
:PROPERTIES:
:CUSTOM_ID: gpg-breakage
:END:
** CANCELLED gpg 1.4.2 lacks error reporting if sign/encrypt with revoked key.
CLOSED: [2018-03-09 Fri 08:19]
:PROPERTIES:
:CUSTOM_ID: gpg-classic-lacks-stuff
:END:
- State "CANCELLED" from "TODO" [2018-03-09 Fri 08:19] \\
WON'T FIX.
** CANCELLED gpg 1.4.2 does crappy error reporting (namely none at all) when
CLOSED: [2018-03-09 Fri 08:20]
:PROPERTIES:
:CUSTOM_ID: gpg-classic-problems-but-do-we-care
:END:
- State "CANCELLED" from "TODO" [2018-03-09 Fri 08:20] \\
WON'T FIX.
** gpg 1.4.2 lacks error reporting if sign/encrypt with revoked key.
** gpg 1.4.2 does crappy error reporting (namely none at all) when
smart card is missing for sign operation:
[GNUPG:] CARDCTRL 4
gpg: selecting openpgp failed: ec=6.110
gpg: signing failed: general error
[GNUPG:] BEGIN_ENCRYPTION 2 10
gpg: test: sign+encrypt failed: general error
** DONE Without agent and with wrong passphrase, gpg 1.4.2 enters into an
CLOSED: [2018-03-09 Fri 08:20]
:PROPERTIES:
:CUSTOM_ID: recursive-gpg-classic
:END:
- State "DONE" from "TODO" [2018-03-09 Fri 08:20] \\
Must have been fixed in a subsequent release.
** Without agent and with wrong passphrase, gpg 1.4.2 enters into an
infinite loop.
** CANCELLED Use correct argv[0]
CLOSED: [2018-03-09 Fri 08:24]
:PROPERTIES:
:CUSTOM_ID: correct-argv
:END:
- State "CANCELLED" from "TODO" [2018-03-09 Fri 08:24] \\
WON'T FIX.
Also, there is no rungpg.c file in GPGME (or in GPG or most, if not
all of the rest of the libs and packages; I suspect there hasn't been
for a very long time).
** Use correct argv[0]
In rungpg.c:build_argv we use
argv[argc] = strdup ("gpg"); /* argv[0] */
This should be changed to take the real file name used in account.
* Operations
:PROPERTIES:
:CUSTOM_ID: operations-are-not-surgical
:END:
** Include cert values -2, -1, 0 and 1 should be defined as macros.
:PROPERTIES:
:CUSTOM_ID: certified-macros
:END:
** If an operation failed, make sure that the result functions don't return
:PROPERTIES:
:CUSTOM_ID: operation-failure
:END:
corrupt partial information. !!!
NOTE: The EOF status handler is not called in this case !!!
** Verify must not fail on NODATA premature if auto-key-retrieval failed.
:PROPERTIES:
:CUSTOM_ID: autobot-key-retrieval
:END:
It should not fail silently if it knows there is an error. !!!
** All operations: Better error reporting. !!
:PROPERTIES:
:CUSTOM_ID: better-reporting-not-like-fox-news
:END:
** Export status handler need much more work. !!!
:PROPERTIES:
:CUSTOM_ID: export-status-handler
:END:
** Import should return a useful error when one happened.
:PROPERTIES:
:CUSTOM_ID: import-useful-stuff-even-wrong-stuff
:END:
*** Import does not take notice of NODATA status report.
:PROPERTIES:
:CUSTOM_ID: import-no-data
:END:
*** When GPGSM does issue IMPORT_OK status reports, make sure to check for
:PROPERTIES:
:CUSTOM_ID: gpgsm-import-ok
:END:
them in tests/gpgs m/t-import.c.
** Verify can include info about version/algo/class, but currently
:PROPERTIES:
:CUSTOM_ID: verify-class
:END:
this is only available for gpg, not gpgsm.
** Return ENC_TO output in verify result. Again, this is not available
:PROPERTIES:
:CUSTOM_ID: return-to-enc
:END:
for gpgsm.
** Genkey should return something more useful than General_Error.
:PROPERTIES:
:CUSTOM_ID: general-key-assumed-command-from-general-error
:END:
** If possible, use --file-setsize to set the file size for proper progress
:PROPERTIES:
:CUSTOM_ID: file-setsize
:END:
callback handling. Write data interface for file size.
** Optimize the file descriptor list, so the number of open fds is
:PROPERTIES:
:CUSTOM_ID: optimus-descriptus-younger-brother-of-optimus-prime
:END:
always known easily.
** Encryption: It should be verified that the behaviour for partially untrusted
:PROPERTIES:
:CUSTOM_ID: only-mostly-dead-means-partially-alive
:END:
recipients is correct.
** When GPG issues INV_something for invalid signers, catch them.
:PROPERTIES:
:CUSTOM_ID: invalid-sig
:END:
* Error Values
:PROPERTIES:
:CUSTOM_ID: error-value
:END:
** Map ASSUAN/GpgSM ERR error values in a better way than is done now. !!
:PROPERTIES:
:CUSTOM_ID: map-ass-error
:END:
** Some error values should identify the source more correctly (mostly error
:PROPERTIES:
:CUSTOM_ID: source-errors
:END:
values derived from status messages).
** In rungpg.c we need to check the version of the engine
:PROPERTIES:
:CUSTOM_ID: rungpg-c-engine-ver
:END:
This requires a way to get the cached version number from the
engine layer.
* Tests
:PROPERTIES:
:CUSTOM_ID: tests
:END:
** TODO Write a fake gpg-agent so that we can supply known passphrases to
:PROPERTIES:
:CUSTOM_ID: test-fake-gpg-agent
:END:
** Write a fake gpg-agent so that we can supply known passphrases to
gpgsm and setup the configuration files to use the agent. Without
this we are testing a currently running gpg-agent which is not a
clever idea. !
** t-data
:PROPERTIES:
:CUSTOM_ID: test-data
:END:
*** Test gpgme_data_release_and_get_mem.
:PROPERTIES:
:CUSTOM_ID: test-gpgme-data-release-mem
:END:
*** Test gpgme_data_seek for invalid types.
:PROPERTIES:
:CUSTOM_ID: test-gpgme-data-seek
:END:
** t-keylist
:PROPERTIES:
:CUSTOM_ID: test-keylist
:END:
Write a test for ext_keylist.
** Test reading key signatures.
:PROPERTIES:
:CUSTOM_ID: test-key-sig
:END:
* Debug
:PROPERTIES:
:CUSTOM_ID: debug
:END:
** Tracepoints should be added at: Every public interface enter/leave,
:PROPERTIES:
:CUSTOM_ID: tracepoint-pub-int
:END:
before and in every callback, at major decision points, at every
internal data point which might easily be observed by the outside
(system handles). We also trace handles and I/O support threads in
@ -618,83 +202,21 @@ Hey Emacs, this is -*- org -*- mode!
decrypt-verify.c delete.c edit.c encrypt.c encrypt-sign.c export.c
genkey.c import.c key.c keylist.c passphrase.c progress.c signers.c
sig-notation.c trust-item.c trustlist.c verify.c
** TODO Handle malloc and vasprintf errors. But decide first if they should be
:PROPERTIES:
:CUSTOM_ID: malloc-vasprintf
:END:
** Handle malloc and vasprintf errors. But decide first if they should be
ignored (and logged with 255?!), or really be assertions. !
* Build suite
:PROPERTIES:
:CUSTOM_ID: build-suite
:END:
** TODO Make sure everything is cleaned correctly (esp. test area).
:PROPERTIES:
:CUSTOM_ID: clean-tests
:END:
** TODO Enable AC_CONFIG_MACRO_DIR and bump up autoconf version requirement.
:PROPERTIES:
:CUSTOM_ID: autoconf-macros
:END:
** Make sure everything is cleaned correctly (esp. test area).
** Enable AC_CONFIG_MACRO_DIR and bump up autoconf version requirement.
(To fix "./autogen.sh; ./configure --enable-maintainer-mode; touch
configure.ac; make"). Currently worked around with ACLOCAL_AMFLAGS???
* Error checking
:PROPERTIES:
:CUSTOM_ID: error-checking
:END:
** TODO engine-gpgsm, with-validation
:PROPERTIES:
:CUSTOM_ID: gpgsm-validation
:END:
** engine-gpgsm, with-validation
Add error checking some time after releasing a new gpgsm.
* Language bindings and related components
:PROPERTIES:
:CUSTOM_ID: language-bindings-and-related-stuff
:END:
** TODO Emacs and elisp binding
:PROPERTIES:
:CUSTOM_ID: emacs-and-elisp
:END:
Currently GNU Emacs uses EPA and EPG to provide GnuPG support. EPG
does this by calling the GPG executable and wrapping the commands
with elisp functions. A more preferable solution would be to
implement an epgme.el which integrated with GPGME, then if it could
not to attempt calling the gpgme-tool and only if those failed to
fall back to the current epg.el and calling the command line
binaries.
** TODO API of an API
:PROPERTIES:
:CUSTOM_ID: api-squared
:END:
See the more detailed notes on this in the [[lang/python/docs/TODO.org][python TODO]].
** TODO GPGME installation and package management guide
:PROPERTIES:
:CUSTOM_ID: package-management
:END:
Write a guide/best practices for maintainers of GPGME packages with
third party package management systems.
* Copyright 2004, 2005, 2018 g10 Code GmbH
:PROPERTIES:
:CUSTOM_ID: copyright-and-license
:END:
Copyright 2004, 2005 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

View File

@ -58,19 +58,3 @@ AC_DEFUN([GNUPG_CHECK_VA_COPY],
AC_MSG_RESULT($gnupg_cv_must_copy_va_byval)
fi
])
dnl LIST_MEMBER()
dnl Check whether an element ist contained in a list. Set `found' to
dnl `1' if the element is found in the list, to `0' otherwise.
AC_DEFUN([LIST_MEMBER],
[
name=$1
list=$2
found=0
for n in $list; do
if test "x$name" = "x$n"; then
found=1
fi
done
])

View File

@ -2,13 +2,19 @@
case "$myhost" in
w32)
configure_opts=""
configure_opts="
--with-gpg-error-prefix=@SYSROOT@
--with-libassuan-prefix=@SYSROOT@
"
;;
amd64)
configure_opts=""
configure_opts="
--with-gpg-error-prefix=@SYSROOT@
--with-libassuan-prefix=@SYSROOT@
"
;;
esac
final_info="mkdir build && cd build && ../configure --enable-maintainer-mode && make"
final_info="./configure --enable-maintainer-mode && make"

View File

@ -1,6 +1,6 @@
#! /bin/sh
# autogen.sh
# Copyright (C) 2003, 2014, 2017, 2018, 2022 g10 Code GmbH
# Copyright (C) 2003, 2014 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
@ -15,7 +15,7 @@
# configure it for the respective package. It is maintained as part of
# GnuPG and source copied by other packages.
#
# Version: 2023-03-15
# Version: 2014-01-10
configure_ac="configure.ac"
@ -41,7 +41,7 @@ fatal () {
info () {
if [ -z "${SILENT}" ]; then
echo "autogen.sh:" "$*" >&2
echo "autogen.sh:" "$*"
fi
}
@ -70,8 +70,6 @@ MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
DIE=no
FORCE=
SILENT=
PRINT_HOST=no
PRINT_BUILD=no
tmp=$(dirname "$0")
tsdir=$(cd "${tmp}"; pwd)
@ -79,18 +77,7 @@ if [ -n "${AUTOGEN_SH_SILENT}" ]; then
SILENT=" --silent"
fi
if test x"$1" = x"--help"; then
echo "usage: ./autogen.sh [OPTIONS] [ARGS]"
echo " Options:"
echo " --silent Silent operation"
echo " --force Pass --force to autoconf"
echo " --find-version Helper for configure.ac"
echo " --git-build Run all commands to build from a Git"
echo " --print-host Print only the host triplet"
echo " --print-build Print only the build platform triplet"
echo " --build-TYPE Configure to cross build for TYPE"
echo ""
echo " ARGS are passed to configure in --build-TYPE mode."
echo " Configuration for this script is expected in autogen.rc"
echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]"
exit 0
fi
if test x"$1" = x"--silent"; then
@ -101,14 +88,6 @@ if test x"$1" = x"--force"; then
FORCE=" --force"
shift
fi
if test x"$1" = x"--print-host"; then
PRINT_HOST=yes
shift
fi
if test x"$1" = x"--print-build"; then
PRINT_BUILD=yes
shift
fi
# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces
@ -137,6 +116,8 @@ extraoptions=
# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc
w32_toolprefixes=
w32_extraoptions=
w32ce_toolprefixes=
w32ce_extraoptions=
w64_toolprefixes=
w64_extraoptions=
amd64_toolprefixes=
@ -144,6 +125,7 @@ amd64_toolprefixes=
# What follows are variables which are sourced but default to
# environment variables or lacking them hardcoded values.
#w32root=
#w32ce_root=
#w64root=
#amd64root=
@ -151,19 +133,15 @@ amd64_toolprefixes=
myhost=""
myhostsub=""
case "$1" in
--find-version)
myhost="find-version"
SILENT=" --silent"
shift
;;
--git-build)
myhost="git-build"
shift
;;
--build-w32)
myhost="w32"
shift
;;
--build-w32ce)
myhost="w32"
myhostsub="ce"
shift
;;
--build-w64)
myhost="w32"
myhostsub="64"
@ -183,25 +161,6 @@ esac
die_p
# **** GIT BUILD ****
# This is a helper to build from git.
if [ "$myhost" = "git-build" ]; then
tmp="$(pwd)"
cd "$tsdir" || fatal "error cd-ing to $tsdir"
./autogen.sh || fatal "error running ./autogen.sh"
cd "$tmp" || fatal "error cd-ing back to $tmp"
die_p
"$tsdir"/configure || fatal "error running $tsdir/configure"
die_p
make || fatal "error running make"
die_p
make check || fatal "error running make check"
die_p
exit 0
fi
# **** end GIT BUILD ****
# Source our configuration
if [ -f "${tsdir}/autogen.rc" ]; then
. "${tsdir}/autogen.rc"
@ -213,90 +172,23 @@ if [ -f "$HOME/.gnupg-autogen.rc" ]; then
. "$HOME/.gnupg-autogen.rc"
fi
# **** FIND VERSION ****
# This is a helper for the configure.ac M4 magic
# Called
# ./autogen.sh --find-version PACKAGE MAJOR MINOR [MICRO]
# returns a complete version string with automatic beta numbering.
if [ "$myhost" = "find-version" ]; then
package="$1"
major="$2"
minor="$3"
micro="$4"
if [ -z "$package" -o -z "$major" -o -z "$minor" ]; then
echo "usage: ./autogen.sh --find-version PACKAGE MAJOR MINOR [MICRO]" >&2
exit 1
fi
if [ -z "$micro" ]; then
matchstr1="$package-$major.[0-9]*"
matchstr2="$package-$major-base"
matchstr3=""
vers="$major.$minor"
else
matchstr1="$package-$major.$minor.[0-9]*"
matchstr2="$package-$major.[0-9]*-base"
matchstr3="$package-$major-base"
vers="$major.$minor.$micro"
fi
beta=no
if [ -e .git ]; then
ingit=yes
tmp=$(git describe --match "${matchstr1}" --long 2>/dev/null)
if [ -n "$tmp" ]; then
tmp=$(echo "$tmp" | sed s/^"$package"// \
| awk -F- '$3!=0 && $3 !~ /^beta/ {print"-beta"$3}')
else
# (due tof "-base" in the tag we need to take the 4th field)
tmp=$(git describe --match "${matchstr2}" --long 2>/dev/null)
if [ -n "$tmp" ]; then
tmp=$(echo "$tmp" | sed s/^"$package"// \
| awk -F- '$4!=0 && $4 !~ /^beta/ {print"-beta"$4}')
elif [ -n "${matchstr3}" ]; then
tmp=$(git describe --match "${matchstr3}" --long 2>/dev/null)
if [ -n "$tmp" ]; then
tmp=$(echo "$tmp" | sed s/^"$package"// \
| awk -F- '$4!=0 && $4 !~ /^beta/ {print"-beta"$4}')
fi
fi
fi
[ -n "$tmp" ] && beta=yes
rev=$(git rev-parse --short HEAD | tr -d '\n\r')
rvd=$((0x$(echo ${rev} | dd bs=1 count=4 2>/dev/null)))
else
ingit=no
beta=yes
tmp="-unknown"
rev="0000000"
rvd="0"
fi
echo "$package-$vers$tmp:$beta:$ingit:$vers$tmp:$vers:$tmp:$rev:$rvd:"
exit 0
fi
# **** end FIND VERSION ****
if [ ! -f "$tsdir/build-aux/config.guess" ]; then
fatal "$tsdir/build-aux/config.guess not found"
exit 1
fi
build=`$tsdir/build-aux/config.guess`
if [ $PRINT_BUILD = yes ]; then
echo "$build"
exit 0
fi
# ******************
# W32 build script
# ******************
if [ "$myhost" = "w32" ]; then
if [ ! -f "$tsdir/build-aux/config.guess" ]; then
fatal "$tsdir/build-aux/config.guess not found"
exit 1
fi
build=`$tsdir/build-aux/config.guess`
case $myhostsub in
ce)
w32root="$w32ce_root"
[ -z "$w32root" ] && w32root="$HOME/w32ce_root"
toolprefixes="$w32ce_toolprefixes arm-mingw32ce"
extraoptions="$extraoptions $w32ce_extraoptions"
;;
64)
w32root="$w64root"
[ -z "$w32root" ] && w32root="$HOME/w64root"
@ -330,10 +222,6 @@ if [ "$myhost" = "w32" ]; then
fi
die_p
fi
if [ $PRINT_HOST = yes ]; then
echo "$host"
exit 0
fi
if [ -f "$tsdir/config.log" ]; then
if ! head $tsdir/config.log | grep "$host" >/dev/null; then
@ -344,8 +232,7 @@ if [ "$myhost" = "w32" ]; then
$tsdir/configure --enable-maintainer-mode ${SILENT} \
--prefix=${w32root} \
--host=${host} --build=${build} SYSROOT=${w32root} \
PKG_CONFIG_LIBDIR=${w32root}/lib/pkgconfig \
--host=${host} --build=${build} \
${configure_opts} ${extraoptions} "$@"
rc=$?
exit $rc
@ -355,6 +242,13 @@ fi
# ***** AMD64 cross build script *******
# Used to cross-compile for AMD64 (for testing)
if [ "$myhost" = "amd64" ]; then
shift
if [ ! -f $tsdir/build-aux/config.guess ]; then
echo "$tsdir/build-aux/config.guess not found" >&2
exit 1
fi
build=`$tsdir/build-aux/config.guess`
[ -z "$amd64root" ] && amd64root="$HOME/amd64root"
info "Using $amd64root as standard install directory"
replace_sysroot
@ -375,10 +269,6 @@ if [ "$myhost" = "amd64" ]; then
echo "Stop." >&2
exit 1
fi
if [ $PRINT_HOST = yes ]; then
echo "$host"
exit 0
fi
if [ -f "$tsdir/config.log" ]; then
if ! head $tsdir/config.log | grep "$host" >/dev/null; then
@ -451,16 +341,13 @@ fi
# Check the git setup.
if [ -d .git ]; then
CP="cp -p"
# If we have a GNU cp we can add -v
if cp --version >/dev/null 2>/dev/null; then
[ -z "${SILENT}" ] && CP="$CP -v"
fi
CP="cp -a"
[ -z "${SILENT}" ] && CP="$CP -v"
if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
[ -z "${SILENT}" ] && cat <<EOF
*** Activating trailing whitespace git pre-commit hook. ***
For more information see this thread:
https://mail.gnome.org/archives/desktop-devel-list/2009-May/msg00084.html
http://mail.gnome.org/archives/desktop-devel-list/2009-May/msg00084html
To deactivate this pre-commit hook again move .git/hooks/pre-commit
and .git/hooks/pre-commit.sample out of the way.
EOF
@ -484,10 +371,6 @@ EOF
EOF
$CP build-aux/git-hooks/commit-msg .git/hooks/commit-msg
chmod +x .git/hooks/commit-msg
if [ x"${display_name}" != x ]; then
git config format.subjectPrefix "PATCH ${display_name}"
git config sendemail.to "${patches_to}"
fi
fi
fi

View File

@ -1,9 +1,8 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Wrapper for compilers which do not understand `-c -o'.
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright 1999, 2000 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
@ -17,331 +16,84 @@ scriptversion=2012-10-14.11; # UTC
# 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, see <https://www.gnu.org/licenses/>.
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# Usage:
# compile PROGRAM [ARGS]...
# `-o FOO.o' is removed from the args passed to the actual compile.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
prog=$1
shift
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
args=
while test $# -gt 0; do
case "$1" in
-o)
# configure might choose to run compile as `compile cc -o foo foo.c'.
# So we do something ugly here.
ofile=$2
shift
case "$ofile" in
*.o | *.obj)
;;
*)
args="$args -o $ofile"
ofile=
;;
esac
;;
*.c)
cfile=$1
args="$args $1"
;;
*)
args="$args $1"
;;
esac
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
# If no `-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# ok.
exec "$prog" $args
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# Note: use `[/.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
if mkdir $lockdir > /dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
trap "rmdir $lockdir; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
"$prog" $args
status=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
mv "$cofile" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
rmdir $lockdir
exit $status

1708
build-aux/config.guess vendored

File diff suppressed because it is too large Load Diff

2885
build-aux/config.sub vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,10 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC
scriptversion=2007-03-29.01
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -16,7 +17,9 @@ scriptversion=2013-05-30.07; # UTC
# 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, see <https://www.gnu.org/licenses/>.
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@ -27,9 +30,9 @@ scriptversion=2013-05-30.07; # UTC
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
@ -39,11 +42,11 @@ as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
@ -56,66 +59,6 @@ EOF
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
@ -128,9 +71,6 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
@ -142,32 +82,9 @@ if test "$depmode" = hp; then
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
@ -190,7 +107,8 @@ gcc3)
done
"$@"
stat=$?
if test $stat -ne 0; then
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
@ -198,17 +116,13 @@ gcc3)
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
@ -216,31 +130,31 @@ gcc)
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -258,7 +172,8 @@ sgi)
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
@ -266,41 +181,43 @@ sgi)
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
make_dummy_depfile
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
@ -313,7 +230,9 @@ aix)
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
@ -322,100 +241,44 @@ aix)
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
if test -f "$tmpdepfile"; then
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
@ -427,8 +290,8 @@ pgcc)
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -439,8 +302,9 @@ hp2)
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
@ -451,7 +315,8 @@ hp2)
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
@ -461,107 +326,72 @@ hp2)
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
# Add `dependent.h:' lines.
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mechanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
@ -574,13 +404,13 @@ dashmstdout)
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
# Remove `-o $object'.
IFS=" "
for arg
do
@ -600,18 +430,18 @@ dashmstdout)
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -625,51 +455,41 @@ makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
@ -680,13 +500,13 @@ cpp)
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
# Remove `-o $object'.
IFS=" "
for arg
do
@ -705,10 +525,10 @@ cpp)
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
@ -718,56 +538,35 @@ cpp)
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
@ -786,6 +585,5 @@ exit 0
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# time-stamp-end: "$"
# End:

View File

@ -86,17 +86,11 @@ sub check_msg($$)
2 <= @line && length $line[1]
and return 'second line must be empty';
# See git-commit(1), this is the --cleanup=scissors option. Everything
# after and including this line gets ignored.
my $marker = '# ------------------------ >8 ------------------------';
# Limit line length to allow for the ChangeLog's leading TAB.
foreach my $line (@line)
{
72 < length $line && $line =~ /^[^#]/
and return 'line longer than 72 characters';
last if $line eq $marker;
}
return '';

View File

@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC
scriptversion=2006-12-25.00
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@ -35,7 +35,7 @@ scriptversion=2011-11-20.07; # UTC
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
@ -156,10 +156,6 @@ while test $# -ne 0; do
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
@ -190,10 +186,6 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
@ -202,17 +194,13 @@ if test $# -eq 0; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
trap '(exit $?); exit' 1 2 13 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
@ -240,9 +228,9 @@ fi
for src
do
# Protect names problematic for 'test' and other utilities.
# Protect names starting with `-'.
case $src in
-* | [=\(\)!]) src=./$src;;
-*) src=./$src;;
esac
if test -n "$dir_arg"; then
@ -264,7 +252,12 @@ do
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
@ -354,7 +347,7 @@ do
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# other-writeable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
@ -392,7 +385,7 @@ do
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
-*) prefix='./';;
*) prefix='';;
esac
@ -410,7 +403,7 @@ do
for d
do
test X"$d" = X && continue
test -z "$d" && continue
prefix=$prefix$d
if test -d "$prefix"; then
@ -522,6 +515,5 @@ done
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# time-stamp-end: "$"
# End:

View File

@ -1,68 +0,0 @@
#
# This is a sed script to patch the generated libtool,
# which works well against both of libtool 2.4.2 and 2.4.7.
#
# You may use this work under the terms of a Creative Commons CC0 1.0
# License/Waiver.
#
# CC0 Public Domain Dedication
# https://creativecommons.org/publicdomain/zero/1.0/
#
# This sed script applys two hunks of the patch:
#
# Part1: after the comment "# bleh windows"
# Part2: after the comment "#extension on DOS 8.3..."
#
# Only when those two parts are patched correctly, it exits with 0 or
# else, it exits with 1
#
# Find the part 1, by the comment
/^[ \t]*# bleh windows$/b part1_start
# Not found the part1, raise an error
$ q1
b
:part1_start
n
# The first line in the part 1 must be the begining of the case statement.
/^[ \t]*case \$host in$/! q1
n
# Insert the entry for x86_64-*mingw32*, for modified versuffix.
i\
x86_64-*mingw32*)
i\
func_arith $current - $age
i\
major=$func_arith_result
i\
versuffix="6-$major"
i\
;;
:part1_0
# Find the end of the case statement
/^[ \t]*esac$/b find_part2
# Not found the end of the case statement, raise an error
$ q1
n
b part1_0
:find_part2
/^[ \t]*# extension on DOS 8.3 file.*systems.$/b part2_process
# Not found the part2, raise an error
$ q1
n
b find_part2
:part2_process
$ q1
s/^[ \t]*\(versuffix=\)\(.*\)\(-$major\)\(.*\)$/\t case \$host in\n\t x86_64-*mingw32*)\n\t \1\26\3\4\n\t ;;\n\t *)\n\t \1\2\3\4\n\t ;;\n\t esac/
t part2_done
n
b part2_process
:part2_done
$ q0
n
b part2_done

View File

@ -24,7 +24,7 @@
#
# You should have received a copy of the GNU General Public License
# along with GNU Libtool; see the file COPYING. If not, a copy
# can be downloaded from https://www.gnu.org/licenses/gpl.html,
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
# or obtained by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -75,8 +75,8 @@
# autoconf: $autoconf_version
#
# Report bugs to <bug-libtool@gnu.org>.
# GNU libtool home page: <https://www.gnu.org/software/libtool/>.
# General help using GNU software: <https://www.gnu.org/gethelp/>.
# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
# General help using GNU software: <http://www.gnu.org/gethelp/>.
PROGRAM=libtool
PACKAGE=libtool

View File

@ -18,7 +18,7 @@ scriptversion=2010-08-21.06; # UTC
# 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, see <https://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a

View File

@ -1,10 +1,11 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
# Common stub for a few missing GNU programs while installing.
scriptversion=2013-10-28.13; # UTC
scriptversion=2012-01-06.13; # UTC
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -17,7 +18,7 @@ scriptversion=2013-10-28.13; # UTC
# 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, see <https://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@ -25,40 +26,68 @@ scriptversion=2013-10-28.13; # UTC
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
autom4te touch the output file, or create a stub one
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
\`g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
@ -70,141 +99,228 @@ Send bug reports to <bug-automake@gnu.org>."
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# normalize program name to check for.
program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=https://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program). This is about non-GNU programs, so use $1 not
# $program.
case $1 in
lex*|yacc*)
# Not GNU programs, they don't have --version.
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case $program in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case $f in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te*)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison*|yacc*)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if test $# -ne 1; then
eval LASTARG=\${$#}
case $LASTARG in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if test ! -f y.tab.h; then
echo >y.tab.h
fi
if test ! -f y.tab.c; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex*|flex*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if test $# -ne 1; then
eval LASTARG=\${$#}
case $LASTARG in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if test ! -f lex.yy.c; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit $?
fi
;;
makeinfo*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '
/^@setfilename/{
s/.* \([^ ]*\) *$/\1/
p
q
}' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)

View File

@ -20,7 +20,7 @@
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% As a special exception, when this file is read by TeX when processing
% a Texinfo source document, you may use the result without
@ -31,7 +31,7 @@
% reports; you can get the latest version from:
% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
% https://www.gnu.org/software/texinfo/ (the Texinfo home page)
% http://www.gnu.org/software/texinfo/ (the Texinfo home page)
% The texinfo.tex in any given distribution could well be out
% of date, so if that's what you're using, please check.
%
@ -55,7 +55,7 @@
% extent. You can get the existing language-specific files from the
% full Texinfo distribution.
%
% The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
\message{Loading texinfo [version \texinfoversion]:}
@ -482,7 +482,7 @@
% \def\foo{\parsearg\Xfoo}
% \def\Xfoo#1{...}
%
% Actually, I use \csname\string\foo\endcsname, i.e. \\foo, as it is my
% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
% favourite TeX trick. --kasal, 16nov03
\def\parseargdef#1{%

View File

@ -1,2 +0,0 @@
Configuration files may go here. Note that config.h.in is
auto-generated so that this file is not in git.

File diff suppressed because it is too large Load Diff

49
contrib/ChangeLog-2011 Normal file
View File

@ -0,0 +1,49 @@
2011-12-02 Werner Koch <wk@g10code.com>
NB: ChangeLog files are no longer manually maintained. Starting
on December 1st, 2011 we put change information only in the GIT
commit log, and generate a top-level ChangeLog file from logs at
"make dist". See doc/HACKING for details.
2010-11-15 Marcus Brinkmann <mb@g10code.com>
* conf-w32ce-msc/fcntl.h: New file.
* conf-w32ce-msc/build.mk (conf_sources): Add fnctl.h.
(sources): Remove memrchr.c.
* conf-w32ce-msc/io.h: New file.
* conf-w32ce-msc/build.mk (conf_sources): Add io.h.
* conf-w32ce-msc/stdint.h: New file.
* conf-w32ce-msc/build.mk (conf_sources): Add stdint.h.
* conf-w32ce-msc/build.mk (copy-static-source): Revert last change.
2010-11-15 Werner Koch <wk@g10code.com>
* conf-w32ce-msc/build.mk (copy-static-source): Create stdint.h.
(all): Add ws2.lib
(clean): New.
2010-11-04 Werner Koch <wk@g10code.com>
* conf-w32ce-msc/build.mk (copy-built-source): Revert last
change. Does not work with W32CE where MSC defines it in except.h.
2010-11-03 Werner Koch <wk@g10code.com>
* conf-w32ce-msc/build.mk (copy-built-source): Create dummy sehmap.h.
2010-11-01 Werner Koch <wk@g10code.com>
* conf-w32ce-msc/config.h: New.
* conf-w32ce-msc/build.mk: New.
Copyright (C) 2010 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.

256
contrib/conf-w32ce-msc/build.mk Executable file
View File

@ -0,0 +1,256 @@
# build.mk - Makefile to build libgpg-error using Visual-C
# Copyright 2010 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.
# This is a helper make script to build libgpg-error for WindowsCE
# using the Microsoft Visual C compiler.
targetdir = /home/smb/xppro-gnu/src/gpgme/src
# The target build directory where we run the Visual C compiler/ This
# needs to be an absolute directory name. Further we expect this
# structure of the tree:
#
# TARGET/src - Source directories: One directory for each project
# /bin - Installed DLLs
# /lib - Installed import libs.
# /include - Instaled header files.
targetdir = /home/smb/xppro-gnu
targetsrc = $(targetdir)/src
# Install directories (relative)
bindir = ../../../bin
libdir = ../../../lib
incdir = ../../../include
help:
@echo "Run "
@echo " make -f ../contrib/conf-w32ce-msc/build.mk copy-source"
@echo "on the POSIX system and then"
@echo " nmake -f build.mk all"
@echo " nmake -f build.mk install"
@echo "on the Windows system"
ce_defines = -DWINCE -D_WIN32_WCE=0x502 -DUNDER_CE \
-DWIN32_PLATFORM_PSPC -D_UNICODE -DUNICODE \
-D_CONSOLE -DARM -D_ARM_
#-D_DEBUG -DDEBUG
CFLAGS = -nologo -W3 -fp:fast -Os $(ce_defines) \
-DHAVE_CONFIG_H -DDLL_EXPORT -D_CRT_SECURE_NO_WARNINGS \
-I. -I$(incdir) -I$(incdir)/gpg-extra
LDFLAGS =
# Standard source files
sources = \
assuan-support.c \
ath-pth.c \
ath-pthread.c \
ath.c \
ath.h \
context.h \
conversion.c \
data-compat.c \
data-fd.c \
data-mem.c \
data-stream.c \
data-user.c \
data.c \
data.h \
debug.c \
debug.h \
decrypt-verify.c \
decrypt.c \
delete.c \
dirinfo.c \
edit.c \
encrypt-sign.c \
encrypt.c \
engine-assuan.c \
engine-backend.h \
engine-g13.c \
engine-gpg.c \
engine-gpgconf.c \
engine-gpgsm.c \
engine-uiserver.c \
engine.c \
engine.h \
error.c \
export.c \
funopen.c \
genkey.c \
get-env.c \
getauditlog.c \
gpgconf.c \
gpgme-tool.c \
gpgme-w32spawn.c \
gpgme.c \
import.c \
isascii.c \
kdpipeiodevice.h \
key.c \
keylist.c \
op-support.c \
opassuan.c \
ops.h \
passphrase.c \
passwd.c \
priv-io.h \
progress.c \
putc_unlocked.c \
sema.h \
setenv.c \
sig-notation.c \
sign.c \
signers.c \
stpcpy.c \
trust-item.c \
trustlist.c \
ttyname_r.c \
util.h \
vasprintf.c \
verify.c \
version.c \
vfs-create.c \
vfs-mount.c \
w32-ce.c \
w32-ce.h \
w32-glib-io.c \
w32-io.c \
w32-sema.c \
w32-util.c \
wait-global.c \
wait-private.c \
wait-user.c \
wait.c \
wait.h \
gpgme.def
# The object files we need to create from sources.
objs = \
conversion.obj \
get-env.obj \
data.obj \
data-fd.obj \
data-stream.obj \
data-mem.obj \
data-user.obj \
data-compat.obj \
signers.obj \
sig-notation.obj \
wait.obj \
wait-global.obj \
wait-private.obj \
wait-user.obj \
op-support.obj \
encrypt.obj \
encrypt-sign.obj \
decrypt.obj \
decrypt-verify.obj \
verify.obj \
sign.obj \
passphrase.obj \
progress.obj \
key.obj \
keylist.obj \
trust-item.obj \
trustlist.obj \
import.obj \
export.obj \
genkey.obj \
delete.obj \
edit.obj \
getauditlog.obj \
opassuan.obj \
passwd.obj \
engine.obj \
engine-gpg.obj \
engine-gpgsm.obj \
assuan-support.obj \
engine-assuan.obj \
engine-gpgconf.obj \
engine-g13.obj \
vfs-mount.obj \
vfs-create.obj \
gpgconf.obj \
w32-ce.obj \
w32-util.obj \
w32-sema.obj \
w32-io.obj \
dirinfo.obj \
debug.obj \
gpgme.obj \
version.obj \
error.obj \
ath.obj \
vasprintf.obj \
ttyname_r.obj \
stpcpy.obj \
setenv.obj
# Sources files in this directory inclduing this Makefile
conf_sources = \
build.mk \
config.h \
stdint.h io.h fcntl.h
# Source files built by running the standard build system.
built_sources = \
gpgme.h \
status-table.h
copy-static-source:
@if [ ! -f ./gpgme.c ]; then \
echo "Please cd to the src/ directory first"; \
exit 1; \
fi
cp -t $(targetsrc)/gpgme/src $(sources);
cd ../contrib/conf-w32ce-msc ; \
cp -t $(targetsrc)/gpgme/src $(conf_sources)
copy-built-source:
@if [ ! -f ./gpgme.h ]; then \
echo "Please build using ./autogen.sh --build-w32ce first"; \
exit 1; \
fi
cp -t $(targetsrc)/gpgme/src $(built_sources)
copy-source: copy-static-source copy-built-source
.c.obj:
$(CC) $(CFLAGS) -c $<
all: $(sources) $(conf_sources) $(built_sources) $(objs)
link /DLL /IMPLIB:libgpgme-11-msc.lib \
/OUT:libgpgme-11-msc.dll \
/DEF:gpgme.def /NOLOGO /MANIFEST:NO \
/NODEFAULTLIB:"oldnames.lib" /DYNAMICBASE:NO \
$(objs) \
$(libdir)/libgpg-error-0-msc.lib \
$(libdir)/libassuan-0-msc.lib \
coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib \
commctrl.lib ws2.lib /subsystem:windowsce,5.02
# Note that we don't need to create the install directories because
# libgpg-error must have been build and installed prior to this
# package.
install: all
copy /y gpgme.h $(incdir:/=\)
copy /y libgpgme-11-msc.dll $(bindir:/=\)
copy /y libgpgme-11-msc.lib $(libdir:/=\)
clean:
del *.obj libgpgme-11-msc.lib libgpgme-11-msc.dll libgpgme-11-msc.exp

View File

@ -0,0 +1,314 @@
/* config.h for building with Visual-C for WindowsCE.
* Copyright 2010 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.
*/
/* This file was originally created by running
* ./autogen.sh --build-w32ce
* on svn revision 1495 (gpgme 1.3.1-svn1495) and then adjusted to work
* with Visual-C.
*/
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.3.1-svn1495-msc1"
/* Name of this package */
#define PACKAGE "gpgme"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "bug-gpgme@gnupg.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "gpgme"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "gpgme " PACKAGE_VERSION
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "gpgme"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Whether Assuan support is enabled */
#define ENABLE_ASSUAN 1
/* Whether G13 support is enabled */
#define ENABLE_G13 1
/* Whether GPGCONF support is enabled */
#define ENABLE_GPGCONF 1
/* Whether GPGSM support is enabled */
#define ENABLE_GPGSM 1
/* Defined if we are building with uiserver support. */
/* #undef ENABLE_UISERVER */
/* Path to the G13 binary. */
#define G13_PATH "c:\\gnupg\\g13.exe"
/* Path to the GPGCONF binary. */
#define GPGCONF_PATH "c:\\gnupg\\gpgconf.exe"
/* version of the libassuan library */
#define GPGME_LIBASSUAN_VERSION "2.0.2-svn381"
/* Path to the GPGSM binary. */
#define GPGSM_PATH "c:\\gnupg\\gpgsm.exe"
/* The default error source for GPGME. */
#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_GPGME
/* Path to the GnuPG binary. */
#define GPG_PATH "c:\\gnupg\\gpg.exe"
/* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */
/* Defined if we run on some of the PCDOS like systems (DOS, Windoze. OS/2)
with special properties like no file modes */
#define HAVE_DOSISH_SYSTEM 1
/* Define to 1 if the system has the type `error_t'. */
/* #undef HAVE_ERROR_T */
/* Define to 1 if you have the `fopencookie' function. */
/* #undef HAVE_FOPENCOOKIE */
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
/* #undef HAVE_FSEEKO */
/* Define to 1 if you have the `funopen' function. */
/* #undef HAVE_FUNOPEN */
/* Define to 1 if you have the `getegid' function. */
/* #undef HAVE_GETEGID */
/* Define to 1 if you have the `getenv_r' function. */
/* #undef HAVE_GETENV_R */
/* Define to 1 if you have the `getgid' function. */
/* #undef HAVE_GETGID */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <locale.h> header file. */
/* #undef HAVE_LOCALE_H */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if we have Pth. */
/* #undef HAVE_PTH */
/* Define if we have pthread. */
/* #undef HAVE_PTHREAD */
/* Define to 1 if you have the `setenv' function. */
/* #undef HAVE_SETENV */
/* Define to 1 if you have the `setlocale' function. */
/* #undef HAVE_SETLOCALE */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `stpcpy' function. */
/* #undef HAVE_STPCPY */
/* Define to 1 if you have the <strings.h> header file. */
/* #undef HAVE_STRINGS_H */
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/select.h> header file. */
/* #undef HAVE_SYS_SELECT_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
/* #undef HAVE_SYS_STAT_H */
/* Define to 1 if you have the <sys/types.h> header file. */
/* #undef HAVE_SYS_TYPES_H */
/* Define to 1 if you have the <sys/uio.h> header file. */
/* #undef HAVE_SYS_UIO_H */
/* Define if getenv() is thread-safe */
/* #undef HAVE_THREAD_SAFE_GETENV */
/* Define to 1 if you have the `timegm' function. */
/* #undef HAVE_TIMEGM */
/* Define if __thread is supported */
/* #define HAVE_TLS 1 */
/* Define to 1 if you have the `ttyname_r' function. */
/* #undef HAVE_TTYNAME_R */
/* Define to 1 if the system has the type `uintptr_t'. */
#define HAVE_UINTPTR_T 1
/* Define to 1 if you have the <unistd.h> header file. */
/* #define HAVE_UNISTD_H 1 */
/* Define to 1 if you have the `vasprintf' function. */
/* #undef HAVE_VASPRINTF */
/* Defined if we run on a W32 CE API based system */
#define HAVE_W32CE_SYSTEM 1
/* Defined if we run on a W32 API based system */
#define HAVE_W32_SYSTEM 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* used to implement the va_copy macro */
/* #undef MUST_COPY_VA_BYVAL */
/* Min. needed G13 version. */
#define NEED_G13_VERSION "2.1.0"
/* Min. needed GPGCONF version. */
#define NEED_GPGCONF_VERSION "2.0.4"
/* Min. needed GPGSM version. */
#define NEED_GPGSM_VERSION "1.9.6"
/* Min. needed GnuPG version. */
#define NEED_GPG_VERSION "1.4.0"
/* Separators as used in $PATH. */
#ifdef HAVE_DOSISH_SYSTEM
#define PATHSEP_C ';'
#else
#define PATHSEP_C ':'
#endif
/* The size of `unsigned int', as computed by sizeof. */
#define SIZEOF_UNSIGNED_INT 4
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Defined if descriptor passing is enabled and supported */
/* #undef USE_DESCRIPTOR_PASSING */
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
/* Version of this package */
#define VERSION PACKAGE_VERSION
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
/* #undef _LARGEFILE_SOURCE */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */
/* 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. */
#ifndef _REENTRANT
# define _REENTRANT 1
#endif
/* Activate POSIX interface on MacOS X */
/* #undef _XOPEN_SOURCE */
/* Define to a type to use for `error_t' if it is not otherwise available. */
#define error_t int
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#define inline __inline
#endif
/* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */
/* Define to the type of an unsigned integer type wide enough to hold a
pointer, if such a type exists, and if the system does not define it. */
/* #undef uintptr_t */
/* Definition of GCC specific attributes. */
#if __GNUC__ > 2
# define GPGME_GCC_A_PURE __attribute__ ((__pure__))
#else
# define GPGME_GCC_A_PURE
#endif
/* Under WindowsCE we need gpg-error's strerror macro. */
#define GPG_ERR_ENABLE_ERRNO_MACROS 1
/* snprintf is not part of oldnames.lib thus we redefine it here. */
#define snprintf _snprintf
/* We don't want warnings like this:
warning C4996: e.g. "The POSIX name for this item is
deprecated. Instead, use the ISO C++ conformant name: _fileno"
warning C4018: '<' : signed/unsigned mismatch
warning C4244: '=' : conversion from 'time_t' to
'unsigned long', possible loss of data
*/
#pragma warning(disable:4996 4018 4244)

1
contrib/conf-w32ce-msc/fcntl.h Executable file
View File

@ -0,0 +1 @@
/* Dummy fcntl.h header. */

2
contrib/conf-w32ce-msc/io.h Executable file
View File

@ -0,0 +1,2 @@
/* Dummy io.h header. */

View File

@ -0,0 +1,9 @@
typedef unsigned long long uint64_t;
typedef long long int64_t;
typedef unsigned int uint32_t;
typedef int int32_t;
typedef unsigned short uint16_t;
typedef short int16_t;
typedef unsigned int uintptr_t;
typedef int intptr_t;

View File

@ -397,7 +397,7 @@
(Listing Keys): Update examples.
(Decrypt): Result might also be available when operation failed.
(Verify): Result might also be available when operation failed.
All spotted by Stéphane Corthésy.
All spotted by Stéphane Corthésy.
2003-07-22 Marcus Brinkmann <marcus@g10code.de>
@ -700,7 +700,7 @@
2002-05-26 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi: Some typographical corrections throughout.
* gpgme.texi: Some typographical correctons throughout.
2002-05-09 Marcus Brinkmann <marcus@g10code.de>
@ -720,7 +720,7 @@
* gpgme.texi (Manipulating Data Buffers): Changed some data types
to void*.
(Protocol Selection): Added gpgme_get_protocol.
(Verify): Updated to include the new attribute functions and
(Verify): Updated to include the new attribute fucntions and
status codes.
2002-04-27 Werner Koch <wk@gnupg.org>
@ -839,7 +839,7 @@
2002-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Run Control): New section.
(Verify): Document gpgme_get_notation.
(Verify): Docuent gpgme_get_notation.
(More Information): New section describing gpgme_get_op_info.
2002-01-22 Marcus Brinkmann <marcus@g10code.de>
@ -865,7 +865,7 @@
* gpgme.texi (Top): Complete detailmenu.
* gpgme.texi: Convert embarrassing cruft to the real thing.
* gpgme.texi: Convert embarassing cruft to the real thing.
2002-01-16 Marcus Brinkmann <marcus@g10code.de>

View File

@ -23,34 +23,11 @@
the big picture. Omit the leading TABs that you're used to seeing
in a "real" ChangeLog file, but keep the maximum line length at 72
or smaller, so that the generated ChangeLog lines, each with its
leading TAB, will not exceed 80 columns. If you want to add text
which shall not be copied to the ChangeLog, separate it by a line
consisting of two dashes at the begin of a line.
leading TAB, will not exceed 80 columns.
Note that ./autogen.sh installs a git hook to do some basic syntax
checking on the commit log message.
Typo fixes and documentation updates don't need a ChangeLog entry;
thus you would use a commit message like
#+begin_example
Fix typo in a comment
--
#+end_example
The marker line here is important; without it the first line would
appear in the ChangeLog.
If you exceptionally need to have longer lines in a commit log you may
do this after this scissor line:
#+begin_example
# ------------------------ >8 ------------------------
#+end_example
(hash, blank, 24 dashes, blank, scissor, blank, 24 dashes).
Note that such a comment will be removed if the git commit option
=--cleanup-scissor= is used.
** License policy
GPGME is currently licensed under the LGPLv2.1+ with tools and the
@ -96,29 +73,6 @@
need. If you really need to do it, use a separate commit for such a
change.
- C99 syntax should not be used; stick to C90.
- Please do not use C++ =//= style comments.
- Try to fit lines into 80 columns.
- Ignore signed/unsigned pointer mismatches
- No arithmetic on void pointers; cast to char* first.
** Commit log keywords
- GnuPG-bug-id :: Values are comma or space delimited bug numbers
from bug.gnupg.org pertaining to this commit.
- Debian-bug-id :: Same as above but from the Debian bug tracker.
- CVE-id :: CVE id number pertaining to this commit.
- Regression-due-to :: Commit id of the regression fixed by this commit.
- Fixes-commit :: Commit id this commit fixes.
- Reported-by :: Value is a name or mail address of a bug reporte.
- Suggested-by :: Value is a name or mail address of someone how
suggested this change.
- Co-authored-by :: Name or mail address of a co-author
- Some-comments-by :: Name or mail address of the author of
additional comments (commit log or code).
- Proofread-by :: Sometimes used by translation commits.
- Signed-off-by :: Name or mail address of the developer
* Debug hints
- Use gpgme-tool for manual tests.

View File

@ -14,49 +14,23 @@
# Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <https://gnu.org/licenses/>.
# SPDX-License-Identifier: LGPL-2.1-or-later
# 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
DISTCLEANFILES = gpgme.tmp
CLEANFILES = mkdefsinc defs.inc
EXTRA_DIST = module-overview.sk HACKING DCO ChangeLog-2011 \
mkdefsinc.c defsincdate \
examples/gpgme-mozilla.json examples/gpgme-chrome.json
BUILT_SOURCES = defsincdate defs.inc
EXTRA_DIST = module-overview.sk HACKING DCO ChangeLog-2011
info_TEXINFOS = gpgme.texi
gpgme_TEXINFOS = uiserver.texi lesser.texi gpl.texi
gpgme.texi : defs.inc
mkdefsinc: mkdefsinc.c Makefile $(top_builddir)/conf/config.h
$(CC_FOR_BUILD) -I. -I$(top_builddir)/conf -I$(srcdir) \
$(AM_CPPFLAGS) -o $@ $(srcdir)/mkdefsinc.c
dist-hook: defsincdate
defsincdate: $(gpgme_TEXINFOS)
: >defsincdate ; \
if test -e $(top_srcdir)/.git; then \
(cd $(srcdir) && git log -1 --format='%ct' -- \
$(info_TEXINFOS) $(gpgme_TEXINFOS) 2>/dev/null) >>defsincdate; \
fi
defs.inc: defsincdate Makefile mkdefsinc
incd="`test -f defsincdate || echo '$(srcdir)/'`defsincdate"; \
./mkdefsinc -C $(srcdir) --date "`cat $$incd 2>/dev/null`" \
$(info_TEXINFOS) $(gpgme_TEXINFOS) >$@
online: gpgme.html gpgme.pdf
set -e; \
echo "Uploading current manuals to www.gnupg.org ..."; \
user=werner ; \
(cd gpgme.html && rsync -vr --exclude='.svn' . \
$${user}@ftp.gnupg.org:webspace/manuals/gpgme/ ); \
rsync -v gpgme.pdf $${user}@ftp.gnupg.org:webspace/manuals/
$${user}@cvs.gnupg.org:webspace/manuals/gpgme/ ); \
rsync -v gpgme.pdf $${user}@cvs.gnupg.org:webspace/manuals/

View File

@ -1,9 +0,0 @@
{
"name": "gpgmejson",
"description": "Integration with GnuPG",
"path": "/usr/bin/gpgme-json",
"type": "stdio",
"allowed_origins": [
"chrome-extension://kajibbejlbohfaggdiogboambcijhkke/"
]
}

View File

@ -1,9 +0,0 @@
{
"name": "gpgmejson",
"description": "Integration with GnuPG",
"path": "/usr/bin/gpgme-json",
"type": "stdio",
"allowed_extensions": [
"jid1-AQqSMBYb0a8ADg@jetpack"
]
}

View File

@ -1,4 +1,4 @@
/* show-group-options.c - Example code to retrieve the group option.
/* show-group-options.c - Example code to retriev the group option.
Copyright (C) 2008 g10 Code GmbH
This file is part of GPGME.
@ -14,7 +14,7 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, see <https://www.gnu.org/licenses/>.
License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,17 @@
@node Copying
@unnumbered GNU General Public License
@center Version 3, 29 June 2007
@c This file is intended to be included in another file.
@display
Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{https://fsf.org/}
Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{http://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
@end display
@unnumberedsec Preamble
@section Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
@ -78,7 +77,7 @@ The precise terms and conditions for copying, distribution and
modification follow.
@iftex
@unnumberedsec TERMS AND CONDITIONS
@section TERMS AND CONDITIONS
@end iftex
@ifinfo
@center TERMS AND CONDITIONS
@ -228,7 +227,7 @@ terms of section 4, provided that you also meet all of these
conditions:
@enumerate a
@item
@item
The work must carry prominent notices stating that you modified it,
and giving a relevant date.
@ -659,16 +658,13 @@ an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
@end enumerate
@iftex
@heading END OF TERMS AND CONDITIONS
@end iftex
@ifinfo
@center END OF TERMS AND CONDITIONS
@end ifinfo
@unnumberedsec How to Apply These Terms to Your New Programs
@section How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@ -678,11 +674,9 @@ terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the ``copyright'' line and a pointer to where the full notice is
found.
@example
@var{one line to give the program's name and a brief idea of what it does.}
the ``copyright'' line and a pointer to where the full notice is found.
@smallexample
@var{one line to give the program's name and a brief idea of what it does.}
Copyright (C) @var{year} @var{name of author}
This program is free software: you can redistribute it and/or modify
@ -696,22 +690,18 @@ 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, see @url{https://www.gnu.org/licenses/}.
@end example
along with this program. If not, see @url{http://www.gnu.org/licenses/}.
@end smallexample
@noindent
Also add information on how to contact you by electronic and paper mail.
@noindent
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
@smallexample
@var{program} Copyright (C) @var{year} @var{name of author}
This program comes with ABSOLUTELY NO WARRANTY; for details
type @samp{show w}. This is free software, and you are
welcome to redistribute it under certain conditions;
type @samp{show c} for details.
@var{program} Copyright (C) @var{year} @var{name of author}
This program comes with ABSOLUTELY NO WARRANTY; for details type @samp{show w}.
This is free software, and you are welcome to redistribute it under certain conditions; type @samp{show c} for details.
@end smallexample
The hypothetical commands @samp{show w} and @samp{show c} should show
@ -722,11 +712,13 @@ use an ``about box''.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a ``copyright disclaimer'' for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
@url{https://www.gnu.org/licenses/}.
@url{http://www.gnu.org/licenses/}.
The GNU General Public License does not permit incorporating your
program into proprietary programs. If your program is a subroutine
library, you may consider it more useful to permit linking proprietary
applications with the library. If this is what you want to do, use
the GNU Lesser General Public License instead of this License. But
first, please read @url{https://www.gnu.org/philosophy/why-not-lgpl.html}.
first, please read @url{http://www.gnu.org/philosophy/why-not-lgpl.html}.
@end enumerate

View File

@ -1,7 +1,7 @@
@node Library Copying
@unnumbered GNU Lesser General Public License
@cindex LGPL, GNU Lesser General Public License
@cindex LGPL, Lesser General Public License
@center Version 2.1, February 1999
@display
@ -16,7 +16,7 @@ as the successor of the GNU Library Public License, version 2, hence the
version number 2.1.]
@end display
@heading Preamble
@section Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@ -119,7 +119,7 @@ former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
@iftex
@heading TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@section TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end iftex
@ifinfo
@center GNU LESSER GENERAL PUBLIC LICENSE
@ -476,7 +476,12 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
@iftex
@heading NO WARRANTY
@end iftex
@ifinfo
@center NO WARRANTY
@end ifinfo
@item
BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
@ -510,7 +515,7 @@ DAMAGES.
@end ifinfo
@page
@heading How to Apply These Terms to Your New Libraries
@section How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that

View File

@ -1,310 +0,0 @@
/* mkdefsinc.c - Tool to create defs.inc
* Copyright (C) 2015 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.
*/
/* This tool needs to be build with command line supplied -D options
for the various directory variables. It is easier to do this in
build file than to use fragile make rules and a template file. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define PGM "mkdefsinc"
/* We include config.h after all include files because the config.h
values are not valid for the build platform but we need some values
nevertheless. */
#include "config.h"
static int verbose;
/* The usual free wrapper. */
static void
xfree (void *a)
{
if (a)
free (a);
}
static char *
xmalloc (size_t n)
{
char *p;
p = malloc (n);
if (!p)
{
fputs (PGM ": out of core\n", stderr);
exit (1);
}
return p;
}
static char *
xstrdup (const char *string)
{
char *p;
p = xmalloc (strlen (string)+1);
strcpy (p, string);
return p;
}
/* Return a malloced string with the last modification date of the
FILES. Returns NULL on error. */
static char *
get_date_from_files (char **files)
{
const char *file;
const char *usedfile = NULL;
struct stat sb;
struct tm *tp;
int errors = 0;
time_t stamp = 0;
char *result;
for (; (file = *files); files++)
{
if (!*file || !strcmp (file, ".") || !strcmp (file, ".."))
continue;
if (stat (file, &sb))
{
fprintf (stderr, PGM ": stat failed for '%s': %s\n",
file, strerror (errno));
errors = 1;
continue;
}
if (sb.st_mtime > stamp)
{
stamp = sb.st_mtime;
usedfile = file;
}
}
if (errors)
exit (1);
if (usedfile)
fprintf (stderr, PGM ": taking date from '%s'\n", usedfile);
tp = gmtime (&stamp);
if (!tp)
return NULL;
result = xmalloc (4+1+2+1+2+1);
snprintf (result, 4+1+2+1+2+1, "%04d-%02d-%02d",
tp->tm_year + 1900, tp->tm_mon+1, tp->tm_mday);
return result;
}
/* We need to escape file names for Texinfo. */
static void
print_filename (const char *prefix, const char *name)
{
const char *s;
fputs (prefix, stdout);
for (s=name; *s; s++)
switch (*s)
{
case '@': fputs ("@atchar{}", stdout); break;
case '{': fputs ("@lbracechar{}", stdout); break;
case '}': fputs ("@rbracechar{}", stdout); break;
case ',': fputs ("@comma{}", stdout); break;
case '\\':fputs ("@backslashchar{}", stdout); break;
case '#': fputs ("@hashchar{}", stdout); break;
default: putchar (*s); break;
}
putchar('\n');
}
int
main (int argc, char **argv)
{
int last_argc = -1;
char *opt_date = NULL;
int monthoff;
char *p, *pend;
size_t n;
/* Option parsing. */
if (argc)
{
argc--; argv++;
}
while (argc && last_argc != argc )
{
last_argc = argc;
if (!strcmp (*argv, "--"))
{
argc--; argv++;
break;
}
else if (!strcmp (*argv, "--help"))
{
fputs ("Usage: " PGM " [OPTION] [FILES]\n"
"Create defs.inc file.\nOptions:\n"
" -C DIR Change to DIR before doing anything\n"
" --date STRING Take publication date from STRING\n"
" --verbose Enable extra informational output\n"
" --help Display this help and exit\n"
, stdout);
exit (0);
}
else if (!strcmp (*argv, "--verbose"))
{
verbose = 1;
argc--; argv++;
}
else if (!strcmp (*argv, "-C"))
{
argc--; argv++;
if (argc)
{
if (chdir (*argv))
{
fprintf (stderr, PGM ": chdir to '%s' failed: %s\n",
*argv, strerror (errno));
exit (1);
}
argc--; argv++;
}
}
else if (!strcmp (*argv, "--date"))
{
argc--; argv++;
if (argc)
{
opt_date = xstrdup (*argv);
argc--; argv++;
}
}
else if (!strncmp (*argv, "--", 2))
{
fprintf (stderr, PGM ": unknown option '%s'\n", *argv);
exit (1);
}
}
if (opt_date && *opt_date)
{
time_t stamp;
struct tm *tp;
if (*opt_date == '2' && strlen (opt_date) >= 10
&& opt_date[4] == '-' && opt_date[7] == '-')
{
opt_date[10] = 0;
}
else if ((stamp = strtoul (opt_date, NULL, 10)) > 0
&& (tp = gmtime (&stamp)))
{
p = xmalloc (4+1+2+1+2+1);
snprintf (p, 4+1+2+1+2+1, "%04d-%02d-%02d",
tp->tm_year + 1900, tp->tm_mon+1, tp->tm_mday);
xfree (opt_date);
opt_date = p;
}
else
{
fprintf (stderr, PGM ": bad date '%s'\n", opt_date);
exit (1);
}
}
else
{
xfree (opt_date);
opt_date = argc? get_date_from_files (argv) : NULL;
}
if (!opt_date)
{
opt_date = xstrdup ("unknown");
monthoff = 0;
}
else
{
const char *month = "?";
switch (atoi (opt_date+5))
{
case 1: month = "January"; break;
case 2: month = "February"; break;
case 3: month = "March"; break;
case 4: month = "April"; break;
case 5: month = "May"; break;
case 6: month = "June"; break;
case 7: month = "July"; break;
case 8: month = "August"; break;
case 9: month = "September"; break;
case 10: month = "October"; break;
case 11: month = "November"; break;
case 12: month = "December"; break;
}
n = strlen (opt_date) + strlen (month) + 2 + 1;
p = xmalloc (n);
snprintf (p, n, "%d %n%s %d",
atoi (opt_date+8), &monthoff, month, atoi (opt_date));
xfree (opt_date);
opt_date = p;
}
fputs ("@c defs.inc -*- texinfo -*-\n"
"@c Common and build specific constants for the manuals.\n"
"@c This file has been created by " PGM ".\n\n", stdout);
fputs ("@ifclear defsincincluded\n"
"@set defsincincluded 1\n\n", stdout);
fputs ("\n@c Flags\n\n", stdout);
fputs ("\n@c Directories\n\n", stdout);
/* print_filename ("@set BINDIR ", GNUPG_BINDIR ); */
fputs ("\n@c Version information a la version.texi\n\n", stdout);
printf ("@set UPDATED %s\n", opt_date);
printf ("@set UPDATED-MONTH %s\n", opt_date + monthoff);
printf ("@set EDITION %s\n", PACKAGE_VERSION);
printf ("@set VERSION %s\n", PACKAGE_VERSION);
fputs ("\n@c Macros\n\n", stdout);
/* Trailer. */
fputs ("\n"
"@end ifclear\n"
"\n"
"@c Loc" "al Variables:\n"
"@c buffer-read-only: t\n"
"@c End:\n", stdout);
if (ferror (stdout))
{
fprintf (stderr, PGM ": error writing to stdout: %s\n", strerror (errno));
return 1;
}
return 0;
}

View File

@ -20,7 +20,7 @@
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% As a special exception, when this file is read by TeX when processing
% a Texinfo source document, you may use the result without
@ -28,7 +28,7 @@
%
% Please try the latest version of texinfo.tex before submitting bug
% reports; you can get the latest version from:
% https://www.gnu.org/software/texinfo/ (the Texinfo home page), or
% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
% ftp://tug.org/tex/texinfo.tex
% (and all CTAN mirrors, see http://www.ctan.org).
% The texinfo.tex in any given distribution could well be out
@ -54,7 +54,7 @@
% extent. You can get the existing language-specific files from the
% full Texinfo distribution.
%
% The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
\message{Loading texinfo [version \texinfoversion]:}
@ -354,7 +354,7 @@
% We don't want .vr (or whatever) entries like this:
% \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
% "\acronym" won't work when it's read back in;
% it needs to be
% it needs to be
% {\code {{\tt \backslashcurfont }acronym}
\shipout\vbox{%
% Do this early so pdf references go to the beginning of the page.
@ -460,7 +460,7 @@
\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
% Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space.
%
% \argremovec might leave us with trailing space, e.g.,
% @end itemize @c foo
@ -485,7 +485,7 @@
% to get _exactly_ the rest of the line, we had to prevent such situation.
% We prepended an \empty token at the very beginning and we expand it now,
% just before passing the control to \argtorun.
% (Similarly, we have to think about #3 of \argcheckspacesY above: it is
% (Similarily, we have to think about #3 of \argcheckspacesY above: it is
% either the null string, or it ends with \^^M---thus there is no danger
% that a pair of braces would be stripped.
%
@ -498,7 +498,7 @@
% \def\foo{\parsearg\Xfoo}
% \def\Xfoo#1{...}
%
% Actually, I use \csname\string\foo\endcsname, i.e. \\foo, as it is my
% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
% favourite TeX trick. --kasal, 16nov03
\def\parseargdef#1{%
@ -542,7 +542,7 @@
% used to check whether the current environment is the one expected.
%
% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
% are not treated as environments; they don't open a group. (The
% are not treated as enviroments; they don't open a group. (The
% implementation of @end takes care not to call \endgroup in this
% special case.)
@ -565,7 +565,7 @@
\fi
}
% Environment mismatch, #1 expected:
% Evironment mismatch, #1 expected:
\def\badenverr{%
\errhelp = \EMsimple
\errmessage{This command can appear only \inenvironment\temp,
@ -705,7 +705,7 @@
\def\?{?\spacefactor=\endofsentencespacefactor\space}
% @frenchspacing on|off says whether to put extra space after punctuation.
%
%
\def\onword{on}
\def\offword{off}
%
@ -1260,7 +1260,7 @@ where each line of input produces a line of output.}
% that's what we do).
% double active backslashes.
%
%
{\catcode`\@=0 \catcode`\\=\active
@gdef@activebackslashdouble{%
@catcode`@\=@active
@ -1272,11 +1272,11 @@ where each line of input produces a line of output.}
% us) handles it with this amazing macro to replace tokens, with minor
% changes for Texinfo. It is included here under the GPL by permission
% from the author, Heiko Oberdiek.
%
%
% #1 is the tokens to replace.
% #2 is the replacement.
% #3 is the control sequence with the string.
%
%
\def\HyPsdSubst#1#2#3{%
\def\HyPsdReplace##1#1##2\END{%
##1%
@ -1542,7 +1542,7 @@ output) for that.)}
% tried to figure out what each command should do in the context
% of @url. for now, just make @/ a no-op, that's the only one
% people have actually reported a problem with.
%
%
\normalturnoffactive
\def\@{@}%
\let\/=\empty
@ -1941,7 +1941,7 @@ end
% Definitions for a main text size of 11pt. This is the default in
% Texinfo.
%
%
\def\definetextfontsizexi{%
% Text fonts (11.2pt, magstep1).
\def\textnominalsize{11pt}
@ -2074,7 +2074,7 @@ end
% section, chapter, etc., sizes following suit. This is for the GNU
% Press printing of the Emacs 22 manual. Maybe other manuals in the
% future. Used with @smallbook, which sets the leading to 12pt.
%
%
\def\definetextfontsizex{%
% Text fonts (10pt).
\def\textnominalsize{10pt}
@ -2165,7 +2165,7 @@ end
\setfont\secsf\sfbshape{12}{1000}{OT1}
\let\secbf\secrm
\setfont\secsc\scbshape{10}{\magstep1}{OT1}
\font\seci=cmmi12
\font\seci=cmmi12
\font\secsy=cmsy10 scaled \magstep1
\def\sececsize{1200}
@ -2209,7 +2209,7 @@ end
% We provide the user-level command
% @fonttextsize 10
% (or 11) to redefine the text font size. pt is assumed.
%
%
\def\xword{10}
\def\xiword{11}
%
@ -2219,7 +2219,7 @@ end
%
% Set \globaldefs so that documents can use this inside @tex, since
% makeinfo 4.8 does not support it, but we need it nonetheless.
%
%
\begingroup \globaldefs=1
\ifx\textsizearg\xword \definetextfontsizex
\else \ifx\textsizearg\xiword \definetextfontsizexi
@ -2505,7 +2505,7 @@ end
% each of the four underscores in __typeof__. This is undesirable in
% some manuals, especially if they don't have long identifiers in
% general. @allowcodebreaks provides a way to control this.
%
%
\newif\ifallowcodebreaks \allowcodebreakstrue
\def\keywordtrue{true}
@ -2636,7 +2636,7 @@ end
% @acronym for "FBI", "NATO", and the like.
% We print this one point size smaller, since it's intended for
% all-uppercase.
%
%
\def\acronym#1{\doacronym #1,,\finish}
\def\doacronym#1,#2,#3\finish{%
{\selectfonts\lsize #1}%
@ -2648,7 +2648,7 @@ end
% @abbr for "Comput. J." and the like.
% No font change, but don't do end-of-sentence spacing.
%
%
\def\abbr#1{\doabbr #1,,\finish}
\def\doabbr#1,#2,#3\finish{%
{\plainfrenchspacing #1}%
@ -2667,43 +2667,43 @@ end
% Theiling, which support regular, slanted, bold and bold slanted (and
% "outlined" (blackboard board, sort of) versions, which we don't need).
% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
%
%
% Although only regular is the truly official Euro symbol, we ignore
% that. The Euro is designed to be slightly taller than the regular
% font height.
%
%
% feymr - regular
% feymo - slanted
% feybr - bold
% feybo - bold slanted
%
%
% There is no good (free) typewriter version, to my knowledge.
% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
% Hmm.
%
%
% Also doesn't work in math. Do we need to do math with euro symbols?
% Hope not.
%
%
%
%
\def\euro{{\eurofont e}}
\def\eurofont{%
% We set the font at each command, rather than predefining it in
% \textfonts and the other font-switching commands, so that
% installations which never need the symbol don't have to have the
% font installed.
%
%
% There is only one designed size (nominal 10pt), so we always scale
% that to the current nominal size.
%
%
% By the way, simply using "at 1em" works for cmr10 and the like, but
% does not work for cmbx10 and other extended/shrunken fonts.
%
%
\def\eurosize{\csname\curfontsize nominalsize\endcsname}%
%
\ifx\curfontstyle\bfstylename
\ifx\curfontstyle\bfstylename
% bold:
\font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
\else
\else
% regular:
\font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
\fi
@ -2756,7 +2756,7 @@ end
% Laurent Siebenmann reports \Orb undefined with:
% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
% so we'll define it if necessary.
%
%
\ifx\Orb\undefined
\def\Orb{\mathhexbox20D}
\fi
@ -3105,7 +3105,7 @@ end
% cause the example and the item to crash together. So we use this
% bizarre value of 10001 as a signal to \aboveenvbreak to insert
% \parskip glue after all. Section titles are handled this way also.
%
%
\penalty 10001
\endgroup
\itemxneedsnegativevskipfalse
@ -3901,7 +3901,7 @@ end
% processing continues to some further point. On the other hand, it
% seems \endinput does not hurt in the printed index arg, since that
% is still getting written without apparent harm.
%
%
% Sample source (mac-idx3.tex, reported by Graham Percival to
% help-texinfo, 22may06):
% @macro funindex {WORD}
@ -3909,12 +3909,12 @@ end
% @end macro
% ...
% @funindex commtest
%
%
% The above is not enough to reproduce the bug, but it gives the flavor.
%
%
% Sample whatsit resulting:
% .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
%
%
% So:
\let\endinput = \empty
%
@ -4170,11 +4170,11 @@ end
% makeinfo does not expand macros in the argument to @deffn, which ends up
% writing an index entry, and texindex isn't prepared for an index sort entry
% that starts with \.
%
%
% Since macro invocations are followed by braces, we can just redefine them
% to take a single TeX argument. The case of a macro invocation that
% goes to end-of-line is not handled.
%
%
\macrolist
}
@ -4302,7 +4302,7 @@ end
% to re-insert the same penalty (values >10000 are used for various
% signals); since we just inserted a non-discardable item, any
% following glue (such as a \parskip) would be a breakpoint. For example:
%
%
% @deffn deffn-whatever
% @vindex index-whatever
% Description.
@ -5368,11 +5368,11 @@ end
% glue accumulate. (Not a breakpoint because it's preceded by a
% discardable item.)
\vskip-\parskip
%
%
% This is purely so the last item on the list is a known \penalty >
% 10000. This is so \startdefun can avoid allowing breakpoints after
% section headings. Otherwise, it would insert a valid breakpoint between:
%
%
% @section sec-whatever
% @deffn def-whatever
\penalty 10001
@ -5430,7 +5430,7 @@ end
% These characters do not print properly in the Computer Modern roman
% fonts, so we must take special care. This is more or less redundant
% with the Texinfo input format setup at the end of this file.
%
%
\def\activecatcodes{%
\catcode`\"=\active
\catcode`\$=\active
@ -5480,7 +5480,7 @@ end
% redefined for the two-volume lispref. We always output on
% \jobname.toc even if this is redefined.
%
%
\def\tocreadfilename{\jobname.toc}
% Normal (long) toc.
@ -6035,8 +6035,8 @@ end
% from cmtt (char 0x0d). The undirected quote is ugly, so don't make it
% the default, but it works for pasting with more pdf viewers (at least
% evince), the lilypond developers report. xpdf does work with the
% regular 0x27.
%
% regular 0x27.
%
\def\codequoteright{%
\expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
\expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
@ -6048,7 +6048,7 @@ end
% and a similar option for the left quote char vs. a grave accent.
% Modern fonts display ASCII 0x60 as a grave accent, so some people like
% the code environments to do likewise.
%
%
\def\codequoteleft{%
\expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
\expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
@ -6579,7 +6579,7 @@ end
% This does \let #1 = #2, with \csnames; that is,
% \let \csname#1\endcsname = \csname#2\endcsname
% (except of course we have to play expansion games).
%
%
\def\cslet#1#2{%
\expandafter\let
\csname#1\expandafter\endcsname
@ -7317,7 +7317,7 @@ end
% In case a @footnote appears in a vbox, save the footnote text and create
% the real \insert just after the vbox finished. Otherwise, the insertion
% would be lost.
% Similarly, if a @footnote appears inside an alignment, save the footnote
% Similarily, if a @footnote appears inside an alignment, save the footnote
% text to a box and make the \insert when a row of the table is finished.
% And the same can be done for other insert classes. --kasal, 16nov03.
@ -7737,7 +7737,7 @@ end
%
% If they passed de_DE, and txi-de_DE.tex doesn't exist,
% try txi-de.tex.
%
%
\def\documentlanguagetrywithoutunderscore#1_#2\finish{%
\openin 1 txi-#1.tex
\ifeof 1
@ -7793,7 +7793,7 @@ should work if nowhere else does.}
\setnonasciicharscatcode\active
\lattwochardefs
%
\else \ifx \declaredencoding \latone
\else \ifx \declaredencoding \latone
\setnonasciicharscatcode\active
\latonechardefs
%
@ -7805,7 +7805,7 @@ should work if nowhere else does.}
\setnonasciicharscatcode\active
\utfeightchardefs
%
\else
\else
\message{Unknown document encoding #1, ignoring.}%
%
\fi % utfeight
@ -7817,7 +7817,7 @@ should work if nowhere else does.}
% A message to be logged when using a character that isn't available
% the default font encoding (OT1).
%
%
\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
% Take account of \c (plain) vs. \, (Texinfo) difference.
@ -7830,21 +7830,21 @@ should work if nowhere else does.}
%
% Latin1 (ISO-8859-1) character definitions.
\def\latonechardefs{%
\gdef^^a0{~}
\gdef^^a0{~}
\gdef^^a1{\exclamdown}
\gdef^^a2{\missingcharmsg{CENT SIGN}}
\gdef^^a2{\missingcharmsg{CENT SIGN}}
\gdef^^a3{{\pounds}}
\gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
\gdef^^a5{\missingcharmsg{YEN SIGN}}
\gdef^^a6{\missingcharmsg{BROKEN BAR}}
\gdef^^a6{\missingcharmsg{BROKEN BAR}}
\gdef^^a7{\S}
\gdef^^a8{\"{}}
\gdef^^a9{\copyright}
\gdef^^a8{\"{}}
\gdef^^a9{\copyright}
\gdef^^aa{\ordf}
\gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}}
\gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}}
\gdef^^ac{$\lnot$}
\gdef^^ad{\-}
\gdef^^ae{\registeredsymbol}
\gdef^^ad{\-}
\gdef^^ae{\registeredsymbol}
\gdef^^af{\={}}
%
\gdef^^b0{\textdegree}
@ -7871,7 +7871,7 @@ should work if nowhere else does.}
\gdef^^c2{\^A}
\gdef^^c3{\~A}
\gdef^^c4{\"A}
\gdef^^c5{\ringaccent A}
\gdef^^c5{\ringaccent A}
\gdef^^c6{\AE}
\gdef^^c7{\cedilla C}
\gdef^^c8{\`E}
@ -8012,7 +8012,7 @@ should work if nowhere else does.}
\gdef^^d6{\"O}
\gdef^^d7{$\times$}
\gdef^^d8{\v R}
\gdef^^d9{\ringaccent U}
\gdef^^d9{\ringaccent U}
\gdef^^da{\'U}
\gdef^^db{\H U}
\gdef^^dc{\"U}
@ -8056,11 +8056,11 @@ should work if nowhere else does.}
}
% UTF-8 character definitions.
%
%
% This code to support UTF-8 is based on LaTeX's utf8.def, with some
% changes for Texinfo conventions. It is included here under the GPL by
% permission from Frank Mittelbach and the LaTeX team.
%
%
\newcount\countUTFx
\newcount\countUTFy
\newcount\countUTFz
@ -8900,7 +8900,7 @@ should work if nowhere else does.}
% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
% the literal character `\'.
%
%
@def@normalturnoffactive{%
@let\=@normalbackslash
@let"=@normaldoublequote

View File

@ -158,21 +158,21 @@ indicated by a @sc{c:}, server responses by @sc{c:}:
@smallexample
@group
@clnt{RESET}
@srvr{OK}
@clnt{RECIPIENT foo@@example.net}
@srvr{OK}
@clnt{RECIPIENT bar@@example.com}
@srvr{OK}
@clnt{PREP_ENCRYPT}
@srvr{S PROTOCOL OpenPGP}
@srvr{OK}
@clnt{INPUT FD=17}
@srvr{OK}
@clnt{OUTPUT FD=18}
@srvr{OK}
@clnt{ENCRYPT}
@srvr{OK}
@clnt RESET
@srvr OK
@clnt RECIPIENT foo@@example.net
@srvr OK
@clnt RECIPIENT bar@@example.com
@srvr OK
@clnt PREP_ENCRYPT
@srvr S PROTOCOL OpenPGP
@srvr OK
@clnt INPUT FD=17
@srvr OK
@clnt OUTPUT FD=18
@srvr OK
@clnt ENCRYPT
@srvr OK
@end group
@end smallexample
@ -226,7 +226,7 @@ before the final OK response:
@deffn {Status line} MICALG @var{string}
The @var{string} represents the hash algorithm used to create the
signature. It is used with RFC-1847 style signature messages and defined by
signature. It is used with MOSS style signature messages and defined by
PGP/MIME (RFC-3156) and S/MIME (RFC-3851). The GPGME library has a
supporting function @code{gpgme_hash_algo_name} to return the algorithm
name as a string. This string needs to be lowercased and for OpenPGP
@ -260,14 +260,12 @@ encoded. For details on the file descriptor, see the description of
@noindent
The decryption is started with the command:
@deffn Command DECRYPT -@w{}-protocol=@var{name} [-@w{}-no-verify] [-@w{}-export-session-key]
@deffn Command DECRYPT -@w{}-protocol=@var{name} [-@w{}-no-verify]
@var{name} is the encryption protocol used for the message. For a
description of the allowed protocols see the @code{ENCRYPT} command.
This argument is mandatory. If the option @option{--no-verify} is
given, the server should not try to verify a signature, in case the
input data is an OpenPGP combined message. If the option
@option{--export-session-key} is given and the underlying engine knows
how to export the session key, it will appear on a status line
This argument is mandatory. If the option @option{--no-verify} is given,
the server should not try to verify a signature, in case the input data
is an OpenPGP combined message.
@end deffn
@ -370,18 +368,13 @@ message.
All file related UI server commands operate on a number of input files
or directories, specified by one or more @code{FILE} commands:
@deffn Command FILE [--clear] @var{name}
@deffn Command FILE @var{name} [--continued]
Add the file or directory @var{name} to the list of pathnames to be
processed by the server. The parameter @var{name} must be an absolute
path name (including the drive letter) and is percent espaced (in
particular, the characters %, = and white space characters are always
escaped). If the option @code{--clear} is given, the list of files is
cleared before adding @var{name}.
Historical note: The original spec did not define @code{--clear} but
the keyword @code{--continued} after the file name to indicate that
more files are to be expected. However, this has never been used and
thus removed from the specs.
escaped). The option @code{--continued} is present for all but the
last @code{FILE} command.
@end deffn
@ -484,7 +477,7 @@ First, the input files need to be specified by one or more
@code{FILE} commands. Afterwards, the actual operation is requested:
@deffn Command CHECKSUM_CREATE_FILES --nohup
Request that checksums are created for the files specified by
Request that checksums are created for the files specifed by
@code{FILE}. The choice of checksum algorithm and the destination
storage and format for the created checksums depend on the preferences
of the user and the functionality provided by the UI server. For
@ -499,7 +492,7 @@ promptly, and completes the operation asynchronously.
@deffn Command CHECKSUM_VERIFY_FILES --nohup
Request that checksums are created for the files specified by
Request that checksums are created for the files specifed by
@code{FILE} and verified against previously created and stored
checksums. The choice of checksum algorithm and the source storage
and format for previously created checksums depend on the preferences
@ -564,7 +557,7 @@ do this it uses the Assuan command:
@deffn Command START_KEYMANAGER
The server shall pop up the main window of the key manager (aka
certificate manager). The client expects that the key manager is brought
into the foregound and that this command immediately returns (does not
into the foregound and that this command immediatley returns (does not
wait until the key manager has been fully brought up).
@end deffn
@ -575,7 +568,7 @@ do this it uses the Assuan command:
@deffn Command START_CONFDIALOG
The server shall pop up its configuration dialog. The client expects
that this dialog is brought into the foregound and that this command
immediately returns (i.e. it does not wait until the dialog has been
immediatley returns (i.e. it does not wait until the dialog has been
fully brought up).
@end deffn

View File

@ -3,8 +3,8 @@ Summary: GPGME - GnuPG Made Easy
Name: gpgme
Version: @pkg_version@
Release: 1
URL: https://gnupg.org/gpgme.html
Source: https://www.gnupg.org/ftp/gcrypt/gpgme/%{name}-%{version}.tar.gz
URL: http://www.gnupg.org/gpgme.html
Source: ftp://ftp.gnupg.org/gcrypt/alpha/gpgme/%{name}-%{version}.tar.gz
Group: Development/Libraries
Copyright: GPL
BuildRoot: %{_tmppath}/%{name}-%{version}
@ -38,12 +38,10 @@ make distclean
%post
/sbin/ldconfig
/sbin/install-info %{_infodir}/gpgme.info.gz %{_infodir}/dir
/sbin/install-info %{_infodir}/gpgme-python-howto.info.gz %{_infodir}/dir
%preun
if [ "$1" = 0 ]; then
/sbin/install-info --delete %{_infodir}/gpgme.info.gz %{_infodir}/dir
/sbin/install-info --delete %{_infodir}/gpgme-python-howto.info.gz %{_infodir}/dir
fi
%postun
@ -59,7 +57,6 @@ fi
%{_includedir}/gpgme.h
%{_datadir}/aclocal/gpgme.m4
%{_infodir}/gpgme.info*
%{_infodir}/gpgme-python-howto.info*
%changelog
* Sat Aug 30 2003 Robert Schiele <rschiele@uni-mannheim.de>

View File

@ -35,9 +35,9 @@ support OpenPGP and the Cryptographic Message Syntax.
%%GNU: no
%%web-page: https://www.gnupg.org/gpgme.html
%%web-page: http://www.gnupg.org/gpgme.html
%%support: paid extension/consulting from https://www.g10code.com
%%support: paid extension/consulting from http://www.g10code.com
%%doc: English programmer reference in Texinfo, Postscript, HTML included
@ -47,13 +47,13 @@ support OpenPGP and the Cryptographic Message Syntax.
%%sponsors:
%%source: https://www.gnupg.org/ftp/gcrypt/gpgme/
%%source: ftp://ftp.gnupg.org/gcrypt/gpgme/
%%debian:
%%redhat:
%%repository: See https://dev.gnupg.org/source/gpgme/
%%repository: See http://www.gnupg.org/cvs-access.html
%%related:

View File

@ -14,10 +14,9 @@
# Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <https://gnu.org/licenses/>.
# SPDX-License-Identifier: LGPL-2.1-or-later
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
SUBDIRS = $(ENABLED_LANGUAGES)
DIST_SUBDIRS = cl cpp qt python js
SUBDIRS = cl
EXTRA_DIST = README

View File

@ -10,7 +10,3 @@ sub-directory.
Directory Language
cl Common Lisp
cpp C++
qt Qt-Framework API
python Python 2 and 3 (module name: gpg)
js Native messaging client for the gpgme-json server.

View File

@ -13,11 +13,12 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <https://gnu.org/licenses/>.
# SPDX-License-Identifier: LGPL-2.1-or-later
# 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
clfiles = gpgme.asd gpgme-package.lisp gpgme-grovel.lisp gpgme.lisp
clfiles = gpgme.asd gpgme-package.lisp gpgme.lisp
# FIXME: Should be configurable.
clfilesdir = $(datadir)/common-lisp/source/gpgme

View File

@ -3,50 +3,33 @@ Common Lisp Support for GPGME
Requirements:
ASDF Packaging Support
CFFI Foreign Function Interface
trivial-garbage Finalizers
gpg-error GPG Error Codes
ASDF Packaging Support
CFFI Foreign Function Interface
gpg-error GPG Error Codes
Use with:
> (asdf:load-system "gpgme")
> (asdf:operate 'asdf:load-op ':gpgme)
Examples
--------
(with-open-file (out "/tmp/myout"
:direction :output
:if-exists :supersede
:element-type '(unsigned-byte 8))
(with-open-file (stream "/tmp/myout" :direction :output
:if-exists :supersede :element-type '(unsigned-byte 8))
(with-context (ctx)
(setf (armorp ctx) t)
(setf (armor-p ctx) t)
(op-export ctx "DEADBEEF" out)))
(with-context (ctx)
(with-output-to-string (out)
(setf (armorp ctx) t)
(setf (armor-p ctx) t)
(op-export ctx "McTester" out)))
(gpgme:with-context (ctx :armor t)
(with-output-to-string (out)
(gpgme:op-export ctx "McTester" out)))
(gpgme:with-context (ctx :armor t)
(let ((recipient1 (gpgme:get-key ctx "DEADBEEF"))
(recipient2 (gpgme:get-key ctx "Alice"))
(message "Hello, world!"))
(with-output-to-string (out)
(with-input-from-string (in message)
(gpgme:op-encrypt ctx (vector recipient1 recipient2) in out)))))
(gpgme:with-context (ctx :armor t)
(let ((message "Hello, world!"))
(with-output-to-string (out)
(with-input-from-string (in message)
(gpgme:op-sign ctx in out)))))
TODO
----

View File

@ -1,31 +0,0 @@
;;;; gpgme-grovel.lisp
;;; This file is part of GPGME-CL.
;;;
;;; GPGME-CL 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-CL is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;; Lesser General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GPGME; if not, write to the Free Software Foundation,
;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
(in-package :gpgme)
(include "errno.h" "sys/types.h")
(constant (+ebadf+ "EBADF"))
(ctype off-t "off_t")
(ctype size-t "size_t")
(ctype ssize-t "ssize_t")
(cvar ("errno" *errno*) :int)

View File

@ -26,8 +26,7 @@
(defpackage #:gpgme
(:use #:common-lisp #:cffi #:gpg-error)
(:import-from #:trivial-garbage
#:finalize)
(:export #:check-version
#:*version*
#:context

View File

@ -25,14 +25,11 @@
(in-package #:gpgme-system)
(defsystem gpgme
:description "GnuPG Made Easy."
:author "g10 Code GmbH"
:version "@VERSION@"
:licence "GPL"
:defsystem-depends-on ("cffi-grovel")
:depends-on ("cffi" "gpg-error" "trivial-garbage")
:components ((:file "gpgme-package")
(:cffi-grovel-file "gpgme-grovel"
:depends-on ("gpgme-package"))
(:file "gpgme"
:depends-on ("gpgme-package" "gpgme-grovel"))))
:description "GnuPG Made Easy."
:author "g10 Code GmbH"
:version "@VERSION@"
:licence "GPL"
:depends-on ("cffi" "gpg-error")
:components ((:file "gpgme-package")
(:file "gpgme"
:depends-on ("gpgme-package"))))

View File

@ -24,12 +24,6 @@
(in-package :gpgme)
(deftype byte-array ()
'(simple-array (unsigned-byte 8) (*)))
(deftype character-array ()
'(simple-array character (*)))
;;; Debugging.
(defvar *debug* nil "If debugging output should be given or not.")
@ -44,15 +38,23 @@
;;; System dependencies.
; Access to ERRNO.
; FIXME: Use cffi-grovel? cffi-unix?
(defctype size-t :unsigned-int "The system size_t type.")
(defctype ssize-t :int "The system ssize_t type.")
; FIXME: Ouch. Grovel? Helper function?
(defconstant +seek-set+ 0)
(defconstant +seek-cur+ 1)
(defconstant +seek-end+ 2)
(defctype off-t :long-long "The system off_t type.")
(defcfun ("strerror" c-strerror) :string
(err :int))
(defun get-errno ()
*errno*)
(defun set-errno (errno)
(setf *errno* errno))
; Access to ERRNO.
; FIXME: Ouch. Should be grovel + helper function.
(define-condition system-error (error)
((errno :initarg :errno :reader system-error-errno))
@ -62,6 +64,14 @@
(c-strerror (system-error-errno c)))))
(:documentation "Signalled when an errno is encountered."))
(defconstant +ebadf+ 1)
; Ouch.
(defun get-errno ()
+ebadf+)
;;; More about errno below.
; Needed to write passphrases.
(defcfun ("write" c-write) ssize-t
(fd :int)
@ -73,6 +83,14 @@
(when (< res 0) (error 'system-error :errno (get-errno)))
res))
;;; More about errno here.
(defun set-errno (errno)
(cond
; Works on GNU/Linux.
((eql errno +ebadf+) (system-write -1 (null-pointer) 0))
(t (error 'invalid-errno :errno errno))))
;;;
;;; C Interface Definitions
;;;
@ -82,39 +100,22 @@
;;; Some new data types used for easier translation.
;;; The number of include certs. Translates to NIL for default.
(defctype cert-int-t
(:wrapper :int
:from-c translate-cert-int-t-from-foreign
:to-c translate-cert-int-t-to-foreign))
(defctype cert-int-t :int)
;;; A string that may be NIL to indicate a null pointer.
(defctype string-or-nil-t
(:wrapper :string
:to-c translate-string-or-nil-t-to-foreign))
(defctype string-or-nil-t :string)
;;; Some opaque data types used by GPGME.
(defctype gpgme-ctx-t
(:wrapper :pointer
:to-c translate-gpgme-ctx-t-to-foreign)
"The GPGME context type.")
(defctype gpgme-ctx-t :pointer "The GPGME context type.")
(defctype gpgme-data-t
(:wrapper :pointer
:to-c translate-gpgme-data-t-to-foreign)
"The GPGME data object type.")
(defctype gpgme-data-t :pointer "The GPGME data object type.")
;;; Wrappers for the libgpg-error library.
(defctype gpgme-error-t
(:wrapper gpg-error::gpg-error-t
:from-c translate-gpgme-error-t-from-foreign
:to-c translate-gpgme-error-t-to-foreign)
"The GPGME error type.")
(defctype gpgme-error-t gpg-error::gpg-error-t "The GPGME error type.")
(defctype gpgme-error-no-signal-t
(:wrapper gpg-error::gpg-error-t
:from-c translate-gpgme-error-no-signal-t-from-foreign)
(defctype gpgme-error-no-signal-t gpg-error::gpg-error-t
"The GPGME error type (this version does not signal conditions in translation.")
(defctype gpgme-err-code-t gpg-error::gpg-err-code-t
@ -140,11 +141,11 @@
(gpg-err-source err))
(defun gpgme-strerror (err)
"Return a string containing a description of the error code."
"Return a string containig a description of the error code."
(gpg-strerror err))
(defun gpgme-strsource (err)
"Return a string containing a description of the error source."
"Return a string containig a description of the error source."
(gpg-strsource err))
(defun gpgme-err-code-from-errno (err)
@ -170,11 +171,7 @@
(:none 0)
(:binary 1)
(:base64 2)
(:armor 3)
(:url 4)
(:urlesc 5)
(:url0 6)
(:mime 7))
(:armor 3))
;;;
@ -185,11 +182,7 @@
(:rsa-s 3)
(:elg-e 16)
(:dsa 17)
(:ecc 18)
(:elg 20)
(:ecdsa 301)
(:ecdh 302)
(:eddsa 303))
(:elg 20))
(defcenum gpgme-hash-algo-t
"Hash algorithms from libgcrypt."
@ -203,7 +196,6 @@
(:sha256 8)
(:sha384 9)
(:sha512 10)
(:sha224 11)
(:md4 301)
(:crc32 302)
(:crc32-rfc1510 303)
@ -233,14 +225,7 @@
(defcenum gpgme-protocol-t
"The available protocols."
(:openpgp 0)
(:cms 1)
(:gpgconf 2)
(:assuan 3)
(:g13 4)
(:uiserver 5)
(:spawn 6)
(:default 254)
(:unknown 255))
(:cms 1))
;;;
@ -249,10 +234,6 @@
(:local 1)
(:extern 2)
(:sigs 4)
(:sig-notations)
(:with-secret 16)
(:with-tofu 32)
(:ephemeral 128)
(:validate 256))
;;;
@ -262,12 +243,10 @@
(:human-readable 1)
(:critical 2))
(defctype gpgme-sig-notation-t
(:wrapper :pointer
:from-c translate-gpgme-sig-notation-t-from-foreign)
(defctype gpgme-sig-notation-t :pointer
"Signature notation pointer type.")
;; FIXME: Doesn't this depend on endianness?
;; FIXME: Doesn't this depend on endianess?
(defbitfield (gpgme-sig-notation-bitfield :unsigned-int)
(:human-readable 1)
(:critical 2))
@ -284,115 +263,15 @@
;;;
;; FIXME: Add status codes.
(defcenum gpgme-status-code-t
"The possible status codes for the edit operation."
(:eof 0)
(:enter 1)
(:leave 2)
(:abort 3)
(:goodsig 4)
(:badsig 5)
(:errsig 6)
(:badarmor 7)
(:rsa-or-idea 8)
(:keyexpired 9)
(:keyrevoked 10)
(:trust-undefined 11)
(:trust-never 12)
(:trust-marginal 13)
(:trust-fully 14)
(:trust-ultimate 15)
(:shm-info 16)
(:shm-get 17)
(:shm-get-bool 18)
(:shm-get-hidden 19)
(:need-passphrase 20)
(:validsig 21)
(:sig-id 22)
(:enc-to 23)
(:nodata 24)
(:bad-passphrase 25)
(:no-pubkey 26)
(:no-seckey 27)
(:need-passphrase-sym 28)
(:decryption-failed 29)
(:decryption-okay 30)
(:missing-passphrase 31)
(:good-passphrase 32)
(:goodmdc 33)
(:badmdc 34)
(:errmdc 35)
(:imported 36)
(:import-ok 37)
(:import-problem 38)
(:import-res 39)
(:file-start 40)
(:file-done 41)
(:file-error 42)
(:begin-decryption 43)
(:end-decryption 44)
(:begin-encryption 45)
(:end-encryption 46)
(:delete-problem 47)
(:get-bool 48)
(:get-line 49)
(:get-hidden 50)
(:got-it 51)
(:progress 52)
(:sig-created 53)
(:session-key 54)
(:notation-name 55)
(:notation-data 56)
(:policy-url 57)
(:begin-stream 58)
(:end-stream 59)
(:key-created 60)
(:userid-hint 61)
(:unexpected 62)
(:inv-recp 63)
(:no-recp 64)
(:already-signed 65)
(:sigexpired 66)
(:expsig 67)
(:expkeysig 68)
(:truncated 69)
(:error 70)
(:newsig 71)
(:revkeysig 72)
(:sig-subpacket 73)
(:need-passphrase-pin 74)
(:sc-op-failure 75)
(:sc-op-success 76)
(:cardctrl 77)
(:backup-key-created 78)
(:pka-trust-bad 79)
(:pka-trust-good 80)
(:plaintext 81)
(:inv-sgnr 82)
(:no-sgnr 83)
(:success 84)
(:decryption-info 85)
(:plaintext-length 86)
(:mountpoint 87)
(:pinentry-launched 88)
(:attribute 89)
(:begin-signing 90)
(:key-not-created 91)
(:inquire-maxlen 92)
(:failure 93)
(:key-considered 94)
(:tofu-user 95)
(:tofu-stats 96)
(:tofu-stats-long 97)
(:notation-flags 98)
(:decryption-compliance-mode 99)
(:verification-compliance-mode 100))
(:enter 1))
;;;
(defctype gpgme-engine-info-t
(:wrapper :pointer
:from-c translate-gpgme-engine-info-t-to-foreign)
(defctype gpgme-engine-info-t :pointer
"The engine information structure pointer type.")
(defcstruct gpgme-engine-info
@ -406,12 +285,9 @@
;;;
(defctype gpgme-subkey-t
(:wrapper :pointer
:from-c translate-gpgme-subkey-t-from-foreign)
"A subkey from a key.")
(defctype gpgme-subkey-t :pointer "A subkey from a key.")
;; FIXME: Doesn't this depend on endianness?
;; FIXME: Doesn't this depend on endianess?
(defbitfield (gpgme-subkey-bitfield :unsigned-int)
"The subkey bitfield."
(:revoked 1)
@ -423,9 +299,7 @@
(:can-certify 64)
(:secret 128)
(:can-authenticate 256)
(:is-qualified 512)
(:is-cardkey 1024)
(:is-de-vs 2048))
(:is-qualified 512))
(defcstruct gpgme-subkey
"Subkey from a key."
@ -440,12 +314,10 @@
(expires :long))
(defctype gpgme-key-sig-t
(:wrapper :pointer
:from-c translate-gpgme-key-sig-t-from-foreign)
(defctype gpgme-key-sig-t :pointer
"A signature on a user ID.")
;; FIXME: Doesn't this depend on endianness?
;; FIXME: Doesn't this depend on endianess?
(defbitfield (gpgme-key-sig-bitfield :unsigned-int)
"The key signature bitfield."
(:revoked 1)
@ -471,12 +343,10 @@
(sig-class :unsigned-int))
(defctype gpgme-user-id-t
(:wrapper :pointer
:from-c translate-gpgme-user-id-t-from-foreign)
(defctype gpgme-user-id-t :pointer
"A user ID from a key.")
;; FIXME: Doesn't this depend on endianness?
;; FIXME: Doesn't this depend on endianess?
(defbitfield (gpgme-user-id-bitfield :unsigned-int)
"The user ID bitfield."
(:revoked 1)
@ -495,13 +365,10 @@
(-last-keysig gpgme-key-sig-t))
(defctype gpgme-key-t
(:wrapper :pointer
:from-c translate-gpgme-key-t-from-foreign
:to-c translate-gpgme-key-t-to-foreign)
(defctype gpgme-key-t :pointer
"A key from the keyring.")
;; FIXME: Doesn't this depend on endianness?
;; FIXME: Doesn't this depend on endianess?
(defbitfield (gpgme-key-bitfield :unsigned-int)
"The key bitfield."
(:revoked 1)
@ -826,9 +693,7 @@
;;;
(defctype gpgme-invalid-key-t
(:wrapper :pointer
:from-c translate-gpgme-invalid-key-t-from-foreign)
(defctype gpgme-invalid-key-t :pointer
"An invalid key structure.")
(defcstruct gpgme-invalid-key
@ -843,9 +708,7 @@
"Encryption result structure."
(invalid-recipients gpgme-invalid-key-t))
(defctype gpgme-op-encrypt-result-t
(:wrapper :pointer
:from-c translate-gpgme-op-encrypt-result-t-from-foreign)
(defctype gpgme-op-encrypt-result-t :pointer
"An encryption result structure.")
(defcfun ("gpgme_op_encrypt_result" c-gpgme-op-encrypt-result)
@ -853,15 +716,7 @@
(ctx gpgme-ctx-t))
(defbitfield gpgme-encrypt-flags-t
(:always-trust 1)
(:no-encrypt-to 2)
(:prepare 4)
(:expect-sign 8)
(:no-compress 16)
(:symmetric 32)
(:throw-keyids 64)
(:wrap 128)
(:want-address 256))
(:always-trust 1))
(defcfun ("gpgme_op_encrypt_start" c-gpgme-op-encrypt-start) gpgme-error-t
(ctx gpgme-ctx-t)
@ -894,9 +749,7 @@
;;; Decryption.
(defctype gpgme-recipient-t
(:wrapper :pointer
:from-c translate-gpgme-recipient-t-from-foreign)
(defctype gpgme-recipient-t :pointer
"A recipient structure.")
(defcstruct gpgme-recipient
@ -909,9 +762,7 @@
(defbitfield gpgme-op-decrypt-result-bitfield
"Decryption result structure bitfield."
(:wrong-key-usage 1)
(:is-de-vs 2)
(:is-mine 4))
(:wrong-key-usage 1))
(defcstruct gpgme-op-decrypt-result
"Decryption result structure."
@ -920,9 +771,7 @@
(recipients gpgme-recipient-t)
(file-name :string))
(defctype gpgme-op-decrypt-result-t
(:wrapper :pointer
:from-c translate-gpgme-op-decrypt-result-t-from-foreign)
(defctype gpgme-op-decrypt-result-t :pointer
"A decryption result structure.")
(defcfun ("gpgme_op_decrypt_result" c-gpgme-op-decrypt-result)
@ -952,9 +801,7 @@
;;; Signing.
(defctype gpgme-new-signature-t
(:wrapper :pointer
:from-c translate-gpgme-new-signature-t-from-foreign)
(defctype gpgme-new-signature-t :pointer
"A new signature structure.")
(defcstruct gpgme-new-signature
@ -974,9 +821,7 @@
(invalid-signers gpgme-invalid-key-t)
(signatures gpgme-new-signature-t))
(defctype gpgme-op-sign-result-t
(:wrapper :pointer
:from-c translate-gpgme-op-sign-result-t-from-foreign)
(defctype gpgme-op-sign-result-t :pointer
"A signing result structure.")
(defcfun ("gpgme_op_sign_result" c-gpgme-op-sign-result)
@ -1009,21 +854,15 @@
(:crl-missing #x0100)
(:crl-too-old #x0200)
(:bad-policy #x0400)
(:sys-error #x0800)
(:tofu-conflict #x1000))
(:sys-error #x0800))
(defctype gpgme-signature-t
(:wrapper :pointer
:from-c translate-gpgme-signature-t-from-foreign)
(defctype gpgme-signature-t :pointer
"A signature structure.")
;; FIXME: Doesn't this depend on endianness?
;; FIXME: Doesn't this depend on endianess?
(defbitfield (gpgme-signature-bitfield :unsigned-int)
"The signature bitfield."
(:wrong-key-usage 1)
(:pka-trust 2)
(:chain-model 4)
(:is-de-vs 8))
(:wrong-key-usage 1))
(defcstruct gpgme-signature
"Signature structure."
@ -1045,9 +884,7 @@
(signatures gpgme-signature-t)
(file-name :string))
(defctype gpgme-op-verify-result-t
(:wrapper :pointer
:from-c translate-gpgme-op-verify-result-t-from-foreign)
(defctype gpgme-op-verify-result-t :pointer
"A verify result structure.")
(defcfun ("gpgme_op_verify_result" c-gpgme-op-verify-result)
@ -1076,9 +913,7 @@
(:subkey #x0008)
(:secret #x0010))
(defctype gpgme-import-status-t
(:wrapper :pointer
:from-c translate-gpgme-import-status-t-from-foreign)
(defctype gpgme-import-status-t :pointer
"An import status structure.")
(defcstruct gpgme-import-status
@ -1106,9 +941,7 @@
(not-imported :int)
(imports gpgme-import-status-t))
(defctype gpgme-op-import-result-t
(:wrapper :pointer
:from-c translate-gpgme-op-import-result-t-from-foreign)
(defctype gpgme-op-import-result-t :pointer
"An import status result structure.")
(defcfun ("gpgme_op_import_result" c-gpgme-op-import-result)
@ -1144,8 +977,7 @@
(defbitfield (gpgme-genkey-flags-t :unsigned-int)
"Flags used for the key generation result bitfield."
(:primary #x0001)
(:sub #x0002)
(:uid #x0004))
(:sub #x0002))
(defcstruct gpgme-op-genkey-result
"Key generation result structure."
@ -1246,20 +1078,21 @@
;;; cert-int-t is a helper type that takes care of representing the
;;; default number of certs as NIL.
(defun translate-cert-int-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'cert-int-t)))
(cond
((eql value +include-certs-default+) nil)
(t value)))
(defun translate-cert-int-t-to-foreign (value)
(defmethod translate-to-foreign (value (type (eql 'cert-int-t)))
(cond
(value value)
(t +include-certs-default+)))
;;; string-or-nil-t translates a null pointer to NIL and vice versa.
;;; Translation from foreign null pointer already works as expected.
;;; FIXME: May the "to foreign" conversion problem be a bug in CFFI?
(defun translate-string-or-nil-t-to-foreign (value)
(defmethod translate-to-foreign (value (type (eql 'string-or-nil-t)))
(cond
(value value)
(t (null-pointer))))
@ -1276,12 +1109,12 @@
;;; FIXME: Should we use a hash table (or struct, or clos) instead of
;;; property list, as recommended by the Lisp FAQ?
(defun translate-gpgme-engine-info-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-engine-info-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next protocol file-name version req-version home-dir)
value (:struct gpgme-engine-info))
value gpgme-engine-info)
(append (list protocol (list
:file-name file-name
:version version
@ -1289,53 +1122,55 @@
:home-dir home-dir))
next)))))
(defun translate-gpgme-invalid-key-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-invalid-key-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next fpr reason)
value (:struct gpgme-invalid-key))
value gpgme-invalid-key)
(append (list (list :fpr fpr
:reason reason))
next)))))
(defun translate-gpgme-op-encrypt-result-t-from-foreign (value)
(defmethod translate-from-foreign (value
(type (eql 'gpgme-op-encrypt-result-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((invalid-recipients)
value (:struct gpgme-op-encrypt-result))
value gpgme-op-encrypt-result)
(list :encrypt
(list :invalid-recipients invalid-recipients))))))
(defun translate-gpgme-recipient-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-recipient-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next keyid pubkey-algo status)
value (:struct gpgme-recipient))
value gpgme-recipient)
(append (list (list :keyid keyid
:pubkey-algo pubkey-algo
:status status))
next)))))
(defun translate-gpgme-op-decrypt-result-t-from-foreign (value)
(defmethod translate-from-foreign (value
(type (eql 'gpgme-op-decrypt-result-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((unsupported-algorithm bitfield recipients file-name)
value (:struct gpgme-op-decrypt-result))
value gpgme-op-decrypt-result)
(list :decrypt (list :unsupported-algorithm unsupported-algorithm
:bitfield bitfield
:recipients recipients
:file-name file-name))))))
(defun translate-gpgme-new-signature-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-new-signature-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next type pubkey-algo hash-algo timestamp fpr sig-class)
value (:struct gpgme-new-signature))
value gpgme-new-signature)
(append (list (list :type type
:pubkey-algo pubkey-algo
:hash-algo hash-algo
@ -1344,23 +1179,24 @@
:sig-class sig-class))
next)))))
(defun translate-gpgme-op-sign-result-t-from-foreign (value)
(defmethod translate-from-foreign (value
(type (eql 'gpgme-op-sign-result-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((invalid-signers signatures)
value (:struct gpgme-op-sign-result))
value gpgme-op-sign-result)
(list :sign (list :invalid-signers invalid-signers
:signatures signatures))))))
(defun translate-gpgme-signature-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-signature-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next summary fpr status notations timestamp
exp-timestamp bitfield validity validity-reason
pubkey-algo hash-algo)
value (:struct gpgme-signature))
value gpgme-signature)
(append (list (list :summary summary
:fpr fpr
:status status
@ -1373,27 +1209,29 @@
:pubkey-algo pubkey-algo))
next)))))
(defun translate-gpgme-op-verify-result-t-from-foreign (value)
(defmethod translate-from-foreign (value
(type (eql 'gpgme-op-verify-result-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((signatures file-name)
value (:struct gpgme-op-verify-result))
value gpgme-op-verify-result)
(list :verify (list :signatures signatures
:file-name file-name))))))
(defun translate-gpgme-import-status-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-import-status-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next fpr result status)
value (:struct gpgme-import-status))
value gpgme-import-status)
(append (list (list :fpr fpr
:result result
:status status))
next)))))
(defun translate-gpgme-op-import-result-t-from-foreign (value)
(defmethod translate-from-foreign (value
(type (eql 'gpgme-op-import-result-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
@ -1402,7 +1240,7 @@
new-revocations secret-read secret-imported
secret-unchanged skipped-new-keys not-imported
imports)
value (:struct gpgme-op-import-result))
value gpgme-op-import-result)
(list :verify (list :considered considered
:no-user-id no-user-id
:imported imported
@ -1434,19 +1272,19 @@
(gpgme-strsource (gpgme-error-value c)))))
(:documentation "Signalled when a GPGME function returns an error."))
(defun translate-gpgme-error-t-from-foreign (value)
(defmethod translate-from-foreign (value (name (eql 'gpgme-error-t)))
"Raise a GPGME-ERROR if VALUE is non-zero."
(when (not (eql (gpgme-err-code value) :gpg-err-no-error))
(error 'gpgme-error :gpgme-error value))
(gpg-err-canonicalize value))
(defun translate-gpgme-error-t-to-foreign (value)
(defmethod translate-to-foreign (value (name (eql 'gpgme-error-t)))
"Canonicalize the error value."
(if (eql (gpgme-err-code value) :gpg-err-no-error)
0
(gpg-err-as-value value)))
(defun translate-gpgme-error-no-signal-t-from-foreign (value)
(defmethod translate-from-foreign (value (name (eql 'gpgme-error-no-signal-t)))
"Canonicalize the error value."
(gpg-err-canonicalize value))
@ -1683,75 +1521,68 @@
;;; The release callback removes the stream from the *data-handles*
;;; hash and releases the CBS structure that is used as the key in
;;; that hash. It is implicitly invoked (through GPGME) by
;;; that hash. It is implicitely invoked (through GPGME) by
;;; gpgme-data-release.
(defcallback data-release-cb :void ((handle :pointer))
(unwind-protect (remhash (pointer-address handle) *data-handles*)
(when (not (null-pointer-p handle)) (foreign-free handle))))
(defcallback data-read-cb ssize-t ((handle :pointer) (buffer :pointer)
(size size-t))
(size size-t))
(when *debug* (format t "DEBUG: gpgme-data-read-cb: want ~A~%" size))
(let ((stream (gethash (pointer-address handle) *data-handles*)))
(cond
(stream
(let* ((stream-type (stream-element-type stream))
(seq (make-array size :element-type stream-type))
(read (read-sequence seq stream)))
(cond
((equal stream-type '(unsigned-byte 8))
(dotimes (i read)
(setf (mem-aref buffer :unsigned-char i)
(aref (the byte-array seq) i))))
((eql stream-type 'character)
(dotimes (i read)
(setf (mem-aref buffer :unsigned-char i)
(char-code (aref (the character-array seq) i)))))
(t
(dotimes (i read)
(setf (mem-aref buffer :unsigned-char i)
(coerce (aref seq i) '(unsigned-byte 8))))))
(when *debug* (format t "DEBUG: gpgme-data-read-cb: read ~A~%" read))
read))
(t
(set-errno +ebadf+)
-1))))
(seq (make-array size :element-type stream-type))
(read (read-sequence seq stream)))
(loop for i from 0 to (- read 1)
do (setf (mem-aref buffer :unsigned-char i)
;;; FIXME: This is a half-assed attempt at
;;; supporting character streams.
(cond
((eql stream-type 'character)
(char-code (elt seq i)))
(t (coerce (elt seq i) stream-type)))))
(when *debug* (format t "DEBUG: gpgme-data-read-cb: read ~A~%" read))
read))
(t (set-errno +ebadf+)
-1))))
(defcallback data-write-cb ssize-t ((handle :pointer) (buffer :pointer)
(size size-t))
(size size-t))
(when *debug* (format t "DEBUG: gpgme-data-write-cb: want ~A~%" size))
(let ((stream (gethash (pointer-address handle) *data-handles*)))
(cond
(stream
(let* ((stream-type (stream-element-type stream))
(seq (make-array size :element-type stream-type)))
(cond
((equal stream-type '(unsigned-byte 8))
(dotimes (i size)
(setf (aref (the byte-array seq) i)
(mem-aref buffer :unsigned-char i))))
((eql stream-type 'character)
(dotimes (i size)
(setf (aref (the character-array seq) i)
(code-char (mem-aref buffer :unsigned-char i)))))
(t
(dotimes (i size)
(setf (aref seq i)
(coerce (mem-aref buffer :unsigned-char i) stream-type)))))
(write-sequence seq stream)
size))
(t
(set-errno +ebadf+)
-1))))
(seq (make-array size :element-type stream-type)))
(loop for i from 0 to (- size 1)
do (setf (elt seq i)
;;; FIXME: This is a half-assed attempt at
;;; supporting character streams.
(cond
((eql stream-type 'character)
(code-char (mem-aref buffer :unsigned-char i)))
(t (coerce (mem-aref buffer :unsigned-char i)
stream-type)))))
(write-sequence seq stream)
;;; FIXME: What about write errors?
size))
(t (set-errno +ebadf+)
-1))))
;;; This little helper macro allows us to swallow the cbs structure by
;;; simply setting it to a null pointer, but still protect against
;;; conditions.
(defmacro with-cbs-swallowed ((cbs) &body body)
`(let ((,cbs (foreign-alloc '(:struct gpgme-data-cbs))))
`(let ((,cbs (foreign-alloc 'gpgme-data-cbs)))
(unwind-protect (progn ,@body)
(when (not (null-pointer-p ,cbs)) (foreign-free ,cbs)))))
;;; FIXME: Wrap the object and attach to it a finalizer. Requires new
;;; CFFI. Should we use an OO interface, ie make-instance? For now,
;;; we do not provide direct access to data objects.
(defun gpgme-data-new (stream &key encoding file-name)
"Allocate a new GPGME data object for STREAM."
(with-foreign-object (dh-p 'gpgme-data-t)
@ -1761,14 +1592,12 @@
;;; unique C pointer as handle anyway to look up the stream in the
;;; callback. This is a convenient one to use.
(with-cbs-swallowed (cbs)
(setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'read)
(callback data-read-cb))
(setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'write)
(callback data-write-cb))
(setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'seek)
(null-pointer))
(setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'release)
(callback data-release-cb))
(setf
(foreign-slot-value cbs 'gpgme-data-cbs 'read) (callback data-read-cb)
(foreign-slot-value cbs 'gpgme-data-cbs 'write) (callback data-write-cb)
(foreign-slot-value cbs 'gpgme-data-cbs 'seek) (null-pointer)
(foreign-slot-value cbs 'gpgme-data-cbs 'release) (callback
data-release-cb))
(c-gpgme-data-new-from-cbs dh-p cbs cbs)
(let ((dh (mem-ref dh-p 'gpgme-data-t)))
(when encoding (gpgme-data-set-encoding dh encoding))
@ -1783,40 +1612,19 @@
(when *debug* (format t "DEBUG: gpgme-data-new: ~A~%" dh))
dh))))
;;; This function releases a GPGME data object. It implicitly
;;; This function releases a GPGME data object. It implicitely
;;; invokes the data-release-cb function to clean up associated junk.
(defun gpgme-data-release (dh)
"Release a GPGME data object."
(when *debug* (format t "DEBUG: gpgme-data-release: ~A~%" dh))
(c-gpgme-data-release dh))
(defclass data ()
(c-data) ; The C data object pointer
(:documentation "The GPGME data type."))
(defmethod initialize-instance :after ((data data) &key streamspec
&allow-other-keys)
(let ((c-data (if (listp streamspec)
(apply #'gpgme-data-new streamspec)
(gpgme-data-new streamspec)))
(cleanup t))
(unwind-protect
(progn
(setf (slot-value data 'c-data) c-data)
(finalize data (lambda () (gpgme-data-release c-data)))
(setf cleanup nil))
(if cleanup (gpgme-data-release c-data)))))
(defun translate-gpgme-data-t-to-foreign (value)
;; Allow a pointer to be passed directly for the finalizer to work.
(cond
((null value) (null-pointer))
((pointerp value) value)
(t (slot-value value 'c-data))))
(defmacro with-gpgme-data ((dh streamspec) &body body)
`(let ((,dh (make-instance 'data :streamspec ,streamspec)))
,@body))
`(let ((,dh (if (listp ,streamspec)
(apply 'gpgme-data-new ,streamspec)
(gpgme-data-new ,streamspec))))
(unwind-protect (progn ,@body)
(when (not (null-pointer-p ,dh)) (gpgme-data-release ,dh)))))
(defun gpgme-data-get-encoding (dh)
"Get the encoding associated with the data object DH."
@ -1885,7 +1693,7 @@
(setf cleanup nil))
(if cleanup (gpgme-release c-ctx)))))
(defun translate-gpgme-ctx-t-to-foreign (value)
(defmethod translate-to-foreign (value (type (eql 'gpgme-ctx-t)))
;; Allow a pointer to be passed directly for the finalizer to work.
(if (pointerp value) value (slot-value value 'c-ctx)))
@ -1907,7 +1715,7 @@
(:documentation "Set the protocol of CONTEXT to PROTOCOL."))
;;; FIXME: Adjust translator to reject invalid protocols. Currently,
;;; specifying an invalid protocol throws a "NIL is not 32 signed int"
;;; specifing an invalid protocol throws a "NIL is not 32 signed int"
;;; error. This is suboptimal.
(defmethod (setf protocol) (protocol (ctx context))
(gpgme-set-protocol ctx protocol))
@ -2040,11 +1848,11 @@
(setf (slot-value key 'c-key) c-key)
(finalize key (lambda () (gpgme-key-unref c-key))))
(defun translate-gpgme-key-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-key-t)))
(when *debug* (format t "DEBUG: import key: ~A~%" value))
(make-instance 'key :c-key value))
(defun translate-gpgme-key-t-to-foreign (value)
(defmethod translate-to-foreign (value (type (eql 'gpgme-key-t)))
;; Allow a pointer to be passed directly for the finalizer to work.
(if (pointerp value) value (slot-value value 'c-key)))
@ -2059,12 +1867,12 @@
;;; and zero length value (omit?) and human-readable (convert to string).
;;; FIXME: Turn binary data into sequence or vector or what it should be.
;;; FIXME: Turn the whole thing into a hash?
(defun translate-gpgme-sig-notation-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-sig-notation-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next name value name-len value-len flags bitfield)
value (:struct gpgme-sig-notation))
value gpgme-sig-notation)
(append (list (list
:name name
:value value
@ -2075,12 +1883,12 @@
next)))))
;;; FIXME: Deal nicer with timestamps. bitfield field name?
(defun translate-gpgme-subkey-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-subkey-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next bitfield pubkey-algo length keyid fpr timestamp expires)
value (:struct gpgme-subkey))
value gpgme-subkey)
(append (list (list
:bitfield bitfield
:pubkey-algo pubkey-algo
@ -2091,13 +1899,13 @@
:expires expires))
next)))))
(defun translate-gpgme-key-sig-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-key-sig-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next bitfield pubkey-algo keyid timestamp expires status
uid name email comment sig-class)
value (:struct gpgme-key-sig))
value gpgme-key-sig)
(append (list (list
:bitfield bitfield
:pubkey-algo pubkey-algo
@ -2112,12 +1920,12 @@
:sig-class sig-class))
next)))))
(defun translate-gpgme-user-id-t-from-foreign (value)
(defmethod translate-from-foreign (value (type (eql 'gpgme-user-id-t)))
(cond
((null-pointer-p value) nil)
(t (with-foreign-slots
((next bitfield validity uid name email comment signatures)
value (:struct gpgme-user-id))
value gpgme-user-id)
(append (list (list
:bitfield bitfield
:validity validity
@ -2133,7 +1941,7 @@
(with-foreign-slots
((bitfield protocol issuer-serial issuer-name chain-id
owner-trust subkeys uids keylist-mode)
c-key (:struct gpgme-key))
c-key gpgme-key)
(list
:bitfield bitfield
:protocol protocol

View File

@ -1,29 +0,0 @@
# Makefile.am for GPGMEPP.
# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik
# Software engineering by Intevation GmbH
#
# This file is part of GPGMEPP.
#
# GPGME-CL 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-CL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <https://gnu.org/licenses/>.
# SPDX-License-Identifier: LGPL-2.1-or-later
if RUN_GPG_TESTS
tests = tests
else
tests =
endif
SUBDIRS = src ${tests}
EXTRA_DIST = README

View File

@ -1,101 +0,0 @@
GpgMEpp - C++ bindings/wrapper for GPGME
----------------------------------------
Based on KF5gpgmepp
Overview
--------
GpgMEpp is a C++ wrapper (or C++ bindings) for the GnuPG project's
gpgme (GnuPG Made Easy) library, version 0.4.4 and later.
It is fairly complete, with some minor things still missing (in
particular, the key edit interface).
The design principles of this library are as follows:
1. A value-based interface (most clases are implicitly shared)
2. Callbacks are replaced by C++ interfaces (classes with only
abstract methods).
3. No exceptions are thrown
4. There is (as yet) no explicit support for multi-threaded use
(other than what gpgme itself provides; most notably the
refcounting for implicit sharing is not thread-safe)
5. To avoid binary incompatible interface changes, we make
extensive use of the d-pointer pattern and avoid virtual
methods; any polymorphism present is already provided by gpgme
itself, anyway (see e.g. Data). A notable exception of the
no-virtuals rule is the use of abstract classes to cover
C-callbacks.
6. Use of STL containers for improved memory management and
dealing with lists.
7. Complete abstraction of the C-API so "gpgme.h" should not
be needed in your project using GpgME++.
8. Abstraction of GnuPG's edit-key interface by prepared
Editinteractor classes.
GpgMEpp was originally developed as part of the KDEPIM community.
Usage
-----
The usage pattern of GpgMEpp closely follows GPGMEs core usage
pattern so the documentation for GPGME itself provides a good
way to start.
The context structure in GPGME is mapped to a Context object in
GpgMEpp. Additional convenience code provides Data objects and
a Dataprovider interface that can be used to implement GPGME's
data with any subclass by implementing the right callbacks.
EditInteractor subclasses provide ready to use classes for
common --edit-key tasks. You can implement your own editinteractor
classes by implementing the EditInteractor interface and using
your subclass as an interactor in the edit function.
Example to set the ownertrust of a key:
/* Create an edit interactor */
EditInteractor *ei = new GpgSetOwnerTrustEditInteractor(Key::Ultimate);
/* Obtain a Context */
Context *ctx = Context::createForProtocol(Protocol::OpenPGP);
/* Create an in memory data object */
Data data;
/* Start the edit on some key previously obtained. */
Error e = ctx->edit(key, std::unique_ptr<EditInteractor>(ei), data);
/* Errors provide boolean comparison */
if (!e)
...
/* Delete the context */
delete ctx;
Examples / Tests
----------------
GpgMEpp is tested through the Qt API. You can refer to the
tests in qt/tests for examples of usage or refer to
the actual QGpgME*Job.cpp implementations which rely
on GpgMEpp and should cover most use cases.
Hacking
-------
GpgMEpp follows KDE Coding styles. See:
https://techbase.kde.org/Policies/Frameworks_Coding_Style
for more info.
License
-------
GPGMEpp is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
GPGMEpp 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.

View File

@ -1,99 +0,0 @@
# CMake Config file for GPGMEPP.
# Copyright (C) 2016 Intevation GmbH
#
# This file is part of GPGMEPP.
#
# GPGME-CL 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-CL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU 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
# based on a generated file from cmake.
# Generated by CMake 3.0.2
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
message(FATAL_ERROR "CMake >= 2.6.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget Gpgmepp)
list(APPEND _expectedTargets ${_expectedTarget})
if(NOT TARGET ${_expectedTarget})
list(APPEND _targetsNotDefined ${_expectedTarget})
endif()
if(TARGET ${_expectedTarget})
list(APPEND _targetsDefined ${_expectedTarget})
endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
# Create imported target Gpgmepp
add_library(Gpgmepp SHARED IMPORTED)
set_target_properties(Gpgmepp PROPERTIES
IMPORTED_IMPLIB "@resolved_libdir@/libgpgmepp.dll.a"
INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/gpgme++;@resolved_includedir@"
INTERFACE_LINK_LIBRARIES "pthread;@resolved_libdir@/libgpgme.dll.a;@LIBASSUAN_LIBS@"
IMPORTED_LOCATION "@resolved_bindir@/libgpgmepp-6.dll"
)
list(APPEND _IMPORT_CHECK_TARGETS Gpgmepp )
list(APPEND _IMPORT_CHECK_FILES_FOR_Gpgmepp "@resolved_libdir@/libgpgmepp.dll.a" "@resolved_bindir@/libgpgmepp-6.dll" )
if(CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
endif()
# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
if(NOT EXISTS "${file}" )
message(FATAL_ERROR "The imported target \"${target}\" references the file
\"${file}\"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
\"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
endif()
endforeach()
unset(_IMPORT_CHECK_FILES_FOR_${target})
endforeach()
unset(_IMPORT_CHECK_TARGETS)
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)

View File

@ -1,95 +0,0 @@
# CMake Config file for GPGMEPP.
# Copyright (C) 2016 Intevation GmbH
#
# This file is part of GPGMEPP.
#
# GPGME-CL 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-CL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU 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
# based on a generated file from cmake.
# Generated by CMake 3.0.2
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
message(FATAL_ERROR "CMake >= 2.6.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget Gpgmepp)
list(APPEND _expectedTargets ${_expectedTarget})
if(NOT TARGET ${_expectedTarget})
list(APPEND _targetsNotDefined ${_expectedTarget})
endif()
if(TARGET ${_expectedTarget})
list(APPEND _targetsDefined ${_expectedTarget})
endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
# Create imported target Gpgmepp
add_library(Gpgmepp SHARED IMPORTED)
set_target_properties(Gpgmepp PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/gpgme++;@resolved_includedir@"
INTERFACE_LINK_LIBRARIES "pthread;@resolved_libdir@/libgpgme@libsuffix@;@LIBASSUAN_LIBS@"
IMPORTED_LOCATION "@resolved_libdir@/libgpgmepp@libsuffix@"
)
if(CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
endif()
# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
if(NOT EXISTS "${file}" )
message(FATAL_ERROR "The imported target \"${target}\" references the file
\"${file}\"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
\"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
endif()
endforeach()
unset(_IMPORT_CHECK_FILES_FOR_${target})
endforeach()
unset(_IMPORT_CHECK_TARGETS)
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)

View File

@ -1,31 +0,0 @@
# CMake Version file for GPGMEPP.
# Copyright (C) 2016 Intevation GmbH
#
# This file is part of GPGMEPP.
#
# GPGME-CL 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-CL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU 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
# based on a generated file from cmake.
set(PACKAGE_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@")
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View File

@ -1,130 +0,0 @@
# Makefile.am for GPGMEPP.
# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik
# Software engineering by Intevation GmbH
#
# This file is part of GPGMEPP.
#
# GPGME-CL 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-CL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU 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
EXTRA_DIST = GpgmeppConfig.cmake.in.in GpgmeppConfigVersion.cmake.in \
gpgmepp_version.h.in GpgmeppConfig-w32.cmake.in.in
lib_LTLIBRARIES = libgpgmepp.la
main_sources = \
exception.cpp context.cpp key.cpp trustitem.cpp data.cpp callbacks.cpp \
eventloopinteractor.cpp editinteractor.cpp \
keylistresult.cpp keygenerationresult.cpp importresult.cpp \
decryptionresult.cpp verificationresult.cpp \
signingresult.cpp encryptionresult.cpp \
engineinfo.cpp gpgsetexpirytimeeditinteractor.cpp \
gpgsetownertrusteditinteractor.cpp gpgsignkeyeditinteractor.cpp \
gpgadduserideditinteractor.cpp gpggencardkeyinteractor.cpp \
gpgaddexistingsubkeyeditinteractor.cpp \
gpgrevokekeyeditinteractor.cpp \
defaultassuantransaction.cpp \
scdgetinfoassuantransaction.cpp gpgagentgetinfoassuantransaction.cpp \
statusconsumerassuantransaction.cpp \
vfsmountresult.cpp configuration.cpp tofuinfo.cpp swdbresult.cpp \
util.cpp
gpgmepp_headers = \
configuration.h context.h data.h decryptionresult.h \
defaultassuantransaction.h editinteractor.h encryptionresult.h \
engineinfo.h error.h eventloopinteractor.h exception.h global.h \
gpgadduserideditinteractor.h gpgagentgetinfoassuantransaction.h \
gpgmefw.h gpgsetexpirytimeeditinteractor.h \
gpgsetownertrusteditinteractor.h gpgsignkeyeditinteractor.h \
gpggencardkeyinteractor.h \
gpgaddexistingsubkeyeditinteractor.h \
gpgrevokekeyeditinteractor.h \
importresult.h keygenerationresult.h key.h keylistresult.h \
notation.h result.h scdgetinfoassuantransaction.h signingresult.h \
statusconsumerassuantransaction.h \
trustitem.h verificationresult.h vfsmountresult.h gpgmepp_export.h \
tofuinfo.h swdbresult.h
private_gpgmepp_headers = \
result_p.h context_p.h util.h callbacks.h data_p.h
interface_headers= \
interfaces/assuantransaction.h interfaces/dataprovider.h \
interfaces/passphraseprovider.h interfaces/progressprovider.h \
interfaces/statusconsumer.h
gpgmeppincludedir = $(includedir)/gpgme++
gpgmeppinclude_HEADERS = $(gpgmepp_headers)
nobase_gpgmeppinclude_HEADERS = $(interface_headers)
nodist_gpgmeppinclude_HEADERS = gpgmepp_version.h
libgpgmepp_la_SOURCES = $(main_sources) $(gpgmepp_headers) context_vanilla.cpp \
$(interface_headers) $(private_gpgmepp_headers)
AM_CPPFLAGS = -I$(top_builddir)/src \
@GPGME_CPP_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \
-DBUILDING_GPGMEPP -Wsuggest-override \
-Wzero-as-null-pointer-constant
libgpgmepp_la_LIBADD = ../../../src/libgpgme.la @LIBASSUAN_LIBS@
libgpgmepp_la_LDFLAGS = -no-undefined -version-info \
@LIBGPGMEPP_LT_CURRENT@:@LIBGPGMEPP_LT_REVISION@:@LIBGPGMEPP_LT_AGE@
if HAVE_MACOS_SYSTEM
libsuffix=.dylib
else
libsuffix=.so
endif
copied_headers = $(gpgmepp_headers:%=gpgme++/%) $(interface_headers:%=gpgme++/%)
$(copied_headers): Makefile.am
mkdir -p $(builddir)/gpgme++/interfaces
echo -n "#include \"$(abs_srcdir)" > "$@"
echo -n "$@" | sed "s/gpgme++//" >> "$@"
echo "\"" >> "$@"
if HAVE_W32_SYSTEM
GpgmeppConfig.cmake: GpgmeppConfig-w32.cmake.in
sed -e 's|[@]resolved_bindir@|$(bindir)|g' < "$<" | \
sed -e 's|[@]resolved_libdir@|$(libdir)|g' | \
sed -e 's|[@]resolved_includedir@|$(includedir)|g' > $@
else
GpgmeppConfig.cmake: GpgmeppConfig.cmake.in
sed -e 's|[@]resolved_libdir@|$(libdir)|g' < "$<" | \
sed -e 's|[@]libsuffix@|$(libsuffix)|g' | \
sed -e 's|[@]resolved_includedir@|$(includedir)|g' > $@
endif
install-cmake-files: GpgmeppConfig.cmake GpgmeppConfigVersion.cmake
-$(INSTALL) -d $(DESTDIR)$(libdir)/cmake/Gpgmepp
$(INSTALL) -m 644 GpgmeppConfig.cmake \
$(DESTDIR)$(libdir)/cmake/Gpgmepp/GpgmeppConfig.cmake
$(INSTALL) -m 644 GpgmeppConfigVersion.cmake \
$(DESTDIR)$(libdir)/cmake/Gpgmepp/GpgmeppConfigVersion.cmake
uninstall-cmake-files:
-rm $(DESTDIR)$(libdir)/cmake/Gpgmepp/GpgmeppConfigVersion.cmake
-rm $(DESTDIR)$(libdir)/cmake/Gpgmepp/GpgmeppConfig.cmake
-rmdir $(DESTDIR)$(libdir)/cmake/Gpgmepp/
install-data-local: install-cmake-files
uninstall-local: uninstall-cmake-files
BUILT_SOURCES = $(copied_headers)
CLEANFILES = GpgmeppConfig.cmake GpgmeppConfigVersion.cmake \
gpgmepp_version.h GpgmeppConfig.cmake.in \
$(copied_headers)

View File

@ -1,155 +0,0 @@
/*
callbacks.cpp - callback targets for internal use:
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "callbacks.h"
#include "util.h"
#include <interfaces/progressprovider.h>
#include <interfaces/passphraseprovider.h>
#include <interfaces/dataprovider.h>
#include <error.h>
#include <gpgme.h>
#include <gpg-error.h>
#include <cassert>
#include <cerrno>
#include <cstring>
#include <unistd.h>
#include <stdlib.h>
static inline gpgme_error_t make_err_from_syserror()
{
return gpgme_error_from_syserror();
}
using GpgME::ProgressProvider;
using GpgME::PassphraseProvider;
using GpgME::DataProvider;
void progress_callback(void *opaque, const char *what,
int type, int current, int total)
{
ProgressProvider *provider = static_cast<ProgressProvider *>(opaque);
if (provider) {
provider->showProgress(what, type, current, total);
}
}
/* To avoid that a compiler optimizes certain memset calls away, these
macros may be used instead. */
#define wipememory2(_ptr,_set,_len) do { \
volatile char *_vptr=(volatile char *)(_ptr); \
size_t _vlen=(_len); \
while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
} while(0)
#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint, const char *desc,
int prev_was_bad, int fd)
{
PassphraseProvider *provider = static_cast<PassphraseProvider *>(opaque);
bool canceled = false;
gpgme_error_t err = GPG_ERR_NO_ERROR;
char *passphrase = provider ? provider->getPassphrase(uid_hint, desc, prev_was_bad, canceled) : nullptr ;
if (canceled) {
err = make_error(GPG_ERR_CANCELED);
} else {
if (passphrase && *passphrase) {
size_t passphrase_length = std::strlen(passphrase);
size_t written = 0;
do {
ssize_t now_written = gpgme_io_write(fd, passphrase + written, passphrase_length - written);
if (now_written < 0) {
err = make_err_from_syserror();
break;
}
written += now_written;
} while (written < passphrase_length);
}
}
if (passphrase && *passphrase) {
wipememory(passphrase, std::strlen(passphrase));
}
free(passphrase);
gpgme_io_write(fd, "\n", 1);
return err;
}
static gpgme_ssize_t
data_read_callback(void *opaque, void *buf, size_t buflen)
{
DataProvider *provider = static_cast<DataProvider *>(opaque);
if (!provider) {
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
return -1;
}
return (gpgme_ssize_t)provider->read(buf, buflen);
}
static gpgme_ssize_t
data_write_callback(void *opaque, const void *buf, size_t buflen)
{
DataProvider *provider = static_cast<DataProvider *>(opaque);
if (!provider) {
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
return -1;
}
return (gpgme_ssize_t)provider->write(buf, buflen);
}
static gpgme_off_t
data_seek_callback(void *opaque, gpgme_off_t offset, int whence)
{
DataProvider *provider = static_cast<DataProvider *>(opaque);
if (!provider) {
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
return -1;
}
if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END) {
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
return -1;
}
return provider->seek((off_t)offset, whence);
}
static void data_release_callback(void *opaque)
{
DataProvider *provider = static_cast<DataProvider *>(opaque);
if (provider) {
provider->release();
}
}
const gpgme_data_cbs GpgME::data_provider_callbacks = {
&data_read_callback,
&data_write_callback,
&data_seek_callback,
&data_release_callback
};

View File

@ -1,47 +0,0 @@
/*
callbacks.h - callback targets for internal use:
Copyright (C) 2003 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation GmbH
This file is part of GPGME++.
This is an internal header file, subject to change without
notice. DO NOT USE.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_CALLBACKS_H__
#define __GPGMEPP_CALLBACKS_H__
#include <gpgme.h>
extern "C" {
void progress_callback(void *opaque, const char *what,
int type, int current, int total);
gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint,
const char *desc, int prev_was_bad, int fd);
}
namespace GpgME
{
extern const gpgme_data_cbs data_provider_callbacks;
extern const gpgme_edit_cb_t edit_interactor_callback;
}
#endif // __GPGME_CALLBACKS_H__

View File

@ -1,788 +0,0 @@
/*
configuration.cpp - wraps gpgme configuration components
Copyright (C) 2010 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "configuration.h"
#include "error.h"
#include "util.h"
#include <gpgme.h>
#include <iterator>
#include <algorithm>
#include <ostream>
#include <cstring>
#include <assert.h>
using namespace GpgME;
using namespace GpgME::Configuration;
typedef std::shared_ptr< std::remove_pointer<gpgme_conf_opt_t>::type > shared_gpgme_conf_opt_t;
typedef std::weak_ptr< std::remove_pointer<gpgme_conf_opt_t>::type > weak_gpgme_conf_opt_t;
typedef std::shared_ptr< std::remove_pointer<gpgme_conf_arg_t>::type > shared_gpgme_conf_arg_t;
typedef std::weak_ptr< std::remove_pointer<gpgme_conf_arg_t>::type > weak_gpgme_conf_arg_t;
typedef std::shared_ptr< std::remove_pointer<gpgme_ctx_t>::type > shared_gpgme_ctx_t;
typedef std::weak_ptr< std::remove_pointer<gpgme_ctx_t>::type > weak_gpgme_ctx_t;
namespace
{
struct nodelete {
template <typename T> void operator()(T *) {}
};
}
// static
std::vector<Component> Component::load(Error &returnedError)
{
//
// 1. get a context:
//
gpgme_ctx_t ctx_native = nullptr;
if (const gpgme_error_t err = gpgme_new(&ctx_native)) {
returnedError = Error(err);
return std::vector<Component>();
}
const shared_gpgme_ctx_t ctx(ctx_native, &gpgme_release);
//
// 2. load the config:
//
gpgme_conf_comp_t conf_list_native = nullptr;
if (const gpgme_error_t err = gpgme_op_conf_load(ctx_native, &conf_list_native)) {
returnedError = Error(err);
return std::vector<Component>();
}
shared_gpgme_conf_comp_t head(conf_list_native, &gpgme_conf_release);
//
// 3. convert to vector<Component>:
//
std::vector<Component> result;
while (head) {
// secure 'head->next' (if any) against memleaks:
shared_gpgme_conf_comp_t next;
if (head->next) {
next.reset(head->next, &gpgme_conf_release);
}
// now prevent double-free of next.get() and following:
head->next = nullptr;
// now add a new Component to 'result' (may throw):
result.resize(result.size() + 1);
result.back().comp.swap(head); // .comp = std::move( head );
head.swap(next); // head = std::move( next );
}
return result;
}
Error Component::save() const
{
if (isNull()) {
return Error(make_error(GPG_ERR_INV_ARG));
}
//
// 1. get a context:
//
gpgme_ctx_t ctx_native = nullptr;
if (const gpgme_error_t err = gpgme_new(&ctx_native)) {
return Error(err);
}
const shared_gpgme_ctx_t ctx(ctx_native, &gpgme_release);
//
// 2. save the config:
//
return Error(gpgme_op_conf_save(ctx.get(), comp.get()));
}
const char *Component::name() const
{
return comp ? comp->name : nullptr;
}
const char *Component::description() const
{
return comp ? comp->description : nullptr ;
}
const char *Component::programName() const
{
return comp ? comp->program_name : nullptr ;
}
Option Component::option(unsigned int idx) const
{
gpgme_conf_opt_t opt = nullptr;
if (comp) {
opt = comp->options;
}
while (opt && idx) {
opt = opt->next;
--idx;
}
if (opt) {
return Option(comp, opt);
}
return Option();
}
Option Component::option(const char *name) const
{
gpgme_conf_opt_t opt = nullptr;
if (comp) {
opt = comp->options;
}
using namespace std; // for strcmp
while (opt && strcmp(name, opt->name) != 0) {
opt = opt->next;
}
if (opt) {
return Option(comp, opt);
}
return Option();
}
unsigned int Component::numOptions() const
{
unsigned int result = 0;
for (gpgme_conf_opt_t opt = comp ? comp->options : nullptr ; opt ; opt = opt->next) {
++result;
}
return result;
}
std::vector<Option> Component::options() const
{
std::vector<Option> result;
for (gpgme_conf_opt_t opt = comp ? comp->options : nullptr ; opt ; opt = opt->next) {
result.push_back(Option(comp, opt));
}
return result;
}
static gpgme_conf_arg_t mygpgme_conf_arg_copy(gpgme_conf_arg_t other, gpgme_conf_type_t type)
{
gpgme_conf_arg_t result = nullptr, last = nullptr;
for (gpgme_conf_arg_t a = other ; a ; a = a->next) {
gpgme_conf_arg_t arg = nullptr;
const gpgme_error_t err
= gpgme_conf_arg_new(&arg, type,
a->no_arg ? nullptr :
type == GPGME_CONF_STRING ? a->value.string :
/* else */ static_cast<void *>(&a->value));
if (err) {
gpgme_conf_arg_release(result, type);
return nullptr;
}
assert(arg);
if (result) {
last->next = arg;
} else {
result = arg;
}
last = arg;
}
return result;
}
Component Option::parent() const
{
return Component(comp.lock());
}
unsigned int Option::flags() const
{
return isNull() ? 0 : opt->flags;
}
Level Option::level() const
{
return isNull() ? Internal : static_cast<Level>(opt->level) ;
}
const char *Option::name() const
{
return isNull() ? nullptr : opt->name ;
}
const char *Option::description() const
{
return isNull() ? nullptr : opt->description ;
}
const char *Option::argumentName() const
{
return isNull() ? nullptr : opt->argname ;
}
Type Option::type() const
{
return isNull() ? NoType : static_cast<Type>(opt->type) ;
}
Type Option::alternateType() const
{
return isNull() ? NoType : static_cast<Type>(opt->alt_type) ;
}
Argument Option::defaultValue() const
{
if (isNull()) {
return Argument();
} else {
return Argument(comp.lock(), opt, opt->default_value, false);
}
}
const char *Option::defaultDescription() const
{
return isNull() ? nullptr : opt->default_description ;
}
Argument Option::noArgumentValue() const
{
if (isNull()) {
return Argument();
} else {
return Argument(comp.lock(), opt, opt->no_arg_value, false);
}
}
const char *Option::noArgumentDescription() const
{
return isNull() ? nullptr : opt->no_arg_description ;
}
Argument Option::activeValue() const
{
if (isNull()) {
return Argument();
} else {
return Argument(comp.lock(), opt, opt->value, false);
}
}
Argument Option::currentValue() const
{
if (isNull()) {
return Argument();
}
const gpgme_conf_arg_t arg =
opt->change_value ? opt->new_value ? opt->new_value : opt->default_value :
opt->value ? opt->value :
/* else */ opt->default_value ;
return Argument(comp.lock(), opt, arg, false);
}
Argument Option::newValue() const
{
if (isNull()) {
return Argument();
} else {
return Argument(comp.lock(), opt, opt->new_value, false);
}
}
bool Option::set() const
{
if (isNull()) {
return false;
} else if (opt->change_value) {
return opt->new_value;
} else {
return opt->value;
}
}
bool Option::dirty() const
{
return !isNull() && opt->change_value ;
}
Error Option::setNewValue(const Argument &argument)
{
if (isNull()) {
return Error(make_error(GPG_ERR_INV_ARG));
} else if (argument.isNull()) {
return resetToDefaultValue();
} else if (const gpgme_conf_arg_t arg = mygpgme_conf_arg_copy(argument.arg, opt->alt_type)) {
return Error(gpgme_conf_opt_change(opt, 0, arg));
} else {
return Error(make_error(GPG_ERR_ENOMEM));
}
}
Error Option::resetToActiveValue()
{
if (isNull()) {
return Error(make_error(GPG_ERR_INV_ARG));
} else {
return Error(gpgme_conf_opt_change(opt, 1, nullptr));
}
}
Error Option::resetToDefaultValue()
{
if (isNull()) {
return Error(make_error(GPG_ERR_INV_ARG));
} else {
return Error(gpgme_conf_opt_change(opt, 0, nullptr));
}
}
static gpgme_conf_arg_t make_argument(gpgme_conf_type_t type, const void *value)
{
gpgme_conf_arg_t arg = nullptr;
if (const gpgme_error_t err = gpgme_conf_arg_new(&arg, type, value)) {
return nullptr;
} else {
return arg;
}
}
Argument Option::createNoneArgument(bool set) const
{
if (isNull() || alternateType() != NoType) {
return Argument();
} else {
if (set) {
return createNoneListArgument(1);
}
}
return Argument();
}
Argument Option::createStringArgument(const char *value) const
{
if (isNull() || alternateType() != StringType) {
return Argument();
} else {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true);
}
}
Argument Option::createStringArgument(const std::string &value) const
{
if (isNull() || alternateType() != StringType) {
return Argument();
} else {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value.c_str()), true);
}
}
Argument Option::createIntArgument(int value) const
{
if (isNull() || alternateType() != IntegerType) {
return Argument();
} else {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_INT32, &value), true);
}
}
Argument Option::createUIntArgument(unsigned int value) const
{
if (isNull() || alternateType() != UnsignedIntegerType) {
return Argument();
} else {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_UINT32, &value), true);
}
}
namespace
{
const void *to_void_star(const char *s)
{
return s;
}
const void *to_void_star(const std::string &s)
{
return s.c_str();
}
const void *to_void_star(const int &i)
{
return &i; // const-&: sic!
}
const void *to_void_star(const unsigned int &i)
{
return &i; // const-&: sic!
}
template <typename T>
gpgme_conf_arg_t make_argument(gpgme_conf_type_t type, const std::vector<T> &value)
{
gpgme_conf_arg_t result = nullptr;
gpgme_conf_arg_t last = nullptr;
for (typename std::vector<T>::const_iterator it = value.begin(), end = value.end() ; it != end ; ++it) {
if (gpgme_conf_arg_t arg = make_argument(type, to_void_star(*it))) {
if (last) {
last = last->next = arg;
} else {
result = last = arg;
}
}
}
return result;
}
}
Argument Option::createNoneListArgument(unsigned int value) const
{
if (value) {
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_NONE, &value), true);
}
return Argument();
}
Argument Option::createStringListArgument(const std::vector<const char *> &value) const
{
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true);
}
Argument Option::createStringListArgument(const std::vector<std::string> &value) const
{
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true);
}
Argument Option::createIntListArgument(const std::vector<int> &value) const
{
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_INT32, value), true);
}
Argument Option::createUIntListArgument(const std::vector<unsigned int> &value) const
{
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_UINT32, value), true);
}
Argument::Argument(const shared_gpgme_conf_comp_t &comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg, bool owns)
: comp(comp),
opt(opt),
arg(owns ? arg : mygpgme_conf_arg_copy(arg, opt ? opt->alt_type : GPGME_CONF_NONE))
{
}
#if 0
Argument::Argument(const shared_gpgme_conf_comp_t &comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg)
: comp(comp),
opt(opt),
arg(mygpgme_conf_arg_copy(arg, opt ? opt->alt_type : GPGME_CONF_NONE))
{
}
#endif
Argument::Argument(const Argument &other)
: comp(other.comp),
opt(other.opt),
arg(mygpgme_conf_arg_copy(other.arg, opt ? opt->alt_type : GPGME_CONF_NONE))
{
}
Argument::~Argument()
{
gpgme_conf_arg_release(arg, opt ? opt->alt_type : GPGME_CONF_NONE);
}
Option Argument::parent() const
{
return Option(comp.lock(), opt);
}
bool Argument::boolValue() const
{
return numberOfTimesSet();
}
unsigned int Argument::numElements() const
{
if (isNull()) {
return 0;
}
unsigned int result = 0;
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
++result;
}
return result;
}
const char *Argument::stringValue(unsigned int idx) const
{
if (isNull() || opt->alt_type != GPGME_CONF_STRING) {
return nullptr;
}
gpgme_conf_arg_t a = arg;
while (a && idx) {
a = a->next;
--idx;
}
return a ? a->value.string : nullptr ;
}
int Argument::intValue(unsigned int idx) const
{
if (isNull() || opt->alt_type != GPGME_CONF_INT32) {
return 0;
}
gpgme_conf_arg_t a = arg;
while (a && idx) {
a = a->next;
--idx;
}
return a ? a->value.int32 : 0 ;
}
unsigned int Argument::uintValue(unsigned int idx) const
{
if (isNull() || opt->alt_type != GPGME_CONF_UINT32) {
return 0;
}
gpgme_conf_arg_t a = arg;
while (a && idx) {
a = a->next;
--idx;
}
return a ? a->value.uint32 : 0 ;
}
unsigned int Argument::numberOfTimesSet() const
{
if (isNull() || opt->alt_type != GPGME_CONF_NONE) {
return 0;
}
return arg->value.count;
}
std::vector<const char *> Argument::stringValues() const
{
if (isNull() || opt->alt_type != GPGME_CONF_STRING) {
return std::vector<const char *>();
}
std::vector<const char *> result;
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
result.push_back(a->value.string);
}
return result;
}
std::vector<int> Argument::intValues() const
{
if (isNull() || opt->alt_type != GPGME_CONF_INT32) {
return std::vector<int>();
}
std::vector<int> result;
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
result.push_back(a->value.int32);
}
return result;
}
std::vector<unsigned int> Argument::uintValues() const
{
if (isNull() || opt->alt_type != GPGME_CONF_UINT32) {
return std::vector<unsigned int>();
}
std::vector<unsigned int> result;
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
result.push_back(a->value.uint32);
}
return result;
}
std::ostream &Configuration::operator<<(std::ostream &os, Level level)
{
switch (level) {
case Basic: return os << "Basic";
case Advanced: return os << "Advanced";
case Expert: return os << "Expert";
case Invisible: return os << "Invisible";
case Internal: return os << "Internal";
case NumLevels: ;
}
return os << "<unknown>";
}
std::ostream &Configuration::operator<<(std::ostream &os, Type type)
{
switch (type) {
case NoType: return os << "None";
case StringType: return os << "String";
case IntegerType: return os << "Integer";
case UnsignedIntegerType: return os << "UnsignedInteger";
case FilenameType: return os << "Filename";
case LdapServerType: return os << "LdapServer";
case KeyFingerprintType: return os << "KeyFingerprint";
case PublicKeyType: return os << "PublicKey";
case SecretKeyType: return os << "SecretKey";
case AliasListType: return os << "AliasList";
case MaxType: ;
}
return os << "<unknown>";
}
std::ostream &Configuration::operator<<(std::ostream &os, Flag f)
{
unsigned int flags = f;
std::vector<const char *> s;
if (flags & Group) {
s.push_back("Group");
}
if (flags & Optional) {
s.push_back("Optional");
}
if (flags & List) {
s.push_back("List");
}
if (flags & Runtime) {
s.push_back("Runtime");
}
if (flags & Default) {
s.push_back("Default");
}
if (flags & DefaultDescription) {
s.push_back("DefaultDescription");
}
if (flags & NoArgumentDescription) {
s.push_back("NoArgumentDescription");
}
if (flags & NoChange) {
s.push_back("NoChange");
}
flags &= ~(Group | Optional | List | Runtime | Default | DefaultDescription | NoArgumentDescription | NoChange);
if (flags) {
s.push_back("other flags(");
}
std::copy(s.begin(), s.end(),
std::ostream_iterator<const char *>(os, "|"));
if (flags) {
os << flags << ')';
}
return os;
}
std::ostream &Configuration::operator<<(std::ostream &os, const Component &c)
{
os << "Component["
<< "\n name : " << protect(c.name())
<< "\n description: " << protect(c.description())
<< "\n programName: " << protect(c.programName())
<< "\n options : \n";
const std::vector<Option> options = c.options();
std::copy(options.begin(), options.end(),
std::ostream_iterator<Option>(os, "\n"));
os << "\n]";
return os;
}
std::ostream &Configuration::operator<<(std::ostream &os, const Option &o)
{
return os << "Option["
<< "\n name: : " << protect(o.name())
<< "\n description : " << protect(o.description())
<< "\n argName : " << protect(o.argumentName())
<< "\n flags : " << static_cast<Flag>(o.flags())
<< "\n level : " << o.level()
<< "\n type : " << o.type()
<< "\n alt_type : " << o.alternateType()
<< "\n default_val : " << o.defaultValue()
<< "\n default_desc: " << protect(o.defaultDescription())
<< "\n no_arg_value: " << o.noArgumentValue()
<< "\n no_arg_desc : " << protect(o.noArgumentDescription())
<< "\n active_value: " << o.activeValue()
<< "\n new_value : " << o.newValue()
<< "\n --> cur_val : " << o.currentValue()
<< "\n set : " << o.set()
<< "\n dirty : " << o.dirty()
<< "\n]"
;
}
std::ostream &Configuration::operator<<(std::ostream &os, const Argument &a)
{
const Option o = a.parent();
const bool list = o.flags() & List;
os << "Argument[";
if (a) {
switch (o.alternateType()) {
case NoType:
if (list) {
os << a.numberOfTimesSet() << 'x';
} else {
os << a.boolValue();
}
break;
default:
case StringType:
if (list) {
const std::vector<const char *> v = a.stringValues();
os << v.size() << ':';
// can't use std::copy + ostream_iterator here, since we need the protect() call
bool first = true;
std::for_each(v.begin(), v.end(), [&first, &os](const char *s) {
if (first) {
first = false;
} else {
os << ',';
}
os << protect(s);
});
} else {
os << protect(a.stringValue());
}
break;
case IntegerType:
if (list) {
const std::vector<int> v = a.intValues();
os << v.size() << ':';
std::copy(v.begin(), v.end(),
std::ostream_iterator<int>(os, ","));
} else {
os << a.intValue();
}
break;
case UnsignedIntegerType:
if (list) {
const std::vector<unsigned int> v = a.uintValues();
os << v.size() << ':';
std::copy(v.begin(), v.end(),
std::ostream_iterator<unsigned int>(os, ","));
} else {
os << a.intValue();
}
break;
}
}
return os << ']';
}

View File

@ -1,292 +0,0 @@
/*
configuration.h - wraps gpgme configuration components
Copyright (C) 2010 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// -*- c++ -*-
#ifndef __GPGMEPP_CONFIGURATION_H__
#define __GPGMEPP_CONFIGURATION_H__
#include "global.h"
#include "gpgmefw.h"
#include <iosfwd>
#include <vector>
#include <string>
#include <algorithm>
#include <memory>
namespace GpgME
{
namespace Configuration
{
typedef std::shared_ptr< std::remove_pointer<gpgme_conf_comp_t>::type > shared_gpgme_conf_comp_t;
typedef std::weak_ptr< std::remove_pointer<gpgme_conf_comp_t>::type > weak_gpgme_conf_comp_t;
class Argument;
class Option;
class Component;
enum Level {
Basic,
Advanced,
Expert,
Invisible,
Internal,
NumLevels
};
enum Type {
NoType,
StringType,
IntegerType,
UnsignedIntegerType,
FilenameType = 32,
LdapServerType,
KeyFingerprintType,
PublicKeyType,
SecretKeyType,
AliasListType,
MaxType
};
enum Flag {
Group = (1 << 0),
Optional = (1 << 1),
List = (1 << 2),
Runtime = (1 << 3),
Default = (1 << 4),
DefaultDescription = (1 << 5),
NoArgumentDescription = (1 << 6),
NoChange = (1 << 7),
LastFlag = NoChange
};
//
// class Component
//
class GPGMEPP_EXPORT Component
{
public:
Component() : comp() {}
explicit Component(const shared_gpgme_conf_comp_t &gpgme_comp)
: comp(gpgme_comp) {}
Component(const Component &other) = default;
const Component &operator=(const Component &other)
{
if (this != &other) {
Component(other).swap(*this);
}
return *this;
}
void swap(Component &other)
{
using std::swap;
swap(this->comp, other.comp);
}
bool isNull() const
{
return !comp;
}
static std::vector<Component> load(Error &err);
Error save() const;
const char *name() const;
const char *description() const;
const char *programName() const;
Option option(unsigned int index) const;
Option option(const char *name) const;
unsigned int numOptions() const;
std::vector<Option> options() const;
GPGMEPP_MAKE_SAFE_BOOL_OPERATOR(!isNull())
private:
shared_gpgme_conf_comp_t comp;
};
//
// class Option
//
class GPGMEPP_EXPORT Option
{
public:
Option() : comp(), opt(nullptr) {}
Option(const shared_gpgme_conf_comp_t &gpgme_comp, gpgme_conf_opt_t gpgme_opt)
: comp(gpgme_comp), opt(gpgme_opt) {}
Option(const Option &other) = default;
const Option &operator=(const Option &other)
{
if (this != &other) {
Option(other).swap(*this);
}
return *this;
}
void swap(Option &other)
{
using std::swap;
swap(this->comp, other.comp);
swap(this->opt, other.opt);
}
bool isNull() const
{
return comp.expired() || !opt;
}
Component parent() const;
unsigned int flags() const;
Level level() const;
const char *name() const;
const char *description() const;
const char *argumentName() const;
Type type() const;
Type alternateType() const;
Argument defaultValue() const;
const char *defaultDescription() const;
Argument noArgumentValue() const;
const char *noArgumentDescription() const;
/*! The value that is in the config file (or null, if it's not set). */
Argument activeValue() const;
/*! The value that is in this object, i.e. either activeValue(), newValue(), or defaultValue() */
Argument currentValue() const;
Argument newValue() const;
bool set() const;
bool dirty() const;
Error setNewValue(const Argument &argument);
Error resetToDefaultValue();
Error resetToActiveValue();
Argument createNoneArgument(bool set) const;
Argument createStringArgument(const char *value) const;
Argument createStringArgument(const std::string &value) const;
Argument createIntArgument(int value) const;
Argument createUIntArgument(unsigned int value) const;
Argument createNoneListArgument(unsigned int count) const;
Argument createStringListArgument(const std::vector<const char *> &value) const;
Argument createStringListArgument(const std::vector<std::string> &value) const;
Argument createIntListArgument(const std::vector<int> &values) const;
Argument createUIntListArgument(const std::vector<unsigned int> &values) const;
GPGMEPP_MAKE_SAFE_BOOL_OPERATOR(!isNull())
private:
weak_gpgme_conf_comp_t comp;
gpgme_conf_opt_t opt;
};
//
// class Argument
//
class GPGMEPP_EXPORT Argument
{
friend class ::GpgME::Configuration::Option;
Argument(const shared_gpgme_conf_comp_t &comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg, bool owns);
public:
Argument() : comp(), opt(nullptr), arg(nullptr) {}
//Argument( const shared_gpgme_conf_comp_t & comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg );
Argument(const Argument &other);
~Argument();
const Argument &operator=(const Argument &other)
{
if (this != &other) {
Argument(other).swap(*this);
}
return *this;
}
void swap(Argument &other)
{
using std::swap;
swap(this->comp, other.comp);
swap(this->opt, other.opt);
swap(this->arg, other.arg);
}
bool isNull() const
{
return comp.expired() || !opt || !arg;
}
Option parent() const;
unsigned int numElements() const;
bool boolValue() const;
const char *stringValue(unsigned int index = 0) const;
int intValue(unsigned int index = 0) const;
unsigned int uintValue(unsigned int index = 0) const;
unsigned int numberOfTimesSet() const;
std::vector<const char *> stringValues() const;
std::vector<int> intValues() const;
std::vector<unsigned int> uintValues() const;
GPGMEPP_MAKE_SAFE_BOOL_OPERATOR(!isNull())
private:
weak_gpgme_conf_comp_t comp;
gpgme_conf_opt_t opt;
gpgme_conf_arg_t arg;
};
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Level level);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Type type);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Flag flag);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Component &component);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Option &option);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Argument &argument);
} // namespace Configuration
} // namespace GpgME
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Configuration::Component)
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Configuration::Option)
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Configuration::Argument)
#endif // __GPGMEPP_CONFIGURATION_H__

File diff suppressed because it is too large Load Diff

View File

@ -1,564 +0,0 @@
/*
context.h - wraps a gpgme key context
Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// -*- c++ -*-
#ifndef __GPGMEPP_CONTEXT_H__
#define __GPGMEPP_CONTEXT_H__
#include "global.h"
#include "error.h"
#include "key.h"
#include "verificationresult.h" // for Signature::Notation
#include <memory>
#include <string>
#include <vector>
#include <utility>
#include <iosfwd>
namespace GpgME
{
class Data;
class TrustItem;
class ProgressProvider;
class PassphraseProvider;
class EventLoopInteractor;
class EditInteractor;
class AssuanTransaction;
class KeyListResult;
class KeyGenerationResult;
class ImportResult;
class DecryptionResult;
class VerificationResult;
class SigningResult;
class EncryptionResult;
class VfsMountResult;
class EngineInfo;
class GPGMEPP_EXPORT Context
{
explicit Context(gpgme_ctx_t);
public:
//using GpgME::Protocol;
/// RAII-style class for saving/restoring the key list mode.
class GPGMEPP_EXPORT KeyListModeSaver
{
public:
explicit KeyListModeSaver(Context *ctx);
~KeyListModeSaver();
private:
Context *mCtx;
unsigned int mKeyListMode;
};
//
// Creation and destruction:
//
static Context *createForProtocol(Protocol proto);
/** Same as above but returning a unique ptr. */
static std::unique_ptr<Context> create(Protocol proto);
static std::unique_ptr<Context> createForEngine(Engine engine, Error *err = nullptr);
virtual ~Context();
//
// Context Attributes
//
Protocol protocol() const;
void setArmor(bool useArmor);
bool armor() const;
void setTextMode(bool useTextMode);
bool textMode() const;
void setOffline(bool useOfflineMode);
bool offline() const;
const char *getFlag(const char *name) const;
Error setFlag(const char *name, const char *value);
enum CertificateInclusion {
DefaultCertificates = -256,
AllCertificatesExceptRoot = -2,
AllCertificates = -1,
NoCertificates = 0,
OnlySenderCertificate = 1
};
void setIncludeCertificates(int which);
int includeCertificates() const;
//using GpgME::KeyListMode;
void setKeyListMode(unsigned int keyListMode);
void addKeyListMode(unsigned int keyListMode);
unsigned int keyListMode() const;
/** Set the passphrase provider
*
* To avoid problems where a class using a context registers
* itself as the provider the Context does not take ownership
* of the provider and the caller must ensure that the provider
* is deleted if it is no longer needed.
*/
void setPassphraseProvider(PassphraseProvider *provider);
PassphraseProvider *passphraseProvider() const;
/** Set the progress provider
*
* To avoid problems where a class using a context registers
* itself as the provider the Context does not take ownership
* of the provider and the caller must ensure that the provider
* is deleted if it is no longer needed.
*/
void setProgressProvider(ProgressProvider *provider);
ProgressProvider *progressProvider() const;
void setManagedByEventLoopInteractor(bool managed);
bool managedByEventLoopInteractor() const;
GpgME::Error setLocale(int category, const char *value);
EngineInfo engineInfo() const;
GpgME::Error setEngineFileName(const char *filename);
GpgME::Error setEngineHomeDirectory(const char *filename);
enum PinentryMode{
PinentryDefault = 0,
PinentryAsk = 1,
PinentryCancel = 2,
PinentryError = 3,
PinentryLoopback = 4
};
GpgME::Error setPinentryMode(PinentryMode which);
PinentryMode pinentryMode() const;
private:
friend class ::GpgME::EventLoopInteractor;
void installIOCallbacks(gpgme_io_cbs *iocbs);
void uninstallIOCallbacks();
public:
//
//
// Key Management
//
//
//
// Key Listing
//
GpgME::Error startKeyListing(const char *pattern = nullptr, bool secretOnly = false);
GpgME::Error startKeyListing(const char *patterns[], bool secretOnly = false);
Key nextKey(GpgME::Error &e);
KeyListResult endKeyListing();
KeyListResult keyListResult() const;
Key key(const char *fingerprint, GpgME::Error &e, bool secret = false);
//
// Key Generation
//
KeyGenerationResult generateKey(const char *parameters, Data &pubKey);
GpgME::Error startKeyGeneration(const char *parameters, Data &pubkey);
KeyGenerationResult keyGenerationResult() const;
//
// Key Export
//
enum ExportMode {
ExportDefault = 0,
ExportExtern = 2,
ExportMinimal = 4,
ExportSecret = 16,
ExportRaw = 32,
ExportPKCS12 = 64,
ExportNoUID = 128, // obsolete; has no effect
ExportSSH = 256,
ExportSecretSubkey = 512,
};
GpgME::Error exportPublicKeys(const char *pattern, Data &keyData);
GpgME::Error exportPublicKeys(const char *pattern, Data &keyData, unsigned int mode);
GpgME::Error exportPublicKeys(const char *pattern[], Data &keyData);
GpgME::Error exportPublicKeys(const char *pattern[], Data &keyData, unsigned int mode);
GpgME::Error startPublicKeyExport(const char *pattern, Data &keyData);
GpgME::Error startPublicKeyExport(const char *pattern, Data &keyData, unsigned int mode);
GpgME::Error startPublicKeyExport(const char *pattern[], Data &keyData);
GpgME::Error startPublicKeyExport(const char *pattern[], Data &keyData, unsigned int mode);
GpgME::Error exportSecretKeys(const char *pattern, Data &keyData, unsigned int mode = ExportSecret);
GpgME::Error exportSecretKeys(const char *pattern[], Data &keyData, unsigned int mode = ExportSecret);
GpgME::Error startSecretKeyExport(const char *pattern, Data &keyData, unsigned int mode = ExportSecret);
GpgME::Error startSecretKeyExport(const char *pattern[], Data &keyData, unsigned int mode = ExportSecret);
GpgME::Error exportSecretSubkeys(const char *pattern, Data &keyData, unsigned int mode = ExportSecretSubkey);
GpgME::Error exportSecretSubkeys(const char *pattern[], Data &keyData, unsigned int mode = ExportSecretSubkey);
GpgME::Error startSecretSubkeyExport(const char *pattern, Data &keyData, unsigned int mode = ExportSecretSubkey);
GpgME::Error startSecretSubkeyExport(const char *pattern[], Data &keyData, unsigned int mode = ExportSecretSubkey);
// generic export functions; prefer using the specific public/secret key export functions
GpgME::Error exportKeys(const char *pattern, Data &keyData, unsigned int mode = ExportDefault);
GpgME::Error exportKeys(const char *pattern[], Data &keyData, unsigned int mode = ExportDefault);
GpgME::Error startKeyExport(const char *pattern, Data &keyData, unsigned int mode = ExportDefault);
GpgME::Error startKeyExport(const char *pattern[], Data &keyData, unsigned int mode = ExportDefault);
//
// Key Import
//
ImportResult importKeys(const Data &data);
ImportResult importKeys(const std::vector<Key> &keys);
ImportResult importKeys(const std::vector<std::string> &keyIds);
GpgME::Error startKeyImport(const Data &data);
GpgME::Error startKeyImport(const std::vector<Key> &keys);
GpgME::Error startKeyImport(const std::vector<std::string> &keyIds);
ImportResult importResult() const;
//
// Key Deletion
//
GpgME::Error deleteKey(const Key &key, bool allowSecretKeyDeletion = false);
GpgME::Error startKeyDeletion(const Key &key, bool allowSecretKeyDeletion = false);
//
// Passphrase changing
//
GpgME::Error passwd(const Key &key);
GpgME::Error startPasswd(const Key &key);
//
// Key Editing
//
GpgME::Error edit(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
GpgME::Error startEditing(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
//
// Modern Interface actions. Require 2.1.x
//
Error startCreateKey (const char *userid,
const char *algo,
unsigned long reserved,
unsigned long expires,
const Key &certkey,
unsigned int flags);
Error createKey (const char *userid,
const char *algo,
unsigned long reserved,
unsigned long expires,
const Key &certkey,
unsigned int flags);
// Same as create key but returning a result
GpgME::KeyGenerationResult createKeyEx (const char *userid,
const char *algo,
unsigned long reserved,
unsigned long expires,
const Key &certkey,
unsigned int flags);
Error addUid(const Key &key, const char *userid);
Error startAddUid(const Key &key, const char *userid);
Error revUid(const Key &key, const char *userid);
Error startRevUid(const Key &key, const char *userid);
Error setPrimaryUid(const Key &key, const char *userid);
Error startSetPrimaryUid(const Key &key, const char *userid);
Error createSubkey(const Key &key, const char *algo,
unsigned long reserved = 0,
unsigned long expires = 0,
unsigned int flags = 0);
Error startCreateSubkey(const Key &key, const char *algo,
unsigned long reserved = 0,
unsigned long expires = 0,
unsigned int flags = 0);
enum SetExpireFlags {
SetExpireDefault = 0,
SetExpireAllSubkeys = 1
};
Error setExpire(const Key &k, unsigned long expires,
const std::vector<Subkey> &subkeys = std::vector<Subkey>(),
const SetExpireFlags flags = SetExpireDefault);
Error startSetExpire(const Key &k, unsigned long expires,
const std::vector<Subkey> &subkeys = std::vector<Subkey>(),
const SetExpireFlags flags = SetExpireDefault);
Error revokeSignature(const Key &key, const Key &signingKey,
const std::vector<UserID> &userIds = std::vector<UserID>());
Error startRevokeSignature(const Key &key, const Key &signingKey,
const std::vector<UserID> &userIds = std::vector<UserID>());
Error addAdsk(const Key &k, const char *adsk);
Error startAddAdsk(const Key &k, const char *adsk);
// using TofuInfo::Policy
Error setTofuPolicy(const Key &k, unsigned int policy);
Error setTofuPolicyStart(const Key &k, unsigned int policy);
EditInteractor *lastEditInteractor() const;
std::unique_ptr<EditInteractor> takeLastEditInteractor();
//
// SmartCard Editing
//
GpgME::Error cardEdit(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
GpgME::Error startCardEditing(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
EditInteractor *lastCardEditInteractor() const;
std::unique_ptr<EditInteractor> takeLastCardEditInteractor();
//
// Trust Item Management
//
GpgME::Error startTrustItemListing(const char *pattern, int maxLevel);
TrustItem nextTrustItem(GpgME::Error &e);
GpgME::Error endTrustItemListing();
//
// Assuan Transactions
//
GpgME::Error assuanTransact(const char *command, std::unique_ptr<AssuanTransaction> transaction);
GpgME::Error assuanTransact(const char *command);
GpgME::Error startAssuanTransaction(const char *command, std::unique_ptr<AssuanTransaction> transaction);
GpgME::Error startAssuanTransaction(const char *command);
AssuanTransaction *lastAssuanTransaction() const;
std::unique_ptr<AssuanTransaction> takeLastAssuanTransaction();
//
//
// Crypto Operations
//
enum DecryptionFlags {
// Keep in line with core's flags
DecryptNone = 0,
DecryptVerify = 1,
DecryptArchive = 2,
DecryptUnwrap = 128,
DecryptMaxValue = 0x80000000
};
//
// Decryption
//
// Alternative way to set decryption flags as they were added only in
// 1.9.0 and so other API can still be used but with 1.9.0 additionally
// flags can be set.
void setDecryptionFlags (const DecryptionFlags flags);
DecryptionResult decrypt(const Data &cipherText, Data &plainText);
GpgME::Error startDecryption(const Data &cipherText, Data &plainText);
DecryptionResult decrypt(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
GpgME::Error startDecryption(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
DecryptionResult decryptionResult() const;
//
// Signature Verification
//
VerificationResult verifyDetachedSignature(const Data &signature, const Data &signedText);
VerificationResult verifyOpaqueSignature(const Data &signedData, Data &plainText);
GpgME::Error startDetachedSignatureVerification(const Data &signature, const Data &signedText);
GpgME::Error startOpaqueSignatureVerification(const Data &signedData, Data &plainText);
VerificationResult verificationResult() const;
//
// Combined Decryption and Signature Verification
//
std::pair<DecryptionResult, VerificationResult> decryptAndVerify(const Data &cipherText, Data &plainText);
std::pair<DecryptionResult, VerificationResult> decryptAndVerify(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
GpgME::Error startCombinedDecryptionAndVerification(const Data &cipherText, Data &plainText);
GpgME::Error startCombinedDecryptionAndVerification(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
// use verificationResult() and decryptionResult() to retrieve the result objects...
//
// Signing
//
void clearSigningKeys();
GpgME::Error addSigningKey(const Key &signer);
Key signingKey(unsigned int index) const;
std::vector<Key> signingKeys() const;
void clearSignatureNotations();
GpgME::Error addSignatureNotation(const char *name, const char *value, unsigned int flags = 0);
GpgME::Error addSignaturePolicyURL(const char *url, bool critical = false);
const char *signaturePolicyURL() const;
Notation signatureNotation(unsigned int index) const;
std::vector<Notation> signatureNotations() const;
//using GpgME::SignatureMode;
SigningResult sign(const Data &plainText, Data &signature, SignatureMode mode);
GpgME::Error startSigning(const Data &plainText, Data &signature, SignatureMode mode);
SigningResult signingResult() const;
// wrapper for gpgme_set_sender
const char *getSender();
GpgME::Error setSender(const char *sender);
//
// Encryption
//
enum EncryptionFlags {
None = 0,
AlwaysTrust = 1,
NoEncryptTo = 2,
Prepare = 4,
ExpectSign = 8,
NoCompress = 16,
Symmetric = 32,
ThrowKeyIds = 64,
EncryptWrap = 128,
WantAddress = 256,
EncryptArchive = 512,
EncryptFile = 1024
};
EncryptionResult encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
GpgME::Error encryptSymmetrically(const Data &plainText, Data &cipherText);
GpgME::Error startEncryption(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
EncryptionResult encryptionResult() const;
//
// Combined Signing and Encryption
//
std::pair<SigningResult, EncryptionResult> signAndEncrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
GpgME::Error startCombinedSigningAndEncryption(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
// use encryptionResult() and signingResult() to retrieve the result objects...
//
//
// Audit Log
//
//
enum AuditLogFlags {
DefaultAuditLog = 0,
HtmlAuditLog = 1,
DiagnosticAuditLog = 2,
AuditLogWithHelp = 128
};
GpgME::Error startGetAuditLog(Data &output, unsigned int flags = 0);
GpgME::Error getAuditLog(Data &output, unsigned int flags = 0);
//
//
// G13 crypto container operations
//
//
GpgME::Error createVFS(const char *containerFile, const std::vector<Key> &recipients);
VfsMountResult mountVFS(const char *containerFile, const char *mountDir);
// Spawn Engine
enum SpawnFlags {
SpawnNone = 0,
SpawnDetached = 1,
SpawnAllowSetFg = 2,
SpawnShowWindow = 4
};
/** Spwan the process \a file with arguments \a argv.
*
* If a data parameter is null the /dev/null will be
* used. (Or other platform stuff).
*
* @param file The executable to start.
* @param argv list of arguments file should be argv[0].
* @param input The data to be sent through stdin.
* @param output The data to be receive the stdout.
* @param err The data to receive stderr.
* @param flags Additional flags.
*
* @returns An error or empty error.
*/
GpgME::Error spawn(const char *file, const char *argv[],
Data &input, Data &output, Data &err,
SpawnFlags flags);
/** Async variant of spawn. Immediately returns after starting the
* process. */
GpgME::Error spawnAsync(const char *file, const char *argv[],
Data &input, Data &output,
Data &err, SpawnFlags flags);
//
//
// Run Control
//
//
bool poll();
GpgME::Error wait();
GpgME::Error lastError() const;
GpgME::Error cancelPendingOperation();
GpgME::Error cancelPendingOperationImmediately();
class Private;
const Private *impl() const
{
return d;
}
Private *impl()
{
return d;
}
private:
// Helper functions that need to be context because they rely
// on the "Friendlyness" of context to access the gpgme types.
gpgme_key_t *getKeysFromRecipients(const std::vector<Key> &recipients);
private:
Private *const d;
private: // disable...
Context(const Context &);
const Context &operator=(const Context &);
};
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Context::CertificateInclusion incl);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Context::EncryptionFlags flags);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Context::AuditLogFlags flags);
} // namespace GpgME
#endif // __GPGMEPP_CONTEXT_H__

View File

@ -1,88 +0,0 @@
/*
context_p.h - wraps a gpgme context (private part)
Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// -*- c++ -*-
#ifndef __GPGMEPP_CONTEXT_P_H__
#define __GPGMEPP_CONTEXT_P_H__
#include <context.h>
#include <data.h>
#include <gpgme.h>
namespace GpgME
{
class Context::Private
{
public:
enum Operation {
None = 0,
Encrypt = 0x001,
Decrypt = 0x002,
Sign = 0x004,
Verify = 0x008,
DecryptAndVerify = Decrypt | Verify,
SignAndEncrypt = Sign | Encrypt,
Import = 0x010,
Export = 0x020, // no gpgme_export_result_t, but nevertheless...
Delete = 0x040, // no gpgme_delete_result_t, but nevertheless...
KeyGen = 0x080,
KeyList = 0x100,
KeyListWithImport = KeyList | Import, // gpgme_keylist_result_t and gpgme_import_result_t
TrustList = 0x200, // no gpgme_trustlist_result_t, but nevertheless...
Edit = 0x400, // no gpgme_edit_result_t, but nevertheless...
CardEdit = 0x800, // no gpgme_card_edit_result_t, but nevertheless...
GetAuditLog = 0x1000, // no gpgme_getauditlog_result_t, but nevertheless...
AssuanTransact = 0x2000,
Passwd = 0x4000, // no gpgme_passwd_result_t, but nevertheless...
CreateVFS = 0x4000,
MountVFS = 0x8000,
EndMarker
};
Private(gpgme_ctx_t c = nullptr);
~Private();
gpgme_ctx_t ctx;
gpgme_io_cbs *iocbs;
Operation lastop;
gpgme_error_t lasterr;
Data lastAssuanInquireData;
std::unique_ptr<AssuanTransaction> lastAssuanTransaction;
std::unique_ptr<EditInteractor> lastEditInteractor, lastCardEditInteractor;
DecryptionFlags decryptFlags;
};
} // namespace GpgME
#endif // __GPGMEPP_CONTEXT_P_H__

View File

@ -1,39 +0,0 @@
/*
context_vanilla.cpp - wraps a gpgme key context, gpgme (vanilla)-specific functions
Copyright (C) 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <global.h>
GIOChannel *GpgME::getGIOChannel(int)
{
return nullptr;
}
QIODevice *GpgME::getQIODevice(int)
{
return nullptr;
}

View File

@ -1,293 +0,0 @@
/*
data.cpp - wraps a gpgme data object
Copyright (C) 2003 Klarälvdalens Datakonsult AB
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "data_p.h"
#include "context_p.h"
#include <error.h>
#include <interfaces/dataprovider.h>
#include <gpgme.h>
#ifndef NDEBUG
#include <iostream>
#endif
GpgME::Data::Private::~Private()
{
if (data) {
gpgme_data_release(data);
}
}
const GpgME::Data::Null GpgME::Data::null;
GpgME::Data::Data()
{
gpgme_data_t data;
const gpgme_error_t e = gpgme_data_new(&data);
d.reset(new Private(e ? nullptr : data));
}
GpgME::Data::Data(const Null &)
: d(new Private(nullptr))
{
}
GpgME::Data::Data(gpgme_data_t data)
: d(new Private(data))
{
}
GpgME::Data::Data(const char *buffer, size_t size, bool copy)
{
gpgme_data_t data;
const gpgme_error_t e = gpgme_data_new_from_mem(&data, buffer, size, int(copy));
std::string sizestr = std::to_string(size);
// Ignore errors as this is optional
gpgme_data_set_flag(data, "size-hint", sizestr.c_str());
d.reset(new Private(e ? nullptr : data));
}
GpgME::Data::Data(const char *filename)
{
gpgme_data_t data;
const gpgme_error_t e = gpgme_data_new(&data);
d.reset(new Private(e ? nullptr : data));
if (!e) {
setFileName(filename);
}
}
GpgME::Data::Data(const char *filename, off_t offset, size_t length)
{
gpgme_data_t data;
const gpgme_error_t e = gpgme_data_new_from_filepart(&data, filename, nullptr, offset, length);
d.reset(new Private(e ? nullptr : data));
}
GpgME::Data::Data(FILE *fp)
{
gpgme_data_t data;
const gpgme_error_t e = gpgme_data_new_from_stream(&data, fp);
d.reset(new Private(e ? nullptr : data));
}
GpgME::Data::Data(FILE *fp, off_t offset, size_t length)
{
gpgme_data_t data;
const gpgme_error_t e = gpgme_data_new_from_filepart(&data, nullptr, fp, offset, length);
d.reset(new Private(e ? nullptr : data));
}
GpgME::Data::Data(int fd)
{
gpgme_data_t data;
const gpgme_error_t e = gpgme_data_new_from_fd(&data, fd);
d.reset(new Private(e ? nullptr : data));
}
GpgME::Data::Data(DataProvider *dp)
{
d.reset(new Private);
if (!dp) {
return;
}
if (!dp->isSupported(DataProvider::Read)) {
d->cbs.read = nullptr;
}
if (!dp->isSupported(DataProvider::Write)) {
d->cbs.write = nullptr;
}
if (!dp->isSupported(DataProvider::Seek)) {
d->cbs.seek = nullptr;
}
if (!dp->isSupported(DataProvider::Release)) {
d->cbs.release = nullptr;
}
const gpgme_error_t e = gpgme_data_new_from_cbs(&d->data, &d->cbs, dp);
if (e) {
d->data = nullptr;
}
if (dp->isSupported(DataProvider::Seek)) {
off_t size = seek(0, SEEK_END);
seek(0, SEEK_SET);
std::string sizestr = std::to_string(size);
// Ignore errors as this is optional
gpgme_data_set_flag(d->data, "size-hint", sizestr.c_str());
}
#ifndef NDEBUG
//std::cerr << "GpgME::Data(): DataProvider supports: "
// << ( d->cbs.read ? "read" : "no read" ) << ", "
// << ( d->cbs.write ? "write" : "no write" ) << ", "
// << ( d->cbs.seek ? "seek" : "no seek" ) << ", "
// << ( d->cbs.release ? "release" : "no release" ) << std::endl;
#endif
}
bool GpgME::Data::isNull() const
{
return !d || !d->data;
}
GpgME::Data::Encoding GpgME::Data::encoding() const
{
switch (gpgme_data_get_encoding(d->data)) {
case GPGME_DATA_ENCODING_NONE: return AutoEncoding;
case GPGME_DATA_ENCODING_BINARY: return BinaryEncoding;
case GPGME_DATA_ENCODING_BASE64: return Base64Encoding;
case GPGME_DATA_ENCODING_ARMOR: return ArmorEncoding;
case GPGME_DATA_ENCODING_MIME: return MimeEncoding;
case GPGME_DATA_ENCODING_URL: return UrlEncoding;
case GPGME_DATA_ENCODING_URLESC: return UrlEscEncoding;
case GPGME_DATA_ENCODING_URL0: return Url0Encoding;
}
return AutoEncoding;
}
GpgME::Error GpgME::Data::setEncoding(Encoding enc)
{
gpgme_data_encoding_t ge = GPGME_DATA_ENCODING_NONE;
switch (enc) {
case AutoEncoding: ge = GPGME_DATA_ENCODING_NONE; break;
case BinaryEncoding: ge = GPGME_DATA_ENCODING_BINARY; break;
case Base64Encoding: ge = GPGME_DATA_ENCODING_BASE64; break;
case ArmorEncoding: ge = GPGME_DATA_ENCODING_ARMOR; break;
case MimeEncoding: ge = GPGME_DATA_ENCODING_MIME; break;
case UrlEncoding: ge = GPGME_DATA_ENCODING_URL; break;
case UrlEscEncoding: ge = GPGME_DATA_ENCODING_URLESC; break;
case Url0Encoding: ge = GPGME_DATA_ENCODING_URL0; break;
}
return Error(gpgme_data_set_encoding(d->data, ge));
}
GpgME::Data::Type GpgME::Data::type() const
{
if (isNull()) {
return Invalid;
}
switch (gpgme_data_identify(d->data, 0)) {
case GPGME_DATA_TYPE_INVALID: return Invalid;
case GPGME_DATA_TYPE_UNKNOWN: return Unknown;
case GPGME_DATA_TYPE_PGP_SIGNED: return PGPSigned;
case GPGME_DATA_TYPE_PGP_OTHER: return PGPOther;
case GPGME_DATA_TYPE_PGP_KEY: return PGPKey;
case GPGME_DATA_TYPE_CMS_SIGNED: return CMSSigned;
case GPGME_DATA_TYPE_CMS_ENCRYPTED: return CMSEncrypted;
case GPGME_DATA_TYPE_CMS_OTHER: return CMSOther;
case GPGME_DATA_TYPE_X509_CERT: return X509Cert;
case GPGME_DATA_TYPE_PKCS12: return PKCS12;
case GPGME_DATA_TYPE_PGP_ENCRYPTED: return PGPEncrypted;
case GPGME_DATA_TYPE_PGP_SIGNATURE: return PGPSignature;
}
return Invalid;
}
char *GpgME::Data::fileName() const
{
return gpgme_data_get_file_name(d->data);
}
GpgME::Error GpgME::Data::setFileName(const char *name)
{
return Error(gpgme_data_set_file_name(d->data, name));
}
GpgME::Error GpgME::Data::setFileName(const std::string &name)
{
return Error(gpgme_data_set_file_name(d->data, name.c_str()));
}
ssize_t GpgME::Data::read(void *buffer, size_t length)
{
return gpgme_data_read(d->data, buffer, length);
}
ssize_t GpgME::Data::write(const void *buffer, size_t length)
{
return gpgme_data_write(d->data, buffer, length);
}
off_t GpgME::Data::seek(off_t offset, int whence)
{
return gpgme_data_seek(d->data, offset, whence);
}
GpgME::Error GpgME::Data::rewind()
{
return Error(gpgme_data_rewind(d->data));
}
std::vector<GpgME::Key> GpgME::Data::toKeys(Protocol proto) const
{
std::vector<GpgME::Key> ret;
if (isNull()) {
return ret;
}
auto ctx = GpgME::Context::createForProtocol(proto);
if (!ctx) {
return ret;
}
if (gpgme_op_keylist_from_data_start (ctx->impl()->ctx, d->data, 0)) {
return ret;
}
gpgme_key_t key;
while (!gpgme_op_keylist_next (ctx->impl()->ctx, &key)) {
ret.push_back(GpgME::Key(key, false));
}
gpgme_data_seek (d->data, 0, SEEK_SET);
delete ctx;
return ret;
}
std::string GpgME::Data::toString()
{
std::string ret;
char buf[4096];
size_t nread;
seek (0, SEEK_SET);
while ((nread = read (buf, 4096)) > 0)
{
ret += std::string (buf, nread);
}
seek (0, SEEK_SET);
return ret;
}
GpgME::Error GpgME::Data::setFlag(const char *name, const char *value)
{
return Error(gpgme_data_set_flag(d->data, name, value));
}
GpgME::Error GpgME::Data::setSizeHint(uint64_t size)
{
const std::string val = std::to_string(size);
return Error(gpgme_data_set_flag(d->data, "size-hint", val.c_str()));
}

View File

@ -1,149 +0,0 @@
/*
data.h - wraps a gpgme data object
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_DATA_H__
#define __GPGMEPP_DATA_H__
#include "global.h"
#include "key.h"
#include <sys/types.h> // for size_t, off_t
#include <cstdint> // unit64_t
#include <cstdio> // FILE
#include <algorithm>
#include <memory>
namespace GpgME
{
class DataProvider;
class Error;
class GPGMEPP_EXPORT Data
{
struct Null {
Null() {}
};
public:
/* implicit */ Data(const Null &);
Data();
explicit Data(gpgme_data_t data);
// Memory-Based Data Buffers:
Data(const char *buffer, size_t size, bool copy = true);
explicit Data(const char *filename);
Data(const char *filename, off_t offset, size_t length);
Data(std::FILE *fp, off_t offset, size_t length);
// File-Based Data Buffers:
explicit Data(std::FILE *fp);
explicit Data(int fd);
// Callback-Based Data Buffers:
explicit Data(DataProvider *provider);
static const Null null;
Data(const Data &other) = default;
const Data &operator=(Data other)
{
swap(other);
return *this;
}
void swap(Data &other)
{
using std::swap;
swap(this->d, other.d);
}
bool isNull() const;
enum Encoding {
AutoEncoding,
BinaryEncoding,
Base64Encoding,
ArmorEncoding,
MimeEncoding,
UrlEncoding,
UrlEscEncoding,
Url0Encoding,
};
Encoding encoding() const;
Error setEncoding(Encoding encoding);
enum Type {
Invalid,
Unknown,
PGPSigned,
PGPOther,
PGPKey,
CMSSigned,
CMSEncrypted,
CMSOther,
X509Cert,
PKCS12,
PGPEncrypted,
PGPSignature,
};
Type type() const;
char *fileName() const;
Error setFileName(const char *name);
Error setFileName(const std::string &name);
ssize_t read(void *buffer, size_t length);
ssize_t write(const void *buffer, size_t length);
off_t seek(off_t offset, int whence);
/* Convenience function to do a seek (0, SEEK_SET). */
Error rewind();
/** Try to parse the data to a key object using the
* Protocol proto. Returns an empty list on error.*/
std::vector<Key> toKeys(const Protocol proto = Protocol::OpenPGP) const;
/** Return a copy of the data as std::string. Sets seek pos to 0 */
std::string toString();
/** See gpgme_data_set_flag */
Error setFlag(const char *name, const char *value);
/** Set a size hint for this data e.g. for progress calculations. */
Error setSizeHint(uint64_t size);
class Private;
Private *impl()
{
return d.get();
}
const Private *impl() const
{
return d.get();
}
private:
std::shared_ptr<Private> d;
};
}
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Data)
#endif // __GPGMEPP_DATA_H__

View File

@ -1,42 +0,0 @@
/*
data_p.h - wraps a gpgme data object, private part -*- c++ -*-
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_DATA_P_H__
#define __GPGMEPP_DATA_P_H__
#include <data.h>
#include "callbacks.h"
class GpgME::Data::Private
{
public:
explicit Private(gpgme_data_t d = nullptr)
: data(d), cbs(data_provider_callbacks) {}
~Private();
gpgme_data_t data;
gpgme_data_cbs cbs;
};
#endif // __GPGMEPP_DATA_P_H__

View File

@ -1,281 +0,0 @@
/*
decryptionresult.cpp - wraps a gpgme keygen result
Copyright (C) 2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <decryptionresult.h>
#include "result_p.h"
#include "util.h"
#include <gpgme.h>
#include <algorithm>
#include <iterator>
#include <cstring>
#include <cstdlib>
#include <istream>
#include <string.h>
class GpgME::DecryptionResult::Private
{
public:
explicit Private(const _gpgme_op_decrypt_result &r) : res(r)
{
if (res.unsupported_algorithm) {
res.unsupported_algorithm = strdup(res.unsupported_algorithm);
}
if (res.file_name) {
res.file_name = strdup(res.file_name);
}
if (res.symkey_algo) {
res.symkey_algo = strdup(res.symkey_algo);
}
//FIXME: copying gpgme_recipient_t objects invalidates the keyid member,
//thus we use _keyid for now (internal API)
for (gpgme_recipient_t r = res.recipients ; r ; r = r->next) {
recipients.push_back(*r);
}
res.recipients = nullptr;
}
~Private()
{
if (res.unsupported_algorithm) {
std::free(res.unsupported_algorithm);
}
res.unsupported_algorithm = nullptr;
if (res.file_name) {
std::free(res.file_name);
}
res.file_name = nullptr;
if (res.symkey_algo) {
std::free(res.symkey_algo);
}
res.symkey_algo = nullptr;
}
_gpgme_op_decrypt_result res;
std::vector<_gpgme_recipient> recipients;
};
GpgME::DecryptionResult::DecryptionResult(gpgme_ctx_t ctx, int error)
: GpgME::Result(error), d()
{
init(ctx);
}
GpgME::DecryptionResult::DecryptionResult(gpgme_ctx_t ctx, const Error &error)
: GpgME::Result(error), d()
{
init(ctx);
}
void GpgME::DecryptionResult::init(gpgme_ctx_t ctx)
{
if (!ctx) {
return;
}
gpgme_decrypt_result_t res = gpgme_op_decrypt_result(ctx);
if (!res) {
return;
}
d.reset(new Private(*res));
}
make_standard_stuff(DecryptionResult)
const char *GpgME::DecryptionResult::unsupportedAlgorithm() const
{
return d ? d->res.unsupported_algorithm : nullptr ;
}
bool GpgME::DecryptionResult::isWrongKeyUsage() const
{
return d && d->res.wrong_key_usage;
}
bool GpgME::DecryptionResult::isDeVs() const
{
return d && d->res.is_de_vs;
}
bool GpgME::DecryptionResult::isMime() const
{
return d && d->res.is_mime;
}
const char *GpgME::DecryptionResult::fileName() const
{
return d ? d->res.file_name : nullptr ;
}
unsigned int GpgME::DecryptionResult::numRecipients() const
{
return d ? d->recipients.size() : 0 ;
}
GpgME::DecryptionResult::Recipient GpgME::DecryptionResult::recipient(unsigned int idx) const
{
if (d && idx < d->recipients.size()) {
return Recipient(&d->recipients[idx]);
}
return Recipient();
}
namespace
{
struct make_recipient {
GpgME::DecryptionResult::Recipient operator()(_gpgme_recipient &t)
{
return GpgME::DecryptionResult::Recipient(&t);
}
};
}
std::vector<GpgME::DecryptionResult::Recipient> GpgME::DecryptionResult::recipients() const
{
std::vector<Recipient> result;
if (d) {
result.reserve(d->recipients.size());
std::transform(d->recipients.begin(), d->recipients.end(),
std::back_inserter(result),
make_recipient());
}
return result;
}
const char *GpgME::DecryptionResult::sessionKey() const
{
return d ? d->res.session_key : nullptr;
}
const char *GpgME::DecryptionResult::symkeyAlgo() const
{
return d ? d->res.symkey_algo : nullptr;
}
bool GpgME::DecryptionResult::isLegacyCipherNoMDC() const
{
return d && d->res.legacy_cipher_nomdc;
}
class GpgME::DecryptionResult::Recipient::Private : public _gpgme_recipient
{
public:
Private(gpgme_recipient_t reci) : _gpgme_recipient(*reci) {}
};
GpgME::DecryptionResult::Recipient::Recipient()
: d()
{
}
GpgME::DecryptionResult::Recipient::Recipient(gpgme_recipient_t r)
: d()
{
if (r) {
d.reset(new Private(r));
}
}
bool GpgME::DecryptionResult::Recipient::isNull() const
{
return !d;
}
const char *GpgME::DecryptionResult::Recipient::keyID() const
{
//_keyid is internal API, but the public keyid is invalid after copying (see above)
if (d) {
return d->_keyid;
}
return nullptr;
}
const char *GpgME::DecryptionResult::Recipient::shortKeyID() const
{
//_keyid is internal API, but the public keyid is invalid after copying (see above)
if (d) {
return d->_keyid + 8;
}
return nullptr;
}
unsigned int GpgME::DecryptionResult::Recipient::publicKeyAlgorithm() const
{
if (d) {
return d->pubkey_algo;
}
return 0;
}
const char *GpgME::DecryptionResult::Recipient::publicKeyAlgorithmAsString() const
{
if (d) {
return gpgme_pubkey_algo_name(d->pubkey_algo);
}
return nullptr;
}
GpgME::Error GpgME::DecryptionResult::Recipient::status() const
{
if (d) {
return Error(d->status);
}
return Error();
}
std::ostream &GpgME::operator<<(std::ostream &os, const DecryptionResult &result)
{
os << "GpgME::DecryptionResult(";
if (!result.isNull()) {
os << "\n error: " << result.error()
<< "\n fileName: " << protect(result.fileName())
<< "\n unsupportedAlgorithm: " << protect(result.unsupportedAlgorithm())
<< "\n isWrongKeyUsage: " << result.isWrongKeyUsage()
<< "\n isDeVs " << result.isDeVs()
<< "\n legacyCipherNoMDC " << result.isLegacyCipherNoMDC()
<< "\n symkeyAlgo: " << protect(result.symkeyAlgo())
<< "\n recipients:\n";
const std::vector<DecryptionResult::Recipient> recipients = result.recipients();
std::copy(recipients.begin(), recipients.end(),
std::ostream_iterator<DecryptionResult::Recipient>(os, "\n"));
}
return os << ')';
}
std::ostream &GpgME::operator<<(std::ostream &os, const DecryptionResult::Recipient &reci)
{
os << "GpgME::DecryptionResult::Recipient(";
if (!reci.isNull()) {
os << "\n keyID: " << protect(reci.keyID())
<< "\n shortKeyID: " << protect(reci.shortKeyID())
<< "\n publicKeyAlgorithm: " << protect(reci.publicKeyAlgorithmAsString())
<< "\n status: " << reci.status();
}
return os << ')';
}

View File

@ -1,142 +0,0 @@
/*
decryptionresult.h - wraps a gpgme keygen result
Copyright (C) 2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_DECRYPTIONRESULT_H__
#define __GPGMEPP_DECRYPTIONRESULT_H__
#include "gpgmefw.h"
#include "result.h"
#include "gpgmepp_export.h"
#include <vector>
#include <algorithm>
#include <iosfwd>
#include <memory>
namespace GpgME
{
class Error;
class GPGMEPP_EXPORT DecryptionResult : public Result
{
public:
DecryptionResult();
DecryptionResult(gpgme_ctx_t ctx, int error);
DecryptionResult(gpgme_ctx_t ctx, const Error &err);
explicit DecryptionResult(const Error &err);
DecryptionResult(const DecryptionResult &other) = default;
const DecryptionResult &operator=(DecryptionResult other)
{
swap(other);
return *this;
}
void swap(DecryptionResult &other)
{
Result::swap(other);
using std::swap;
swap(this->d, other.d);
}
bool isNull() const;
GPGMEPP_DEPRECATED const char *unsupportedAlgortihm() const
{
return unsupportedAlgorithm();
}
const char *unsupportedAlgorithm() const;
GPGMEPP_DEPRECATED bool wrongKeyUsage() const
{
return isWrongKeyUsage();
}
bool isWrongKeyUsage() const;
bool isDeVs() const;
bool isMime() const;
const char *fileName() const;
const char *sessionKey() const;
const char *symkeyAlgo() const;
class Recipient;
unsigned int numRecipients() const;
Recipient recipient(unsigned int idx) const;
std::vector<Recipient> recipients() const;
bool isLegacyCipherNoMDC() const;
private:
class Private;
void init(gpgme_ctx_t ctx);
std::shared_ptr<Private> d;
};
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const DecryptionResult &result);
class GPGMEPP_EXPORT DecryptionResult::Recipient
{
public:
Recipient();
explicit Recipient(gpgme_recipient_t reci);
Recipient(const Recipient &other) = default;
const Recipient &operator=(Recipient other)
{
swap(other);
return *this;
}
void swap(Recipient &other)
{
using std::swap;
swap(this->d, other.d);
}
bool isNull() const;
const char *keyID() const;
const char *shortKeyID() const;
unsigned int publicKeyAlgorithm() const;
const char *publicKeyAlgorithmAsString() const;
Error status() const;
private:
class Private;
std::shared_ptr<Private> d;
};
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const DecryptionResult::Recipient &reci);
}
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(DecryptionResult)
#endif // __GPGMEPP_DECRYPTIONRESULT_H__

View File

@ -1,82 +0,0 @@
/*
defaultassuantransaction.cpp - default Assuan Transaction that just stores data and status lines
Copyright (C) 2009 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "defaultassuantransaction.h"
#include "error.h"
#include "data.h"
using namespace GpgME;
DefaultAssuanTransaction::DefaultAssuanTransaction()
: AssuanTransaction(),
m_status(),
m_data()
{
}
DefaultAssuanTransaction::~DefaultAssuanTransaction() {}
Error DefaultAssuanTransaction::data(const char *data, size_t len)
{
m_data.append(data, len);
return Error();
}
Data DefaultAssuanTransaction::inquire(const char *name, const char *args, Error &err)
{
(void)name; (void)args; (void)err;
return Data::null;
}
Error DefaultAssuanTransaction::status(const char *status, const char *args)
{
m_status.push_back(std::pair<std::string, std::string>(status, args));
return Error();
}
std::vector<std::string> DefaultAssuanTransaction::statusLine(const char *tag) const
{
std::vector<std::string> result;
for (std::vector< std::pair<std::string, std::string> >::const_iterator it = m_status.begin(), end = m_status.end() ; it != end ; ++it) {
if (it->first == tag) {
result.push_back(it->second);
}
}
return result;
}
std::string DefaultAssuanTransaction::firstStatusLine(const char *tag) const
{
for (std::vector< std::pair<std::string, std::string> >::const_iterator it = m_status.begin(), end = m_status.end() ; it != end ; ++it) {
if (it->first == tag) {
return it->second;
}
}
return std::string();
}

View File

@ -1,67 +0,0 @@
/*
defaultassuantransaction.h - default Assuan Transaction that just stores data and status lines
Copyright (C) 2009 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_DEFAULTASSUANTRANSACTION_H__
#define __GPGMEPP_DEFAULTASSUANTRANSACTION_H__
#include "interfaces/assuantransaction.h"
#include <string>
#include <vector>
#include <utility>
namespace GpgME
{
class GPGMEPP_EXPORT DefaultAssuanTransaction : public AssuanTransaction
{
public:
explicit DefaultAssuanTransaction();
~DefaultAssuanTransaction();
const std::vector< std::pair<std::string, std::string> > &statusLines() const
{
return m_status;
}
std::vector<std::string> statusLine(const char *tag) const;
std::string firstStatusLine(const char *tag) const;
const std::string &data() const
{
return m_data;
}
private:
Error data(const char *data, size_t datalen) override;
Data inquire(const char *name, const char *args, Error &err) override;
Error status(const char *status, const char *args) override;
private:
std::vector< std::pair<std::string, std::string> > m_status;
std::string m_data;
};
} // namespace GpgME
#endif // __GPGMEPP_DEFAULTASSUANTRANSACTION_H__

View File

@ -1,422 +0,0 @@
/*
editinteractor.cpp - Interface for edit interactors
Copyright (C) 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "editinteractor.h"
#include "callbacks.h"
#include "error.h"
#include "util.h"
#include <gpgme.h>
#ifdef _WIN32
# include <io.h>
#include <windows.h>
#else
# include <unistd.h>
#endif
#include <cerrno>
#include <cstring>
#include <cstdlib>
#ifndef GPG_ERR_ALREADY_SIGNED
# define GPG_ERR_ALREADY_SIGNED GPG_ERR_USER_1
#endif
using namespace GpgME;
static const char *status_to_string(unsigned int status);
static Error status_to_error(unsigned int status);
static Error parse_sc_op_failure(const char *args);
class EditInteractor::Private
{
friend class ::GpgME::EditInteractor;
friend class ::GpgME::CallbackHelper;
EditInteractor *const q;
public:
explicit Private(EditInteractor *qq);
~Private();
private:
unsigned int state = StartState;
Error error;
std::FILE *debug = nullptr;
bool debugNeedsClosing = false;
};
class GpgME::CallbackHelper
{
private:
static int writeAll(int fd, const void *buf, size_t count)
{
size_t toWrite = count;
while (toWrite > 0) {
const int n = gpgme_io_write(fd, buf, toWrite);
if (n < 0) {
return n;
}
toWrite -= n;
}
return count;
}
public:
static int edit_interactor_callback_impl(void *opaque, gpgme_status_code_t status, const char *args, int fd)
{
EditInteractor::Private *ei = (EditInteractor::Private *)opaque;
Error err = status_to_error(status);
if (!err) {
// advance to next state based on input:
const unsigned int oldState = ei->state;
if (ei->q->needsNoResponse(status)) {
// keep state
} else if (status == GPGME_STATUS_ERROR) {
err = ei->q->parseStatusError(args);
ei->state = EditInteractor::ErrorState;
} else if (status == GPGME_STATUS_SC_OP_FAILURE) {
err = parse_sc_op_failure(args);
ei->state = EditInteractor::ErrorState;
} else {
ei->state = ei->q->nextState(status, args, err);
}
if (ei->debug) {
std::fprintf(ei->debug, "EditInteractor: %u -> nextState( %s, %s ) -> %u\n",
oldState, status_to_string(status), args ? args : "<null>", ei->state);
}
if (err || err.isCanceled()) {
ei->state = oldState;
goto error;
}
if (ei->state != oldState &&
// if there was an error from before, we stop here (### this looks weird, can this happen at all?)
ei->error.code() == GPG_ERR_NO_ERROR) {
// successful state change -> call action
if (const char *const result = ei->q->action(err)) {
if (err) {
goto error;
}
if (ei->debug) {
std::fprintf(ei->debug, "EditInteractor: action result \"%s\"\n", result);
}
// if there's a result, write it:
if (*result) {
gpgme_err_set_errno(0);
const ssize_t len = std::strlen(result);
if (writeAll(fd, result, len) != len) {
err = Error::fromSystemError();
if (ei->debug) {
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asStdString().c_str());
}
goto error;
}
}
gpgme_err_set_errno(0);
if (writeAll(fd, "\n", 1) != 1) {
err = Error::fromSystemError();
if (ei->debug) {
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asStdString().c_str());
}
goto error;
}
} else {
if (err) {
goto error;
}
if (ei->debug) {
std::fprintf(ei->debug, "EditInteractor: no action result\n");
}
}
} else {
if (ei->debug) {
std::fprintf(ei->debug, "EditInteractor: no action executed\n");
}
}
}
error:
if (err || err.isCanceled()) {
ei->error = err;
ei->state = EditInteractor::ErrorState;
}
if (ei->debug) {
std::fprintf(ei->debug, "EditInteractor: error now %u (%s)\n",
ei->error.encodedError(), gpgme_strerror(ei->error.encodedError()));
}
return ei->error.encodedError();
}
};
static gpgme_error_t edit_interactor_callback(void *opaque, gpgme_status_code_t status, const char *args, int fd)
{
return CallbackHelper::edit_interactor_callback_impl(opaque, status, args, fd);
}
const gpgme_edit_cb_t GpgME::edit_interactor_callback = ::edit_interactor_callback;
EditInteractor::Private::Private(EditInteractor *qq)
: q(qq)
{
const char *debug_env = std::getenv("GPGMEPP_INTERACTOR_DEBUG");
if (!debug_env) {
return;
}
if (!strcmp(debug_env, "stdout")) {
debug = stdout;
} else if (!strcmp(debug_env, "stderr")) {
debug = stderr;
} else if (debug_env) {
debug = std::fopen(debug_env, "a+");
debugNeedsClosing = true;
}
}
EditInteractor::Private::~Private()
{
if (debug && debugNeedsClosing) {
std::fclose(debug);
}
}
EditInteractor::EditInteractor()
: d(new Private(this))
{
}
EditInteractor::~EditInteractor()
{
delete d;
}
unsigned int EditInteractor::state() const
{
return d->state;
}
Error EditInteractor::lastError() const
{
return d->error;
}
bool EditInteractor::needsNoResponse(unsigned int status) const
{
switch (status) {
case GPGME_STATUS_ALREADY_SIGNED:
case GPGME_STATUS_ERROR:
case GPGME_STATUS_GET_BOOL:
case GPGME_STATUS_GET_LINE:
case GPGME_STATUS_KEY_CREATED:
case GPGME_STATUS_NEED_PASSPHRASE_SYM:
case GPGME_STATUS_SC_OP_FAILURE:
case GPGME_STATUS_CARDCTRL:
case GPGME_STATUS_BACKUP_KEY_CREATED:
return false;
default:
return true;
}
}
// static
Error status_to_error(unsigned int status)
{
switch (status) {
case GPGME_STATUS_MISSING_PASSPHRASE:
return Error::fromCode(GPG_ERR_NO_PASSPHRASE);
case GPGME_STATUS_ALREADY_SIGNED:
return Error::fromCode(GPG_ERR_ALREADY_SIGNED);
case GPGME_STATUS_SIGEXPIRED:
return Error::fromCode(GPG_ERR_SIG_EXPIRED);
}
return Error();
}
void EditInteractor::setDebugChannel(std::FILE *debug)
{
d->debug = debug;
}
GpgME::Error EditInteractor::parseStatusError(const char *args)
{
Error err;
const auto fields = split(args, ' ');
if (fields.size() >= 2) {
err = Error{static_cast<unsigned int>(std::stoul(fields[1]))};
} else {
err = Error::fromCode(GPG_ERR_GENERAL);
}
return err;
}
static Error sc_op_failure_to_error(unsigned int status)
{
switch (status) {
case 1:
// GPG_ERR_CANCELED or GPG_ERR_FULLY_CANCELED
return Error::fromCode(GPG_ERR_CANCELED);
case 2:
// GPG_ERR_BAD_PIN or GPG_ERR_BAD_RESET_CODE [sic]
return Error::fromCode(GPG_ERR_BAD_PIN);
case 3:
return Error::fromCode(GPG_ERR_PIN_BLOCKED);
case 4:
return Error::fromCode(GPG_ERR_NO_RESET_CODE);
}
return Error::fromCode(GPG_ERR_CARD);
}
// static
Error parse_sc_op_failure(const char *args)
{
Error err;
const auto fields = split(args, ' ');
if (fields.size() >= 1) {
err = sc_op_failure_to_error(static_cast<unsigned int>(std::stoul(fields[0])));
} else {
err = Error::fromCode(GPG_ERR_CARD);
}
return err;
}
static const char *const status_strings[] = {
"EOF",
/* mkstatus processing starts here */
"ENTER",
"LEAVE",
"ABORT",
"GOODSIG",
"BADSIG",
"ERRSIG",
"BADARMOR",
"RSA_OR_IDEA",
"KEYEXPIRED",
"KEYREVOKED",
"TRUST_UNDEFINED",
"TRUST_NEVER",
"TRUST_MARGINAL",
"TRUST_FULLY",
"TRUST_ULTIMATE",
"SHM_INFO",
"SHM_GET",
"SHM_GET_BOOL",
"SHM_GET_HIDDEN",
"NEED_PASSPHRASE",
"VALIDSIG",
"SIG_ID",
"ENC_TO",
"NODATA",
"BAD_PASSPHRASE",
"NO_PUBKEY",
"NO_SECKEY",
"NEED_PASSPHRASE_SYM",
"DECRYPTION_FAILED",
"DECRYPTION_OKAY",
"MISSING_PASSPHRASE",
"GOOD_PASSPHRASE",
"GOODMDC",
"BADMDC",
"ERRMDC",
"IMPORTED",
"IMPORT_OK",
"IMPORT_PROBLEM",
"IMPORT_RES",
"FILE_START",
"FILE_DONE",
"FILE_ERROR",
"BEGIN_DECRYPTION",
"END_DECRYPTION",
"BEGIN_ENCRYPTION",
"END_ENCRYPTION",
"DELETE_PROBLEM",
"GET_BOOL",
"GET_LINE",
"GET_HIDDEN",
"GOT_IT",
"PROGRESS",
"SIG_CREATED",
"SESSION_KEY",
"NOTATION_NAME",
"NOTATION_DATA",
"POLICY_URL",
"BEGIN_STREAM",
"END_STREAM",
"KEY_CREATED",
"USERID_HINT",
"UNEXPECTED",
"INV_RECP",
"NO_RECP",
"ALREADY_SIGNED",
"SIGEXPIRED",
"EXPSIG",
"EXPKEYSIG",
"TRUNCATED",
"ERROR",
"NEWSIG",
"REVKEYSIG",
"SIG_SUBPACKET",
"NEED_PASSPHRASE_PIN",
"SC_OP_FAILURE",
"SC_OP_SUCCESS",
"CARDCTRL",
"BACKUP_KEY_CREATED",
"PKA_TRUST_BAD",
"PKA_TRUST_GOOD",
"PLAINTEXT",
};
static const unsigned int num_status_strings = sizeof status_strings / sizeof * status_strings ;
const char *status_to_string(unsigned int idx)
{
if (idx < num_status_strings) {
return status_strings[idx];
} else {
return "(unknown)";
}
}

View File

@ -1,73 +0,0 @@
/*
editinteractor.h - Interface for edit interactors
Copyright (C) 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_EDITINTERACTOR_H__
#define __GPGMEPP_EDITINTERACTOR_H__
#include "gpgmepp_export.h"
#include <cstdio>
namespace GpgME
{
class Error;
class Context;
class CallbackHelper;
class GPGMEPP_EXPORT EditInteractor
{
friend class ::GpgME::Context;
friend class ::GpgME::CallbackHelper;
EditInteractor(const EditInteractor &);
EditInteractor &operator=(const EditInteractor &);
public:
EditInteractor();
virtual ~EditInteractor();
enum {
StartState = 0,
ErrorState = 0xFFFFFFFF
};
virtual const char *action(Error &err) const = 0;
virtual unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const = 0;
unsigned int state() const;
Error lastError() const;
bool needsNoResponse(unsigned int statusCode) const;
void setDebugChannel(std::FILE *file);
protected:
Error parseStatusError(const char *args);
private:
class Private;
Private *const d;
};
} // namespace GpgME
#endif // __GPGMEPP_EDITINTERACTOR_H__

View File

@ -1,165 +0,0 @@
/*
encryptionresult.cpp - wraps a gpgme verify result
Copyright (C) 2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <encryptionresult.h>
#include "result_p.h"
#include "util.h"
#include <gpgme.h>
#include <cstring>
#include <cstdlib>
#include <istream>
#include <algorithm>
#include <iterator>
#include <string.h>
class GpgME::EncryptionResult::Private
{
public:
explicit Private(const gpgme_encrypt_result_t r)
{
if (!r) {
return;
}
for (gpgme_invalid_key_t ik = r->invalid_recipients ; ik ; ik = ik->next) {
gpgme_invalid_key_t copy = new _gpgme_invalid_key(*ik);
if (ik->fpr) {
copy->fpr = strdup(ik->fpr);
}
copy->next = nullptr;
invalid.push_back(copy);
}
}
~Private()
{
for (std::vector<gpgme_invalid_key_t>::iterator it = invalid.begin() ; it != invalid.end() ; ++it) {
std::free((*it)->fpr);
delete *it; *it = nullptr;
}
}
std::vector<gpgme_invalid_key_t> invalid;
};
GpgME::EncryptionResult::EncryptionResult(gpgme_ctx_t ctx, int error)
: GpgME::Result(error), d()
{
init(ctx);
}
GpgME::EncryptionResult::EncryptionResult(gpgme_ctx_t ctx, const Error &error)
: GpgME::Result(error), d()
{
init(ctx);
}
void GpgME::EncryptionResult::init(gpgme_ctx_t ctx)
{
if (!ctx) {
return;
}
gpgme_encrypt_result_t res = gpgme_op_encrypt_result(ctx);
if (!res) {
return;
}
d.reset(new Private(res));
}
make_standard_stuff(EncryptionResult)
unsigned int GpgME::EncryptionResult::numInvalidRecipients() const
{
return d ? d->invalid.size() : 0 ;
}
GpgME::InvalidRecipient GpgME::EncryptionResult::invalidEncryptionKey(unsigned int idx) const
{
return InvalidRecipient(d, idx);
}
std::vector<GpgME::InvalidRecipient> GpgME::EncryptionResult::invalidEncryptionKeys() const
{
if (!d) {
return std::vector<GpgME::InvalidRecipient>();
}
std::vector<GpgME::InvalidRecipient> result;
result.reserve(d->invalid.size());
for (unsigned int i = 0 ; i < d->invalid.size() ; ++i) {
result.push_back(InvalidRecipient(d, i));
}
return result;
}
GpgME::InvalidRecipient::InvalidRecipient(const std::shared_ptr<EncryptionResult::Private> &parent, unsigned int i)
: d(parent), idx(i)
{
}
GpgME::InvalidRecipient::InvalidRecipient() : d(), idx(0) {}
bool GpgME::InvalidRecipient::isNull() const
{
return !d || idx >= d->invalid.size() ;
}
const char *GpgME::InvalidRecipient::fingerprint() const
{
return isNull() ? nullptr : d->invalid[idx]->fpr ;
}
GpgME::Error GpgME::InvalidRecipient::reason() const
{
return Error(isNull() ? 0 : d->invalid[idx]->reason);
}
std::ostream &GpgME::operator<<(std::ostream &os, const EncryptionResult &result)
{
os << "GpgME::EncryptionResult(";
if (!result.isNull()) {
os << "\n error: " << result.error()
<< "\n invalid recipients:\n";
const std::vector<InvalidRecipient> ir = result.invalidEncryptionKeys();
std::copy(ir.begin(), ir.end(),
std::ostream_iterator<InvalidRecipient>(os, "\n"));
}
return os << ')';
}
std::ostream &GpgME::operator<<(std::ostream &os, const InvalidRecipient &ir)
{
os << "GpgME::InvalidRecipient(";
if (!ir.isNull()) {
os << "\n fingerprint: " << protect(ir.fingerprint())
<< "\n reason: " << ir.reason()
<< '\n';
}
return os << ')';
}

View File

@ -1,117 +0,0 @@
/*
encryptionresult.h - wraps a gpgme sign result
Copyright (C) 2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_ENCRYPTIONRESULT_H__
#define __GPGMEPP_ENCRYPTIONRESULT_H__
#include "gpgmefw.h"
#include "result.h"
#include "gpgmepp_export.h"
#include <memory>
#include <vector>
#include <iosfwd>
namespace GpgME
{
class Error;
class InvalidRecipient;
class GPGMEPP_EXPORT EncryptionResult : public Result
{
public:
EncryptionResult();
EncryptionResult(gpgme_ctx_t ctx, int error);
EncryptionResult(gpgme_ctx_t ctx, const Error &error);
EncryptionResult(const Error &err);
EncryptionResult(const EncryptionResult &other) = default;
const EncryptionResult &operator=(EncryptionResult other)
{
swap(other);
return *this;
}
void swap(EncryptionResult &other)
{
Result::swap(other);
using std::swap;
swap(this->d, other.d);
}
bool isNull() const;
unsigned int numInvalidRecipients() const;
InvalidRecipient invalidEncryptionKey(unsigned int index) const;
std::vector<InvalidRecipient> invalidEncryptionKeys() const;
class Private;
private:
void init(gpgme_ctx_t ctx);
std::shared_ptr<Private> d;
};
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const EncryptionResult &result);
class GPGMEPP_EXPORT InvalidRecipient
{
friend class ::GpgME::EncryptionResult;
InvalidRecipient(const std::shared_ptr<EncryptionResult::Private> &parent, unsigned int index);
public:
InvalidRecipient();
InvalidRecipient(const InvalidRecipient &other) = default;
const InvalidRecipient &operator=(InvalidRecipient other)
{
swap(other);
return *this;
}
void swap(InvalidRecipient &other)
{
using std::swap;
swap(this->d, other.d);
}
bool isNull() const;
const char *fingerprint() const;
Error reason() const;
private:
std::shared_ptr<EncryptionResult::Private> d;
unsigned int idx;
};
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const InvalidRecipient &recipient);
}
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(EncryptionResult)
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(InvalidRecipient)
#endif // __GPGMEPP_ENCRYPTIONRESULT_H__

View File

@ -1,94 +0,0 @@
/*
engineinfo.h
Copyright (C) 2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "engineinfo.h"
#include <gpgme.h>
class GpgME::EngineInfo::Private
{
public:
Private(gpgme_engine_info_t engine = nullptr) : info(engine) {}
~Private()
{
info = nullptr;
}
gpgme_engine_info_t info;
};
GpgME::EngineInfo::EngineInfo() : d() {}
GpgME::EngineInfo::EngineInfo(gpgme_engine_info_t engine)
: d(new Private(engine))
{
}
bool GpgME::EngineInfo::isNull() const
{
return !d || !d->info;
}
GpgME::Protocol GpgME::EngineInfo::protocol() const
{
if (isNull()) {
return UnknownProtocol;
}
switch (d->info->protocol) {
case GPGME_PROTOCOL_OpenPGP: return OpenPGP;
case GPGME_PROTOCOL_CMS: return CMS;
default:
return UnknownProtocol;
}
}
const char *GpgME::EngineInfo::fileName() const
{
return isNull() ? nullptr : d->info->file_name;
}
const char *GpgME::EngineInfo::version() const
{
return isNull() ? nullptr : d->info->version;
}
GpgME::EngineInfo::Version GpgME::EngineInfo::engineVersion() const
{
return Version(version());
}
const char *GpgME::EngineInfo::requiredVersion() const
{
return isNull() ? nullptr : d->info->req_version;
}
const char *GpgME::EngineInfo::homeDirectory() const
{
return isNull() ? nullptr : d->info->home_dir;
}

View File

@ -1,255 +0,0 @@
/*
engineinfo.h
Copyright (C) 2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_ENGINEINFO_H__
#define __GPGMEPP_ENGINEINFO_H__
#include "global.h"
#include <memory>
#include <algorithm>
#include <string>
#include <iostream>
namespace GpgME
{
class GPGMEPP_EXPORT EngineInfo
{
public:
struct Version
{
int major, minor, patch;
Version()
{
major = 0;
minor = 0;
patch = 0;
}
Version(const std::string& version)
{
if (version.empty() ||
std::sscanf(version.c_str(), "%d.%d.%d", &major, &minor, &patch) != 3) {
major = 0;
minor = 0;
patch = 0;
}
}
Version(const char *version)
{
if (!version ||
std::sscanf(version, "%d.%d.%d", &major, &minor, &patch) != 3) {
major = 0;
minor = 0;
patch = 0;
}
}
bool operator < (const Version& other) const
{
if (major > other.major ||
(major == other.major && minor > other.minor) ||
(major == other.major && minor == other.minor && patch > other.patch) ||
(major >= other.major && minor >= other.minor && patch >= other.patch)) {
return false;
}
return true;
}
bool operator < (const char* other) const
{
return operator<(Version(other));
}
bool operator <= (const Version &other) const
{
return !operator>(other);
}
bool operator <= (const char *other) const
{
return operator<=(Version(other));
}
bool operator > (const char* other) const
{
return operator>(Version(other));
}
bool operator > (const Version & other) const
{
return !operator<(other) && !operator==(other);
}
bool operator >= (const Version &other) const
{
return !operator<(other);
}
bool operator >= (const char *other) const
{
return operator>=(Version(other));
}
bool operator == (const Version& other) const
{
return major == other.major
&& minor == other.minor
&& patch == other.patch;
}
bool operator == (const char* other) const
{
return operator==(Version(other));
}
bool operator != (const Version &other) const
{
return !operator==(other);
}
bool operator != (const char *other) const
{
return operator!=(Version(other));
}
// the non-const overloads of the comparison operators are kept for
// binary compatibility
bool operator < (const Version& other)
{
if (major > other.major ||
(major == other.major && minor > other.minor) ||
(major == other.major && minor == other.minor && patch > other.patch) ||
(major >= other.major && minor >= other.minor && patch >= other.patch)) {
return false;
}
return true;
}
bool operator < (const char* other)
{
return operator<(Version(other));
}
bool operator <= (const Version &other)
{
return !operator>(other);
}
bool operator <= (const char *other)
{
return operator<=(Version(other));
}
bool operator > (const char* other)
{
return operator>(Version(other));
}
bool operator > (const Version & other)
{
return !operator<(other) && !operator==(other);
}
bool operator >= (const Version &other)
{
return !operator<(other);
}
bool operator >= (const char *other)
{
return operator>=(Version(other));
}
bool operator == (const Version& other)
{
return major == other.major
&& minor == other.minor
&& patch == other.patch;
}
bool operator == (const char* other)
{
return operator==(Version(other));
}
bool operator != (const Version &other)
{
return !operator==(other);
}
bool operator != (const char *other)
{
return operator!=(Version(other));
}
friend std::ostream& operator << (std::ostream& stream, const Version& ver)
{
stream << ver.major;
stream << '.';
stream << ver.minor;
stream << '.';
stream << ver.patch;
return stream;
}
};
EngineInfo();
explicit EngineInfo(gpgme_engine_info_t engine);
EngineInfo(const EngineInfo &other) = default;
const EngineInfo &operator=(EngineInfo other)
{
swap(other);
return *this;
}
void swap(EngineInfo &other)
{
using std::swap;
swap(this->d, other.d);
}
bool isNull() const;
Protocol protocol() const;
const char *fileName() const;
const char *version() const;
Version engineVersion() const;
const char *requiredVersion() const;
const char *homeDirectory() const;
private:
class Private;
std::shared_ptr<Private> d;
};
}
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(EngineInfo)
#endif // __GPGMEPP_ENGINEINFO_H__

View File

@ -1,84 +0,0 @@
/*
error.h - wraps a gpgme error
Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// -*- c++ -*-
#ifndef __GPGMEPP_ERROR_H__
#define __GPGMEPP_ERROR_H__
#include "global.h"
#include <string>
#include <iosfwd>
#include <gpg-error.h>
#ifndef GPGMEPP_ERR_SOURCE_DEFAULT
# define GPGMEPP_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1
#endif
namespace GpgME
{
class GPGMEPP_EXPORT Error
{
public:
Error() : mErr(0), mMessage() {}
explicit Error(unsigned int e) : mErr(e), mMessage() {}
const char *source() const;
/* This function is deprecated. Use asStdString() instead. asString() may
* return wrongly encoded (i.e. not UTF-8) results on Windows for the main
* thread if the function was first called from a secondary thread. */
GPGMEPP_DEPRECATED const char *asString() const;
std::string asStdString() const;
int code() const;
int sourceID() const;
bool isCanceled() const;
unsigned int encodedError() const
{
return mErr;
}
int toErrno() const;
static bool hasSystemError();
static Error fromSystemError(unsigned int src = GPGMEPP_ERR_SOURCE_DEFAULT);
static void setSystemError(gpg_err_code_t err);
static void setErrno(int err);
static Error fromErrno(int err, unsigned int src = GPGMEPP_ERR_SOURCE_DEFAULT);
static Error fromCode(unsigned int err, unsigned int src = GPGMEPP_ERR_SOURCE_DEFAULT);
GPGMEPP_MAKE_SAFE_BOOL_OPERATOR(mErr &&!isCanceled())
private:
unsigned int mErr;
mutable std::string mMessage;
};
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Error &err);
} // namespace GpgME
#endif /* __GPGMEPP_ERROR_H__ */

View File

@ -1,205 +0,0 @@
/*
eventloopinteractor.cpp
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <eventloopinteractor.h>
#include <context.h>
#include "context_p.h"
#include <key.h>
#include <trustitem.h>
#include <gpgme.h>
#include <vector>
using std::vector;
#ifndef NDEBUG
# include <iostream>
#endif
#include <cassert>
namespace GpgME
{
//
// EventLoopInteractor::Private Declaration
//
class EventLoopInteractor::Private
{
public:
struct OneFD {
OneFD(int aFd, int aDir, gpgme_io_cb_t aFnc,
void *aFncData, void *aExternalTag)
: fd(aFd), dir(aDir), fnc(aFnc),
fncData(aFncData), externalTag(aExternalTag) {}
int fd;
int dir;
gpgme_io_cb_t fnc;
void *fncData;
void *externalTag;
};
vector<OneFD *> mCallbacks;
static void removeIOCb(void *tag);
static gpgme_error_t registerIOCb(void *data, int fd, int dir,
gpgme_io_cb_t fnc, void *fnc_data,
void **r_tag);
static void eventIOCb(void *, gpgme_event_io_t type, void *type_data);
static const gpgme_io_cbs iocbs;
};
const gpgme_io_cbs EventLoopInteractor::Private::iocbs = {
&EventLoopInteractor::Private::registerIOCb,
nullptr,
&EventLoopInteractor::Private::removeIOCb,
&EventLoopInteractor::Private::eventIOCb,
nullptr
};
//
// EventLoopInteractor::Private IO Callback Implementations
//
gpgme_error_t EventLoopInteractor::Private::registerIOCb(void *, int fd, int dir,
gpgme_io_cb_t fnc, void *fnc_data,
void **r_tag)
{
assert(instance()); assert(instance()->d);
bool ok = false;
void *etag = instance()->registerWatcher(fd, dir ? Read : Write, ok);
if (!ok) {
return gpgme_error(GPG_ERR_GENERAL);
}
instance()->d->mCallbacks.push_back(new OneFD(fd, dir, fnc, fnc_data, etag));
if (r_tag) {
*r_tag = instance()->d->mCallbacks.back();
}
return GPG_ERR_NO_ERROR;
}
void EventLoopInteractor::Private::removeIOCb(void *tag)
{
if (!instance() || !instance()->d) {
return;
}
for (vector<OneFD *>::iterator it = instance()->d->mCallbacks.begin();
it != instance()->d->mCallbacks.end() ; ++it) {
if (*it == tag) {
instance()->unregisterWatcher((*it)->externalTag);
delete *it; *it = nullptr;
instance()->d->mCallbacks.erase(it);
return;
}
}
}
void EventLoopInteractor::Private::eventIOCb(void *data, gpgme_event_io_t type, void *type_data)
{
assert(instance());
Context *ctx = static_cast<Context *>(data);
switch (type) {
case GPGME_EVENT_START: {
instance()->operationStartEvent(ctx);
// TODO: what's in type_data?
}
break;
case GPGME_EVENT_DONE: {
gpgme_error_t e = *static_cast<gpgme_error_t *>(type_data);
if (ctx && ctx->impl()) {
ctx->impl()->lasterr = e;
}
instance()->operationDoneEvent(ctx, Error(e));
}
break;
case GPGME_EVENT_NEXT_KEY: {
gpgme_key_t key = static_cast<gpgme_key_t>(type_data);
instance()->nextKeyEvent(ctx, Key(key, false));
}
break;
case GPGME_EVENT_NEXT_TRUSTITEM: {
gpgme_trust_item_t item = static_cast<gpgme_trust_item_t>(type_data);
instance()->nextTrustItemEvent(ctx, TrustItem(item));
gpgme_trust_item_unref(item);
}
break;
default: // warn
;
}
}
//
// EventLoopInteractor Implementation
//
EventLoopInteractor *EventLoopInteractor::mSelf = nullptr;
EventLoopInteractor::EventLoopInteractor() : d(new Private)
{
assert(!mSelf);
mSelf = this;
}
EventLoopInteractor::~EventLoopInteractor()
{
// warn if there are still callbacks registered
mSelf = nullptr;
delete d;
}
void EventLoopInteractor::manage(Context *context)
{
if (!context || context->managedByEventLoopInteractor()) {
return;
}
gpgme_io_cbs *iocbs = new gpgme_io_cbs(Private::iocbs);
iocbs->event_priv = context;
context->installIOCallbacks(iocbs);
}
void EventLoopInteractor::unmanage(Context *context)
{
if (context) {
context->uninstallIOCallbacks();
}
}
void EventLoopInteractor::actOn(int fd, Direction dir)
{
for (vector<Private::OneFD *>::const_iterator it = d->mCallbacks.begin();
it != d->mCallbacks.end() ; ++it) {
if ((*it)->fd == fd && ((*it)->dir ? Read : Write) == dir) {
(*((*it)->fnc))((*it)->fncData, fd);
break;
}
}
}
} // namespace GpgME

View File

@ -1,158 +0,0 @@
/*
eventloopinteractor.h
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// -*- c++ -*-
#ifndef __GPGMEPP_EVENTLOOPINTERACTOR_H__
#define __GPGMEPP_EVENTLOOPINTERACTOR_H__
#include "gpgmepp_export.h"
namespace GpgME
{
class Context;
class Error;
class TrustItem;
class Key;
/*! \file eventloopinteractor.h
\brief Abstract base class for gpgme's external event loop support
This class does most of the work involved with hooking GpgME++
up with external event loops, such as the GTK or Qt ones.
It actually provides two interfaces: An interface to the gpgme
IO Callback handling and one for gpgme events. The IO Callback
interface consists of the three methods \c actOn(), \c
registerWatcher() and \c unregisterWatcher(). The event
interface consists of the three methods \c nextTrustItemEvent(),
\c nextKeyEvent() and \c operationDoneEvent().
\sect General Usage
\c EventLoopInteractor is designed to be used as a
singleton. However, in order to make any use of it, you have to
subclass it and reimplement it's pure virtual methods (see
below). We suggest you keep the constructor protected and
provide a static \c instance() method that returns the single
instance. Alternatively, you can create an instance on the
stack, e.g. in \c main().
If you want \c EventLoopInteractor to manage a particular \c
Context, just call \c manage() on the \c Context. OTOH, if you
want to disable IO callbacks for a \c Context, use \c unmanage().
\sect IO Callback Interface
One part of this interface is represented by \c
registerWatcher() and \c unregisterWatcher(), both of which are
pure virtual. \c registerWatcher() should do anything necessary
to hook up watching of file descriptor \c fd for reading (\c dir
= \c Read) or writing (\c dir = Write) to the event loop you use
and return a tag identifying that particular watching process
uniquely. This could be the index into an array of objects you
use for that purpose or the address of such an object. E.g. in
Qt, you'd essentially just create a new \c QSocketNotifier:
\verbatim
void * registerWatcher( int fd, Direction dir ) {
return new QSocketNotifier( fd, dir == Read ? QSocketNotifier::Read : QSocketNotifier::Write );
// misses connecting to the activated() signal...
}
\endverbatim
which uses the address of the created object as unique tag. The
tag returned by \c registerWatcher is stored by \c
EventLoopInteractor and passed as argument to \c
unregisterWatcher(). So, in the picture above, you'd implement \c
unregisterWatcher() like this:
\verbatim
void unregisterWatcher( void * tag ) {
delete static_cast<QSocketNotifier*>( tag );
}
\endverbatim
The other part of the IO callback interface is \c actOn(), which
you should call if you receive notification from your event loop
about activity on file descriptor \c fd in direction \c dir. In
the picture above, you'd call this from the slot connected to
the socket notifier's \c activated() signal.
\note \c registerWatcher() as well as \c unregisterWatcher() may
be called from within \c actOn(), so be careful with
e.g. locking in threaded environments and keep in mind that the
object you used to find the \c fd and \c dir fo the \c actOn()
call might be deleted when \c actOn() returns!
\sect Event Handler Interface
*/
class GPGMEPP_EXPORT EventLoopInteractor
{
protected:
EventLoopInteractor();
public:
virtual ~EventLoopInteractor();
static EventLoopInteractor *instance()
{
return mSelf;
}
void manage(Context *context);
void unmanage(Context *context);
enum Direction { Read, Write };
protected:
//
// IO Notification Interface
//
/** Call this if your event loop detected activity on file
descriptor fd, with direction dir */
void actOn(int fd, Direction dir);
virtual void *registerWatcher(int fd, Direction dir, bool &ok) = 0;
virtual void unregisterWatcher(void *tag) = 0;
//
// Event Handler Interface
//
virtual void operationStartEvent(Context *context) = 0;
virtual void nextTrustItemEvent(Context *context, const TrustItem &item) = 0;
virtual void nextKeyEvent(Context *context, const Key &key) = 0;
virtual void operationDoneEvent(Context *context, const Error &e) = 0;
private:
class Private;
friend class Private;
Private *const d;
static EventLoopInteractor *mSelf;
};
}
#endif // __GPGMEPP_EVENTLOOPINTERACTOR_H__

View File

@ -1,64 +0,0 @@
/*
exception.cpp - exception wrapping a gpgme error
Copyright (C) 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// -*- c++ -*-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "exception.h"
#include <gpgme.h>
#include <sstream>
using namespace GpgME;
using namespace std; // only safe b/c it's so small a file!
Exception::~Exception() throw() {}
// static
string Exception::make_message(const Error &err, const string &msg)
{
return make_message(err, msg, NoOptions);
}
// static
string Exception::make_message(const Error &err, const string &msg, Options opt)
{
if (opt & MessageOnly) {
return msg;
}
char error_string[128];
error_string[0] = '\0';
gpgme_strerror_r(err.encodedError(), error_string, sizeof error_string);
error_string[sizeof error_string - 1] = '\0';
stringstream ss;
ss << gpgme_strsource(err.encodedError()) << ": ";
if (!msg.empty()) {
ss << msg << ": ";
}
ss << error_string << " (" << static_cast<unsigned long>(err.encodedError()) << ')';
return ss.str();
}

View File

@ -1,70 +0,0 @@
/*
exception.h - exception wrapping a gpgme error
Copyright (C) 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// -*- c++ -*-
#ifndef __GPGMEPP_EXCEPTION_H__
#define __GPGMEPP_EXCEPTION_H__
#include "error.h"
#include <stdexcept>
#include <string>
namespace GpgME
{
class GPGMEPP_EXPORT Exception : public std::runtime_error
{
public:
enum Options {
NoOptions = 0x0,
MessageOnly = 0x1,
AllOptions = MessageOnly
};
explicit Exception(const GpgME::Error &err, const std::string &msg = std::string(), Options opt = NoOptions)
: std::runtime_error(make_message(err, msg, opt)), m_error(err), m_message(msg) {}
~Exception() throw();
Error error() const
{
return m_error;
}
const std::string &message() const
{
return m_message;
}
private:
static std::string make_message(const GpgME::Error &err, const std::string &msg);
static std::string make_message(const GpgME::Error &err, const std::string &msg, Options opt);
private:
const GpgME::Error m_error;
const std::string m_message;
};
} // namespace GpgME
#endif /* __GPGMEPP_EXCEPTION_H__ */

View File

@ -1,244 +0,0 @@
/*
global.h - global gpgme functions and enums
Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// -*- c++ -*-
#ifndef __GPGMEPP_GLOBAL_H__
#define __GPGMEPP_GLOBAL_H__
#include "gpgmefw.h"
#include "gpgmepp_export.h"
#include <iosfwd>
#include <cstring>
namespace GpgME
{
class Error;
class EngineInfo;
class Context;
}
struct _GIOChannel;
typedef struct _GIOChannel GIOChannel;
class QIODevice;
namespace GpgME
{
GPGMEPP_EXPORT void initializeLibrary();
/*!
Initializes the library, returns Error::code() ==
GPG_ERR_USER_1 if underlying gpgme is too old.
*/
GPGMEPP_EXPORT Error initializeLibrary(int);
enum Protocol { OpenPGP, CMS, UnknownProtocol };
enum Engine { GpgEngine, GpgSMEngine, GpgConfEngine, UnknownEngine, AssuanEngine, G13Engine, SpawnEngine };
enum KeyListMode {
Local = 0x1,
Extern = 0x2,
Locate = Local|Extern,
Signatures = 0x4,
SignatureNotations = 0x8,
Validate = 0x10,
Ephemeral = 0x20,
WithTofu = 0x40,
WithKeygrip = 0x80,
WithSecret = 0x100,
ForceExtern = 0x200,
LocateExternal = Locate|ForceExtern,
KeyListModeMask = 0x3ff
};
enum SignatureMode {
NormalSignatureMode = 0,
Detached = 1,
Clearsigned = 2,
SignArchive = 4,
SignFile = 8,
};
enum class RevocationReason {
Unspecified = 0,
Compromised = 1,
Superseded = 2,
NoLongerUsed = 3
};
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Protocol proto);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Engine eng);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, KeyListMode mode);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, SignatureMode mode);
GPGMEPP_EXPORT Error setDefaultLocale(int category, const char *value);
GPGMEPP_EXPORT Context *wait(Error &e, bool hang = true);
typedef void (*IdleFunction)(void);
GPGMEPP_EXPORT IdleFunction registerIdleFunction(IdleFunction idleFunction);
typedef void (*IOCallback)(void *data, int fd);
GPGMEPP_EXPORT EngineInfo engineInfo(Protocol proto);
GPGMEPP_EXPORT EngineInfo engineInfo(Engine engine);
/** Wrapper around gpgme_get_dirinfo. What can be:
homedir, sysconfdir, bindir, libexecdir, libdir,
datadir, localedir, agent-socket, agent-ssh-socket,
dirmngr-socket, uiserver-socket, gpgconf-name, gpg-name,
gpgsm-name, g13-name, keyboxd-name, agent-name, scdaemon-name,
dirmngr-name, pinentry-name, socketdir, gpg-wks-client-name, gpgtar-name.
This may be extended in the future.
*/
GPGMEPP_EXPORT const char *dirInfo(const char *what);
GPGMEPP_EXPORT Error checkEngine(Protocol proto);
GPGMEPP_EXPORT Error checkEngine(Engine engine);
/* Wrapper for gpgme_set_global_flag */
GPGMEPP_EXPORT int setGlobalFlag(const char *name, const char *value);
GPGMEPP_EXPORT GIOChannel *getGIOChannel(int fd);
GPGMEPP_EXPORT QIODevice *getQIODevice(int fd);
enum Feature {
ValidatingKeylistModeFeature = 0x00000001,
CancelOperationFeature = 0x00000002,
WrongKeyUsageFeature = 0x00000004,
DefaultCertificateInclusionFeature = 0x00000008,
GetSetEngineInfoFeature = 0x00000010,
EngineInfoHomeDirFeature = 0x00000020,
NoEncryptToEncryptionFlagFeature = 0x00000040,
EphemeralKeylistModeFeature = 0x00000080,
SetDataFileNameFeeature = 0x00000100,
VerificationResultFileNameFeature = 0x00000200,
DecryptionResultFileNameFeature = 0x00000400,
DecryptionResultRecipientsFeature = 0x00000800,
AuditLogFeature = 0x00001000,
GpgConfEngineFeature = 0x00002000,
CancelOperationAsyncFeature = 0x00004000,
AssuanEngineFeature = 0x00008000,
ClearAddGetSignatureNotationsFeature = 0x00010000,
SignatureNotationsKeylistModeFeature = 0x00020000,
KeySignatureNotationsFeature = 0x00040000,
SignatureNotationsFlagsFeature = 0x00080000,
SignatureNotationsCriticalFlagFeature = 0x00100000,
SignatureNotationsHumanReadableFlagFeature = 0x00200000,
CardKeyFeature = 0x00400000,
ImportFromKeyserverFeature = 0x00800000,
KeyIsQualifiedFeature = 0x01000200,
SubkeyIsQualifiedFeature = 0x02000000,
SignaturePkaFieldsFeature = 0x04000000,
SignatureAlgorithmFieldsFeature = 0x08000000,
FdPointerFeature = 0x10000000,
G13VFSFeature = 0x20000000,
PasswdFeature = 0x40000000, // gpgme >= 1.3.0
// unusable (max value)
FeatureMaxValue = 0x80000000
};
enum Feature2 {
BinaryAndFineGrainedIdentify = 0x00000001, // gpgme >= 1.7.0
Feature2MaxValue = 0x80000000
};
// use hasFeature( unsigned long, unsigned long ) instead
GPGMEPP_DEPRECATED_EXPORT bool hasFeature(unsigned long feature);
GPGMEPP_EXPORT bool hasFeature(unsigned long feature, unsigned long feature2);
} // namespace GpgME
# ifndef GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION
# define GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION( Class ) \
namespace std { template <> inline void swap< GpgME::Class >( GpgME::Class & lhs, GpgME::Class & rhs ) { lhs.swap( rhs ); } }
# endif
# ifndef GPGMEPP_MAKE_SAFE_BOOL_OPERATOR
# define GPGMEPP_MAKE_SAFE_BOOL_OPERATOR( Cond ) \
private: \
struct __safe_bool_dummy__ { void nonnull() {} }; \
typedef void ( __safe_bool_dummy__::*unspecified_bool_type )(); \
public: \
operator unspecified_bool_type() const { return ( Cond ) ? &__safe_bool_dummy__::nonnull : nullptr; }
# endif
inline int _gpgmepp_strcmp(const char *s1, const char *s2)
{
return s1 ? s2 ? std::strcmp(s1, s2) : 1 : s2 ? -1 : 0;
}
#define _GPGMEPP_MAKE_STRCMP( Name, expr, cmp ) \
template <template <typename U> class Op> \
struct Name { \
typedef bool result_type; \
\
bool operator()( const char * lhs, const char * rhs ) const { \
return Op<int>()( cmp, 0 ); \
} \
\
bool operator()( const std::string & lhs, const std::string & rhs ) const { \
return operator()( lhs.c_str(), rhs.c_str() ); \
} \
bool operator()( const char * lhs, const std::string & rhs ) const { \
return operator()( lhs, rhs.c_str() ); \
} \
bool operator()( const std::string & lhs, const char * rhs ) const { \
return operator()( lhs.c_str(), rhs ); \
} \
\
template <typename T> \
bool operator()( const T & lhs, const T & rhs ) const { \
return operator()( (lhs expr), (rhs expr) ); \
} \
template <typename T> \
bool operator()( const T & lhs, const char * rhs ) const { \
return operator()( (lhs expr), rhs ); \
} \
template <typename T> \
bool operator()( const char * lhs, const T & rhs ) const { \
return operator()( lhs, (rhs expr) ); \
} \
template <typename T> \
bool operator()( const T & lhs, const std::string & rhs ) const { \
return operator()( (lhs expr), rhs ); \
} \
template <typename T> \
bool operator()( const std::string & lhs, const T & rhs ) const { \
return operator()( lhs, (rhs expr) ); \
} \
}
#define GPGMEPP_MAKE_STRCMP( Name, expr ) \
_GPGMEPP_MAKE_STRCMP( Name, expr, _gpgmepp_strcmp( lhs, rhs ) )
#endif // __GPGMEPP_GLOBAL_H__

View File

@ -1,205 +0,0 @@
/*
gpgaddexistingsubkeyeditinteractor.cpp - Edit Interactor to add an existing subkey to an OpenPGP key
Copyright (c) 2022 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gpgaddexistingsubkeyeditinteractor.h"
#include "error.h"
#include <gpgme.h>
// avoid conflict (msvc)
#ifdef ERROR
# undef ERROR
#endif
using namespace GpgME;
class GpgAddExistingSubkeyEditInteractor::Private
{
enum {
START = EditInteractor::StartState,
COMMAND,
ADD_EXISTING_KEY,
KEYGRIP,
FLAGS,
VALID,
KEY_CREATED,
QUIT,
SAVE,
ERROR = EditInteractor::ErrorState
};
GpgAddExistingSubkeyEditInteractor *const q = nullptr;
public:
Private(GpgAddExistingSubkeyEditInteractor *q, const std::string &keygrip)
: q{q}
, keygrip{keygrip}
{
}
const char *action(Error &err) const;
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const;
std::string keygrip;
std::string expiry;
};
const char *GpgAddExistingSubkeyEditInteractor::Private::action(Error &err) const
{
switch (q->state()) {
case COMMAND:
return "addkey";
case ADD_EXISTING_KEY:
return "keygrip";
case KEYGRIP:
return keygrip.c_str();
case FLAGS:
return "Q"; // do not toggle any usage flags
case VALID:
return expiry.empty() ? "0" : expiry.c_str();
case QUIT:
return "quit";
case SAVE:
return "Y";
case START:
case KEY_CREATED:
case ERROR:
return nullptr;
default:
err = Error::fromCode(GPG_ERR_GENERAL);
return nullptr;
}
}
unsigned int GpgAddExistingSubkeyEditInteractor::Private::nextState(unsigned int status, const char *args, Error &err) const
{
using std::strcmp;
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
static const Error NO_KEY_ERROR = Error::fromCode(GPG_ERR_NO_KEY);
static const Error INV_TIME_ERROR = Error::fromCode(GPG_ERR_INV_TIME);
switch (q->state()) {
case START:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
case COMMAND:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.algo") == 0) {
return ADD_EXISTING_KEY;
}
err = GENERAL_ERROR;
return ERROR;
case ADD_EXISTING_KEY:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.keygrip") == 0) {
return KEYGRIP;
}
err = GENERAL_ERROR;
return ERROR;
case KEYGRIP:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.flags") == 0) {
return FLAGS;
} else if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.keygrip") == 0) {
err = NO_KEY_ERROR;
return ERROR;
}
err = GENERAL_ERROR;
return ERROR;
case FLAGS:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.valid") == 0) {
return VALID;
}
err = GENERAL_ERROR;
return ERROR;
case VALID:
if (status == GPGME_STATUS_KEY_CREATED) {
return KEY_CREATED;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
} else if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.valid") == 0) {
err = INV_TIME_ERROR;
return ERROR;
}
err = GENERAL_ERROR;
return ERROR;
case KEY_CREATED:
return QUIT;
case QUIT:
if (status == GPGME_STATUS_GET_BOOL &&
strcmp(args, "keyedit.save.okay") == 0) {
return SAVE;
}
err = GENERAL_ERROR;
return ERROR;
case ERROR:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
}
err = q->lastError();
return ERROR;
default:
err = GENERAL_ERROR;
return ERROR;
}
}
GpgAddExistingSubkeyEditInteractor::GpgAddExistingSubkeyEditInteractor(const std::string &keygrip)
: EditInteractor{}
, d{new Private{this, keygrip}}
{
}
GpgAddExistingSubkeyEditInteractor::~GpgAddExistingSubkeyEditInteractor() = default;
void GpgAddExistingSubkeyEditInteractor::setExpiry(const std::string &timeString)
{
d->expiry = timeString;
}
const char *GpgAddExistingSubkeyEditInteractor::action(Error &err) const
{
return d->action(err);
}
unsigned int GpgAddExistingSubkeyEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
{
return d->nextState(status, args, err);
}

View File

@ -1,59 +0,0 @@
/*
gpgaddexistingsubkeyeditinteractor.h - Edit Interactor to add an existing subkey to an OpenPGP key
Copyright (c) 2022 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_GPGADDEXISTINGSUBKEYEDITINTERACTOR_H__
#define __GPGMEPP_GPGADDEXISTINGSUBKEYEDITINTERACTOR_H__
#include "editinteractor.h"
#include <memory>
namespace GpgME
{
class GPGMEPP_EXPORT GpgAddExistingSubkeyEditInteractor : public EditInteractor
{
public:
/** Edit interactor to add the existing subkey with keygrip \a keygrip
* to the key a key edit operation is working on.
**/
explicit GpgAddExistingSubkeyEditInteractor(const std::string &keygrip);
~GpgAddExistingSubkeyEditInteractor() override;
/** Sets the validity period of the added subkey. Use "0" for no expiration
* or a simplified ISO date string ("yyyymmddThhmmss") for setting an
* expiration date. */
void setExpiry(const std::string &timeString);
private:
const char *action(Error &err) const override;
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
private:
class Private;
const std::unique_ptr<Private> d;
};
} // namespace GpgME
#endif // __GPGMEPP_GPGADDEXISTINGSUBKEYEDITINTERACTOR_H__

View File

@ -1,191 +0,0 @@
/*
gpgadduserideditinteractor.cpp - Edit Interactor to add a new UID to an OpenPGP key
Copyright (C) 2008 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gpgadduserideditinteractor.h"
#include "error.h"
#include <gpgme.h>
#include <cstring>
using std::strcmp;
// avoid conflict (msvc)
#ifdef ERROR
# undef ERROR
#endif
using namespace GpgME;
GpgAddUserIDEditInteractor::GpgAddUserIDEditInteractor()
: EditInteractor(),
m_name(),
m_email(),
m_comment()
{
}
GpgAddUserIDEditInteractor::~GpgAddUserIDEditInteractor() {}
void GpgAddUserIDEditInteractor::setNameUtf8(const std::string &name)
{
m_name = name;
}
void GpgAddUserIDEditInteractor::setEmailUtf8(const std::string &email)
{
m_email = email;
}
void GpgAddUserIDEditInteractor::setCommentUtf8(const std::string &comment)
{
m_comment = comment;
}
// work around --enable-final
namespace GpgAddUserIDEditInteractor_Private
{
enum {
START = EditInteractor::StartState,
COMMAND,
NAME,
EMAIL,
COMMENT,
QUIT,
SAVE,
ERROR = EditInteractor::ErrorState
};
}
const char *GpgAddUserIDEditInteractor::action(Error &err) const
{
using namespace GpgAddUserIDEditInteractor_Private;
switch (state()) {
case COMMAND:
return "adduid";
case NAME:
return m_name.c_str();
case EMAIL:
return m_email.c_str();
case COMMENT:
return m_comment.c_str();
case QUIT:
return "quit";
case SAVE:
return "Y";
case START:
case ERROR:
return nullptr;
default:
err = Error::fromCode(GPG_ERR_GENERAL);
return nullptr;
}
}
unsigned int GpgAddUserIDEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
{
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
static const Error INV_NAME_ERROR = Error::fromCode(GPG_ERR_INV_NAME);
static const Error INV_EMAIL_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
static const Error INV_COMMENT_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
using namespace GpgAddUserIDEditInteractor_Private;
switch (state()) {
case START:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
case COMMAND:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.name") == 0) {
return NAME;
}
err = GENERAL_ERROR;
return ERROR;
case NAME:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.email") == 0) {
return EMAIL;
}
err = GENERAL_ERROR;
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.name") == 0) {
err = INV_NAME_ERROR;
}
return ERROR;
case EMAIL:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.comment") == 0) {
return COMMENT;
}
err = GENERAL_ERROR;
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.email") == 0) {
err = INV_EMAIL_ERROR;
}
return ERROR;
case COMMENT:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
}
err = GENERAL_ERROR;
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.comment") == 0) {
err = INV_COMMENT_ERROR;
}
return ERROR;
case QUIT:
if (status == GPGME_STATUS_GET_BOOL &&
strcmp(args, "keyedit.save.okay") == 0) {
return SAVE;
}
err = GENERAL_ERROR;
return ERROR;
case ERROR:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
}
err = lastError();
return ERROR;
default:
err = GENERAL_ERROR;
return ERROR;
}
}

View File

@ -1,69 +0,0 @@
/*
gpgadduserideditinteractor.h - Edit Interactor to add a new UID to an OpenPGP key
Copyright (C) 2008 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_GPGADDUSERIDEDITINTERACTOR_H__
#define __GPGMEPP_GPGADDUSERIDEDITINTERACTOR_H__
#include "editinteractor.h"
#include <string>
namespace GpgME
{
class GPGMEPP_EXPORT GpgAddUserIDEditInteractor : public EditInteractor
{
public:
explicit GpgAddUserIDEditInteractor();
~GpgAddUserIDEditInteractor();
void setNameUtf8(const std::string &name);
const std::string &nameUtf8() const
{
return m_name;
}
void setEmailUtf8(const std::string &email);
const std::string &emailUtf8() const
{
return m_email;
}
void setCommentUtf8(const std::string &comment);
const std::string &commentUtf8() const
{
return m_comment;
}
private:
const char *action(Error &err) const override;
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
private:
std::string m_name, m_email, m_comment;
};
} // namespace GpgME
#endif // __GPGMEPP_GPGADDUSERIDEDITINTERACTOR_H__

View File

@ -1,123 +0,0 @@
/*
gpgagentgetinfoassuantransaction.cpp - Assuan Transaction to get information from gpg-agent
Copyright (C) 2009 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gpgagentgetinfoassuantransaction.h"
#include "error.h"
#include "data.h"
#include "util.h"
#include <assert.h>
using namespace GpgME;
GpgAgentGetInfoAssuanTransaction::GpgAgentGetInfoAssuanTransaction(InfoItem item)
: AssuanTransaction(),
m_item(item),
m_command(),
m_data()
{
}
GpgAgentGetInfoAssuanTransaction::~GpgAgentGetInfoAssuanTransaction() {}
std::string GpgAgentGetInfoAssuanTransaction::version() const
{
if (m_item == Version) {
return m_data;
} else {
return std::string();
}
}
unsigned int GpgAgentGetInfoAssuanTransaction::pid() const
{
if (m_item == Pid) {
return to_pid(m_data);
} else {
return 0U;
}
}
std::string GpgAgentGetInfoAssuanTransaction::socketName() const
{
if (m_item == SocketName) {
return m_data;
} else {
return std::string();
}
}
std::string GpgAgentGetInfoAssuanTransaction::sshSocketName() const
{
if (m_item == SshSocketName) {
return m_data;
} else {
return std::string();
}
}
static const char *const gpgagent_getinfo_tokens[] = {
"version",
"pid",
"socket_name",
"ssh_socket_name",
"scd_running",
};
void GpgAgentGetInfoAssuanTransaction::makeCommand() const
{
assert(m_item >= 0);
assert(m_item < LastInfoItem);
m_command = "GETINFO ";
m_command += gpgagent_getinfo_tokens[m_item];
}
const char *GpgAgentGetInfoAssuanTransaction::command() const
{
makeCommand();
return m_command.c_str();
}
Error GpgAgentGetInfoAssuanTransaction::data(const char *data, size_t len)
{
m_data.append(data, len);
return Error();
}
Data GpgAgentGetInfoAssuanTransaction::inquire(const char *name, const char *args, Error &err)
{
(void)name; (void)args; (void)err;
return Data::null;
}
Error GpgAgentGetInfoAssuanTransaction::status(const char *status, const char *args)
{
(void)status; (void)args;
return Error();
}

View File

@ -1,75 +0,0 @@
/*
gpgagentgetinfoassuantransaction.h - Assuan Transaction to get information from gpg-agent
Copyright (C) 2009 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_GPGAGENTGETINFOASSUANTRANSACTION_H__
#define __GPGMEPP_GPGAGENTGETINFOASSUANTRANSACTION_H__
#include "interfaces/assuantransaction.h"
#include <string>
#include <vector>
namespace GpgME
{
class GPGMEPP_EXPORT GpgAgentGetInfoAssuanTransaction : public AssuanTransaction
{
public:
enum InfoItem {
Version, // string
Pid, // unsigned long
SocketName, // string (path)
SshSocketName, // string (path)
ScdRunning, // (none, returns GPG_ERR_GENERAL when scdaemon isn't running)
//CommandHasOption, // not supported
LastInfoItem
};
explicit GpgAgentGetInfoAssuanTransaction(InfoItem item);
~GpgAgentGetInfoAssuanTransaction();
std::string version() const;
unsigned int pid() const;
std::string socketName() const;
std::string sshSocketName() const;
private:
const char *command() const;
Error data(const char *data, size_t datalen) override;
Data inquire(const char *name, const char *args, Error &err) override;
Error status(const char *status, const char *args) override;
private:
void makeCommand() const;
private:
InfoItem m_item;
mutable std::string m_command;
std::string m_data;
};
} // namespace GpgME
#endif // __GPGMEPP_GPGAGENTGETINFOASSUANTRANSACTION_H__

View File

@ -1,469 +0,0 @@
/*
gpggencardkeyinteractor.cpp - Edit Interactor to generate a key on a card
Copyright (C) 2017 by Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gpggencardkeyinteractor.h"
#include "error.h"
#include <gpgme.h>
using namespace GpgME;
class GpgGenCardKeyInteractor::Private
{
public:
Private() : keysize("2048")
{
}
std::string name, email, backupFileName, expiry, serial, keysize;
bool backup = false;
Algo algo = RSA;
std::string curve;
};
GpgGenCardKeyInteractor::~GpgGenCardKeyInteractor() = default;
GpgGenCardKeyInteractor::GpgGenCardKeyInteractor(const std::string &serial):
d(new Private)
{
d->serial = serial;
}
void GpgGenCardKeyInteractor::setNameUtf8(const std::string &name)
{
d->name = name;
}
void GpgGenCardKeyInteractor::setEmailUtf8(const std::string &email)
{
d->email = email;
}
void GpgGenCardKeyInteractor::setDoBackup(bool value)
{
d->backup = value;
}
void GpgGenCardKeyInteractor::setKeySize(int value)
{
d->keysize = std::to_string(value);
}
void GpgGenCardKeyInteractor::setExpiry(const std::string &timeStr)
{
d->expiry = timeStr;
}
std::string GpgGenCardKeyInteractor::backupFileName() const
{
return d->backupFileName;
}
void GpgGenCardKeyInteractor::setAlgo(Algo algo)
{
d->algo = algo;
}
void GpgGenCardKeyInteractor::setCurve(Curve curve)
{
if (curve == DefaultCurve) {
d->curve.clear();
} else if (curve >= 1 && curve <= LastCurve) {
d->curve = std::to_string(static_cast<int>(curve));
}
}
namespace GpgGenCardKeyInteractor_Private
{
enum {
START = EditInteractor::StartState,
DO_ADMIN,
EXPIRE,
GOT_SERIAL,
COMMAND,
NAME,
EMAIL,
COMMENT,
BACKUP,
REPLACE,
SIZE,
SIZE2,
SIZE3,
BACKUP_KEY_CREATED,
KEY_CREATED,
QUIT,
SAVE,
KEY_ATTR,
KEY_ALGO1,
KEY_ALGO2,
KEY_ALGO3,
KEY_CURVE1,
KEY_CURVE2,
KEY_CURVE3,
ERROR = EditInteractor::ErrorState
};
}
const char *GpgGenCardKeyInteractor::action(Error &err) const
{
using namespace GpgGenCardKeyInteractor_Private;
switch (state()) {
case DO_ADMIN:
return "admin";
case COMMAND:
return "generate";
case KEY_ATTR:
return "key-attr";
case KEY_ALGO1:
case KEY_ALGO2:
case KEY_ALGO3:
return d->algo == RSA ? "1" : "2";
case KEY_CURVE1:
case KEY_CURVE2:
case KEY_CURVE3:
return d->curve.empty() ? "1" : d->curve.c_str(); // default is Curve25519
case NAME:
return d->name.c_str();
case EMAIL:
return d->email.c_str();
case EXPIRE:
return d->expiry.c_str();
case BACKUP:
return d->backup ? "Y" : "N";
case REPLACE:
return "Y";
case SIZE:
case SIZE2:
case SIZE3:
return d->keysize.c_str();
case COMMENT:
return "";
case SAVE:
return "Y";
case QUIT:
return "quit";
case KEY_CREATED:
case START:
case GOT_SERIAL:
case BACKUP_KEY_CREATED:
case ERROR:
return nullptr;
default:
err = Error::fromCode(GPG_ERR_GENERAL);
return nullptr;
}
}
unsigned int GpgGenCardKeyInteractor::nextState(unsigned int status, const char *args, Error &err) const
{
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
static const Error INV_NAME_ERROR = Error::fromCode(GPG_ERR_INV_NAME);
static const Error INV_EMAIL_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
static const Error INV_COMMENT_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
using namespace GpgGenCardKeyInteractor_Private;
switch (state()) {
case START:
if (status == GPGME_STATUS_CARDCTRL &&
!d->serial.empty()) {
const std::string sArgs = args;
if (sArgs.find(d->serial) == std::string::npos) {
// Wrong smartcard
err = Error::fromCode(GPG_ERR_WRONG_CARD);
return ERROR;
} else {
printf("EditInteractor: Confirmed S/N: %s %s\n",
d->serial.c_str(), sArgs.c_str());
}
return GOT_SERIAL;
} else if (d->serial.empty()) {
return GOT_SERIAL;
}
err = GENERAL_ERROR;
return ERROR;
case GOT_SERIAL:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
return DO_ADMIN;
}
err = GENERAL_ERROR;
return ERROR;
case DO_ADMIN:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
return KEY_ATTR;
}
err = GENERAL_ERROR;
return ERROR;
// Handling for key-attr subcommand
case KEY_ATTR:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
// Happens if key attr is not yet supported.
return COMMAND;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.algo") == 0) {
return KEY_ALGO1;
}
err = GENERAL_ERROR;
return ERROR;
case KEY_ALGO1:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.size") == 0) {
return SIZE;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.curve") == 0) {
return KEY_CURVE1;
}
err = GENERAL_ERROR;
return ERROR;
case KEY_ALGO2:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.size") == 0) {
return SIZE2;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.curve") == 0) {
return KEY_CURVE2;
}
err = GENERAL_ERROR;
return ERROR;
case KEY_ALGO3:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.size") == 0) {
return SIZE3;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.curve") == 0) {
return KEY_CURVE3;
}
err = GENERAL_ERROR;
return ERROR;
case KEY_CURVE1:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.algo") == 0) {
return KEY_ALGO2;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
case KEY_CURVE2:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.algo") == 0) {
return KEY_ALGO3;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
case KEY_CURVE3:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.algo") == 0) {
return KEY_ALGO3;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
// End key-attr handling
case COMMAND:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.backup_enc") == 0) {
return BACKUP;
}
err = GENERAL_ERROR;
return ERROR;
case BACKUP:
if (status == GPGME_STATUS_GET_BOOL &&
strcmp(args, "cardedit.genkeys.replace_keys") == 0) {
return REPLACE;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.size") == 0) {
return SIZE;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.valid") == 0) {
return EXPIRE;
}
err = GENERAL_ERROR;
return ERROR;
case REPLACE:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.size") == 0) {
return SIZE;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.valid") == 0) {
return EXPIRE;
}
err = GENERAL_ERROR;
return ERROR;
case SIZE:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.size") == 0) {
return SIZE2;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.valid") == 0) {
return EXPIRE;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.algo") == 0) {
return KEY_ALGO2;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
case SIZE2:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.size") == 0) {
return SIZE3;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.valid") == 0) {
return EXPIRE;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.genkeys.algo") == 0) {
return KEY_ALGO3;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
case SIZE3:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.valid") == 0) {
return EXPIRE;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
case EXPIRE:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.name") == 0) {
return NAME;
}
err = GENERAL_ERROR;
return ERROR;
case NAME:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.email") == 0) {
return EMAIL;
}
err = GENERAL_ERROR;
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.name") == 0) {
err = INV_NAME_ERROR;
}
return ERROR;
case EMAIL:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.comment") == 0) {
return COMMENT;
}
err = GENERAL_ERROR;
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.email") == 0) {
err = INV_EMAIL_ERROR;
}
return ERROR;
case COMMENT:
if (status == GPGME_STATUS_BACKUP_KEY_CREATED) {
std::string sArgs = args;
const auto pos = sArgs.rfind(" ");
if (pos != std::string::npos) {
d->backupFileName = sArgs.substr(pos + 1);
return BACKUP_KEY_CREATED;
}
}
if (status == GPGME_STATUS_KEY_CREATED) {
return KEY_CREATED;
}
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
}
err = GENERAL_ERROR;
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.comment") == 0) {
err = INV_COMMENT_ERROR;
}
return ERROR;
case BACKUP_KEY_CREATED:
if (status == GPGME_STATUS_KEY_CREATED) {
return KEY_CREATED;
}
err = GENERAL_ERROR;
return ERROR;
case KEY_CREATED:
return QUIT;
case QUIT:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "cardedit.prompt") == 0) {
return QUIT;
}
err = GENERAL_ERROR;
return ERROR;
case ERROR:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
}
err = lastError();
return ERROR;
default:
err = GENERAL_ERROR;
return ERROR;
}
}

View File

@ -1,95 +0,0 @@
/*
gpggencardkeyinteractor.h - Edit Interactor to generate a key on a card
Copyright (C) 2017 by Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
#define __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
#include "editinteractor.h"
#include <string>
#include <memory>
namespace GpgME
{
class GPGMEPP_EXPORT GpgGenCardKeyInteractor: public EditInteractor
{
public:
/** Edit interactor to generate a key on a smartcard.
*
* The \a serialnumber argument is intended to safeguard
* against accidentally working on the wrong smartcard.
*
* The edit interactor will fail if the card did not match.
*
* @param serialnumber: Serialnumber of the intended card.
**/
explicit GpgGenCardKeyInteractor(const std::string &serialnumber);
~GpgGenCardKeyInteractor();
/** Set the key sizes for the subkeys (default 2048) */
void setKeySize(int size);
void setNameUtf8(const std::string &name);
void setEmailUtf8(const std::string &email);
void setDoBackup(bool value);
void setExpiry(const std::string &timeString);
enum Algo {
RSA = 1,
ECC = 2,
};
void setAlgo(Algo algo);
// the enum values minus 1 have to match the indexes of the curves used by
// ask_curve() in gnupg's g10/keygen.c
enum Curve {
DefaultCurve = 0, // currently Curve25519
Curve25519 = 1,
Curve448,
NISTP256,
NISTP384,
NISTP521,
BrainpoolP256,
BrainpoolP384,
BrainpoolP512,
Secp256k1,
LastCurve = Secp256k1,
};
void setCurve(Curve curve);
std::string backupFileName() const;
private:
const char *action(Error &err) const override;
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
private:
class Private;
std::shared_ptr<Private> d;
};
} // namespace GpgME
#endif // __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__

View File

@ -1,81 +0,0 @@
/*
gpgmefw.h - Forwards declarations for gpgme (0.3 and 0.4)
Copyright (C) 2004 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_GPGMEFW_H__
#define __GPGMEPP_GPGMEFW_H__
struct gpgme_context;
typedef gpgme_context *gpgme_ctx_t;
struct gpgme_data;
typedef gpgme_data *gpgme_data_t;
struct gpgme_io_cbs;
struct _gpgme_key;
typedef struct _gpgme_key *gpgme_key_t;
struct _gpgme_trust_item;
typedef struct _gpgme_trust_item *gpgme_trust_item_t;
struct _gpgme_subkey;
typedef struct _gpgme_subkey *gpgme_sub_key_t;
struct _gpgme_user_id;
typedef struct _gpgme_user_id *gpgme_user_id_t;
struct _gpgme_key_sig;
typedef struct _gpgme_key_sig *gpgme_key_sig_t;
struct _gpgme_sig_notation;
typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
struct _gpgme_engine_info;
typedef struct _gpgme_engine_info *gpgme_engine_info_t;
struct _gpgme_op_keylist_result;
typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t;
struct _gpgme_recipient;
typedef struct _gpgme_recipient *gpgme_recipient_t;
struct gpgme_conf_opt;
typedef struct gpgme_conf_opt *gpgme_conf_opt_t;
struct gpgme_conf_comp;
typedef struct gpgme_conf_comp *gpgme_conf_comp_t;
struct gpgme_conf_arg;
typedef struct gpgme_conf_arg *gpgme_conf_arg_t;
struct _gpgme_tofu_info;
typedef struct _gpgme_tofu_info *gpgme_tofu_info_t;
struct _gpgme_op_query_swdb_result;
typedef struct _gpgme_op_query_swdb_result *gpgme_query_swdb_result_t;
struct _gpgme_revocation_key;
typedef struct _gpgme_revocation_key *gpgme_revocation_key_t;
#endif // __GPGMEPP_GPGMEFW_H__

View File

@ -1,74 +0,0 @@
/*gpgmepp_export.h - Export macros for gpgmepp
Copyright (C) 2016, by Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef GPGMEPP_EXPORT_H
#define GPGMEPP_EXPORT_H
#ifdef GPGMEPP_STATIC_DEFINE
# define GPGMEPP_EXPORT
# define GPGMEPP_NO_EXPORT
#else
# ifndef GPGMEPP_EXPORT
# ifdef BUILDING_GPGMEPP
/* We are building this library */
# ifdef WIN32
# define GPGMEPP_EXPORT __declspec(dllexport)
# else
# define GPGMEPP_EXPORT __attribute__((visibility("default")))
# endif
# else
/* We are using this library */
# ifdef WIN32
# define GPGMEPP_EXPORT __declspec(dllimport)
# else
# define GPGMEPP_EXPORT __attribute__((visibility("default")))
# endif
# endif
# endif
# ifndef GPGMEPP_NO_EXPORT
# ifdef WIN32
# define GPGMEPP_NO_EXPORT
# else
# define GPGMEPP_NO_EXPORT __attribute__((visibility("hidden")))
# endif
# endif
#endif
#ifndef GPGMEPP_DEPRECATED
# define GPGMEPP_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef GPGMEPP_DEPRECATED_EXPORT
# define GPGMEPP_DEPRECATED_EXPORT GPGMEPP_EXPORT GPGMEPP_DEPRECATED
#endif
#ifndef GPGMEPP_DEPRECATED_NO_EXPORT
# define GPGMEPP_DEPRECATED_NO_EXPORT GPGMEPP_NO_EXPORT GPGMEPP_DEPRECATED
#endif
#define DEFINE_NO_DEPRECATED 0
#if DEFINE_NO_DEPRECATED
# define GPGMEPP_NO_DEPRECATED
#endif
#endif

View File

@ -1,31 +0,0 @@
/*gpgmepp_version.h - Version macros for gpgmepp
Copyright (C) 2016, Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef GPGMEPP_VERSION_H
#define GPGMEPP_VERSION_H
#define GPGMEPP_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@"
#define GPGMEPP_VERSION_MAJOR @VERSION_MAJOR@
#define GPGMEPP_VERSION_MINOR @VERSION_MINOR@
#define GPGMEPP_VERSION_PATCH @VERSION_MICRO@
#define GPGMEPP_VERSION ((@VERSION_MAJOR@<<16)|(@VERSION_MINOR@<<8)|(@VERSION_MICRO@))
#endif

View File

@ -1,207 +0,0 @@
/*
gpgrevokekeyeditinteractor.cpp - Edit Interactor to revoke own OpenPGP keys
Copyright (c) 2022 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gpgrevokekeyeditinteractor.h"
#include "error.h"
#include <gpgme.h>
#include <vector>
// avoid conflict (msvc)
#ifdef ERROR
# undef ERROR
#endif
using namespace GpgME;
class GpgRevokeKeyEditInteractor::Private
{
enum {
START = EditInteractor::StartState,
COMMAND,
CONFIRM_REVOKING_ENTIRE_KEY,
REASON_CODE,
REASON_TEXT,
// all these free slots belong to REASON_TEXT, too; we increase state()
// by one for each line of text, so that action() is called
REASON_TEXT_DONE = REASON_TEXT + 1000,
CONFIRM_REASON,
QUIT,
CONFIRM_SAVE,
ERROR = EditInteractor::ErrorState
};
GpgRevokeKeyEditInteractor *const q = nullptr;
public:
Private(GpgRevokeKeyEditInteractor *q)
: q{q}
, reasonCode{"0"}
{
}
const char *action(Error &err) const;
unsigned int nextState(unsigned int statusCode, const char *args, Error &err);
std::string reasonCode;
std::vector<std::string> reasonLines;
int nextLine = -1;
};
const char *GpgRevokeKeyEditInteractor::Private::action(Error &err) const
{
switch (const auto state = q->state()) {
case COMMAND:
return "revkey";
case CONFIRM_REVOKING_ENTIRE_KEY:
return "Y";
case REASON_CODE:
return reasonCode.c_str();
case REASON_TEXT_DONE:
return "";
case CONFIRM_REASON:
return "Y";
case QUIT:
return "quit";
case CONFIRM_SAVE:
return "Y";
case START:
return nullptr;
default:
if (state >= REASON_TEXT && state < REASON_TEXT_DONE) {
return reasonLines[nextLine].c_str();
}
// fall through
case ERROR:
err = Error::fromCode(GPG_ERR_GENERAL);
return nullptr;
}
}
unsigned int GpgRevokeKeyEditInteractor::Private::nextState(unsigned int status, const char *args, Error &err)
{
using std::strcmp;
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
switch (const auto state = q->state()) {
case START:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
case COMMAND:
if (status == GPGME_STATUS_GET_BOOL &&
strcmp(args, "keyedit.revoke.subkey.okay") == 0) {
return CONFIRM_REVOKING_ENTIRE_KEY;
}
err = GENERAL_ERROR;
return ERROR;
case CONFIRM_REVOKING_ENTIRE_KEY:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "ask_revocation_reason.code") == 0) {
return REASON_CODE;
}
err = GENERAL_ERROR;
return ERROR;
case REASON_CODE:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "ask_revocation_reason.text") == 0) {
nextLine++;
return static_cast<std::size_t>(nextLine) < reasonLines.size() ? REASON_TEXT : REASON_TEXT_DONE;
}
err = GENERAL_ERROR;
return ERROR;
default:
if (state >= REASON_TEXT && state < REASON_TEXT_DONE) {
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "ask_revocation_reason.text") == 0) {
nextLine++;
return static_cast<std::size_t>(nextLine) < reasonLines.size() ? state + 1 : REASON_TEXT_DONE;
}
}
err = GENERAL_ERROR;
return ERROR;
case REASON_TEXT_DONE:
if (status == GPGME_STATUS_GET_BOOL &&
strcmp(args, "ask_revocation_reason.okay") == 0) {
return CONFIRM_REASON;
}
err = GENERAL_ERROR;
return ERROR;
case CONFIRM_REASON:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
}
err = GENERAL_ERROR;
return ERROR;
case QUIT:
if (status == GPGME_STATUS_GET_BOOL &&
strcmp(args, "keyedit.save.okay") == 0) {
return CONFIRM_SAVE;
}
err = GENERAL_ERROR;
return ERROR;
case ERROR:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
}
err = q->lastError();
return ERROR;
}
}
GpgRevokeKeyEditInteractor::GpgRevokeKeyEditInteractor()
: EditInteractor{}
, d{new Private{this}}
{
}
GpgRevokeKeyEditInteractor::~GpgRevokeKeyEditInteractor() = default;
void GpgRevokeKeyEditInteractor::setReason(RevocationReason reason, const std::vector<std::string> &description)
{
d->reasonCode = std::to_string(static_cast<int>(reason));
d->reasonLines = description;
}
const char *GpgRevokeKeyEditInteractor::action(Error &err) const
{
return d->action(err);
}
unsigned int GpgRevokeKeyEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
{
return d->nextState(status, args, err);
}

View File

@ -1,62 +0,0 @@
/*
gpgrevokekeyeditinteractor.h - Edit Interactor to revoke own OpenPGP keys
Copyright (c) 2022 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_GPGREVOKEKEYEDITINTERACTOR_H__
#define __GPGMEPP_GPGREVOKEKEYEDITINTERACTOR_H__
#include "editinteractor.h"
#include "global.h"
#include <memory>
#include <vector>
namespace GpgME
{
/** Edit interactor to revoke the key a key edit operation is working on.
* Supports revocation of own keys only. */
class GPGMEPP_EXPORT GpgRevokeKeyEditInteractor : public EditInteractor
{
public:
GpgRevokeKeyEditInteractor();
~GpgRevokeKeyEditInteractor() override;
/** Sets the reason for the revocation. The reason defaults to \c Unspecified.
* \a description can be used for adding a comment for the revocation. The
* individual elements of \a description must be non-empty strings and they
* must not contain any endline characters.
*/
void setReason(RevocationReason reason, const std::vector<std::string> &description = {});
private:
const char *action(Error &err) const override;
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
private:
class GPGMEPP_NO_EXPORT Private;
const std::unique_ptr<Private> d;
};
} // namespace GpgME
#endif // __GPGMEPP_GPGREVOKEKEYEDITINTERACTOR_H__

View File

@ -1,143 +0,0 @@
/*
gpgsetexpirytimeeditinteractor.cpp - Edit Interactor to change the expiry time of an OpenPGP key
Copyright (C) 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gpgsetexpirytimeeditinteractor.h"
#include "error.h"
#include <gpgme.h>
#include <cstring>
using std::strcmp;
// avoid conflict (msvc)
#ifdef ERROR
# undef ERROR
#endif
using namespace GpgME;
GpgSetExpiryTimeEditInteractor::GpgSetExpiryTimeEditInteractor(const std::string &t)
: EditInteractor(),
m_strtime(t)
{
}
GpgSetExpiryTimeEditInteractor::~GpgSetExpiryTimeEditInteractor() {}
// work around --enable-final
namespace GpgSetExpiryTimeEditInteractor_Private
{
enum {
START = EditInteractor::StartState,
COMMAND,
DATE,
QUIT,
SAVE,
ERROR = EditInteractor::ErrorState
};
}
const char *GpgSetExpiryTimeEditInteractor::action(Error &err) const
{
using namespace GpgSetExpiryTimeEditInteractor_Private;
switch (state()) {
case COMMAND:
return "expire";
case DATE:
return m_strtime.c_str();
case QUIT:
return "quit";
case SAVE:
return "Y";
case START:
case ERROR:
return nullptr;
default:
err = Error::fromCode(GPG_ERR_GENERAL);
return nullptr;
}
}
unsigned int GpgSetExpiryTimeEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
{
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
static const Error INV_TIME_ERROR = Error::fromCode(GPG_ERR_INV_TIME);
using namespace GpgSetExpiryTimeEditInteractor_Private;
switch (state()) {
case START:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return COMMAND;
}
err = GENERAL_ERROR;
return ERROR;
case COMMAND:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.valid") == 0) {
return DATE;
}
err = GENERAL_ERROR;
return ERROR;
case DATE:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
} else if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keygen.valid")) {
err = INV_TIME_ERROR;
return ERROR;
}
err = GENERAL_ERROR;
return ERROR;
case QUIT:
if (status == GPGME_STATUS_GET_BOOL &&
strcmp(args, "keyedit.save.okay") == 0) {
return SAVE;
}
err = GENERAL_ERROR;
return ERROR;
case ERROR:
if (status == GPGME_STATUS_GET_LINE &&
strcmp(args, "keyedit.prompt") == 0) {
return QUIT;
}
err = lastError();
return ERROR;
default:
err = GENERAL_ERROR;
return ERROR;
}
}

View File

@ -1,51 +0,0 @@
/*
gpgsetexpirytimeeditinteractor.h - Edit Interactor to change the expiry time of an OpenPGP key
Copyright (C) 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation 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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __GPGMEPP_GPGSETEXPIRYTIMEEDITINTERACTOR_H__
#define __GPGMEPP_GPGSETEXPIRYTIMEEDITINTERACTOR_H__
#include "editinteractor.h"
#include <string>
namespace GpgME
{
class GPGMEPP_EXPORT GpgSetExpiryTimeEditInteractor : public EditInteractor
{
public:
explicit GpgSetExpiryTimeEditInteractor(const std::string &timeString = "0");
~GpgSetExpiryTimeEditInteractor();
private:
const char *action(Error &err) const override;
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
private:
const std::string m_strtime;
};
} // namespace GpgME
#endif // __GPGMEPP_GPGSETEXPIRYTIMEEDITINTERACTOR_H___

Some files were not shown because too many files have changed in this diff Show More