// fcntl.h -- file-control definitions for the GNO/ME runtime.
//
// O_* values match GNO's <sys/fcntl.h> exactly so binaries agree with the
// kernel and shell.  open()/creat() live in runtime/src/libcGno.c as GS/OS-
// toolbox emulation over the gsos* wrappers.
#ifndef _FCNTL_H
#define _FCNTL_H

#include <sys/types.h>     // mode_t / off_t (single source of truth)

#ifdef __cplusplus
extern "C" {
#endif

// Access modes (open-only), matching GNO <sys/fcntl.h>.
#define O_RDONLY   0x0001
#define O_WRONLY   0x0002
#define O_RDWR     0x0004
#define O_ACCMODE  0x0007

// Status / creation flags, matching GNO <sys/fcntl.h>.
#define O_NONBLOCK 0x0008
#define O_APPEND   0x0010
#define O_CREAT    0x0020
#define O_TRUNC    0x0040
#define O_EXCL     0x0080
#define O_BINARY   0x0100         // non-POSIX GNO flag: create as BIN not TXT
#define O_TRANS    0x0200         // GNO-specific (text translation)
#define O_NOCTTY   0              // no controlling-tty assignment (no bit)

// whence values for lseek(); guarded so <stdio.h>'s copies do not clash.
#ifndef SEEK_SET
#define SEEK_SET   0
#endif
#ifndef SEEK_CUR
#define SEEK_CUR   1
#endif
#ifndef SEEK_END
#define SEEK_END   2
#endif

int open(const char *path, int flags, ...);
int creat(const char *path, mode_t mode);

#ifdef __cplusplus
}
#endif

#endif
