Giter Site home page Giter Site logo

objfw / objfw Goto Github PK

View Code? Open in Web Editor NEW
226.0 17.0 25.0 28.75 MB

[Official Mirror] A portable framework for the Objective-C language.

Home Page: https://objfw.nil.im

License: GNU Lesser General Public License v3.0

Makefile 0.87% Shell 0.50% Objective-C 92.97% C 0.96% Assembly 2.41% M4 2.07% Pawn 0.07% Mathematica 0.15%
objective-c framework portable objfw linux macos ios android windows freebsd

objfw's Introduction

There are three ways you are probably reading this right now:

  • On ObjFW's homepage, via Fossil's web interface
  • On GitHub
  • Via an editor or pager, by opening README.md from a clone or tarball

ObjFW is developed using Fossil, so if you are reading this on GitHub or any other place, you are most likely using a mirror.

Table of Contents

What is ObjFW?

ObjFW is a portable, lightweight framework for the Objective-C language. It enables you to write an application in Objective-C that will run on any platform supported by ObjFW without having to worry about differences between operating systems or various frameworks you would otherwise need if you want to be portable.

It supports all modern Objective-C features when using Clang, but is also compatible with GCC ≥ 4.6 to allow maximum portability.

ObjFW is intentionally incompatible with Foundation. This has two reasons:

  • GNUstep already provides a reimplementation of Foundation, which is only compatible to a certain degree. This means that a developer still needs to care about differences between frameworks if they want to be portable. The idea behind ObjFW is that a developer does not need to concern themselves with portability and making sure their code works with multiple frameworks: Instead, if it works it ObjFW on one platform, they can reasonably expect it to also work with ObjFW on another platform. ObjFW behaving differently on different operating systems (unless inevitable because it is a platform-specific part, like the Windows Registry) is considered a bug and will be fixed.
  • Foundation predates a lot of modern Objective-C concepts. The most prominent one is exceptions, which are only used in Foundation as a replacement for abort(). This results in cumbersome error handling, especially in initializers, which in Foundation only return nil on error with no indication of what went wrong. It also means that the return of every init call needs to be checked against nil. But in the wild, nobody actually checks each and every return from init against nil, leading to bugs. ObjFW fixes this by making exceptions a first class citizen.

ObjFW also comes with its own lightweight and extremely fast Objective-C runtime, which in real world use cases was found to be significantly faster than both GNU's and Apple's runtime.

Installation

ObjFW packages are available for various operating systems and can be installed as following:

Operating System Command
Alpine Linux doas apk add objfw
CRUX sudo prt-get depinst objfw
Fedora sudo dnf install objfw
FreeBSD sudo pkg install objfw
Haiku pkgman install objfw
Haiku (gcc2h) pkgman install objfw_x86
macOS (Homebrew) brew install objfw
macOS (pkgsrc) cd $PKGSRCDIR/devel/objfw && make install
NetBSD cd /usr/pkgsrc/devel/objfw && make install
OpenBSD doas pkg_add objfw
OpenIndiana sudo pkg install developer/objfw
Windows (MSYS2/CLANG64) pacman -S mingw-w64-clang-x86_64-objfw
Windows (MSYS2/CLANGARM64) pacman -S mingw-w64-clang-aarch64-objfw
Windows (MSYS2/UCRT64) pacman -S mingw-w64-ucrt-x86_64-objfw
Windows (MSYS2/MINGW32) pacman -S mingw-w64-i686-objfw

If your operating system is not listed, you can build ObjFW from source.

License

ObjFW is released under the GNU Lesser General Public License version 3.0.

If this license does not work for you, contact me and we can find a solution.

Releases

Releases of ObjFW, as well as change logs and the accompanying documentation, can be found here.

Cloning the repository

ObjFW is developed in a Fossil repository, with automatic incremental exports to Git. This means you can either clone the Fossil repository or the Git repository - it does not make a huge difference. The main advantage of cloning the Fossil repository over cloning the Git repository is that you also get all the tickets, wiki pages, etc.

Fossil

Clone the Fossil repository like this:

fossil clone https://objfw.nil.im

You can then use Fossil's web interface to browse the timeline, tickets, wiki pages, etc.:

cd objfw
fossil ui

In order to verify the signature of the currently checked out checkin, you can use:

fossil artifact current | gpg --verify

Please note that not all checkins are signed, as the signing key only resides on trusted systems. This means that checkins I perform on e.g. Windows are unsigned. However, usually it should not take long until there is another signed checkin. Alternatively, you can go back until the last signed checkin and review changes from there on.

Git

To clone the Git repository, use the following:

git clone https://github.com/ObjFW/ObjFW

Git commits are not signed, so if you want to check the signature of an individual commit, branch head or tag, please use Fossil.

Building from source

To build ObjFW from source and install it, just run the following commands:

./configure
make
make check
sudo make install

In case you checked out ObjFW from the Fossil or Git repository, you need to run the following command first:

./autogen.sh

macOS and iOS

Building as a framework

When building for macOS or iOS, everything is built as a .framework by default if --disable-shared has not been specified to ./configure. The frameworks will end up in $PREFIX/Library/Frameworks.

To build for macOS, just follow the regular instructions above.

To build for iOS, follow the regular instructions, but instead of ./configure do something like this:

clang="xcrun --sdk iphoneos clang"
export OBJC="$clang -arch arm64e -arch arm64"
export OBJCPP="$clang -arch arm64e -E"
export IPHONEOS_DEPLOYMENT_TARGET="10.0"
./configure --prefix=/usr/local/ios --host=arm64-apple-darwin

To build for the iOS simulator, follow the regular instructions, but instead of ./configure use something like this:

clang="xcrun --sdk iphonesimulator clang"
export OBJC="$clang -arch $(uname -m)"
export IPHONEOS_DEPLOYMENT_TARGET="10.0"
./configure --prefix=/usr/local/iossim --host=$(uname -m)-apple-darwin

Using the macOS or iOS framework in Xcode

To use the macOS framework in Xcode, you need to add the .frameworks to your project and add the following flags to Other C Flags:

-fconstant-string-class=OFConstantString -fno-constant-cfstrings

Broken Xcode versions

Some versions of Xcode shipped with a version of Clang that ignores -fconstant-string-class=OFConstantString. This will manifest in an error like this:

OFAllocFailedException.m:94:10: error: cannot find interface declaration for
      'NSConstantString'
        return @"Allocating an object failed!";
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Unfortunately, there is no workaround for this other than to upgrade/downgrade Xcode or to build upstream Clang yourself.

In particular, Xcode 11 Beta 1 to Beta 3 are known to be affected. While Xcode 11 Beta 4 to Xcode 11.3 work, the bug was unfortunately reintroduced in Xcode 11.4.1 and was only fixed in Xcode 12 Beta 1.

You can get older versions of Xcode here by clicking on "More" in the top-right corner.

Windows

Windows is only officially supported when following these instructions, as there are many MinGW versions that behave slightly differently and often cause problems.

Getting MSYS2

The first thing to install is MSYS2 to provide a basic UNIX-like environment for Windows. Unfortunately, the binaries are not signed, so make sure you download it via HTTPS. However, packages you download and install via MSYS2 are cryptographically signed.

Setting up MSYS2

MSYS2 currently supports 7 different environments. All of them except for the one called just "MSYS" are supported, but which packages you need to install depends on the environment(s) you want to use. If you only want to target Windows 10 and newer, the CLANG64 and CLANG32 environments are the recommended ones.

For CLANG64, use:

pacman -Syu mingw-w64-clang-x86_64-clang \
            mingw-w64-clang-x86_64-fossil \
            mingw-w64-clang-x86_64-openssl

For CLANG32, use:

pacman -Syu mingw-w64-clang-i686-clang \
            mingw-w64-clang-i686-fossil \
            mingw-w64-clang-i686-openssl

For CLANGARM64, use (you need to use Fossil via another environment):

pacman -Syu mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-openssl

For MINGW64, use:

pacman -Syu mingw-w64-x86_64-clang \
            mingw-w64-x86_64-fossil \
            mingw-w64-x86_64-openssl

For MINGW32, use:

pacman -Syu mingw-w64-i686-clang \
            mingw-w64-i686-fossil \
            mingw-w64-i686-openssl

For UCRT64, use:

pacman -Syu mingw-w64-ucrt-x86_64-clang \
            mingw-w64-ucrt-x86_64-fossil \
            mingw-w64-ucrt-x86_64-openssl

When using pacman to install the packages, pacman might tell you to close the window. If it does so, close the window, restart MSYS2 and execute the pacman command again.

There is nothing wrong with installing multiple environments, as MSYS2 has created shortcuts for each of them in your start menu. Just make sure to use the correct shortcut for the environment you want to use.

