{
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;
}
#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
/**
void *result;
#ifdef W32_MEM_LIMIT
- size += sizeof(size_t);
+ size += sizeof (size_t);
if (mem_used + size > W32_MEM_LIMIT)
return NULL;
#endif
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
* 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;
};
* @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;
+ }
+ }
}
* @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;
}
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;
}
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;
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)
{
#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);
* 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);
}
on_next = GNUNET_YES;
}
}
- GNUNET_CONTAINER_slist_iter_destroy (i);
+ GNUNET_CONTAINER_slist_iter_destroy (i);
}
/* Poll for faulty pipes */
}
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)
{
if (GNUNET_SYSERR ==
(disablev6 = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
- sctx->serviceName,
+ sctx->
+ serviceName,
"DISABLEV6")))
return GNUNET_SYSERR;
}
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);
}
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);
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 ==
{
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 */
// 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;
}
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 */