OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /eco32/tags/eco32-0.24/stdalone/twotasks-1/dump
    from Rev 18 to Rev 211
    Reverse comparison

Rev 18 → Rev 211

/dump.c
0,0 → 1,48
/*
* dump.c -- dump a binary file as contents of a C array
*/
 
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
 
int main(int argc, char *argv[]) {
FILE *infile, *outfile;
int c, n;
 
if (argc != 3) {
printf("Usage: %s <infile> <outfile>\n", argv[0]);
return 1;
}
infile = fopen(argv[1], "rb");
if (infile == NULL) {
printf("Error: cannot open file '%s' for input\n", argv[1]);
return 1;
}
outfile = fopen(argv[2], "wt");
if (outfile == NULL) {
printf("Error: cannot open file '%s' for output\n", argv[2]);
return 1;
}
n = 0;
while (1) {
c = getc(infile);
if (c == EOF) {
break;
}
fprintf(outfile, "0x%02X, ", c);
n++;
if (n == 8) {
n = 0;
fprintf(outfile, "\n");
}
}
if (n != 0) {
fprintf(outfile, "\n");
}
fclose(infile);
fclose(outfile);
return 0;
}
/Makefile
0,0 → 1,15
#
# Makefile for dump utility
#
 
.PHONY: all install clean
 
all: dump
 
install: dump
 
dump: dump.c
gcc -m32 -g -Wall -o dump dump.c
 
clean:
rm -f *~ dump

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.