Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: utils/archive/dart_archive.c

Issue 10832116: Attach the native entry struct to the ArchiveEntry object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix the ISO9660 constant Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/archive/archive.dart ('k') | utils/archive/entry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <assert.h> 5 #include <assert.h>
6 #include <errno.h> 6 #include <errno.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "dart_archive.h" 9 #include "dart_archive.h"
10 #include "entry.h"
10 #include "messaging.h" 11 #include "messaging.h"
12 #include "reader.h"
11 13
12 /** The enumeration of request types for communicating with Dart. */ 14 /** The enumeration of request types for communicating with Dart. */
13 enum RequestType { 15 enum RequestType {
14 kArchiveReadNew = 0, 16 kArchiveReadNew = 0,
15 kArchiveReadSupportFilterAll, 17 kArchiveReadSupportFilterAll,
16 kArchiveReadSupportFilterBzip2, 18 kArchiveReadSupportFilterBzip2,
17 kArchiveReadSupportFilterCompress, 19 kArchiveReadSupportFilterCompress,
18 kArchiveReadSupportFilterGzip, 20 kArchiveReadSupportFilterGzip,
19 kArchiveReadSupportFilterLzma, 21 kArchiveReadSupportFilterLzma,
20 kArchiveReadSupportFilterXz, 22 kArchiveReadSupportFilterXz,
(...skipping 11 matching lines...) Expand all
32 kArchiveReadSetFilterOptions, 34 kArchiveReadSetFilterOptions,
33 kArchiveReadSetFormatOptions, 35 kArchiveReadSetFormatOptions,
34 kArchiveReadSetOptions, 36 kArchiveReadSetOptions,
35 kArchiveReadOpenFilename, 37 kArchiveReadOpenFilename,
36 kArchiveReadOpenMemory, 38 kArchiveReadOpenMemory,
37 kArchiveReadNextHeader, 39 kArchiveReadNextHeader,
38 kArchiveReadDataBlock, 40 kArchiveReadDataBlock,
39 kArchiveReadDataSkip, 41 kArchiveReadDataSkip,
40 kArchiveReadClose, 42 kArchiveReadClose,
41 kArchiveReadFree, 43 kArchiveReadFree,
44 kArchiveEntryClone,
45 kArchiveEntryFree,
46 kArchiveEntryNew,
47 kArchiveEntrySetHardlink,
48 kArchiveEntrySetPathname,
49 kArchiveEntrySetSourcepath,
50 kArchiveEntrySetSymlink,
51 kArchiveEntrySetGid,
52 kArchiveEntrySetUid,
53 kArchiveEntrySetPerm,
54 kArchiveEntrySetGname,
55 kArchiveEntrySetUname,
56 kArchiveEntrySetFflagsSet,
57 kArchiveEntrySetFflagsClear,
58 kArchiveEntrySetFflagsText,
59 kArchiveEntrySetFiletype,
60 kArchiveEntrySetMode,
61 kArchiveEntrySetSize,
62 kArchiveEntrySetDev,
63 kArchiveEntrySetDevmajor,
64 kArchiveEntrySetDevminor,
65 kArchiveEntrySetIno,
66 kArchiveEntrySetNlink,
67 kArchiveEntrySetRdev,
68 kArchiveEntrySetRdevmajor,
69 kArchiveEntrySetRdevminor,
70 kArchiveEntrySetAtime,
71 kArchiveEntrySetBirthtime,
72 kArchiveEntrySetCtime,
73 kArchiveEntrySetMtime,
42 kNumberOfRequestTypes 74 kNumberOfRequestTypes
43 }; 75 };
44 76
45 /** 77 /**
46 * Dispatches a message from Dart to its native function equivalent. 78 * Dispatches a message from Dart to its native function equivalent.
47 * 79 *
48 * In addition to matching up a message with its respective function, this 80 * In addition to matching up a message with its respective function, this
49 * parses out the standard archive struct argument from the message and resolves 81 * parses out the standard archive struct argument from the message and resolves
50 * it to an actual pointer to an archive struct. 82 * it to an actual pointer to an archive struct.
51 */ 83 */
(...skipping 10 matching lines...) Expand all
62 } 94 }
63 95
64 Dart_CObject* wrapped_request_type = message->value.as_array.values[0]; 96 Dart_CObject* wrapped_request_type = message->value.as_array.values[0];
65 if (wrapped_request_type->type != kInt32) { 97 if (wrapped_request_type->type != kInt32) {
66 postInvalidArgument(reply_port_id, "Invalid request type %d.", 98 postInvalidArgument(reply_port_id, "Invalid request type %d.",
67 wrapped_request_type->type); 99 wrapped_request_type->type);
68 return; 100 return;
69 } 101 }
70 enum RequestType request_type = wrapped_request_type->value.as_int32; 102 enum RequestType request_type = wrapped_request_type->value.as_int32;
71 103
72 Dart_CObject* archive_id = message->value.as_array.values[1]; 104 Dart_CObject* id = message->value.as_array.values[1];
73 struct archive* archive; 105 void* ptr;
74 if (archive_id->type == kNull) { 106 if (id->type == kNull) {
75 archive = NULL; 107 ptr = NULL;
76 } else if (archive_id->type == kInt64 || archive_id->type == kInt32) { 108 } else if (id->type == kInt64 || id->type == kInt32) {
77 archive = (struct archive*) (intptr_t) getInteger(archive_id); 109 ptr = (void*) (intptr_t) getInteger(id);
78 } else { 110 } else {
79 postInvalidArgument(reply_port_id, "Invalid archive id type %d.", 111 postInvalidArgument(reply_port_id, "Invalid id type %d.", id->type);
80 archive_id->type);
81 return; 112 return;
82 } 113 }
83 114
84 switch (request_type) { 115 switch (request_type) {
85 case kArchiveReadNew: 116 case kArchiveReadNew:
86 archiveReadNew(reply_port_id); 117 archiveReadNew(reply_port_id);
87 break; 118 break;
88 case kArchiveReadSupportFilterAll: 119 case kArchiveReadSupportFilterAll:
89 archiveReadSupportFilterAll(reply_port_id, archive); 120 archiveReadSupportFilterAll(reply_port_id, (struct archive*) ptr);
90 break; 121 break;
91 case kArchiveReadSupportFilterBzip2: 122 case kArchiveReadSupportFilterBzip2:
92 archiveReadSupportFilterBzip2(reply_port_id, archive); 123 archiveReadSupportFilterBzip2(reply_port_id, (struct archive*) ptr);
93 break; 124 break;
94 case kArchiveReadSupportFilterCompress: 125 case kArchiveReadSupportFilterCompress:
95 archiveReadSupportFilterCompress(reply_port_id, archive); 126 archiveReadSupportFilterCompress(reply_port_id, (struct archive*) ptr);
96 break; 127 break;
97 case kArchiveReadSupportFilterGzip: 128 case kArchiveReadSupportFilterGzip:
98 archiveReadSupportFilterGzip(reply_port_id, archive); 129 archiveReadSupportFilterGzip(reply_port_id, (struct archive*) ptr);
99 break; 130 break;
100 case kArchiveReadSupportFilterLzma: 131 case kArchiveReadSupportFilterLzma:
101 archiveReadSupportFilterLzma(reply_port_id, archive); 132 archiveReadSupportFilterLzma(reply_port_id, (struct archive*) ptr);
102 break; 133 break;
103 case kArchiveReadSupportFilterXz: 134 case kArchiveReadSupportFilterXz:
104 archiveReadSupportFilterXz(reply_port_id, archive); 135 archiveReadSupportFilterXz(reply_port_id, (struct archive*) ptr);
105 break; 136 break;
106 case kArchiveReadSupportFilterProgram: 137 case kArchiveReadSupportFilterProgram:
107 archiveReadSupportFilterProgram(reply_port_id, archive, message); 138 archiveReadSupportFilterProgram(
139 reply_port_id, (struct archive*) ptr, message);
108 break; 140 break;
109 case kArchiveReadSupportFilterProgramSignature: 141 case kArchiveReadSupportFilterProgramSignature:
110 archiveReadSupportFilterProgramSignature( 142 archiveReadSupportFilterProgramSignature(
111 reply_port_id, archive, message); 143 reply_port_id, (struct archive*) ptr, message);
112 break; 144 break;
113 case kArchiveReadSupportFormatAll: 145 case kArchiveReadSupportFormatAll:
114 archiveReadSupportFormatAll(reply_port_id, archive); 146 archiveReadSupportFormatAll(reply_port_id, (struct archive*) ptr);
115 break; 147 break;
116 case kArchiveReadSupportFormatAr: 148 case kArchiveReadSupportFormatAr:
117 archiveReadSupportFormatAr(reply_port_id, archive); 149 archiveReadSupportFormatAr(reply_port_id, (struct archive*) ptr);
118 break; 150 break;
119 case kArchiveReadSupportFormatCpio: 151 case kArchiveReadSupportFormatCpio:
120 archiveReadSupportFormatCpio(reply_port_id, archive); 152 archiveReadSupportFormatCpio(reply_port_id, (struct archive*) ptr);
121 break; 153 break;
122 case kArchiveReadSupportFormatEmpty: 154 case kArchiveReadSupportFormatEmpty:
123 archiveReadSupportFormatEmpty(reply_port_id, archive); 155 archiveReadSupportFormatEmpty(reply_port_id, (struct archive*) ptr);
124 break; 156 break;
125 case kArchiveReadSupportFormatIso9660: 157 case kArchiveReadSupportFormatIso9660:
126 archiveReadSupportFormatIso9660(reply_port_id, archive); 158 archiveReadSupportFormatIso9660(reply_port_id, (struct archive*) ptr);
127 break; 159 break;
128 case kArchiveReadSupportFormatMtree: 160 case kArchiveReadSupportFormatMtree:
129 archiveReadSupportFormatMtree(reply_port_id, archive); 161 archiveReadSupportFormatMtree(reply_port_id, (struct archive*) ptr);
130 break; 162 break;
131 case kArchiveReadSupportFormatRaw: 163 case kArchiveReadSupportFormatRaw:
132 archiveReadSupportFormatRaw(reply_port_id, archive); 164 archiveReadSupportFormatRaw(reply_port_id, (struct archive*) ptr);
133 break; 165 break;
134 case kArchiveReadSupportFormatTar: 166 case kArchiveReadSupportFormatTar:
135 archiveReadSupportFormatTar(reply_port_id, archive); 167 archiveReadSupportFormatTar(reply_port_id, (struct archive*) ptr);
136 break; 168 break;
137 case kArchiveReadSupportFormatZip: 169 case kArchiveReadSupportFormatZip:
138 archiveReadSupportFormatZip(reply_port_id, archive); 170 archiveReadSupportFormatZip(reply_port_id, (struct archive*) ptr);
139 break; 171 break;
140 case kArchiveReadSetFilterOptions: 172 case kArchiveReadSetFilterOptions:
141 archiveReadSetFilterOptions(reply_port_id, archive, message); 173 archiveReadSetFilterOptions(reply_port_id, (struct archive*) ptr, message);
142 break; 174 break;
143 case kArchiveReadSetFormatOptions: 175 case kArchiveReadSetFormatOptions:
144 archiveReadSetFormatOptions(reply_port_id, archive, message); 176 archiveReadSetFormatOptions(reply_port_id, (struct archive*) ptr, message);
145 break; 177 break;
146 case kArchiveReadSetOptions: 178 case kArchiveReadSetOptions:
147 archiveReadSetOptions(reply_port_id, archive, message); 179 archiveReadSetOptions(reply_port_id, (struct archive*) ptr, message);
148 break; 180 break;
149 case kArchiveReadOpenFilename: 181 case kArchiveReadOpenFilename:
150 archiveReadOpenFilename(reply_port_id, archive, message); 182 archiveReadOpenFilename(reply_port_id, (struct archive*) ptr, message);
151 break; 183 break;
152 case kArchiveReadOpenMemory: 184 case kArchiveReadOpenMemory:
153 archiveReadOpenMemory(reply_port_id, archive, message); 185 archiveReadOpenMemory(reply_port_id, (struct archive*) ptr, message);
154 break; 186 break;
155 case kArchiveReadNextHeader: 187 case kArchiveReadNextHeader:
156 archiveReadNextHeader(reply_port_id, archive); 188 archiveReadNextHeader(reply_port_id, (struct archive*) ptr);
157 break; 189 break;
158 case kArchiveReadDataBlock: 190 case kArchiveReadDataBlock:
159 archiveReadDataBlock(reply_port_id, archive); 191 archiveReadDataBlock(reply_port_id, (struct archive*) ptr);
160 break; 192 break;
161 case kArchiveReadDataSkip: 193 case kArchiveReadDataSkip:
162 archiveReadDataSkip(reply_port_id, archive); 194 archiveReadDataSkip(reply_port_id, (struct archive*) ptr);
163 break; 195 break;
164 case kArchiveReadClose: 196 case kArchiveReadClose:
165 archiveReadClose(reply_port_id, archive); 197 archiveReadClose(reply_port_id, (struct archive*) ptr);
166 break; 198 break;
167 case kArchiveReadFree: 199 case kArchiveReadFree:
168 archiveReadFree(reply_port_id, archive); 200 archiveReadFree(reply_port_id, (struct archive*) ptr);
201 break;
202 case kArchiveEntryClone:
203 archiveEntryClone(reply_port_id, (struct archive_entry*) ptr);
204 break;
205 case kArchiveEntryFree:
206 archiveEntryFree(reply_port_id, (struct archive_entry*) ptr);
207 break;
208 case kArchiveEntryNew:
209 archiveEntryNew(reply_port_id);
210 break;
211 case kArchiveEntrySetHardlink:
212 archiveEntrySetHardlink(
213 reply_port_id, (struct archive_entry*) ptr, message);
214 break;
215 case kArchiveEntrySetPathname:
216 archiveEntrySetPathname(
217 reply_port_id, (struct archive_entry*) ptr, message);
218 break;
219 case kArchiveEntrySetSourcepath:
220 archiveEntrySetSourcepath(
221 reply_port_id, (struct archive_entry*) ptr, message);
222 break;
223 case kArchiveEntrySetSymlink:
224 archiveEntrySetSymlink(reply_port_id, (struct archive_entry*) ptr, message);
225 break;
226 case kArchiveEntrySetGid:
227 archiveEntrySetGid(reply_port_id, (struct archive_entry*) ptr, message);
228 break;
229 case kArchiveEntrySetUid:
230 archiveEntrySetUid(reply_port_id, (struct archive_entry*) ptr, message);
231 break;
232 case kArchiveEntrySetPerm:
233 archiveEntrySetPerm(reply_port_id, (struct archive_entry*) ptr, message);
234 break;
235 case kArchiveEntrySetGname:
236 archiveEntrySetGname(reply_port_id, (struct archive_entry*) ptr, message);
237 break;
238 case kArchiveEntrySetUname:
239 archiveEntrySetUname(reply_port_id, (struct archive_entry*) ptr, message);
240 break;
241 case kArchiveEntrySetFflagsSet:
242 archiveEntrySetFflagsSet(
243 reply_port_id, (struct archive_entry*) ptr, message);
244 break;
245 case kArchiveEntrySetFflagsClear:
246 archiveEntrySetFflagsClear(
247 reply_port_id, (struct archive_entry*) ptr, message);
248 break;
249 case kArchiveEntrySetFflagsText:
250 archiveEntrySetFflagsText(
251 reply_port_id, (struct archive_entry*) ptr, message);
252 break;
253 case kArchiveEntrySetFiletype:
254 archiveEntrySetFiletype(
255 reply_port_id, (struct archive_entry*) ptr, message);
256 break;
257 case kArchiveEntrySetMode:
258 archiveEntrySetMode(reply_port_id, (struct archive_entry*) ptr, message);
259 break;
260 case kArchiveEntrySetSize:
261 archiveEntrySetSize(reply_port_id, (struct archive_entry*) ptr, message);
262 break;
263 case kArchiveEntrySetDev:
264 archiveEntrySetDev(reply_port_id, (struct archive_entry*) ptr, message);
265 break;
266 case kArchiveEntrySetDevmajor:
267 archiveEntrySetDevmajor(
268 reply_port_id, (struct archive_entry*) ptr, message);
269 break;
270 case kArchiveEntrySetDevminor:
271 archiveEntrySetDevminor(
272 reply_port_id, (struct archive_entry*) ptr, message);
273 break;
274 case kArchiveEntrySetIno:
275 archiveEntrySetIno(reply_port_id, (struct archive_entry*) ptr, message);
276 break;
277 case kArchiveEntrySetNlink:
278 archiveEntrySetNlink(reply_port_id, (struct archive_entry*) ptr, message);
279 break;
280 case kArchiveEntrySetRdev:
281 archiveEntrySetRdev(reply_port_id, (struct archive_entry*) ptr, message);
282 break;
283 case kArchiveEntrySetRdevmajor:
284 archiveEntrySetRdevmajor(
285 reply_port_id, (struct archive_entry*) ptr, message);
286 break;
287 case kArchiveEntrySetRdevminor:
288 archiveEntrySetRdevminor(
289 reply_port_id, (struct archive_entry*) ptr, message);
290 break;
291 case kArchiveEntrySetAtime:
292 archiveEntrySetAtime(reply_port_id, (struct archive_entry*) ptr, message);
293 break;
294 case kArchiveEntrySetBirthtime:
295 archiveEntrySetBirthtime(
296 reply_port_id, (struct archive_entry*) ptr, message);
297 break;
298 case kArchiveEntrySetCtime:
299 archiveEntrySetCtime(reply_port_id, (struct archive_entry*) ptr, message);
300 break;
301 case kArchiveEntrySetMtime:
302 archiveEntrySetMtime(reply_port_id, (struct archive_entry*) ptr, message);
169 break; 303 break;
170 default: 304 default:
171 postInvalidArgument(reply_port_id, "Invalid request id %d.", request_type); 305 postInvalidArgument(reply_port_id, "Invalid request id %d.", request_type);
172 break; 306 break;
173 } 307 }
174 } 308 }
175 309
176 /** 310 /**
177 * Checks if [handle] represents an error and, if so, propagates it to Dart. 311 * Checks if [handle] represents an error and, if so, propagates it to Dart.
178 * Otherwise, returns [handle]. 312 * Otherwise, returns [handle].
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 414
281 /** Initializes the C extension. */ 415 /** Initializes the C extension. */
282 DART_EXPORT Dart_Handle dart_archive_Init(Dart_Handle parent_library) { 416 DART_EXPORT Dart_Handle dart_archive_Init(Dart_Handle parent_library) {
283 if (Dart_IsError(parent_library)) return parent_library; 417 if (Dart_IsError(parent_library)) return parent_library;
284 418
285 Dart_Handle result_code = Dart_SetNativeResolver(parent_library, resolveName); 419 Dart_Handle result_code = Dart_SetNativeResolver(parent_library, resolveName);
286 if (Dart_IsError(result_code)) return result_code; 420 if (Dart_IsError(result_code)) return result_code;
287 421
288 return Dart_Null(); 422 return Dart_Null();
289 } 423 }
OLDNEW
« no previous file with comments | « utils/archive/archive.dart ('k') | utils/archive/entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698