mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Add "ipod" mode to bin2c.
ipod2c is identical to bin2c except it skipping the header of the input files. Add this behaviour as option to bin2c to be able of using bin2c instead of ipod2c. Change-Id: I71afcaca6f2f6b0fce4c6aa3dff6be5bb205f384
This commit is contained in:
parent
fe3d58004c
commit
b4424ca2f3
1 changed files with 28 additions and 6 deletions
|
@ -5,7 +5,6 @@
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id$
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Dave Chapman
|
* Copyright (C) 2007 Dave Chapman
|
||||||
*
|
*
|
||||||
|
@ -40,6 +39,13 @@
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "bin2c [options] infile cfile\n");
|
||||||
|
fprintf(stderr, " -i ipod mode\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static off_t filesize(int fd)
|
static off_t filesize(int fd)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
@ -116,14 +122,25 @@ int main (int argc, char* argv[])
|
||||||
unsigned char* buf;
|
unsigned char* buf;
|
||||||
int len;
|
int len;
|
||||||
int n;
|
int n;
|
||||||
|
int skip = 0;
|
||||||
|
int opts = 0;
|
||||||
|
|
||||||
if (argc != 3) {
|
|
||||||
fprintf(stderr,"Usage: bin2c file cname\n");
|
if(argc < 2) {
|
||||||
|
usage();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(strcmp(argv[1], "-i") == 0) {
|
||||||
|
skip = 8;
|
||||||
|
opts++;
|
||||||
|
}
|
||||||
|
if (argc < opts + 3) {
|
||||||
|
usage();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
infile=argv[1];
|
infile=argv[opts + 1];
|
||||||
cname=argv[2];
|
cname=argv[opts + 2];
|
||||||
|
|
||||||
fd = open(infile,O_RDONLY|O_BINARY);
|
fd = open(infile,O_RDONLY|O_BINARY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -131,7 +148,12 @@ int main (int argc, char* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = filesize(fd);
|
len = filesize(fd) - skip;
|
||||||
|
n = lseek(fd, skip, SEEK_SET);
|
||||||
|
if (n != skip) {
|
||||||
|
fprintf(stderr,"Seek failed\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
buf = malloc(len);
|
buf = malloc(len);
|
||||||
n = read(fd,buf,len);
|
n = read(fd,buf,len);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue