12c7b1c5 (kx 2023-03-24 02:53:04 +0300 1)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 2) #ifndef __BCF_H
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 3) #define __BCF_H
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 4)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 5) /******************************************
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 6) Binary config file format (32-bit only):
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 7) */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 8)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 9) #define BCF_MAG0 0x3f /* b_ident[BI_MAG0] */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 10) #define BCF_MAG1 'B' /* b_ident[BI_MAG1] */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 11) #define BCF_MAG2 'C' /* b_ident[BI_MAG2] */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 12) #define BCF_MAG3 'F' /* b_ident[BI_MAG3] */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 13)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 14) #define BCFMAG "\77BCF"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 15) #define SZBCFMAG 4
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 16)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 17) /* b_ident[BI_CLASS]: */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 18) #define BCF_CLASS_NONE 0 /* invalid class */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 19) #define BCF_CLASS_32 1 /* 32-bit objects */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 20) #define BCF_CLASS_64 2 /* 64-bit objects (reserved) */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 21)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 22) /* b_ident[BI_DATA]: */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 23) #define BCF_DATA_NONE 0 /* invalid data encoding */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 24) #define BCF_DATA_LSB 1 /* Least Significant Byte */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 25) #define BCF_DATA_MSB 2 /* Most Significant Byte */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 26)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 27) #define BV_NONE 0 /* invalid version */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 28) #define BV_CURRENT 1 /* current file version b_ident[BI_VERSION] */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 29)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 30) #define BCF_PAD 8 /* start of padding bytes in b_ident b_ident[BI_PAD] */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 31)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 32) #define BI_MAG0 0 /* file identification */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 33) #define BI_MAG1 1 /* file identification */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 34) #define BI_MAG2 2 /* file identification */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 35) #define BI_MAG3 3 /* file identification */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 36) #define BI_CLASS 4 /* file class */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 37) #define BI_DATA 5 /* data encoding */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 38) #define BI_VERSION 6 /* file version */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 39) #define BI_PAD 7 /* start of padding bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 40)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 41) #define BI_NIDENT (16) /* size of b_ident[] */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 42)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 43) #define SI_NIDENT (8) /* size of b_ident[] */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 44)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 45) /* Type for a 16-bit quantity: */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 46) typedef uint16_t Bcf32_Half;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 47)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 48) /* Type for a 32-bit quantity: */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 49) typedef uint32_t Bcf32_Word;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 50) typedef int32_t Bcf32_Sword;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 51)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 52) /* Type for a 64-bit quantity: */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 53) typedef uint64_t Bcf32_Xword;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 54) typedef int64_t Bcf32_Sxword;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 55)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 56) /* Types of address: */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 57) typedef uint32_t Bcf32_Addr;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 58)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 59) /* Types of file offsets: */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 60) typedef uint32_t Bcf32_Off;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 61)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 62) typedef struct {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 63) unsigned char b_ident[BI_NIDENT];
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 64) Bcf32_Half b_hsize; /* BCF header's size in bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 65) Bcf32_Word b_fsize; /* Whole BCF file size in bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 66)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 67) Bcf32_Off b_shoff; /* section header table’s file offset in bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 68) Bcf32_Half b_shentsize; /* section header's size in bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 69) Bcf32_Half b_shnum; /* number of entries in section headers table */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 70)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 71) Bcf32_Off b_rhoff; /* repository header table’s file offset in bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 72) Bcf32_Half b_rhentsize; /* repository header's size in bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 73) Bcf32_Half b_rhnum; /* number of entries in repository headers table */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 74)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 75) Bcf32_Off b_dtoff; /* data entries table’s file offset in bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 76) Bcf32_Half b_dtentsize; /* data entry's size in bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 77) Bcf32_Half b_dtnum; /* number of entries in data entries table */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 78)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 79) Bcf32_Off b_stoff; /* string table’s file offset in bytes */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 80) } __attribute__ ((packed)) Bcf32_fhdr;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 81)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 82) /* Type of setcions: */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 83) #define ST_GLOBAL 1 /* this section contains variable entries only */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 84) #define ST_REPOS 2 /* this section contains repository entries only */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 85)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 86) #define SMAG_GLOBAL ".global"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 87) #define SMAG_REPOS ".repos"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 88)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 89) typedef struct {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 90) unsigned char s_name[SI_NIDENT];
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 91) Bcf32_Half s_type; /* .global or .repos */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 92) Bcf32_Off s_shdr; /* section header's offset in the string table */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 93) Bcf32_Off s_sdata; /* section data/repos's file offset */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 94) Bcf32_Half s_dnum; /* number of data/repos entries in section */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 95) } __attribute__ ((packed)) Bcf32_shdr;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 96)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 97) typedef struct {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 98) Bcf32_Off r_rhdr; /* repo header's offset in the string table */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 99) Bcf32_Off r_rdata; /* repo data's file offset */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 100) Bcf32_Half r_dnum; /* number of data entries in repo */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 101) } __attribute__ ((packed)) Bcf32_rhdr;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 102)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 103) #define DT_NUMERICAL 0x01
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 104) #define DT_PATH 0x02
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 105) #define DT_STRING 0x04
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 106)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 107) typedef struct {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 108) Bcf32_Off d_name; /* variable name's offset in the string table */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 109) union
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 110) {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 111) Bcf32_Word d_value; /* numerical variable's value */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 112) Bcf32_Off d_valptr; /* variable value's offset in string table */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 113) } _v;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 114) Bcf32_Half d_type; /* 0x01 - numerical, 0x02 - path, 0x04 - string */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 115) } __attribute__ ((packed)) Bcf32_dntr;
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 116)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 117) /************************
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 118) Shared memory (POSIX API):
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 119) */
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 120) #define CSVN_SHM_BCF "/csvn.bcf"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 121) #define CGIT_SHM_BCF "/cgit.bcf"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 122)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 123) #endif /* __BCF_H */