struct base64_encodestate estate;
size_t lread = 0;
- xexit_no_nl = YES;
-
sfd = 0; dfd = 1;
if (fargv[0]) {
#include "tfcrypt.h"
-tfc_yesno xexit_no_nl;
-
void xerror(tfc_yesno noexit, tfc_yesno noerrno, tfc_yesno nostats, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- if (statline_was_shown == YES && do_statline_dynamic == YES) tfc_esay("\n");
+ if (noexit == YES && (statline_was_shown == YES && do_statline_dynamic == YES)) tfc_esay("\n");
tfc_nfsay(stderr, "%s: ", tfc_format_pid(progname));
tfc_vfsay(stderr, NO, fmt, ap);
va_end(ap);
if (nostats == NO) {
- print_crypt_status(-1);
- tfc_esay("\n");
+ print_crypt_status(TFC_SIGERR);
}
- xexit_no_nl = YES;
-
_do_sil_exit:
if (noexit == YES) {
errno = 0;
memset(pwdask, 0, sizeof(pwdask));
memset(pwdagain, 0, sizeof(pwdagain));
- if (xexit_no_nl == NO) tfc_esay("\n");
exit(status);
}
{
tfc_yesno is_embedded_prog = NO;
- xexit_no_nl = YES;
-
if (optopt == 'V') {
tfc_say("tfcrypt toolkit, version %s.", _TFCRYPT_VERSION);
if (do_edcrypt != TFC_DO_PLAIN) {
static void print_crypt_status_genrnd(int signal)
{
- if (signal == SIGTERM || signal == SIGINT) {
- if (xexit_no_nl == YES) xexit_no_nl = NO;
- }
print_crypt_status(signal);
}
static void exit_sigterm_genrnd(int signal)
{
- if (xexit_no_nl == YES) xexit_no_nl = NO;
exit_sigterm(signal);
}
size_t lblock, lio, lrem;
tfc_byte *pblk;
- xexit_no_nl = YES;
-
for (x = 1; x < NSIG; x++) signal(x, SIG_IGN);
memset(&sigact, 0, sizeof(sigact));
sigact.sa_flags = SA_RESTART;
if (verbose) tfc_esay("done!");
if (verbose || status_timer) {
- print_crypt_status(0);
+ print_crypt_status(TFC_SIGSTAT);
tfc_esay("\n");
}
void exit_sigterm(int signal)
{
+ tfc_esay("\n");
xexit(0);
}
tfc_yesno finished = NO;
if (last == YES) return;
- if (signal <= 0) {
+ if (signal == TFC_SIGLAST) {
+ last = YES;
finished = YES;
- do_stop = YES; /* error path or sksum finished */
- if (signal == 0) last = YES;
}
switch (do_edcrypt) {
}
if (do_stop == NO && do_statline_dynamic == NO) tfc_esay("\n");
+ else if (signal == TFC_SIGLAST || signal == TFC_SIGERR) tfc_esay("\n");
statline_was_shown = YES;
if ((signal == SIGINT || signal == SIGTERM) && do_stop == YES) exit_sigterm(signal);
static void exit_sigterm_skein(int signal)
{
- if (xexit_no_nl == YES) xexit_no_nl = NO;
exit_sigterm(signal);
}
skein_final(hash, &sk);
if (ctr_mode == TFC_MODE_SKSUM) {
if (verbose || status_timer) {
- print_crypt_status(-1);
+ print_crypt_status(TFC_SIGSTAT);
tfc_esay("\n");
}
total_processed_src = total_processed_dst = delta_processed = 0;
int x = 0, xx;
size_t bits;
- xexit_no_nl = YES;
-
if (macbits < TF_MAX_BITS) {
bits = macbits;
goto _dothat;
break;
case 'q':
quiet = YES;
- xexit_no_nl = YES;
verbose = NO;
do_full_hexdump = NO;
status_timer = 0;
}
else if (do_mac == TFC_MAC_DROP2) total_processed_src += SKEIN_DIGEST_SIZE;
- if (verbose || status_timer || (do_stop == YES && quiet == NO)) print_crypt_status(0);
+ if (verbose || status_timer || (do_stop == YES && quiet == NO)) print_crypt_status(TFC_SIGLAST);
xexit(exitcode);
return -1;
size_t xread(int fd, void *data, size_t szdata);
size_t xwrite(int fd, const void *data, size_t szdata);
-extern tfc_yesno xexit_no_nl;
-
void xerror(tfc_yesno noexit, tfc_yesno noerrno, tfc_yesno nostats, const char *fmt, ...);
void xexit(int status);
void usage(void);
};
enum { TFC_CTR_SHOW = 1, TFC_CTR_HEAD, TFC_CTR_RAND, TFC_CTR_ZERO, TFC_CTR_SSET };
enum { TFC_NO_FTRUNC, TFC_DO_FTRUNC, TFC_FTRUNC_TAIL };
+enum { TFC_SIGLAST = -2, TFC_SIGERR = -1, TFC_SIGSTAT = 0 };
#endif