ext/fcntl/fcntl.c


DEFINITIONS

This source file includes following functions.
  1. Init_fcntl


   1  /************************************************
   2  
   3    fcntl.c -
   4  
   5    $Author: matz $
   6    created at: Mon Apr  7 18:53:05 JST 1997
   7  
   8    Copyright (C) 1997-2001 Yukihiro Matsumoto
   9  
  10  ************************************************/
  11  
  12  /************************************************
  13  = NAME
  14  
  15  fcntl - load the C fcntl.h defines
  16  
  17  = SYNOPSIS
  18  
  19      require "fcntl"
  20      m = s.fcntl(Fcntl::F_GETFL, 0)
  21      f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK|m)
  22  
  23  = DESCRIPTION
  24  
  25  This module is just a translation of the C <fnctl.h> file.
  26  
  27  = NOTE
  28  
  29  Only #define symbols get translated; you must still correctly
  30  pack up your own arguments to pass as args for locking functions, etc.
  31  
  32  ************************************************/
  33  
  34  #include "ruby.h"
  35  #include <fcntl.h>
  36  
  37  void
  38  Init_fcntl()
  39  {
  40      VALUE mFcntl = rb_define_module("Fcntl");
  41  #ifdef F_DUPFD
  42      rb_define_const(mFcntl, "F_DUPFD", INT2NUM(F_DUPFD));
  43  #endif
  44  #ifdef F_GETFD
  45      rb_define_const(mFcntl, "F_GETFD", INT2NUM(F_GETFD));
  46  #endif
  47  #ifdef F_GETLK
  48      rb_define_const(mFcntl, "F_GETLK", INT2NUM(F_GETLK));
  49  #endif
  50  #ifdef F_SETFD
  51      rb_define_const(mFcntl, "F_SETFD", INT2NUM(F_SETFD));
  52  #endif
  53  #ifdef F_GETFL
  54      rb_define_const(mFcntl, "F_GETFL", INT2NUM(F_GETFL));
  55  #endif
  56  #ifdef F_SETFL
  57      rb_define_const(mFcntl, "F_SETFL", INT2NUM(F_SETFL));
  58  #endif
  59  #ifdef F_SETLK
  60      rb_define_const(mFcntl, "F_SETLK", INT2NUM(F_SETLK));
  61  #endif
  62  #ifdef F_SETLKW
  63      rb_define_const(mFcntl, "F_SETLKW", INT2NUM(F_SETLKW));
  64  #endif
  65  #ifdef FD_CLOEXEC
  66      rb_define_const(mFcntl, "FD_CLOEXEC", INT2NUM(FD_CLOEXEC));
  67  #endif
  68  #ifdef F_RDLCK
  69      rb_define_const(mFcntl, "F_RDLCK", INT2NUM(F_RDLCK));
  70  #endif
  71  #ifdef F_UNLCK
  72      rb_define_const(mFcntl, "F_UNLCK", INT2NUM(F_UNLCK));
  73  #endif
  74  #ifdef F_WRLCK
  75      rb_define_const(mFcntl, "F_WRLCK", INT2NUM(F_WRLCK));
  76  #endif
  77  #ifdef O_CREAT
  78      rb_define_const(mFcntl, "O_CREAT", INT2NUM(O_CREAT));
  79  #endif
  80  #ifdef O_EXCL
  81      rb_define_const(mFcntl, "O_EXCL", INT2NUM(O_EXCL));
  82  #endif
  83  #ifdef O_NOCTTY
  84      rb_define_const(mFcntl, "O_NOCTTY", INT2NUM(O_NOCTTY));
  85  #endif
  86  #ifdef O_TRUNC
  87      rb_define_const(mFcntl, "O_TRUNC", INT2NUM(O_TRUNC));
  88  #endif
  89  #ifdef O_APPEND
  90      rb_define_const(mFcntl, "O_APPEND", INT2NUM(O_APPEND));
  91  #endif
  92  #ifdef O_NONBLOCK
  93      rb_define_const(mFcntl, "O_NONBLOCK", INT2NUM(O_NONBLOCK));
  94  #endif
  95  #ifdef O_NDELAY
  96      rb_define_const(mFcntl, "O_NDELAY", INT2NUM(O_NDELAY));
  97  #endif
  98  #ifdef O_RDONLY
  99      rb_define_const(mFcntl, "O_RDONLY", INT2NUM(O_RDONLY));
 100  #endif
 101  #ifdef O_RDWR
 102      rb_define_const(mFcntl, "O_RDWR", INT2NUM(O_RDWR));
 103  #endif
 104  #ifdef O_WRONLY
 105      rb_define_const(mFcntl, "O_WRONLY", INT2NUM(O_WRONLY));
 106  #endif
 107  }