aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auto.def7
-rw-r--r--jim-aio.c7
-rw-r--r--jimiocompat.c18
-rw-r--r--jimiocompat.h7
4 files changed, 38 insertions, 1 deletions
diff --git a/auto.def b/auto.def
index c3ff6e6..781d2a6 100644
--- a/auto.def
+++ b/auto.def
@@ -262,7 +262,7 @@ cc-check-functions geteuid mkstemp isatty
cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
cc-check-functions shutdown socketpair link symlink fsync dup umask
-cc-check-functions localtime gmtime strptime
+cc-check-functions localtime gmtime strptime getpeername
if {![cc-check-functions realpath]} {
cc-check-functions _fullpath
}
@@ -302,10 +302,15 @@ cc-check-lfs
if {[get-define _FILE_OFFSET_BITS] != 64 || ![cc-check-functions stat64]} {
# Modern systems and really old systems have plain stat, fstat, lstat
cc-check-functions fstat lstat
+ # Some platforms have lstat but don't declare it!
+ cc-with {-includes unistd.h} {
+ cc-check-decls lstat
+ }
} else {
# But perhaps some 32 bit systems still require explicit use of the 64 bit versions
cc-check-functions fstat64 lstat64 lseek64
}
+cc-check-functions access
define TCL_LIBRARY [get-define libdir]/jim
diff --git a/jim-aio.c b/jim-aio.c
index 4c59e1d..d91b350 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -641,6 +641,7 @@ static Jim_Obj *aio_sockname(Jim_Interp *interp, int fd)
return JimFormatSocketAddress(interp, &sa, salen);
}
+#ifdef HAVE_GETPEERNAME
static Jim_Obj *aio_peername(Jim_Interp *interp, int fd)
{
union sockaddr_any sa;
@@ -651,6 +652,7 @@ static Jim_Obj *aio_peername(Jim_Interp *interp, int fd)
}
return JimFormatSocketAddress(interp, &sa, salen);
}
+#endif
#endif /* JIM_BOOTSTRAP */
static const char *JimAioErrorString(AioFile *af)
@@ -1324,6 +1326,7 @@ static int aio_cmd_sockname(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int aio_cmd_peername(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
+#ifdef HAVE_GETPEERNAME
AioFile *af = Jim_CmdPrivData(interp);
Jim_Obj *objPtr = aio_peername(interp, af->fd);
@@ -1333,6 +1336,10 @@ static int aio_cmd_peername(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
}
Jim_SetResult(interp, objPtr);
return JIM_OK;
+#else
+ Jim_SetResultString(interp, "not supported", -1);
+ return JIM_ERR;
+#endif
}
static int aio_cmd_listen(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
diff --git a/jimiocompat.c b/jimiocompat.c
index 8e7f3f2..1384e61 100644
--- a/jimiocompat.c
+++ b/jimiocompat.c
@@ -249,3 +249,21 @@ int Jim_OpenForRead(const char *filename)
}
#endif
+
+#ifndef HAVE_UMASK
+mode_t umask(mode_t mode) {
+ return 0;
+}
+#endif
+
+#ifndef HAVE_ACCESS
+/* poor-mans access() - ignore mode and treat everything as F_OK */
+int access(const char *path, int mode)
+{
+ struct stat sb;
+ if (Jim_Stat(path, &sb) == 0 && S_ISREG(sb.st_mode)) {
+ return 0;
+ }
+ return -1;
+}
+#endif
diff --git a/jimiocompat.h b/jimiocompat.h
index 0837b73..5cbcde8 100644
--- a/jimiocompat.h
+++ b/jimiocompat.h
@@ -87,6 +87,9 @@ int Jim_OpenForRead(const char *filename);
#define Jim_FileStat fstat
#endif
#if defined(HAVE_LSTAT)
+ #if !HAVE_DECL_LSTAT
+ int lstat (const char *__path, struct stat *__buf );
+ #endif
#define Jim_LinkStat lstat
#endif
#endif
@@ -123,4 +126,8 @@ int Jim_OpenForRead(const char *filename);
*/
int Jim_FileStoreStatData(Jim_Interp *interp, Jim_Obj *varName, const jim_stat_t *sb);
+#ifndef HAVE_ACCESS
+int access(const char *path, int mode);
+#endif
+
#endif