From: Jelte Jansen Date: Tue, 14 Dec 2004 13:06:43 +0000 (+0000) Subject: codingstylez X-Git-Tag: release-0.50~700 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=919a25d2612ada96e97bb7ced5384c8620b997fa;p=thirdparty%2Fldns.git codingstylez --- diff --git a/CodingStyle b/CodingStyle index b52eb099..053face5 100644 --- a/CodingStyle +++ b/CodingStyle @@ -5,6 +5,31 @@ The libdns coding style guide * Spaces only after comma's, and in between operators. And after keywords (if, while, for) * Underscores to make long names readable -* prefix (exported) functions with 'dns_' +* prefix (exported) functions with 'ldns_' * no unneeded parentheses after 'return' +* always curly brackets in if-statements +* use defines voor (weird) constants, and masks +* std_bool, configure thing + +* Return values: + - new/pointer: return pointer or NULL on error + - 'read' functions: t_status wire2thing(uint8_t *p, size_t max, + size_t pos, *thing); + - void functions like destroy + - bool functions + +* Parameter sequence: (dest, [dest_meta, ] src, [src_meta] etc) +* field names start with _ +* enum for rcode, opcode, types etc, + example: + enum rcode { + RCODE_OK = 0, + ... = ., + RCODE_FIRST = RCODE_OK, + RCODE_LAST = 15, + RCODE_COUNT = RCODE_LAST + 1 + } +* Everything by reference, all data structures an optional _clone() function +* arrays: ps[] with size_t p_count for the number of elements +* _size for size in bytes diff --git a/packet.h b/packet.h index 84071a0d..871236b4 100644 --- a/packet.h +++ b/packet.h @@ -105,14 +105,18 @@ void packet_set_arcount(t_packet *, uint16_t); /** * Allocates and initializes a t_packet structure + * + * @return pointer to the new packet */ t_packet *dns_packet_new(); /** * Converts the data on the uint8_t bytearray (in wire format) to a DNS packet * - * Returns the number of bytes read from the wire + * @param data pointer to the buffer with the data + * @param packet pointer to the structure to hold the packet + * @return the number of bytes read from the wire */ -size_t dns_wire2packet(uint8_t *, t_packet *); +size_t dns_wire2packet(uint8_t *data, t_packet *packet); #endif