libudev-hwdb.c revision beb23689e357ed549f5c9d4a3440da2132a419f1
/***
This file is part of systemd.
Copyright 2012 Kay Sievers <kay@vrfy.org>
Copyright 2008 Alan Jenkins <alan.christopher.jenkins@googlemail.com>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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 License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdlib.h>
#include <fnmatch.h>
#include <getopt.h>
#include "libudev-private.h"
#include "libudev-hwdb-def.h"
/**
* SECTION:libudev-hwdb
* @short_description: retrieve properties from the hardware database
*
* Libudev hardware database interface.
*/
/**
* udev_hwdb:
*
* Opaque object representing the hardware database.
*/
struct udev_hwdb {
int refcount;
FILE *f;
union {
struct trie_header_f *head;
const char *map;
};
struct udev_list properties_list;
};
struct linebuf {
};
}
return NULL;
}
return false;
return true;
}
{
return false;
return true;
}
}
}
static const struct trie_child_entry_f *trie_node_children(struct udev_hwdb *hwdb, const struct trie_node_f *node) {
}
static const struct trie_value_entry_f *trie_node_values(struct udev_hwdb *hwdb, const struct trie_node_f *node) {
return (const struct trie_value_entry_f *)base;
}
}
}
}
static const struct trie_node_f *node_lookup_f(struct udev_hwdb *hwdb, const struct trie_node_f *node, uint8_t c) {
struct trie_child_entry_f *child;
struct trie_child_entry_f search;
search.c = c;
if (child)
return NULL;
}
/* TODO: add sub-matches (+) against DMI data */
if (key[0] != ' ')
return 0;
return -ENOMEM;
return 0;
}
size_t i;
const char *prefix;
int err;
for (i = 0; i < node->children_count; i++) {
if (err < 0)
return err;
}
if (err < 0)
return err;
}
return 0;
}
const struct trie_node_f *node;
size_t i = 0;
int err;
linebuf_init(&buf);
while (node) {
const struct trie_node_f *child;
size_t p = 0;
if (node->prefix_off) {
uint8_t c;
if (c == '*' || c == '?' || c == '[')
if (c != search[i + p])
return 0;
}
i += p;
}
if (child) {
if (err < 0)
return err;
}
if (child) {
if (err < 0)
return err;
}
if (child) {
if (err < 0)
return err;
}
if (search[i] == '\0') {
size_t n;
if (err < 0)
return err;
}
return 0;
}
i++;
}
return 0;
}
/**
* udev_hwdb_new:
* @udev: udev library context
*
* Create a hardware database context to query properties for devices.
*
* Returns: a hwdb context.
**/
if (!hwdb)
return NULL;
if (!hwdb->f) {
return NULL;
}
return NULL;
}
return NULL;
}
return NULL;
}
log_debug("=== trie on-disk ===\n");
return hwdb;
}
/**
* udev_hwdb_ref:
* @hwdb: context
*
* Take a reference of a hwdb context.
*
* Returns: the passed enumeration context
**/
if (!hwdb)
return NULL;
return hwdb;
}
/**
* udev_hwdb_unref:
* @hwdb: context
*
* Drop a reference of a hwdb context. If the refcount reaches zero,
* all resources of the hwdb context will be released.
*
* Returns: the passed hwdb context if it has still an active reference, or #NULL otherwise.
**/
if (!hwdb)
return NULL;
return hwdb;
if (hwdb->f)
return NULL;
}
if (!hwdb)
return false;
if (!hwdb->f)
return false;
return true;
return true;
return false;
}
/**
* udev_hwdb_get_properties_list_entry:
* @hwdb: context
* @modalias: modalias string
* @flags: (unused)
*
* Lookup a matching device in the hardware database. The lookup key is a
* modalias string, whose formats are defined for the Linux kernel modules.
* Examples are: pci:v00008086d00001C2D*, usb:v04F2pB221*. The first entry
* of a list of retrieved properties is returned.
*
* Returns: a udev_list_entry.
*/
_public_ struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev_hwdb *hwdb, const char *modalias, unsigned int flags) {
int err;
return NULL;
}
if (err < 0) {
return NULL;
}
}