blob: 52aebac0509b9c201b4461429d3e29e148854b10 [file] [log] [blame]
Lucas De Marchi8f923be2011-12-03 04:28:49 -02001/*
2 * libkmod - interface to kernel module operations
3 *
Lucas De Marchie6b0e492013-01-16 11:27:21 -02004 * Copyright (C) 2011-2013 ProFUSION embedded systems
Lucas De Marchi8f923be2011-12-03 04:28:49 -02005 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
Lucas De Marchicb451f32011-12-12 18:24:35 -02008 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
Lucas De Marchi8f923be2011-12-03 04:28:49 -020010 *
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
Lucas De Marchidea2dfe2014-12-25 23:32:03 -020017 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
Lucas De Marchi8f923be2011-12-03 04:28:49 -020018 */
Lucas De Marchie8847fd2011-11-30 15:23:28 -020019
Lucas De Marchie8fd8fe2012-07-18 10:19:48 -030020#pragma once
Lucas De Marchie8847fd2011-11-30 15:23:28 -020021
Lucas De Marchib18979b2014-10-03 02:03:55 -030022#include <inttypes.h>
Lucas De Marchie8847fd2011-11-30 15:23:28 -020023
Lucas De Marchie8847fd2011-11-30 15:23:28 -020024struct index_value {
25 struct index_value *next;
26 unsigned int priority;
Gustavo Sverzut Barbieri1433ba92011-12-08 14:50:29 -020027 unsigned int len;
Lucas De Marchie8847fd2011-11-30 15:23:28 -020028 char value[0];
29};
30
31/* In-memory index (depmod only) */
Lucas De Marchie8847fd2011-11-30 15:23:28 -020032struct index_file;
Lucas De Marchie8847fd2011-11-30 15:23:28 -020033struct index_file *index_file_open(const char *filename);
Lucas De Marchi4a4876d2011-12-02 17:48:14 -020034void index_file_close(struct index_file *idx);
35char *index_search(struct index_file *idx, const char *key);
Lucas De Marchi758428a2012-01-16 15:56:17 -020036void index_dump(struct index_file *in, int fd, const char *prefix);
Lucas De Marchi4a4876d2011-12-02 17:48:14 -020037struct index_value *index_searchwild(struct index_file *idx, const char *key);
Lucas De Marchie8847fd2011-11-30 15:23:28 -020038
39void index_values_free(struct index_value *values);
40
Lucas De Marchib471a6b2011-12-01 23:14:20 -020041/* Implementation using mmap */
42struct index_mm;
Lucas De Marchi5109f2b2011-12-08 15:10:55 -020043struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
Lucas De Marchi2e2e2522012-03-02 20:33:26 -030044 unsigned long long *stamp);
Lucas De Marchib471a6b2011-12-01 23:14:20 -020045void index_mm_close(struct index_mm *index);
Lucas De Marchib797b792011-12-02 17:49:03 -020046char *index_mm_search(struct index_mm *idx, const char *key);
Lucas De Marchibf89f702011-12-02 18:23:36 -020047struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key);
Lucas De Marchi758428a2012-01-16 15:56:17 -020048void index_mm_dump(struct index_mm *idx, int fd, const char *prefix);