From 1c84743f00c5732b68e80d6bf4fa78e090538dd0 Mon Sep 17 00:00:00 2001 From: Dima Pulkinen Date: Mon, 5 Aug 2024 13:27:32 +0300 Subject: [PATCH] add gethostname implementation --- src/libcglue/Makefile.am | 2 +- src/libcglue/glue.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libcglue/Makefile.am b/src/libcglue/Makefile.am index 4aeab90e..d44c3fb7 100755 --- a/src/libcglue/Makefile.am +++ b/src/libcglue/Makefile.am @@ -30,7 +30,7 @@ GLUE_OBJS = __dummy_passwd.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wai _isatty.o symlink.o truncate.o chmod.o fchmod.o pathconf.o readlink.o utime.o fchown.o _getentropy.o getpwuid.o \ fsync.o getpwnam.o getuid.o geteuid.o basename.o statvfs.o \ openat.o renameat.o fchmodat.o fstatat.o mkdirat.o faccessat.o fchownat.o linkat.o readlinkat.o unlinkat.o \ - realpath.o + realpath.o gethostname.o INIT_OBJS = \ __libpthreadglue_init.o \ diff --git a/src/libcglue/glue.c b/src/libcglue/glue.c index a8fe5738..0a49a7bf 100755 --- a/src/libcglue/glue.c +++ b/src/libcglue/glue.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "fdman.h" @@ -1213,4 +1214,18 @@ char *realpath(const char *path, char *resolved_path) return resolved_path; } -#endif /* F_realpath */ \ No newline at end of file +#endif /* F_realpath */ + +#ifdef F_gethostname +int gethostname (char *__name, size_t __len) { + char nickname[_SC_HOST_NAME_MAX]; + memset(nickname, 0, _SC_HOST_NAME_MAX); + + if (sceUtilityGetSystemParamString(PSP_SYSTEMPARAM_ID_STRING_NICKNAME, nickname, _SC_HOST_NAME_MAX) != PSP_SYSTEMPARAM_RETVAL_FAIL) { + strlcpy(__name, nickname, __len); + return 0; + } + + return __set_errno(EINVAL); +} +#endif /* F_gethostname */