#include "tfcrypt.h"
+enum { TFB64_STOP1 = 1, TFB64_STOPF };
+
void do_edbase64(char **fargv)
{
struct base64_decodestate dstate;
ldone = 0;
if (error_action == TFC_ERRACT_SYNC) rdpos = tfc_fdgetpos(sfd);
_again: lio = xread(sfd, pblk, lrem);
- if (lio == 0) do_stop = YES;
+ if (lio == 0) do_stop = TFB64_STOP1;
if (lio != NOSIZE) ldone += lio;
else {
if (errno != EIO && catch_all_errors != YES)
pblk = dstblk;
if (ldone == 0) {
- do_stop = TFC_STOP_FULL;
+ do_stop = TFB64_STOPF;
break;
}
lrem = ldone;
else xerror(NO, NO, NO, "%s", fargv[1]);
if (do_edcrypt == TFC_DO_ENCRYPT) {
size_t t;
- if (lread >= lblock || do_stop == TFC_STOP_FULL) {
+ if (lread >= lblock || do_stop == TFB64_STOPF) {
t = xwrite(dfd, "\n", 1);
if (t != NOSIZE) lio += t;
else lio = NOSIZE;
}
}
- if (do_edcrypt == TFC_DO_ENCRYPT && do_stop == TFC_STOP_BEGAN) {
+ if (do_edcrypt == TFC_DO_ENCRYPT && do_stop == TFB64_STOP1) {
size_t t = estate.count;
pblk = dstblk + estate.count;
base64_encode_blockend((char *)dstblk, &estate);
lrem = estate.count - t;
ldone = 0;
- do_stop = TFC_STOP_FULL;
+ do_stop = TFB64_STOPF;
goto _wagain;
}
size_t x;
do {
+ errno = 0;
x = (size_t)read(fd, data, szdata);
} while (x == NOSIZE && errno == EINTR);
size_t x;
do {
+ errno = 0;
x = (size_t)write(fd, data, szdata);
} while (x == NOSIZE && errno == EINTR);
double seconds, human_totalproc_src, human_totalproc_dst, human_wr_speed;
int src_scale_idx, dst_scale_idx, wr_speed_scale;
const char *oper_mode, *inplace;
- static tfc_yesno last, was_sigint;
+ static tfc_yesno last;
if (last == YES) return;
- if (signal == 0) last = YES;
+ if (signal == 0 || signal == -1) last = YES;
switch (do_edcrypt) {
case TFC_DO_ENCRYPT: oper_mode = "encrypted"; break;
}
if (signal == SIGINT || signal == SIGTERM) {
- if (signal == SIGINT) was_sigint = YES;
- if (do_stop == TFC_STOP_FULL) xexit(0);
- do_stop = TFC_STOP_FULL;
- status_timer = 0;
- verbose = NO;
- if (bench_timer) goto _out;
- return;
+ do_stop = YES;
}
-_out: tfc_getcurtime(¤t_time);
+ tfc_getcurtime(¤t_time);
total_time += (current_time - delta_time);
seconds = TFC_UTODSECS(current_time - delta_time);
wr_speed = delta_processed / seconds;
total_processed_src, human_totalproc_src, tfc_getscale(src_scale_idx),
wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale),
TFC_UTODSECS(current_time - delta_time));
- if (was_sigint == NO) tfc_esay("\n");
+ tfc_esay("\n");
xexit(0);
}
wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale), tfc_format_time(total_time));
}
- if ((do_statline_dynamic == NO || last == YES || signal == -1) && was_sigint == NO) tfc_esay("\n");
+ 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);
+ }
+
delta_processed = 0;
tfc_getcurtime(&delta_time);
- if (signal == SIGTSTP) {
- tfc_esay("stopping.");
- kill(getpid(), SIGSTOP);
- }
+ if (signal == SIGTSTP) kill(getpid(), SIGSTOP);
if (status_timer) setup_next_alarm(status_timer);
}
lrem = lblock = sizeof(tmpdata);
if (error_action == TFC_ERRACT_SYNC) rdpos = tfc_fdgetpos(mkfd);
_mkragain: lio = xread(mkfd, pblk, lrem);
- if (lio == 0) do_stop = YES;
+ if (lio == 0 && do_stop == NO) do_stop = YES;
if (lio != NOSIZE) ldone += lio;
else {
if (errno != EIO && catch_all_errors != YES)
lrem = lblock = blk_len_adj(maxlen, total_processed_src, blksize);
if (error_action == TFC_ERRACT_SYNC) rdpos = tfc_fdgetpos(sfd);
_ragain: lio = xread(sfd, pblk, lrem);
- if (lio == 0) do_stop = TFC_STOP_BEGAN;
+ if (lio == 0) do_stop = YES;
if (lio != NOSIZE) ldone += lio;
else {
if (errno != EIO && catch_all_errors != YES)
if (maxlen != NOFSIZE && total_processed_src >= maxlen) break;
}
- if (do_stop == TFC_STOP_FULL) goto _nomac;
-
errno = 0;
if (do_mac >= TFC_MAC_VRFY) {
if (!do_mac_file) {
memset(tmpdata, 0, sizeof(tmpdata));
}
-_nomac:
- if (verbose || status_timer || do_stop == TFC_STOP_FULL) print_crypt_status(0);
+ if (verbose || status_timer || do_stop == YES) print_crypt_status(0);
if (do_preserve_time) fcopy_matime(dfd, &s_stat);
xclose(sfd);
enum { NO, YES };
enum { TFC_ERRACT_EXIT, TFC_ERRACT_CONT, TFC_ERRACT_SYNC, TFC_ERRACT_LSYNC };
-enum { TFC_STOP_BEGAN = 1, TFC_STOP_FULL };
enum { TFC_DO_PLAIN, TFC_DO_ENCRYPT, TFC_DO_DECRYPT };
enum { TFC_MAC_DROP = -1, TFC_MAC_SIGN = 1, TFC_MAC_VRFY, TFC_MAC_JUST_VRFY };
enum { TFC_MACKEY_RAWKEY = 1, TFC_MACKEY_PASSWORD, TFC_MACKEY_FILE };