~ubuntu-branches/ubuntu/feisty/strigi/feisty-backports

« back to all changes in this revision

Viewing changes to src/daemon/filters.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2006-11-12 19:23:58 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20061112192358-bopz8iu9cr8bosyc
Tags: 0.3.9-1
* New upstream release
* Remove patch to inotify support option, merged upstream
* Add poppler-utils and wv as Depends
* Include utils.mk to rules
* Add deepfind, deepgrep, luceneindexer and xmlindexer to
  strigi-daemon.install
* Update strigi-daemon.lintian-overrides for 0.3.9 version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of Strigi Desktop Search
2
 
 *
3
 
 * Copyright (C) 2006 Flavio Castelli <flavio.castelli@gmail.com>
4
 
 *
5
 
 * This library is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU Library General Public
7
 
 * License as published by the Free Software Foundation; either
8
 
 * version 2 of the License, or (at your option) any later version.
9
 
 *
10
 
 * This library is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
 * Library General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU Library General Public License
16
 
 * along with this library; see the file COPYING.LIB.  If not, write to
17
 
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
 
 * Boston, MA 02110-1301, USA.
19
 
 */
20
 
 
21
 
#include "filters.h"
22
 
#include "strigilogging.h"
23
 
 
24
 
#include <fnmatch.h>
25
 
 
26
 
using namespace std;
27
 
 
28
 
bool PatternFilter::match(const string& text)
29
 
{
30
 
    int ret = fnmatch (m_rule.c_str(), text.c_str(), 0);
31
 
       
32
 
    if ((ret != FNM_NOMATCH) && (ret != 0))
33
 
        STRIGI_LOG_WARNING ("strigi.filtermanager", "error while applying pattern " + m_rule + "over text " + text)
34
 
    else if ( ret == 0)
35
 
    {
36
 
        STRIGI_LOG_DEBUG ("strigi.filtermanager", text + " matched pattern " + m_rule)
37
 
        return true;
38
 
    }
39
 
    
40
 
    return false;
41
 
}
42
 
 
43
 
bool PathFilter::match (const string& text)
44
 
{
45
 
    // create the real pattern, whe have to add a * for globbing
46
 
    string realPattern = m_rule;
47
 
    realPattern+="*";
48
 
    
49
 
    int ret = fnmatch (realPattern.c_str(), text.c_str(), 0);
50
 
       
51
 
    if ((ret != FNM_NOMATCH) && (ret != 0))
52
 
        STRIGI_LOG_WARNING ("strigi.filtermanager", "error while applying pattern " + m_rule + "over text " + text)
53
 
                else if ( ret == 0)
54
 
    {
55
 
        STRIGI_LOG_DEBUG ("strigi.filtermanager", text + " matched pattern " + m_rule)
56
 
                return true;
57
 
    }
58
 
    
59
 
    return false;
60
 
}
61