Merge branch 'odin' of git.hitchhiker-linux.org:jeang3nie/seahag into odin

This commit is contained in:
Nathan Fisher 2023-08-07 23:55:04 -04:00
commit d7a5c40637
10 changed files with 284 additions and 59 deletions

View file

@ -31,10 +31,9 @@
*/ */
#ifndef BYTES_H #ifndef BYTES_H
#define BYTES_H #define BYTES_H 1
#include <stdint.h> #include <stdio.h> // FILE
#include <stdio.h>
#include "haggis.h" #include "haggis.h"

View file

@ -31,10 +31,11 @@
*/ */
#ifndef HAGGIS_H #ifndef HAGGIS_H
#define HAGGIS_H #define HAGGIS_H 1
#include <stdint.h> #include "linklist.h"
#include <stdio.h> #include <stdint.h> // uint<x>_t
#include <stdio.h> // FILE
typedef uint8_t u8; typedef uint8_t u8;
@ -73,12 +74,12 @@ typedef union {
typedef struct { typedef struct {
haggis_algorithm tag; haggis_algorithm tag;
haggis_sum *sum; haggis_sum sum;
} haggis_checksum; } haggis_checksum;
typedef struct { typedef struct {
u64 len; u64 len;
haggis_checksum *cksum; haggis_checksum cksum;
u8 *data; u8 *data;
} haggis_file; } haggis_file;
@ -99,9 +100,9 @@ typedef enum {
} haggis_typeflag; } haggis_typeflag;
typedef union { typedef union {
haggis_file *file; haggis_file file;
haggis_filename *target; haggis_filename target;
haggis_device *dev; haggis_device dev;
} haggis_ft; } haggis_ft;
typedef struct { typedef struct {
@ -118,7 +119,9 @@ typedef struct {
haggis_filetype *filetype; haggis_filetype *filetype;
} haggis_node; } haggis_node;
haggis_node* haggis_create_node(char *file); haggis_node* haggis_node_init();
void haggis_node_deinit(haggis_node *node);
haggis_node* haggis_create_node(char *file, haggis_hardlink_list *list);
int haggis_extract_node(FILE *stram, haggis_node *node); int haggis_extract_node(FILE *stram, haggis_node *node);
int haggis_load_node(FILE *stream, haggis_node *node); int haggis_load_node(FILE *stream, haggis_node *node);
int haggis_store_node(FILE *stream, haggis_node *node); int haggis_store_node(FILE *stream, haggis_node *node);

View file

@ -31,12 +31,9 @@
*/ */
#ifndef JOBQ_H #ifndef JOBQ_H
#define JOBQ_H #define JOBQ_H 1
#include <pthread.h> #include <pthread.h>
#include <stddef.h>
#include <stdlib.h>
#include <sys/_pthreadtypes.h>
#include "haggis.h" #include "haggis.h"

View file

@ -30,8 +30,9 @@
* other than his own. * other than his own.
*/ */
#include <sys/stat.h> #include <limits.h> // PATH_MAX
#include <stdint.h> #include <stdint.h> // uint<x>_t
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
#include <sha.h> #include <sha.h>
#include <sha256.h> #include <sha256.h>
@ -43,16 +44,19 @@
#elif defined(__linux__) #elif defined(__linux__)
#include <sha1.h> #include <sha1.h>
#include <sha2.h> #include <sha2.h>
#include <sys/sysmacros.h> // major, minor, dev_t
#endif /* if defined (__FreeBSD__) */ #endif /* if defined (__FreeBSD__) */
#include <md5.h> #include <md5.h>
#include <stddef.h>
#include <stdio.h> #include <stdio.h> // fopen, fread, fwrite, FILE
#include <stdlib.h> #include <stdlib.h> // free, malloc
#include <string.h> #include <string.h> // memcpy, strlen
#include <unistd.h> // readlink
#include <sys/stat.h> // stat
#include "bytes.h" #include "bytes.h"
#include "haggis.h" #include "haggis.h"
#include "linklist.h"
static unsigned char header[7] = {0x89, 'h', 'a', 'g', 'g', 'i', 's'}; static unsigned char header[7] = {0x89, 'h', 'a', 'g', 'g', 'i', 's'};
@ -71,6 +75,15 @@ int haggis_check_header(FILE *stream) {
return 1; return 1;
} }
void haggis_device_init(dev_t rdev, haggis_device *dev) {
dev->major.val = (uint32_t)major(rdev);
dev->minor.val = (uint32_t)minor(rdev);
}
void haggis_device_deinit(haggis_device *dev) {
free(dev);
}
int haggis_store_device(FILE *stream, haggis_device *dev) { int haggis_store_device(FILE *stream, haggis_device *dev) {
if (fwrite(dev->major.bytes, 1, 4, stream) != 4) if (fwrite(dev->major.bytes, 1, 4, stream) != 4)
return 1; return 1;
@ -80,9 +93,9 @@ int haggis_store_device(FILE *stream, haggis_device *dev) {
} }
int haggis_load_device(FILE *stream, haggis_ft *ft) { int haggis_load_device(FILE *stream, haggis_ft *ft) {
if (fread(ft->dev->major.bytes, 1, 4, stream) != 4) if (fread(ft->dev.major.bytes, 1, 4, stream) != 4)
return 1; return 1;
if (fread(ft->dev->minor.bytes, 1, 4, stream) != 4) if (fread(ft->dev.minor.bytes, 1, 4, stream) != 4)
return 1; return 1;
return 0; return 0;
} }
@ -95,21 +108,21 @@ int haggis_store_cksum(FILE *stream, haggis_checksum *cksum) {
flag = 0; flag = 0;
if (fwrite(&flag, 1, 1, stream) != 1) if (fwrite(&flag, 1, 1, stream) != 1)
return 1; return 1;
if (fwrite(cksum->sum->md5, 1, 16, stream) != 16) if (fwrite(cksum->sum.md5, 1, 16, stream) != 16)
return 1; return 1;
break; break;
case sha1: case sha1:
flag = 1; flag = 1;
if (fwrite(&flag, 1, 1, stream) != 1) if (fwrite(&flag, 1, 1, stream) != 1)
return 1; return 1;
if (fwrite(cksum->sum->sha1, 1, 20, stream) != 20) if (fwrite(cksum->sum.sha1, 1, 20, stream) != 20)
return 1; return 1;
break; break;
case sha256: case sha256:
flag = 2; flag = 2;
if (fwrite(&flag, 1, 1, stream) != 1) if (fwrite(&flag, 1, 1, stream) != 1)
return 1; return 1;
if (fwrite(cksum->sum->sha256, 1, 32, stream) != 32) if (fwrite(cksum->sum.sha256, 1, 32, stream) != 32)
return 1; return 1;
break; break;
case skip: case skip:
@ -129,17 +142,17 @@ int haggis_load_cksum(FILE *stream, haggis_checksum *cksum) {
switch (flag) { switch (flag) {
case md5: case md5:
cksum->tag = 0; cksum->tag = 0;
if (fread(&cksum->sum->md5, 1, 16, stream) != 16) if (fread(&cksum->sum.md5, 1, 16, stream) != 16)
return 1; return 1;
break; break;
case sha1: case sha1:
cksum->tag = 1; cksum->tag = 1;
if (fread(&cksum->sum->sha1, 1, 20, stream) != 20) if (fread(&cksum->sum.sha1, 1, 20, stream) != 20)
return 1; return 1;
break; break;
case sha256: case sha256:
cksum->tag = 2; cksum->tag = 2;
if (fread(&cksum->sum->sha256, 1, 32, stream) != 32) if (fread(&cksum->sum.sha256, 1, 32, stream) != 32)
return 1; return 1;
break; break;
case skip: case skip:
@ -156,7 +169,7 @@ int validate_md5(haggis_file *file) {
MD5Init(&ctx); MD5Init(&ctx);
MD5Update(&ctx, file->data, (size_t)file->len.val); MD5Update(&ctx, file->data, (size_t)file->len.val);
MD5Final(digest, &ctx); MD5Final(digest, &ctx);
if (memcmp(file->cksum->sum->md5, digest, sizeof(digest))) if (memcmp(file->cksum.sum.md5, digest, sizeof(digest)))
return 2; return 2;
return 0; return 0;
} }
@ -169,7 +182,7 @@ int validate_sha1(haggis_file *file) {
SHA1_Init(&ctx); SHA1_Init(&ctx);
SHA1_Update(&ctx, file->data, (size_t)file->len.val); SHA1_Update(&ctx, file->data, (size_t)file->len.val);
SHA1_Final(digest, &ctx); SHA1_Final(digest, &ctx);
if (memcmp(file->cksum->sum->sha1, digest, sizeof(digest))) if (memcmp(file->cksum.sum.sha1, digest, sizeof(digest)))
return 2; return 2;
return 0; return 0;
} }
@ -181,7 +194,7 @@ int validate_sha1(haggis_file *file) {
SHA1Init(&ctx); SHA1Init(&ctx);
SHA1Update(&ctx, file->data, (size_t)file->len.val); SHA1Update(&ctx, file->data, (size_t)file->len.val);
SHA1Final(digest, &ctx); SHA1Final(digest, &ctx);
if (memcmp(file->cksum->sum->sha1, digest, sizeof(digest))) if (memcmp(file->cksum.sum.sha1, digest, sizeof(digest)))
return 2; return 2;
return 0; return 0;
} }
@ -195,7 +208,7 @@ int validate_sha256(haggis_file *file) {
SHA256_Init(&ctx); SHA256_Init(&ctx);
SHA256_Update(&ctx, file->data, (size_t)file->len.val); SHA256_Update(&ctx, file->data, (size_t)file->len.val);
SHA256_Final(digest, &ctx); SHA256_Final(digest, &ctx);
if (memcmp(file->cksum->sum->sha256, digest, sizeof(digest))) if (memcmp(file->cksum.sum.sha256, digest, sizeof(digest)))
return 2; return 2;
return 0; return 0;
} }
@ -207,14 +220,14 @@ int validate_sha256(haggis_file *file) {
SHA256Init(&ctx); SHA256Init(&ctx);
SHA256Update(&ctx, file->data, (size_t)file->len.val); SHA256Update(&ctx, file->data, (size_t)file->len.val);
SHA256Final(digest, &ctx); SHA256Final(digest, &ctx);
if (memcmp(file->cksum->sum->sha256, digest, sizeof(digest))) if (memcmp(file->cksum.sum.sha256, digest, sizeof(digest)))
return 2; return 2;
return 0; return 0;
} }
#endif /* if defined (__FreeBSD__) */ #endif /* if defined (__FreeBSD__) */
int haggis_validate_cksum(haggis_file *file) { int haggis_validate_cksum(haggis_file *file) {
switch (file->cksum->tag) { switch (file->cksum.tag) {
case md5: case md5:
return validate_md5(file); return validate_md5(file);
case sha1: case sha1:
@ -227,10 +240,45 @@ int haggis_validate_cksum(haggis_file *file) {
return 0; return 0;
} }
haggis_file* haggis_file_init(char *path) {
FILE *f;
long len;
haggis_file *hf;
f = fopen(path, "r");
if (f == NULL) return NULL;
if (fseek(f, 0, SEEK_END) == -1) {
fclose(f);
return NULL;
}
len = ftell(f);
if (len == -1) {
fclose(f);
return NULL;
}
hf = malloc(sizeof(haggis_file));
if (hf == NULL) return NULL;
hf->len.val = (uint64_t)len;
rewind(f);
hf->data = malloc((size_t)len);
if (fread(hf->data, 1, (size_t)len, f) != (size_t)len) {
free(hf->data);
free(hf);
fclose(f);
return NULL;
}
fclose(f);
return hf;
}
void haggis_file_deinit(haggis_file *f) {
if (f->data != NULL) free(f->data);
}
int haggis_store_file(FILE *stream, haggis_file *file) { int haggis_store_file(FILE *stream, haggis_file *file) {
if (store_u64(stream, file->len) != 8) if (store_u64(stream, file->len) != 8)
return 1; return 1;
if (haggis_store_cksum(stream, file->cksum) != 0) if (haggis_store_cksum(stream, &file->cksum) != 0)
return 1; return 1;
int res = fwrite(file->data, 1, (size_t)file->len.val, stream); int res = fwrite(file->data, 1, (size_t)file->len.val, stream);
if (res != (size_t)file->len.val) if (res != (size_t)file->len.val)
@ -239,30 +287,38 @@ int haggis_store_file(FILE *stream, haggis_file *file) {
} }
int haggis_load_file(FILE *stream, haggis_ft *ft) { int haggis_load_file(FILE *stream, haggis_ft *ft) {
u64 len; if (load_u64(stream, ft->file.len) != 8)
len.val = 0;
if (load_u64(stream, len) != 8)
return 1; return 1;
ft->file->len = len; if (haggis_load_cksum(stream, &ft->file.cksum) != 0)
if (haggis_load_cksum(stream, ft->file->cksum) != 0)
return 1; return 1;
u8 *data = malloc((size_t)len.val); ft->file.data = malloc((size_t)ft->file.len.val);
if (data == NULL) if (ft->file.data == NULL)
return -1; return -1;
int res = fread(data, 1, (size_t)ft->file->len.val, stream); int res = fread(ft->file.data, 1, (size_t)ft->file.len.val, stream);
if (res != (size_t)ft->file->len.val) { if (res != (size_t)ft->file.len.val) {
free(ft); free(ft);
return 1; return 1;
} }
ft->file->data = data; if (haggis_validate_cksum(&ft->file)) {
if (haggis_validate_cksum(ft->file)) {
free(ft); free(ft);
return 1; return 1;
} }
return 0; return 0;
} }
haggis_filename* haggis_filename_init(char *target, haggis_filename *fname) {
size_t len;
len = strlen(target) - 1;
fname->len.val = (uint16_t)len;
fname->name = target;
return fname;
}
void haggis_filename_deinit(haggis_filename *fname) {
if (fname->name != NULL) free(fname->name);
}
int haggis_load_filename(FILE *stream, haggis_filename *n) { int haggis_load_filename(FILE *stream, haggis_filename *n) {
u16 len; u16 len;
char *name; char *name;
@ -293,10 +349,10 @@ int haggis_load_filetype(FILE *stream, haggis_typeflag tag, haggis_filetype *fil
file->tag = 0; file->tag = 0;
return haggis_load_file(stream, file->f_type); return haggis_load_file(stream, file->f_type);
case hardlink: case hardlink:
return haggis_load_filename(stream, file->f_type->target); return haggis_load_filename(stream, &file->f_type->target);
file->tag = 1; file->tag = 1;
case softlink: case softlink:
return haggis_load_filename(stream, file->f_type->target); return haggis_load_filename(stream, &file->f_type->target);
file->tag = 2; file->tag = 2;
case directory: case directory:
file->tag = 3; file->tag = 3;
@ -325,19 +381,19 @@ int haggis_store_filetype(FILE *stream, haggis_filetype *filetype) {
flag = 0; flag = 0;
if (fwrite(&flag, 1, 1, stream) != 1) if (fwrite(&flag, 1, 1, stream) != 1)
return 1; return 1;
if (haggis_store_file(stream, filetype->f_type->file) != 0) if (haggis_store_file(stream, &filetype->f_type->file) != 0)
return 1; return 1;
break; break;
case hardlink: case hardlink:
flag = 1; flag = 1;
if (fwrite(&flag, 1, 1, stream) != 1) if (fwrite(&flag, 1, 1, stream) != 1)
return 1; return 1;
return haggis_store_filename(stream, filetype->f_type->target); return haggis_store_filename(stream, &filetype->f_type->target);
case softlink: case softlink:
flag = 2; flag = 2;
if (fwrite(&flag, 1, 1, stream) != 1) if (fwrite(&flag, 1, 1, stream) != 1)
return 1; return 1;
return haggis_store_filename(stream, filetype->f_type->target); return haggis_store_filename(stream, &filetype->f_type->target);
case directory: case directory:
flag = 3; flag = 3;
if (fwrite(&flag, 1, 1, stream) != 1) if (fwrite(&flag, 1, 1, stream) != 1)
@ -347,14 +403,14 @@ int haggis_store_filetype(FILE *stream, haggis_filetype *filetype) {
flag = 4; flag = 4;
if (fwrite(&flag, 1, 1, stream) != 1) if (fwrite(&flag, 1, 1, stream) != 1)
return 1; return 1;
if (haggis_store_device(stream, filetype->f_type->dev) != 0) if (haggis_store_device(stream, &filetype->f_type->dev) != 0)
return 1; return 1;
break; break;
case block: case block:
flag = 5; flag = 5;
if (fwrite(&flag, 1, 1, stream) != 1) if (fwrite(&flag, 1, 1, stream) != 1)
return 1; return 1;
if (haggis_store_device(stream, filetype->f_type->dev) != 0) if (haggis_store_device(stream, &filetype->f_type->dev) != 0)
return 1; return 1;
break; break;
case fifo: case fifo:
@ -383,17 +439,50 @@ u16 haggis_derive_mode(u16 raw, haggis_filetype *ft) {
return mode; return mode;
} }
haggis_node* haggis_create_node(char *file) { void haggis_node_deinit(haggis_node *node) {
if (node == NULL) return;
if (node->name != NULL) haggis_filename_deinit(node->name);
switch (node->filetype->tag) {
case normal:
if (node->filetype->f_type->file.data != NULL) {
free(node->filetype->f_type->file.data);
}
break;
case hardlink:
case softlink:
if (node->filetype->f_type->target.name != NULL) {
haggis_filename_deinit(&node->filetype->f_type->target);
}
break;
case character:
case block:
case directory:
case fifo:
case eof:
break;
};
free(node);
}
haggis_node* haggis_create_node(char *file, haggis_hardlink_list *list) {
struct stat *st = NULL; struct stat *st = NULL;
haggis_typeflag tf; haggis_typeflag tf;
u16 mode; u16 mode;
u32 uid; u32 uid;
u32 gid; u32 gid;
u64 mtime; u64 mtime;
haggis_node *node = malloc(sizeof(haggis_node)); char *target;
char pathbuf[PATH_MAX];
haggis_filename *fname;
haggis_file *f;
haggis_node *node;
node = malloc(sizeof(haggis_node));
if (node == NULL) if (node == NULL)
return NULL; return NULL;
node->filetype = malloc(sizeof(haggis_filetype));
if (node->filetype == NULL)
return NULL;
if (stat(file, st) != 0) { if (stat(file, st) != 0) {
free(node); free(node);
return NULL; return NULL;
@ -419,21 +508,93 @@ haggis_node* haggis_create_node(char *file) {
gid.val = (uint32_t)st->st_gid; gid.val = (uint32_t)st->st_gid;
node->gid = gid; node->gid = gid;
mtime.val = (uint64_t)st->st_mtim.tv_sec; mtime.val = (uint64_t)st->st_mtim.tv_sec;
node->mtime = mtime;
mode.val = (uint16_t)(st->st_mode & 07777); mode.val = (uint16_t)(st->st_mode & 07777);
node->mode = mode; node->mode = mode;
switch (tf) { switch (tf) {
case normal: case normal:
target = haggis_linklist_get_or_put(list, st->st_ino, file);
if (target == NULL) {
node->filetype->tag = normal;
f = haggis_file_init(file);
if (f == NULL) {
haggis_node_deinit(node);
return NULL;
}
} else {
node->filetype->tag = hardlink;
fname = haggis_filename_init(target, &node->filetype->f_type->target);
if (fname == NULL) {
haggis_node_deinit(node);
return NULL;
}
}
break;
case block: case block:
target = haggis_linklist_get_or_put(list, st->st_ino, file);
if (target == NULL) {
node->filetype->tag = block;
haggis_device_init(st->st_rdev, &node->filetype->f_type->dev);
} else {
node->filetype->tag = hardlink;
fname = haggis_filename_init(target, &node->filetype->f_type->target);
if (fname == NULL) {
haggis_node_deinit(node);
return NULL;
}
}
break;
case character: case character:
target = haggis_linklist_get_or_put(list, st->st_ino, file);
if (target == NULL) {
node->filetype->tag = character;
haggis_device_init(st->st_rdev, &node->filetype->f_type->dev);
} else {
node->filetype->tag = hardlink;
fname = haggis_filename_init(target, &node->filetype->f_type->target);
if (fname == NULL) {
haggis_node_deinit(node);
return NULL;
}
}
break;
case fifo: case fifo:
target = haggis_linklist_get_or_put(list, st->st_ino, file);
if (target == NULL) {
node->filetype->tag = fifo;
} else {
node->filetype->tag = hardlink;
fname = haggis_filename_init(target, &node->filetype->f_type->target);
if (fname == NULL) {
haggis_node_deinit(node);
return NULL;
}
fname->name = target;
}
break; break;
case directory: case directory:
node->filetype->tag = directory;
break; break;
case hardlink: case hardlink:
node->filetype->tag = hardlink;
break; break;
case softlink: case softlink:
node->filetype->tag = softlink;
ssize_t res = readlink(file, pathbuf, PATH_MAX);
if (res == -1) {
haggis_node_deinit(node);
return NULL;
}
target = malloc(res + 1);
memcpy(target, pathbuf, (unsigned long)res);
fname = haggis_filename_init(target, &node->filetype->f_type->target);
if (fname == NULL) {
haggis_node_deinit(node);
return NULL;
}
break; break;
case eof: case eof:
node->filetype->tag = eof;
break; break;
} }
// todo // todo

View file

@ -29,6 +29,7 @@
* as such so that the author does not get blamed for bugs * as such so that the author does not get blamed for bugs
* other than his own. * other than his own.
*/ */
#include <stdlib.h> // free, malloc
#include "jobq.h" #include "jobq.h"

0
test/Makefile Normal file
View file

0
test/checksum.c Normal file
View file

0
test/device.c Normal file
View file

0
test/filename.c Normal file
View file

64
test/haggis_private.h Normal file
View file

@ -0,0 +1,64 @@
/* _,.---._ .-._ .--.-. ,--.--------.
* _,..---._ ,-.' , - `. /==/ \ .-._/==/ //==/, - , -\
* /==/, - \ /==/_, , - \|==|, \/ /, |==\ -\\==\.-. - ,-./
* |==| _ _\==| .=. |==|- \| | \==\- \`--`\==\- \
* |==| .=. |==|_ : ;=: - |==| , | -| `--`-' \==\_ \
* |==|,| | -|==| , '=' |==| - _ | |==|- |
* |==| '=' /\==\ - ,_ /|==| /\ , | |==|, |
* |==|-, _`/ '.='. - .' /==/, | |- | /==/ -/
* `-.`.____.' `--`--'' `--`./ `--` `--`--`
* _ __ ,---. .-._ .=-.-. _,.----.
* .-`.' ,`..--.' \ /==/ \ .-._ /==/_ /.' .' - \
* /==/, - \==\-/\ \ |==|, \/ /, /==|, |/==/ , ,-'
* |==| _ .=. /==/-|_\ | |==|- \| ||==| ||==|- | .
* |==| , '=',\==\, - \ |==| , | -||==|- ||==|_ `-' \
* |==|- '..'/==/ - ,| |==| - _ ||==| ,||==| _ , |
* |==|, | /==/- /\ - \|==| /\ , ||==|- |\==\. /
* /==/ - | \==\ _.\=\.-'/==/, | |- |/==/. / `-.`.___.-'
* `--`---' `--` `--`./ `--``--`-`
*
* @(#)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_PRIVATE_H
#define HAGGIS_PRIVATE_H 1
#include <stdio.h>
#include <sys/types.h>
#include "haggis.h"
int haggis_store_header(FILE *stream);
int haggis_check_header(FILE *stream);
haggis_device* haggis_device_init(dev_t rdev);
void haggis_device_deinit(haggis_device *dev);
int haggis_store_device(FILE *stream, haggis_device *dev);
int haggis_load_device(FILE *stream, haggis_ft *ft);
int haggis_store_cksum(FILE *stream, haggis_checksum *cksum);
int haggis_load_cksum(FILE *stream, haggis_checksum *cksum);
int validate_md5(haggis_file *file);
int validate_sha1(haggis_file *file);
int validate_sha256(haggis_file *file);
int haggis_validate_cksum(haggis_file *file);
haggis_file* haggis_file_init(char *path);
int haggis_store_file(FILE *stream, haggis_file *file);
int haggis_load_file(FILE *stream, haggis_ft *ft);
haggis_filename* haggis_filename_init(char *target);
void haggis_filename_deinit(haggis_filename *fname);
int haggis_load_filename(FILE *stream, haggis_filename *n);
int haggis_store_filename(FILE *stream, haggis_filename *n);
int haggis_load_filetype(FILE *stream, haggis_typeflag tag, haggis_filetype *file);
int haggis_store_filetype(FILE *stream, haggis_filetype *filetype);
#endif // !HAGGIS_PRIVATE_H