aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gpgsm/t-support.h
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2003-06-05 23:20:29 +0000
committerMarcus Brinkmann <[email protected]>2003-06-05 23:20:29 +0000
commit02536bb72b884dceeaadda9364860f0649450e2e (patch)
treeafecdba3949d91312fa74bd6aa34fe898370415e /tests/gpgsm/t-support.h
parentdoc/ (diff)
downloadgpgme-02536bb72b884dceeaadda9364860f0649450e2e.tar.gz
gpgme-02536bb72b884dceeaadda9364860f0649450e2e.zip
doc/
2003-06-06 Marcus Brinkmann <[email protected]> * gpgme.texi: Change error codes to GPG_ERR_* variants. (Error Handling): Rewritten. gpgme/ 2003-06-05 Marcus Brinkmann <[email protected]> Everywhere: Use libgpg-error error codes. * Makefile.am (EXTRA_DIST): Remove mkerrors. (BUILT_SOURCES): Remove errors.c. (MOSTLYCLEANFILES): Likewise. (libgpgme_la_SOURCES): Likewise. Add error.c. (errors.c): Remove target. * mkerrors: File removed. * error.c: New file. * gpgme.h (gpgme_error_t): Change to type gpg_error_t. (gpgme_err_code_t, gpgme_err_source_t): New types. (gpgme_err_code, gpgme_err_source, gpgme_error, gpgme_err_make): New static inline functions. (gpgme_strsource, gpgme_err_code_from_errno, gpgme_err_code_to_errno, gpgme_err_make_from_errno, gpgme_error_from_errno): New prototypes. tests/ 2003-06-06 Marcus Brinkmann <[email protected]> Everywhere: Use libgpg-error error codes. * gpg/Makefile.am (noinst_HEADERS): New variable. * gpg/t-support.h: New file. * gpgsm/Makefile.am (noinst_HEADERS): New variable. * gpgsm/t-support.h: New file.
Diffstat (limited to '')
-rw-r--r--tests/gpgsm/t-support.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/gpgsm/t-support.h b/tests/gpgsm/t-support.h
new file mode 100644
index 00000000..c6470515
--- /dev/null
+++ b/tests/gpgsm/t-support.h
@@ -0,0 +1,81 @@
+/* t-support.h - Helper routines for regression tests.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2002, 2003 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ GPGME is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GPGME; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <unistd.h>
+#include <errno.h>
+
+#include <gpgme.h>
+
+#define fail_if_err(err) \
+ do \
+ { \
+ if (err) \
+ { \
+ fprintf (stderr, "%s:%d: %s: %s\n", \
+ __FILE__, __LINE__, gpg_strsource (err), \
+ gpg_strerror (err)); \
+ exit (1); \
+ } \
+ } \
+ while (0)
+
+
+void
+print_data (gpgme_data_t dh)
+{
+#define BUF_SIZE 512
+ char buf[BUF_SIZE + 1];
+ int ret;
+
+ ret = gpgme_data_seek (dh, 0, SEEK_SET);
+ if (ret)
+ fail_if_err (gpg_error_from_errno (errno));
+ while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
+ fwrite (buf, ret, 1, stdout);
+ if (ret < 0)
+ fail_if_err (gpg_error_from_errno (errno));
+}
+
+
+gpgme_error_t
+passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
+ int last_was_bad, int fd)
+{
+ write (fd, "abc\n", 4);
+ return 0;
+}
+
+
+char *
+make_filename (const char *fname)
+{
+ const char *srcdir = getenv ("srcdir");
+ char *buf;
+
+ if (!srcdir)
+ srcdir = ".";
+ buf = malloc (strlen(srcdir) + strlen(fname) + 2);
+ if (!buf)
+ exit (8);
+ strcpy (buf, srcdir);
+ strcat (buf, "/");
+ strcat (buf, fname);
+ return buf;
+}