58 lines
1.9 KiB
C
58 lines
1.9 KiB
C
#ifndef ZYB_HEADERS_H
|
|
#define ZYB_HEADERS_H
|
|
|
|
// libc
|
|
#include <sys/types.h>
|
|
|
|
#define ZYB_MAGIC "ZYB\0"
|
|
#define ZYB_DEP_MAGIC "DEP\0"
|
|
#define ZYB_FILE_MAGIC "ZIP\0"
|
|
#define ZYB_FORMAT_VER 1
|
|
#define ZYB_NAME_LENGTH 100
|
|
|
|
/*
|
|
* This struct is the very first thing in any .zyb file.
|
|
* It contains package metadata, such as the name and dependencies.
|
|
*/
|
|
struct __attribute__((__packed__, aligned(2))) zyb_header {
|
|
/*
|
|
* This struct is the first part of the header,
|
|
* containing critical information about the package.
|
|
*/
|
|
struct __attribute__((__packed__, aligned(2))) lead {
|
|
char magic[4]; // Magic (ZYB_MAGIC)
|
|
unsigned short version; // Format version (ZYB_FORMAT_VER)
|
|
char arch[6]; // Magic identifying arch
|
|
char os[6]; // Magic identifying os
|
|
char name[ZYB_NAME_LENGTH]; // Name of the package
|
|
unsigned short major, minor, patch; // SemVer
|
|
unsigned short dependencies; // Number of dependencies
|
|
unsigned char reserved[2]; // Padding
|
|
} leader;
|
|
/*
|
|
* This struct contains information about each dependency.
|
|
* The number of these struct should EXACTLY be lead.dependencies.
|
|
*/
|
|
struct __attribute__((__packed__, aligned(2))) dependency {
|
|
char magic[4]; // Magic (ZYB_DEP_MAGIC)
|
|
char name[ZYB_NAME_LENGTH]; // Name of the dependency
|
|
unsigned short major, minor, patch; // Minimum SemVer
|
|
unsigned char reserved[2]; // Padding
|
|
} dependencies[0];
|
|
};
|
|
|
|
/*
|
|
* This struct appends every single file in the .zyb.
|
|
* It contains metadata for the individual files in the package.
|
|
* WARNING: CHECKSUM IS FOR THE UNZIPPED FILE.
|
|
*/
|
|
struct __attribute__((__packed__, aligned(2))) zyb_file_header {
|
|
char magic[4]; // Magic (ZYB_FILE_MAGIC)
|
|
char *path; // Destination path of the file
|
|
mode_t permissions; // UNIX permission attributes (32 bits)
|
|
off_t length; // File length (64 bits)
|
|
unsigned char checksum[32]; // Checksum of the unzipped file
|
|
unsigned char reserved[2]; // Padding
|
|
};
|
|
|
|
#endif
|