summaryrefslogtreecommitdiff
path: root/src/pdfgrep.h
blob: 93c52aef276e1ea36328807807c59ae76b6e0cdc (plain)
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
/***************************************************************************
 *   Copyright (C) 2015-2018 by Hans-Peter Deifel                          *
 *   hpd@hpdeifel.de                                                       *
 *                                                                         *
 *   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.                                            *
 ***************************************************************************/

#ifndef PDFGREP_H
#define PDFGREP_H

#include "config.h"
#include "exclude.h"
#include "intervals.h"

#include <vector>
#include <string>

/* Exit codes. */
enum {
	/* EXIT_SUCCESS = 0 */

	// no match was found
	EXIT_NOT_FOUND = 1,
	// an error occured
	EXIT_ERROR = 2,
};

enum class Recursion {
	NONE,
	FOLLOW_SYMLINKS,
	DONT_FOLLOW_SYMLINKS
};

struct Colorconf {
	char *filename;
	char *pagenum;
	char *highlight;
	char *separator;
};

// Controls, what to print
struct Outconf {
	bool filename = false;
	bool pagenum = false;
	bool color = false;
	bool only_matching = false;
	bool null_byte_sep = false;
	std::string prefix_sep = ":";

	// true, if we need to print context separators between lines
	bool context_mode = false;
	int context_before = 0;
	int context_after = 0;

	Colorconf colors;
};

enum class OnlyFilenames {
	NOPE,
	WITH_MATCHES,
	WITHOUT_MATCH
};

struct Options {
	bool ignore_case = false;
	Recursion recursive = Recursion::NONE;
	bool count = false;
	bool pagecount = false;
	bool quiet = false;
	// vector of all passwords to try on any pdf
	std::vector<std::string> passwords;
	int max_count = 0;
	bool debug = 0;
	bool warn_empty = false;
#ifdef HAVE_UNAC
	bool use_unac = false;
#endif
	Outconf outconf;
	ExcludeList excludes;
	ExcludeList includes;
	bool use_cache = false;
	std::string cache_directory;
	IntervalContainer page_range;
	OnlyFilenames only_filenames = OnlyFilenames::NOPE;
};

#ifdef HAVE_UNAC
/* convenience layer over libunac */
std::string simple_unac(const Options &opts, const std::string str);
#endif

#endif /* PDFGREP_H */

/* Local Variables: */
/* mode: c++ */
/* End: */