fcntl 1.0.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
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 +41 -63
  8. metadata +18 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80b17a247c77e5f9d90df98db79ea4fad010c708591d4b9ebf747da37cc0d7a9
4
- data.tar.gz: a3cb9608903122b80a1e3fcfb6c89a00708baaf5b4538050d8115c79caf3c834
3
+ metadata.gz: 79225134a2c323e2db686035be55955b776a78388372a6473cdbc6697ebcced3
4
+ data.tar.gz: 99196c26496d96bcf3c771df166e4e8c89d9a87a969146b70966969c97765821
5
5
  SHA512:
6
- metadata.gz: 22627ca3ecdcd922c13625ad4382ae676e35c0c078ef0da5526c8d333d67cc541b383b86a90f90277cc73c1ddf7c4af1226e86abe06d502f0b32255dba673e13
7
- data.tar.gz: 3f8f5794736bf2f2090ed50a3e0de64d78906b3a3f720e56be8e417736e7734b35efea12d0a3b5556741df76f54835b082aa09ce948407e63bd5aef112090806
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.
@@ -61,13 +64,19 @@ pack up your own arguments to pass as args for locking functions, etc.
61
64
  * f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK|m)
62
65
  *
63
66
  */
67
+
68
+ #define FCNTL_VERSION "1.2.0"
69
+
64
70
  void
65
71
  Init_fcntl(void)
