From 30395e5d7ef27690a045bd87ecb76c0f78ecdd09 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Tue, 8 Aug 2023 01:40:21 -0400 Subject: [PATCH] Simplify types --- include/haggis.h | 24 ++++++++++-------------- test/Makefile | 33 +++++++++++++++++++++++++++++++++ test/haggis_private.h | 4 ++-- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/include/haggis.h b/include/haggis.h index e8d5d4c..4b1f602 100644 --- a/include/haggis.h +++ b/include/haggis.h @@ -66,15 +66,13 @@ typedef enum { skip, } haggis_algorithm; -typedef union { - u8 md5[16]; - u8 sha1[20]; - u8 sha256[32]; -} haggis_sum; - typedef struct { haggis_algorithm tag; - haggis_sum sum; + union { + u8 md5[16]; + u8 sha1[20]; + u8 sha256[32]; + } sum; } haggis_checksum; typedef struct { @@ -99,15 +97,13 @@ typedef enum { eof, } haggis_typeflag; -typedef union { - haggis_file file; - haggis_filename target; - haggis_device dev; -} haggis_ft; - typedef struct { haggis_typeflag tag; - haggis_ft f_type; + union { + haggis_file file; + haggis_filename target; + haggis_device dev; + } f_type; } haggis_filetype; typedef struct { diff --git a/test/Makefile b/test/Makefile index e69de29..fc90986 100644 --- a/test/Makefile +++ b/test/Makefile @@ -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. +# + + diff --git a/test/haggis_private.h b/test/haggis_private.h index 4354358..f6aa430 100644 --- a/test/haggis_private.h +++ b/test/haggis_private.h @@ -43,7 +43,7 @@ int haggis_store_header(FILE *stream); int haggis_check_header(FILE *stream); void haggis_device_init(dev_t rdev, 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_load_cksum(FILE *stream, haggis_checksum *cksum); 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_file_init(char *path, haggis_file *hf); 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_deinit(haggis_filename *fname); int haggis_load_filename(FILE *stream, haggis_filename *n);