Next: Data scan functions Up: LibClamAV Previous: Engine 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` family of functions.

    	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 just need to call `cl_statchkdir` and check its return value:

    	if(cl_statchkdir(&dbstat) == 1) {
    	    reload_database...;
    	    cl_statfree(&dbstat);
    	    cl_statinidir(cl_retdbdir(), &dbstat);
    	}

Remember to reset the `cl_stat` structure after reload.

Subsections

- Data scan functions
- Memory
- clamav-config
- Example