66
72
  {
67
73
  VALUE mFcntl = rb_define_module("Fcntl");
74
+
75
+ /* The version string. */
76
+ rb_define_const(mFcntl, "VERSION", rb_str_new_cstr(FCNTL_VERSION));
77
+
68
78
  #ifdef F_DUPFD
69
- /* Document-const: F_DUPFD
70
- *
79
+ /*
71
80
  * Duplicate a file descriptor to the minimum unused file descriptor
72
81
  * greater than or equal to the argument.
73
82
  *
@@ -78,195 +87,164 @@ Init_fcntl(void)
78
87
  rb_define_const(mFcntl, "F_DUPFD", INT2NUM(F_DUPFD));
79
88
  #endif
80
89
  #ifdef F_GETFD
81
- /* Document-const: F_GETFD
82
- *
90
+ /*
83
91
  * Read the close-on-exec flag of a file descriptor.
84
92
  */
85
93
  rb_define_const(mFcntl, "F_GETFD", INT2NUM(F_GETFD));
86
94
  #endif
87
95
  #ifdef F_GETLK
88
- /* Document-const: F_GETLK
89
- *
96
+ /*
90
97
  * Determine whether a given region of a file is locked. This uses one of
91
98
  * the F_*LK flags.
92
99
  */
93
100
  rb_define_const(mFcntl, "F_GETLK", INT2NUM(F_GETLK));
94
101
  #endif
95
102
  #ifdef F_SETFD
96
- /* Document-const: F_SETFD
97
- *
103
+ /*
98
104
  * Set the close-on-exec flag of a file descriptor.
99
105
  */
100
106
  rb_define_const(mFcntl, "F_SETFD", INT2NUM(F_SETFD));
101
107
  #endif
102
108
  #ifdef F_GETFL
103
- /* Document-const: F_GETFL
104
- *
109
+ /*
105
110
  * Get the file descriptor flags. This will be one or more of the O_*
106
111
  * flags.
107
112
  */
108
113
  rb_define_const(mFcntl, "F_GETFL", INT2NUM(F_GETFL));
109
114
  #endif
110
115
  #ifdef F_SETFL
111
- /* Document-const: F_SETFL
112
- *
116
+ /*
113
117
  * Set the file descriptor flags. This will be one or more of the O_*
114
118
  * flags.
115
119
  */
116
120
  rb_define_const(mFcntl, "F_SETFL", INT2NUM(F_SETFL));
117
121
  #endif
118
122
  #ifdef F_SETLK
119
- /* Document-const: F_SETLK
120
- *
123
+ /*
121
124
  * Acquire a lock on a region of a file. This uses one of the F_*LCK
122
125
  * flags.
123
126
  */
124
127
  rb_define_const(mFcntl, "F_SETLK", INT2NUM(F_SETLK));
125
128
  #endif
126
129
  #ifdef F_SETLKW
127
- /* Document-const: F_SETLKW
128
- *
130
+ /*
129
131
  * Acquire a lock on a region of a file, waiting if necessary. This uses
130
132
  * one of the F_*LCK flags
131
133
  */
132
134
  rb_define_const(mFcntl, "F_SETLKW", INT2NUM(F_SETLKW));
133
135
  #endif
134
136
  #ifdef FD_CLOEXEC
135
- /* Document-const: FD_CLOEXEC
136
- *
137
+ /*
137
138
  * the value of the close-on-exec flag.
138
139
  */
139
140
  rb_define_const(mFcntl, "FD_CLOEXEC", INT2NUM(FD_CLOEXEC));
140
141
  #endif
141
142
  #ifdef F_RDLCK
142
- /* Document-const: F_RDLCK
143
- *
143
+ /*
144
144
  * Read lock for a region of a file
145
145
  */
146
146
  rb_define_const(mFcntl, "F_RDLCK", INT2NUM(F_RDLCK));
147
147
  #endif
148
148
  #ifdef F_UNLCK
149
- /* Document-const: F_UNLCK
150
- *
149
+ /*
151
150
  * Remove lock for a region of a file
152
151
  */
153
152
  rb_define_const(mFcntl, "F_UNLCK", INT2NUM(F_UNLCK));
154
153
  #endif
155
154
  #ifdef F_WRLCK
156
- /* Document-const: F_WRLCK
157
- *
155
+ /*
158
156
  * Write lock for a region of a file
159
157
  */
160
158
  rb_define_const(mFcntl, "F_WRLCK", INT2NUM(F_WRLCK));
161
159
  #endif
162
160
  #ifdef F_SETPIPE_SZ
163
- /* Document-const: F_SETPIPE_SZ
164
- *
161
+ /*
165
162
  * Change the capacity of the pipe referred to by fd to be at least arg bytes.
166
163
  */
167
164
  rb_define_const(mFcntl, "F_SETPIPE_SZ", INT2NUM(F_SETPIPE_SZ));
168
165
  #endif
169
166
  #ifdef F_GETPIPE_SZ
170
- /* Document-const: F_GETPIPE_SZ
171
- *
167
+ /*
172
168
  * Return (as the function result) the capacity of the pipe referred to by fd.
173
169
  */
174
170
  rb_define_const(mFcntl, "F_GETPIPE_SZ", INT2NUM(F_GETPIPE_SZ));
175
171
  #endif
176
172
  #ifdef O_CREAT
177
- /* Document-const: O_CREAT
178
- *
173
+ /*
179
174
  * Create the file if it doesn't exist
180
175
  */
181
176
  rb_define_const(mFcntl, "O_CREAT", INT2NUM(O_CREAT));
182
177
  #endif
183
178
  #ifdef O_EXCL
184
- /* Document-const: O_EXCL
185
- *
179
+ /*
186
180
  * Used with O_CREAT, fail if the file exists
187
181
  */
188
182
  rb_define_const(mFcntl, "O_EXCL", INT2NUM(O_EXCL));
189
183
  #endif
190
184
  #ifdef O_NOCTTY
191
- /* Document-const: O_NOCTTY
192
- *
185
+ /*
193
186
  * Open TTY without it becoming the controlling TTY
194
187
  */
195
188
  rb_define_const(mFcntl, "O_NOCTTY", INT2NUM(O_NOCTTY));
196
189
  #endif
197
190
  #ifdef O_TRUNC
198
- /* Document-const: O_TRUNC
199
- *
191
+ /*
200
192
  * Truncate the file on open
201
193
  */
202
194
  rb_define_const(mFcntl, "O_TRUNC", INT2NUM(O_TRUNC));
203
195
  #endif
204
196
  #ifdef O_APPEND
205
- /* Document-const: O_APPEND
206
- *
197
+ /*
207
198
  * Open the file in append mode
208
199
  */
209
200
  rb_define_const(mFcntl, "O_APPEND", INT2NUM(O_APPEND));
210
201
  #endif
211
202
  #ifdef O_NONBLOCK
212
- /* Document-const: O_NONBLOCK
213
- *
203
+ /*
214
204
  * Open the file in non-blocking mode
215
205
  */
216
206
  rb_define_const(mFcntl, "O_NONBLOCK", INT2NUM(O_NONBLOCK));
217
207
  #endif
218
208
  #ifdef O_NDELAY
219
- /* Document-const: O_NDELAY
220
- *
209
+ /*
221
210
  * Open the file in non-blocking mode
222
211
  */
223
212
  rb_define_const(mFcntl, "O_NDELAY", INT2NUM(O_NDELAY));
224
213
  #endif
225
214
  #ifdef O_RDONLY
226
- /* Document-const: O_RDONLY
227
- *
215
+ /*
228
216
  * Open the file in read-only mode
229
217
  */
230
218
  rb_define_const(mFcntl, "O_RDONLY", INT2NUM(O_RDONLY));
231
219
  #endif
232
220
  #ifdef O_RDWR
233
- /* Document-const: O_RDWR
234
- *
221
+ /*
235
222
  * Open the file in read-write mode
236
223
  */
237
224
  rb_define_const(mFcntl, "O_RDWR", INT2NUM(O_RDWR));
238
225
  #endif
239
226
  #ifdef O_WRONLY
240
- /* Document-const: O_WRONLY
241
- *
227
+ /*
242
228
  * Open the file in write-only mode.
243
229
  */
244
230
  rb_define_const(mFcntl, "O_WRONLY", INT2NUM(O_WRONLY));
245
231
  #endif
246
- #ifdef O_ACCMODE
247
- /* Document-const: O_ACCMODE
248
- *
232
+ #ifndef O_ACCMODE
233
+ int O_ACCMODE = (O_RDONLY | O_WRONLY | O_RDWR);
234
+ #endif
235
+ /*
249
236
  * Mask to extract the read/write flags
250
237
  */
251
238
  rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_ACCMODE));
252
- #else
253
- /* Document-const: O_ACCMODE
254
- *
255
- * Mask to extract the read/write flags
256
- */
257
- rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_RDONLY | O_WRONLY | O_RDWR));
258
- #endif
259
239
  #ifdef F_DUP2FD
260
- /* Document-const: F_DUP2FD
261
- *
240
+ /*
262
241
  * It is a FreeBSD specific constant and equivalent
263
242
  * to dup2 call.
264
243
  */
265
244
  rb_define_const(mFcntl, "F_DUP2FD", INT2NUM(F_DUP2FD));
266
245
  #endif
267
246
  #ifdef F_DUP2FD_CLOEXEC
268
- /* Document-const: F_DUP2FD_CLOEXEC
269
- *
247
+ /*
270
248
  * It is a FreeBSD specific constant and acts
271
249
  * similarly as F_DUP2FD but set the FD_CLOEXEC
272
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.0.2
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: 2022-12-05 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.4.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: []