aboutsummaryrefslogtreecommitdiff
path: root/tools/hex2bin-2.0/src/common.h
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-11-05 11:22:55 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-11-05 11:31:28 +0000
commit2fbdf974338bde8576efdae40a819a76b2391033 (patch)
tree64d41a37470143f142344f9a439d96de3e7918c2 /tools/hex2bin-2.0/src/common.h
downloadkitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.tar.gz
kitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.zip
Initial import of the open source release
Diffstat (limited to 'tools/hex2bin-2.0/src/common.h')
-rw-r--r--tools/hex2bin-2.0/src/common.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/tools/hex2bin-2.0/src/common.h b/tools/hex2bin-2.0/src/common.h
new file mode 100644
index 0000000..64caff5
--- /dev/null
+++ b/tools/hex2bin-2.0/src/common.h
@@ -0,0 +1,116 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "binary.h"
+#include "libcrc.h"
+
+/* To compile with Microsoft Visual Studio */
+#ifdef _MSC_VER
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#if defined(MSDOS) || defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS)
+#define _IS_OPTION_(x) (((x) == '-') || ((x) == '/'))
+#else
+/* Assume unix and similar */
+/* We don't accept an option beginning with a '/' because it could be a file name. */
+#define _IS_OPTION_(x) ((x) == '-')
+#endif
+
+/* We use buffer to speed disk access. */
+#ifdef USE_FILE_BUFFERS
+#define BUFFSZ 4096
+#endif
+
+/* FIXME how to get it from the system/OS? */
+#define MAX_FILE_NAME_SIZE 81
+
+#ifdef DOS
+#define MAX_EXTENSION_SIZE 4
+#else
+#define MAX_EXTENSION_SIZE 16
+#endif
+
+/* The data records can contain 255 bytes: this means 512 characters. */
+#define MAX_LINE_SIZE 1024
+
+typedef char filetype[MAX_FILE_NAME_SIZE];
+typedef unsigned char byte;
+typedef unsigned short word;
+
+#define LAST_CHECK_METHOD 4
+
+typedef enum Crc
+{
+ CHK8_SUM =0,
+ CHK16,
+ CRC8,
+ CRC16,
+ CRC32
+} t_CRC;
+
+extern const char *Pgm_Name;
+void usage(void);
+void DisplayCheckMethods(void);
+
+void *NoFailMalloc (size_t size);
+void NoFailOpenInputFile (char *Flnm);
+void NoFailOpenOutputFile (char *Flnm);
+void GetLine(char* str,FILE *in);
+int GetBin(const char *str);
+int GetDec(const char *str);
+int GetHex(const char *str);
+bool GetBoolean(const char *str);
+void GetExtension(const char *str,char *ext);
+void PutExtension(char *Flnm, char *Extension);
+
+filetype Filename; /* string for opening files */
+char Extension[MAX_EXTENSION_SIZE]; /* filename extension for output files */
+
+FILE *Filin, /* input files */
+ *Filout; /* output files */
+
+#ifdef USE_FILE_BUFFERS
+char *FilinBuf, /* text buffer for file input */
+ *FiloutBuf; /* text buffer for file output */
+#endif
+
+int Pad_Byte;
+bool Enable_Checksum_Error;
+bool Status_Checksum_Error;
+byte Checksum;
+unsigned int Record_Nb;
+
+/* This will hold binary codes translated from hex file. */
+byte *Memory_Block;
+unsigned int Lowest_Address, Highest_Address;
+unsigned int Starting_Address;
+unsigned int Max_Length;
+unsigned int Minimum_Block_Size;
+int Module;
+bool Minimum_Block_Size_Setted;
+bool Starting_Address_Setted;
+bool Max_Length_Setted;
+bool Swap_Wordwise;
+
+int Endian;
+
+t_CRC Cks_Type;
+unsigned int Cks_Start, Cks_End, Cks_Addr, Cks_Value;
+bool Cks_range_set;
+bool Cks_Addr_set;
+bool Force_Value;
+
+unsigned int Crc_Poly, Crc_Init, Crc_XorOut;
+bool Crc_RefIn;
+bool Crc_RefOut;
+
+void VerifyChecksumValue(void);
+void CrcParamsCheck(void);
+void WriteMemBlock16(uint16_t Value);
+void WriteMemBlock32(uint32_t Value);
+void WriteMemory(void);
+