Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jan 3rd, 2011  |  syntax: C  |  size: 4.45 KB  |  hits: 66  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /***************************************************************************
  2.  *             __________               __   ___.
  3.  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  4.  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  5.  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  6.  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  7.  *                     \/            \/     \/    \/            \/
  8.  * $Id: file.h 28752 2010-12-06 22:26:31Z kugel $
  9.  *
  10.  * Copyright (C) 2002 by Bj√∂rn Stenberg
  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.  ****************************************************************************/
  21.  
  22. #ifndef _FILE_H_
  23. #define _FILE_H_
  24.  
  25. #include <sys/types.h>
  26. #include "config.h"
  27. #include "gcc_extensions.h"
  28. #include <fcntl.h>
  29. #ifdef WIN32
  30. /* this has SEEK_SET et al */
  31. #include <stdio.h>
  32. #endif
  33.  
  34.  
  35. #undef MAX_PATH /* this avoids problems when building simulator */
  36. #define MAX_PATH 260
  37. #define MAX_OPEN_FILES 11
  38.  
  39. typedef int (*open_func)(const char* pathname, int flags, ...);
  40. typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
  41. typedef int (*creat_func)(const char *pathname, mode_t mode);
  42. typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
  43. typedef void (*qsort_func)(void *base, size_t nmemb,  size_t size,
  44.                            int(*_compar)(const void *, const void *));
  45.  
  46. /*
  47.    The function declaration scheme is as follows.
  48.  
  49.    - For plugins and codecs, no file access functions are declared since
  50.      in this case they are accessed via the rb API.
  51.  
  52.    - For application build (target or sim), they are declared as macros
  53.      which expand to app_xxx. I.e. the functions that get declared after
  54.      the preprocessing are app_open, app_remove etc. These functions are
  55.      implemented using the host functions open, remove etc.
  56.  
  57.    - For non-app simulator builds, they are declared as macros
  58.      which expand to sim_xxx. I.e. the functions that get declared after
  59.      the preprocessing are sim_open, sim_remove etc.  These functions are
  60.      implemented using the host functions open, remove etc.
  61.  
  62. */
  63.  
  64. #if !defined(PLUGIN) && !defined(CODEC)
  65.  
  66. #if defined(APPLICATION)
  67. #   define FN_PREFIX       app_
  68. #elif defined(SIMULATOR)
  69. #   define FN_PREFIX       sim_
  70. #endif /* SIMULATOR */
  71.  
  72. /*
  73.    Define to what the function names should expand
  74.    (alphabetically ordered for easier matching with declarations below)
  75. */
  76. #ifdef FN_PREFIX
  77. #define close(x)       FN_PREFIX ## close(x)
  78. #define creat(x,m)     FN_PREFIX ## creat(x,m)
  79. #define filesize(x)    FN_PREFIX ## filesize(x)
  80. #define fsync(x)       FN_PREFIX ## fsync(x)
  81. #define ftruncate(x,y) FN_PREFIX ## ftruncate(x,y)
  82. #define lseek(x,y,z)   FN_PREFIX ## lseek(x,y,z)
  83. #define open(x, ...)   FN_PREFIX ## open(x, __VA_ARGS__)
  84. #define read(x,y,z)    FN_PREFIX ## read(x,y,z)
  85. #define remove(x)      FN_PREFIX ## remove(x)
  86. #define rename(x,y)    FN_PREFIX ## rename(x,y)
  87. #define write(x,y,z)   FN_PREFIX ## write(x,y,z)
  88. #undef FN_PREFIX
  89. #endif /* FN_PREFIX */
  90.  
  91.  
  92. #if (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(__PCTOOL__)
  93. /* posix compatibility function */
  94. static inline int creat(const char *pathname, mode_t mode)
  95. {
  96.     (void)mode;
  97.     return file_creat(pathname);
  98. }
  99. #define creat(path, mode) file_creat(path)
  100. #define open(x, y, ...)   file_open(x,y)
  101. #endif /* CONFIG_PLATFORM & PLATFORM_NATIVE) && !__PCTOOL__ */
  102.  
  103.  
  104. /* Function declarations */
  105. extern int     close(int fd);
  106. extern int     creat(const char *pathname, mode_t mode);
  107. extern off_t   filesize(int fd);
  108. extern int     fsync(int fd);
  109. extern int     ftruncate(int fd, off_t length);
  110. extern off_t   lseek(int fildes, off_t offset, int whence);
  111. extern int     open(const char* pathname, int flags, ...);
  112. extern ssize_t read(int fd, void *buf, size_t count);
  113. extern int     remove(const char* pathname);
  114. extern int     rename(const char* path, const char* newname);
  115. extern ssize_t write(int fd, const void *buf, size_t count);
  116.  
  117. extern int release_files(int volume);
  118. int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
  119. #endif /* !PLUGIN && !CODEC */
  120.  
  121. #endif /* _FILE_H_ */