/usr/include/eiskaltdcpp/dcpp/ADLSearch.h is in libeiskaltdcpp-dev 2.2.9-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | /*
* Copyright (C) 2001-2012 Jacek Sieka, arnetheduck on gmail point com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Automatic Directory Listing Search
* Henrik Engstr�m, henrikengstrom at home se
*/
#pragma once
#include "Util.h"
#include "SettingsManager.h"
#include "StringSearch.h"
#include "Singleton.h"
#include "DirectoryListing.h"
namespace dcpp {
class AdlSearchManager;
/// Class that represent an ADL search
class ADLSearch
{
public:
// Constructor
ADLSearch();
// Prepare search
void Prepare(StringMap& params);
// The search string
string searchString;
// Active search
bool isActive;
// Auto Queue Results
bool isAutoQueue;
// Search source type
enum SourceType {
TypeFirst = 0,
OnlyFile = TypeFirst,
OnlyDirectory,
FullPath,
TypeLast
} sourceType;
SourceType StringToSourceType(const string& s);
string SourceTypeToString(SourceType t);
// Maximum & minimum file sizes (in bytes).
// Negative values means do not check.
int64_t minFileSize;
int64_t maxFileSize;
enum SizeType {
SizeBytes = TypeFirst,
SizeKibiBytes,
SizeMebiBytes,
SizeGibiBytes
};
SizeType typeFileSize;
SizeType StringToSizeType(const string& s);
string SizeTypeToString(SizeType t);
int64_t GetSizeBase();
// Name of the destination directory (empty = 'ADLSearch') and its index
string destDir;
unsigned long ddIndex;
// Search for file match
bool MatchesFile(const string& f, const string& fp, int64_t size);
// Search for directory match
bool MatchesDirectory(const string& d);
private:
friend class ADLSearchManager;
//decide if regexp should be used
bool bUseRegexp;
string regexpstring;
// Substring searches
StringSearch::List stringSearchList;
bool SearchAll(const string& s);
};
/// Class that holds all active searches
class ADLSearchManager : public Singleton<ADLSearchManager>
{
public:
// Destination directory indexing
struct DestDir {
string name;
DirectoryListing::Directory* dir;
DirectoryListing::Directory* subdir;
bool fileAdded;
DestDir() : name(""), dir(NULL), subdir(NULL) {}
};
typedef vector<DestDir> DestDirList;
// Constructor/destructor
ADLSearchManager() : user(UserPtr(), Util::emptyString) { Load(); }
virtual ~ADLSearchManager() { Save(); }
// Search collection
typedef vector<ADLSearch> SearchCollection;
SearchCollection collection;
// Load/save search collection to XML file
void Load();
void Save();
// Settings
GETSET(bool, breakOnFirst, BreakOnFirst)
GETSET(HintedUser, user, User)
// @remarks Used to add ADLSearch directories to an existing DirectoryListing
void matchListing(DirectoryListing& /*aDirList*/) noexcept;
private:
// @internal
void matchRecurse(DestDirList& /*aDestList*/, DirectoryListing::Directory* /*aDir*/, string& /*aPath*/);
// Search for file match
void MatchesFile(DestDirList& destDirVector, DirectoryListing::File *currentFile, string& fullPath);
// Search for directory match
void MatchesDirectory(DestDirList& destDirVector, DirectoryListing::Directory* currentDir, string& fullPath);
// Step up directory
void StepUpDirectory(DestDirList& destDirVector);
// Prepare destination directory indexing
void PrepareDestinationDirectories(DestDirList& destDirVector, DirectoryListing::Directory* root, StringMap& params);
// Finalize destination directories
void FinalizeDestinationDirectories(DestDirList& destDirVector, DirectoryListing::Directory* root);
string getConfigFile();
};
} // namespace dcpp
|