diff options
Diffstat (limited to 'g10/encode.c')
-rw-r--r-- | g10/encode.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/g10/encode.c b/g10/encode.c index 3a90c3712..d2dba0fd0 100644 --- a/g10/encode.c +++ b/g10/encode.c @@ -566,16 +566,35 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out ) } void -encode_crypt_files(int argc, char **argv, STRLIST remusr) +encode_crypt_files(int nfiles, char **files, STRLIST remusr) { int rc = 0; - - while (argc--) { - print_file_status(STATUS_FILE_START, *argv, 2); - if ( (rc = encode_crypt(*argv, remusr)) ) - log_error("%s: encryption failed: %s\n", print_fname_stdin(*argv), - g10_errstr(rc) ); - write_status( STATUS_FILE_DONE ); - argv++; + + if (!nfiles) { + char line[2048]; + unsigned int lno = 0; + while ( 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); + return; + } + line[strlen(line)-1] = '\0'; + print_file_status(STATUS_FILE_START, line, 2); + if ( (rc = encode_crypt(line, remusr)) ) + log_error("%s: encryption failed: %s\n", print_fname_stdin(line), + g10_errstr(rc) ); + write_status( STATUS_FILE_DONE ); + } + } + else { + while (nfiles--) { + print_file_status(STATUS_FILE_START, *files, 2); + if ( (rc = encode_crypt(*files, remusr)) ) + log_error("%s: encryption failed: %s\n", print_fname_stdin(*files), + g10_errstr(rc) ); + write_status( STATUS_FILE_DONE ); + files++; + } } } |