~ubuntu-branches/ubuntu/feisty/clamav/feisty-backports

« back to all changes in this revision

Viewing changes to docs/html/node42.html

  • Committer: Bazaar Package Importer
  • Author(s): SpecialK
  • Date: 2008-01-04 11:25:36 UTC
  • mfrom: (19.2.4 hardy)
  • Revision ID: james.westby@ubuntu.com-20080104112536-b23litkqiv48cm9o
Tags: 0.92~dfsg-2~feisty1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
8
8
<HTML>
9
9
<HEAD>
10
 
<TITLE>Engine structure</TITLE>
11
 
<META NAME="description" CONTENT="Engine structure">
 
10
<TITLE>Database reloading</TITLE>
 
11
<META NAME="description" CONTENT="Database reloading">
12
12
<META NAME="keywords" CONTENT="clamdoc">
13
13
<META NAME="resource-type" CONTENT="document">
14
14
<META NAME="distribution" CONTENT="global">
19
19
 
20
20
<LINK REL="STYLESHEET" HREF="clamdoc.css">
21
21
 
22
 
<LINK REL="previous" HREF="node41.html">
23
 
<LINK REL="up" HREF="node38.html">
 
22
<LINK REL="next" HREF="node47.html">
 
23
<LINK REL="previous" HREF="node37.html">
 
24
<LINK REL="up" HREF="node29.html">
24
25
<LINK REL="next" HREF="node43.html">
25
26
</HEAD>
26
27
 
27
28
<BODY >
28
29
<!--Navigation Panel-->
29
 
<A NAME="tex2html739"
 
30
<A NAME="tex2html735"
30
31
  HREF="node43.html">
31
32
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
32
 
<A NAME="tex2html735"
33
 
  HREF="node38.html">
 
33
<A NAME="tex2html731"
 
34
  HREF="node29.html">
34
35
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
35
 
<A NAME="tex2html731"
 
36
<A NAME="tex2html725"
36
37
  HREF="node41.html">
37
38
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
38
 
<A NAME="tex2html737"
 
39
<A NAME="tex2html733"
39
40
  HREF="node1.html">
40
41
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
41
42
<BR>
42
 
<B> Next:</B> <A NAME="tex2html740"
43
 
  HREF="node43.html">Database reloading</A>
44
 
<B> Up:</B> <A NAME="tex2html736"
45
 
  HREF="node38.html">API</A>
46
 
<B> Previous:</B> <A NAME="tex2html732"
47
 
  HREF="node41.html">Error handling</A>
48
 
 &nbsp <B>  <A NAME="tex2html738"
 
43
<B> Next:</B> <A NAME="tex2html736"
 
44
  HREF="node43.html">Data scan functions</A>
 
45
<B> Up:</B> <A NAME="tex2html732"
 
46
  HREF="node29.html">LibClamAV</A>
 
47
<B> Previous:</B> <A NAME="tex2html726"
 
48
  HREF="node41.html">Engine structure</A>
 
49
 &nbsp <B>  <A NAME="tex2html734"
49
50
  HREF="node1.html">Contents</A></B> 
50
51
<BR>
51
52
<BR>
52
53
<!--End of Navigation Panel-->
53
54
 
54
 
<H3><A NAME="SECTION00074400000000000000">
55
 
Engine structure</A>
56
 
</H3>
57
 
    When all required databases are loaded you should prepare the detection
58
 
    engine by calling <code>cl_build</code>. In the case of failure you should
59
 
    free the memory occupied by the engine with <code>cl_free</code>:
60
 
    <PRE>
61
 
        int cl_build(struct cl_engine *engine);
62
 
        void cl_free(struct cl_engine *engine);
63
 
</PRE>
64
 
    In our example:
65
 
    <PRE>
66
 
        if((ret = cl_build(engine))) {
67
 
            printf("cl_build() error: %s\n", cl_strerror(ret));
68
 
            cl_free(engine);
69
 
            exit(1);
 
55
<H2><A NAME="SECTION00074000000000000000">
 
56
Database reloading</A>
 
57
</H2>
 
58
    The most important thing is to keep the internal instance of the database
 
59
    up to date. You can watch database changes with the <code>cl_stat</code>
 
60
    family of functions.
 
61
    <PRE>
 
62
        int cl_statinidir(const char *dirname, struct cl_stat *dbstat);
 
63
        int cl_statchkdir(const struct cl_stat *dbstat);
 
64
        int cl_statfree(struct cl_stat *dbstat);
 
65
</PRE>
 
66
    Initialization:
 
67
    <PRE>
 
68
            ...
 
69
            struct cl_stat dbstat;
 
70
 
 
71
        memset(&amp;dbstat, 0, sizeof(struct cl_stat));
 
72
        cl_statinidir(dbdir, &amp;dbstat);
 
73
</PRE>
 
74
    To check for a change you just need to call <code>cl_statchkdir</code> and check
 
75
    its return value:
 
76
    <PRE>
 
77
        if(cl_statchkdir(&amp;dbstat) == 1) {
 
78
            reload_database...;
 
79
            cl_statfree(&amp;dbstat);
 
80
            cl_statinidir(cl_retdbdir(), &amp;dbstat);
70
81
        }
71
82
</PRE>
 
83
    Remember to reset the <code>cl_stat</code> structure after reload.
72
84
 
73
85
<P>
74
86
<BR><HR>
 
87
<!--Table of Child-Links-->
 
88
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
 
89
 
 
90
<UL>
 
91
<LI><A NAME="tex2html737"
 
92
  HREF="node43.html">Data scan functions</A>
 
93
<LI><A NAME="tex2html738"
 
94
  HREF="node44.html">Memory</A>
 
95
<LI><A NAME="tex2html739"
 
96
  HREF="node45.html">clamav-config</A>
 
97
<LI><A NAME="tex2html740"
 
98
  HREF="node46.html">Example</A>
 
99
</UL>
 
100
<!--End of Table of Child-Links-->
 
101
<BR><HR>
75
102
<ADDRESS>
76
103
Tomasz Kojm
77
 
2007-07-11
 
104
2007-12-12
78
105
</ADDRESS>
79
106
</BODY>
80
107
</HTML>