fcntl 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (8) hide show
  1. checksums.yaml +4 -4
  2. data/.document +3 -0
  3. data/.rdoc_options +2 -0
  4. data/BSDL +22 -0
  5. data/COPYING +56 -0
  6. data/README.md +68 -0
  7. data/ext/fcntl/fcntl.c +36 -64
  8. metadata +18 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e7c991d1b9de093aeae813fb84183cab403c9056cf9b23132d3e8aa69b5e408
4
- data.tar.gz: bc201a3be6cc6219b5a71a2572f11ba34954521cbc6255e447ad5c3412170e22
3
+ metadata.gz: 79225134a2c323e2db686035be55955b776a78388372a6473cdbc6697ebcced3
4
+ data.tar.gz: 99196c26496d96bcf3c771df166e4e8c89d9a87a969146b70966969c97765821
5
5
  SHA512:
6
- metadata.gz: 6f18cad987cebc00180caee04ec4f1b1d3d9c98f58bd095649c41c8ec55ed76cb9f55717b222fb4affe1d8093bb1374231c976dd8169d6ab3eee5002a0554f7f
7
- data.tar.gz: 348b5d867917b56864920378867db54b5dfa0152c32c8377c9734b516751e210d5db6f64813a47175a750b209a8761b67a187c72ee9732531cda89bf3a6cafad
6
+ metadata.gz: c22e487673b2613ab8e64b48b7ada262e489c7696e33bf148c3ed8411818667a1c53e0eb870765854d02d57ce54d04f76e335a2cb383cb4adf46fa90786404f4
7
+ data.tar.gz: d1888d9fc427e7343671757ab1bd7ec290727110a761a75cee6b4014f641ddf392bd81c97a8384dc7bf71ef9e155d342602ee69db8db7b515766cb7678c16349
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ *.txt
2
+ *.md
3
+ ext/fcntl/*.[ch]
data/.rdoc_options ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ main_page: README.md
data/BSDL ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # Fcntl
2
+
3
+ Fcntl loads the constants defined in the system's `<fcntl.h>` C header file, and used with both the fcntl(2) and open(2) POSIX system calls.
4
+
5
+ * To perform a fcntl(2) operation, use IO::fcntl.
6
+ * To perform an open(2) operation, use IO::sysopen.
7
+
8
+ The set of operations and constants available depends upon specific operating system. Some values listed below may not be supported on your system.
9
+
10
+ See your fcntl(2) man page for complete details.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'fcntl'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install fcntl
27
+
28
+ ## Usage
29
+
30
+ Open `/tmp/tempfile` as a write-only file that is created if it doesn't
31
+ exist:
32
+
33
+ ```ruby
34
+ require 'fcntl'
35
+
36
+ fd = IO.sysopen('/tmp/tempfile',
37
+ Fcntl::O_WRONLY | Fcntl::O_EXCL | Fcntl::O_CREAT)
38
+ f = IO.open(fd)
39
+ f.syswrite("TEMP DATA")
40
+ f.close
41
+ ```
42
+
43
+ Get the flags on file `s`:
44
+
45
+ ```ruby
46
+ m = s.fcntl(Fcntl::F_GETFL, 0)
47
+ ```
48
+
49
+ Set the non-blocking flag on `f` in addition to the existing flags in `m`.
50
+
51
+ ```ruby
52
+ f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK|m)
53
+ ```
54
+
55
+ ## Development
56
+
57
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
58
+
59
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
60
+
61
+ ## Contributing
62
+
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/fcntl.
64
+
65
+
66
+ ## License
67
+
68
+ The gem is available as open source under the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause).
data/ext/fcntl/fcntl.c CHANGED
@@ -28,7 +28,10 @@ pack up your own arguments to pass as args for locking functions, etc.
28
28
  #include "ruby.h"
29
29
  #include <fcntl.h>
30
30
 
31
- /* Fcntl loads the constants defined in the system's <fcntl.h> C header
31
+ /*
32
+ * Document-module: Fcntl
33
+ *
34
+ * Fcntl loads the constants defined in the system's <fcntl.h> C header
32
35
  * file, and used with both the fcntl(2) and open(2) POSIX system calls.
33
36
  *
34
37
  * To perform a fcntl(2) operation, use IO::fcntl.
@@ -62,18 +65,18 @@ pack up your own arguments to pass as args for locking functions, etc.
62
65
  *
63
66
  */
