aboutsummaryrefslogtreecommitdiffstats
path: root/g10/decrypt.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g10/decrypt.c58
1 files changed, 46 insertions, 12 deletions
diff --git a/g10/decrypt.c b/g10/decrypt.c
index df778d1ad..028815eec 100644
--- a/g10/decrypt.c
+++ b/g10/decrypt.c
@@ -1,5 +1,6 @@
/* decrypt.c - verify signed data
- * Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+ * 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -83,13 +84,14 @@ decrypt_message( const char *filename )
}
void
-decrypt_messages(int nfiles, char **files)
+decrypt_messages(int nfiles, char *files[])
{
IOBUF fp;
armor_filter_context_t afx;
progress_filter_context_t pfx;
char *p, *output = NULL;
- int rc = 0;
+ int rc=0,use_stdin=0;
+ unsigned int lno=0;
if (opt.outfile)
{
@@ -98,20 +100,53 @@ decrypt_messages(int nfiles, char **files)
}
- while (nfiles--)
+ if(!nfiles)
+ use_stdin=1;
+
+ for(;;)
{
- print_file_status(STATUS_FILE_START, *files, 3);
- output = make_outfile_name(*files);
+ char line[2048];
+ char *filename=NULL;
+
+ if(use_stdin)
+ {
+ if(fgets(line, DIM(line), stdin))
+ {
+ lno++;
+ if (!*line || line[strlen(line)-1] != '\n')
+ log_error("input line %u too long or missing LF\n", lno);
+ else
+ {
+ line[strlen(line)-1] = '\0';
+ filename=line;
+ }
+ }
+ }
+ else
+ {
+ if(nfiles)
+ {
+ filename=*files;
+ nfiles--;
+ files++;
+ }
+ }
+
+ if(filename==NULL)
+ break;
+
+ print_file_status(STATUS_FILE_START, filename, 3);
+ output = make_outfile_name(filename);
if (!output)
goto next_file;
- fp = iobuf_open(*files);
+ fp = iobuf_open(filename);
if (!fp)
{
- log_error(_("can't open `%s'\n"), print_fname_stdin(*files));
+ log_error(_("can't open `%s'\n"), print_fname_stdin(filename));
goto next_file;
}
- handle_progress (&pfx, fp, *files);
+ handle_progress (&pfx, fp, filename);
if (!opt.no_armor)
{
@@ -124,7 +159,7 @@ decrypt_messages(int nfiles, char **files)
rc = proc_packets(NULL, fp);
iobuf_close(fp);
if (rc)
- log_error("%s: decryption failed: %s\n", print_fname_stdin(*files),
+ log_error("%s: decryption failed: %s\n", print_fname_stdin(filename),
g10_errstr(rc));
p = get_last_passphrase();
set_next_passphrase(p);
@@ -134,8 +169,7 @@ decrypt_messages(int nfiles, char **files)
/* Note that we emit file_done even after an error. */
write_status( STATUS_FILE_DONE );
m_free(output);
- files++;
}
+
set_next_passphrase(NULL);
}
-