next up previous contents
Next: Data scan functions Up: LibClamAV Previous: Database structure   Contents

Database reloading

The most important thing is to keep the internal instance of the database up to date. You can watch database changes with the cl_stat functions family.
	int cl_statinidir(const char *dirname, struct cl_stat *dbstat);
	int cl_statchkdir(const struct cl_stat *dbstat);
	int cl_statfree(struct cl_stat *dbstat);
Initialization:
	    ...
	    struct cl_stat dbstat;

	memset(&dbstat, 0, sizeof(struct cl_stat));
	cl_statinidir(dbdir, &dbstat);
To check for a change you only need to call cl_statchkdir:
	if(cl_statchkdir(&dbstat) == 1) {
	    reload_database...;
	    cl_statfree(&dbstat);
	    cl_statinidir(cl_retdbdir(), &dbstat);
	}
Remember to reinitialize the structure after reload.



Subsections

Tomasz Kojm 2005-07-25