Main Page | Class List | File List | Class Members | File Members

logfile.h

Go to the documentation of this file.
00001 /* Copyright (c) 1993-2002
00002  *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
00003  *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
00004  * Copyright (c) 1987 Oliver Laumann
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2, or (at your option)
00009  * any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program (see the file COPYING); if not, write to the
00018  * Free Software Foundation, Inc.,
00019  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
00020  *
00021  ****************************************************************
00022  * $Id: logfile.h,v 1.11 1994/05/31 12:33:27 jnweiger Exp $ FAU
00023  */
00024 
00025 struct logfile
00026 {
00027   struct logfile *next;
00028   FILE *fp;             /* a hopefully uniq filepointer to the log file */
00029   char *name;           /* the name. used to reopen, when stat fails. */
00030   int opencount;        /* synchronize logfopen() and logfclose() */
00031   int writecount;       /* increments at logfwrite(), counts write() and fflush() */
00032   int flushcount;       /* increments at logfflush(), zeroed at logfwrite() */
00033   struct stat *st;      /* how the file looks like */
00034 };
00035 
00036 /*
00037  * open a logfile, The second argument must be NULL, when the named file
00038  * is already a logfile or must be a appropriatly opened file pointer
00039  * otherwise.
00040  * example: l = logfopen(name, islogfile(name) : NULL ? fopen(name, "a"));
00041  */
00042 struct logfile *logfopen __P((char *name, FILE *fp));
00043 
00044 /*
00045  * lookup a logfile by name. This is useful, so that we can provide
00046  * logfopen with a nonzero second argument, exactly when needed. 
00047  * islogfile(NULL); returns nonzero if there are any open logfiles at all.
00048  */
00049 int islogfile __P((char *name));
00050 
00051 /* 
00052  * logfclose does free()
00053  */
00054 int logfclose __P((struct logfile *));
00055 int logfwrite __P((struct logfile *, char *, int));
00056 
00057 /* 
00058  * logfflush should be called periodically. If no argument is passed,
00059  * all logfiles are flushed, else the specified file
00060  * the number of flushed filepointers is returned
00061  */
00062 int logfflush __P((struct logfile *ifany));
00063 
00064 /* 
00065  * a reopen function may be registered here, in case you want to bring your 
00066  * own (more secure open), it may come along with a private data pointer.
00067  * this function is called, whenever logfwrite/logfflush detect that the
00068  * file has been (re)moved, truncated or changed by someone else.
00069  * if you provide NULL as parameter to logreopen_register, the builtin
00070  * reopen function will be reactivated.
00071  */
00072 void logreopen_register __P((int (*fn) __P((char *, int, struct logfile *)) ));
00073 
00074 /* 
00075  * Your custom reopen function is required to reuse the exact
00076  * filedescriptor. 
00077  * See logfile.c for further specs and an example.
00078  *
00079  * lf_move_fd may help you here, if you do not have dup2(2).
00080  * It closes fd and opens wantfd to access whatever fd accessed.
00081  */
00082 int lf_move_fd __P((int fd, int wantfd));

Generated on Sat Jul 2 20:56:16 2005 for GNU Screen by  doxygen 1.4.3