## Database reloading

It's very important 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 (0 - no change, 1 - some change occured):

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

Remember to reset the `cl_stat` structure after each reload.

Subsections

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