summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-12-28 19:58:07 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-12-28 19:58:07 (GMT)
commit18d31fd97c3305b54a6d1d56b6ef8600089ef6da (patch)
treefad65ce7d2ba37095405c27df79a9c7a5883f448
parentd715d52a11fbcbc3310412ae7c7ec1e71e5bcbed (diff)
downloadCMake-18d31fd97c3305b54a6d1d56b6ef8600089ef6da.zip
CMake-18d31fd97c3305b54a6d1d56b6ef8600089ef6da.tar.gz
CMake-18d31fd97c3305b54a6d1d56b6ef8600089ef6da.tar.bz2
COMP: Several borland fixes
-rw-r--r--Utilities/cmtar/CMakeLists.txt6
-rw-r--r--Utilities/cmtar/append.c10
-rw-r--r--Utilities/cmtar/compat/basename.c4
-rw-r--r--Utilities/cmtar/compat/compat.h9
-rw-r--r--Utilities/cmtar/compat/dirname.c4
-rw-r--r--Utilities/cmtar/decode.c8
-rw-r--r--Utilities/cmtar/extract.c22
-rw-r--r--Utilities/cmtar/filesystem.c4
-rw-r--r--Utilities/cmtar/filesystem.h9
-rw-r--r--Utilities/cmtar/handle.c15
-rw-r--r--Utilities/cmtar/internal.h1
-rw-r--r--Utilities/cmtar/libtar.c2
-rw-r--r--Utilities/cmtar/util.c12
-rw-r--r--Utilities/cmtar/wrapper.c22
14 files changed, 77 insertions, 51 deletions
diff --git a/Utilities/cmtar/CMakeLists.txt b/Utilities/cmtar/CMakeLists.txt
index 48a3efa..7ffe0e1 100644
--- a/Utilities/cmtar/CMakeLists.txt
+++ b/Utilities/cmtar/CMakeLists.txt
@@ -290,7 +290,6 @@ SET(libtar_SRC
output.c
util.c
wrapper.c
- filesystem.c filesystem.h
internal.h
${LIBTAR_BINARY_DIR}/libtar/config.h
config.h.in
@@ -304,6 +303,11 @@ SET(libtar_SRC
# compat/strmode.c
# compat/strsep.c
)
+IF(NOT UNIX)
+ SET(libtar_SRC
+ ${libtar_SRC}
+ filesystem.c filesystem.h)
+ENDIF(NOT UNIX)
IF(NOT HAVE_STRLCPY)
SET(libtar_SRC ${libtar_SRC} compat/strlcpy.c)
diff --git a/Utilities/cmtar/append.c b/Utilities/cmtar/append.c
index 5007c62..77bb34f 100644
--- a/Utilities/cmtar/append.c
+++ b/Utilities/cmtar/append.c
@@ -15,7 +15,7 @@
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
-#ifdef _MSC_VER
+#if defined(_WIN32) && !defined(__CYGWIN__)
# include <libtar/compat.h>
#else
# include <sys/param.h>
@@ -45,7 +45,7 @@ typedef struct tar_dev tar_dev_t;
struct tar_ino
{
ino_t ti_ino;
- char ti_name[MAXPATHLEN];
+ char ti_name[TAR_MAXPATHLEN];
};
typedef struct tar_ino tar_ino_t;
@@ -68,7 +68,7 @@ tar_append_file(TAR *t, char *realname, char *savename)
libtar_hashptr_t hp;
tar_dev_t *td = NULL;
tar_ino_t *ti = NULL;
- char path[MAXPATHLEN];
+ char path[TAR_MAXPATHLEN];
#ifdef DEBUG
printf("==> tar_append_file(TAR=0x%lx (\"%s\"), realname=\"%s\", "
@@ -162,8 +162,8 @@ tar_append_file(TAR *t, char *realname, char *savename)
#endif
if (i == -1)
return -1;
- if (i >= MAXPATHLEN)
- i = MAXPATHLEN - 1;
+ if (i >= TAR_MAXPATHLEN)
+ i = TAR_MAXPATHLEN - 1;
path[i] = '\0';
#ifdef DEBUG
printf(" tar_append_file(): encoding symlink \"%s\" -> "
diff --git a/Utilities/cmtar/compat/basename.c b/Utilities/cmtar/compat/basename.c
index 3b87b0e..ddaf89d 100644
--- a/Utilities/cmtar/compat/basename.c
+++ b/Utilities/cmtar/compat/basename.c
@@ -33,14 +33,14 @@ static char rcsid[] = "$OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp
#include <errno.h>
#include <string.h>
-//#include <sys/param.h>
#include <libtar/compat.h>
+#include <libtarint/internal.h>
char *
openbsd_basename(path)
const char *path;
{
- static char bname[MAXPATHLEN];
+ static char bname[TAR_MAXPATHLEN];
register const char *endp, *startp;
/* Empty or NULL string gets treated as "." */
diff --git a/Utilities/cmtar/compat/compat.h b/Utilities/cmtar/compat/compat.h
index 880f54b..f308b99 100644
--- a/Utilities/cmtar/compat/compat.h
+++ b/Utilities/cmtar/compat/compat.h
@@ -312,3 +312,12 @@ char *strsep(register char **, register const char *);
#endif
#define S_ISFIFO(m) (((m)&S_IFFIFO)==S_IFFIFO)
#endif
+
+#if defined(PATH_MAX)
+# define TAR_MAXPATHLEN PATH_MAX
+#elif defined(MAXPATHLEN)
+# define TAR_MAXPATHLEN MAXPATHLEN
+#else
+# define TAR_MAXPATHLEN 16384
+#endif
+
diff --git a/Utilities/cmtar/compat/dirname.c b/Utilities/cmtar/compat/dirname.c
index f322bbd..f05a381 100644
--- a/Utilities/cmtar/compat/dirname.c
+++ b/Utilities/cmtar/compat/dirname.c
@@ -33,14 +33,14 @@ static char rcsid[] = "$OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $
#include <errno.h>
#include <string.h>
-//#include <sys/param.h>
#include <libtar/compat.h>
+#include <libtarint/internal.h>
char *
openbsd_dirname(path)
const char *path;
{
- static char bname[MAXPATHLEN];
+ static char bname[TAR_MAXPATHLEN];
register const char *endp;
/* Empty or NULL string gets treated as "." */
diff --git a/Utilities/cmtar/decode.c b/Utilities/cmtar/decode.c
index 178ffc0..788fb3f 100644
--- a/Utilities/cmtar/decode.c
+++ b/Utilities/cmtar/decode.c
@@ -14,10 +14,10 @@
#include <stdio.h>
-#ifndef _MSC_VER
-#include <sys/param.h>
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# include <libtar/compat.h>
#else
-#include <libtar/compat.h>
+# include <sys/param.h>
#endif
#ifndef WIN32
@@ -34,7 +34,7 @@
char *
th_get_pathname(TAR *t)
{
- char filename[MAXPATHLEN];
+ char filename[TAR_MAXPATHLEN];
if (t->th_buf.gnu_longname)
return t->th_buf.gnu_longname;
diff --git a/Utilities/cmtar/extract.c b/Utilities/cmtar/extract.c
index 506dff1..7ceece1 100644
--- a/Utilities/cmtar/extract.c
+++ b/Utilities/cmtar/extract.c
@@ -17,14 +17,20 @@
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
-#ifdef _MSC_VER
-#include <sys/utime.h>
-#include <io.h>
-#include <direct.h>
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# ifdef _MSC_VER
+# include <sys/utime.h>
+# else
+# include <utime.h>
+# endif
+# include <io.h>
+# include <direct.h>
#else
-#include <utime.h>
-#include <sys/param.h>
+# include <utime.h>
+# include <sys/param.h>
#endif
+
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <string.h>
@@ -41,8 +47,8 @@
struct linkname
{
- char ln_save[MAXPATHLEN];
- char ln_real[MAXPATHLEN];
+ char ln_save[TAR_MAXPATHLEN];
+ char ln_real[TAR_MAXPATHLEN];
};
typedef struct linkname linkname_t;
diff --git a/Utilities/cmtar/filesystem.c b/Utilities/cmtar/filesystem.c
index 3418d1e..1ddd5a5 100644
--- a/Utilities/cmtar/filesystem.c
+++ b/Utilities/cmtar/filesystem.c
@@ -3,7 +3,6 @@
// First microsoft compilers
-#ifdef _MSC_VER
#include <windows.h>
#include <io.h>
#include <ctype.h>
@@ -61,7 +60,7 @@ kwDirEntry * kwReadDir(kwDirectory * dir)
return NULL;
}
entry = (kwDirEntry*)malloc(sizeof(kwDirEntry));
- strncpy(entry->d_name,dir->Entry.name,MAXPATHLEN-1);
+ strncpy(entry->d_name,dir->Entry.name,TAR_MAXPATHLEN-1);
if(_findnext(dir->SrchHandle, &dir->Entry) == -1)
{
dir->EOD=1;
@@ -79,4 +78,3 @@ int kwCloseDir(kwDirectory * dir)
if(r==-1) return 0;
return 1;
}
-#endif
diff --git a/Utilities/cmtar/filesystem.h b/Utilities/cmtar/filesystem.h
index f2ee202..cd61ed2 100644
--- a/Utilities/cmtar/filesystem.h
+++ b/Utilities/cmtar/filesystem.h
@@ -1,8 +1,8 @@
#ifndef _FILESYSTEM_H_
#define _FILESYSTEM_H_
-#ifdef _MSC_VER
#include <io.h>
+#include <libtarint/internal.h>
struct _KWDIR
{
@@ -15,12 +15,9 @@ struct _KWDIR
int EOD; //end of directory
};
-#ifndef MAXPATHLEN
-#define MAXPATHLEN _MAX_PATH
-#endif
typedef struct _KWDIRENTRY
{
- char d_name[MAXPATHLEN];
+ char d_name[TAR_MAXPATHLEN];
}kwDirEntry;
typedef struct _KWDIR kwDirectory;
@@ -31,5 +28,3 @@ int kwCloseDir(kwDirectory * dir);
#endif //MSC
-
-#endif
diff --git a/Utilities/cmtar/handle.c b/Utilities/cmtar/handle.c
index 1fe053e..5238e03 100644
--- a/Utilities/cmtar/handle.c
+++ b/Utilities/cmtar/handle.c
@@ -34,7 +34,22 @@
const char libtar_version[] = PACKAGE_VERSION;
+#define libtar_symbol(name, ret, args, callargs) \
+ static ret libtar_##name args \
+ { \
+ return name callargs; \
+ }
+
+#if defined(__BORLANDC__)
+libtar_symbol(open, int, (const char* pathname, int flags, mode_t mode), (pathname, flags, mode));
+libtar_symbol(close, int, (int fd), (fd));
+libtar_symbol(read, ssize_t, (int fd, void* buf, size_t count), (fd, buf, count));
+libtar_symbol(write, ssize_t, (int fd, void* buf, size_t count), (fd, buf, count));
+
+static tartype_t default_type = { libtar_open, libtar_close, libtar_read, libtar_write };
+#else
static tartype_t default_type = { open, close, read, write };
+#endif
static int
diff --git a/Utilities/cmtar/internal.h b/Utilities/cmtar/internal.h
index 434fbb0..cc2cbd3 100644
--- a/Utilities/cmtar/internal.h
+++ b/Utilities/cmtar/internal.h
@@ -14,4 +14,3 @@
#include <libtar/compat.h>
#include <libtar/libtar.h>
-
diff --git a/Utilities/cmtar/libtar.c b/Utilities/cmtar/libtar.c
index cdbe7a1..ee01075 100644
--- a/Utilities/cmtar/libtar.c
+++ b/Utilities/cmtar/libtar.c
@@ -113,7 +113,7 @@ create(char *tarfile, char *rootdir, libtar_list_t *l)
{
TAR *t;
char *pathname;
- char buf[MAXPATHLEN];
+ char buf[TAR_MAXPATHLEN];
libtar_listptr_t lp;
if (tar_open(&t, tarfile,
diff --git a/Utilities/cmtar/util.c b/Utilities/cmtar/util.c
index 007ed93..1959e0a 100644
--- a/Utilities/cmtar/util.c
+++ b/Utilities/cmtar/util.c
@@ -20,7 +20,7 @@
# include <string.h>
#endif
-#ifdef _MSC_VER
+#if defined(_WIN32) && !defined(__CYGWIN__)
#include <direct.h>
#else
#include <sys/param.h>
@@ -30,7 +30,7 @@
int
path_hashfunc(char *key, int numbuckets)
{
- char buf[MAXPATHLEN];
+ char buf[TAR_MAXPATHLEN];
char *p;
strcpy(buf, key);
@@ -82,7 +82,7 @@ ino_hash(ino_t *inode)
int
mkdirhier(char *path)
{
- char src[MAXPATHLEN], dst[MAXPATHLEN] = "";
+ char src[TAR_MAXPATHLEN], dst[TAR_MAXPATHLEN] = "";
char *dirp, *nextp = src;
int retval = 1;
@@ -103,10 +103,10 @@ mkdirhier(char *path)
if (dst[0] != '\0')
strcat(dst, "/");
strcat(dst, dirp);
-#ifndef _MSC_VER
- if (mkdir(dst, 0777) == -1)
-#else
+#if defined(_WIN32) && !defined(__CYGWIN__)
if (mkdir(dst) == -1)
+#else
+ if (mkdir(dst, 0777) == -1)
#endif
{
if (errno != EEXIST)
diff --git a/Utilities/cmtar/wrapper.c b/Utilities/cmtar/wrapper.c
index a545862..be090ee 100644
--- a/Utilities/cmtar/wrapper.c
+++ b/Utilities/cmtar/wrapper.c
@@ -14,7 +14,7 @@
#include <stdio.h>
#include <libtar/compat.h>
-#ifdef _MSC_VER
+#if defined(_WIN32) && !defined(__CYGWIN__)
#include <libtarint/filesystem.h>
#else
#include <sys/param.h>
@@ -35,7 +35,7 @@ int
tar_extract_glob(TAR *t, char *globname, char *prefix)
{
char *filename;
- char buf[MAXPATHLEN];
+ char buf[TAR_MAXPATHLEN];
int i;
while ((i = th_read(t)) == 0)
@@ -65,7 +65,7 @@ int
tar_extract_all(TAR *t, char *prefix)
{
char *filename;
- char buf[MAXPATHLEN];
+ char buf[TAR_MAXPATHLEN];
int i;
#ifdef DEBUG
@@ -100,9 +100,9 @@ tar_extract_all(TAR *t, char *prefix)
int
tar_append_tree(TAR *t, char *realdir, char *savedir)
{
- char realpath[MAXPATHLEN];
- char savepath[MAXPATHLEN];
-#ifndef _MSC_VER
+ char realpath[TAR_MAXPATHLEN];
+ char savepath[TAR_MAXPATHLEN];
+#if !defined(_WIN32) || defined(__CYGWIN__)
struct dirent *dent;
DIR *dp;
#else
@@ -123,7 +123,7 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
puts(" tar_append_tree(): done with tar_append_file()...");
#endif
-#ifdef _MSC_VER
+#if defined(_WIN32) && !defined(__CYGWIN__)
dp = kwOpenDir(realdir);
#else
dp = opendir(realdir);
@@ -135,7 +135,7 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
return 0;
return -1;
}
-#ifdef _MSC_VER
+#if defined(_WIN32) && !defined(__CYGWIN__)
while ((dent = kwReadDir(dp)) != NULL)
#else
while ((dent = readdir(dp)) != NULL)
@@ -145,10 +145,10 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
strcmp(dent->d_name, "..") == 0)
continue;
- snprintf(realpath, MAXPATHLEN, "%s/%s", realdir,
+ snprintf(realpath, TAR_MAXPATHLEN, "%s/%s", realdir,
dent->d_name);
if (savedir)
- snprintf(savepath, MAXPATHLEN, "%s/%s", savedir,
+ snprintf(savepath, TAR_MAXPATHLEN, "%s/%s", savedir,
dent->d_name);
#ifndef WIN32
@@ -171,7 +171,7 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
return -1;
}
-#ifdef _MSC_VER
+#if defined(_WIN32) && !defined(__CYGWIN__)
kwCloseDir(dp);
#else
closedir(dp);