Use intelligent screen refresh only in split regions.
[screen-lua.git] / src / logfile.h
blobc588a32a9eb22456cdc01422c494aa42a3d45739
1 /* Copyright (c) 2008, 2009
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Micah Cowan (micah@cowan.name)
5 * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
6 * Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
7 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
8 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
9 * Copyright (c) 1987 Oliver Laumann
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3, or (at your option)
14 * any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program (see the file COPYING); if not, see
23 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 ****************************************************************
27 * $Id$ GNU
30 struct logfile
32 struct logfile *next;
33 FILE *fp; /* a hopefully uniq filepointer to the log file */
34 char *name; /* the name. used to reopen, when stat fails. */
35 int opencount; /* synchronize logfopen() and logfclose() */
36 int writecount; /* increments at logfwrite(), counts write() and fflush() */
37 int flushcount; /* increments at logfflush(), zeroed at logfwrite() */
38 struct stat *st; /* how the file looks like */
42 * open a logfile, The second argument must be NULL, when the named file
43 * is already a logfile or must be a appropriatly opened file pointer
44 * otherwise.
45 * example: l = logfopen(name, islogfile(name) : NULL ? fopen(name, "a"));
47 struct logfile *logfopen __P((char *name, FILE *fp));
50 * lookup a logfile by name. This is useful, so that we can provide
51 * logfopen with a nonzero second argument, exactly when needed.
52 * islogfile(NULL); returns nonzero if there are any open logfiles at all.
54 int islogfile __P((char *name));
56 /*
57 * logfclose does free()
59 int logfclose __P((struct logfile *));
60 int logfwrite __P((struct logfile *, char *, int));
62 /*
63 * logfflush should be called periodically. If no argument is passed,
64 * all logfiles are flushed, else the specified file
65 * the number of flushed filepointers is returned
67 int logfflush __P((struct logfile *ifany));
69 /*
70 * a reopen function may be registered here, in case you want to bring your
71 * own (more secure open), it may come along with a private data pointer.
72 * this function is called, whenever logfwrite/logfflush detect that the
73 * file has been (re)moved, truncated or changed by someone else.
74 * if you provide NULL as parameter to logreopen_register, the builtin
75 * reopen function will be reactivated.
77 void logreopen_register __P((int (*fn) __P((char *, int, struct logfile *)) ));
79 /*
80 * Your custom reopen function is required to reuse the exact
81 * filedescriptor.
82 * See logfile.c for further specs and an example.
84 * lf_move_fd may help you here, if you do not have dup2(2).
85 * It closes fd and opens wantfd to access whatever fd accessed.
87 int lf_move_fd __P((int fd, int wantfd));