2002-05-13 15:23:30 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2002-04-30 13:14:59 +00:00
|
|
|
|
2002-06-14 11:00:13 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2005-02-22 12:19:12 +00:00
|
|
|
#include <stdarg.h>
|
2002-05-07 12:06:32 +00:00
|
|
|
#include <sys/stat.h>
|
2003-07-04 08:30:01 +00:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/mount.h>
|
2004-06-10 13:29:52 +00:00
|
|
|
#elif !defined(WIN32)
|
2002-11-12 11:32:26 +00:00
|
|
|
#include <sys/vfs.h>
|
2003-07-04 08:30:01 +00:00
|
|
|
#endif
|
2004-06-14 07:00:50 +00:00
|
|
|
|
2005-02-22 12:19:12 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2004-06-14 07:00:50 +00:00
|
|
|
#ifndef _MSC_VER
|
2002-05-07 12:25:30 +00:00
|
|
|
#include <dirent.h>
|
2003-01-28 23:14:41 +00:00
|
|
|
#include <unistd.h>
|
2004-06-14 07:00:50 +00:00
|
|
|
#else
|
|
|
|
#include "dir-win32.h"
|
|
|
|
#endif
|
2002-04-30 13:14:59 +00:00
|
|
|
|
2005-02-22 12:19:12 +00:00
|
|
|
#define MAX_PATH 260
|
|
|
|
|
2002-06-14 11:00:13 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include "debug.h"
|
|
|
|
|
2002-05-07 12:25:30 +00:00
|
|
|
#define SIMULATOR_ARCHOS_ROOT "archos"
|
|
|
|
|
2005-02-22 12:19:12 +00:00
|
|
|
struct sim_dirent {
|
|
|
|
unsigned char d_name[MAX_PATH];
|
|
|
|
int attribute;
|
|
|
|
int size;
|
|
|
|
int startcluster;
|
|
|
|
unsigned short wrtdate; /* Last write date */
|
|
|
|
unsigned short wrttime; /* Last write time */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dirstruct {
|
|
|
|
void *dir; /* actually a DIR* dir */
|
|
|
|
char *name;
|
|
|
|
} SIM_DIR;
|
|
|
|
|
2002-05-07 12:25:30 +00:00
|
|
|
struct mydir {
|
2003-03-05 22:59:36 +00:00
|
|
|
DIR *dir;
|
|
|
|
char *name;
|
2002-05-07 12:25:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct mydir MYDIR;
|
2002-04-30 13:14:59 +00:00
|
|
|
|
2005-02-24 23:11:21 +00:00
|
|
|
#if 1 /* maybe this needs disabling for MSVC... */
|
2004-06-14 22:22:49 +00:00
|
|
|
static unsigned int rockbox2sim(int opt)
|
|
|
|
{
|
|
|
|
int newopt = 0;
|
|
|
|
if(opt & 1)
|
|
|
|
newopt |= O_WRONLY;
|
|
|
|
if(opt & 2)
|
|
|
|
newopt |= O_RDWR;
|
|
|
|
if(opt & 4)
|
|
|
|
newopt |= O_CREAT;
|
|
|
|
if(opt & 8)
|
|
|
|
newopt |= O_APPEND;
|
|
|
|
if(opt & 0x10)
|
|
|
|
newopt |= O_TRUNC;
|
|
|
|
|
|
|
|
return newopt;
|
|
|
|
}
|
2004-07-08 05:50:20 +00:00
|
|
|
#endif
|
2004-06-14 22:22:49 +00:00
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
MYDIR *sim_opendir(const char *name)
|
2002-04-30 13:14:59 +00:00
|
|
|
{
|
2003-03-05 22:59:36 +00:00
|
|
|
char buffer[256]; /* sufficiently big */
|
|
|
|
DIR *dir;
|
|
|
|
|
|
|
|
if(name[0] == '/') {
|
|
|
|
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
|
|
|
dir=(DIR *)opendir(buffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dir=(DIR *)opendir(name);
|
|
|
|
|
|
|
|
if(dir) {
|
|
|
|
MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
|
|
|
|
my->dir = dir;
|
|
|
|
my->name = (char *)strdup(name);
|
|
|
|
|
|
|
|
return my;
|
|
|
|
}
|
|
|
|
/* failed open, return NULL */
|
|
|
|
return (MYDIR *)0;
|
2002-04-30 13:14:59 +00:00
|
|
|
}
|
2002-05-05 10:28:23 +00:00
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
struct sim_dirent *sim_readdir(MYDIR *dir)
|
2002-05-07 11:35:03 +00:00
|
|
|
{
|
2003-03-05 22:59:36 +00:00
|
|
|
char buffer[512]; /* sufficiently big */
|
2004-06-10 13:29:52 +00:00
|
|
|
static struct sim_dirent secret;
|
2003-03-05 22:59:36 +00:00
|
|
|
struct stat s;
|
|
|
|
struct dirent *x11 = (readdir)(dir->dir);
|
2002-05-07 11:35:03 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
if(!x11)
|
2004-06-10 13:29:52 +00:00
|
|
|
return (struct sim_dirent *)0;
|
2002-05-07 11:35:03 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
strcpy(secret.d_name, x11->d_name);
|
2002-05-07 12:06:32 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
/* build file name */
|
|
|
|
sprintf(buffer, SIMULATOR_ARCHOS_ROOT "%s/%s",
|
|
|
|
dir->name, x11->d_name);
|
|
|
|
stat(buffer, &s); /* get info */
|
2002-05-07 12:06:32 +00:00
|
|
|
|
2005-02-22 12:19:12 +00:00
|
|
|
#define ATTR_DIRECTORY 0x10
|
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0;
|
|
|
|
secret.size = s.st_size;
|
2004-06-20 16:34:29 +00:00
|
|
|
secret.wrtdate = (unsigned short)(s.st_mtime >> 16);
|
|
|
|
secret.wrttime = (unsigned short)(s.st_mtime & 0xFFFF);
|
2002-05-07 11:35:03 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
return &secret;
|
2002-05-07 11:35:03 +00:00
|
|
|
}
|
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
void sim_closedir(MYDIR *dir)
|
2002-05-07 12:06:32 +00:00
|
|
|
{
|
2003-03-05 22:59:36 +00:00
|
|
|
free(dir->name);
|
2005-03-05 21:48:58 +00:00
|
|
|
closedir(dir->dir);
|
2002-05-07 12:06:32 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
free(dir);
|
2002-05-07 12:06:32 +00:00
|
|
|
}
|
|
|
|
|
2004-06-14 22:22:49 +00:00
|
|
|
int sim_open(const char *name, int o)
|
2002-05-05 10:28:23 +00:00
|
|
|
{
|
2003-03-05 22:59:36 +00:00
|
|
|
char buffer[256]; /* sufficiently big */
|
2004-06-14 22:22:49 +00:00
|
|
|
int opts = rockbox2sim(o);
|
2002-05-05 10:28:23 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
if(name[0] == '/') {
|
|
|
|
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
2005-02-28 18:32:57 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
debugf("We open the real file '%s'\n", buffer);
|
2005-03-05 21:48:58 +00:00
|
|
|
return open(buffer, opts, 0666);
|
2003-03-05 22:59:36 +00:00
|
|
|
}
|
2004-06-14 22:32:13 +00:00
|
|
|
fprintf(stderr, "WARNING, bad file name lacks slash: %s\n",
|
|
|
|
name);
|
|
|
|
return -1;
|
2002-05-05 10:28:23 +00:00
|
|
|
}
|
2002-11-12 11:32:26 +00:00
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
int sim_creat(const char *name, mode_t mode)
|
2003-01-09 00:55:00 +00:00
|
|
|
{
|
2003-03-05 22:59:36 +00:00
|
|
|
char buffer[256]; /* sufficiently big */
|
|
|
|
(void)mode;
|
|
|
|
if(name[0] == '/') {
|
|
|
|
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
|
|
|
|
|
|
|
debugf("We create the real file '%s'\n", buffer);
|
2005-03-05 21:48:58 +00:00
|
|
|
return creat(buffer, 0666);
|
2003-03-05 22:59:36 +00:00
|
|
|
}
|
2004-06-14 22:32:13 +00:00
|
|
|
fprintf(stderr, "WARNING, bad file name lacks slash: %s\n",
|
|
|
|
name);
|
|
|
|
return -1;
|
2005-02-28 18:32:57 +00:00
|
|
|
}
|
2003-01-09 00:55:00 +00:00
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
int sim_mkdir(const char *name, mode_t mode)
|
2004-01-21 14:58:40 +00:00
|
|
|
{
|
|
|
|
char buffer[256]; /* sufficiently big */
|
|
|
|
(void)mode;
|
2004-06-10 13:29:52 +00:00
|
|
|
|
|
|
|
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
2004-01-21 14:58:40 +00:00
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
debugf("We create the real directory '%s'\n", buffer);
|
|
|
|
#ifdef WIN32
|
2005-02-22 12:19:12 +00:00
|
|
|
/* since we build with -DNOCYGWIN we have the plain win32 version */
|
2005-03-05 21:48:58 +00:00
|
|
|
return mkdir(buffer);
|
2004-06-10 13:29:52 +00:00
|
|
|
#else
|
2005-03-05 21:48:58 +00:00
|
|
|
return mkdir(buffer, 0666);
|
2004-06-10 13:29:52 +00:00
|
|
|
#endif
|
2004-01-21 14:58:40 +00:00
|
|
|
}
|
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
int sim_rmdir(const char *name)
|
2004-04-16 09:24:38 +00:00
|
|
|
{
|
|
|
|
char buffer[256]; /* sufficiently big */
|
|
|
|
if(name[0] == '/') {
|
|
|
|
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
|
|
|
|
|
|
|
debugf("We remove the real directory '%s'\n", buffer);
|
2005-03-05 21:48:58 +00:00
|
|
|
return rmdir(buffer);
|
2004-04-16 09:24:38 +00:00
|
|
|
}
|
2005-03-05 21:48:58 +00:00
|
|
|
return rmdir(name);
|
2004-04-16 09:24:38 +00:00
|
|
|
}
|
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
int sim_remove(const char *name)
|
2003-01-09 00:55:00 +00:00
|
|
|
{
|
2003-03-05 22:59:36 +00:00
|
|
|
char buffer[256]; /* sufficiently big */
|
2003-01-09 00:55:00 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
if(name[0] == '/') {
|
|
|
|
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
2003-01-09 00:55:00 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
debugf("We remove the real file '%s'\n", buffer);
|
2005-03-05 21:48:58 +00:00
|
|
|
return remove(buffer);
|
2003-03-05 22:59:36 +00:00
|
|
|
}
|
2005-03-05 21:48:58 +00:00
|
|
|
return remove(name);
|
2003-01-09 00:55:00 +00:00
|
|
|
}
|
|
|
|
|
2004-06-10 13:29:52 +00:00
|
|
|
int sim_rename(const char *oldpath, const char* newpath)
|
2003-01-15 11:38:03 +00:00
|
|
|
{
|
2003-03-05 22:59:36 +00:00
|
|
|
char buffer1[256];
|
|
|
|
char buffer2[256];
|
2003-01-15 11:38:03 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
if(oldpath[0] == '/') {
|
|
|
|
sprintf(buffer1, "%s%s", SIMULATOR_ARCHOS_ROOT, oldpath);
|
|
|
|
sprintf(buffer2, "%s%s", SIMULATOR_ARCHOS_ROOT, newpath);
|
2003-01-15 11:38:03 +00:00
|
|
|
|
2003-03-05 22:59:36 +00:00
|
|
|
debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2);
|
2005-03-05 21:48:58 +00:00
|
|
|
return rename(buffer1, buffer2);
|
2003-03-05 22:59:36 +00:00
|
|
|
}
|
|
|
|
return -1;
|
2003-01-15 11:38:03 +00:00
|
|
|
}
|
|
|
|
|
2005-02-28 18:32:57 +00:00
|
|
|
/* rockbox off_t may be different from system off_t */
|
|
|
|
long sim_lseek(int fildes, long offset, int whence)
|
|
|
|
{
|
|
|
|
return lseek(fildes, offset, whence);
|
|
|
|
}
|
|
|
|
|
|
|
|
long sim_filesize(int fd)
|
2003-03-18 00:39:57 +00:00
|
|
|
{
|
2005-03-09 19:26:59 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
return _filelength(fd);
|
|
|
|
#else
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
if (!fstat(fd, &buf))
|
|
|
|
return buf.st_size;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
#endif
|
2003-03-18 00:39:57 +00:00
|
|
|
}
|
|
|
|
|
2002-11-12 11:32:26 +00:00
|
|
|
void fat_size(unsigned int* size, unsigned int* free)
|
|
|
|
{
|
2004-06-10 13:29:52 +00:00
|
|
|
#ifdef WIN32
|
2005-02-22 21:55:48 +00:00
|
|
|
long secperclus, bytespersec, free_clusters, num_clusters;
|
|
|
|
|
|
|
|
if (GetDiskFreeSpace(NULL, &secperclus, &bytespersec, &free_clusters,
|
|
|
|
&num_clusters)) {
|
|
|
|
if (size)
|
|
|
|
*size = num_clusters * secperclus / 2 * (bytespersec / 512);
|
|
|
|
if (free)
|
|
|
|
*free = free_clusters * secperclus / 2 * (bytespersec / 512);
|
|
|
|
}
|
2004-06-10 13:29:52 +00:00
|
|
|
#else
|
2002-11-12 11:32:26 +00:00
|
|
|
struct statfs fs;
|
|
|
|
|
|
|
|
if (!statfs(".", &fs)) {
|
|
|
|
DEBUGF("statfs: bsize=%d blocks=%d free=%d\n",
|
|
|
|
fs.f_bsize, fs.f_blocks, fs.f_bfree);
|
|
|
|
if (size)
|
|
|
|
*size = fs.f_blocks * (fs.f_bsize / 1024);
|
|
|
|
if (free)
|
|
|
|
*free = fs.f_bfree * (fs.f_bsize / 1024);
|
|
|
|
}
|
2005-02-22 21:55:48 +00:00
|
|
|
#endif
|
2002-11-12 11:32:26 +00:00
|
|
|
else {
|
|
|
|
if (size)
|
|
|
|
*size = 0;
|
|
|
|
if (free)
|
|
|
|
*free = 0;
|
|
|
|
}
|
|
|
|
}
|
2005-02-22 12:19:12 +00:00
|
|
|
|
|
|
|
int sim_fsync(int fd)
|
|
|
|
{
|
|
|
|
#ifdef WIN32
|
|
|
|
return _commit(fd);
|
|
|
|
#else
|
|
|
|
return fsync(fd);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
/* sim-win32 */
|
|
|
|
#define dlopen(_x_, _y_) LoadLibrary(_x_)
|
2005-02-22 18:21:16 +00:00
|
|
|
#define dlsym(_x_, _y_) (void *)GetProcAddress(_x_, _y_)
|
2005-02-22 12:19:12 +00:00
|
|
|
#define dlclose(_x_) FreeLibrary(_x_)
|
|
|
|
#else
|
|
|
|
/* sim-x11 */
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#endif
|
|
|
|
|
2005-07-10 16:33:03 +00:00
|
|
|
void *sim_codec_load_ram(char* codecptr, int size,
|
|
|
|
void* ptr2, int bufwrap, int *pd_fd)
|
|
|
|
{
|
|
|
|
void *pd;
|
|
|
|
char *path = "archos/_temp_codec.dll";
|
|
|
|
int (*codec_start)(void * api);
|
|
|
|
int fd;
|
|
|
|
int copy_n;
|
|
|
|
#ifdef WIN32
|
|
|
|
char buf[256];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* We have to create the dynamic link library file from ram
|
|
|
|
* so we could simulate the codec loading.
|
|
|
|
*/
|
|
|
|
*pd_fd = -1;
|
|
|
|
fd = open(path, O_WRONLY | O_CREAT, S_IRWXU);
|
|
|
|
if (fd < 0) {
|
|
|
|
DEBUGF("failed to open for write: %s\n", path);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bufwrap == 0)
|
|
|
|
bufwrap = size;
|
|
|
|
|
|
|
|
copy_n = bufwrap < size ? bufwrap : size;
|
|
|
|
if (write(fd, codecptr, copy_n) != copy_n) {
|
|
|
|
DEBUGF("write failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
size -= copy_n;
|
|
|
|
if (size > 0) {
|
|
|
|
if (write(fd, ptr2, size) != size) {
|
|
|
|
DEBUGF("write failed [2]");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
/* Now load the library. */
|
|
|
|
pd = dlopen(path, RTLD_NOW);
|
|
|
|
if (!pd) {
|
|
|
|
DEBUGF("failed to load %s\n", path);
|
|
|
|
#ifdef WIN32
|
|
|
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
|
|
|
|
buf, sizeof buf, NULL);
|
|
|
|
DEBUGF("dlopen(%s): %s\n", path, buf);
|
|
|
|
#else
|
|
|
|
DEBUGF("dlopen(%s): %s\n", path, dlerror());
|
|
|
|
#endif
|
|
|
|
dlclose(pd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
codec_start = dlsym(pd, "codec_start");
|
|
|
|
if (!codec_start) {
|
|
|
|
codec_start = dlsym(pd, "_codec_start");
|
|
|
|
if (!codec_start) {
|
|
|
|
dlclose(pd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*pd_fd = (int)pd;
|
|
|
|
return codec_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sim_codec_close(int pd)
|
|
|
|
{
|
|
|
|
dlclose((void *)pd);
|
|
|
|
}
|
|
|
|
|
2005-02-22 12:19:12 +00:00
|
|
|
void *sim_plugin_load(char *plugin, int *fd)
|
|
|
|
{
|
|
|
|
void* pd;
|
|
|
|
char path[256];
|
|
|
|
int (*plugin_start)(void * api, void* param);
|
2005-02-22 18:21:16 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
char buf[256];
|
|
|
|
#endif
|
|
|
|
|
2005-02-22 12:19:12 +00:00
|
|
|
snprintf(path, sizeof path, "archos%s", plugin);
|
|
|
|
|
|
|
|
*fd = -1;
|
|
|
|
|
|
|
|
pd = dlopen(path, RTLD_NOW);
|
|
|
|
if (!pd) {
|
2005-02-22 18:21:16 +00:00
|
|
|
DEBUGF("failed to load %s\n", plugin);
|
|
|
|
#ifdef WIN32
|
|
|
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
|
|
|
|
buf, sizeof buf, NULL);
|
|
|
|
DEBUGF("dlopen(%s): %s\n", path, buf);
|
|
|
|
#else
|
|
|
|
DEBUGF("dlopen(%s): %s\n", path, dlerror());
|
|
|
|
#endif
|
2005-02-22 12:19:12 +00:00
|
|
|
dlclose(pd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
plugin_start = dlsym(pd, "plugin_start");
|
|
|
|
if (!plugin_start) {
|
|
|
|
plugin_start = dlsym(pd, "_plugin_start");
|
|
|
|
if (!plugin_start) {
|
|
|
|
dlclose(pd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2005-02-22 18:21:16 +00:00
|
|
|
*fd = (int)pd; /* success */
|
2005-02-22 12:19:12 +00:00
|
|
|
return plugin_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sim_plugin_close(int pd)
|
|
|
|
{
|
2005-02-22 18:21:16 +00:00
|
|
|
dlclose((void *)pd);
|
2005-02-22 12:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef WIN32
|
|
|
|
/* the win32 version is in debug-win32.c */
|
|
|
|
|
|
|
|
void debug_init(void)
|
|
|
|
{
|
|
|
|
/* nothing to be done */
|
|
|
|
}
|
|
|
|
|
|
|
|
void debugf(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start( ap, fmt );
|
|
|
|
vfprintf( stderr, fmt, ap );
|
|
|
|
va_end( ap );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ldebugf(const char* file, int line, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start( ap, fmt );
|
|
|
|
fprintf( stderr, "%s:%d ", file, line );
|
|
|
|
vfprintf( stderr, fmt, ap );
|
|
|
|
va_end( ap );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-03-05 21:48:58 +00:00
|
|
|
/* rockbox off_t may be different from system off_t */
|
|
|
|
int sim_ftruncate(int fd, long length)
|
2005-02-22 12:19:12 +00:00
|
|
|
{
|
|
|
|
#ifdef WIN32
|
|
|
|
return _chsize(fd, length);
|
|
|
|
#else
|
|
|
|
return ftruncate(fd, length);
|
|
|
|
#endif
|
|
|
|
}
|