Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

watcher.c File Reference


Detailed Description

File watcher.

Periodically monitors file and invoke processing callback should the file change.

Author:
Raphael Manfredi
Date:
2004

#include "common.h"
#include "watcher.h"
#include "atoms.h"
#include "cq.h"
#include "misc.h"
#include "walloc.h"
#include "override.h"

Data Structures

struct  monitored
 A monitored file. More...


Defines

#define MONITOR_PERIOD_MS   (30*1000) /**< 30 seconds */
 30 seconds


Functions

 RCSID ("$Id:watcher.c, v 1.4 2005/06/25 01:37:43 daichik Exp $")
time_t watcher_mtime (const gchar *filename)
 Compute the modified time of the file on disk.

void watcher_check_mtime (gpointer unused_key, gpointer value, gpointer unused_udata)
 Check each registered file for change -- hash table iterator callback.

void watcher_timer (cqueue_t *unused_cq, gpointer unused_udata)
 Callout queue callback to perform periodic monitoring of the registered files.

void watcher_register (const gchar *filename, watcher_cb_t cb, gpointer udata)
 Register new file to be monitored.

void watcher_register_path (const file_path_t *fp, watcher_cb_t cb, gpointer udata)
 Same as watcher_register() but a path, i.e.

void watcher_free (struct monitored *m)
 Free monitoring structure.

void watcher_unregister (const gchar *filename)
 Cancel monitoring of specified file.

void watcher_unregister_path (const file_path_t *fp)
 Same as watcher_unregister() but a path, i.e.

void watcher_init (void)
 Initialization.

void free_monitored_kv (gpointer unused_key, gpointer value, gpointer unused_udata)
 Free monitored structure -- hash table iterator callback.

void watcher_close (void)
 Final cleanup.


Variables

gpointer monitor_ev = NULL
 Monitoring event.

GHashTable * monitored = NULL
 filename -> struct monitored


Define Documentation

#define MONITOR_PERIOD_MS   (30*1000) /**< 30 seconds */
 

30 seconds


Function Documentation

void free_monitored_kv gpointer  unused_key,
gpointer  value,
gpointer  unused_udata
[static]
 

Free monitored structure -- hash table iterator callback.

RCSID "$Id:watcher.  c,
v 1.4 2005/06/25 01:37:43 daichik Exp $" 
 

void watcher_check_mtime gpointer  unused_key,
gpointer  value,
gpointer  unused_udata
[static]
 

Check each registered file for change -- hash table iterator callback.

void watcher_close void   ) 
 

Final cleanup.

void watcher_free struct monitored m  )  [static]
 

Free monitoring structure.

void watcher_init void   ) 
 

Initialization.

time_t watcher_mtime const gchar *  filename  )  [static]
 

Compute the modified time of the file on disk.

void watcher_register const gchar *  filename,
watcher_cb_t  cb,
gpointer  udata
 

Register new file to be monitored.

If the file was already monitored, cancel the previous monitoring action and replace it with this one.

Parameters:
filename the file to monitor (string duplicated)
cb the callback to invoke when the file changes
udata extra data to pass to the callback, along with filename

void watcher_register_path const file_path_t fp,
watcher_cb_t  cb,
gpointer  udata
 

Same as watcher_register() but a path, i.e.

a (dir, base) tuple is given instead of a complete filename.

void watcher_timer cqueue_t unused_cq,
gpointer  unused_udata
[static]
 

Callout queue callback to perform periodic monitoring of the registered files.

void watcher_unregister const gchar *  filename  ) 
 

Cancel monitoring of specified file.

void watcher_unregister_path const file_path_t fp  ) 
 

Same as watcher_unregister() but a path, i.e.

a (dir, base) tuple is given instead of a complete filename.


Variable Documentation

gpointer monitor_ev = NULL [static]
 

Monitoring event.

GHashTable* monitored = NULL [static]
 

filename -> struct monitored


Generated on Sun Feb 12 10:50:10 2006 for Gtk-Gnutella by doxygen 1.3.6