ObjFW  Check-in [e668c03098]

Overview
Comment:Add errno in exceptions where it's useful.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e668c03098cf92a6e99b52b1e7529f1ba65ed2c502049031fbbfb9a54a3882e6
User & Date: js on 2008-12-19 23:15:00
Other Links: manifest | tags
Context
2008-12-20
14:19
Remove wchar_t stuff, as that's not portable anyway. check-in: 4360177618 user: js tags: trunk
2008-12-19
23:15
Add errno in exceptions where it's useful. check-in: e668c03098 user: js tags: trunk
22:30
Better variable names for initialization of some exceptions. check-in: 5ad7e24b78 user: js tags: trunk
Changes

Modified src/Makefile from [92b50c2e19] to [89b989e5ca].

18
19
20
21
22
23
24
25
26
27
28
29
30

INCLUDES = ${SRCS:.m=.h}	\
	   OFMacros.h		\
	   OFStream.h

include ../buildsys.mk

CPPFLAGS += -I..
CFLAGS += ${LIB_CFLAGS}
OBJCFLAGS += ${LIB_CFLAGS}
LD = ${OBJC}
LDFLAGS += ${LIB_LDFLAGS}
LIBS += -lobjc







|



|

18
19
20
21
22
23
24
25
26
27
28
29
30

INCLUDES = ${SRCS:.m=.h}	\
	   OFMacros.h		\
	   OFStream.h

include ../buildsys.mk

CPPFLAGS += -I.. -pthread
CFLAGS += ${LIB_CFLAGS}
OBJCFLAGS += ${LIB_CFLAGS}
LD = ${OBJC}
LDFLAGS += ${LIB_LDFLAGS} -pthread
LIBS += -lobjc

Modified src/OFExceptions.h from [4f1293951f] to [e7cf625e34].

146
147
148
149
150
151
152

153
154
155
156
157
158
159
/**
 * An OFException indicating the file couldn't be opened.
 */
@interface OFOpenFileFailedException: OFException
{
	char *path;
	char *mode;

}

/**
 * \param obj The object which caused the exception
 * \param path A C string of the path to the file tried to open
 * \param mode A C string of the mode in which the file should have been opened
 * \return A new open file failed exception







>







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/**
 * An OFException indicating the file couldn't be opened.
 */
@interface OFOpenFileFailedException: OFException
{
	char *path;
	char *mode;
	int  err;
}

/**
 * \param obj The object which caused the exception
 * \param path A C string of the path to the file tried to open
 * \param mode A C string of the mode in which the file should have been opened
 * \return A new open file failed exception
177
178
179
180
181
182
183





184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202

203
204
205
206
207
208
209
- free;

/**
 * \return An error message for the exception as a C String
 */
- (const char*)cString;






/**
 * \return A C string of the path to the file which couldn't be opened
 */
- (char*)path;

/**
 * \return A C string of the mode in which the file should have been opened
 */
- (char*)mode;
@end

/**
 * An OFException indicating a read or write to the file failed.
 */
@interface OFReadOrWriteFailedException: OFException
{
	size_t req_size;
	size_t req_items;
	BOOL has_items;

}

/**
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \param nitems The requested number of items that couldn't be read / written
 * \return A new open file failed exception







>
>
>
>
>


















|
>







178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
- free;

/**
 * \return An error message for the exception as a C String
 */
- (const char*)cString;

/**
 * \return The errno from when the exception was created
 */
- (int)errNo;

/**
 * \return A C string of the path to the file which couldn't be opened
 */
- (char*)path;

/**
 * \return A C string of the mode in which the file should have been opened
 */
- (char*)mode;
@end

/**
 * An OFException indicating a read or write to the file failed.
 */
@interface OFReadOrWriteFailedException: OFException
{
	size_t req_size;
	size_t req_items;
	BOOL   has_items;
	int    err;
}

/**
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \param nitems The requested number of items that couldn't be read / written
 * \return A new open file failed exception
238
239
240
241
242
243
244





245
246
247
248
249
250
251
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \return A new open file failed exception
 */
- initWithObject: (id)obj
	 andSize: (size_t)size;






/**
 * \return The requested size of the data that couldn't be read / written
 */
- (size_t)requestedSize;

/**
 * \return The requested number of items that coudln't be read / written







>
>
>
>
>







245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \return A new open file failed exception
 */
- initWithObject: (id)obj
	 andSize: (size_t)size;

/**
 * \return The errno from when the exception was created
 */
- (int)errNo;

/**
 * \return The requested size of the data that couldn't be read / written
 */
- (size_t)requestedSize;

/**
 * \return The requested number of items that coudln't be read / written
322
323
324
325
326
327
328

329
330
331
332
333
334
335
/**
 * An OFException indicating the translation of an address failed.
 */
@interface OFAddressTranslationFailedException: OFException
{
	char *node;
	char *service;

}

/**
 * \param obj The object which caused the exception
 * \param node The node for which translation was requested
 * \param service The service of the node for which translation was requested
 * \return A new address translation failed exception







>







334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
/**
 * An OFException indicating the translation of an address failed.
 */
@interface OFAddressTranslationFailedException: OFException
{
	char *node;
	char *service;
	int  err;
}

/**
 * \param obj The object which caused the exception
 * \param node The node for which translation was requested
 * \param service The service of the node for which translation was requested
 * \return A new address translation failed exception
353
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
382
383
384
- free;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;






/**
 * /return The node for which translation was requested
 */
- (const char*)node;

/**
 * \return The service of the node for which translation was requested
 */
- (const char*)service;
@end

/**
 * An OFException indicating that the connection could not be established.
 */
@interface OFConnectionFailedException: OFException
{
	char *host;
	uint16_t port;

}

/**
 * \param obj The object which caused the exception
 * \param host The host to which the connection failed
 * \param port The port on the host to which the connection failed
 * \return A new connection failed exception







>
>
>
>
>
















|

>







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
391
392
393
394
395
396
397
398
399
400
401
402
403
- free;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;

/**
 * \return The errno from when the exception was created
 */
- (int)errNo;

/**
 * /return The node for which translation was requested
 */
- (const char*)node;

/**
 * \return The service of the node for which translation was requested
 */
- (const char*)service;
@end

/**
 * An OFException indicating that the connection could not be established.
 */
@interface OFConnectionFailedException: OFException
{
	char	 *host;
	uint16_t port;
	int	 err;
}

/**
 * \param obj The object which caused the exception
 * \param host The host to which the connection failed
 * \param port The port on the host to which the connection failed
 * \return A new connection failed exception
402
403
404
405
406
407
408





409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427

428
429
430
431
432
433
434
- free;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;






/**
 * \return The host to which the connection failed
 */
- (const char*)host;

/**
 * \return The port on the host to which the connection failed
 */
- (uint16_t)port;
@end

/**
 * An OFException indicating that binding the socket failed.
 */
@interface OFBindFailedException: OFException
{
	char *host;
	uint16_t port;
	int family;

}

/**
 * \param obj The object which caused the exception
 * \param host The host on which binding failed
 * \param port The port on which binding failed
 * \param family The family for which binnding failed







>
>
>
>
>
















|

|
>







421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
- free;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;

/**
 * \return The errno from when the exception was created
 */
- (int)errNo;

/**
 * \return The host to which the connection failed
 */
- (const char*)host;

/**
 * \return The port on the host to which the connection failed
 */
- (uint16_t)port;
@end

/**
 * An OFException indicating that binding the socket failed.
 */
@interface OFBindFailedException: OFException
{
	char	 *host;
	uint16_t port;
	int	 family;
	int	 err;
}

/**
 * \param obj The object which caused the exception
 * \param host The host on which binding failed
 * \param port The port on which binding failed
 * \param family The family for which binnding failed
456
457
458
459
460
461
462





463
464
465
466
467
468
469
- free;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;






/**
 * \return The host on which binding failed
 */
- (const char*)host;

/**
 * \return The port on which binding failed







>
>
>
>
>







481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
- free;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;

/**
 * \return The errno from when the exception was created
 */
- (int)errNo;

/**
 * \return The host on which binding failed
 */
- (const char*)host;

/**
 * \return The port on which binding failed
478
479
480
481
482
483
484

485
486
487
488
489
490
491

/**
 * An OFException indicating that listening on the socket failed.
 */
@interface OFListenFailedException: OFException
{
	int backlog;

}

/**
 * \param obj The object which caused the exception
 * \param backlog The requested size of the back log
 * \return A new listen failed exception
 */







>







508
509
510
511
512
513
514
515
516
517
518
519
520
521
522

/**
 * An OFException indicating that listening on the socket failed.
 */
@interface OFListenFailedException: OFException
{
	int backlog;
	int err;
}

/**
 * \param obj The object which caused the exception
 * \param backlog The requested size of the back log
 * \return A new listen failed exception
 */
503
504
505
506
507
508
509





510
511
512
513
514
515
516
517
518
519












520
521
522
523





