summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile8
-rw-r--r--GNUmakefile.mingw53
-rw-r--r--INSTALL58
-rw-r--r--mswin/libs3.def24
-rw-r--r--src/mingw_functions.c55
-rw-r--r--src/mingw_s3_functions.c35
-rw-r--r--src/request.c6
-rw-r--r--src/s3.c23
8 files changed, 198 insertions, 64 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 16bd5dd..4cd28d1 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -38,8 +38,8 @@
# --------------------------------------------------------------------------
# Set libs3 version number
-LIBS3_VER_MAJOR := 0
-LIBS3_VER_MINOR := 3
+LIBS3_VER_MAJOR := trunk
+LIBS3_VER_MINOR := trunk
LIBS3_VER := $(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR)
@@ -87,8 +87,8 @@ ifndef CFLAGS
endif
CFLAGS += -Wall -Werror -std=c99 -Iinc $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
- -DLIBS3_VER_MAJOR=$(LIBS3_VER_MAJOR) \
- -DLIBS3_VER_MINOR=$(LIBS3_VER_MINOR)
+ -DLIBS3_VER_MAJOR=\"$(LIBS3_VER_MAJOR)\" \
+ -DLIBS3_VER_MINOR=\"$(LIBS3_VER_MINOR)\"
# --------------------------------------------------------------------------
diff --git a/GNUmakefile.mingw b/GNUmakefile.mingw
index 29994a5..3d5c332 100644
--- a/GNUmakefile.mingw
+++ b/GNUmakefile.mingw
@@ -38,8 +38,8 @@
# --------------------------------------------------------------------------
# Set libs3 version number
-LIBS3_VER_MAJOR := 0
-LIBS3_VER_MINOR := 3
+LIBS3_VER_MAJOR := trunk
+LIBS3_VER_MINOR := trunk
LIBS3_VER := $(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR)
@@ -53,7 +53,7 @@ endif
# --------------------------------------------------------------------------
# DESTDIR directory
ifndef DESTDIR
- DESTDIR := destdir
+ DESTDIR := libs3-$(LIBS3_VER)
endif
@@ -96,9 +96,9 @@ endif
CFLAGS += -Wall -Werror -std=c99 -Iinc $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
$(OPENSSL_CFLAGS) \
- -DLIBS3_VER_MAJOR=$(LIBS3_VER_MAJOR) \
- -DLIBS3_VER_MINOR=$(LIBS3_VER_MINOR) \
- -Dsleep=Sleep \
+ -DLIBS3_VER_MAJOR=\"$(LIBS3_VER_MAJOR)\" \
+ -DLIBS3_VER_MINOR=\"$(LIBS3_VER_MINOR)\" \
+ -Dsleep=Sleep -DFOPEN_EXTRA_FLAGS=\"b\" \
-Iinc/mingw -include windows.h
@@ -114,27 +114,16 @@ exported: libs3 s3 headers
.PHONY: install
install: libs3 s3 headers
- install -Dps -m u+rwx,go+rx $(BUILD)/bin/s3 $(DESTDIR)/bin/s3
- install -Dp -m u+rw,go+r $(BUILD)/include/libs3.h $(DESTDIR)/include/libs3.h
- install -Dps -m u+rw,go+r $(BUILD)/lib/libs3.a $(DESTDIR)/lib/libs3.a
- install -Dps -m u+rw,go+r $(BUILD)/lib/libs3.so \
- $(DESTDIR)/lib/libs3.so
- ln -sf libs3.so $(DESTDIR)/lib/libs3.so.$(LIBS3_VER_MAJOR)
- ln -sf libs3.so.$(LIBS3_VER_MAJOR) \
- $(DESTDIR)/lib/libs3.so.$(LIBS3_VER)
-
-
-# --------------------------------------------------------------------------
-# Uninstall target
-
-.PHONY: uninstall
-uninstall:
- rm -f $(DESTDIR)/bin/s3 \
- $(DESTDIR)/include/libs3.h \
- $(DESTDIR)/lib/libs3.a \
- $(DESTDIR)/lib/libs3.so \
- $(DESTDIR)/lib/libs3.so.$(LIBS3_VER_MAJOR) \
- $(DESTDIR)/lib/libs3.so.$(LIBS3_VER) \
+ -@mkdir $(DESTDIR)\bin
+ -@mkdir $(DESTDIR)\include
+ -@mkdir $(DESTDIR)\lib
+ copy $(BUILD)\bin\s3.exe $(DESTDIR)\bin
+ copy $(BUILD)\lib\libs3.dll $(DESTDIR)\bin
+ copy $(BUILD)\lib\libs3.a $(DESTDIR)\lib
+ copy mswin\libs3.def $(DESTDIR)\lib
+ copy $(BUILD)\include\libs3.h $(DESTDIR)\include
+ copy LICENSE $(DESTDIR)
+ copy COPYING $(DESTDIR)
# --------------------------------------------------------------------------
@@ -160,11 +149,12 @@ LIBS3_SOURCES := src/acl.c src/bucket.c src/error_parser.c src/general.c \
$(LIBS3_SHARED): $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o)
-@mkdir $(subst /,\,$(dir $@))
- gcc -shared -Wl,--out-implib,libs3.a -o $@ $^ $(CURL_LIBS) $(LIBXML2_LIBS) $(OPENSSL_LIBS) -lws2_32
+ gcc -shared -o $@ $^ $(CURL_LIBS) $(LIBXML2_LIBS) $(OPENSSL_LIBS) -lws2_32
-$(BUILD)/lib/libs3.a: $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o)
+$(BUILD)/lib/libs3.a: $(LIBS3_SHARED)
-@mkdir $(subst /,\,$(dir $@))
- $(AR) cr $@ $^
+ dlltool --def mswin\libs3.def --dllname $(subst /,\,$<) \
+ --output-lib $(subst /,\,$@)
# --------------------------------------------------------------------------
@@ -173,7 +163,8 @@ $(BUILD)/lib/libs3.a: $(LIBS3_SOURCES:src/%.c=$(BUILD)/obj/%.o)
.PHONY: s3
s3: $(BUILD)/bin/s3.exe
-$(BUILD)/bin/s3.exe: $(BUILD)/obj/s3.o $(BUILD)/lib/libs3.a
+$(BUILD)/bin/s3.exe: $(BUILD)/obj/s3.o $(BUILD)/obj/mingw_s3_functions.o \
+ $(BUILD)/lib/libs3.a
-@mkdir $(subst /,\,$(dir $@))
gcc -o $@ $^ $(CURL_LIBS) $(LIBXML2_LIBS) $(OPENSSL_LIBS) -lws2_32
diff --git a/INSTALL b/INSTALL
index 510faa3..8d2ae97 100644
--- a/INSTALL
+++ b/INSTALL
@@ -2,6 +2,11 @@
To install libs3 on a POSIX system (except Microsoft Windows):
--------------------------------------------------------------
+Note that all POSIX builds have prerequisites, such as development libraries
+that libs3 requires and that must be installed at the time that libs3 is
+built. The easiest way to find out what those are, is to run the build
+command and then observe the results.
+
*** For RPM-based systems (Fedora Core, Mandrake, etc) ***
* rpmbuild -ta <libs3 archive>
@@ -20,15 +25,56 @@ This will produce a Debian package in the build/pkg directory.
*** For all other systems ***
-* make install
-
-Note that additionally, the installation directory can be specified (it
-defaults to /usr):
+* make [DESTDIR=destination root] install
-* DESTDIR=/usr/local make install
+DESTDIR defaults to /usr
To install libs3 on a Microsoft Windows system:
-----------------------------------------------
-(TBD)
+*** Using MingW ***
+
+* libs3 can be built on Windows using the MingW compiler. No other tool
+ is needed. However, the following libraries are needed to build libs3:
+
+ - curl development libraries
+ - libxml2 development libraries
+ - openssl development libraries
+
+ These projects are independent of libs3, and their release schedule and
+ means of distribution would make it very difficult to provide links to
+ the files to download and keep them up-to-date in this file, so no attempt
+ is made here.
+
+ curl and libxml2 libraries and their associated files can be placed in:
+ c:\libs3-libs\bin
+ c:\libs3-libs\include
+
+ The openssl libraries and associated files can be placed in:
+ c:\openssl
+ c:\openssl\include
+
+ If the above locations are used, then the GNUmakefile.mingw will work with
+ no special caveats. If the above locations are not used, then the following
+ environment variables should be set:
+ CURL_LIBS should be set to the MingW compiler flags needed to locate and
+ link in the curl libraries
+ CURL_CFLAGS should be set to the MingW compiler flags needed to locate and
+ include the curl headers
+ LIBXML2_LIBS should be set to the MingW compiler flags needed to locate and
+ link in the libxml2 libraries
+ LIBXML2_CFLAGS should be set to the MingW compiler flags needed to locate and
+ include the libxml2 headers
+ OPENSSL_LIBS should be set to the MingW compiler flags needed to locate and
+ link in the openssl libraries
+ OPENSSL_CFLAGS should be set to the MingW compiler flags needed to locate and
+ include the openssl headers
+
+* mingw32-make [DESTDIR=destination] -f GNUmakefile.mingw install
+
+DESTDIR defaults to libs3-<version>
+
+* DESTDIR can be zipped up into a .zip file for distribution. For best
+ results, the dependent libraries (curl, openssl, etc) should be included,
+ along with their licenses.
diff --git a/mswin/libs3.def b/mswin/libs3.def
new file mode 100644
index 0000000..031386a
--- /dev/null
+++ b/mswin/libs3.def
@@ -0,0 +1,24 @@
+EXPORTS
+S3_convert_acl
+S3_copy_object
+S3_create_bucket
+S3_create_request_context
+S3_deinitialize
+S3_delete_bucket
+S3_delete_object
+S3_destroy_request_context
+S3_get_acl
+S3_get_object
+S3_get_request_context_fdsets
+S3_get_status_name
+S3_head_object
+S3_initialize
+S3_list_bucket
+S3_list_service
+S3_put_object
+S3_runall_request_context
+S3_runonce_request_context
+S3_set_acl
+S3_status_is_retryable
+S3_test_bucket
+S3_validate_bucket_name
diff --git a/src/mingw_functions.c b/src/mingw_functions.c
index 6cdd296..cebad07 100644
--- a/src/mingw_functions.c
+++ b/src/mingw_functions.c
@@ -28,20 +28,51 @@
int uname(struct utsname *u)
{
- u->sysname = "not implemented";
- u->machine = "not implemented";
+ OSVERSIONINFO info;
+ info.dwOSVersionInfoSize = sizeof(info);
- return 0;
-}
+ if (!GetVersionEx(&info)) {
+ return -1;
+ }
-int setenv(const char *a, const char *b, int c)
-{
- return 0;
-}
+ u->machine = "";
-int unsetenv(const char *a)
-{
- return 0;
-}
+ switch (info.dwMajorVersion) {
+ case 4:
+ switch (info.dwMinorVersion) {
+ case 0:
+ u->sysname = "Microsoft Windows NT 4.0";
+ break;
+ case 10:
+ u->sysname = "Microsoft Windows 98";
+ break;
+ case 90:
+ u->sysname = "Microsoft Windows Me";
+ break;
+ default:
+ return -1;
+ }
+ break;
+
+ case 5:
+ switch (info.dwMinorVersion) {
+ case 0:
+ u->sysname = "Microsoft Windows 2000";
+ break;
+ case 1:
+ u->sysname = "Microsoft Windows XP";
+ break;
+ case 2:
+ u->sysname = "Microsoft Server 2003";
+ break;
+ default:
+ return -1;
+ }
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
diff --git a/src/mingw_s3_functions.c b/src/mingw_s3_functions.c
new file mode 100644
index 0000000..478083f
--- /dev/null
+++ b/src/mingw_s3_functions.c
@@ -0,0 +1,35 @@
+/** **************************************************************************
+ * mingw_s3_functions.c
+ *
+ * Copyright 2008 Bryan Ischo <bryan@ischo.com>
+ *
+ * This file is part of libs3.
+ *
+ * libs3 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3 of the License.
+ *
+ * In addition, as a special exception, the copyright holders give
+ * permission to link the code of this library and its programs with the
+ * OpenSSL library, and distribute linked combinations including the two.
+ *
+ * libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License version 3
+ * along with libs3, in a file named COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ ************************************************************************** **/
+
+int setenv(const char *a, const char *b, int c)
+{
+ return SetEnvironmentVariable(a, b);
+}
+
+int unsetenv(const char *a)
+{
+ return SetEnvironmentVariable(a, 0);
+}
diff --git a/src/request.c b/src/request.c
index a21b275..3f3ae15 100644
--- a/src/request.c
+++ b/src/request.c
@@ -1053,12 +1053,12 @@ S3Status request_api_initialize(const char *userAgentInfo)
platform[sizeof(platform) - 1] = 0;
}
else {
- snprintf(platform, sizeof(platform), "%s %s", utsn.sysname,
- utsn.machine);
+ snprintf(platform, sizeof(platform), "%s%s%s", utsn.sysname,
+ utsn.machine[0] ? " " : "", utsn.machine);
}
snprintf(userAgentG, sizeof(userAgentG),
- "Mozilla/4.0 (Compatible; %s; libs3 %d.%d; %s)",
+ "Mozilla/4.0 (Compatible; %s; libs3 %s.%s; %s)",
userAgentInfo, LIBS3_VER_MAJOR, LIBS3_VER_MINOR, platform);
return S3StatusOK;
diff --git a/src/s3.c b/src/s3.c
index 9761cb1..18d91cf 100644
--- a/src/s3.c
+++ b/src/s3.c
@@ -41,6 +41,11 @@
#include <unistd.h>
#include "libs3.h"
+// Some Windows stuff
+#ifndef FOPEN_EXTRA_FLAGS
+#define FOPEN_EXTRA_FLAGS ""
+#endif
+
// Something is weird with glibc ... setenv/unsetenv/ftruncate are not defined
// in stdlib.h as they should be. And fileno is not in stdio.h
@@ -1312,8 +1317,10 @@ static int putObjectDataCallback(int bufferSize, char *buffer,
data->contentLength -= ret;
if (data->contentLength && !data->noStatus) {
- printf("%llu bytes remaining (%d%% complete) ...\n",
- data->contentLength,
+ // Avoid a weird bug in MingW, which won't print the second integer
+ // value properly when it's in the same call, so print separately
+ printf("%llu bytes remaining ", data->contentLength);
+ printf("(%d%% complete) ...\n",
(int) (((data->originalContentLength -
data->contentLength) * 100) /
data->originalContentLength));
@@ -1469,7 +1476,7 @@ static void put_object(int argc, char **argv, int optind)
contentLength = statbuf.st_size;
}
// Open the file
- if (!(data.infile = fopen(filename, "r"))) {
+ if (!(data.infile = fopen(filename, "r" FOPEN_EXTRA_FLAGS))) {
fprintf(stderr, "\nERROR: Failed to open input file %s: ",
filename);
perror(0);
@@ -1843,13 +1850,13 @@ static void get_object(int argc, char **argv, int optind)
// Stat the file, and if it doesn't exist, open it in w mode
struct stat buf;
if (stat(filename, &buf) == -1) {
- outfile = fopen(filename, "w");
+ outfile = fopen(filename, "w" FOPEN_EXTRA_FLAGS);
}
else {
// Open in r+ so that we don't truncate the file, just in case
// there is an error and we write no bytes, we leave the file
// unmodified
- outfile = fopen(filename, "r+");
+ outfile = fopen(filename, "r+" FOPEN_EXTRA_FLAGS);
}
if (!outfile) {
@@ -2019,13 +2026,13 @@ void get_acl(int argc, char **argv, int optind)
// Stat the file, and if it doesn't exist, open it in w mode
struct stat buf;
if (stat(filename, &buf) == -1) {
- outfile = fopen(filename, "w");
+ outfile = fopen(filename, "w" FOPEN_EXTRA_FLAGS);
}
else {
// Open in r+ so that we don't truncate the file, just in case
// there is an error and we write no bytes, we leave the file
// unmodified
- outfile = fopen(filename, "r+");
+ outfile = fopen(filename, "r+" FOPEN_EXTRA_FLAGS);
}
if (!outfile) {
@@ -2179,7 +2186,7 @@ void set_acl(int argc, char **argv, int optind)
FILE *infile;
if (filename) {
- if (!(infile = fopen(filename, "r"))) {
+ if (!(infile = fopen(filename, "r" FOPEN_EXTRA_FLAGS))) {
fprintf(stderr, "\nERROR: Failed to open input file %s: ",
filename);
perror(0);