summaryrefslogtreecommitdiff
path: root/userland/libc/stdlib/mkstemp.c
blob: 1ea8790890be16f1e4caf542efccb48620c9ef29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#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);
}