64
67
 
65
- #define FCNTL_VERSION "1.1.0"
68
+ #define FCNTL_VERSION "1.2.0"
66
69
 
67
70
  void
68
71
  Init_fcntl(void)
69
72
  {
70
73
  VALUE mFcntl = rb_define_module("Fcntl");
71
74
 
75
+ /* The version string. */
72
76
  rb_define_const(mFcntl, "VERSION", rb_str_new_cstr(FCNTL_VERSION));
73
77
 
74
78
  #ifdef F_DUPFD
75
- /* Document-const: F_DUPFD
76
- *
79
+ /*
77
80
  * Duplicate a file descriptor to the minimum unused file descriptor
78
81
  * greater than or equal to the argument.
79
82
  *
@@ -84,195 +87,164 @@ Init_fcntl(void)
84
87
  rb_define_const(mFcntl, "F_DUPFD", INT2NUM(F_DUPFD));
85
88
  #endif
86
89
  #ifdef F_GETFD
87
- /* Document-const: F_GETFD
88
- *
90
+ /*
89
91
  * Read the close-on-exec flag of a file descriptor.
90
92
  */
91
93
  rb_define_const(mFcntl, "F_GETFD", INT2NUM(F_GETFD));
92
94
  #endif
93
95
  #ifdef F_GETLK
94
- /* Document-const: F_GETLK
95
- *
96
+ /*
96
97
  * Determine whether a given region of a file is locked. This uses one of
97
98
  * the F_*LK flags.
98
99
  */
99
100
  rb_define_const(mFcntl, "F_GETLK", INT2NUM(F_GETLK));
100
101
  #endif
101
102
  #ifdef F_SETFD
102
- /* Document-const: F_SETFD
103
- *
103
+ /*
104
104
  * Set the close-on-exec flag of a file descriptor.
105
105
  */
106
106
  rb_define_const(mFcntl, "F_SETFD", INT2NUM(F_SETFD));
107
107
  #endif
108
108
  #ifdef F_GETFL
109
- /* Document-const: F_GETFL
110
- *
109
+ /*
111
110
  * Get the file descriptor flags. This will be one or more of the O_*
112
111
  * flags.
113
112
  */
114
113
  rb_define_const(mFcntl, "F_GETFL", INT2NUM(F_GETFL));
115
114
  #endif
116
115
  #ifdef F_SETFL
117
- /* Document-const: F_SETFL
118
- *
116
+ /*
119
117
  * Set the file descriptor flags. This will be one or more of the O_*
120
118
  * flags.
121
119
  */
122
120
  rb_define_const(mFcntl, "F_SETFL", INT2NUM(F_SETFL));
123
121
  #endif
124
122
  #ifdef F_SETLK
125
- /* Document-const: F_SETLK
126
- *
123
+ /*
127
124
  * Acquire a lock on a region of a file. This uses one of the F_*LCK
128
125
  * flags.
129
126
  */
130
127
  rb_define_const(mFcntl, "F_SETLK", INT2NUM(F_SETLK));
131
128
  #endif
132
129
  #ifdef F_SETLKW
133
- /* Document-const: F_SETLKW
134
- *
130
+ /*
135
131
  * Acquire a lock on a region of a file, waiting if necessary. This uses
136
132
  * one of the F_*LCK flags
137
133
  */
138
134
  rb_define_const(mFcntl, "F_SETLKW", INT2NUM(F_SETLKW));
139
135
  #endif
140
136
  #ifdef FD_CLOEXEC
141
- /* Document-const: FD_CLOEXEC
142
- *
137
+ /*
143
138
  * the value of the close-on-exec flag.
144
139
  */
145
140
  rb_define_const(mFcntl, "FD_CLOEXEC", INT2NUM(FD_CLOEXEC));
146
141
  #endif
147
142
  #ifdef F_RDLCK
148
- /* Document-const: F_RDLCK
149
- *
143
+ /*
150
144
  * Read lock for a region of a file
151
145
  */
152
146
  rb_define_const(mFcntl, "F_RDLCK", INT2NUM(F_RDLCK));
153
147
  #endif
154
148
  #ifdef F_UNLCK
155
- /* Document-const: F_UNLCK
156
- *
149
+ /*
157
150
  * Remove lock for a region of a file
158
151
  */
159
152
  rb_define_const(mFcntl, "F_UNLCK", INT2NUM(F_UNLCK));
160
153
  #endif
161
154
  #ifdef F_WRLCK
162
- /* Document-const: F_WRLCK
163
- *
155
+ /*
164
156
  * Write lock for a region of a file
165
157
  */
166
158
  rb_define_const(mFcntl, "F_WRLCK", INT2NUM(F_WRLCK));
167
159
  #endif
168
160
  #ifdef F_SETPIPE_SZ
169
- /* Document-const: F_SETPIPE_SZ
170
- *
161
+ /*
171
162
  * Change the capacity of the pipe referred to by fd to be at least arg bytes.
172
163
  */
173
164
  rb_define_const(mFcntl, "F_SETPIPE_SZ", INT2NUM(F_SETPIPE_SZ));
174
165
  #endif
175
166
  #ifdef F_GETPIPE_SZ
176
- /* Document-const: F_GETPIPE_SZ
177
- *
167
+ /*
178
168
  * Return (as the function result) the capacity of the pipe referred to by fd.
179
169
  */
180
170
  rb_define_const(mFcntl, "F_GETPIPE_SZ", INT2NUM(F_GETPIPE_SZ));
181
171
  #endif
182
172
  #ifdef O_CREAT
183
- /* Document-const: O_CREAT
184
- *
173
+ /*
185
174
  * Create the file if it doesn't exist
186
175
  */
187
176
  rb_define_const(mFcntl, "O_CREAT", INT2NUM(O_CREAT));
188
177
  #endif
189
178
  #ifdef O_EXCL
190
- /* Document-const: O_EXCL
191
- *
179
+ /*
192
180
  * Used with O_CREAT, fail if the file exists
193
181
  */
194
182
  rb_define_const(mFcntl, "O_EXCL", INT2NUM(O_EXCL));
195
183
  #endif
196
184
  #ifdef O_NOCTTY
197
- /* Document-const: O_NOCTTY
198
- *
185
+ /*
199
186
  * Open TTY without it becoming the controlling TTY
200
187
  */
201
188
  rb_define_const(mFcntl, "O_NOCTTY", INT2NUM(O_NOCTTY));
202
189
  #endif
203
190
  #ifdef O_TRUNC
204
- /* Document-const: O_TRUNC
205
- *
191
+ /*
206
192
  * Truncate the file on open
207
193
  */
208
194
  rb_define_const(mFcntl, "O_TRUNC", INT2NUM(O_TRUNC));
209
195
  #endif
210
196
  #ifdef O_APPEND
211
- /* Document-const: O_APPEND
212
- *
197
+ /*
213
198
  * Open the file in append mode
214
199
  */
215
200
  rb_define_const(mFcntl, "O_APPEND", INT2NUM(O_APPEND));
216
201
  #endif
217
202
  #ifdef O_NONBLOCK
218
- /* Document-const: O_NONBLOCK
219
- *
203
+ /*
220
204
  * Open the file in non-blocking mode
221
205
  */
222
206
  rb_define_const(mFcntl, "O_NONBLOCK", INT2NUM(O_NONBLOCK));
223
207
  #endif
224
208
  #ifdef O_NDELAY
225
- /* Document-const: O_NDELAY
226
- *
209
+ /*
227
210
  * Open the file in non-blocking mode
228
211
  */
229
212
  rb_define_const(mFcntl, "O_NDELAY", INT2NUM(O_NDELAY));
230
213
  #endif
231
214
  #ifdef O_RDONLY
232
- /* Document-const: O_RDONLY
233
- *
215
+ /*
234
216
  * Open the file in read-only mode
235
217
  */
236
218
  rb_define_const(mFcntl, "O_RDONLY", INT2NUM(O_RDONLY));
237
219
  #endif
238
220
  #ifdef O_RDWR
239
- /* Document-const: O_RDWR
240
- *
221
+ /*
241
222
  * Open the file in read-write mode
242
223
  */
243
224
  rb_define_const(mFcntl, "O_RDWR", INT2NUM(O_RDWR));
244
225
  #endif
245
226
  #ifdef O_WRONLY
246
- /* Document-const: O_WRONLY
247
- *
227
+ /*
248
228
  * Open the file in write-only mode.
249
229
  */
250
230
  rb_define_const(mFcntl, "O_WRONLY", INT2NUM(O_WRONLY));
251
231
  #endif
252
- #ifdef O_ACCMODE
253
- /* Document-const: O_ACCMODE
254
- *
232
+ #ifndef O_ACCMODE
233
+ int O_ACCMODE = (O_RDONLY | O_WRONLY | O_RDWR);
234
+ #endif
235
+ /*
255
236
  * Mask to extract the read/write flags
256
237
  */
257
238
  rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_ACCMODE));
