]> git.sesse.net Git - plocate/blob - lib.h
Release plocate 1.1.22.
[plocate] / lib.h
1 /* Common functions.
2
3 Copyright (C) 2005, 2007 Red Hat, Inc. All rights reserved.
4 This copyrighted material is made available to anyone wishing to use, modify,
5 copy, or redistribute it subject to the terms and conditions of the GNU General
6 Public License v.2.
7
8 This program is distributed in the hope that it will be useful, but WITHOUT ANY
9 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
10 PARTICULAR PURPOSE. See the GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License along with
13 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
14 Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
16 Author: Miloslav Trmac <mitr@redhat.com>
17
18 plocate modifications: Copyright (C) 2020 Steinar H. Gunderson.
19 plocate parts and modifications are licensed under the GPLv2 or, at your option,
20 any later version.
21 */
22
23 #ifndef LIB_H__
24 #define LIB_H__
25
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include <stdio.h>
29 #include <string>
30 #include <sys/types.h>
31 #include <vector>
32
33 #define _(X) (X)
34
35 /* Compare two path names using the database directory order. This is not
36    exactly strcmp () order: "a" < "a.b", so "a/z" < "a.b". */
37 extern int dir_path_cmp(const std::string &a, const std::string &b);
38
39 /* Sort LIST using dir_path_cmp () */
40 extern void string_list_dir_path_sort(std::vector<std::string> *list);
41
42 /* Is PATH included in LIST?  Update *IDX to move within LIST.
43
44    LIST is assumed to be sorted using dir_path_cmp (), successive calls to this
45    function are assumed to use PATH values increasing in dir_path_cmp (). */
46 extern bool string_list_contains_dir_path(const std::vector<std::string> *list,
47                                           size_t *idx, const std::string &path);
48
49 #endif