Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -162,20 +162,20 @@ /** * \return An error message for the exception as a C String */ - (char*)cString; -/*** +/** * \return A pointer to the memory which is not part of the object */ - (void*)pointer; @end /** * An OFException indicating the given value is out of range. */ -@interface OFOutOfRangeException: OFException +@interface OFOutOfRangeException: OFException {} /** * Creates a new out of range exception. * * \param obj The object which caused the exception * \return A new out of range exception @@ -287,21 +287,21 @@ @end /** * An OFException indicating a read to the file failed. */ -@interface OFReadFailedException: OFReadOrWriteFailedException +@interface OFReadFailedException: OFReadOrWriteFailedException {} /** * \return An error message for the exception as a C String */ - (char*)cString; @end /** * An OFException indicating a write to the file failed. */ -@interface OFWriteFailedException: OFReadOrWriteFailedException +@interface OFWriteFailedException: OFReadOrWriteFailedException {} /** * \return An error message for the exception as a C String */ - (char*)cString; @end Index: src/OFHashes.h ================================================================== --- src/OFHashes.h +++ src/OFHashes.h @@ -14,10 +14,13 @@ #import "OFObject.h" #define MD5_DIGEST_SIZE 16 #define SHA1_DIGEST_SIZE 20 +/** + * The OFMD5Hash class provides functions to create an MD5 hash. + */ @interface OFMD5Hash: OFObject { uint32_t buf[4]; uint32_t bits[2]; uint8_t in[64]; @@ -24,15 +27,30 @@ BOOL calculated; } - init; + +/** + * Adds a buffer to the hash to be calculated. + * + * \param buf The buffer which should be included into calculation. + * \param size The size of the buffer + */ - updateWithBuffer: (const uint8_t*)buf ofSize: (size_t)size; + +/** + * \return A buffer containing the hash (MD5_DIGEST_SIZE = 16 bytes). + * The buffer is part of object's memory pool. + */ - (uint8_t*)digest; @end +/** + * The OFSHA1Hash class provides functions to create an SHA1 hash. + */ @interface OFSHA1Hash: OFObject { uint32_t state[5]; uint64_t count; uint8_t buffer[64]; @@ -40,9 +58,21 @@ BOOL calculated; } - init; + +/** + * Adds a buffer to the hash to be calculated. + * + * \param buf The buffer which should be included into calculation. + * \param size The size of the buffer + */ - updateWithBuffer: (const uint8_t*)buf ofSize: (size_t)size; + +/** + * \return A buffer containing the hash (SHA1_DIGEST_SIZE = 20 bytes). + * The buffer is part of object's memory pool. + */ - (uint8_t*)digest; @end Index: src/OFList.h ================================================================== --- src/OFList.h +++ src/OFList.h @@ -10,19 +10,50 @@ */ #import "OFObject.h" #import "OFListObject.h" +/** + * The OFList class provides easy to use double-linked lists. + */ @interface OFList: OFObject { OFListObject *first; OFListObject *last; } - init; + +/** + * Frees the OFList and all OFListObjects, but not the data they contian. + */ - free; + +/** + * Frees the list and the data included in all OFListObjects it contains. + */ - freeIncludingData; + +/** + * \returns The first OFListObject in the OFList + */ - (OFListObject*)first; + +/** + * \returns The last OFListObject in the OFList + */ - (OFListObject*)last; -- add: (OFListObject*)ptr; + +/** + * Adds a new OFListObject to the OFList. + * + * \param obj An OFListObject + */ +- add: (OFListObject*)obj; + +/** + * Creates a new OFListObject and adds it to the OFList. + * + * \param ptr Pointer to the data for the OFListObject which will be added + */ - addNew: (void*)ptr; @end Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -56,25 +56,25 @@ - (OFListObject*)last { return last; } -- add: (OFListObject*)ptr +- add: (OFListObject*)obj { if (!first || !last) { - first = last = ptr; + first = last = obj; return self; } - [ptr setPrev: last]; - [last setNext: ptr]; + [obj setPrev: last]; + [last setNext: obj]; - last = ptr; + last = obj; return self; } - addNew: (void*)ptr { return [self add: [OFListObject newWithData: ptr]]; } @end Index: src/OFListObject.h ================================================================== --- src/OFListObject.h +++ src/OFListObject.h @@ -9,21 +9,63 @@ * the packaging of this file. */ #import "OFObject.h" +/** + * The OFListObject class is a class for objects to be stored in an OFObject. + */ @interface OFListObject: OFObject { void *data; OFListObject *next; OFListObject *prev; } +/** + * \param The data the OFListObject should contain + * \return A new OFListObject. + */ + newWithData: (void*)ptr; + +/** + * Initializes an already allocated OFListObjeect. + * + * \param The data the OFListObject should contain + * \return An initialized OFListObject. + */ - initWithData: (void*)ptr; + +/** + * Free the OFListObject and the data it contains. + */ - freeIncludingData; + +/** + * \return The data included in the OFListObject + */ - (void*)data; + +/** + * \return The next OFListObject in the OFList + */ - (OFListObject*)next; + +/** + * \return The previous OFListObject in the OFList + */ - (OFListObject*)prev; -- setNext: (OFListObject*)ptr; -- setPrev: (OFListObject*)ptr; + +/** + * Sets the next OFListObject in the OFList. + * + * \param obj An OFListObject + */ +- setNext: (OFListObject*)obj; + +/** + * Sets the previous OFListObject in the OFList. + * + * \param obj An OFListObject + */ +- setPrev: (OFListObject*)obj; @end Index: src/OFListObject.m ================================================================== --- src/OFListObject.m +++ src/OFListObject.m @@ -50,17 +50,17 @@ - (OFListObject*)prev { return prev; } -- setNext: (OFListObject*)ptr +- setNext: (OFListObject*)obj { - next = ptr; + next = obj; return self; } -- setPrev: (OFListObject*)ptr +- setPrev: (OFListObject*)obj { - prev = ptr; + prev = obj; return self; } @end Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -15,11 +15,11 @@ #import "OFObject.h" /** * The OFString class can store and modify string of different types. */ -@interface OFString: OFObject +@interface OFString: OFObject {} /** * \param str A constant C string from which the new OFConstCString will be * created * \return A new OFConstCString */ Index: src/OFXMLFactory.h ================================================================== --- src/OFXMLFactory.h +++ src/OFXMLFactory.h @@ -9,12 +9,45 @@ * the packaging of this file. */ #import "OFObject.h" -@interface OFXMLFactory: OFObject +/** + * The OFXMLFactory class provides an easy way to create XML stanzas. + */ +@interface OFXMLFactory: OFObject {} +/** + * XML-escapes a C string. + * + * \param s The C string to escape + * \return The escaped C string. + * You need to free it manually! + */ + (char*)escapeCString: (const char*)s; + +/** + * Creates an XML stanza. + * + * \param name The name of the tag as a C string + * \param close A boolean whether the tag should be closed + * \param data Data that should be inside the tag. + * It will NOT be escaped, so you can also include other stanzas. + * \param ... Field / value pairs for the tag in the form "field", "value". + * Last element must be NULL. + * Example: "field1", "value1", "field2", "value2", NULL + * \return The created XML stanza as a C string. + * You need to free it manually! + */ + (char*)createStanza: (const char*)name withCloseTag: (BOOL)close andData: (const char*)data, ...; + +/** + * Concats an array of C strings into one C string and frees the array of C + * strings. + * + * \param strs An array of C strings + * \return The concatenated C strings. + * You need to free it manually! + */ + (char*)concatAndFreeCStrings: (char **)strs; @end