extern.h revision 137225
1300548Sadrian/*-
2300548Sadrian * Copyright (c) 1991, 1993
3300548Sadrian *	The Regents of the University of California.  All rights reserved.
4300548Sadrian *
5300548Sadrian * Redistribution and use in source and binary forms, with or without
6300548Sadrian * modification, are permitted provided that the following conditions
7300548Sadrian * are met:
8300548Sadrian * 1. Redistributions of source code must retain the above copyright
9300548Sadrian *    notice, this list of conditions and the following disclaimer.
10300548Sadrian * 2. Redistributions in binary form must reproduce the above copyright
11300548Sadrian *    notice, this list of conditions and the following disclaimer in the
12300548Sadrian *    documentation and/or other materials provided with the distribution.
13300548Sadrian * 3. All advertising materials mentioning features or use of this software
14300548Sadrian *    must display the following acknowledgement:
15300548Sadrian *	This product includes software developed by the University of
16300548Sadrian *	California, Berkeley and its contributors.
17300548Sadrian * 4. Neither the name of the University nor the names of its contributors
18300548Sadrian *    may be used to endorse or promote products derived from this software
19300548Sadrian *    without specific prior written permission.
20300548Sadrian *
21300548Sadrian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22300548Sadrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23300548Sadrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24300548Sadrian * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25300548Sadrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26300548Sadrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27300548Sadrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28300548Sadrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29300548Sadrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30300548Sadrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31300548Sadrian * SUCH DAMAGE.
32300548Sadrian *
33300548Sadrian *	@(#)extern.h	8.1 (Berkeley) 6/6/93
34300548Sadrian *
35300548Sadrian * $FreeBSD: head/usr.bin/tail/extern.h 137225 2004-11-04 19:18:19Z paul $
36300548Sadrian */
37300548Sadrian
38300548Sadrian#define	WR(p, size) do { \
39300548Sadrian	if (write(STDOUT_FILENO, p, size) != (ssize_t)size) \
40300548Sadrian		oerr(); \
41300548Sadrian	} while(0)
42300548Sadrian
43300548Sadrian#define TAILMAPLEN (4<<20)
44300548Sadrian
45300548Sadrianstruct mapinfo {
46300548Sadrian	off_t	mapoff;
47300548Sadrian	off_t	maxoff;
48300548Sadrian	size_t	maplen;
49300548Sadrian	char	*start;
50300548Sadrian	int	fd;
51300548Sadrian};
52300548Sadrian
53300548Sadrianstruct file_info {
54300548Sadrian	FILE *fp;
55300548Sadrian	char *file_name;
56300548Sadrian	struct stat st;
57300548Sadrian};
58300548Sadrian
59300548Sadriantypedef struct file_info file_info_t;
60300548Sadrian
61300548Sadrianenum STYLE { NOTSET = 0, FBYTES, FLINES, RBYTES, RLINES, REVERSE };
62300548Sadrian
63300548Sadrianvoid follow(file_info_t *, enum STYLE, off_t);
64300548Sadrianvoid forward(FILE *, enum STYLE, off_t, struct stat *);
65300548Sadrianvoid reverse(FILE *, enum STYLE, off_t, struct stat *);
66300548Sadrian
67300548Sadrianint bytes(FILE *, off_t);
68300548Sadrianint lines(FILE *, off_t);
69300548Sadrian
70300548Sadrianvoid ierr(void);
71300548Sadrianvoid oerr(void);
72300548Sadrianint mapprint(struct mapinfo *, off_t, off_t);
73300548Sadrianint maparound(struct mapinfo *, off_t);
74300548Sadrian
75300548Sadrianextern int Fflag, fflag, rflag, rval, no_files;
76300548Sadrianextern const char *fname;
77300548Sadrian