chiark / gitweb /
daemonize, versioncmp: Generally useful functions from tripe.
[mLib] / fwatch.h
1 /* -*-c-*-
2  *
3  * $Id: fwatch.h,v 1.2 2004/04/08 01:36:11 mdw Exp $
4  *
5  * Watch a file for changes
6  *
7  * (c) 2001 Straylight/Edgeware
8  */
9
10 /*----- Licensing notice --------------------------------------------------* 
11  *
12  * This file is part of the mLib utilities library.
13  *
14  * mLib is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU Library General Public License as
16  * published by the Free Software Foundation; either version 2 of the
17  * License, or (at your option) any later version.
18  * 
19  * mLib is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU Library General Public License for more details.
23  * 
24  * You should have received a copy of the GNU Library General Public
25  * License along with mLib; if not, write to the Free
26  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27  * MA 02111-1307, USA.
28  */
29
30 #ifndef MLIB_FWATCH_H
31 #define MLIB_FWATCH_H
32
33 #ifdef __cplusplus
34   extern "C" {
35 #endif
36
37 /*----- Header files ------------------------------------------------------*/
38
39 #include <sys/types.h>
40 #include <sys/stat.h>
41
42 /*----- Data structures ---------------------------------------------------*/
43
44 typedef struct fwatch {
45   int err;
46   dev_t dev;
47   ino_t ino;
48   time_t mtime;
49   off_t size;
50   mode_t mode;
51   uid_t uid;
52   gid_t gid;
53 } fwatch;
54
55 /*----- Functions provided ------------------------------------------------*/
56
57 /* --- @fwatch_init@, @fwatch_update@, etc --- *
58  *
59  * Arguments:   @fwatch *f@ = pointer to an @fwatch@ structure
60  *              @const char *name@ = name of the file to watch
61  *              @int fd@ = a file descriptor to watch
62  *
63  * Returns:     The @update@ functions return nonzero if the file has
64  *              changed.
65  *
66  * Use:         Stores information about a file which can be used to watch
67  *              for changes.  The structures may be freed without telling
68  *              anyone.
69  */
70
71 extern void fwatch_init(fwatch */*f*/, const char */*name*/);
72 extern void fwatch_initfd(fwatch */*f*/, int /*fd*/);
73 extern int fwatch_update(fwatch */*f*/, const char */*name*/);
74 extern int fwatch_updatefd(fwatch */*f*/, int /*fd*/);
75
76 /*----- That's all, folks -------------------------------------------------*/
77
78 #ifdef __cplusplus
79   }
80 #endif
81
82 #endif