Blame gio/gvdb/gvdb-format.h

Packit ae235b
/*
Packit ae235b
 * Copyright © 2010 Codethink Limited
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General Public
Packit ae235b
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 *
Packit ae235b
 * Author: Ryan Lortie <desrt@desrt.ca>
Packit ae235b
 */
Packit ae235b
Packit ae235b
#ifndef __gvdb_format_h__
Packit ae235b
#define __gvdb_format_h__
Packit ae235b
Packit ae235b
#include <glib.h>
Packit ae235b
Packit ae235b
typedef struct { guint16 value; } guint16_le;
Packit ae235b
typedef struct { guint32 value; } guint32_le;
Packit ae235b
Packit ae235b
struct gvdb_pointer {
Packit ae235b
  guint32_le start;
Packit ae235b
  guint32_le end;
Packit ae235b
};
Packit ae235b
Packit ae235b
struct gvdb_hash_header {
Packit ae235b
  guint32_le n_bloom_words;
Packit ae235b
  guint32_le n_buckets;
Packit ae235b
};
Packit ae235b
Packit ae235b
struct gvdb_hash_item {
Packit ae235b
  guint32_le hash_value;
Packit ae235b
  guint32_le parent;
Packit ae235b
Packit ae235b
  guint32_le key_start;
Packit ae235b
  guint16_le key_size;
Packit ae235b
  gchar type;
Packit ae235b
  gchar unused;
Packit ae235b
Packit ae235b
  union
Packit ae235b
  {
Packit ae235b
    struct gvdb_pointer pointer;
Packit ae235b
    gchar direct[8];
Packit ae235b
  } value;
Packit ae235b
};
Packit ae235b
Packit ae235b
struct gvdb_header {
Packit ae235b
  guint32 signature[2];
Packit ae235b
  guint32_le version;
Packit ae235b
  guint32_le options;
Packit ae235b
Packit ae235b
  struct gvdb_pointer root;
Packit ae235b
};
Packit ae235b
Packit ae235b
static inline guint32_le guint32_to_le (guint32 value) {
Packit ae235b
  guint32_le result = { GUINT32_TO_LE (value) };
Packit ae235b
  return result;
Packit ae235b
}
Packit ae235b
Packit ae235b
static inline guint32 guint32_from_le (guint32_le value) {
Packit ae235b
  return GUINT32_FROM_LE (value.value);
Packit ae235b
}
Packit ae235b
Packit ae235b
static inline guint16_le guint16_to_le (guint16 value) {
Packit ae235b
  guint16_le result = { GUINT16_TO_LE (value) };
Packit ae235b
  return result;
Packit ae235b
}
Packit ae235b
Packit ae235b
static inline guint16 guint16_from_le (guint16_le value) {
Packit ae235b
  return GUINT16_FROM_LE (value.value);
Packit ae235b
}
Packit ae235b
Packit ae235b
#define GVDB_SIGNATURE0 1918981703
Packit ae235b
#define GVDB_SIGNATURE1 1953390953
Packit ae235b
#define GVDB_SWAPPED_SIGNATURE0 GUINT32_SWAP_LE_BE (GVDB_SIGNATURE0)
Packit ae235b
#define GVDB_SWAPPED_SIGNATURE1 GUINT32_SWAP_LE_BE (GVDB_SIGNATURE1)
Packit ae235b
Packit ae235b
#endif /* __gvdb_format_h__ */