1 /* Copyright (C) 2007-2008 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 #include "android/resource.h" 13 #include "config-host.h" 14 #include <string.h> 15 16 typedef struct { 17 const char* name; 18 const unsigned char* base; 19 size_t size; 20 } FileEntry; 21 22 const unsigned char* 23 _resource_find( const char* name, 24 const FileEntry* entries, 25 size_t *psize ) 26 { 27 const FileEntry* e = entries; 28 29 for ( ; e->name != NULL; e++ ) { 30 //dprint("SCAN %s\n", e->name); 31 if ( strcmp(e->name, name) == 0 ) { 32 *psize = e->size; 33 return e->base; 34 } 35 } 36 return NULL; 37 } 38 39 #undef _file_entries 40 #define _file_entries _skin_entries 41 const unsigned char* 42 android_resource_find( const char* name, 43 size_t *psize ) 44 { 45 # include "android/skin/default.h" 46 return _resource_find( name, _file_entries, psize ); 47 } 48 49 #undef _file_entries 50 #define _file_entries _icon_entries 51 52 const unsigned char* 53 android_icon_find( const char* name, 54 size_t *psize ) 55 { 56 #ifdef _WIN32 57 return NULL; 58 #else 59 # include "android/icons.h" 60 return _resource_find( name, _file_entries, psize ); 61 #endif 62 } 63 64 65