diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 |
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /gpglib/import.c | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2 | |
Initial checkin
Imported from subversion report, converted to git. Updated all paths in
scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'gpglib/import.c')
| -rw-r--r-- | gpglib/import.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/gpglib/import.c b/gpglib/import.c new file mode 100644 index 0000000..b3cdd38 --- /dev/null +++ b/gpglib/import.c @@ -0,0 +1,70 @@ +/* +** Copyright 2001-2003 Double Precision, Inc. See COPYING for +** distribution information. +*/ + + +#include "config.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/time.h> + +#include "gpg.h" +#include "gpglib.h" + +#include "unicode/unicode.h" +#include "numlib/numlib.h" + +extern int libmail_gpg_stdin, libmail_gpg_stdout, libmail_gpg_stderr; +extern pid_t libmail_gpg_pid; + + +/* +** Import a key. +*/ + +int libmail_gpg_import_start(const char *gpgdir, int secret) +{ + char *argvec[5]; + + argvec[0]="gpg"; + argvec[1]="--import"; + argvec[2]="--no-tty"; + argvec[3]=0; + +#if GPG_HAS_ALLOW_SECRET_KEY_IMPORT + if (secret) + { + argvec[3]="--allow-secret-key-import"; + argvec[4]=0; + } +#endif + + if (libmail_gpg_fork(&libmail_gpg_stdin, &libmail_gpg_stdout, NULL, gpgdir, argvec) < 0) + return (-1); + return (0); +} + +int libmail_gpg_import_do(const char *p, size_t n, + int (*dump_func)(const char *, size_t, void *), + void *voidarg) +{ + if (libmail_gpg_write(p, n, dump_func, dump_func, NULL, 0, voidarg)) + { + libmail_gpg_cleanup(); + return (-1); + } + return (0); +} + +int libmail_gpg_import_finish(int (*dump_func)(const char *, size_t, void *), + void *voidarg) +{ + if (libmail_gpg_read(dump_func, dump_func, NULL, 0, voidarg)) + return (-1); + return (libmail_gpg_cleanup()); +} |
