]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
codingstylez
authorJelte Jansen <jeltejan@NLnetLabs.nl>
Tue, 14 Dec 2004 13:06:43 +0000 (13:06 +0000)
committerJelte Jansen <jeltejan@NLnetLabs.nl>
Tue, 14 Dec 2004 13:06:43 +0000 (13:06 +0000)
CodingStyle
packet.h

index b52eb099464b1775a0115515ef135430d536c182..053face583ec3e17f30352f3573127761e207881 100644 (file)
@@ -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
 
index 84071a0d1af5650295332883a6d2d057458719c3..871236b4d06853c97fda7efcf06081d9bc97d03a 100644 (file)
--- 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