seahag/include/haggis.h

122 lines
3 KiB
C
Raw Normal View History

2023-07-19 23:42:04 -04:00
/* _,.---._ .-._ .--.-. ,--.--------.
* _,..---._ ,-.' , - `. /==/ \ .-._/==/ //==/, - , -\
* /==/, - \ /==/_, , - \|==|, \/ /, |==\ -\\==\.-. - ,-./
* |==| _ _\==| .=. |==|- \| | \==\- \`--`\==\- \
* |==| .=. |==|_ : ;=: - |==| , | -| `--`-' \==\_ \
* |==|,| | -|==| , '=' |==| - _ | |==|- |
* |==| '=' /\==\ - ,_ /|==| /\ , | |==|, |
* |==|-, _`/ '.='. - .' /==/, | |- | /==/ -/
* `-.`.____.' `--`--'' `--`./ `--` `--`--`
* _ __ ,---. .-._ .=-.-. _,.----.
* .-`.' ,`..--.' \ /==/ \ .-._ /==/_ /.' .' - \
* /==/, - \==\-/\ \ |==|, \/ /, /==|, |/==/ , ,-'
* |==| _ .=. /==/-|_\ | |==|- \| ||==| ||==|- | .
* |==| , '=',\==\, - \ |==| , | -||==|- ||==|_ `-' \
* |==|- '..'/==/ - ,| |==| - _ ||==| ,||==| _ , |
* |==|, | /==/- /\ - \|==| /\ , ||==|- |\==\. /
* /==/ - | \==\ _.\=\.-'/==/, | |- |/==/. / `-.`.___.-'
* `--`---' `--` `--`./ `--``--`-`
*
* @(#)Copyright (c) 2023, Nathan D. Fisher.
*
* This is free software. It comes with NO WARRANTY.
* Permission to use, modify and distribute this source code
* is granted subject to the following conditions.
* 1/ that the above copyright notice and this notice
* are preserved in all copies and that due credit be given
* to the author.
* 2/ that any changes to this code are clearly commented
* as such so that the author does not get blamed for bugs
* other than his own.
*/
#ifndef HAGGIS_H
#define HAGGIS_H
#include <stdint.h>
#include <stdio.h>
2023-07-19 23:42:04 -04:00
typedef uint8_t u8;
union u16 {
uint16_t val;
u8 bytes[2];
};
union u32 {
uint32_t val;
u8 bytes[4];
};
union u64 {
uint64_t val;
u8 bytes[8];
};
2023-07-19 23:42:04 -04:00
struct haggis_device {
union u32 major;
union u32 minor;
2023-07-19 23:42:04 -04:00
};
enum haggis_algorithm {
md5,
sha1,
sha256,
skip,
};
union haggis_sum {
u8 md5[16];
u8 sha1[20];
u8 sha256[32];
2023-07-19 23:42:04 -04:00
};
struct haggis_checksum {
enum haggis_algorithm tag;
union haggis_sum *sum;
};
struct haggis_file {
union u64 len;
2023-07-19 23:42:04 -04:00
struct haggis_checksum *cksum;
2023-07-23 23:42:51 -04:00
u8 *data;
};
struct haggis_filename {
union u16 len;
2023-07-23 23:42:51 -04:00
char *name;
2023-07-19 23:42:04 -04:00
};
enum haggis_typeflag {
normal,
hardlink,
softlink,
directory,
character,
block,
fifo,
eof,
};
union haggis_ft {
struct haggis_file *file;
struct haggis_filename *target;
2023-07-19 23:42:04 -04:00
struct haggis_device *dev;
};
struct haggis_filetype {
enum haggis_typeflag tag;
union haggis_ft *f_type;
};
struct haggis_node {
2023-07-23 23:42:51 -04:00
struct haggis_filename *name;
union u32 uid;
union u32 gid;
union u64 mtime;
union u16 mode;
2023-07-19 23:42:04 -04:00
struct haggis_filetype *filetype;
};
#endif // !HAGGIS_H