summaryrefslogtreecommitdiffstats
path: root/yamdrv/mcs2h.c
diff options
context:
space:
mode:
Diffstat (limited to 'yamdrv/mcs2h.c')
-rw-r--r--yamdrv/mcs2h.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/yamdrv/mcs2h.c b/yamdrv/mcs2h.c
index 6914965..bf1ae72 100644
--- a/yamdrv/mcs2h.c
+++ b/yamdrv/mcs2h.c
@@ -6,12 +6,12 @@ int in2hex(char *ptr)
{
char str[3];
int val;
-
+
memcpy(str, ptr, 2);
str[2] = '\0';
-
+
sscanf(str, "%x", &val);
-
+
return val;
}
@@ -19,7 +19,7 @@ unsigned char swap(unsigned char c)
{
unsigned char r = 0;
int i;
-
+
for (i = 0 ; i < 8 ; i++)
{
r <<= 1;
@@ -34,12 +34,12 @@ int in4hex(char *ptr)
{
char str[5];
int val;
-
+
memcpy(str, ptr, 4);
str[4] = '\0';
-
+
sscanf(str, "%x", &val);
-
+
return val;
}
@@ -50,22 +50,22 @@ int main(int ac, char *av[])
time_t temps;
FILE *fptr;
char buf[256];
-
+
if (ac != 3)
{
fprintf(stderr, "format : mcs2h 1200|9600 filename\n");
return 1;
}
-
+
fptr = fopen(av[2], "r");
if (fptr == NULL)
{
fprintf(stderr, "file %s not found\n", av[2]);
return 1;
}
-
+
time(&temps);
-
+
printf( "/*\n"
" *\n"
" * File %s converted to h format by mcs2h\n"
@@ -84,10 +84,10 @@ int main(int ac, char *av[])
nb = in2hex(buf+1);
add = in4hex(buf+3);
type = in2hex(buf+7);
-
+
if (type != 0)
continue;
-
+
if (first)
first = 0;
else
@@ -98,9 +98,9 @@ int main(int ac, char *av[])
printf("0x%02x%s", swap(in2hex(buf+9+i*2)), (i < (nb-1)) ? "," : "");
}
}
-
+
printf(" };\n");
-
+
fclose(fptr);
return 0;
}