524
      andBackLog: (int)backlog;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;






/**
 * \return The requested back log.
 */
- (int)backLog;
@end

/**
 * An OFException indicating that accepting a connection failed.
 */
@interface OFAcceptFailedException: OFException {}












/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;





@end







>
>
>
>
>









|
>
>
>
>
>
>
>
>
>
>
>
>




>
>
>
>
>

534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
      andBackLog: (int)backlog;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;

/**
 * \return The errno from when the exception was created
 */
- (int)errNo;

/**
 * \return The requested back log.
 */
- (int)backLog;
@end

/**
 * An OFException indicating that accepting a connection failed.
 */
@interface OFAcceptFailedException: OFException
{
	int err;
}

/**
 * Initializes an already allocated accept failed exception.
 *
 * \param obj The object which caused the exception
 * \return An initialized accept failed exception
 */
- initWithObject: (id)obj;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;

/**
 * \return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/OFExceptions.m from [735948244b] to [1c2da67154].

11
12
13
14
15
16
17

18
19
20
21
22
23
24

#import "config.h"

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


#import "OFExceptions.h"

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








>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#import "config.h"

#define _GNU_SOURCE
#import <stdio.h>
#import <stdlib.h>
#import <string.h>
#import <errno.h>

#import "OFExceptions.h"

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

166
167
168
169
170
171
172

173
174
175
176
177
178
179
- initWithObject: (id)obj
	 andPath: (const char*)path_
	 andMode: (const char*)mode_
{
	if ((self = [super initWithObject: obj])) {
		path = (path_ != NULL ? strdup(path_) : NULL);
		mode = (mode_ != NULL ? strdup(mode_) : NULL);

	}

	return self;
}

- free
{







>







167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
- initWithObject: (id)obj
	 andPath: (const char*)path_
	 andMode: (const char*)mode_
{
	if ((self = [super initWithObject: obj])) {
		path = (path_ != NULL ? strdup(path_) : NULL);
		mode = (mode_ != NULL ? strdup(mode_) : NULL);
		err = errno;
	}

	return self;
}

- free
{
187
188
189
190
191
192
193
194

195
196
197





198
199
200
201
202
203
204

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "Failed to open file %s with mode %s in object of "
	    "class %s!", path, mode, [self name]);


	return string;
}






- (char*)path
{
	return path;
}

- (char*)mode







|
>



>
>
>
>
>







189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "Failed to open file %s with mode %s in object of "
	    "class %s! Error string was: %s", path, mode, [self name],
	    strerror(err));

	return string;
}

- (int)errNo
{
	return err;
}

- (char*)path
{
	return path;
}

- (char*)mode
228
229
230
231
232
233
234

235
236
237
238
239
240
241
242
243
244
245
246

247
248
249
250





251
252
253
254
255
256
257
	 andSize: (size_t)size
       andNItems: (size_t)nitems
{
	if ((self = [super initWithObject: obj])) {
		req_size = size;
		req_items = nitems;
		has_items = YES;

	}

	return self;
}

- initWithObject: (id)obj
	 andSize: (size_t)size
{
	if ((self = [super initWithObject: obj])) {
		req_size = size;
		req_items = 0;
		has_items = NO;

	}

	return self;
}






- (size_t)requestedSize
{
	return req_size;
}

- (size_t)requestedItems







>












>




>
>
>
>
>







236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
	 andSize: (size_t)size
       andNItems: (size_t)nitems
{
	if ((self = [super initWithObject: obj])) {
		req_size = size;
		req_items = nitems;
		has_items = YES;
		err = errno;
	}

	return self;
}

- initWithObject: (id)obj
	 andSize: (size_t)size
{
	if ((self = [super initWithObject: obj])) {
		req_size = size;
		req_items = 0;
		has_items = NO;
		err = errno;
	}

	return self;
}

- (int)errNo
{
	return err;
}

- (size_t)requestedSize
{
	return req_size;
}

- (size_t)requestedItems
269
270
271
272
273
274
275

276
277
278
279

280
281
282
283
284
285
286
287
288
289
290
291
292

293
294
295
296

297
298
299
300
301
302
303
- (const char*)cString
{
	if (string != NULL)
		return string;;

	if (has_items)
		asprintf(&string, "Failed to read %zu items of size %zu in "

		    "object of class %s!", req_items, req_size, [object name]);
	else
		asprintf(&string, "Failed to read %zu bytes in object of class "
		    "%s!", req_size, [object name]);


	return string;
}
@end

@implementation OFWriteFailedException
- (const char*)cString
{
	if (string != NULL)
		return string;

	if (has_items)
		asprintf(&string, "Failed to write %zu items of size %zu in "

		    "object of class %s!", req_items, req_size, [object name]);
	else
		asprintf(&string, "Failed to write %zu bytes in object of "
		    "class %s!", req_size, [object name]);


	return string;
}
@end

@implementation OFSetOptionFailedException
- (const char*)cString







>
|


|
>













>
|


|
>







284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
- (const char*)cString
{
	if (string != NULL)
		return string;;

	if (has_items)
		asprintf(&string, "Failed to read %zu items of size %zu in "
		    "object of class %s! Error string was: %s", req_items,
		    req_size, [object name], strerror(err));
	else
		asprintf(&string, "Failed to read %zu bytes in object of class "
		    "%s! Error string was: %s", req_size, [object name],
		    strerror(err));

	return string;
}
@end

@implementation OFWriteFailedException
- (const char*)cString
{
	if (string != NULL)
		return string;

	if (has_items)
		asprintf(&string, "Failed to write %zu items of size %zu in "
		    "object of class %s! Error string was: %s", req_items,
		    req_size, [object name], strerror(err));
	else
		asprintf(&string, "Failed to write %zu bytes in object of "
		    "class %s! Error string was: %s", req_size, [object name],
		    strerror(err));

	return string;
}
@end

@implementation OFSetOptionFailedException
- (const char*)cString
365
366
367
368
369
370
371

372
373
374
375
376
377
378
- initWithObject: (id)obj
	 andNode: (const char*)node_
      andService: (const char*)service_
{
	if ((self = [super initWithObject: obj])) {
		node = (node_ != NULL ? strdup(node_) : NULL);
		service = (service_ != NULL ? strdup(service_) : NULL);

	}

	return self;
}

- free
{







>







384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
- initWithObject: (id)obj
	 andNode: (const char*)node_
      andService: (const char*)service_
{
	if ((self = [super initWithObject: obj])) {
		node = (node_ != NULL ? strdup(node_) : NULL);
		service = (service_ != NULL ? strdup(service_) : NULL);
		err = errno;
	}

	return self;
}

- free
{
389
390
391
392
393
394
395
396
397

398
399
400





401
402
403
404
405
406
407
	if (string != NULL)
		return string;

	asprintf(&string, "The service %s on %s could not be translated to an "
	    "address for an object of type %s. This means that either the node "
	    "was not found, there is no such service on the node, there was a "
	    "problem with the name server, there was a problem with your "
	    "network connection or you specified an invalid node or service.",
	    service, node, [object name]);


	return string;
}






- (const char*)node
{
	return node;
}

- (const char*)service







|
|
>



>
>
>
>
>







409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
	if (string != NULL)
		return string;

	asprintf(&string, "The service %s on %s could not be translated to an "
	    "address for an object of type %s. This means that either the node "
	    "was not found, there is no such service on the node, there was a "
	    "problem with the name server, there was a problem with your "
	    "network connection or you specified an invalid node or service. "
	    "Error string was: %s", service, node, [object name],
	    strerror(err));

	return string;
}

- (int)errNo
{
	return err;
}

- (const char*)node
{
	return node;
}

- (const char*)service
423
424
425
426
427
428
429

430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449

450
451
452





453
454
455
456
457
458
459
- initWithObject: (id)obj
	 andHost: (const char*)host_
	 andPort: (uint16_t)port_
{
	if ((self = [super initWithObject: obj])) {
		host = (host_ != NULL ? strdup(host_) : NULL);
		port = port_;

	}

	return self;
}

- free
{
	if (host != NULL)
		free(host);

	return [super free];
}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "A connection to %s:%d could not be established in "
	    "object of type %s!", host, port, [object name]);


	return string;
}






- (const char*)host
{
	return host;
}

- (uint16_t)port







>



















|
>



>
>
>
>
>







449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
- initWithObject: (id)obj
	 andHost: (const char*)host_
	 andPort: (uint16_t)port_
{
	if ((self = [super initWithObject: obj])) {
		host = (host_ != NULL ? strdup(host_) : NULL);
		port = port_;
		err = errno;
	}

	return self;
}

- free
{
	if (host != NULL)
		free(host);

	return [super free];
}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "A connection to %s:%d could not be established in "
	    "object of type %s! Error string was: %s", host, port,
	    [object name], strerror(err));

	return string;
}

- (int)errNo
{
	return err;
}

- (const char*)host
{
	return host;
}

- (uint16_t)port
479
480
481
482
483
484
485

486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505

506
507
508





509
510
511
512
513
514
515
	 andPort: (uint16_t)port_
       andFamily: (int)family_
{
	if ((self = [super initWithObject: obj])) {
		host = (host_ != NULL ? strdup(host_) : NULL);
		port = port_;
		family = family_;

	}

	return self;
}

- free
{
	if (host != NULL)
		free(host);

	return [super free];
}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "Binding to port %d on %s using family %d failed in "
	    "object of type %s!", port, host, family, [object name]);


	return string;
}






- (const char*)host
{
	return host;
}

- (uint16_t)port







>



















|
>



>
>
>
>
>







512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
	 andPort: (uint16_t)port_
       andFamily: (int)family_
{
	if ((self = [super initWithObject: obj])) {
		host = (host_ != NULL ? strdup(host_) : NULL);
		port = port_;
		family = family_;
		err = errno;
	}

	return self;
}

- free
{
	if (host != NULL)
		free(host);

	return [super free];
}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "Binding to port %d on %s using family %d failed in "
	    "object of type %s! Error string was: %s", port, host, family,
	    [object name], strerror(err));

	return string;
}

- (int)errNo
{
	return err;
}

- (const char*)host
{
	return host;
}

- (uint16_t)port
530
531
532
533
534
535
536
537
538


539
540
541
542
543
544
545
546
547
548
549

550
551
552





553
554
555
556
557
558
559
560








561
562
563
564
565
566
567
568
569
570





571
	return [[self alloc] initWithObject: obj
				 andBackLog: backlog_];
}

- initWithObject: (id)obj
      andBackLog: (int)backlog_
{
	if ((self = [super initWithObject: obj]))
		backlog = backlog_;



	return self;
}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "Failed to listen in socket of type %s with a back "
	    "log of %d!", [object name], backlog);


	return string;
}






- (int)backLog
{
	return backlog;
}
@end

@implementation OFAcceptFailedException








- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "Failed to accept connection in socket of type %s!",
	    [object name]);

	return string;
}





@end







|

>
>










|
>



>
>
>
>
>








>
>
>
>
>
>
>
>





|
|



>
>
>
>
>

570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
	return [[self alloc] initWithObject: obj
				 andBackLog: backlog_];
}

- initWithObject: (id)obj
      andBackLog: (int)backlog_
{
	if ((self = [super initWithObject: obj])) {
		backlog = backlog_;
		err = errno;
	}

	return self;
}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "Failed to listen in socket of type %s with a back "
	    "log of %d! Error string was: %s", [object name], backlog,
	    strerror(err));

	return string;
}

- (int)errNo
{
	return err;
}

- (int)backLog
{
	return backlog;
}
@end

@implementation OFAcceptFailedException
- initWithObject: (id)obj
{
	if ((self = [super initWithObject: obj]))
		err = errno;

	return self;
}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "Failed to accept connection in socket of type %s! "
	    "Error string was: %s", [object name], strerror(err));

	return string;
}

- (int)errNo
{
	return err;
}
@end

Modified src/OFObject.h from [0778c8e9f4] to [ac2041ef80].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#import <stdint.h>

/**
 * The OFObject class is the base class for all other classes inside ObjFW.
 */
