summaryrefslogtreecommitdiff
path: root/firmware/include
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/include')
-rw-r--r--firmware/include/dir.h36
-rw-r--r--firmware/include/file.h36
-rw-r--r--firmware/include/sprintf.h2
-rw-r--r--firmware/include/stdio.h1
-rw-r--r--firmware/include/sys/types.h49
5 files changed, 76 insertions, 48 deletions
diff --git a/firmware/include/dir.h b/firmware/include/dir.h
index 12ec724692..26ccd03ed3 100644
--- a/firmware/include/dir.h
+++ b/firmware/include/dir.h
@@ -30,6 +30,16 @@
#define ATTR_ARCHIVE 0x20
#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
+#ifdef SIMULATOR
+#define dirent sim_dirent
+#define DIR SIM_DIR
+#define opendir(x) sim_opendir(x)
+#define readdir(x) sim_readdir(x)
+#define closedir(x) sim_closedir(x)
+#define mkdir(x, y) sim_mkdir(x, y)
+#define rmdir(x) sim_rmdir(x)
+#endif
+
#ifndef DIRENT_DEFINED
struct dirent {
@@ -42,12 +52,10 @@ struct dirent {
};
#endif
-
-#ifndef SIMULATOR
-
#include "fat.h"
typedef struct {
+#ifndef SIMULATOR
bool busy;
int startcluster;
struct fat_dir fatdir;
@@ -56,25 +64,13 @@ typedef struct {
#ifdef HAVE_MULTIVOLUME
int volumecounter; /* running counter for faked volume entries */
#endif
+#else
+ /* simulator: */
+ void *dir; /* actually a DIR* dir */
+ char *name;
+#endif
} DIR;
-#else /* SIMULATOR */
-
-#ifdef WIN32
-#ifndef __MINGW32__
-#include <io.h>
-#endif /* __MINGW32__ */
-
-typedef struct DIRtag
-{
- struct dirent fd;
- int handle;
-} DIR;
-
-#endif /* WIN32 */
-
-#endif /* SIMULATOR */
-
#ifndef DIRFUNCTIONS_DEFINED
extern DIR* opendir(const char* name);
diff --git a/firmware/include/file.h b/firmware/include/file.h
index af1ad72be9..694de48348 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -20,6 +20,8 @@
#ifndef _FILE_H_
#define _FILE_H_
+#include <sys/types.h>
+
#undef MAX_PATH /* this avoids problems when building simulator */
#define MAX_PATH 260
@@ -42,30 +44,14 @@
#define O_TRUNC 0x10
#endif
-#if !defined(__ssize_t_defined) && !defined(_SSIZE_T_) && !defined(ssize_t)
-#define __ssize_t_defined
-#define _SSIZE_T_
-#define ssize_t ssize_t
-typedef signed long ssize_t;
-#endif
-
-#if !defined(__off_t_defined) && !defined(_OFF_T_) && !defined(off_t)
-#define __off_t_defined
-#define _OFF_T_
-#define off_t off_t
-typedef signed long off_t;
-#endif
-
-#if !defined(__mode_t_defined) && !defined(_MODE_T_) && !defined(mode_t)
-#define __mode_t_defined
-#define _MODE_T_
-#define mode_t mode_t
-typedef unsigned int mode_t;
-#endif
-
-#ifndef _SIZE_T
-#define _SIZE_T
-typedef unsigned long size_t;
+#ifdef SIMULATOR
+#define open(x,y) sim_open(x,y)
+#define creat(x,y) sim_creat(x,y)
+#define remove(x) sim_remove(x)
+#define rename(x,y) sim_rename(x,y)
+#define filesize(x) sim_filesize(x)
+#define fsync(x) sim_fsync(x)
+#define ftruncate(x,y) sim_ftruncate(x,y)
#endif
typedef int (*open_func)(const char* pathname, int flags);
@@ -75,7 +61,6 @@ typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
int(*_compar)(const void *, const void *));
-#ifndef SIMULATOR
extern int open(const char* pathname, int flags);
extern int close(int fd);
extern int fsync(int fd);
@@ -88,6 +73,5 @@ extern int rename(const char* path, const char* newname);
extern int ftruncate(int fd, off_t length);
extern off_t filesize(int fd);
extern int release_files(int volume);
-#endif /* SIMULATOR */
#endif
diff --git a/firmware/include/sprintf.h b/firmware/include/sprintf.h
index d68647ee72..b667a0406b 100644
--- a/firmware/include/sprintf.h
+++ b/firmware/include/sprintf.h
@@ -33,7 +33,7 @@ int snprintf (char *buf, size_t size, const char *fmt, ...)
ATTRIBUTE_PRINTF(3, 4);
int vsnprintf (char *buf, int size, const char *fmt, va_list ap);
-int fprintf (int fd, const char *fmt, ...)
+int fdprintf (int fd, const char *fmt, ...)
ATTRIBUTE_PRINTF(2, 3);
#endif /* __SPRINTF_H__ */
diff --git a/firmware/include/stdio.h b/firmware/include/stdio.h
index dd22f7d5b1..968bd59aab 100644
--- a/firmware/include/stdio.h
+++ b/firmware/include/stdio.h
@@ -39,7 +39,6 @@ int vsnprintf (char *buf, int size, const char *fmt, __VALIST ap);
#ifdef SIMULATOR
typedef void FILE;
int vfprintf(FILE *stream, const char *format, __VALIST ap);
-int fprintf(FILE *stream, const char *format, ...);
#ifdef WIN32
#define FILENAME_MAX 260 /* ugly hard-coded value of a limit that is set
in file.h */
diff --git a/firmware/include/sys/types.h b/firmware/include/sys/types.h
new file mode 100644
index 0000000000..7bca33b78d
--- /dev/null
+++ b/firmware/include/sys/types.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2005 by Daniel Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef _SYS_TYPES_H_
+#define _SYS_TYPES_H_
+
+#if !defined(__ssize_t_defined) && !defined(_SSIZE_T_) && !defined(ssize_t)
+#define __ssize_t_defined
+#define _SSIZE_T_
+#define ssize_t ssize_t
+typedef signed long ssize_t;
+#endif
+
+#if !defined(__off_t_defined) && !defined(_OFF_T_) && !defined(off_t)
+#define __off_t_defined
+#define _OFF_T_
+#define off_t off_t
+typedef signed long off_t;
+#endif
+
+#if !defined(__mode_t_defined) && !defined(_MODE_T_) && !defined(mode_t)
+#define __mode_t_defined
+#define _MODE_T_
+#define mode_t mode_t
+typedef unsigned int mode_t;
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned long size_t;
+#endif
+
+#endif /* _SYS_TYPES_H */