Finally, install a few more things that are common between all environments:

pacman -S autoconf automake make

Getting, building and installing ObjFW

Start the MSYS2 using the shortcut for the environment you want to use and check out ObjFW:

fossil clone https://objfw.nil.im

You can also download a release tarball if you want. Now cd to the newly checked out repository and build and install it:

./autogen.sh && ./configure && make -j16 install

If everything was successful, you can now build projects using ObjFW for Windows using the normal objfw-compile and friends.

Nintendo DS, Nintendo 3DS and Wii

Download and install devkitPro.

Nintendo DS

Follow the normal process, but instead of ./configure run:

./configure --host=arm-none-eabi --with-nds

Nintendo 3DS

Follow the normal process, but instead of ./configure run:

./configure --host=arm-none-eabi --with-3ds

Wii

Follow the normal process, but instead of ./configure run:

./configure --host=powerpc-eabi --with-wii

Amiga

Install amiga-gcc. Then follow the normal process, but instead of ./configure run:

./configure --host=m68k-amigaos

Writing your first application with ObjFW

To create your first, empty application, you can use objfw-new:

objfw-new --app MyFirstApp

This creates a file MyFirstApp.m. The -[applicationDidFinishLaunching:] method is called as soon as ObjFW finished all initialization. Use this as the entry point to your own code. For example, you could add the following line there to create a "Hello World":

[OFStdOut writeLine: @"Hello World!"];

You can compile your new app using objfw-compile:

objfw-compile -o MyFirstApp MyFirstApp.m

objfw-compile is a tool that allows building applications and libraries using ObjFW without needing a full-blown build system. If you want to use your own build system, you can get the necessary flags from objfw-config.

Documentation

You can find the documentation for released versions of ObjFW here.

In order to build the documentation yourself (necessary to have documentation for trunk / master), you need to have Doxygen installed. Once installed, you can build the documentation from the root directory of the repository:

make docs

Bugs and feature requests

If you find any bugs or have feature requests, please file a new bug in the bug tracker.

Alternatively, feel free to send a mail to [email protected]!

Support and community

If you have any questions about ObjFW or would like to talk to other ObjFW users, the following venues are available:

Please don't hesitate to join any or all of those!

Donating

If you want to donate to ObjFW, you can read about possible ways to do so here.

Thanks

  • Thank you to Jonathan Neuschäfer for reviewing the entirety (all 84k LoC at the time) of ObjFW's codebase in 2017!
  • Thank you to Hill Ma for donating an M1 Mac Mini to the project in 2022!

Commercial use

If for whatever reason the terms of GNU Lesser General Public License version 3.0 don't work for you, a proprietary license for ObjFW including support is available upon request. Just write a mail to [email protected] and we can find a reasonable solution for both parties.

objfw's People

Contributors

midar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

objfw's Issues

Unsolvable Block retain cycle in non ARC code

In simple code like this:

#import <ObjFW/ObjFW.h>

typedef void (^SomeBlock)();

@interface BlocksStorage: OFObject
{
    @private
    OFMutableDictionary* _storage;
}

- (void)storeBlock:(SomeBlock) block;

- (void)printInfo;

- (void)executeBlock;

@end

@interface BlockProperty: OFObject

@property(copy)SomeBlock MyBlock;

@end

@interface Worker: OFObject

@property(retain)BlocksStorage* MyStorage;

@end

int main (int argc, char** argv)
{
    BlockProperty* test1 = [BlockProperty new];
    of_log(@"%@ retained %d times", test1, [test1 retainCount]);
    test1.MyBlock();
    Worker* test2 = [Worker new];
    of_log(@"%@ retained % times", test2, [test2 retainCount]);
    [test2.MyStorage executeBlock];

    [test1 release];
    [test2 release];
    of_log(@"%@ retained %d times", test1, [test1 retainCount]);
    of_log(@"%@ retained % times", test2, [test2 retainCount]);

    return 0;
}

@implementation BlockProperty

- (id)init
{
    self = [super init];

    //BlockProperty* weakSelf = self; Not resolve problem
    //id weakSelf = self; Not resolve problem

    self.MyBlock = ^{
        of_log(@"This is Object with Block propery from %@", self); //RETAIN CYCLE
    };

    return self;
}
#if __has_feature(objc_arc)
#else
- (void)dealloc 
{
    [self.MyBlock release];
    [super dealloc];
}
#endif
@end;

@implementation BlocksStorage

- (id)init
{
    self = [super init];

    _storage = [OFMutableDictionary new];

    return self;
}

- (void)storeBlock:(SomeBlock)block
{
    [_storage setObject:[block copy] forKey:@"test"];
}

- (void)printInfo
{
    of_log(@"I am storage of blocks");
}
#if __has_feature(objc_arc)
#else
- (void)dealloc
{
    [_storage release];
    [super dealloc];
}
#endif

- (void)executeBlock
{
    for (SomeBlock action in [_storage allObjects]) {
        action();
    }
}

@end

@implementation Worker

- (id)init
{
    self = [super init];

    self.MyStorage = [BlocksStorage new];

    [self.MyStorage storeBlock: ^{
        of_log(@"I am block from %@", self);
    }];

    return self;
}
#if __has_feature(objc_arc)
#else
- (void)dealloc
{
    [self.MyStorage release];

    [super dealloc];
}
#endif

@end

Blocks capture "self" pointer from context and increase retain counter. Usage of strong local variable or __block variable cant resolve this problem. (http://stackoverflow.com/questions/7853915/how-do-i-avoid-capturing-self-in-blocks-when-implementing-an-api)

Is there some solution for this problem?

System:
Windows 7 SP1 / Windows 8.1
Mingw32 with gcc 4.9.2 dwarf EH as toolchain and Clang 3.6 as compiler.

P.S. Sorry for my english

// Edit(Midar): Added formatting for code so it doesn't get rendered as markdown.

Compilation error for x86_64-w64-mingw32 target

class.m:436:37: error: implicit conversion loses integer precision: 'unsigned long long' to 'long' [-Werror,-Wshorten-64-to-32]
superclass->instance_size : 0) + extra_bytes;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
class.m:446:42: error: implicit conversion loses integer precision: 'unsigned long long' to 'long' [-Werror,-Wshorten-64-to-32]
superclass->isa->instance_size : 0) + extra_bytes;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
2 errors generated.
Failed to compile class.m!

macOS 10.12 deprecates NSStartSearchPathEnumeration for sysdir_start_search_path_enumeration

I know there may not be support yet but opening the project after a failed build yields several Lexicon errors.
The following build commands failed: CompileC build/ObjFW.build/Release/ObjFW.build/Objects-normal/x86_64/OFSystemInfo.o src/OFSystemInfo.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler Ld build/Release/ObjFW.framework/Versions/A/ObjFW normal x86_64 (2 failures)

Invalid __block type specifier behavior

On Windows and Mac OS X (and maybe Linux) __block variable behavior is not corresponding to Apple (and Clang) documentation.

Simple code tested on Mac OS:

#import <Foundation/Foundation.h>
#import <ObjFW/ObjFW.h>

typedef void(^block_t)(void);

block_t createBlock(void) {
    __block int i = 2;

    return [^{ NSLog(@"%i", i); i--; NSLog(@"%i", i);} copy];
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        NSLog(@"Hello, World!");

        block_t myBlock = createBlock();

        myBlock();
        myBlock();
    }
    return 0;
}

Linked with ObjFW framework (or dll on Windows):

2016-10-13 00:29:29.416 testclang[13106:4746764] Hello, World!
2016-10-13 00:29:29.417 testclang[13106:4746764] 5256272
2016-10-13 00:29:29.417 testclang[13106:4746764] 5256271
2016-10-13 00:29:29.417 testclang[13106:4746764] 5256272
2016-10-13 00:29:29.417 testclang[13106:4746764] 5256271
Program ended with exit code: 0

Linked only with Foundation:

2016-10-13 00:30:56.425 testclang[13119:4747431] Hello, World!
2016-10-13 00:30:56.426 testclang[13119:4747431] 2
2016-10-13 00:30:56.426 testclang[13119:4747431] 1
2016-10-13 00:30:56.426 testclang[13119:4747431] 1
2016-10-13 00:30:56.426 testclang[13119:4747431] 0
Program ended with exit code: 0

As You can see, in ObjFW case, variable "i" captured by "myBlock" is dead after stack destruction of function "block_t createBlock(void)"

Uncaught Exception when use %Z or %z date formatter in OFDate method localDateStringWithFormat:

Like seid in http://www.cplusplus.com/reference/ctime/strftime/
%Z || Timezone name or abbreviation If timezone cannot be determined, no characters || CDT

