unistd.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * unistd.h
  3. *
  4. * Copyright (C) 2017 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _UNISTD_H_
  20. #define _UNISTD_H_
  21. #include <stddef.h>
  22. #include <stdint.h>
  23. #define PATH_MAX 16384
  24. #define STDIN_FILENO 0
  25. #define STDOUT_FILENO 1
  26. #define STDERR_FILENO 2
  27. #define O_RDONLY 0
  28. #define O_WRONLY 1
  29. #define O_RDWR 2
  30. #define O_CREAT (1 << 6)
  31. #define O_EXCL (1 << 7)
  32. #define O_TRUNC (1 << 9)
  33. #define O_APPEND (1 << 10)
  34. #define O_NONBLOCK (1 << 11)
  35. #define SEEK_SET 0
  36. #define SEEK_CUR 1
  37. #define SEEK_END 2
  38. typedef uint16_t mode_t;
  39. typedef ptrdiff_t off_t;
  40. typedef ptrdiff_t ssize_t;
  41. char *getcwd(char *buf, size_t size);
  42. char *getwd(char *buf);
  43. char *get_current_dir_name(void);
  44. int fchdir(int fd);
  45. int chdir(const char *path);
  46. #ifndef __DONT_DEFINE_OPEN__
  47. int open(const char *pathname, int flags, ...);
  48. #endif
  49. int creat(const char *pathname, mode_t mode);
  50. int close(int fd);
  51. ssize_t read(int fd, void *buf, size_t count);
  52. ssize_t write(int fd, const void *buf, size_t count);
  53. off_t lseek(int fd, off_t offset, int whence);
  54. #endif