258
- #else
259
- /* Document-const: O_ACCMODE
260
- *
261
- * Mask to extract the read/write flags
262
- */
263
- rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_RDONLY | O_WRONLY | O_RDWR));
264
- #endif
265
239
  #ifdef F_DUP2FD
266
- /* Document-const: F_DUP2FD
267
- *
240
+ /*
268
241
  * It is a FreeBSD specific constant and equivalent
269
242
  * to dup2 call.
270
243
  */
271
244
  rb_define_const(mFcntl, "F_DUP2FD", INT2NUM(F_DUP2FD));
272
245
  #endif
273
246
  #ifdef F_DUP2FD_CLOEXEC
274
- /* Document-const: F_DUP2FD_CLOEXEC
275
- *
247
+ /*
276
248
  * It is a FreeBSD specific constant and acts
277
249
  * similarly as F_DUP2FD but set the FD_CLOEXEC
278
250
  * flag in addition.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fcntl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-07 00:00:00.000000000 Z
11
+ date: 2024-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Loads constants defined in the OS fcntl.h C header file
14
14
  email:
@@ -16,8 +16,18 @@ email:
16
16
  executables: []
17
17
  extensions:
18
18
  - ext/fcntl/extconf.rb
19
- extra_rdoc_files: []
19
+ extra_rdoc_files:
20
+ - ".document"
21
+ - ".rdoc_options"
22
+ - BSDL
23
+ - COPYING
24
+ - README.md
20
25
  files:
26
+ - ".document"
27
+ - ".rdoc_options"
28
+ - BSDL
29
+ - COPYING
30
+ - README.md
21
31
  - ext/fcntl/extconf.rb
22
32
  - ext/fcntl/fcntl.c
23
33
  homepage: https://github.com/ruby/fcntl
@@ -25,7 +35,7 @@ licenses:
25
35
  - Ruby
26
36
  - BSD-2-Clause
27
37
  metadata: {}
28
- post_install_message:
38
+ post_install_message:
29
39
  rdoc_options: []
30
40
  require_paths:
31
41
  - lib
@@ -33,15 +43,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
33
43
  requirements:
34
44
  - - ">="
35
45
  - !ruby/object:Gem::Version
36
- version: 2.3.0
46
+ version: 2.5.0
37
47
  required_rubygems_version: !ruby/object:Gem::Requirement
38
48
  requirements:
39
49
  - - ">="
40
50
  - !ruby/object:Gem::Version
41
51
  version: '0'
42
52
  requirements: []
43
- rubygems_version: 3.5.0.dev
44
- signing_key:
53
+ rubygems_version: 3.5.11
54
+ signing_key:
45
55
  specification_version: 4
46
56
  summary: Loads constants defined in the OS fcntl.h C header file
47
57
  test_files: []