menu: added new Keywords tag to .desktop files
[barry.git] / src / cod-internal.h
blob8d3718860c982ba737b172198574c83441ffbed9
1 ///
2 /// \file cod-internal.h
3 /// COD structure
4 ///
6 /*
7 Copyright (C) 2008-2009, Nicolas VIVIEN
8 Copyright (C) 2009, Josh Kropf
9 See also:
10 http://drbolsen.wordpress.com/2006/07/26/blackberry-cod-file-format/
11 http://drbolsen.wordpress.com/2006/08/11/10/
12 http://www.pkware.com/documents/casestudies/APPNOTE.TXT
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 See the GNU General Public License in the COPYING file at the
24 root directory of this project for more details.
28 #ifndef __BARRY_COD_INTERNAL_H__
29 #define __BARRY_COD_INTERNAL_H__
31 #include "dll.h"
32 #include <stdint.h>
33 #include <sys/types.h>
34 #include "platform.h" // safe to include platform.h here, since
35 // cod-internal.h is not installed either
37 #if USE_PACK_PRAGMA
38 #pragma pack(push, 1)
39 #endif
41 #define CODFILE_TYPE_SIMPLE {0xDE, 0xC0}
42 #define CODFILE_TYPE_PKZIP {0x50, 0x4B}
43 #define PKZIP_LOCAL_FILE_SIG {0x50, 0x4B, 0x03, 0x04}
44 #define PKZIP_DIRECTORY_SIG {0x50, 0x4B, 0x01, 0x02}
45 #define PKZIP_END_DIRECTORY_SIG {0x50, 0x4B, 0x05, 0x06}
48 typedef struct BXLOCAL {
49 uint16_t hour:5;
50 uint16_t minute:6;
51 uint16_t second:5;
52 } ATTRIBUTE_PACKED msdos_time_t;
55 typedef struct BXLOCAL {
56 uint16_t year:7; // number of years since 1980
57 uint16_t month:4;
58 uint16_t day:5;
59 } ATTRIBUTE_PACKED msdos_date_t;
62 typedef struct BXLOCAL {
63 //uint8_t signature[4]; // PKZIP local file header 0x504B0304
64 uint16_t version_needed; // version needed to extract, 0x0A00
65 uint16_t general_flag; // general purpose bit flag, 0x0000
66 uint16_t compression_method; // compression method, 0x0000 = stored, no compression
67 msdos_time_t last_mod_time;
68 msdos_date_t last_mod_date;
69 uint32_t crc_32;
70 uint32_t compressed_size; // compression method is 'stored'
71 uint32_t uncompressed_size; // both sizes are equal
72 uint16_t file_name_length;
73 uint16_t extra_field_length;
74 //char file_name[variable];
75 //char extra_field[variable];
76 } ATTRIBUTE_PACKED pkzip_local_header_t;
79 typedef struct BXLOCAL {
80 //uint8_t signature[4]; // PKZIP central directory 0x504B0304
81 uint16_t version_madeby; // version used to compress, 0x0A00
82 uint16_t version_needed; // version needed to extract, 0x0A00
83 uint16_t general_flag; // general purpose bit flag, 0x0000
84 uint16_t compression_method; // compression method, 0x0000 = stored, no compression
85 msdos_time_t last_mod_time;
86 msdos_date_t last_mod_date;
87 uint32_t crc_32;
88 uint32_t compressed_size; // size of corresponding local file entry
89 uint32_t uncompressed_size; // both sizes are equal
90 uint16_t file_name_length;
91 uint16_t extra_field_length;
92 uint16_t file_comment_length;
93 uint16_t disk_number; // number of the disk on which this file begins, always zero
94 uint16_t internal_file_attr; // always zero
95 uint32_t external_file_attr; // always zero
96 uint32_t relative_offset; // offset from beginning of this disk (this zip file)
97 // to start of corresponding local file entry
98 //char file_name[variable];
99 //char extra_field[variable];
100 //char file_comment[variable];
101 } ATTRIBUTE_PACKED pkzip_directory_t;
104 typedef struct BXLOCAL {
105 //uint8_t signature[4]; // PKZIP end central directory 0x504B0506
106 uint16_t this_disk_number; // number of this disk, always zero
107 uint16_t disk_with_first; // number of the disk with the start of
108 // central directory, always zero
109 uint16_t this_disk_entry_count; // total number of entries in the central directory on this disk
110 uint16_t total_entry_count; // total number of entries in the central directory
111 // always equals this_disk_entry_count
112 uint32_t directory_length; // total size of the central directory
113 uint32_t directory_offset; // offset from beginning of this disk (this zip file)
114 // to the first central directory entry
115 uint16_t file_comment_length;
116 //char file_comment[variable];
117 } ATTRIBUTE_PACKED pkzip_end_directory_t;
120 typedef struct BXLOCAL {
121 uint16_t type; // Type // 50 4B
122 uint8_t unknown1[8]; // // 03 04 0A 00 00 00 00 00
123 uint8_t unknown2[4]; // // AB 5C 6A 39
124 uint8_t unknown3[4]; // // BE 5C 58 D1
125 uint32_t size1; // COD size 0x0DCC // CC 0D 01 00
126 uint32_t size2; // COD size 0x0DCC // CC OD 01 00
127 uint8_t strsize; // Size of string // 19
128 uint8_t reserved2; // Reserved 0x00 // 00
129 uint8_t strfree; // Empty uint8_t // 04
130 uint8_t reserved3; // Reserved 0x00 // 00
131 } ATTRIBUTE_PACKED codfile_header_t;
134 typedef struct BXLOCAL {
135 uint32_t flashid;
136 uint32_t section_number; // always 0
137 uint32_t vtable_pointer; // always 0
138 time_t timestamp;
139 uint32_t user_version;
140 uint32_t fieldref_pointer;
141 uint16_t maxtype_list_size;
142 uint16_t reserved; // always 0xFF
143 int32_t data_section; // always 0xFFFF
144 int32_t module_info; // always 0xFFFF
145 uint16_t version;
146 uint16_t code_size;
147 uint16_t data_size;
148 uint16_t flags;
149 } ATTRIBUTE_PACKED code_header_t;
152 typedef struct BXLOCAL {
153 uint8_t flags;
154 uint8_t version;
155 uint16_t num_icalls;
156 uint8_t num_modules;
157 uint8_t num_classes ;
158 uint16_t exported_string_offset;
159 uint16_t data_uint8_ts_offset;
160 uint16_t empty_field;
161 uint16_t class_definitions;
162 uint16_t array_of_unknow1_fields[14];
163 uint16_t aliases;
164 uint16_t array_of_unknow2_fields[22];
165 } ATTRIBUTE_PACKED data_header_t;
167 #if USE_PACK_PRAGMA
168 #pragma pack(pop)
169 #endif
171 #endif