00001 /*--------------------------------------------------------------------------------- 00002 00003 access object in a GBFS file 00004 00005 Copyright 2002-2004 Damian Yerrick 00006 00007 Additional code Dave Murphy 00008 00009 Permission is hereby granted, free of charge, to any person obtaining 00010 a copy of this software and associated documentation files (the 00011 "Software"), to deal in the Software without restriction, including 00012 without limitation the rights to use, copy, modify, merge, publish, 00013 distribute, sublicense, and/or sell copies of the Software, and to 00014 permit persons to whom the Software is furnished to do so, subject to 00015 the following conditions: 00016 00017 The above copyright notice and this permission notice shall be 00018 included in all copies or substantial portions of the Software. 00019 00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00021 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 00022 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00023 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00024 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00025 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 00026 OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 00027 IN THE SOFTWARE. 00028 00029 ---------------------------------------------------------------------------------*/ 00030 00031 00032 /* Dependency on prior include files 00033 00034 Before you #include "gbfs.h", you should define the following types: 00035 typedef (unsigned 16-bit integer) u16; 00036 typedef (unsigned 32-bit integer) u32; 00037 Your system header should do this for you. 00038 */ 00039 #warning gbfs is deprecated for nds 00040 #ifndef _INCLUDE_GBFS_H_ 00041 #define _INCLUDE_GBFS_H_ 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 /* to make a 300 KB space called samples do GBFS_SPACE(samples, 300) */ 00048 00049 #define GBFS_SPACE(filename, kbytes) \ 00050 const char filename[(kbytes)*1024] __attribute__ ((aligned (16))) = \ 00051 "PinEightGBFSSpace-" #filename "-" #kbytes ; 00052 00053 typedef struct GBFS_FILE { 00054 char magic[16]; /* "PinEightGBFS\r\n\032\n" */ 00055 u32 total_len; /* total length of archive */ 00056 u16 dir_off; /* offset in bytes to directory */ 00057 u16 dir_nmemb; /* number of files */ 00058 char reserved[8]; /* for future use */ 00059 } GBFS_FILE; 00060 00061 typedef struct GBFS_ENTRY { 00062 char name[24]; /* filename, nul-padded */ 00063 u32 len; /* length of object in bytes */ 00064 u32 data_offset; /* in bytes from beginning of file */ 00065 } GBFS_ENTRY; 00066 00067 00068 /*--------------------------------------------------------------------------------- 00069 Set the search limits and stride for searching 00070 ---------------------------------------------------------------------------------*/ 00071 void gbfs_search_range( u32 gbfs_1st_limit, 00072 u32 gbfs_2nd_start, u32 gbfs_2nd_limit, 00073 u32 gbfs_stride ); 00074 00075 const GBFS_FILE * find_first_gbfs_file(const void *start); 00076 00077 const void *skip_gbfs_file(const GBFS_FILE * file); 00078 00079 const void *gbfs_get_obj(const GBFS_FILE *file, 00080 const char *name, 00081 u32 *len); 00082 00083 const void *gbfs_get_nth_obj(GBFS_FILE const * file, 00084 size_t n, 00085 char *name, 00086 u32 *len); 00087 00088 void *gbfs_copy_obj(void *dst, 00089 const GBFS_FILE *file, 00090 const char *name); 00091 00092 size_t gbfs_count_objs(const GBFS_FILE *file); 00093 00094 00095 #ifdef __cplusplus 00096 } 00097 #endif 00098 00099 #endif // _INCLUDE_GBFS_H_