source: asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/temp/mkostemps.c@ 352

Last change on this file since 352 was 352, checked in by coas-nagasima, 6 years ago

arm向けASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 676 bytes
Line 
1#define _BSD_SOURCE
2#include <string.h>
3#include <fcntl.h>
4#include <unistd.h>
5#include <errno.h>
6#include "libc.h"
7
8char *__randname(char *);
9
10int __mkostemps(char *template, int len, int flags)
11{
12 size_t l = strlen(template);
13 if (l<6 || len>l-6 || memcmp(template+l-len-6, "XXXXXX", 6)) {
14 errno = EINVAL;
15 return -1;
16 }
17
18 flags -= flags & O_ACCMODE;
19 int fd, retries = 100;
20 do {
21 __randname(template+l-len-6);
22 if ((fd = open(template, flags | O_RDWR | O_CREAT | O_EXCL, 0600))>=0)
23 return fd;
24 } while (--retries && errno == EEXIST);
25
26 memcpy(template+l-len-6, "XXXXXX", 6);
27 return -1;
28}
29
30weak_alias(__mkostemps, mkostemps);
31weak_alias(__mkostemps, mkostemps64);
Note: See TracBrowser for help on using the repository browser.