/*
 * unistd.h — POSIX-style file descriptor I/O for Sprinter ESTEX.
 *
 * Each call maps to a single ESTEX RST 10h function:
 *   read   → $13  write  → $14
 *   close  → $12  unlink → $0E
 *
 * On error every call returns -1 (the ESTEX error code is not exposed yet;
 * a future errno mechanism will surface it).
 */

#ifndef UNISTD_H
#define UNISTD_H

#include <stddef.h>      /* size_t */

/* lseek whence values (POSIX). */
#define SEEK_SET  0
#define SEEK_CUR  1
#define SEEK_END  2

int   read (int fd, void *buf, size_t n);
int   write(int fd, const void *buf, size_t n);
int   close(int fd);
int   unlink(const char *path);
long  lseek(int fd, long offset, int whence);

/* Block the calling task for `seconds` seconds (50 Hz IRQ-based timer). */
void  sleep(unsigned int seconds);

/* Directory operations (ESTEX $1B-$1E).  All return 0 on success and -1
 * with errno set on failure; getcwd returns the buffer on success or NULL.
 * size is ignored — ESTEX always wants a 256-byte buffer. */
int   mkdir (const char *path);
int   rmdir (const char *path);
int   chdir (const char *path);
char *getcwd(char *buf, size_t size);

#endif
