1 /* Copyright (c) 1993-2002
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Copyright (c) 1987 Oliver Laumann
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program (see the file COPYING); if not, see
18 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 ****************************************************************
28 FILE *fp
; /* a hopefully uniq filepointer to the log file */
29 char *name
; /* the name. used to reopen, when stat fails. */
30 int opencount
; /* synchronize logfopen() and logfclose() */
31 int writecount
; /* increments at logfwrite(), counts write() and fflush() */
32 int flushcount
; /* increments at logfflush(), zeroed at logfwrite() */
33 struct stat
*st
; /* how the file looks like */
37 * open a logfile, The second argument must be NULL, when the named file
38 * is already a logfile or must be a appropriatly opened file pointer
40 * example: l = logfopen(name, islogfile(name) : NULL ? fopen(name, "a"));
42 struct logfile
*logfopen
__P((char *name
, FILE *fp
));
45 * lookup a logfile by name. This is useful, so that we can provide
46 * logfopen with a nonzero second argument, exactly when needed.
47 * islogfile(NULL); returns nonzero if there are any open logfiles at all.
49 int islogfile
__P((char *name
));
52 * logfclose does free()
54 int logfclose
__P((struct logfile
*));
55 int logfwrite
__P((struct logfile
*, char *, int));
58 * logfflush should be called periodically. If no argument is passed,
59 * all logfiles are flushed, else the specified file
60 * the number of flushed filepointers is returned
62 int logfflush
__P((struct logfile
*ifany
));
65 * a reopen function may be registered here, in case you want to bring your
66 * own (more secure open), it may come along with a private data pointer.
67 * this function is called, whenever logfwrite/logfflush detect that the
68 * file has been (re)moved, truncated or changed by someone else.
69 * if you provide NULL as parameter to logreopen_register, the builtin
70 * reopen function will be reactivated.
72 void logreopen_register
__P((int (*fn
) __P((char *, int, struct logfile
*)) ));
75 * Your custom reopen function is required to reuse the exact
77 * See logfile.c for further specs and an example.
79 * lf_move_fd may help you here, if you do not have dup2(2).
80 * It closes fd and opens wantfd to access whatever fd accessed.
82 int lf_move_fd
__P((int fd
, int wantfd
));