diff options
author | Daniel Stenberg <daniel@haxx.se> | 2005-02-22 12:19:12 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2005-02-22 12:19:12 +0000 |
commit | 22b7701fe75cce9afdbc27046821dc089f9e7dac (patch) | |
tree | ca5b4f0428fad0fc9c775dfb0ac879ddee863846 /uisimulator/common | |
parent | 376057d2b67bae0a7b24ae1715d3cbb0b540b7a9 (diff) | |
download | rockbox-22b7701fe75cce9afdbc27046821dc089f9e7dac.tar.gz rockbox-22b7701fe75cce9afdbc27046821dc089f9e7dac.zip |
Build cleanup and general fixes. fprintf() is now fdprintf(), the separation
between uisimulator files and firmware/apps files are better done.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6031 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/common')
-rw-r--r-- | uisimulator/common/Makefile | 6 | ||||
-rw-r--r-- | uisimulator/common/dir.h | 45 | ||||
-rw-r--r-- | uisimulator/common/file.h | 76 | ||||
-rw-r--r-- | uisimulator/common/io.c | 124 | ||||
-rw-r--r-- | uisimulator/common/lcd-common.c | 4 | ||||
-rw-r--r-- | uisimulator/common/stubs.c | 3 |
6 files changed, 124 insertions, 134 deletions
diff --git a/uisimulator/common/Makefile b/uisimulator/common/Makefile index b044440adf..e2b6b2a4f8 100644 --- a/uisimulator/common/Makefile +++ b/uisimulator/common/Makefile | |||
@@ -23,7 +23,7 @@ RM = rm -f | |||
23 | DEBUG = -g | 23 | DEBUG = -g |
24 | 24 | ||
25 | # Use this for simulator-only files | 25 | # Use this for simulator-only files |
26 | INCLUDES = -I. -I$(OBJDIR) -I$(FIRMDIR)/export -I$(APPSDIR) | 26 | INCLUDES = -I. -I$(OBJDIR) -I$(FIRMDIR)/export -I$(APPSDIR) -I$(ROOTDIR)/uisimulator/$(SIMVER) |
27 | 27 | ||
28 | SRC := $(shell cat SOURCES | gcc -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \ | 28 | SRC := $(shell cat SOURCES | gcc -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \ |
29 | $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - ) | 29 | $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - ) |
@@ -38,7 +38,7 @@ DIRS = . | |||
38 | 38 | ||
39 | CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS) | 39 | CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS) |
40 | 40 | ||
41 | OUTFILE = $(OBJDIR)/libsim.a | 41 | OUTFILE = $(OBJDIR)/libcomsim.a |
42 | 42 | ||
43 | all: $(OUTFILE) | 43 | all: $(OUTFILE) |
44 | 44 | ||
@@ -46,7 +46,7 @@ include $(TOOLSDIR)/make.inc | |||
46 | 46 | ||
47 | clean: | 47 | clean: |
48 | @echo "cleaning commonsim" | 48 | @echo "cleaning commonsim" |
49 | @$(RM) $(OBJS) *~ core $(DEPFILE) | 49 | @$(RM) $(OBJS) *~ core $(DEPFILE) $(OUTFILE) |
50 | 50 | ||
51 | $(OUTFILE): $(OBJS) | 51 | $(OUTFILE): $(OBJS) |
52 | @echo "AR+RANLIB $@" | 52 | @echo "AR+RANLIB $@" |
diff --git a/uisimulator/common/dir.h b/uisimulator/common/dir.h deleted file mode 100644 index 18cfbb3736..0000000000 --- a/uisimulator/common/dir.h +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef _SIM_DIR_H_ | ||
20 | #define _SIM_DIR_H_ | ||
21 | |||
22 | #include <sys/types.h> | ||
23 | |||
24 | #define DIRFUNCTIONS_DEFINED /* prevent those prototypes */ | ||
25 | #define dirent sim_dirent | ||
26 | #include "../../firmware/include/dir.h" | ||
27 | #undef dirent | ||
28 | |||
29 | typedef void * MYDIR; | ||
30 | |||
31 | extern MYDIR *sim_opendir(const char *name); | ||
32 | extern struct sim_dirent* sim_readdir(MYDIR* dir); | ||
33 | extern int sim_closedir(MYDIR *dir); | ||
34 | extern int sim_mkdir(const char *name, int mode); | ||
35 | extern int sim_rmdir(char *name); | ||
36 | |||
37 | #define DIR MYDIR | ||
38 | #define dirent sim_dirent | ||
39 | #define opendir(x) sim_opendir(x) | ||
40 | #define readdir(x) sim_readdir(x) | ||
41 | #define closedir(x) sim_closedir(x) | ||
42 | #define mkdir(x, y) sim_mkdir(x, y) | ||
43 | #define rmdir(x) sim_rmdir(x) | ||
44 | |||
45 | #endif | ||
diff --git a/uisimulator/common/file.h b/uisimulator/common/file.h deleted file mode 100644 index 7ea59a0b74..0000000000 --- a/uisimulator/common/file.h +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef _SIM_FILE_H_ | ||
21 | #define _SIM_FILE_H_ | ||
22 | |||
23 | #ifdef WIN32 | ||
24 | #include <io.h> | ||
25 | #include <fcntl.h> | ||
26 | #else | ||
27 | #include <stdio.h> | ||
28 | #endif | ||
29 | |||
30 | #include <sys/types.h> | ||
31 | |||
32 | #ifdef WIN32 | ||
33 | #ifndef _commit | ||
34 | extern int _commit( int handle ); | ||
35 | |||
36 | #ifdef _MSC_VER | ||
37 | typedef unsigned int mode_t; | ||
38 | #endif | ||
39 | |||
40 | #endif | ||
41 | #endif | ||
42 | |||
43 | int sim_open(const char *name, int opts); | ||
44 | int sim_close(int fd); | ||
45 | int sim_rename(const char *oldpath, const char *newpath); | ||
46 | off_t sim_filesize(int fd); | ||
47 | int sim_creat(const char *name, mode_t mode); | ||
48 | int sim_remove(const char *name); | ||
49 | |||
50 | #ifndef NO_REDEFINES_PLEASE | ||
51 | #define open(x,y) sim_open(x,y) | ||
52 | #define close(x) sim_close(x) | ||
53 | #define filesize(x) sim_filesize(x) | ||
54 | #define creat(x,y) sim_creat(x,y) | ||
55 | #define remove(x) sim_remove(x) | ||
56 | #define rename(x,y) sim_rename(x,y) | ||
57 | #ifdef WIN32 | ||
58 | #define fsync _commit | ||
59 | #endif | ||
60 | #endif | ||
61 | |||
62 | #include "../../firmware/include/file.h" | ||
63 | |||
64 | #ifndef WIN32 | ||
65 | int open(const char* pathname, int flags); | ||
66 | int close(int fd); | ||
67 | int printf(const char *format, ...); | ||
68 | int ftruncate(int fd, off_t length); | ||
69 | int fsync(int fd); | ||
70 | |||
71 | off_t lseek(int fildes, off_t offset, int whence); | ||
72 | ssize_t read(int fd, void *buf, size_t count); | ||
73 | ssize_t write(int fd, const void *buf, size_t count); | ||
74 | #endif | ||
75 | |||
76 | #endif | ||
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index 6335735f8f..48b888a027 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <string.h> | 22 | #include <string.h> |
23 | #include <stdarg.h> | ||
23 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
24 | #ifdef __FreeBSD__ | 25 | #ifdef __FreeBSD__ |
25 | #include <sys/param.h> | 26 | #include <sys/param.h> |
@@ -28,6 +29,10 @@ | |||
28 | #include <sys/vfs.h> | 29 | #include <sys/vfs.h> |
29 | #endif | 30 | #endif |
30 | 31 | ||
32 | #ifdef WIN32 | ||
33 | #include <windows.h> | ||
34 | #endif | ||
35 | |||
31 | #ifndef _MSC_VER | 36 | #ifndef _MSC_VER |
32 | #include <dirent.h> | 37 | #include <dirent.h> |
33 | #include <unistd.h> | 38 | #include <unistd.h> |
@@ -35,18 +40,27 @@ | |||
35 | #include "dir-win32.h" | 40 | #include "dir-win32.h" |
36 | #endif | 41 | #endif |
37 | 42 | ||
43 | #define MAX_PATH 260 | ||
44 | |||
38 | #include <fcntl.h> | 45 | #include <fcntl.h> |
39 | #include "debug.h" | 46 | #include "debug.h" |
40 | 47 | ||
41 | #define DIRFUNCTIONS_DEFINED /* prevent those prototypes */ | ||
42 | #define dirent sim_dirent | ||
43 | #define DIR SIMDIR | ||
44 | #include "../../firmware/include/dir.h" | ||
45 | #undef dirent | ||
46 | #undef DIR | ||
47 | |||
48 | #define SIMULATOR_ARCHOS_ROOT "archos" | 48 | #define SIMULATOR_ARCHOS_ROOT "archos" |
49 | 49 | ||
50 | struct sim_dirent { | ||
51 | unsigned char d_name[MAX_PATH]; | ||
52 | int attribute; | ||
53 | int size; | ||
54 | int startcluster; | ||
55 | unsigned short wrtdate; /* Last write date */ | ||
56 | unsigned short wrttime; /* Last write time */ | ||
57 | }; | ||
58 | |||
59 | struct dirstruct { | ||
60 | void *dir; /* actually a DIR* dir */ | ||
61 | char *name; | ||
62 | } SIM_DIR; | ||
63 | |||
50 | struct mydir { | 64 | struct mydir { |
51 | DIR *dir; | 65 | DIR *dir; |
52 | char *name; | 66 | char *name; |
@@ -113,6 +127,8 @@ struct sim_dirent *sim_readdir(MYDIR *dir) | |||
113 | dir->name, x11->d_name); | 127 | dir->name, x11->d_name); |
114 | stat(buffer, &s); /* get info */ | 128 | stat(buffer, &s); /* get info */ |
115 | 129 | ||
130 | #define ATTR_DIRECTORY 0x10 | ||
131 | |||
116 | secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0; | 132 | secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0; |
117 | secret.size = s.st_size; | 133 | secret.size = s.st_size; |
118 | secret.wrtdate = (unsigned short)(s.st_mtime >> 16); | 134 | secret.wrtdate = (unsigned short)(s.st_mtime >> 16); |
@@ -181,6 +197,7 @@ int sim_mkdir(const char *name, mode_t mode) | |||
181 | 197 | ||
182 | debugf("We create the real directory '%s'\n", buffer); | 198 | debugf("We create the real directory '%s'\n", buffer); |
183 | #ifdef WIN32 | 199 | #ifdef WIN32 |
200 | /* since we build with -DNOCYGWIN we have the plain win32 version */ | ||
184 | return (mkdir)(buffer); | 201 | return (mkdir)(buffer); |
185 | #else | 202 | #else |
186 | return (mkdir)(buffer, 0666); | 203 | return (mkdir)(buffer, 0666); |
@@ -260,3 +277,96 @@ void fat_size(unsigned int* size, unsigned int* free) | |||
260 | } | 277 | } |
261 | #endif | 278 | #endif |
262 | } | 279 | } |
280 | |||
281 | int sim_fsync(int fd) | ||
282 | { | ||
283 | #ifdef WIN32 | ||
284 | return _commit(fd); | ||
285 | #else | ||
286 | return fsync(fd); | ||
287 | #endif | ||
288 | } | ||
289 | |||
290 | #ifdef WIN32 | ||
291 | /* sim-win32 */ | ||
292 | typedef enum plugin_status (*plugin_fn)(void* api, void* param); | ||
293 | #define dlopen(_x_, _y_) LoadLibrary(_x_) | ||
294 | #define dlsym(_x_, _y_) (plugin_fn)GetProcAddress(_x_, _y_) | ||
295 | #define dlclose(_x_) FreeLibrary(_x_) | ||
296 | #define dlerror() "Unknown" | ||
297 | #else | ||
298 | /* sim-x11 */ | ||
299 | #include <dlfcn.h> | ||
300 | #endif | ||
301 | |||
302 | void *sim_plugin_load(char *plugin, int *fd) | ||
303 | { | ||
304 | void* pd; | ||
305 | char path[256]; | ||
306 | char buf[256]; | ||
307 | int (*plugin_start)(void * api, void* param); | ||
308 | |||
309 | snprintf(path, sizeof path, "archos%s", plugin); | ||
310 | |||
311 | *fd = -1; | ||
312 | |||
313 | pd = dlopen(path, RTLD_NOW); | ||
314 | if (!pd) { | ||
315 | snprintf(buf, sizeof buf, "failed to load %s", plugin); | ||
316 | DEBUGF("dlopen(%s): %s\n",path,dlerror()); | ||
317 | dlclose(pd); | ||
318 | return NULL; | ||
319 | } | ||
320 | |||
321 | plugin_start = dlsym(pd, "plugin_start"); | ||
322 | if (!plugin_start) { | ||
323 | plugin_start = dlsym(pd, "_plugin_start"); | ||
324 | if (!plugin_start) { | ||
325 | dlclose(pd); | ||
326 | return NULL; | ||
327 | } | ||
328 | } | ||
329 | *fd = pd; /* success */ | ||
330 | return plugin_start; | ||
331 | } | ||
332 | |||
333 | void sim_plugin_close(int pd) | ||
334 | { | ||
335 | dlclose(pd); | ||
336 | } | ||
337 | |||
338 | #ifndef WIN32 | ||
339 | /* the win32 version is in debug-win32.c */ | ||
340 | |||
341 | void debug_init(void) | ||
342 | { | ||
343 | /* nothing to be done */ | ||
344 | } | ||
345 | |||
346 | void debugf(const char *fmt, ...) | ||
347 | { | ||
348 | va_list ap; | ||
349 | va_start( ap, fmt ); | ||
350 | vfprintf( stderr, fmt, ap ); | ||
351 | va_end( ap ); | ||
352 | } | ||
353 | |||
354 | void ldebugf(const char* file, int line, const char *fmt, ...) | ||
355 | { | ||
356 | va_list ap; | ||
357 | va_start( ap, fmt ); | ||
358 | fprintf( stderr, "%s:%d ", file, line ); | ||
359 | vfprintf( stderr, fmt, ap ); | ||
360 | va_end( ap ); | ||
361 | } | ||
362 | |||
363 | #endif | ||
364 | |||
365 | int sim_ftruncate(int fd, off_t length) | ||
366 | { | ||
367 | #ifdef WIN32 | ||
368 | return _chsize(fd, length); | ||
369 | #else | ||
370 | return ftruncate(fd, length); | ||
371 | #endif | ||
372 | } | ||
diff --git a/uisimulator/common/lcd-common.c b/uisimulator/common/lcd-common.c index c69ef06f1f..95c42ad8db 100644 --- a/uisimulator/common/lcd-common.c +++ b/uisimulator/common/lcd-common.c | |||
@@ -25,9 +25,9 @@ | |||
25 | #include "lcd.h" | 25 | #include "lcd.h" |
26 | 26 | ||
27 | #ifdef WIN32 | 27 | #ifdef WIN32 |
28 | #include "lcd-win32.h" | 28 | #include "lcd-win32.h" |
29 | #else | 29 | #else |
30 | #include "lcd-x11.h" | 30 | #include "lcd-x11.h" |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | void lcd_blit(const unsigned char* p_data, int x, int y, int width, int height, | 33 | void lcd_blit(const unsigned char* p_data, int x, int y, int width, int height, |
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index c43fb5f1f2..3ed16e8e34 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include "string.h" | 29 | #include "string.h" |
30 | #include "lcd.h" | 30 | #include "lcd.h" |
31 | #include "settings.h" | 31 | |
32 | #include "ata.h" /* for volume definitions */ | 32 | #include "ata.h" /* for volume definitions */ |
33 | 33 | ||
34 | extern char having_new_lcd; | 34 | extern char having_new_lcd; |
@@ -285,5 +285,6 @@ void remove_thread(int threadnum) | |||
285 | } | 285 | } |
286 | 286 | ||
287 | /* assure an unused place to direct virtual pointers to */ | 287 | /* assure an unused place to direct virtual pointers to */ |
288 | #define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */ | ||
288 | unsigned char vp_dummy[VIRT_SIZE]; | 289 | unsigned char vp_dummy[VIRT_SIZE]; |
289 | 290 | ||