]>
Commit | Line | Data |
---|---|---|
8f923be6 LDM |
1 | /* |
2 | * libkmod - interface to kernel module operations | |
3 | * | |
e6b0e49b | 4 | * Copyright (C) 2011-2013 ProFUSION embedded systems |
8f923be6 LDM |
5 | * |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
cb451f35 LDM |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2.1 of the License, or (at your option) any later version. | |
8f923be6 LDM |
10 | * |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
dea2dfee | 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
8f923be6 | 18 | */ |
e8847fd2 | 19 | |
e8fd8fec | 20 | #pragma once |
e8847fd2 | 21 | |
b18979b7 | 22 | #include <inttypes.h> |
e8847fd2 | 23 | |
e8847fd2 LDM |
24 | struct index_value { |
25 | struct index_value *next; | |
26 | unsigned int priority; | |
1433ba9e | 27 | unsigned int len; |
e8847fd2 LDM |
28 | char value[0]; |
29 | }; | |
30 | ||
31 | /* In-memory index (depmod only) */ | |
e8847fd2 | 32 | struct index_file; |
e8847fd2 | 33 | struct index_file *index_file_open(const char *filename); |
4a4876d6 LDM |
34 | void index_file_close(struct index_file *idx); |
35 | char *index_search(struct index_file *idx, const char *key); | |
758428a7 | 36 | void index_dump(struct index_file *in, int fd, const char *prefix); |
4a4876d6 | 37 | struct index_value *index_searchwild(struct index_file *idx, const char *key); |
e8847fd2 LDM |
38 | |
39 | void index_values_free(struct index_value *values); | |
40 | ||
b471a6b4 LDM |
41 | /* Implementation using mmap */ |
42 | struct index_mm; | |
5109f2b4 | 43 | struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename, |
2e2e252b | 44 | unsigned long long *stamp); |
b471a6b4 | 45 | void index_mm_close(struct index_mm *index); |
b797b791 | 46 | char *index_mm_search(struct index_mm *idx, const char *key); |
bf89f70c | 47 | struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key); |
758428a7 | 48 | void index_mm_dump(struct index_mm *idx, int fd, const char *prefix); |