summaryrefslogtreecommitdiff
path: root/utils/jz4740_tools/HXFmerge.c
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-07-03 12:17:56 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-07-03 12:17:56 +0000
commit6fd40a57b81484a57f1c5a8ddbd48855a89e660f (patch)
tree59609082705b4b825ca472a4f65d0ce04bab2925 /utils/jz4740_tools/HXFmerge.c
parentab498e547b9c96bc2ae662cdc4c5fdb5d2db1f35 (diff)
downloadrockbox-6fd40a57b81484a57f1c5a8ddbd48855a89e660f.tar.gz
rockbox-6fd40a57b81484a57f1c5a8ddbd48855a89e660f.zip
Jz4740 Tools:
* update Makefile * add README * update svn properties * fix small mistakes git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17926 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/jz4740_tools/HXFmerge.c')
-rw-r--r--[-rwxr-xr-x]utils/jz4740_tools/HXFmerge.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/utils/jz4740_tools/HXFmerge.c b/utils/jz4740_tools/HXFmerge.c
index f90d094fd9..fb5a0bf2f3 100755..100644
--- a/utils/jz4740_tools/HXFmerge.c
+++ b/utils/jz4740_tools/HXFmerge.c
@@ -1,6 +1,23 @@
1/* 1/***************************************************************************
2Made by Maurus Cuelenaere 2 * __________ __ ___.
3*/ 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
4 21
5#include <stdio.h> 22#include <stdio.h>
6#include <stdlib.h> 23#include <stdlib.h>
@@ -42,8 +59,8 @@ static unsigned int le2int(unsigned char* buf)
42#define MIN(a, b) (a > b ? b : a) 59#define MIN(a, b) (a > b ? b : a)
43static char* replace(char* str) 60static char* replace(char* str)
44{ 61{
45 char tmp[255]; 62 static char tmp[255];
46 memcpy(tmp, str, MIN(strlen(str), 255); 63 memcpy(tmp, str, MIN(strlen(str), 255));
47 char *ptr = tmp; 64 char *ptr = tmp;
48 while(*ptr != 0) 65 while(*ptr != 0)
49 { 66 {
@@ -156,19 +173,32 @@ static void merge_hxf(const char* indir, FILE* outfile, const char* add)
156 173
157 if(strlen(add)>0) 174 if(strlen(add)>0)
158 { 175 {
176#ifdef _DIRENT_HAVE_D_NAMLEN
159 WRITE(int2le(dirs->d_namlen+strlen(add)), 4); 177 WRITE(int2le(dirs->d_namlen+strlen(add)), 4);
178#else
179 WRITE(int2le(strlen(dirs->d_name)+strlen(add)), 4);
180#endif
160#ifndef _WIN32 181#ifndef _WIN32
161 WRITE(replace(add), strlen(add)-1); 182 WRITE(replace(&add), strlen(add)-1);
162#else 183#else
163 WRITE(add, strlen(add)-1); 184 WRITE(add, strlen(add)-1);
164#endif 185#endif
165 WRITE(PATH_SEPARATOR, 1); 186 WRITE(PATH_SEPARATOR, 1);
187#ifdef _DIRENT_HAVE_D_NAMLEN
166 WRITE(dirs->d_name, dirs->d_namlen); 188 WRITE(dirs->d_name, dirs->d_namlen);
189#else
190 WRITE(dirs->d_name, strlen(dirs->d_name));
191#endif
167 } 192 }
168 else 193 else
169 { 194 {
195#ifdef _DIRENT_HAVE_D_NAMLEN
170 WRITE(int2le(dirs->d_namlen), 4); 196 WRITE(int2le(dirs->d_namlen), 4);
171 WRITE(dirs->d_name, dirs->d_namlen); 197 WRITE(dirs->d_name, dirs->d_namlen);
198#else
199 WRITE(int2le(strlen(dirs->d_name)), 4);
200 WRITE(dirs->d_name, strlen(dirs->d_name));
201#endif
172 } 202 }
173 WRITE(int2le(filesize), 4); 203 WRITE(int2le(filesize), 4);
174 if(filesize>0) 204 if(filesize>0)