Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
1ad2dd61
Unverified
Commit
1ad2dd61
authored
Jan 31, 2018
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Jan 31, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3923 from ksss/tempnam
Shouldn't use tempnam
parents
55431b4c
e422ba0b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
6 deletions
+37
-6
mrbgems/mruby-socket/test/sockettest.c
mrbgems/mruby-socket/test/sockettest.c
+37
-6
No files found.
mrbgems/mruby-socket/test/sockettest.c
View file @
1ad2dd61
...
@@ -2,18 +2,49 @@
...
@@ -2,18 +2,49 @@
#include <stdlib.h>
#include <stdlib.h>
#include "mruby.h"
#include "mruby.h"
#include "mruby/error.h"
#if defined(_WIN32) || defined(_WIN64)
#define close _close
#define unlink _unlink
#ifdef _MSC_VER
static
int
mkstemp
(
char
*
p
)
{
int
fd
;
char
*
fname
=
_mktemp
(
p
);
if
(
fname
==
NULL
)
return
-
1
;
fd
=
open
(
fname
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
_S_IREAD
|
_S_IWRITE
);
if
(
fd
>=
0
)
return
fd
;
return
-
1
;
}
#endif
#else
#include <unistd.h>
#ifdef _WIN32
#define tempnam _tempnam
#endif
#endif
mrb_value
mrb_value
mrb_sockettest_tmppath
(
mrb_state
*
mrb
,
mrb_value
klass
)
mrb_sockettest_tmppath
(
mrb_state
*
mrb
,
mrb_value
klass
)
{
{
char
*
tmp
=
tempnam
(
NULL
,
"mruby-socket"
);
char
name
[]
=
"mruby-socket.XXXXXXXX"
;
mrb_value
str
=
mrb_str_new_cstr
(
mrb
,
tmp
);
int
fd
=
mkstemp
(
name
);
free
(
tmp
);
if
(
fd
==
-
1
)
{
return
str
;
mrb_sys_fail
(
mrb
,
0
);
}
if
(
close
(
fd
)
==
-
1
)
{
mrb_sys_fail
(
mrb
,
0
);
}
if
(
unlink
(
name
)
==
-
1
)
{
mrb_sys_fail
(
mrb
,
0
);
}
return
mrb_str_new_cstr
(
mrb
,
name
);
}
}
mrb_value
mrb_value
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment