Keywords: clamdoc

Next: Error handling Up: API Previous: Initialization Contents

### Database loading

The following set of functions provides an interface for loading the virus database:

    	const char *cl_retdbdir(void);

    	int cl_load(const char *path, struct cl_engine *engine,
    		    unsigned int *signo, unsigned int options);

`cl_retdbdir()` returns the default (hardcoded) path to the directory with ClamAV databases. `cl_load()` loads a single database file or all databases from a given directory (when `path` points to a directory). The second argument is used for passing in the pointer to the engine that should be previously allocated with `cl_engine_new()`. A number of loaded signatures will be added to `signo` 10. The last argument can pass the following flags:

- CL_DB_STDOPT
  This is an alias for a recommended set of scan options.
- CL_DB_PHISHING
  Load phishing signatures.
- CL_DB_PHISHING_URLS
  Initialize the phishing detection module and load .wdb and .pdb files.
- CL_DB_PUA
  Load signatures for Potentially Unwanted Applications.
- CL_DB_OFFICIAL_ONLY
  Only load official signatures from digitally signed databases.
- CL_DB_BYTECODE
  Load bytecode.

`cl_load()` returns `CL_SUCCESS` on success and another code on failure.

    	    ...
    	    struct cl_engine *engine;
    	    unsigned int sigs = 0;
    	    int ret;

    	if((ret = cl_init()) != CL_SUCCESS) {
    	    printf("cl_init() error: %s\n", cl_strerror(ret));
    	    return 1;
    	}

    	if(!(engine = cl_engine_new())) {
    	    printf("Can't create new engine\n");
    	    return 1;
    	}

    	ret = cl_load(cl_retdbdir(), engine, &sigs, CL_DB_STDOPT);