docs/html/node56.html
96e05490
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
e79e504d
 <!--Converted with LaTeX2HTML 2008 (1.71)
96e05490
 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>
06e931e5
 <TITLE>Database checks</TITLE>
 <META NAME="description" CONTENT="Database checks">
96e05490
 <META NAME="keywords" CONTENT="clamdoc">
 <META NAME="resource-type" CONTENT="document">
 <META NAME="distribution" CONTENT="global">
 
e79e504d
 <META NAME="Generator" CONTENT="LaTeX2HTML v2008">
96e05490
 <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
 
 <LINK REL="STYLESHEET" HREF="clamdoc.css">
 
ba4cac37
 <LINK REL="next" HREF="node57.html">
06e931e5
 <LINK REL="previous" HREF="node55.html">
 <LINK REL="up" HREF="node49.html">
ba4cac37
 <LINK REL="next" HREF="node57.html">
96e05490
 </HEAD>
 
 <BODY >
 
 <DIV CLASS="navigation"><!--Navigation Panel-->
06e931e5
 <A NAME="tex2html959"
ba4cac37
   HREF="node57.html">
 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
06e931e5
 <A NAME="tex2html955"
   HREF="node49.html">
96e05490
 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
06e931e5
 <A NAME="tex2html949"
96e05490
   HREF="node55.html">
 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
06e931e5
 <A NAME="tex2html957"
96e05490
   HREF="node1.html">
 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
 <BR>
06e931e5
 <B> Next:</B> <A NAME="tex2html960"
   HREF="node57.html">Data scan functions</A>
 <B> Up:</B> <A NAME="tex2html956"
   HREF="node49.html">API</A>
 <B> Previous:</B> <A NAME="tex2html950"
   HREF="node55.html">Limits</A>
  &nbsp; <B>  <A NAME="tex2html958"
96e05490
   HREF="node1.html">Contents</A></B> 
 <BR>
 <BR></DIV>
 <!--End of Navigation Panel-->
 
06e931e5
 <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.
e79e504d
     <PRE>
06e931e5
 	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);
e79e504d
 </PRE>
06e931e5
     Initialization:
e79e504d
     <PRE>
06e931e5
 	    ...
 	    struct cl_stat dbstat;
 
 	memset(&amp;dbstat, 0, sizeof(struct cl_stat));
 	cl_statinidir(dbdir, &amp;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(&amp;dbstat) == 1) {
 	    reload_database...;
 	    cl_statfree(&amp;dbstat);
 	    cl_statinidir(cl_retdbdir(), &amp;dbstat);
 	}
 </PRE>
     Libclamav <SPAN CLASS="MATH"><IMG
  WIDTH="58" HEIGHT="35" ALIGN="MIDDLE" BORDER="0"
  SRC="img6.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);
e79e504d
 </PRE>
06e931e5
     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.
ba4cac37
 
96e05490
 <P>
e79e504d
 <BR><HR>
96e05490
 <ADDRESS>
06e931e5
 Cisco 2014-05-21
96e05490
 </ADDRESS>
 </BODY>
 </HTML>