diff --git a/hex2hcd.c b/hex2hcd.c
index 3da7e68..c2bf411 100644
--- a/hex2hcd.c
+++ b/hex2hcd.c
@@ -26,43 +26,43 @@
static unsigned int asc_to_int(char a)
{
- return a >= 'A' ? (a - 'A') + 10 : a - '0';
+ return a >= 'A' ? (a - 'A') + 10 : a - '0';
}
static unsigned int hex_to_int(const char *h)
{
- return asc_to_int(*h) * 0x10 + asc_to_int(*(h + 1));
+ return asc_to_int(*h) * 0x10 + asc_to_int(*(h + 1));
}
static unsigned int lhex_to_int(const char *h)
{
- return hex_to_int(h) * 0x100 + hex_to_int(h + 2);
+ return hex_to_int(h) * 0x100 + hex_to_int(h + 2);
}
static int check_sum(const char *str, int len)
{
- unsigned int sum, cal;
- int i;
- sum = hex_to_int(str + len - 2);
- for (cal = 0, i = 1; i < len - 2; i += 2)
- cal += hex_to_int(str + i);
- cal = 0x100 - cal & 0xFF;
- return sum == cal;
+ unsigned int sum, cal;
+ int i;
+ sum = hex_to_int(str + len - 2);
+ for (cal = 0, i = 1; i < len - 2; i += 2)
+ cal += hex_to_int(str + i);
+ cal = 0x100 - cal & 0xFF;
+ return sum == cal;
}
static int check_hex_line(const char *str, int len)
{
- if ((str[0] != ':') || (len < 11) || !check_sum(str, len) ||
- (hex_to_int(str + 1) * 2 + 11 != len))
- return 0;
- return 1;
+ if ((str[0] != ':') || (len < 11) || !check_sum(str, len) ||
+ (hex_to_int(str + 1) * 2 + 11 != len))
+ return 0;
+ return 1;
}
static FILE *open_file(const char *fileName, const char *mode)
{
- FILE *f = fopen(fileName, mode);
- if (f == NULL) {
- printf("The file '%s' could not be opened with the following reason\n", fileName);
+ FILE *f = fopen(fileName, mode);
+ if (f == NULL) {
+ printf("The file '%s' could not be opened with the following reason\n", fileName);
printf("%s\n", strerror(errno));
exit(-EIO);
}
@@ -71,78 +71,77 @@ static FILE *open_file(const char *fileName, const char *mode)
int main(int argc, char *argv[])
{
- unsigned int addr = 0;
- char *ifn, *ofn;
- FILE *ifp, *ofp;
- char *rbuf;
- ssize_t len, i;
- size_t buflen;
+ unsigned int addr = 0;
+ char *ifn, *ofn;
+ FILE *ifp, *ofp;
+ char *rbuf;
+ ssize_t len, i;
+ size_t buflen;
- switch (argc) {
- case 2:
- ifn = ofn = argv[1];
- break;
- case 3:
- ifn = argv[1];
- ofn = argv[2];
- break;
- default:
- printf("Usage: %s [