diff --git a/src/dj.c b/src/dj.c index 2e565ce..a20b472 100644 --- a/src/dj.c +++ b/src/dj.c @@ -47,7 +47,7 @@ struct Io{ long seek; /* bytes to seek/skip (will be 0 after skippage) (-sS) */ }; -/* To be assigned to main:fmt_output and used with output(). */ +/* To be assigned to main:fmt and used with printio(). */ static char *fmt_asv = "%d\037%d\036%d\037%d\035%d\036%d\034"; static char *fmt_human = "%d+%d > %d+%d; %d > %d\n"; @@ -142,8 +142,6 @@ Io_fdseek(struct Io *io){ assert(io->fd != STDOUT_FILENO || io->fl == write_flags); assert(io->fd != STDERR_FILENO || io->fl == write_flags); - printf("%s\n", io->fn); - if(io->seek == 0 || (!fdisstd(io->fd) && lseek(io->fd, io->seek, SEEK_SET) != -1)) return; @@ -215,7 +213,7 @@ oserr(char *s){ /* Prints statistics regarding the use of dj, particularly partially and * completely read and written records. */ static void -output(struct Io io[2], char *fmt){ +printio(char *fmt, struct Io io[2]){ fprintf(stderr, fmt, io[0].rec, io[0].prec, io[1].rec, io[1].prec, @@ -252,7 +250,7 @@ usage(char *s){ int main(int argc, char *argv[]){ int align; /* low 8b used, negative if no alignment is being done */ int count; /* 0 if dj(1) runs until no more reads are possible */ - char *fmt_output; /* == fmt_asv (default) or fmt_human (-H) */ + char *fmt; /* == fmt_asv (default) or fmt_human (-H) */ size_t i; /* side of io being modified */ struct Io io[2]; char noerror; /* 0=exits (default) 1=retries on partial reads or writes */ @@ -260,7 +258,7 @@ int main(int argc, char *argv[]){ /* Set defaults. */ align = -1; count = 0; - fmt_output = fmt_asv; + fmt = fmt_asv; noerror = 0; for(i = 0; i < 2; ++i){ io[i].bs = 1024 /* 1 KiB */; /* GNU dd(1) default; POSIX says 512B */ @@ -288,7 +286,7 @@ int main(int argc, char *argv[]){ break; return oserr(optarg); case 'n': noerror = 1; break; - case 'H': fmt_output = fmt_human; break; + case 'H': fmt = fmt_human; break; case 'a': if(optarg[0] == '\0' || optarg[1] == '\0'){ align = optarg[0]; @@ -298,7 +296,7 @@ int main(int argc, char *argv[]){ case 'c': case 'b': case 's': case 'B': case 'S': /* numbers */ if(c == 'c' && (count = parse(optarg)) >= 0) break; - i = (c >= 'A' && c <= 'Z'); /* uppercase changes output */ + i = (c >= 'A' && c <= 'Z'); c |= 0x20 /* 0b 0010 0000 */; /* (ASCII) make lowercase */ if((c == 'b' && (io[i].bs = parse(optarg)) > 0) || (c == 's' && (io[i].seek = parse(optarg)) >= 0)) @@ -336,7 +334,7 @@ int main(int argc, char *argv[]){ else if(io[0].bufuse < io[0].bs){ ++io[0].prec; fprintf(stderr, "%s: Partial read:\n\t", program_name); - output(io, fmt_output); + printio(fmt, io); if(!noerror) count = 1; if(align >= 0) @@ -365,7 +363,7 @@ int main(int argc, char *argv[]){ }else if(t > io[1].bufuse && io[1].bufuse > 0){ io[1].prec += 1; fprintf(stderr, "%s: Partial write:\n\t", program_name); - output(io, fmt_output); + printio(fmt, io); if(!noerror) count = 1; }else if(io[1].bufuse == 0 && t < io[1].bs) @@ -375,7 +373,7 @@ int main(int argc, char *argv[]){ }while(io[0].bufuse > 0); }while(count == 0 || --count > 0); - output(io, fmt_output); + printio(fmt, io); return EX_OK; }