X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tfc_error.c;h=ad14e7d0bc23eca1cf7b97230738f628fa8c75e2;hb=e16562d4f4180c1364181c92d6d8f285f322f12c;hp=f69fdbe4ed0bf0800fcad4a101f14a3633f6a4e3;hpb=cd6f1f9a84c17dbdf6ab320a04eae300502b898d;p=tfcrypt.git diff --git a/tfc_error.c b/tfc_error.c index f69fdbe..ad14e7d 100644 --- a/tfc_error.c +++ b/tfc_error.c @@ -28,18 +28,20 @@ #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); if (statline_was_shown == YES && do_statline_dynamic == YES) tfc_esay("\n"); - tfc_nfsay(stderr, "%s: ", progname); + tfc_nfsay(stderr, "%s: ", tfc_format_pid(progname)); tfc_vfsay(stderr, NO, fmt, ap); if (errno && noerrno == NO) { s = strerror(errno); @@ -49,9 +51,14 @@ void xerror(tfc_yesno noexit, tfc_yesno noerrno, tfc_yesno nostats, const char * 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; @@ -62,12 +69,16 @@ _ex: void xexit(int status) { - xclose(sfd); + if (status > 1) goto _do_clean_and_exit; + 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); + +_do_clean_and_exit: + xclose(sfd); xclose(dfd); memset(srcblk, 0, sizeof(srcblk)); @@ -91,6 +102,7 @@ void xexit(int status) memset(pwdask, 0, sizeof(pwdask)); memset(pwdagain, 0, sizeof(pwdagain)); + if (xexit_no_nl == NO) tfc_esay("\n"); exit(status); } @@ -98,6 +110,8 @@ void usage(void) { 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) { @@ -313,6 +327,8 @@ void usage(void) tfc_say(" statless: emit less information in status line (only processed data)."); tfc_say(" norepeat: do not ask for any possible password confirmations."); tfc_say(" showsecrets: show passwords in plaintext instead of masking them."); + tfc_say(" finished: add \"finished\" word before status line when work is finished."); + tfc_say(" pid: show %s's process id near it's name in error messages, logs etc.", progname); tfc_say(" prompt=str: set main password prompts to this string."); tfc_say(" macprompt=str: set MAC password prompts to this string."); tfc_say(" shorthex: with -H, do not print printable characters, dump only hex string.");