Path: blob/main/contrib/libfido2/openbsd-compat/posix_win.c
39562 views
/*1* Public domain2*3* File IO compatibility shims4* Brent Cook <[email protected]>5*/67#define NO_REDEF_POSIX_FUNCTIONS89#include <windows.h>1011#include <errno.h>12#include <io.h>1314#include "posix_win.h"1516int17posix_open(const char *path, ...)18{19va_list ap;20int mode = 0;21int flags;2223va_start(ap, path);24flags = va_arg(ap, int);25if (flags & O_CREAT)26mode = va_arg(ap, int);27va_end(ap);2829flags |= O_BINARY | O_NOINHERIT;3031return (open(path, flags, mode));32}3334int35posix_close(int fd)36{37return (close(fd));38}3940ssize_t41posix_read(int fd, void *buf, size_t count)42{43if (count > INT_MAX) {44errno = EINVAL;45return (-1);46}4748return (read(fd, buf, (unsigned int)count));49}5051ssize_t52posix_write(int fd, const void *buf, size_t count)53{54if (count > INT_MAX) {55errno = EINVAL;56return (-1);57}5859return (write(fd, buf, (unsigned int)count));60}616263