summaryrefslogtreecommitdiff
path: root/userland/libc/stdlib/mkstemp.c
blob: 0dec8e99958986f51c8c12296cd5ecb2f1fc1b20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <fcntl.h>
#include <stdlib.h>

char rand_char(void) {
  return 'A' + (rand() % 10);
}

int mkstemp(char *template) {
  // FIXME: Incomplete
  const char *s = template;
  for (; *template; template ++) {
    if ('X' == *template) {
      *template = rand_char();
    }
  }
  return open(s, O_RDWR, O_CREAT);
}