Newer
Older
ubixfs-2 / btree_types.h
#ifndef BTREE_TYPES_H 
#define BTREE_TYPES_H

typedef signed char            int8;
typedef signed short int       int16;
typedef signed long int        int32;
typedef signed long long int   int64;
typedef unsigned char          uInt8;
typedef unsigned short int     uInt16;
typedef unsigned int           uInt32;
typedef unsigned long long int uInt64;

enum treeTypes { BT_CUSTOM, BT_PCHAR, BT_STRING, BT_SINGLE, BT_DOUBLE, BT_INT32, BT_INT64 };

typedef struct TblockRun {
  int32  AG;
  uInt16 start;
  uInt16 len;
} __attribute__((__packed__));

typedef TblockRun inodeAddr;

struct TbNode;

typedef union {
  int32     i;
  uInt32    u;
  float     f;
  double    d;
  void    * p;
  TbNode  * bPtr;
  inodeAddr iAddr;
  int64     offset;
} uPtr;

typedef struct bTreeSearch {
  uPtr      value;
  void *    key;
  int       keySize;
}; // bTreeSearchRec

typedef struct bTreeInfo {
  int64     magic;
  uPtr      root;
  uPtr      firstDeleted;
  uInt32    nodes;
  uInt32    height;
  uInt32    keys;
  uInt32    bNodeSize;
  treeTypes treeType;
} __attribute__((__packed__));

typedef struct TbNodeData {
  uPtr      link;
  union {
    char    str[1];
    float   f;
    double  d;
    int32   i;
    int64   x;
  } key;
} __attribute__((__packed__));

typedef struct TbNode {
  uInt32    magic;
  uInt32    tag;
  uInt32    numKeys;
  uInt32    size;
  uPtr      left;
  uPtr      right;
  uPtr      parent;
  uPtr      reserved;
  TbNodeData data;
} __attribute__((__packed__));

#endif