mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 10:23:17 +00:00
108 lines
3.6 KiB
HTML
108 lines
3.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
|
<!--Converted with LaTeX2HTML 2008 (1.71)
|
|
original version by: Nikos Drakos, CBLU, University of Leeds
|
|
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
|
|
* with significant contributions from:
|
|
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>Database checks</TITLE>
|
|
<META NAME="description" CONTENT="Database checks">
|
|
<META NAME="keywords" CONTENT="clamdoc">
|
|
<META NAME="resource-type" CONTENT="document">
|
|
<META NAME="distribution" CONTENT="global">
|
|
|
|
<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
|
|
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
|
|
|
|
<LINK REL="STYLESHEET" HREF="clamdoc.css">
|
|
|
|
<LINK REL="next" HREF="node58.html">
|
|
<LINK REL="previous" HREF="node56.html">
|
|
<LINK REL="up" HREF="node50.html">
|
|
<LINK REL="next" HREF="node58.html">
|
|
</HEAD>
|
|
|
|
<BODY >
|
|
|
|
<DIV CLASS="navigation"><!--Navigation Panel-->
|
|
<A NAME="tex2html974"
|
|
HREF="node58.html">
|
|
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
|
|
<A NAME="tex2html970"
|
|
HREF="node50.html">
|
|
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
|
|
<A NAME="tex2html964"
|
|
HREF="node56.html">
|
|
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
|
|
<A NAME="tex2html972"
|
|
HREF="node1.html">
|
|
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
|
|
<BR>
|
|
<B> Next:</B> <A NAME="tex2html975"
|
|
HREF="node58.html">Data scan functions</A>
|
|
<B> Up:</B> <A NAME="tex2html971"
|
|
HREF="node50.html">API</A>
|
|
<B> Previous:</B> <A NAME="tex2html965"
|
|
HREF="node56.html">Limits</A>
|
|
<B> <A NAME="tex2html973"
|
|
HREF="node1.html">Contents</A></B>
|
|
<BR>
|
|
<BR></DIV>
|
|
<!--End of Navigation Panel-->
|
|
|
|
<H3><A NAME="SECTION00073700000000000000">
|
|
Database checks</A>
|
|
</H3>
|
|
It's very important to keep the internal instance of the database up to
|
|
date. You can watch database changes with the <code>cl_stat..()</code> family
|
|
of functions.
|
|
<PRE>
|
|
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);
|
|
</PRE>
|
|
Initialization:
|
|
<PRE>
|
|
...
|
|
struct cl_stat dbstat;
|
|
|
|
memset(&dbstat, 0, sizeof(struct cl_stat));
|
|
cl_statinidir(dbdir, &dbstat);
|
|
</PRE>
|
|
To check for a change you just need to call <code>cl_statchkdir</code> and check
|
|
its return value (0 - no change, 1 - some change occured). Remember to reset
|
|
the <code>cl_stat</code> structure after reloading the database.
|
|
<PRE>
|
|
if(cl_statchkdir(&dbstat) == 1) {
|
|
reload_database...;
|
|
cl_statfree(&dbstat);
|
|
cl_statinidir(cl_retdbdir(), &dbstat);
|
|
}
|
|
</PRE>
|
|
Libclamav <SPAN CLASS="MATH"><IMG
|
|
WIDTH="58" HEIGHT="35" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img5.png"
|
|
ALT="$\ge0.96$"></SPAN> includes and additional call to check the number of
|
|
signatures that can be loaded from a given directory:
|
|
<PRE>
|
|
int cl_countsigs(const char *path, unsigned int countoptions,
|
|
unsigned int *sigs);
|
|
</PRE>
|
|
The first argument points to the database directory, the second one
|
|
specifies what signatures should be counted:
|
|
<code>CL_COUNTSIGS_OFFICIAL</code> (official signatures),
|
|
<BR> <code>CL_COUNTSIGS_UNOFFICIAL</code> (third party signatures),
|
|
<code>CL_COUNTSIGS_ALL</code> (all signatures). The last argument points
|
|
to the counter to which the number of detected signatures will
|
|
be added (therefore the counter should be initially set to 0).
|
|
The call returns <code>CL_SUCCESS</code> or an error code.
|
|
|
|
<P>
|
|
<BR><HR>
|
|
<ADDRESS>
|
|
Cisco 2018-02-28
|
|
</ADDRESS>
|
|
</BODY>
|
|
</HTML>
|