@interface OFObject: Object
{
	void **__memchunks;
	size_t __memchunks_size;
}

/**
 * Initialize the already allocated object.
 * Also sets up the memory pool for the object.
 *







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#import <stdint.h>

/**
 * The OFObject class is the base class for all other classes inside ObjFW.
 */
@interface OFObject: Object
{
	void   **__memchunks;
	size_t __memchunks_size;
}

/**
 * Initialize the already allocated object.
 * Also sets up the memory pool for the object.
 *

Modified src/OFTCPSocket.h from [e73bbae27a] to [4b9806efa1].

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#endif

/**
 * The OFTCPSocket class provides functions to create and use sockets.
 */
@interface OFTCPSocket: OFObject <OFStream>
{
	int sock;
	struct sockaddr *saddr;
	socklen_t saddr_len;
}

/**
 * Initializes an already allocated OFTCPSocket.
 *
 * \return An initialized OFTCPSocket







|
|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#endif

/**
 * The OFTCPSocket class provides functions to create and use sockets.
 */
@interface OFTCPSocket: OFObject <OFStream>
{
	int	  sock;
	struct	  sockaddr *saddr;
	socklen_t saddr_len;
}

/**
 * Initializes an already allocated OFTCPSocket.
 *
 * \return An initialized OFTCPSocket