A qubtree file is little-endian binary.  It begins with the "magic" string:

#define QTR_MAGIC               "QUB_(;-)_QFS"

followed immediately by the root node.


Each node has the following structure:

typedef struct {
  unsigned char flags[3];           // see below
  unsigned char dataType;           // see below
  unsigned int dataSize;            // see "conceptual overview"
  unsigned int dataCount;
  unsigned int dataPos;             // offset in bytes of the beginning of data in the file, or NULL if none (see DATA_IN_NODE below)
  unsigned int childPos;            // offset in bytes of the child node in the file, or NULL if none
  unsigned int siblingPos;          // offset in bytes of the sibling node in the file, or NULL if none
  unsigned char reserved[ 7 ];      // (zero)
  unsigned char nameLen;            // length of the node's name in bytes
  // name goes here                 // the name follows immediately after the node
} QTR_OnDisk;




#define QTR_FLAG_PRELOAD             0x000002         // all data will be loaded when file is opened
#define QTR_FLAG_DATA_IN_NODE        0x000004         // dataPos contains the data itself rather than a byte offset
                                                      // (for data that takes <= 4 bytes)


enum QTR_DataType { QTR_TYPE_EMPTY,          // no data
                    QTR_TYPE_UNKNOWN,
                    QTR_TYPE_POINTER,
                    QTR_TYPE_STRING,         // ASCII
		    QTR_TYPE_UCHAR,          // 1 byte int, unsigned
                    QTR_TYPE_CHAR,           // 1 byte int
                    QTR_TYPE_USHORT,         // 2 byte int, unsigned
                    QTR_TYPE_SHORT,          // 2 byte int, signed
                    QTR_TYPE_UINT,           // 4 byte int, unsigned
                    QTR_TYPE_INT,            // 4 byte int, signed
		    QTR_TYPE_ULONG,          // 8 byte int, unsigned  *unsupported*
                    QTR_TYPE_LONG,           // 8 byte int, signed    *unsupported*
                    QTR_TYPE_FLOAT,          // 4 byte float
                    QTR_TYPE_DOUBLE,         // 8 byte float
                    QTR_TYPE_LDOUBLE         // 10 byte float         *unsupported*
                  }; 


