Vault  4.1
vtypes_internal_platform.h
Go to the documentation of this file.
00001 /*
00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved.
00003 This file is part of the Code Vault version 4.1
00004 http://www.bombaydigital.com/
00005 License: MIT. See LICENSE.md in the Vault top level directory.
00006 */
00007 
00008 #ifndef vtypes_internal_platform_h
00009 #define vtypes_internal_platform_h
00010 
00013 /*
00014 These are the Mac OS X-specific includes and definitions needed
00015 to compile the Vault code itself. Code that includes Vault headers
00016 does not need to be exposed to any of this.
00017 */
00018 
00019 #include <fcntl.h> // open(), file mode constants
00020 #include <sys/stat.h> // mkdir(), stat()
00021 #include <errno.h> // errno, error constants
00022 
00023 #define O_BINARY 0x8000 ///< Macro to define O_BINARY mode, which is not in the standard headers.
00024 
00025 #undef FD_ZERO
00026 #define FD_ZERO(p) memset(p, 0, sizeof(*(p)))
00027 
00028 // Both CodeWarrior and GCC (4.0 at least) provide gettimeofday(), which uses UTC-based values.
00029 #define V_INSTANT_SNAPSHOT_IS_UTC    // platform_snapshot() gives us a UTC time suitable for platform_now()
00030 
00031 /*
00032 These are the custom uniform definitions of system-level functions that behave
00033 slightly differently on each compiler/library/OS platform. These are declared
00034 in each platform's header file in a way that works with that platform.
00035 */
00036 namespace vault {
00037 
00038 //inline int putenv(char* env) { return ::putenv(env); } (not used in our Mac platform code)
00039 //inline char* getenv(const char* name) { return ::getenv(name); } (not used in our Mac platform code)
00040 inline char* getcwd(char* buf, size_t size) { return ::getcwd(buf, size); }
00041 inline ssize_t read(int fd, void* buffer, size_t numBytes) { return ::read(fd, buffer, numBytes); }
00042 inline ssize_t write(int fd, const void* buffer, size_t numBytes) { return ::write(fd, buffer, numBytes); }
00043 inline off_t lseek(int fd, off_t offset, int whence) { return ::lseek(fd, offset, whence); }
00044 inline int open(const char* path, int flags, mode_t mode) { return ::open(path, flags, mode); }
00045 inline FILE* fopen(const char* path, const char* mode) { return ::fopen(path, mode); }
00046 inline int close(int fd) { return ::close(fd); }
00047 inline int mkdir(const char* path, mode_t mode) { return ::mkdir(path, mode); }
00048 inline int rmdir(const char* path) { return ::rmdir(path); }
00049 inline int unlink(const char* path) { return ::unlink(path); }
00050 inline int rename(const char* oldName, const char* newName) { return ::rename(oldName, newName); }
00051 inline int stat(const char* path, struct stat* buf) { return ::stat(path, buf); }
00052 inline int strcasecmp(const char* s1, const char* s2) { return ::strcasecmp(s1, s2); }
00053 inline int strncasecmp(const char* s1, const char* s2, size_t length) { return ::strncasecmp(s1, s2, length); }
00054 inline int vsnprintf(char* buffer, size_t length, const char* format, va_list args) { return ::vsnprintf(buffer, length, format, args); }
00055 }
00056 
00057 #endif /* vtypes_internal_platform_h */

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.