Deleted Added
sdiff udiff text old ( 114433 ) new ( 126667 )
full compact
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Keith Muller of the University of California, San Diego and Lance
7 * Visser of Convex Computer Corporation.
8 *

--- 33 unchanged lines hidden (view full) ---

42 The Regents of the University of California. All rights reserved.\n";
43#endif /* not lint */
44
45#ifndef lint
46static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
47#endif /* not lint */
48#endif
49#include <sys/cdefs.h>
50__FBSDID("$FreeBSD: head/bin/dd/dd.c 114433 2003-05-01 16:58:57Z obrien $");
51
52#include <sys/param.h>
53#include <sys/stat.h>
54#include <sys/conf.h>
55#include <sys/disklabel.h>
56#include <sys/filio.h>
57#include <sys/time.h>
58

--- 40 unchanged lines hidden (view full) ---

99
100 while (files_cnt--)
101 dd_in();
102
103 dd_close();
104 exit(0);
105}
106
107static void
108setup(void)
109{
110 u_int cnt;
111 struct timeval tv;
112
113 if (in.name == NULL) {
114 in.name = "stdin";

--- 56 unchanged lines hidden (view full) ---

171 * Truncate the output file. If it fails on a type of output file
172 * that it should _not_ fail on, error out.
173 */
174 if ((ddflags & (C_OF | C_SEEK | C_NOTRUNC)) == (C_OF | C_SEEK) &&
175 out.flags & ISTRUNC)
176 if (ftruncate(out.fd, out.offset * out.dbsz) == -1)
177 err(1, "truncating %s", out.name);
178
179 /*
180 * If converting case at the same time as another conversion, build a
181 * table that does both at once. If just converting case, use the
182 * built-in tables.
183 */
184 if (ddflags & (C_LCASE | C_UCASE)) {
185 if (ddflags & (C_ASCII | C_EBCDIC)) {
186 if (ddflags & C_LCASE) {
187 for (cnt = 0; cnt <= 0377; ++cnt)
188 casetab[cnt] = tolower(ctab[cnt]);
189 } else {
190 for (cnt = 0; cnt <= 0377; ++cnt)
191 casetab[cnt] = toupper(ctab[cnt]);
192 }
193 } else {
194 if (ddflags & C_LCASE) {
195 for (cnt = 0; cnt <= 0377; ++cnt)
196 casetab[cnt] = tolower((int)cnt);
197 } else {
198 for (cnt = 0; cnt <= 0377; ++cnt)
199 casetab[cnt] = toupper((int)cnt);
200 }
201 }
202 ctab = casetab;
203 }
204
205 (void)gettimeofday(&tv, (struct timezone *)NULL);
206 st.start = tv.tv_sec + tv.tv_usec * 1e-6;
207}
208
209static void

--- 251 unchanged lines hidden ---