diff options
Diffstat (limited to 'addons/library.xbmc.addon')
| -rw-r--r-- | addons/library.xbmc.addon/dlfcn-win32.cpp | 263 | ||||
| -rw-r--r-- | addons/library.xbmc.addon/dlfcn-win32.h | 46 | ||||
| -rw-r--r-- | addons/library.xbmc.addon/libXBMC_addon.h | 600 |
3 files changed, 909 insertions, 0 deletions
diff --git a/addons/library.xbmc.addon/dlfcn-win32.cpp b/addons/library.xbmc.addon/dlfcn-win32.cpp new file mode 100644 index 0000000..5839921 --- /dev/null +++ b/addons/library.xbmc.addon/dlfcn-win32.cpp | |||
| @@ -0,0 +1,263 @@ | |||
| 1 | /* | ||
| 2 | * dlfcn-win32 | ||
| 3 | * Copyright (c) 2007 Ramiro Polla | ||
| 4 | * | ||
| 5 | * This library is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU Lesser General Public | ||
| 7 | * License as published by the Free Software Foundation; either | ||
| 8 | * version 2.1 of the License, or (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This library is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | * Lesser General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU Lesser General Public | ||
| 16 | * License along with this library; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <windows.h> | ||
| 21 | #include <stdio.h> | ||
| 22 | |||
| 23 | #include "dlfcn-win32.h" | ||
| 24 | |||
| 25 | /* Note: | ||
| 26 | * MSDN says these functions are not thread-safe. We make no efforts to have | ||
| 27 | * any kind of thread safety. | ||
| 28 | */ | ||
| 29 | |||
| 30 | /* I have no special reason to have set MAX_GLOBAL_OBJECTS to this value. Any | ||
| 31 | * comments are welcome. | ||
| 32 | */ | ||
| 33 | #define MAX_OBJECTS 255 | ||
| 34 | |||
| 35 | static HMODULE global_objects[MAX_OBJECTS]; | ||
| 36 | |||
| 37 | /* This function adds an object to the list of global objects. | ||
| 38 | * The implementation is very simple and slow. | ||
| 39 | * TODO: should failing this function be enough to fail the call to dlopen( )? | ||
| 40 | */ | ||
| 41 | static void global_object_add( HMODULE hModule ) | ||
| 42 | { | ||
| 43 | int i; | ||
| 44 | |||
| 45 | for( i = 0 ; i < MAX_OBJECTS ; i++ ) | ||
| 46 | { | ||
| 47 | if( !global_objects[i] ) | ||
| 48 | { | ||
| 49 | global_objects[i] = hModule; | ||
| 50 | break; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | static void global_object_rem( HMODULE hModule ) | ||
| 56 | { | ||
| 57 | int i; | ||
| 58 | |||
| 59 | for( i = 0 ; i < MAX_OBJECTS ; i++ ) | ||
| 60 | { | ||
| 61 | if( global_objects[i] == hModule ) | ||
| 62 | { | ||
| 63 | global_objects[i] = 0; | ||
| 64 | break; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | /* Argument to last function. Used in dlerror( ) */ | ||
| 70 | static char last_name[MAX_PATH]; | ||
| 71 | |||
| 72 | static int copy_string( char *dest, int dest_size, const char *src ) | ||
| 73 | { | ||
| 74 | int i = 0; | ||
| 75 | |||
| 76 | if( src && dest ) | ||
| 77 | { | ||
| 78 | for( i = 0 ; i < dest_size-1 ; i++ ) | ||
| 79 | { | ||
| 80 | if( !src[i] ) | ||
| 81 | break; | ||
| 82 | else | ||
| 83 | dest[i] = src[i]; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | dest[i] = '\0'; | ||
| 87 | |||
| 88 | return i; | ||
| 89 | } | ||
| 90 | |||
| 91 | void *dlopen( const char *file, int mode ) | ||
| 92 | { | ||
| 93 | HMODULE hModule; | ||
| 94 | UINT uMode; | ||
| 95 | |||
| 96 | /* Do not let Windows display the critical-error-handler message box */ | ||
| 97 | uMode = SetErrorMode( SEM_FAILCRITICALERRORS ); | ||
| 98 | |||
| 99 | if( file == 0 ) | ||
| 100 | { | ||
| 101 | /* Save NULL pointer for error message */ | ||
| 102 | _snprintf_s( last_name, MAX_PATH, MAX_PATH, "0x%p", file ); | ||
| 103 | |||
| 104 | /* POSIX says that if the value of file is 0, a handle on a global | ||
| 105 | * symbol object must be provided. That object must be able to access | ||
| 106 | * all symbols from the original program file, and any objects loaded | ||
| 107 | * with the RTLD_GLOBAL flag. | ||
| 108 | * The return value from GetModuleHandle( ) allows us to retrieve | ||
| 109 | * symbols only from the original program file. For objects loaded with | ||
| 110 | * the RTLD_GLOBAL flag, we create our own list later on. | ||
| 111 | */ | ||
| 112 | hModule = GetModuleHandle( NULL ); | ||
| 113 | } | ||
| 114 | else | ||
| 115 | { | ||
| 116 | char lpFileName[MAX_PATH]; | ||
| 117 | int i; | ||
| 118 | |||
| 119 | /* MSDN says backslashes *must* be used instead of forward slashes. */ | ||
| 120 | for( i = 0 ; i < sizeof(lpFileName)-1 ; i++ ) | ||
| 121 | { | ||
| 122 | if( !file[i] ) | ||
| 123 | break; | ||
| 124 | else if( file[i] == '/' ) | ||
| 125 | lpFileName[i] = '\\'; | ||
| 126 | else | ||
| 127 | lpFileName[i] = file[i]; | ||
| 128 | } | ||
| 129 | lpFileName[i] = '\0'; | ||
| 130 | |||
| 131 | /* Save file name for error message */ | ||
| 132 | copy_string( last_name, sizeof(last_name), lpFileName ); | ||
| 133 | |||
| 134 | /* POSIX says the search path is implementation-defined. | ||
| 135 | * LOAD_WITH_ALTERED_SEARCH_PATH is used to make it behave more closely | ||
| 136 | * to UNIX's search paths (start with system folders instead of current | ||
| 137 | * folder). | ||
| 138 | */ | ||
| 139 | hModule = LoadLibraryEx( (LPSTR) lpFileName, NULL, | ||
| 140 | LOAD_WITH_ALTERED_SEARCH_PATH ); | ||
| 141 | /* If the object was loaded with RTLD_GLOBAL, add it to list of global | ||
| 142 | * objects, so that its symbols may be retrieved even if the handle for | ||
| 143 | * the original program file is passed. POSIX says that if the same | ||
| 144 | * file is specified in multiple invocations, and any of them are | ||
| 145 | * RTLD_GLOBAL, even if any further invocations use RTLD_LOCAL, the | ||
| 146 | * symbols will remain global. | ||
| 147 | */ | ||
| 148 | |||
| 149 | if( hModule && (mode & RTLD_GLOBAL) ) | ||
| 150 | global_object_add( hModule ); | ||
| 151 | } | ||
| 152 | |||
| 153 | /* Return to previous state of the error-mode bit flags. */ | ||
| 154 | SetErrorMode( uMode ); | ||
| 155 | |||
| 156 | return (void *) hModule; | ||
| 157 | } | ||
| 158 | |||
| 159 | int dlclose( void *handle ) | ||
| 160 | { | ||
| 161 | HMODULE hModule = (HMODULE) handle; | ||
| 162 | BOOL ret; | ||
| 163 | |||
| 164 | /* Save handle for error message */ | ||
| 165 | _snprintf_s( last_name, MAX_PATH, MAX_PATH, "0x%p", handle ); | ||
| 166 | |||
| 167 | ret = FreeLibrary( hModule ); | ||
| 168 | |||
| 169 | /* If the object was loaded with RTLD_GLOBAL, remove it from list of global | ||
| 170 | * objects. | ||
| 171 | */ | ||
| 172 | if( ret ) | ||
| 173 | global_object_rem( hModule ); | ||
| 174 | |||
| 175 | /* dlclose's return value in inverted in relation to FreeLibrary's. */ | ||
| 176 | ret = !ret; | ||
| 177 | |||
| 178 | return (int) ret; | ||
| 179 | } | ||
| 180 | |||
| 181 | void *dlsym( void *handle, const char *name ) | ||
| 182 | { | ||
| 183 | FARPROC symbol; | ||
| 184 | HMODULE myhandle = (HMODULE) handle; | ||
| 185 | |||
| 186 | /* Save symbol name for error message */ | ||
| 187 | copy_string( last_name, sizeof(last_name), name ); | ||
| 188 | |||
| 189 | symbol = GetProcAddress( myhandle, name ); | ||
| 190 | #if 0 | ||
| 191 | if( symbol == NULL ) | ||
| 192 | { | ||
| 193 | HMODULE hModule; | ||
| 194 | |||
| 195 | /* If the handle for the original program file is passed, also search | ||
| 196 | * in all globally loaded objects. | ||
| 197 | */ | ||
| 198 | |||
| 199 | hModule = GetModuleHandle( NULL ); | ||
| 200 | |||
| 201 | if( hModule == handle ) | ||
| 202 | { | ||
| 203 | int i; | ||
| 204 | |||
| 205 | for( i = 0 ; i < MAX_OBJECTS ; i++ ) | ||
| 206 | { | ||
| 207 | if( global_objects[i] != 0 ) | ||
| 208 | { | ||
| 209 | symbol = GetProcAddress( global_objects[i], name ); | ||
| 210 | if( symbol != NULL ) | ||
| 211 | break; | ||
| 212 | } | ||
| 213 | } | ||
| 214 | } | ||
| 215 | |||
| 216 | |||
| 217 | CloseHandle( hModule ); | ||
| 218 | } | ||
| 219 | #endif | ||
| 220 | return (void*) symbol; | ||
| 221 | } | ||
| 222 | |||
| 223 | char *dlerror( void ) | ||
| 224 | { | ||
| 225 | DWORD dwMessageId; | ||
| 226 | /* POSIX says this function doesn't have to be thread-safe, so we use one | ||
| 227 | * static buffer. | ||
| 228 | * MSDN says the buffer cannot be larger than 64K bytes, so we set it to | ||
| 229 | * the limit. | ||
| 230 | */ | ||
| 231 | static char lpBuffer[65535]; | ||
| 232 | DWORD ret; | ||
| 233 | |||
| 234 | dwMessageId = GetLastError( ); | ||
| 235 | |||
| 236 | if( dwMessageId == 0 ) | ||
| 237 | return NULL; | ||
| 238 | |||
| 239 | /* Format error message to: | ||
| 240 | * "<argument to function that failed>": <Windows localized error message> | ||
| 241 | */ | ||
| 242 | ret = copy_string( lpBuffer, sizeof(lpBuffer), "\"" ); | ||
| 243 | ret += copy_string( lpBuffer+ret, sizeof(lpBuffer)-ret, last_name ); | ||
| 244 | ret += copy_string( lpBuffer+ret, sizeof(lpBuffer)-ret, "\": " ); | ||
| 245 | ret += FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwMessageId, | ||
| 246 | MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), | ||
| 247 | lpBuffer+ret, sizeof(lpBuffer)-ret, NULL ); | ||
| 248 | |||
| 249 | if( ret > 1 ) | ||
| 250 | { | ||
| 251 | /* POSIX says the string must not have trailing <newline> */ | ||
| 252 | if( lpBuffer[ret-2] == '\r' && lpBuffer[ret-1] == '\n' ) | ||
| 253 | lpBuffer[ret-2] = '\0'; | ||
| 254 | } | ||
| 255 | |||
| 256 | /* POSIX says that invoking dlerror( ) a second time, immediately following | ||
| 257 | * a prior invocation, shall result in NULL being returned. | ||
| 258 | */ | ||
| 259 | SetLastError(0); | ||
| 260 | |||
| 261 | return lpBuffer; | ||
| 262 | } | ||
| 263 | |||
diff --git a/addons/library.xbmc.addon/dlfcn-win32.h b/addons/library.xbmc.addon/dlfcn-win32.h new file mode 100644 index 0000000..b93a029 --- /dev/null +++ b/addons/library.xbmc.addon/dlfcn-win32.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * dlfcn-win32 | ||
| 4 | * Copyright (c) 2007 Ramiro Polla | ||
| 5 | * | ||
| 6 | * This library is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This library is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with this library; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef DLFCN_H | ||
| 22 | #define DLFCN_H | ||
| 23 | |||
| 24 | /* POSIX says these are implementation-defined. | ||
| 25 | * To simplify use with Windows API, we treat them the same way. | ||
| 26 | */ | ||
| 27 | |||
| 28 | #define RTLD_LAZY 0 | ||
| 29 | #define RTLD_NOW 0 | ||
| 30 | |||
| 31 | #define RTLD_GLOBAL (1 << 1) | ||
| 32 | #define RTLD_LOCAL (1 << 2) | ||
| 33 | |||
| 34 | /* These two were added in The Open Group Base Specifications Issue 6. | ||
| 35 | * Note: All other RTLD_* flags in any dlfcn.h are not standard compliant. | ||
| 36 | */ | ||
| 37 | |||
| 38 | #define RTLD_DEFAULT 0 | ||
| 39 | #define RTLD_NEXT 0 | ||
| 40 | |||
| 41 | void *dlopen ( const char *file, int mode ); | ||
| 42 | int dlclose( void *handle ); | ||
| 43 | void *dlsym ( void *handle, const char *name ); | ||
| 44 | char *dlerror( void ); | ||
| 45 | |||
| 46 | #endif /* DLFCN-WIN32_H */ | ||
diff --git a/addons/library.xbmc.addon/libXBMC_addon.h b/addons/library.xbmc.addon/libXBMC_addon.h new file mode 100644 index 0000000..c3ed54f --- /dev/null +++ b/addons/library.xbmc.addon/libXBMC_addon.h | |||
| @@ -0,0 +1,600 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2013 Team XBMC | ||
| 4 | * http://xbmc.org | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with XBMC; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <string> | ||
| 23 | #include <vector> | ||
| 24 | #include <string.h> | ||
| 25 | #include <stdlib.h> | ||
| 26 | #include <stdio.h> | ||
| 27 | #include <stdint.h> | ||
| 28 | #include <stdarg.h> | ||
| 29 | |||
| 30 | #ifdef _WIN32 // windows | ||
| 31 | #ifndef _SSIZE_T_DEFINED | ||
| 32 | typedef intptr_t ssize_t; | ||
| 33 | #define _SSIZE_T_DEFINED | ||
| 34 | #endif // !_SSIZE_T_DEFINED | ||
| 35 | #include "dlfcn-win32.h" | ||
| 36 | #define ADDON_DLL "\\library.xbmc.addon\\libXBMC_addon" ADDON_HELPER_EXT | ||
| 37 | #define ADDON_HELPER_EXT ".dll" | ||
| 38 | #else | ||
| 39 | #if defined(__APPLE__) // osx | ||
| 40 | #if defined(__POWERPC__) | ||
| 41 | #define ADDON_HELPER_ARCH "powerpc-osx" | ||
| 42 | #elif defined(__arm__) | ||
| 43 | #define ADDON_HELPER_ARCH "arm-osx" | ||
| 44 | #elif defined(__x86_64__) | ||
| 45 | #define ADDON_HELPER_ARCH "x86-osx" | ||
| 46 | #else | ||
| 47 | #define ADDON_HELPER_ARCH "x86-osx" | ||
| 48 | #endif | ||
| 49 | #else // linux | ||
| 50 | #if defined(__x86_64__) | ||
| 51 | #define ADDON_HELPER_ARCH "x86_64-linux" | ||
| 52 | #elif defined(_POWERPC) | ||
| 53 | #define ADDON_HELPER_ARCH "powerpc-linux" | ||
| 54 | #elif defined(_POWERPC64) | ||
| 55 | #define ADDON_HELPER_ARCH "powerpc64-linux" | ||
| 56 | #elif defined(__ARMEL__) | ||
| 57 | #define ADDON_HELPER_ARCH "arm" | ||
| 58 | #elif defined(__mips__) | ||
| 59 | #define ADDON_HELPER_ARCH "mips" | ||
| 60 | #else | ||
| 61 | #define ADDON_HELPER_ARCH "i486-linux" | ||
| 62 | #endif | ||
| 63 | #endif | ||
| 64 | #include <dlfcn.h> // linux+osx | ||
| 65 | #define ADDON_HELPER_EXT ".so" | ||
| 66 | #define ADDON_DLL_NAME "libXBMC_addon-" ADDON_HELPER_ARCH ADDON_HELPER_EXT | ||
| 67 | #define ADDON_DLL "/library.xbmc.addon/" ADDON_DLL_NAME | ||
| 68 | #endif | ||
| 69 | #if defined(ANDROID) | ||
| 70 | #include <sys/stat.h> | ||
| 71 | #endif | ||
| 72 | |||
| 73 | #ifdef LOG_DEBUG | ||
| 74 | #undef LOG_DEBUG | ||
| 75 | #endif | ||
| 76 | #ifdef LOG_INFO | ||
| 77 | #undef LOG_INFO | ||
| 78 | #endif | ||
| 79 | #ifdef LOG_NOTICE | ||
| 80 | #undef LOG_NOTICE | ||
| 81 | #endif | ||
| 82 | #ifdef LOG_ERROR | ||
| 83 | #undef LOG_ERROR | ||
| 84 | #endif | ||
| 85 | |||
| 86 | namespace ADDON | ||
| 87 | { | ||
| 88 | typedef enum addon_log | ||
| 89 | { | ||
| 90 | LOG_DEBUG, | ||
| 91 | LOG_INFO, | ||
| 92 | LOG_NOTICE, | ||
| 93 | LOG_ERROR | ||
| 94 | } addon_log_t; | ||
| 95 | |||
| 96 | typedef enum queue_msg | ||
| 97 | { | ||
| 98 | QUEUE_INFO, | ||
| 99 | QUEUE_WARNING, | ||
| 100 | QUEUE_ERROR | ||
| 101 | } queue_msg_t; | ||
| 102 | |||
| 103 | class CHelper_libXBMC_addon | ||
| 104 | { | ||
| 105 | public: | ||
| 106 | CHelper_libXBMC_addon() | ||
| 107 | { | ||
| 108 | m_libXBMC_addon = NULL; | ||
| 109 | m_Handle = NULL; | ||
| 110 | } | ||
| 111 | |||
| 112 | ~CHelper_libXBMC_addon() | ||
| 113 | { | ||
| 114 | if (m_libXBMC_addon) | ||
| 115 | { | ||
| 116 | XBMC_unregister_me(m_Handle, m_Callbacks); | ||
| 117 | dlclose(m_libXBMC_addon); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 121 | bool RegisterMe(void *Handle) | ||
| 122 | { | ||
| 123 | m_Handle = Handle; | ||
| 124 | |||
| 125 | std::string libBasePath; | ||
| 126 | libBasePath = ((cb_array*)m_Handle)->libPath; | ||
| 127 | libBasePath += ADDON_DLL; | ||
| 128 | |||
| 129 | #if defined(ANDROID) | ||
| 130 | struct stat st; | ||
| 131 | if(stat(libBasePath.c_str(),&st) != 0) | ||
| 132 | { | ||
| 133 | std::string tempbin = getenv("XBMC_ANDROID_LIBS"); | ||
| 134 | libBasePath = tempbin + "/" + ADDON_DLL_NAME; | ||
| 135 | } | ||
| 136 | #endif | ||
| 137 | |||
| 138 | m_libXBMC_addon = dlopen(libBasePath.c_str(), RTLD_LAZY); | ||
| 139 | if (m_libXBMC_addon == NULL) | ||
| 140 | { | ||
| 141 | fprintf(stderr, "Unable to load %s\n", dlerror()); | ||
| 142 | return false; | ||
| 143 | } | ||
| 144 | |||
| 145 | XBMC_register_me = (void* (*)(void *HANDLE)) | ||
| 146 | dlsym(m_libXBMC_addon, "XBMC_register_me"); | ||
| 147 | if (XBMC_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 148 | |||
| 149 | XBMC_unregister_me = (void (*)(void* HANDLE, void* CB)) | ||
| 150 | dlsym(m_libXBMC_addon, "XBMC_unregister_me"); | ||
| 151 | if (XBMC_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 152 | |||
| 153 | XBMC_log = (void (*)(void* HANDLE, void* CB, const addon_log_t loglevel, const char *msg)) | ||
| 154 | dlsym(m_libXBMC_addon, "XBMC_log"); | ||
| 155 | if (XBMC_log == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 156 | |||
| 157 | XBMC_get_setting = (bool (*)(void* HANDLE, void* CB, const char* settingName, void *settingValue)) | ||
| 158 | dlsym(m_libXBMC_addon, "XBMC_get_setting"); | ||
| 159 | if (XBMC_get_setting == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 160 | |||
| 161 | XBMC_queue_notification = (void (*)(void* HANDLE, void* CB, const queue_msg_t loglevel, const char *msg)) | ||
| 162 | dlsym(m_libXBMC_addon, "XBMC_queue_notification"); | ||
| 163 | if (XBMC_queue_notification == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 164 | |||
| 165 | XBMC_wake_on_lan = (bool (*)(void* HANDLE, void *CB, const char *mac)) | ||
| 166 | dlsym(m_libXBMC_addon, "XBMC_wake_on_lan"); | ||
| 167 | if (XBMC_wake_on_lan == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 168 | |||
| 169 | XBMC_unknown_to_utf8 = (char* (*)(void* HANDLE, void* CB, const char* str)) | ||
| 170 | dlsym(m_libXBMC_addon, "XBMC_unknown_to_utf8"); | ||
| 171 | if (XBMC_unknown_to_utf8 == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 172 | |||
| 173 | XBMC_get_localized_string = (char* (*)(void* HANDLE, void* CB, int dwCode)) | ||
| 174 | dlsym(m_libXBMC_addon, "XBMC_get_localized_string"); | ||
| 175 | if (XBMC_get_localized_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 176 | |||
| 177 | XBMC_free_string = (void (*)(void* HANDLE, void* CB, char* str)) | ||
| 178 | dlsym(m_libXBMC_addon, "XBMC_free_string"); | ||
| 179 | if (XBMC_free_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 180 | |||
| 181 | XBMC_get_dvd_menu_language = (char* (*)(void* HANDLE, void* CB)) | ||
| 182 | dlsym(m_libXBMC_addon, "XBMC_get_dvd_menu_language"); | ||
| 183 | if (XBMC_get_dvd_menu_language == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 184 | |||
| 185 | XBMC_open_file = (void* (*)(void* HANDLE, void* CB, const char* strFileName, unsigned int flags)) | ||
| 186 | dlsym(m_libXBMC_addon, "XBMC_open_file"); | ||
| 187 | if (XBMC_open_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 188 | |||
| 189 | XBMC_open_file_for_write = (void* (*)(void* HANDLE, void* CB, const char* strFileName, bool bOverWrite)) | ||
| 190 | dlsym(m_libXBMC_addon, "XBMC_open_file_for_write"); | ||
| 191 | if (XBMC_open_file_for_write == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 192 | |||
| 193 | XBMC_read_file = (ssize_t (*)(void* HANDLE, void* CB, void* file, void* lpBuf, size_t uiBufSize)) | ||
| 194 | dlsym(m_libXBMC_addon, "XBMC_read_file"); | ||
| 195 | if (XBMC_read_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 196 | |||
| 197 | XBMC_read_file_string = (bool (*)(void* HANDLE, void* CB, void* file, char *szLine, int iLineLength)) | ||
| 198 | dlsym(m_libXBMC_addon, "XBMC_read_file_string"); | ||
| 199 | if (XBMC_read_file_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 200 | |||
| 201 | XBMC_write_file = (ssize_t (*)(void* HANDLE, void* CB, void* file, const void* lpBuf, size_t uiBufSize)) | ||
| 202 | dlsym(m_libXBMC_addon, "XBMC_write_file"); | ||
| 203 | if (XBMC_write_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 204 | |||
| 205 | XBMC_flush_file = (void (*)(void* HANDLE, void* CB, void* file)) | ||
| 206 | dlsym(m_libXBMC_addon, "XBMC_flush_file"); | ||
| 207 | if (XBMC_flush_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 208 | |||
| 209 | XBMC_seek_file = (int64_t (*)(void* HANDLE, void* CB, void* file, int64_t iFilePosition, int iWhence)) | ||
| 210 | dlsym(m_libXBMC_addon, "XBMC_seek_file"); | ||
| 211 | if (XBMC_seek_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 212 | |||
| 213 | XBMC_truncate_file = (int (*)(void* HANDLE, void* CB, void* file, int64_t iSize)) | ||
| 214 | dlsym(m_libXBMC_addon, "XBMC_truncate_file"); | ||
| 215 | if (XBMC_truncate_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 216 | |||
| 217 | XBMC_get_file_position = (int64_t (*)(void* HANDLE, void* CB, void* file)) | ||
| 218 | dlsym(m_libXBMC_addon, "XBMC_get_file_position"); | ||
| 219 | if (XBMC_get_file_position == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 220 | |||
| 221 | XBMC_get_file_length = (int64_t (*)(void* HANDLE, void* CB, void* file)) | ||
| 222 | dlsym(m_libXBMC_addon, "XBMC_get_file_length"); | ||
| 223 | if (XBMC_get_file_length == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 224 | |||
| 225 | XBMC_close_file = (void (*)(void* HANDLE, void* CB, void* file)) | ||
| 226 | dlsym(m_libXBMC_addon, "XBMC_close_file"); | ||
| 227 | if (XBMC_close_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 228 | |||
| 229 | XBMC_get_file_chunk_size = (int (*)(void* HANDLE, void* CB, void* file)) | ||
| 230 | dlsym(m_libXBMC_addon, "XBMC_get_file_chunk_size"); | ||
| 231 | if (XBMC_get_file_chunk_size == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 232 | |||
| 233 | XBMC_file_exists = (bool (*)(void* HANDLE, void* CB, const char *strFileName, bool bUseCache)) | ||
| 234 | dlsym(m_libXBMC_addon, "XBMC_file_exists"); | ||
| 235 | if (XBMC_file_exists == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 236 | |||
| 237 | XBMC_stat_file = (int (*)(void* HANDLE, void* CB, const char *strFileName, struct __stat64* buffer)) | ||
| 238 | dlsym(m_libXBMC_addon, "XBMC_stat_file"); | ||
| 239 | if (XBMC_stat_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 240 | |||
| 241 | XBMC_delete_file = (bool (*)(void* HANDLE, void* CB, const char *strFileName)) | ||
| 242 | dlsym(m_libXBMC_addon, "XBMC_delete_file"); | ||
| 243 | if (XBMC_delete_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 244 | |||
| 245 | XBMC_can_open_directory = (bool (*)(void* HANDLE, void* CB, const char* strURL)) | ||
| 246 | dlsym(m_libXBMC_addon, "XBMC_can_open_directory"); | ||
| 247 | if (XBMC_can_open_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 248 | |||
| 249 | XBMC_create_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath)) | ||
| 250 | dlsym(m_libXBMC_addon, "XBMC_create_directory"); | ||
| 251 | if (XBMC_create_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 252 | |||
| 253 | XBMC_directory_exists = (bool (*)(void* HANDLE, void* CB, const char* strPath)) | ||
| 254 | dlsym(m_libXBMC_addon, "XBMC_directory_exists"); | ||
| 255 | if (XBMC_directory_exists == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 256 | |||
| 257 | XBMC_remove_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath)) | ||
| 258 | dlsym(m_libXBMC_addon, "XBMC_remove_directory"); | ||
| 259 | if (XBMC_remove_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } | ||
| 260 | |||
| 261 | m_Callbacks = XBMC_register_me(m_Handle); | ||
| 262 | return m_Callbacks != NULL; | ||
| 263 | } | ||
| 264 | |||
| 265 | /*! | ||
| 266 | * @brief Add a message to XBMC's log. | ||
| 267 | * @param loglevel The log level of the message. | ||
| 268 | * @param format The format of the message to pass to XBMC. | ||
| 269 | */ | ||
| 270 | void Log(const addon_log_t loglevel, const char *format, ... ) | ||
| 271 | { | ||
| 272 | char buffer[16384]; | ||
| 273 | va_list args; | ||
| 274 | va_start (args, format); | ||
| 275 | vsprintf (buffer, format, args); | ||
| 276 | va_end (args); | ||
| 277 | return XBMC_log(m_Handle, m_Callbacks, loglevel, buffer); | ||
| 278 | } | ||
| 279 | |||
| 280 | /*! | ||
| 281 | * @brief Get a settings value for this add-on. | ||
| 282 | * @param settingName The name of the setting to get. | ||
| 283 | * @param settingValue The value. | ||
| 284 | * @return True if the settings was fetched successfully, false otherwise. | ||
| 285 | */ | ||
| 286 | bool GetSetting(const char* settingName, void *settingValue) | ||
| 287 | { | ||
| 288 | return XBMC_get_setting(m_Handle, m_Callbacks, settingName, settingValue); | ||
| 289 | } | ||
| 290 | |||
| 291 | /*! | ||
| 292 | * @brief Queue a notification in the GUI. | ||
| 293 | * @param type The message type. | ||
| 294 | * @param format The format of the message to pass to display in XBMC. | ||
| 295 | */ | ||
| 296 | void QueueNotification(const queue_msg_t type, const char *format, ... ) | ||
| 297 | { | ||
| 298 | char buffer[16384]; | ||
| 299 | va_list args; | ||
| 300 | va_start (args, format); | ||
| 301 | vsprintf (buffer, format, args); | ||
| 302 | va_end (args); | ||
| 303 | return XBMC_queue_notification(m_Handle, m_Callbacks, type, buffer); | ||
| 304 | } | ||
| 305 | |||
| 306 | /*! | ||
| 307 | * @brief Send WakeOnLan magic packet. | ||
| 308 | * @param mac Network address of the host to wake. | ||
| 309 | * @return True if the magic packet was successfully sent, false otherwise. | ||
| 310 | */ | ||
| 311 | bool WakeOnLan(const char* mac) | ||
| 312 | { | ||
| 313 | return XBMC_wake_on_lan(m_Handle, m_Callbacks, mac); | ||
| 314 | } | ||
| 315 | |||
| 316 | /*! | ||
| 317 | * @brief Translate a string with an unknown encoding to UTF8. | ||
| 318 | * @param str The string to translate. | ||
| 319 | * @return The string translated to UTF8. Must be freed by calling FreeString() when done. | ||
| 320 | */ | ||
| 321 | char* UnknownToUTF8(const char* str) | ||
| 322 | { | ||
| 323 | return XBMC_unknown_to_utf8(m_Handle, m_Callbacks, str); | ||
| 324 | } | ||
| 325 | |||
| 326 | /*! | ||
| 327 | * @brief Get a localised message. | ||
| 328 | * @param dwCode The code of the message to get. | ||
| 329 | * @return The message. Must be freed by calling FreeString() when done. | ||
| 330 | */ | ||
| 331 | char* GetLocalizedString(int dwCode) | ||
| 332 | { | ||
| 333 | return XBMC_get_localized_string(m_Handle, m_Callbacks, dwCode); | ||
| 334 | } | ||
| 335 | |||
| 336 | |||
| 337 | /*! | ||
| 338 | * @brief Get the DVD menu language. | ||
| 339 | * @return The language. Must be freed by calling FreeString() when done. | ||
| 340 | */ | ||
| 341 | char* GetDVDMenuLanguage() | ||
| 342 | { | ||
| 343 | return XBMC_get_dvd_menu_language(m_Handle, m_Callbacks); | ||
| 344 | } | ||
| 345 | |||
| 346 | /*! | ||
| 347 | * @brief Free the memory used by str | ||
| 348 | * @param str The string to free | ||
| 349 | */ | ||
| 350 | void FreeString(char* str) | ||
| 351 | { | ||
| 352 | return XBMC_free_string(m_Handle, m_Callbacks, str); | ||
| 353 | } | ||
| 354 | |||
| 355 | /*! | ||
| 356 | * @brief Open the file with filename via XBMC's CFile. Needs to be closed by calling CloseFile() when done. | ||
| 357 | * @param strFileName The filename to open. | ||
| 358 | * @param flags The flags to pass. Documented in XBMC's File.h | ||
| 359 | * @return A handle for the file, or NULL if it couldn't be opened. | ||
| 360 | */ | ||
| 361 | void* OpenFile(const char* strFileName, unsigned int flags) | ||
| 362 | { | ||
| 363 | return XBMC_open_file(m_Handle, m_Callbacks, strFileName, flags); | ||
| 364 | } | ||
| 365 | |||
| 366 | /*! | ||
| 367 | * @brief Open the file with filename via XBMC's CFile in write mode. Needs to be closed by calling CloseFile() when done. | ||
| 368 | * @param strFileName The filename to open. | ||
| 369 | * @param bOverWrite True to overwrite, false otherwise. | ||
| 370 | * @return A handle for the file, or NULL if it couldn't be opened. | ||
| 371 | */ | ||
| 372 | void* OpenFileForWrite(const char* strFileName, bool bOverWrite) | ||
| 373 | { | ||
| 374 | return XBMC_open_file_for_write(m_Handle, m_Callbacks, strFileName, bOverWrite); | ||
| 375 | } | ||
| 376 | |||
| 377 | /*! | ||
| 378 | * @brief Read from an open file. | ||
| 379 | * @param file The file handle to read from. | ||
| 380 | * @param lpBuf The buffer to store the data in. | ||
| 381 | * @param uiBufSize The size of the buffer. | ||
| 382 | * @return number of successfully read bytes if any bytes were read and stored in | ||
| 383 | * buffer, zero if no bytes are available to read (end of file was reached) | ||
| 384 | * or undetectable error occur, -1 in case of any explicit error | ||
| 385 | */ | ||
| 386 | ssize_t ReadFile(void* file, void* lpBuf, size_t uiBufSize) | ||
| 387 | { | ||
| 388 | return XBMC_read_file(m_Handle, m_Callbacks, file, lpBuf, uiBufSize); | ||
| 389 | } | ||
| 390 | |||
| 391 | /*! | ||
| 392 | * @brief Read a string from an open file. | ||
| 393 | * @param file The file handle to read from. | ||
| 394 | * @param szLine The buffer to store the data in. | ||
| 395 | * @param iLineLength The size of the buffer. | ||
| 396 | * @return True when a line was read, false otherwise. | ||
| 397 | */ | ||
| 398 | bool ReadFileString(void* file, char *szLine, int iLineLength) | ||
| 399 | { | ||
| 400 | return XBMC_read_file_string(m_Handle, m_Callbacks, file, szLine, iLineLength); | ||
| 401 | } | ||
| 402 | |||
| 403 | /*! | ||
| 404 | * @brief Write to a file opened in write mode. | ||
| 405 | * @param file The file handle to write to. | ||
| 406 | * @param lpBuf The data to write. | ||
| 407 | * @param uiBufSize Size of the data to write. | ||
| 408 | * @return number of successfully written bytes if any bytes were written, | ||
| 409 | * zero if no bytes were written and no detectable error occur, | ||
| 410 | * -1 in case of any explicit error | ||
| 411 | */ | ||
| 412 | ssize_t WriteFile(void* file, const void* lpBuf, size_t uiBufSize) | ||
| 413 | { | ||
| 414 | return XBMC_write_file(m_Handle, m_Callbacks, file, lpBuf, uiBufSize); | ||
| 415 | } | ||
| 416 | |||
| 417 | /*! | ||
| 418 | * @brief Flush buffered data. | ||
| 419 | * @param file The file handle to flush the data for. | ||
| 420 | */ | ||
| 421 | void FlushFile(void* file) | ||
| 422 | { | ||
| 423 | return XBMC_flush_file(m_Handle, m_Callbacks, file); | ||
| 424 | } | ||
| 425 | |||
| 426 | /*! | ||
| 427 | * @brief Seek in an open file. | ||
| 428 | * @param file The file handle to see in. | ||
| 429 | * @param iFilePosition The new position. | ||
| 430 | * @param iWhence Seek argument. See stdio.h for possible values. | ||
| 431 | * @return The new position. | ||
| 432 | */ | ||
| 433 | int64_t SeekFile(void* file, int64_t iFilePosition, int iWhence) | ||
| 434 | { | ||
| 435 | return XBMC_seek_file(m_Handle, m_Callbacks, file, iFilePosition, iWhence); | ||
| 436 | } | ||
| 437 | |||
| 438 | /*! | ||
| 439 | * @brief Truncate a file to the requested size. | ||
| 440 | * @param file The file handle to truncate. | ||
| 441 | * @param iSize The new max size. | ||
| 442 | * @return New size? | ||
| 443 | */ | ||
| 444 | int TruncateFile(void* file, int64_t iSize) | ||
| 445 | { | ||
| 446 | return XBMC_truncate_file(m_Handle, m_Callbacks, file, iSize); | ||
| 447 | } | ||
| 448 | |||
| 449 | /*! | ||
| 450 | * @brief The current position in an open file. | ||
| 451 | * @param file The file handle to get the position for. | ||
| 452 | * @return The requested position. | ||
| 453 | */ | ||
| 454 | int64_t GetFilePosition(void* file) | ||
| 455 | { | ||
| 456 | return XBMC_get_file_position(m_Handle, m_Callbacks, file); | ||
| 457 | } | ||
| 458 | |||
| 459 | /*! | ||
| 460 | * @brief Get the file size of an open file. | ||
| 461 | * @param file The file to get the size for. | ||
| 462 | * @return The requested size. | ||
| 463 | */ | ||
| 464 | int64_t GetFileLength(void* file) | ||
| 465 | { | ||
| 466 | return XBMC_get_file_length(m_Handle, m_Callbacks, file); | ||
| 467 | } | ||
| 468 | |||
| 469 | /*! | ||
| 470 | * @brief Close an open file. | ||
| 471 | * @param file The file handle to close. | ||
| 472 | */ | ||
| 473 | void CloseFile(void* file) | ||
| 474 | { | ||
| 475 | return XBMC_close_file(m_Handle, m_Callbacks, file); | ||
| 476 | } | ||
| 477 | |||
| 478 | /*! | ||
| 479 | * @brief Get the chunk size for an open file. | ||
| 480 | * @param file the file handle to get the size for. | ||
| 481 | * @return The requested size. | ||
| 482 | */ | ||
| 483 | int GetFileChunkSize(void* file) | ||
| 484 | { | ||
| 485 | return XBMC_get_file_chunk_size(m_Handle, m_Callbacks, file); | ||
| 486 | } | ||
| 487 | |||
| 488 | /*! | ||
| 489 | * @brief Check if a file exists. | ||
| 490 | * @param strFileName The filename to check. | ||
| 491 | * @param bUseCache Check in file cache. | ||
| 492 | * @return true if the file exists false otherwise. | ||
| 493 | */ | ||
| 494 | bool FileExists(const char *strFileName, bool bUseCache) | ||
| 495 | { | ||
| 496 | return XBMC_file_exists(m_Handle, m_Callbacks, strFileName, bUseCache); | ||
| 497 | } | ||
| 498 | |||
| 499 | /*! | ||
| 500 | * @brief Reads file status. | ||
| 501 | * @param strFileName The filename to read the status from. | ||
| 502 | * @param buffer The file status is written into this buffer. | ||
| 503 | * @return The file status was successfully read. | ||
| 504 | */ | ||
| 505 | int StatFile(const char *strFileName, struct __stat64* buffer) | ||
| 506 | { | ||
| 507 | return XBMC_stat_file(m_Handle, m_Callbacks, strFileName, buffer); | ||
| 508 | } | ||
| 509 | |||
| 510 | /*! | ||
| 511 | * @brief Deletes a file. | ||
| 512 | * @param strFileName The filename to delete. | ||
| 513 | * @return The file was successfully deleted. | ||
| 514 | */ | ||
| 515 | bool DeleteFile(const char *strFileName) | ||
| 516 | { | ||
| 517 | return XBMC_delete_file(m_Handle, m_Callbacks, strFileName); | ||
| 518 | } | ||
| 519 | |||
| 520 | /*! | ||
| 521 | * @brief Checks whether a directory can be opened. | ||
| 522 | * @param strUrl The URL of the directory to check. | ||
| 523 | * @return True when it can be opened, false otherwise. | ||
| 524 | */ | ||
| 525 | bool CanOpenDirectory(const char* strUrl) | ||
| 526 | { | ||
| 527 | return XBMC_can_open_directory(m_Handle, m_Callbacks, strUrl); | ||
| 528 | } | ||
| 529 | |||
| 530 | /*! | ||
| 531 | * @brief Creates a directory. | ||
| 532 | * @param strPath Path to the directory. | ||
| 533 | * @return True when it was created, false otherwise. | ||
| 534 | */ | ||
| 535 | bool CreateDirectory(const char *strPath) | ||
| 536 | { | ||
| 537 | return XBMC_create_directory(m_Handle, m_Callbacks, strPath); | ||
| 538 | } | ||
| 539 | |||
| 540 | /*! | ||
| 541 | * @brief Checks if a directory exists. | ||
| 542 | * @param strPath Path to the directory. | ||
| 543 | * @return True when it exists, false otherwise. | ||
| 544 | */ | ||
| 545 | bool DirectoryExists(const char *strPath) | ||
| 546 | { | ||
| 547 | return XBMC_directory_exists(m_Handle, m_Callbacks, strPath); | ||
| 548 | } | ||
| 549 | |||
| 550 | /*! | ||
| 551 | * @brief Removes a directory. | ||
| 552 | * @param strPath Path to the directory. | ||
| 553 | * @return True when it was removed, false otherwise. | ||
| 554 | */ | ||
| 555 | bool RemoveDirectory(const char *strPath) | ||
| 556 | { | ||
| 557 | return XBMC_remove_directory(m_Handle, m_Callbacks, strPath); | ||
| 558 | } | ||
| 559 | |||
| 560 | protected: | ||
| 561 | void* (*XBMC_register_me)(void *HANDLE); | ||
| 562 | void (*XBMC_unregister_me)(void *HANDLE, void* CB); | ||
| 563 | void (*XBMC_log)(void *HANDLE, void* CB, const addon_log_t loglevel, const char *msg); | ||
| 564 | bool (*XBMC_get_setting)(void *HANDLE, void* CB, const char* settingName, void *settingValue); | ||
| 565 | void (*XBMC_queue_notification)(void *HANDLE, void* CB, const queue_msg_t type, const char *msg); | ||
| 566 | bool (*XBMC_wake_on_lan)(void *HANDLE, void* CB, const char* mac); | ||
| 567 | char* (*XBMC_unknown_to_utf8)(void *HANDLE, void* CB, const char* str); | ||
| 568 | char* (*XBMC_get_localized_string)(void *HANDLE, void* CB, int dwCode); | ||
| 569 | char* (*XBMC_get_dvd_menu_language)(void *HANDLE, void* CB); | ||
| 570 | void (*XBMC_free_string)(void *HANDLE, void* CB, char* str); | ||
| 571 | void* (*XBMC_open_file)(void *HANDLE, void* CB, const char* strFileName, unsigned int flags); | ||
| 572 | void* (*XBMC_open_file_for_write)(void *HANDLE, void* CB, const char* strFileName, bool bOverWrite); | ||
| 573 | ssize_t (*XBMC_read_file)(void *HANDLE, void* CB, void* file, void* lpBuf, size_t uiBufSize); | ||
| 574 | bool (*XBMC_read_file_string)(void *HANDLE, void* CB, void* file, char *szLine, int iLineLength); | ||
| 575 | ssize_t(*XBMC_write_file)(void *HANDLE, void* CB, void* file, const void* lpBuf, size_t uiBufSize); | ||
| 576 | void (*XBMC_flush_file)(void *HANDLE, void* CB, void* file); | ||
| 577 | int64_t (*XBMC_seek_file)(void *HANDLE, void* CB, void* file, int64_t iFilePosition, int iWhence); | ||
| 578 | int (*XBMC_truncate_file)(void *HANDLE, void* CB, void* file, int64_t iSize); | ||
| 579 | int64_t (*XBMC_get_file_position)(void *HANDLE, void* CB, void* file); | ||
| 580 | int64_t (*XBMC_get_file_length)(void *HANDLE, void* CB, void* file); | ||
| 581 | void (*XBMC_close_file)(void *HANDLE, void* CB, void* file); | ||
| 582 | int (*XBMC_get_file_chunk_size)(void *HANDLE, void* CB, void* file); | ||
| 583 | bool (*XBMC_file_exists)(void *HANDLE, void* CB, const char *strFileName, bool bUseCache); | ||
| 584 | int (*XBMC_stat_file)(void *HANDLE, void* CB, const char *strFileName, struct __stat64* buffer); | ||
| 585 | bool (*XBMC_delete_file)(void *HANDLE, void* CB, const char *strFileName); | ||
| 586 | bool (*XBMC_can_open_directory)(void *HANDLE, void* CB, const char* strURL); | ||
| 587 | bool (*XBMC_create_directory)(void *HANDLE, void* CB, const char* strPath); | ||
| 588 | bool (*XBMC_directory_exists)(void *HANDLE, void* CB, const char* strPath); | ||
| 589 | bool (*XBMC_remove_directory)(void *HANDLE, void* CB, const char* strPath); | ||
| 590 | |||
| 591 | private: | ||
| 592 | void *m_libXBMC_addon; | ||
| 593 | void *m_Handle; | ||
| 594 | void *m_Callbacks; | ||
| 595 | struct cb_array | ||
| 596 | { | ||
| 597 | const char* libPath; | ||
| 598 | }; | ||
| 599 | }; | ||
| 600 | }; | ||
