chiark / gitweb /
Test universal hashing and fix bugs.
[mLib] / fwatch.h
CommitLineData
32e1147e 1/* -*-c-*-
2 *
3 * $Id: fwatch.h,v 1.1 2001/02/03 18:43:56 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/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: fwatch.h,v $
33 * Revision 1.1 2001/02/03 18:43:56 mdw
34 * New feature: watch a file for changes.
35 *
36 */
37
38#ifndef MLIB_FWATCH_H
39#define MLIB_FWATCH_H
40
41#ifdef __cplusplus
42 extern "C" {
43#endif
44
45/*----- Header files ------------------------------------------------------*/
46
47#include <sys/types.h>
48#include <sys/stat.h>
49
50/*----- Data structures ---------------------------------------------------*/
51
52typedef struct fwatch {
53 int err;
54 dev_t dev;
55 ino_t ino;
56 time_t mtime;
57 off_t size;
58 mode_t mode;
59 uid_t uid;
60 gid_t gid;
61} fwatch;
62
63/*----- Functions provided ------------------------------------------------*/
64
65/* --- @fwatch_init@, @fwatch_update@, etc --- *
66 *
67 * Arguments: @fwatch *f@ = pointer to an @fwatch@ structure
68 * @const char *name@ = name of the file to watch
69 * @int fd@ = a file descriptor to watch
70 *
71 * Returns: The @update@ functions return nonzero if the file has
72 * changed.
73 *
74 * Use: Stores information about a file which can be used to watch
75 * for changes. The structures may be freed without telling
76 * anyone.
77 */
78
79extern void fwatch_init(fwatch */*f*/, const char */*name*/);
80extern void fwatch_initfd(fwatch */*f*/, int /*fd*/);
81extern int fwatch_update(fwatch */*f*/, const char */*name*/);
82extern int fwatch_updatefd(fwatch */*f*/, int /*fd*/);
83
84/*----- That's all, folks -------------------------------------------------*/
85
86#ifdef __cplusplus
87 }
88#endif
89
90#endif