[or-cvs] Docment or add DOCDOC comments to undocumented functions in...

Nick Mathewson nickm at seul.org
Sat Jun 11 18:52:14 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv7477/src/or

Modified Files:
	buffers.c circuitbuild.c circuitlist.c circuituse.c command.c 
	config.c connection.c connection_edge.c connection_or.c 
	control.c cpuworker.c directory.c dirserv.c dns.c hibernate.c 
	main.c onion.c relay.c rendclient.c rendcommon.c rendservice.c 
	rephist.c router.c routerlist.c routerparse.c test.c 
	tor_main.c 
Log Message:
Docment or add DOCDOC comments to undocumented functions in src/or.  Make function definition format uniform.

Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/buffers.c,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -d -r1.160 -r1.161
--- buffers.c	11 Jun 2005 06:07:22 -0000	1.160
+++ buffers.c	11 Jun 2005 18:52:11 -0000	1.161
@@ -76,7 +76,8 @@
  * beginning. This operation is relatively expensive, so it shouldn't
  * be used e.g. for every single read or write.
  */
-static void buf_normalize(buf_t *buf)
+static void
+buf_normalize(buf_t *buf)
 {
   check();
   if (buf->cur + buf->datalen <= buf->mem+buf->len) {
@@ -96,7 +97,8 @@
 }
 
 /** Return the point in the buffer where the next byte will get stored. */
-static INLINE char *_buf_end(buf_t *buf)
+static INLINE char *
+_buf_end(buf_t *buf)
 {
   char *next = buf->cur + buf->datalen;
   char *end = buf->mem + buf->len;
@@ -105,7 +107,8 @@
 
 /** If the pointer <b>cp</b> has passed beyond the end of the buffer, wrap it
  * around. */
-static INLINE char *_wrap_ptr(buf_t *buf, char *cp) {
+static INLINE char *
+_wrap_ptr(buf_t *buf, char *cp) {
   return (cp >= buf->mem + buf->len) ? (cp - buf->len) : cp;
 }
 
@@ -114,7 +117,8 @@
  * at <b>at</b>, and set *<b>more_len</b> to the number of bytes starting
  * at <b>buf-&gt;mem</b>.  Otherwise, set *<b>more_len</b> to 0.
  */
-static INLINE void _split_range(buf_t *buf, char *at, size_t *len,
+static INLINE void
+_split_range(buf_t *buf, char *at, size_t *len,
                                 size_t *more_len)
 {
   char *eos = at + *len;
@@ -128,7 +132,8 @@
 }
 
 /** Change a buffer's capacity. <b>new_capacity</b> must be \>= buf->datalen. */
-static void buf_resize(buf_t *buf, size_t new_capacity)
+static void
+buf_resize(buf_t *buf, size_t new_capacity)
 {
   off_t offset;
 #ifdef CHECK_AFTER_RESIZE
@@ -225,7 +230,8 @@
  * it so that it can.  (The new size will be a power of 2 times the old
  * size.)
  */
-static INLINE int buf_ensure_capacity(buf_t *buf, size_t capacity)
+static INLINE int
+buf_ensure_capacity(buf_t *buf, size_t capacity)
 {
   size_t new_len;
   if (buf->len >= capacity)  /* Don't grow if we're already big enough. */
@@ -251,7 +257,8 @@
  * one of the above no longer holds.  (We shrink the buffer by
  * dividing by powers of 2.)
  */
-static INLINE void buf_shrink_if_underfull(buf_t *buf) {
+static INLINE void
+buf_shrink_if_underfull(buf_t *buf) {
   size_t new_len;
   /* If the buffer is at least 1/8 full, or if shrinking the buffer would
    * put it under MIN_GREEDY_SHRINK_SIZE, don't do it. */
@@ -298,7 +305,8 @@
 
 /** Remove the first <b>n</b> bytes from buf.
  */
-static INLINE void buf_remove_from_front(buf_t *buf, size_t n) {
+static INLINE void
+buf_remove_from_front(buf_t *buf, size_t n) {
   tor_assert(buf->datalen >= n);
   buf->datalen -= n;
   buf_total_used -= n;
@@ -312,7 +320,8 @@
 }
 
 /** Make sure that the memory in buf ends with a zero byte. */
-static INLINE int buf_nul_terminate(buf_t *buf)
+static INLINE int
+buf_nul_terminate(buf_t *buf)
 {
   if (buf_ensure_capacity(buf,buf->datalen+1)<0)
     return -1;
@@ -322,7 +331,8 @@
 
 /** Create and return a new buf with capacity <b>size</b>.
  */
-buf_t *buf_new_with_capacity(size_t size) {
+buf_t *
+buf_new_with_capacity(size_t size) {
   buf_t *buf;
   buf = tor_malloc_zero(sizeof(buf_t));
   buf->magic = BUFFER_MAGIC;
@@ -336,13 +346,15 @@
 }
 
 /** Allocate and return a new buffer with default capacity. */
-buf_t *buf_new()
+buf_t *
+buf_new(void)
 {
   return buf_new_with_capacity(INITIAL_BUF_SIZE);
 }
 
 /** Remove all data from <b>buf</b> */
-void buf_clear(buf_t *buf)
+void
+buf_clear(buf_t *buf)
 {
   buf_total_used -= buf->datalen;
   buf->datalen = 0;
@@ -350,28 +362,33 @@
 }
 
 /** Return the number of bytes stored in <b>buf</b> */
-size_t buf_datalen(const buf_t *buf)
+size_t
+buf_datalen(const buf_t *buf)
 {
   return buf->datalen;
 }
 
 /** Return the maximum bytes that can be stored in <b>buf</b> before buf
  * needs to resize. */
-size_t buf_capacity(const buf_t *buf)
+size_t
+buf_capacity(const buf_t *buf)
 {
   return buf->len;
 }
 
 /** For testing only: Return a pointer to the raw memory stored in <b>buf</b>.
  */
-const char *_buf_peek_raw_buffer(const buf_t *buf)
+const char *
+_buf_peek_raw_buffer(const buf_t *buf)
 {
   return buf->cur;
 }
 
 /** Release storage held by <b>buf</b>.
  */
-void buf_free(buf_t *buf) {
+void
+buf_free(buf_t *buf)
+{
   assert_buf_ok(buf);
   buf->magic = 0xDEADBEEF;
   free(RAW_MEM(buf->mem));
@@ -380,8 +397,15 @@
   tor_free(buf);
 }
 
-static INLINE int read_to_buf_impl(int s, size_t at_most, buf_t *buf,
-                            char *pos, int *reached_eof)
+/** Helper for read_to_buf: read no more than at_most bytes from
+ * socket s into buffer buf, starting at the position pos.  (Does not
+ * check for overflow.)  Set *reached_eof to true on EOF.  Return
+ * number of bytes read on success, 0 if the read would block, -1 on
+ * failure.
+ */
+static INLINE int
+read_to_buf_impl(int s, size_t at_most, buf_t *buf,
+                 char *pos, int *reached_eof)
 {
   int read_result;
 
@@ -414,7 +438,8 @@
  * else return the number of bytes read.  Return 0 if recv() would
  * block.
  */
-int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof)
+int
+read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof)
 {
   int r;
   char *next;
@@ -456,6 +481,11 @@
   return r;
 }
 
+/** Helper for read_to_buf_tls: read no more than at_most bytes from
+ * the TLS connection tlsinto buffer buf, starting at the position
+ * next.  (Does not check for overflow.)  Return number of bytes read
+ * on success, 0 if the read would block, -1 on failure.
+ */
 static INLINE int
 read_to_buf_tls_impl(tor_tls *tls, size_t at_most, buf_t *buf, char *next)
 {
@@ -495,7 +525,9 @@
  * events: sometimes, before a TLS stream can read, the network must be
  * ready to write -- or vice versa.
  */
-int read_to_buf_tls(tor_tls *tls, size_t at_most, buf_t *buf) {
+int
+read_to_buf_tls(tor_tls *tls, size_t at_most, buf_t *buf)
+{
   int r;
   char *next;
   size_t at_start;
@@ -537,6 +569,10 @@
   return r;
 }
 
+/** Helper for flush_buf: try to write sz bytes from buffer buf onto
+ * socket s.  On success, deduct the bytes written from *buf_flushlen.
+ * Return the number of bytes written on success, -1 on failure.
+ */
 static INLINE int
 flush_buf_impl(int s, buf_t *buf, size_t sz, size_t *buf_flushlen)
 {
@@ -565,7 +601,8 @@
  * from the buffer.  Return the number of bytes written on success,
  * -1 on failure.  Return 0 if write() would block.
  */
-int flush_buf(int s, buf_t *buf, size_t *buf_flushlen)
+int
+flush_buf(int s, buf_t *buf, size_t *buf_flushlen)
 {
   int r;
   size_t flushed = 0;
@@ -604,6 +641,10 @@
   return flushed;
 }
 
+/** Helper for flush_buf_tls: try to write sz bytes from buffer buf onto
+ * TLS object tls.  On success, deduct the bytes written from *buf_flushlen.
+ * Return the number of bytes written on success, -1 on failure.
+ */
 static INLINE int
 flush_buf_tls_impl(tor_tls *tls, buf_t *buf, size_t sz, size_t *buf_flushlen)
 {
@@ -699,7 +740,10 @@
   return buf->datalen;
 }
 
-static INLINE void peek_from_buf(char *string, size_t string_len, buf_t *buf)
+/** Helper: copy the first string_len bytes from buf onto string.
+ */
+static INLINE void
+peek_from_buf(char *string, size_t string_len, buf_t *buf)
 {
   size_t len2;
 
@@ -724,7 +768,8 @@
  * into <b>string</b>.  Return the new buffer size.  <b>string_len</b> must be \<=
  * the number of bytes on the buffer.
  */
-int fetch_from_buf(char *string, size_t string_len, buf_t *buf)
+int
+fetch_from_buf(char *string, size_t string_len, buf_t *buf)
 {
   /* There must be string_len bytes in buf; write them onto string,
    * then memmove buf back (that is, remove them from buf).
@@ -755,9 +800,11 @@
  *
  * Else, change nothing and return 0.
  */
-int fetch_from_buf_http(buf_t *buf,
-                        char **headers_out, size_t max_headerlen,
-                        char **body_out, size_t *body_used, size_t max_bodylen) {
+int
+fetch_from_buf_http(buf_t *buf,
+                    char **headers_out, size_t max_headerlen,
+                    char **body_out, size_t *body_used, size_t max_bodylen)
+{
   char *headers, *body, *p;
   size_t headerlen, bodylen, contentlen;
 
@@ -846,7 +893,9 @@
  *
  * If returning 0 or -1, <b>req->address</b> and <b>req->port</b> are undefined.
  */
-int fetch_from_buf_socks(buf_t *buf, socks_request_t *req) {
+int
+fetch_from_buf_socks(buf_t *buf, socks_request_t *req)
+{
   unsigned char len;
   char tmpbuf[INET_NTOA_BUF_LEN];
   uint32_t destip;
@@ -1059,8 +1108,9 @@
  *
  * Return -1 on error.
  */
-int fetch_from_buf_control(buf_t *buf, uint32_t *len_out, uint16_t *type_out,
-                           char **body_out)
+int
+fetch_from_buf_control(buf_t *buf, uint32_t *len_out, uint16_t *type_out,
+                       char **body_out)
 {
   uint32_t msglen;
   uint16_t type;

Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuitbuild.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- circuitbuild.c	9 Jun 2005 19:03:31 -0000	1.117
+++ circuitbuild.c	11 Jun 2005 18:52:11 -0000	1.118
@@ -36,7 +36,9 @@
  *
  * Return it, or 0 if can't get a unique circ_id.
  */
-static uint16_t get_unique_circ_id_by_conn(connection_t *conn) {
+static uint16_t
+get_unique_circ_id_by_conn(connection_t *conn)
+{
   uint16_t test_circ_id;
   int attempts=0;
   uint16_t high_bit;
@@ -130,7 +132,9 @@
  * circ's cpath. Also log the length of the cpath, and the intended
  * exit point.
  */
-void circuit_log_path(int severity, circuit_t *circ) {
+void
+circuit_log_path(int severity, circuit_t *circ)
+{
   char *s = circuit_list_path(circ,1);
   log_fn(severity,"%s",s);
   tor_free(s);
@@ -141,7 +145,9 @@
  * extended; the _first_ hop that isn't open (if any) is marked as
  * unable to extend.
  */
-void circuit_rep_hist_note_result(circuit_t *circ) {
+void
+circuit_rep_hist_note_result(circuit_t *circ)
+{
   struct crypt_path_t *hop;
   char *prev_digest = NULL;
   routerinfo_t *router;
@@ -183,7 +189,8 @@
  */
 static void
 circuit_dump_details(int severity, circuit_t *circ, int poll_index,
-                     const char *type, int this_circid, int other_circid) {
+                     const char *type, int this_circid, int other_circid)
+{
   log(severity,"Conn %d has %s circuit: circID %d (other side %d), state %d (%s), born %d:",
       poll_index, type, this_circid, other_circid, circ->state,
       circuit_state_to_string(circ->state), (int)circ->timestamp_created);
@@ -195,7 +202,9 @@
 /** Log, at severity <b>severity</b>, information about each circuit
  * that is connected to <b>conn</b>.
  */
-void circuit_dump_by_conn(connection_t *conn, int severity) {
+void
+circuit_dump_by_conn(connection_t *conn, int severity)
+{
   circuit_t *circ;
   connection_t *tmpconn;
 
@@ -233,7 +242,8 @@
 /** Pick all the entries in our cpath. Stop and return 0 when we're
  * happy, or return -1 if an error occurs. */
 static int
-onion_populate_cpath(circuit_t *circ) {
+onion_populate_cpath(circuit_t *circ)
+{
   int r;
 again:
   r = onion_extend_cpath(circ->purpose, &circ->cpath, circ->build_state);
@@ -250,7 +260,8 @@
 /** Create and return a new circuit. Initialize its purpose and
  * build-state based on our arguments. */
 circuit_t *
-circuit_init(uint8_t purpose, int need_uptime, int need_capacity, int internal) {
+circuit_init(uint8_t purpose, int need_uptime, int need_capacity, int internal)
+{
   circuit_t *circ = circuit_new(0, NULL); /* sets circ->p_circ_id and circ->p_conn */
   circ->state = CIRCUIT_STATE_OR_WAIT;
   circ->build_state = tor_malloc_zero(sizeof(cpath_build_state_t));
@@ -270,7 +281,8 @@
  */
 circuit_t *
 circuit_establish_circuit(uint8_t purpose, routerinfo_t *exit,
-                          int need_uptime, int need_capacity, int internal) {
+                          int need_uptime, int need_capacity, int internal)
+{
   circuit_t *circ;
 
   circ = circuit_init(purpose, need_uptime, need_capacity, internal);
@@ -294,7 +306,9 @@
  * OR we should connect to, and if necessary start the connection to
  * it. If we're already connected, then send the 'create' cell.
  * Return 0 for ok, -1 if circ should be marked-for-close. */
-int circuit_handle_first_hop(circuit_t *circ) {
+int
+circuit_handle_first_hop(circuit_t *circ)
+{
   routerinfo_t *firsthop;
   connection_t *n_conn;
 
@@ -344,7 +358,9 @@
  *
  * Status is 1 if connect succeeded, or 0 if connect failed.
  */
-void circuit_n_conn_done(connection_t *or_conn, int status) {
+void
+circuit_n_conn_done(connection_t *or_conn, int status)
+{
   circuit_t *circ;
 
   log_fn(LOG_DEBUG,"or_conn to %s, status=%d",
@@ -384,8 +400,10 @@
   }
 }
 
+/** DOCDOC */
 static int
-circuit_deliver_create_cell(circuit_t *circ, uint8_t cell_type, char *payload) {
+circuit_deliver_create_cell(circuit_t *circ, uint8_t cell_type, char *payload)
+{
   cell_t cell;
   uint16_t id;
 
@@ -424,7 +442,9 @@
  *
  * Return -1 if we want to tear down circ, else return 0.
  */
-int circuit_send_next_onion_skin(circuit_t *circ) {
+int
+circuit_send_next_onion_skin(circuit_t *circ)
+{
   crypt_path_t *hop;
   routerinfo_t *router;
   int r;
@@ -531,7 +551,9 @@
 /** Our clock just jumped forward by <b>seconds_elapsed</b>. Assume
  * something has also gone wrong with our network: notify the user,
  * and abandon all not-yet-used circuits. */
-void circuit_note_clock_jumped(int seconds_elapsed) {
+void
+circuit_note_clock_jumped(int seconds_elapsed)
+{
   log(LOG_NOTICE,"Your clock just jumped %d seconds forward; assuming established circuits no longer work.", seconds_elapsed);
   has_completed_circuit=0; /* so it'll log when it works again */
   circuit_mark_all_unused_circs();
@@ -541,7 +563,9 @@
  * sure we're connected to the next hop, and pass it the onion skin in
  * a create cell.
  */
-int circuit_extend(cell_t *cell, circuit_t *circ) {
+int
+circuit_extend(cell_t *cell, circuit_t *circ)
+{
   connection_t *n_conn;
   relay_header_t rh;
   char *onionskin;
@@ -624,7 +648,8 @@
  *
  * (If 'reverse' is true, then f_XX and b_XX are swapped.)
  */
-int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data, int reverse)
+int
+circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data, int reverse)
 {
   crypto_digest_env_t *tmp_digest;
   crypto_cipher_env_t *tmp_crypto;
@@ -675,7 +700,9 @@
  *
  * Return -1 if we want to mark circ for close, else return 0.
  */
-int circuit_finish_handshake(circuit_t *circ, uint8_t reply_type, char *reply) {
+int
+circuit_finish_handshake(circuit_t *circ, uint8_t reply_type, char *reply)
+{
   char keys[CPATH_KEY_MATERIAL_LEN];
   crypt_path_t *hop;
 
@@ -735,7 +762,9 @@
  * means that a connection broke or an extend failed. For now,
  * just give up: for circ to close, and return 0.
  */
-int circuit_truncated(circuit_t *circ, crypt_path_t *layer) {
+int
+circuit_truncated(circuit_t *circ, crypt_path_t *layer)
+{
 //  crypt_path_t *victim;
 //  connection_t *stream;
 
@@ -778,7 +807,9 @@
 /** Given a response payload and keys, initialize, then send a created
  * cell back.
  */
-int onionskin_answer(circuit_t *circ, uint8_t cell_type, char *payload, char *keys) {
+int
+onionskin_answer(circuit_t *circ, uint8_t cell_type, char *payload, char *keys)
+{
   cell_t cell;
   crypt_path_t *tmp_cpath;
 
@@ -833,7 +864,9 @@
  * to handle the desired path length, return as large a path length as
  * is feasible, except if it's less than 2, in which case return -1.
  */
-static int new_route_len(double cw, uint8_t purpose, smartlist_t *routers) {
+static int
+new_route_len(double cw, uint8_t purpose, smartlist_t *routers)
+{
   int num_acceptable_routers;
   int routelen;
 
@@ -893,7 +926,8 @@
  * existing circuit, and return it.
  */
 static smartlist_t *
-circuit_get_unhandled_ports(time_t now) {
+circuit_get_unhandled_ports(time_t now)
+{
   smartlist_t *source = rep_hist_get_predicted_ports(now);
   smartlist_t *dest = smartlist_create();
   uint16_t *tmp;
@@ -917,7 +951,8 @@
  */
 int
 circuit_all_predicted_ports_handled(time_t now, int *need_uptime,
-                                    int *need_capacity) {
+                                    int *need_capacity)
+{
   int i, enough;
   uint16_t *port;
   smartlist_t *sl = circuit_get_unhandled_ports(now);
@@ -937,7 +972,8 @@
  * <b>needed_ports</b>, else return 0.
  */
 static int
-router_handles_some_port(routerinfo_t *router, smartlist_t *needed_ports) {
+router_handles_some_port(routerinfo_t *router, smartlist_t *needed_ports)
+{
   int i;
   uint16_t port;
 
@@ -958,7 +994,8 @@
 #define MIN_CIRCUITS_HANDLING_STREAM 2
 
 static int
-ap_stream_wants_exit_attention(connection_t *conn) {
+ap_stream_wants_exit_attention(connection_t *conn)
+{
   if (conn->type == CONN_TYPE_AP &&
       conn->state == AP_CONN_STATE_CIRCUIT_WAIT &&
       !conn->marked_for_close &&
@@ -1182,7 +1219,8 @@
  * router (or use <b>exit</b> if provided). Store these in the
  * cpath. Return 0 if ok, -1 if circuit should be closed. */
 static int
-onion_pick_cpath_exit(circuit_t *circ, routerinfo_t *exit) {
+onion_pick_cpath_exit(circuit_t *circ, routerinfo_t *exit)
+{
   cpath_build_state_t *state = circ->build_state;
 
   routerlist_t *rl;
@@ -1218,7 +1256,8 @@
  * the caller will do this if it wants to.
  */
 int
-circuit_append_new_exit(circuit_t *circ, routerinfo_t *exit) {
+circuit_append_new_exit(circuit_t *circ, routerinfo_t *exit)
+{
   tor_assert(exit);
   tor_assert(circ && CIRCUIT_IS_ORIGIN(circ));
   tor_free(circ->build_state->chosen_exit_name);
@@ -1233,7 +1272,9 @@
  * to <b>exit</b>, and get it to send the next extend cell. If you can't
  * send the extend cell, mark the circuit for close and return -1, else
  * return 0. */
-int circuit_extend_to_new_exit(circuit_t *circ, routerinfo_t *exit) {
+int
+circuit_extend_to_new_exit(circuit_t *circ, routerinfo_t *exit)
+{
   circuit_append_new_exit(circ, exit);
   circ->state = CIRCUIT_STATE_BUILDING;
   if (circuit_send_next_onion_skin(circ)<0) {
@@ -1248,7 +1289,9 @@
 /** Return the number of routers in <b>routers</b> that are currently up
  * and available for building circuits through.
  */
-static int count_acceptable_routers(smartlist_t *routers) {
+static int
+count_acceptable_routers(smartlist_t *routers)
+{
   int i, n;
   int num=0;
   routerinfo_t *r;
@@ -1280,7 +1323,8 @@
  *
  * This function is used to extend cpath by another hop.
  */
-void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop)
+void
+onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop)
 {
   if (*head_ptr) {
     new_hop->next = (*head_ptr);
@@ -1293,10 +1337,12 @@
   }
 }
 
-static routerinfo_t *choose_good_middle_server(uint8_t purpose,
-                                               cpath_build_state_t *state,
-                                               crypt_path_t *head,
-                                               int cur_len)
+/** DOCDOC */
+static routerinfo_t *
+choose_good_middle_server(uint8_t purpose,
+                          cpath_build_state_t *state,
+                          crypt_path_t *head,
+                          int cur_len)
 {
   int i;
   routerinfo_t *r, *choice;
@@ -1326,7 +1372,9 @@
   return choice;
 }
 
-static routerinfo_t *choose_good_entry_server(cpath_build_state_t *state)
+/** DOCDOC */
+static routerinfo_t *
+choose_good_entry_server(cpath_build_state_t *state)
 {
   routerinfo_t *r, *choice;
   smartlist_t *excluded = smartlist_create();
@@ -1366,7 +1414,8 @@
 /** Return the first non-open hop in cpath, or return NULL if all
  * hops are open. */
 static crypt_path_t *
-onion_next_hop_in_cpath(crypt_path_t *cpath) {
+onion_next_hop_in_cpath(crypt_path_t *cpath)
+{
   crypt_path_t *hop = cpath;
   do {
     if (hop->state != CPATH_STATE_OPEN)
@@ -1457,7 +1506,8 @@
  * corresponding router <b>choice</b>, and append it to the
  * end of the cpath <b>head_ptr</b>. */
 static int
-onion_append_hop(crypt_path_t **head_ptr, routerinfo_t *choice) {
+onion_append_hop(crypt_path_t **head_ptr, routerinfo_t *choice)
+{
   crypt_path_t *hop = tor_malloc_zero(sizeof(crypt_path_t));
 
   /* link hop into the cpath, at the end. */

Index: circuitlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuitlist.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- circuitlist.c	9 Jun 2005 19:03:31 -0000	1.49
+++ circuitlist.c	11 Jun 2005 18:52:11 -0000	1.50
@@ -32,9 +32,10 @@
   circuit_t *circuit;
 };
 
-static INLINE int compare_orconn_circid_entries(
-       struct orconn_circid_circuit_map_t *a,
-       struct orconn_circid_circuit_map_t *b)
+/** DOCDOC */
+static INLINE int
+compare_orconn_circid_entries(struct orconn_circid_circuit_map_t *a,
+                              struct orconn_circid_circuit_map_t *b)
 {
   if (a->or_conn < b->or_conn)
     return -1;
@@ -43,12 +44,14 @@
   else
     return ((int)b->circ_id) - ((int)a->circ_id);
 };
+
 static RB_HEAD(orconn_circid_tree, orconn_circid_circuit_map_t) orconn_circid_circuit_map = RB_INITIALIZER(orconn_circid_circuit_map);
 RB_PROTOTYPE(orconn_circid_tree, orconn_circid_circuit_map_t, node, compare_orconn_circid_entries);
 RB_GENERATE(orconn_circid_tree, orconn_circid_circuit_map_t, node, compare_orconn_circid_entries);
 
 struct orconn_circid_circuit_map_t *_last_circid_orconn_ent = NULL;
 
+/** DOCDOC */
 void
 circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
                           connection_t *conn,
@@ -111,7 +114,9 @@
 /** Add <b>circ</b> to the global list of circuits. This is called only from
  * within circuit_new.
  */
-static void circuit_add(circuit_t *circ) {
+static void
+circuit_add(circuit_t *circ)
+{
   if (!global_circuitlist) { /* first one */
     global_circuitlist = circ;
     circ->next = NULL;
@@ -124,7 +129,8 @@
 /** Detach from the global circuit list, and deallocate, all
  * circuits that have been marked for close.
  */
-void circuit_close_all_marked(void)
+void
+circuit_close_all_marked(void)
 {
   circuit_t *tmp,*m;
 
@@ -167,7 +173,9 @@
 /** Allocate space for a new circuit, initializing with <b>p_circ_id</b>
  * and <b>p_conn</b>. Add it to the global circuit list.
  */
-circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn) {
+circuit_t *
+circuit_new(uint16_t p_circ_id, connection_t *p_conn)
+{
   circuit_t *circ;
   static uint32_t n_circuits_allocated = 1;
     /* never zero, since a global ID of 0 is treated specially by the controller */
@@ -198,7 +206,9 @@
 
 /** Deallocate space associated with circ.
  */
-static void circuit_free(circuit_t *circ) {
+static void
+circuit_free(circuit_t *circ)
+{
   tor_assert(circ);
   tor_assert(circ->magic == CIRCUIT_MAGIC);
   if (circ->n_crypto)
@@ -228,7 +238,9 @@
 }
 
 /** Deallocate space associated with the linked list <b>cpath</b>. */
-static void circuit_free_cpath(crypt_path_t *cpath) {
+static void
+circuit_free_cpath(crypt_path_t *cpath)
+{
   crypt_path_t *victim, *head=cpath;
 
   if (!cpath)
@@ -265,7 +277,8 @@
 
 /** Deallocate space associated with the cpath node <b>victim</b>. */
 static void
-circuit_free_cpath_node(crypt_path_t *victim) {
+circuit_free_cpath_node(crypt_path_t *victim)
+{
   if (victim->f_crypto)
     crypto_free_cipher_env(victim->f_crypto);
   if (victim->b_crypto)
@@ -303,7 +316,9 @@
  *    in p_streams or n_streams.
  * Return NULL if no such circuit exists.
  */
-circuit_t *circuit_get_by_circid_orconn(uint16_t circ_id, connection_t *conn) {
+circuit_t *
+circuit_get_by_circid_orconn(uint16_t circ_id, connection_t *conn)
+{
   struct orconn_circid_circuit_map_t search;
   struct orconn_circid_circuit_map_t *found;
 
@@ -346,7 +361,8 @@
 }
 
 /** DOCDOC */
-circuit_t *circuit_get_by_edge_conn(connection_t *conn)
+circuit_t *
+circuit_get_by_edge_conn(connection_t *conn)
 {
   circuit_t *circ;
   connection_t *tmpconn;
@@ -382,7 +398,9 @@
  *
  * Return NULL if no such circuit exists.
  */
-circuit_t *circuit_get_by_conn(connection_t *conn) {
+circuit_t *
+circuit_get_by_conn(connection_t *conn)
+{
   circuit_t *circ;
   connection_t *tmpconn;
 
@@ -413,7 +431,9 @@
  *
  * Return NULL if no such circuit exists.
  */
-circuit_t *circuit_get_by_rend_query_and_purpose(const char *rend_query, uint8_t purpose) {
+circuit_t *
+circuit_get_by_rend_query_and_purpose(const char *rend_query, uint8_t purpose)
+{
   circuit_t *circ;
 
   for (circ = global_circuitlist; circ; circ = circ->next) {
@@ -454,7 +474,8 @@
 /** Return the circuit waiting for a rendezvous with the provided cookie.
  * Return NULL if no such circuit is found.
  */
-circuit_t *circuit_get_rendezvous(const char *cookie)
+circuit_t *
+circuit_get_rendezvous(const char *cookie)
 {
   circuit_t *circ;
   for (circ = global_circuitlist; circ; circ = circ->next) {
@@ -476,7 +497,8 @@
  */
 circuit_t *
 circuit_get_clean_open(uint8_t purpose, int need_uptime,
-                       int need_capacity, int internal) {
+                       int need_capacity, int internal)
+{
   circuit_t *circ;
   circuit_t *best=NULL;
 
@@ -500,7 +522,9 @@
 
 /** Go through the circuitlist; mark-for-close each circuit that starts
  *  at us but has not yet been used. */
-void circuit_mark_all_unused_circs(void) {
+void
+circuit_mark_all_unused_circs(void)
+{
   circuit_t *circ;
 
   for (circ=global_circuitlist; circ; circ = circ->next) {
@@ -526,7 +550,8 @@
  *   - If circ->rend_splice is set (we are the midpoint of a joined
  *     rendezvous stream), then mark the other circuit to close as well.
  */
-void _circuit_mark_for_close(circuit_t *circ, int line, const char *file)
+void
+_circuit_mark_for_close(circuit_t *circ, int line, const char *file)
 {
   connection_t *conn;
 
@@ -600,7 +625,8 @@
 /** Verify that cpath layer <b>cp</b> has all of its invariants
  * correct. Trigger an assert if anything is invalid.
  */
-void assert_cpath_layer_ok(const crypt_path_t *cp)
+void
+assert_cpath_layer_ok(const crypt_path_t *cp)
 {
 //  tor_assert(cp->addr); /* these are zero for rendezvous extra-hops */
 //  tor_assert(cp->port);
@@ -652,7 +678,8 @@
 /** Verify that circuit <b>c</b> has all of its invariants
  * correct. Trigger an assert if anything is invalid.
  */
-void assert_circuit_ok(const circuit_t *c)
+void
+assert_circuit_ok(const circuit_t *c)
 {
   connection_t *conn;
 

Index: circuituse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- circuituse.c	11 Jun 2005 05:31:16 -0000	1.74
+++ circuituse.c	11 Jun 2005 18:52:11 -0000	1.75
@@ -28,11 +28,12 @@
 /* Return 1 if <b>circ</b> could be returned by circuit_get_best().
  * Else return 0.
  */
-static int circuit_is_acceptable(circuit_t *circ,
-                                 connection_t *conn,
-                                 int must_be_open,
-                                 uint8_t purpose,
-                                 time_t now)
+static int
+circuit_is_acceptable(circuit_t *circ,
+                      connection_t *conn,
+                      int must_be_open,
+                      uint8_t purpose,
+                      time_t now)
 {
   routerinfo_t *exitrouter;
   tor_assert(circ);
@@ -102,7 +103,8 @@
 /* Return 1 if circuit <b>a</b> is better than circuit <b>b</b> for
  * <b>purpose</b>, and return 0 otherwise. Used by circuit_get_best.
  */
-static int circuit_is_better(circuit_t *a, circuit_t *b, uint8_t purpose)
+static int
+circuit_is_better(circuit_t *a, circuit_t *b, uint8_t purpose)
 {
   switch (purpose) {
     case CIRCUIT_PURPOSE_C_GENERAL:
@@ -184,7 +186,9 @@
 /** Close all circuits that start at us, aren't open, and were born
  * at least MIN_SECONDS_BEFORE_EXPIRING_CIRC seconds ago.
  */
-void circuit_expire_building(time_t now) {
+void
+circuit_expire_building(time_t now)
+{
   circuit_t *victim, *circ = global_circuitlist;
 
   while (circ) {
@@ -254,7 +258,8 @@
  * open or in-progress circuit.
  */
 void
-circuit_remove_handled_ports(smartlist_t *needed_ports) {
+circuit_remove_handled_ports(smartlist_t *needed_ports)
+{
   int i;
   uint16_t *port;
 
@@ -275,7 +280,9 @@
  * an acceptable exit node for conn if conn is defined, else for "*:port".
  * Else return 0.
  */
-int circuit_stream_is_being_handled(connection_t *conn, uint16_t port, int min) {
+int
+circuit_stream_is_being_handled(connection_t *conn, uint16_t port, int min)
+{
   circuit_t *circ;
   routerinfo_t *exitrouter;
   int num=0;
@@ -377,7 +384,9 @@
  * services just want enough circuits for current tasks, whereas
  * others want a minimum set of idle circuits hanging around.
  */
-void circuit_build_needed_circs(time_t now) {
+void
+circuit_build_needed_circs(time_t now)
+{
   static long time_to_new_circuit = 0;
 
   /* launch a new circ for any pending streams that need one */
@@ -410,7 +419,9 @@
 /** If the stream <b>conn</b> is a member of any of the linked
  * lists of <b>circ</b>, then remove it from the list.
  */
-void circuit_detach_stream(circuit_t *circ, connection_t *conn) {
+void
+circuit_detach_stream(circuit_t *circ, connection_t *conn)
+{
   connection_t *prevconn;
 
   tor_assert(circ);
@@ -472,7 +483,9 @@
  * If it's an edge conn, then detach it from its circ, so we don't
  * try to reference it later.
  */
-void circuit_about_to_close_connection(connection_t *conn) {
+void
+circuit_about_to_close_connection(connection_t *conn)
+{
   /* currently, we assume it's too late to flush conn's buf here.
    * down the road, maybe we'll consider that eof doesn't mean can't-write
    */
@@ -550,7 +563,8 @@
 
 /** A testing circuit has completed. Take whatever stats we want. */
 static void
-circuit_testing_opened(circuit_t *circ) {
+circuit_testing_opened(circuit_t *circ)
+{
   /* For now, we only use testing circuits to see if our ORPort is
      reachable. But we remember reachability in onionskin_answer(),
      so there's no need to record anything here. Just close the circ. */
@@ -576,8 +590,9 @@
  * call connection_ap_attach_pending, which looks for pending streams
  * that could use circ.
  */
-void circuit_has_opened(circuit_t *circ) {
-
+void
+circuit_has_opened(circuit_t *circ)
+{
   control_event_circuit_status(circ, CIRC_EVENT_BUILT);
 
   switch (circ->purpose) {
@@ -610,10 +625,11 @@
   }
 }
 
-/*~ Called whenever a circuit could not be successfully built.
+/** Called whenever a circuit could not be successfully built.
  */
-void circuit_build_failed(circuit_t *circ) {
-
+void
+circuit_build_failed(circuit_t *circ)
+{
   /* we should examine circ and see if it failed because of
    * the last hop or an earlier hop. then use this info below.
    */
@@ -771,7 +787,9 @@
 /** Record another failure at opening a general circuit. When we have
  * too many, we'll stop trying for the remainder of this minute.
  */
-static void circuit_increment_failure_count(void) {
+static void
+circuit_increment_failure_count(void)
+{
   ++n_circuit_failures;
   log_fn(LOG_DEBUG,"n_circuit_failures now %d.",n_circuit_failures);
 }
@@ -780,7 +798,9 @@
  * we will try MAX_CIRCUIT_FAILURES times more (if necessary) before
  * stopping again.
  */
-void circuit_reset_failure_count(int timeout) {
+void
+circuit_reset_failure_count(int timeout)
+{
   if (timeout && n_circuit_failures > MAX_CIRCUIT_FAILURES)
     did_circs_fail_last_period = 1;
   else
@@ -797,7 +817,8 @@
 static int
 circuit_get_open_circ_or_launch(connection_t *conn,
                                 uint8_t desired_circuit_purpose,
-                                circuit_t **circp) {
+                                circuit_t **circp)
+{
   circuit_t *circ;
   int is_resolve;
   int need_uptime;
@@ -919,7 +940,9 @@
  * p_streams. Also set apconn's cpath_layer to the last hop in
  * circ's cpath.
  */
-static void link_apconn_to_circ(connection_t *apconn, circuit_t *circ) {
+static void
+link_apconn_to_circ(connection_t *apconn, circuit_t *circ)
+{
   /* add it into the linked list of streams on this circuit */
   log_fn(LOG_DEBUG,"attaching new conn to circ. n_circ_id %d.", circ->n_circ_id);
   apconn->timestamp_lastread = time(NULL); /* reset it, so we can measure circ timeouts */
@@ -938,7 +961,8 @@
 /** If an exit wasn't specifically chosen, save the history for future
  * use */
 static void
-consider_recording_trackhost(connection_t *conn, circuit_t *circ) {
+consider_recording_trackhost(connection_t *conn, circuit_t *circ)
+{
   int found_needle = 0;
   char *str;
   or_options_t *options = get_options();
@@ -1023,7 +1047,9 @@
  * Otherwise, associate conn with a safe live circuit, do the
  * right next step, and return 1.
  */
-int connection_ap_handshake_attach_circuit(connection_t *conn) {
+int
+connection_ap_handshake_attach_circuit(connection_t *conn)
+{
   int retval;
   int conn_age;
 

Index: command.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/command.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- command.c	11 Jun 2005 05:31:16 -0000	1.91
+++ command.c	11 Jun 2005 18:52:11 -0000	1.92
@@ -36,8 +36,10 @@
  * <b>cell</b> that just arrived on <b>conn</b>. Increment <b>*time</b>
  * by the number of microseconds used by the call to <b>*func(cell, conn)</b>.
  */
-static void command_time_process_cell(cell_t *cell, connection_t *conn, int *time,
-                               void (*func)(cell_t *, connection_t *)) {
+static void
+command_time_process_cell(cell_t *cell, connection_t *conn, int *time,
+                               void (*func)(cell_t *, connection_t *))
+{
   struct timeval start, end;
   long time_passed;
 
@@ -64,7 +66,9 @@
  * this second, and the total number of microseconds it took to
  * process each type of cell.
  */
-void command_process_cell(cell_t *cell, connection_t *conn) {
+void
+command_process_cell(cell_t *cell, connection_t *conn)
+{
 #ifdef KEEP_TIMING_STATS
   /* how many of each cell have we seen so far this second? needs better
    * name. */
@@ -150,7 +154,9 @@
  * onionskin_pending, and pass the onionskin to the cpuworker. Circ will
  * get picked up again when the cpuworker finishes decrypting it.
  */
-static void command_process_create_cell(cell_t *cell, connection_t *conn) {
+static void
+command_process_create_cell(cell_t *cell, connection_t *conn)
+{
   circuit_t *circ;
 
   if (we_are_hibernating()) {
@@ -219,7 +225,9 @@
  * finish processing keys, and then call circuit_send_next_onion_skin() to
  * extend to the next hop in the circuit if necessary.
  */
-static void command_process_created_cell(cell_t *cell, connection_t *conn) {
+static void
+command_process_created_cell(cell_t *cell, connection_t *conn)
+{
   circuit_t *circ;
 
   circ = circuit_get_by_circid_orconn(cell->circ_id, conn);
@@ -259,7 +267,9 @@
  * it came in with a recognized circ_id. Pass it on to
  * circuit_receive_relay_cell() for actual processing.
  */
-static void command_process_relay_cell(cell_t *cell, connection_t *conn) {
+static void
+command_process_relay_cell(cell_t *cell, connection_t *conn)
+{
   circuit_t *circ;
 
   circ = circuit_get_by_circid_orconn(cell->circ_id, conn);
@@ -304,7 +314,9 @@
  * Then mark the circuit for close (which marks all edges for close,
  * and passes the destroy cell onward if necessary).
  */
-static void command_process_destroy_cell(cell_t *cell, connection_t *conn) {
+static void
+command_process_destroy_cell(cell_t *cell, connection_t *conn)
+{
   circuit_t *circ;
 
   circ = circuit_get_by_circid_orconn(cell->circ_id, conn);

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.360
retrieving revision 1.361
diff -u -d -r1.360 -r1.361
--- config.c	11 Jun 2005 05:31:16 -0000	1.360
+++ config.c	11 Jun 2005 18:52:11 -0000	1.361
@@ -232,7 +232,8 @@
 
 /** Return the currently configured options. */
 or_options_t *
-get_options(void) {
+get_options(void)
+{
   tor_assert(global_options);
   return global_options;
 }
@@ -241,7 +242,8 @@
  * of their current value; free the old value as necessary.
  */
 void
-set_options(or_options_t *new_val) {
+set_options(or_options_t *new_val)
+{
   if (global_options)
     options_free(global_options);
   global_options = new_val;
@@ -258,7 +260,8 @@
  * else return address.
  */
 const char *
-safe_str(const char *address) {
+safe_str(const char *address)
+{
   if (get_options()->SafeLogging)
     return "[scrubbed]";
   else
@@ -276,7 +279,8 @@
  * here yet.  Some is still in do_hup() and other places.
  */
 int
-options_act(void) {
+options_act(void)
+{
   struct config_line_t *cl;
   or_options_t *options = get_options();
   static int libevent_initialized = 0;
@@ -549,7 +553,8 @@
  * config_var_t.  Otherwise, if <b>key</b> is a non-standard abbreviation,
  * warn, and return the corresponding config_var_t.  Otherwise return NULL.
  */
-static config_var_t *config_find_option(const char *key)
+static config_var_t *
+config_find_option(const char *key)
 {
   int i;
   size_t keylen = strlen(key);
@@ -1225,7 +1230,8 @@
 }
 
 static int
-validate_ports_csv(smartlist_t *sl, const char *name) {
+validate_ports_csv(smartlist_t *sl, const char *name)
+{
   int i;
   int result = 0;
   tor_assert(name);
@@ -1641,8 +1647,8 @@
 
 /** Check if any of the previous options have changed but aren't allowed to. */
 static int
-options_transition_allowed(or_options_t *old, or_options_t *new_val) {
-
+options_transition_allowed(or_options_t *old, or_options_t *new_val)
+{
   if (!old)
     return 0;
 
@@ -1682,7 +1688,8 @@
 #ifdef MS_WINDOWS
 /** Return the directory on windows where we expect to find our application
  * data. */
-static char *get_windows_conf_root(void)
+static char *
+get_windows_conf_root(void)
 {
   static int is_set = 0;
   static char path[MAX_PATH+1];
@@ -1738,7 +1745,8 @@
 /** Verify whether lst is a string containing valid-looking space-separated
  * nicknames, or NULL. Return 0 on success. Warn and return -1 on failure.
  */
-static int check_nickname_list(const char *lst, const char *name)
+static int
+check_nickname_list(const char *lst, const char *name)
 {
   int r = 0;
   smartlist_t *sl;
@@ -1897,8 +1905,12 @@
   return -1;
 }
 
+/** Adjust the address map mased on the MapAddress elements in the
+ * configuration <b>options</b>
+ */
 static void
-config_register_addressmaps(or_options_t *options) {
+config_register_addressmaps(or_options_t *options)
+{
   smartlist_t *elts;
   struct config_line_t *opt;
   char *from, *to;
@@ -2180,6 +2192,8 @@
 
 #define DEFAULT_EXIT_POLICY "reject 0.0.0.0/8,reject 169.254.0.0/16,reject 127.0.0.0/8,reject 192.168.0.0/16,reject 10.0.0.0/8,reject 172.16.0.0/12,reject *:25,reject *:119,reject *:135-139,reject *:445,reject *:1214,reject *:4661-4666,reject *:6346-6429,reject *:6699,reject *:6881-6999,accept *:*"
 
+/** Add the default exit policy entries to <b>policy</b>
+ */
 void
 config_append_default_exit_policy(addr_policy_t **policy)
 {
@@ -2247,7 +2261,8 @@
 
 /** Release all storage held by <b>p</b> */
 void
-addr_policy_free(addr_policy_t *p) {
+addr_policy_free(addr_policy_t *p)
+{
   addr_policy_t *e;
 
   while (p) {
@@ -2374,7 +2389,8 @@
 /** Adjust the value of options->DataDirectory, or fill it in if it's
  * absent. Return 0 on success, -1 on failure. */
 static int
-normalize_data_directory(or_options_t *options) {
+normalize_data_directory(or_options_t *options)
+{
 #ifdef MS_WINDOWS
   char *p;
   if (options->DataDirectory)
@@ -2412,7 +2428,8 @@
 /** Check and normalize the value of options->DataDirectory; return 0 if it
  * sane, -1 otherwise. */
 static int
-validate_data_directory(or_options_t *options) {
+validate_data_directory(or_options_t *options)
+{
   if (normalize_data_directory(options) < 0)
     return -1;
   tor_assert(options->DataDirectory);
@@ -2676,7 +2693,7 @@
   } else if (!strcmp(m, "poll")) {
     if (!strcmp(v, "1.0c") || !strcmp(v, "1.0d"))
       buggy = 1;
-    else if (!strcmp(v, "1.0e"))
+T    else if (!strcmp(v, "1.0e"))
       slow = 1;
   } else if (!strcmp(m, "poll")) {
     if (!strcmp(v, "1.0c") || !strcmp(v, "1.0d") || !strcmp(v, "1.0e"))
@@ -2700,6 +2717,7 @@
 }
 #endif
 
+/** Dump the version of every file to the log. */
 static void
 print_cvs_version(void)
 {

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.377
retrieving revision 1.378
diff -u -d -r1.377 -r1.378
--- connection.c	11 Jun 2005 06:07:22 -0000	1.377
+++ connection.c	11 Jun 2005 18:52:11 -0000	1.378
@@ -27,6 +27,9 @@
 
 /**************************************************************/
 
+/**
+ * Return the human-readable name for the connection type <b>type</b>
+ */
 const char *
 conn_type_to_string(int type)
 {
@@ -50,8 +53,13 @@
   }
 }
 
+/**
+ * Return the human-readable name for the connection state <b>state</b>
+ * for the connection type <b>type</b>
+ */
 const char *
-conn_state_to_string(int type, int state) {
+conn_state_to_string(int type, int state)
+{
   static char buf[96];
   switch (type) {
     case CONN_TYPE_OR_LISTENER:
@@ -138,7 +146,9 @@
  *
  * Initialize conn's timestamps to now.
  */
-connection_t *connection_new(int type) {
+connection_t *
+connection_new(int type)
+{
   static uint32_t n_connections_allocated = 0;
   connection_t *conn;
   time_t now = time(NULL);
@@ -188,7 +198,8 @@
  * is an OR or OP connection.
  */
 static void
-_connection_free(connection_t *conn) {
+_connection_free(connection_t *conn)
+{
   tor_assert(conn->magic == CONNECTION_MAGIC);
 
   if (!connection_is_listener(conn)) {
@@ -224,7 +235,9 @@
 
 /** Make sure <b>conn</b> isn't in any of the global conn lists; then free it.
  */
-void connection_free(connection_t *conn) {
+void
+connection_free(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(!connection_is_on_closeable_list(conn));
   tor_assert(!connection_in_array(conn));
@@ -243,7 +256,9 @@
  * Don't do the checks in connection_free(), because they will
  * fail.
  */
-void connection_free_all(void) {
+void
+connection_free_all(void)
+{
   int i, n;
   connection_t **carray;
 
@@ -261,7 +276,8 @@
  *   - AP and Exit conns need to send an end cell if they can.
  *   - DNS conns need to fail any resolves that are pending on them.
  */
-void connection_about_to_close_connection(connection_t *conn)
+void
+connection_about_to_close_connection(connection_t *conn)
 {
   circuit_t *circ;
 
@@ -338,7 +354,8 @@
  * flush it. Must be used in conjunction with (right before)
  * connection_mark_for_close().
  */
-void connection_close_immediate(connection_t *conn)
+void
+connection_close_immediate(connection_t *conn)
 {
   assert_connection_ok(conn,0);
   if (conn->s < 0) {
@@ -395,7 +412,8 @@
  * hold_open_until_flushed to 0. This means it will get cleaned
  * up in the next loop through close_if_marked() in main.c.
  */
-void connection_expire_held_open(void)
+void
+connection_expire_held_open(void)
 {
   connection_t **carray, *conn;
   int n, i;
@@ -428,7 +446,9 @@
  * If <b>bindaddress</b> includes a port, we bind on that port; otherwise, we
  * use bindport.
  */
-static int connection_create_listener(const char *bindaddress, uint16_t bindport, int type) {
+static int
+connection_create_listener(const char *bindaddress, uint16_t bindport, int type)
+{
   struct sockaddr_in bindaddr; /* where to bind */
   connection_t *conn;
   uint16_t usePort;
@@ -527,7 +547,9 @@
 /** The listener connection <b>conn</b> told poll() it wanted to read.
  * Call accept() on conn-\>s, and add the new connection if necessary.
  */
-static int connection_handle_listener_read(connection_t *conn, int new_type) {
+static int
+connection_handle_listener_read(connection_t *conn, int new_type)
+{
   int news; /* the new socket */
   connection_t *newconn;
   /* information about the remote peer when connecting to other routers */
@@ -629,8 +651,9 @@
 /** Initialize states for newly accepted connection <b>conn</b>.
  * If conn is an OR, start the tls handshake.
  */
-static int connection_init_accepted_conn(connection_t *conn) {
-
+static int
+connection_init_accepted_conn(connection_t *conn)
+{
   connection_start_reading(conn);
 
   switch (conn->type) {
@@ -658,7 +681,10 @@
  *
  * On success, add conn to the list of polled connections.
  */
-int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_t port) {
+int
+connection_connect(connection_t *conn, char *address,
+                   uint32_t addr, uint16_t port)
+{
   int s;
   struct sockaddr_in dest_addr;
   or_options_t *options = get_options();
@@ -732,7 +758,9 @@
 /** If there exist any listeners of type <b>type</b> in the connection
  * array, mark them for close.
  */
-static void listener_close_if_present(int type) {
+static void
+listener_close_if_present(int type)
+{
   connection_t *conn;
   connection_t **carray;
   int i,n;
@@ -761,9 +789,9 @@
  * Otherwise, only relaunch the listeners of this type if the number of
  * existing connections is not as configured (e.g., because one died).
  */
-static int retry_listeners(int type, struct config_line_t *cfg,
-                           int port_option, const char *default_addr,
-                           int force)
+static int
+retry_listeners(int type, struct config_line_t *cfg,
+                int port_option, const char *default_addr, int force)
 {
   if (!force) {
     int want, have, n_conn, i;
@@ -821,7 +849,9 @@
  * is false, then only relaunch listeners when we have the wrong number of
  * connections for a given type.
  */
-int retry_all_listeners(int force) {
+int
+retry_all_listeners(int force)
+{
   or_options_t *options = get_options();
 
   if (server_mode(options) &&
@@ -844,7 +874,9 @@
 extern int global_read_bucket, global_write_bucket;
 
 /** How many bytes at most can we read onto this connection? */
-static int connection_bucket_read_limit(connection_t *conn) {
+static int
+connection_bucket_read_limit(connection_t *conn)
+{
   int at_most;
 
   /* do a rudimentary round-robin so one circuit can't hog a connection */
@@ -867,14 +899,19 @@
 }
 
 /** We just read num_read onto conn. Decrement buckets appropriately. */
-static void connection_read_bucket_decrement(connection_t *conn, int num_read) {
+static void
+connection_read_bucket_decrement(connection_t *conn, int num_read)
+{
   global_read_bucket -= num_read; //tor_assert(global_read_bucket >= 0);
   if (connection_speaks_cells(conn) && conn->state == OR_CONN_STATE_OPEN) {
     conn->receiver_bucket -= num_read; //tor_assert(conn->receiver_bucket >= 0);
   }
 }
 
-static void connection_consider_empty_buckets(connection_t *conn) {
+/** DOCDOC */
+static void
+connection_consider_empty_buckets(connection_t *conn)
+{
   if (global_read_bucket <= 0) {
     log_fn(LOG_DEBUG,"global bucket exhausted. Pausing.");
     conn->wants_to_read = 1;
@@ -892,14 +929,18 @@
 
 /** Initialize the global read bucket to options->BandwidthBurst,
  * and current_time to the current time. */
-void connection_bucket_init(void) {
+void
+connection_bucket_init(void)
+{
   or_options_t *options = get_options();
   global_read_bucket = (int)options->BandwidthBurst; /* start it at max traffic */
   global_write_bucket = (int)options->BandwidthBurst; /* start it at max traffic */
 }
 
 /** A second has rolled over; increment buckets appropriately. */
-void connection_bucket_refill(struct timeval *now) {
+void
+connection_bucket_refill(struct timeval *now)
+{
   int i, n;
   connection_t *conn;
   connection_t **carray;
@@ -947,7 +988,9 @@
 /** Is the receiver bucket for connection <b>conn</b> low enough that we
  * should add another pile of tokens to it?
  */
-static int connection_receiver_bucket_should_increase(connection_t *conn) {
+static int
+connection_receiver_bucket_should_increase(connection_t *conn)
+{
   tor_assert(conn);
 
   if (!connection_speaks_cells(conn))
@@ -973,7 +1016,9 @@
  * Mark the connection and return -1 if you want to close it, else
  * return 0.
  */
-int connection_handle_read(connection_t *conn) {
+int
+connection_handle_read(connection_t *conn)
+{
   int max_to_read=-1, try_to_read;
 
   if (conn->marked_for_close)
@@ -1041,7 +1086,9 @@
  *
  * Return -1 if we want to break conn, else return 0.
  */
-static int connection_read_to_buf(connection_t *conn, int *max_to_read) {
+static int
+connection_read_to_buf(connection_t *conn, int *max_to_read)
+{
   int result, at_most = *max_to_read;
   size_t bytes_in_buf, more_to_read;
 
@@ -1140,13 +1187,17 @@
 }
 
 /** A pass-through to fetch_from_buf. */
-int connection_fetch_from_buf(char *string, size_t len, connection_t *conn) {
+int
+connection_fetch_from_buf(char *string, size_t len, connection_t *conn)
+{
   return fetch_from_buf(string, len, conn->inbuf);
 }
 
 /** Return conn-\>outbuf_flushlen: how many bytes conn wants to flush
  * from its outbuf. */
-int connection_wants_to_flush(connection_t *conn) {
+int
+connection_wants_to_flush(connection_t *conn)
+{
   return conn->outbuf_flushlen;
 }
 
@@ -1154,7 +1205,9 @@
  * send back a relay-level sendme yet? Return 1 if so, 0 if not. Used by
  * connection_edge_consider_sending_sendme().
  */
-int connection_outbuf_too_full(connection_t *conn) {
+int
+connection_outbuf_too_full(connection_t *conn)
+{
   return (conn->outbuf_flushlen > 10*CELL_PAYLOAD_SIZE);
 }
 
@@ -1172,7 +1225,9 @@
  * Mark the connection and return -1 if you want to close it, else
  * return 0.
  */
-int connection_handle_write(connection_t *conn) {
+int
+connection_handle_write(connection_t *conn)
+{
   int e;
   socklen_t len=sizeof(e);
   int result;
@@ -1288,7 +1343,8 @@
 }
 
 /* DOCDOC */
-void _connection_controller_force_write(connection_t *conn)
+void
+_connection_controller_force_write(connection_t *conn)
 {
   /* XXX This is hideous code duplication, but raising it seems a little
    * tricky for now.  Think more about this one.   We only call it for
@@ -1324,8 +1380,9 @@
 /** Append <b>len</b> bytes of <b>string</b> onto <b>conn</b>'s
  * outbuf, and ask it to start writing.
  */
-void connection_write_to_buf(const char *string, size_t len, connection_t *conn) {
-
+void
+connection_write_to_buf(const char *string, size_t len, connection_t *conn)
+{
   if (!len)
     return;
   /* if it's marked for close, only allow write if we mean to flush it */
@@ -1351,7 +1408,9 @@
 
 /** Return the conn to addr/port that has the most recent
  * timestamp_created, or NULL if no such conn exists. */
-connection_t *connection_or_exact_get_by_addr_port(uint32_t addr, uint16_t port) {
+connection_t *
+connection_or_exact_get_by_addr_port(uint32_t addr, uint16_t port)
+{
   int i, n;
   connection_t *conn, *best=NULL;
   connection_t **carray;
@@ -1369,7 +1428,8 @@
   return best;
 }
 
-connection_t *connection_get_by_identity_digest(const char *digest, int type)
+connection_t *
+connection_get_by_identity_digest(const char *digest, int type)
 {
   int i, n;
   connection_t *conn, *best=NULL;
@@ -1392,7 +1452,8 @@
  * marked for close.
  */
 connection_t *
-connection_get_by_global_id(uint32_t id) {
+connection_get_by_global_id(uint32_t id)
+{
   int i, n;
   connection_t *conn;
   connection_t **carray;
@@ -1413,7 +1474,9 @@
 /** Return a connection of type <b>type</b> that is not marked for
  * close.
  */
-connection_t *connection_get_by_type(int type) {
+connection_t *
+connection_get_by_type(int type)
+{
   int i, n;
   connection_t *conn;
   connection_t **carray;
@@ -1430,7 +1493,9 @@
 /** Return a connection of type <b>type</b> that is in state <b>state</b>,
  * and that is not marked for close.
  */
-connection_t *connection_get_by_type_state(int type, int state) {
+connection_t *
+connection_get_by_type_state(int type, int state)
+{
   int i, n;
   connection_t *conn;
   connection_t **carray;
@@ -1448,7 +1513,9 @@
  * <b>state</b>, that was written to least recently, and that is not
  * marked for close.
  */
-connection_t *connection_get_by_type_state_lastwritten(int type, int state) {
+connection_t *
+connection_get_by_type_state_lastwritten(int type, int state)
+{
   int i, n;
   connection_t *conn, *best=NULL;
   connection_t **carray;
@@ -1486,7 +1553,9 @@
 }
 
 /** Return 1 if <b>conn</b> is a listener conn, else return 0. */
-int connection_is_listener(connection_t *conn) {
+int
+connection_is_listener(connection_t *conn)
+{
   if (conn->type == CONN_TYPE_OR_LISTENER ||
       conn->type == CONN_TYPE_AP_LISTENER ||
       conn->type == CONN_TYPE_DIR_LISTENER ||
@@ -1498,7 +1567,9 @@
 /** Return 1 if <b>conn</b> is in state "open" and is not marked
  * for close, else return 0.
  */
-int connection_state_is_open(connection_t *conn) {
+int
+connection_state_is_open(connection_t *conn)
+{
   tor_assert(conn);
 
   if (conn->marked_for_close)
@@ -1514,7 +1585,9 @@
 }
 
 /** Return 1 if conn is in 'connecting' state, else return 0. */
-int connection_state_is_connecting(connection_t *conn) {
+int
+connection_state_is_connecting(connection_t *conn)
+{
   tor_assert(conn);
 
   if (conn->marked_for_close)
@@ -1537,7 +1610,9 @@
  *
  * Return 0.
  */
-int connection_send_destroy(uint16_t circ_id, connection_t *conn) {
+int
+connection_send_destroy(uint16_t circ_id, connection_t *conn)
+{
   cell_t cell;
 
   tor_assert(conn);
@@ -1555,7 +1630,8 @@
  * auth, based on the input string <b>authenticator</b>. Returns it
  * if success, else returns NULL. */
 char *
-alloc_http_authenticator(const char *authenticator) {
+alloc_http_authenticator(const char *authenticator)
+{
   /* an authenticator in Basic authentication
    * is just the string "username:password" */
   const int authenticator_length = strlen(authenticator);
@@ -1579,8 +1655,9 @@
  * connection_*_process_inbuf() function. It also passes in
  * package_partial if wanted.
  */
-static int connection_process_inbuf(connection_t *conn, int package_partial) {
-
+static int
+connection_process_inbuf(connection_t *conn, int package_partial)
+{
   tor_assert(conn);
 
   switch (conn->type) {
@@ -1610,8 +1687,9 @@
  * This function just passes conn to the connection-specific
  * connection_*_finished_flushing() function.
  */
-static int connection_finished_flushing(connection_t *conn) {
-
+static int
+connection_finished_flushing(connection_t *conn)
+{
   tor_assert(conn);
 
 //  log_fn(LOG_DEBUG,"entered. Socket %u.", conn->s);
@@ -1643,7 +1721,8 @@
  * This function just passes conn to the connection-specific
  * connection_*_finished_connecting() function.
  */
-static int connection_finished_connecting(connection_t *conn)
+static int
+connection_finished_connecting(connection_t *conn)
 {
   tor_assert(conn);
   switch (conn->type)
@@ -1661,7 +1740,9 @@
   }
 }
 
-static int connection_reached_eof(connection_t *conn)
+/** Callback: invoked when a connection reaches an EOF event. */
+static int
+connection_reached_eof(connection_t *conn)
 {
   switch (conn->type) {
     case CONN_TYPE_OR:
@@ -1687,7 +1768,8 @@
 /** Verify that connection <b>conn</b> has all of its invariants
  * correct. Trigger an assert if anything is invalid.
  */
-void assert_connection_ok(connection_t *conn, time_t now)
+void
+assert_connection_ok(connection_t *conn, time_t now)
 {
   tor_assert(conn);
   tor_assert(conn->magic == CONNECTION_MAGIC);

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.330
retrieving revision 1.331
diff -u -d -r1.330 -r1.331
--- connection_edge.c	9 Jun 2005 19:03:31 -0000	1.330
+++ connection_edge.c	11 Jun 2005 18:52:11 -0000	1.331
@@ -26,8 +26,8 @@
  */
 void
 _connection_mark_unattached_ap(connection_t *conn, int endreason,
-                               int line, const char *file) {
-
+                               int line, const char *file)
+{
   tor_assert(conn->type == CONN_TYPE_AP);
   conn->has_sent_end = 1; /* no circ yet */
 
@@ -57,7 +57,9 @@
 
 /** There was an EOF. Send an end and mark the connection for close.
  */
-int connection_edge_reached_eof(connection_t *conn) {
+int
+connection_edge_reached_eof(connection_t *conn)
+{
 #ifdef HALF_OPEN
   /* eof reached; we're done reading, but we might want to write more. */
   conn->done_receiving = 1;
@@ -98,8 +100,9 @@
  * Mark and return -1 if there was an unexpected error with the conn,
  * else return 0.
  */
-int connection_edge_process_inbuf(connection_t *conn, int package_partial) {
-
+int
+connection_edge_process_inbuf(connection_t *conn, int package_partial)
+{
   tor_assert(conn);
   tor_assert(CONN_IS_EDGE(conn));
 
@@ -138,7 +141,9 @@
 /** This edge needs to be closed, because its circuit has closed.
  * Mark it for close and return 0.
  */
-int connection_edge_destroy(uint16_t circ_id, connection_t *conn) {
+int
+connection_edge_destroy(uint16_t circ_id, connection_t *conn)
+{
   tor_assert(CONN_IS_EDGE(conn));
 
   if (!conn->marked_for_close) {
@@ -228,7 +233,9 @@
  * If <b>conn</b> is broken, mark it for close and return -1, else
  * return 0.
  */
-int connection_edge_finished_flushing(connection_t *conn) {
+int
+connection_edge_finished_flushing(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(CONN_IS_EDGE(conn));
 
@@ -256,7 +263,8 @@
 /** Connected handler for exit connections: start writing pending
  * data, deliver 'CONNECTED' relay cells as appropriate, and check
  * any pending data that may have been received. */
-int connection_edge_finished_connecting(connection_t *conn)
+int
+connection_edge_finished_connecting(connection_t *conn)
 {
   char connected_payload[4];
 
@@ -296,7 +304,9 @@
  * For rendezvous streams, simply give up after 45 seconds (with no
  * retry attempt).
  */
-void connection_ap_expire_beginning(void) {
+void
+connection_ap_expire_beginning(void)
+{
   connection_t **carray;
   connection_t *conn;
   circuit_t *circ;
@@ -366,7 +376,8 @@
 /** Tell any AP streams that are waiting for a new circuit that one is
  * available.
  */
-void connection_ap_attach_pending(void)
+void
+connection_ap_attach_pending(void)
 {
   connection_t **carray;
   connection_t *conn;
@@ -455,27 +466,33 @@
 static strmap_t *virtaddress_reversemap=NULL;
 
 /** Initialize addressmap. */
-void addressmap_init(void) {
+void
+addressmap_init(void)
+{
   addressmap = strmap_new();
   virtaddress_reversemap = strmap_new();
 }
 
 /** Free the memory associated with the addressmap entry <b>_ent</b>. */
 static void
-addressmap_ent_free(void *_ent) {
+addressmap_ent_free(void *_ent)
+{
   addressmap_entry_t *ent = _ent;
   tor_free(ent->new_address);
   tor_free(ent);
 }
 
+/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b> */
 static void
-addressmap_virtaddress_ent_free(void *_ent) {
+addressmap_virtaddress_ent_free(void *_ent)
+{
   virtaddress_entry_t *ent = _ent;
   tor_free(ent->ipv4_address);
   tor_free(ent->hostname_address);
   tor_free(ent);
 }
 
+/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b> */
 static void
 addressmap_virtaddress_remove(const char *addr, addressmap_entry_t *ent)
 {
@@ -521,13 +538,17 @@
 /** Clean out entries from the addressmap cache that were
  * added long enough ago that they are no longer valid.
  */
-void addressmap_clean(time_t now) {
+void
+addressmap_clean(time_t now)
+{
   addressmap_get_mappings(NULL, 2, now);
 }
 
 /** Free all the elements in the addressmap, and free the addressmap
  * itself. */
-void addressmap_free_all(void) {
+void
+addressmap_free_all(void)
+{
   strmap_free(addressmap, addressmap_ent_free);
   addressmap = NULL;
   strmap_free(virtaddress_reversemap, addressmap_virtaddress_ent_free);
@@ -537,7 +558,9 @@
  * more rewrites; but don't get into an infinite loop.
  * Don't write more than maxlen chars into address.
  */
-void addressmap_rewrite(char *address, size_t maxlen) {
+void
+addressmap_rewrite(char *address, size_t maxlen)
+{
   addressmap_entry_t *ent;
   int rewrites;
 
@@ -557,7 +580,9 @@
 }
 
 /** Return 1 if <b>address</b> is already registered, else return 0 */
-int addressmap_already_mapped(const char *address) {
+int
+addressmap_already_mapped(const char *address)
+{
   return strmap_get(addressmap, address) ? 1 : 0;
 }
 
@@ -572,7 +597,9 @@
  * If <b>new_address</b> is NULL, or equal to <b>address</b>, remove
  * any mappings that exist from <b>address</b>.
  */
-void addressmap_register(const char *address, char *new_address, time_t expires) {
+void
+addressmap_register(const char *address, char *new_address, time_t expires)
+{
   addressmap_entry_t *ent;
 
   ent = strmap_get(addressmap, address);
@@ -616,7 +643,8 @@
  * Increment the number of resolve failures we have on record
  * for it, and then return that number.
  */
-int client_dns_incr_failures(const char *address)
+int
+client_dns_incr_failures(const char *address)
 {
   addressmap_entry_t *ent;
   ent = strmap_get(addressmap,address);
@@ -638,7 +666,8 @@
  * If <b>exitname</b> is defined, then append the addresses with
  * ".exitname.exit" before registering the mapping.
  */
-void client_dns_set_addressmap(const char *address, uint32_t val, const char *exitname)
+void
+client_dns_set_addressmap(const char *address, uint32_t val, const char *exitname)
 {
   struct in_addr in;
   char extendedaddress[MAX_SOCKS_ADDR_LEN+MAX_HEX_NICKNAME_LEN+10];
@@ -802,7 +831,8 @@
  * colons. Return 0 if it's fine.
  */
 static int
-address_is_invalid_destination(const char *address) {
+address_is_invalid_destination(const char *address)
+{
   /* FFFF should flesh this out */
   if (strchr(address,':'))
     return 1;
@@ -854,7 +884,9 @@
  * Return -1 if an unexpected error with conn (and it should be marked
  * for close), else return 0.
  */
-static int connection_ap_handshake_process_socks(connection_t *conn) {
+static int
+connection_ap_handshake_process_socks(connection_t *conn)
+{
   socks_request_t *socks;
   int sockshere;
   hostname_type_t addresstype;
@@ -1055,7 +1087,9 @@
 /** Iterate over the two bytes of stream_id until we get one that is not
  * already in use; return it. Return 0 if can't get a unique stream_id.
  */
-static uint16_t get_unique_stream_id_by_circ(circuit_t *circ) {
+static uint16_t
+get_unique_stream_id_by_circ(circuit_t *circ)
+{
   connection_t *tmpconn;
   uint16_t test_stream_id;
   uint32_t attempts=0;
@@ -1080,7 +1114,8 @@
  *
  * If ap_conn is broken, mark it for close and return -1. Else return 0.
  */
-int connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ)
+int
+connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ)
 {
   char payload[CELL_PAYLOAD_SIZE];
   int payload_len;
@@ -1122,7 +1157,8 @@
  *
  * If ap_conn is broken, mark it for close and return -1. Else return 0.
  */
-int connection_ap_handshake_send_resolve(connection_t *ap_conn, circuit_t *circ)
+int
+connection_ap_handshake_send_resolve(connection_t *ap_conn, circuit_t *circ)
 {
   int payload_len;
   const char *string_addr;
@@ -1163,7 +1199,9 @@
  *
  * Return the other end of the socketpair, or -1 if error.
  */
-int connection_ap_make_bridge(char *address, uint16_t port) {
+int
+connection_ap_make_bridge(char *address, uint16_t port)
+{
   int fd[2];
   connection_t *conn;
 
@@ -1220,10 +1258,11 @@
  * -1 for unreachable; the answer should be in the format specified
  * in the socks extensions document.
  **/
-void connection_ap_handshake_socks_resolved(connection_t *conn,
-                                            int answer_type,
-                                            size_t answer_len,
-                                            const char *answer)
+void
+connection_ap_handshake_socks_resolved(connection_t *conn,
+                                       int answer_type,
+                                       size_t answer_len,
+                                       const char *answer)
 {
   char buf[256];
   size_t replylen;
@@ -1285,9 +1324,10 @@
  *
  * If <b>reply</b> is undefined, <b>status</b> can't be 0.
  */
-void connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
-                                         size_t replylen,
-                                         socks5_reply_status_t status) {
+void
+connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
+                                    size_t replylen,
+                                    socks5_reply_status_t status) {
   char buf[256];
   tor_assert(conn->socks_request); /* make sure it's an AP stream */
 
@@ -1341,7 +1381,9 @@
  *
  * Return -1 if we want to tear down <b>circ</b>. Else return 0.
  */
-int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) {
+int
+connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
+{
   connection_t *n_stream;
   relay_header_t rh;
   char *address=NULL;
@@ -1449,7 +1491,9 @@
  * Called when we receive a RELAY_RESOLVE cell 'cell' along the circuit 'circ';
  * begin resolving the hostname, and (eventually) reply with a RESOLVED cell.
  */
-int connection_exit_begin_resolve(cell_t *cell, circuit_t *circ) {
+int
+connection_exit_begin_resolve(cell_t *cell, circuit_t *circ)
+{
   connection_t *dummy_conn;
   relay_header_t rh;
 
@@ -1498,7 +1542,8 @@
  * streams must not reveal what IP they connected to.)
  */
 void
-connection_exit_connect(connection_t *conn) {
+connection_exit_connect(connection_t *conn)
+{
   char connected_payload[4];
   uint32_t addr;
   uint16_t port;
@@ -1577,7 +1622,9 @@
 /** Return 1 if <b>conn</b> is a rendezvous stream, or 0 if
  * it is a general stream.
  */
-int connection_edge_is_rendezvous_stream(connection_t *conn) {
+int
+connection_edge_is_rendezvous_stream(connection_t *conn)
+{
   tor_assert(conn);
   if (*conn->rend_query) /* XXX */
     return 1;
@@ -1589,7 +1636,8 @@
  * (We might be uncertain if conn's destination address has not yet been
  * resolved.)
  */
-int connection_ap_can_use_exit(connection_t *conn, routerinfo_t *exit)
+int
+connection_ap_can_use_exit(connection_t *conn, routerinfo_t *exit)
 {
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_AP);
@@ -1648,6 +1696,8 @@
   }
 }
 
+/** Free all storage held by our SOCKS allow policy
+ */
 void
 free_socks_policy(void)
 {
@@ -1658,7 +1708,8 @@
 /** Return 1 if <b>addr</b> is permitted to connect to our socks port,
  * based on <b>socks_policy</b>. Else return 0.
  */
-int socks_policy_permits_address(uint32_t addr)
+int
+socks_policy_permits_address(uint32_t addr)
 {
   int a;
 
@@ -1695,7 +1746,8 @@
  *     Return NORMAL_HOSTNAME and change nothing.
  */
 hostname_type_t
-parse_extended_hostname(char *address) {
+parse_extended_hostname(char *address)
+{
     char *s;
     char query[REND_SERVICE_ID_LEN+1];
 

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_or.c,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -d -r1.177 -r1.178
--- connection_or.c	9 Jun 2005 19:03:31 -0000	1.177
+++ connection_or.c	11 Jun 2005 18:52:11 -0000	1.178
@@ -26,7 +26,9 @@
  * in the buffer <b>dest</b>. See tor-spec.txt for details about the
  * wire format.
  */
-static void cell_pack(char *dest, const cell_t *src) {
+static void
+cell_pack(char *dest, const cell_t *src)
+{
   *(uint16_t*)dest     = htons(src->circ_id);
   *(uint8_t*)(dest+2)  = src->command;
   memcpy(dest+3, src->payload, CELL_PAYLOAD_SIZE);
@@ -35,13 +37,17 @@
 /** Unpack the network-order buffer <b>src</b> into a host-order
  * cell_t structure <b>dest</b>.
  */
-static void cell_unpack(cell_t *dest, const char *src) {
+static void
+cell_unpack(cell_t *dest, const char *src)
+{
   dest->circ_id = ntohs(*(uint16_t*)(src));
   dest->command = *(uint8_t*)(src+2);
   memcpy(dest->payload, src+3, CELL_PAYLOAD_SIZE);
 }
 
-int connection_or_reached_eof(connection_t *conn) {
+int
+connection_or_reached_eof(connection_t *conn)
+{
   log_fn(LOG_INFO,"OR connection reached EOF. Closing.");
   connection_mark_for_close(conn);
   return 0;
@@ -53,8 +59,8 @@
  * and hope for better luck next time.
  */
 static int
-connection_or_read_proxy_response(connection_t *conn) {
-
+connection_or_read_proxy_response(connection_t *conn)
+{
   char *headers;
   char *reason=NULL;
   int status_code;
@@ -108,8 +114,9 @@
  * connection_or_process_cells_from_inbuf()
  * (else do nothing).
  */
-int connection_or_process_inbuf(connection_t *conn) {
-
+int
+connection_or_process_inbuf(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_OR);
 
@@ -131,7 +138,9 @@
  * If <b>conn</b> is broken, mark it for close and return -1, else
  * return 0.
  */
-int connection_or_finished_flushing(connection_t *conn) {
+int
+connection_or_finished_flushing(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_OR);
 
@@ -156,7 +165,8 @@
 
 /** Connected handler for OR connections: begin the TLS handshake.
  */
-int connection_or_finished_connecting(connection_t *conn)
+int
+connection_or_finished_connecting(connection_t *conn)
 {
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_OR);
@@ -208,7 +218,8 @@
  * if the other side initiated it.
  */
 static void
-connection_or_init_conn_from_router(connection_t *conn, routerinfo_t *router) {
+connection_or_init_conn_from_router(connection_t *conn, routerinfo_t *router)
+{
   or_options_t *options = get_options();
 
   conn->addr = router->addr;
@@ -221,6 +232,7 @@
   conn->address = tor_strdup(router->address);
 }
 
+/** DOCDOC */
 static void
 connection_or_init_conn_from_address(connection_t *conn,
                                      uint32_t addr, uint16_t port,
@@ -257,6 +269,7 @@
   tor_inet_ntoa(&in,conn->address,INET_NTOA_BUF_LEN);
 }
 
+/** DOCDOC */
 void
 connection_or_update_nickname(connection_t *conn)
 {
@@ -303,8 +316,9 @@
  *
  * Return the launched conn, or NULL if it failed.
  */
-connection_t *connection_or_connect(uint32_t addr, uint16_t port,
-                                    const char *id_digest) {
+connection_t *
+connection_or_connect(uint32_t addr, uint16_t port, const char *id_digest)
+{
   connection_t *conn;
   routerinfo_t *me;
   or_options_t *options = get_options();
@@ -370,7 +384,9 @@
  *
  * Return -1 if <b>conn</b> is broken, else return 0.
  */
-int connection_tls_start_handshake(connection_t *conn, int receiving) {
+int
+connection_tls_start_handshake(connection_t *conn, int receiving)
+{
   conn->state = OR_CONN_STATE_HANDSHAKING;
   conn->tls = tor_tls_new(conn->s, receiving, 0);
   if (!conn->tls) {
@@ -390,7 +406,9 @@
  *
  * Return -1 if <b>conn</b> is broken, else return 0.
  */
-int connection_tls_continue_handshake(connection_t *conn) {
+int
+connection_tls_continue_handshake(connection_t *conn)
+{
   check_no_tls_errors();
   switch (tor_tls_handshake(conn->tls)) {
     case TOR_TLS_ERROR:
@@ -412,7 +430,9 @@
 
 static char ZERO_DIGEST[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
 
-int connection_or_nonopen_was_started_here(connection_t *conn)
+/** DOCDOC */
+int
+connection_or_nonopen_was_started_here(connection_t *conn)
 {
   tor_assert(sizeof(ZERO_DIGEST) == DIGEST_LEN);
   tor_assert(conn->type == CONN_TYPE_OR);
@@ -443,7 +463,8 @@
  * an authdirserver).
  */
 static int
-connection_tls_finish_handshake(connection_t *conn) {
+connection_tls_finish_handshake(connection_t *conn)
+{
   routerinfo_t *router;
   char nickname[MAX_NICKNAME_LEN+1];
   connection_t *c;
@@ -567,7 +588,9 @@
  * (Commented out) If it's an OR conn, and an entire TLS record is
  * ready, then try to flush the record now.
  */
-void connection_or_write_cell_to_buf(const cell_t *cell, connection_t *conn) {
+void
+connection_or_write_cell_to_buf(const cell_t *cell, connection_t *conn)
+{
   char networkcell[CELL_NETWORK_SIZE];
   char *n = networkcell;
 
@@ -615,7 +638,9 @@
  *
  * Always return 0.
  */
-static int connection_or_process_cells_from_inbuf(connection_t *conn) {
+static int
+connection_or_process_cells_from_inbuf(connection_t *conn)
+{
   char buf[CELL_NETWORK_SIZE];
   cell_t cell;
 

Index: control.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- control.c	11 Jun 2005 05:31:17 -0000	1.86
+++ control.c	11 Jun 2005 18:52:11 -0000	1.87
@@ -184,6 +184,7 @@
   }
 }
 
+/** DOCDOC */
 static INLINE int
 log_severity_to_event(int severity)
 {
@@ -199,7 +200,8 @@
 
 /** Set <b>global_event_mask</b> to the bitwise OR of each live control
  * connection's event_mask field. */
-static void update_global_event_mask(void)
+static void
+update_global_event_mask(void)
 {
   connection_t **conns;
   int n_conns, i;
@@ -215,7 +217,10 @@
   adjust_event_log_severity();
 }
 
-void adjust_event_log_severity(void) {
+/** DOCDOC */
+void
+adjust_event_log_severity(void)
+{
   int i;
   int min_log_event=EVENT_ERR_MSG, max_log_event=EVENT_DEBUG_MSG;
 
@@ -286,7 +291,9 @@
   send_control_message(conn, CONTROL_CMD_DONE, 0, NULL);
 }
 
-static void send_control_done2(connection_t *conn, const char *msg, size_t len)
+/** DOCDOC */
+static void
+send_control_done2(connection_t *conn, const char *msg, size_t len)
 {
   if (len==0)
     len = strlen(msg);
@@ -527,6 +534,7 @@
   return 0;
 }
 
+/** DOCDOC */
 static int
 handle_control_saveconf(connection_t *conn, uint32_t len,
                         const char *body)
@@ -540,6 +548,7 @@
   return 0;
 }
 
+/** DOCDOC */
 static int
 handle_control_signal(connection_t *conn, uint32_t len,
                       const char *body)
@@ -555,6 +564,7 @@
   return 0;
 }
 
+/** DOCDOC */
 static int
 handle_control_mapaddress(connection_t *conn, uint32_t len, const char *body)
 {
@@ -663,6 +673,7 @@
   return 0;
 }
 
+/** DOCDOC */
 static int
 handle_control_getinfo(connection_t *conn, uint32_t len, const char *body)
 {
@@ -702,6 +713,8 @@
 
   return 0;
 }
+
+/** DOCDOC */
 static int
 handle_control_extendcircuit(connection_t *conn, uint32_t len,
                              const char *body)
@@ -779,7 +792,10 @@
   smartlist_free(routers);
   return 0;
 }
-static int handle_control_attachstream(connection_t *conn, uint32_t len,
+
+/** DOCDOC */
+static int
+handle_control_attachstream(connection_t *conn, uint32_t len,
                                         const char *body)
 {
   uint32_t conn_id;
@@ -829,6 +845,8 @@
   send_control_done(conn);
   return 0;
 }
+
+/** DOCDOC */
 static int
 handle_control_postdescriptor(connection_t *conn, uint32_t len,
                               const char *body)
@@ -848,6 +866,8 @@
 
   return 0;
 }
+
+/** DOCDOC */
 static int
 handle_control_redirectstream(connection_t *conn, uint32_t len,
                               const char *body)
@@ -873,6 +893,8 @@
   send_control_done(conn);
   return 0;
 }
+
+/** DOCDOC */
 static int
 handle_control_closestream(connection_t *conn, uint32_t len,
                            const char *body)
@@ -901,6 +923,7 @@
   return 0;
 }
 
+/** DOCDOC */
 static int
 handle_control_closecircuit(connection_t *conn, uint32_t len,
                             const char *body)
@@ -930,6 +953,7 @@
   return 0;
 }
 
+/** DOCDOC */
 static int
 handle_control_fragments(connection_t *conn, uint16_t command_type,
                          uint32_t body_len, char *body)
@@ -972,7 +996,8 @@
 
 /** Called when <b>conn</b> has no more bytes left on its outbuf. */
 int
-connection_control_finished_flushing(connection_t *conn) {
+connection_control_finished_flushing(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_CONTROL);
 
@@ -981,7 +1006,9 @@
 }
 
 /** Called when <b>conn</b> has gotten its socket closed. */
-int connection_control_reached_eof(connection_t *conn) {
+int
+connection_control_reached_eof(connection_t *conn)
+{
   log_fn(LOG_INFO,"Control connection reached EOF. Closing.");
   connection_mark_for_close(conn);
   return 0;
@@ -990,7 +1017,8 @@
 /** Called when <b>conn</b> has received more bytes on its inbuf.
  */
 int
-connection_control_process_inbuf(connection_t *conn) {
+connection_control_process_inbuf(connection_t *conn)
+{
   uint32_t body_len;
   uint16_t command_type;
   char *body;
@@ -1253,7 +1281,8 @@
  * interested control connections.  <b>routers</b> is a list of
  * DIGEST_LEN-byte identity digests.
  */
-int control_event_descriptors_changed(smartlist_t *routers)
+int
+control_event_descriptors_changed(smartlist_t *routers)
 {
   size_t len;
   char *msg;
@@ -1302,4 +1331,3 @@
 
   return 0;
 }
-

Index: cpuworker.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/cpuworker.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- cpuworker.c	11 Jun 2005 05:31:17 -0000	1.82
+++ cpuworker.c	11 Jun 2005 18:52:11 -0000	1.83
@@ -43,13 +43,17 @@
 
 /** Initialize the cpuworker subsystem.
  */
-void cpu_init(void) {
+void
+cpu_init(void)
+{
   last_rotation_time=time(NULL);
   spawn_enough_cpuworkers();
 }
 
 /** Called when we're done sending a request to a cpuworker. */
-int connection_cpu_finished_flushing(connection_t *conn) {
+int
+connection_cpu_finished_flushing(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_CPUWORKER);
   connection_stop_writing(conn);
@@ -58,7 +62,9 @@
 
 /** Pack addr,port,and circ_id; set *tag to the result. (See note on
  * cpuworker_main for wire format.) */
-static void tag_pack(char *tag, uint32_t addr, uint16_t port, uint16_t circ_id) {
+static void
+tag_pack(char *tag, uint32_t addr, uint16_t port, uint16_t circ_id)
+{
   *(uint32_t *)tag     = addr;
   *(uint16_t *)(tag+4) = port;
   *(uint16_t *)(tag+6) = circ_id;
@@ -66,7 +72,9 @@
 
 /** Unpack <b>tag</b> into addr, port, and circ_id.
  */
-static void tag_unpack(const char *tag, uint32_t *addr, uint16_t *port, uint16_t *circ_id) {
+static void
+tag_unpack(const char *tag, uint32_t *addr, uint16_t *port, uint16_t *circ_id)
+{
   struct in_addr in;
   char addrbuf[INET_NTOA_BUF_LEN];
 
@@ -83,7 +91,8 @@
  * cpuworkers.  Close all currently idle cpuworkers, and mark the last
  * rotation time as now.
  */
-void cpuworkers_rotate(void)
+void
+cpuworkers_rotate(void)
 {
   connection_t *cpuworker;
   while ((cpuworker = connection_get_by_type_state(CONN_TYPE_CPUWORKER,
@@ -97,7 +106,9 @@
 
 /** If the cpuworker closes the connection,
  * mark it as closed and spawn a new one as needed. */
-int connection_cpu_reached_eof(connection_t *conn) {
+int
+connection_cpu_reached_eof(connection_t *conn)
+{
   log_fn(LOG_WARN,"Read eof. Worker died unexpectedly.");
   if (conn->state != CPUWORKER_STATE_IDLE) {
     /* the circ associated with this cpuworker will have to wait until
@@ -116,7 +127,9 @@
  * wait for a complete answer. If the answer is complete,
  * process it as appropriate.
  */
-int connection_cpu_process_inbuf(connection_t *conn) {
+int
+connection_cpu_process_inbuf(connection_t *conn)
+{
   char success;
   char buf[LEN_ONION_RESPONSE];
   uint32_t addr;
@@ -199,7 +212,9 @@
  *  (Note: this _should_ be by addr/port, since we're concerned with specific
  * connections, not with routers (where we'd use identity).)
  */
-static int cpuworker_main(void *data) {
+static int
+cpuworker_main(void *data)
+{
   char question[ONIONSKIN_CHALLENGE_LEN];
   uint8_t question_type;
   int *fdarray = data;
@@ -280,7 +295,9 @@
 
 /** Launch a new cpuworker.
  */
-static int spawn_cpuworker(void) {
+static int
+spawn_cpuworker(void)
+{
   int *fdarray;
   int fd;
   connection_t *conn;
@@ -325,7 +342,9 @@
 /** If we have too few or too many active cpuworkers, try to spawn new ones
  * or kill idle ones.
  */
-static void spawn_enough_cpuworkers(void) {
+static void
+spawn_enough_cpuworkers(void)
+{
   int num_cpuworkers_needed = get_options()->NumCpus;
 
   if (num_cpuworkers_needed < MIN_CPUWORKERS)
@@ -343,7 +362,9 @@
 }
 
 /** Take a pending task from the queue and assign it to 'cpuworker'. */
-static void process_pending_task(connection_t *cpuworker) {
+static void
+process_pending_task(connection_t *cpuworker)
+{
   circuit_t *circ;
 
   tor_assert(cpuworker);
@@ -364,7 +385,8 @@
  * thinks of itself as idle. I don't know why. But here's a workaround
  * to kill any cpuworker that's been busy for more than 3600 seconds. */
 static void
-cull_wedged_cpuworkers(void) {
+cull_wedged_cpuworkers(void)
+{
   connection_t **carray;
   connection_t *conn;
   int n_conns, i;
@@ -391,8 +413,10 @@
  * If question_type is CPUWORKER_TASK_ONION then task is a circ.
  * No other question_types are allowed.
  */
-int assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type,
-                        void *task) {
+int
+assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type,
+                    void *task)
+{
   circuit_t *circ;
   char tag[TAG_LEN];
 

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.233
retrieving revision 1.234
diff -u -d -r1.233 -r1.234
--- directory.c	11 Jun 2005 05:31:17 -0000	1.233
+++ directory.c	11 Jun 2005 18:52:11 -0000	1.234
@@ -85,6 +85,7 @@
   }
 }
 
+/** Free storage used to hold parsed directory policy */
 void
 free_dir_policy(void)
 {
@@ -95,7 +96,8 @@
 /** Return 1 if <b>addr</b> is permitted to connect to our dir port,
  * based on <b>dir_policy</b>. Else return 0.
  */
-int dir_policy_permits_address(uint32_t addr)
+int
+dir_policy_permits_address(uint32_t addr)
 {
   int a;
 
@@ -110,8 +112,11 @@
   return 0;
 }
 
+/** Return true iff the directory purpose 'purpose' must use an
+ * anonymous connection to a directory. */
 static int
-purpose_is_private(uint8_t purpose) {
+purpose_is_private(uint8_t purpose)
+{
   if (purpose == DIR_PURPOSE_FETCH_DIR ||
       purpose == DIR_PURPOSE_UPLOAD_DIR ||
       purpose == DIR_PURPOSE_FETCH_RUNNING_LIST)
@@ -363,7 +368,8 @@
 static void
 directory_send_command(connection_t *conn, const char *platform,
                        int purpose, const char *resource,
-                       const char *payload, size_t payload_len) {
+                       const char *payload, size_t payload_len)
+{
   char tmp[8192];
   char proxystring[256];
   char proxyauthstring[256];
@@ -846,7 +852,10 @@
   return 0;
 }
 
-int connection_dir_reached_eof(connection_t *conn) {
+/** Called when a directory connection reaches EOF */
+int
+connection_dir_reached_eof(connection_t *conn)
+{
   int retval;
   if (conn->state != DIR_CONN_STATE_CLIENT_READING) {
     log_fn(LOG_INFO,"conn reached eof, not reading. Closing.");
@@ -863,8 +872,8 @@
 /** Read handler for directory connections.  (That's connections <em>to</em>
  * directory servers and connections <em>at</em> directory servers.)
  */
-int connection_dir_process_inbuf(connection_t *conn) {
-
+int connection_dir_process_inbuf(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_DIR);
 
@@ -910,7 +919,8 @@
  * Else return 0.
  */
 static int
-already_fetching_directory(int purpose) {
+already_fetching_directory(int purpose)
+{
   int i, n;
   connection_t *conn;
   connection_t **carray;
@@ -1050,7 +1060,7 @@
  * 400.  Always return 0. */
 static int
 directory_handle_command_post(connection_t *conn, char *headers,
-                                         char *body, size_t body_len)
+                              char *body, size_t body_len)
 {
   const char *cp;
   char *url;
@@ -1116,7 +1126,9 @@
  * from the inbuf, try to process it; otherwise, leave it on the
  * buffer.  Return a 0 on success, or -1 on error.
  */
-static int directory_handle_command(connection_t *conn) {
+static int
+directory_handle_command(connection_t *conn)
+{
   char *headers=NULL, *body=NULL;
   size_t body_len=0;
   int r;
@@ -1155,8 +1167,9 @@
  * been flushed.  Close the connection or wait for a response as
  * appropriate.
  */
-int connection_dir_finished_flushing(connection_t *conn) {
-
+int
+connection_dir_finished_flushing(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_DIR);
 
@@ -1180,7 +1193,8 @@
 
 /** Connected handler for directory connections: begin sending data to the
  * server */
-int connection_dir_finished_connecting(connection_t *conn)
+int
+connection_dir_finished_connecting(connection_t *conn)
 {
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_DIR);

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -d -r1.166 -r1.167
--- dirserv.c	11 Jun 2005 05:31:17 -0000	1.166
+++ dirserv.c	11 Jun 2005 18:52:11 -0000	1.167
@@ -196,7 +196,8 @@
 /** If we are an authoritative dirserver, and the list of approved
  * servers contains one whose identity key digest is <b>digest</b>,
  * return that router's nickname.  Otherwise return NULL. */
-const char *dirserv_get_nickname_by_digest(const char *digest)
+const char *
+dirserv_get_nickname_by_digest(const char *digest)
 {
   char hexdigest[HEX_DIGEST_LEN+1];
   if (!fingerprint_list)
@@ -730,6 +731,7 @@
 static char *the_directory_z = NULL;
 static size_t the_directory_z_len = 0;
 
+/** DOCDOC */
 typedef struct cached_dir_t {
   char *dir;
   char *dir_z;
@@ -745,8 +747,9 @@
 /** If we have no cached directory, or it is older than <b>when</b>, then
  * replace it with <b>directory</b>, published at <b>when</b>.
  */
-void dirserv_set_cached_directory(const char *directory, time_t when,
-                                  int is_running_routers)
+void
+dirserv_set_cached_directory(const char *directory, time_t when,
+                             int is_running_routers)
 {
   time_t now;
   cached_dir_t *d;
@@ -781,7 +784,8 @@
 /** Set *<b>directory</b> to the most recently generated encoded signed
  * directory, generating a new one as necessary.  If not an authoritative
  * directory may return 0 if no directory is yet cached.*/
-size_t dirserv_get_directory(const char **directory, int compress)
+size_t
+dirserv_get_directory(const char **directory, int compress)
 {
   if (!get_options()->AuthoritativeDir) {
     cached_dir_t *d = &cached_directory;
@@ -807,7 +811,8 @@
 /**
  * Generate a fresh directory (authdirservers only.)
  */
-static int dirserv_regenerate_directory(void)
+static int
+dirserv_regenerate_directory(void)
 {
   char *new_directory=NULL;
 
@@ -859,7 +864,8 @@
 static size_t the_runningrouters_z_len=0;
 
 /** Replace the current running-routers list with a newly generated one. */
-static int generate_runningrouters(crypto_pk_env_t *private_key)
+static int
+generate_runningrouters(crypto_pk_env_t *private_key)
 {
   char *s=NULL, *cp;
   char *router_status=NULL;
@@ -942,7 +948,8 @@
 /** Set *<b>rr</b> to the most recently generated encoded signed
  * running-routers list, generating a new one as necessary.  Return the
  * size of the directory on success, and 0 on failure. */
-size_t dirserv_get_runningrouters(const char **rr, int compress)
+size_t
+dirserv_get_runningrouters(const char **rr, int compress)
 {
   if (!get_options()->AuthoritativeDir) {
     cached_dir_t *d = &cached_runningrouters;
@@ -1012,6 +1019,7 @@
   }
 }
 
+/** Release all storage used by the directory server. */
 void
 dirserv_free_all(void)
 {

Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -d -r1.157 -r1.158
--- dns.c	11 Jun 2005 05:31:17 -0000	1.157
+++ dns.c	11 Jun 2005 18:52:11 -0000	1.158
@@ -91,19 +91,25 @@
 SPLAY_GENERATE(cache_tree, cached_resolve, node, compare_cached_resolves);
 
 /** Initialize the DNS cache. */
-static void init_cache_tree(void) {
+static void
+init_cache_tree(void)
+{
   SPLAY_INIT(&cache_root);
 }
 
 /** Initialize the DNS subsystem; called by the OR process. */
-void dns_init(void) {
+void
+dns_init(void)
+{
   init_cache_tree();
   last_rotation_time=time(NULL);
   spawn_enough_dnsworkers();
 }
 
+/** Helper: free storage held by an entry in the DNS cache. */
 static void
-_free_cached_resolve(struct cached_resolve *r) {
+_free_cached_resolve(struct cached_resolve *r)
+{
   while (r->pending_connections) {
     struct pending_connection_t *victim = r->pending_connections;
     r->pending_connections = victim->next;
@@ -112,6 +118,7 @@
   tor_free(r);
 }
 
+/** Free all storage held in the DNS cache */
 void
 dns_free_all(void)
 {
@@ -129,7 +136,9 @@
 
 /** Remove every cached_resolve whose <b>expire</b> time is before <b>now</b>
  * from the cache. */
-static void purge_expired_resolves(uint32_t now) {
+static void
+purge_expired_resolves(uint32_t now)
+{
   struct cached_resolve *resolve;
   struct pending_connection_t *pend;
   connection_t *pendconn;
@@ -169,7 +178,10 @@
   }
 }
 
-static void send_resolved_cell(connection_t *conn, uint8_t answer_type)
+/** Send a response to the RESOVLE request of a connection. answer_type must
+ *  be one of RESOLVED_TYPE_(IPV4|ERROR|ERROR_TRANSIENT) */
+static void
+send_resolved_cell(connection_t *conn, uint8_t answer_type)
 {
   char buf[RELAY_PAYLOAD_SIZE];
   size_t buflen;
@@ -223,7 +235,9 @@
  * Else, if not seen before, add conn to pending list, hand to
  * dns farm, and return 0.
  */
-int dns_resolve(connection_t *exitconn) {
+int
+dns_resolve(connection_t *exitconn)
+{
   struct cached_resolve *resolve;
   struct cached_resolve search;
   struct pending_connection_t *pending_connection;
@@ -305,7 +319,9 @@
 /** Find or spawn a dns worker process to handle resolving
  * <b>exitconn</b>-\>address; tell that dns worker to begin resolving.
  */
-static int assign_to_dnsworker(connection_t *exitconn) {
+static int
+assign_to_dnsworker(connection_t *exitconn)
+{
   connection_t *dnsconn;
   unsigned char len;
 
@@ -341,7 +357,8 @@
 
 /** Remove <b>conn</b> from the list of connections waiting for conn-\>address.
  */
-void connection_dns_remove(connection_t *conn)
+void
+connection_dns_remove(connection_t *conn)
 {
   struct pending_connection_t *pend, *victim;
   struct cached_resolve search;
@@ -386,7 +403,9 @@
 
 /** Log an error and abort if conn is waiting for a DNS resolve.
  */
-void assert_connection_edge_not_dns_pending(connection_t *conn) {
+void
+assert_connection_edge_not_dns_pending(connection_t *conn)
+{
   struct pending_connection_t *pend;
   struct cached_resolve *resolve;
 
@@ -401,7 +420,9 @@
 
 /** Log an error and abort if any connection waiting for a DNS resolve is
  * corrupted. */
-void assert_all_pending_dns_resolves_ok(void) {
+void
+assert_all_pending_dns_resolves_ok(void)
+{
   struct pending_connection_t *pend;
   struct cached_resolve *resolve;
 
@@ -420,7 +441,9 @@
  * the resolve for <b>address</b> itself, and remove any cached results for
  * <b>address</b> from the cache.
  */
-void dns_cancel_pending_resolve(char *address) {
+void
+dns_cancel_pending_resolve(char *address)
+{
   struct pending_connection_t *pend;
   struct cached_resolve search;
   struct cached_resolve *resolve;
@@ -469,7 +492,9 @@
 
 /** Remove <b>resolve</b> from the cache.
  */
-static void dns_purge_resolve(struct cached_resolve *resolve) {
+static void
+dns_purge_resolve(struct cached_resolve *resolve)
+{
   struct cached_resolve *tmp;
 
   /* remove resolve from the linked list */
@@ -500,7 +525,9 @@
  * <b>outcome</b> is one of
  * DNS_RESOLVE_{FAILED_TRANSIENT|FAILED_PERMANENT|SUCCEEDED}.
  */
-static void dns_found_answer(char *address, uint32_t addr, char outcome) {
+static void
+dns_found_answer(char *address, uint32_t addr, char outcome)
+{
   struct pending_connection_t *pend;
   struct cached_resolve search;
   struct cached_resolve *resolve;
@@ -604,14 +631,18 @@
  */
 
 /** Write handler: called when we've pushed a request to a dnsworker. */
-int connection_dns_finished_flushing(connection_t *conn) {
+int
+connection_dns_finished_flushing(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_DNSWORKER);
   connection_stop_writing(conn);
   return 0;
 }
 
-int connection_dns_reached_eof(connection_t *conn) {
+int
+connection_dns_reached_eof(connection_t *conn)
+{
   log_fn(LOG_WARN,"Read eof. Worker died unexpectedly.");
   if (conn->state == DNSWORKER_STATE_BUSY) {
     /* don't cancel the resolve here -- it would be cancelled in
@@ -628,7 +659,9 @@
 /** Read handler: called when we get data from a dnsworker. See
  * if we have a complete answer.  If so, call dns_found_answer on the
  * result.  If not, wait.  Returns 0. */
-int connection_dns_process_inbuf(connection_t *conn) {
+int
+connection_dns_process_inbuf(connection_t *conn)
+{
   char success;
   uint32_t addr;
 
@@ -681,7 +714,8 @@
 /** Close and re-open all idle dnsworkers; schedule busy ones to be closed
  * and re-opened once they're no longer busy.
  **/
-void dnsworkers_rotate(void)
+void
+dnsworkers_rotate(void)
 {
   connection_t *dnsconn;
   log_fn(LOG_INFO, "Rotating DNS workers.");
@@ -711,7 +745,9 @@
  * The dnsworker runs indefinitely, until its connection is closed or an error
  * occurs.
  */
-static int dnsworker_main(void *data) {
+static int
+dnsworker_main(void *data)
+{
   char address[MAX_ADDRESSLEN];
   unsigned char address_len;
   char answer[5];
@@ -782,7 +818,9 @@
 
 /** Launch a new DNS worker; return 0 on success, -1 on failure.
  */
-static int spawn_dnsworker(void) {
+static int
+spawn_dnsworker(void)
+{
   int *fdarray;
   int fd;
   connection_t *conn;
@@ -828,7 +866,9 @@
 
 /** If we have too many or too few DNS workers, spawn or kill some.
  */
-static void spawn_enough_dnsworkers(void) {
+static void
+spawn_enough_dnsworkers(void)
+{
   int num_dnsworkers_needed; /* aim to have 1 more than needed,
                            * but no less than min and no more than max */
   connection_t *dnsconn;

Index: hibernate.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/hibernate.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- hibernate.c	9 Jun 2005 19:03:31 -0000	1.53
+++ hibernate.c	11 Jun 2005 18:52:11 -0000	1.54
@@ -209,7 +209,9 @@
 /** If we want to manage the accounting system and potentially
  * hibernate, return 1, else return 0.
  */
-int accounting_is_enabled(or_options_t *options) {
+int
+accounting_is_enabled(or_options_t *options)
+{
   if (options->AccountingMax)
     return 1;
   return 0;
@@ -366,7 +368,8 @@
  * the start and end of the interval, and clear byte/time totals.
  */
 static void
-reset_accounting(time_t now) {
+reset_accounting(time_t now)
+{
   log_fn(LOG_INFO, "Starting new accounting interval.");
   update_expected_bandwidth();
   interval_start_time = start_of_accounting_period_containing(now);
@@ -400,6 +403,8 @@
   return 0;
 }
 
+/** Invoked once per second.  Checks whether it is time to hibernate,
+ * record bandwidth used, etc.  */
 void
 accounting_run_housekeeping(time_t now)
 {
@@ -640,7 +645,8 @@
 
 /** Return true iff we have sent/received almost all the bytes we are willing
  * to send/receive this interval. */
-static int hibernate_soft_limit_reached(void)
+static int
+hibernate_soft_limit_reached(void)
 {
   uint64_t soft_limit = (uint64_t) ((get_options()->AccountingMax) * .95);
   if (!soft_limit)
@@ -652,7 +658,9 @@
 /** Called when we get a SIGINT, or when bandwidth soft limit is
  * reached. Puts us into "loose hibernation": we don't accept new
  * connections, but we continue handling old ones. */
-static void hibernate_begin(int new_state, time_t now) {
+static void
+hibernate_begin(int new_state, time_t now)
+{
   connection_t *conn;
   or_options_t *options = get_options();
 
@@ -689,8 +697,8 @@
 
 /** Called when we've been hibernating and our timeout is reached. */
 static void
-hibernate_end(int new_state) {
-
+hibernate_end(int new_state)
+{
   tor_assert(hibernate_state == HIBERNATE_STATE_LOWBANDWIDTH ||
              hibernate_state == HIBERNATE_STATE_DORMANT);
 
@@ -704,20 +712,23 @@
 
 /** A wrapper around hibernate_begin, for when we get SIGINT. */
 void
-hibernate_begin_shutdown(void) {
+hibernate_begin_shutdown(void)
+{
   hibernate_begin(HIBERNATE_STATE_EXITING, time(NULL));
 }
 
 /** Return true iff we are currently hibernating. */
 int
-we_are_hibernating(void) {
+we_are_hibernating(void)
+{
   return hibernate_state != HIBERNATE_STATE_LIVE;
 }
 
 /** If we aren't currently dormant, close all connections and become
  * dormant. */
 static void
-hibernate_go_dormant(time_t now) {
+hibernate_go_dormant(time_t now)
+{
   connection_t *conn;
 
   if (hibernate_state == HIBERNATE_STATE_DORMANT)
@@ -780,7 +791,9 @@
 /** Consider our environment and decide if it's time
  * to start/stop hibernating.
  */
-void consider_hibernation(time_t now) {
+void
+consider_hibernation(time_t now)
+{
   int accounting_enabled = get_options()->AccountingMax != 0;
   char buf[ISO_TIME_LEN+1];
 

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.515
retrieving revision 1.516
diff -u -d -r1.515 -r1.516
--- main.c	11 Jun 2005 05:31:17 -0000	1.515
+++ main.c	11 Jun 2005 18:52:11 -0000	1.516
@@ -121,7 +121,9 @@
  * connection's socket must be set; the connection starts out
  * non-reading and non-writing.
  */
-int connection_add(connection_t *conn) {
+int
+connection_add(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->s >= 0);
 
@@ -153,7 +155,9 @@
  * corresponding poll entry.  Calling this function will shift the last
  * connection (if any) into the position occupied by conn.
  */
-int connection_remove(connection_t *conn) {
+int
+connection_remove(connection_t *conn)
+{
   int current_index;
 
   tor_assert(conn);
@@ -188,7 +192,9 @@
  *
  * Then free it.
  */
-static void connection_unlink(connection_t *conn, int remove) {
+static void
+connection_unlink(connection_t *conn, int remove)
+{
   circuit_about_to_close_connection(conn);
   connection_about_to_close_connection(conn);
   if (remove) {
@@ -212,12 +218,16 @@
 }
 
 /** Return 1 if conn is on the closeable list, else return 0. */
-int connection_is_on_closeable_list(connection_t *conn) {
+int
+connection_is_on_closeable_list(connection_t *conn)
+{
   return smartlist_isin(closeable_connection_lst, conn);
 }
 
 /** Return true iff conn is in the current poll array. */
-int connection_in_array(connection_t *conn) {
+int
+connection_in_array(connection_t *conn)
+{
   int i;
   for (i=0; i<nfds; ++i) {
     if (conn==connection_array[i])
@@ -230,15 +240,19 @@
  * to the length of the array. <b>*array</b> and <b>*n</b> must not
  * be modified.
  */
-void get_connection_array(connection_t ***array, int *n) {
+void
+get_connection_array(connection_t ***array, int *n)
+{
   *array = connection_array;
   *n = nfds;
 }
 
 /** Set the event mask on <b>conn</b> to <b>events</b>.  (The event
-* mask is a bitmask whose bits are EV_READ and EV_WRITE.)
+ * mask is a bitmask whose bits are EV_READ and EV_WRITE.)
  */
-void connection_watch_events(connection_t *conn, short events) {
+void
+connection_watch_events(connection_t *conn, short events)
+{
   int r;
 
   tor_assert(conn);
@@ -269,14 +283,18 @@
 }
 
 /** Return true iff <b>conn</b> is listening for read events. */
-int connection_is_reading(connection_t *conn) {
+int
+connection_is_reading(connection_t *conn)
+{
   tor_assert(conn);
 
   return conn->read_event && event_pending(conn->read_event, EV_READ, NULL);
 }
 
 /** Tell the main loop to stop notifying <b>conn</b> of any read events. */
-void connection_stop_reading(connection_t *conn) {
+void
+connection_stop_reading(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->read_event);
 
@@ -287,7 +305,9 @@
 }
 
 /** Tell the main loop to start notifying <b>conn</b> of any read events. */
-void connection_start_reading(connection_t *conn) {
+void
+connection_start_reading(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->read_event);
 
@@ -297,14 +317,18 @@
 }
 
 /** Return true iff <b>conn</b> is listening for write events. */
-int connection_is_writing(connection_t *conn) {
+int
+connection_is_writing(connection_t *conn)
+{
   tor_assert(conn);
 
   return conn->write_event && event_pending(conn->write_event, EV_WRITE, NULL);
 }
 
 /** Tell the main loop to stop notifying <b>conn</b> of any write events. */
-void connection_stop_writing(connection_t *conn) {
+void
+connection_stop_writing(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->write_event);
 
@@ -315,7 +339,9 @@
 }
 
 /** Tell the main loop to start notifying <b>conn</b> of any write events. */
-void connection_start_writing(connection_t *conn) {
+void
+connection_start_writing(connection_t *conn)
+{
   tor_assert(conn);
   tor_assert(conn->write_event);
 
@@ -371,7 +397,8 @@
 
 /** Libevent callback: this gets invoked when (connection_t*)<b>conn</b> has
  * some data to write. */
-static void conn_write_callback(int fd, short events, void *_conn)
+static void
+conn_write_callback(int fd, short events, void *_conn)
 {
   connection_t *conn = _conn;
 
@@ -404,7 +431,9 @@
  *      all other lists, close it, and free it.
  * Returns 1 if the connection was closed, 0 otherwise.
  */
-static int conn_close_if_marked(int i) {
+static int
+conn_close_if_marked(int i)
+{
   connection_t *conn;
   int retval;
 
@@ -456,7 +485,9 @@
  * and try another directory fetch. Kill off all the circuit_wait
  * streams that are waiting now, since they will all timeout anyway.
  */
-void directory_all_unreachable(time_t now) {
+void
+directory_all_unreachable(time_t now)
+{
   connection_t *conn;
 
   has_fetched_directory=0;
@@ -470,6 +501,9 @@
   }
 }
 
+/**
+ * Return the interval to wait betweeen directory downloads, in seconds.
+ */
 static INLINE int
 get_dir_fetch_period(or_options_t *options)
 {
@@ -484,6 +518,9 @@
     return 40*60;
 }
 
+/**
+ * Return the interval to wait betweeen router status downloads, in seconds.
+ */
 static INLINE int
 get_status_fetch_period(or_options_t *options)
 {
@@ -501,7 +538,9 @@
 /** This function is called whenever we successfully pull down a directory.
  * If <b>identity_digest</b> is defined, it contains the digest of the
  * router that just gave us this directory. */
-void directory_has_arrived(time_t now, char *identity_digest) {
+void
+directory_has_arrived(time_t now, char *identity_digest)
+{
   or_options_t *options = get_options();
 
   log_fn(LOG_INFO, "A directory has arrived.");
@@ -536,7 +575,9 @@
 /** Perform regular maintenance tasks for a single connection.  This
  * function gets run once per second per connection by run_scheduled_events.
  */
-static void run_connection_housekeeping(int i, time_t now) {
+static void
+run_connection_housekeeping(int i, time_t now)
+{
   cell_t cell;
   connection_t *conn = connection_array[i];
   or_options_t *options = get_options();
@@ -598,7 +639,9 @@
 /** Perform regular maintenance tasks.  This function gets run once per
  * second by prepare_for_poll.
  */
-static void run_scheduled_events(time_t now) {
+static void
+run_scheduled_events(time_t now)
+{
   static time_t last_rotated_certificate = 0;
   static time_t time_to_check_listeners = 0;
   static time_t time_to_check_descriptor = 0;
@@ -769,7 +812,8 @@
 static struct event *timeout_event = NULL;
 
 /** Libevent callback: invoked once every second. */
-static void second_elapsed_callback(int fd, short event, void *args)
+static void
+second_elapsed_callback(int fd, short event, void *args)
 {
   static struct timeval one_second;
   static long current_second = 0;
@@ -843,7 +887,9 @@
 
 /** Called when we get a SIGHUP: reload configuration files and keys,
  * retry all connections, re-upload all descriptors, and so on. */
-static int do_hup(void) {
+static int
+do_hup(void)
+{
   char keydir[512];
   or_options_t *options = get_options();
 
@@ -894,7 +940,9 @@
 }
 
 /** Tor main loop. */
-static int do_main_loop(void) {
+static int
+do_main_loop(void)
+{
   int loop_result;
 
   /* load the private keys, if we're supposed to have them, and set up the
@@ -1005,7 +1053,10 @@
   return 0;
 }
 
-static void signal_callback(int fd, short events, void *arg)
+/** Libevent callback: invoked when we get a signal.
+ */
+static void
+signal_callback(int fd, short events, void *arg)
 {
   uintptr_t sig = (uintptr_t)arg;
   switch (sig)
@@ -1051,8 +1102,12 @@
   }
 }
 
+/**
+ * Write current memory uusage information to the log.
+ */
 static void
-dumpmemusage(int severity) {
+dumpmemusage(int severity)
+{
   extern uint64_t buf_total_used;
   extern uint64_t buf_total_alloc;
   extern uint64_t rephist_total_alloc;
@@ -1067,7 +1122,8 @@
 /** Write all statistics to the log, with log level 'severity'.  Called
  * in response to a SIGUSR1. */
 static void
-dumpstats(int severity) {
+dumpstats(int severity)
+{
   int i;
   connection_t *conn;
   time_t now = time(NULL);
@@ -1144,7 +1200,8 @@
 
 /** Called by exit() as we shut down the process.
  */
-static void exit_function(void)
+static void
+exit_function(void)
 {
   /* NOTE: If we ever daemonize, this gets called immediately.  That's
    * okay for now, because we only use this on Windows.  */
@@ -1154,7 +1211,8 @@
 }
 
 /** Set up the signal handlers for either parent or child. */
-void handle_signals(int is_parent)
+void
+handle_signals(int is_parent)
 {
 #ifndef MS_WINDOWS /* do signal stuff only on unix */
   int i;
@@ -1199,7 +1257,9 @@
 
 /** Main entry point for the Tor command-line client.
  */
-static int tor_init(int argc, char *argv[]) {
+static int
+tor_init(int argc, char *argv[])
+{
   time_of_process_start = time(NULL);
   closeable_connection_lst = smartlist_create();
   /* Initialize the history structures. */
@@ -1250,7 +1310,8 @@
  *
  * Also valgrind should then report 0 reachable in its
  * leak report */
-void tor_free_all(int postfork)
+void
+tor_free_all(int postfork)
 {
   routerlist_free_current();
   free_trusted_dir_servers();
@@ -1281,7 +1342,8 @@
 }
 
 /** Do whatever cleanup is necessary before shutting Tor down. */
-void tor_cleanup(void) {
+void
+tor_cleanup(void) {
   or_options_t *options = get_options();
   /* Remove our pid file. We don't care if there was an error when we
    * unlink, nothing we could do about it anyways. */
@@ -1298,7 +1360,8 @@
 }
 
 /** Read/create keys as needed, and echo our fingerprint to stdout. */
-static void do_list_fingerprint(void)
+static void
+do_list_fingerprint(void)
 {
   char buf[FINGERPRINT_LEN+1];
   crypto_pk_env_t *k;
@@ -1325,7 +1388,8 @@
 
 /** Entry point for password hashing: take the desired password from
  * the command line, and print its salted hash to stdout. **/
-static void do_hash_password(void)
+static void
+do_hash_password(void)
 {
 
   char output[256];
@@ -1357,7 +1421,9 @@
   return 0;
 }
 
-void nt_service_control(DWORD request)
+/** DOCDOC */
+void
+nt_service_control(DWORD request)
 {
   switch (request) {
     case SERVICE_CONTROL_STOP:
@@ -1369,7 +1435,9 @@
   SetServiceStatus(hStatus, &service_status);
 }
 
-void nt_service_body(int argc, char **argv)
+/** DOCDOC */
+void
+nt_service_body(int argc, char **argv)
 {
   int err;
   service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
@@ -1402,7 +1470,9 @@
   return;
 }
 
-void nt_service_main(void)
+/** DOCDOC */
+void
+nt_service_main(void)
 {
   SERVICE_TABLE_ENTRY table[2];
   DWORD result = 0;
@@ -1438,7 +1508,9 @@
   }
 }
 
-int nt_service_install()
+/** DOCDOC */
+int
+nt_service_install(void)
 {
   /* XXXX Problems with NT services:
    * 1. The configuration file needs to be in the same directory as the .exe
@@ -1541,7 +1613,9 @@
   return 0;
 }
 
-int nt_service_remove()
+/** DOCDOC */
+int
+nt_service_remove(void)
 {
   SC_HANDLE hSCManager = NULL;
   SC_HANDLE hService = NULL;
@@ -1587,7 +1661,10 @@
 }
 #endif
 
-int tor_main(int argc, char *argv[]) {
+/** DOCDOC */
+int
+tor_main(int argc, char *argv[])
+{
 #ifdef MS_WINDOWS_SERVICE
   backup_argv = argv;
   backup_argc = argc;

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/onion.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -d -r1.180 -r1.181
--- onion.c	9 Jun 2005 19:03:31 -0000	1.180
+++ onion.c	11 Jun 2005 18:52:11 -0000	1.181
@@ -31,7 +31,9 @@
 /** Add <b>circ</b> to the end of ol_list and return 0, except
  * if ol_list is too long, in which case do nothing and return -1.
  */
-int onion_pending_add(circuit_t *circ) {
+int
+onion_pending_add(circuit_t *circ)
+{
   struct onion_queue_t *tmp;
   time_t now = time(NULL);
 
@@ -73,7 +75,9 @@
 /** Remove the first item from ol_list and return it, or return
  * NULL if the list is empty.
  */
-circuit_t *onion_next_task(void) {
+circuit_t *
+onion_next_task(void)
+{
   circuit_t *circ;
 
   if (!ol_list)
@@ -90,7 +94,9 @@
 /** Go through ol_list, find the onion_queue_t element which points to
  * circ, remove and free that element. Leave circ itself alone.
  */
-void onion_pending_remove(circuit_t *circ) {
+void
+onion_pending_remove(circuit_t *circ)
+{
   struct onion_queue_t *tmpo, *victim;
 
   if (!ol_list)
@@ -329,6 +335,7 @@
   return 0;
 }
 
+/** DOCDOC */
 int
 fast_server_handshake(const char *key_in, /* DIGEST_LEN bytes */
                       char *handshake_reply_out, /* DIGEST_LEN*2 bytes */
@@ -359,6 +366,7 @@
   return 0;
 }
 
+/** DOCDOC */
 int
 fast_client_handshake(const char *handshake_state, /* DIGEST_LEN bytes */
                       const char *handshake_reply_out, /* DIGEST_LEN*2 bytes */

Index: relay.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/relay.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- relay.c	9 Jun 2005 19:03:31 -0000	1.71
+++ relay.c	11 Jun 2005 18:52:11 -0000	1.72
@@ -44,7 +44,9 @@
 /** Update digest from the payload of cell. Assign integrity part to
  * cell.
  */
-static void relay_set_digest(crypto_digest_env_t *digest, cell_t *cell) {
+static void
+relay_set_digest(crypto_digest_env_t *digest, cell_t *cell)
+{
   char integrity[4];
   relay_header_t rh;
 
@@ -63,7 +65,9 @@
  * to 0). If the integrity part is valid, return 1, else restore digest
  * and cell to their original state and return 0.
  */
-static int relay_digest_matches(crypto_digest_env_t *digest, cell_t *cell) {
+static int
+relay_digest_matches(crypto_digest_env_t *digest, cell_t *cell)
+{
   char received_integrity[4], calculated_integrity[4];
   relay_header_t rh;
   crypto_digest_env_t *backup_digest=NULL;
@@ -104,8 +108,10 @@
  *
  * Return -1 if the crypto fails, else return 0.
  */
-static int relay_crypt_one_payload(crypto_cipher_env_t *cipher, char *in,
-                                   int encrypt_mode) {
+static int
+relay_crypt_one_payload(crypto_cipher_env_t *cipher, char *in,
+                        int encrypt_mode)
+{
   char out[CELL_PAYLOAD_SIZE]; /* 'in' must be this size too */
 
   if (( encrypt_mode && crypto_cipher_encrypt(cipher, out, in, CELL_PAYLOAD_SIZE)) ||
@@ -126,8 +132,9 @@
  *  - Else connection_or_write_cell_to_buf to the conn on the other
  *    side of the circuit.
  */
-int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
-                               int cell_direction) {
+int
+circuit_receive_relay_cell(cell_t *cell, circuit_t *circ, int cell_direction)
+{
   connection_t *conn=NULL;
   crypt_path_t *layer_hint=NULL;
   char recognized=0;
@@ -214,8 +221,10 @@
  * else return 0.
  */
 /* wrap this into receive_relay_cell one day */
-static int relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
-                       crypt_path_t **layer_hint, char *recognized) {
+static int
+relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
+            crypt_path_t **layer_hint, char *recognized)
+{
   crypt_path_t *thishop;
   relay_header_t rh;
 
@@ -370,7 +379,9 @@
  * network-order in the buffer <b>dest</b>. See tor-spec.txt for details
  * about the wire format.
  */
-void relay_header_pack(char *dest, const relay_header_t *src) {
+void
+relay_header_pack(char *dest, const relay_header_t *src)
+{
   *(uint8_t*)(dest) = src->command;
 
   set_uint16(dest+1, htons(src->recognized));
@@ -382,7 +393,9 @@
 /** Unpack the network-order buffer <b>src</b> into a host-order
  * relay_header_t structure <b>dest</b>.
  */
-void relay_header_unpack(relay_header_t *dest, const char *src) {
+void
+relay_header_unpack(relay_header_t *dest, const char *src)
+{
   dest->command = *(uint8_t*)(src);
 
   dest->recognized = ntohs(get_uint16(src+1));
@@ -400,9 +413,11 @@
  * If you can't send the cell, mark the circuit for close and
  * return -1. Else return 0.
  */
-int connection_edge_send_command(connection_t *fromconn, circuit_t *circ,
-                                 int relay_command, const char *payload,
-                                 size_t payload_len, crypt_path_t *cpath_layer) {
+int
+connection_edge_send_command(connection_t *fromconn, circuit_t *circ,
+                             int relay_command, const char *payload,
+                             size_t payload_len, crypt_path_t *cpath_layer)
+{
   cell_t cell;
   relay_header_t rh;
   int cell_direction;
@@ -462,7 +477,8 @@
  * <b>reason</b> is -1 if no reason was provided.
  */
 static const char *
-connection_edge_end_reason_str(int reason) {
+connection_edge_end_reason_str(int reason)
+{
   switch (reason) {
     case -1:
       log_fn(LOG_WARN,"End cell arrived with length 0. Should be at least 1.");
@@ -542,6 +558,9 @@
 #define S_CASE(s) case s
 #endif
 
+/** Given an errno from a failed exit connection, return a reason code
+ * appropriate for use in a RELAY END cell.
+ */
 int
 errno_to_end_reason(int e)
 {
@@ -585,17 +604,22 @@
 /** Return 1 if reason is something that you should retry if you
  * get the end cell before you've connected; else return 0. */
 static int
-edge_reason_is_retriable(int reason) {
+edge_reason_is_retriable(int reason)
+{
   return reason == END_STREAM_REASON_HIBERNATING ||
          reason == END_STREAM_REASON_RESOURCELIMIT ||
          reason == END_STREAM_REASON_EXITPOLICY ||
          reason == END_STREAM_REASON_RESOLVEFAILED;
 }
 
+/** Called when we receive an END cell on a stream that isn't open yet.
+ * Arguments are as for connection_edge_process_relay_cell().
+ */
 static int
 connection_edge_process_end_not_open(
     relay_header_t *rh, cell_t *cell, circuit_t *circ,
-    connection_t *conn, crypt_path_t *layer_hint) {
+    connection_t *conn, crypt_path_t *layer_hint)
+{
   struct in_addr in;
   routerinfo_t *exitrouter;
   int reason = *(cell->payload+RELAY_HEADER_SIZE);
@@ -693,8 +717,8 @@
 static int
 connection_edge_process_relay_cell_not_open(
     relay_header_t *rh, cell_t *cell, circuit_t *circ,
-    connection_t *conn, crypt_path_t *layer_hint) {
-
+    connection_t *conn, crypt_path_t *layer_hint)
+{
   if (rh->command == RELAY_COMMAND_END)
     return connection_edge_process_end_not_open(rh, cell, circ, conn, layer_hint);
 
@@ -995,7 +1019,9 @@
  * Return -1 (and send a RELAY_END cell if necessary) if conn should
  * be marked for close, else return 0.
  */
-int connection_edge_package_raw_inbuf(connection_t *conn, int package_partial) {
+int
+connection_edge_package_raw_inbuf(connection_t *conn, int package_partial)
+{
   size_t amount_to_process, length;
   char payload[CELL_PAYLOAD_SIZE];
   circuit_t *circ;
@@ -1077,7 +1103,9 @@
  * If conn->outbuf is not too full, and our deliver window is
  * low, send back a suitable number of stream-level sendme cells.
  */
-void connection_edge_consider_sending_sendme(connection_t *conn) {
+void
+connection_edge_consider_sending_sendme(connection_t *conn)
+{
   circuit_t *circ;
 
   if (connection_outbuf_too_full(conn))
@@ -1125,8 +1153,8 @@
 static int
 circuit_resume_edge_reading_helper(connection_t *conn,
                                    circuit_t *circ,
-                                   crypt_path_t *layer_hint) {
-
+                                   crypt_path_t *layer_hint)
+{
   for ( ; conn; conn=conn->next_stream) {
     if (conn->marked_for_close)
       continue;

Index: rendclient.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/rendclient.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- rendclient.c	9 Jun 2005 19:03:31 -0000	1.88
+++ rendclient.c	11 Jun 2005 18:52:11 -0000	1.89
@@ -53,7 +53,8 @@
  * down introcirc if possible.
  */
 int
-rend_client_send_introduction(circuit_t *introcirc, circuit_t *rendcirc) {
+rend_client_send_introduction(circuit_t *introcirc, circuit_t *rendcirc)
+{
   size_t payload_len;
   int r;
   char payload[RELAY_PAYLOAD_SIZE];
@@ -383,7 +384,9 @@
  * with at least one intro point, move them to the next state;
  * else fail them.
  */
-void rend_client_desc_here(char *query) {
+void
+rend_client_desc_here(char *query)
+{
   connection_t *conn;
   rend_cache_entry_t *entry;
   time_t now = time(NULL);
@@ -419,7 +422,9 @@
 /** strdup a nickname for a random introduction
  * point of query. return NULL if error.
  */
-char *rend_client_get_random_intro(char *query) {
+char *
+rend_client_get_random_intro(char *query)
+{
   int i;
   smartlist_t *sl;
   char *choice;

Index: rendcommon.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/rendcommon.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- rendcommon.c	9 Jun 2005 19:03:31 -0000	1.49
+++ rendcommon.c	11 Jun 2005 18:52:11 -0000	1.50
@@ -85,8 +85,8 @@
  * success, return a newly alloced service_descriptor_t.  On failure,
  * return NULL.
  */
-rend_service_descriptor_t *rend_parse_service_descriptor(
-                           const char *str, size_t len)
+rend_service_descriptor_t *
+rend_parse_service_descriptor(const char *str, size_t len)
 {
   rend_service_descriptor_t *result = NULL;
   int i;
@@ -144,7 +144,8 @@
  * base32 encoded.  NUL-terminates out.  (We use this string to
  * identify services in directory requests and .onion URLs.)
  */
-int rend_get_service_id(crypto_pk_env_t *pk, char *out)
+int
+rend_get_service_id(crypto_pk_env_t *pk, char *out)
 {
   char buf[DIGEST_LEN];
   tor_assert(pk);
@@ -165,11 +166,13 @@
 
 /** Initializes the service descriptor cache.
  */
-void rend_cache_init(void)
+void
+rend_cache_init(void)
 {
   rend_cache = strmap_new();
 }
 
+/** Helper: free storage held by a single service descriptor cache entry. */
 static void
 _rend_cache_entry_free(void *p)
 {
@@ -179,6 +182,7 @@
   tor_free(e);
 }
 
+/** Free all storage held by the service descriptor cache. */
 void
 rend_cache_free_all(void)
 {
@@ -188,7 +192,8 @@
 
 /** Removes all old entries from the service descriptor cache.
  */
-void rend_cache_clean(void)
+void
+rend_cache_clean(void)
 {
   strmap_iter_t *iter;
   const char *key;
@@ -210,7 +215,9 @@
 
 /** Return true iff <b>query</b> is a syntactically valid service ID (as
  * generated by rend_get_service_id).  */
-int rend_valid_service_id(const char *query) {
+int
+rend_valid_service_id(const char *query)
+{
   if (strlen(query) != REND_SERVICE_ID_LEN)
     return 0;
 
@@ -223,7 +230,8 @@
 /** If we have a cached rend_cache_entry_t for the service ID <b>query</b>, set
  * *<b>e</b> to that entry and return 1.  Else return 0.
  */
-int rend_cache_lookup_entry(const char *query, rend_cache_entry_t **e)
+int
+rend_cache_lookup_entry(const char *query, rend_cache_entry_t **e)
 {
   tor_assert(rend_cache);
   if (!rend_valid_service_id(query))
@@ -242,7 +250,8 @@
  * Note: calls to rend_cache_clean or rend_cache_store may invalidate
  * *desc.
  */
-int rend_cache_lookup_desc(const char *query, const char **desc, size_t *desc_len)
+int
+rend_cache_lookup_desc(const char *query, const char **desc, size_t *desc_len)
 {
   rend_cache_entry_t *e;
   int r;
@@ -260,7 +269,8 @@
  * it's the same or older than one we've already got; return 1 if
  * it's novel.
  */
-int rend_cache_store(const char *desc, size_t desc_len)
+int
+rend_cache_store(const char *desc, size_t desc_len)
 {
   rend_cache_entry_t *e;
   rend_service_descriptor_t *parsed;
@@ -322,8 +332,9 @@
 
 /** Called when we get a rendezvous-related relay cell on circuit
  * <b>circ</b>.  Dispatch on rendezvous relay command. */
-void rend_process_relay_cell(circuit_t *circ, int command, size_t length,
-                             const char *payload)
+void
+rend_process_relay_cell(circuit_t *circ, int command, size_t length,
+                        const char *payload)
 {
   int r;
   switch (command) {

Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/rendservice.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- rendservice.c	9 Jun 2005 19:03:31 -0000	1.125
+++ rendservice.c	11 Jun 2005 18:52:11 -0000	1.126
@@ -63,7 +63,8 @@
 
 /** Release the storage held by <b>service</b>.
  */
-static void rend_service_free(rend_service_t *service)
+static void
+rend_service_free(rend_service_t *service)
 {
   if (!service) return;
   tor_free(service->directory);
@@ -82,7 +83,8 @@
 
 /** Release all the storage held in rend_service_list.
  */
-void rend_service_free_all(void)
+void
+rend_service_free_all(void)
 {
   if (!rend_service_list) {
     return;
@@ -95,7 +97,8 @@
 
 /** Validate <b>service</b> and add it to rend_service_list if possible.
  */
-static void add_service(rend_service_t *service)
+static void
+add_service(rend_service_t *service)
 {
   int i;
   rend_service_port_config_t *p;
@@ -131,7 +134,8 @@
  *
  * IP defaults to 127.0.0.1; RealPort defaults to VirtualPort.
  */
-static rend_service_port_config_t *parse_port_config(const char *string)
+static rend_service_port_config_t *
+parse_port_config(const char *string)
 {
   int virtport;
   int realport;
@@ -186,8 +190,8 @@
  * failure.  (If <b>validate_only</b> is set, parse, warn and return as
  * normal, but don't actually change the configured services.)
  */
-
-int rend_config_services(or_options_t *options, int validate_only)
+int
+rend_config_services(or_options_t *options, int validate_only)
 {
   struct config_line_t *line;
   rend_service_t *service = NULL;
@@ -253,7 +257,8 @@
 /** Replace the old value of <b>service</b>-\>desc with one that reflects
  * the other fields in service.
  */
-static void rend_service_update_descriptor(rend_service_t *service)
+static void
+rend_service_update_descriptor(rend_service_t *service)
 {
   rend_service_descriptor_t *d;
   circuit_t *circ;
@@ -288,7 +293,8 @@
 /** Load and/or generate private keys for all hidden services.  Return 0 on
  * success, -1 on failure.
  */
-int rend_service_load_keys(void)
+int
+rend_service_load_keys(void)
 {
   int i;
   rend_service_t *s;
@@ -828,7 +834,9 @@
  *  - Pick new intro points as necessary.
  *  - Launch circuits to any new intro points.
  */
-void rend_services_introduce(void) {
+void
+rend_services_introduce(void)
+{
   int i,j,r;
   routerinfo_t *router;
   rend_service_t *service;
@@ -937,7 +945,8 @@
  * from now, and pick it independently for each service.
  */
 void
-rend_consider_services_upload(time_t now) {
+rend_consider_services_upload(time_t now)
+{
   int i;
   rend_service_t *service;
   int rendpostperiod = get_options()->RendPostPeriod;

Index: rephist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/rephist.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- rephist.c	9 Jun 2005 19:03:31 -0000	1.58
+++ rephist.c	11 Jun 2005 18:52:11 -0000	1.59
@@ -5,7 +5,9 @@
 
 /**
  * \file rephist.c
- * \brief Basic history functionality for reputation module.
+ * \brief Basic history and "reputation" functionality to remember
+ *    which servers have worked in the past, how much bandwidth we've
+ *    been using, which ports we tend to want, and so on.
  **/
 
 #include "or.h"
@@ -57,7 +59,8 @@
 
 /** Return the or_history_t for the named OR, creating it if necessary.
  */
-static or_history_t *get_or_history(const char* id)
+static or_history_t *
+get_or_history(const char* id)
 {
   or_history_t *hist;
   char hexid[HEX_DIGEST_LEN+1];
@@ -81,8 +84,8 @@
  * the second, creating it if necessary. (ORs are identified by
  * identity digest)
  */
-static link_history_t *get_link_history(const char *from_id,
-                                        const char *to_id)
+static link_history_t *
+get_link_history(const char *from_id, const char *to_id)
 {
   or_history_t *orhist;
   link_history_t *lhist;
@@ -103,6 +106,7 @@
   return lhist;
 }
 
+/** Helper: free storage held by a single link history entry */
 static void
 _free_link_history(void *val)
 {
@@ -110,6 +114,7 @@
   tor_free(val);
 }
 
+/** Helper: free storage held by a single OR history entry */
 static void
 free_or_history(void *_hist)
 {
@@ -122,7 +127,8 @@
 /** Update an or_history_t object <b>hist</b> so that its uptime/downtime
  * count is up-to-date as of <b>when</b>.
  */
-static void update_or_history(or_history_t *hist, time_t when)
+static void
+update_or_history(or_history_t *hist, time_t when)
 {
   tor_assert(hist);
   if (hist->up_since) {
@@ -137,7 +143,8 @@
 
 /** Initialize the static data structures for tracking history.
  */
-void rep_hist_init(void)
+void
+rep_hist_init(void)
 {
   history_map = strmap_new();
   bw_arrays_init();
@@ -147,7 +154,8 @@
 /** Remember that an attempt to connect to the OR with identity digest
  * <b>id</b> failed at <b>when</b>.
  */
-void rep_hist_note_connect_failed(const char* id, time_t when)
+void
+rep_hist_note_connect_failed(const char* id, time_t when)
 {
   or_history_t *hist;
   hist = get_or_history(id);
@@ -166,7 +174,8 @@
 /** Remember that an attempt to connect to the OR with identity digest
  * <b>id</b> succeeded at <b>when</b>.
  */
-void rep_hist_note_connect_succeeded(const char* id, time_t when)
+void
+rep_hist_note_connect_succeeded(const char* id, time_t when)
 {
   or_history_t *hist;
   hist = get_or_history(id);
@@ -185,7 +194,8 @@
 /** Remember that we intentionally closed our connection to the OR
  * with identity digest <b>id</b> at <b>when</b>.
  */
-void rep_hist_note_disconnect(const char* id, time_t when)
+void
+rep_hist_note_disconnect(const char* id, time_t when)
 {
   or_history_t *hist;
   hist = get_or_history(id);
@@ -202,7 +212,8 @@
 /** Remember that our connection to the OR with identity digest
  * <b>id</b> had an error and stopped working at <b>when</b>.
  */
-void rep_hist_note_connection_died(const char* id, time_t when)
+void
+rep_hist_note_connection_died(const char* id, time_t when)
 {
   or_history_t *hist;
   if (!id) {
@@ -229,8 +240,8 @@
  * digest <b>from_id</b> to the OR with identity digest
  *  <b>to_name</b>.
  */
-void rep_hist_note_extend_succeeded(const char *from_id,
-                                    const char *to_id)
+void
+rep_hist_note_extend_succeeded(const char *from_id, const char *to_id)
 {
   link_history_t *hist;
   /* log_fn(LOG_WARN, "EXTEND SUCCEEDED: %s->%s",from_name,to_name); */
@@ -245,7 +256,8 @@
  * <b>from_id</b> to the OR with identity digest <b>to_name</b>, but
  * failed.
  */
-void rep_hist_note_extend_failed(const char *from_id, const char *to_id)
+void
+rep_hist_note_extend_failed(const char *from_id, const char *to_id)
 {
   link_history_t *hist;
   /* log_fn(LOG_WARN, "EXTEND FAILED: %s->%s",from_name,to_name); */
@@ -259,7 +271,8 @@
 /** Log all the reliability data we have remembered, with the chosen
  * severity.
  */
-void rep_hist_dump_stats(time_t now, int severity)
+void
+rep_hist_dump_stats(time_t now, int severity)
 {
   strmap_iter_t *lhist_it;
   strmap_iter_t *orhist_it;
@@ -331,7 +344,8 @@
 
 /** Remove history info for routers/links that haven't changed since
  * <b>before</b> */
-void rep_history_clean(time_t before)
+void
+rep_history_clean(time_t before)
 {
   or_history_t *or_history;
   link_history_t *link_history;
@@ -365,7 +379,8 @@
 }
 
 #if 0
-void write_rep_history(const char *filename)
+void
+write_rep_history(const char *filename)
 {
   FILE *f = NULL;
   char *tmpfile;
@@ -439,7 +454,9 @@
 
 /** Shift the current period of b forward by one.
  */
-static void commit_max(bw_array_t *b) {
+static void
+commit_max(bw_array_t *b)
+{
   /* Store total from current period. */
   b->totals[b->next_max_idx] = b->total_in_period;
   /* Store maximum from current period. */
@@ -458,7 +475,9 @@
 
 /** Shift the current observation time of 'b' forward by one second.
  */
-static INLINE void advance_obs(bw_array_t *b) {
+static INLINE void
+advance_obs(bw_array_t *b)
+{
   int nextidx;
   int total;
 
@@ -482,7 +501,9 @@
 
 /** Add 'n' bytes to the number of bytes in b for second 'when'.
  */
-static INLINE void add_obs(bw_array_t *b, time_t when, int n) {
+static INLINE void
+add_obs(bw_array_t *b, time_t when, int n)
+{
   /* Don't record data in the past. */
   if (when<b->cur_obs_time)
     return;
@@ -498,7 +519,8 @@
 
 /** Allocate, initialize, and return a new bw_array.
  */
-static bw_array_t *bw_array_new(void) {
+static bw_array_t *bw_array_new(void)
+{
   bw_array_t *b;
   time_t start;
   b = tor_malloc_zero(sizeof(bw_array_t));
@@ -514,7 +536,8 @@
 
 /** Set up read_array and write_array
  */
-static void bw_arrays_init(void)
+static void
+bw_arrays_init(void)
 {
   read_array = bw_array_new();
   write_array = bw_array_new();
@@ -527,7 +550,9 @@
  * <b>when</b> can go back to time, but it's safe to ignore calls
  * earlier than the latest <b>when</b> you've heard of.
  */
-void rep_hist_note_bytes_written(int num_bytes, time_t when) {
+void
+rep_hist_note_bytes_written(int num_bytes, time_t when)
+{
 /* Maybe a circular array for recent seconds, and step to a new point
  * every time a new second shows up. Or simpler is to just to have
  * a normal array and push down each item every second; it's short.
@@ -542,7 +567,9 @@
 /** We wrote <b>num_bytes</b> more bytes in second <b>when</b>.
  * (like rep_hist_note_bytes_written() above)
  */
-void rep_hist_note_bytes_read(int num_bytes, time_t when) {
+void
+rep_hist_note_bytes_read(int num_bytes, time_t when)
+{
 /* if we're smart, we can make this func and the one above share code */
   add_obs(read_array, when, num_bytes);
 }
@@ -551,7 +578,8 @@
  * most bandwidth used in any NUM_SECS_ROLLING_MEASURE period for the last
  * NUM_SECS_BW_SUM_IS_VALID seconds.)
  */
-static int find_largest_max(bw_array_t *b)
+static int
+find_largest_max(bw_array_t *b)
 {
   int i,max;
   max=0;
@@ -569,7 +597,9 @@
  *
  * Return the smaller of these sums, divided by NUM_SECS_ROLLING_MEASURE.
  */
-int rep_hist_bandwidth_assess(void) {
+int
+rep_hist_bandwidth_assess(void)
+{
   int w,r;
   r = find_largest_max(read_array);
   w = find_largest_max(write_array);
@@ -633,7 +663,10 @@
 /** The corresponding most recently used time for each port. */
 static smartlist_t *predicted_ports_times=NULL;
 
-static void add_predicted_port(uint16_t port, time_t now) {
+/** DOCDOC */
+static void
+add_predicted_port(uint16_t port, time_t now)
+{
   /* XXXX we could just use uintptr_t here, I think. */
   uint16_t *tmp_port = tor_malloc(sizeof(uint16_t));
   time_t *tmp_time = tor_malloc(sizeof(time_t));
@@ -644,13 +677,19 @@
   smartlist_add(predicted_ports_times, tmp_time);
 }
 
-static void predicted_ports_init(void) {
+/** DOCDOC */
+static void
+predicted_ports_init(void)
+{
   predicted_ports_list = smartlist_create();
   predicted_ports_times = smartlist_create();
   add_predicted_port(80, time(NULL)); /* add one to kickstart us */
 }
 
-static void predicted_ports_free(void) {
+/** DOCDOC */
+static void
+predicted_ports_free(void)
+{
   rephist_total_alloc -= smartlist_len(predicted_ports_list)*sizeof(uint16_t);
   SMARTLIST_FOREACH(predicted_ports_list, char *, cp, tor_free(cp));
   smartlist_free(predicted_ports_list);
@@ -663,7 +702,9 @@
  * This is used for predicting what sorts of streams we'll make in the
  * future and making circuits to anticipate that.
  */
-void rep_hist_note_used_port(uint16_t port, time_t now) {
+void
+rep_hist_note_used_port(uint16_t port, time_t now)
+{
   int i;
   uint16_t *tmp_port;
   time_t *tmp_time;
@@ -693,7 +734,9 @@
  *
  * The caller promises not to mess with it.
  */
-smartlist_t *rep_hist_get_predicted_ports(time_t now) {
+smartlist_t *
+rep_hist_get_predicted_ports(time_t now)
+{
   int i;
   uint16_t *tmp_port;
   time_t *tmp_time;
@@ -726,7 +769,9 @@
 static time_t predicted_hidserv_capacity_time = 0;
 
 /** Remember that we used an internal circ at time <b>now</b>. */
-void rep_hist_note_used_hidserv(time_t now, int need_uptime, int need_capacity) {
+void
+rep_hist_note_used_hidserv(time_t now, int need_uptime, int need_capacity)
+{
   predicted_hidserv_time = now;
   if (need_uptime)
     predicted_hidserv_uptime_time = now;
@@ -735,7 +780,9 @@
 }
 
 /** Return 1 if we've used an internal circ recently; else return 0. */
-int rep_hist_get_predicted_hidserv(time_t now, int *need_uptime, int *need_capacity) {
+int
+rep_hist_get_predicted_hidserv(time_t now, int *need_uptime, int *need_capacity)
+{
   if (!predicted_hidserv_time) /* initialize it */
     predicted_hidserv_time = now;
   if (predicted_hidserv_time + PREDICTED_CIRCS_RELEVANCE_TIME < now)
@@ -751,7 +798,10 @@
 void rep_hist_note_used_resolve(time_t now) { }
 int rep_hist_get_predicted_resolve(time_t now) { return 0; }
 
-void rep_hist_free_all(void)
+/** Free all storage held by the OR/link history caches, by the
+ * bandwidth history arrays, or by the port history. */
+void
+rep_hist_free_all(void)
 {
   strmap_free(history_map, free_or_history);
   tor_free(read_array);

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -d -r1.180 -r1.181
--- router.c	9 Jun 2005 21:23:54 -0000	1.180
+++ router.c	11 Jun 2005 18:52:11 -0000	1.181
@@ -34,7 +34,9 @@
 /** Replace the current onion key with <b>k</b>.  Does not affect lastonionkey;
  * to update onionkey correctly, call rotate_onion_key().
  */
-void set_onion_key(crypto_pk_env_t *k) {
+void
+set_onion_key(crypto_pk_env_t *k)
+{
   tor_mutex_acquire(key_lock);
   onionkey = k;
   onionkey_set_at = time(NULL);
@@ -44,7 +46,9 @@
 
 /** Return the current onion key.  Requires that the onion key has been
  * loaded or generated. */
-crypto_pk_env_t *get_onion_key(void) {
+crypto_pk_env_t *
+get_onion_key(void)
+{
   tor_assert(onionkey);
   return onionkey;
 }
@@ -53,14 +57,17 @@
  * key rotation.  If no rotation has been performed since this process
  * started, return NULL.
  */
-crypto_pk_env_t *get_previous_onion_key(void) {
+crypto_pk_env_t *
+get_previous_onion_key(void)
+{
   return lastonionkey;
 }
 
 /** Store a copy of the current onion key into *<b>key</b>, and a copy
  * of the most recent onion key into *<b>last</b>.
  */
-void dup_onion_keys(crypto_pk_env_t **key, crypto_pk_env_t **last)
+void
+dup_onion_keys(crypto_pk_env_t **key, crypto_pk_env_t **last)
 {
   tor_assert(key);
   tor_assert(last);
@@ -77,26 +84,34 @@
  * when the process launched, or the time of the most recent key rotation since
  * the process launched.
  */
-time_t get_onion_key_set_at(void) {
+time_t
+get_onion_key_set_at(void)
+{
   return onionkey_set_at;
 }
 
 /** Set the current identity key to k.
  */
-void set_identity_key(crypto_pk_env_t *k) {
+void
+set_identity_key(crypto_pk_env_t *k)
+{
   identitykey = k;
 }
 
 /** Returns the current identity key; requires that the identity key has been
  * set.
  */
-crypto_pk_env_t *get_identity_key(void) {
+crypto_pk_env_t *
+get_identity_key(void)
+{
   tor_assert(identitykey);
   return identitykey;
 }
 
 /** Return true iff the identity key has been set. */
-int identity_key_is_set(void) {
+int
+identity_key_is_set(void)
+{
   return identitykey != NULL;
 }
 
@@ -107,7 +122,8 @@
  *     pending work.  (This will cause fresh cpuworkers to be generated.)
  *   - generate and upload a fresh routerinfo.
  */
-void rotate_onion_key(void)
+void
+rotate_onion_key(void)
 {
   char fname[512];
   char fname_prev[512];
@@ -153,7 +169,6 @@
 init_key_from_file_name_changed(const char *fname_old,
                                 const char *fname_new)
 {
-
   if (file_status(fname_new) == FN_FILE || file_status(fname_old) != FN_FILE)
     /* The new filename is there, or both are, or neither is. */
     return init_key_from_file(fname_new);
@@ -171,7 +186,8 @@
  * create a new RSA key and save it in <b>fname</b>.  Return the read/created
  * key, or NULL on error.
  */
-crypto_pk_env_t *init_key_from_file(const char *fname)
+crypto_pk_env_t *
+init_key_from_file(const char *fname)
 {
   crypto_pk_env_t *prkey = NULL;
   FILE *file = NULL;
@@ -223,7 +239,9 @@
 /** Initialize all OR private keys, and the TLS context, as necessary.
  * On OPs, this only initializes the tls context.
  */
-int init_keys(void) {
+int
+init_keys(void)
+{
   /* XXX009 Two problems with how this is called:
    * 1. It should be idempotent for servers, so we can call init_keys
    *    as much as we need to.
@@ -382,15 +400,23 @@
 static int can_reach_dir_port = 0;
 
 /** Return 1 if or port is known reachable; else return 0. */
-int check_whether_orport_reachable(void) {
+int
+check_whether_orport_reachable(void)
+{
   return clique_mode(get_options()) || can_reach_or_port;
 }
+
 /** Return 1 if we don't have a dirport configured, or if it's reachable. */
-int check_whether_dirport_reachable(void) {
+int
+check_whether_dirport_reachable(void)
+{
   return !get_options()->DirPort || can_reach_dir_port;
 }
 
-void consider_testing_reachability(void) {
+/**DOCDOC*/
+void
+consider_testing_reachability(void)
+{
   routerinfo_t *me = router_get_my_routerinfo();
   if (!me) {
     log_fn(LOG_WARN,"Bug: router_get_my_routerinfo() did not find my routerinfo?");
@@ -411,7 +437,9 @@
 }
 
 /** Annotate that we found our ORPort reachable. */
-void router_orport_found_reachable(void) {
+void
+router_orport_found_reachable(void)
+{
   if (!can_reach_or_port) {
     if (!clique_mode(get_options()))
       log(LOG_NOTICE,"Your ORPort is reachable from the outside. Excellent.%s",
@@ -422,7 +450,9 @@
 }
 
 /** Annotate that we found our DirPort reachable. */
-void router_dirport_found_reachable(void) {
+void
+router_dirport_found_reachable(void)
+{
   if (!can_reach_dir_port) {
     log(LOG_NOTICE,"Your DirPort is reachable from the outside. Excellent.");
     can_reach_dir_port = 1;
@@ -430,7 +460,9 @@
 }
 
 /** Our router has just moved to a new IP. Reset stats. */
-void server_has_changed_ip(void) {
+void
+server_has_changed_ip(void)
+{
   stats_n_seconds_working = 0;
   can_reach_or_port = 0;
   can_reach_dir_port = 0;
@@ -440,18 +472,24 @@
 /** Return true iff we believe ourselves to be an authoritative
  * directory server.
  */
-int authdir_mode(or_options_t *options) {
+int
+authdir_mode(or_options_t *options)
+{
   return options->AuthoritativeDir != 0;
 }
 /** Return true iff we try to stay connected to all ORs at once.
  */
-int clique_mode(or_options_t *options) {
+int
+clique_mode(or_options_t *options)
+{
   return authdir_mode(options);
 }
 
 /** Return true iff we are trying to be a server.
  */
-int server_mode(or_options_t *options) {
+int
+server_mode(or_options_t *options)
+{
   if (options->ClientOnly) return 0;
   return (options->ORPort != 0 || options->ORBindAddress);
 }
@@ -461,16 +499,25 @@
 
 /** Return true iff we have published our descriptor lately.
  */
-int advertised_server_mode(void) {
+int
+advertised_server_mode(void)
+{
   return server_is_advertised;
 }
 
-static void set_server_advertised(int s) {
+/**
+ * Called with a boolean: set whether we have recently published our descriptor.
+ */
+static void
+set_server_advertised(int s)
+{
   server_is_advertised = s;
 }
 
 /** Return true iff we are trying to be a socks proxy. */
-int proxy_mode(or_options_t *options) {
+int
+proxy_mode(or_options_t *options)
+{
   return (options->SocksPort != 0 || options->SocksBindAddress);
 }
 
@@ -484,7 +531,9 @@
  * - We believe we are reachable from the outside; or
  * - We have the AuthoritativeDirectory option set.
  */
-static int decide_if_publishable_server(time_t now) {
+static int
+decide_if_publishable_server(time_t now)
+{
   or_options_t *options = get_options();
 
   if (options->ClientOnly)
@@ -499,7 +548,12 @@
   return check_whether_orport_reachable();
 }
 
-void consider_publishable_server(time_t now, int force) {
+/** Initiate server descriptor upload as reasonable (if server is publishable,
+ * etc).  <b>force</b> is as for router_upload_dir_desc_to_dirservers.
+ */
+void
+consider_publishable_server(time_t now, int force)
+{
   if (decide_if_publishable_server(now)) {
     set_server_advertised(1);
     if (router_rebuild_descriptor(force) == 0)
@@ -517,7 +571,9 @@
  * other ORs we know about. Otherwise, open connections to those we
  * think are in clique mode.
  */
-void router_retry_connections(void) {
+void
+router_retry_connections(void)
+{
   int i;
   routerinfo_t *router;
   routerlist_t *rl;
@@ -544,7 +600,9 @@
 
 /** Return true iff this OR should try to keep connections open to all
  * other ORs. */
-int router_is_clique_mode(routerinfo_t *router) {
+int
+router_is_clique_mode(routerinfo_t *router)
+{
   if (router_digest_is_trusted_dir(router->identity_digest))
     return 1;
   return 0;
@@ -565,7 +623,9 @@
  * descriptor successfully yet, try to upload our signed descriptor to
  * all the directory servers we know about.
  */
-void router_upload_dir_desc_to_dirservers(int force) {
+void
+router_upload_dir_desc_to_dirservers(int force)
+{
   const char *s;
 
   s = router_get_my_descriptor();
@@ -582,7 +642,8 @@
 /** OR only: Check whether my exit policy says to allow connection to
  * conn.  Return false if we accept; true if we reject.
  */
-int router_compare_to_my_exit_policy(connection_t *conn)
+int
+router_compare_to_my_exit_policy(connection_t *conn)
 {
   tor_assert(desc_routerinfo);
 
@@ -597,7 +658,8 @@
 
 /** Return true iff I'm a server and <b>digest</b> is equal to
  * my identity digest. */
-int router_digest_is_me(const char *digest)
+int
+router_digest_is_me(const char *digest)
 {
   routerinfo_t *me = router_get_my_routerinfo();
   if (!me || memcmp(me->identity_digest, digest, DIGEST_LEN))
@@ -606,14 +668,16 @@
 }
 
 /** A wrapper around router_digest_is_me(). */
-int router_is_me(routerinfo_t *router)
+int
+router_is_me(routerinfo_t *router)
 {
   return router_digest_is_me(router->identity_digest);
 }
 
 /** Return a routerinfo for this OR, rebuilding a fresh one if
  * necessary.  Return NULL on error, or if called on an OP. */
-routerinfo_t *router_get_my_routerinfo(void)
+routerinfo_t *
+router_get_my_routerinfo(void)
 {
   if (!server_mode(get_options()))
     return NULL;
@@ -628,7 +692,9 @@
 /** OR only: Return a signed server descriptor for this OR, rebuilding a fresh
  * one if necessary.  Return NULL on error.
  */
-const char *router_get_my_descriptor(void) {
+const char *
+router_get_my_descriptor(void)
+{
   if (!desc_routerinfo) {
     if (router_rebuild_descriptor(1))
       return NULL;
@@ -641,7 +707,9 @@
  * a fresh routerinfo and signed server descriptor for this OR.
  * Return 0 on success, -1 on error.
  */
-int router_rebuild_descriptor(int force) {
+int
+router_rebuild_descriptor(int force)
+{
   routerinfo_t *ri;
   uint32_t addr;
   char platform[256];
@@ -720,7 +788,8 @@
  * string describing the version of Tor and the operating system we're
  * currently running on.
  */
-void get_platform_str(char *platform, size_t len)
+void
+get_platform_str(char *platform, size_t len)
 {
   tor_snprintf(platform, len, "Tor %s on %s",
            VERSION, get_uname());
@@ -738,8 +807,10 @@
  * result into <b>s</b>, using at most <b>maxlen</b> bytes.  Return -1 on
  * failure, and the number of bytes used on success.
  */
-int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
-                                 crypto_pk_env_t *ident_key) {
+int
+router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
+                             crypto_pk_env_t *ident_key)
+{
   char *onion_pkey; /* Onion key, PEM-encoded. */
   char *identity_pkey; /* Identity key, PEM-encoded. */
   char digest[20];
@@ -936,7 +1007,8 @@
 }
 
 /** Return true iff <b>s</b> is a legally valid server nickname. */
-int is_legal_nickname(const char *s)
+int
+is_legal_nickname(const char *s)
 {
   size_t len;
   tor_assert(s);
@@ -946,7 +1018,8 @@
 }
 /** Return true iff <b>s</b> is a legally valid server nickname or
  * hex-encoded identity-key digest. */
-int is_legal_nickname_or_hexdigest(const char *s)
+int
+is_legal_nickname_or_hexdigest(const char *s)
 {
   size_t len;
   tor_assert(s);
@@ -958,7 +1031,8 @@
 }
 
 /** Release all resources held in router keys. */
-void router_free_all_keys(void)
+void
+router_free_all_keys(void)
 {
   if (onionkey)
     crypto_free_pk_env(onionkey);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -d -r1.238 -r1.239
--- routerlist.c	11 Jun 2005 05:31:17 -0000	1.238
+++ routerlist.c	11 Jun 2005 18:52:11 -0000	1.239
@@ -45,7 +45,8 @@
  * Reload the original list of trusted dirservers, and the most recent
  * cached directory (if present).
  */
-int router_reload_router_list(void)
+int
+router_reload_router_list(void)
 {
   char filename[512];
   int is_recent;
@@ -77,7 +78,8 @@
  * trusted_dir_server_t * for all known trusted dirservers.  Callers
  * must not modify the list or its contents.
  */
-void router_get_trusted_dir_servers(smartlist_t **outp)
+void
+router_get_trusted_dir_servers(smartlist_t **outp)
 {
   if (!trusted_dir_servers)
     trusted_dir_servers = smartlist_create();
@@ -92,10 +94,12 @@
  * true, then only pick a dirserver that can answer runningrouters queries
  * (that is, a trusted dirserver, or one running 0.0.9rc5-cvs or later).
  */
-routerinfo_t *router_pick_directory_server(int requireothers,
-                                           int fascistfirewall,
-                                           int for_runningrouters,
-                                           int retry_if_no_servers) {
+routerinfo_t *
+router_pick_directory_server(int requireothers,
+                             int fascistfirewall,
+                             int for_runningrouters,
+                             int retry_if_no_servers)
+{
   routerinfo_t *choice;
 
   if (!routerlist)
@@ -127,9 +131,12 @@
   return choice;
 }
 
-trusted_dir_server_t *router_pick_trusteddirserver(int requireothers,
-                                                   int fascistfirewall,
-                                                   int retry_if_no_servers) {
+/** DOCDOC */
+trusted_dir_server_t *
+router_pick_trusteddirserver(int requireothers,
+                             int fascistfirewall,
+                             int retry_if_no_servers)
+{
   trusted_dir_server_t *choice;
 
   choice = router_pick_trusteddirserver_impl(requireothers, fascistfirewall);
@@ -197,6 +204,7 @@
   return router;
 }
 
+/** DOCDOC */
 static trusted_dir_server_t *
 router_pick_trusteddirserver_impl(int requireother, int fascistfirewall)
 {
@@ -231,7 +239,9 @@
 }
 
 /** Go through and mark the auth dirservers as up */
-static void mark_all_trusteddirservers_up(void) {
+static void
+mark_all_trusteddirservers_up(void)
+{
   if (routerlist) {
     SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, router,
                  if (router_digest_is_trusted_dir(router->identity_digest)) {
@@ -249,7 +259,9 @@
 /** Return 0 if \\exists an authoritative dirserver that's currently
  * thought to be running, else return 1.
  */
-int all_trusted_directory_servers_down(void) {
+int
+all_trusted_directory_servers_down(void)
+{
   if (!trusted_dir_servers)
     return 1;
   SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, dir,
@@ -259,7 +271,9 @@
 
 /** Add all the family of <b>router</b> to the smartlist <b>sl</b>.
  */
-void routerlist_add_family(smartlist_t *sl, routerinfo_t *router) {
+void
+routerlist_add_family(smartlist_t *sl, routerinfo_t *router)
+{
   routerinfo_t *r;
   struct config_line_t *cl;
 
@@ -395,8 +409,10 @@
   }
 }
 
+/** DOCDOC */
 routerinfo_t *
-routerlist_find_my_routerinfo(void) {
+routerlist_find_my_routerinfo(void)
+{
   routerinfo_t *router;
   int i;
 
@@ -411,6 +427,7 @@
   return NULL;
 }
 
+/** DOCDOC */
 int
 router_is_unreliable(routerinfo_t *router, int need_uptime, int need_capacity)
 {
@@ -421,6 +438,7 @@
   return 0;
 }
 
+/** DOCDOC */
 static void
 routerlist_sl_remove_unreliable_routers(smartlist_t *sl)
 {
@@ -437,6 +455,7 @@
   }
 }
 
+/** DOCDOC */
 routerinfo_t *
 routerlist_sl_choose_by_bandwidth(smartlist_t *sl)
 {
@@ -490,11 +509,12 @@
  * available.  If <b>strict</b> is true, never pick any node besides
  * those in <b>preferred</b>.
  */
-routerinfo_t *router_choose_random_node(const char *preferred,
-                                        const char *excluded,
-                                        smartlist_t *excludedsmartlist,
-                                        int need_uptime, int need_capacity,
-                                        int allow_unverified, int strict)
+routerinfo_t *
+router_choose_random_node(const char *preferred,
+                          const char *excluded,
+                          smartlist_t *excludedsmartlist,
+                          int need_uptime, int need_capacity,
+                          int allow_unverified, int strict)
 {
   smartlist_t *sl, *excludednodes;
   routerinfo_t *choice;
@@ -544,7 +564,9 @@
 /** Return the router in our routerlist whose address is <b>addr</b> and
  * whose OR port is <b>port</b>. Return NULL if no such router is known.
  */
-routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port) {
+routerinfo_t *
+router_get_by_addr_port(uint32_t addr, uint16_t port)
+{
   int i;
   routerinfo_t *router;
 
@@ -563,8 +585,8 @@
  * encoded in hexadecimal, matches <b>hexdigest</b> (which is
  * optionally prefixed with a single dollar sign).  Return false if
  * <b>hexdigest</b> is malformed, or it doesn't match.  */
-static INLINE int router_hex_digest_matches(routerinfo_t *router,
-                                     const char *hexdigest)
+static INLINE int
+router_hex_digest_matches(routerinfo_t *router, const char *hexdigest)
 {
   char digest[DIGEST_LEN];
   tor_assert(hexdigest);
@@ -582,7 +604,8 @@
  * (case-insensitive), or if <b>router's</b> identity key digest
  * matches a hexadecimal value stored in <b>nickname</b>.  Return
  * false otherwise.*/
-int router_nickname_matches(routerinfo_t *router, const char *nickname)
+int
+router_nickname_matches(routerinfo_t *router, const char *nickname)
 {
   if (nickname[0]!='$' && !strcasecmp(router->nickname, nickname))
     return 1;
@@ -594,7 +617,8 @@
  * nickname or (case-sensitive) hexadecimal key digest is
  * <b>nickname</b>.  Return NULL if no such router is known.
  */
-routerinfo_t *router_get_by_nickname(const char *nickname)
+routerinfo_t *
+router_get_by_nickname(const char *nickname)
 {
   int i, maybedigest;
   routerinfo_t *router;
@@ -625,7 +649,9 @@
 
 /** Return true iff <b>digest</b> is the digest of the identity key of
  * a trusted directory. */
-int router_digest_is_trusted_dir(const char *digest) {
+int
+router_digest_is_trusted_dir(const char *digest)
+{
   if (!trusted_dir_servers)
     return 0;
   SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, ent,
@@ -635,7 +661,9 @@
 
 /** Return the router in our routerlist whose hexadecimal key digest
  * is <b>hexdigest</b>.  Return NULL if no such router is known. */
-routerinfo_t *router_get_by_hexdigest(const char *hexdigest) {
+routerinfo_t *
+router_get_by_hexdigest(const char *hexdigest)
+{
   char digest[DIGEST_LEN];
 
   tor_assert(hexdigest);
@@ -652,7 +680,9 @@
 
 /** Return the router in our routerlist whose 20-byte key digest
  * is <b>digest</b>.  Return NULL if no such router is known. */
-routerinfo_t *router_get_by_digest(const char *digest) {
+routerinfo_t *
+router_get_by_digest(const char *digest)
+{
   int i;
   routerinfo_t *router;
 
@@ -673,18 +703,23 @@
 }
 
 /** Set *<b>prouterlist</b> to the current list of all known routers. */
-void router_get_routerlist(routerlist_t **prouterlist) {
+void
+router_get_routerlist(routerlist_t **prouterlist)
+{
   *prouterlist = routerlist;
 }
 
 /** Return the publication time on the current routerlist, or 0 if we have no
  * routerlist. */
-time_t routerlist_get_published_time(void) {
+time_t
+routerlist_get_published_time(void)
+{
   return routerlist ? routerlist->published_on : 0;
 }
 
 /** Free all storage held by <b>router</b>. */
-void routerinfo_free(routerinfo_t *router)
+void
+routerinfo_free(routerinfo_t *router)
 {
   if (!router)
     return;
@@ -707,7 +742,8 @@
 }
 
 /** Allocate a fresh copy of <b>router</b> */
-routerinfo_t *routerinfo_copy(const routerinfo_t *router)
+routerinfo_t *
+routerinfo_copy(const routerinfo_t *router)
 {
   routerinfo_t *r;
   addr_policy_t **e, *tmp;
@@ -741,7 +777,8 @@
 }
 
 /** Free all storage held by a routerlist <b>rl</b> */
-void routerlist_free(routerlist_t *rl)
+void
+routerlist_free(routerlist_t *rl)
 {
   tor_assert(rl);
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
@@ -752,7 +789,9 @@
   tor_free(rl);
 }
 
-void routerlist_free_current(void)
+/** Free all entries in the current router list. */
+void
+routerlist_free_current(void)
 {
   if (routerlist)
     routerlist_free(routerlist);
@@ -764,7 +803,9 @@
   }
 }
 
-void free_trusted_dir_servers(void)
+/** Free all entries in the list of trusted directory servers. */
+void
+free_trusted_dir_servers(void)
 {
   if (trusted_dir_servers) {
     SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, ds,
@@ -775,7 +816,9 @@
 }
 
 /** Mark the router with ID <b>digest</b> as non-running in our routerlist. */
-void router_mark_as_down(const char *digest) {
+void
+router_mark_as_down(const char *digest)
+{
   routerinfo_t *router;
   tor_assert(digest);
 
@@ -802,7 +845,8 @@
  * DOCDOC msg
  */
 static int
-router_add_to_routerlist(routerinfo_t *router, const char **msg) {
+router_add_to_routerlist(routerinfo_t *router, const char **msg)
+{
   int i;
   routerinfo_t *r;
   char id_digest[DIGEST_LEN];
@@ -958,10 +1002,11 @@
  * If <b>dir_is_cached</b> is non-zero, then we're reading it
  * from the cache so don't bother to re-write it to the cache.
  */
-int router_load_routerlist_from_directory(const char *s,
-                                          crypto_pk_env_t *pkey,
-                                          int dir_is_recent,
-                                          int dir_is_cached)
+int
+router_load_routerlist_from_directory(const char *s,
+                                      crypto_pk_env_t *pkey,
+                                      int dir_is_recent,
+                                      int dir_is_cached)
 {
   routerlist_t *new_list = NULL;
   if (router_parse_routerlist_from_directory(s, &new_list, pkey,
@@ -1134,8 +1179,10 @@
 
 /** Return 1 if all running sufficiently-stable routers will reject
  * addr:port, return 0 if any might accept it. */
-int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port,
-                                          int need_uptime) {
+int
+router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port,
+                                          int need_uptime)
+{
   int i;
   routerinfo_t *router;
   addr_policy_result_t r;
@@ -1241,13 +1288,16 @@
 
 /** Return true iff <b>router</b> does not permit exit streams.
  */
-int router_exit_policy_rejects_all(routerinfo_t *router) {
+int
+router_exit_policy_rejects_all(routerinfo_t *router)
+{
   return router_compare_addr_to_addr_policy(0, 0, router->exit_policy)
     == ADDR_POLICY_REJECTED;
 }
 
 /** Release all space held in <b>rr</b>. */
-void running_routers_free(running_routers_t *rr)
+void
+running_routers_free(running_routers_t *rr)
 {
   if (!rr)
     return;
@@ -1274,8 +1324,9 @@
  * on the contents of <b>rr</b>. */
 /* Note: this function is not yet used, since nobody publishes just
  * running-router lists yet. */
-void routerlist_update_from_runningrouters(routerlist_t *list,
-                                           running_routers_t *rr)
+void
+routerlist_update_from_runningrouters(routerlist_t *list,
+                                      running_routers_t *rr)
 {
   routerinfo_t *me = router_get_my_routerinfo();
   smartlist_t *all_routers;
@@ -1317,9 +1368,10 @@
  *
  * Return 1 if we found router in running_list, else return 0.
  */
-int routers_update_status_from_entry(smartlist_t *routers,
-                                     time_t list_time,
-                                     const char *s)
+int
+routers_update_status_from_entry(smartlist_t *routers,
+                                 time_t list_time,
+                                 const char *s)
 {
   int is_running = 1;
   int is_verified = 0;
@@ -1448,7 +1500,8 @@
 }
 
 /** Remove all members from the list of trusted dir servers. */
-void clear_trusted_dir_servers(void)
+void
+clear_trusted_dir_servers(void)
 {
   if (trusted_dir_servers) {
     SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, ent,

Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerparse.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- routerparse.c	11 Jun 2005 05:31:17 -0000	1.112
+++ routerparse.c	11 Jun 2005 18:52:11 -0000	1.113
@@ -152,7 +152,8 @@
 /** Set <b>digest</b> to the SHA-1 digest of the hash of the directory in
  * <b>s</b>.  Return 0 on success, nonzero on failure.
  */
-int router_get_dir_hash(const char *s, char *digest)
+int
+router_get_dir_hash(const char *s, char *digest)
 {
   return router_get_hash_impl(s,digest,
                               "signed-directory","\ndirectory-signature");
@@ -161,7 +162,8 @@
 /** Set <b>digest</b> to the SHA-1 digest of the hash of the first router in
  * <b>s</b>. Return 0 on success, nonzero on failure.
  */
-int router_get_router_hash(const char *s, char *digest)
+int
+router_get_router_hash(const char *s, char *digest)
 {
   return router_get_hash_impl(s,digest,
                               "router ","\nrouter-signature");
@@ -170,7 +172,8 @@
 /** Set <b>digest</b> to the SHA-1 digest of the hash of the running-routers
  * string in <b>s</b>. Return 0 on success, nonzero on failure.
  */
-int router_get_runningrouters_hash(const char *s, char *digest)
+int
+router_get_runningrouters_hash(const char *s, char *digest)
 {
   return router_get_hash_impl(s,digest,
                               "network-status","\ndirectory-signature");
@@ -309,8 +312,9 @@
 
 /* Return 0 if myversion is supported; else log a message and return
  * -1 (or exit if ignoreversions is false) */
-int check_software_version_against_directory(const char *directory,
-                                             int ignoreversion)
+int
+check_software_version_against_directory(const char *directory,
+                                         int ignoreversion)
 {
   char *v;
   v = get_recommended_software_from_directory(directory);
@@ -629,7 +633,8 @@
 /** Given a directory or running-routers string in <b>str</b>, try to
  * find the its dir-signing-key token (if any).  If this token is
  * present, extract and return the key.  Return NULL on failure. */
-static crypto_pk_env_t *find_dir_signing_key(const char *str)
+static crypto_pk_env_t *
+find_dir_signing_key(const char *str)
 {
   const char *cp;
   directory_token_t *tok;
@@ -675,7 +680,8 @@
 
 /** Return true iff <b>key</b> is allowed to sign directories.
  */
-static int dir_signing_key_is_trusted(crypto_pk_env_t *key)
+static int
+dir_signing_key_is_trusted(crypto_pk_env_t *key)
 {
   char digest[DIGEST_LEN];
   if (!key) return 0;
@@ -702,10 +708,11 @@
  * (New callers should always use <b>declared_key</b> when possible;
  * <b>pkey</b> is only for debugging.)
  */
-static int check_directory_signature(const char *digest,
-                                     directory_token_t *tok,
-                                     crypto_pk_env_t *pkey,
-                                     crypto_pk_env_t *declared_key)
+static int
+check_directory_signature(const char *digest,
+                          directory_token_t *tok,
+                          crypto_pk_env_t *pkey,
+                          crypto_pk_env_t *declared_key)
 {
   char signed_digest[PK_BYTES];
   crypto_pk_env_t *_pkey = NULL;
@@ -816,8 +823,9 @@
  * *<b>end</b>.  Mallocs a new router and returns it if all goes well, else
  * returns NULL.
  */
-routerinfo_t *router_parse_entry_from_string(const char *s,
-                                           const char *end) {
+routerinfo_t *
+router_parse_entry_from_string(const char *s, const char *end)
+{
   routerinfo_t *router = NULL;
   char signed_digest[128];
   char digest[128];
@@ -1014,10 +1022,6 @@
     router->platform = tor_strdup("<unknown>");
   }
 
-//  log_fn(LOG_DEBUG,"or_port %d, dir_port %d, bandwidthrate %u, bandwidthburst %u.",
-//    router->or_port, router->dir_port,
-//    (unsigned) router->bandwidthrate, (unsigned) router->bandwidthburst);
-
   goto done;
   return router;
 
@@ -1075,6 +1079,7 @@
   return r;
 }
 
+/** DOCDOC */
 int
 router_add_exit_policy_from_string(routerinfo_t *router, const char *s)
 {
@@ -1089,6 +1094,7 @@
   return 0;
 }
 
+/** DOCDOC */
 static int
 router_add_exit_policy(routerinfo_t *router,directory_token_t *tok)
 {
@@ -1106,8 +1112,8 @@
 /** Given a K_ACCEPT or K_REJECT token and a router, create and return
  * a new exit_policy_t corresponding to the token. */
 static addr_policy_t *
-router_parse_addr_policy(directory_token_t *tok) {
-
+router_parse_addr_policy(directory_token_t *tok)
+{
   addr_policy_t *newe;
 //  struct in_addr in;
   char *arg;
@@ -1152,6 +1158,7 @@
   return NULL;
 }
 
+/** log and exit if <b>t</b> is malformed */
 void
 assert_addr_policy_ok(addr_policy_t *t)
 {
@@ -1204,7 +1211,8 @@
  * or RTR_ONLY, reject all tokens of the wrong type.
  */
 static directory_token_t *
-get_next_token(const char **s, where_syntax where) {
+get_next_token(const char **s, where_syntax where)
+{
   const char *next, *obstart;
   int i, done, allocated, is_opt;
   directory_token_t *tok;
@@ -1461,9 +1469,10 @@
  *
  * If no such substring exists, return -1.
  */
-static int router_get_hash_impl(const char *s, char *digest,
-                                const char *start_str,
-                                const char *end_str)
+static int
+router_get_hash_impl(const char *s, char *digest,
+                     const char *start_str,
+                     const char *end_str)
 {
   char *start, *end;
   start = strstr(s, start_str);
@@ -1500,7 +1509,9 @@
  * and compare it to the version in <b>cutoff</b>. Return 1 if
  * the router is at least as new as the cutoff, else return 0.
  */
-int tor_version_as_new_as(const char *platform, const char *cutoff) {
+int
+tor_version_as_new_as(const char *platform, const char *cutoff)
+{
   tor_version_t cutoff_version, router_version;
   char *s, *start;
   char tmp[128];
@@ -1529,7 +1540,8 @@
 
 /** Parse a tor version from <b>s</b>, and store the result in <b>out</b>.
  * Return 0 on success, -1 on failure. */
-int tor_version_parse(const char *s, tor_version_t *out)
+int
+tor_version_parse(const char *s, tor_version_t *out)
 {
   char *eos=NULL, *cp=NULL;
   /* Format is:
@@ -1598,7 +1610,8 @@
 
 /** Compare two tor versions; Return <0 if a < b; 0 if a ==b, >0 if a >
  * b. */
-int tor_version_compare(tor_version_t *a, tor_version_t *b)
+int
+tor_version_compare(tor_version_t *a, tor_version_t *b)
 {
   int i;
   tor_assert(a);
@@ -1621,6 +1634,8 @@
   }
 }
 
+/** Return true iff versions <b>a</b> and <b>b</b> belong to the same series.
+ */
 static int
 tor_version_same_series(tor_version_t *a, tor_version_t *b)
 {

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/test.c,v
retrieving revision 1.181
retrieving revision 1.182
diff -u -d -r1.181 -r1.182
--- test.c	11 Jun 2005 05:31:17 -0000	1.181
+++ test.c	11 Jun 2005 18:52:11 -0000	1.182
@@ -122,7 +122,8 @@
 }
 
 static void
-test_buffers(void) {
+test_buffers(void)
+{
   char str[256];
   char str2[256];
 
@@ -599,7 +600,8 @@
 }
 
 static void
-test_util(void) {
+test_util(void)
+{
   struct timeval start, end;
   struct tm a_time;
   smartlist_t *sl;
@@ -1428,7 +1430,8 @@
 }
 
 int
-main(int c, char**v) {
+main(int c, char**v)
+{
   or_options_t *options = tor_malloc_zero(sizeof(or_options_t));
   network_init();
   options_init(options);

Index: tor_main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/tor_main.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- tor_main.c	11 Jun 2005 05:31:17 -0000	1.11
+++ tor_main.c	11 Jun 2005 18:52:11 -0000	1.12
@@ -15,7 +15,8 @@
 /** We keep main() in a separate file so that our unit tests can use
  * functions from main.c)
  */
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
   return tor_main(argc, argv);
 }



More information about the tor-commits mailing list