X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tfc_error.c;h=4d64afde69f5c3be13151e53a4e12ed6e98aecb0;hb=ef3f3a7b878b0be4da7a22a6954f378aa86561e3;hp=d74fd567c7cbe241d04395f7582376f22695cc3a;hpb=f98c367a4cf1ed9f0c6d7620e3f1988596945495;p=tfcrypt.git diff --git a/tfc_error.c b/tfc_error.c index d74fd56..4d64afd 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; @@ -64,15 +71,16 @@ void xexit(int status) { 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)); @@ -94,6 +102,7 @@ _do_clean_and_exit: memset(pwdask, 0, sizeof(pwdask)); memset(pwdagain, 0, sizeof(pwdagain)); + if (xexit_no_nl == NO) tfc_esay("\n"); exit(status); } @@ -101,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) { @@ -137,9 +148,11 @@ void usage(void) tfc_say(" -a: shortcut of -O xtime."); tfc_say(" -l length: read only these first bytes of source."); tfc_say(" -O opts: set options (comma separated list):"); + tfc_say(" ro: open all files only for reading, even those intended for writing,"); tfc_say(" sync: request a synchronous I/O for a output,"); tfc_say(" fsync: on each write() call a corresponding fsync(fd),"); tfc_say(" trunc: open(O_WRONLY) will truncate output file to zero size."); + tfc_say(" append: open(O_APPEND) will append data to output file."); tfc_say(" pad: pad incomplete (l.t. %u bytes) block with zeroes.", TFC_U(TF_BLOCK_SIZE)); tfc_say(" xtime: copy timestamps from source to destination files."); tfc_say(" gibsize: use SI units of size: 1k = 1000. Applies only to size prefixes."); @@ -151,6 +164,8 @@ void usage(void) tfc_say(" iobs=val: set IO block size value. Must not exceed %u bytes.", TFC_U(TFC_BLKSIZE)); tfc_say(" iseek=val: seek source file/device by these val bytes."); tfc_say(" oseek=val: seek destination file/device by these val bytes."); + tfc_say(" ioseek=val: seek both source and destination."); + tfc_say(" ioseek is equal to iseek and oseek."); tfc_say(" count=val: process only these val bytes, both input and output."); tfc_say(" ftrunc=val: truncate output file to these val bytes before closing it."); tfc_say(" ftrunc=tail: truncate output's tail, leaving only processed data."); @@ -303,9 +318,11 @@ void usage(void) tfc_say(" Multiple -E specifiers may be given in separate options."); tfc_say(" -o logfile: redirect all messages to logfile instead of stderr."); tfc_say(" -O opts: set options (comma separated list):"); + tfc_say(" ro: open all files only for reading, even those intended for writing,"); tfc_say(" sync: request a synchronous I/O for a output,"); tfc_say(" fsync: on each write() call a corresponding fsync(fd),"); tfc_say(" trunc: open(O_WRONLY) will truncate output file to zero size."); + tfc_say(" append: open(O_APPEND) will append data to output file."); tfc_say(" pad: pad incomplete (l.t. %u bytes) block with zeroes.", TFC_U(TF_BLOCK_SIZE)); tfc_say(" xtime: copy timestamps from source to destination files."); tfc_say(" gibsize: use SI units of size: 1k = 1000. Applies only to size prefixes."); @@ -316,6 +333,9 @@ 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(" readloops=val: when seekable source ends, reading continues from it's beginning again."); 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."); @@ -332,6 +352,8 @@ void usage(void) tfc_say(" ixctr=val: Increment initial counter by this val bytes."); tfc_say(" Internally this number is translated into number of %u byte blocks.", TFC_U(TF_BLOCK_SIZE)); tfc_say(" oseek=val: seek destination file/device by these val bytes."); + tfc_say(" ioseek=val: seek both source and destination."); + tfc_say(" ioseek is equal to iseek and oseek."); tfc_say(" count=val: process only these val bytes, both input and output."); tfc_say(" ftrunc=val: truncate output file to these val bytes before closing it."); tfc_say(" ftrunc=tail: truncate output's tail, leaving only processed data.");