28#ifndef OO_EXCLUDE_DEBUG_SUPPORT
38#ifdef OO_LOG_DEBUG_PROTOCOL_PACKETS
41#define LogOOTCPStreamDecoderPacket(packet) do {} while (0)
68 if (packetCB == NULL)
return NULL;
70 decoder = malloc(
sizeof *decoder);
71 if (decoder == NULL)
return NULL;
76 decoder->
Packet = packetCB;
77 decoder->
Error = errorCB;
87 if (decoder == NULL)
return;
106 if (decoder == NULL || data == NULL)
return;
114 const unsigned char *bytes = NULL;
119 if (decoder == NULL)
return;
124 if (bytes == NULL && remaining != 0)
126 Error(decoder,
OOALSTR(
"Invalid data -- NULL bytes but %u byte count."), remaining);
130 while (remaining != 0)
135 bytesToAdd = remaining;
140 remaining -= bytesToAdd;
166 (decoder->
header[1] << 16) |
167 (decoder->
header[2] << 8) |
168 (decoder->
header[3] << 0);
178 Error(decoder,
OOALSTR(
"OOTCPStreamDecoder internal error: reached unreachable state. nextSize = %lu, bufferUsed = %lu, nextPacketData = %@."), (
unsigned long)decoder->
nextSize, (
unsigned long)decoder->
headerSpaceUsed, decoder->
nextPacketData);
195 Error(decoder,
OOALSTR(
"Protocol error: packet is not property list (property list error: %@)."), errorString);
211 if (packetType == NULL)
213 Error(decoder,
OOALSTR(
"Protocol error: packet contains no packet type."));
232 if (decoder == NULL || decoder->
Error == NULL || format == NULL)
return;
234 va_start(args, format);
OOALStringRef OOTypeDescription(OOALObjectRef object)
bool OOALIsDictionary(OOALObjectRef object)
OOALStringRef OOALStringCreateWithFormatAndArguments(OOALStringRef format, va_list args)
const struct NSAutoreleasePool * OOALAutoreleasePoolRef
void OOALMutableDataAppendBytes(OOALMutableDataRef data, const void *bytes, size_t length)
const void * OOALDataGetBytePtr(OOALDataRef data)
const struct NSString * OOALStringRef
size_t OOALDataGetLength(OOALDataRef data)
OOALObjectRef OOALDictionaryGetValue(OOALDictionaryRef dictionary, OOALObjectRef key)
#define OOALDestroyAutoreleasePool(pool)
const struct NSDictionary * OOALDictionaryRef
bool OOALIsString(OOALObjectRef object)
OOALAutoreleasePoolRef OOALCreateAutoreleasePool(void)
struct NSData * OOALMutableDataRef
OOALMutableDataRef OOALDataCreateMutable(size_t capacity)
void OOALRelease(OOALObjectRef object)
OOALObjectRef OOALPropertyListFromData(OOALMutableDataRef data, OOALStringRef *errStr)
const struct NSData * OOALDataRef
OOTCPStreamDecoderRef OOTCPStreamDecoderCreate(OOTCPStreamDecoderPacketCallback packetCB, OOTCPStreamDecoderErrorCallback errorCB, OOTCPStreamDecoderFinalizeCallback finalizeCB, void *cbInfo)
static void PacketReady(OOTCPStreamDecoderRef decoder)
void OOTCPStreamDecoderReceiveBytes(OOTCPStreamDecoderRef decoder, const void *inBytes, size_t length)
void OOTCPStreamDecoderDestroy(OOTCPStreamDecoderRef decoder)
static void Error(OOTCPStreamDecoderRef decoder, OOALStringRef format,...)
void OOTCPStreamDecoderReceiveData(OOTCPStreamDecoderRef decoder, OOALDataRef data)
#define LogOOTCPStreamDecoderPacket(packet)
void(* OOTCPStreamDecoderFinalizeCallback)(void *cbInfo)
void(* OOTCPStreamDecoderPacketCallback)(void *cbInfo, OOALStringRef packetType, OOALDictionaryRef packet)
void(* OOTCPStreamDecoderErrorCallback)(void *cbInfo, OOALStringRef errorDesc)
OOTCPStreamDecoderFinalizeCallback Finalize
OOALMutableDataRef nextPacketData
OOTCPStreamDecoderErrorCallback Error
OOTCPStreamDecoderPacketCallback Packet