ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/BeOS/CreatePCIDrivers/hexconv.cpp
Revision: 1.1.1.1 (vendor branch)
Committed: 2002-02-04T16:58:13Z (22 years, 10 months ago) by cebix
Branch: MAIN, cebix
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
Imported sources

File Contents

# User Rev Content
1 cebix 1.1 #include <stdio.h>
2    
3     int main(int argc, char **argv)
4     {
5     if (argc != 3) {
6     printf("Usage: %s <raw file> <C source>\n", argv[0]);
7     return 0;
8     }
9    
10     FILE *fin = fopen(argv[1], "rb");
11     if (fin == NULL) {
12     printf("Can't open '%s' for reading\n", argv[1]);
13     return 0;
14     }
15    
16     FILE *fout = fopen(argv[2], "w");
17     if (fout == NULL) {
18     printf("Can't open '%s' for writing\n", argv[2]);
19     return 0;
20     }
21    
22     unsigned char buf[16];
23     while (!feof(fin)) {
24     fprintf(fout, "\t");
25     int actual = fread(buf, 1, 16, fin);
26     for (int i=0; i<actual; i++)
27     fprintf(fout, "0x%02x, ", buf[i]);
28     fprintf(fout, "\n");
29     }
30    
31     fclose(fin);
32     fclose(fout);
33     return 0;
34     }