… | |
… | |
228 | SV *rv = &PL_sv_undef; |
228 | SV *rv = &PL_sv_undef; |
229 | |
229 | |
230 | if (req->result >= 0) |
230 | if (req->result >= 0) |
231 | { |
231 | { |
232 | int i; |
232 | int i; |
233 | char *buf = req->ptr2; |
233 | char *names = (char *)req->ptr2; |
|
|
234 | eio_dirent *ent = (eio_dirent *)req->ptr1; /* might be 0 */ |
234 | AV *av = newAV (); |
235 | AV *av = newAV (); |
235 | |
236 | |
236 | av_extend (av, req->result - 1); |
237 | av_extend (av, req->result - 1); |
237 | |
238 | |
238 | for (i = 0; i < req->result; ++i) |
239 | for (i = 0; i < req->result; ++i) |
239 | { |
240 | { |
240 | if (req->int1 & EIO_READDIR_DENTS) |
241 | if (req->int1 & EIO_READDIR_DENTS) |
241 | { |
242 | { |
242 | eio_dirent *ent = (eio_dirent *)buf; |
|
|
243 | SV *namesv = newSVpvn (ent->name, ent->namelen); |
243 | SV *namesv = newSVpvn (names + ent->nameofs, ent->namelen); |
244 | |
244 | |
245 | if (req->int1 & EIO_READDIR_CUSTOM2) |
245 | if (req->int1 & EIO_READDIR_CUSTOM2) |
246 | { |
246 | { |
247 | static SV *sv_type [EIO_DT_MAX + 1]; /* type sv cache */ |
247 | static SV *sv_type [EIO_DT_MAX + 1]; /* type sv cache */ |
248 | AV *avent = newAV (); |
248 | AV *avent = newAV (); |
… | |
… | |
262 | av_store (av, i, newRV_noinc ((SV *)avent)); |
262 | av_store (av, i, newRV_noinc ((SV *)avent)); |
263 | } |
263 | } |
264 | else |
264 | else |
265 | av_store (av, i, namesv); |
265 | av_store (av, i, namesv); |
266 | |
266 | |
267 | buf += sizeof (eio_dirent); |
267 | ++ent; |
268 | } |
268 | } |
269 | else |
269 | else |
270 | { |
270 | { |
271 | SV *name = newSVpv (buf, 0); |
271 | SV *name = newSVpv (names, 0); |
272 | av_store (av, i, name); |
272 | av_store (av, i, name); |
273 | buf += SvCUR (name) + 1; |
273 | names += SvCUR (name) + 1; |
274 | } |
274 | } |
275 | } |
275 | } |
276 | |
276 | |
277 | rv = sv_2mortal (newRV_noinc ((SV *)av)); |
277 | rv = sv_2mortal (newRV_noinc ((SV *)av)); |
278 | } |
278 | } |
… | |
… | |
294 | GV *gv = (GV *)sv_newmortal (); |
294 | GV *gv = (GV *)sv_newmortal (); |
295 | int flags = req->int1 & (O_RDONLY | O_WRONLY | O_RDWR); |
295 | int flags = req->int1 & (O_RDONLY | O_WRONLY | O_RDWR); |
296 | char sym [64]; |
296 | char sym [64]; |
297 | int symlen; |
297 | int symlen; |
298 | |
298 | |
299 | symlen = snprintf (sym, sizeof (sym), "fd#%u", (unsigned int)req->result); |
299 | symlen = snprintf (sym, sizeof (sym), "fd#%d", (int)req->result); |
300 | gv_init (gv, stash, sym, symlen, 0); |
300 | gv_init (gv, stash, sym, symlen, 0); |
301 | |
301 | |
302 | symlen = snprintf ( |
302 | symlen = snprintf ( |
303 | sym, |
303 | sym, |
304 | sizeof (sym), |
304 | sizeof (sym), |
305 | "%s&=%u", |
305 | "%s&=%d", |
306 | flags == O_RDONLY ? "<" : flags == O_WRONLY ? ">" : "+<", |
306 | flags == O_RDONLY ? "<" : flags == O_WRONLY ? ">" : "+<", |
307 | (unsigned int)req->result |
307 | (int)req->result |
308 | ); |
308 | ); |
309 | |
309 | |
310 | if (do_open (gv, sym, symlen, 0, 0, 0, 0)) |
310 | if (do_open (gv, sym, symlen, 0, 0, 0, 0)) |
311 | fh = (SV *)gv; |
311 | fh = (SV *)gv; |
312 | } |
312 | } |
… | |
… | |
555 | |
555 | |
556 | PROTOTYPES: ENABLE |
556 | PROTOTYPES: ENABLE |
557 | |
557 | |
558 | BOOT: |
558 | BOOT: |
559 | { |
559 | { |
560 | stash = gv_stashpv ("IO::AIO", 1); |
|
|
561 | |
|
|
562 | static const struct { |
560 | static const struct { |
563 | const char *name; |
561 | const char *name; |
564 | IV iv; |
562 | IV iv; |
565 | } *civ, const_iv[] = { |
563 | } *civ, const_iv[] = { |
566 | # define const_iv(name, value) { # name, (IV) value }, |
564 | # define const_iv(name, value) { # name, (IV) value }, |
… | |
… | |
592 | const_eio (DT_LNK) |
590 | const_eio (DT_LNK) |
593 | const_eio (DT_SOCK) |
591 | const_eio (DT_SOCK) |
594 | const_eio (DT_WHT) |
592 | const_eio (DT_WHT) |
595 | }; |
593 | }; |
596 | |
594 | |
|
|
595 | stash = gv_stashpv ("IO::AIO", 1); |
|
|
596 | |
597 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
597 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
598 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
598 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
599 | |
599 | |
600 | create_respipe (); |
600 | create_respipe (); |
601 | |
601 | |