Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id: file.h 28752 2010-12-06 22:26:31Z kugel $
- *
- * Copyright (C) 2002 by Björn Stenberg
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
- #ifndef _FILE_H_
- #define _FILE_H_
- #include <sys/types.h>
- #include "config.h"
- #include "gcc_extensions.h"
- #include <fcntl.h>
- #ifdef WIN32
- /* this has SEEK_SET et al */
- #include <stdio.h>
- #endif
- #undef MAX_PATH /* this avoids problems when building simulator */
- #define MAX_PATH 260
- #define MAX_OPEN_FILES 11
- typedef int (*open_func)(const char* pathname, int flags, ...);
- typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
- typedef int (*creat_func)(const char *pathname, mode_t mode);
- 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 *));
- /*
- The function declaration scheme is as follows.
- - For plugins and codecs, no file access functions are declared since
- in this case they are accessed via the rb API.
- - For application build (target or sim), they are declared as macros
- which expand to app_xxx. I.e. the functions that get declared after
- the preprocessing are "app_open", "app_remove" etc. These functions
- are implemented using the host functions "open", "remove" etc.
- - For non-app simulator builds, they are declared as macros
- which expand to sim_xxx. I.e. the functions that get declared after
- the preprocessing are "sim_open", "sim_remove" etc. These functions
- are implemented using the host functions "open", "remove" etc.
- */
- #if !defined(PLUGIN) && !defined(CODEC)
- #if defined(APPLICATION)
- # define FN_PREFIX app_
- #elif defined(SIMULATOR)
- # define FN_PREFIX sim_
- #endif /* SIMULATOR */
- /*
- Define to what the function names should expand
- (alphabetically ordered for easier matching with declarations below)
- */
- #ifdef FN_PREFIX
- #define close(x) FN_PREFIX ## close(x)
- #define creat(x,m) FN_PREFIX ## creat(x,m)
- #define fdprintf (fd, fmt, ...) FN_PREFIX ## fdprintf(fd, fmt, __VA_ARGS__)
- #define filesize(x) FN_PREFIX ## filesize(x)
- #define fsync(x) FN_PREFIX ## fsync(x)
- #define ftruncate(x,y) FN_PREFIX ## ftruncate(x,y)
- #define lseek(x,y,z) FN_PREFIX ## lseek(x,y,z)
- #define open(x, ...) FN_PREFIX ## open(x, __VA_ARGS__)
- #define read(x,y,z) FN_PREFIX ## read(x,y,z)
- #define remove(x) FN_PREFIX ## remove(x)
- #define rename(x,y) FN_PREFIX ## rename(x,y)
- #define write(x,y,z) FN_PREFIX ## write(x,y,z)
- #undef FN_PREFIX
- #endif /* FN_PREFIX */
- #if (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(__PCTOOL__)
- /* posix compatibility function */
- static inline int creat(const char *pathname, mode_t mode)
- {
- (void)mode;
- return file_creat(pathname);
- }
- #define creat(path, mode) file_creat(path)
- #define open(x, y, ...) file_open(x,y)
- extern int release_files(int volume);
- #endif /* CONFIG_PLATFORM & PLATFORM_NATIVE) && !__PCTOOL__ */
- /* Function declarations */
- extern int close(int fd);
- extern int creat(const char *pathname, mode_t mode);
- extern off_t filesize(int fd);
- extern int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
- extern int fsync(int fd);
- extern int ftruncate(int fd, off_t length);
- extern off_t lseek(int fildes, off_t offset, int whence);
- extern int open(const char* pathname, int flags, ...);
- extern ssize_t read(int fd, void *buf, size_t count);
- extern int remove(const char* pathname);
- extern int rename(const char* path, const char* newname);
- extern ssize_t write(int fd, const void *buf, size_t count);
- #endif /* !PLUGIN && !CODEC */
- #endif /* _FILE_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement