Simplify types

This commit is contained in:
Nathan Fisher 2023-08-08 01:40:21 -04:00
parent 9457d03a45
commit 30395e5d7e
3 changed files with 45 additions and 16 deletions

View file

@ -66,15 +66,13 @@ typedef enum {
skip, skip,
} haggis_algorithm; } haggis_algorithm;
typedef union { typedef struct {
haggis_algorithm tag;
union {
u8 md5[16]; u8 md5[16];
u8 sha1[20]; u8 sha1[20];
u8 sha256[32]; u8 sha256[32];
} haggis_sum; } sum;
typedef struct {
haggis_algorithm tag;
haggis_sum sum;
} haggis_checksum; } haggis_checksum;
typedef struct { typedef struct {
@ -99,15 +97,13 @@ typedef enum {
eof, eof,
} haggis_typeflag; } haggis_typeflag;
typedef union { typedef struct {
haggis_typeflag tag;
union {
haggis_file file; haggis_file file;
haggis_filename target; haggis_filename target;
haggis_device dev; haggis_device dev;
} haggis_ft; } f_type;
typedef struct {
haggis_typeflag tag;
haggis_ft f_type;
} haggis_filetype; } haggis_filetype;
typedef struct { typedef struct {

View file

@ -0,0 +1,33 @@
# _,.---._ .-._ .--.-. ,--.--------.
# _,..---._ ,-.' , - `. /==/ \ .-._/==/ //==/, - , -\
# /==/, - \ /==/_, , - \|==|, \/ /, |==\ -\\==\.-. - ,-./
# |==| _ _\==| .=. |==|- \| | \==\- \`--`\==\- \
# |==| .=. |==|_ : ;=: - |==| , | -| `--`-' \==\_ \
# |==|,| | -|==| , '=' |==| - _ | |==|- |
# |==| '=' /\==\ - ,_ /|==| /\ , | |==|, |
# |==|-, _`/ '.='. - .' /==/, | |- | /==/ -/
# `-.`.____.' `--`--'' `--`./ `--` `--`--`
# _ __ ,---. .-._ .=-.-. _,.----.
# .-`.' ,`..--.' \ /==/ \ .-._ /==/_ /.' .' - \
# /==/, - \==\-/\ \ |==|, \/ /, /==|, |/==/ , ,-'
# |==| _ .=. /==/-|_\ | |==|- \| ||==| ||==|- | .
# |==| , '=',\==\, - \ |==| , | -||==|- ||==|_ `-' \
# |==|- '..'/==/ - ,| |==| - _ ||==| ,||==| _ , |
# |==|, | /==/- /\ - \|==| /\ , ||==|- |\==\. /
# /==/ - | \==\ _.\=\.-'/==/, | |- |/==/. / `-.`.___.-'
# `--`---' `--` `--`./ `--``--`-`
#
# @(#)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.
#

View file

@ -43,7 +43,7 @@ int haggis_store_header(FILE *stream);
int haggis_check_header(FILE *stream); int haggis_check_header(FILE *stream);
void haggis_device_init(dev_t rdev, haggis_device *dev); void haggis_device_init(dev_t rdev, haggis_device *dev);
int haggis_store_device(FILE *stream, haggis_device *dev); 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_device *dev);
int haggis_store_cksum(FILE *stream, haggis_checksum *cksum); int haggis_store_cksum(FILE *stream, haggis_checksum *cksum);
int haggis_load_cksum(FILE *stream, haggis_checksum *cksum); int haggis_load_cksum(FILE *stream, haggis_checksum *cksum);
int validate_md5(haggis_file *file); int validate_md5(haggis_file *file);
@ -52,7 +52,7 @@ int validate_sha256(haggis_file *file);
int haggis_validate_cksum(haggis_file *file); int haggis_validate_cksum(haggis_file *file);
int haggis_file_init(char *path, haggis_file *hf); int haggis_file_init(char *path, haggis_file *hf);
int haggis_store_file(FILE *stream, haggis_file *file); 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_file *f);
void haggis_filename_init(char *target, haggis_filename *fname); void haggis_filename_init(char *target, haggis_filename *fname);
void haggis_filename_deinit(haggis_filename *fname); void haggis_filename_deinit(haggis_filename *fname);
int haggis_load_filename(FILE *stream, haggis_filename *n); int haggis_load_filename(FILE *stream, haggis_filename *n);