From e42af110fc91c0ecdeb1cf47e014b4fc04757c44 Mon Sep 17 00:00:00 2001 From: Tobias Nygren Date: Wed, 22 Jul 2020 21:26:21 +0200 Subject: [PATCH] add stubs of missing libc functions --- components/libssh/compat/netinet/tcp.h | 1 + components/libssh/compat/poll.h | 2 ++ components/libssh/compat/stubs.h | 31 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 components/libssh/compat/netinet/tcp.h create mode 100644 components/libssh/compat/poll.h create mode 100644 components/libssh/compat/stubs.h diff --git a/components/libssh/compat/netinet/tcp.h b/components/libssh/compat/netinet/tcp.h new file mode 100644 index 0000000..d24e8f3 --- /dev/null +++ b/components/libssh/compat/netinet/tcp.h @@ -0,0 +1 @@ +/* lwip doesn't provide this file */ diff --git a/components/libssh/compat/poll.h b/components/libssh/compat/poll.h new file mode 100644 index 0000000..a528150 --- /dev/null +++ b/components/libssh/compat/poll.h @@ -0,0 +1,2 @@ +/* esp-idf has but not */ +#include diff --git a/components/libssh/compat/stubs.h b/components/libssh/compat/stubs.h new file mode 100644 index 0000000..a1a59d2 --- /dev/null +++ b/components/libssh/compat/stubs.h @@ -0,0 +1,31 @@ +#include +#include +#include + +#if !defined(GLOB_NOMATCH) +#define GLOB_NOMATCH -3 +#endif + +#define gai_strerror(ecode) "unknown error" +#define getuid() getuid_stub() (uid_t)0 + +static inline int getpwuid_r_stub(struct passwd **result) { errno = ENOENT; *result = NULL; return 1; } +#define getpwuid_r(uid,passwd,buffer,buflen,result) getpwuid_r_stub(result) + +static inline struct passwd *getpwnam_stub() { errno = ENOENT; return NULL; } +#define getpwnam(name) getpwnam_stub() + +static inline int gethostname_stub(char *name, size_t namelen) {strlcpy(name, "esp32", namelen); return 0; } +#define gethostname(name, namelen) gethostname_stub(name, namelen) + +static inline pid_t waitpid_stub() { errno = ENOSYS; return (pid_t)-1; } +#define waitpid(pid,status,options) waitpid_stub() + +static inline int glob_stub() { errno = ENOENT; return GLOB_NOMATCH; } +#define glob(pattern, flags, errfunc, pglob) glob_stub() + +#define globfree(pglob) do { } while(0) + + +static inline int socketpair_stub() { errno = ENOSYS; return -1; } +#define socketpair(d, type, protocol, sv) socketpair_stub()