Author: iratqq
Date: Mon Feb 2 02:03:40 2009
New Revision: 5793
Modified:
trunk/uim/uim-posix.c
Log:
* uim/uim-posix.c (c_file_ready):
- New function.
(uim_init_posix_subrs):
- Add file-ready?
Modified: trunk/uim/uim-posix.c
==============================================================================
--- trunk/uim/uim-posix.c (original)
+++ trunk/uim/uim-posix.c Mon Feb 2 02:03:40 2009
@@ -555,6 +555,23 @@
return uim_scm_callf("reverse", "o", ret_);
}
+static uim_lisp
+c_file_ready(uim_lisp fd_)
+{
+ struct pollfd pfd;
+ int ndfs;
+
+ pfd.fd = C_INT(fd_);
+ pfd.events = POLLIN;
+ ndfs = poll(&pfd, 1, 0);
+
+ if (ndfs < 0) {
+ return uim_scm_f();
+ } else if (ndfs == 0)
+ return uim_scm_f();
+ else
+ return uim_scm_t();
+}
void
uim_init_posix_subrs(void)
@@ -599,4 +616,6 @@
uim_scm_gc_protect(&uim_lisp_poll_flags);
uim_lisp_poll_flags = make_arg_list(poll_flags);
uim_scm_eval_c_string("(define poll-flags-alist (file-poll-flags?))");
+
+ uim_scm_init_proc1("file-ready?", c_file_ready);
}