5 kx
5 kx #ifndef __BCF_H
5 kx #define __BCF_H
5 kx
5 kx /******************************************
5 kx Binary config file format (32-bit only):
5 kx */
5 kx
5 kx #define BCF_MAG0 0x3f /* b_ident[BI_MAG0] */
5 kx #define BCF_MAG1 'B' /* b_ident[BI_MAG1] */
5 kx #define BCF_MAG2 'C' /* b_ident[BI_MAG2] */
5 kx #define BCF_MAG3 'F' /* b_ident[BI_MAG3] */
5 kx
5 kx #define BCFMAG "\77BCF"
5 kx #define SZBCFMAG 4
5 kx
5 kx /* b_ident[BI_CLASS]: */
5 kx #define BCF_CLASS_NONE 0 /* invalid class */
5 kx #define BCF_CLASS_32 1 /* 32-bit objects */
5 kx #define BCF_CLASS_64 2 /* 64-bit objects (reserved) */
5 kx
5 kx /* b_ident[BI_DATA]: */
5 kx #define BCF_DATA_NONE 0 /* invalid data encoding */
5 kx #define BCF_DATA_LSB 1 /* Least Significant Byte */
5 kx #define BCF_DATA_MSB 2 /* Most Significant Byte */
5 kx
5 kx #define BV_NONE 0 /* invalid version */
5 kx #define BV_CURRENT 1 /* current file version b_ident[BI_VERSION] */
5 kx
5 kx #define BCF_PAD 8 /* start of padding bytes in b_ident b_ident[BI_PAD] */
5 kx
5 kx #define BI_MAG0 0 /* file identification */
5 kx #define BI_MAG1 1 /* file identification */
5 kx #define BI_MAG2 2 /* file identification */
5 kx #define BI_MAG3 3 /* file identification */
5 kx #define BI_CLASS 4 /* file class */
5 kx #define BI_DATA 5 /* data encoding */
5 kx #define BI_VERSION 6 /* file version */
5 kx #define BI_PAD 7 /* start of padding bytes */
5 kx
5 kx #define BI_NIDENT (16) /* size of b_ident[] */
5 kx
5 kx #define SI_NIDENT (8) /* size of b_ident[] */
5 kx
5 kx /* Type for a 16-bit quantity: */
5 kx typedef uint16_t Bcf32_Half;
5 kx
5 kx /* Type for a 32-bit quantity: */
5 kx typedef uint32_t Bcf32_Word;
5 kx typedef int32_t Bcf32_Sword;
5 kx
5 kx /* Type for a 64-bit quantity: */
5 kx typedef uint64_t Bcf32_Xword;
5 kx typedef int64_t Bcf32_Sxword;
5 kx
5 kx /* Types of address: */
5 kx typedef uint32_t Bcf32_Addr;
5 kx
5 kx /* Types of file offsets: */
5 kx typedef uint32_t Bcf32_Off;
5 kx
5 kx typedef struct {
5 kx unsigned char b_ident[BI_NIDENT];
5 kx Bcf32_Half b_hsize; /* BCF header's size in bytes */
5 kx Bcf32_Word b_fsize; /* Whole BCF file size in bytes */
5 kx
5 kx Bcf32_Off b_shoff; /* section header table’s file offset in bytes */
5 kx Bcf32_Half b_shentsize; /* section header's size in bytes */
5 kx Bcf32_Half b_shnum; /* number of entries in section headers table */
5 kx
5 kx Bcf32_Off b_rhoff; /* repository header table’s file offset in bytes */
5 kx Bcf32_Half b_rhentsize; /* repository header's size in bytes */
5 kx Bcf32_Half b_rhnum; /* number of entries in repository headers table */
5 kx
5 kx Bcf32_Off b_dtoff; /* data entries table’s file offset in bytes */
5 kx Bcf32_Half b_dtentsize; /* data entry's size in bytes */
5 kx Bcf32_Half b_dtnum; /* number of entries in data entries table */
5 kx
5 kx Bcf32_Off b_stoff; /* string table’s file offset in bytes */
5 kx } __attribute__ ((packed)) Bcf32_fhdr;
5 kx
5 kx /* Type of setcions: */
5 kx #define ST_GLOBAL 1 /* this section contains variable entries only */
5 kx #define ST_REPOS 2 /* this section contains repository entries only */
5 kx
5 kx #define SMAG_GLOBAL ".global"
5 kx #define SMAG_REPOS ".repos"
5 kx
5 kx typedef struct {
5 kx unsigned char s_name[SI_NIDENT];
5 kx Bcf32_Half s_type; /* .global or .repos */
5 kx Bcf32_Off s_shdr; /* section header's offset in the string table */
5 kx Bcf32_Off s_sdata; /* section data/repos's file offset */
5 kx Bcf32_Half s_dnum; /* number of data/repos entries in section */
5 kx } __attribute__ ((packed)) Bcf32_shdr;
5 kx
5 kx typedef struct {
5 kx Bcf32_Off r_rhdr; /* repo header's offset in the string table */
5 kx Bcf32_Off r_rdata; /* repo data's file offset */
5 kx Bcf32_Half r_dnum; /* number of data entries in repo */
5 kx } __attribute__ ((packed)) Bcf32_rhdr;
5 kx
5 kx #define DT_NUMERICAL 0x01
5 kx #define DT_PATH 0x02
5 kx #define DT_STRING 0x04
5 kx
5 kx typedef struct {
5 kx Bcf32_Off d_name; /* variable name's offset in the string table */
5 kx union
5 kx {
5 kx Bcf32_Word d_value; /* numerical variable's value */
5 kx Bcf32_Off d_valptr; /* variable value's offset in string table */
5 kx } _v;
5 kx Bcf32_Half d_type; /* 0x01 - numerical, 0x02 - path, 0x04 - string */
5 kx } __attribute__ ((packed)) Bcf32_dntr;
5 kx
5 kx /************************
5 kx Shared memory (POSIX API):
5 kx */
5 kx #define CSVN_SHM_BCF "/csvn.bcf"
5 kx #define CGIT_SHM_BCF "/cgit.bcf"
5 kx
5 kx #endif /* __BCF_H */