diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-03-03 23:29:38 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-03-03 23:29:38 +0800 |
commit | 4bf9b57cca977760a89bda7b419a85ca471ba1ce (patch) | |
tree | 1a50b7716ec7369d2dfeaa885d8c055226bcf734 /hurd/path_max.c | |
parent | cfa5ea2f4a8fd79136cfe95ad1fdfe88d52eece8 (diff) | |
download | crupest-4bf9b57cca977760a89bda7b419a85ca471ba1ce.tar.gz crupest-4bf9b57cca977760a89bda7b419a85ca471ba1ce.tar.bz2 crupest-4bf9b57cca977760a89bda7b419a85ca471ba1ce.zip |
feat(www): hurd and todos.
Diffstat (limited to 'hurd/path_max.c')
-rw-r--r-- | hurd/path_max.c | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/hurd/path_max.c b/hurd/path_max.c deleted file mode 100644 index eee777c..0000000 --- a/hurd/path_max.c +++ /dev/null @@ -1,63 +0,0 @@ -#include <errno.h> -#include <stdlib.h> -#include <unistd.h> - -static inline char *xreadlink(const char *restrict path) { - char *buffer; - size_t allocated = 128; - ssize_t len; - - while (1) { - buffer = (char *)malloc(allocated); - if (!buffer) { - return NULL; - } - len = readlink(path, buffer, allocated); - if (len < (ssize_t)allocated) { - return buffer; - } - free(buffer); - if (len >= (ssize_t)allocated) { - allocated *= 2; - continue; - } - return NULL; - } -} - -static inline char *xgethostname() { - long max_host_name; - char *buffer; - - max_host_name = sysconf(_SC_HOST_NAME_MAX); - buffer = malloc(max_host_name + 1); - - if (gethostname(buffer, max_host_name + 1)) { - free(buffer); - return NULL; - } - - buffer[max_host_name] = '\0'; - return buffer; -} - -static inline char *xgetcwd() { - char *buffer; - size_t allocated = 128; - - while (1) { - buffer = (char *)malloc(allocated); - if (!buffer) { - return NULL; - } - getcwd(buffer, allocated); - if (buffer) - return buffer; - free(buffer); - if (errno == ERANGE) { - allocated *= 2; - continue; - } - return NULL; - } -} |