]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
index: cleanup header, move as much as possible to libkmod-index.c
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Sat, 10 Dec 2011 13:53:51 +0000 (11:53 -0200)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Sat, 10 Dec 2011 13:53:51 +0000 (11:53 -0200)
libkmod/libkmod-index.c
libkmod/libkmod-index.h

index d97a03c7571317dc0ce3d8ed60de1e89514bc034..40b223cf47eae8045807e8e4a67497aae8835d0b 100644 (file)
 
 /* index.c: module index file shared functions for modprobe and depmod */
 
+#define INDEX_CHILDMAX 128
+
+/* Disk format:
+
+   uint32_t magic = INDEX_MAGIC;
+   uint32_t version = INDEX_VERSION;
+   uint32_t root_offset;
+
+   (node_offset & INDEX_NODE_MASK) specifies the file offset of nodes:
+
+        char[] prefix; // nul terminated
+
+        char first;
+        char last;
+        uint32_t children[last - first + 1];
+
+        uint32_t value_count;
+        struct {
+            uint32_t priority;
+            char[] value; // nul terminated
+        } values[value_count];
+
+   (node_offset & INDEX_NODE_FLAGS) indicates which fields are present.
+   Empty prefixes are omitted, leaf nodes omit the three child-related fields.
+
+   This could be optimised further by adding a sparse child format
+   (indicated using a new flag).
+ */
+
+/* Format of node offsets within index file */
+enum node_offset {
+       INDEX_NODE_FLAGS    = 0xF0000000, /* Flags in high nibble */
+       INDEX_NODE_PREFIX   = 0x80000000,
+       INDEX_NODE_VALUES = 0x40000000,
+       INDEX_NODE_CHILDS   = 0x20000000,
+
+       INDEX_NODE_MASK     = 0x0FFFFFFF, /* Offset value */
+};
+
 void index_values_free(struct index_value *values)
 {
        while (values) {
index a6aba5e8eb37a0b9c0349b3e9a4361682add7b49..b8c1fb9d67c7823a219e225f6ac298388cacf0ee 100644 (file)
@@ -110,53 +110,6 @@ struct index_value {
 };
 
 /* In-memory index (depmod only) */
-
-#define INDEX_CHILDMAX 128
-struct index_node {
-       char *prefix;           /* path compression */
-       struct index_value *values;
-       unsigned char first;    /* range of child nodes */
-       unsigned char last;
-       struct index_node *children[INDEX_CHILDMAX]; /* indexed by character */
-};
-
-/* Disk format:
-
-   uint32_t magic = INDEX_MAGIC;
-   uint32_t version = INDEX_VERSION;
-   uint32_t root_offset;
-
-   (node_offset & INDEX_NODE_MASK) specifies the file offset of nodes:
-
-        char[] prefix; // nul terminated
-
-        char first;
-        char last;
-        uint32_t children[last - first + 1];
-
-        uint32_t value_count;
-        struct {
-            uint32_t priority;
-            char[] value; // nul terminated
-        } values[value_count];
-
-   (node_offset & INDEX_NODE_FLAGS) indicates which fields are present.
-   Empty prefixes are omitted, leaf nodes omit the three child-related fields.
-
-   This could be optimised further by adding a sparse child format
-   (indicated using a new flag).
- */
-
-/* Format of node offsets within index file */
-enum node_offset {
-       INDEX_NODE_FLAGS    = 0xF0000000, /* Flags in high nibble */
-       INDEX_NODE_PREFIX   = 0x80000000,
-       INDEX_NODE_VALUES = 0x40000000,
-       INDEX_NODE_CHILDS   = 0x20000000,
-
-       INDEX_NODE_MASK     = 0x0FFFFFFF, /* Offset value */
-};
-
 struct index_file;
 struct index_file *index_file_open(const char *filename);
 void index_file_close(struct index_file *idx);