Overview
Context
Changes
Modified src/OFFile.m
from [59b3e4b4fd]
to [73e673b29a].
︙ | | |
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
|
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
|
-
-
+
+
-
-
-
+
-
-
|
if ((ret = read(fileDescriptor, buffer, length)) == 0)
isAtEndOfStream = YES;
return ret;
}
- (size_t)_writeNBytes: (size_t)length
fromBuffer: (const void*)buffer
- (void)_writeNBytes: (size_t)length
fromBuffer: (const void*)buffer
{
size_t ret;
if (fileDescriptor == -1 || isAtEndOfStream ||
(ret = write(fileDescriptor, buffer, length)) < length)
write(fileDescriptor, buffer, length) < length)
@throw [OFWriteFailedException newWithClass: isa
stream: self
requestedLength: length];
return ret;
}
- (void)_seekToOffset: (off_t)offset
{
if (lseek(fileDescriptor, offset, SEEK_SET) == -1)
@throw [OFSeekFailedException newWithClass: isa
stream: self
|
︙ | | |
Modified src/OFStream.h
from [a6e5a685c5]
to [848fb0d1e3].
︙ | | |
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
-
-
-
+
+
|
- (void)flushWriteBuffer;
/**
* Writes from a buffer into the stream.
*
* \param buffer The buffer from which the data is written to the stream
* \param length The length of the data that should be written
* \return The number of bytes written
*/
- (size_t)writeNBytes: (size_t)length
fromBuffer: (const void*)buffer;
- (void)writeNBytes: (size_t)length
fromBuffer: (const void*)buffer;
/**
* Writes a uint8_t into the stream.
*
* \param int8 A uint8_t
*/
- (void)writeInt8: (uint8_t)int8;
|
︙ | | |
Modified src/OFStream.m
from [fbc06e6c49]
to [d77796d59f].
︙ | | |
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
-
-
+
+
|
- (size_t)_readNBytes: (size_t)length
intoBuffer: (void*)buffer
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
- (size_t)_writeNBytes: (size_t)length
fromBuffer: (const void*)buffer
- (void)_writeNBytes: (size_t)length
fromBuffer: (const void*)buffer
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
- (BOOL)isAtEndOfStream
{
|
︙ | | |
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
|
-
-
+
+
-
-
+
+
-
-
|
fromBuffer: writeBuffer];
[self freeMemory: writeBuffer];
writeBuffer = NULL;
writeBufferLength = 0;
}
- (size_t)writeNBytes: (size_t)length
fromBuffer: (const void*)buffer
- (void)writeNBytes: (size_t)length
fromBuffer: (const void*)buffer
{
if (!buffersWrites)
return [self _writeNBytes: length
fromBuffer: buffer];
[self _writeNBytes: length
fromBuffer: buffer];
else {
writeBuffer = [self resizeMemory: writeBuffer
toSize: writeBufferLength + length];
memcpy(writeBuffer + writeBufferLength, buffer, length);
writeBufferLength += length;
return length;
}
}
- (void)writeInt8: (uint8_t)int8
{
[self writeNBytes: 1
fromBuffer: (char*)&int8];
|
︙ | | |
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
|
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
-
+
-
-
+
+
-
+
|
[self writeNBytes: 8
fromBuffer: (char*)&double_];
}
- (size_t)writeDataArray: (OFDataArray*)dataArray
{
return [self writeNBytes: [dataArray count] * [dataArray itemSize]
fromBuffer: [dataArray cArray]];
size_t length = [dataArray count] * [dataArray itemSize];
[self writeNBytes: length
fromBuffer: [dataArray cArray]];
return [dataArray count] * [dataArray itemSize];
}
- (size_t)writeString: (OFString*)string
{
size_t length = [string cStringLength];
return [self writeNBytes: [string cStringLength]
fromBuffer: [string cString]];
[self writeNBytes: length
fromBuffer: [string cString]];
return length;
}
- (size_t)writeLine: (OFString*)string
{
size_t retLength, stringLength = [string cStringLength];
size_t stringLength = [string cStringLength];
char *buffer;
buffer = [self allocMemoryWithSize: stringLength + 1];
@try {
memcpy(buffer, [string cString], stringLength);
buffer[stringLength] = '\n';
retLength = [self writeNBytes: stringLength + 1
fromBuffer: buffer];
[self writeNBytes: stringLength + 1
fromBuffer: buffer];
} @finally {
[self freeMemory: buffer];
}
return retLength;
return stringLength + 1;
}
- (size_t)writeFormat: (OFString*)format, ...
{
va_list arguments;
size_t ret;
|
︙ | | |
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
|
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
|
-
-
+
+
-
+
-
|
selector: _cmd];
if ((length = of_vasprintf(&cString, [format cString],
arguments)) == -1)
@throw [OFInvalidFormatException newWithClass: isa];
@try {
return [self writeNBytes: length
fromBuffer: cString];
[self writeNBytes: length
fromBuffer: cString];
} @finally {
free(cString);
}
/* Get rid of a warning, never reached anyway */
return length;
assert(0);
}
- (size_t)pendingBytes
{
return cacheLength;
}
|
︙ | | |
Modified src/OFStreamSocket.m
from [a6c16a5220]
to [8d5170a63f].
︙ | | |
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
-
-
+
+
-
-
-
+
-
-
|
if (ret == 0)
isAtEndOfStream = YES;
return ret;
}
- (size_t)_writeNBytes: (size_t)length
fromBuffer: (const void*)buffer
- (void)_writeNBytes: (size_t)length
fromBuffer: (const void*)buffer
{
ssize_t ret;
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException newWithClass: isa
socket: self];
if (isAtEndOfStream) {
OFWriteFailedException *e;
e = [OFWriteFailedException newWithClass: isa
stream: self
requestedLength: length];
#ifndef _WIN32
e->errNo = ENOTCONN;
#else
e->errNo = WSAENOTCONN;
#endif
@throw e;
}
if ((ret = send(sock, buffer, length, 0)) == -1)
if (send(sock, buffer, length, 0) < length)
@throw [OFWriteFailedException newWithClass: isa
stream: self
requestedLength: length];
return ret;
}
#ifdef _WIN32
- (void)setBlocking: (BOOL)enable
{
u_long v = enable;
isBlocking = enable;
|
︙ | | |