ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-Inotify2/Inotify2.xs
(Generate patch)

Comparing Linux-Inotify2/Inotify2.xs (file contents):
Revision 1.2 by root, Tue Aug 23 02:45:23 2005 UTC vs.
Revision 1.3 by root, Mon Dec 19 16:50:27 2005 UTC

3#include "EXTERN.h" 3#include "EXTERN.h"
4#include "perl.h" 4#include "perl.h"
5#include "XSUB.h" 5#include "XSUB.h"
6 6
7#include <unistd.h> 7#include <unistd.h>
8#include <fcntl.h>
8 9
9#include "inotify.h" 10#include "inotify.h"
10#include "inotify-syscalls.h" 11#include "inotify-syscalls.h"
11 12
12MODULE = Linux::Inotify2 PACKAGE = Linux::Inotify2 13MODULE = Linux::Inotify2 PACKAGE = Linux::Inotify2
51inotify_add_watch (int fd, char *name, U32 mask) 52inotify_add_watch (int fd, char *name, U32 mask)
52 53
53int 54int
54inotify_rm_watch (int fd, U32 wd) 55inotify_rm_watch (int fd, U32 wd)
55 56
57int
58inotify_blocking (int fd, I32 blocking)
59 CODE:
60 fcntl (fd, F_SETFL, blocking ? 0 : O_NONBLOCK);
61
56void 62void
57inotify_read (int fd, int size = 8192) 63inotify_read (int fd, int size = 8192)
58 PPCODE: 64 PPCODE:
59{ 65{
60 char buf [size], *cur, *end; 66 char buf [size], *cur, *end;
61 int got = read (fd, buf, size); 67 int got = read (fd, buf, size);
62 68
63 if (got < 0) 69 if (got < 0)
70 if (errno != EAGAIN && errno != EINTR)
64 croak ("Linux::Inotify2: read error while reading events"); 71 croak ("Linux::Inotify2: read error while reading events");
72 else
73 XSRETURN_EMPTY;
65 74
66 cur = buf; 75 cur = buf;
67 end = buf + got; 76 end = buf + got;
68 77
69 while (cur < end) 78 while (cur < end)
78 hv_store (hv, "wd", sizeof ("wd") - 1, newSViv (ev->wd), 0); 87 hv_store (hv, "wd", sizeof ("wd") - 1, newSViv (ev->wd), 0);
79 hv_store (hv, "mask", sizeof ("mask") - 1, newSViv (ev->mask), 0); 88 hv_store (hv, "mask", sizeof ("mask") - 1, newSViv (ev->mask), 0);
80 hv_store (hv, "cookie", sizeof ("cookie") - 1, newSViv (ev->cookie), 0); 89 hv_store (hv, "cookie", sizeof ("cookie") - 1, newSViv (ev->cookie), 0);
81 hv_store (hv, "name", sizeof ("name") - 1, newSVpvn (ev->name, ev->len), 0); 90 hv_store (hv, "name", sizeof ("name") - 1, newSVpvn (ev->name, ev->len), 0);
82 91
83 XPUSHs (newRV_noinc ((SV *)hv)); 92 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv)));
84 } 93 }
85} 94}
86 95
87 96

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines