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