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

Side by Side Diff: utils/archive/entry.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: 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "entry.h"
6 #include "messaging.h"
7
8 #define DART_TIMESTAMP(name) \
9 Dart_CObject name; \
10 if (archive_entry_ ## name ## _is_set(e)) { \
11 int64_t seconds = archive_entry_ ## name(e); \
12 int64_t nanoseconds = archive_entry_ ## name ## _nsec(e); \
13 name.type = kInt64; \
14 name.value.as_int64 = seconds * 1000 + nanoseconds / 1000000; \
15 } else { \
16 name.type = kNull; \
17 }
18
19 #define RAW_ARCHIVE_SIZE 29
20
21 void postArchiveEntryArray(Dart_Port p, struct archive_entry* e) {
22 if (checkPointerError(p, e, "archive entry")) return;
23
24 Dart_CObject* archive_entry_array[RAW_ARCHIVE_SIZE];
25
26 DART_INT64(id, (intptr_t) e);
27 archive_entry_array[0] = &id;
28
29 // archive_entry_paths(3)
30 DART_STRING(hardlink, (char*) archive_entry_hardlink(e))
Bob Nystrom 2012/08/02 18:18:25 Not having semicolons after these looks scary to m
nweiz 2012/08/02 21:32:27 Done.
31 archive_entry_array[1] = &hardlink;
32 DART_STRING(pathname, (char*) archive_entry_pathname(e))
33 archive_entry_array[2] = &pathname;
34 DART_STRING(sourcepath, (char*) archive_entry_sourcepath(e))
35 archive_entry_array[3] = &sourcepath;
36 DART_STRING(symlink, (char*) archive_entry_symlink(e))
37 archive_entry_array[4] = &symlink;
38
39 // archive_entry_perms(3)
40 DART_INT32(gid, archive_entry_gid(e))
41 archive_entry_array[5] = &gid;
42 DART_INT32(uid, archive_entry_uid(e))
43 archive_entry_array[6] = &uid;
44 DART_INT32(perm, archive_entry_perm(e))
45 archive_entry_array[7] = &perm;
46 DART_STRING(strmode, (char*) archive_entry_strmode(e))
47 archive_entry_array[8] = &strmode;
48 DART_STRING(gname, (char*) archive_entry_gname(e))
49 archive_entry_array[9] = &gname;
50 DART_STRING(uname, (char*) archive_entry_uname(e))
51 archive_entry_array[10] = &uname;
52
53 unsigned long fflags_set;
54 unsigned long fflags_clear;
55 archive_entry_fflags(e, &fflags_set, &fflags_clear);
56 DART_INT64(wrapped_fflags_set, fflags_set)
57 archive_entry_array[11] = &wrapped_fflags_set;
58 DART_INT64(wrapped_fflags_clear, fflags_clear)
59 archive_entry_array[12] = &wrapped_fflags_clear;
60
61 DART_STRING(fflags_text, (char*) archive_entry_fflags_text(e))
62 archive_entry_array[13] = &fflags_text;
63
64 // archive_entry_stat(3)
65 DART_INT32(filetype, archive_entry_filetype(e))
66 archive_entry_array[14] = &filetype;
67 DART_INT32(mode, archive_entry_mode(e))
68 archive_entry_array[15] = &mode;
69
70 Dart_CObject size;
71 if (archive_entry_size_is_set(e)) {
72 size.type = kInt64;
73 size.value.as_int64 = archive_entry_size(e);
74 } else {
75 size.type = kNull;
76 }
77 archive_entry_array[16] = &size;
78
79 Dart_CObject dev;
80 if (archive_entry_dev_is_set(e)) {
81 dev.type = kInt64;
82 dev.value.as_int64 = archive_entry_dev(e);
83 } else {
84 dev.type = kNull;
85 }
86 archive_entry_array[17] = &dev;
87
88 DART_INT64(devmajor, archive_entry_devmajor(e))
89 archive_entry_array[18] = &devmajor;
90 DART_INT64(devminor, archive_entry_devminor(e))
91 archive_entry_array[19] = &devminor;
92
93 Dart_CObject ino;
94 if (archive_entry_ino_is_set(e)) {
95 ino.type = kInt64;
96 ino.value.as_int64 = archive_entry_ino64(e);
97 } else {
98 ino.type = kNull;
99 }
100 archive_entry_array[20] = &ino;
101
102 DART_INT64(nlink, archive_entry_nlink(e))
103 archive_entry_array[21] = &nlink;
104 DART_INT64(rdev, archive_entry_rdev(e))
105 archive_entry_array[22] = &rdev;
106 DART_INT64(rdevmajor, archive_entry_rdevmajor(e))
107 archive_entry_array[23] = &rdevmajor;
108 DART_INT64(rdevminor, archive_entry_rdevminor(e))
109 archive_entry_array[24] = &rdevminor;
110
111 // archive_entry_time(3)
112 DART_TIMESTAMP(atime);
113 archive_entry_array[25] = &atime;
114 DART_TIMESTAMP(birthtime);
115 archive_entry_array[26] = &birthtime;
116 DART_TIMESTAMP(ctime);
117 archive_entry_array[27] = &ctime;
118 DART_TIMESTAMP(mtime);
119 archive_entry_array[28] = &mtime;
120 // If you add entries, don't forget to increase RAW_ARCHIVE_SIZE.
121
122 Dart_CObject wrapped_archive_entry;
123 wrapped_archive_entry.type = kArray;
124 wrapped_archive_entry.value.as_array.values = archive_entry_array;
125 wrapped_archive_entry.value.as_array.length = RAW_ARCHIVE_SIZE;
126
127 postSuccess(p, &wrapped_archive_entry);
128 }
129
130 void archiveEntryClone(Dart_Port p, struct archive_entry* e) {
131 postArchiveEntryArray(p, archive_entry_clone(e));
132 }
133
134 void archiveEntryFree(Dart_Port p, struct archive_entry* e) {
135 archive_entry_free(e);
136 postSuccess(p, NULL);
137 }
138
139 void archiveEntryNew(Dart_Port p) {
140 postArchiveEntryArray(p, archive_entry_new());
141 }
142
143 void archiveEntrySetHardlink(Dart_Port p, struct archive_entry* e,
144 Dart_CObject* request) {
145 Dart_CObject* value = getNullableStringArgument(p, request, 0);
146 if (value == NULL) return;
147 archive_entry_set_hardlink(e, getNullableString(value));
148 postSuccess(p, NULL);
149 }
150
151 void archiveEntrySetPathname(Dart_Port p, struct archive_entry* e,
152 Dart_CObject* request) {
153 Dart_CObject* value = getNullableStringArgument(p, request, 0);
154 if (value == NULL) return;
155 archive_entry_set_pathname(e, getNullableString(value));
156 postSuccess(p, NULL);
157 }
158
159 void archiveEntrySetSourcepath(Dart_Port p, struct archive_entry* e,
160 Dart_CObject* request) {
161 Dart_CObject* value = getNullableStringArgument(p, request, 0);
162 if (value == NULL) return;
163 archive_entry_set_sourcepath(e, getNullableString(value));
164 postSuccess(p, NULL);
165 }
166
167 void archiveEntrySetSymlink(Dart_Port p, struct archive_entry* e,
168 Dart_CObject* request) {
169 Dart_CObject* value = getNullableStringArgument(p, request, 0);
170 if (value == NULL) return;
171 archive_entry_set_symlink(e, getNullableString(value));
172 postSuccess(p, NULL);
173 }
174
175 void archiveEntrySetGid(Dart_Port p, struct archive_entry* e,
176 Dart_CObject* request) {
177 Dart_CObject* value = getIntArgument(p, request, 0);
178 if (value == NULL) return;
179 archive_entry_set_gid(e, getInteger(value));
180 postSuccess(p, NULL);
181 }
182
183 void archiveEntrySetUid(Dart_Port p, struct archive_entry* e,
184 Dart_CObject* request) {
185 Dart_CObject* value = getIntArgument(p, request, 0);
186 if (value == NULL) return;
187 archive_entry_set_uid(e, getInteger(value));
188 postSuccess(p, NULL);
189 }
190
191 void archiveEntrySetPerm(Dart_Port p, struct archive_entry* e,
192 Dart_CObject* request) {
193 Dart_CObject* value = getIntArgument(p, request, 0);
194 if (value == NULL) return;
195 archive_entry_set_perm_mask(e, getInteger(value));
196 postSuccess(p, NULL);
197 }
198
199 void archiveEntrySetGname(Dart_Port p, struct archive_entry* e,
200 Dart_CObject* request) {
201 Dart_CObject* value = getNullableStringArgument(p, request, 0);
202 if (value == NULL) return;
203 archive_entry_update_gname_utf8(e, getNullableString(value));
204 postSuccess(p, NULL);
205 }
206
207 void archiveEntrySetUname(Dart_Port p, struct archive_entry* e,
208 Dart_CObject* request) {
209 Dart_CObject* value = getNullableStringArgument(p, request, 0);
210 if (value == NULL) return;
211 archive_entry_update_uname_utf8(e, getNullableString(value));
212 postSuccess(p, NULL);
213 }
214
215 void archiveEntrySetFflagsSet(Dart_Port p, struct archive_entry* e,
216 Dart_CObject* request) {
217 Dart_CObject* value = getIntArgument(p, request, 0);
218 if (value == NULL) return;
219 archive_entry_set_fflags(e, getInteger(value), 0);
220 postSuccess(p, NULL);
221 }
222
223 void archiveEntrySetFflagsClear(Dart_Port p, struct archive_entry* e,
224 Dart_CObject* request) {
225 Dart_CObject* value = getIntArgument(p, request, 0);
226 if (value == NULL) return;
227 archive_entry_set_fflags(e, 0, getInteger(value));
228 postSuccess(p, NULL);
229 }
230
231 void archiveEntrySetFflagsText(Dart_Port p, struct archive_entry* e,
232 Dart_CObject* request) {
233 Dart_CObject* value = getNullableStringArgument(p, request, 0);
234 if (value == NULL) return;
235 archive_entry_set_fflags_text(e, getNullableString(value));
236 postSuccess(p, NULL);
237 }
238
239 void archiveEntrySetFiletype(Dart_Port p, struct archive_entry* e,
240 Dart_CObject* request) {
241 Dart_CObject* value = getIntArgument(p, request, 0);
242 if (value == NULL) return;
243 archive_entry_set_filetype(e, getInteger(value));
244 postSuccess(p, NULL);
245 }
246
247 void archiveEntrySetMode(Dart_Port p, struct archive_entry* e,
248 Dart_CObject* request) {
249 Dart_CObject* value = getIntArgument(p, request, 0);
250 if (value == NULL) return;
251 archive_entry_set_mode(e, getInteger(value));
252 postSuccess(p, NULL);
253 }
254
255 void archiveEntrySetSize(Dart_Port p, struct archive_entry* e,
256 Dart_CObject* request) {
257 if (request->type == kNull) {
258 archive_entry_unset_size(e);
259 postSuccess(p, NULL);
260 return;
261 }
262
263 Dart_CObject* value = getIntArgument(p, request, 0);
264 if (value == NULL) return;
265 archive_entry_set_size(e, getInteger(value));
266 postSuccess(p, NULL);
267 }
268
269 void archiveEntrySetDev(Dart_Port p, struct archive_entry* e,
270 Dart_CObject* request) {
271 Dart_CObject* value = getIntArgument(p, request, 0);
272 if (value == NULL) return;
273 archive_entry_set_dev(e, getInteger(value));
274 postSuccess(p, NULL);
275 }
276
277 void archiveEntrySetDevmajor(Dart_Port p, struct archive_entry* e,
278 Dart_CObject* request) {
279 Dart_CObject* value = getIntArgument(p, request, 0);
280 if (value == NULL) return;
281 archive_entry_set_devmajor(e, getInteger(value));
282 postSuccess(p, NULL);
283 }
284
285 void archiveEntrySetDevminor(Dart_Port p, struct archive_entry* e,
286 Dart_CObject* request) {
287 Dart_CObject* value = getIntArgument(p, request, 0);
288 if (value == NULL) return;
289 archive_entry_set_devminor(e, getInteger(value));
290 postSuccess(p, NULL);
291 }
292
293 void archiveEntrySetIno(Dart_Port p, struct archive_entry* e,
294 Dart_CObject* request) {
295 Dart_CObject* value = getIntArgument(p, request, 0);
296 if (value == NULL) return;
297 archive_entry_set_ino64(e, getInteger(value));
298 postSuccess(p, NULL);
299 }
300
301 void archiveEntrySetNlink(Dart_Port p, struct archive_entry* e,
302 Dart_CObject* request) {
303 Dart_CObject* value = getIntArgument(p, request, 0);
304 if (value == NULL) return;
305 archive_entry_set_nlink(e, getInteger(value));
306 postSuccess(p, NULL);
307 }
308
309 void archiveEntrySetRdev(Dart_Port p, struct archive_entry* e,
310 Dart_CObject* request) {
311 Dart_CObject* value = getIntArgument(p, request, 0);
312 if (value == NULL) return;
313 archive_entry_set_rdev(e, getInteger(value));
314 postSuccess(p, NULL);
315 }
316
317 void archiveEntrySetRdevmajor(Dart_Port p, struct archive_entry* e,
318 Dart_CObject* request) {
319 Dart_CObject* value = getIntArgument(p, request, 0);
320 if (value == NULL) return;
321 archive_entry_set_rdevmajor(e, getInteger(value));
322 postSuccess(p, NULL);
323 }
324
325 void archiveEntrySetRdevminor(Dart_Port p, struct archive_entry* e,
326 Dart_CObject* request) {
327 Dart_CObject* value = getIntArgument(p, request, 0);
328 if (value == NULL) return;
329 archive_entry_set_rdevminor(e, getInteger(value));
330 postSuccess(p, NULL);
331 }
332
333 void archiveEntrySetAtime(Dart_Port p, struct archive_entry* e,
334 Dart_CObject* request) {
335 if (request->type == kNull) {
336 archive_entry_unset_atime(e);
337 postSuccess(p, NULL);
338 return;
339 }
340
341 Dart_CObject* value = getIntArgument(p, request, 0);
342 if (value == NULL) return;
343 int64_t atime = getInteger(value);
344 archive_entry_set_atime(e, atime / 1000, (atime % 1000) * 1000000);
345 postSuccess(p, NULL);
346 }
347
348 void archiveEntrySetBirthtime(Dart_Port p, struct archive_entry* e,
349 Dart_CObject* request) {
350 if (request->type == kNull) {
351 archive_entry_unset_birthtime(e);
352 postSuccess(p, NULL);
353 return;
354 }
355
356 Dart_CObject* value = getIntArgument(p, request, 0);
357 if (value == NULL) return;
358 int64_t birthtime = getInteger(value);
359 archive_entry_set_birthtime(
360 e, birthtime / 1000, (birthtime % 1000) * 1000000);
361 postSuccess(p, NULL);
362 }
363
364 void archiveEntrySetCtime(Dart_Port p, struct archive_entry* e,
365 Dart_CObject* request) {
366 if (request->type == kNull) {
367 archive_entry_unset_ctime(e);
368 postSuccess(p, NULL);
369 return;
370 }
371
372 Dart_CObject* value = getIntArgument(p, request, 0);
373 if (value == NULL) return;
374 int64_t ctime = getInteger(value);
375 archive_entry_set_ctime(e, ctime / 1000, (ctime % 1000) * 1000000);
376 postSuccess(p, NULL);
377 }
378
379 void archiveEntrySetMtime(Dart_Port p, struct archive_entry* e,
380 Dart_CObject* request) {
381 if (request->type == kNull) {
382 archive_entry_unset_mtime(e);
383 postSuccess(p, NULL);
384 return;
385 }
386
387 Dart_CObject* value = getIntArgument(p, request, 0);
388 if (value == NULL) return;
389 int64_t mtime = getInteger(value);
390 archive_entry_set_mtime(e, mtime / 1000, (mtime % 1000) * 1000000);
391 postSuccess(p, NULL);
392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698