mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
New command --decrypt-files.
Some fixes.
This commit is contained in:
parent
b3a5994235
commit
e17cd91abe
6 changed files with 111 additions and 41 deletions
77
g10/encode.c
77
g10/encode.c
|
@ -568,47 +568,46 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out )
|
|||
void
|
||||
encode_crypt_files(int nfiles, char **files, STRLIST remusr)
|
||||
{
|
||||
int rc = 0;
|
||||
int rc = 0;
|
||||
|
||||
if (opt.outfile)
|
||||
{
|
||||
if (opt.verbose)
|
||||
log_info(_("ignore --output for multiple files"));
|
||||
opt.outfile = NULL;
|
||||
}
|
||||
if (opt.outfile)
|
||||
{
|
||||
log_error(_("--output doesn't work for this command\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue