extern.h revision 160045
174462Salfred/*-
250476Speter * Copyright (c) 1991, 1993
31901Swollman *	The Regents of the University of California.  All rights reserved.
4107052Sru *
574462Salfred * Redistribution and use in source and binary forms, with or without
674462Salfred * modification, are permitted provided that the following conditions
774462Salfred * are met:
874462Salfred * 1. Redistributions of source code must retain the above copyright
974462Salfred *    notice, this list of conditions and the following disclaimer.
1074462Salfred * 2. Redistributions in binary form must reproduce the above copyright
11181344Sdfr *    notice, this list of conditions and the following disclaimer in the
12181344Sdfr *    documentation and/or other materials provided with the distribution.
13181344Sdfr * 3. All advertising materials mentioning features or use of this software
1430624Sbde *    must display the following acknowledgement:
1574462Salfred *	This product includes software developed by the University of
1674462Salfred *	California, Berkeley and its contributors.
1774462Salfred * 4. Neither the name of the University nor the names of its contributors
1874462Salfred *    may be used to endorse or promote products derived from this software
1974462Salfred *    without specific prior written permission.
2074462Salfred *
2174462Salfred * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2274462Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2374462Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2474462Salfred * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2574462Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2630624Sbde * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2774462Salfred * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2826221Swpaul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29156613Sdeischen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30156613Sdeischen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3174462Salfred * SUCH DAMAGE.
32111618Snectar *
3326221Swpaul *	@(#)extern.h	8.1 (Berkeley) 6/6/93
3427581Sbde *
3526221Swpaul * $FreeBSD: head/usr.bin/tail/extern.h 160045 2006-06-29 22:07:49Z flz $
3626221Swpaul */
37231702Sdim
3826221Swpaul#define	WR(p, size) do { \
3926221Swpaul	if (write(STDOUT_FILENO, p, size) != (ssize_t)size) \
4026221Swpaul		oerr(); \
4126221Swpaul	} while(0)
4226221Swpaul
4326221Swpaul#define TAILMAPLEN (4<<20)
4426221Swpaul
4526221Swpaulstruct mapinfo {
4626221Swpaul	off_t	mapoff;
4774870Sru	off_t	maxoff;
4874462Salfred	size_t	maplen;
4974462Salfred	char	*start;
50102147Sbde	int	fd;
5174462Salfred};
5274870Sru
5356629Sshinstruct file_info {
54150009Sstefanf	FILE *fp;
55150009Sstefanf	char *file_name;
56150009Sstefanf	struct stat st;
5774462Salfred};
5874462Salfred
59150009Sstefanftypedef struct file_info file_info_t;
6074462Salfred
6174462Salfredenum STYLE { NOTSET = 0, FBYTES, FLINES, RBYTES, RLINES, REVERSE };
6274462Salfred
6374462Salfredvoid follow(file_info_t *, enum STYLE, off_t);
6474462Salfredvoid forward(FILE *, enum STYLE, off_t, struct stat *);
6530624Sbdevoid reverse(FILE *, enum STYLE, off_t, struct stat *);
6621063Speter
6774462Salfredint bytes(FILE *, off_t);
6821063Speterint lines(FILE *, off_t);
69150009Sstefanf
70150009Sstefanfvoid ierr(void);
7174462Salfredvoid oerr(void);
7274462Salfredint mapprint(struct mapinfo *, off_t, off_t);
7374462Salfredint maparound(struct mapinfo *, off_t);
7474462Salfred
7574462Salfredextern int Fflag, fflag, qflag, rflag, rval, no_files;
7674462Salfredextern const char *fname;
7774462Salfred