[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9444 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9444 - gnunet/src/util |
Date: |
Tue, 10 Nov 2009 01:16:49 -0700 |
Author: grothoff
Date: 2009-11-10 01:16:49 -0700 (Tue, 10 Nov 2009)
New Revision: 9444
Modified:
gnunet/src/util/client.c
gnunet/src/util/common_allocation.c
gnunet/src/util/configuration.c
gnunet/src/util/connection.c
gnunet/src/util/container_slist.c
gnunet/src/util/network.c
gnunet/src/util/service.c
gnunet/src/util/test_bio.c
gnunet/src/util/test_configuration.c
gnunet/src/util/test_peer.c
Log:
indent
Modified: gnunet/src/util/client.c
===================================================================
--- gnunet/src/util/client.c 2009-11-10 08:11:47 UTC (rev 9443)
+++ gnunet/src/util/client.c 2009-11-10 08:16:49 UTC (rev 9444)
@@ -362,8 +362,8 @@
{
if ((conn->received_pos >= sizeof (struct GNUNET_MessageHeader)) &&
(conn->received_pos >=
- ntohs (((const struct GNUNET_MessageHeader *) conn->
- received_buf)->size)))
+ ntohs (((const struct GNUNET_MessageHeader *) conn->received_buf)->
+ size)))
conn->msg_complete = GNUNET_YES;
}
Modified: gnunet/src/util/common_allocation.c
===================================================================
--- gnunet/src/util/common_allocation.c 2009-11-10 08:11:47 UTC (rev 9443)
+++ gnunet/src/util/common_allocation.c 2009-11-10 08:16:49 UTC (rev 9444)
@@ -32,11 +32,11 @@
#endif
#if 0
- #define W32_MEM_LIMIT 200000000
+#define W32_MEM_LIMIT 200000000
#endif
#ifdef W32_MEM_LIMIT
- static LONG mem_used = 0;
+static LONG mem_used = 0;
#endif
/**
@@ -66,7 +66,7 @@
void *result;
#ifdef W32_MEM_LIMIT
- size += sizeof(size_t);
+ size += sizeof (size_t);
if (mem_used + size > W32_MEM_LIMIT)
return NULL;
#endif
@@ -109,7 +109,7 @@
const char *filename, int linenumber)
{
#ifdef W32_MEM_LIMIT
- n += sizeof(size_t);
+ n += sizeof (size_t);
ptr = &((size_t *) ptr)[-1];
mem_used = mem_used - *((size_t *) ptr) + n;
#endif
Modified: gnunet/src/util/configuration.c
===================================================================
--- gnunet/src/util/configuration.c 2009-11-10 08:11:47 UTC (rev 9443)
+++ gnunet/src/util/configuration.c 2009-11-10 08:16:49 UTC (rev 9444)
@@ -102,9 +102,10 @@
* Used for diffing a configuration object against
* the default one
*/
-struct GNUNNET_CONFIGURATION_Diff_Handle{
- struct GNUNET_CONFIGURATION_Handle* cfgNew;
- struct GNUNET_CONFIGURATION_Handle* cfgDiff;
+struct GNUNNET_CONFIGURATION_Diff_Handle
+{
+ struct GNUNET_CONFIGURATION_Handle *cfgNew;
+ struct GNUNET_CONFIGURATION_Handle *cfgDiff;
};
@@ -479,71 +480,81 @@
* @param option option name of the value (of the default conf.)
* @param value value to copy (of the default conf.)
*/
-void
-compareEntries(
- void *cls,
- const char *section,
- const char *option,
- const char *value)
+void
+compareEntries (void *cls,
+ const char *section, const char *option, const char *value)
{
- struct ConfigSection *secNew;
- struct ConfigEntry *entNew;
- struct GNUNNET_CONFIGURATION_Diff_Handle* cfgDiff = (struct
GNUNNET_CONFIGURATION_Diff_Handle*)cls;
-
- secNew = findSection(cfgDiff->cfgNew, section);
- entNew = findEntry(cfgDiff->cfgNew, section, option);
- if (secNew && strcmp(entNew->val, value) != 0) {
- /* Value in the new configuration has been changed */
- /* Add the changed value to the diff configuration object */
- struct ConfigEntry *diffEntry = NULL;
- struct ConfigSection *diffSection = NULL;
-
- diffSection = cfgDiff->cfgDiff->sections;
- if (diffSection == NULL) {
- /* First section */
- diffSection = GNUNET_malloc(sizeof(struct
ConfigSection));
- memcpy(diffSection, secNew, sizeof(struct
ConfigSection));
- cfgDiff->cfgDiff->sections = diffSection;
- diffSection->entries = NULL;
- diffSection->next = NULL;
- }
- else {
- while ((strcmp(diffSection->name, secNew->name) != 0)
&& (diffSection->next != NULL)) {
- diffSection = diffSection->next;
- }
- if (strcmp(diffSection->name, secNew->name) != 0) {
- /* Section not found in diffs configuration */
- diffSection->next = GNUNET_malloc(sizeof(struct
ConfigSection));
- memcpy(diffSection->next, secNew, sizeof(struct
ConfigSection));
- diffSection->next->entries = NULL;
- diffSection->next->next = NULL;
- }
- else {
- diffEntry = diffSection->entries;
- }
- }
-
- if (diffEntry == NULL) {
- /* First Entry */
- diffEntry = GNUNET_malloc(sizeof(struct ConfigEntry));
- memcpy(diffEntry, entNew, sizeof(struct ConfigEntry));
- if (diffSection->next == NULL)
- /* The first Entry of the first Section */
- diffSection->entries = diffEntry;
- else
- /* The first entry of the non-first Section */
- diffSection->next->entries = diffEntry;
- diffEntry->next = NULL;
- }
- else {
- while (diffEntry->next != NULL) {
- diffEntry = diffEntry->next;
- }
- diffEntry->next = GNUNET_malloc(sizeof(struct
ConfigEntry));
- memcpy(diffEntry->next, entNew, sizeof(struct
ConfigEntry));
- diffEntry->next->next = NULL;
- }
- }
+ struct ConfigSection *secNew;
+ struct ConfigEntry *entNew;
+ struct GNUNNET_CONFIGURATION_Diff_Handle *cfgDiff =
+ (struct GNUNNET_CONFIGURATION_Diff_Handle *) cls;
+
+ secNew = findSection (cfgDiff->cfgNew, section);
+ entNew = findEntry (cfgDiff->cfgNew, section, option);
+ if (secNew && strcmp (entNew->val, value) != 0)
+ {
+ /* Value in the new configuration has been changed */
+ /* Add the changed value to the diff configuration object */
+ struct ConfigEntry *diffEntry = NULL;
+ struct ConfigSection *diffSection = NULL;
+
+ diffSection = cfgDiff->cfgDiff->sections;
+ if (diffSection == NULL)
+ {
+ /* First section */
+ diffSection = GNUNET_malloc (sizeof (struct ConfigSection));
+ memcpy (diffSection, secNew, sizeof (struct ConfigSection));
+ cfgDiff->cfgDiff->sections = diffSection;
+ diffSection->entries = NULL;
+ diffSection->next = NULL;
+ }
+ else
+ {
+ while ((strcmp (diffSection->name, secNew->name) != 0)
+ && (diffSection->next != NULL))
+ {
+ diffSection = diffSection->next;
+ }
+ if (strcmp (diffSection->name, secNew->name) != 0)
+ {
+ /* Section not found in diffs configuration */
+ diffSection->next =
+ GNUNET_malloc (sizeof (struct ConfigSection));
+ memcpy (diffSection->next, secNew,
+ sizeof (struct ConfigSection));
+ diffSection->next->entries = NULL;
+ diffSection->next->next = NULL;
+ }
+ else
+ {
+ diffEntry = diffSection->entries;
+ }
+ }
+
+ if (diffEntry == NULL)
+ {
+ /* First Entry */
+ diffEntry = GNUNET_malloc (sizeof (struct ConfigEntry));
+ memcpy (diffEntry, entNew, sizeof (struct ConfigEntry));
+ if (diffSection->next == NULL)
+ /* The first Entry of the first Section */
+ diffSection->entries = diffEntry;
+ else
+ /* The first entry of the non-first Section */
+ diffSection->next->entries = diffEntry;
+ diffEntry->next = NULL;
+ }
+ else
+ {
+ while (diffEntry->next != NULL)
+ {
+ diffEntry = diffEntry->next;
+ }
+ diffEntry->next = GNUNET_malloc (sizeof (struct ConfigEntry));
+ memcpy (diffEntry->next, entNew, sizeof (struct ConfigEntry));
+ diffEntry->next->next = NULL;
+ }
+ }
}
@@ -555,24 +566,23 @@
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
-GNUNET_CONFIGURATION_write_diffs(
- struct GNUNET_CONFIGURATION_Handle *cfgDefault,
- struct GNUNET_CONFIGURATION_Handle *cfgNew,
- const char* filename
- )
+GNUNET_CONFIGURATION_write_diffs (struct GNUNET_CONFIGURATION_Handle
+ *cfgDefault,
+ struct GNUNET_CONFIGURATION_Handle *cfgNew,
+ const char *filename)
{
- int ret;
- struct GNUNNET_CONFIGURATION_Diff_Handle diffHandle;
- diffHandle.cfgDiff = GNUNET_CONFIGURATION_create();
- diffHandle.cfgDiff->sections = NULL;
- diffHandle.cfgNew = cfgNew;
- GNUNET_CONFIGURATION_iterate(cfgDefault, compareEntries, &diffHandle);
-
- ret = GNUNET_CONFIGURATION_write(diffHandle.cfgDiff, filename);
-
- /* Housekeeping */
- GNUNET_CONFIGURATION_destroy(diffHandle.cfgDiff);
- return ret;
+ int ret;
+ struct GNUNNET_CONFIGURATION_Diff_Handle diffHandle;
+ diffHandle.cfgDiff = GNUNET_CONFIGURATION_create ();
+ diffHandle.cfgDiff->sections = NULL;
+ diffHandle.cfgNew = cfgNew;
+ GNUNET_CONFIGURATION_iterate (cfgDefault, compareEntries, &diffHandle);
+
+ ret = GNUNET_CONFIGURATION_write (diffHandle.cfgDiff, filename);
+
+ /* Housekeeping */
+ GNUNET_CONFIGURATION_destroy (diffHandle.cfgDiff);
+ return ret;
}
Modified: gnunet/src/util/connection.c
===================================================================
--- gnunet/src/util/connection.c 2009-11-10 08:11:47 UTC (rev 9443)
+++ gnunet/src/util/connection.c 2009-11-10 08:16:49 UTC (rev 9444)
@@ -817,12 +817,11 @@
ret->port = port;
ret->hostname = GNUNET_strdup (hostname);
ret->dns_active = GNUNET_RESOLVER_ip_get (sched,
- cfg,
- ret->hostname,
- AF_UNSPEC,
-
GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT,
- &try_connect_using_address,
- ret);
+ cfg,
+ ret->hostname,
+ AF_UNSPEC,
+
GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT,
+ &try_connect_using_address, ret);
return ret;
}
@@ -971,9 +970,8 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Receive from `%s' encounters error: time out by %llums...
(%p)\n",
GNUNET_a2s (sh->addr, sh->addrlen),
- GNUNET_TIME_absolute_get_duration (sh->
- receive_timeout).value,
- sh);
+ GNUNET_TIME_absolute_get_duration (sh->receive_timeout).
+ value, sh);
#endif
signal_timeout (sh);
return;
@@ -1320,8 +1318,8 @@
GNUNET_assert (sock->write_buffer_pos <= sock->write_buffer_size);
RETRY:
ret = GNUNET_NETWORK_socket_send (sock->sock,
- &sock->
- write_buffer[sock->write_buffer_pos],
+ &sock->write_buffer[sock->
+ write_buffer_pos],
have);
if (ret == -1)
{
@@ -1418,8 +1416,8 @@
#endif
sock->write_task = GNUNET_SCHEDULER_add_write_net (sock->sched,
GNUNET_TIME_absolute_get_remaining
- (sock->
-
nth.transmit_timeout),
+ (sock->nth.
+ transmit_timeout),
sock->sock,
&transmit_ready,
sock);
Modified: gnunet/src/util/container_slist.c
===================================================================
--- gnunet/src/util/container_slist.c 2009-11-10 08:11:47 UTC (rev 9443)
+++ gnunet/src/util/container_slist.c 2009-11-10 08:16:49 UTC (rev 9444)
@@ -336,7 +336,9 @@
* Release an iterator
* @param i iterator
*/
-void GNUNET_CONTAINER_slist_iter_destroy (struct
GNUNET_CONTAINER_SList_Iterator *i)
+void
+GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator
+ *i)
{
GNUNET_free (i);
}
Modified: gnunet/src/util/network.c
===================================================================
--- gnunet/src/util/network.c 2009-11-10 08:11:47 UTC (rev 9443)
+++ gnunet/src/util/network.c 2009-11-10 08:16:49 UTC (rev 9444)
@@ -976,7 +976,7 @@
on_next = GNUNET_YES;
}
}
- GNUNET_CONTAINER_slist_iter_destroy (i);
+ GNUNET_CONTAINER_slist_iter_destroy (i);
}
/* Poll for faulty pipes */
@@ -1043,7 +1043,7 @@
}
select_loop_end:
if (retcode == 0 && nfds == 0)
- Sleep(GNUNET_MIN(100, limit - GetTickCount()));
+ Sleep (GNUNET_MIN (100, limit - GetTickCount ()));
}
while (retcode == 0 && (ms_total == INFINITE || GetTickCount () < limit));
if (retcode != -1)
Modified: gnunet/src/util/service.c
===================================================================
--- gnunet/src/util/service.c 2009-11-10 08:11:47 UTC (rev 9443)
+++ gnunet/src/util/service.c 2009-11-10 08:16:49 UTC (rev 9444)
@@ -799,7 +799,8 @@
{
if (GNUNET_SYSERR ==
(disablev6 = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
- sctx->serviceName,
+ sctx->
+ serviceName,
"DISABLEV6")))
return GNUNET_SYSERR;
}
Modified: gnunet/src/util/test_bio.c
===================================================================
--- gnunet/src/util/test_bio.c 2009-11-10 08:11:47 UTC (rev 9443)
+++ gnunet/src/util/test_bio.c 2009-11-10 08:16:49 UTC (rev 9444)
@@ -49,8 +49,7 @@
GNUNET_assert (NULL != fileW);
GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_string (fileW, TESTSTRING));
GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_meta_data (fileW, metaDataW));
- GNUNET_assert (GNUNET_OK ==
- GNUNET_BIO_write_int64 (fileW, TESTNUMBER64));
+ GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int64 (fileW, TESTNUMBER64));
GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (fileW));
fileR = GNUNET_BIO_read_open (fileName);
@@ -199,14 +198,16 @@
}
static int
-test_directory_r(){
+test_directory_r ()
+{
char *msg;
char readResult[200];
struct GNUNET_BIO_ReadHandle *fileR;
fileR = GNUNET_BIO_read_open ("/dev");
GNUNET_assert (NULL != fileR);
- GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read (fileR, "Read error",
readResult, 65537));
+ GNUNET_assert (GNUNET_SYSERR ==
+ GNUNET_BIO_read (fileR, "Read error", readResult, 65537));
msg = NULL;
GNUNET_BIO_read_close (fileR, &msg);
GNUNET_free (msg);
@@ -240,7 +241,7 @@
fileW = GNUNET_BIO_write_open ("/dev/full");
GNUNET_assert (NULL != fileW);
GNUNET_assert (GNUNET_SYSERR ==
- GNUNET_BIO_write (fileW, fileNameNO, sizeof(fileNameNO)));
+ GNUNET_BIO_write (fileW, fileNameNO, sizeof (fileNameNO)));
GNUNET_assert (GNUNET_SYSERR ==
GNUNET_BIO_write_string (fileW, TESTSTRING));
GNUNET_assert (GNUNET_SYSERR ==
@@ -384,14 +385,15 @@
{
GNUNET_assert (0 == test_normal_rw ());
GNUNET_assert (0 == test_nullfile_rw ());
- GNUNET_assert (0 == test_directory_r());
+ GNUNET_assert (0 == test_directory_r ());
return 0;
}
int
-main (int argc, char *argv[]){
- GNUNET_assert (0 == check_file_rw());
- GNUNET_assert (0 == check_metadata_rw());
- GNUNET_assert (0 == check_string_rw());
- return 0;
+main (int argc, char *argv[])
+{
+ GNUNET_assert (0 == check_file_rw ());
+ GNUNET_assert (0 == check_metadata_rw ());
+ GNUNET_assert (0 == check_string_rw ());
+ return 0;
} /* end of main */
Modified: gnunet/src/util/test_configuration.c
===================================================================
--- gnunet/src/util/test_configuration.c 2009-11-10 08:11:47 UTC (rev
9443)
+++ gnunet/src/util/test_configuration.c 2009-11-10 08:16:49 UTC (rev
9444)
@@ -231,23 +231,26 @@
// return 1;
// }
//
- struct GNUNET_CONFIGURATION_Handle* cfgDefault = GNUNET_CONFIGURATION_create
();
- struct GNUNET_CONFIGURATION_Handle* cfgNew = GNUNET_CONFIGURATION_create();
+ struct GNUNET_CONFIGURATION_Handle *cfgDefault =
+ GNUNET_CONFIGURATION_create ();
+ struct GNUNET_CONFIGURATION_Handle *cfgNew = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_parse (cfgDefault,
"src/util/test_configuration_data.conf"))
- {
- fprintf (stderr, "Failed to parse configuration file\n");
- GNUNET_CONFIGURATION_destroy (cfgDefault);
- return 1;
- }
+ GNUNET_CONFIGURATION_parse (cfgDefault,
+ "src/util/test_configuration_data.conf"))
+ {
+ fprintf (stderr, "Failed to parse configuration file\n");
+ GNUNET_CONFIGURATION_destroy (cfgDefault);
+ return 1;
+ }
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_parse (cfgNew,
"/Users/soufi/Desktop/test_configuration_data.conf"))
- {
- fprintf (stderr, "Failed to parse configuration file\n");
- GNUNET_CONFIGURATION_destroy (cfgNew);
- return 1;
- }
-
- GNUNET_CONFIGURATION_write_diffs(cfgDefault, cfgNew, "/tmp/safey.conf");
+ GNUNET_CONFIGURATION_parse (cfgNew,
+
"/Users/soufi/Desktop/test_configuration_data.conf"))
+ {
+ fprintf (stderr, "Failed to parse configuration file\n");
+ GNUNET_CONFIGURATION_destroy (cfgNew);
+ return 1;
+ }
+
+ GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfgNew, "/tmp/safey.conf");
return 0;
}
Modified: gnunet/src/util/test_peer.c
===================================================================
--- gnunet/src/util/test_peer.c 2009-11-10 08:11:47 UTC (rev 9443)
+++ gnunet/src/util/test_peer.c 2009-11-10 08:16:49 UTC (rev 9444)
@@ -36,70 +36,80 @@
static struct GNUNET_PeerIdentity pidArr[NUMBER_OF_PEERS];
-static void generatePeerIdList()
+static void
+generatePeerIdList ()
{
int i;
- for (i = 0; i < NUMBER_OF_PEERS; i++ ) {
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
&pidArr[i].hashPubKey);
+ for (i = 0; i < NUMBER_OF_PEERS; i++)
+ {
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
+ &pidArr[i].hashPubKey);
#ifdef DEBUG
- printf ("Peer %d: %s\n",
- i,
- GNUNET_i2s (&pidArr[i]));
+ printf ("Peer %d: %s\n", i, GNUNET_i2s (&pidArr[i]));
#endif
- }
+ }
}
-static int check()
+static int
+check ()
{
int i;
GNUNET_PEER_Id pid;
-
+
/* Insert Peers into PeerEntry table and hashmap */
- for (i=0; i < NUMBER_OF_PEERS; i++) {
- pid = GNUNET_PEER_intern(&pidArr[i]);
- if ( pid != (i + 1)) {
- fprintf(stderr, "Unexpected Peer ID returned by intern function \n");
- return 1;
+ for (i = 0; i < NUMBER_OF_PEERS; i++)
+ {
+ pid = GNUNET_PEER_intern (&pidArr[i]);
+ if (pid != (i + 1))
+ {
+ fprintf (stderr,
+ "Unexpected Peer ID returned by intern function \n");
+ return 1;
+ }
}
- }
-
+
/* Referencing the first 3 peers once again */
- for (i = 0; i < 3; i++) {
- pid = GNUNET_PEER_intern(&pidArr[i]);
- if (pid != (i + 1)) {
- fprintf(stderr, "Unexpcted Peer ID returned by intern function \n");
- return 1;
+ for (i = 0; i < 3; i++)
+ {
+ pid = GNUNET_PEER_intern (&pidArr[i]);
+ if (pid != (i + 1))
+ {
+ fprintf (stderr,
+ "Unexpcted Peer ID returned by intern function \n");
+ return 1;
+ }
}
- }
-
+
/* Dereferencing the first 3 peers once [decrementing their reference count]
*/
{
- GNUNET_PEER_Id ids[] = {1, 2, 3};
- GNUNET_PEER_decrement_rcs(ids, 3);
+ GNUNET_PEER_Id ids[] = { 1, 2, 3 };
+ GNUNET_PEER_decrement_rcs (ids, 3);
}
-
+
/* re-referencing the first 3 peers using the change_rc function */
- for (i = 0; i < 3; i++) {
- GNUNET_PEER_change_rc(i, 1);
- }
-
+ for (i = 0; i < 3; i++)
+ {
+ GNUNET_PEER_change_rc (i, 1);
+ }
+
/* Removing the second Peer from the PeerEntry hash map */
- GNUNET_PEER_change_rc(2, -2);
-
+ GNUNET_PEER_change_rc (2, -2);
+
/* convert the pid of the first PeerEntry into that of the third */
- GNUNET_PEER_resolve(1, &pidArr[3]);
-
+ GNUNET_PEER_resolve (1, &pidArr[3]);
+
return 0;
}
-int main()
+int
+main ()
{
GNUNET_log_setup ("test-peer", "ERROR", NULL);
- generatePeerIdList();
- return check();
+ generatePeerIdList ();
+ return check ();
}
/* end of test_peer.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9444 - gnunet/src/util,
gnunet <=