struct base64_encodestate estate;
size_t lread = 0;
+ xexit_no_nl = YES;
+
sfd = 0; dfd = 1;
if (fargv[0]) {
memset(&estate, 0, sizeof(struct base64_encodestate));
memset(&dstate, 0, sizeof(struct base64_decodestate));
- if (do_preserve_time) fcopy_matime(dfd, &s_stat);
xexit(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;
char *s;
- if (quiet) goto _ex;
+ if (quiet) goto _do_sil_exit;
va_start(ap, fmt);
va_end(ap);
- if (nostats == NO) print_crypt_status(-1);
+ if (nostats == NO) {
+ print_crypt_status(-1);
+ tfc_esay("\n");
+ }
+
+ xexit_no_nl = YES;
-_ex:
+_do_sil_exit:
if (noexit == YES) {
errno = 0;
return;
{
if (status > 1) goto _do_clean_and_exit;
- xclose(sfd);
if (do_ftrunc > TFC_NO_FTRUNC) {
if (do_ftrunc == TFC_FTRUNC_TAIL) ftrunc_dfd = total_processed_dst;
if (ftruncate(dfd, (off_t)ftrunc_dfd) == -1) xerror(YES, NO, YES, "ftruncate(%d)", dfd);
}
if (do_preserve_time) fcopy_matime(dfd, &s_stat);
- xclose(dfd);
_do_clean_and_exit:
+ xclose(sfd);
+ xclose(dfd);
+
memset(srcblk, 0, sizeof(srcblk));
memset(dstblk, 0, sizeof(dstblk));
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 (ctr_mode != TFC_MODE_PLAIN) {
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);
+ if (verbose) tfc_esay("\n");
xclose(fd);
xexit(0);
int src_scale_idx, dst_scale_idx, wri_scale_idx, wr_speed_scale;
const char *oper_mode, *inplace;
static tfc_yesno last;
+ tfc_yesno finished = NO;
if (last == YES) return;
- if (signal == 0 || signal == -1) last = YES;
+ if (signal <= 0) {
+ finished = YES;
+ do_stop = YES; /* error path or sksum finished */
+ if (signal == 0) last = YES;
+ }
switch (do_edcrypt) {
case TFC_DO_ENCRYPT: oper_mode = "encrypted"; break;
oper_mode,
total_processed_src, human_totalproc_src, tfc_getscale(src_scale_idx),
wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale), seconds);
- tfc_esay("\n");
xexit(0);
}
tfc_nfsay(stderr, "%s%s%s:"
" %s %.2f%s,"
" %.2f%s B/s @%s",
- inplace, (last && show_when_done) ? "finished: " : "", tfc_format_pid(progname),
+ inplace, (finished && show_when_done) ? "finished: " : "", tfc_format_pid(progname),
oper_mode,
human_totalproc_dst, tfc_getscale(dst_scale_idx),
human_wr_speed, tfc_getscale(wr_speed_scale), tfc_format_time(total_time));
if (ctr_mode <= TFC_MODE_PLAIN) tfc_nfsay(stderr, "%s%s%s: read: %llu (%.2f%s),"
" %s %llu (%.2f%s) bytes,"
" (%llu (%.2f%s) B/s), time %s",
- inplace, (last && show_when_done) ? "finished: " : "", tfc_format_pid(progname),
+ inplace, (finished && show_when_done) ? "finished: " : "", tfc_format_pid(progname),
total_processed_src, human_totalproc_src, tfc_getscale(src_scale_idx),
oper_mode,
total_processed_dst, human_totalproc_dst, tfc_getscale(dst_scale_idx),
" %s %s %llu (%.2f%s) bytes,"
" written %llu (%.2f%s) bytes,"
" (%llu (%.2f%s) B/s), time %s",
- inplace, (last && show_when_done) ? "finished: " : "", tfc_format_pid(progname),
+ inplace, (finished && show_when_done) ? "finished: " : "", tfc_format_pid(progname),
total_processed_src, human_totalproc_src, tfc_getscale(src_scale_idx),
tfc_modename(ctr_mode), oper_mode,
total_processed_dst, human_totalproc_dst, tfc_getscale(dst_scale_idx),
}
if (do_stop == NO && do_statline_dynamic == NO) tfc_esay("\n");
- if (last) tfc_esay("\n");
statline_was_shown = YES;
- if ((signal == SIGINT || signal == SIGTERM) && do_stop == YES) {
- tfc_esay("\n");
- exit_sigterm(signal);
- }
+ if ((signal == SIGINT || signal == SIGTERM) && do_stop == YES) exit_sigterm(signal);
delta_processed = 0;
tfc_getcurtime(&delta_time);
tfc_byte *pblk;
size_t ldone, lblock, lrem, lio;
tfc_fsize total = 0;
- tfc_yesno stop;
if (ctr_mode == TFC_MODE_SKSUM) total_processed_src = total_processed_dst = delta_processed = 0;
else skein_init(&sk, bits);
errno = 0;
- stop = NO;
+ do_stop = NO;
while (1) {
- if (stop) break;
+ if (do_stop) break;
pblk = skblk;
lblock = lrem = blk_len_adj(readto, total, TFC_BLKSIZE);
ldone = 0;
if (error_action == TFC_ERRACT_SYNC) rdpos = tfc_fdgetpos(fd);
_again: lio = xread(fd, pblk, lrem);
- if (lio == 0) stop = YES;
+ if (lio == 0) do_stop = YES;
if (lio != NOSIZE) ldone += lio;
else {
if (errno != EIO && catch_all_errors != YES) goto _fail;
skein_final(hash, &sk);
if (ctr_mode == TFC_MODE_SKSUM) {
- if (verbose || status_timer) print_crypt_status(-1);
+ if (verbose || status_timer) {
+ print_crypt_status(-1);
+ tfc_esay("\n");
+ }
total_processed_src = total_processed_dst = delta_processed = 0;
}
memset(skblk, 0, TFC_BLKSIZE);
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;
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);