xref: /titanic_44/usr/src/cmd/tail/extern.h (revision 209e49b2ff611e7d61ff58e13756ae67f51be550)
1*209e49b2SChris Love /*
2*209e49b2SChris Love  * Copyright (c) 1991, 1993
3*209e49b2SChris Love  *	The Regents of the University of California.  All rights reserved.
4*209e49b2SChris Love  *
5*209e49b2SChris Love  * Redistribution and use in source and binary forms, with or without
6*209e49b2SChris Love  * modification, are permitted provided that the following conditions
7*209e49b2SChris Love  * are met:
8*209e49b2SChris Love  * 1. Redistributions of source code must retain the above copyright
9*209e49b2SChris Love  *    notice, this list of conditions and the following disclaimer.
10*209e49b2SChris Love  * 2. Redistributions in binary form must reproduce the above copyright
11*209e49b2SChris Love  *    notice, this list of conditions and the following disclaimer in the
12*209e49b2SChris Love  *    documentation and/or other materials provided with the distribution.
13*209e49b2SChris Love  * 4. Neither the name of the University nor the names of its contributors
14*209e49b2SChris Love  *    may be used to endorse or promote products derived from this software
15*209e49b2SChris Love  *    without specific prior written permission.
16*209e49b2SChris Love  *
17*209e49b2SChris Love  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18*209e49b2SChris Love  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*209e49b2SChris Love  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*209e49b2SChris Love  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21*209e49b2SChris Love  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*209e49b2SChris Love  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*209e49b2SChris Love  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*209e49b2SChris Love  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*209e49b2SChris Love  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*209e49b2SChris Love  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*209e49b2SChris Love  * SUCH DAMAGE.
28*209e49b2SChris Love  *
29*209e49b2SChris Love  */
30*209e49b2SChris Love 
31*209e49b2SChris Love 
32*209e49b2SChris Love #define	WR(p, size) do { \
33*209e49b2SChris Love 	if (write(STDOUT_FILENO, p, size) != (ssize_t)size) \
34*209e49b2SChris Love 		oerr(); \
35*209e49b2SChris Love 	} while (0)
36*209e49b2SChris Love 
37*209e49b2SChris Love #define	TAILMAPLEN (4<<20)
38*209e49b2SChris Love 
39*209e49b2SChris Love struct mapinfo {
40*209e49b2SChris Love 	off_t	mapoff;
41*209e49b2SChris Love 	off_t	maxoff;
42*209e49b2SChris Love 	size_t	maplen;
43*209e49b2SChris Love 	char	*start;
44*209e49b2SChris Love 	int	fd;
45*209e49b2SChris Love };
46*209e49b2SChris Love 
47*209e49b2SChris Love struct file_info {
48*209e49b2SChris Love 	FILE *fp;
49*209e49b2SChris Love 	char *file_name;
50*209e49b2SChris Love 	struct stat st;
51*209e49b2SChris Love };
52*209e49b2SChris Love 
53*209e49b2SChris Love typedef struct file_info file_info_t;
54*209e49b2SChris Love 
55*209e49b2SChris Love enum STYLE { NOTSET = 0, FBYTES, FLINES, RBYTES, RLINES, REVERSE };
56*209e49b2SChris Love 
57*209e49b2SChris Love void follow(file_info_t *, enum STYLE, off_t);
58*209e49b2SChris Love void forward(FILE *, const char *, enum STYLE, off_t, struct stat *);
59*209e49b2SChris Love void reverse(FILE *, const char *, enum STYLE, off_t, struct stat *);
60*209e49b2SChris Love 
61*209e49b2SChris Love int bytes(FILE *, const char *, off_t);
62*209e49b2SChris Love int lines(FILE *, const char *, off_t);
63*209e49b2SChris Love 
64*209e49b2SChris Love void ierr(const char *);
65*209e49b2SChris Love void oerr(void);
66*209e49b2SChris Love int mapprint(struct mapinfo *, off_t, off_t);
67*209e49b2SChris Love int maparound(struct mapinfo *, off_t);
68*209e49b2SChris Love 
69*209e49b2SChris Love extern int Fflag, fflag, qflag, rflag, rval, no_files;
70