But in my application I get exception like this:
[2015-10-24 22:11:07.729 fcgizonecreator.exe(14424)] Dispatch task in thread 14428
[2015-10-24 22:11:07.731 fcgizonecreator.exe(14424)] Application retain count^ 1
[2015-10-24 22:11:07.731 fcgizonecreator.exe(14424)] [14408]Request:test3.php recived on Server: webzonemanager localhost:9000
[2015-10-24 22:11:07.732 fcgizonecreator.exe(14424)] An encoding is invalid!
Try load Dynamorio DLL's...
loaded
[2015-10-24 22:11:07.950 fcgizonecreator.exe(14424)] 0 libobjfw.dll 6F1787D7 -[OFException init] +0x000F8740 [c:\Proj\objfw-master\src\exceptions/OFException.m : 240]
[2015-10-24 22:11:07.951 fcgizonecreator.exe(14424)] 1 libobjfw.dll 6F17870B +[OFException exception] +0x000F8690 [c:\Proj\objfw-master\src\exceptions/OFException.m : 234]
[2015-10-24 22:11:07.951 fcgizonecreator.exe(14424)] 2 libobjfw.dll 6F150BC4 -[OFString_UTF8 OF_initWithUTF8String_length_storage_] +0x000D09D0 [c:\Proj\objfw-master\src/OFString_UTF8.m : 195]
[2015-10-24 22:11:07.952 fcgizonecreator.exe(14424)] 3 libobjfw.dll 6F0DF59A -[OFString_placeholder initWithUTF8String_] +0x0005F4A0 [c:\Proj\objfw-master\src/OFString.m : 317]
[2015-10-24 22:11:07.952 fcgizonecreator.exe(14424)] 4 libobjfw.dll 6F0E09AF +[OFString stringWithUTF8String_] +0x00060920 [c:\Proj\objfw-master\src/OFString.m : 560]
[2015-10-24 22:11:07.952 fcgizonecreator.exe(14424)] 5 libobjfw.dll 6F09B11B -[OFDate localDateStringWithFormat_] +0x0001ACD0 [c:\Proj\objfw-master\src/OFDate.m : 555]
[2015-10-24 22:11:07.952 fcgizonecreator.exe(14424)] 6 fcgizonecreator.exe 00401F20 __50-[OFFCGIServer server:didReceiveRequest:response:]_block_invoke +0x00001CD0 [./fcgizonecreator.m : 85]
[2015-10-24 22:11:07.953 fcgizonecreator.exe(14424)] 7 libdispatch.dll 705822ED _dispatch_call_block_and_release +0x000022D0 [c:/Proj/xdispatch-master/libdispatch/src/blocks.c : 45]
.......

Incorrect URL Encoding of cyrillic strings

URL Encoding of cyrillic (and I suppose that all non latin) characters work incorrect

Original: мой файл
Encoded: %40%2C%40%2E%40%29%20%41%/4%40%20%40%29%40%2B

When I try to URL decode this string I get exception A format is invalid!

Short code:

#import <ObjFW/ObjFW.h>

int main(int argc, char const *argv[])
{
    OFString* cyrillic = @"мой файл";
    OFString* encoded = [cyrillic stringByURLEncoding];
    of_log(@"Original %@", cyrillic);
    of_log(@"Encoded %@", encoded);
    of_log(@"Decoded %@", [encoded stringByURLDecoding]); //Invalid format exception there
    return 0;
}

Error compiling on Linux.

Fresh clone on ubuntu 14.10...

OFApplication.m:144:1: error: ivar '_programName' which backs the property is not referenced in this property's accessor [-Werror,-Wunused-property-ivar]
+ (OFString*)programName
^
./OFApplication.h:134:40: note: property declared here
@property (readonly, assign) OFString *programName;
                                       ^
OFApplication.m:149:1: error: ivar '_arguments' which backs the property is not referenced in this property's accessor [-Werror,-Wunused-property-ivar]
+ (OFArray*)arguments
^
./OFApplication.h:139:61: note: property declared here
@property (readonly, assign) OFArray OF_GENERIC(OFString*) *arguments;
                                                            ^
OFApplication.m:154:1: error: ivar '_environment' which backs the property is not referenced in this property's accessor [-Werror,-Wunused-property-ivar]
+ (OFDictionary*)environment
^
./OFApplication.h:145:52: note: property declared here
    OFDictionary OF_GENERIC(OFString*, OFString*) *environment;
                                                   ^
3 errors generated.
make[3]: *** [OFApplication.lib.o] Error 1
make[2]: *** [all] Error 2
make[1]: *** [src] Error 2
make: *** [all] Error 2

OFUDPSocket documentation of async function does not match with the real implementation.

The comments about the asyncRecieveIntoBuffer function tells me:

selector
The selector to call on the target. The signature must be `bool (OFUDPSocket *socket, void *buffer, size_t length, of_udp_socket_address_t*, OFException *exception)`.

However internally the selector gets interpreted like this:

bool (*func)(id, SEL, OFStream*, void*, size_t,
                OFException*) = (bool(*)(id, SEL, OFStream*, void*,
                size_t, OFException*))
                [queueItem->_target methodForSelector:
                queueItem->_selector];

Which results in a of_udp_socket_address_t that is most times NULL or points to any exception and the real exception parameter being always nil.

Please add the of_udp_socket_address_t to the call, like your documentation says.

Add support of symlink for Windows targets

Since Windows Vista/Sever 2008 Win API has method CreateSymbolicLink()
I think that OFFileManager should to implement runtime detection of Windows major version and use kernel32.dll to load function "CreateSymbolicLink" dynamically

typedef BOOL WINAPI (*symlink_fn)(const wchar_t*, const wchar_t*, DWORD);
static bool __has_symbolic_link_support = false;
static symlink_fn create_symbolic_link = NULL;

+ (void)load 
{

    OSVERSIONINFOW osvi;
    ZeroMemory(&osvi, sizeof(OSVERSIONINFOW));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);

    GetVersionExW(&osvi);

    if (osvi.dwMajorVersion >= 6) {
        __has_symbolic_link_support = true;

        if (!create_symbolic_link) {
            create_symbolic_link = (symlink_fn) GetProcAddress(GetModuleHandle("kernel32.dll"), "CreateSymbolicLinkW");

            if (!create_symbolic_link)
                create_symbolic_link = (symlink_fn)-1;
        }
    }

}

OFHTTPClient::performRequest:redirects: rewrite Multiple Set-Cookie headers in HTTP Response

After parsing http response header, method use [serverHeaders setObject: value forKey: key]; to store key and value for every field in header, if HTTP server send response with multiple Set-Cookie fields, OFHTTPResponse save only last of them.
[2015-10-29 03:11:04.560 client.exe(30220)] Response on <OFHTTPRequest:
URL = <OFURL: http://localhost/testcookie.php>
Method = GET
Headers = (nil)
Body = (nil)
Remote address = (nil)

from server with status code 200 headers {
Date = Thu, 29 Oct 2015 00:11:04 GMT;
X-Powered-By = PHP/5.5.12;
Set-Cookie = TestCookie=%F7%F2%EE-%F2%EE+%E3%E4%E5-%F2%EE; expires=Thu, 29-Oct-2015 01:11:04 GMT; Max-Age=3600; path=/~rasmus/; domain=example.com; secure;
Content-Type = text/html;
Server = Apache/2.4.9 (Win32) mod_fcgid/2.3.9 PHP/5.5.12;
Content-Length = 21;
}
[2015-10-29 03:11:04.563 client.exe(30220)] Cookies: TestCookie=%F7%F2%EE-%F2%EE+%E3%E4%E5-%F2%EE; expires=Thu, 29-Oct-2015 01:11:04 GMT; Max-Age=3600; path=/~rasmus/; domain=example.com; secure

Connection:Keep-Alive
Content-Length:55
Content-Type:text/html
Date:Thu, 29 Oct 2015 00:10:19 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.9 (Win32) mod_fcgid/2.3.9 PHP/5.5.12
Set-Cookie:TestCookie=%F7%F2%EE-%F2%EE+%E3%E4%E5-%F2%EE
Set-Cookie:TestCookie=%F7%F2%EE-%F2%EE+%E3%E4%E5-%F2%EE; expires=Thu, 29-Oct-2015 01:10:19 GMT; Max-Age=3600
Set-Cookie:TestCookie=%F7%F2%EE-%F2%EE+%E3%E4%E5-%F2%EE; expires=Thu, 29-Oct-2015 01:10:19 GMT; Max-Age=3600; path=/~rasmus/; domain=example.com; secure

[OFTLSSocket] incorrect "delegate" property type

In OFTLSSocket.h delegate property declared as @property OF_NULLABLE_PROPERTY (assign) id <OFTLSSocket> delegate; instead @property OF_NULLABLE_PROPERTY (assign) id <OFTLSSocketDelegate> delegate;

C++ Exceptions Handling in Objective-C++

Does it possible to catch C++ exception in ObjC++ code?
For now I get unhandled exception with application abort, no matter what exception and block I use, C++ try\catch or ObjC @Try@catch and no matter what exception was throwed C++ or ObjC

application backtrace:

msvcrt.dll!abort
libobjfw.dll!find_actionrecord
libobjfw.dll!gnu_objc_personality
libgcc_s_seh-1.dll!GCC_specific_handler
libobjfw.dll!__gnu_objc_personality_seh0
ntdll.dll!RtlpExecuteHandlerForException
ntdll.dll!RtlDispatchException
ntdll.dll!RtlRaiseException
KERNELBASE.dll!RaiseException
libgcc_s_seh-1.dll!Unwind_RaiseException
libstdc++-6.dll!_cxa_throw
testobjcxx.exe!main

for dwarf EH pic look the same

KernelEventObserver (select) throws OutOfRangeException in random time when remove objects observed for reading

I use async accept and async read methods in main run loop of my tcp server application. For automatic of clients disconnection I use OFTimer object with 10 sec. timeout, that execute cancelAsync Requests method for every connected socket. For testing server, I use python script, that connect to my server in loop, sends some data and disconnects. On server side, connection timeout timer closes socket connection automatically.
In some moment, after 70 - 80 connections, my TCP server falls with exception, when OFKernelEventObserver_select execute method OF_removeObjectForReading.
In source code I see checking "if (fd < 0 || fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception];" (by default FD_SETSIZE == 1024), but in method OF_addObjectForReading, for Windows OS used "if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception];"

My question is - How can I fix this incorrect (IMHO) behaviour?

(OS Windows 8.1 x86_64 + ObjFW DLL x86 (32-bit))

Adding a portable UDP Socket Object, just like OFTCPSocket

With support for TCP Sockets and even TSL encryption, why not provide a similar interface for UDP Ports?
I assume this is more a nice-to-have feature then something urgent or a "real" issue, but I could really need such functionality for my cross-platform objective-c project and it is not an uncommon protocol ;)

ObjFW.h missing imports (includes)

ObjFW.h does not include:
crc32.h
instance.h
OFChecksumFailedException.h
OFGetOptionFailedException.h
OFObserveFailedException.h
OFUnboundPrefixException.h
OFUnknownXMLEntityException.h

Compiling in MSYS fails loudly.

Compiling under MSYS, using the mingw-w64 tools, causes pretty loud failures.

  • Sleep is always "implicitly declared" and when running with threads enabled, at one point, a huge error will be thrown saying that the definitions are not matching.
Successfully compiled lookup.m (lib).
In file included from property.m:27:
..\threading.h:215:3: error: implicit declaration of function 'Sleep' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                Sleep(0);
                ^
1 error generated.
Failed to compile property.m (lib)!
../../buildsys.mk:491: die Regel für Ziel „property.lib.o“ scheiterte
make[5]: *** [property.lib.o] Fehler 1
../../buildsys.mk:116: die Regel für Ziel „all“ scheiterte
make[4]: *** [all] Fehler 2
../buildsys.mk:129: die Regel für Ziel „runtime“ scheiterte
make[3]: *** [runtime] Fehler 2
../buildsys.mk:116: die Regel für Ziel „all“ scheiterte
make[2]: *** [all] Fehler 2
buildsys.mk:129: die Regel für Ziel „src“ scheiterte
make[1]: *** [src] Fehler 2
buildsys.mk:116: die Regel für Ziel „all“ scheiterte
make: *** [all] Fehler 2

I did edit buildsys.mk which then led me to the definition error (I removed -Werror)

  • Running with threads disabled, does:
Successfully compiled windows_1252.m (lib).
OFDataArray.lib.o:(.data+0x928): multiple definition of `__objc_ivar_offset_OFDataArray._itemSize'
OFBigDataArray.lib.o:(.data[__objc_ivar_offset_OFDataArray._itemSize]+0x0): first defined here
OFDataArray.lib.o: In function `-[OFDataArray initWithContentsOfURL:]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/OFDataArray.m:214: multiple definition of `__objc_ivar_offset_OFDataArray._items'
OFBigDataArray.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFBigDataArray.m:29: first defined here
OFDataArray.lib.o: In function `-[OFDataArray initWithContentsOfURL:]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/OFDataArray.m:214: multiple definition of `__objc_ivar_offset_OFDataArray._capacity'
OFBigDataArray.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFBigDataArray.m:29: first defined here
OFDataArray.lib.o: In function `-[OFDataArray initWithContentsOfURL:]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/OFDataArray.m:233: multiple definition of `__objc_ivar_offset_OFDataArray._count'
OFBigDataArray.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFBigDataArray.m:29: first defined here
OFInflate64Stream.lib.o:(.data[__objc_ivar_offset_OFInflateStream._atEndOfStream]+0x0): multiple definition of `__objc_ivar_offset_OFInflateStream._atEndOfStream'
OFInflateStream.lib.o:(.data+0x6d0): first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._state'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:374: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._inLastBlock'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:374: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._stream'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:373: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._buffer'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:373: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._bufferIndex'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:373: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._bufferLength'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:373: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._bitIndex'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:373: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._context'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:373: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._slidingWindow'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:375: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._slidingWindowMask'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:373: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._slidingWindowIndex'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:375: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._savedBits'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:466: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._savedBitsLength'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:466: first defined here
OFInflate64Stream.lib.o: In function `+[OFInflate64Stream initialize]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/./OFInflateStream.m:256: multiple definition of `__objc_ivar_offset_OFInflateStream._byte'
OFInflateStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFInflateStream.m:463: first defined here
OFSHA224Or256Hash.lib.o:(.data+0x458): multiple definition of `__objc_ivar_offset_OFSHA224Or256Hash._state'
OFSHA224Hash.lib.o:(.data[__objc_ivar_offset_OFSHA224Or256Hash._state]+0x0): first defined here
OFSHA384Or512Hash.lib.o:(.data+0x458): multiple definition of `__objc_ivar_offset_OFSHA384Or512Hash._state'
OFSHA384Hash.lib.o:(.data[__objc_ivar_offset_OFSHA384Or512Hash._state]+0x0): first defined here
OFSortedList.lib.o:(.data[__objc_ivar_offset_OFList._lastListObject]+0x0): multiple definition of `__objc_ivar_offset_OFList._lastListObject'
OFList.lib.o:(.data+0x6e0): first defined here
OFStream.lib.o:(.data+0x6c0): multiple definition of `__objc_ivar_offset_OFStream._readBufferLength'
OFSeekableStream.lib.o:(.data[__objc_ivar_offset_OFStream._readBufferLength]+0x0): first defined here
OFStream.lib.o: In function `-[OFStream readBigEndianFloat]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/OFStream.m:242: multiple definition of `__objc_ivar_offset_OFStream._readBuffer'
OFSeekableStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFSeekableStream.m:27: first defined here
OFXMLElement.lib.o:(.data[__objc_ivar_offset_OFXMLAttribute._name]+0x0): multiple definition of `__objc_ivar_offset_OFXMLAttribute._name'
OFXMLAttribute.lib.o:(.data+0x6b8): first defined here
OFXMLElement.lib.o: In function `_references_to_categories_of_OFXMLElement':
C:\Users\kingwersen\Downloads\objfw-0.8\src/OFXMLElement.m:42: multiple definition of `__objc_ivar_offset_OFXMLAttribute._namespace'
OFXMLAttribute.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFXMLAttribute.m:124: first defined here
OFXMLElement+Serialization.lib.o:(.data[__objc_ivar_offset_OFXMLElement._name]+0x0): multiple definition of `__objc_ivar_offset_OFXMLElement._name'
OFXMLElement.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFXMLElement.m:211: first defined here
OFHTTPServer.lib.o:(.data[__objc_ivar_offset_OFHTTPResponse._statusCode]+0x0): multiple definition of `__objc_ivar_offset_OFHTTPResponse._statusCode'
OFHTTPResponse.lib.o:(.data+0x8c8): first defined here
OFHTTPServer.lib.o: In function `-[OFHTTPServerResponse initWithSocket:server:]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/OFHTTPServer.m:185: multiple definition of `__objc_ivar_offset_OFHTTPResponse._headers'
OFHTTPResponse.lib.o:(.data+0x880): first defined here
OFStreamSocket.lib.o:(.data[__objc_ivar_offset_OFStream._blocking]+0x0): multiple definition of `__objc_ivar_offset_OFStream._blocking'
OFStream.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src/OFStream.m:242: first defined here
OFTCPSocket.lib.o:(.data[__objc_ivar_offset_OFStreamSocket._socket]+0x0): multiple definition of `__objc_ivar_offset_OFStreamSocket._socket'
OFStreamSocket.lib.o:(.data+0x6c0): first defined here
OFArray_adjacentSubarray.lib.o:(.data[__objc_ivar_offset_OFArray_subarray._array]+0x0): multiple definition of `__objc_ivar_offset_OFArray_subarray._array'
OFArray_subarray.lib.o:(.data+0x628): first defined here
OFArray_adjacentSubarray.lib.o: In function `-[OFArray_adjacentSubarray objects]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/OFArray_adjacentSubarray.m:24: multiple definition of `__objc_ivar_offset_OFArray_subarray._range'
OFArray_subarray.lib.o:(.data+0x630): first defined here
OFString_UTF8.lib.o:(.data+0x6c0): multiple definition of `__objc_ivar_offset_OFString_UTF8._s'
OFMutableString_UTF8.lib.o:(.data[__objc_ivar_offset_OFString_UTF8._s]+0x0): first defined here
.exceptions_exceptions.lib.a.objs/OFReadOrWriteFailedException.lib.o:(.data+0x4f8): multiple definition of `__objc_ivar_offset_OFReadOrWriteFailedException._object'
.exceptions_exceptions.lib.a.objs/OFReadFailedException.lib.o:(.data[__objc_ivar_offset_OFReadOrWriteFailedException._object]+0x0): first defined here
.exceptions_exceptions.lib.a.objs/OFReadOrWriteFailedException.lib.o:(.data+0x500): multiple definition of `__objc_ivar_offset_OFReadOrWriteFailedException._requestedLength'
.exceptions_exceptions.lib.a.objs/OFReadFailedException.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src\exceptions/OFReadFailedException.m:23: first defined here
.exceptions_exceptions.lib.a.objs/OFReadOrWriteFailedException.lib.o:(.data+0x508): multiple definition of `__objc_ivar_offset_OFReadOrWriteFailedException._errNo'
.exceptions_exceptions.lib.a.objs/OFReadFailedException.lib.o:C:\Users\kingwersen\Downloads\objfw-0.8\src\exceptions/OFReadFailedException.m:23: first defined here
OFKernelEventObserver.lib.o: In function `+[OFKernelEventObserver alloc]':
C:\Users\kingwersen\Downloads\objfw-0.8\src/OFKernelEventObserver.m:92: undefined reference to `_OBJC_CLASS_OFKernelEventObserver_select'
OFKernelEventObserver.lib.o:(.rdata[__objc_class_ref_OFKernelEventObserver_select]+0x0): undefined reference to `__objc_class_name_OFKernelEventObserver_select'
clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
Failed to link libobjfw.so!
../buildsys.mk:238: die Regel für Ziel „libobjfw.so“ scheiterte
make[3]: *** [libobjfw.so] Fehler 1
../buildsys.mk:116: die Regel für Ziel „all“ scheiterte
make[2]: *** [all] Fehler 2
buildsys.mk:129: die Regel für Ziel „src“ scheiterte
make[1]: *** [src] Fehler 2
buildsys.mk:116: die Regel für Ziel „all“ scheiterte
make: *** [all] Fehler 2

My setup:

  • gcc: 5.2.0
  • clang: 3.6.2

Could you possibly look into this? Thanks!

Proper encoding when writing to console on Win32

I wrote some Python scripts for generating ObjC source code files like windows_1252.m & iso_8859_15.m & codepage_437.m in ObjFW source
I'm not sure that I understand correctly your approach to encoding conversion, but tried to reproduce it.

Can You look at code, and if it is correct add more encodings for OFString
Link: https://yadi.sk/d/BR-53fdbpAgbu
P.S. I tested only Cyrillic encodings CP866, Win1251 and KOI8-R/U for now

GZIPArchive.m compilation error on MinGW

GZIPArchive.m:36:21: error: use of undeclared identifier 'S_IRWXG'
mode &= (S_IRWXU | S_IRWXG | S_IRWXO);
^
GZIPArchive.m:36:31: error: use of undeclared identifier 'S_IRWXO'
mode &= (S_IRWXU | S_IRWXG | S_IRWXO);

Windows has chmod but does not support S_IRWXG and S_IRWXO modes

[Question] Create objc classes at runtime

Apple ObjC runtime has ability to create classes and methods for those classes at runtime.
Does ObjFW runtime has this functionality?
If answer is No, then will be this functionality implemented in future?

Building in minGW failed

  1. There is no wget in MinGW Basic System so test make faild to download UnicodData.
  2. Make from main folder stuck after leaving plugins folder (new problem in test folder)
$ make
Entering directory src.
Entering directory exceptions.
Leaving directory exceptions.
Entering directory runtime.
Leaving directory runtime.
Leaving directory src.
Entering directory utils.
Leaving directory utils.
Entering directory tests.
Entering directory plugin.
Leaving directory plugin.

Runtime error: Unhandled exception:
The encoding is invalid for class OFString_UTF8!

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
make[3]: *** [run-tests] Error 3
make[2]: *** [run] Error 2
make[1]: *** [tests] Error 2
make: *** [all] Error 2

Solution

Changing default terminal to minnty.

ObjC++ variable initialization error for macros.h/of_explicit_memset

In C++ volatile unsigned char * variable cannot be initialized with void * type

Should be something like this:

static OF_INLINE void
of_explicit_memset(void *buffer_, int character, size_t length)
{
#ifdef __cplusplus
    volatile unsigned char *buffer = static_cast<unsigned char *>(buffer_);
#else
        volatile unsigned char *buffer = buffer_;
#endif

	while (buffer < (unsigned char*)buffer_ + length)
		*buffer++ = character;
}

[runtime] add support of imp_implementationWithBlock

Apple ObjC Runtime have functions imp_implementationWithBlock, imp_getBlock, imp_removeBlock which allow to create implementation of class methods at runtime via Blocks-closuer.
It will be great to get those features in ObjFW

[Feature Request] extend OFRunLoop flexibility

Sometimes we need to add code that must be executed inside OFRunLoop in a special sequence, and very often OFTimer is not the best solution for this, because we can not determine at what stage this code will be executed. OFTimers are always executed before the kernel read / write events, but for the GUI or other personnel some code must be executed before the timers, after the timers and before observing the kernel events and after observing the kernel to interrogate all GUI events.
Perhaps OFRunLoop should be extended by methods, both for target+selectors, and for Blocks of runloop sources (like it was done for timers, which have ability to call object method or Blocks), that will be executed in accordance with flags passed to method, as like Apple done it for CFRunLoop sources https://developer.apple.com/documentation/corefoundation/cfrunloopactivity?language=objc

In this way we will have ability to execute some code in time of OFRunLoop starts, before Timers runing, before I/O events observing, before waiting to next timer execution time or next iteration, after that waiting, in time of OFRunLoop breakening / termination or in all this cases.

OFTCPSocket asyncConnect crash

Very often crashes when using asynchronous connection to remote host.
If exception has occurred, I try to write error information about it in log file in an another thread. As result I got crash like this:
6F1646D6 02475820 00000003 00000003 libobjfw.dll!objc_exit
004019CA 02478CB8 02478CB8 02478CB8 test.exe!_destroy_helper_block
6F08BC24 02478CB8 6F19ADD0 02478CB8 libobjfw.dll!_Block_release
6F08C376 02478CB8 6F19ADD0 00186B90 libobjfw.dll!_i_OFBlock__release
6F0FAACF 02472548 6F18F110 02472548 libobjfw.dll!_i_OFTimer__dealloc
6F0CAD8E 02472548 6F1B20D0 00000000 libobjfw.dll!_i_OFObject__release
6F15DCDF 00000000 6F191B70 00000000 libobjfw.dll!objc_autoreleasePoolPop
6F0D67D0 0246F540 6F191B68 00000000 libobjfw.dll!i_OFRunLoop__runUntilDate
6F0D5CF6 0246F540 6F1818B8 0246F540 libobjfw.dll!_i_OFRunLoop__run
6F0829F9 0216D208 6F181900 02478D08 libobjfw.dll!_i_OFApplication__OF_run
6F0818A1 0061FEAC 0061FEA8 00403C70 libobjfw.dll!of_application_main
0040167E 00000001 0216EF88 02161E30 test.exe!main
004013DE 00287000 759C38D0 B466C8F1 test.exe!__tmainCRTStartup
759C38F4 00287000 B6463519 00000000 KERNEL32.DLL!BaseThreadInitThunk
777C5DE3 FFFFFFFF 777EB7E6 00000000 ntdll.dll!__RtlUserThreadStart
777C5DAE 004014E0 00287000 00000000 ntdll.dll!_RtlUserThreadStart

Simple code:

#import<ObjFW/ObjFW.h>

@interface Delegate: OFObject <OFApplicationDelegate>

- (void)applicationDidFinishLaunching;
- (void)connect:(OFTCPSocket *)s except:(OFException *)e;

@end

OF_APPLICATION_DELEGATE(Delegate)


@implementation Delegate

- (void)applicationDidFinishLaunching
{
        OFTCPSocket* sock = [OFTCPSocket socket];
    [sock asyncConnectToHost:@"localhost" port:25 target:self selector:@selector(connect:except:)];
}

- (void)connect:(OFTCPSocket *)s except:(OFException *)e
{
    if (e != nil) {
        OFTimer* tm = [OFTimer timerWithTimeInterval:0.0 repeats:false block:^(OFTimer *timer){
                of_log(@"%@", e);

        }];

        [[OFRunLoop mainRunLoop] addTimer:tm];
        return;
    }
}

@end

crash.txt

Make error

Hi. I have problems with build form source.

28351 Segmentation fault      (core dumped) LD_LIBRARY_PATH=.${LD_LIBRARY_PATH+:}$LD_LIBRARY_PATH DYLD_LIBRARY_PATH=.${DYLD_LIBRARY_PATH+:}$DYLD_LIBRARY_PATH LIBRARY_PATH=.${LIBRARY_PATH+:}$LIBRARY_PATH ./tests
make[3]: *** [run-tests] Error 139
make[2]: *** [run] Error 2
make[1]: *** [tests] Error 2
make: *** [all] Error 2

I'm using

explicite@kapitan:~/Explicite-objfw-49b08cd$ uname -r -p -i -o
3.5.0-17-generic x86_64 x86_64 GNU/Linux

explicite@kapitan:~/Explicite-objfw-49b08cd$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v  --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2

OFFileManager does not recognise drive letter on Win32

Method createDirectoryAtPath:createParents: try to create path component that actually is a drive letter (C: D: E: etc)
directoryExistsAtPath: used inside the method does not return true for drive letters, because drive letters are not directories

#import <ObjFW/ObjFW.h>

int main(int argc, char const *argv[])
{
    OFString* path = @"C:\\test_folder\\test_subfolder";

    [[OFFileManager defaultManager] createDirectoryAtPath:path createParents:true]; //exception Failed to create directory C:: File exists

    return 0;
}

P.S. This is old bug, but I forgot to report it

OFHTTPServer occasionally freez at HTTP header parsing

Sometimes, more often at first http request to OFHTTPServer, it stoped at header parsing operation.
For firefox it happens after parsing User-Agent header record:

[2016-03-19 05:08:51.053 delegate.exe(20212)] Connection Accepted <OFHTTPServerEx: 024A7DE8> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:08:51.053 delegate.exe(20212)] Init <OFHTTPServerEx_Connection: 024A2070> with socket <OFTCPSocket: 024A6770>
[2016-03-19 05:08:51.053 delegate.exe(20212)] did read line (GET / HTTP/1.1) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:08:51.054 delegate.exe(20212)] did parse prolog <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:08:51.054 delegate.exe(20212)] did read line (Host: 127.0.0.1:8080) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:08:51.054 delegate.exe(20212)] did parse headers (Host: 127.0.0.1:8080) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:08:51.054 delegate.exe(20212)] find pos 4
[2016-03-19 05:08:51.055 delegate.exe(20212)] key Host value 127.0.0.1:8080
[2016-03-19 05:08:51.055 delegate.exe(20212)] key normalizedKey Host
[2016-03-19 05:08:51.055 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces 127.0.0.1:8080
[2016-03-19 05:08:51.055 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:51.055 delegate.exe(20212)] value 127.0.0.1:8080
[2016-03-19 05:08:51.055 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:51.056 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:08:51.056 delegate.exe(20212)] Header line parsed
[2016-03-19 05:08:51.056 delegate.exe(20212)] did read line (User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:08:51.056 delegate.exe(20212)] did parse headers (User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:08:51.057 delegate.exe(20212)] find pos 10
[2016-03-19 05:08:51.057 delegate.exe(20212)] key User-Agent value Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
[2016-03-19 05:08:51.057 delegate.exe(20212)] key normalizedKey User-Agent
[2016-03-19 05:08:51.058 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
[2016-03-19 05:08:51.058 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:51.058 delegate.exe(20212)] value Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
[2016-03-19 05:08:51.059 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:51.059 delegate.exe(20212)] Check for Host header record
!!!!!![2016-03-19 05:08:51.059 delegate.exe(20212)] Header line parsed
!!!!!! 9 seconds freeze
[2016-03-19 05:09:00.060 delegate.exe(20212)] did read line (Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.060 delegate.exe(20212)] did parse headers (Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>

[2016-03-19 05:09:00.061 delegate.exe(20212)] find pos 6
[2016-03-19 05:09:00.061 delegate.exe(20212)] key Accept value text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
[2016-03-19 05:09:00.062 delegate.exe(20212)] key normalizedKey Accept
[2016-03-19 05:09:00.063 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
[2016-03-19 05:09:00.063 delegate.exe(20212)] old (nil)
[2016-03-19 05:09:00.064 delegate.exe(20212)] value text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
[2016-03-19 05:09:00.064 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:09:00.065 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:09:00.066 delegate.exe(20212)] Header line parsed
[2016-03-19 05:09:00.068 delegate.exe(20212)] did read line (Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.068 delegate.exe(20212)] did parse headers (Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.068 delegate.exe(20212)] find pos 15
[2016-03-19 05:09:00.069 delegate.exe(20212)] key Accept-Language value ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
[2016-03-19 05:09:00.069 delegate.exe(20212)] key normalizedKey Accept-Language
[2016-03-19 05:09:00.070 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
[2016-03-19 05:09:00.070 delegate.exe(20212)] old (nil)
[2016-03-19 05:09:00.070 delegate.exe(20212)] value ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
[2016-03-19 05:09:00.070 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:09:00.071 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:09:00.071 delegate.exe(20212)] Header line parsed
[2016-03-19 05:09:00.072 delegate.exe(20212)] did read line (Accept-Encoding: gzip, deflate) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.072 delegate.exe(20212)] did parse headers (Accept-Encoding: gzip, deflate) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.072 delegate.exe(20212)] find pos 15
[2016-03-19 05:09:00.072 delegate.exe(20212)] key Accept-Encoding value gzip, deflate
[2016-03-19 05:09:00.073 delegate.exe(20212)] key normalizedKey Accept-Encoding
[2016-03-19 05:09:00.073 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces gzip, deflate
[2016-03-19 05:09:00.073 delegate.exe(20212)] old (nil)
[2016-03-19 05:09:00.073 delegate.exe(20212)] value gzip, deflate
[2016-03-19 05:09:00.074 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:09:00.074 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:09:00.074 delegate.exe(20212)] Header line parsed
[2016-03-19 05:09:00.075 delegate.exe(20212)] did read line (Connection: keep-alive) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.075 delegate.exe(20212)] did parse headers (Connection: keep-alive) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.075 delegate.exe(20212)] find pos 10
[2016-03-19 05:09:00.075 delegate.exe(20212)] key Connection value keep-alive
[2016-03-19 05:09:00.076 delegate.exe(20212)] key normalizedKey Connection
[2016-03-19 05:09:00.076 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces keep-alive
[2016-03-19 05:09:00.076 delegate.exe(20212)] old (nil)
[2016-03-19 05:09:00.076 delegate.exe(20212)] value keep-alive
[2016-03-19 05:09:00.076 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:09:00.076 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:09:00.077 delegate.exe(20212)] Header line parsed
[2016-03-19 05:09:00.078 delegate.exe(20212)] did read line (Cache-Control: max-age=0) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.078 delegate.exe(20212)] did parse headers (Cache-Control: max-age=0) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.078 delegate.exe(20212)] find pos 13
[2016-03-19 05:09:00.078 delegate.exe(20212)] key Cache-Control value max-age=0
[2016-03-19 05:09:00.078 delegate.exe(20212)] key normalizedKey Cache-Control
[2016-03-19 05:09:00.079 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces max-age=0
[2016-03-19 05:09:00.079 delegate.exe(20212)] old (nil)
[2016-03-19 05:09:00.079 delegate.exe(20212)] value max-age=0
[2016-03-19 05:09:00.079 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:09:00.080 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:09:00.080 delegate.exe(20212)] Header line parsed
[2016-03-19 05:09:00.081 delegate.exe(20212)] did read line () block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.081 delegate.exe(20212)] did parse headers () <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.081 delegate.exe(20212)] creating response <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.081 delegate.exe(20212)] Init <OFHTTPServerExResponse: 024A6A40
Status code = 0
Headers = (nil)

with socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.312 delegate.exe(20212)] did write html <OFHTTPServerExResponse: 024A6A40
Status code = 200
Headers = {
Set-Cookie = testcookie=success; Path=/; Domain=localhost; Discard;
Connection = Keep-Alive;
Content-Type = text/plain;
}
socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.313 delegate.exe(20212)] did send headers <OFHTTPServerExResponse: 024A6A40
Status code = 200
Headers = {
Set-Cookie = testcookie=success; Path=/; Domain=localhost; Discard;
Connection = Keep-Alive;
Content-Type = text/plain;
}
socket <OFTCPSocket: 024A6770>
[2016-03-19 05:09:00.315 delegate.exe(20212)] did close server response <OFHTTPServerExResponse: 024A6A40
Status code = 200
Headers = {
Set-Cookie = testcookie=success; Path=/; Domain=localhost; Discard;
Connection = Keep-Alive;
Content-Type = text/plain;
}
socket <OFTCPSocket: 024A6770>

For Google Chrome it happens after Upgrade-Insecure-Requests parsing:

[2016-03-19 05:08:24.846 delegate.exe(20212)] Connection Accepted <OFHTTPServerEx: 024A7DE8> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:24.847 delegate.exe(20212)] Init <OFHTTPServerEx_Connection: 024A2070> with socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:24.847 delegate.exe(20212)] did read line (GET /index.html HTTP/1.1) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:24.847 delegate.exe(20212)] did parse prolog <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:24.848 delegate.exe(20212)] did read line (Host: localhost:8080) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:24.848 delegate.exe(20212)] did parse headers (Host: localhost:8080) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:24.848 delegate.exe(20212)] find pos 4
[2016-03-19 05:08:24.848 delegate.exe(20212)] key Host value localhost:8080
[2016-03-19 05:08:24.849 delegate.exe(20212)] key normalizedKey Host
[2016-03-19 05:08:24.849 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces localhost:8080
[2016-03-19 05:08:24.849 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:24.849 delegate.exe(20212)] value localhost:8080
[2016-03-19 05:08:24.849 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:24.850 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:08:24.850 delegate.exe(20212)] Header line parsed
[2016-03-19 05:08:24.850 delegate.exe(20212)] did read line (Connection: keep-alive) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:24.850 delegate.exe(20212)] did parse headers (Connection: keep-alive) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:24.851 delegate.exe(20212)] find pos 10
[2016-03-19 05:08:24.851 delegate.exe(20212)] key Connection value keep-alive
[2016-03-19 05:08:24.851 delegate.exe(20212)] key normalizedKey Connection
[2016-03-19 05:08:24.851 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces keep-alive
[2016-03-19 05:08:24.852 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:24.852 delegate.exe(20212)] value keep-alive
[2016-03-19 05:08:24.852 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:24.852 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:08:24.852 delegate.exe(20212)] Header line parsed
[2016-03-19 05:08:25.098 delegate.exe(20212)] Connection Accepted <OFHTTPServerEx: 024A7DE8> socket <OFTCPSocket: 024A6BA8>
[2016-03-19 05:08:25.099 delegate.exe(20212)] Init <OFHTTPServerEx_Connection: 024A2160> with socket <OFTCPSocket: 024A6BA8>
[2016-03-19 05:08:25.099 delegate.exe(20212)] did read line (Cache-Control: max-age=0) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:25.099 delegate.exe(20212)] did parse headers (Cache-Control: max-age=0) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:25.100 delegate.exe(20212)] find pos 13
[2016-03-19 05:08:25.100 delegate.exe(20212)] key Cache-Control value max-age=0
[2016-03-19 05:08:25.100 delegate.exe(20212)] key normalizedKey Cache-Control
[2016-03-19 05:08:25.100 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces max-age=0
[2016-03-19 05:08:25.101 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:25.101 delegate.exe(20212)] value max-age=0
[2016-03-19 05:08:25.101 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:25.101 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:08:25.101 delegate.exe(20212)] Header line parsed
[2016-03-19 05:08:25.101 delegate.exe(20212)] did read line (Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:25.102 delegate.exe(20212)] did parse headers (Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:25.102 delegate.exe(20212)] find pos 6
[2016-03-19 05:08:25.102 delegate.exe(20212)] key Accept value text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
[2016-03-19 05:08:25.102 delegate.exe(20212)] key normalizedKey Accept
[2016-03-19 05:08:25.102 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
[2016-03-19 05:08:25.103 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:25.103 delegate.exe(20212)] value text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
[2016-03-19 05:08:25.103 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:25.103 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:08:25.103 delegate.exe(20212)] Header line parsed
[2016-03-19 05:08:25.103 delegate.exe(20212)] did read line (Upgrade-Insecure-Requests: 1) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:25.103 delegate.exe(20212)] did parse headers (Upgrade-Insecure-Requests: 1) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:25.104 delegate.exe(20212)] find pos 25
[2016-03-19 05:08:25.104 delegate.exe(20212)] key Upgrade-Insecure-Requests value 1
[2016-03-19 05:08:25.104 delegate.exe(20212)] key normalizedKey Upgrade-Insecure-Requests
[2016-03-19 05:08:25.104 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces 1
[2016-03-19 05:08:25.104 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:25.104 delegate.exe(20212)] value 1
[2016-03-19 05:08:25.104 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:25.104 delegate.exe(20212)] Check for Host header record
!!![2016-03-19 05:08:25.105 delegate.exe(20212)] Header line parsed
!!! 9 seconds freeze
[2016-03-19 05:08:34.106 delegate.exe(20212)] did read line (User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>

[2016-03-19 05:08:34.106 delegate.exe(20212)] did parse headers (User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.107 delegate.exe(20212)] find pos 10
[2016-03-19 05:08:34.107 delegate.exe(20212)] key User-Agent value Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
[2016-03-19 05:08:34.107 delegate.exe(20212)] key normalizedKey User-Agent
[2016-03-19 05:08:34.108 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
[2016-03-19 05:08:34.108 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:34.108 delegate.exe(20212)] value Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
[2016-03-19 05:08:34.109 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:34.109 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:08:34.109 delegate.exe(20212)] Header line parsed
[2016-03-19 05:08:34.110 delegate.exe(20212)] did read line (Accept-Encoding: gzip, deflate, sdch) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.110 delegate.exe(20212)] did parse headers (Accept-Encoding: gzip, deflate, sdch) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.110 delegate.exe(20212)] find pos 15
[2016-03-19 05:08:34.110 delegate.exe(20212)] key Accept-Encoding value gzip, deflate, sdch
[2016-03-19 05:08:34.111 delegate.exe(20212)] key normalizedKey Accept-Encoding
[2016-03-19 05:08:34.111 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces gzip, deflate, sdch
[2016-03-19 05:08:34.111 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:34.112 delegate.exe(20212)] value gzip, deflate, sdch
[2016-03-19 05:08:34.112 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:34.112 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:08:34.112 delegate.exe(20212)] Header line parsed
[2016-03-19 05:08:34.114 delegate.exe(20212)] did read line (Accept-Language: en-US,en;q=0.8,ru;q=0.6) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.114 delegate.exe(20212)] did parse headers (Accept-Language: en-US,en;q=0.8,ru;q=0.6) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.115 delegate.exe(20212)] find pos 15
[2016-03-19 05:08:34.115 delegate.exe(20212)] key Accept-Language value en-US,en;q=0.8,ru;q=0.6
[2016-03-19 05:08:34.115 delegate.exe(20212)] key normalizedKey Accept-Language
[2016-03-19 05:08:34.116 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces en-US,en;q=0.8,ru;q=0.6
[2016-03-19 05:08:34.116 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:34.116 delegate.exe(20212)] value en-US,en;q=0.8,ru;q=0.6
[2016-03-19 05:08:34.117 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:34.117 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:08:34.117 delegate.exe(20212)] Header line parsed
[2016-03-19 05:08:34.118 delegate.exe(20212)] did read line (Cookie: testcookie=success) block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.118 delegate.exe(20212)] did parse headers (Cookie: testcookie=success) <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.118 delegate.exe(20212)] find pos 6
[2016-03-19 05:08:34.119 delegate.exe(20212)] key Cookie value testcookie=success
[2016-03-19 05:08:34.119 delegate.exe(20212)] key normalizedKey Cookie
[2016-03-19 05:08:34.119 delegate.exe(20212)] value stringByDeletingLeadingWhitespaces testcookie=success
[2016-03-19 05:08:34.120 delegate.exe(20212)] old (nil)
[2016-03-19 05:08:34.120 delegate.exe(20212)] value testcookie=success
[2016-03-19 05:08:34.120 delegate.exe(20212)] Dictionary operation complite
[2016-03-19 05:08:34.120 delegate.exe(20212)] Check for Host header record
[2016-03-19 05:08:34.121 delegate.exe(20212)] Header line parsed
[2016-03-19 05:08:34.122 delegate.exe(20212)] did read line () block <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.122 delegate.exe(20212)] did parse headers () <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.122 delegate.exe(20212)] creating response <OFHTTPServerEx_Connection: 024A2070> socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.123 delegate.exe(20212)] Init <OFHTTPServerExResponse: 024A6968
Status code = 0
Headers = (nil)

with socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.124 delegate.exe(20212)] did write html <OFHTTPServerExResponse: 024A6968
Status code = 200
Headers = {
Set-Cookie = testcookie=success; Path=/; Domain=localhost; Discard;
Connection = Keep-Alive;
Content-Type = text/plain;
}
socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.126 delegate.exe(20212)] did send headers <OFHTTPServerExResponse: 024A6968
Status code = 200
Headers = {
Set-Cookie = testcookie=success; Path=/; Domain=localhost; Discard;
Connection = Keep-Alive;
Content-Type = text/plain;
}
socket <OFTCPSocket: 024A6728>
[2016-03-19 05:08:34.127 delegate.exe(20212)] did close server response <OFHTTPServerExResponse: 024A6968
Status code = 200
Headers = {
Set-Cookie = testcookie=success; Path=/; Domain=localhost; Discard;
Connection = Keep-Alive;
Content-Type = text/plain;
}
socket <OFTCPSocket: 024A6728>

As result next connections in current HTTP session (favicon image downloads eg) accepted by listening socket, closed by timeout

Adding a Macro similar to NSClassFromString()

I really like how dynamic the objective-c runtime is, and I miss that importing the runtime when using ObjFW is not that straight forward and even does not work when the Apple runtime is used (which obviously makes sense). So it would be nice, if at least a macro could be added that defaults to NSClassFromString on the Apple Runtime and provides similar functionality with OFString on other runtimes.

[Building] solve some issues with clang and Windows

ObjFW build system has some issues, if use clang compiler as ObjC compiler:

  1. asm if clang used as compiler, it is defined as assembler, in this case ASFLAGS should have "-no-integrated-as", otherwise we get error at compilation assembler sources

  2. clang only flags - on Windows (MSYS/Cygwin), clang use gcc and ld as linker, in this case compilation flags "-fno-constant-cfstrings", "-fblocks", "-fobjc-runtime=objfw" should be used with flag "-Xclang", otherwise clang call gcc at linking stage with those flags (gcc -fblocks -fno-constant-cfstrings -fobjc-runtime=objfw ... etc)

  3. broken posix threads (pthread) in clang 3.8 - on Windows clang 3.8 does not use -pthread by default, this will raise errors at linking stage

  4. "multiple definitions of symbol" error - this error fixed with additional linker flag "-Xlinker --allow-multiple-definition"

Report to You that I got successful build ObjFW with latest MSYS2 and Clang 3.8 with passed selftest

OFFileManger does not remove directories on Win32

removeIteamAtPath: method does not delete directories, except files located in that directory
I think ObjFW need to use _wrmdir instead _wremove

Tested on Windows 7SP1/10 with MinGW-W64 5.3/4.9 mingw_rt ver.4

#import <ObjFW/ObjFW.h>


int main(int argc, char const *argv[])
{
    OFFileManager* fm = [OFFileManager defaultManager];

    OFString* dir = [fm currentDirectoryPath];
    dir = [dir stringByAppendingPathComponent:@"test_dir"];

    [fm createDirectoryAtPath:dir];

    [fm removeItemAtPath:dir]; //exception Failed to remove item at path C:\MinGW\msys\1.0\home\gungravekoga\test_dir: Permission denied
    return 0;
}

[OFSettings] extend features

For now class OFSettings serach ini-file with settings only in user config path setted in OS environment variable, and only named like application name passed to init method , this behavior is very limited.
Maybe OFSettings should have method, which sets list of folders to search config-file, similar to OFLocalization class method "addLanguageDirectory:"?
And, maybe, method "initWithApplicationName:" should be renamed to "initWithName:", it has more sense, different ini-files for different application setting...?

doesn't compile ubuntu + clang

Ubuntu 14.04
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)

./configure --prefix=/home/yura/local --enable-static --enable-runtime
make

first, _GNU_SOURCE should be specified in src/exceptions/

 #include "config.h"
+#ifdef HAVE_DLADDR
+# define _GNU_SOURCE
+#endif

second i doesn't know how to fix:

OFAutoreleasePool.m:32:8: error: unknown type name 'thread_local'
static thread_local OFAutoreleasePool **cache = NULL;
       ^

Linux Subsystem for windows vs mingw

Hello - This is both an issue and a fix but I can't work out the protocol about submitting code to another repository

Clang is broken on msys2, something to do with saving the libraries as lib{}.dll instead of {}.dll
So I have written a shell script that builds eveything with the Linux subsystem for windows.

  1. You must have the windows 10 creators update (It means the Linux Ubuntu version is 16.04 instead of 14.04)
  2. you must install the Linux subsystem or reinstall if you had it before the creators update and make sure you install the Ubuntu option (default and only option as of writing)
  3. you open powershell and type bash to get to the Linux subsystem to run the script (for reasons I don't know, objfw fails the tests if it isn't inside powershell first?)

once in bash within powershell, this is the script you run as sudo:

green=`tput setaf 2`
reset=`tput sgr0`
echo "${green}Adding LLVM to sources${reset}"
llvmText="deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main
deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial main
# 4.0
deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main
deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main
# 5.0
deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main
deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main
"

if [ -e /etc/apt/sources.list.d/llvm.list ]
then
    echo "${green}Skipping LLVM Source installation - already there!${reset}"
else
    llvmText > /etc/apt/sources.list.d/llvm.list
    wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add -
fi

echo "${green}Updating & Upgrading Sources${reset}"
apt-get update
apt-get -y upgrade
apt-get install -y build-essential cmake autoconf clang-4.0 mingw-w64 gobjc++-mingw-w64 gobjc-mingw-w64
ls -s /usr/bin/clang-4.0 /usr/bin/clang
ls -s /usr/bin/clang++-4.0 /usr/bin/clang++

echo "${green}Getting wclang${reset}"
git clone https://github.com/tpoechtrager/wclang
cd wclang
echo "${green}Building wclang${reset}"
cmake -DCMAKE_INSTALL_PREFIX=/usr .
make
echo "${green}Copying Binaries to /usr/bin${reset}"
cd src
cp wclang /usr/bin/x86_64-w64-mingw32-clang
cp wclang /usr/bin/x86_64-w64-mingw32-clang++
cd ../../

echo "${green}Getting OBJFW${reset}"
git clone https://github.com/Midar/objfw
cd objfw
echo "${green}Running Config${reset}"
autoreconf
./configure --host=x86_64-w64-mingw32 --enable-static --disable-shared
echo "${green}Building${reset}"
make -j16
make install
echo "${green}Finished${reset}"

Here it is in gist: https://gist.github.com/yobson/3f6de8e375f45e1a4aeede1dbc2a37d1
hope this helps. Linux subsystem makes windows development 100000x better as it is far more intergrated with windows than msys2

hope my shell script helps!

James

OFTarArchiveEntry.m compilation error with Clang+MinGW for i686

OFTarArchiveEntry.m:70:25: error: implicit conversion from 'unsigned long long' to 'size_t' (aka 'unsigned int') changes value from 18446744073709551615 to 4294967295 [-Werror,-Wconstant-conversion]
header + 124, 12, UINT64_MAX);
^~~~~~~~~~
c:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include\stdint.h:89:20: note: expanded from macro 'UINT64_MAX'

define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */

               ^~~~~~~~~~~~~~~~~~~~~

OFTarArchiveEntry.m:74:25: error: implicit conversion from 'unsigned long long' to 'size_t' (aka 'unsigned int') changes value from 18446744073709551615 to 4294967295 [-Werror,-Wconstant-conversion]
header + 136, 12, UINTMAX_MAX)];
^~~~~~~~~~~
c:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include\stdint.h:138:21: note: expanded from macro 'UINTMAX_MAX'

define UINTMAX_MAX UINT64_MAX

                ^~~~~~~~~~

c:/mingw-w64/i686-4.9.2-posix-dwarf-rt_v3-rev1/mingw32/i686-w64-mingw32/include\stdint.h:89:20: note: expanded from macro 'UINT64_MAX'

define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */

               ^~~~~~~~~~~~~~~~~~~~~

OFTarArchiveEntry.m:150:21: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'size_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
exactLength: _toRead];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.