1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-27 01:08:15 +00:00

actions: be helpful on missing ascii-armor option

Refs #4 on github
This commit is contained in:
Mirek Kratochvil 2014-01-24 10:30:13 +01:00
parent 06378a826a
commit f2d1ba9365
3 changed files with 26 additions and 0 deletions

@ -240,6 +240,9 @@ int action_decrypt (bool armor,
sencode*M = sencode_decode (data);
if (!M) {
err ("error: could not parse input sencode");
if (!armor && envelope_lookalike (data) )
err ("notice: input looks ascii-armored, "
"try using the armor option");
return 1;
}
@ -599,6 +602,9 @@ int action_verify (bool armor, const std::string&detach,
sencode*M = sencode_decode (data);
if (!M) {
err ("error: could not parse input sencode");
if (!armor && envelope_lookalike (data) )
err ("notice: input looks ascii-armored, "
"try using the armor option");
return 1;
}
@ -821,6 +827,9 @@ int action_decrypt_verify (bool armor, bool yes,
sencode*M = sencode_decode (data);
if (!M) {
err ("error: could not parse input sencode");
if (!armor && envelope_lookalike (data) )
err ("notice: input looks ascii-armored, "
"try using the armor option");
return 1;
}
@ -1033,6 +1042,9 @@ int action_import (bool armor, bool no_action, bool yes, bool fp,
sencode*S = sencode_decode (data);
if (!S) {
err ("error: could not parse input sencode");
if (!armor && envelope_lookalike (data) )
err ("notice: input looks ascii-armored, "
"try using the armor option");
return 1;
}
@ -1301,6 +1313,9 @@ int action_import_sec (bool armor, bool no_action, bool yes, bool fp,
sencode*S = sencode_decode (data);
if (!S) {
err ("error: could not parse input sencode");
if (!armor && envelope_lookalike (data) )
err ("notice: input looks ascii-armored, "
"try using the armor option");
return 1;
}

@ -216,3 +216,8 @@ std::string envelope_format (const std::string&type,
return res;
}
}
bool envelope_lookalike (const std::string&data)
{
return data.find ("------ccr begin ") != data.npos;
}

@ -48,4 +48,10 @@ std::string envelope_format (const std::string&type,
const std::vector<std::string>& parts,
prng&rng);
/*
* guesses whether input looks like an envelope
*/
bool envelope_lookalike (const std::string&);
#endif