file.i 642 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // FILE *
  2. %{
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /* Ruby 1.9 changed the file name of this header */
  7. #ifdef HAVE_RUBY_IO_H
  8. #include "ruby/io.h"
  9. #else
  10. #include "rubyio.h"
  11. #endif
  12. #ifdef __cplusplus
  13. }
  14. #endif
  15. %}
  16. %typemap(in) FILE *READ {
  17. OpenFile *of;
  18. GetOpenFile($input, of);
  19. rb_io_check_readable(of);
  20. $1 = GetReadFile(of);
  21. rb_read_check($1);
  22. }
  23. %typemap(in) FILE *READ_NOCHECK {
  24. OpenFile *of;
  25. GetOpenFile($input, of);
  26. rb_io_check_readable(of);
  27. $1 = GetReadFile(of);
  28. }
  29. %typemap(in) FILE *WRITE {
  30. OpenFile *of;
  31. GetOpenFile($input, of);
  32. rb_io_check_writable(of);
  33. $1 = GetWriteFile(of);
  34. }