2011-12-03 13:28:49 +07:00
|
|
|
/*
|
|
|
|
* libkmod - interface to kernel module operations
|
|
|
|
*
|
2013-01-16 20:27:21 +07:00
|
|
|
* Copyright (C) 2011-2013 ProFUSION embedded systems
|
2011-12-03 13:28:49 +07:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
2011-12-13 03:24:35 +07:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2011-12-03 13:28:49 +07:00
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2014-12-26 08:32:03 +07:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2011-12-03 13:28:49 +07:00
|
|
|
*/
|
2011-12-01 00:23:28 +07:00
|
|
|
|
2012-07-18 20:19:48 +07:00
|
|
|
#pragma once
|
2011-12-01 00:23:28 +07:00
|
|
|
|
2014-10-03 12:03:55 +07:00
|
|
|
#include <inttypes.h>
|
2011-12-01 00:23:28 +07:00
|
|
|
|
|
|
|
struct index_value {
|
|
|
|
struct index_value *next;
|
|
|
|
unsigned int priority;
|
2011-12-08 23:50:29 +07:00
|
|
|
unsigned int len;
|
2011-12-01 00:23:28 +07:00
|
|
|
char value[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* In-memory index (depmod only) */
|
|
|
|
struct index_file;
|
|
|
|
struct index_file *index_file_open(const char *filename);
|
2011-12-03 02:48:14 +07:00
|
|
|
void index_file_close(struct index_file *idx);
|
|
|
|
char *index_search(struct index_file *idx, const char *key);
|
2012-01-17 00:56:17 +07:00
|
|
|
void index_dump(struct index_file *in, int fd, const char *prefix);
|
2011-12-03 02:48:14 +07:00
|
|
|
struct index_value *index_searchwild(struct index_file *idx, const char *key);
|
2011-12-01 00:23:28 +07:00
|
|
|
|
|
|
|
void index_values_free(struct index_value *values);
|
|
|
|
|
2011-12-02 08:14:20 +07:00
|
|
|
/* Implementation using mmap */
|
|
|
|
struct index_mm;
|
2020-03-10 12:00:27 +07:00
|
|
|
int index_mm_open(const struct kmod_ctx *ctx, const char *filename,
|
|
|
|
unsigned long long *stamp, struct index_mm **pidx);
|
2011-12-02 08:14:20 +07:00
|
|
|
void index_mm_close(struct index_mm *index);
|
2011-12-03 02:49:03 +07:00
|
|
|
char *index_mm_search(struct index_mm *idx, const char *key);
|
2011-12-03 03:23:36 +07:00
|
|
|
struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key);
|
2012-01-17 00:56:17 +07:00
|
|
|
void index_mm_dump(struct index_mm *idx, int fd, const char *prefix);
|