11556Srgrimes/*-
21556Srgrimes * Copyright (c) 1991, 1993, 1994
31556Srgrimes *	The Regents of the University of California.  All rights reserved.
41556Srgrimes *
51556Srgrimes * This code is derived from software contributed to Berkeley by
61556Srgrimes * Keith Muller of the University of California, San Diego and Lance
71556Srgrimes * Visser of Convex Computer Corporation.
81556Srgrimes *
91556Srgrimes * Redistribution and use in source and binary forms, with or without
101556Srgrimes * modification, are permitted provided that the following conditions
111556Srgrimes * are met:
121556Srgrimes * 1. Redistributions of source code must retain the above copyright
131556Srgrimes *    notice, this list of conditions and the following disclaimer.
141556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
151556Srgrimes *    notice, this list of conditions and the following disclaimer in the
161556Srgrimes *    documentation and/or other materials provided with the distribution.
171556Srgrimes * 4. Neither the name of the University nor the names of its contributors
181556Srgrimes *    may be used to endorse or promote products derived from this software
191556Srgrimes *    without specific prior written permission.
201556Srgrimes *
211556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241556Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311556Srgrimes * SUCH DAMAGE.
321556Srgrimes *
331556Srgrimes *	@(#)dd.h	8.3 (Berkeley) 4/2/94
3450471Speter * $FreeBSD$
351556Srgrimes */
361556Srgrimes
371556Srgrimes/* Input/output stream state. */
381556Srgrimestypedef struct {
3951249Sgreen	u_char		*db;		/* buffer address */
4051249Sgreen	u_char		*dbp;		/* current buffer I/O address */
4151249Sgreen	/* XXX ssize_t? */
4251249Sgreen	size_t		dbcnt;		/* current buffer byte count */
4351249Sgreen	size_t		dbrcnt;		/* last read byte count */
4451249Sgreen	size_t		dbsz;		/* buffer size */
451556Srgrimes
461556Srgrimes#define	ISCHR		0x01		/* character device (warn on short) */
4762311Sgreen#define	ISPIPE		0x02		/* pipe-like (see position.c) */
4851249Sgreen#define	ISTAPE		0x04		/* tape */
4951212Sgreen#define	ISSEEK		0x08		/* valid to seek on */
5048802Sgreen#define	NOREAD		0x10		/* not readable */
5162311Sgreen#define	ISTRUNC		0x20		/* valid to ftruncate() */
5251249Sgreen	u_int		flags;
531556Srgrimes
54126690Sbde	const char	*name;		/* name */
5551249Sgreen	int		fd;		/* file descriptor */
5651249Sgreen	off_t		offset;		/* # of blocks to skip */
571556Srgrimes} IO;
581556Srgrimes
591556Srgrimestypedef struct {
60111629Smarkm	uintmax_t	in_full;	/* # of full input blocks */
61111629Smarkm	uintmax_t	in_part;	/* # of partial input blocks */
62111629Smarkm	uintmax_t	out_full;	/* # of full output blocks */
63111629Smarkm	uintmax_t	out_part;	/* # of partial output blocks */
64111629Smarkm	uintmax_t	trunc;		/* # of truncated records */
65111629Smarkm	uintmax_t	swab;		/* # of odd-length swab blocks */
66111629Smarkm	uintmax_t	bytes;		/* # of bytes written */
67126690Sbde	double		start;		/* start time of dd */
681556Srgrimes} STAT;
691556Srgrimes
701556Srgrimes/* Flags (in ddflags). */
711556Srgrimes#define	C_ASCII		0x00001
721556Srgrimes#define	C_BLOCK		0x00002
731556Srgrimes#define	C_BS		0x00004
741556Srgrimes#define	C_CBS		0x00008
751556Srgrimes#define	C_COUNT		0x00010
761556Srgrimes#define	C_EBCDIC	0x00020
771556Srgrimes#define	C_FILES		0x00040
781556Srgrimes#define	C_IBS		0x00080
791556Srgrimes#define	C_IF		0x00100
801556Srgrimes#define	C_LCASE		0x00200
811556Srgrimes#define	C_NOERROR	0x00400
821556Srgrimes#define	C_NOTRUNC	0x00800
831556Srgrimes#define	C_OBS		0x01000
841556Srgrimes#define	C_OF		0x02000
85126690Sbde#define	C_OSYNC		0x04000
86126690Sbde#define	C_PAREVEN	0x08000
87126690Sbde#define	C_PARNONE	0x100000
88126690Sbde#define	C_PARODD	0x200000
89126690Sbde#define	C_PARSET	0x400000
90126690Sbde#define	C_SEEK		0x800000
91126690Sbde#define	C_SKIP		0x1000000
92126690Sbde#define	C_SPARSE	0x2000000
93126690Sbde#define	C_SWAB		0x4000000
94126690Sbde#define	C_SYNC		0x8000000
95126690Sbde#define	C_UCASE		0x10000000
96126690Sbde#define	C_UNBLOCK	0x20000000
97133762Srwatson#define	C_FILL		0x40000000
98126667Sphk
99126690Sbde#define	C_PARITY	(C_PAREVEN | C_PARODD | C_PARNONE | C_PARSET)
100