[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6750 - in GNUnet/src: applications/chat applications/fs/ec
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6750 - in GNUnet/src: applications/chat applications/fs/ecrs applications/fs/fsui applications/tbench applications/testing include util/network |
Date: |
Thu, 24 Apr 2008 00:10:07 -0600 (MDT) |
Author: grothoff
Date: 2008-04-24 00:10:06 -0600 (Thu, 24 Apr 2008)
New Revision: 6750
Modified:
GNUnet/src/applications/chat/chattest.c
GNUnet/src/applications/fs/ecrs/ecrs.h
GNUnet/src/applications/fs/ecrs/helper.c
GNUnet/src/applications/fs/ecrs/keyspace.c
GNUnet/src/applications/fs/ecrs/namespace.c
GNUnet/src/applications/fs/ecrs/parser.c
GNUnet/src/applications/fs/ecrs/search.c
GNUnet/src/applications/fs/ecrs/uri.c
GNUnet/src/applications/fs/fsui/deserialize.c
GNUnet/src/applications/fs/fsui/downloadtest.c
GNUnet/src/applications/fs/fsui/fsui.c
GNUnet/src/applications/fs/fsui/fsui.h
GNUnet/src/applications/fs/fsui/fsuitest.c
GNUnet/src/applications/fs/fsui/recursivetest.c
GNUnet/src/applications/fs/fsui/search.c
GNUnet/src/applications/fs/fsui/searchtest.c
GNUnet/src/applications/fs/fsui/serialize.c
GNUnet/src/applications/fs/fsui/serializetest.c
GNUnet/src/applications/fs/fsui/serializetest2.c
GNUnet/src/applications/fs/fsui/serializetest3.c
GNUnet/src/applications/fs/fsui/serializetest4.c
GNUnet/src/applications/fs/fsui/upload.c
GNUnet/src/applications/tbench/tbenchtest.c
GNUnet/src/applications/testing/remote.c
GNUnet/src/applications/testing/remotetopologies.c
GNUnet/src/include/gnunet_ecrs_lib.h
GNUnet/src/include/gnunet_fsui_lib.h
GNUnet/src/util/network/io.c
Log:
formatting
Modified: GNUnet/src/applications/chat/chattest.c
===================================================================
--- GNUnet/src/applications/chat/chattest.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/chat/chattest.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -42,10 +42,10 @@
static int
receive_callback1 (void *cls,
- struct GNUNET_CHAT_Room *room,
- const char *senderNick,
- const char *message,
- GNUNET_CronTime timestamp, GNUNET_CHAT_MSG_OPTIONS options)
+ struct GNUNET_CHAT_Room *room,
+ const char *senderNick,
+ const char *message,
+ GNUNET_CronTime timestamp, GNUNET_CHAT_MSG_OPTIONS options)
{
fprintf (stdout, _("`%s' said: %s\n"), senderNick, message);
return GNUNET_OK;
@@ -53,7 +53,7 @@
static int
member_list_callback1 (void *cls, const char *senderNick,
- int is_joining, GNUNET_CronTime timestamp)
+ int is_joining, GNUNET_CronTime timestamp)
{
fprintf (stdout, is_joining
? _("`%s' entered the room\n")
@@ -63,10 +63,10 @@
static int
receive_callback2 (void *cls,
- struct GNUNET_CHAT_Room *room,
- const char *senderNick,
- const char *message,
- GNUNET_CronTime timestamp, GNUNET_CHAT_MSG_OPTIONS options)
+ struct GNUNET_CHAT_Room *room,
+ const char *senderNick,
+ const char *message,
+ GNUNET_CronTime timestamp, GNUNET_CHAT_MSG_OPTIONS options)
{
fprintf (stdout, _("`%s' said: %s\n"), senderNick, message);
return GNUNET_OK;
@@ -74,7 +74,7 @@
static int
member_list_callback2 (void *cls, const char *senderNick,
- int is_joining, GNUNET_CronTime timestamp)
+ int is_joining, GNUNET_CronTime timestamp)
{
fprintf (stdout, is_joining
? _("`%s' entered the room\n")
@@ -96,11 +96,11 @@
struct GNUNET_CHAT_Room *r1;
struct GNUNET_CHAT_Room *r2;
- GNUNET_RSA_PublicKey * me = NULL;
- const struct GNUNET_RSA_PrivateKey *key = NULL;
+ GNUNET_RSA_PublicKey *me = NULL;
+ const struct GNUNET_RSA_PrivateKey *key = NULL;
- key = GNUNET_RSA_create_key ();
- GNUNET_RSA_get_public_key (key, &me);
+ key = GNUNET_RSA_create_key ();
+ GNUNET_RSA_get_public_key (key, &me);
ret = 0;
cfg = GNUNET_GC_create ();
@@ -121,14 +121,15 @@
}
#endif
- r1 = GNUNET_CHAT_join_room (NULL,cfg,"nicktest1","testroom",me,key,""
-
,&receive_callback1, NULL,member_list_callback1,
- NULL);
-
- r2 = GNUNET_CHAT_join_room (NULL,cfg,"nicktest2","testroom",me,key,"",
- &receive_callback2, NULL,member_list_callback2,
- NULL);
+ r1 =
+ GNUNET_CHAT_join_room (NULL, cfg, "nicktest1", "testroom", me, key, "",
+ &receive_callback1, NULL, member_list_callback1,
+ NULL);
+ r2 = GNUNET_CHAT_join_room (NULL, cfg, "nicktest2", "testroom", me, key, "",
+ &receive_callback2, NULL, member_list_callback2,
+ NULL);
+
GNUNET_CHAT_leave_room (r1);
GNUNET_CHAT_leave_room (r2);
Modified: GNUnet/src/applications/fs/ecrs/ecrs.h
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrs.h 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/ecrs/ecrs.h 2008-04-24 06:10:06 UTC (rev
6750)
@@ -93,7 +93,7 @@
* %-encoding are NOT used internally
* (only in URI-strings).
*/
- char ** keywords;
+ char **keywords;
unsigned int keywordCount;
} ksk;
struct
Modified: GNUnet/src/applications/fs/ecrs/helper.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/helper.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/ecrs/helper.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -68,19 +68,17 @@
pos = searchString;
while ('\0' != *pos)
{
- if ( (saw_quote ==0) &&
- (isspace (*pos)) )
+ if ((saw_quote == 0) && (isspace (*pos)))
{
inWord = 0;
}
- else
- if (0 == inWord)
- {
- inWord = 1;
- ++num_Words;
- }
+ else if (0 == inWord)
+ {
+ inWord = 1;
+ ++num_Words;
+ }
if ('"' == *pos)
- saw_quote = (saw_quote + 1) % 2;
+ saw_quote = (saw_quote + 1) % 2;
pos++;
}
if (num_Words == 0)
@@ -102,11 +100,10 @@
keywords = GNUNET_malloc (num_Words * sizeof (char *));
num_Words = 0;
inWord = 0;
- pos = searchString;
- while ('\0' != *pos)
+ pos = searchString;
+ while ('\0' != *pos)
{
- if ( (saw_quote == 0) &&
- (isspace (*pos)) )
+ if ((saw_quote == 0) && (isspace (*pos)))
{
inWord = 0;
*pos = '\0';
@@ -118,7 +115,7 @@
++num_Words;
}
if ('"' == *pos)
- saw_quote = (saw_quote + 1) % 2;
+ saw_quote = (saw_quote + 1) % 2;
pos++;
}
uri =
@@ -154,10 +151,10 @@
{
unsigned int i;
struct GNUNET_ECRS_URI *uri;
- const char * keyword;
- char * val;
- const char * r;
- char * w;
+ const char *keyword;
+ char *val;
+ const char *r;
+ char *w;
uri = GNUNET_malloc (sizeof (URI));
uri->type = ksk;
@@ -167,26 +164,26 @@
{
keyword = keywords[i];
if (keyword[0] == '+')
- {
- val = GNUNET_strdup(keyword);
- }
+ {
+ val = GNUNET_strdup (keyword);
+ }
else
- {
- val = GNUNET_malloc(strlen(keyword) + 2);
- strcpy(val, " ");
- strcat(val, keyword);
- }
+ {
+ val = GNUNET_malloc (strlen (keyword) + 2);
+ strcpy (val, " ");
+ strcat (val, keyword);
+ }
r = val;
w = val;
while ('\0' != *r)
- {
- if ('"' == *r)
- r++;
- else
- *(w++) = *(r++);
- }
- uri->data.ksk.keywords[i] = GNUNET_strdup(val);
- GNUNET_free(val);
+ {
+ if ('"' == *r)
+ r++;
+ else
+ *(w++) = *(r++);
+ }
+ uri->data.ksk.keywords[i] = GNUNET_strdup (val);
+ GNUNET_free (val);
}
return uri;
}
Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -137,7 +137,7 @@
char *dstURI;
GNUNET_EC_KBlock *kb;
char **keywords;
- const char * keyword;
+ const char *keyword;
unsigned int keywordCount;
int i;
#if DEBUG_KEYSPACE
@@ -150,7 +150,7 @@
char *cpy; /* copy of the encrypted portion */
struct GNUNET_ECRS_URI *xuri;
- if (!GNUNET_ECRS_uri_test_ksk (uri))
+ if (!GNUNET_ECRS_uri_test_ksk (uri))
{
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR;
@@ -223,7 +223,7 @@
memcpy (&kb[1], cpy, mdsize + strlen (dstURI) + 1);
keyword = keywords[i];
/* first character of keyword indicates if it is
- mandatory or not -- ignore for hashing */
+ mandatory or not -- ignore for hashing */
GNUNET_hash (&keyword[1], strlen (&keyword[1]), &key);
#if DEBUG_KEYSPACE
IF_GELOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -139,7 +139,7 @@
GNUNET_EC_NBlock *nb;
GNUNET_EC_KNBlock *knb;
char **keywords;
- const char * keyword;
+ const char *keyword;
unsigned int keywordCount;
int i;
char *cpy;
@@ -263,9 +263,9 @@
size - sizeof (GNUNET_EC_KBlock) - sizeof (unsigned int));
for (i = 0; i < keywordCount; i++)
{
- keyword = keywords[i];
- /* first character of keyword indicates
- mandatory or not -- ignore for hashing! */
+ keyword = keywords[i];
+ /* first character of keyword indicates
+ mandatory or not -- ignore for hashing! */
GNUNET_hash (&keyword[1], strlen (&keyword[1]), &hc);
pk = GNUNET_RSA_create_key_from_hash (&hc);
GNUNET_RSA_get_public_key (pk, &knb->kblock.keyspace);
Modified: GNUnet/src/applications/fs/ecrs/parser.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/parser.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/ecrs/parser.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -39,7 +39,7 @@
{
struct GNUNET_ECRS_URI **uri = scls;
struct GNUNET_ECRS_URI *u = *uri;
- char * val;
+ char *val;
size_t slen;
if (u == NULL)
@@ -54,53 +54,45 @@
{
GNUNET_GE_ASSERT (NULL, u->type == ksk);
}
- slen = strlen(value);
+ slen = strlen (value);
if (slen == 0)
- return GNUNET_SYSERR; /* cannot be empty */
+ return GNUNET_SYSERR; /* cannot be empty */
if (value[0] == '+')
{
/* simply preserve the "mandatory" flag */
if (slen < 2)
- return GNUNET_SYSERR; /* empty keywords not allowed */
- if ( (value[1] == '"') &&
- (slen > 3) &&
- (value[slen-1] == '"') )
- {
- /* remove the quotes, keep the '+' */
- val = GNUNET_malloc(slen-1);
- val[0] = '+';
- memcpy(&val[1],
- &value[2],
- slen-3);
- val[slen-2] = '\0';
- }
+ return GNUNET_SYSERR; /* empty keywords not allowed */
+ if ((value[1] == '"') && (slen > 3) && (value[slen - 1] == '"'))
+ {
+ /* remove the quotes, keep the '+' */
+ val = GNUNET_malloc (slen - 1);
+ val[0] = '+';
+ memcpy (&val[1], &value[2], slen - 3);
+ val[slen - 2] = '\0';
+ }
else
- {
- /* no quotes, just keep the '+' */
- val = GNUNET_strdup (value);
- }
+ {
+ /* no quotes, just keep the '+' */
+ val = GNUNET_strdup (value);
+ }
}
else
{
- if ( (value[0] == '"') &&
- (slen > 2) &&
- (value[slen-1] == '"') )
- {
- /* remove the quotes, add a space */
- val = GNUNET_malloc(slen);
- val[0] = ' ';
- memcpy(&val[1],
- &value[1],
- slen-2);
- val[slen-1] = '\0';
- }
+ if ((value[0] == '"') && (slen > 2) && (value[slen - 1] == '"'))
+ {
+ /* remove the quotes, add a space */
+ val = GNUNET_malloc (slen);
+ val[0] = ' ';
+ memcpy (&val[1], &value[1], slen - 2);
+ val[slen - 1] = '\0';
+ }
else
- {
- /* add a space to indicate "not mandatory" */
- val = GNUNET_malloc(slen+2);
- strcpy(val, " ");
- strcat(val, value);
- }
+ {
+ /* add a space to indicate "not mandatory" */
+ val = GNUNET_malloc (slen + 2);
+ strcpy (val, " ");
+ strcat (val, value);
+ }
}
GNUNET_array_grow (u->data.ksk.keywords,
u->data.ksk.keywordCount, u->data.ksk.keywordCount + 1);
Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/ecrs/search.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -173,7 +173,7 @@
struct GNUNET_RSA_PrivateKey *pk;
GNUNET_RSA_PublicKey pub;
int i;
- const char * keyword;
+ const char *keyword;
#if DEBUG_SEARCH
GNUNET_GE_LOG (ectx,
@@ -182,12 +182,11 @@
#endif
for (i = 0; i < uri->data.ksk.keywordCount; i++)
{
- keyword = uri->data.ksk.keywords[i];
- /* first character of the keyword is
- "+" or " " to indicate mandatory or
- not -- ignore for hashing! */
- GNUNET_hash (&keyword[1],
- strlen (&keyword[1]), &hc);
+ keyword = uri->data.ksk.keywords[i];
+ /* first character of the keyword is
+ "+" or " " to indicate mandatory or
+ not -- ignore for hashing! */
+ GNUNET_hash (&keyword[1], strlen (&keyword[1]), &hc);
pk = GNUNET_RSA_create_key_from_hash (&hc);
GNUNET_RSA_get_public_key (pk, &pub);
GNUNET_hash (&pub, sizeof (GNUNET_RSA_PublicKey), &query);
@@ -567,15 +566,15 @@
{
struct GNUNET_ECRS_SearchContext *ctx;
- if (GNUNET_YES == GNUNET_ECRS_uri_test_ksk(uri))
+ if (GNUNET_YES == GNUNET_ECRS_uri_test_ksk (uri))
{
- if (1 != GNUNET_ECRS_uri_get_keyword_count_from_ksk(uri))
- return NULL;
+ if (1 != GNUNET_ECRS_uri_get_keyword_count_from_ksk (uri))
+ return NULL;
}
else
{
- if (GNUNET_YES != GNUNET_ECRS_uri_test_sks(uri))
- return NULL;
+ if (GNUNET_YES != GNUNET_ECRS_uri_test_sks (uri))
+ return NULL;
}
ctx = GNUNET_malloc (sizeof (struct GNUNET_ECRS_SearchContext));
ctx->start = GNUNET_get_time ();
@@ -588,10 +587,10 @@
ctx->aborted = GNUNET_NO;
ctx->lock = GNUNET_mutex_create (GNUNET_YES);
ctx->sctx = GNUNET_FS_create_search_context (ectx, cfg, ctx->lock);
- if (ctx->sctx == NULL)
+ if (ctx->sctx == NULL)
{
- GNUNET_mutex_destroy(ctx->lock);
- GNUNET_free(ctx);
+ GNUNET_mutex_destroy (ctx->lock);
+ GNUNET_free (ctx);
return NULL;
}
add_search_for_uri (uri, ctx);
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -88,12 +88,11 @@
* In URI-encoding, does the given character
* need to be encoded using %-encoding?
*/
-static int needs_percent(char c) {
- return (! ( (isalnum(c)) ||
- (c == '-') ||
- (c == '_') ||
- (c == '.') ||
- (c == '~') ) );
+static int
+needs_percent (char c)
+{
+ return (!((isalnum (c)) ||
+ (c == '-') || (c == '_') || (c == '.') || (c == '~')));
}
/**
@@ -109,7 +108,7 @@
unsigned int j;
unsigned int wpos;
size_t slen;
- const char * keyword;
+ const char *keyword;
n =
keywordCount + strlen (GNUNET_ECRS_URI_PREFIX) +
@@ -117,45 +116,43 @@
for (i = 0; i < keywordCount; i++)
{
keyword = keywords[i];
- slen = strlen(keyword);
+ slen = strlen (keyword);
n += slen;
for (j = 0; j < slen; j++)
- {
- if ( (j == 0) &&
- (keyword[j] == ' ') )
- {
- n--;
- continue; /* skip leading space */
- }
- if (needs_percent(keyword[j]))
- n += 2; /* will use %-encoding */
- }
+ {
+ if ((j == 0) && (keyword[j] == ' '))
+ {
+ n--;
+ continue; /* skip leading space */
+ }
+ if (needs_percent (keyword[j]))
+ n += 2; /* will use %-encoding */
+ }
}
ret = GNUNET_malloc (n);
strcpy (ret, GNUNET_ECRS_URI_PREFIX);
strcat (ret, GNUNET_ECRS_SEARCH_INFIX);
- wpos = strlen(ret);
+ wpos = strlen (ret);
for (i = 0; i < keywordCount; i++)
{
keyword = keywords[i];
- slen = strlen(keyword);
+ slen = strlen (keyword);
for (j = 0; j < slen; j++)
- {
- if ( (j == 0) &&
- (keyword[j] == ' ') )
- continue; /* skip leading space */
- if (needs_percent(keyword[j]))
- {
- sprintf(&ret[wpos], "%%%02X", keyword[j]);
- wpos += 3;
- }
- else
- {
- ret[wpos++] = keyword[j];
- }
- }
+ {
+ if ((j == 0) && (keyword[j] == ' '))
+ continue; /* skip leading space */
+ if (needs_percent (keyword[j]))
+ {
+ sprintf (&ret[wpos], "%%%02X", keyword[j]);
+ wpos += 3;
+ }
+ else
+ {
+ ret[wpos++] = keyword[j];
+ }
+ }
if (i != keywordCount - 1)
- ret[wpos++] = '+';
+ ret[wpos++] = '+';
}
return ret;
}
@@ -284,47 +281,48 @@
* if there is not a '+'.
*/
static char *
-percent_decode_keyword(const char * in) {
- char * out;
- char * ret;
- unsigned int rpos;
+percent_decode_keyword (const char *in)
+{
+ char *out;
+ char *ret;
+ unsigned int rpos;
unsigned int wpos;
unsigned int hx;
- out = GNUNET_strdup(in);
+ out = GNUNET_strdup (in);
rpos = 0;
wpos = 0;
while (out[rpos] != '\0')
{
if (out[rpos] == '%')
- {
- if (1 != sscanf(&out[rpos+1], "%2X", &hx))
- {
- GNUNET_free(out);
- return NULL;
- }
- rpos += 3;
- if (hx == '"')
- continue; /* skip double quote */
- out[wpos++] = (char) hx;
- }
+ {
+ if (1 != sscanf (&out[rpos + 1], "%2X", &hx))
+ {
+ GNUNET_free (out);
+ return NULL;
+ }
+ rpos += 3;
+ if (hx == '"')
+ continue; /* skip double quote */
+ out[wpos++] = (char) hx;
+ }
else
- {
- out[wpos++] = out[rpos++];
- }
+ {
+ out[wpos++] = out[rpos++];
+ }
}
if (out[0] == '+')
{
- ret = GNUNET_strdup(out);
+ ret = GNUNET_strdup (out);
}
else
{
/* need to prefix with space */
- ret = GNUNET_malloc(strlen(out)+2);
- strcpy(ret, " ");
- strcat(ret, out);
+ ret = GNUNET_malloc (strlen (out) + 2);
+ strcpy (ret, " ");
+ strcat (ret, out);
}
- GNUNET_free(out);
+ GNUNET_free (out);
return ret;
}
@@ -373,23 +371,21 @@
saw_quote = 0;
for (i = pos; i < slen; i++)
{
- if ( (uri[i] == '%') &&
- (&uri[i] == strstr(&uri[i], "%22")) )
- {
- saw_quote = (saw_quote + 1) % 2;
- i += 3;
- continue;
- }
- if ( (uri[i] == '+') &&
- (saw_quote == 0) )
+ if ((uri[i] == '%') && (&uri[i] == strstr (&uri[i], "%22")))
{
+ saw_quote = (saw_quote + 1) % 2;
+ i += 3;
+ continue;
+ }
+ if ((uri[i] == '+') && (saw_quote == 0))
+ {
ret++;
if (uri[i - 1] == '+')
return GNUNET_SYSERR; /* "++" not allowed */
}
}
if (saw_quote == 1)
- return GNUNET_SYSERR; /* quotes not balanced */
+ return GNUNET_SYSERR; /* quotes not balanced */
iret = ret;
dup = GNUNET_strdup (uri);
(*keywords) = GNUNET_malloc (ret * sizeof (char *));
@@ -397,19 +393,17 @@
(*keywords)[i] = NULL;
for (i = slen - 1; i >= pos; i--)
{
- if ( (uri[i] == '%') &&
- (&uri[i] == strstr(&uri[i], "%22")) )
- {
- saw_quote = (saw_quote + 1) % 2;
- i += 3;
- continue;
- }
- if ( (dup[i] == '+') &&
- (saw_quote == 0) )
+ if ((uri[i] == '%') && (&uri[i] == strstr (&uri[i], "%22")))
{
+ saw_quote = (saw_quote + 1) % 2;
+ i += 3;
+ continue;
+ }
+ if ((dup[i] == '+') && (saw_quote == 0))
+ {
(*keywords)[--ret] = percent_decode_keyword (&dup[i + 1]);
- if (NULL == (*keywords)[ret])
- goto CLEANUP;
+ if (NULL == (*keywords)[ret])
+ goto CLEANUP;
dup[i] = '\0';
}
}
@@ -419,12 +413,12 @@
GNUNET_GE_ASSERT (ectx, ret == 0);
GNUNET_free (dup);
return iret;
- CLEANUP:
+CLEANUP:
for (i = 0; i < ret; i++)
- GNUNET_free_non_null((*keywords)[i]);
- GNUNET_free(*keywords);
+ GNUNET_free_non_null ((*keywords)[i]);
+ GNUNET_free (*keywords);
*keywords = NULL;
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
/**
@@ -785,7 +779,7 @@
void *cls)
{
unsigned int i;
- char * keyword;
+ char *keyword;
if (uri->type != ksk)
return -1;
@@ -795,11 +789,9 @@
{
keyword = uri->data.ksk.keywords[i];
/* first character of keyword indicates
- if it is mandator or not */
- if (GNUNET_OK != iterator (&keyword[1],
- keyword[0] == '+',
- cls))
- return i;
+ if it is mandator or not */
+ if (GNUNET_OK != iterator (&keyword[1], keyword[0] == '+', cls))
+ return i;
}
return i;
}
@@ -939,8 +931,8 @@
int j;
int havePreview;
int add;
- const char * kword;
- char * nkword;
+ const char *kword;
+ char *nkword;
if (md == NULL)
return NULL;
@@ -990,12 +982,11 @@
if (add == 1)
{
GNUNET_GE_ASSERT (NULL, md->items[i].data != NULL);
- kword = md->items[i].data;
- nkword = GNUNET_malloc(strlen(kword)+2);
- strcpy(nkword, " "); /* not mandatory */
- strcat(nkword, kword);
- ret->data.ksk.keywords[i - havePreview]
- = nkword;
+ kword = md->items[i].data;
+ nkword = GNUNET_malloc (strlen (kword) + 2);
+ strcpy (nkword, " "); /* not mandatory */
+ strcat (nkword, kword);
+ ret->data.ksk.keywords[i - havePreview] = nkword;
}
}
}
Modified: GNUnet/src/applications/fs/fsui/deserialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/deserialize.c 2008-04-24 06:05:27 UTC
(rev 6749)
+++ GNUnet/src/applications/fs/fsui/deserialize.c 2008-04-24 06:10:06 UTC
(rev 6750)
@@ -31,19 +31,19 @@
#include "gnunet_directories.h"
#include "fsui.h"
-typedef struct {
+typedef struct
+{
int fd;
unsigned int have;
unsigned int size;
unsigned int pos;
- char * buffer;
+ char *buffer;
} ReadBuffer;
static int
-read_buffered(ReadBuffer * rb,
- void * d,
- unsigned int size) {
- char * dst = d;
+read_buffered (ReadBuffer * rb, void *d, unsigned int size)
+{
+ char *dst = d;
unsigned int min;
unsigned int pos;
int ret;
@@ -51,37 +51,35 @@
if (rb->fd == -1)
return -1;
pos = 0;
- do
+ do
{
/* first, use buffer */
min = rb->have - rb->pos;
- if (min > 0)
- {
- if (min > size)
- min = size;
- memcpy(&dst[pos],
- &rb->buffer[rb->pos],
- min);
- rb->pos += min;
- pos += min;
- }
+ if (min > 0)
+ {
+ if (min > size)
+ min = size;
+ memcpy (&dst[pos], &rb->buffer[rb->pos], min);
+ rb->pos += min;
+ pos += min;
+ }
if (pos == size)
- return pos; /* done! */
- GNUNET_GE_ASSERT(NULL, rb->have == rb->pos);
+ return pos; /* done! */
+ GNUNET_GE_ASSERT (NULL, rb->have == rb->pos);
/* fill buffer */
- ret = READ(rb->fd, rb->buffer, rb->size);
+ ret = READ (rb->fd, rb->buffer, rb->size);
if (ret == -1)
- {
- CLOSE(rb->fd);
- rb->fd = -1;
- return -1;
- }
+ {
+ CLOSE (rb->fd);
+ rb->fd = -1;
+ return -1;
+ }
if (ret == 0)
- return 0;
+ return 0;
rb->pos = 0;
rb->have = ret;
}
- while (pos < size); /* should always be true */
+ while (pos < size); /* should always be true */
return pos;
}
@@ -102,7 +100,8 @@
{
unsigned int big;
- if (sizeof (unsigned int) != read_buffered (rb, &big, sizeof (unsigned int)))
+ if (sizeof (unsigned int) !=
+ read_buffered (rb, &big, sizeof (unsigned int)))
return GNUNET_SYSERR;
*val = ntohl (big);
return GNUNET_OK;
@@ -294,7 +293,7 @@
memset (ret, 0, sizeof (GNUNET_FSUI_DownloadList));
ret->ctx = ctx;
if ((GNUNET_OK != read_int (rb, &soff)) ||
- (GNUNET_OK != read_int (rb, (int*) &ret->state)) ||
+ (GNUNET_OK != read_int (rb, (int *) &ret->state)) ||
(GNUNET_OK != read_int (rb, &ret->is_recursive)) ||
(GNUNET_OK != read_int (rb, &ret->is_directory)) ||
(GNUNET_OK != read_uint (rb, &ret->anonymityLevel)) ||
@@ -445,43 +444,42 @@
* that we are performing.
*/
struct SearchRecordList *
-read_search_record_list(struct GNUNET_GE_Context * ectx,
- ReadBuffer *rb)
+read_search_record_list (struct GNUNET_GE_Context *ectx, ReadBuffer * rb)
{
unsigned int is_required;
GNUNET_HashCode key;
- struct GNUNET_ECRS_URI * uri;
- struct SearchRecordList * ret;
- struct SearchRecordList * head;
- struct SearchRecordList * tail;
+ struct GNUNET_ECRS_URI *uri;
+ struct SearchRecordList *ret;
+ struct SearchRecordList *head;
+ struct SearchRecordList *tail;
ret = NULL;
head = NULL;
tail = NULL;
- while (1)
+ while (1)
{
- if (GNUNET_OK != read_uint(rb, &is_required))
- break;
+ if (GNUNET_OK != read_uint (rb, &is_required))
+ break;
if (is_required == -1)
- break; /* end of list marker */
- if (sizeof(GNUNET_HashCode)
- != read_buffered(rb, &key, sizeof(GNUNET_HashCode)))
- break;
- uri = read_uri(ectx, rb);
+ break; /* end of list marker */
+ if (sizeof (GNUNET_HashCode)
+ != read_buffered (rb, &key, sizeof (GNUNET_HashCode)))
+ break;
+ uri = read_uri (ectx, rb);
if (uri == NULL)
- break; /* error */
- ret = GNUNET_malloc(sizeof(struct SearchRecordList));
+ break; /* error */
+ ret = GNUNET_malloc (sizeof (struct SearchRecordList));
ret->key = key;
ret->uri = uri;
ret->search = NULL;
ret->is_required = is_required;
ret->next = NULL;
if (head == NULL)
- head = ret;
+ head = ret;
if (tail != NULL)
- tail->next = ret;
+ tail->next = ret;
tail = ret;
- }
+ }
return head;
}
@@ -493,40 +491,40 @@
* @param search_list list of ECRS search requests
*/
struct SearchResultList *
-read_result_list(struct GNUNET_GE_Context * ectx,
- ReadBuffer *rb,
- unsigned int search_count,
- struct SearchRecordList ** search_list)
+read_result_list (struct GNUNET_GE_Context *ectx,
+ ReadBuffer * rb,
+ unsigned int search_count,
+ struct SearchRecordList **search_list)
{
unsigned int matching;
unsigned int remaining;
unsigned int probeSucc;
unsigned int probeFail;
- struct SearchResultList * ret;
- struct SearchResultList * head;
- struct SearchResultList * tail;
+ struct SearchResultList *ret;
+ struct SearchResultList *head;
+ struct SearchResultList *tail;
unsigned int i;
unsigned int idx;
ret = NULL;
head = NULL;
tail = NULL;
- while (1)
- {
- if (GNUNET_OK != read_uint(rb, &matching))
- break;
+ while (1)
+ {
+ if (GNUNET_OK != read_uint (rb, &matching))
+ break;
if (matching == -1)
- break; /* end of list marker */
- if ( (GNUNET_OK != read_uint(rb, &remaining)) ||
- (GNUNET_OK != read_uint(rb, &probeSucc)) ||
- (GNUNET_OK != read_uint(rb, &probeFail)) )
- break;
- ret = GNUNET_malloc(sizeof(struct SearchResultList));
- if (GNUNET_OK != readFileInfo(ectx, rb, &ret->fi))
- {
- GNUNET_free(ret);
- break;
- }
+ break; /* end of list marker */
+ if ((GNUNET_OK != read_uint (rb, &remaining)) ||
+ (GNUNET_OK != read_uint (rb, &probeSucc)) ||
+ (GNUNET_OK != read_uint (rb, &probeFail)))
+ break;
+ ret = GNUNET_malloc (sizeof (struct SearchResultList));
+ if (GNUNET_OK != readFileInfo (ectx, rb, &ret->fi))
+ {
+ GNUNET_free (ret);
+ break;
+ }
ret->matchingSearchCount = matching;
ret->mandatoryMatchesRemaining = remaining;
ret->probeSuccess = probeSucc;
@@ -535,38 +533,34 @@
ret->next = NULL;
ret->matchingSearches = NULL;
i = 0;
- GNUNET_array_grow(ret->matchingSearches,
- i,
- ret->matchingSearchCount);
+ GNUNET_array_grow (ret->matchingSearches, i, ret->matchingSearchCount);
while (i-- > 0)
- {
- if ( (GNUNET_OK != read_uint(rb, &idx)) ||
- (idx > search_count) )
- {
- GNUNET_GE_BREAK(NULL, 0);
- GNUNET_array_grow(ret->matchingSearches,
- ret->matchingSearchCount,
- 0);
- GNUNET_free(ret);
- return head;
- }
- if (idx == 0)
- {
- GNUNET_GE_BREAK(NULL, 0);
- ret->matchingSearches[i] = NULL;
- }
- else
- {
- GNUNET_GE_BREAK(NULL, search_list[idx - 1] != NULL);
- ret->matchingSearches[i] = search_list[idx - 1];
- }
- }
+ {
+ if ((GNUNET_OK != read_uint (rb, &idx)) || (idx > search_count))
+ {
+ GNUNET_GE_BREAK (NULL, 0);
+ GNUNET_array_grow (ret->matchingSearches,
+ ret->matchingSearchCount, 0);
+ GNUNET_free (ret);
+ return head;
+ }
+ if (idx == 0)
+ {
+ GNUNET_GE_BREAK (NULL, 0);
+ ret->matchingSearches[i] = NULL;
+ }
+ else
+ {
+ GNUNET_GE_BREAK (NULL, search_list[idx - 1] != NULL);
+ ret->matchingSearches[i] = search_list[idx - 1];
+ }
+ }
if (head == NULL)
- head = ret;
+ head = ret;
if (tail != NULL)
- tail->next = ret;
+ tail->next = ret;
tail = ret;
- }
+ }
return head;
}
@@ -595,13 +589,13 @@
return GNUNET_OK;
list = GNUNET_malloc (sizeof (GNUNET_FSUI_SearchList));
memset (list, 0, sizeof (GNUNET_FSUI_SearchList));
- list->lock = GNUNET_mutex_create(GNUNET_NO);
+ list->lock = GNUNET_mutex_create (GNUNET_NO);
list->ctx = ctx;
if ((GNUNET_OK != read_int (rb, (int *) &list->state)) ||
(GNUNET_OK != read_long (rb, (long long *) &list->start_time)) ||
(GNUNET_OK != read_long (rb, (long long *) &stime)) ||
(GNUNET_OK != read_uint (rb, &list->anonymityLevel)) ||
- (GNUNET_OK != read_uint (rb, &list->mandatory_keyword_count)) )
+ (GNUNET_OK != read_uint (rb, &list->mandatory_keyword_count)))
{
GNUNET_GE_BREAK (NULL, 0);
break;
@@ -630,28 +624,28 @@
GNUNET_GE_BREAK (NULL, 0);
break;
}
- list->searches = read_search_record_list(ctx->ectx, rb);
+ list->searches = read_search_record_list (ctx->ectx, rb);
if (list->searches == NULL)
- goto ERR; /* can never be empty in practice */
+ goto ERR; /* can never be empty in practice */
srl = list->searches;
total_searches = 0;
while (srl != NULL)
- {
- total_searches++;
- srl = srl->next;
- }
- srla = GNUNET_malloc(total_searches * sizeof(struct SearchRecordList*));
+ {
+ total_searches++;
+ srl = srl->next;
+ }
+ srla =
+ GNUNET_malloc (total_searches * sizeof (struct SearchRecordList *));
srl = list->searches;
i = total_searches;
while (srl != NULL)
- {
- srla[--i] = srl;
- srl = srl->next;
- }
- list->resultsReceived = read_result_list(ctx->ectx, rb,
- total_searches,
- srla);
- GNUNET_free(srla);
+ {
+ srla[--i] = srl;
+ srl = srl->next;
+ }
+ list->resultsReceived = read_result_list (ctx->ectx, rb,
+ total_searches, srla);
+ GNUNET_free (srla);
list->next = NULL;
/* finally: append (!) to list */
@@ -673,19 +667,19 @@
{
srp = list->resultsReceived;
list->resultsReceived = srp->next;
- GNUNET_free(srp);
+ GNUNET_free (srp);
}
while (list->searches != NULL)
{
srl = list->searches;
- list->searches = srl->next;
+ list->searches = srl->next;
if (srl->uri != NULL)
- GNUNET_ECRS_uri_destroy(srl->uri);
- GNUNET_free(srl);
+ GNUNET_ECRS_uri_destroy (srl->uri);
+ GNUNET_free (srl);
}
if (list->uri != NULL)
GNUNET_ECRS_uri_destroy (list->uri);
- GNUNET_mutex_destroy(list->lock);
+ GNUNET_mutex_destroy (list->lock);
GNUNET_free (list);
return GNUNET_SYSERR;
}
@@ -702,7 +696,8 @@
static int
readUploadList (struct GNUNET_FSUI_Context *ctx,
struct GNUNET_FSUI_UploadList *parent,
- ReadBuffer * rb, struct GNUNET_FSUI_UploadShared *shared, int
top)
+ ReadBuffer * rb, struct GNUNET_FSUI_UploadShared *shared,
+ int top)
{
struct GNUNET_FSUI_UploadList *list;
struct GNUNET_FSUI_UploadList l;
@@ -910,7 +905,7 @@
rb.pos = 0;
rb.size = 64 * 1024;
rb.have = 0;
- rb.buffer = GNUNET_malloc(rb.size);
+ rb.buffer = GNUNET_malloc (rb.size);
if ((GNUNET_OK != checkMagic (&rb)) ||
(GNUNET_OK != readCollection (&rb, ctx)) ||
(GNUNET_OK != readSearches (&rb, ctx)) ||
@@ -927,7 +922,7 @@
}
CLOSE (rb.fd);
UNLINK (ctx->name);
- GNUNET_free(rb.buffer);
+ GNUNET_free (rb.buffer);
}
/* end of deserialize.c */
Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c 2008-04-24 06:05:27 UTC
(rev 6749)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c 2008-04-24 06:10:06 UTC
(rev 6750)
@@ -249,7 +249,9 @@
GNUNET_disk_file_write (ectx, fn, buf, FILESIZE, "600");
GNUNET_free (buf);
meta = GNUNET_ECRS_meta_data_create ();
- kuri = GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2, (const char **)
keywords);
+ kuri =
+ GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2,
+ (const char **) keywords);
waitForEvent = GNUNET_FSUI_upload_completed;
upload = GNUNET_FSUI_upload_start (ctx,
fn,
@@ -272,8 +274,7 @@
break;
}
GNUNET_FSUI_upload_stop (ctx, upload);
- GNUNET_snprintf (keyword, 40, "+%s +%s", keywords[0],
- keywords[1]);
+ GNUNET_snprintf (keyword, 40, "+%s +%s", keywords[0], keywords[1]);
uri = GNUNET_ECRS_keyword_string_to_uri (ectx, keyword);
waitForEvent = GNUNET_FSUI_download_completed;
search = GNUNET_FSUI_search_start (ctx, 0, uri);
Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/fsui/fsui.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -196,11 +196,11 @@
GNUNET_FSUI_Context *ret;
GNUNET_FSUI_SearchList *list;
GNUNET_FSUI_UnindexList *xlist;
- struct SearchResultList * pos;
- struct SearchRecordList * rec;
+ struct SearchResultList *pos;
+ struct SearchRecordList *rec;
unsigned int valid;
unsigned int i;
- GNUNET_ECRS_FileInfo * fis;
+ GNUNET_ECRS_FileInfo *fis;
char *fn;
char *gh;
unsigned long long size;
@@ -265,24 +265,24 @@
valid = 0;
pos = list->resultsReceived;
while (pos != NULL)
- {
- if (pos->mandatoryMatchesRemaining == 0)
- valid++;
- pos = pos->next;
- }
+ {
+ if (pos->mandatoryMatchesRemaining == 0)
+ valid++;
+ pos = pos->next;
+ }
fis = NULL;
if (valid > 0)
- {
- fis = GNUNET_malloc(sizeof(GNUNET_ECRS_FileInfo) * valid);
- pos = list->resultsReceived;
- i = 0;
- while (pos != NULL)
- {
- if (pos->mandatoryMatchesRemaining == 0)
- fis[i++] = pos->fi;
- pos = pos->next;
- }
- }
+ {
+ fis = GNUNET_malloc (sizeof (GNUNET_ECRS_FileInfo) * valid);
+ pos = list->resultsReceived;
+ i = 0;
+ while (pos != NULL)
+ {
+ if (pos->mandatoryMatchesRemaining == 0)
+ fis[i++] = pos->fi;
+ pos = pos->next;
+ }
+ }
event.type = GNUNET_FSUI_search_resumed;
event.data.SearchResumed.sc.pos = list;
event.data.SearchResumed.sc.cctx = NULL;
@@ -292,7 +292,7 @@
event.data.SearchResumed.searchURI = list->uri;
event.data.SearchResumed.state = list->state;
list->cctx = cb (closure, &event);
- GNUNET_free_non_null(fis);
+ GNUNET_free_non_null (fis);
list = list->next;
}
/* 2c) signal upload restarts */
@@ -349,39 +349,39 @@
if (list->state == GNUNET_FSUI_PENDING)
{
list->state = GNUNET_FSUI_ACTIVE;
- rec = list->searches;
- while (rec != NULL)
- {
- rec->search = GNUNET_ECRS_search_start (list->ctx->ectx,
- list->ctx->cfg,
- rec->uri,
- list->anonymityLevel,
-
&GNUNET_FSUI_search_progress_callback,
- list);
- if (rec->search == NULL)
- {
- GNUNET_GE_LOG (ectx,
- GNUNET_GE_FATAL | GNUNET_GE_ADMIN |
- GNUNET_GE_IMMEDIATE,
- "Failed to resume search\n");
- list->state = GNUNET_FSUI_PENDING;
- }
- rec = rec->next;
- }
- if (list->state != GNUNET_FSUI_ACTIVE)
- {
- /* stop searches, we failed... */
- rec = list->searches;
- while (rec != NULL)
- {
- if (rec->search != NULL)
- {
- GNUNET_ECRS_search_stop(rec->search);
- rec->search = NULL;
- }
- rec = rec->next;
- }
- }
+ rec = list->searches;
+ while (rec != NULL)
+ {
+ rec->search = GNUNET_ECRS_search_start (list->ctx->ectx,
+ list->ctx->cfg,
+ rec->uri,
+ list->anonymityLevel,
+
&GNUNET_FSUI_search_progress_callback,
+ list);
+ if (rec->search == NULL)
+ {
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_FATAL | GNUNET_GE_ADMIN |
+ GNUNET_GE_IMMEDIATE,
+ "Failed to resume search\n");
+ list->state = GNUNET_FSUI_PENDING;
+ }
+ rec = rec->next;
+ }
+ if (list->state != GNUNET_FSUI_ACTIVE)
+ {
+ /* stop searches, we failed... */
+ rec = list->searches;
+ while (rec != NULL)
+ {
+ if (rec->search != NULL)
+ {
+ GNUNET_ECRS_search_stop (rec->search);
+ rec->search = NULL;
+ }
+ rec = rec->next;
+ }
+ }
}
list = list->next;
}
@@ -510,8 +510,8 @@
GNUNET_FSUI_DownloadList *dpos;
GNUNET_FSUI_UnindexList *xpos;
GNUNET_FSUI_UploadList *upos;
- struct SearchRecordList * rec;
- struct SearchResultList * res;
+ struct SearchRecordList *rec;
+ struct SearchResultList *res;
GNUNET_FSUI_Event event;
void *unused;
@@ -546,23 +546,23 @@
{
if (spos->state == GNUNET_FSUI_ACTIVE)
spos->state = GNUNET_FSUI_PENDING;
- rec = spos->searches;
- while (rec != NULL)
- {
- GNUNET_ECRS_search_stop (rec->search);
- rec->search = NULL;
- rec = rec->next;
- }
- res = spos->resultsReceived;
- while (res != NULL)
- {
- if (res->test_download != NULL)
- {
- GNUNET_ECRS_file_download_partial_stop(res->test_download);
- res->test_download = NULL;
- }
- res = res->next;
- }
+ rec = spos->searches;
+ while (rec != NULL)
+ {
+ GNUNET_ECRS_search_stop (rec->search);
+ rec->search = NULL;
+ rec = rec->next;
+ }
+ res = spos->resultsReceived;
+ while (res != NULL)
+ {
+ if (res->test_download != NULL)
+ {
+ GNUNET_ECRS_file_download_partial_stop (res->test_download);
+ res->test_download = NULL;
+ }
+ res = res->next;
+ }
if (spos->state != GNUNET_FSUI_PENDING)
spos->state++; /* _JOINED */
}
@@ -645,21 +645,21 @@
ctx->activeSearches = spos->next;
GNUNET_ECRS_uri_destroy (spos->uri);
while (spos->searches != NULL)
- {
- rec = spos->searches;
- spos->searches = rec->next;
- GNUNET_ECRS_uri_destroy(rec->uri);
- GNUNET_free(rec);
- }
+ {
+ rec = spos->searches;
+ spos->searches = rec->next;
+ GNUNET_ECRS_uri_destroy (rec->uri);
+ GNUNET_free (rec);
+ }
while (spos->resultsReceived != NULL)
- {
- res = spos->resultsReceived;
- spos->resultsReceived = res->next;
+ {
+ res = spos->resultsReceived;
+ spos->resultsReceived = res->next;
GNUNET_ECRS_meta_data_destroy (res->fi.meta);
GNUNET_ECRS_uri_destroy (res->fi.uri);
- GNUNET_free(res->matchingSearches);
- GNUNET_free(res);
- }
+ GNUNET_free (res->matchingSearches);
+ GNUNET_free (res);
+ }
GNUNET_free (spos);
}
/* 4b) free unindex memory */
Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/fsui/fsui.h 2008-04-24 06:10:06 UTC (rev
6750)
@@ -36,7 +36,7 @@
struct SearchResultList
{
- struct SearchResultList * next;
+ struct SearchResultList *next;
/**
* Test download (if any).
@@ -48,7 +48,7 @@
* (do NOT free the search records that this array
* points to when freeing this result!).
*/
- struct SearchRecordList ** matchingSearches;
+ struct SearchRecordList **matchingSearches;
/**
* What info do we have about this result?
@@ -86,13 +86,13 @@
*/
struct SearchRecordList
{
-
- struct SearchRecordList * next;
+ struct SearchRecordList *next;
+
/**
* Handles to the ECRS SearchContexts.
*/
- struct GNUNET_ECRS_SearchContext * search;
+ struct GNUNET_ECRS_SearchContext *search;
/**
* Which keyword are we searching? (this is
@@ -128,8 +128,8 @@
/**
* Lock for the search.
- */
- struct GNUNET_Mutex * lock;
+ */
+ struct GNUNET_Mutex *lock;
/**
* Searches are kept in a simple linked list.
@@ -144,7 +144,7 @@
/**
* Handles to the ECRS SearchContexts.
*/
- struct SearchRecordList * searches;
+ struct SearchRecordList *searches;
/**
* Which URI are we searching?
Modified: GNUnet/src/applications/fs/fsui/fsuitest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsuitest.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/fsui/fsuitest.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -149,7 +149,9 @@
filename,
"foo bar test!", strlen ("foo bar test!"), "600");
meta = GNUNET_ECRS_meta_data_create ();
- kuri = GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2, (const char **)
keywords);
+ kuri =
+ GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2,
+ (const char **) keywords);
upload = GNUNET_FSUI_upload_start (ctx, filename,
(GNUNET_FSUI_DirectoryScanCallback) & GNUNET_disk_directory_scan, NULL, 0, /*
anonymity */
0, /* priority */
GNUNET_YES,
Modified: GNUnet/src/applications/fs/fsui/recursivetest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/recursivetest.c 2008-04-24 06:05:27 UTC
(rev 6749)
+++ GNUnet/src/applications/fs/fsui/recursivetest.c 2008-04-24 06:10:06 UTC
(rev 6750)
@@ -46,7 +46,8 @@
{
char *fn;
- fn = GNUNET_malloc (strlen ("/tmp/gnunet-fsui-recursivetest/FSUITEST") + 15);
+ fn =
+ GNUNET_malloc (strlen ("/tmp/gnunet-fsui-recursivetest/FSUITEST") + 15);
GNUNET_snprintf (fn,
strlen ("/tmp/gnunet-fsui-recursivetest/FSUITEST") + 15,
"/tmp/gnunet-fsui-recursivetest/FSUITEST%u/", i);
@@ -65,55 +66,54 @@
done = 0;
while (!done && tree[index] != '\0')
{
- s = GNUNET_malloc (strlen(current)+strlen(DIR_SEPARATOR_STR)+14);
- GNUNET_snprintf (s, strlen(current)+strlen(DIR_SEPARATOR_STR)+14,
- "%s%s%u",
- current, DIR_SEPARATOR_STR, fi);
- switch (tree[index++])
- {
- case 'd':
- if (check)
- {
- if (GNUNET_disk_directory_test (NULL, s) == GNUNET_NO)
- {
- index = -1;
- done = 1;
- }
- }
- else
- {
- GNUNET_disk_directory_create (NULL, s);
- }
- if (!done)
- index = makeHierarchyHelper (s, tree, index, check);
- break;
- case 'f':
- if (check)
- {
- /* TODO: compare file contents */
- if (GNUNET_disk_directory_test (NULL, s) != GNUNET_NO)
- {
- index = -1;
- done = 1;
- }
- }
- else
- {
- buf = GNUNET_malloc (FILESIZE);
- for (i = 0; i < FILESIZE; i++)
- buf[i] = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 256);
- GNUNET_disk_file_write (ectx, s, buf, FILESIZE, "600");
- GNUNET_free (buf);
- }
- break;
- case '.':
- done = 1;
- break;
- default:
- break;
- }
- GNUNET_free (s);
- fi++;
+ s = GNUNET_malloc (strlen (current) + strlen (DIR_SEPARATOR_STR) + 14);
+ GNUNET_snprintf (s, strlen (current) + strlen (DIR_SEPARATOR_STR) + 14,
+ "%s%s%u", current, DIR_SEPARATOR_STR, fi);
+ switch (tree[index++])
+ {
+ case 'd':
+ if (check)
+ {
+ if (GNUNET_disk_directory_test (NULL, s) == GNUNET_NO)
+ {
+ index = -1;
+ done = 1;
+ }
+ }
+ else
+ {
+ GNUNET_disk_directory_create (NULL, s);
+ }
+ if (!done)
+ index = makeHierarchyHelper (s, tree, index, check);
+ break;
+ case 'f':
+ if (check)
+ {
+ /* TODO: compare file contents */
+ if (GNUNET_disk_directory_test (NULL, s) != GNUNET_NO)
+ {
+ index = -1;
+ done = 1;
+ }
+ }
+ else
+ {
+ buf = GNUNET_malloc (FILESIZE);
+ for (i = 0; i < FILESIZE; i++)
+ buf[i] = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 256);
+ GNUNET_disk_file_write (ectx, s, buf, FILESIZE, "600");
+ GNUNET_free (buf);
+ }
+ break;
+ case '.':
+ done = 1;
+ break;
+ default:
+ break;
+ }
+ GNUNET_free (s);
+ fi++;
}
return index;
}
@@ -123,7 +123,7 @@
{
char *fn;
- fn = makeName(i);
+ fn = makeName (i);
makeHierarchyHelper (fn, tree, 0, 0);
return fn;
}
@@ -134,12 +134,12 @@
char *fn;
int res;
- fn = makeName(i);
+ fn = makeName (i);
if (GNUNET_disk_directory_test (NULL, fn) != GNUNET_YES)
return GNUNET_SYSERR;
res = ((makeHierarchyHelper (fn, tree, 0, 1) == -1) ?
GNUNET_SYSERR : GNUNET_OK);
- GNUNET_free(fn);
+ GNUNET_free (fn);
return res;
}
@@ -222,8 +222,8 @@
#if DEBUG_VERBOSE
printf ("Download complete.\n");
#endif
- if (checkHierarchy(43, DIRECTORY_TREE_SPEC) == GNUNET_OK)
- search_done = 1;
+ if (checkHierarchy (43, DIRECTORY_TREE_SPEC) == GNUNET_OK)
+ search_done = 1;
break;
case GNUNET_FSUI_download_progress:
#if DEBUG_VERBOSE > 1
@@ -322,9 +322,11 @@
cfg, "fsuirecursivetest", 32, GNUNET_YES,
&eventCallback, NULL);
CHECK (ctx != NULL);
- fn = makeHierarchy(42, DIRECTORY_TREE_SPEC);
+ fn = makeHierarchy (42, DIRECTORY_TREE_SPEC);
meta = GNUNET_ECRS_meta_data_create ();
- kuri = GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2, (const char **)
keywords);
+ kuri =
+ GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2,
+ (const char **) keywords);
waitForEvent = GNUNET_FSUI_upload_completed;
upload = GNUNET_FSUI_upload_start (ctx,
fn,
@@ -347,14 +349,13 @@
break;
}
GNUNET_FSUI_upload_stop (ctx, upload);
- GNUNET_snprintf (keyword, 40, "+%s +%s", keywords[0],
- keywords[1]);
+ GNUNET_snprintf (keyword, 40, "+%s +%s", keywords[0], keywords[1]);
uri = GNUNET_ECRS_keyword_string_to_uri (ectx, keyword);
waitForEvent = GNUNET_FSUI_download_completed;
search = GNUNET_FSUI_search_start (ctx, 0, uri);
CHECK (search != NULL);
prog = 0;
- while (! search_done)
+ while (!search_done)
{
prog++;
CHECK (prog < 1000);
Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/fsui/search.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -38,14 +38,17 @@
#define DEBUG_SEARCH GNUNET_NO
-void bug() {}
+void
+bug ()
+{
+}
/**
* Pass the result to the client and note it as shown.
*/
static void
-processResult (struct GNUNET_FSUI_SearchList * ctx,
- struct SearchResultList * pos)
+processResult (struct GNUNET_FSUI_SearchList *ctx,
+ struct SearchResultList *pos)
{
GNUNET_FSUI_Event event;
@@ -66,15 +69,14 @@
*/
int
GNUNET_FSUI_search_progress_callback (const GNUNET_ECRS_FileInfo * fi,
- const GNUNET_HashCode * key,
- int isRoot,
- void *cls)
+ const GNUNET_HashCode * key,
+ int isRoot, void *cls)
{
GNUNET_FSUI_SearchList *pos = cls;
unsigned int i;
struct GNUNET_GE_Context *ectx;
- struct SearchResultList * srl;
- struct SearchRecordList * rec;
+ struct SearchResultList *srl;
+ struct SearchRecordList *rec;
ectx = pos->ctx->ectx;
GNUNET_URITRACK_track (ectx, pos->ctx->cfg, fi);
@@ -89,96 +91,87 @@
srl = pos->resultsReceived;
while (srl != NULL)
{
- if (GNUNET_ECRS_uri_test_equal (fi->uri,
- srl->fi.uri))
- {
- for (i=0;i<srl->matchingSearchCount;i++)
- {
- if ( (GNUNET_ECRS_uri_test_sks(pos->uri)) ||
- (0 == memcmp(key,
- &srl->matchingSearches[i]->key,
- sizeof(GNUNET_HashCode))) )
- {
+ if (GNUNET_ECRS_uri_test_equal (fi->uri, srl->fi.uri))
+ {
+ for (i = 0; i < srl->matchingSearchCount; i++)
+ {
+ if ((GNUNET_ECRS_uri_test_sks (pos->uri)) ||
+ (0 == memcmp (key,
+ &srl->matchingSearches[i]->key,
+ sizeof (GNUNET_HashCode))))
+ {
#if DEBUG_SEARCH
- GNUNET_GE_LOG (ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
GNUNET_GE_USER,
- "Received search result that I have seen
before.\n");
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
+ GNUNET_GE_USER,
+ "Received search result that I have seen
before.\n");
#endif
- GNUNET_mutex_unlock (pos->lock);
- return GNUNET_OK; /* seen before */
- }
- }
- /* not seen before, find corresponding search! */
- rec = pos->searches;
- while ( (rec != NULL) &&
- (0 != memcmp(key,
- &rec->key,
- sizeof(GNUNET_HashCode))) )
- rec = rec->next;
- if (rec == NULL)
- {
- GNUNET_GE_BREAK(NULL, 0);
- GNUNET_mutex_unlock (pos->lock);
- return GNUNET_OK; /* should have matching search */
- }
- GNUNET_array_append(srl->matchingSearches,
- srl->matchingSearchCount,
- rec);
- if (rec->is_required)
- {
- if (srl->mandatoryMatchesRemaining > 0)
- srl->mandatoryMatchesRemaining--;
- else
- {
- bug();
- GNUNET_GE_BREAK(NULL, 0);
- }
- }
- if (srl->mandatoryMatchesRemaining == 0)
- processResult(pos, srl);
- GNUNET_mutex_unlock (pos->lock);
- return GNUNET_OK;
- }
+ GNUNET_mutex_unlock (pos->lock);
+ return GNUNET_OK; /* seen before */
+ }
+ }
+ /* not seen before, find corresponding search! */
+ rec = pos->searches;
+ while ((rec != NULL) &&
+ (0 != memcmp (key, &rec->key, sizeof (GNUNET_HashCode))))
+ rec = rec->next;
+ if (rec == NULL)
+ {
+ GNUNET_GE_BREAK (NULL, 0);
+ GNUNET_mutex_unlock (pos->lock);
+ return GNUNET_OK; /* should have matching search */
+ }
+ GNUNET_array_append (srl->matchingSearches,
+ srl->matchingSearchCount, rec);
+ if (rec->is_required)
+ {
+ if (srl->mandatoryMatchesRemaining > 0)
+ srl->mandatoryMatchesRemaining--;
+ else
+ {
+ bug ();
+ GNUNET_GE_BREAK (NULL, 0);
+ }
+ }
+ if (srl->mandatoryMatchesRemaining == 0)
+ processResult (pos, srl);
+ GNUNET_mutex_unlock (pos->lock);
+ return GNUNET_OK;
+ }
srl = srl->next;
}
/* new result */
rec = pos->searches;
- while ( (rec != NULL) &&
- (! GNUNET_ECRS_uri_test_sks(pos->uri)) &&
- (0 != memcmp(key,
- &rec->key,
- sizeof(GNUNET_HashCode))) )
+ while ((rec != NULL) &&
+ (!GNUNET_ECRS_uri_test_sks (pos->uri)) &&
+ (0 != memcmp (key, &rec->key, sizeof (GNUNET_HashCode))))
rec = rec->next;
if (rec == NULL)
{
- GNUNET_GE_BREAK(NULL, 0);
+ GNUNET_GE_BREAK (NULL, 0);
GNUNET_mutex_unlock (pos->lock);
- return GNUNET_OK; /* should have matching search */
+ return GNUNET_OK; /* should have matching search */
}
- srl = GNUNET_malloc(sizeof(struct SearchResultList));
- memset(srl,
- 0,
- sizeof(struct SearchResultList));
- GNUNET_array_append(srl->matchingSearches,
- srl->matchingSearchCount,
- rec);
+ srl = GNUNET_malloc (sizeof (struct SearchResultList));
+ memset (srl, 0, sizeof (struct SearchResultList));
+ GNUNET_array_append (srl->matchingSearches, srl->matchingSearchCount, rec);
srl->fi.meta = GNUNET_ECRS_meta_data_duplicate (fi->meta);
srl->fi.uri = GNUNET_ECRS_uri_duplicate (fi->uri);
srl->mandatoryMatchesRemaining = pos->mandatory_keyword_count;
if (rec->is_required)
{
if (srl->mandatoryMatchesRemaining > 0)
- srl->mandatoryMatchesRemaining--;
+ srl->mandatoryMatchesRemaining--;
else
- {
- bug();
- GNUNET_GE_BREAK(NULL, 0);
- }
- }
+ {
+ bug ();
+ GNUNET_GE_BREAK (NULL, 0);
+ }
+ }
srl->next = pos->resultsReceived;
pos->resultsReceived = srl;
if (srl->mandatoryMatchesRemaining == 0)
- processResult(pos, srl);
+ processResult (pos, srl);
GNUNET_mutex_unlock (pos->lock);
return GNUNET_OK;
}
@@ -190,39 +183,33 @@
* @param closure our GNUNET_FSUI_SearchList.
*/
static int
-create_ecrs_search(const char * keyword,
- int is_mandatory,
- void * closure)
+create_ecrs_search (const char *keyword, int is_mandatory, void *closure)
{
- struct GNUNET_FSUI_SearchList * pos = closure;
- struct SearchRecordList * srl;
+ struct GNUNET_FSUI_SearchList *pos = closure;
+ struct SearchRecordList *srl;
- srl = GNUNET_malloc(sizeof(struct SearchRecordList));
- memset(srl, 0, sizeof(struct SearchRecordList));
- srl->uri = GNUNET_ECRS_keyword_command_line_to_uri(pos->ctx->ectx,
- 1,
- &keyword);
- GNUNET_hash(keyword,
- strlen(keyword),
- &srl->key);
+ srl = GNUNET_malloc (sizeof (struct SearchRecordList));
+ memset (srl, 0, sizeof (struct SearchRecordList));
+ srl->uri = GNUNET_ECRS_keyword_command_line_to_uri (pos->ctx->ectx,
+ 1, &keyword);
+ GNUNET_hash (keyword, strlen (keyword), &srl->key);
srl->is_required = is_mandatory;
if (is_mandatory)
pos->mandatory_keyword_count++;
srl->next = pos->searches;
pos->searches = srl;
- srl->search =
+ srl->search =
GNUNET_ECRS_search_start (pos->ctx->ectx,
- pos->ctx->cfg,
- srl->uri,
- pos->anonymityLevel,
- &GNUNET_FSUI_search_progress_callback,
- pos);
+ pos->ctx->cfg,
+ srl->uri,
+ pos->anonymityLevel,
+ &GNUNET_FSUI_search_progress_callback, pos);
if (srl->search == NULL)
{
- GNUNET_ECRS_uri_destroy(srl->uri);
+ GNUNET_ECRS_uri_destroy (srl->uri);
pos->searches = srl->next;
- GNUNET_free(srl);
- pos->start_time = 0; /* flag to indicate error */
+ GNUNET_free (srl);
+ pos->start_time = 0; /* flag to indicate error */
return GNUNET_SYSERR;
}
return GNUNET_OK;
@@ -239,72 +226,67 @@
GNUNET_FSUI_SearchList *pos;
struct GNUNET_GE_Context *ectx;
GNUNET_FSUI_Event event;
- struct SearchRecordList * srl;
+ struct SearchRecordList *srl;
- if (! (GNUNET_ECRS_uri_test_ksk(uri) ||
- GNUNET_ECRS_uri_test_sks(uri) ) )
+ if (!(GNUNET_ECRS_uri_test_ksk (uri) || GNUNET_ECRS_uri_test_sks (uri)))
{
- GNUNET_GE_BREAK(NULL, 0);
+ GNUNET_GE_BREAK (NULL, 0);
return NULL;
- }
+ }
ectx = ctx->ectx;
pos = GNUNET_malloc (sizeof (GNUNET_FSUI_SearchList));
- memset(pos,
- 0,
- sizeof (GNUNET_FSUI_SearchList));
+ memset (pos, 0, sizeof (GNUNET_FSUI_SearchList));
pos->state = GNUNET_FSUI_ACTIVE;
pos->anonymityLevel = anonymityLevel;
pos->ctx = ctx;
pos->start_time = GNUNET_get_time ();
pos->uri = GNUNET_ECRS_uri_duplicate (uri);
- pos->lock = GNUNET_mutex_create(GNUNET_NO);
+ pos->lock = GNUNET_mutex_create (GNUNET_NO);
event.type = GNUNET_FSUI_search_started;
event.data.SearchStarted.sc.pos = pos;
event.data.SearchStarted.sc.cctx = NULL;
event.data.SearchStarted.searchURI = pos->uri;
event.data.SearchStarted.anonymityLevel = pos->anonymityLevel;
pos->cctx = pos->ctx->ecb (pos->ctx->ecbClosure, &event);
- GNUNET_mutex_lock(pos->lock);
- if (GNUNET_ECRS_uri_test_ksk(uri))
+ GNUNET_mutex_lock (pos->lock);
+ if (GNUNET_ECRS_uri_test_ksk (uri))
{
/* (possibly boolean) keyword search */
- GNUNET_ECRS_uri_get_keywords_from_ksk(uri,
- &create_ecrs_search,
- pos);
+ GNUNET_ECRS_uri_get_keywords_from_ksk (uri, &create_ecrs_search, pos);
if (pos->start_time == 0)
- {
- /* failed to start ECRS searches */
- while (pos->searches != NULL)
- {
- srl = pos->searches;
- pos->searches = srl->next;
- GNUNET_ECRS_search_stop(srl->search);
- GNUNET_ECRS_uri_destroy (srl->uri);
- GNUNET_free(srl);
- }
- }
+ {
+ /* failed to start ECRS searches */
+ while (pos->searches != NULL)
+ {
+ srl = pos->searches;
+ pos->searches = srl->next;
+ GNUNET_ECRS_search_stop (srl->search);
+ GNUNET_ECRS_uri_destroy (srl->uri);
+ GNUNET_free (srl);
+ }
+ }
}
else
{
/* Namespace search, only one ECRS search */
- srl = GNUNET_malloc(sizeof(struct SearchRecordList));
- memset(srl, 0, sizeof(struct SearchRecordList));
+ srl = GNUNET_malloc (sizeof (struct SearchRecordList));
+ memset (srl, 0, sizeof (struct SearchRecordList));
srl->uri = GNUNET_ECRS_uri_duplicate (uri);
srl->search = GNUNET_ECRS_search_start (pos->ctx->ectx,
- pos->ctx->cfg,
- pos->uri,
- pos->anonymityLevel,
-
&GNUNET_FSUI_search_progress_callback,
- pos);
+ pos->ctx->cfg,
+ pos->uri,
+ pos->anonymityLevel,
+
&GNUNET_FSUI_search_progress_callback,
+ pos);
if (srl->search == NULL)
- {
- GNUNET_ECRS_uri_destroy (srl->uri);
- GNUNET_free (srl);
- }
+ {
+ GNUNET_ECRS_uri_destroy (srl->uri);
+ GNUNET_free (srl);
+ }
else
- {
- pos->searches = srl;
- }
+ {
+ pos->searches = srl;
+ }
}
if (pos->searches == NULL)
{
@@ -312,14 +294,14 @@
event.type = GNUNET_FSUI_search_stopped;
event.data.SearchStopped.sc.pos = pos;
event.data.SearchStopped.sc.cctx = NULL;
- pos->cctx = pos->ctx->ecb (pos->ctx->ecbClosure, &event);
+ pos->cctx = pos->ctx->ecb (pos->ctx->ecbClosure, &event);
GNUNET_ECRS_uri_destroy (pos->uri);
- GNUNET_mutex_unlock(pos->lock);
- GNUNET_mutex_destroy(pos->lock);
+ GNUNET_mutex_unlock (pos->lock);
+ GNUNET_mutex_destroy (pos->lock);
GNUNET_free (pos);
return NULL;
- }
- GNUNET_mutex_unlock(pos->lock);
+ }
+ GNUNET_mutex_unlock (pos->lock);
/* success, add to FSUI state */
GNUNET_mutex_lock (ctx->lock);
pos->next = ctx->activeSearches;
@@ -335,8 +317,8 @@
GNUNET_FSUI_search_abort (struct GNUNET_FSUI_SearchList *sl)
{
GNUNET_FSUI_Event event;
- struct SearchRecordList * rec;
- struct SearchResultList * srl;
+ struct SearchRecordList *rec;
+ struct SearchResultList *srl;
struct GNUNET_FSUI_Context *ctx;
ctx = sl->ctx;
@@ -359,24 +341,22 @@
{
rec = sl->searches;
sl->searches = rec->next;
- GNUNET_ECRS_search_stop(rec->search);
+ GNUNET_ECRS_search_stop (rec->search);
GNUNET_ECRS_uri_destroy (rec->uri);
- GNUNET_free(rec);
+ GNUNET_free (rec);
}
/* clean up a bit more: we don't need matchingSearches
- anymore, and the pointers are now invalid! */
+ anymore, and the pointers are now invalid! */
GNUNET_mutex_lock (ctx->lock);
srl = sl->resultsReceived;
while (srl != NULL)
{
- GNUNET_array_grow(srl->matchingSearches,
- srl->matchingSearchCount,
- 0);
+ GNUNET_array_grow (srl->matchingSearches, srl->matchingSearchCount, 0);
if (srl->test_download != NULL)
- {
- GNUNET_ECRS_file_download_partial_stop(srl->test_download);
- srl->test_download = NULL;
- }
+ {
+ GNUNET_ECRS_file_download_partial_stop (srl->test_download);
+ srl->test_download = NULL;
+ }
srl = srl->next;
}
event.type = GNUNET_FSUI_search_aborted;
@@ -394,8 +374,8 @@
GNUNET_FSUI_search_pause (struct GNUNET_FSUI_SearchList *sl)
{
GNUNET_FSUI_Event event;
- struct SearchRecordList * rec;
- struct SearchResultList * srl;
+ struct SearchRecordList *rec;
+ struct SearchResultList *srl;
struct GNUNET_FSUI_Context *ctx;
ctx = sl->ctx;
@@ -412,7 +392,7 @@
while (rec != NULL)
{
if (rec->search != NULL)
- GNUNET_ECRS_search_stop(rec->search);
+ GNUNET_ECRS_search_stop (rec->search);
rec->search = NULL;
rec = rec->next;
}
@@ -421,10 +401,10 @@
while (srl != NULL)
{
if (srl->test_download != NULL)
- {
- GNUNET_ECRS_file_download_partial_stop(srl->test_download);
- srl->test_download = NULL;
- }
+ {
+ GNUNET_ECRS_file_download_partial_stop (srl->test_download);
+ srl->test_download = NULL;
+ }
srl = srl->next;
}
event.type = GNUNET_FSUI_search_paused;
@@ -442,7 +422,7 @@
GNUNET_FSUI_search_restart (struct GNUNET_FSUI_SearchList *pos)
{
GNUNET_FSUI_Event event;
- struct SearchRecordList * rec;
+ struct SearchRecordList *rec;
struct GNUNET_FSUI_Context *ctx;
ctx = pos->ctx;
@@ -456,19 +436,19 @@
while (rec != NULL)
{
rec->search = GNUNET_ECRS_search_start (pos->ctx->ectx,
- pos->ctx->cfg,
- rec->uri,
- pos->anonymityLevel,
-
&GNUNET_FSUI_search_progress_callback,
- pos);
+ pos->ctx->cfg,
+ rec->uri,
+ pos->anonymityLevel,
+
&GNUNET_FSUI_search_progress_callback,
+ pos);
if (rec->search == NULL)
- break;
+ break;
rec = rec->next;
}
if (rec != NULL)
{
/* failed to restart, auto-pause again */
- GNUNET_FSUI_search_pause(pos);
+ GNUNET_FSUI_search_pause (pos);
GNUNET_mutex_unlock (ctx->lock);
return GNUNET_SYSERR;
}
@@ -486,8 +466,8 @@
GNUNET_FSUI_SearchList *pos;
GNUNET_FSUI_SearchList *prev;
int i;
- struct SearchRecordList * rec;
- struct SearchResultList * srl;
+ struct SearchRecordList *rec;
+ struct SearchResultList *srl;
struct GNUNET_FSUI_Context *ctx;
ctx = sl->ctx;
@@ -520,13 +500,13 @@
rec = sl->searches;
sl->searches = rec->next;
if (rec->search != NULL)
- {
- GNUNET_GE_BREAK (ctx->ectx, 0);
- GNUNET_ECRS_search_stop(rec->search);
- rec->search = NULL;
- }
+ {
+ GNUNET_GE_BREAK (ctx->ectx, 0);
+ GNUNET_ECRS_search_stop (rec->search);
+ rec->search = NULL;
+ }
GNUNET_ECRS_uri_destroy (rec->uri);
- GNUNET_free(rec);
+ GNUNET_free (rec);
}
event.type = GNUNET_FSUI_search_stopped;
event.data.SearchStopped.sc.pos = pos;
@@ -537,16 +517,14 @@
{
srl = sl->resultsReceived;
sl->resultsReceived = srl->next;
- GNUNET_array_grow(srl->matchingSearches,
- srl->matchingSearchCount,
- 0);
+ GNUNET_array_grow (srl->matchingSearches, srl->matchingSearchCount, 0);
GNUNET_ECRS_uri_destroy (srl->fi.uri);
GNUNET_ECRS_meta_data_destroy (srl->fi.meta);
if (srl->test_download != NULL)
- GNUNET_ECRS_file_download_partial_stop(srl->test_download);
- GNUNET_free(srl);
+ GNUNET_ECRS_file_download_partial_stop (srl->test_download);
+ GNUNET_free (srl);
}
- GNUNET_mutex_destroy(pos->lock);
+ GNUNET_mutex_destroy (pos->lock);
GNUNET_free (pos);
return GNUNET_OK;
}
Modified: GNUnet/src/applications/fs/fsui/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/searchtest.c 2008-04-24 06:05:27 UTC
(rev 6749)
+++ GNUnet/src/applications/fs/fsui/searchtest.c 2008-04-24 06:10:06 UTC
(rev 6750)
@@ -188,7 +188,9 @@
fn, "foo bar test!", strlen ("foo bar test!"),
"600");
meta = GNUNET_ECRS_meta_data_create ();
- kuri = GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2, (const char **)
keywords);
+ kuri =
+ GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2,
+ (const char **) keywords);
waitForEvent = GNUNET_FSUI_upload_completed;
upload =
GNUNET_FSUI_upload_start (ctx,
Modified: GNUnet/src/applications/fs/fsui/serialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serialize.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/fsui/serialize.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -32,18 +32,18 @@
#include "fsui.h"
-typedef struct {
+typedef struct
+{
int fd;
unsigned int have;
unsigned int size;
- char * buffer;
+ char *buffer;
} WriteBuffer;
static void
-write_buffered(WriteBuffer * wb,
- const void * s,
- unsigned int size) {
- const char * src = s;
+write_buffered (WriteBuffer * wb, const void *s, unsigned int size)
+{
+ const char *src = s;
unsigned int min;
unsigned int pos;
int ret;
@@ -51,32 +51,28 @@
if (wb->fd == -1)
return;
pos = 0;
- do
+ do
{
/* first, just use buffer */
min = wb->size - wb->have;
if (min > size)
- min = size;
- memcpy(&wb->buffer[wb->have],
- &src[pos],
- min);
+ min = size;
+ memcpy (&wb->buffer[wb->have], &src[pos], min);
pos += min;
wb->have += min;
if (pos == size)
- return; /* done */
- GNUNET_GE_ASSERT(NULL, wb->have == wb->size);
- ret = WRITE(wb->fd,
- wb->buffer,
- wb->size);
+ return; /* done */
+ GNUNET_GE_ASSERT (NULL, wb->have == wb->size);
+ ret = WRITE (wb->fd, wb->buffer, wb->size);
if (ret != wb->size)
- {
- CLOSE(wb->fd);
- wb->fd = -1;
- return; /* error */
- }
+ {
+ CLOSE (wb->fd);
+ wb->fd = -1;
+ return; /* error */
+ }
wb->have = 0;
}
- while (pos < size); /* should always be true */
+ while (pos < size); /* should always be true */
}
@@ -192,9 +188,9 @@
i = 0;
break;
}
- i++;
+ i++;
}
- if (pos == NULL)
+ if (pos == NULL)
i = 0;
WRITEINT (wb, i);
}
@@ -235,18 +231,17 @@
* that we are performing.
*/
static void
-write_search_record_list(struct GNUNET_GE_Context * ectx,
- WriteBuffer *wb,
- struct SearchRecordList * pos)
+write_search_record_list (struct GNUNET_GE_Context *ectx,
+ WriteBuffer * wb, struct SearchRecordList *pos)
{
- while (pos != NULL)
+ while (pos != NULL)
{
- WRITEINT(wb, pos->is_required);
- write_buffered(wb, &pos->key, sizeof(GNUNET_HashCode));
- writeURI(wb, pos->uri);
+ WRITEINT (wb, pos->is_required);
+ write_buffered (wb, &pos->key, sizeof (GNUNET_HashCode));
+ writeURI (wb, pos->uri);
pos = pos->next;
- }
- WRITEINT(wb, -1);
+ }
+ WRITEINT (wb, -1);
}
/**
@@ -258,40 +253,39 @@
* @param pos results to write
*/
void
-write_result_list(struct GNUNET_GE_Context * ectx,
- WriteBuffer *wb,
- struct SearchRecordList * search_list,
- struct SearchResultList * pos)
+write_result_list (struct GNUNET_GE_Context *ectx,
+ WriteBuffer * wb,
+ struct SearchRecordList *search_list,
+ struct SearchResultList *pos)
{
unsigned int i;
unsigned int idx;
- struct SearchRecordList * spos;
+ struct SearchRecordList *spos;
- while (pos != NULL)
- {
- WRITEINT(wb, pos->matchingSearchCount);
- WRITEINT(wb, pos->mandatoryMatchesRemaining);
- WRITEINT(wb, pos->probeSuccess);
- WRITEINT(wb, pos->probeFailure);
- writeFileInfo(ectx, wb, &pos->fi);
+ while (pos != NULL)
+ {
+ WRITEINT (wb, pos->matchingSearchCount);
+ WRITEINT (wb, pos->mandatoryMatchesRemaining);
+ WRITEINT (wb, pos->probeSuccess);
+ WRITEINT (wb, pos->probeFailure);
+ writeFileInfo (ectx, wb, &pos->fi);
i = pos->matchingSearchCount;
while (i-- > 0)
- {
- idx = 1;
- spos = search_list;
- while ( (spos != NULL) &&
- (spos != pos->matchingSearches[i]) )
- {
- idx++;
- spos = spos->next;
- }
- if (spos == NULL)
- idx = 0;
- WRITEINT(wb, idx);
- }
+ {
+ idx = 1;
+ spos = search_list;
+ while ((spos != NULL) && (spos != pos->matchingSearches[i]))
+ {
+ idx++;
+ spos = spos->next;
+ }
+ if (spos == NULL)
+ idx = 0;
+ WRITEINT (wb, idx);
+ }
pos = pos->next;
- }
- WRITEINT(wb, -1);
+ }
+ WRITEINT (wb, -1);
}
@@ -313,13 +307,9 @@
WRITEINT (wb, spos->anonymityLevel);
WRITEINT (wb, spos->mandatory_keyword_count);
writeURI (wb, spos->uri);
- write_search_record_list(ctx->ectx,
- wb,
- spos->searches);
- write_result_list(ctx->ectx,
- wb,
- spos->searches,
- spos->resultsReceived);
+ write_search_record_list (ctx->ectx, wb, spos->searches);
+ write_result_list (ctx->ectx,
+ wb, spos->searches, spos->resultsReceived);
spos = spos->next;
}
WRITEINT (wb, 0);
@@ -420,25 +410,23 @@
WriteBuffer wb;
wb.fd = GNUNET_disk_file_open (ctx->ectx,
- ctx->name,
- O_CREAT | O_TRUNC | O_WRONLY,
- S_IRUSR | S_IWUSR);
+ ctx->name,
+ O_CREAT | O_TRUNC | O_WRONLY,
+ S_IRUSR | S_IWUSR);
if (wb.fd == -1)
return;
wb.have = 0;
wb.size = 64 * 1024;
- wb.buffer = GNUNET_malloc(wb.size);
- write_buffered (&wb, "FSUI03\n\0", 8); /* magic */
+ wb.buffer = GNUNET_malloc (wb.size);
+ write_buffered (&wb, "FSUI03\n\0", 8); /* magic */
writeCollection (&wb, ctx);
writeSearches (&wb, ctx);
writeDownloadList (ctx->ectx, &wb, ctx, ctx->activeDownloads.child);
writeUnindexing (&wb, ctx);
writeUploads (&wb, ctx, ctx->activeUploads.child);
- WRITE(wb.fd,
- wb.buffer,
- wb.have);
+ WRITE (wb.fd, wb.buffer, wb.have);
CLOSE (wb.fd);
- GNUNET_free(wb.buffer);
+ GNUNET_free (wb.buffer);
}
/* end of serialize.c */
Modified: GNUnet/src/applications/fs/fsui/serializetest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest.c 2008-04-24 06:05:27 UTC
(rev 6749)
+++ GNUnet/src/applications/fs/fsui/serializetest.c 2008-04-24 06:10:06 UTC
(rev 6750)
@@ -189,7 +189,9 @@
GNUNET_disk_file_write (ectx, fn, buf, FILESIZE, "600");
GNUNET_free (buf);
meta = GNUNET_ECRS_meta_data_create ();
- kuri = GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2, (const char **)
keywords);
+ kuri =
+ GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2,
+ (const char **) keywords);
waitForEvent = GNUNET_FSUI_upload_completed;
upload = GNUNET_FSUI_upload_start (ctx,
fn,
Modified: GNUnet/src/applications/fs/fsui/serializetest2.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest2.c 2008-04-24 06:05:27 UTC
(rev 6749)
+++ GNUnet/src/applications/fs/fsui/serializetest2.c 2008-04-24 06:10:06 UTC
(rev 6750)
@@ -366,7 +366,9 @@
GNUNET_free (fn);
}
meta = GNUNET_ECRS_meta_data_create ();
- kuri = GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2, (const char **)
keywords);
+ kuri =
+ GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2,
+ (const char **) keywords);
GNUNET_ECRS_meta_data_insert (meta, EXTRACTOR_MIMETYPE,
GNUNET_DIRECTORY_MIME);
upload =
Modified: GNUnet/src/applications/fs/fsui/serializetest3.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest3.c 2008-04-24 06:05:27 UTC
(rev 6749)
+++ GNUnet/src/applications/fs/fsui/serializetest3.c 2008-04-24 06:10:06 UTC
(rev 6750)
@@ -157,8 +157,7 @@
cfg, "serializetest3", 32, GNUNET_YES,
&eventCallback, NULL);
CHECK (ctx != NULL);
- GNUNET_snprintf (keyword, 40, "+%s +%s", keywords[0],
- keywords[1]);
+ GNUNET_snprintf (keyword, 40, "+%s +%s", keywords[0], keywords[1]);
uri = GNUNET_ECRS_keyword_string_to_uri (ectx, keyword);
search = GNUNET_FSUI_search_start (ctx, 0, uri);
CHECK (search != NULL);
Modified: GNUnet/src/applications/fs/fsui/serializetest4.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest4.c 2008-04-24 06:05:27 UTC
(rev 6749)
+++ GNUnet/src/applications/fs/fsui/serializetest4.c 2008-04-24 06:10:06 UTC
(rev 6750)
@@ -339,7 +339,9 @@
GNUNET_free (fn);
}
meta = GNUNET_ECRS_meta_data_create ();
- kuri = GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2, (const char **)
keywords);
+ kuri =
+ GNUNET_ECRS_keyword_command_line_to_uri (ectx, 2,
+ (const char **) keywords);
GNUNET_ECRS_meta_data_insert (meta, EXTRACTOR_MIMETYPE,
GNUNET_DIRECTORY_MIME);
upload =
@@ -354,8 +356,7 @@
kuri = NULL;
GNUNET_FSUI_upload_stop (ctx, upload);
CHECK (upURI != NULL);
- GNUNET_snprintf (keyword, 40, "+%s +%s", keywords[0],
- keywords[1]);
+ GNUNET_snprintf (keyword, 40, "+%s +%s", keywords[0], keywords[1]);
uri = GNUNET_ECRS_keyword_string_to_uri (ectx, keyword);
download = GNUNET_FSUI_download_start (ctx,
0,
Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/fs/fsui/upload.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -862,7 +862,7 @@
void *unused;
struct GNUNET_FSUI_UploadShared *shared;
struct GNUNET_FSUI_Context *ctx;
-
+
if (ul == NULL)
return GNUNET_SYSERR;
ctx = ul->shared->ctx;
Modified: GNUnet/src/applications/tbench/tbenchtest.c
===================================================================
--- GNUnet/src/applications/tbench/tbenchtest.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/tbench/tbenchtest.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -157,17 +157,17 @@
/* 'blast' pass: hit bandwidth limits! */
for (i = 8; i < 60000; i *= 2)
{
- if (GNUNET_shutdown_test() == GNUNET_YES)
- break;
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
if (ret == 0)
ret =
test (sock, i, 1 + 1024 / i, 4, 10 * GNUNET_CRON_MILLISECONDS, 2,
2 * GNUNET_CRON_SECONDS);
}
- if (GNUNET_shutdown_test() != GNUNET_YES)
+ if (GNUNET_shutdown_test () != GNUNET_YES)
ret =
test (sock, 32768, 10, 10, 500 * GNUNET_CRON_MILLISECONDS, 1,
- 10 * GNUNET_CRON_SECONDS);
+ 10 * GNUNET_CRON_SECONDS);
GNUNET_client_connection_destroy (sock);
#if START_PEERS
GNUNET_TESTING_stop_daemons (peers);
Modified: GNUnet/src/applications/testing/remote.c
===================================================================
--- GNUnet/src/applications/testing/remote.c 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/applications/testing/remote.c 2008-04-24 06:10:06 UTC (rev
6750)
@@ -97,7 +97,7 @@
GNUNET_REMOTE_TOPOLOGIES type_of_topology;
list_as_array = &array_of_pointers[0];
-
+
char *ssh_username;
char *control_host;
char *remote_config_path;
@@ -111,7 +111,7 @@
char *temp_pid_file;
char *curr_host;
char *temp_remote_config_path;
-
+
unsigned long long starting_port;
unsigned long long port_increment;
unsigned long long daemons_per_machine;
@@ -150,9 +150,8 @@
"SSH_USERNAME", "",
&ssh_username);
GNUNET_GC_get_configuration_value_number (newcfg, "MULTIPLE_SERVER_TESTING",
- "TOPOLOGY",
- 0, -1, 0, &topology);
- type_of_topology = (unsigned int)topology;
+ "TOPOLOGY", 0, -1, 0, &topology);
+ type_of_topology = (unsigned int) topology;
GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
"CONTROL_HOST", "localhost",
&control_host);
@@ -476,19 +475,19 @@
switch (t)
{
case GNUNET_REMOTE_CLIQUE:
- fprintf(stderr,"Creating clique topology\n");
+ fprintf (stderr, "Creating clique topology\n");
ret = GNUNET_REMOTE_connect_clique (head);
break;
case GNUNET_REMOTE_SMALL_WORLD:
- fprintf(stderr,"Creating small world topology\n");
+ fprintf (stderr, "Creating small world topology\n");
ret = GNUNET_SYSERR;
break;
case GNUNET_REMOTE_RING:
- fprintf(stderr,"Creating ring topology\n");
+ fprintf (stderr, "Creating ring topology\n");
ret = GNUNET_SYSERR;
break;
case GNUNET_REMOTE_2D_TORUS:
- fprintf(stderr,"Creating 2d torus topology\n");
+ fprintf (stderr, "Creating 2d torus topology\n");
ret = GNUNET_REMOTE_connect_2d_torus (number_of_daemons, list_as_array);
break;
default:
@@ -542,7 +541,7 @@
* with MANY conns, we'll see...
*/
while (pos != NULL)
- {
+ {
friend_pos = pos->friend_entries;
while (friend_pos != NULL)
{
@@ -557,7 +556,7 @@
}
pos = pos->next;
}
-
+
}
else
{
Modified: GNUnet/src/applications/testing/remotetopologies.c
===================================================================
--- GNUnet/src/applications/testing/remotetopologies.c 2008-04-24 06:05:27 UTC
(rev 6749)
+++ GNUnet/src/applications/testing/remotetopologies.c 2008-04-24 06:10:06 UTC
(rev 6750)
@@ -176,113 +176,124 @@
struct GNUNET_REMOTE_host_list
**list_as_array)
{
- unsigned int i;
- unsigned int square;
- unsigned int rows;
- unsigned int cols;
- unsigned int toggle = 1;
- unsigned int nodeToConnect;
-
- GNUNET_EncName *node1;
+ unsigned int i;
+ unsigned int square;
+ unsigned int rows;
+ unsigned int cols;
+ unsigned int toggle = 1;
+ unsigned int nodeToConnect;
+
+ GNUNET_EncName *node1;
GNUNET_EncName *node2;
struct GNUNET_REMOTE_friends_list *node1temp;
struct GNUNET_REMOTE_friends_list *node2temp;
node1 = GNUNET_malloc (sizeof (GNUNET_EncName));
node2 = GNUNET_malloc (sizeof (GNUNET_EncName));
-
- square = floor(sqrt(number_of_daemons));
- rows = square;
- cols = square;
-
- if(square * square != number_of_daemons)
- {
- while(rows * cols < number_of_daemons)
- {
- if (toggle % 2 == 0)
- rows++;
- else
- cols++;
-
- toggle++;
- }
- }
- fprintf(stderr,_("Connecting nodes in 2d torus topology: %u rows %u
columns\n"),rows,cols);
- /* Rows and columns are all sorted out, now iterate over all nodes and
connect each
- * to the node to its right and above. Once this is over, we'll have
our torus!
- * Special case for the last node (if the rows and columns are not
equal), connect
- * to the first in the row to maintain topology.
- */
- for(i = 0;i<number_of_daemons;i++)
- {
- /* First connect to the node to the right */
- if (((i + 1) % cols != 0) && (i+1 != number_of_daemons))
- nodeToConnect = i+1;
- else if (i+1 == number_of_daemons)
- nodeToConnect = rows * cols - cols;
- else
- nodeToConnect = i - cols + 1;
-
- fprintf(stderr,"connecting node %u to %u\n",i,nodeToConnect);
- GNUNET_REMOTE_get_daemons_information
(list_as_array[i]->hostname, list_as_array[i]->port,
-
list_as_array[nodeToConnect]->hostname,
-
list_as_array[nodeToConnect]->port, &node1,&node2);
-
- node1temp = GNUNET_malloc (sizeof (struct
GNUNET_REMOTE_friends_list));
- node2temp = GNUNET_malloc (sizeof (struct GNUNET_REMOTE_friends_list));
- node2temp->hostentry = list_as_array[i];
- node1temp->hostentry = list_as_array[nodeToConnect];
+ square = floor (sqrt (number_of_daemons));
+ rows = square;
+ cols = square;
- node1temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
- node2temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
+ if (square * square != number_of_daemons)
+ {
+ while (rows * cols < number_of_daemons)
+ {
+ if (toggle % 2 == 0)
+ rows++;
+ else
+ cols++;
- memcpy (node1temp->nodeid, node2, sizeof (GNUNET_EncName));
- memcpy (node2temp->nodeid, node1, sizeof (GNUNET_EncName));
+ toggle++;
+ }
+ }
+ fprintf (stderr,
+ _("Connecting nodes in 2d torus topology: %u rows %u columns\n"),
+ rows, cols);
+ /* Rows and columns are all sorted out, now iterate over all nodes and
connect each
+ * to the node to its right and above. Once this is over, we'll have our
torus!
+ * Special case for the last node (if the rows and columns are not equal),
connect
+ * to the first in the row to maintain topology.
+ */
+ for (i = 0; i < number_of_daemons; i++)
+ {
+ /* First connect to the node to the right */
+ if (((i + 1) % cols != 0) && (i + 1 != number_of_daemons))
+ nodeToConnect = i + 1;
+ else if (i + 1 == number_of_daemons)
+ nodeToConnect = rows * cols - cols;
+ else
+ nodeToConnect = i - cols + 1;
- node1temp->next = list_as_array[i]->friend_entries;
- node2temp->next = list_as_array[nodeToConnect]->friend_entries;
+ fprintf (stderr, "connecting node %u to %u\n", i, nodeToConnect);
+ GNUNET_REMOTE_get_daemons_information (list_as_array[i]->hostname,
+ list_as_array[i]->port,
+ list_as_array[nodeToConnect]->
+ hostname,
+ list_as_array[nodeToConnect]->
+ port, &node1, &node2);
- list_as_array[i]->friend_entries = node1temp;
- list_as_array[nodeToConnect]->friend_entries = node2temp;
-
-
- /* Second connect to the node immediately above */
- if (i < cols)
- nodeToConnect = (rows * cols) - cols + i;
- else
- nodeToConnect = i - cols;
-
- if (nodeToConnect < number_of_daemons)
- {
- fprintf(stderr,"connecting node %u to
%u\n",i,nodeToConnect);
- GNUNET_REMOTE_get_daemons_information
(list_as_array[i]->hostname, list_as_array[i]->port,
-
list_as_array[nodeToConnect]->hostname,
-
list_as_array[nodeToConnect]->port, &node1,&node2);
-
- node1temp = GNUNET_malloc (sizeof (struct
GNUNET_REMOTE_friends_list));
- node2temp = GNUNET_malloc (sizeof (struct
GNUNET_REMOTE_friends_list));
-
- node2temp->hostentry = list_as_array[i];
- node1temp->hostentry = list_as_array[nodeToConnect];
-
- node1temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
- node2temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
-
- memcpy (node1temp->nodeid, node2, sizeof (GNUNET_EncName));
- memcpy (node2temp->nodeid, node1, sizeof (GNUNET_EncName));
-
- node1temp->next = list_as_array[i]->friend_entries;
- node2temp->next = list_as_array[nodeToConnect]->friend_entries;
-
- list_as_array[i]->friend_entries = node1temp;
- list_as_array[nodeToConnect]->friend_entries = node2temp;
- }
-
- }
-
- GNUNET_free(node1);
- GNUNET_free(node2);
+ node1temp = GNUNET_malloc (sizeof (struct GNUNET_REMOTE_friends_list));
+ node2temp = GNUNET_malloc (sizeof (struct GNUNET_REMOTE_friends_list));
+
+ node2temp->hostentry = list_as_array[i];
+ node1temp->hostentry = list_as_array[nodeToConnect];
+
+ node1temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
+ node2temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
+
+ memcpy (node1temp->nodeid, node2, sizeof (GNUNET_EncName));
+ memcpy (node2temp->nodeid, node1, sizeof (GNUNET_EncName));
+
+ node1temp->next = list_as_array[i]->friend_entries;
+ node2temp->next = list_as_array[nodeToConnect]->friend_entries;
+
+ list_as_array[i]->friend_entries = node1temp;
+ list_as_array[nodeToConnect]->friend_entries = node2temp;
+
+
+ /* Second connect to the node immediately above */
+ if (i < cols)
+ nodeToConnect = (rows * cols) - cols + i;
+ else
+ nodeToConnect = i - cols;
+
+ if (nodeToConnect < number_of_daemons)
+ {
+ fprintf (stderr, "connecting node %u to %u\n", i, nodeToConnect);
+ GNUNET_REMOTE_get_daemons_information (list_as_array[i]->hostname,
+ list_as_array[i]->port,
+ list_as_array
+ [nodeToConnect]->hostname,
+ list_as_array
+ [nodeToConnect]->port,
+ &node1, &node2);
+
+ node1temp =
+ GNUNET_malloc (sizeof (struct GNUNET_REMOTE_friends_list));
+ node2temp =
+ GNUNET_malloc (sizeof (struct GNUNET_REMOTE_friends_list));
+
+ node2temp->hostentry = list_as_array[i];
+ node1temp->hostentry = list_as_array[nodeToConnect];
+
+ node1temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
+ node2temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
+
+ memcpy (node1temp->nodeid, node2, sizeof (GNUNET_EncName));
+ memcpy (node2temp->nodeid, node1, sizeof (GNUNET_EncName));
+
+ node1temp->next = list_as_array[i]->friend_entries;
+ node2temp->next = list_as_array[nodeToConnect]->friend_entries;
+
+ list_as_array[i]->friend_entries = node1temp;
+ list_as_array[nodeToConnect]->friend_entries = node2temp;
+ }
+
+ }
+
+ GNUNET_free (node1);
+ GNUNET_free (node2);
return GNUNET_OK;
}
@@ -428,11 +439,11 @@
GNUNET_snprintf (host, 128, "%s:%u", hostname1, port1);
GNUNET_GC_set_configuration_value_string (cfg1, NULL, "NETWORK", "HOST",
host);
-
+
GNUNET_snprintf (host, 128, "%s:%u", hostname2, port2);
GNUNET_GC_set_configuration_value_string (cfg2, NULL, "NETWORK", "HOST",
host);
-
+
if ((GNUNET_OK ==
GNUNET_wait_for_daemon_running (NULL, cfg1, 300 * GNUNET_CRON_SECONDS))
&& (GNUNET_OK ==
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2008-04-24 06:10:06 UTC (rev
6750)
@@ -102,9 +102,8 @@
* @param is_mandatory is the keyword mandatory (in a search)
* @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
*/
-typedef int (*GNUNET_ECRS_KeywordIterator) (const char *keyword,
- int is_mandatory,
- void *closure);
+typedef int (*GNUNET_ECRS_KeywordIterator) (const char *keyword,
+ int is_mandatory, void *closure);
/**
* Create a fresh MetaData token.
@@ -391,7 +390,8 @@
struct GNUNET_ECRS_URI *GNUNET_ECRS_keyword_string_to_uri (struct
GNUNET_GE_Context
*ectx,
- const char
*keywords);
+ const char
+ *keywords);
/* helper.c */
/**
@@ -555,18 +555,8 @@
* @return GNUNET_SYSERR if the upload failed (i.e. not enough space
* or gnunetd not running)
*/
-int GNUNET_ECRS_file_upload (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const char *filename,
- int doIndex,
- unsigned int anonymityLevel,
- unsigned int priority,
- GNUNET_CronTime expirationTime, /* absolute time
*/
- GNUNET_ECRS_UploadProgressCallback upcb,
- void *upcbClosure,
- GNUNET_ECRS_TestTerminate tt,
- void *ttClosure,
- struct GNUNET_ECRS_URI **uri); /* upload.c */
+int GNUNET_ECRS_file_upload (struct GNUNET_GE_Context *ectx, struct
GNUNET_GC_Configuration *cfg, const char *filename, int doIndex, unsigned int
anonymityLevel, unsigned int priority, GNUNET_CronTime expirationTime,
/* absolute time */
+ GNUNET_ECRS_UploadProgressCallback upcb, void
*upcbClosure, GNUNET_ECRS_TestTerminate tt, void *ttClosure, struct
GNUNET_ECRS_URI **uri); /* upload.c */
/**
* Test if a file is indexed.
@@ -608,13 +598,7 @@
*
* @return GNUNET_SYSERR if the unindexing failed (i.e. not indexed)
*/
-int GNUNET_ECRS_file_unindex (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const char *filename,
- GNUNET_ECRS_UploadProgressCallback upcb,
- void *upcbClosure,
- GNUNET_ECRS_TestTerminate tt,
- void *ttClosure); /* unindex.c */
+int GNUNET_ECRS_file_unindex (struct GNUNET_GE_Context *ectx, struct
GNUNET_GC_Configuration *cfg, const char *filename,
GNUNET_ECRS_UploadProgressCallback upcb, void *upcbClosure,
GNUNET_ECRS_TestTerminate tt, void *ttClosure); /* unindex.c */
/**
@@ -637,16 +621,24 @@
*
* @return URI on success, NULL on error (namespace already exists)
*/
-struct GNUNET_ECRS_URI *
-GNUNET_ECRS_namespace_create (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const char *name,
- const struct GNUNET_ECRS_MetaData *meta,
- unsigned int anonymityLevel,
- unsigned int priority,
- GNUNET_CronTime expiration,
- const struct GNUNET_ECRS_URI *advertisementURI,
- const GNUNET_HashCode * rootEntry);
+struct GNUNET_ECRS_URI *GNUNET_ECRS_namespace_create (struct GNUNET_GE_Context
+ *ectx,
+ struct
+ GNUNET_GC_Configuration
+ *cfg, const char *name,
+ const struct
+ GNUNET_ECRS_MetaData
+ *meta,
+ unsigned int
+ anonymityLevel,
+ unsigned int priority,
+ GNUNET_CronTime
+ expiration,
+ const struct
+ GNUNET_ECRS_URI
+ *advertisementURI,
+ const GNUNET_HashCode *
+ rootEntry);
/* namespace.c */
/**
@@ -667,9 +659,7 @@
*
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
-int GNUNET_ECRS_namespace_delete (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const char *namespaceName); /* namespace.c
*/
+int GNUNET_ECRS_namespace_delete (struct GNUNET_GE_Context *ectx, struct
GNUNET_GC_Configuration *cfg, const char *namespaceName); /* namespace.c */
/**
* Callback with information about local (!) namespaces.
@@ -688,10 +678,7 @@
* @param list where to store the names (is allocated, caller frees)
* @return GNUNET_SYSERR on error, otherwise the number of pseudonyms in list
*/
-int GNUNET_ECRS_get_namespaces (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- GNUNET_ECRS_NamespaceInfoProcessor cb,
- void *cls); /* namespace.c */
+int GNUNET_ECRS_get_namespaces (struct GNUNET_GE_Context *ectx, struct
GNUNET_GC_Configuration *cfg, GNUNET_ECRS_NamespaceInfoProcessor cb, void
*cls); /* namespace.c */
/**
* Add an entry into a namespace.
@@ -703,19 +690,35 @@
* entry?
* @return URI on success, NULL on error
*/
-struct GNUNET_ECRS_URI *
-GNUNET_ECRS_namespace_add_content (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const char *name,
- unsigned int anonymityLevel,
- unsigned int priority,
- GNUNET_CronTime expirationTime,
- GNUNET_Int32Time creationTime,
- GNUNET_Int32Time updateInterval,
- const GNUNET_HashCode * thisId,
- const GNUNET_HashCode * nextId,
- const struct GNUNET_ECRS_URI *dst,
- const struct GNUNET_ECRS_MetaData *md);
+struct GNUNET_ECRS_URI *GNUNET_ECRS_namespace_add_content (struct
+ GNUNET_GE_Context
+ *ectx,
+ struct
+
GNUNET_GC_Configuration
+ *cfg,
+ const char *name,
+ unsigned int
+ anonymityLevel,
+ unsigned int
+ priority,
+ GNUNET_CronTime
+ expirationTime,
+ GNUNET_Int32Time
+ creationTime,
+ GNUNET_Int32Time
+ updateInterval,
+ const
+ GNUNET_HashCode *
+ thisId,
+ const
+ GNUNET_HashCode *
+ nextId,
+ const struct
+ GNUNET_ECRS_URI
+ *dst,
+ const struct
+ GNUNET_ECRS_MetaData
+ *md);
/* namespace.c */
/**
@@ -761,13 +764,7 @@
* this must be a simple URI (with a single
* keyword)
*/
-struct GNUNET_ECRS_SearchContext *
-GNUNET_ECRS_search_start (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const struct GNUNET_ECRS_URI *uri,
- unsigned int anonymityLevel,
- GNUNET_ECRS_SearchResultProcessor spcb,
- void *spcbClosure); /* search.c */
+struct GNUNET_ECRS_SearchContext *GNUNET_ECRS_search_start (struct
GNUNET_GE_Context *ectx, struct GNUNET_GC_Configuration *cfg, const struct
GNUNET_ECRS_URI *uri, unsigned int anonymityLevel,
GNUNET_ECRS_SearchResultProcessor spcb, void *spcbClosure); /* search.c */
/**
* Stop search for content.
@@ -783,14 +780,7 @@
* @param uri specifies the search parameters
* @param uri set to the URI of the uploaded file
*/
-int GNUNET_ECRS_search (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const struct GNUNET_ECRS_URI *uri,
- unsigned int anonymityLevel,
- GNUNET_ECRS_SearchResultProcessor spcb,
- void *spcbClosure,
- GNUNET_ECRS_TestTerminate tt,
- void *ttClosure); /* search.c */
+int GNUNET_ECRS_search (struct GNUNET_GE_Context *ectx, struct
GNUNET_GC_Configuration *cfg, const struct GNUNET_ECRS_URI *uri, unsigned int
anonymityLevel, GNUNET_ECRS_SearchResultProcessor spcb, void *spcbClosure,
GNUNET_ECRS_TestTerminate tt, void *ttClosure); /* search.c */
/**
* Notification of ECRS to a client about the progress of an insertion
@@ -864,15 +854,7 @@
* @param uri the URI of the file (determines what to download)
* @param filename where to store the file
*/
-int GNUNET_ECRS_file_download (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const struct GNUNET_ECRS_URI *uri,
- const char *filename,
- unsigned int anonymityLevel,
- GNUNET_ECRS_DownloadProgressCallback dpcb,
- void *dpcbClosure,
- GNUNET_ECRS_TestTerminate tt,
- void *ttClosure); /* download.c */
+int GNUNET_ECRS_file_download (struct GNUNET_GE_Context *ectx, struct
GNUNET_GC_Configuration *cfg, const struct GNUNET_ECRS_URI *uri, const char
*filename, unsigned int anonymityLevel, GNUNET_ECRS_DownloadProgressCallback
dpcb, void *dpcbClosure, GNUNET_ECRS_TestTerminate tt, void *ttClosure); /*
download.c */
/**
* DOWNLOAD parts of a file. Note that this will store
@@ -893,19 +875,7 @@
* @param start starting offset
* @param length length of the download (starting at offset)
*/
-int GNUNET_ECRS_file_download_partial (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const struct GNUNET_ECRS_URI *uri,
- const char *filename,
- unsigned long long offset,
- unsigned long long length,
- unsigned int anonymityLevel,
- int no_temporaries,
- GNUNET_ECRS_DownloadProgressCallback
- dpcb,
- void *dpcbClosure,
- GNUNET_ECRS_TestTerminate tt,
- void *ttClosure); /* download.c */
+int GNUNET_ECRS_file_download_partial (struct GNUNET_GE_Context *ectx, struct
GNUNET_GC_Configuration *cfg, const struct GNUNET_ECRS_URI *uri, const char
*filename, unsigned long long offset, unsigned long long length, unsigned int
anonymityLevel, int no_temporaries, GNUNET_ECRS_DownloadProgressCallback dpcb,
void *dpcbClosure, GNUNET_ECRS_TestTerminate tt, void *ttClosure); /*
download.c */
/**
* Iterate over all entries in a directory. Note that directories
@@ -921,12 +891,7 @@
* @return number of entries on success, GNUNET_SYSERR if the
* directory is malformed
*/
-int GNUNET_ECRS_directory_list_contents (struct GNUNET_GE_Context *ectx,
- const char *data,
- unsigned long long len,
- struct GNUNET_ECRS_MetaData **md,
- GNUNET_ECRS_SearchResultProcessor
spcb,
- void *spcbClosure); /* directory.c
*/
+int GNUNET_ECRS_directory_list_contents (struct GNUNET_GE_Context *ectx, const
char *data, unsigned long long len, struct GNUNET_ECRS_MetaData **md,
GNUNET_ECRS_SearchResultProcessor spcb, void *spcbClosure); /*
directory.c */
/**
* Create a directory.
Modified: GNUnet/src/include/gnunet_fsui_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fsui_lib.h 2008-04-24 06:05:27 UTC (rev
6749)
+++ GNUnet/src/include/gnunet_fsui_lib.h 2008-04-24 06:10:06 UTC (rev
6750)
@@ -902,28 +902,28 @@
*
* @return GNUNET_SYSERR if such a search is not known
*/
-int GNUNET_FSUI_search_abort (struct GNUNET_FSUI_SearchList *sl); /*
search.c */
+int GNUNET_FSUI_search_abort (struct GNUNET_FSUI_SearchList *sl); /*
search.c */
/**
* Pause a search.
*
* @return GNUNET_SYSERR if such a search is not known
*/
-int GNUNET_FSUI_search_pause (struct GNUNET_FSUI_SearchList *sl); /*
search.c */
+int GNUNET_FSUI_search_pause (struct GNUNET_FSUI_SearchList *sl); /*
search.c */
/**
* Restart a paused search.
*
* @return GNUNET_SYSERR if such a search is not known
*/
-int GNUNET_FSUI_search_restart (struct GNUNET_FSUI_SearchList *sl); /*
search.c */
+int GNUNET_FSUI_search_restart (struct GNUNET_FSUI_SearchList *sl); /*
search.c */
/**
* Stop a search.
*
* @return GNUNET_SYSERR if such a search is not known
*/
-int GNUNET_FSUI_search_stop (struct GNUNET_FSUI_SearchList *sl); /*
search.c */
+int GNUNET_FSUI_search_stop (struct GNUNET_FSUI_SearchList *sl); /*
search.c */
/**
* Start to download a file or directory.
@@ -943,7 +943,7 @@
*
* @return GNUNET_SYSERR on error
*/
-int GNUNET_FSUI_download_abort (struct GNUNET_FSUI_DownloadList *dl); /*
download.c */
+int GNUNET_FSUI_download_abort (struct GNUNET_FSUI_DownloadList *dl); /*
download.c */
/**
* Stop a download. If the dl is for a recursive
@@ -951,7 +951,7 @@
*
* @return GNUNET_SYSERR on error
*/
-int GNUNET_FSUI_download_stop (struct GNUNET_FSUI_DownloadList *dl); /*
download.c */
+int GNUNET_FSUI_download_stop (struct GNUNET_FSUI_DownloadList *dl); /*
download.c */
/**
* Method that can be used to select files that
Modified: GNUnet/src/util/network/io.c
===================================================================
--- GNUnet/src/util/network/io.c 2008-04-24 06:05:27 UTC (rev 6749)
+++ GNUnet/src/util/network/io.c 2008-04-24 06:10:06 UTC (rev 6750)
@@ -227,11 +227,11 @@
GNUNET_GE_ASSERT (NULL, s->checksum == -s->handle);
if ((ret == (size_t) - 1) &&
(errno == EINTR) && (0 != (nc & GNUNET_NC_IGNORE_INT)))
- {
- if (GNUNET_shutdown_test() == GNUNET_YES)
- return GNUNET_SYSERR;
- continue;
- }
+ {
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ return GNUNET_SYSERR;
+ continue;
+ }
if ((ret == (size_t) - 1) || (ret > max - pos))
{
if (errno == EINTR)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6750 - in GNUnet/src: applications/chat applications/fs/ecrs applications/fs/fsui applications/tbench applications/testing include util/network,
gnunet <=