From: Thomas Roessler Date: Thu, 11 Oct 2001 08:41:57 +0000 (+0000) Subject: Include C version of pgpewrap, by Wessel Dankers . X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cccd60bff65c29ef0402575a0c11bb90ccf5db10;p=neomutt Include C version of pgpewrap, by Wessel Dankers . --- diff --git a/Makefile.am b/Makefile.am index 42af40ffa..16c6ee345 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,11 +11,7 @@ endif SUBDIRS = m4 po intl doc contrib $(IMAP_SUBDIR) -if NEEDS_PGPEWRAP -bin_SCRIPTS = pgpewrap muttbug flea -else bin_SCRIPTS = muttbug flea -endif BUILT_SOURCES = keymap_defs.h @@ -63,7 +59,7 @@ CPPFLAGS=@CPPFLAGS@ -I$(includedir) non_us_sources = pgp.c pgpinvoke.c pgpkey.c pgplib.c sha1.c \ pgpmicalg.c gnupgparse.c sha1.h \ doc/language.txt doc/language50.txt OPS.PGP doc/PGP-Notes.txt \ - OPS.MIX remailer.c remailer.h pgpewrap \ + OPS.MIX remailer.c remailer.h pgpewrap.c \ contrib/pgp2.rc contrib/pgp5.rc contrib/gpg.rc \ mutt_ssl.c mutt_ssl.h README.SSL mutt_ssl_nss.c \ pgppacket.c pgppacket.h @@ -81,7 +77,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h account.h \ mx.h pager.h pgp.h pop.h protos.h reldate.h rfc1524.h rfc2047.h \ rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare \ _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ - mbyte.h lib.h extlib.c pgpewrap pgplib.h Muttrc.head Muttrc \ + mbyte.h lib.h extlib.c pgpewrap.c pgplib.h Muttrc.head Muttrc \ makedoc.c stamp-doc-rc README.SSL \ muttbug pgppacket.h depcomp ascii.h BEWARE diff --git a/configure.in b/configure.in index 8ca897fad..4bd59e5a9 100644 --- a/configure.in +++ b/configure.in @@ -72,8 +72,7 @@ else if test x$HAVE_PGP != xno ; then AC_DEFINE(HAVE_PGP) - PGPAUX_TARGET=pgpring - AM_CONDITIONAL(NEEDS_PGPEWRAP, true) + PGPAUX_TARGET="pgpring pgpewrap" MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pgp.o pgpinvoke.o pgpkey.o pgplib.o gnupgparse.o pgpmicalg.o pgppacket.o" OPS="$OPS \$(srcdir)/OPS.PGP" fi diff --git a/pgpewrap b/pgpewrap deleted file mode 100755 index 37f9facd5..000000000 --- a/pgpewrap +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -- - -cmd=$1 -pfx="" - -die() { - echo "Command line usage: $0 [flags] -- prefix [recipients]" >& 2 - exit 1 -} - -while test $# -gt 0 && shift && test -n "$1" ; do - if test "$1" = "--" ; then - shift || die - pfx="$1" - shift || die - fi - cmd="$cmd $pfx $1" -done - -exec $cmd diff --git a/pgpewrap.c b/pgpewrap.c new file mode 100644 index 000000000..0d5a1c258 --- /dev/null +++ b/pgpewrap.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +int main(int argc, char **argv) { + char **opts, **opt, *pfx; + int i; + + opts = malloc((2 * argc + 1) * sizeof (* opts)); + if(!opts) { + perror(argv[0]); + exit(2); + } + + opt = opts; + *opt++ = argv[1]; + pfx = NULL; + + for(i = 2; i < argc; ) { + if(!strcmp(argv[i], "--")) { + i += 2; + if(i > argc) { + fprintf(stderr, "Command line usage: %s [flags] -- prefix [recipients]\n", argv[0]); + return 1; + } + pfx = argv[i-1]; + } + if(pfx) + *opt++ = pfx; + *opt++ = argv[i++]; + } + *opt = NULL; + + execvp(opts[0], opts); + perror(argv[0]); + return 2; +}