Index: ChangeLog
==================================================================
--- ChangeLog
+++ ChangeLog
@@ -1,8 +1,24 @@
Legend:
* Changes of existing features or bugfixes.
+ New features.
+
+ObjFW 0.5.4 -> ObjFW 0.6, 27.02.2012
+ The differences between 0.5.4 and 0.6 are too big to list them all. However,
+ the major new features are:
+ * OFString, OFArray, OFDictionary, OFSet and OFCountedSet are now class
+ clusters.
+ + Serialization and deserialization of objects into/from XML and JSON.
+ + New class OFIntrospection for introspecting classes.
+ + New class OFProcess for working with and controlling child processes.
+ * Lots of OFXMLParser and OFXMLElement improvements.
+ + OFHTTPRequests can have a delegate now for status updates and processing
+ data as soon as it arrives.
+ + There are several backends for OFStreamObserver now, including kqueue, poll
+ and select.
+ + SOCKS5 support for OFTCPSockets (client only).
+ * Several API changes.
ObjFW 0.5.3 -> ObjFW 0.5.4, 30.08.2011
* The blocks runtime is now working correctly.
* Documentation fixes.
* -framework works with objfw-compile now.
Index: Info.plist
==================================================================
--- Info.plist
+++ Info.plist
@@ -15,10 +15,10 @@
CFBundlePackageType
FMWK
CFBundleSignature
OBJFW
CFBundleVersion
- 0.6-dev
+ 0.6
CFBundleShortVersionString
- 0.6-dev
+ 0.6
Index: PLATFORMS
==================================================================
--- PLATFORMS
+++ PLATFORMS
@@ -6,31 +6,33 @@
+--------------------------+--------------+----------------------+---------+
| FreeBSD 8.0 | x86 | | old GNU |
+--------------------------+--------------+----------------------+---------+
| Haiku r41078 | x86 | GCC 4.4.4 | old GNU |
+--------------------------+--------------+----------------------+---------+
- | Linux 2.6.* | x86 | GCC 4.4.1 | old GNU |
- | Linux 2.6.* | x86 | GCC 4.6 | GNU |
- | Linux 2.6.* | x86 | LLVM/Clang r83252 | old GNU |
- | Linux 2.6.* | x86_64 | GCC 4.4.1 | old GNU |
+ | Linux 2.6.* / 3.* | x86 | GCC 4.4.1 | old GNU |
+ | Linux 2.6.* / 3.* | x86 | GCC 4.6 | GNU |
+ | Linux 2.6.* / 3.* | x86 | LLVM/Clang r83252 | old GNU |
+ | Linux 2.6.* / 3.* | x86_64 | GCC 4.4.1 | old GNU |
| Maemo 5 | arm | GCC 4.5.1 | old GNU |
+--------------------------+--------------+----------------------+---------+
- | iPhone OS 2.2.1 - 4.2 | arm | GCC 4.2 | Apple |
+ | iPhone OS 2.2.1 - 5.0 | arm | GCC 4.2 | Apple |
| Mac OS X 10.5 | ppc | GCC 4.0 + 4.2 | Apple |
| Mac OS X 10.5 | ppc64 | GCC 4.0 + 4.2 | Apple |
- | Mac OS X 10.5 - 10.6 | x86 | GCC 4.0 + 4.2 | Apple |
- | Mac OS X 10.5 - 10.6 | x86_64 | GCC 4.0 + 4.2 | Apple |
+ | Mac OS X 10.5 - 10.7 | x86 | GCC 4.0 + 4.2 | Apple |
+ | Mac OS X 10.5 - 10.7 | x86_64 | GCC 4.0 + 4.2 | Apple |
+--------------------------+--------------+----------------------+---------+
| MirBSD 10uAB - 10uAD | x86 | GCC 4.4.2 | old GNU |
| MirBSD 10uAD | x86 | LLVM/Clang r90573 | old GNU |
+--------------------------+--------------+----------------------+---------+
| NetBSD 4.0 | x86 | GCC 4.1.2 prerelease | old GNU |
| NetBSD 5.1 | x86_64 | GCC 4.1.3 prerelease | old GNU |
| NetBSD 5.1 | x86_64 | GCC 4.6 | GNU |
| NetBSD 5.1 | x86_64 | LLVM/Clang r134860 | old GNU |
+ | NetBSD 5.99.56 | x86_64 | GCC 4.5.3 | old GNU |
+ | NetBSD 5.99.56 | x86_64 | LLVM/Clang 2.9 | old GNU |
+--------------------------+--------------+----------------------+---------+
- | OpenBSD 4.6 - 4.7 | x86_64 | GCC 4.2.1 - 4.2.4 | old GNU |
+ | OpenBSD 4.6 - 5.0 | x86_64 | GCC 4.2.1 - 4.2.4 | old GNU |
+--------------------------+--------------+----------------------+---------+
| OpenSolaris 2009.06 | x86 | | old GNU |
| OpenSolaris 2009.06 | x86_64 | | old GNU |
+--------------------------+--------------+----------------------+---------+
| QNX 6.5.0 | x86 | GCC 4.6.1 | GNU |
Index: configure.ac
==================================================================
--- configure.ac
+++ configure.ac
@@ -1,6 +1,6 @@
-AC_INIT(ObjFW, 0.6-dev, js@webkeks.org)
+AC_INIT(ObjFW, 0.6, js@webkeks.org)
AC_CONFIG_SRCDIR(src)
AS_IF([test x"$host" = x"psp"], [
OBJCFLAGS="-G0 $OBJCFLAGS"
LIBS="$LIBS -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc"
@@ -475,24 +475,10 @@
])
AC_CHECK_FUNC(localtime_r, [
AC_DEFINE(HAVE_LOCALTIME_R, 1, [Whether we have localtime_r])
])
-AC_MSG_CHECKING(for tm_gmtoff in struct tm)
-AC_TRY_COMPILE([
- #define _GNU_SOURCE
- #include
-], [
- struct tm tm;
- tm.tm_gmtoff = 0;
-], [
- AC_DEFINE(STRUCT_TM_HAS_TM_GMTOFF, 1, [Whether struct tm has tm_gmtoff])
- AC_MSG_RESULT(yes)
-], [
- AC_MSG_RESULT(no)
-])
-
AC_CHECK_FUNC(kqueue, [
AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue])
AC_SUBST(OFSTREAMOBSERVER_KQUEUE_M, "OFStreamObserver_kqueue.m")
])
AC_CHECK_HEADER(poll.h, [
Index: src/OFApplication.h
==================================================================
--- src/OFApplication.h
+++ src/OFApplication.h
@@ -59,12 +59,15 @@
* signal-safe operations like setting a variable or calling a
* signal-safe function!
*/
- (void)applicationDidReceiveSIGINT;
+#ifndef _WIN32
/**
* \brief A method which is called when the application received a SIGHUP.
+ *
+ * This signal is not available on Windows.
*
* \warning You are not allowed to send any messages inside this method, as
* message dispatching is not signal-safe! You are only allowed to do
* signal-safe operations like setting a variable or calling a
* signal-safe function!
@@ -71,10 +74,12 @@
*/
- (void)applicationDidReceiveSIGHUP;
/**
* \brief A method which is called when the application received a SIGUSR1.
+ *
+ * This signal is not available on Windows.
*
* \warning You are not allowed to send any messages inside this method, as
* message dispatching is not signal-safe! You are only allowed to do
* signal-safe operations like setting a variable or calling a
* signal-safe function!
@@ -81,17 +86,20 @@
*/
- (void)applicationDidReceiveSIGUSR1;
/**
* \brief A method which is called when the application received a SIGUSR2.
+ *
+ * This signal is not available on Windows.
*
* \warning You are not allowed to send any messages inside this method, as
* message dispatching is not signal-safe! You are only allowed to do
* signal-safe operations like setting a variable or calling a
* signal-safe function!
*/
- (void)applicationDidReceiveSIGUSR2;
+#endif
@end
/**
* \brief Represents the application as an object.
*/
@@ -103,13 +111,15 @@
int *argc;
char ***argv;
@public
id delegate;
void (*SIGINTHandler)(id, SEL);
+#ifndef _WIN32
void (*SIGHUPHandler)(id, SEL);
void (*SIGUSR1Handler)(id, SEL);
void (*SIGUSR2Handler)(id, SEL);
+#endif
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, assign) OFString *programName;
@property (readonly, assign) OFArray *arguments;
Index: src/OFApplication.m
==================================================================
--- src/OFApplication.m
+++ src/OFApplication.m
@@ -16,12 +16,15 @@
#include "config.h"
#define OF_APPLICATION_M
+#include
#include
#include
+
+#include
#import "OFApplication.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
@@ -53,13 +56,15 @@
{ \
app->sig##Handler(app->delegate, \
@selector(applicationDidReceive##sig)); \
}
SIGNAL_HANDLER(SIGINT)
+#ifndef _WIN32
SIGNAL_HANDLER(SIGHUP)
SIGNAL_HANDLER(SIGUSR1)
SIGNAL_HANDLER(SIGUSR2)
+#endif
#undef SIGNAL_HANDLER
int
of_application_main(int *argc, char **argv[], Class cls)
{
@@ -258,13 +263,15 @@
@selector(applicationDidReceive##sig)]) \
signal(sig, handle##sig); \
else \
signal(sig, SIG_DFL);
REGISTER_SIGNAL(SIGINT)
+#ifndef _WIN32
REGISTER_SIGNAL(SIGHUP)
REGISTER_SIGNAL(SIGUSR1)
REGISTER_SIGNAL(SIGUSR2)
+#endif
#undef REGISTER_SIGNAL
}
- (void)run
{
Index: src/OFArray.h
==================================================================
--- src/OFArray.h
+++ src/OFArray.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include
#import "OFObject.h"
#import "OFCollection.h"
Index: src/OFAutoreleasePool.h
==================================================================
--- src/OFAutoreleasePool.h
+++ src/OFAutoreleasePool.h
@@ -37,14 +37,12 @@
*
* \param object The object to add to the autorelease pool
*/
+ (void)addObject: (id)object;
-/// \cond internal
+ (void)_releaseAll;
- (void)_addObject: (id)object;
-/// \endcond
/**
* \brief Releases all objects in the autorelease pool.
*
* This does not free the memory allocated to store pointers to the objects in
Index: src/OFDate.h
==================================================================
--- src/OFDate.h
+++ src/OFDate.h
@@ -54,13 +54,12 @@
/**
* \brief Creates a new OFDate with the specified string in the specified
* format.
*
- * The time zone used is UTC. If a time zone is specified anyway, an
- * OFInvalidFormatException is thrown. See +[dateWithLocalDateString:format:]
- * if you want to specify a time zone.
+ * The time zone used is UTC. See +[dateWithLocalDateString:format:] if you
+ * want local time.
*
* See the manpage for strftime for information on the format.
*
* \warning The format is currently limited to the following format specifiers:
* %%d, %%e, %%H, %%m, %%M, %%S, %%y, %%Y, %%, %%n and %%t.
@@ -74,12 +73,10 @@
/**
* \brief Creates a new OFDate with the specified string in the specified
* format.
*
- * If no time zone is specified, local time is assumed.
- *
* See the manpage for strftime for information on the format.
*
* \warning The format is currently limited to the following format specifiers:
* %%d, %%e, %%H, %%m, %%M, %%S, %%y, %%Y, %%, %%n and %%t.
*
Index: src/OFDate.m
==================================================================
--- src/OFDate.m
+++ src/OFDate.m
@@ -248,16 +248,10 @@
if (of_strptime([string UTF8String], [format UTF8String],
&tm) == NULL)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
-#ifdef STRUCT_TM_HAS_TM_GMTOFF
- if (tm.tm_gmtoff != 0)
- @throw [OFInvalidFormatException
- exceptionWithClass: isa];
-#endif
-
/* Years */
seconds = (int64_t)(tm.tm_year - 70) * 31536000;
/* Days of leap years, excluding the year to look at */
seconds += (((tm.tm_year + 1899) / 4) - 492) * 86400;
seconds -= (((tm.tm_year + 1899) / 100) - 19) * 86400;
Index: src/OFDictionary.h
==================================================================
--- src/OFDictionary.h
+++ src/OFDictionary.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include
#import "OFObject.h"
#import "OFCollection.h"
Index: src/OFFile.h
==================================================================
--- src/OFFile.h
+++ src/OFFile.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include
#import "OFSeekableStream.h"
Index: src/OFHTTPRequest.h
==================================================================
--- src/OFHTTPRequest.h
+++ src/OFHTTPRequest.h
@@ -280,15 +280,13 @@
@property (readonly) short statusCode;
@property (readonly, copy) OFDictionary *headers;
@property (readonly, retain) OFDataArray *data;
#endif
-/// \cond internal
- initWithStatusCode: (short)status
headers: (OFDictionary*)headers
data: (OFDataArray*)data;
-/// \endcond
/**
* \brief Returns the state code of the result of the HTTP request.
*
* \return The status code of the result of the HTTP request
Index: src/OFHTTPRequest.m
==================================================================
--- src/OFHTTPRequest.m
+++ src/OFHTTPRequest.m
@@ -186,10 +186,19 @@
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *scheme = [URL scheme];
OFTCPSocket *sock;
OFHTTPRequestResult *result;
+ OFString *line, *path;
+ OFMutableDictionary *serverHeaders;
+ OFDataArray *data;
+ OFEnumerator *keyEnumerator, *objectEnumerator;
+ OFString *key, *object, *contentLengthHeader;
+ int status;
+ const char *type = NULL;
+ char *buffer;
+ size_t bytesReceived;
if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"])
@throw [OFUnsupportedProtocolException exceptionWithClass: isa
URL: URL];
@@ -206,219 +215,194 @@
}
[delegate request: self
didCreateSocket: sock];
- @try {
- OFString *line, *path;
- OFMutableDictionary *serverHeaders;
- OFDataArray *data;
- OFEnumerator *keyEnumerator, *objectEnumerator;
- OFString *key, *object, *contentLengthHeader;
- int status;
- const char *type = NULL;
- char *buffer;
- size_t bytesReceived;
-
- [sock connectToHost: [URL host]
- port: [URL port]];
-
- /*
- * Work around a bug with packet bisection in lighttpd when
- * using HTTPS.
- */
- [sock setBuffersWrites: YES];
-
- if (requestType == OF_HTTP_REQUEST_TYPE_GET)
- type = "GET";
- if (requestType == OF_HTTP_REQUEST_TYPE_HEAD)
- type = "HEAD";
- if (requestType == OF_HTTP_REQUEST_TYPE_POST)
- type = "POST";
-
- if ([(path = [URL path]) isEqual: @""])
- path = @"/";
-
- if ([URL query] != nil)
- [sock writeFormat: @"%s %@?%@ HTTP/1.0\r\n",
- type, path, [URL query]];
- else
- [sock writeFormat: @"%s %@ HTTP/1.0\r\n", type, path];
-
- if ([URL port] == 80)
- [sock writeFormat: @"Host: %@\r\n", [URL host]];
- else
- [sock writeFormat: @"Host: %@:%d\r\n", [URL host],
- [URL port]];
-
- keyEnumerator = [headers keyEnumerator];
- objectEnumerator = [headers objectEnumerator];
-
- while ((key = [keyEnumerator nextObject]) != nil &&
- (object = [objectEnumerator nextObject]) != nil)
- [sock writeFormat: @"%@: %@\r\n", key, object];
-
- if (requestType == OF_HTTP_REQUEST_TYPE_POST) {
- if ([headers objectForKey: @"Content-Type"] == nil)
- [sock writeString: @"Content-Type: "
- @"application/x-www-form-urlencoded; "
- @"charset=UTF-8\r\n"];
-
- if ([headers objectForKey: @"Content-Length"] == nil)
- [sock writeFormat: @"Content-Length: %d\r\n",
- [queryString UTF8StringLength]];
- }
-
- [sock writeString: @"\r\n"];
-
- /* Work around a bug in lighttpd, see above */
- [sock flushWriteBuffer];
- [sock setBuffersWrites: NO];
-
- if (requestType == OF_HTTP_REQUEST_TYPE_POST)
- [sock writeString: queryString];
-
- /*
- * We also need to check for HTTP/1.1 since Apache always
- * declares the reply to be HTTP/1.1.
- */
- line = [sock readLine];
- if (![line hasPrefix: @"HTTP/1.0 "] &&
- ![line hasPrefix: @"HTTP/1.1 "])
- @throw [OFInvalidServerReplyException
- exceptionWithClass: isa];
-
- status = (int)[[line substringWithRange:
- of_range(9, 3)] decimalValue];
-
- serverHeaders = [OFMutableDictionary dictionary];
-
- while ((line = [sock readLine]) != nil) {
- OFString *key, *value;
- const char *line_c = [line UTF8String], *tmp;
-
- if ([line isEqual: @""])
- break;
-
- if ((tmp = strchr(line_c, ':')) == NULL)
- @throw [OFInvalidServerReplyException
- exceptionWithClass: isa];
-
- key = [OFString stringWithUTF8String: line_c
- length: tmp - line_c];
- normalize_key(key);
-
- do {
- tmp++;
- } while (*tmp == ' ');
-
- value = [OFString stringWithUTF8String: tmp];
-
- if ((redirects > 0 && (status == 301 || status == 302 ||
- status == 303) && [key isEqual: @"Location"]) &&
- (redirectsFromHTTPSToHTTPAllowed ||
- [scheme isEqual: @"http"] ||
- ![value hasPrefix: @"http://"])) {
- OFURL *new;
- BOOL follow;
-
- new = [OFURL URLWithString: value
- relativeToURL: URL];
-
- follow = [delegate request: self
- willFollowRedirectTo: new];
-
- if (!follow && delegate != nil) {
- [serverHeaders setObject: value
- forKey: key];
- continue;
- }
-
- new = [new retain];
- [URL release];
- URL = new;
-
- if (status == 303) {
- requestType = OF_HTTP_REQUEST_TYPE_GET;
- [queryString release];
- queryString = nil;
- }
-
- [pool release];
- pool = nil;
-
- return [self performWithRedirects:
- redirects - 1];
- }
-
- [serverHeaders setObject: value
- forKey: key];
- }
-
- [delegate request: self
- didReceiveHeaders: serverHeaders
- withStatusCode: status];
-
- if (storesData)
- data = [OFDataArray dataArray];
- else
- data = nil;
-
- buffer = [self allocMemoryWithSize: of_pagesize];
- bytesReceived = 0;
- @try {
- size_t len;
-
- while ((len = [sock readNBytes: of_pagesize
- intoBuffer: buffer]) > 0) {
- [delegate request: self
- didReceiveData: buffer
- withLength: len];
-
- bytesReceived += len;
- [data addNItems: len
- fromCArray: buffer];
- }
- } @finally {
- [self freeMemory: buffer];
- }
-
- if ((contentLengthHeader =
- [serverHeaders objectForKey: @"Content-Length"]) != nil) {
- intmax_t cl = [contentLengthHeader decimalValue];
-
- if (cl > SIZE_MAX)
- @throw [OFOutOfRangeException
- exceptionWithClass: isa];
-
- /*
- * We only want to throw on these status codes as we
- * will throw an OFHTTPRequestFailedException for all
- * other status codes later.
- */
- if (cl != bytesReceived && (status == 200 ||
- status == 301 || status == 302 || status == 303))
- @throw [OFTruncatedDataException
- exceptionWithClass: isa];
- }
-
- [serverHeaders makeImmutable];
-
- result = [[OFHTTPRequestResult alloc]
- initWithStatusCode: status
- headers: serverHeaders
- data: data];
-
- if (status != 200 && status != 301 && status != 302 &&
- status != 303)
- @throw [OFHTTPRequestFailedException
- exceptionWithClass: isa
- HTTPRequest: self
- result: result];
- } @finally {
- [pool release];
- }
+ [sock connectToHost: [URL host]
+ port: [URL port]];
+
+ /*
+ * Work around a bug with packet bisection in lighttpd when using
+ * HTTPS.
+ */
+ [sock setBuffersWrites: YES];
+
+ if (requestType == OF_HTTP_REQUEST_TYPE_GET)
+ type = "GET";
+ if (requestType == OF_HTTP_REQUEST_TYPE_HEAD)
+ type = "HEAD";
+ if (requestType == OF_HTTP_REQUEST_TYPE_POST)
+ type = "POST";
+
+ if ([(path = [URL path]) isEqual: @""])
+ path = @"/";
+
+ if ([URL query] != nil)
+ [sock writeFormat: @"%s %@?%@ HTTP/1.0\r\n",
+ type, path, [URL query]];
+ else
+ [sock writeFormat: @"%s %@ HTTP/1.0\r\n", type, path];
+
+ if ([URL port] == 80)
+ [sock writeFormat: @"Host: %@\r\n", [URL host]];
+ else
+ [sock writeFormat: @"Host: %@:%d\r\n", [URL host],
+ [URL port]];
+
+ keyEnumerator = [headers keyEnumerator];
+ objectEnumerator = [headers objectEnumerator];
+
+ while ((key = [keyEnumerator nextObject]) != nil &&
+ (object = [objectEnumerator nextObject]) != nil)
+ [sock writeFormat: @"%@: %@\r\n", key, object];
+
+ if (requestType == OF_HTTP_REQUEST_TYPE_POST) {
+ if ([headers objectForKey: @"Content-Type"] == nil)
+ [sock writeString: @"Content-Type: "
+ @"application/x-www-form-urlencoded; "
+ @"charset=UTF-8\r\n"];
+
+ if ([headers objectForKey: @"Content-Length"] == nil)
+ [sock writeFormat: @"Content-Length: %d\r\n",
+ [queryString UTF8StringLength]];
+ }
+
+ [sock writeString: @"\r\n"];
+
+ /* Work around a bug in lighttpd, see above */
+ [sock flushWriteBuffer];
+ [sock setBuffersWrites: NO];
+
+ if (requestType == OF_HTTP_REQUEST_TYPE_POST)
+ [sock writeString: queryString];
+
+ /*
+ * We also need to check for HTTP/1.1 since Apache always declares the
+ * reply to be HTTP/1.1.
+ */
+ line = [sock readLine];
+ if (![line hasPrefix: @"HTTP/1.0 "] && ![line hasPrefix: @"HTTP/1.1 "])
+ @throw [OFInvalidServerReplyException exceptionWithClass: isa];
+
+ status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];
+
+ serverHeaders = [OFMutableDictionary dictionary];
+
+ while ((line = [sock readLine]) != nil) {
+ OFString *key, *value;
+ const char *line_c = [line UTF8String], *tmp;
+
+ if ([line isEqual: @""])
+ break;
+
+ if ((tmp = strchr(line_c, ':')) == NULL)
+ @throw [OFInvalidServerReplyException
+ exceptionWithClass: isa];
+
+ key = [OFString stringWithUTF8String: line_c
+ length: tmp - line_c];
+ normalize_key(key);
+
+ do {
+ tmp++;
+ } while (*tmp == ' ');
+
+ value = [OFString stringWithUTF8String: tmp];
+
+ if ((redirects > 0 && (status == 301 || status == 302 ||
+ status == 303) && [key isEqual: @"Location"]) &&
+ (redirectsFromHTTPSToHTTPAllowed ||
+ [scheme isEqual: @"http"] ||
+ ![value hasPrefix: @"http://"])) {
+ OFURL *new;
+ BOOL follow;
+
+ new = [OFURL URLWithString: value
+ relativeToURL: URL];
+
+ follow = [delegate request: self
+ willFollowRedirectTo: new];
+
+ if (!follow && delegate != nil) {
+ [serverHeaders setObject: value
+ forKey: key];
+ continue;
+ }
+
+ new = [new retain];
+ [URL release];
+ URL = new;
+
+ if (status == 303) {
+ requestType = OF_HTTP_REQUEST_TYPE_GET;
+ [queryString release];
+ queryString = nil;
+ }
+
+ [pool release];
+
+ return [self performWithRedirects: redirects - 1];
+ }
+
+ [serverHeaders setObject: value
+ forKey: key];
+ }
+
+ [delegate request: self
+ didReceiveHeaders: serverHeaders
+ withStatusCode: status];
+
+ data = (storesData ? [OFDataArray dataArray] : nil);
+
+ buffer = [self allocMemoryWithSize: of_pagesize];
+ bytesReceived = 0;
+ @try {
+ size_t len;
+
+ while ((len = [sock readNBytes: of_pagesize
+ intoBuffer: buffer]) > 0) {
+ [delegate request: self
+ didReceiveData: buffer
+ withLength: len];
+
+ bytesReceived += len;
+ [data addNItems: len
+ fromCArray: buffer];
+ }
+ } @finally {
+ [self freeMemory: buffer];
+ }
+
+ if ((contentLengthHeader =
+ [serverHeaders objectForKey: @"Content-Length"]) != nil) {
+ intmax_t cl = [contentLengthHeader decimalValue];
+
+ if (cl > SIZE_MAX)
+ @throw [OFOutOfRangeException exceptionWithClass: isa];
+
+ /*
+ * We only want to throw on these status codes as we will throw
+ * an OFHTTPRequestFailedException for all other status codes
+ * later.
+ */
+ if (cl != bytesReceived && (status == 200 || status == 301 ||
+ status == 302 || status == 303))
+ @throw [OFTruncatedDataException
+ exceptionWithClass: isa];
+ }
+
+ [serverHeaders makeImmutable];
+
+ result = [[OFHTTPRequestResult alloc] initWithStatusCode: status
+ headers: serverHeaders
+ data: data];
+
+ if (status != 200 && status != 301 && status != 302 && status != 303)
+ @throw [OFHTTPRequestFailedException
+ exceptionWithClass: isa
+ HTTPRequest: self
+ result: result];
return [result autorelease];
}
@end
Index: src/OFMutableString.h
==================================================================
--- src/OFMutableString.h
+++ src/OFMutableString.h
@@ -12,13 +12,10 @@
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
-#include
-#include
-
#import "OFString.h"
/**
* \brief A class for storing and modifying strings.
*/
Index: src/OFMutableString.m
==================================================================
--- src/OFMutableString.m
+++ src/OFMutableString.m
@@ -17,10 +17,12 @@
#include "config.h"
#include
#include
#include
+
+#include
#import "OFString.h"
#import "OFMutableString_UTF8.h"
#import "OFAutoreleasePool.h"
Index: src/OFNumber.h
==================================================================
--- src/OFNumber.h
+++ src/OFNumber.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include
#import "OFObject.h"
#import "OFSerialization.h"
Index: src/OFPlugin.h
==================================================================
--- src/OFPlugin.h
+++ src/OFPlugin.h
@@ -32,12 +32,12 @@
{
of_plugin_handle_t handle;
}
/**
- * \brief Loads an OFPlugin from a file.
+ * \brief Loads a plugin from a file.
*
- * \param path Path to the OFPlugin file. The suffix is appended automatically.
- * \return The loaded OFPlugin
+ * \param path Path to the plugin file. The suffix is appended automatically.
+ * \return The loaded plugin
*/
-+ pluginFromFile: (OFString*)path;
++ (id)pluginFromFile: (OFString*)path;
@end
Index: src/OFPlugin.m
==================================================================
--- src/OFPlugin.m
+++ src/OFPlugin.m
@@ -35,11 +35,11 @@
# define dlsym(handle, symbol) GetProcAddress(handle, symbol)
# define dlclose(handle) FreeLibrary(handle)
#endif
@implementation OFPlugin
-+ pluginFromFile: (OFString*)path
++ (id)pluginFromFile: (OFString*)path
{
OFAutoreleasePool *pool;
OFMutableString *file;
of_plugin_handle_t handle;
OFPlugin *(*initPlugin)();
Index: src/OFProcess.h
==================================================================
--- src/OFProcess.h
+++ src/OFProcess.h
@@ -12,13 +12,18 @@
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
-#ifndef _WIN32
-# include
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
#endif
+
+#include
#import "OFStream.h"
#ifdef _WIN32
# include
Index: src/OFProcess.m
==================================================================
--- src/OFProcess.m
+++ src/OFProcess.m
@@ -87,11 +87,14 @@
switch ((pid = fork())) {
case 0:;
OFString **cArray = [arguments cArray];
size_t i, count = [arguments count];
- char **argv = alloca((count + 2) * sizeof(char*));
+ char **argv;
+
+ argv = [self allocMemoryForNItems: count + 2
+ ofSize: sizeof(char*)];
argv[0] = (char*)[programName cStringWithEncoding:
OF_STRING_ENCODING_NATIVE];
for (i = 0; i < count; i++)
Index: src/OFSeekableStream.h
==================================================================
--- src/OFSeekableStream.h
+++ src/OFSeekableStream.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include
#import "OFStream.h"
Index: src/OFSet.h
==================================================================
--- src/OFSet.h
+++ src/OFSet.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include
#import "OFObject.h"
#import "OFCollection.h"
Index: src/OFStream.h
==================================================================
--- src/OFStream.h
+++ src/OFStream.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include
#import "OFObject.h"
#import "OFString.h"
@@ -812,13 +819,11 @@
/**
* \brief Closes the stream.
*/
- (void)close;
-/// \cond internal
- (size_t)_readNBytes: (size_t)length
intoBuffer: (void*)buffer;
- (void)_writeNBytes: (size_t)length
fromBuffer: (const void*)buffer;
- (BOOL)_isWaitingForDelimiter;
-/// \endcond
@end
Index: src/OFStreamObserver.h
==================================================================
--- src/OFStreamObserver.h
+++ src/OFStreamObserver.h
@@ -176,17 +176,15 @@
* \param timeout The time to wait for an event, in milliseconds
* \return A boolean whether events occurred during the timeinterval
*/
- (BOOL)observeWithTimeout: (int)timeout;
-/// \cond internal
- (void)_addFileDescriptorForReading: (int)fd;
- (void)_addFileDescriptorForWriting: (int)fd;
- (void)_removeFileDescriptorForReading: (int)fd;
- (void)_removeFileDescriptorForWriting: (int)fd;
- (void)_processQueue;
- (BOOL)_processCache;
-/// \endcond
@end
@interface OFObject (OFStreamObserverDelegate)
@end
Index: src/OFStreamObserver_select.h
==================================================================
--- src/OFStreamObserver_select.h
+++ src/OFStreamObserver_select.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#ifdef OF_HAVE_SYS_SELECT_H
# include
#endif
Index: src/OFString+JSONValue.m
==================================================================
--- src/OFString+JSONValue.m
+++ src/OFString+JSONValue.m
@@ -94,11 +94,11 @@
skipWhitespaces(pointer, stop);
skipComment(pointer, stop);
}
}
-static OF_INLINE uint16_t
+static inline uint16_t
parseUnicodeEscape(const char *pointer, const char *stop)
{
uint16_t ret = 0;
char i;
@@ -123,11 +123,11 @@
}
return ret;
}
-static OF_INLINE OFString*
+static inline OFString*
parseString(const char *restrict *pointer, const char *stop)
{
char *buffer;
size_t i = 0;
@@ -257,11 +257,11 @@
free(buffer);
return nil;
}
-static OF_INLINE OFMutableArray*
+static inline OFMutableArray*
parseArray(const char *restrict *pointer, const char *stop)
{
OFMutableArray *array = [OFMutableArray array];
if (++(*pointer) >= stop)
@@ -299,11 +299,11 @@
(*pointer)++;
return array;
}
-static OF_INLINE OFMutableDictionary*
+static inline OFMutableDictionary*
parseDictionary(const char *restrict *pointer, const char *stop)
{
OFMutableDictionary *dictionary = [OFMutableDictionary dictionary];
if (++(*pointer) >= stop)
@@ -351,11 +351,11 @@
(*pointer)++;
return dictionary;
}
-static OF_INLINE OFNumber*
+static inline OFNumber*
parseNumber(const char *restrict *pointer, const char *stop)
{
BOOL hasDecimal = NO;
size_t i;
OFString *string;
Index: src/OFString.h
==================================================================
--- src/OFString.h
+++ src/OFString.h
@@ -12,11 +12,17 @@
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
-#include
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
+
#include
#include
#import "OFObject.h"
#import "OFSerialization.h"
Index: src/OFString.m
==================================================================
--- src/OFString.m
+++ src/OFString.m
@@ -20,14 +20,10 @@
#include
#include
#include
-#ifdef _WIN32
-# include
-#endif
-
#import "OFString.h"
#import "OFString_UTF8.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFFile.h"
@@ -1469,37 +1465,42 @@
return new;
}
- (BOOL)hasPrefix: (OFString*)prefix
{
- OFAutoreleasePool *pool;
of_unichar_t *tmp;
const of_unichar_t *prefixString;
size_t prefixLength;
int compare;
if ((prefixLength = [prefix length]) > [self length])
return NO;
- tmp = alloca(prefixLength * sizeof(of_unichar_t));
- [self getCharacters: tmp
- inRange: of_range(0, prefixLength)];
-
- pool = [[OFAutoreleasePool alloc] init];
-
- prefixString = [prefix unicodeString];
- compare = memcmp(tmp, prefixString,
- prefixLength * sizeof(of_unichar_t));
-
- [pool release];
+ tmp = [self allocMemoryForNItems: prefixLength
+ ofSize: sizeof(of_unichar_t)];
+ @try {
+ OFAutoreleasePool *pool;
+
+ [self getCharacters: tmp
+ inRange: of_range(0, prefixLength)];
+
+ pool = [[OFAutoreleasePool alloc] init];
+
+ prefixString = [prefix unicodeString];
+ compare = memcmp(tmp, prefixString,
+ prefixLength * sizeof(of_unichar_t));
+
+ [pool release];
+ } @finally {
+ [self freeMemory: tmp];
+ }
return !compare;
}
- (BOOL)hasSuffix: (OFString*)suffix
{
- OFAutoreleasePool *pool;
of_unichar_t *tmp;
const of_unichar_t *suffixString;
size_t length, suffixLength;
int compare;
@@ -1506,21 +1507,29 @@
if ((suffixLength = [suffix length]) > [self length])
return NO;
length = [self length];
- tmp = alloca(suffixLength * sizeof(of_unichar_t));
- [self getCharacters: tmp
- inRange: of_range(length - suffixLength, suffixLength)];
-
- pool = [[OFAutoreleasePool alloc] init];
-
- suffixString = [suffix unicodeString];
- compare = memcmp(tmp, suffixString,
- suffixLength * sizeof(of_unichar_t));
-
- [pool release];
+ tmp = [self allocMemoryForNItems: suffixLength
+ ofSize: sizeof(of_unichar_t)];
+ @try {
+ OFAutoreleasePool *pool;
+
+ [self getCharacters: tmp
+ inRange: of_range(length - suffixLength,
+ suffixLength)];
+
+ pool = [[OFAutoreleasePool alloc] init];
+
+ suffixString = [suffix unicodeString];
+ compare = memcmp(tmp, suffixString,
+ suffixLength * sizeof(of_unichar_t));
+
+ [pool release];
+ } @finally {
+ [self freeMemory: tmp];
+ }
return !compare;
}
- (OFArray*)componentsSeparatedByString: (OFString*)delimiter
Index: src/OFString_UTF8.m
==================================================================
--- src/OFString_UTF8.m
+++ src/OFString_UTF8.m
@@ -18,10 +18,12 @@
#include
#include
#include
#include
+
+#include
#import "OFString_UTF8.h"
#import "OFMutableString_UTF8.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
Index: src/OFTCPSocket+SOCKS5.h
==================================================================
--- src/OFTCPSocket+SOCKS5.h
+++ src/OFTCPSocket+SOCKS5.h
@@ -23,10 +23,8 @@
#ifdef __cplusplus
}
#endif
@interface OFTCPSocket (SOCKS5)
-/// \cond internal
- (void)_SOCKS5ConnectToHost: (OFString*)host
port: (uint16_t)port;
-/// \endcond
@end
Index: src/OFTCPSocket.h
==================================================================
--- src/OFTCPSocket.h
+++ src/OFTCPSocket.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#ifndef _WIN32
# include
# include
# include
Index: src/asprintf.h
==================================================================
--- src/asprintf.h
+++ src/asprintf.h
@@ -13,10 +13,17 @@
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "objfw-defs.h"
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#ifndef OF_HAVE_ASPRINTF
# include
# ifdef __cplusplus
Index: src/base64.h
==================================================================
--- src/base64.h
+++ src/base64.h
@@ -13,10 +13,17 @@
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "objfw-defs.h"
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#ifdef OF_OBJFW_RUNTIME
# import
#else
# import
Index: src/macros.h
==================================================================
--- src/macros.h
+++ src/macros.h
@@ -14,17 +14,10 @@
* file.
*/
#import "OFObject.h"
-#ifndef __STDC_LIMIT_MACROS
-# define __STDC_LIMIT_MACROS
-#endif
-#ifndef __STDC_CONSTANT_MACROS
-# define __STDC_CONSTANT_MACROS
-#endif
-
#include
#include
#if defined(OF_APPLE_RUNTIME) || defined(OF_GNU_RUNTIME)
# import
Index: src/of_asprintf.h
==================================================================
--- src/of_asprintf.h
+++ src/of_asprintf.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include
#import "macros.h"
Index: src/of_strptime.h
==================================================================
--- src/of_strptime.h
+++ src/of_strptime.h
@@ -11,10 +11,17 @@
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
+
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include
#ifdef __cplusplus
extern "C" {
Index: utils/objfw-compile
==================================================================
--- utils/objfw-compile
+++ utils/objfw-compile
@@ -84,11 +84,11 @@
exit 1
fi
shift
- if ! echo "$1" | grep "^[0-9]\+\.[0-9]\+" >/dev/null
+ if ! echo "$1" | grep "^[0-9]\+\.[0-9]\+$" >/dev/null
then
echo "$1 is not a valid library version!"
exit 1
fi
Index: utils/objfw-config.in
==================================================================
--- utils/objfw-config.in
+++ utils/objfw-config.in
@@ -35,11 +35,11 @@
LIBS="-L${libdir} -lobjfw @LIBS@"
PLUGIN_CFLAGS="@PLUGIN_CFLAGS@"
PLUGIN_LDFLAGS="@PLUGIN_LDFLAGS@"
PLUGIN_SUFFIX="@PLUGIN_SUFFIX@"
PROG_SUFFIX="@EXEEXT@"
-VERSION="0.6-dev"
+VERSION="0.6"
show_help() {
cat <<__EOF__
objfw-config: Available arguments are: