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: ObjFW.xcodeproj/project.pbxproj ================================================================== --- ObjFW.xcodeproj/project.pbxproj +++ ObjFW.xcodeproj/project.pbxproj @@ -202,11 +202,11 @@ 4B3D23EB1337FCB000DD29B8 /* unicode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B67998C1099E7C50041064A /* unicode.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3D23EE1337FFD000DD29B8 /* of_asprintf.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB50DD012F863C700C9393F /* of_asprintf.m */; }; 4B3D5694139A617D0010A78F /* OFSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B3D5693139A617D0010A78F /* OFSerializationTests.m */; }; 4B45355313DCFE1E0037AB4D /* OFCountedSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B45355113DCFE1E0037AB4D /* OFCountedSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B45355413DCFE1E0037AB4D /* OFCountedSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B45355213DCFE1E0037AB4D /* OFCountedSet.m */; }; - 4B48B95414DC23B100546D39 /* OFXMLProcessingInstructions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B48B95214DC23B100546D39 /* OFXMLProcessingInstructions.h */; }; + 4B48B95414DC23B100546D39 /* OFXMLProcessingInstructions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B48B95214DC23B100546D39 /* OFXMLProcessingInstructions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B48B95514DC23B100546D39 /* OFXMLProcessingInstructions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B48B95314DC23B100546D39 /* OFXMLProcessingInstructions.m */; }; 4B49EA66143B39CE0005BBC6 /* OFXMLNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B49EA65143B39CE0005BBC6 /* OFXMLNodeTests.m */; }; 4B49EA6D143B3A090005BBC6 /* OFXMLCDATA.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B49EA67143B3A090005BBC6 /* OFXMLCDATA.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B49EA6E143B3A090005BBC6 /* OFXMLCDATA.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B49EA68143B3A090005BBC6 /* OFXMLCDATA.m */; }; 4B49EA6F143B3A090005BBC6 /* OFXMLCharacters.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B49EA69143B3A090005BBC6 /* OFXMLCharacters.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1183,10 +1183,11 @@ 4B3D23E11337FCB000DD29B8 /* OFXMLElement.h in Headers */, 4BB25E8C139C388A00F574EA /* OFXMLElement+Serialization.h in Headers */, 4B3D23E21337FCB000DD29B8 /* OFXMLElementBuilder.h in Headers */, 4B11005C14329B9A003A45D8 /* OFXMLNode.h in Headers */, 4B3D23E31337FCB000DD29B8 /* OFXMLParser.h in Headers */, + 4B48B95414DC23B100546D39 /* OFXMLProcessingInstructions.h in Headers */, 4B3D23E41337FCB000DD29B8 /* ObjFW.h in Headers */, 4B3D23E51337FCB000DD29B8 /* asprintf.h in Headers */, 4B3D23E61337FCB000DD29B8 /* atomic.h in Headers */, 4B3D23E71337FCB000DD29B8 /* base64.h in Headers */, 4B3D23E81337FCB000DD29B8 /* macros.h in Headers */, @@ -1259,11 +1260,10 @@ 4B83F0F4142FDEFD00E4A821 /* OFStreamObserver_kqueue.h in Headers */, 4B64D6EF1425381E007BDFB1 /* OFStreamObserver_poll.h in Headers */, 4B64D6F11425381E007BDFB1 /* OFStreamObserver_select.h in Headers */, 4B552554147AA5DB0003BF47 /* OFString_UTF8.h in Headers */, 4BD653C5143B8489006182F0 /* OFTCPSocket+SOCKS5.h in Headers */, - 4B48B95414DC23B100546D39 /* OFXMLProcessingInstructions.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ @@ -1477,10 +1477,11 @@ 4B3D23AF1337FC0D00DD29B8 /* OFXMLElement.m in Sources */, 4BB25E8D139C388A00F574EA /* OFXMLElement+Serialization.m in Sources */, 4B3D23B01337FC0D00DD29B8 /* OFXMLElementBuilder.m in Sources */, 4B11005D14329B9A003A45D8 /* OFXMLNode.m in Sources */, 4B3D23B11337FC0D00DD29B8 /* OFXMLParser.m in Sources */, + 4B48B95514DC23B100546D39 /* OFXMLProcessingInstructions.m in Sources */, 4B3D23B31337FC0D00DD29B8 /* base64.m in Sources */, 4B3D23B41337FC0D00DD29B8 /* iso_8859_15.m in Sources */, 4B3D23B51337FC0D00DD29B8 /* foundation-compat.m in Sources */, 4B3D23EE1337FFD000DD29B8 /* of_asprintf.m in Sources */, 4BA355BA14879BDD00442EF4 /* of_strptime.m in Sources */, @@ -1535,11 +1536,10 @@ 4B55A104133ABEA900B58A93 /* OFThreadStillRunningException.m in Sources */, 4B17FFAA133A34E7003E6DCD /* OFTruncatedDataException.m in Sources */, 4B17FFB6133A375B003E6DCD /* OFUnboundNamespaceException.m in Sources */, 4B17FFB2133A3664003E6DCD /* OFUnsupportedProtocolException.m in Sources */, 4B55A117133AC24600B58A93 /* OFWriteFailedException.m in Sources */, - 4B48B95514DC23B100546D39 /* OFXMLProcessingInstructions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 4BF33AEC133807310059CEF7 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -1549,10 +1549,11 @@ 4BF33AFD133807A20059CEF7 /* OFBlockTests.m in Sources */, 4BF33AFE133807A20059CEF7 /* OFDataArrayTests.m in Sources */, 4BF33AFF133807A20059CEF7 /* OFDateTests.m in Sources */, 4BF33B00133807A20059CEF7 /* OFDictionaryTests.m in Sources */, 4BF33B02133807A20059CEF7 /* OFHTTPRequestTests.m in Sources */, + 4BAA60C814D09699006F068D /* OFJSONTests.m in Sources */, 4BF33B03133807A20059CEF7 /* OFListTests.m in Sources */, 4BF33B04133807A20059CEF7 /* OFMD5HashTests.m in Sources */, 4BF33B05133807A20059CEF7 /* OFNumberTests.m in Sources */, 4BF33B06133807A20059CEF7 /* OFObjectTests.m in Sources */, 4BF33B07133807A20059CEF7 /* OFPluginTests.m in Sources */, @@ -1567,11 +1568,10 @@ 4BF33B0E133807A20059CEF7 /* OFXMLElementBuilderTests.m in Sources */, 4B49EA66143B39CE0005BBC6 /* OFXMLNodeTests.m in Sources */, 4BF33B10133807A20059CEF7 /* OFXMLParserTests.m in Sources */, 4BF33B11133807A20059CEF7 /* PropertiesTests.m in Sources */, 4BF33B12133807A20059CEF7 /* TestsAppDelegate.m in Sources */, - 4BAA60C814D09699006F068D /* OFJSONTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ 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/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -538,12 +538,11 @@ lastPageByte = of_pagesize - 1; newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) data = [self resizeMemory: data - toNItems: newSize - ofSize: itemSize]; + toSize: newSize]; memmove(data + (index + nItems) * itemSize, data + index * itemSize, (count - index) * itemSize); memcpy(data + index * itemSize, cArray, nItems * itemSize); 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/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -245,24 +245,30 @@ - mutableCopy { return [[OFMutableDictionary alloc] initWithDictionary: self]; } -- (BOOL)isEqual: (id)dictionary +- (BOOL)isEqual: (id)object { + OFDictionary *otherDictionary; OFAutoreleasePool *pool; OFEnumerator *enumerator; id key; - if ([dictionary count] != [self count]) + if (![object isKindOfClass: [OFDictionary class]]) + return NO; + + otherDictionary = object; + + if ([otherDictionary count] != [self count]) return NO; pool = [[OFAutoreleasePool alloc] init]; enumerator = [self keyEnumerator]; while ((key = [enumerator nextObject]) != nil) { - id object = [dictionary objectForKey: key]; + id object = [otherDictionary objectForKey: key]; if (object == nil || ![object isEqual: [self objectForKey: key]]) { [pool release]; return NO; 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,198 @@ } [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) { + [result release]; + @throw [OFHTTPRequestFailedException + exceptionWithClass: isa + HTTPRequest: self + result: result]; + } + + [pool release]; 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/atomic.h ================================================================== --- src/atomic.h +++ src/atomic.h @@ -81,15 +81,25 @@ static OF_INLINE void* of_atomic_add_ptr(void* volatile *p, intptr_t i) { #if !defined(OF_THREADS) return (*(char* volatile*)p += i); -#elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) +#elif defined(OF_X86_ASM) __asm__ ( "lock\n\t" "xaddl %0, %2\n\t" "addl %1, %0" + : "+&r"(i) + : "r"(i), "m"(*p) + ); + + return (void*)i; +#elif defined(OF_AMD64_ASM) + __asm__ ( + "lock\n\t" + "xaddq %0, %2\n\t" + "addq %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return (void*)i; @@ -163,16 +173,27 @@ static OF_INLINE void* of_atomic_sub_ptr(void* volatile *p, intptr_t i) { #if !defined(OF_THREADS) return (*(char* volatile*)p -= i); -#elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) +#elif defined(OF_X86_ASM) __asm__ ( "negl %0\n\t" "lock\n\t" "xaddl %0, %2\n\t" "subl %1, %0" + : "+&r"(i) + : "r"(i), "m"(*p) + ); + + return (void*)i; +#elif defined(OF_AMD64_ASM) + __asm__ ( + "negq %0\n\t" + "lock\n\t" + "xaddq %0, %2\n\t" + "subq %1, %0" : "+&r"(i) : "r"(i), "m"(*p) ); return (void*)i; 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: