ObjFW  Check-in [d06376b200]

Overview
Comment:Get socket error in OFReadOrWriteFailedException if caused by a socket.
This only affects Win32.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d06376b2008aaffae69f04ab3b360f2a4c639efaf0e48936cef32144be31e02e
User & Date: js on 2009-04-22 17:59:12
Other Links: manifest | tags
Context
2009-04-22
22:17
Better handling of closed and ended files in OFFile. check-in: b13a0f08e7 user: js tags: trunk
17:59
Get socket error in OFReadOrWriteFailedException if caused by a socket.
This only affects Win32.
check-in: d06376b200 user: js tags: trunk
2009-04-21
18:07
Remove useless + load from OFObject. check-in: ba65a43f3f user: js tags: trunk
Changes

Modified src/OFExceptions.m from [38d5511316] to [5d90848615].

12
13
14
15
16
17
18











19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#import "config.h"

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>












#ifndef _WIN32
#include <errno.h>
#define GET_ERR	     errno
#define GET_SOCK_ERR errno
#define ERRFMT	     "Error string was: %s"
#define ERRPARAM     strerror(err)
#else
#include <windows.h>
#define GET_ERR	     GetLastError()
#define GET_SOCK_ERR WSAGetLastError()
#define ERRFMT	     "Error code was: %d"
#define ERRPARAM     err
#endif

#import <objc/objc-api.h>
#ifdef __objc_INCLUDE_GNU
#define SEL_NAME(x) sel_get_name(x)
#else
#import <objc/runtime.h>
#define SEL_NAME(x) sel_getName(x)
#endif

#import "OFExceptions.h"

#ifndef HAVE_ASPRINTF
#import "asprintf.h"
#endif

@implementation OFAllocFailedException
+ (Class)class
{







>
>
>
>
>
>
>
>
>
>
>














<
<
<
<
<
<
<
<
<
<







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43










44
45
46
47
48
49
50
#import "config.h"

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#import <objc/objc-api.h>
#ifdef __objc_INCLUDE_GNU
#define SEL_NAME(x) sel_get_name(x)
#else
#import <objc/runtime.h>
#define SEL_NAME(x) sel_getName(x)
#endif

#import "OFExceptions.h"
#import "OFTCPSocket.h"

#ifndef _WIN32
#include <errno.h>
#define GET_ERR	     errno
#define GET_SOCK_ERR errno
#define ERRFMT	     "Error string was: %s"
#define ERRPARAM     strerror(err)
#else
#include <windows.h>
#define GET_ERR	     GetLastError()
#define GET_SOCK_ERR WSAGetLastError()
#define ERRFMT	     "Error code was: %d"
#define ERRPARAM     err
#endif











#ifndef HAVE_ASPRINTF
#import "asprintf.h"
#endif

@implementation OFAllocFailedException
+ (Class)class
{
354
355
356
357
358
359
360




361
362
363
364
365
366
367
368
369
370
371
372
373




374
375
376
377
378
379
380
381
      andNItems: (size_t)nitems
{
	self = [super initWithClass: class_];

	req_size = size;
	req_items = nitems;
	has_items = YES;




	err = GET_ERR;

	return self;
}

- initWithClass: (Class)class_
	andSize: (size_t)size
{
	self = [super initWithClass: class_];

	req_size = size;
	req_items = 0;
	has_items = NO;




	err = GET_ERR;

	return self;
}

- (int)errNo
{
	return err;







>
>
>
>
|












>
>
>
>
|







355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
      andNItems: (size_t)nitems
{
	self = [super initWithClass: class_];

	req_size = size;
	req_items = nitems;
	has_items = YES;

	if (class_ == [OFTCPSocket class])
		err = GET_SOCK_ERR;
	else
		err = GET_ERR;

	return self;
}

- initWithClass: (Class)class_
	andSize: (size_t)size
{
	self = [super initWithClass: class_];

	req_size = size;
	req_items = 0;
	has_items = NO;

	if (class_ == [OFTCPSocket class])
		err = GET_SOCK_ERR;
	else
		err = GET_ERR;

	return self;
}

- (int)errNo
{
	return err;