[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5249 - in GNUnet/src: applications/advertising application
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5249 - in GNUnet/src: applications/advertising applications/bootstrap_http applications/chat applications/datastore applications/dht/module applications/dht/tools applications/dstore applications/fragmentation applications/fs applications/fs/collection applications/fs/ecrs applications/fs/fsui applications/fs/lib applications/fs/module applications/fs/namespace applications/fs/tools applications/fs/uritrack applications/gap applications/getoption applications/identity applications/kvstore_sqlite applications/pingpong applications/rpc applications/session applications/sqstore_mysql applications/sqstore_mysql_embedded applications/sqstore_sqlite applications/state applications/stats applications/tbench applications/template applications/testbed applications/testing applications/topology_default applications/topology_f2f applications/tracekit applications/traffic applications/transport applications/vpn server setup setup/gtk setup/lib setup/ncurses setup/text transports transports/upnp util/boot util/config util/config_impl util/containers util/cron util/crypto util/disk util/error util/getopt util/loggers util/network util/network_client util/os util/string util/threads util/win |
Date: |
Thu, 5 Jul 2007 15:12:34 -0600 (MDT) |
Author: durner
Date: 2007-07-05 15:12:30 -0600 (Thu, 05 Jul 2007)
New Revision: 5249
Modified:
GNUnet/src/applications/advertising/advertising.c
GNUnet/src/applications/advertising/advertising_test.c
GNUnet/src/applications/advertising/bootstrap.c
GNUnet/src/applications/bootstrap_http/http.c
GNUnet/src/applications/bootstrap_http/httptest.c
GNUnet/src/applications/chat/chat.c
GNUnet/src/applications/chat/gnunet-chat.c
GNUnet/src/applications/datastore/datastore.c
GNUnet/src/applications/datastore/filter.c
GNUnet/src/applications/datastore/prefetch.c
GNUnet/src/applications/dht/module/cs.c
GNUnet/src/applications/dht/module/dstore.c
GNUnet/src/applications/dht/module/routing.c
GNUnet/src/applications/dht/module/service.c
GNUnet/src/applications/dht/module/table.c
GNUnet/src/applications/dht/tools/dht-query.c
GNUnet/src/applications/dht/tools/dht_api.c
GNUnet/src/applications/dht/tools/dhttest.c
GNUnet/src/applications/dht/tools/dhttest2.c
GNUnet/src/applications/dstore/dstore.c
GNUnet/src/applications/dstore/dstore_test.c
GNUnet/src/applications/fragmentation/fragmentation.c
GNUnet/src/applications/fragmentation/fragmentationtest.c
GNUnet/src/applications/fs/collection/collection.c
GNUnet/src/applications/fs/collection/collectiontest.c
GNUnet/src/applications/fs/ecrs/bincoder.c
GNUnet/src/applications/fs/ecrs/bincodertest.c
GNUnet/src/applications/fs/ecrs/directory.c
GNUnet/src/applications/fs/ecrs/directorytest.c
GNUnet/src/applications/fs/ecrs/download.c
GNUnet/src/applications/fs/ecrs/ecrs.c
GNUnet/src/applications/fs/ecrs/ecrstest.c
GNUnet/src/applications/fs/ecrs/helper.c
GNUnet/src/applications/fs/ecrs/indexinfo.c
GNUnet/src/applications/fs/ecrs/keyspace.c
GNUnet/src/applications/fs/ecrs/meta.c
GNUnet/src/applications/fs/ecrs/metatest.c
GNUnet/src/applications/fs/ecrs/metatest2.c
GNUnet/src/applications/fs/ecrs/namespace.c
GNUnet/src/applications/fs/ecrs/namespacetest.c
GNUnet/src/applications/fs/ecrs/parser.c
GNUnet/src/applications/fs/ecrs/search.c
GNUnet/src/applications/fs/ecrs/searchtest.c
GNUnet/src/applications/fs/ecrs/unindex.c
GNUnet/src/applications/fs/ecrs/upload.c
GNUnet/src/applications/fs/ecrs/uri.c
GNUnet/src/applications/fs/ecrs/uritest.c
GNUnet/src/applications/fs/ecrs_core.c
GNUnet/src/applications/fs/ecrs_core_test.c
GNUnet/src/applications/fs/fsui/deserialize.c
GNUnet/src/applications/fs/fsui/download.c
GNUnet/src/applications/fs/fsui/downloadtest.c
GNUnet/src/applications/fs/fsui/fsui-loader.c
GNUnet/src/applications/fs/fsui/fsui.c
GNUnet/src/applications/fs/fsui/fsuitest.c
GNUnet/src/applications/fs/fsui/fsuitest2.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/unindex.c
GNUnet/src/applications/fs/fsui/upload.c
GNUnet/src/applications/fs/lib/fslib.c
GNUnet/src/applications/fs/lib/fslibtest.c
GNUnet/src/applications/fs/module/anonymity.c
GNUnet/src/applications/fs/module/dht_push.c
GNUnet/src/applications/fs/module/fs.c
GNUnet/src/applications/fs/module/migration.c
GNUnet/src/applications/fs/module/ondemand.c
GNUnet/src/applications/fs/module/querymanager.c
GNUnet/src/applications/fs/namespace/namespace_info.c
GNUnet/src/applications/fs/namespace/namespace_infotest.c
GNUnet/src/applications/fs/tools/gnunet-directory.c
GNUnet/src/applications/fs/tools/gnunet-download.c
GNUnet/src/applications/fs/tools/gnunet-insert.c
GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
GNUnet/src/applications/fs/tools/gnunet-search.c
GNUnet/src/applications/fs/tools/gnunet-unindex.c
GNUnet/src/applications/fs/uritrack/callbacks.c
GNUnet/src/applications/fs/uritrack/file_info.c
GNUnet/src/applications/fs/uritrack/tracktest.c
GNUnet/src/applications/fs/uritrack/uri_info.c
GNUnet/src/applications/gap/gap.c
GNUnet/src/applications/gap/gaptest.c
GNUnet/src/applications/gap/gaptest2.c
GNUnet/src/applications/gap/gaptest3.c
GNUnet/src/applications/gap/pid_table.c
GNUnet/src/applications/getoption/clientapi.c
GNUnet/src/applications/getoption/getoption.c
GNUnet/src/applications/identity/clientapi.c
GNUnet/src/applications/identity/hostkey.c
GNUnet/src/applications/identity/identity.c
GNUnet/src/applications/identity/identitytest.c
GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c
GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c
GNUnet/src/applications/pingpong/pingpong.c
GNUnet/src/applications/rpc/parameters.c
GNUnet/src/applications/rpc/parameterstest.c
GNUnet/src/applications/rpc/rpc.c
GNUnet/src/applications/session/connect.c
GNUnet/src/applications/session/sessiontest.c
GNUnet/src/applications/session/sessiontest2.c
GNUnet/src/applications/session/sessiontest_http.c
GNUnet/src/applications/sqstore_mysql/mysql.c
GNUnet/src/applications/sqstore_mysql/mysqltest.c
GNUnet/src/applications/sqstore_mysql/mysqltest2.c
GNUnet/src/applications/sqstore_mysql/mysqltest3.c
GNUnet/src/applications/sqstore_mysql_embedded/mysql.c
GNUnet/src/applications/sqstore_mysql_embedded/mysqltest.c
GNUnet/src/applications/sqstore_mysql_embedded/mysqltest2.c
GNUnet/src/applications/sqstore_mysql_embedded/mysqltest3.c
GNUnet/src/applications/sqstore_sqlite/sqlite.c
GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c
GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c
GNUnet/src/applications/state/state.c
GNUnet/src/applications/state/statetest.c
GNUnet/src/applications/stats/clientapi.c
GNUnet/src/applications/stats/gnunet-stats.c
GNUnet/src/applications/stats/sqstats.c
GNUnet/src/applications/stats/statistics.c
GNUnet/src/applications/tbench/gnunet-tbench.c
GNUnet/src/applications/tbench/tbench.c
GNUnet/src/applications/tbench/tbenchtest.c
GNUnet/src/applications/template/gnunet-template.c
GNUnet/src/applications/template/template.c
GNUnet/src/applications/testbed/commands.c
GNUnet/src/applications/testbed/gnunet-testbed.c
GNUnet/src/applications/testbed/socket.c
GNUnet/src/applications/testbed/testbed.c
GNUnet/src/applications/testing/testing.c
GNUnet/src/applications/testing/testingtest.c
GNUnet/src/applications/topology_default/topology.c
GNUnet/src/applications/topology_f2f/topology.c
GNUnet/src/applications/tracekit/gnunet-tracekit.c
GNUnet/src/applications/tracekit/tracekit.c
GNUnet/src/applications/traffic/clientapi.c
GNUnet/src/applications/traffic/traffic.c
GNUnet/src/applications/transport/transport.c
GNUnet/src/applications/vpn/gnunet-vpn.c
GNUnet/src/applications/vpn/vpn.c
GNUnet/src/server/connection.c
GNUnet/src/server/core.c
GNUnet/src/server/gnunet-peer-info.c
GNUnet/src/server/gnunet-transport-check.c
GNUnet/src/server/gnunet-update.c
GNUnet/src/server/gnunetd.c
GNUnet/src/server/handler.c
GNUnet/src/server/startup.c
GNUnet/src/server/tcpserver.c
GNUnet/src/server/version.c
GNUnet/src/setup/gnunet-setup.c
GNUnet/src/setup/gnunet-win-tool.c
GNUnet/src/setup/gtk/about.c
GNUnet/src/setup/gtk/gconf.c
GNUnet/src/setup/gtk/glade_support.c
GNUnet/src/setup/gtk/wizard_gtk.c
GNUnet/src/setup/lib/gns.c
GNUnet/src/setup/lib/tree.c
GNUnet/src/setup/lib/wizard_util.c
GNUnet/src/setup/ncurses/mconf.c
GNUnet/src/setup/ncurses/wizard_curs.c
GNUnet/src/setup/text/conf.c
GNUnet/src/transports/http.c
GNUnet/src/transports/ip.c
GNUnet/src/transports/ip6.c
GNUnet/src/transports/nat.c
GNUnet/src/transports/smtp.c
GNUnet/src/transports/tcp.c
GNUnet/src/transports/tcp6.c
GNUnet/src/transports/tcp_helper.c
GNUnet/src/transports/udp.c
GNUnet/src/transports/udp6.c
GNUnet/src/transports/udp_helper.c
GNUnet/src/transports/upnp/error.c
GNUnet/src/transports/upnp/init.c
GNUnet/src/transports/upnp/ip.c
GNUnet/src/transports/upnp/upnp.c
GNUnet/src/transports/upnp/upnptest.c
GNUnet/src/transports/upnp/util.c
GNUnet/src/transports/upnp/xmlnode.c
GNUnet/src/util/boot/startup.c
GNUnet/src/util/config/config.c
GNUnet/src/util/config_impl/configtest.c
GNUnet/src/util/config_impl/impl.c
GNUnet/src/util/containers/bloomfilter.c
GNUnet/src/util/containers/bloomtest.c
GNUnet/src/util/containers/hashtable.c
GNUnet/src/util/containers/hashtest.c
GNUnet/src/util/containers/vector.c
GNUnet/src/util/containers/vectortest.c
GNUnet/src/util/cron/cron.c
GNUnet/src/util/cron/crontest.c
GNUnet/src/util/cron/timertest.c
GNUnet/src/util/crypto/crc32.c
GNUnet/src/util/crypto/hashing.c
GNUnet/src/util/crypto/hashingtest.c
GNUnet/src/util/crypto/hashperf.c
GNUnet/src/util/crypto/hostkey_gcrypt.c
GNUnet/src/util/crypto/hostkeytest.c
GNUnet/src/util/crypto/kblockkey.c
GNUnet/src/util/crypto/kblockkey_test.c
GNUnet/src/util/crypto/locking_gcrypt.c
GNUnet/src/util/crypto/random.c
GNUnet/src/util/crypto/symcipher_gcrypt.c
GNUnet/src/util/crypto/symciphertest.c
GNUnet/src/util/crypto/weakkeytest.c
GNUnet/src/util/disk/storage.c
GNUnet/src/util/disk/storagetest.c
GNUnet/src/util/error/error.c
GNUnet/src/util/getopt/getopt.c
GNUnet/src/util/getopt/printhelp.c
GNUnet/src/util/getopt/printversion.c
GNUnet/src/util/getopt/setoption.c
GNUnet/src/util/loggers/file.c
GNUnet/src/util/loggers/memory.c
GNUnet/src/util/loggers/smtp.c
GNUnet/src/util/network/dns.c
GNUnet/src/util/network/io.c
GNUnet/src/util/network/ip.c
GNUnet/src/util/network/ipcheck.c
GNUnet/src/util/network/select.c
GNUnet/src/util/network/selecttest.c
GNUnet/src/util/network_client/daemon.c
GNUnet/src/util/network_client/tcpio.c
GNUnet/src/util/network_client/tcpiotest.c
GNUnet/src/util/os/console.c
GNUnet/src/util/os/cpustatus.c
GNUnet/src/util/os/daemon.c
GNUnet/src/util/os/daemontest.c
GNUnet/src/util/os/dso.c
GNUnet/src/util/os/installpath.c
GNUnet/src/util/os/osconfig.c
GNUnet/src/util/os/priority.c
GNUnet/src/util/os/semaphore.c
GNUnet/src/util/os/semaphoretest.c
GNUnet/src/util/os/statuscalls.c
GNUnet/src/util/os/statuscallstest.c
GNUnet/src/util/os/user.c
GNUnet/src/util/string/string.c
GNUnet/src/util/string/xmalloc.c
GNUnet/src/util/string/xmalloctest.c
GNUnet/src/util/threads/mutex.c
GNUnet/src/util/threads/pthread.c
GNUnet/src/util/threads/semaphore.c
GNUnet/src/util/threads/semaphoretest.c
GNUnet/src/util/threads/shutdowntest.c
GNUnet/src/util/threads/shutdowntest2.c
GNUnet/src/util/threads/signal.c
GNUnet/src/util/threads/time.c
GNUnet/src/util/threads/timertest.c
GNUnet/src/util/win/win.cc
GNUnet/src/util/win/winproc.c
Log:
convert tabs to blanks
Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/advertising/advertising.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -145,7 +145,7 @@
*/
static int
receivedhello(const PeerIdentity * sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
TSession * tsession;
P2P_hello_MESSAGE * copy;
PeerIdentity foreignId;
@@ -166,48 +166,48 @@
return SYSERR;
}
identity->getPeerIdentity(&msg->publicKey,
- &foreignId);
+ &foreignId);
if (! equalsHashCode512(&msg->senderIdentity.hashPubKey,
- &foreignId.hashPubKey)) {
+ &foreignId.hashPubKey)) {
GE_BREAK(ectx, 0);
return SYSERR; /* public key and host hash do not match */
}
if (SYSERR == verifySig(&msg->senderIdentity,
- P2P_hello_MESSAGE_size(msg)
- - sizeof(Signature)
- - sizeof(PublicKey)
- - sizeof(MESSAGE_HEADER),
- &msg->signature,
- &msg->publicKey)) {
+ P2P_hello_MESSAGE_size(msg)
+ - sizeof(Signature)
+ - sizeof(PublicKey)
+ - sizeof(MESSAGE_HEADER),
+ &msg->signature,
+ &msg->publicKey)) {
IF_GELOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- hash2enc(&msg->senderIdentity.hashPubKey,
- &enc));
+ GE_WARNING | GE_BULK | GE_USER,
+ hash2enc(&msg->senderIdentity.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("HELLO message from `%s' has an invalid signature. Dropping.\n"),
- (char*)&enc);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("HELLO message from `%s' has an invalid signature. Dropping.\n"),
+ (char*)&enc);
GE_BREAK(ectx, 0);
return SYSERR; /* message invalid */
}
if ((TIME_T)ntohl(msg->expirationTime) > TIME(NULL) + MAX_HELLO_EXPIRES) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("HELLO message has expiration too far in the future.
Dropping.\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("HELLO message has expiration too far in the future. Dropping.\n"));
GE_BREAK(ectx, 0);
return SYSERR;
}
if (SYSERR == transport->verifyhello(msg)) {
#if DEBUG_ADVERTISING
IF_GELOG(ectx,
- GE_INFO | GE_BULK | GE_USER,
- hash2enc(&msg->senderIdentity.hashPubKey,
- &enc));
+ GE_INFO | GE_BULK | GE_USER,
+ hash2enc(&msg->senderIdentity.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "Transport verification of HELLO message from `%s' failed (%u).\n",
- &enc,
- ntohs(msg->protocol));
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Transport verification of HELLO message from `%s' failed (%u).\n",
+ &enc,
+ ntohs(msg->protocol));
#endif
return OK; /* not good, but do process rest of message */
}
@@ -215,14 +215,14 @@
stats->change(stat_hello_in, 1);
#if DEBUG_ADVERTISING
IF_GELOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- hash2enc(&msg->senderIdentity.hashPubKey,
- &enc));
+ GE_INFO | GE_REQUEST | GE_USER,
+ hash2enc(&msg->senderIdentity.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- "HELLO advertisement from `%s' for protocol %d received.\n",
- &enc,
- ntohs(msg->protocol));
+ GE_INFO | GE_REQUEST | GE_USER,
+ "HELLO advertisement from `%s' for protocol %d received.\n",
+ &enc,
+ ntohs(msg->protocol));
#endif
if (ntohs(msg->protocol) == NAT_PROTOCOL_NUMBER) {
/* We *can* not verify NAT. Ever. So all we
@@ -244,38 +244,38 @@
/* Then check if we have seen this hello before, if it is identical
except for the TTL, we trust it and do not play PING-PONG */
copy = identity->identity2Hello(&foreignId,
- ntohs(msg->protocol),
- NO);
+ ntohs(msg->protocol),
+ NO);
if (NULL != copy) {
if ( (ntohs(copy->senderAddressSize) ==
- ntohs(msg->senderAddressSize)) &&
- (0 == memcmp(&msg->MTU,
- ©->MTU,
- sizeof(unsigned short)*2+
- sizeof(unsigned int) +
- ntohs(copy->senderAddressSize)) ) ) {
+ ntohs(msg->senderAddressSize)) &&
+ (0 == memcmp(&msg->MTU,
+ ©->MTU,
+ sizeof(unsigned short)*2+
+ sizeof(unsigned int) +
+ ntohs(copy->senderAddressSize)) ) ) {
/* ok, we've seen this one exactly like this before (at most the
- TTL has changed); thus we can 'trust' it without playing
- ping-pong */
+ TTL has changed); thus we can 'trust' it without playing
+ ping-pong */
identity->addHost(msg);
if (stats != NULL)
- stats->change(stat_hello_update, 1);
+ stats->change(stat_hello_update, 1);
FREE(copy);
return OK;
}
#if DEBUG_ADVERTISING
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "HELLO advertisement differs from prior knowledge,"
- " requireing ping-pong confirmation.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "HELLO advertisement differs from prior knowledge,"
+ " requireing ping-pong confirmation.\n");
#endif
FREE(copy);
}
if (YES == GC_get_configuration_value_yesno(coreAPI->cfg,
- "GNUNETD",
- "PRIVATE-NETWORK",
- NO)) {
+ "GNUNETD",
+ "PRIVATE-NETWORK",
+ NO)) {
/* the option 'PRIVATE-NETWORK' can be used
to limit the connections of this peer to
peers of which the hostkey has been copied
@@ -292,8 +292,8 @@
editing :-). */
#if DEBUG_ADVERTISING
GE_LOG(ectx,
- GE_INFO | GE_BULK | GE_USER,
- "Private network, discarding unknown advertisements\n");
+ GE_INFO | GE_BULK | GE_USER,
+ "Private network, discarding unknown advertisements\n");
#endif
return SYSERR;
}
@@ -307,8 +307,8 @@
if ( (sender != NULL) &&
( (now - lasthelloMsg) / cronSECONDS) *
(os_network_monitor_get_limit(coreAPI->load_monitor,
- Download))
- < P2P_hello_MESSAGE_size(msg) * 10 ) {
+ Download))
+ < P2P_hello_MESSAGE_size(msg) * 10 ) {
/* do not use more than about 10% of the
available bandwidth to VERIFY hellos (by sending
our own with a PING). This does not affect
@@ -320,12 +320,12 @@
hello-ing by ourselves. */
#if DEBUG_ADVERTISING
GE_LOG(ectx,
- GE_INFO | GE_BULK | GE_USER,
- "Not enough resources to verify HELLO message at this time (%u * %u
< %u * 10)\n",
- (unsigned int) ((now - lasthelloMsg) / cronSECONDS),
- (unsigned int) os_network_monitor_get_limit(coreAPI->load_monitor,
- Download),
- (unsigned int) P2P_hello_MESSAGE_size(msg));
+ GE_INFO | GE_BULK | GE_USER,
+ "Not enough resources to verify HELLO message at this time (%u * %u < %u
* 10)\n",
+ (unsigned int) ((now - lasthelloMsg) / cronSECONDS),
+ (unsigned int) os_network_monitor_get_limit(coreAPI->load_monitor,
+ Download),
+ (unsigned int) P2P_hello_MESSAGE_size(msg));
#endif
if (stats != NULL)
stats->change(stat_hello_discard, 1);
@@ -353,18 +353,18 @@
}
copy = MALLOC(P2P_hello_MESSAGE_size(msg));
memcpy(copy,
- msg,
- P2P_hello_MESSAGE_size(msg));
+ msg,
+ P2P_hello_MESSAGE_size(msg));
ping = pingpong->pingUser(&msg->senderIdentity,
- &callAddHost,
- copy,
- YES,
- rand());
+ &callAddHost,
+ copy,
+ YES,
+ rand());
if (ping == NULL) {
res = SYSERR;
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- _("Could not send HELLO+PING, ping buffer full.\n"));
+ GE_INFO | GE_REQUEST | GE_USER,
+ _("Could not send HELLO+PING, ping buffer full.\n"));
transport->disconnect(tsession);
if (stats != NULL)
stats->change(stat_hello_ping_busy, 1);
@@ -373,16 +373,16 @@
buffer = MALLOC(mtu);
if (mtu > ntohs(ping->size)) {
helloEnd = transport->getAdvertisedhellos(mtu - ntohs(ping->size),
- buffer);
+ buffer);
GE_ASSERT(ectx,
- mtu - ntohs(ping->size) >= helloEnd);
+ mtu - ntohs(ping->size) >= helloEnd);
} else {
helloEnd = -2;
}
if (helloEnd <= 0) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Failed to create an advertisement for this peer. Will not send
PING.\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Failed to create an advertisement for this peer. Will not send
PING.\n"));
FREE(buffer);
if (stats != NULL)
stats->change(stat_hello_noselfad, 1);
@@ -391,16 +391,16 @@
}
res = OK;
memcpy(&buffer[helloEnd],
- ping,
- ntohs(ping->size));
+ ping,
+ ntohs(ping->size));
helloEnd += ntohs(ping->size);
FREE(ping);
/* ok, finally we can send! */
if ( (res == OK) &&
(SYSERR == coreAPI->sendPlaintext(tsession,
- buffer,
- helloEnd)) ) {
+ buffer,
+ helloEnd)) ) {
if (stats != NULL)
stats->change(stat_hello_send_error, 1);
@@ -425,9 +425,9 @@
static int
broadcastHelper(const PeerIdentity * hi,
- const unsigned short proto,
- int confirmed,
- void * cls) {
+ const unsigned short proto,
+ int confirmed,
+ void * cls) {
SendData * sd = cls;
P2P_hello_MESSAGE * hello;
TSession * tsession;
@@ -447,30 +447,30 @@
return OK;
#if DEBUG_ADVERTISING
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&hi->hashPubKey,
- &other));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&hi->hashPubKey,
+ &other));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Entering `%s' with target `%s'.\n",
- __FUNCTION__,
- &other);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Entering `%s' with target `%s'.\n",
+ __FUNCTION__,
+ &other);
#endif
if (0 == memcmp(hi,
- coreAPI->myIdentity,
- sizeof(PeerIdentity)))
+ coreAPI->myIdentity,
+ sizeof(PeerIdentity)))
return OK; /* never advertise to myself... */
prio = (int) getConnectPriority();
if (prio >= EXTREME_PRIORITY)
prio = EXTREME_PRIORITY / 4;
if (OK == coreAPI->queryPeerStatus(hi, NULL, NULL)) {
coreAPI->unicast(hi,
- &sd->m->header,
- prio,
- HELLO_BROADCAST_FREQUENCY);
+ &sd->m->header,
+ prio,
+ HELLO_BROADCAST_FREQUENCY);
if (stats != NULL)
stats->change(stat_hello_out,
- 1);
+ 1);
return OK;
}
/* with even lower probability (with n peers
@@ -484,14 +484,14 @@
/* establish short-lived connection, send, tear down */
hello = identity->identity2Hello(hi,
- proto,
- NO);
+ proto,
+ NO);
if (NULL == hello) {
#if DEBUG_ADVERTISING
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Exit from `%s' (error: `%s' failed).\n",
- __FUNCTION__,
- "identity2Hello");
+ "Exit from `%s' (error: `%s' failed).\n",
+ __FUNCTION__,
+ "identity2Hello");
#endif
return OK;
}
@@ -500,25 +500,25 @@
if (tsession == NULL) {
#if DEBUG_ADVERTISING
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Exit from `%s' (%s error).\n",
- __FUNCTION__,
- "transportConnect");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Exit from `%s' (%s error).\n",
+ __FUNCTION__,
+ "transportConnect");
#endif
return OK; /* could not connect */
}
if (stats != NULL)
stats->change(stat_hello_out,
- 1);
+ 1);
coreAPI->sendPlaintext(tsession,
- (char*)&sd->m->header,
- P2P_hello_MESSAGE_size(sd->m));
+ (char*)&sd->m->header,
+ P2P_hello_MESSAGE_size(sd->m));
transport->disconnect(tsession);
#if DEBUG_ADVERTISING
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Exit from %s.\n",
- __FUNCTION__);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Exit from %s.\n",
+ __FUNCTION__);
#endif
return OK;
}
@@ -529,43 +529,43 @@
*/
static void
broadcasthelloTransport(TransportAPI * tapi,
- void * cls) {
+ void * cls) {
const int * prob = cls;
SendData sd;
cron_t now;
if (os_network_monitor_get_load(coreAPI->load_monitor,
- Upload) > 100)
+ Upload) > 100)
return; /* network load too high... */
if ( ((*prob) != 0) &&
(0 != weak_randomi(*prob)) )
return; /* ignore */
now = get_time();
sd.n = identity->forEachHost(now,
- NULL,
- NULL); /* just count */
+ NULL,
+ NULL); /* just count */
sd.m = transport->createhello(tapi->protocolNumber);
if (sd.m == NULL)
return;
#if DEBUG_ADVERTISING
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- _("Advertising my transport %d to selected peers.\n"),
- tapi->protocolNumber);
+ GE_INFO | GE_REQUEST | GE_USER,
+ _("Advertising my transport %d to selected peers.\n"),
+ tapi->protocolNumber);
#endif
identity->addHost(sd.m);
if (sd.n < 1) {
if (identity->forEachHost(0, NULL, NULL) == 0)
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Announcing ourselves pointless: "
- "no other peers are known to us so far.\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Announcing ourselves pointless: "
+ "no other peers are known to us so far.\n"));
FREE(sd.m);
return; /* no point in trying... */
}
identity->forEachHost(now,
- &broadcastHelper,
- &sd);
+ &broadcastHelper,
+ &sd);
FREE(sd.m);
}
@@ -577,16 +577,16 @@
unsigned int i;
if (os_network_monitor_get_load(coreAPI->load_monitor,
- Upload) > 100)
+ Upload) > 100)
return; /* network load too high... */
if (os_cpu_get_load(coreAPI->ectx,
- coreAPI->cfg) > 100)
+ coreAPI->cfg) > 100)
return; /* CPU load too high... */
i = transport->forEach(NULL,
- NULL);
+ NULL);
if (i > 0)
transport->forEach(&broadcasthelloTransport,
- &i);
+ &i);
}
typedef struct {
@@ -595,24 +595,24 @@
} FCC;
static void forwardCallback(const PeerIdentity * peer,
- void * cls) {
+ void * cls) {
FCC * fcc = cls;
if (os_network_monitor_get_load(coreAPI->load_monitor,
- Upload) > 100)
+ Upload) > 100)
return; /* network load too high... */
if ( (fcc->prob != 0) &&
(weak_randomi(fcc->prob) != 0) )
return; /* only forward with a certain chance */
if (equalsHashCode512(&peer->hashPubKey,
- &fcc->msg->senderIdentity.hashPubKey))
+ &fcc->msg->senderIdentity.hashPubKey))
return; /* do not bounce the hello of a peer back
- to the same peer! */
+ to the same peer! */
if (stats != NULL)
stats->change(stat_hello_fwd, 1);
coreAPI->unicast(peer,
- &fcc->msg->header,
- 0, /* priority */
- HELLO_BROADCAST_FREQUENCY);
+ &fcc->msg->header,
+ 0, /* priority */
+ HELLO_BROADCAST_FREQUENCY);
}
/**
@@ -620,9 +620,9 @@
*/
static int
forwardhelloHelper(const PeerIdentity * peer,
- unsigned short protocol,
- int confirmed,
- void * data) {
+ unsigned short protocol,
+ int confirmed,
+ void * data) {
int * probability = data;
P2P_hello_MESSAGE * hello;
TIME_T now;
@@ -630,15 +630,15 @@
FCC fcc;
if (os_network_monitor_get_load(coreAPI->load_monitor,
- Upload) > 100)
+ Upload) > 100)
return SYSERR; /* network load too high... */
if (confirmed == NO)
return OK;
if (protocol == NAT_PROTOCOL_NUMBER)
return OK; /* don't forward NAT addresses */
hello = identity->identity2Hello(peer,
- protocol,
- NO);
+ protocol,
+ NO);
if (NULL == hello)
return OK; /* this should not happen */
/* do not forward expired hellos */
@@ -648,14 +648,14 @@
EncName enc;
/* remove hellos that expired */
IF_GELOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- hash2enc(&peer->hashPubKey,
- &enc));
+ GE_INFO | GE_REQUEST | GE_USER,
+ hash2enc(&peer->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- "Removing HELLO from peer `%s' (expired %ds ago).\n",
- &enc,
- now - ntohl(hello->expirationTime));
+ GE_INFO | GE_REQUEST | GE_USER,
+ "Removing HELLO from peer `%s' (expired %ds ago).\n",
+ &enc,
+ now - ntohl(hello->expirationTime));
#endif
identity->delHostFromKnown(peer, protocol);
FREE(hello);
@@ -665,15 +665,15 @@
if (weak_randomi((*probability)+1) != 0) {
FREE(hello);
return OK; /* only forward with a certain chance,
- (on average: 1 peer per run!) */
+ (on average: 1 peer per run!) */
}
count = coreAPI->forAllConnectedNodes(NULL,
- NULL);
+ NULL);
if (count > 0) {
fcc.msg = hello;
fcc.prob = count;
coreAPI->forAllConnectedNodes(&forwardCallback,
- &fcc);
+ &fcc);
}
FREE(hello);
return OK;
@@ -689,18 +689,18 @@
int count;
if (os_cpu_get_load(coreAPI->ectx,
- coreAPI->cfg) > 100)
+ coreAPI->cfg) > 100)
return; /* CPU load too high... */
if (os_network_monitor_get_load(coreAPI->load_monitor,
- Upload) > 100)
+ Upload) > 100)
return; /* network load too high... */
count = identity->forEachHost(0,
- NULL,
- NULL);
+ NULL,
+ NULL);
if (count > 0)
identity->forEachHost(0, /* ignore blacklisting */
- &forwardhelloHelper,
- &count);
+ &forwardhelloHelper,
+ &count);
}
/**
@@ -708,14 +708,14 @@
*/
static int
ehelloHandler(const PeerIdentity * sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
if (OK == receivedhello(sender,
- message)) {
+ message)) {
/* if the hello was ok, update traffic preference
for the peer (depending on how much we like
to learn about other peers) */
coreAPI->preferTrafficFrom(sender,
- getConnectPriority());
+ getConnectPriority());
}
return OK; /* even if we had errors processing the hello, keep going */
}
@@ -725,10 +725,10 @@
*/
static int
phelloHandler(const PeerIdentity * sender,
- const MESSAGE_HEADER * message,
- TSession * session) {
+ const MESSAGE_HEADER * message,
+ TSession * session) {
receivedhello(sender,
- message);
+ message);
return OK;
}
@@ -739,55 +739,55 @@
*/
static int
configurationUpdateCallback(void * ctx,
- struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option) {
+ struct GC_Configuration * cfg,
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option) {
if (0 != strcmp(section, "NETWORK"))
return 0;
if (ACJ_ANNOUNCE == (activeCronJobs & ACJ_ANNOUNCE)) {
if (YES == GC_get_configuration_value_yesno(cfg,
- "NETWORK",
- "DISABLE-ADVERTISEMENTS",
- NO))
+ "NETWORK",
+ "DISABLE-ADVERTISEMENTS",
+ NO))
cron_del_job(coreAPI->cron,
- &broadcasthello,
- HELLO_BROADCAST_FREQUENCY,
- NULL);
+ &broadcasthello,
+ HELLO_BROADCAST_FREQUENCY,
+ NULL);
activeCronJobs -= ACJ_ANNOUNCE;
} else {
if (YES != GC_get_configuration_value_yesno(cfg,
- "NETWORK",
- "DISABLE-ADVERTISEMENTS",
- NO))
+ "NETWORK",
+ "DISABLE-ADVERTISEMENTS",
+ NO))
cron_add_job(coreAPI->cron,
- &broadcasthello,
- 15 * cronSECONDS,
- HELLO_BROADCAST_FREQUENCY,
- NULL);
+ &broadcasthello,
+ 15 * cronSECONDS,
+ HELLO_BROADCAST_FREQUENCY,
+ NULL);
activeCronJobs += ACJ_ANNOUNCE;
}
if (ACJ_FORWARD == (activeCronJobs & ACJ_FORWARD)) {
if (YES != GC_get_configuration_value_yesno(cfg,
- "NETWORK",
- "HELLOEXCHANGE",
- YES)) {
+ "NETWORK",
+ "HELLOEXCHANGE",
+ YES)) {
cron_del_job(coreAPI->cron,
- &forwardhello,
- HELLO_FORWARD_FREQUENCY,
- NULL); /* seven minutes: exchange */
+ &forwardhello,
+ HELLO_FORWARD_FREQUENCY,
+ NULL); /* seven minutes: exchange */
}
activeCronJobs -= ACJ_FORWARD;
} else {
if (YES == GC_get_configuration_value_yesno(cfg,
- "NETWORK",
- "HELLOEXCHANGE",
- YES)) {
+ "NETWORK",
+ "HELLOEXCHANGE",
+ YES)) {
cron_add_job(coreAPI->cron,
- &forwardhello,
- 15 * cronSECONDS,
- HELLO_FORWARD_FREQUENCY,
- NULL);
+ &forwardhello,
+ 15 * cronSECONDS,
+ HELLO_FORWARD_FREQUENCY,
+ NULL);
}
activeCronJobs += ACJ_FORWARD;
}
@@ -851,27 +851,27 @@
}
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("`%s' registering handler %d (plaintext and ciphertext)\n"),
- "advertising",
- p2p_PROTO_hello);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("`%s' registering handler %d (plaintext and ciphertext)\n"),
+ "advertising",
+ p2p_PROTO_hello);
capi->registerHandler(p2p_PROTO_hello,
- &ehelloHandler);
+ &ehelloHandler);
capi->registerPlaintextHandler(p2p_PROTO_hello,
- &phelloHandler);
+ &phelloHandler);
if (0 != GC_attach_change_listener(capi->cfg,
- &configurationUpdateCallback,
- NULL))
+ &configurationUpdateCallback,
+ NULL))
GE_BREAK(capi->ectx, 0);
startBootstrap(capi);
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "advertising",
- _("ensures that this peer is
known by other"
- " peers and discovers
other peers")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "advertising",
+ _("ensures that this peer is known
by other"
+ " peers and discovers other
peers")));
return OK;
}
@@ -881,26 +881,26 @@
void done_module_advertising() {
stopBootstrap();
GC_detach_change_listener(coreAPI->cfg,
- &configurationUpdateCallback,
- NULL);
+ &configurationUpdateCallback,
+ NULL);
if (ACJ_ANNOUNCE == (activeCronJobs & ACJ_ANNOUNCE)) {
cron_del_job(coreAPI->cron,
- &broadcasthello,
- HELLO_BROADCAST_FREQUENCY,
- NULL);
+ &broadcasthello,
+ HELLO_BROADCAST_FREQUENCY,
+ NULL);
activeCronJobs -= ACJ_ANNOUNCE;
}
if (ACJ_FORWARD == (activeCronJobs & ACJ_FORWARD)) {
cron_del_job(coreAPI->cron,
- &forwardhello,
- HELLO_FORWARD_FREQUENCY,
- NULL); /* seven minutes: exchange */
+ &forwardhello,
+ HELLO_FORWARD_FREQUENCY,
+ NULL); /* seven minutes: exchange */
activeCronJobs -= ACJ_FORWARD;
}
coreAPI->unregisterHandler(p2p_PROTO_hello,
- &ehelloHandler);
+ &ehelloHandler);
coreAPI->unregisterPlaintextHandler(p2p_PROTO_hello,
- &phelloHandler);
+ &phelloHandler);
coreAPI->releaseService(transport);
transport = NULL;
coreAPI->releaseService(identity);
Modified: GNUnet/src/applications/advertising/advertising_test.c
===================================================================
--- GNUnet/src/applications/advertising/advertising_test.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/advertising/advertising_test.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -43,11 +43,11 @@
#define NUM_ROUNDS 10
static int countConnections(const char * name,
- unsigned long long value,
- void * cls) {
+ unsigned long long value,
+ void * cls) {
int * num = cls;
if (0 == strcmp(_("# of connected peers"),
- name)) {
+ name)) {
*num = value;
return SYSERR;
}
@@ -59,7 +59,7 @@
* @return 0: ok, -1: error
*/
int main(int argc,
- const char ** argv) {
+ const char ** argv) {
struct DaemonContext * peers;
int ret = 0;
struct GE_Context * ectx;
@@ -75,16 +75,16 @@
ectx = NULL;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
peers = gnunet_testing_start_daemons(NULL == strstr(argv[0], "_udp") ? "tcp"
: "udp",
- "advertising stats",
- "/tmp/gnunet-advertising-test",
- 2087,
- 10,
- NUM_PEERS);
+ "advertising stats",
+ "/tmp/gnunet-advertising-test",
+ 2087,
+ 10,
+ NUM_PEERS);
if (peers == NULL) {
GC_free(cfg);
return -1;
@@ -92,12 +92,12 @@
/* do circular connect */
for (i=0;i<NUM_PEERS;i++) {
if (OK != gnunet_testing_connect_daemons(2087 + 10*i,
- 2087 + 10* ( (i+1) % NUM_PEERS))) {
+ 2087 + 10* ( (i+1) % NUM_PEERS))) {
gnunet_testing_stop_daemons(peers);
fprintf(stderr,
- "Failed to connect peers %d and %d!\n",
- i,
- (i+1) % NUM_PEERS);
+ "Failed to connect peers %d and %d!\n",
+ i,
+ (i+1) % NUM_PEERS);
GC_free(cfg);
return -1;
}
@@ -112,30 +112,30 @@
min = NUM_PEERS;
for (i=0;i<NUM_PEERS;i++) {
SNPRINTF(buf,
- 128,
- "localhost:%u",
- 2087 + i * 10);
+ 128,
+ "localhost:%u",
+ 2087 + i * 10);
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- buf);
+ ectx,
+ "NETWORK",
+ "HOST",
+ buf);
sock = client_connection_create(NULL,
- cfg);
+ cfg);
STATS_getStatistics(NULL,
- sock,
- &countConnections,
- &have);
+ sock,
+ &countConnections,
+ &have);
connection_destroy(sock);
found += have;
if (have < min)
- min = have;
+ min = have;
}
fprintf(stderr,
- "Have %d connections total in round %d, minimum number was %d\n",
- found,
- k,
- min);
+ "Have %d connections total in round %d, minimum number was %d\n",
+ found,
+ k,
+ min);
if (k < NUM_ROUNDS - 1)
PTHREAD_SLEEP(45 * cronSECONDS); /* one hello-forward round is 45s! */
}
Modified: GNUnet/src/applications/advertising/bootstrap.c
===================================================================
--- GNUnet/src/applications/advertising/bootstrap.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/advertising/bootstrap.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -67,48 +67,48 @@
return;
}
while ( (! hcq->do_shutdown) &&
- (hcq->hellosCount > 0) ) {
+ (hcq->hellosCount > 0) ) {
/* select hellos in random order */
rndidx = weak_randomi(hcq->hellosCount);
#if DEBUG_BOOTSTRAP
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "%s chose hello %d of %d\n",
- __FUNCTION__,
- rndidx, hcq->hellosCount);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "%s chose hello %d of %d\n",
+ __FUNCTION__,
+ rndidx, hcq->hellosCount);
#endif
msg = (P2P_hello_MESSAGE*) hcq->hellos[rndidx];
hcq->hellos[rndidx]
= hcq->hellos[hcq->hellosCount-1];
GROW(hcq->hellos,
- hcq->hellosCount,
- hcq->hellosCount-1);
+ hcq->hellosCount,
+ hcq->hellosCount-1);
coreAPI->injectMessage(NULL,
- (const char*)msg,
- ntohs(msg->header.size),
- NO,
- NULL);
+ (const char*)msg,
+ ntohs(msg->header.size),
+ NO,
+ NULL);
FREE(msg);
if ( (hcq->hellosCount > 0) &&
- (! hlc.do_shutdown) ) {
+ (! hlc.do_shutdown) ) {
/* wait a bit */
unsigned int load;
int nload;
load = os_cpu_get_load(coreAPI->ectx,
- coreAPI->cfg);
+ coreAPI->cfg);
if (load == (unsigned int)-1)
- load = 50;
+ load = 50;
nload = os_network_monitor_get_load(coreAPI->load_monitor,
- Upload);
+ Upload);
if (nload > load)
- load = nload;
+ load = nload;
nload = os_network_monitor_get_load(coreAPI->load_monitor,
- Download);
+ Download);
if (nload > load)
- load = nload;
+ load = nload;
if (load > 100)
- load = 100;
+ load = 100;
PTHREAD_SLEEP(50 + weak_randomi((load+1)*(load+1)));
}
@@ -121,17 +121,17 @@
}
static void downloadHostlistCallback(const P2P_hello_MESSAGE * hello,
- void * c) {
+ void * c) {
HelloListClosure * cls = c;
if (cls->hellosCount >= cls->hellosLen) {
GROW(cls->hellos,
- cls->hellosLen,
- cls->hellosLen + hello_HELPER_TABLE_START_SIZE);
+ cls->hellosLen,
+ cls->hellosLen + hello_HELPER_TABLE_START_SIZE);
}
cls->hellos[cls->hellosCount++] = MALLOC(ntohs(hello->header.size));
memcpy(cls->hellos[cls->hellosCount-1],
- hello,
- ntohs(hello->header.size));
+ hello,
+ ntohs(hello->header.size));
}
#define BOOTSTRAP_INFO "bootstrap-info"
@@ -155,8 +155,8 @@
if (lastTest == 0) {
/* first run in this process */
if (-1 != state->read(coreAPI->ectx,
- BOOTSTRAP_INFO,
- (void**)&data)) {
+ BOOTSTRAP_INFO,
+ (void**)&data)) {
/* but not first on this machine */
lastTest = now;
delta = 2 * cronMINUTES; /* wait 2 minutes */
@@ -164,9 +164,9 @@
} else {
/* first on this machine, too! */
state->write(coreAPI->ectx,
- BOOTSTRAP_INFO,
- 1,
- "X");
+ BOOTSTRAP_INFO,
+ 1,
+ "X");
delta = 60 * cronSECONDS;
}
}
@@ -189,24 +189,24 @@
while (NO == hlc.do_shutdown) {
PTHREAD_SLEEP(2 * cronSECONDS);
if (needBootstrap())
- break;
+ break;
}
if (YES == hlc.do_shutdown)
break;
#if DEBUG_BOOTSTRAP
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Starting bootstrap.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Starting bootstrap.\n");
#endif
hlc.hellosLen = 0;
hlc.hellosCount = 0;
bootstrap->bootstrap(&downloadHostlistCallback,
- &hlc,
- &testTerminate,
- &hlc);
+ &hlc,
+ &testTerminate,
+ &hlc);
GROW(hlc.hellos,
- hlc.hellosLen,
- hlc.hellosCount);
+ hlc.hellosLen,
+ hlc.hellosCount);
processhellos(&hlc);
}
return NULL;
@@ -220,16 +220,16 @@
coreAPI = capi;
state = capi->requestService("state");
GE_ASSERT(capi->ectx,
- state != NULL);
+ state != NULL);
bootstrap = capi->requestService("bootstrap");
GE_ASSERT(capi->ectx,
- bootstrap != NULL);
+ bootstrap != NULL);
hlc.do_shutdown = NO;
pt = PTHREAD_CREATE(&processThread,
- NULL,
- 64 * 1024);
+ NULL,
+ 64 * 1024);
GE_ASSERT(capi->ectx,
- pt != NULL);
+ pt != NULL);
}
/**
Modified: GNUnet/src/applications/bootstrap_http/http.c
===================================================================
--- GNUnet/src/applications/bootstrap_http/http.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/bootstrap_http/http.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -71,9 +71,9 @@
*/
static size_t
downloadHostlistHelper(void * ptr,
- size_t size,
- size_t nmemb,
- void * ctx) {
+ size_t size,
+ size_t nmemb,
+ void * ctx) {
BootstrapContext * bctx = ctx;
size_t osize;
unsigned int total;
@@ -89,34 +89,34 @@
bctx->bsize,
total);
memcpy(&bctx->buf[osize],
- ptr,
- size * nmemb);
+ ptr,
+ size * nmemb);
while ( (bctx->bsize >= sizeof(P2P_hello_MESSAGE)) &&
- (bctx->termTest(bctx->targ)) ) {
+ (bctx->termTest(bctx->targ)) ) {
hello = (const P2P_hello_MESSAGE*) &bctx->buf[0];
hs = ntohs(hello->header.size);
if (bctx->bsize < hs)
break; /* incomplete */
if ( (ntohs(hello->header.type) != p2p_PROTO_hello) ||
- (ntohs(hello->header.size) != P2P_hello_MESSAGE_size(hello) ) ||
- (P2P_hello_MESSAGE_size(hello) >= MAX_BUFFER_SIZE) ) {
+ (ntohs(hello->header.size) != P2P_hello_MESSAGE_size(hello) ) ||
+ (P2P_hello_MESSAGE_size(hello) >= MAX_BUFFER_SIZE) ) {
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_IMMEDIATE,
- _("Bootstrap data obtained from `%s' is invalid.\n"),
- bctx->url);
+ GE_WARNING | GE_USER | GE_IMMEDIATE,
+ _("Bootstrap data obtained from `%s' is invalid.\n"),
+ bctx->url);
return 0; /* Error: invalid format! */
}
if (stats != NULL)
stats->change(stat_hellodownloaded,
- 1);
+ 1);
bctx->callback(hello,
- bctx->arg);
+ bctx->arg);
memmove(&bctx->buf[0],
- &bctx->buf[hs],
- bctx->bsize - hs);
+ &bctx->buf[hs],
+ bctx->bsize - hs);
GROW(bctx->buf,
- bctx->bsize,
- bctx->bsize - hs);
+ bctx->bsize,
+ bctx->bsize - hs);
}
return size * nmemb;
}
@@ -125,9 +125,9 @@
static void downloadHostlist(bootstrap_hello_callback callback,
- void * arg,
- bootstrap_terminate_callback termTest,
- void * targ) {
+ void * arg,
+ bootstrap_terminate_callback termTest,
+ void * targ) {
BootstrapContext bctx;
char * url;
char * proxy;
@@ -167,13 +167,13 @@
}
url = NULL;
if (0 != GC_get_configuration_value_string(coreAPI->cfg,
- "GNUNETD",
- "HOSTLISTURL",
- "",
- &url)) {
+ "GNUNETD",
+ "HOSTLISTURL",
+ "",
+ &url)) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("No hostlist URL specified in configuration, will not
bootstrap.\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("No hostlist URL specified in configuration, will not bootstrap.\n"));
FREE(url);
curl_easy_cleanup(curl);
return;
@@ -184,7 +184,7 @@
pos = strlen(url) - 1;
while (pos > 0) {
if (url[pos] == ' ')
- urls++;
+ urls++;
pos--;
}
}
@@ -207,55 +207,55 @@
pos--;
}
GE_LOG(ectx,
- GE_INFO | GE_BULK | GE_USER,
- _("Bootstrapping using `%s'.\n"),
- url);
+ GE_INFO | GE_BULK | GE_USER,
+ _("Bootstrapping using `%s'.\n"),
+ url);
bctx.url = url;
bctx.total = 0;
proxy = NULL;
GC_get_configuration_value_string(coreAPI->cfg,
- "GNUNETD",
- "HTTP-PROXY",
- "",
- &proxy);
+ "GNUNETD",
+ "HTTP-PROXY",
+ "",
+ &proxy);
CURL_EASY_SETOPT(curl,
- CURLOPT_WRITEFUNCTION,
- &downloadHostlistHelper);
+ CURLOPT_WRITEFUNCTION,
+ &downloadHostlistHelper);
CURL_EASY_SETOPT(curl,
- CURLOPT_WRITEDATA,
- &bctx);
+ CURLOPT_WRITEDATA,
+ &bctx);
if (ret != CURLE_OK)
goto cleanup;
CURL_EASY_SETOPT(curl,
- CURLOPT_FAILONERROR,
- 1);
+ CURLOPT_FAILONERROR,
+ 1);
CURL_EASY_SETOPT(curl,
- CURLOPT_URL,
- &url[pos]);
+ CURLOPT_URL,
+ &url[pos]);
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- _("Trying to download hostlist from `%s'\n"),
- &url[pos]);
+ GE_INFO | GE_USER | GE_BULK,
+ _("Trying to download hostlist from `%s'\n"),
+ &url[pos]);
if (strlen(proxy) > 0)
CURL_EASY_SETOPT(curl,
- CURLOPT_PROXY,
- proxy);
+ CURLOPT_PROXY,
+ proxy);
CURL_EASY_SETOPT(curl,
- CURLOPT_BUFFERSIZE,
- 1024); /* a bit more than one HELLO */
+ CURLOPT_BUFFERSIZE,
+ 1024); /* a bit more than one HELLO */
if (0 == strncmp(&url[pos], "http", 4))
CURL_EASY_SETOPT(curl,
- CURLOPT_USERAGENT,
- "GNUnet");
+ CURLOPT_USERAGENT,
+ "GNUnet");
CURL_EASY_SETOPT(curl,
- CURLOPT_CONNECTTIMEOUT,
- 150L);
+ CURLOPT_CONNECTTIMEOUT,
+ 150L);
/* NOTE: use of CONNECTTIMEOUT without also
setting NOSIGNAL results in really weird
crashes on my system! */
CURL_EASY_SETOPT(curl,
- CURLOPT_NOSIGNAL,
- 1);
+ CURLOPT_NOSIGNAL,
+ 1);
#if USE_MULTI
multi = curl_multi_init();
if (multi == NULL) {
@@ -265,33 +265,33 @@
mret = curl_multi_add_handle(multi, curl);
if (mret != CURLM_OK) {
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_multi_add_handle",
- __FILE__,
- __LINE__,
- curl_multi_strerror(mret));
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_multi_add_handle",
+ __FILE__,
+ __LINE__,
+ curl_multi_strerror(mret));
goto cleanup;
}
while ( (YES == termTest(targ)) &&
- (GNUNET_SHUTDOWN_TEST() == NO) ) {
+ (GNUNET_SHUTDOWN_TEST() == NO) ) {
max = 0;
FD_ZERO(&rs);
FD_ZERO(&ws);
FD_ZERO(&es);
mret = curl_multi_fdset(multi,
- &rs,
- &ws,
- &es,
- &max);
+ &rs,
+ &ws,
+ &es,
+ &max);
if (mret != CURLM_OK) {
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_multi_fdset",
- __FILE__,
- __LINE__,
- curl_multi_strerror(mret));
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_multi_fdset",
+ __FILE__,
+ __LINE__,
+ curl_multi_strerror(mret));
goto cleanup;
}
/* use timeout of 1s in case that SELECT is not interrupted by
@@ -300,50 +300,50 @@
tv.tv_sec = 0;
tv.tv_usec = 1000;
SELECT(max + 1,
- &rs,
- &ws,
- &es,
- &tv);
+ &rs,
+ &ws,
+ &es,
+ &tv);
if (YES != termTest(targ))
break;
do {
running = 0;
mret = curl_multi_perform(multi, &running);
if (running == 0) {
- do {
- msg = curl_multi_info_read(multi,
- &running);
- GE_BREAK(ectx, msg != NULL);
- if (msg == NULL)
- break;
- switch (msg->msg) {
- case CURLMSG_DONE:
- if (msg->data.result != CURLE_OK)
- GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_multi_perform",
- __FILE__,
- __LINE__,
- curl_easy_strerror(msg->data.result));
- break;
- default:
- break;
- }
- } while (running > 0);
- break;
+ do {
+ msg = curl_multi_info_read(multi,
+ &running);
+ GE_BREAK(ectx, msg != NULL);
+ if (msg == NULL)
+ break;
+ switch (msg->msg) {
+ case CURLMSG_DONE:
+ if (msg->data.result != CURLE_OK)
+ GE_LOG(ectx,
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_multi_perform",
+ __FILE__,
+ __LINE__,
+ curl_easy_strerror(msg->data.result));
+ break;
+ default:
+ break;
+ }
+ } while (running > 0);
+ break;
}
} while ( (mret == CURLM_CALL_MULTI_PERFORM) &&
- (YES == termTest(targ)) );
+ (YES == termTest(targ)) );
if ( (mret != CURLM_OK) &&
- (mret != CURLM_CALL_MULTI_PERFORM) ) {
+ (mret != CURLM_CALL_MULTI_PERFORM) ) {
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_multi_perform",
- __FILE__,
- __LINE__,
- curl_multi_strerror(mret));
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_multi_perform",
+ __FILE__,
+ __LINE__,
+ curl_multi_strerror(mret));
goto cleanup;
}
if (running == 0)
@@ -352,42 +352,42 @@
mret = curl_multi_remove_handle(multi, curl);
if (mret != CURLM_OK) {
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_multi_remove_handle",
- __FILE__,
- __LINE__,
- curl_multi_strerror(mret));
+ GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_multi_remove_handle",
+ __FILE__,
+ __LINE__,
+ curl_multi_strerror(mret));
goto cleanup;
}
#else
ret = curl_easy_perform(curl);
if (ret != CURLE_OK)
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_easy_perform",
- __FILE__,
- __LINE__,
- curl_easy_strerror(ret));
+ GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_easy_perform",
+ __FILE__,
+ __LINE__,
+ curl_easy_strerror(ret));
#endif
curl_easy_cleanup(curl);
#if USE_MULTI
mret = curl_multi_cleanup(multi);
if (mret != CURLM_OK)
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_multi_cleanup",
- __FILE__,
- __LINE__,
- curl_multi_strerror(mret));
+ GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_multi_cleanup",
+ __FILE__,
+ __LINE__,
+ curl_multi_strerror(mret));
#endif
GE_LOG(ectx,
- GE_INFO | GE_BULK | GE_USER,
- _("Downloaded %llu bytes from `%s'.\n"),
- bctx.total,
- url);
+ GE_INFO | GE_BULK | GE_USER,
+ _("Downloaded %llu bytes from `%s'.\n"),
+ bctx.total,
+ url);
FREE(url);
FREE(proxy);
curl_global_cleanup();
Modified: GNUnet/src/applications/bootstrap_http/httptest.c
===================================================================
--- GNUnet/src/applications/bootstrap_http/httptest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/bootstrap_http/httptest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -45,7 +45,7 @@
static void hello(const P2P_hello_MESSAGE * m,
- void * arg) {
+ void * arg) {
count++;
}
@@ -59,14 +59,14 @@
Bootstrap_ServiceAPI * boot = b;
boot->bootstrap(&hello,
- NULL,
- &terminate,
- NULL);
+ NULL,
+ &terminate,
+ NULL);
return NULL;
}
int main(int argc,
- char ** argv) {
+ char ** argv) {
static CoreAPIForApplication capi;
struct GC_Configuration * cfg;
struct PluginHandle * plugin;
@@ -79,30 +79,30 @@
count = 0;
cfg = GC_create_C_impl();
GC_set_configuration_value_string(cfg,
- NULL,
- "GNUNETD",
- "HOSTLISTURL",
- "http://gnunet.org/hostlist");
+ NULL,
+ "GNUNETD",
+ "HOSTLISTURL",
+ "http://gnunet.org/hostlist");
memset(&capi,
- 0,
- sizeof(CoreAPIForApplication));
+ 0,
+ sizeof(CoreAPIForApplication));
capi.cfg = cfg;
capi.requestService = &rs;
capi.releaseService = &rsx;
plugin = os_plugin_load(NULL,
- "libgnunetmodule_",
- "bootstrap");
+ "libgnunetmodule_",
+ "bootstrap");
init = os_plugin_resolve_function(plugin,
- "provide_module_",
- YES);
+ "provide_module_",
+ YES);
boot = init(&capi);
p = PTHREAD_CREATE(&pt,
- boot,
- 1024 * 64);
+ boot,
+ 1024 * 64);
PTHREAD_JOIN(p, &unused);
done = os_plugin_resolve_function(plugin,
- "release_module_",
- YES);
+ "release_module_",
+ YES);
done();
os_plugin_unload(plugin);
GC_free(cfg);
Modified: GNUnet/src/applications/chat/chat.c
===================================================================
--- GNUnet/src/applications/chat/chat.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/chat/chat.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -45,8 +45,8 @@
if (++ringIndex >= MAX_LAST_MESSAGES)
ringIndex = 0;
memcpy(&lastMsgs[ringIndex],
- hc,
- sizeof(HashCode512));
+ hc,
+ sizeof(HashCode512));
}
typedef struct {
@@ -56,26 +56,26 @@
} BCC;
static void bccHelper(const PeerIdentity * peer,
- BCC * bcc) {
+ BCC * bcc) {
coreAPI->unicast(peer,
- bcc->message,
- bcc->prio,
- bcc->delay);
+ bcc->message,
+ bcc->prio,
+ bcc->delay);
}
static void broadcastToConnected(const MESSAGE_HEADER * message,
- unsigned int prio,
- unsigned int delay) {
+ unsigned int prio,
+ unsigned int delay) {
BCC bcc;
bcc.message = message;
bcc.prio = prio;
bcc.delay = delay;
coreAPI->forAllConnectedNodes((PerNodeCallback)bccHelper,
- &bcc);
+ &bcc);
}
static int handleChatMSG(const PeerIdentity * sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
int i;
int j;
CS_chat_MESSAGE * cmsg;
@@ -84,7 +84,7 @@
if (ntohs(message->size) != sizeof(P2P_chat_MESSAGE)) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Message received from peer is invalid.\n"));
+ _("Message received from peer is invalid.\n"));
return SYSERR;
}
pmsg = (P2P_chat_MESSAGE*)message;
@@ -107,14 +107,14 @@
cmsg->header.type = htons(CS_PROTO_chat_MSG);
for (j=0;j<clientCount;j++)
coreAPI->sendToClient(clients[j],
- &cmsg->header);
+ &cmsg->header);
pmsg->nick[CHAT_NICK_LENGTH-1] = '\0';
pmsg->message[CHAT_MSG_LENGTH-1] = '\0';
/*
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- " CHAT: received new message from %s: %s\n",
- &pmsg->nick[0],
- &pmsg->message[0]);
+ " CHAT: received new message from %s: %s\n",
+ &pmsg->nick[0],
+ &pmsg->message[0]);
*/
}
MUTEX_UNLOCK(&chatMutex);
@@ -122,7 +122,7 @@
}
static int csHandleChatRequest(ClientHandle client,
- const CS_MESSAGE_HEADER * message) {
+ const CS_MESSAGE_HEADER * message) {
int i;
int j;
CS_chat_MESSAGE * cmsg;
@@ -131,7 +131,7 @@
if (ntohs(message->size) != sizeof(CS_chat_MESSAGE)) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Message received from client is invalid\n"));
+ _("Message received from client is invalid\n"));
return SYSERR; /* invalid message */
}
pmsg = (P2P_chat_MESSAGE*)message;
@@ -149,16 +149,16 @@
j = i;
else
coreAPI->sendToClient(clients[i],
- message);
+ message);
if (j == -1) {
if (clientCount == MAX_CLIENTS)
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Maximum number of chat clients reached.\n"));
+ _("Maximum number of chat clients reached.\n"));
else {
clients[clientCount++] = client;
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- _("Now %d of %d chat clients at this node.\n"),
- clientCount, MAX_CLIENTS);
+ _("Now %d of %d chat clients at this node.\n"),
+ clientCount, MAX_CLIENTS);
}
}
/* forward to all other nodes in the network */
@@ -174,7 +174,7 @@
for (i=0;i<clientCount;i++)
if (clients[i] == client) {
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Chat client exits.\n");
+ "Chat client exits.\n");
clients[i] = clients[--clientCount];
break;
}
@@ -200,29 +200,29 @@
CS_PROTO_chat_MSG);
if (SYSERR == capi->registerHandler(P2P_PROTO_chat_MSG,
- &handleChatMSG))
+ &handleChatMSG))
ok = SYSERR;
if (SYSERR == capi->registerClientExitHandler(&chatClientExitHandler))
ok = SYSERR;
if (SYSERR == capi->registerClientHandler(CS_PROTO_chat_MSG,
- &csHandleChatRequest))
+ &csHandleChatRequest))
ok = SYSERR;
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "chat",
- _("enables P2P-chat
(incomplete)")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "chat",
+ _("enables P2P-chat (incomplete)")));
return ok;
}
void done_module_chat() {
coreAPI->unregisterHandler(P2P_PROTO_chat_MSG,
- &handleChatMSG);
+ &handleChatMSG);
coreAPI->unregisterClientExitHandler(&chatClientExitHandler);
coreAPI->unregisterClientHandler(CS_PROTO_chat_MSG,
- &csHandleChatRequest);
+ &csHandleChatRequest);
MUTEX_DESTROY(&chatMutex);
coreAPI = NULL;
}
Modified: GNUnet/src/applications/chat/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/gnunet-chat.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/chat/gnunet-chat.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -39,13 +39,13 @@
* @return OK on error, SYSERR if we should exit
*/
static int parseOptions(int argc,
- char ** argv) {
+ char ** argv) {
int option_index;
int c;
FREENONNULL(setConfigurationString("GNUNETD",
- "LOGFILE",
- NULL));
+ "LOGFILE",
+ NULL));
while (1) {
static struct GNoption long_options[] = {
LONG_DEFAULT_OPTIONS,
@@ -54,10 +54,10 @@
};
option_index=0;
c = GNgetopt_long(argc,
- argv,
- "vhdc:L:H:n:",
- long_options,
- &option_index);
+ argv,
+ "vhdc:L:H:n:",
+ long_options,
+ &option_index);
if (c == -1)
break; /* No more flags to process */
if (YES == parseDefaultOptions(c, GNoptarg))
@@ -65,32 +65,32 @@
switch(c) {
case 'n':
FREENONNULL(setConfigurationString("GNUNET-CHAT",
- "NICK",
- GNoptarg));
+ "NICK",
+ GNoptarg));
break;
case 'v':
printf("GNUnet v%s, gnunet-chat v%s\n",
- VERSION,
- CHAT_VERSION);
+ VERSION,
+ CHAT_VERSION);
return SYSERR;
case 'h': {
static Help help[] = {
- HELP_CONFIG,
- HELP_HELP,
- HELP_LOGLEVEL,
- { 'n', "nickname", NULL,
- gettext_noop("specify nickname") },
- HELP_VERSION,
- HELP_END,
+ HELP_CONFIG,
+ HELP_HELP,
+ HELP_LOGLEVEL,
+ { 'n', "nickname", NULL,
+ gettext_noop("specify nickname") },
+ HELP_VERSION,
+ HELP_END,
};
formatHelp("gnunet-chat [OPTIONS]",
- _("Start GNUnet chat client."),
- help);
+ _("Start GNUnet chat client."),
+ help);
return SYSERR;
}
default:
GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER,
- _("Use --help to get a list of options.\n"));
+ _("Use --help to get a list of options.\n"));
return -1;
} /* end of parsing commandline */
} /* while (1) */
@@ -103,18 +103,18 @@
buffer = MALLOC(MAX_BUFFER_SIZE);
while (OK == connection_read(sock,
- (CS_MESSAGE_HEADER **)&buffer)) {
+ (CS_MESSAGE_HEADER **)&buffer)) {
char timebuf[64];
time_t timetmp;
struct tm * tmptr;
-
+
time(&timetmp);
tmptr = localtime(&timetmp);
strftime(timebuf,
64,
"%b %e %H:%M ",
tmptr);
-
+
if ( (ntohs(buffer->header.size) != sizeof(CS_chat_MESSAGE)) ||
(ntohs(buffer->header.type) != CS_PROTO_chat_MSG) )
continue;
@@ -122,8 +122,8 @@
buffer->message[CHAT_MSG_LENGTH-1] = '\0';
printf("[%s][%s]: %s",
timebuf,
- &buffer->nick[0],
- &buffer->message[0]);
+ &buffer->nick[0],
+ &buffer->message[0]);
}
FREE(buffer);
SEMAPHORE_UP(doneSem);
@@ -153,32 +153,32 @@
nick = getConfigurationString("GNUNET-CHAT", "NICK");
if (nick == NULL)
errexit(_("You must specify a nickname (use option `%s').\n"),
- "-n");
+ "-n");
doneSem = SEMAPHORE_CREATE(0);
if (0 != PTHREAD_CREATE(&messageReceiveThread,
- &receiveThread,
- sock,
- 128 * 1024))
+ &receiveThread,
+ sock,
+ 128 * 1024))
DIE_STRERROR("pthread_create");
memset(&msg,
- 0,
- sizeof(CS_chat_MESSAGE));
+ 0,
+ sizeof(CS_chat_MESSAGE));
memcpy(&msg.message[0],
- "Hi!\n",
- strlen("Hi!\n"));
+ "Hi!\n",
+ strlen("Hi!\n"));
msg.header.size
= htons(sizeof(CS_chat_MESSAGE));
msg.header.type
= htons(CS_PROTO_chat_MSG);
memcpy(&msg.nick[0],
- nick,
- strlen(nick));
+ nick,
+ strlen(nick));
/* send first "Hi!" message to gnunetd to indicate "join" */
if (SYSERR == connection_write(sock,
- &msg.header))
+ &msg.header))
errexit(_("Could not send join message to gnunetd\n"));
/* read messages from command line and send */
@@ -187,7 +187,7 @@
if (NULL == fgets(&msg.message[0], 1024, stdin))
break;
if (SYSERR == connection_write(sock,
- &msg.header))
+ &msg.header))
errexit(_("Could not send message to gnunetd\n"));
}
closeSocketTemporarily(sock);
Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/datastore/datastore.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -83,9 +83,9 @@
}
static int get(const HashCode512 * query,
- unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ unsigned int type,
+ Datum_Iterator iter,
+ void * closure) {
int ret;
if (! testAvailable(query)) {
@@ -93,22 +93,22 @@
EncName enc;
IF_GELOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Datastore availability pre-test failed for `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Datastore availability pre-test failed for `%s'.\n",
+ &enc);
#endif
if (stats != NULL)
stats->change(stat_filtered, 1);
return 0;
}
ret = sq->get(query,
- type,
- iter,
- closure);
+ type,
+ iter,
+ closure);
if ( (ret == 0) &&
(stats != NULL) )
stats->change(stat_filter_failed, 1);
@@ -119,20 +119,20 @@
* Explicitly remove some content from the database.
*/
static int del(const HashCode512 * query,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
int ok;
EncName enc;
if (! testAvailable(query)) {
IF_GELOG(coreAPI->ectx,
- GE_WARNING | GE_BULK | GE_USER,
- hash2enc(query,
- &enc));
+ GE_WARNING | GE_BULK | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(coreAPI->ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Availability test failed for `%s' at %s:%d.\n"),
- &enc,
- __FILE__, __LINE__);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Availability test failed for `%s' at %s:%d.\n"),
+ &enc,
+ __FILE__, __LINE__);
return 0;
}
ok = sq->del(query, value);
@@ -141,23 +141,23 @@
available += ntohl(value->size);
#if DEBUG_DATASTORE
IF_GELOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Deleted `%s' from database.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Deleted `%s' from database.\n",
+ &enc);
#endif
} else {
IF_GELOG(coreAPI->ectx,
- GE_WARNING | GE_BULK | GE_USER,
- hash2enc(query,
- &enc));
+ GE_WARNING | GE_BULK | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(coreAPI->ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Database failed to delete `%s'.\n"),
- &enc);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Database failed to delete `%s'.\n"),
+ &enc);
}
return ok;
}
@@ -172,32 +172,32 @@
* other serious error (i.e. IO permission denied)
*/
static int put(const HashCode512 * key,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
int ok;
/* check if we have enough space / priority */
if (ntohll(value->expirationTime) < get_time()) {
GE_LOG(coreAPI->ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- "Received content for put already expired!\n");
+ GE_INFO | GE_REQUEST | GE_USER,
+ "Received content for put already expired!\n");
return NO;
}
if ( (available < ntohl(value->size) ) &&
(minPriority > ntohl(value->prio)) ) {
GE_LOG(coreAPI->ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- "Datastore full (%llu/%llu) and content priority too low to kick out
other content. Refusing put.\n",
- sq->getSize(),
- quota);
+ GE_INFO | GE_REQUEST | GE_USER,
+ "Datastore full (%llu/%llu) and content priority too low to kick out
other content. Refusing put.\n",
+ sq->getSize(),
+ quota);
return NO; /* new content has such a low priority that
- we should not even bother! */
+ we should not even bother! */
}
if (ntohl(value->prio) < minPriority)
minPriority = ntohl(value->prio);
/* add the content */
ok = sq->put(key,
- value);
+ value);
if (ok == YES) {
makeAvailable(key);
available -= ntohl(value->size);
@@ -212,19 +212,19 @@
} CE;
static int checkExists(const HashCode512 * key,
- const Datastore_Value * value,
- void * cls) {
+ const Datastore_Value * value,
+ void * cls) {
CE * ce = cls;
if ( (value->size != ce->value->size) ||
(0 != memcmp(&value[1],
- &ce->value[1],
- ntohl(value->size) - sizeof(Datastore_Value))) )
+ &ce->value[1],
+ ntohl(value->size) - sizeof(Datastore_Value))) )
return OK; /* found another value, but different content! */
ce->existing = MALLOC(ntohl(value->size));
memcpy(ce->existing,
- value,
- ntohl(value->size));
+ value,
+ ntohl(value->size));
ce->exists = YES;
return SYSERR; /* abort iteration! */
}
@@ -240,7 +240,7 @@
* other serious error (i.e. IO permission denied)
*/
static int putUpdate(const HashCode512 * key,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
CE cls;
int ok;
@@ -249,49 +249,49 @@
cls.existing = NULL;
cls.value = value;
sq->get(key,
- ntohl(value->type),
- &checkExists,
- &cls);
+ ntohl(value->type),
+ &checkExists,
+ &cls);
if (ntohl(value->type) == D_BLOCK)
sq->get(key,
- ONDEMAND_BLOCK,
- &checkExists,
- &cls);
+ ONDEMAND_BLOCK,
+ &checkExists,
+ &cls);
if (cls.exists) {
if ( (ntohl(value->prio) == 0) &&
- (ntohll(value->expirationTime) <=
ntohll(cls.existing->expirationTime)) ) {
+ (ntohll(value->expirationTime) <= ntohll(cls.existing->expirationTime)) ) {
FREE(cls.existing);
return OK;
}
/* update prio */
sq->update(key,
- cls.existing,
- ntohl(value->prio),
- ntohll(value->expirationTime));
+ cls.existing,
+ ntohl(value->prio),
+ ntohll(value->expirationTime));
FREE(cls.existing);
return OK;
}
#if DEBUG_DATASTORE
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Migration: available %llu (need %u), min priority %u have %u\n",
- available,
- ntohl(value->size),
- minPriority,
- ntohl(value->prio));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Migration: available %llu (need %u), min priority %u have %u\n",
+ available,
+ ntohl(value->size),
+ minPriority,
+ ntohl(value->prio));
#endif
/* check if we have enough space / priority */
if ( (available < ntohl(value->size) ) &&
(minPriority > ntohl(value->prio)) )
return NO; /* new content has such a low priority that
- we should not even bother! */
+ we should not even bother! */
if (ntohl(value->prio) < minPriority)
minPriority = ntohl(value->prio);
/* add the content */
ok = sq->put(key,
- value);
+ value);
if (ok == YES) {
makeAvailable(key);
available -= ntohl(value->size);
@@ -305,8 +305,8 @@
* OK if we deleted expired content and are above quota
*/
static int freeSpaceExpired(const HashCode512 * key,
- const Datastore_Value * value,
- void * closure) {
+ const Datastore_Value * value,
+ void * closure) {
int * icls = closure;
int ret;
@@ -322,8 +322,8 @@
}
static int freeSpaceLow(const HashCode512 * key,
- const Datastore_Value * value,
- void * closure) {
+ const Datastore_Value * value,
+ void * closure) {
int ret;
minPriority = ntohl(value->prio);
@@ -349,13 +349,13 @@
if ( (available < 0) ||
(available < MIN_FREE) ) {
sq->iterateExpirationTime(ANY_BLOCK,
- &freeSpaceExpired,
- &syserr);
+ &freeSpaceExpired,
+ &syserr);
if ( (available < 0) ||
- (available < MIN_FREE) ) {
+ (available < MIN_FREE) ) {
sq->iterateLowPriority(ANY_BLOCK,
- &freeSpaceLow,
- NULL);
+ &freeSpaceLow,
+ NULL);
}
} else {
minPriority = 0;
@@ -373,12 +373,12 @@
State_ServiceAPI * state;
if (-1 == GC_get_configuration_value_number(capi->cfg,
- "FS",
- "QUOTA",
- 0,
- ((unsigned long
long)-1)/1024/1024,
- 1024,
- &lquota)) {
+ "FS",
+ "QUOTA",
+ 0,
+ ((unsigned long long)-1)/1024/1024,
+ 1024,
+ &lquota)) {
GE_BREAK(capi->ectx, 0);
return NULL; /* OOPS */
}
@@ -390,20 +390,20 @@
stat_filter_failed = stats->create(gettext_noop("# bloom filter false
positives"));
stats->set(stats->create(gettext_noop("# bytes allowed in datastore")),
- quota);
+ quota);
}
state = capi->requestService("state");
if (state != NULL) {
sqot = htonll(lquota);
state->write(capi->ectx,
- "FS-LAST-QUOTA",
- sizeof(unsigned long long),
- &sqot);
+ "FS-LAST-QUOTA",
+ sizeof(unsigned long long),
+ &sqot);
capi->releaseService(state);
} else {
GE_LOG(capi->ectx,
- GE_USER | GE_ADMIN | GE_ERROR | GE_BULK,
- _("Failed to load state service. Trying to do without.\n"));
+ GE_USER | GE_ADMIN | GE_ERROR | GE_BULK,
+ _("Failed to load state service. Trying to do without.\n"));
}
sq = capi->requestService("sqstore");
if (sq == NULL) {
@@ -416,10 +416,10 @@
}
coreAPI = capi;
initPrefetch(capi->ectx,
- capi->cfg,
- sq);
+ capi->cfg,
+ sq);
if (OK != initFilters(capi->ectx,
- capi->cfg)) {
+ capi->cfg)) {
GE_BREAK(capi->ectx, 0);
donePrefetch();
capi->releaseService(sq);
@@ -432,10 +432,10 @@
available = quota - sq->getSize();
cron = cron_create(capi->ectx);
cron_add_job(cron,
- &cronMaintenance,
- 10 * cronSECONDS,
- 10 * cronSECONDS,
- NULL);
+ &cronMaintenance,
+ 10 * cronSECONDS,
+ 10 * cronSECONDS,
+ NULL);
cron_start(cron);
api.getSize = &getSize;
api.put = &put;
@@ -454,9 +454,9 @@
void release_module_datastore() {
cron_stop(cron);
cron_del_job(cron,
- &cronMaintenance,
- 10 * cronSECONDS,
- NULL);
+ &cronMaintenance,
+ 10 * cronSECONDS,
+ NULL);
cron_destroy(cron);
cron = NULL;
donePrefetch();
@@ -475,8 +475,8 @@
* bloomfilter.
*/
static int filterAddAll(const HashCode512 * key,
- const Datastore_Value * value,
- void * closure) {
+ const Datastore_Value * value,
+ void * closure) {
makeAvailable(key);
return OK;
}
@@ -493,19 +493,19 @@
State_ServiceAPI * state;
if (-1 == GC_get_configuration_value_number(uapi->cfg,
- "FS",
- "QUOTA",
- 0,
- ((unsigned long
long)-1)/1024/1024,
- 1024,
- "a))
+ "FS",
+ "QUOTA",
+ 0,
+ ((unsigned long long)-1)/1024/1024,
+ 1024,
+ "a))
return; /* OOPS */
state = uapi->requestService("state");
lq = NULL;
if ( (state != NULL) &&
(sizeof(unsigned long long) != state->read(uapi->ectx,
- "FS-LAST-QUOTA",
- (void**)&lq)) &&
+ "FS-LAST-QUOTA",
+ (void**)&lq)) &&
(ntohll(*lq) == quota) ) {
uapi->releaseService(state);
FREE(lq);
@@ -514,27 +514,27 @@
FREENONNULL(lq);
/* ok, need to convert! */
deleteFilter(uapi->ectx,
- uapi->cfg);
+ uapi->cfg);
initFilters(uapi->ectx,
- uapi->cfg);
+ uapi->cfg);
sq = uapi->requestService("sqstore");
if (sq != NULL) {
sq->iterateAllNow(&filterAddAll,
- NULL);
+ NULL);
uapi->releaseService(sq);
} else {
GE_LOG(uapi->ectx,
- GE_USER | GE_ADMIN | GE_ERROR | GE_BULK,
- _("Failed to load sqstore service. Check your configuration!\n"));
+ GE_USER | GE_ADMIN | GE_ERROR | GE_BULK,
+ _("Failed to load sqstore service. Check your configuration!\n"));
}
sq = NULL;
doneFilters();
if (state != NULL) {
lastQuota = htonll(quota);
state->write(uapi->ectx,
- "FS-LAST-QUOTA",
- sizeof(unsigned long long),
- &lastQuota);
+ "FS-LAST-QUOTA",
+ sizeof(unsigned long long),
+ &lastQuota);
uapi->releaseService(state);
}
}
Modified: GNUnet/src/applications/datastore/filter.c
===================================================================
--- GNUnet/src/applications/datastore/filter.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/datastore/filter.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -36,24 +36,24 @@
static struct Bloomfilter * filter;
static char * getFilterName(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * fn;
char * bf;
fn = NULL;
if (-1 == GC_get_configuration_value_filename(cfg,
- "FS",
- "DIR",
- VAR_DAEMON_DIRECTORY "/fs",
- &fn))
+ "FS",
+ "DIR",
+ VAR_DAEMON_DIRECTORY "/fs",
+ &fn))
return NULL;
if (OK != disk_directory_create(ectx,
- fn)) {
+ fn)) {
FREE(fn);
return NULL;
}
bf = MALLOC(strlen(fn)+
- strlen("/bloomfilter")+1);
+ strlen("/bloomfilter")+1);
strcpy(bf, fn);
strcat(bf, "/bloomfilter");
FREE(fn);
@@ -61,18 +61,18 @@
}
int initFilters(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * bf;
unsigned long long quota; /* in kb */
unsigned int bf_size;
if (-1 == GC_get_configuration_value_number(cfg,
- "FS",
- "QUOTA",
- 0,
- ((unsigned long
long)-1)/1024/1024,
- 1024,
- "a))
+ "FS",
+ "QUOTA",
+ 0,
+ ((unsigned long long)-1)/1024/1024,
+ 1024,
+ "a))
return SYSERR;
quota *= 1024;
bf_size = quota / 32; /* 8 bit per entry, 1 bit per 32 kb in DB */
@@ -81,9 +81,9 @@
return SYSERR;
filter
= loadBloomfilter(ectx,
- bf,
- bf_size,
- 5); /* approx. 3% false positives at max use */
+ bf,
+ bf_size,
+ 5); /* approx. 3% false positives at max use */
FREE(bf);
if (filter == NULL)
return SYSERR;
@@ -96,7 +96,7 @@
}
void deleteFilter(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * fn;
GE_ASSERT(ectx, filter == NULL);
@@ -115,7 +115,7 @@
int testAvailable(const HashCode512 * key) {
return testBloomfilter(filter,
- key);
+ key);
}
/* end of filter.c */
Modified: GNUnet/src/applications/datastore/prefetch.c
===================================================================
--- GNUnet/src/applications/datastore/prefetch.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/datastore/prefetch.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -61,11 +61,11 @@
static struct GE_Context * ectx;
static struct GC_Configuration * cfg;
-
+
static int acquire(const HashCode512 * key,
- const Datastore_Value * value,
- void * closure) {
+ const Datastore_Value * value,
+ void * closure) {
if (doneSignal)
return SYSERR;
SEMAPHORE_DOWN(acquireMoreSignal, YES);
@@ -76,8 +76,8 @@
rkey = *key;
rvalue = MALLOC(ntohl(value->size));
memcpy(rvalue,
- value,
- ntohl(value->size));
+ value,
+ ntohl(value->size));
MUTEX_UNLOCK(lock);
if (doneSignal)
return SYSERR;
@@ -91,11 +91,11 @@
int load;
while (doneSignal == NO) {
sq->iterateMigrationOrder(&acquire,
- NULL);
+ NULL);
/* sleep here - otherwise we may start looping immediately
if there is no content in the DB! */
load = os_cpu_get_load(ectx,
- cfg);
+ cfg);
if (load < 10)
load = 10; /* never sleep less than 500 ms */
if (load > 100)
@@ -113,10 +113,10 @@
* @return SYSERR if the RCB is empty
*/
int getRandom(const HashCode512 * receiver,
- unsigned int sizeLimit,
- HashCode512 * key,
- Datastore_Value ** value,
- unsigned int type) {
+ unsigned int sizeLimit,
+ HashCode512 * key,
+ Datastore_Value ** value,
+ unsigned int type) {
MUTEX_LOCK(lock);
if (rvalue == NULL) {
MUTEX_UNLOCK(lock);
@@ -129,10 +129,10 @@
SEMAPHORE_UP(acquireMoreSignal);
return OK;
}
-
+
void initPrefetch(struct GE_Context * e,
- struct GC_Configuration * c,
- SQstore_ServiceAPI * s) {
+ struct GC_Configuration * c,
+ SQstore_ServiceAPI * s) {
ectx = e;
cfg = c;
sq = s;
@@ -140,12 +140,12 @@
doneSignal = NO;
lock = MUTEX_CREATE(NO);
gather_thread = PTHREAD_CREATE(&rcbAcquire,
- NULL,
- 64*1024);
+ NULL,
+ 64*1024);
if (gather_thread == NULL)
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_IMMEDIATE,
- "pthread_create");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_IMMEDIATE,
+ "pthread_create");
}
void donePrefetch() {
Modified: GNUnet/src/applications/dht/module/cs.c
===================================================================
--- GNUnet/src/applications/dht/module/cs.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/dht/module/cs.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -66,7 +66,7 @@
* CS handler for inserting <key,value>-pair into DHT-table.
*/
static int csPut(struct ClientHandle * client,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
const CS_dht_request_put_MESSAGE * req;
unsigned int size;
@@ -78,28 +78,28 @@
size = ntohs(req->header.size)
- sizeof(CS_dht_request_put_MESSAGE);
GE_ASSERT(NULL,
- size < MAX_BUFFER_SIZE);
+ size < MAX_BUFFER_SIZE);
#if DEBUG_CS
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' at %s:%d processes put '%.*s'\n",
- __FUNCTION__,
- __FILE__,
- __LINE__,
- size,
- &req[1]);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' at %s:%d processes put '%.*s'\n",
+ __FUNCTION__,
+ __FILE__,
+ __LINE__,
+ size,
+ &req[1]);
#endif
dhtAPI->put(&req->key,
- ntohl(req->type),
- size,
- ntohll(req->expire) + get_time(), /* convert to absolute time */
- (const char*) &req[1]);
+ ntohl(req->type),
+ size,
+ ntohll(req->expire) + get_time(), /* convert to absolute time */
+ (const char*) &req[1]);
return OK;
}
int get_result(const HashCode512 * key,
- const DataContainer * value,
- void * cls) {
+ const DataContainer * value,
+ void * cls) {
DHT_CLIENT_GET_RECORD * record = cls;
CS_dht_request_put_MESSAGE * msg;
size_t n;
@@ -116,30 +116,30 @@
msg->expire = 0; /* unknown */
msg->key = *key;
memcpy(&msg[1],
- &value[1],
- ntohl(value->size) - sizeof(DataContainer));
+ &value[1],
+ ntohl(value->size) - sizeof(DataContainer));
#if DEBUG_CS
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' at %s:%d processes reply '%.*s'\n",
- __FUNCTION__,
- __FILE__,
- __LINE__,
- ntohl(value->size) - sizeof(DataContainer),
- &value[1]);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' at %s:%d processes reply '%.*s'\n",
+ __FUNCTION__,
+ __FILE__,
+ __LINE__,
+ ntohl(value->size) - sizeof(DataContainer),
+ &value[1]);
#endif
if (OK != coreAPI->sendToClient(record->client,
- &msg->header)) {
+ &msg->header)) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_IMMEDIATE | GE_USER,
- _("`%s' failed. Terminating connection to client.\n"),
- "sendToClient");
+ GE_ERROR | GE_IMMEDIATE | GE_USER,
+ _("`%s' failed. Terminating connection to client.\n"),
+ "sendToClient");
coreAPI->terminateClientConnection(record->client);
}
FREE(msg);
return OK;
}
-
+
static void get_timeout(void * cls) {
DHT_CLIENT_GET_RECORD * record = cls;
int i;
@@ -151,8 +151,8 @@
if (getRecords[i] == record) {
getRecords[i] = getRecords[getRecordsSize-1];
GROW(getRecords,
- getRecordsSize,
- getRecordsSize-1);
+ getRecordsSize,
+ getRecordsSize-1);
found = YES;
break;
}
@@ -167,7 +167,7 @@
* CS handler for inserting <key,value>-pair into DHT-table.
*/
static int csGet(struct ClientHandle * client,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
const CS_dht_request_get_MESSAGE * get;
DHT_CLIENT_GET_RECORD * cpc;
@@ -177,26 +177,26 @@
}
#if DEBUG_CS
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' at %s:%d processes get\n",
- __FUNCTION__,
- __FILE__,
- __LINE__);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' at %s:%d processes get\n",
+ __FUNCTION__,
+ __FILE__,
+ __LINE__);
#endif
get = (const CS_dht_request_get_MESSAGE *) message;
cpc = MALLOC(sizeof(DHT_CLIENT_GET_RECORD));
cpc->client = client;
cpc->get_record = dhtAPI->get_start(ntohl(get->type),
- &get->key,
- ntohll(get->timeout),
- &get_result,
- cpc,
- &get_timeout,
- cpc);
+ &get->key,
+ ntohll(get->timeout),
+ &get_result,
+ cpc,
+ &get_timeout,
+ cpc);
MUTEX_LOCK(lock);
APPEND(getRecords,
- getRecordsSize,
- cpc);
+ getRecordsSize,
+ cpc);
MUTEX_UNLOCK(lock);
return OK;
}
@@ -216,8 +216,8 @@
gr = cgr->get_record;
getRecords[i] = getRecords[getRecordsSize-1];
GROW(getRecords,
- getRecordsSize,
- getRecordsSize-1);
+ getRecordsSize,
+ getRecordsSize-1);
MUTEX_UNLOCK(lock);
dhtAPI->get_stop(gr);
FREE(cgr);
@@ -236,11 +236,11 @@
return SYSERR;
coreAPI = capi;
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("`%s' registering client handlers: %d %d\n"),
- "dht",
- CS_PROTO_dht_REQUEST_PUT,
- CS_PROTO_dht_REQUEST_GET);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("`%s' registering client handlers: %d %d\n"),
+ "dht",
+ CS_PROTO_dht_REQUEST_PUT,
+ CS_PROTO_dht_REQUEST_GET);
status = OK;
lock = MUTEX_CREATE(NO);
if (SYSERR == capi->registerClientHandler(CS_PROTO_dht_REQUEST_PUT,
@@ -252,11 +252,11 @@
if (SYSERR == capi->registerClientExitHandler(&csClientExit))
status = SYSERR;
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "dht",
- gettext_noop("Enables
efficient non-anonymous routing")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "dht",
+ gettext_noop("Enables efficient
non-anonymous routing")));
return status;
}
@@ -268,13 +268,13 @@
status = OK;
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "DHT: shutdown\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "DHT: shutdown\n");
if (OK != coreAPI->unregisterClientHandler(CS_PROTO_dht_REQUEST_PUT,
- &csPut))
+ &csPut))
status = SYSERR;
if (OK != coreAPI->unregisterClientHandler(CS_PROTO_dht_REQUEST_GET,
- &csGet))
+ &csGet))
status = SYSERR;
if (OK != coreAPI->unregisterClientExitHandler(&csClientExit))
status = SYSERR;
Modified: GNUnet/src/applications/dht/module/dstore.c
===================================================================
--- GNUnet/src/applications/dht/module/dstore.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/dht/module/dstore.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -39,38 +39,38 @@
* @return total number of results found
*/
int dht_store_get(const HashCode512 * key,
- unsigned int type,
- ResultHandler handler,
- void * cls) {
+ unsigned int type,
+ ResultHandler handler,
+ void * cls) {
return dstore->get(key,
- type,
- handler,
- cls);
+ type,
+ handler,
+ cls);
}
/**
* Store the given data in the local datastore.
*/
void dht_store_put(unsigned int type,
- const HashCode512 * key,
- cron_t discard_time,
- unsigned int size,
- const char * data) {
+ const HashCode512 * key,
+ cron_t discard_time,
+ unsigned int size,
+ const char * data) {
if (discard_time < get_time()) {
#if DEBUG_DSTORE
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Content already expired (%llu < %llu), will not keep.\n",
- discard_time,
- get_time());
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Content already expired (%llu < %llu), will not keep.\n",
+ discard_time,
+ get_time());
#endif
return;
}
dstore->put(key,
- type,
- discard_time,
- size,
- data);
+ type,
+ discard_time,
+ size,
+ data);
}
/**
@@ -80,7 +80,7 @@
* @return OK on success
*/
int init_dht_store(size_t max_size,
- CoreAPIForApplication * capi) {
+ CoreAPIForApplication * capi) {
coreAPI = capi;
dstore = coreAPI->requestService("dstore");
if (dstore == NULL)
Modified: GNUnet/src/applications/dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dht/module/routing.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/dht/module/routing.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -214,10 +214,10 @@
* where to send it next.
*/
static void routeResult(const HashCode512 * key,
- unsigned int type,
- unsigned int size,
- const char * data,
- void * cls) {
+ unsigned int type,
+ unsigned int size,
+ const char * data,
+ void * cls) {
DHTQueryRecord * q;
int i;
int j;
@@ -237,8 +237,8 @@
result->type = htonl(type);
result->key = *key;
memcpy(&result[1],
- data,
- size);
+ data,
+ size);
}
hash(data,
size,
@@ -252,54 +252,54 @@
continue;
tracked++;
if ( (ntohl(q->get->type) != type) ||
- (0 != memcmp(key,
- &q->get->key,
- sizeof(HashCode512))) )
+ (0 != memcmp(key,
+ &q->get->key,
+ sizeof(HashCode512))) )
continue;
found = NO;
for (j=0;j<q->result_count;j++)
if (0 == memcmp(&hc,
- &q->results[j],
- sizeof(HashCode512))) {
- found = YES;
- break;
+ &q->results[j],
+ sizeof(HashCode512))) {
+ found = YES;
+ break;
}
if (found == YES)
continue;
GROW(q->results,
- q->result_count,
- q->result_count + 1);
+ q->result_count,
+ q->result_count + 1);
routed++;
q->results[q->result_count-1] = hc;
pos = q->sources;
while (pos != NULL) {
if (0 != memcmp(&pos->source,
- coreAPI->myIdentity,
- sizeof(PeerIdentity))) {
+ coreAPI->myIdentity,
+ sizeof(PeerIdentity))) {
#if DEBUG_ROUTING
- GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Routing result to other peer\n");
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Routing result to other peer\n");
#endif
- coreAPI->unicast(&pos->source,
- &result->header,
- 0, /* FIXME: priority */
- 5 * cronSECONDS); /* FIXME */
- if (stats != NULL)
- stats->change(stat_replies_routed, 1);
+ coreAPI->unicast(&pos->source,
+ &result->header,
+ 0, /* FIXME: priority */
+ 5 * cronSECONDS); /* FIXME */
+ if (stats != NULL)
+ stats->change(stat_replies_routed, 1);
} else if (pos->receiver != NULL) {
#if DEBUG_ROUTING
- GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Routing result to local client\n");
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Routing result to local client\n");
#endif
- pos->receiver(key,
- type,
- size,
- data,
- pos->receiver_closure);
- if (stats != NULL)
- stats->change(stat_replies_routed, 1);
+ pos->receiver(key,
+ type,
+ size,
+ data,
+ pos->receiver_closure);
+ if (stats != NULL)
+ stats->change(stat_replies_routed, 1);
}
pos = pos->next;
}
@@ -307,10 +307,10 @@
MUTEX_UNLOCK(lock);
#if DEBUG_ROUTING
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Routed result to %u out of %u pending requests\n",
- routed,
- tracked);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Routed result to %u out of %u pending requests\n",
+ routed,
+ tracked);
#endif
if (cls == NULL)
FREE(result);
@@ -320,9 +320,9 @@
* @return OK if route was added, SYSERR if not
*/
static int addRoute(const PeerIdentity * sender,
- ResultHandler handler,
- void * cls,
- const DHT_GET_MESSAGE * get) {
+ ResultHandler handler,
+ void * cls,
+ const DHT_GET_MESSAGE * get) {
DHTQueryRecord * q;
unsigned int i;
unsigned int rt_pos;
@@ -340,16 +340,16 @@
rt_pos = rt_size;
for (i=0;i<rt_size;i++) {
if ( (sender != NULL) &&
- (records[i] != NULL) &&
- (0 == memcmp(&records[i]->get->key,
- &get->key,
- sizeof(HashCode512))) &&
- (records[i]->get->type == get->type) &&
- (records[i]->expires > now - MAX_TTL) ) {
+ (records[i] != NULL) &&
+ (0 == memcmp(&records[i]->get->key,
+ &get->key,
+ sizeof(HashCode512))) &&
+ (records[i]->get->type == get->type) &&
+ (records[i]->expires > now - MAX_TTL) ) {
/* do not route, same request already (recently)
- active (possibly from other initiator) */
+ active (possibly from other initiator) */
/* FIXME: support sending replies back to
- multiple peers!? */
+ multiple peers!? */
MUTEX_UNLOCK(lock);
return SYSERR;
}
@@ -380,13 +380,13 @@
}
q = records[rt_pos];
memset(q,
- 0,
- sizeof(DHTQueryRecord));
+ 0,
+ sizeof(DHTQueryRecord));
q->expires = now + ttl;
q->get = MALLOC(ntohs(get->header.size));
memcpy(q->get,
- get,
- ntohs(get->header.size));
+ get,
+ ntohs(get->header.size));
pos = MALLOC(sizeof(DHT_Source_Route));
pos->next = q->sources;
q->sources = pos;
@@ -398,9 +398,9 @@
pos->receiver_closure = cls;
#if DEBUG_ROUTING
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Tracking request in slot %u\n",
- rt_pos);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Tracking request in slot %u\n",
+ rt_pos);
#endif
rt_pos = (rt_pos + 1) % rt_size;
MUTEX_UNLOCK(lock);
@@ -420,7 +420,7 @@
* Handle GET message.
*/
static int handleGet(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
PeerIdentity next[GET_TRIES];
const DHT_GET_MESSAGE * get;
DHT_GET_MESSAGE aget;
@@ -439,55 +439,55 @@
#if DEBUG_ROUTING
hash2enc(&get->key, &enc);
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Received DHT GET for key `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Received DHT GET for key `%s'.\n",
+ &enc);
#endif
if (stats != NULL)
stats->change(stat_get_requests_received, 1);
if ( (sender != NULL) &&
(OK != addRoute(sender,
- NULL,
- NULL,
- get)) )
+ NULL,
+ NULL,
+ get)) )
return OK; /* could not route */
total = dht_store_get(&get->key,
- ntohl(get->type),
- &routeResult,
- NULL);
+ ntohl(get->type),
+ &routeResult,
+ NULL);
if ( (total > GET_TRIES) &&
(sender != NULL) ) {
#if DEBUG_ROUTING
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Found %d results locally, will not route GET any further\n",
- total);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Found %d results locally, will not route GET any further\n",
+ total);
#endif
return OK;
}
total = 0;
for (i=0;i<GET_TRIES;i++) {
if (OK != select_dht_peer(&next[i],
- &get->key,
- &next[0],
- i))
+ &get->key,
+ &next[0],
+ i))
break;
if (-1 == hashCodeCompareDistance(&next[i].hashPubKey,
- &coreAPI->myIdentity->hashPubKey,
- &get->key)) {
+ &coreAPI->myIdentity->hashPubKey,
+ &get->key)) {
if (total == 0) {
- aget = *get;
- ttl = ntohl(get->ttl);
- if (ttl > MAX_TTL)
- ttl = MAX_TTL;
- ttl -= 5 * cronSECONDS;
- aget.ttl = htonl(ttl);
- total = 1;
+ aget = *get;
+ ttl = ntohl(get->ttl);
+ if (ttl > MAX_TTL)
+ ttl = MAX_TTL;
+ ttl -= 5 * cronSECONDS;
+ aget.ttl = htonl(ttl);
+ total = 1;
}
coreAPI->unicast(&next[i],
- msg,
- 0, /* FIXME: priority */
- 5 * cronSECONDS); /* FIXME */
+ msg,
+ 0, /* FIXME: priority */
+ 5 * cronSECONDS); /* FIXME */
}
}
return OK;
@@ -505,7 +505,7 @@
* Handle PUT message.
*/
static int handlePut(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
PeerIdentity next[PUT_TRIES];
const DHT_PUT_MESSAGE * put;
cron_t now;
@@ -524,54 +524,54 @@
put = (const DHT_PUT_MESSAGE*) msg;
#if DEBUG_ROUTING
hash2enc(&put->key,
- &enc);
+ &enc);
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Received DHT PUT for key `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Received DHT PUT for key `%s'.\n",
+ &enc);
#endif
store = 0;
for (i=0;i<PUT_TRIES;i++) {
if (OK != select_dht_peer(&next[i],
- &put->key,
- &next[0],
- i)) {
+ &put->key,
+ &next[0],
+ i)) {
store = 1;
break;
}
if (1 == hashCodeCompareDistance(&next[i].hashPubKey,
- &coreAPI->myIdentity->hashPubKey,
- &put->key))
+ &coreAPI->myIdentity->hashPubKey,
+ &put->key))
store = 1; /* we're closer than the selected target */
else
coreAPI->unicast(&next[i],
- msg,
- 0, /* FIXME: priority */
- 5 * cronSECONDS); /* FIXME */
+ msg,
+ 0, /* FIXME: priority */
+ 5 * cronSECONDS); /* FIXME */
}
if (store != 0) {
now = get_time();
#if DEBUG_ROUTING
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Decided to cache data `%.*s' locally until %llu (for %llu ms)\n",
- ntohs(put->header.size) - sizeof(DHT_PUT_MESSAGE),
- &put[1],
- ntohll(put->timeout) + now,
- ntohll(put->timeout));
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Decided to cache data `%.*s' locally until %llu (for %llu ms)\n",
+ ntohs(put->header.size) - sizeof(DHT_PUT_MESSAGE),
+ &put[1],
+ ntohll(put->timeout) + now,
+ ntohll(put->timeout));
#endif
dht_store_put(ntohl(put->type),
- &put->key,
- ntohll(put->timeout) + now,
- ntohs(put->header.size) - sizeof(DHT_PUT_MESSAGE),
- (const char*) &put[1]);
+ &put->key,
+ ntohll(put->timeout) + now,
+ ntohs(put->header.size) - sizeof(DHT_PUT_MESSAGE),
+ (const char*) &put[1]);
} else {
#if DEBUG_ROUTING
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Decided NOT to cache data `%.*s' locally\n",
- ntohs(put->header.size) - sizeof(DHT_PUT_MESSAGE),
- &put[1]);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Decided NOT to cache data `%.*s' locally\n",
+ ntohs(put->header.size) - sizeof(DHT_PUT_MESSAGE),
+ &put[1]);
#endif
}
return OK;
@@ -581,7 +581,7 @@
* Handle RESULT message.
*/
static int handleResult(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
const DHT_RESULT_MESSAGE * result;
#if DEBUG_ROUTING
EncName enc;
@@ -597,15 +597,15 @@
#if DEBUG_ROUTING
hash2enc(&result->key, &enc);
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Received DHT RESULT for key `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Received DHT RESULT for key `%s'.\n",
+ &enc);
#endif
routeResult(&result->key,
- ntohl(result->type),
- ntohs(result->header.size) - sizeof(DHT_RESULT_MESSAGE),
- (const char*) &result[1],
- (void*) msg);
+ ntohl(result->type),
+ ntohs(result->header.size) - sizeof(DHT_RESULT_MESSAGE),
+ (const char*) &result[1],
+ (void*) msg);
return OK;
}
@@ -613,9 +613,9 @@
* Start a DHT get operation.
*/
void dht_get_start(const HashCode512 * key,
- unsigned int type,
- ResultHandler handler,
- void * cls) {
+ unsigned int type,
+ ResultHandler handler,
+ void * cls) {
DHT_GET_MESSAGE get;
get.header.size = htons(sizeof(DHT_GET_MESSAGE));
@@ -625,11 +625,11 @@
get.ttl = htonl(MAX_TTL); /* FIXME? */
get.key = *key;
if (OK == addRoute(NULL,
- handler,
- cls,
- &get))
+ handler,
+ cls,
+ &get))
handleGet(NULL,
- &get.header);
+ &get.header);
}
/**
@@ -637,9 +637,9 @@
* the given iterator).
*/
void dht_get_stop(const HashCode512 * key,
- unsigned int type,
- ResultHandler handler,
- void * cls) {
+ unsigned int type,
+ ResultHandler handler,
+ void * cls) {
int i;
struct DHT_Source_Route * pos;
struct DHT_Source_Route * prev;
@@ -654,17 +654,17 @@
pos = records[i]->sources;
while (pos != NULL) {
if ( (pos->receiver == handler) &&
- (pos->receiver_closure == cls) &&
- (0 == memcmp(key,
- &records[i]->get->key,
- sizeof(HashCode512))) ) {
- if (prev == NULL)
- records[i]->sources = pos->next;
- else
- prev->next = pos->next;
- FREE(pos);
- done = YES;
- break;
+ (pos->receiver_closure == cls) &&
+ (0 == memcmp(key,
+ &records[i]->get->key,
+ sizeof(HashCode512))) ) {
+ if (prev == NULL)
+ records[i]->sources = pos->next;
+ else
+ prev->next = pos->next;
+ FREE(pos);
+ done = YES;
+ break;
}
prev = pos;
pos = prev->next;
@@ -690,10 +690,10 @@
* @param expirationTime absolute expiration time
*/
void dht_put(const HashCode512 * key,
- unsigned int type,
- unsigned int size,
- cron_t expirationTime,
- const char * data) {
+ unsigned int type,
+ unsigned int size,
+ cron_t expirationTime,
+ const char * data) {
DHT_PUT_MESSAGE * put;
put = MALLOC(sizeof(DHT_PUT_MESSAGE) + size);
@@ -703,10 +703,10 @@
put->type = htonl(type);
put->timeout = htonll(expirationTime - get_time()); /* convert to relative
time */
memcpy(&put[1],
- data,
- size);
+ data,
+ size);
handlePut(NULL,
- &put->header);
+ &put->header);
FREE(put);
}
@@ -720,8 +720,8 @@
*/
static unsigned int
extra_get_callback(const PeerIdentity * receiver,
- void * position,
- unsigned int padding) {
+ void * position,
+ unsigned int padding) {
return 0;
}
@@ -737,12 +737,12 @@
coreAPI = capi;
rts = 65536;
GC_get_configuration_value_number(coreAPI->cfg,
- "DHT",
- "TABLESIZE",
- 128,
- 1024 * 1024,
- 1024,
- &rts);
+ "DHT",
+ "TABLESIZE",
+ 128,
+ 1024 * 1024,
+ 1024,
+ &rts);
GROW(records,
rt_size,
rts);
@@ -756,20 +756,20 @@
stat_results_received = stats->create(gettext_noop("# dht results
received"));
}
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("`%s' registering p2p handlers: %d %d %d\n"),
- "dht",
- P2P_PROTO_DHT_GET,
- P2P_PROTO_DHT_PUT,
- P2P_PROTO_DHT_RESULT);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("`%s' registering p2p handlers: %d %d %d\n"),
+ "dht",
+ P2P_PROTO_DHT_GET,
+ P2P_PROTO_DHT_PUT,
+ P2P_PROTO_DHT_RESULT);
coreAPI->registerHandler(P2P_PROTO_DHT_GET,
- &handleGet);
+ &handleGet);
coreAPI->registerHandler(P2P_PROTO_DHT_PUT,
- &handlePut);
+ &handlePut);
coreAPI->registerHandler(P2P_PROTO_DHT_RESULT,
- &handleResult);
+ &handleResult);
coreAPI->registerSendCallback(sizeof(DHT_GET_MESSAGE),
- &extra_get_callback);
+ &extra_get_callback);
return OK;
}
@@ -782,13 +782,13 @@
unsigned int i;
coreAPI->unregisterSendCallback(sizeof(DHT_GET_MESSAGE),
- &extra_get_callback);
+ &extra_get_callback);
coreAPI->unregisterHandler(P2P_PROTO_DHT_GET,
- &handleGet);
+ &handleGet);
coreAPI->unregisterHandler(P2P_PROTO_DHT_PUT,
- &handlePut);
+ &handlePut);
coreAPI->unregisterHandler(P2P_PROTO_DHT_RESULT,
- &handleResult);
+ &handleResult);
if (stats != NULL) {
coreAPI->releaseService(stats);
stats = NULL;
Modified: GNUnet/src/applications/dht/module/service.c
===================================================================
--- GNUnet/src/applications/dht/module/service.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/dht/module/service.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -71,21 +71,21 @@
} DHT_GET_RECORD;
static void client_result_converter(const HashCode512 * key,
- unsigned int type,
- unsigned int size,
- const char * data,
- void * cls) {
+ unsigned int type,
+ unsigned int size,
+ const char * data,
+ void * cls) {
struct DHT_GET_RECORD * get = cls;
DataContainer * dc;
dc = MALLOC(sizeof(DataContainer) + size);
dc->size = ntohl(sizeof(DataContainer) + size);
memcpy(&dc[1],
- data,
- size);
+ data,
+ size);
get->callback(key,
- dc,
- get->cls);
+ dc,
+ get->cls);
FREE(dc);
}
@@ -118,12 +118,12 @@
*/
static struct DHT_GET_RECORD *
dht_get_async_start(unsigned int type,
- const HashCode512 * key,
- cron_t timeout,
- DataProcessor callback,
- void * cls,
- DHT_OP_Complete callbackComplete,
- void * closure) {
+ const HashCode512 * key,
+ cron_t timeout,
+ DataProcessor callback,
+ void * cls,
+ DHT_OP_Complete callbackComplete,
+ void * closure) {
struct DHT_GET_RECORD * ret;
ret = MALLOC(sizeof(DHT_GET_RECORD));
@@ -134,14 +134,14 @@
ret->closure = closure;
ret->type = type;
cron_add_job(cron,
- &timeout_callback,
- timeout,
- 0,
- ret);
+ &timeout_callback,
+ timeout,
+ 0,
+ ret);
dht_get_start(key,
- type,
- &client_result_converter,
- ret);
+ type,
+ &client_result_converter,
+ ret);
return ret;
}
@@ -151,17 +151,17 @@
static int
dht_get_async_stop(struct DHT_GET_RECORD * record) {
cron_suspend(cron,
- YES);
+ YES);
cron_del_job(cron,
- &timeout_callback,
- 0,
- record);
+ &timeout_callback,
+ 0,
+ record);
cron_resume_jobs(cron,
- YES);
+ YES);
dht_get_stop(&record->key,
- record->type,
- &client_result_converter,
- record);
+ record->type,
+ &client_result_converter,
+ record);
FREE(record);
return OK;
}
@@ -180,7 +180,7 @@
cron = cron_create(capi->ectx);
cron_start(cron);
if (OK != init_dht_store(1024 * 1024,
- capi))
+ capi))
return NULL;
if (OK != init_dht_table(capi)) {
done_dht_store();
Modified: GNUnet/src/applications/dht/module/table.c
===================================================================
--- GNUnet/src/applications/dht/module/table.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/dht/module/table.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -226,7 +226,7 @@
* differs.
*/
static unsigned int get_bit_distance(const HashCode512 * h1,
- const HashCode512 * h2) {
+ const HashCode512 * h2) {
unsigned int i;
int diff;
@@ -247,10 +247,10 @@
int i;
index = get_bit_distance(&peer->hashPubKey,
- &coreAPI->myIdentity->hashPubKey);
+ &coreAPI->myIdentity->hashPubKey);
i = bucketCount-1;
while ( (buckets[i].bstart >= index) &&
- (i > 0) )
+ (i > 0) )
i--;
if ( (buckets[i].bstart < index) &&
(buckets[i].bend >= index) )
@@ -264,15 +264,15 @@
*/
static PeerInfo *
findPeerEntryInBucket(PeerBucket * bucket,
- const PeerIdentity * peer) {
+ const PeerIdentity * peer) {
unsigned int i;
if (bucket == NULL)
return NULL;
for (i=0;i<bucket->peers_size;i++)
if (0 == memcmp(peer,
- &bucket->peers[i]->id,
- sizeof(PeerIdentity)))
+ &bucket->peers[i]->id,
+ sizeof(PeerIdentity)))
return bucket->peers[i];
return NULL;
}
@@ -284,7 +284,7 @@
static PeerInfo *
findPeerEntry(const PeerIdentity * peer) {
return findPeerEntryInBucket(findBucketFor(peer),
- peer);
+ peer);
}
/**
@@ -298,12 +298,12 @@
* @return inverse distance metric, non-zero.
*/
static unsigned int inverse_distance(const HashCode512 * target,
- const HashCode512 * have) {
+ const HashCode512 * have) {
unsigned int bucket;
double d;
bucket = get_bit_distance(target,
- have);
+ have);
d = bucket * 32;
d = exp2(d / (sizeof(HashCode512)*8));
if (d > ((unsigned int)-1))
@@ -324,9 +324,9 @@
* @return OK on success, SYSERR on error
*/
int select_dht_peer(PeerIdentity * set,
- const HashCode512 * target,
- const PeerIdentity * blocked,
- unsigned int blocked_size) {
+ const HashCode512 * target,
+ const PeerIdentity * blocked,
+ unsigned int blocked_size) {
unsigned long long total_distance;
unsigned long long selected;
unsigned int distance;
@@ -347,17 +347,17 @@
pi = bucket->peers[ec];
match = NO;
for (i=0;i<blocked_size;i++) {
- if (0 == memcmp(&pi->id,
- &blocked[i],
- sizeof(PeerIdentity))) {
- match = YES;
- break;
- }
+ if (0 == memcmp(&pi->id,
+ &blocked[i],
+ sizeof(PeerIdentity))) {
+ match = YES;
+ break;
+ }
}
if (match == YES)
- continue;
+ continue;
total_distance += inverse_distance(target,
- &pi->id.hashPubKey);
+ &pi->id.hashPubKey);
}
}
if (total_distance == 0) {
@@ -371,21 +371,21 @@
pi = bucket->peers[ec];
match = NO;
for (i=0;i<blocked_size;i++) {
- if (0 == memcmp(&pi->id,
- &blocked[i],
- sizeof(PeerIdentity))) {
- match = YES;
- break;
- }
+ if (0 == memcmp(&pi->id,
+ &blocked[i],
+ sizeof(PeerIdentity))) {
+ match = YES;
+ break;
+ }
}
if (match == YES)
- continue;
+ continue;
distance = inverse_distance(target,
- &pi->id.hashPubKey);
+ &pi->id.hashPubKey);
if (distance > selected) {
- *set = pi->id;
- MUTEX_UNLOCK(lock);
- return OK;
+ *set = pi->id;
+ MUTEX_UNLOCK(lock);
+ return OK;
}
selected -= distance;
}
@@ -401,7 +401,7 @@
* @param cls NULL or pre-build discovery message
*/
static void broadcast_dht_discovery(const PeerIdentity * other,
- void * cls) {
+ void * cls) {
P2P_DHT_Discovery * disco = cls;
unsigned int pc;
unsigned int i;
@@ -411,9 +411,9 @@
stats->change(stat_dht_advertisements, 1);
if (disco != NULL) {
coreAPI->unicast(other,
- &disco->header,
- EXTREME_PRIORITY/4,
- MAINTAIN_FREQUENCY * MAINTAIN_CHANCE / 2);
+ &disco->header,
+ EXTREME_PRIORITY/4,
+ MAINTAIN_FREQUENCY * MAINTAIN_CHANCE / 2);
return;
}
pc = total_peers;
@@ -434,23 +434,23 @@
}
while (i < pc) {
if (OK != select_dht_peer(&pos[i],
- &other->hashPubKey,
- pos,
- i))
+ &other->hashPubKey,
+ pos,
+ i))
pc--;
else
i++;
}
disco->header.size = htons(pc * sizeof(PeerIdentity) +
sizeof(P2P_DHT_Discovery));
coreAPI->unicast(other,
- &disco->header,
- 0,
- MAINTAIN_FREQUENCY * MAINTAIN_CHANCE / 2);
+ &disco->header,
+ 0,
+ MAINTAIN_FREQUENCY * MAINTAIN_CHANCE / 2);
FREE(disco);
}
static void broadcast_dht_discovery_prob(const PeerIdentity * other,
- void * cls) {
+ void * cls) {
if (weak_randomi(MAINTAIN_CHANCE) != 0)
return;
broadcast_dht_discovery(other, cls);
@@ -467,10 +467,10 @@
disc.header.type = htons(P2P_PROTO_DHT_DISCOVERY);
disc.space_available = -1; /* FIXME */
coreAPI->forAllConnectedNodes(&broadcast_dht_discovery_prob,
- &disc);
+ &disc);
} else {
coreAPI->forAllConnectedNodes(&broadcast_dht_discovery_prob,
- NULL);
+ NULL);
}
}
@@ -501,10 +501,10 @@
p = MALLOC(sizeof(PeerIdentity));
*p = pi->id;
if (OK == pingpong->ping(p,
- &pongNotify,
- p,
- NO,
- rand())) {
+ &pongNotify,
+ p,
+ NO,
+ rand())) {
pi->lastTimePingSend = get_time();
pi->request_count++;
}
@@ -541,12 +541,12 @@
if (checkExpired(peer) == YES) {
total_peers--;
if (stats != NULL)
- stats->change(stat_dht_total_peers, -1);
+ stats->change(stat_dht_total_peers, -1);
FREE(peer);
bucket->peers[i] = bucket->peers[bucket->peers_size-1];
GROW(bucket->peers,
- bucket->peers_size,
- bucket->peers_size - 1);
+ bucket->peers_size,
+ bucket->peers_size - 1);
}
}
}
@@ -555,7 +555,7 @@
* Consider adding the given peer to the DHT.
*/
static void considerPeer(const PeerIdentity * sender,
- const PeerIdentity * peer) {
+ const PeerIdentity * peer) {
PeerInfo * pi;
PeerBucket * bucket;
P2P_DHT_ASK_HELLO ask;
@@ -569,12 +569,12 @@
if (bucket->peers_size >= MAINTAIN_BUCKET_SIZE)
return; /* do not care */
if (NULL != findPeerEntryInBucket(bucket,
- peer))
+ peer))
return; /* already have this peer in buckets */
/* do we know how to contact this peer? */
hello = identity->identity2Hello(peer,
- ANY_PROTOCOL_NUMBER,
- NO);
+ ANY_PROTOCOL_NUMBER,
+ NO);
if (hello == NULL) {
/* if identity not known, ask sender for HELLO of other peer */
ask.header.size = htons(sizeof(P2P_DHT_ASK_HELLO));
@@ -582,9 +582,9 @@
ask.reserved = 0;
ask.peer = *peer;
coreAPI->unicast(sender,
- &ask.header,
- 0, /* FIXME: priority */
- 5 * cronSECONDS);
+ &ask.header,
+ 0, /* FIXME: priority */
+ 5 * cronSECONDS);
return;
}
FREE(hello);
@@ -592,14 +592,14 @@
if (OK != coreAPI->queryPeerStatus(peer, NULL, NULL)) {
/* not yet connected; connect sending DISCOVERY */
broadcast_dht_discovery(peer,
- NULL);
+ NULL);
return;
}
/* we are connected (in core), add to bucket */
pi = MALLOC(sizeof(PeerInfo));
memset(pi,
- 0,
- sizeof(PeerInfo));
+ 0,
+ sizeof(PeerInfo));
pi->id = *peer;
pingPeer(pi);
GROW(bucket->peers,
@@ -615,7 +615,7 @@
* Handle discovery message.
*/
static int handleDiscovery(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
unsigned int pc;
unsigned int i;
const P2P_DHT_Discovery * disco;
@@ -636,7 +636,7 @@
if (pc == 0) {
/* if peer has 0 connections, be sure to send discovery back */
broadcast_dht_discovery(sender,
- NULL);
+ NULL);
}
MUTEX_LOCK(lock);
considerPeer(sender, sender);
@@ -651,7 +651,7 @@
* Handle ask hello message.
*/
static int handleAskHello(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
const P2P_DHT_ASK_HELLO * ask;
P2P_hello_MESSAGE * hello;
@@ -661,14 +661,14 @@
if (NULL == findBucketFor(&ask->peer))
return OK;
hello = identity->identity2Hello(&ask->peer,
- ANY_PROTOCOL_NUMBER,
- NO);
+ ANY_PROTOCOL_NUMBER,
+ NO);
if (hello == NULL)
return OK;
coreAPI->unicast(sender,
- &hello->header,
- 0,
- 5 * cronSECONDS);
+ &hello->header,
+ 0,
+ 5 * cronSECONDS);
FREE(hello);
return OK;
}
@@ -708,14 +708,14 @@
pingpong = coreAPI->requestService("pingpong");
GE_ASSERT(coreAPI->ectx, pingpong != NULL);
capi->registerHandler(P2P_PROTO_DHT_DISCOVERY,
- &handleDiscovery);
+ &handleDiscovery);
capi->registerHandler(P2P_PROTO_DHT_ASK_HELLO,
- &handleAskHello);
+ &handleAskHello);
cron_add_job(coreAPI->cron,
- &maintain_dht_job,
- MAINTAIN_FREQUENCY,
- MAINTAIN_FREQUENCY,
- NULL);
+ &maintain_dht_job,
+ MAINTAIN_FREQUENCY,
+ MAINTAIN_FREQUENCY,
+ NULL);
return OK;
}
@@ -729,13 +729,13 @@
unsigned int j;
coreAPI->unregisterHandler(P2P_PROTO_DHT_DISCOVERY,
- &handleDiscovery);
+ &handleDiscovery);
coreAPI->unregisterHandler(P2P_PROTO_DHT_ASK_HELLO,
- &handleAskHello);
+ &handleAskHello);
cron_del_job(coreAPI->cron,
- &maintain_dht_job,
- MAINTAIN_FREQUENCY,
- NULL);
+ &maintain_dht_job,
+ MAINTAIN_FREQUENCY,
+ NULL);
if (stats != NULL) {
coreAPI->releaseService(stats);
stats = NULL;
@@ -748,8 +748,8 @@
for (j=0;j<buckets[i].peers_size;j++)
FREE(buckets[i].peers[j]);
GROW(buckets[i].peers,
- buckets[i].peers_size,
- 0);
+ buckets[i].peers_size,
+ 0);
}
GROW(buckets,
bucketCount,
Modified: GNUnet/src/applications/dht/tools/dht-query.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-query.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/dht/tools/dht-query.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -64,19 +64,19 @@
};
static int printCallback(const HashCode512 * hash,
- const DataContainer * data,
- void * cls) {
+ const DataContainer * data,
+ void * cls) {
char * key = cls;
printf("%s(%s): '%.*s'\n",
- "get",
- key,
- ntohl(data->size) - sizeof(DataContainer),
- (char*)&data[1]);
+ "get",
+ key,
+ ntohl(data->size) - sizeof(DataContainer),
+ (char*)&data[1]);
return OK;
}
static void do_get(struct ClientServerConnection * sock,
- const char * key) {
+ const char * key) {
int ret;
HashCode512 hc;
@@ -85,81 +85,81 @@
&hc);
#if DEBUG_DHT_QUERY
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Issuing '%s(%s)' command.\n",
- "get",
- key);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Issuing '%s(%s)' command.\n",
+ "get",
+ key);
#endif
if (timeout == 0)
timeout = 30 * cronSECONDS;
ret = DHT_LIB_get(cfg,
- ectx,
- DHT_STRING2STRING_BLOCK,
- &hc,
- timeout,
- &printCallback,
- (void*) key);
+ ectx,
+ DHT_STRING2STRING_BLOCK,
+ &hc,
+ timeout,
+ &printCallback,
+ (void*) key);
if (ret == 0)
printf(_("%s(%s) operation returned no results.\n"),
- "get",
- key);
+ "get",
+ key);
}
static void do_put(struct ClientServerConnection * sock,
- const char * key,
- const char * value) {
+ const char * key,
+ const char * value) {
DataContainer * dc;
HashCode512 hc;
hash(key, strlen(key), &hc);
dc = MALLOC(sizeof(DataContainer)
- + strlen(value));
+ + strlen(value));
dc->size = htonl(strlen(value)
- + sizeof(DataContainer));
+ + sizeof(DataContainer));
memcpy(&dc[1],
- value,
- strlen(value));
+ value,
+ strlen(value));
#if DEBUG_DHT_QUERY
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("Issuing '%s(%s,%s)' command.\n"),
- "put",
- key,
- value);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("Issuing '%s(%s,%s)' command.\n"),
+ "put",
+ key,
+ value);
#endif
if (timeout == 0)
timeout = 30 * cronMINUTES;
if (OK == DHT_LIB_put(cfg,
- ectx,
- &hc,
- DHT_STRING2STRING_BLOCK,
- timeout + get_time(), /* convert to absolute time */
- dc)) {
+ ectx,
+ &hc,
+ DHT_STRING2STRING_BLOCK,
+ timeout + get_time(), /* convert to absolute time */
+ dc)) {
printf(_("'%s(%s,%s)' succeeded\n"),
- "put",
- key,
- value);
+ "put",
+ key,
+ value);
} else {
printf(_("'%s(%s,%s)' failed.\n"),
- "put",
- key,
- value);
- }
+ "put",
+ key,
+ value);
+ }
FREE(dc);
}
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
int i;
struct ClientServerConnection * handle;
i = GNUNET_init(argc,
- argv,
- "gnunet-dht-query",
- &cfgFilename,
- gnunetqueryOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-dht-query",
+ &cfgFilename,
+ gnunetqueryOptions,
+ &ectx,
+ &cfg);
if (i == -1) {
GNUNET_fini(ectx, cfg);
return -1;
@@ -168,7 +168,7 @@
handle = client_connection_create(ectx, cfg);
if (handle == NULL) {
fprintf(stderr,
- _("Failed to connect to gnunetd.\n"));
+ _("Failed to connect to gnunetd.\n"));
GC_free(cfg);
GE_free_context(ectx);
return 1;
@@ -177,34 +177,34 @@
while (i < argc) {
if (0 == strcmp("get", argv[i])) {
if (i+2 > argc) {
- fprintf(stderr,
- _("Command `%s' requires an argument (`%s').\n"),
- "get",
- "key");
- break;
+ fprintf(stderr,
+ _("Command `%s' requires an argument (`%s').\n"),
+ "get",
+ "key");
+ break;
} else {
- do_get(handle, argv[i+1]);
- i += 2;
+ do_get(handle, argv[i+1]);
+ i += 2;
}
continue;
}
if (0 == strcmp("put", argv[i])) {
if (i+3 > argc) {
- fprintf(stderr,
- _("Command `%s' requires two arguments (`%s' and `%s').\n"),
- "put",
- "key",
- "value");
- break;
+ fprintf(stderr,
+ _("Command `%s' requires two arguments (`%s' and `%s').\n"),
+ "put",
+ "key",
+ "value");
+ break;
} else {
- do_put(handle, argv[i+1], argv[i+2]);
- i += 3;
+ do_put(handle, argv[i+1], argv[i+2]);
+ i += 3;
}
continue;
}
fprintf(stderr,
- _("Unsupported command `%s'. Aborting.\n"),
- argv[i]);
+ _("Unsupported command `%s'. Aborting.\n"),
+ argv[i]);
break;
}
connection_destroy(handle);
Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -86,10 +86,10 @@
break;
reply = NULL;
if (OK != connection_read(info->sock,
- &reply))
+ &reply))
break;
if ( (sizeof(CS_dht_request_put_MESSAGE) > ntohs(reply->size)) ||
- (CS_PROTO_dht_REQUEST_PUT != ntohs(reply->type)) ) {
+ (CS_PROTO_dht_REQUEST_PUT != ntohs(reply->type)) ) {
GE_BREAK(NULL, 0);
info->total = SYSERR;
break; /* invalid reply */
@@ -103,9 +103,9 @@
size = ntohs(reply->size) - sizeof(CS_dht_request_put_MESSAGE);
cont->size = htonl(size + sizeof(DataContainer));
if ( (info->processor != NULL) &&
- (OK != info->processor(&put->key,
- cont,
- info->closure)) )
+ (OK != info->processor(&put->key,
+ cont,
+ info->closure)) )
info->aborted = YES;
info->total++;
FREE(reply);
@@ -136,12 +136,12 @@
* @return number of results on success, SYSERR on error (i.e. timeout)
*/
int DHT_LIB_get(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- unsigned int type,
- const HashCode512 * key,
- cron_t timeout,
- DataProcessor processor,
- void * closure) {
+ struct GE_Context * ectx,
+ unsigned int type,
+ const HashCode512 * key,
+ cron_t timeout,
+ DataProcessor processor,
+ void * closure) {
struct ClientServerConnection * sock;
CS_dht_request_get_MESSAGE req;
struct PTHREAD * thread;
@@ -152,7 +152,7 @@
void * unused;
sock = client_connection_create(ectx,
- cfg);
+ cfg);
if (sock == NULL)
return SYSERR;
req.header.size = htons(sizeof(CS_dht_request_get_MESSAGE));
@@ -161,7 +161,7 @@
req.timeout = htonll(timeout);
req.key = *key;
if (OK != connection_write(sock,
- &req.header)) {
+ &req.header)) {
connection_destroy(sock);
return SYSERR;
}
@@ -172,16 +172,16 @@
info.aborted = NO;
info.total = 0;
thread = PTHREAD_CREATE(&poll_thread,
- &info,
- 1024 * 8);
+ &info,
+ 1024 * 8);
start = get_time();
while ( (start + timeout > (now = get_time())) &&
- (GNUNET_SHUTDOWN_TEST() == NO) &&
- (info.aborted == NO) ) {
+ (GNUNET_SHUTDOWN_TEST() == NO) &&
+ (info.aborted == NO) ) {
delta =(start + timeout) - now;
if (delta > 100 * cronMILLIS)
delta = 100 * cronMILLIS; /* in case we miss SIGINT
- on CTRL-C */
+ on CTRL-C */
PTHREAD_SLEEP(delta);
}
info.aborted = YES;
@@ -191,7 +191,7 @@
connection_destroy(sock);
return info.total;
}
-
+
/**
* Perform a synchronous put operation. The peer does not have
* to be part of the table!
@@ -203,11 +203,11 @@
* @return OK on success, SYSERR on error
*/
int DHT_LIB_put(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const HashCode512 * key,
- unsigned int type,
- cron_t expire,
- const DataContainer * value) {
+ struct GE_Context * ectx,
+ const HashCode512 * key,
+ unsigned int type,
+ cron_t expire,
+ const DataContainer * value) {
struct ClientServerConnection * sock;
CS_dht_request_put_MESSAGE * req;
int ret;
@@ -220,34 +220,34 @@
}
#if DEBUG_DHT_API
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "DHT_LIB_put called with value '%.*s'\n",
- ntohl(value->size),
- &value[1]);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "DHT_LIB_put called with value '%.*s'\n",
+ ntohl(value->size),
+ &value[1]);
#endif
sock = client_connection_create(ectx,
- cfg);
+ cfg);
if (sock == NULL)
return SYSERR;
GE_ASSERT(NULL,
- ntohl(value->size) >= sizeof(DataContainer));
+ ntohl(value->size) >= sizeof(DataContainer));
req = MALLOC(sizeof(CS_dht_request_put_MESSAGE) +
- ntohl(value->size) -
- sizeof(DataContainer));
+ ntohl(value->size) -
+ sizeof(DataContainer));
req->header.size
= htons(sizeof(CS_dht_request_put_MESSAGE) +
- ntohl(value->size) -
- sizeof(DataContainer));
+ ntohl(value->size) -
+ sizeof(DataContainer));
req->header.type
= htons(CS_PROTO_dht_REQUEST_PUT);
req->key = *key;
req->type = htonl(type);
req->expire = htonll(expire - now); /* convert to relative time */
memcpy(&req[1],
- &value[1],
- ntohl(value->size) - sizeof(DataContainer));
+ &value[1],
+ ntohl(value->size) - sizeof(DataContainer));
ret = connection_write(sock,
- &req->header);
+ &req->header);
connection_destroy(sock);
FREE(req);
return ret;
Modified: GNUnet/src/applications/dht/tools/dhttest.c
===================================================================
--- GNUnet/src/applications/dht/tools/dhttest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/dht/tools/dhttest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -58,7 +58,7 @@
* @return 0: ok, -1: error
*/
int main(int argc,
- const char ** argv) {
+ const char ** argv) {
struct DaemonContext * peers;
int ret = 0;
HashCode512 key;
@@ -76,16 +76,16 @@
ectx = NULL;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
peers = gnunet_testing_start_daemons("tcp",
- "advertising dht stats",
- "/tmp/gnunet-dht-test",
- 2087,
- 10,
- NUM_PEERS);
+ "advertising dht stats",
+ "/tmp/gnunet-dht-test",
+ 2087,
+ 10,
+ NUM_PEERS);
if (peers == NULL) {
GC_free(cfg);
return -1;
@@ -93,26 +93,26 @@
for (i=0;i<NUM_PEERS;i++) {
for (j=0;j<i;j++) {
if (OK != gnunet_testing_connect_daemons(2087 + 10*i,
- 2087 + 10*j)) {
- gnunet_testing_stop_daemons(peers);
- fprintf(stderr,
- "Failed to connect the peers!\n");
- GC_free(cfg);
- return -1;
+ 2087 + 10*j)) {
+ gnunet_testing_stop_daemons(peers);
+ fprintf(stderr,
+ "Failed to connect the peers!\n");
+ GC_free(cfg);
+ return -1;
}
}
}
/* wait for some DHT's to find each other! */
sock = client_connection_create(NULL,
- cfg);
+ cfg);
left = 30; /* how many iterations should we wait? */
while (OK == STATS_getStatistics(NULL,
- sock,
- &waitForConnect,
- NULL)) {
+ sock,
+ &waitForConnect,
+ NULL)) {
printf("Waiting for peers to DHT-connect (%u iterations left)...\n",
- left);
+ left);
sleep(5);
left--;
if (left == 0)
@@ -122,7 +122,7 @@
if (ok == 0) {
gnunet_testing_stop_daemons(peers);
fprintf(stderr,
- "Peers' DHTs failed to DHT-connect!\n");
+ "Peers' DHTs failed to DHT-connect!\n");
GC_free(cfg);
return -1;
}
@@ -130,26 +130,26 @@
/* put loop */
for (i=0;i<NUM_PEERS;i++) {
SNPRINTF(buf,
- 128,
- "localhost:%u",
- 2087 + i * 10);
+ 128,
+ "localhost:%u",
+ 2087 + i * 10);
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- buf);
+ ectx,
+ "NETWORK",
+ "HOST",
+ buf);
hash(buf, 4, &key);
value = MALLOC(8);
value->size = ntohl(8);
memset(&value[1],
- 'A' + i,
- 4);
+ 'A' + i,
+ 4);
CHECK(OK == DHT_LIB_put(cfg,
- ectx,
- &key,
- DHT_STRING2STRING_BLOCK,
- get_time() + 15 * cronMINUTES * NUM_ROUNDS *
NUM_PEERS * NUM_PEERS,
- value));
+ ectx,
+ &key,
+ DHT_STRING2STRING_BLOCK,
+ get_time() + 15 * cronMINUTES * NUM_ROUNDS * NUM_PEERS *
NUM_PEERS,
+ value));
}
/* get loops */
@@ -157,43 +157,43 @@
found = 0;
for (i=0;i<NUM_PEERS;i++) {
SNPRINTF(buf,
- 128,
- "localhost:%u",
- 2087 + i * 10);
+ 128,
+ "localhost:%u",
+ 2087 + i * 10);
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- buf);
+ ectx,
+ "NETWORK",
+ "HOST",
+ buf);
for (j=0;j<NUM_PEERS;j++) {
- SNPRINTF(buf,
- 128,
- "localhost:%u",
- 2087 + j * 10);
- hash(buf, 4, &key);
- fprintf(stderr,
- "Peer %d gets key %d", i, j);
- if (0 < DHT_LIB_get(cfg,
- ectx,
- DHT_STRING2STRING_BLOCK,
- &key,
- (NUM_ROUNDS - k) * cronSECONDS,
- NULL,
- NULL)) {
- fprintf(stderr,
- " - found!\n");
- found++;
- } else
- fprintf(stderr,
- " - NOT found!\n");
+ SNPRINTF(buf,
+ 128,
+ "localhost:%u",
+ 2087 + j * 10);
+ hash(buf, 4, &key);
+ fprintf(stderr,
+ "Peer %d gets key %d", i, j);
+ if (0 < DHT_LIB_get(cfg,
+ ectx,
+ DHT_STRING2STRING_BLOCK,
+ &key,
+ (NUM_ROUNDS - k) * cronSECONDS,
+ NULL,
+ NULL)) {
+ fprintf(stderr,
+ " - found!\n");
+ found++;
+ } else
+ fprintf(stderr,
+ " - NOT found!\n");
}
}
/* end of actual test code */
fprintf(stderr,
- "Found %u out of %u attempts in round %u.\n",
- found,
- NUM_PEERS * NUM_PEERS,
- k);
+ "Found %u out of %u attempts in round %u.\n",
+ found,
+ NUM_PEERS * NUM_PEERS,
+ k);
}
FAILURE:
gnunet_testing_stop_daemons(peers);
Modified: GNUnet/src/applications/dht/tools/dhttest2.c
===================================================================
--- GNUnet/src/applications/dht/tools/dhttest2.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/dht/tools/dhttest2.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -58,7 +58,7 @@
* @return 0: ok, -1: error
*/
int main(int argc,
- const char ** argv) {
+ const char ** argv) {
#if START_PEERS
struct DaemonContext * peers;
#endif
@@ -73,41 +73,41 @@
ectx = NULL;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_PEERS
peers = gnunet_testing_start_daemons("tcp",
- "advertising dht stats",
- "/tmp/gnunet-dht-test",
- 2087,
- 10000,
- 2);
+ "advertising dht stats",
+ "/tmp/gnunet-dht-test",
+ 2087,
+ 10000,
+ 2);
if (peers == NULL) {
GC_free(cfg);
return -1;
}
#endif
if (OK != gnunet_testing_connect_daemons(2087,
- 12087)) {
+ 12087)) {
gnunet_testing_stop_daemons(peers);
fprintf(stderr,
- "Failed to connect the peers!\n");
+ "Failed to connect the peers!\n");
GC_free(cfg);
return -1;
}
/* wait for DHT's to find each other! */
sock = client_connection_create(NULL,
- cfg);
+ cfg);
left = 30; /* how many iterations should we wait? */
while (OK == STATS_getStatistics(NULL,
- sock,
- &waitForConnect,
- NULL)) {
+ sock,
+ &waitForConnect,
+ NULL)) {
printf("Waiting for peers to DHT-connect (%u iterations left)...\n",
- left);
+ left);
sleep(5);
left--;
if (left == 0)
@@ -117,28 +117,28 @@
if (ok == 0) {
gnunet_testing_stop_daemons(peers);
fprintf(stderr,
- "Peers' DHTs failed to DHT-connect!\n");
+ "Peers' DHTs failed to DHT-connect!\n");
GC_free(cfg);
return -1;
}
/* switch to peer2 */
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- "localhost:12087");
+ ectx,
+ "NETWORK",
+ "HOST",
+ "localhost:12087");
/* verify that peer2 also sees the other DHT! */
ok = 0;
sock = client_connection_create(NULL,
- cfg);
+ cfg);
left = 30; /* how many iterations should we wait? */
while (OK == STATS_getStatistics(NULL,
- sock,
- &waitForConnect,
- NULL)) {
+ sock,
+ &waitForConnect,
+ NULL)) {
printf("Waiting for peers to DHT-connect (%u iterations left)...\n",
- left);
+ left);
sleep(5);
left--;
if (left == 0)
@@ -148,7 +148,7 @@
if (ok == 0) {
gnunet_testing_stop_daemons(peers);
fprintf(stderr,
- "Peers' DHTs failed to DHT-connect!\n");
+ "Peers' DHTs failed to DHT-connect!\n");
GC_free(cfg);
return -1;
}
@@ -156,84 +156,84 @@
/* switch to peer1 */
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- "localhost:2087");
+ ectx,
+ "NETWORK",
+ "HOST",
+ "localhost:2087");
/* actual test code */
hash("key2", 4, &key);
value = MALLOC(8);
value->size = ntohl(8);
memset(&value[1],
- 'A',
- 4);
+ 'A',
+ 4);
printf("Peer1 stores key2\n");
CHECK(OK == DHT_LIB_put(cfg,
- ectx,
- &key,
- DHT_STRING2STRING_BLOCK,
- get_time() + 5 * cronMINUTES,
- value));
+ ectx,
+ &key,
+ DHT_STRING2STRING_BLOCK,
+ get_time() + 5 * cronMINUTES,
+ value));
printf("Peer1 gets key2\n");
CHECK(1 == DHT_LIB_get(cfg,
- ectx,
- DHT_STRING2STRING_BLOCK,
- &key,
- 2 * cronSECONDS,
- NULL,
- NULL));
+ ectx,
+ DHT_STRING2STRING_BLOCK,
+ &key,
+ 2 * cronSECONDS,
+ NULL,
+ NULL));
/* switch to peer2 */
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- "localhost:12087");
+ ectx,
+ "NETWORK",
+ "HOST",
+ "localhost:12087");
hash("key", 3, &key);
value = MALLOC(8);
value->size = ntohl(8);
memset(&value[1],
- 'B',
- 4);
+ 'B',
+ 4);
printf("Peer2 stores key.\n");
CHECK(OK == DHT_LIB_put(cfg,
- ectx,
- &key,
- DHT_STRING2STRING_BLOCK,
- get_time() + 5 * cronMINUTES,
- value));
+ ectx,
+ &key,
+ DHT_STRING2STRING_BLOCK,
+ get_time() + 5 * cronMINUTES,
+ value));
printf("Peer2 gets key.\n");
CHECK(1 == DHT_LIB_get(cfg,
- ectx,
- DHT_STRING2STRING_BLOCK,
- &key,
- 2 * cronSECONDS,
- NULL,
- NULL));
+ ectx,
+ DHT_STRING2STRING_BLOCK,
+ &key,
+ 2 * cronSECONDS,
+ NULL,
+ NULL));
hash("key2", 4, &key);
printf("Peer2 gets key2.\n");
CHECK(1 == DHT_LIB_get(cfg,
- ectx,
- DHT_STRING2STRING_BLOCK,
- &key,
- 30 * cronSECONDS,
- NULL,
- NULL));
+ ectx,
+ DHT_STRING2STRING_BLOCK,
+ &key,
+ 30 * cronSECONDS,
+ NULL,
+ NULL));
/* switch to peer1 */
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- "localhost:2087");
+ ectx,
+ "NETWORK",
+ "HOST",
+ "localhost:2087");
printf("Peer1 gets key\n");
CHECK(1 == DHT_LIB_get(cfg,
- ectx,
- DHT_STRING2STRING_BLOCK,
- &key,
- 30 * cronSECONDS,
- NULL,
- NULL));
+ ectx,
+ DHT_STRING2STRING_BLOCK,
+ &key,
+ 30 * cronSECONDS,
+ NULL,
+ NULL));
/* end of actual test code */
FAILURE:
Modified: GNUnet/src/applications/dstore/dstore.c
===================================================================
--- GNUnet/src/applications/dstore/dstore.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/dstore/dstore.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -80,14 +80,14 @@
* @brief Prepare a SQL statement
*/
static int sq_prepare(sqlite3 * dbh,
- const char *zSql, /* SQL statement, UTF-8 encoded */
- sqlite3_stmt **ppStmt) { /* OUT: Statement handle */
+ const char *zSql, /* SQL statement, UTF-8 encoded */
+ sqlite3_stmt **ppStmt) { /* OUT: Statement handle */
char * dummy;
return sqlite3_prepare(dbh,
- zSql,
- strlen(zSql),
- ppStmt,
- (const char**) &dummy);
+ zSql,
+ strlen(zSql),
+ ppStmt,
+ (const char**) &dummy);
}
#define SQLITE3_EXEC(db, cmd) do { if (SQLITE_OK != sqlite3_exec(db, cmd,
NULL, NULL, &emsg)) { GE_LOG(coreAPI->ectx, GE_ERROR | GE_ADMIN | GE_BULK,
_("`%s' failed at %s:%d with error: %s\n"), "sqlite3_exec", __FILE__, __LINE__,
emsg); sqlite3_free(emsg); } } while(0);
@@ -96,25 +96,25 @@
char * emsg;
SQLITE3_EXEC(dbh,
- "PRAGMA temp_store=MEMORY");
+ "PRAGMA temp_store=MEMORY");
SQLITE3_EXEC(dbh,
- "PRAGMA synchronous=OFF");
+ "PRAGMA synchronous=OFF");
SQLITE3_EXEC(dbh,
- "PRAGMA count_changes=OFF");
+ "PRAGMA count_changes=OFF");
SQLITE3_EXEC(dbh,
- "PRAGMA page_size=4092");
+ "PRAGMA page_size=4092");
SQLITE3_EXEC(dbh,
- "CREATE TABLE ds071 ("
- " size INTEGER NOT NULL DEFAULT 0,"
- " type INTEGER NOT NULL DEFAULT 0,"
- " puttime INTEGER NOT NULL DEFAULT 0,"
- " expire INTEGER NOT NULL DEFAULT 0,"
- " key TEXT NOT NULL DEFAULT '',"
- " value BLOB NOT NULL DEFAULT '')");
+ "CREATE TABLE ds071 ("
+ " size INTEGER NOT NULL DEFAULT 0,"
+ " type INTEGER NOT NULL DEFAULT 0,"
+ " puttime INTEGER NOT NULL DEFAULT 0,"
+ " expire INTEGER NOT NULL DEFAULT 0,"
+ " key TEXT NOT NULL DEFAULT '',"
+ " value BLOB NOT NULL DEFAULT '')");
SQLITE3_EXEC(dbh,
- "CREATE INDEX idx_key ON ds071 (key)");
+ "CREATE INDEX idx_key ON ds071 (key)");
SQLITE3_EXEC(dbh,
- "CREATE INDEX idx_puttime ON ds071 (puttime)");
+ "CREATE INDEX idx_puttime ON ds071 (puttime)");
}
static int db_reset() {
@@ -135,7 +135,7 @@
}
CLOSE(fd);
if (SQLITE_OK != sqlite3_open(fn,
- &dbh))
+ &dbh))
return SYSERR;
db_init(dbh);
sqlite3_close(dbh);
@@ -161,27 +161,27 @@
return OK; /* we seem to be about 10% off */
#if DEBUG_DSTORE
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "DStore above qutoa (have %llu, allowed %llu), will delete some
data.\n",
- payload,
- quota);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "DStore above qutoa (have %llu, allowed %llu), will delete some data.\n",
+ payload,
+ quota);
#endif
stmt = NULL;
dstmt = NULL;
if ( (sq_prepare(dbh,
- "SELECT size, type, puttime, expire, key, value FROM ds071
ORDER BY puttime ASC",
- &stmt) != SQLITE_OK) ||
+ "SELECT size, type, puttime, expire, key, value FROM ds071 ORDER BY
puttime ASC",
+ &stmt) != SQLITE_OK) ||
(sq_prepare(dbh,
- "DELETE FROM ds071 "
- "WHERE size = ? AND type = ? AND puttime = ? AND expire = ?
AND key = ? AND value = ?",
- &dstmt) != SQLITE_OK) ) {
+ "DELETE FROM ds071 "
+ "WHERE size = ? AND type = ? AND puttime = ? AND expire = ? AND key
= ? AND value = ?",
+ &dstmt) != SQLITE_OK) ) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- _("`%s' failed at %s:%d with error: %s\n"),
- "sq_prepare",
- __FILE__,
- __LINE__,
- sqlite3_errmsg(dbh));
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "sq_prepare",
+ __FILE__,
+ __LINE__,
+ sqlite3_errmsg(dbh));
GE_BREAK(NULL, 0);
if (dstmt != NULL)
sqlite3_finalize(dstmt);
@@ -192,56 +192,56 @@
dcontent = MALLOC(MAX_CONTENT_SIZE);
err = SQLITE_DONE;
while ( (payload * 10 > quota * 9) && /* we seem to be about 10% off */
- ((err = sqlite3_step(stmt)) == SQLITE_ROW) ) {
+ ((err = sqlite3_step(stmt)) == SQLITE_ROW) ) {
dsize = sqlite3_column_int(stmt, 0);
dtype = sqlite3_column_int(stmt, 1);
dputtime = sqlite3_column_int64(stmt, 2);
dexpire = sqlite3_column_int64(stmt, 3);
GE_BREAK(NULL,
- sqlite3_column_bytes(stmt, 4) == sizeof(HashCode512));
+ sqlite3_column_bytes(stmt, 4) == sizeof(HashCode512));
GE_BREAK(NULL,
- dsize == sqlite3_column_bytes(stmt, 5));
+ dsize == sqlite3_column_bytes(stmt, 5));
memcpy(&dkey,
- sqlite3_column_blob(stmt, 4),
- sizeof(HashCode512));
+ sqlite3_column_blob(stmt, 4),
+ sizeof(HashCode512));
if (dsize >= MAX_CONTENT_SIZE) {
GE_BREAK(NULL, 0);
dsize = MAX_CONTENT_SIZE;
}
memcpy(dcontent,
- sqlite3_column_blob(stmt, 5),
- dsize);
+ sqlite3_column_blob(stmt, 5),
+ dsize);
sqlite3_reset(stmt);
sqlite3_bind_int(dstmt,
- 1,
- dsize);
+ 1,
+ dsize);
sqlite3_bind_int(dstmt,
- 2,
- dtype);
+ 2,
+ dtype);
sqlite3_bind_int64(dstmt,
- 3,
- dputtime);
+ 3,
+ dputtime);
sqlite3_bind_int64(dstmt,
- 4,
- dexpire);
+ 4,
+ dexpire);
sqlite3_bind_blob(dstmt,
- 5,
- &dkey,
- sizeof(HashCode512),
- SQLITE_TRANSIENT);
+ 5,
+ &dkey,
+ sizeof(HashCode512),
+ SQLITE_TRANSIENT);
sqlite3_bind_blob(dstmt,
- 6,
- dcontent,
- dsize,
- SQLITE_TRANSIENT);
+ 6,
+ dcontent,
+ dsize,
+ SQLITE_TRANSIENT);
if ((err = sqlite3_step(dstmt)) != SQLITE_DONE) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- _("`%s' failed at %s:%d with error: %s\n"),
- "sqlite3_step",
- __FILE__,
- __LINE__,
- sqlite3_errmsg(dbh));
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "sqlite3_step",
+ __FILE__,
+ __LINE__,
+ sqlite3_errmsg(dbh));
sqlite3_reset(dstmt);
GE_BREAK(NULL, 0); /* should delete but cannot!? */
break;
@@ -249,22 +249,22 @@
payload -= (dsize + OVERHEAD);
#if DEBUG_DSTORE
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Deleting %u bytes decreases DStore payload to %llu out of %llu\n",
- dsize,
- payload,
- quota);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Deleting %u bytes decreases DStore payload to %llu out of %llu\n",
+ dsize,
+ payload,
+ quota);
#endif
- sqlite3_reset(dstmt);
+ sqlite3_reset(dstmt);
}
if (err != SQLITE_DONE) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- _("`%s' failed at %s:%d with error: %s\n"),
- "sqlite3_step",
- __FILE__,
- __LINE__,
- sqlite3_errmsg(dbh));
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "sqlite3_step",
+ __FILE__,
+ __LINE__,
+ sqlite3_errmsg(dbh));
}
FREE(dcontent);
sqlite3_finalize(dstmt);
@@ -272,10 +272,10 @@
if (payload * 10 > quota * 9) {
/* we seem to be about 10% off */
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_BULK | GE_DEVELOPER,
- "Failed to delete content to drop below quota (bug?).\n",
- payload,
- quota);
+ GE_ERROR | GE_BULK | GE_DEVELOPER,
+ "Failed to delete content to drop below quota (bug?).\n",
+ payload,
+ quota);
return SYSERR;
}
return OK;
@@ -287,10 +287,10 @@
* @return OK on success, SYSERR on error
*/
static int d_put(const HashCode512 * key,
- unsigned int type,
- cron_t discard_time,
- unsigned int size,
- const char * data) {
+ unsigned int type,
+ cron_t discard_time,
+ unsigned int size,
+ const char * data) {
sqlite3 * dbh;
sqlite3_stmt * stmt;
int ret;
@@ -300,57 +300,57 @@
MUTEX_LOCK(lock);
if ( (fn == NULL) ||
(SQLITE_OK != sqlite3_open(fn,
- &dbh)) ) {
+ &dbh)) ) {
db_reset(dbh);
MUTEX_UNLOCK(lock);
return SYSERR;
}
#if DEBUG_DSTORE
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "dstore processes put `%.*s\n",
- size,
- data);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "dstore processes put `%.*s\n",
+ size,
+ data);
#endif
/* first try UPDATE */
if (sq_prepare(dbh,
- "UPDATE ds071 SET puttime=?, expire=? "
- "WHERE key=? AND type=? AND size=? AND value=?",
- &stmt) != SQLITE_OK) {
+ "UPDATE ds071 SET puttime=?, expire=? "
+ "WHERE key=? AND type=? AND size=? AND value=?",
+ &stmt) != SQLITE_OK) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- _("`%s' failed at %s:%d with error: %s\n"),
- "sq_prepare",
- __FILE__,
- __LINE__,
- sqlite3_errmsg(dbh));
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "sq_prepare",
+ __FILE__,
+ __LINE__,
+ sqlite3_errmsg(dbh));
sqlite3_close(dbh);
MUTEX_UNLOCK(lock);
return SYSERR;
}
sqlite3_bind_int64(stmt,
- 1,
- get_time());
+ 1,
+ get_time());
sqlite3_bind_int64(stmt,
- 2,
- discard_time);
+ 2,
+ discard_time);
sqlite3_bind_blob(stmt,
- 3,
- key,
- sizeof(HashCode512),
- SQLITE_TRANSIENT);
+ 3,
+ key,
+ sizeof(HashCode512),
+ SQLITE_TRANSIENT);
sqlite3_bind_int(stmt,
- 4,
- type);
+ 4,
+ type);
sqlite3_bind_int(stmt,
- 5,
- size);
+ 5,
+ size);
sqlite3_bind_blob(stmt,
- 6,
- data,
- size,
- SQLITE_TRANSIENT);
+ 6,
+ data,
+ size,
+ SQLITE_TRANSIENT);
sqlite3_step(stmt);
ret = sqlite3_changes(dbh);
sqlite3_finalize(stmt);
@@ -361,7 +361,7 @@
}
if (bloom != NULL)
addToBloomfilter(bloom,
- key);
+ key);
if (OK != checkQuota(dbh)) {
sqlite3_close(dbh);
@@ -369,53 +369,53 @@
return SYSERR;
}
if (sq_prepare(dbh,
- "INSERT INTO ds071 "
- "(size, type, puttime, expire, key, value) "
- "VALUES (?, ?, ?, ?, ?, ?)",
- &stmt) != SQLITE_OK) {
+ "INSERT INTO ds071 "
+ "(size, type, puttime, expire, key, value) "
+ "VALUES (?, ?, ?, ?, ?, ?)",
+ &stmt) != SQLITE_OK) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- _("`%s' failed at %s:%d with error: %s\n"),
- "sq_prepare",
- __FILE__,
- __LINE__,
- sqlite3_errmsg(dbh));
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "sq_prepare",
+ __FILE__,
+ __LINE__,
+ sqlite3_errmsg(dbh));
sqlite3_close(dbh);
MUTEX_UNLOCK(lock);
return SYSERR;
}
sqlite3_bind_int(stmt,
- 1,
- size);
+ 1,
+ size);
sqlite3_bind_int(stmt,
- 2,
- type);
+ 2,
+ type);
sqlite3_bind_int64(stmt,
- 3,
- get_time());
+ 3,
+ get_time());
sqlite3_bind_int64(stmt,
- 4,
- discard_time);
+ 4,
+ discard_time);
sqlite3_bind_blob(stmt,
- 5,
- key,
- sizeof(HashCode512),
- SQLITE_TRANSIENT);
+ 5,
+ key,
+ sizeof(HashCode512),
+ SQLITE_TRANSIENT);
sqlite3_bind_blob(stmt,
- 6,
- data,
- size,
- SQLITE_TRANSIENT);
+ 6,
+ data,
+ size,
+ SQLITE_TRANSIENT);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
payload += size + OVERHEAD;
#if DEBUG_DSTORE
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Storing %u bytes increases DStore payload to %llu out of %llu\n",
- size,
- payload,
- quota);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Storing %u bytes increases DStore payload to %llu out of %llu\n",
+ size,
+ payload,
+ quota);
#endif
checkQuota(dbh);
sqlite3_close(dbh);
@@ -436,9 +436,9 @@
* iter is non-NULL and aborted the iteration
*/
static int d_get(const HashCode512 * key,
- unsigned int type,
- ResultHandler handler,
- void * closure) {
+ unsigned int type,
+ ResultHandler handler,
+ void * closure) {
sqlite3 * dbh;
sqlite3_stmt * stmt;
cron_t now;
@@ -449,48 +449,48 @@
MUTEX_LOCK(lock);
if ( (bloom != NULL) &&
(NO == testBloomfilter(bloom,
- key)) ) {
+ key)) ) {
MUTEX_UNLOCK(lock);
return 0;
}
if ( (fn == NULL) ||
(SQLITE_OK != sqlite3_open(fn,
- &dbh)) ) {
+ &dbh)) ) {
db_reset(dbh);
MUTEX_UNLOCK(lock);
return SYSERR;
}
#if DEBUG_DSTORE
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "dstore processes get\n");
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "dstore processes get\n");
#endif
now = get_time();
if (sq_prepare(dbh,
- "SELECT size, value FROM ds071 WHERE key=? AND type=? AND
expire >= ?",
- &stmt) != SQLITE_OK) {
+ "SELECT size, value FROM ds071 WHERE key=? AND type=? AND expire >= ?",
+ &stmt) != SQLITE_OK) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- _("`%s' failed at %s:%d with error: %s\n"),
- "sq_prepare",
- __FILE__,
- __LINE__,
- sqlite3_errmsg(dbh));
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "sq_prepare",
+ __FILE__,
+ __LINE__,
+ sqlite3_errmsg(dbh));
sqlite3_close(dbh);
MUTEX_UNLOCK(lock);
return SYSERR;
}
sqlite3_bind_blob(stmt,
- 1,
- key,
- sizeof(HashCode512),
- SQLITE_TRANSIENT);
+ 1,
+ key,
+ sizeof(HashCode512),
+ SQLITE_TRANSIENT);
sqlite3_bind_int(stmt,
- 2,
- type);
+ 2,
+ type);
sqlite3_bind_int(stmt,
- 3,
- now);
+ 3,
+ now);
cnt = 0;
while (sqlite3_step(stmt) == SQLITE_ROW) {
size = sqlite3_column_int(stmt, 0);
@@ -500,10 +500,10 @@
}
dat = sqlite3_column_blob(stmt, 1);
handler(key,
- type,
- size,
- dat,
- closure);
+ type,
+ size,
+ dat,
+ closure);
cnt++;
}
sqlite3_finalize(stmt);
@@ -519,8 +519,8 @@
#if DEBUG_SQLITE
GE_LOG(capi->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite Dstore: initializing database\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite Dstore: initializing database\n");
#endif
if (OK != db_reset())
return NULL;
@@ -531,12 +531,12 @@
api.get = &d_get;
api.put = &d_put;
GC_get_configuration_value_number(coreAPI->cfg,
- "DSTORE",
- "QUOTA",
- 1,
- 1024,
- 1,
- "a);
+ "DSTORE",
+ "QUOTA",
+ 1,
+ 1024,
+ 1,
+ "a);
if (quota == 0) /* error */
quota = 1;
quota *= 1024 * 1024;
@@ -545,9 +545,9 @@
fd = mkstemp(bloom_name);
if (fd != -1) {
bloom = loadBloomfilter(coreAPI->ectx,
- bloom_name,
- quota / (OVERHEAD + 1024), /* 8 bit per entry in
DB, expect 1k entries */
- 5);
+ bloom_name,
+ quota / (OVERHEAD + 1024), /* 8 bit per entry in DB, expect
1k entries */
+ 5);
CLOSE(fd);
}
stats = capi->requestService("stats");
@@ -576,8 +576,8 @@
}
#if DEBUG_SQLITE
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite Dstore: database shutdown\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite Dstore: database shutdown\n");
#endif
MUTEX_DESTROY(lock);
coreAPI = NULL;
Modified: GNUnet/src/applications/dstore/dstore_test.c
===================================================================
--- GNUnet/src/applications/dstore/dstore_test.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/dstore/dstore_test.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -36,10 +36,10 @@
static int error;
static void checkIt(const HashCode512 * key,
- unsigned int type,
- unsigned int size,
- const char * data,
- void * cls) {
+ unsigned int type,
+ unsigned int size,
+ const char * data,
+ void * cls) {
if (size != sizeof(HashCode512)) {
printf("ERROR: Invalid size\n");
error = 2;
@@ -61,30 +61,30 @@
exp = get_time() + 5 * cronMINUTES;
memset(&k,
- 0,
- sizeof(HashCode512));
+ 0,
+ sizeof(HashCode512));
for (i=0;i<100;i++) {
hash(&k,
- sizeof(HashCode512),
- &n);
+ sizeof(HashCode512),
+ &n);
ASSERT(OK == api->put(&k,
- i % 2,
- exp,
- sizeof(HashCode512),
- (const char*) &n));
+ i % 2,
+ exp,
+ sizeof(HashCode512),
+ (const char*) &n));
k = n;
}
memset(&k,
- 0,
- sizeof(HashCode512));
+ 0,
+ sizeof(HashCode512));
for (i=0;i<100;i++) {
hash(&k,
- sizeof(HashCode512),
- &n);
+ sizeof(HashCode512),
+ &n);
ASSERT(1 == api->get(&k,
- i % 2,
- &checkIt,
- &n));
+ i % 2,
+ &checkIt,
+ &n));
k = n;
}
return OK;
@@ -102,15 +102,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("dstore");
if (api != NULL) {
ok = test(api);
Modified: GNUnet/src/applications/fragmentation/fragmentation.c
===================================================================
--- GNUnet/src/applications/fragmentation/fragmentation.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/fragmentation/fragmentation.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -116,7 +116,7 @@
static struct MUTEX * defragCacheLock;
static void freeFL(FL * fl,
- int c) {
+ int c) {
while (fl != NULL) {
FL * link = fl->link;
if (stats != NULL)
@@ -149,18 +149,18 @@
smf = defragmentationCache[i];
while (smf != NULL) {
if (smf->ttl < get_time()) {
- /* free linked list of fragments */
- freeFL(smf->head, 1);
- next = smf->next;
- FREE(smf);
- if (last == NULL)
- defragmentationCache[i] = next;
- else
- last->next = next;
- smf = next;
+ /* free linked list of fragments */
+ freeFL(smf->head, 1);
+ next = smf->next;
+ FREE(smf);
+ if (last == NULL)
+ defragmentationCache[i] = next;
+ else
+ last->next = next;
+ smf = next;
} else {
- last = smf;
- smf = smf->next;
+ last = smf;
+ smf = smf->next;
}
} /* while smf != NULL */
} /* for all buckets */
@@ -190,7 +190,7 @@
goto CLEANUP; /* really bad error! */
off = 0;
while ( (pos != NULL) &&
- (ntohs(pos->frag->off) <= off) ) {
+ (ntohs(pos->frag->off) <= off) ) {
if (off >= off + FRAGSIZE(pos))
goto CLEANUP; /* error! */
if (ntohs(pos->frag->off) + FRAGSIZE(pos) > off)
@@ -206,8 +206,8 @@
pos = pep->head;
while (pos != NULL) {
memcpy(&msg[ntohs(pos->frag->off)],
- &pos->frag[1],
- FRAGSIZE(pos));
+ &pos->frag[1],
+ FRAGSIZE(pos));
pos = pos->link;
}
if (stats != NULL)
@@ -217,10 +217,10 @@
#endif
/* handle message! */
coreAPI->injectMessage(&pep->sender,
- msg,
- len,
- YES,
- NULL);
+ msg,
+ len,
+ YES,
+ NULL);
FREE(msg);
CLEANUP:
/* free fragment buffers */
@@ -241,8 +241,8 @@
* @param packet the ip part in the new entry
*/
static int tryJoin(FC * entry,
- const PeerIdentity * sender,
- const P2P_fragmentation_MESSAGE * packet) {
+ const PeerIdentity * sender,
+ const P2P_fragmentation_MESSAGE * packet) {
/* frame before ours; may end in the middle of
our frame or before it starts; NULL if we are
the earliest position we have received so far */
@@ -260,16 +260,16 @@
GE_ASSERT(NULL, entry != NULL);
if (0 != memcmp(sender,
- &entry->sender,
- sizeof(PeerIdentity)))
+ &entry->sender,
+ sizeof(PeerIdentity)))
return SYSERR; /* wrong fragment list, try another! */
if (ntohl(packet->id) != entry->id)
return SYSERR; /* wrong fragment list, try another! */
#if 0
printf("Received fragment %u from %u to %u\n",
- ntohl(packet->id),
- ntohs(packet->off),
- ntohs(packet->off) + ntohs(packet->header.size) -
sizeof(P2P_fragmentation_MESSAGE));
+ ntohl(packet->id),
+ ntohs(packet->off),
+ ntohs(packet->off) + ntohs(packet->header.size) -
sizeof(P2P_fragmentation_MESSAGE));
#endif
pos = entry->head;
if ( (pos != NULL) &&
@@ -279,8 +279,8 @@
before = NULL;
/* find the before-frame */
while ( (pos != NULL) &&
- (ntohs(pos->frag->off) <
- ntohs(packet->off)) ) {
+ (ntohs(pos->frag->off) <
+ ntohs(packet->off)) ) {
before = pos;
pos = pos->link;
}
@@ -289,9 +289,9 @@
end = ntohs(packet->off) + ntohs(packet->header.size) -
sizeof(P2P_fragmentation_MESSAGE);
if (end <= ntohs(packet->off)) {
GE_LOG(NULL,
- GE_DEVELOPER | GE_DEBUG | GE_BULK,
- "Received invalid fragment at %s:%d\n",
- __FILE__, __LINE__);
+ GE_DEVELOPER | GE_DEBUG | GE_BULK,
+ "Received invalid fragment at %s:%d\n",
+ __FILE__, __LINE__);
return SYSERR; /* yuck! integer overflow! */
}
@@ -300,7 +300,7 @@
else
after = entry->head;
while ( (after != NULL) &&
- (ntohs(after->frag->off)<end) )
+ (ntohs(after->frag->off)<end) )
after = after->link;
if ( (before != NULL) &&
@@ -316,8 +316,8 @@
if ( (before != NULL) &&
(after != NULL) &&
( (htons(before->frag->off) +
- FRAGSIZE(before))
- >= htons(after->frag->off)) ) {
+ FRAGSIZE(before))
+ >= htons(after->frag->off)) ) {
/* this implies that the fragment that starts before us and the
fragment that comes after this one leave no space in the middle
or even overlap; thus we can drop this redundant piece */
@@ -330,8 +330,8 @@
pep = MALLOC(sizeof(FC));
pep->frag = MALLOC(ntohs(packet->header.size));
memcpy(pep->frag,
- packet,
- ntohs(packet->header.size));
+ packet,
+ ntohs(packet->header.size));
pep->link = NULL;
if (before == NULL) {
@@ -383,7 +383,7 @@
* @return SYSERR if the fragment is invalid
*/
static int processFragment(const PeerIdentity * sender,
- const MESSAGE_HEADER * frag) {
+ const MESSAGE_HEADER * frag) {
unsigned int hash;
FC * smf;
@@ -395,14 +395,14 @@
smf = defragmentationCache[hash];
while (smf != NULL) {
if (OK == tryJoin(smf,
- sender,
- (P2P_fragmentation_MESSAGE*) frag)) {
+ sender,
+ (P2P_fragmentation_MESSAGE*) frag)) {
MUTEX_UNLOCK(defragCacheLock);
return OK;
}
if (0 == memcmp(sender,
- &smf->sender,
- sizeof(PeerIdentity))) {
+ &smf->sender,
+ sizeof(PeerIdentity))) {
freeFL(smf->head, 1);
break;
}
@@ -420,8 +420,8 @@
smf->head->link = NULL;
smf->head->frag = MALLOC(ntohs(frag->size));
memcpy(smf->head->frag,
- frag,
- ntohs(frag->size));
+ frag,
+ ntohs(frag->size));
MUTEX_UNLOCK(defragCacheLock);
return OK;
@@ -451,8 +451,8 @@
* such a great idea (i.e. would just waste bandwidth).
*/
static int fragmentBMC(void * buf,
- void * cls,
- unsigned short len) {
+ void * cls,
+ unsigned short len) {
FragmentBMC * ctx = cls;
static int idGen = 0;
P2P_fragmentation_MESSAGE * frag;
@@ -476,8 +476,8 @@
frag->off = htons(0);
frag->len = htons(ctx->len);
memcpy(&frag[1],
- &ctx[1],
- len - sizeof(P2P_fragmentation_MESSAGE));
+ &ctx[1],
+ len - sizeof(P2P_fragmentation_MESSAGE));
/* create remaining fragments, add to queue! */
pos = len - sizeof(P2P_fragmentation_MESSAGE);
@@ -493,12 +493,12 @@
frag->off = htons(pos);
frag->len = htons(ctx->len);
memcpy(&frag[1],
- &((char*)(&ctx[1]))[pos],
- mlen - sizeof(P2P_fragmentation_MESSAGE));
+ &((char*)(&ctx[1]))[pos],
+ mlen - sizeof(P2P_fragmentation_MESSAGE));
coreAPI->unicast(&ctx->sender,
- &frag->header,
- EXTREME_PRIORITY,
- ctx->transmissionTime - get_time());
+ &frag->header,
+ EXTREME_PRIORITY,
+ ctx->transmissionTime - get_time());
pos += mlen - sizeof(P2P_fragmentation_MESSAGE);
}
GE_ASSERT(NULL, pos == ctx->len);
@@ -514,12 +514,12 @@
* the other fragments (with very high priority).
*/
void fragment(const PeerIdentity * peer,
- unsigned int mtu,
- unsigned int prio,
- unsigned int targetTime,
- unsigned int len,
- BuildMessageCallback bmc,
- void * bmcClosure) {
+ unsigned int mtu,
+ unsigned int prio,
+ unsigned int targetTime,
+ unsigned int len,
+ BuildMessageCallback bmc,
+ void * bmcClosure) {
FragmentBMC * fbmc;
int xlen;
@@ -532,24 +532,24 @@
fbmc->len = len;
if (bmc == NULL) {
memcpy(&fbmc[1],
- bmcClosure,
- len);
+ bmcClosure,
+ len);
FREE(bmcClosure);
} else {
if (SYSERR == bmc(&fbmc[1],
- bmcClosure,
- len)) {
+ bmcClosure,
+ len)) {
FREE(fbmc);
return;
}
}
xlen = mtu - sizeof(P2P_fragmentation_MESSAGE);
coreAPI->unicastCallback(peer,
- &fragmentBMC,
- fbmc,
- mtu,
- prio * xlen / len, /* compute new prio */
- targetTime);
+ &fragmentBMC,
+ fbmc,
+ mtu,
+ prio * xlen / len, /* compute new prio */
+ targetTime);
}
/**
@@ -571,17 +571,17 @@
defragmentationCache[i] = NULL;
defragCacheLock = MUTEX_CREATE(NO);
cron_add_job(coreAPI->cron,
- &defragmentationPurgeCron,
- 60 * cronSECONDS,
- 60 * cronSECONDS,
- NULL);
+ &defragmentationPurgeCron,
+ 60 * cronSECONDS,
+ 60 * cronSECONDS,
+ NULL);
GE_LOG(capi->ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("`%s' registering handler %d\n"),
- "fragmentation",
- P2P_PROTO_fragment);
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("`%s' registering handler %d\n"),
+ "fragmentation",
+ P2P_PROTO_fragment);
capi->registerHandler(P2P_PROTO_fragment,
- &processFragment);
+ &processFragment);
ret.fragment = &fragment;
return &ret;
@@ -594,11 +594,11 @@
int i;
coreAPI->unregisterHandler(P2P_PROTO_fragment,
- &processFragment);
+ &processFragment);
cron_del_job(coreAPI->cron,
- &defragmentationPurgeCron,
- 60 * cronSECONDS,
- NULL);
+ &defragmentationPurgeCron,
+ 60 * cronSECONDS,
+ NULL);
for (i=0;i<DEFRAG_BUCKET_COUNT;i++) {
FC * pos = defragmentationCache[i];
while (pos != NULL) {
Modified: GNUnet/src/applications/fragmentation/fragmentationtest.c
===================================================================
--- GNUnet/src/applications/fragmentation/fragmentationtest.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/fragmentation/fragmentationtest.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -55,14 +55,14 @@
static char resultBuffer[65536];
static void handleHelper(const PeerIdentity * sender,
- const char * msg,
- const unsigned int len,
- int wasEncrypted,
- TSession * ts) {
+ const char * msg,
+ const unsigned int len,
+ int wasEncrypted,
+ TSession * ts) {
GE_ASSERT(NULL,
- 0 == memcmp(sender,
- &mySender,
- sizeof(PeerIdentity)));
+ 0 == memcmp(sender,
+ &mySender,
+ sizeof(PeerIdentity)));
myMsg = resultBuffer;
memcpy(resultBuffer, msg, len);
myMsgLen = len;
@@ -87,9 +87,9 @@
* @param id the identity of the fragment
*/
static MESSAGE_HEADER * makeFragment(unsigned short start,
- unsigned short size,
- unsigned short tot,
- int id) {
+ unsigned short size,
+ unsigned short tot,
+ int id) {
P2P_fragmentation_MESSAGE * frag;
int i;
@@ -113,7 +113,7 @@
* @param len the expected length
*/
static void checkPacket(int id,
- unsigned int len) {
+ unsigned int len) {
int i;
GE_ASSERT(NULL, myMsg != NULL);
@@ -327,12 +327,12 @@
/* ************* driver ****************** */
static int registerp2pHandler(const unsigned short type,
- MessagePartHandler callback) {
+ MessagePartHandler callback) {
return OK;
}
static int unregisterp2pHandler(const unsigned short type,
- MessagePartHandler callback) {
+ MessagePartHandler callback) {
return OK;
}
Modified: GNUnet/src/applications/fs/collection/collection.c
===================================================================
--- GNUnet/src/applications/fs/collection/collection.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/collection/collection.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -134,13 +134,13 @@
char * fnBase;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &fnBase);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fnBase);
fn = MALLOC(strlen(fnBase) +
- strlen(COLLECTION) +
- 4);
+ strlen(COLLECTION) +
+ 4);
strcpy(fn, fnBase);
disk_directory_create(ectx, fn);
strcat(fn, DIR_SEPARATOR_STR);
@@ -153,7 +153,7 @@
* Initialize collection module.
*/
void CO_init(struct GE_Context * e,
- struct GC_Configuration * c) {
+ struct GC_Configuration * c) {
char * fn;
int len;
unsigned int mlen;
@@ -175,9 +175,9 @@
}
/* read collection data */
if (OK != disk_file_size(ectx,
- fn,
- &size,
- YES)) {
+ fn,
+ &size,
+ YES)) {
FREE(fn);
return;
}
@@ -197,24 +197,24 @@
}
rsize = (size_t) size;
buf = MMAP(NULL,
- rsize,
- PROT_READ,
- MAP_SHARED,
- fd,
- 0);
+ rsize,
+ PROT_READ,
+ MAP_SHARED,
+ fd,
+ 0);
if (buf == MAP_FAILED) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "mmap",
- fn);
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "mmap",
+ fn);
CLOSE(fd);
FREE(fn);
return;
}
collectionData = MALLOC(sizeof(CollectionInfo));
memcpy(&collectionData->data,
- buf,
- sizeof(CollectionData));
+ buf,
+ sizeof(CollectionData));
pos = &buf[sizeof(CollectionData)];
rsize -= sizeof(CollectionData);
len = ntohl(*(int*)pos);
@@ -243,8 +243,8 @@
len = rsize;
}
memcpy(collectionData->name,
- pos,
- len);
+ pos,
+ len);
rsize -= len;
pos += len;
if (mlen > rsize) {
@@ -253,12 +253,12 @@
}
collectionData->meta
= ECRS_deserializeMetaData(ectx,
- pos,
- mlen);
+ pos,
+ mlen);
rsize -= mlen;
pos += mlen;
GE_BREAK(ectx,
- collectionData->meta != NULL);
+ collectionData->meta != NULL);
for (i=0;i<collectionData->file_count;i++) {
if (rsize < 2 * sizeof(int)) {
GE_BREAK(ectx, 0);
@@ -280,22 +280,22 @@
tmp = MALLOC(len + 1);
tmp[len] = '\0';
memcpy(tmp,
- pos,
- len);
+ pos,
+ len);
pos += len;
rsize -= len;
collectionData->files[i].uri
= ECRS_stringToUri(ectx,
- tmp);
+ tmp);
GE_ASSERT(ectx,
- collectionData->files[i].uri != NULL);
+ collectionData->files[i].uri != NULL);
FREE(tmp);
collectionData->files[i].meta
= ECRS_deserializeMetaData(ectx,
- pos,
- mlen);
+ pos,
+ mlen);
GE_ASSERT(ectx,
- collectionData->files[i].meta != NULL);
+ collectionData->files[i].meta != NULL);
pos += mlen;
rsize -= mlen;
}
@@ -306,7 +306,7 @@
/* kill invalid entries (meta or uri == NULL) */
for (i=0;i<collectionData->file_count;i++) {
if ( (collectionData->files[i].uri != NULL) &&
- (collectionData->files[i].meta != NULL) )
+ (collectionData->files[i].meta != NULL) )
continue;
if (collectionData->files[i].uri != NULL)
ECRS_freeUri(collectionData->files[i].uri);
@@ -315,19 +315,19 @@
collectionData->files[i]
= collectionData->files[collectionData->file_count-1];
GROW(collectionData->files,
- collectionData->file_count,
- collectionData->file_count-1);
+ collectionData->file_count,
+ collectionData->file_count-1);
}
}
static void WRITEINT(int fd,
- int val) {
+ int val) {
int bval;
bval = htonl(val);
WRITE(fd,
- &bval,
- sizeof(int));
+ &bval,
+ sizeof(int));
}
static void writeCO() {
@@ -343,13 +343,13 @@
/* write collection data */
mlen = ECRS_sizeofMetaData(collectionData->meta,
- NO);
+ NO);
buf = MALLOC(mlen);
if (mlen != ECRS_serializeMetaData(ectx,
- collectionData->meta,
- buf,
- mlen,
- NO)) {
+ collectionData->meta,
+ buf,
+ mlen,
+ NO)) {
GE_BREAK(ectx, 0);
FREE(buf);
return;
@@ -357,22 +357,22 @@
fn = getCollectionFileName();
fd = open(fn,
- O_CREAT | O_LARGEFILE | O_WRONLY | O_TRUNC,
- S_IRUSR | S_IWUSR);
+ O_CREAT | O_LARGEFILE | O_WRONLY | O_TRUNC,
+ S_IRUSR | S_IWUSR);
if (fd == -1) {
GE_LOG_STRERROR_FILE(ectx,
- GE_USER | GE_ADMIN | GE_ERROR | GE_BULK,
- "open",
- fn);
+ GE_USER | GE_ADMIN | GE_ERROR | GE_BULK,
+ "open",
+ fn);
FREE(fn);
FREE(buf);
return;
}
GE_BREAK(ectx,
- collectionData->file_count <= 1024 * 1024 * 4);
+ collectionData->file_count <= 1024 * 1024 * 4);
WRITE(fd,
- collectionData,
- sizeof(CollectionData));
+ collectionData,
+ sizeof(CollectionData));
WRITEINT(fd, collectionData->file_count);
WRITEINT(fd, collectionData->changed);
WRITEINT(fd, mlen);
@@ -383,13 +383,13 @@
FREE(buf);
for (i=0;i<collectionData->file_count;i++) {
mlen = ECRS_sizeofMetaData(collectionData->files[i].meta,
- NO);
+ NO);
buf = MALLOC(mlen);
if (mlen != ECRS_serializeMetaData(ectx,
- collectionData->files[i].meta,
- buf,
- mlen,
- NO)) {
+ collectionData->files[i].meta,
+ buf,
+ mlen,
+ NO)) {
GE_BREAK(ectx, 0);
FREE(buf);
break;
@@ -418,7 +418,7 @@
ectx = NULL;
cfg = NULL;
}
-
+
/**
* Start collection.
@@ -430,10 +430,10 @@
* is destroyed (i.e. on exit from the UI).
*/
int CO_startCollection(unsigned int anonymityLevel,
- unsigned int prio,
- TIME_T updateInterval,
- const char * name,
- const struct ECRS_MetaData * meta) {
+ unsigned int prio,
+ TIME_T updateInterval,
+ const char * name,
+ const struct ECRS_MetaData * meta) {
struct ECRS_URI * advertisement;
struct ECRS_URI * rootURI;
HashCode512 nextId;
@@ -443,19 +443,19 @@
CO_stopCollection(); /* cancel old collection */
GE_ASSERT(ectx, name != NULL);
advertisement = ECRS_parseCharKeywordURI(ectx,
- COLLECTION);
+ COLLECTION);
GE_ASSERT(ectx, advertisement != NULL);
TIME(&now);
makeRandomId(&nextId);
rootURI = ECRS_createNamespace(ectx,
- cfg,
- name,
- meta,
- anonymityLevel,
- prio,
- get_time() + COLLECTION_ADV_LIFETIME,
- advertisement,
- &nextId);
+ cfg,
+ name,
+ meta,
+ anonymityLevel,
+ prio,
+ get_time() + COLLECTION_ADV_LIFETIME,
+ advertisement,
+ &nextId);
if (rootURI == NULL) {
ECRS_freeUri(advertisement);
MUTEX_UNLOCK(lock);
@@ -465,8 +465,8 @@
ECRS_freeUri(rootURI);
collectionData = MALLOC(sizeof(CollectionInfo));
memset(collectionData,
- 0,
- sizeof(CollectionInfo));
+ 0,
+ sizeof(CollectionInfo));
makeRandomId(&collectionData->data.lastId);
collectionData->data.nextId = nextId;
collectionData->data.updateInterval
@@ -497,8 +497,8 @@
return SYSERR;
}
ECRS_deleteNamespace(ectx,
- cfg,
- collectionData->name);
+ cfg,
+ collectionData->name);
ECRS_freeMetaData(collectionData->meta);
for (i=0;i<collectionData->file_count;i++) {
ECRS_freeMetaData(collectionData->files[i].meta);
@@ -575,12 +575,12 @@
if ( (ntohl(collectionData->data.updateInterval) != ECRS_SBLOCK_UPDATE_NONE)
&&
(ntohl(collectionData->data.updateInterval) !=
ECRS_SBLOCK_UPDATE_SPORADIC) ) {
deltaId(&collectionData->data.nextId,
- &collectionData->data.lastId,
- &delta);
+ &collectionData->data.lastId,
+ &delta);
collectionData->data.lastId = collectionData->data.nextId;
addHashCodes(&collectionData->data.nextId,
- &delta,
- &collectionData->data.nextId);
+ &delta,
+ &collectionData->data.nextId);
} else {
collectionData->data.lastId = collectionData->data.nextId;
makeRandomId(&collectionData->data.nextId);
@@ -589,26 +589,26 @@
fd = mkstemp(tmpName);
if (fd == -1) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "mkstemp");
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "mkstemp");
FREE(tmpName);
MUTEX_UNLOCK(lock);
return;
}
dirData = NULL;
GE_ASSERT(ectx,
- OK == ECRS_createDirectory(ectx,
- &dirData,
- &dirLen,
- collectionData->file_count,
- collectionData->files,
- collectionData->meta));
+ OK == ECRS_createDirectory(ectx,
+ &dirData,
+ &dirLen,
+ collectionData->file_count,
+ collectionData->files,
+ collectionData->meta));
if (-1 == WRITE(fd,
- dirData,
- dirLen)) {
+ dirData,
+ dirLen)) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "write");
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "write");
FREE(tmpName);
FREE(dirData);
MUTEX_UNLOCK(lock);
@@ -617,17 +617,17 @@
FREE(dirData);
CLOSE(fd);
if (OK != ECRS_uploadFile(ectx,
- cfg,
- tmpName,
- NO, /* indexing */
- ntohl(collectionData->data.anonymityLevel),
- ntohl(collectionData->data.priority),
- get_time() + COLLECTION_ADV_LIFETIME,
- NULL,
- NULL,
- NULL,
- NULL,
- &directoryURI)) {
+ cfg,
+ tmpName,
+ NO, /* indexing */
+ ntohl(collectionData->data.anonymityLevel),
+ ntohl(collectionData->data.priority),
+ get_time() + COLLECTION_ADV_LIFETIME,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &directoryURI)) {
UNLINK(tmpName);
FREE(tmpName);
MUTEX_UNLOCK(lock);
@@ -636,17 +636,17 @@
UNLINK(tmpName);
FREE(tmpName);
uri = ECRS_addToNamespace(ectx,
- cfg,
- collectionData->name,
- ntohl(collectionData->data.anonymityLevel),
- ntohl(collectionData->data.priority),
- get_time() + COLLECTION_ADV_LIFETIME,
- now,
- ntohl(collectionData->data.updateInterval),
- &collectionData->data.lastId,
- &collectionData->data.nextId,
- directoryURI,
- collectionData->meta);
+ cfg,
+ collectionData->name,
+ ntohl(collectionData->data.anonymityLevel),
+ ntohl(collectionData->data.priority),
+ get_time() + COLLECTION_ADV_LIFETIME,
+ now,
+ ntohl(collectionData->data.updateInterval),
+ &collectionData->data.lastId,
+ &collectionData->data.nextId,
+ directoryURI,
+ collectionData->meta);
if (uri != NULL) {
collectionData->data.lastPublication = htonl(now);
collectionData->changed = NO;
@@ -687,7 +687,7 @@
}
for (i=0;i<collectionData->file_count;i++) {
if (ECRS_equalsUri(fi->uri,
- collectionData->files[i].uri)) {
+ collectionData->files[i].uri)) {
MUTEX_UNLOCK(lock);
return;
}
@@ -695,8 +695,8 @@
fc.uri = ECRS_dupUri(fi->uri);
fc.meta = ECRS_dupMetaData(fi->meta);
APPEND(collectionData->files,
- collectionData->file_count,
- fc);
+ collectionData->file_count,
+ fc);
collectionData->changed = YES;
if (ntohl(collectionData->data.updateInterval) == ECRS_SBLOCK_UPDATE_NONE)
CO_publishCollectionNow();
Modified: GNUnet/src/applications/fs/collection/collectiontest.c
===================================================================
--- GNUnet/src/applications/fs/collection/collectiontest.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/fs/collection/collectiontest.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -35,7 +35,7 @@
#define START_DAEMON 1
int main(int argc,
- char * argv[]){
+ char * argv[]){
struct GC_Configuration * cfg;
#if START_DAEMON
pid_t daemon;
@@ -48,7 +48,7 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
@@ -56,20 +56,20 @@
meta = NULL;
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 300 * cronSECONDS));
+ cfg,
+ 300 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
#endif
ok = YES;
meta = ECRS_createMetaData();
ECRS_addToMetaData(meta,
- EXTRACTOR_MIMETYPE,
- "test/foo");
+ EXTRACTOR_MIMETYPE,
+ "test/foo");
sock = client_connection_create(NULL, cfg);
CHECK(sock != NULL);
CO_init(NULL, cfg);
@@ -77,14 +77,14 @@
/* ACTUAL TEST CODE */
CO_stopCollection();
ECRS_deleteNamespace(NULL,
- cfg,
- "test-collection");
+ cfg,
+ "test-collection");
CHECK(NULL == CO_getCollection());
CHECK(OK == CO_startCollection(1,
- 100,
- 60, /* 60s */
- "test-collection",
- meta));
+ 100,
+ 60, /* 60s */
+ "test-collection",
+ meta));
have = CO_getCollection();
CHECK(NULL != have);
CHECK(0 == strcmp(have, "test-collection"));
@@ -102,10 +102,10 @@
CO_publishCollectionNow();
CO_stopCollection();
ECRS_deleteNamespace(NULL,
- cfg,
- "test-collection");
+ cfg,
+ "test-collection");
CHECK(NULL == CO_getCollection());
-
+
/* END OF TEST CODE */
FAILURE:
if (sock != NULL) {
Modified: GNUnet/src/applications/fs/ecrs/bincoder.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/bincoder.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/bincoder.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -51,7 +51,7 @@
*/
static char *
bin2enc(const void * data,
- size_t size) {
+ size_t size) {
size_t len;
size_t pos;
unsigned int bits;
@@ -93,8 +93,8 @@
*/
static int
enc2bin(const char * input,
- void * data,
- size_t size) {
+ void * data,
+ size_t size) {
size_t len;
size_t pos;
unsigned int bits;
Modified: GNUnet/src/applications/fs/ecrs/bincodertest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/bincodertest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/ecrs/bincodertest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -39,8 +39,8 @@
memset(orig, i, i);
enc = bin2enc(orig, i);
ret = enc2bin(enc,
- dec,
- i);
+ dec,
+ i);
if ( (ret != strlen(enc)) ||
(0 != memcmp(orig, dec, i)) ) {
printf("Failed in iteration %d\n", i);
Modified: GNUnet/src/applications/fs/ecrs/directory.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directory.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/directory.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -50,11 +50,11 @@
* directory is malformed
*/
int ECRS_listDirectory(struct GE_Context * ectx,
- const char * data,
- unsigned long long len,
- struct ECRS_MetaData ** md,
- ECRS_SearchProgressCallback spcb,
- void * spcbClosure) {
+ const char * data,
+ unsigned long long len,
+ struct ECRS_MetaData ** md,
+ ECRS_SearchProgressCallback spcb,
+ void * spcbClosure) {
unsigned long long pos;
unsigned long long align;
unsigned int mdSize;
@@ -67,17 +67,17 @@
pos = 0;
if ( (len >= 8 + sizeof(unsigned int)) &&
(0 == memcmp(data,
- GNUNET_DIRECTORY_MAGIC,
- 8)) ) {
+ GNUNET_DIRECTORY_MAGIC,
+ 8)) ) {
memcpy(&mdSize,
- &data[8],
- sizeof(unsigned int));
+ &data[8],
+ sizeof(unsigned int));
mdSize = ntohl(mdSize);
if (mdSize > len - 8 - sizeof(unsigned int) )
return SYSERR; /* invalid size */
*md = ECRS_deserializeMetaData(ectx,
- &data[8 + sizeof(unsigned int)],
- mdSize);
+ &data[8 + sizeof(unsigned int)],
+ mdSize);
if (*md == NULL) {
GE_BREAK(ectx, 0);
return SYSERR; /* malformed !*/
@@ -88,27 +88,27 @@
/* find end of URI */
if (data[pos] == '\0') {
/* URI is never empty, must be end of block,
- skip to next alignment */
+ skip to next alignment */
align = ((pos / BLOCK_ALIGN_SIZE)+1) * BLOCK_ALIGN_SIZE;
if (align == pos) {
- /* if we were already aligned, still skip a block! */
- align += BLOCK_ALIGN_SIZE;
+ /* if we were already aligned, still skip a block! */
+ align += BLOCK_ALIGN_SIZE;
}
pos = align;
if (pos >= len) {
- /* malformed - or partial download... */
- break;
+ /* malformed - or partial download... */
+ break;
}
}
epos = pos;
while ( (epos < len) &&
- (data[epos] != '\0') )
+ (data[epos] != '\0') )
epos++;
if (epos >= len)
return SYSERR; /* malformed - or partial download */
fi.uri = ECRS_stringToUri(ectx,
- &data[pos]);
+ &data[pos]);
pos = epos+1;
if (fi.uri == NULL) {
pos--; /* go back to '\0' to force going to next alignment */
@@ -121,8 +121,8 @@
}
memcpy(&mdSize,
- &data[pos],
- sizeof(unsigned int));
+ &data[pos],
+ sizeof(unsigned int));
mdSize = ntohl(mdSize);
pos += sizeof(unsigned int);
@@ -132,8 +132,8 @@
}
fi.meta = ECRS_deserializeMetaData(ectx,
- &data[pos],
- mdSize);
+ &data[pos],
+ mdSize);
if (fi.meta == NULL) {
ECRS_freeUri(fi.uri);
GE_BREAK(ectx, 0);
@@ -143,9 +143,9 @@
count++;
if (spcb != NULL)
spcb(&fi,
- NULL,
- NO,
- spcbClosure);
+ NULL,
+ NO,
+ spcbClosure);
ECRS_freeMetaData(fi.meta);
ECRS_freeUri(fi.uri);
}
@@ -159,7 +159,7 @@
*/
static unsigned long long
do_align(unsigned long long start_position,
- unsigned long long end_position) {
+ unsigned long long end_position) {
unsigned long long align;
align = (end_position / BLOCK_ALIGN_SIZE) * BLOCK_ALIGN_SIZE;
@@ -179,9 +179,9 @@
* @param perm the permutation of the blocks (updated)
*/
static void block_align(unsigned long long start,
- unsigned int count,
- const unsigned long long * sizes,
- int * perm) {
+ unsigned int count,
+ const unsigned long long * sizes,
+ int * perm) {
int i;
int j;
int tmp;
@@ -201,21 +201,21 @@
cval = perm[j];
cend = cpos + sizes[cval];
if (cpos % BLOCK_ALIGN_SIZE == 0) {
- /* prefer placing the largest blocks first */
- cbad = - (cend % BLOCK_ALIGN_SIZE);
+ /* prefer placing the largest blocks first */
+ cbad = - (cend % BLOCK_ALIGN_SIZE);
} else {
- if (cpos / BLOCK_ALIGN_SIZE == cend / BLOCK_ALIGN_SIZE) {
- /* Data fits into the same block! Prefer small left-overs! */
- cbad = BLOCK_ALIGN_SIZE - cend % BLOCK_ALIGN_SIZE;
- } else {
- /* Would have to waste space to re-align, add big factor, this
- case is a real loss (proportional to space wasted)! */
- cbad = BLOCK_ALIGN_SIZE * (BLOCK_ALIGN_SIZE - cpos %
BLOCK_ALIGN_SIZE);
- }
+ if (cpos / BLOCK_ALIGN_SIZE == cend / BLOCK_ALIGN_SIZE) {
+ /* Data fits into the same block! Prefer small left-overs! */
+ cbad = BLOCK_ALIGN_SIZE - cend % BLOCK_ALIGN_SIZE;
+ } else {
+ /* Would have to waste space to re-align, add big factor, this
+ case is a real loss (proportional to space wasted)! */
+ cbad = BLOCK_ALIGN_SIZE * (BLOCK_ALIGN_SIZE - cpos % BLOCK_ALIGN_SIZE);
+ }
}
if (cbad < badness) {
- best = j;
- badness = cbad;
+ best = j;
+ badness = cbad;
}
}
tmp = perm[i];
@@ -251,11 +251,11 @@
* @return OK on success, SYSERR on error
*/
int ECRS_createDirectory(struct GE_Context * ectx,
- char ** data,
- unsigned long long * len,
- unsigned int count,
- const ECRS_FileInfo * fis,
- struct ECRS_MetaData * meta) {
+ char ** data,
+ unsigned long long * len,
+ unsigned int count,
+ const ECRS_FileInfo * fis,
+ struct ECRS_MetaData * meta) {
int i;
int j;
unsigned long long psize;
@@ -275,22 +275,22 @@
ucs = MALLOC(sizeof(char*) * count);
size = 8 + sizeof(unsigned int);
size += ECRS_sizeofMetaData(meta,
- ECRS_SERIALIZE_FULL);
+ ECRS_SERIALIZE_FULL);
sizes = MALLOC(count * sizeof(unsigned long long));
perm = MALLOC(count * sizeof(int));
for (i=0;i<count;i++) {
perm[i] = i;
ucs[i] = ECRS_uriToString(fis[i].uri);
GE_ASSERT(ectx,
- ucs[i] != NULL);
+ ucs[i] != NULL);
psize = ECRS_sizeofMetaData(fis[i].meta,
- ECRS_SERIALIZE_FULL);
+ ECRS_SERIALIZE_FULL);
if (psize == -1) {
GE_BREAK(ectx, 0);
FREE(sizes);
FREE(perm);
while (i>=0)
- FREE(ucs[i--]);
+ FREE(ucs[i--]);
FREE(ucs);
return SYSERR;
}
@@ -298,16 +298,16 @@
}
/* permutate entries to minimize alignment cost */
block_align(size,
- count,
- sizes,
- perm);
+ count,
+ sizes,
+ perm);
/* compute final size with alignment */
for (i=0;i<count;i++) {
psize = size;
size += sizes[perm[i]];
size = do_align(psize,
- size);
+ size);
}
*len = size;
*data = MALLOC(size);
@@ -315,19 +315,19 @@
pos = 8;
memcpy(*data,
- GNUNET_DIRECTORY_MAGIC,
- 8);
+ GNUNET_DIRECTORY_MAGIC,
+ 8);
ret = ECRS_serializeMetaData(ectx,
- meta,
- &(*data)[pos + sizeof(unsigned int)],
- size - pos - sizeof(unsigned int),
- ECRS_SERIALIZE_FULL);
+ meta,
+ &(*data)[pos + sizeof(unsigned int)],
+ size - pos - sizeof(unsigned int),
+ ECRS_SERIALIZE_FULL);
GE_ASSERT(ectx, ret != SYSERR);
ret = htonl(ret);
memcpy(&(*data)[pos],
- &ret,
- sizeof(unsigned int));
+ &ret,
+ sizeof(unsigned int));
pos += ntohl(ret) + sizeof(unsigned int);
for (j=0;j<count;j++) {
@@ -337,20 +337,20 @@
pos = do_align(psize, pos);
pos -= sizes[i]; /* go back to beginning */
memcpy(&(*data)[pos],
- ucs[i],
- strlen(ucs[i]) + 1);
+ ucs[i],
+ strlen(ucs[i]) + 1);
pos += strlen(ucs[i]) + 1;
FREE(ucs[i]);
ret = ECRS_serializeMetaData(ectx,
- fis[i].meta,
- &(*data)[pos + sizeof(unsigned int)],
- size - pos - sizeof(unsigned int),
- ECRS_SERIALIZE_FULL);
+ fis[i].meta,
+ &(*data)[pos + sizeof(unsigned int)],
+ size - pos - sizeof(unsigned int),
+ ECRS_SERIALIZE_FULL);
GE_ASSERT(ectx, ret != SYSERR);
ret = htonl(ret);
memcpy(&(*data)[pos],
- &ret,
- sizeof(unsigned int));
+ &ret,
+ sizeof(unsigned int));
pos += ntohl(ret) + sizeof(unsigned int);
}
FREE(sizes);
Modified: GNUnet/src/applications/fs/ecrs/directorytest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directorytest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/ecrs/directorytest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -39,17 +39,17 @@
};
static int processor(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * cls) {
+ const HashCode512 * key,
+ int isRoot,
+ void * cls) {
struct PCLS * p = cls;
int i;
for (i=0;i<p->max;i++) {
if (ECRS_equalsMetaData(p->fi[i].meta,
- fi->meta) &&
- ECRS_equalsUri(p->fi[i].uri,
- fi->uri)) {
+ fi->meta) &&
+ ECRS_equalsUri(p->fi[i].uri,
+ fi->uri)) {
p->pos++;
return OK;
}
@@ -77,23 +77,23 @@
fis[p].meta = ECRS_createMetaData();
for (q=0;q<=p;q++) {
SNPRINTF(txt,
- 128,
- "%u -- %u\n",
- p, q);
+ 128,
+ "%u -- %u\n",
+ p, q);
ECRS_addToMetaData(fis[p].meta,
- q % EXTRACTOR_getHighestKeywordTypeNumber(),
- txt);
+ q % EXTRACTOR_getHighestKeywordTypeNumber(),
+ txt);
}
SNPRINTF(uri,
- 512,
-
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
- p);
+ 512,
+
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
+ p);
fis[p].uri = ECRS_stringToUri(NULL, uri);
if (fis[p].uri == NULL) {
ECRS_freeMetaData(fis[p].meta);
while (--p > 0) {
- ECRS_freeMetaData(fis[p].meta);
- ECRS_freeUri(fis[p].uri);
+ ECRS_freeMetaData(fis[p].meta);
+ ECRS_freeUri(fis[p].uri);
}
FREE(fis);
ABORT(); /* error in testcase */
@@ -101,17 +101,17 @@
}
meta = ECRS_createMetaData();
ECRS_addToMetaData(meta,
- EXTRACTOR_TITLE,
- "A title");
+ EXTRACTOR_TITLE,
+ "A title");
ECRS_addToMetaData(meta,
- EXTRACTOR_AUTHOR,
- "An author");
+ EXTRACTOR_AUTHOR,
+ "An author");
if (OK != ECRS_createDirectory(NULL,
- &data,
- &dlen,
- i,
- fis,
- meta)) {
+ &data,
+ &dlen,
+ i,
+ fis,
+ meta)) {
ECRS_freeMetaData(meta);
for (p=0;p<i;p++) {
ECRS_freeMetaData(fis[p].meta);
@@ -123,17 +123,17 @@
cls.pos = 0;
cls.fi = fis;
if (i != ECRS_listDirectory(NULL,
- data,
- dlen,
- &meta2,
- &processor,
- &cls)) {
+ data,
+ dlen,
+ &meta2,
+ &processor,
+ &cls)) {
printf("expected %u\n", i);
ret = 1;
goto END;
}
if (! ECRS_equalsMetaData(meta,
- meta2)) {
+ meta2)) {
ret = 1;
goto END;
}
Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/download.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -102,7 +102,7 @@
* is not complete and may be resumed later.
*/
static void freeIOC(IOContext * this,
- int unlinkTreeFiles) {
+ int unlinkTreeFiles) {
int i;
char * fn;
@@ -120,10 +120,10 @@
strcat(fn, ".A");
fn[strlen(fn)-1]+=i;
if (0 != UNLINK(fn))
- GE_LOG(this->ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Could not unlink temporary file `%s': %s\n"),
- fn, STRERROR(errno));
+ GE_LOG(this->ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Could not unlink temporary file `%s': %s\n"),
+ fn, STRERROR(errno));
FREE(fn);
}
}
@@ -141,10 +141,10 @@
* @return OK on success, SYSERR on failure
*/
static int createIOContext(struct GE_Context * ectx,
- IOContext * this,
- int no_temporaries,
- unsigned long long filesize,
- const char * filename) {
+ IOContext * this,
+ int no_temporaries,
+ unsigned long long filesize,
+ const char * filename) {
int i;
char * fn;
struct stat st;
@@ -161,9 +161,9 @@
/* if exists and oversized, truncate */
if (truncate(filename, filesize) != 0) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "truncate",
- filename);
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "truncate",
+ filename);
return SYSERR;
}
}
@@ -172,21 +172,21 @@
for (i=0;i<=this->treedepth;i++) {
if ( (i == 0) ||
- (no_temporaries != YES) ) {
+ (no_temporaries != YES) ) {
fn = MALLOC(strlen(filename) + 3);
strcpy(fn, filename);
if (i > 0) {
- strcat(fn, ".A");
- fn[strlen(fn)-1] += i;
+ strcat(fn, ".A");
+ fn[strlen(fn)-1] += i;
}
this->handles[i] = disk_file_open(ectx,
- fn,
- O_CREAT|O_RDWR,
- S_IRUSR|S_IWUSR );
+ fn,
+ O_CREAT|O_RDWR,
+ S_IRUSR|S_IWUSR );
if (this->handles[i] < 0) {
- freeIOC(this, YES);
- FREE(fn);
- return SYSERR;
+ freeIOC(this, YES);
+ FREE(fn);
+ return SYSERR;
}
FREE(fn);
}
@@ -205,10 +205,10 @@
* @return number of bytes read, SYSERR on error
*/
int readFromIOC(IOContext * this,
- unsigned int level,
- unsigned long long pos,
- void * buf,
- unsigned int len) {
+ unsigned int level,
+ unsigned long long pos,
+ void * buf,
+ unsigned int len) {
int ret;
MUTEX_LOCK(this->lock);
@@ -217,20 +217,20 @@
return SYSERR;
}
lseek(this->handles[level],
- pos,
- SEEK_SET);
+ pos,
+ SEEK_SET);
ret = READ(this->handles[level],
- buf,
- len);
+ buf,
+ len);
MUTEX_UNLOCK(this->lock);
#if DEBUG_DOWNLOAD
GE_LOG(this->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "IOC read at level %u offset %llu wanted %u got %d\n",
- level,
- pos,
- len,
- ret);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "IOC read at level %u offset %llu wanted %u got %d\n",
+ level,
+ pos,
+ len,
+ ret);
#endif
return ret;
}
@@ -246,10 +246,10 @@
* @return number of bytes written, SYSERR on error
*/
int writeToIOC(IOContext * this,
- unsigned int level,
- unsigned long long pos,
- void * buf,
- unsigned int len) {
+ unsigned int level,
+ unsigned long long pos,
+ void * buf,
+ unsigned int len) {
int ret;
MUTEX_LOCK(this->lock);
@@ -259,28 +259,28 @@
return len; /* lie -- no temps allowed... */
}
lseek(this->handles[level],
- pos,
- SEEK_SET);
+ pos,
+ SEEK_SET);
ret = WRITE(this->handles[level],
- buf,
- len);
+ buf,
+ len);
if (ret != len) {
GE_LOG(this->ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Write(%d, %p, %d) failed: %s\n"),
- this->handles[level],
- buf,
- len,
- STRERROR(errno));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Write(%d, %p, %d) failed: %s\n"),
+ this->handles[level],
+ buf,
+ len,
+ STRERROR(errno));
}
MUTEX_UNLOCK(this->lock);
#if DEBUG_DOWNLOAD
GE_LOG(this->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "IOC write at level %u offset %llu writes %u\n",
- level,
- pos,
- len);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "IOC write at level %u offset %llu writes %u\n",
+ level,
+ pos,
+ len);
#endif
return ret;
}
@@ -452,7 +452,7 @@
*/
static RequestManager *
createRequestManager(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
RequestManager * rm;
rm = MALLOC(sizeof(RequestManager));
@@ -461,8 +461,8 @@
rm->lock
= MUTEX_CREATE(YES);
rm->sctx = FS_SEARCH_makeContext(ectx,
- cfg,
- rm->lock);
+ cfg,
+ rm->lock);
if (rm->sctx == NULL) {
MUTEX_DESTROY(rm->lock);
FREE(rm);
@@ -503,9 +503,9 @@
= 65535;
#if DEBUG_DOWNLOAD
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "created request manager %p\n",
- rm);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "created request manager %p\n",
+ rm);
#endif
return rm;
}
@@ -522,9 +522,9 @@
#if DEBUG_DOWNLOAD
GE_LOG(rm->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "destroying request manager %p\n",
- rm);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "destroying request manager %p\n",
+ rm);
#endif
MUTEX_LOCK(rm->lock);
/* cannot hold lock during shutdown since
@@ -536,7 +536,7 @@
for (i=0;i<rm->requestListIndex;i++) {
if (rm->requestList[i]->searchHandle != NULL)
FS_stop_search(rm->sctx,
- rm->requestList[i]->searchHandle);
+ rm->requestList[i]->searchHandle);
FREE(rm->requestList[i]->node);
FREE(rm->requestList[i]);
}
@@ -563,7 +563,7 @@
RequestEntry * entry = rm->requestList[i];
/* cut TTL in half */
entry->lasttime
- += (entry->lasttime + entry->lastTimeout) / 2;
+ += (entry->lasttime + entry->lastTimeout) / 2;
}
}
MUTEX_UNLOCK(rm->lock);
@@ -576,23 +576,23 @@
* @param node the node to call once a reply is received
*/
static void addRequest(RequestManager * rm,
- NodeClosure * node) {
+ NodeClosure * node) {
RequestEntry * entry;
#if DEBUG_DOWNLOAD
EncName enc;
IF_GELOG(rm->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&node->chk.query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&node->chk.query,
+ &enc));
GE_LOG(rm->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Queuing request (query: %s)\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Queuing request (query: %s)\n",
+ &enc);
#endif
GE_ASSERT(rm->ectx,
- node != NULL);
+ node != NULL);
entry
= MALLOC(sizeof(RequestEntry));
entry->node
@@ -610,11 +610,11 @@
MUTEX_LOCK(rm->lock);
if (rm->shutdown == NO) {
GE_ASSERT(rm->ectx,
- rm->requestListSize > 0);
+ rm->requestListSize > 0);
if (rm->requestListSize == rm->requestListIndex)
GROW(rm->requestList,
- rm->requestListSize,
- rm->requestListSize*2);
+ rm->requestListSize,
+ rm->requestListSize*2);
rm->requestList[rm->requestListIndex++] = entry;
} else {
GE_BREAK(rm->ectx, 0);
@@ -631,7 +631,7 @@
* @param node the block for which the request is canceled
*/
static void delRequest(RequestManager * rm,
- NodeClosure * node) {
+ NodeClosure * node) {
int i;
RequestEntry * re;
@@ -640,16 +640,16 @@
for (i=0;i<rm->requestListIndex;i++) {
re = rm->requestList[i];
if (re->node == node) {
- rm->requestList[i]
- = rm->requestList[--rm->requestListIndex];
- rm->requestList[rm->requestListIndex]
- = NULL;
- MUTEX_UNLOCK(rm->lock);
- if (NULL != re->searchHandle)
- FS_stop_search(rm->sctx,
- re->searchHandle);
- FREE(re);
- return;
+ rm->requestList[i]
+ = rm->requestList[--rm->requestListIndex];
+ rm->requestList[rm->requestListIndex]
+ = NULL;
+ MUTEX_UNLOCK(rm->lock);
+ if (NULL != re->searchHandle)
+ FS_stop_search(rm->sctx,
+ re->searchHandle);
+ FREE(re);
+ return;
}
}
}
@@ -690,19 +690,19 @@
unsigned long long epos;
GE_ASSERT(node->ctx->rm->ectx,
- node->offset < node->ctx->total);
+ node->offset < node->ctx->total);
if (node->level == 0) {
ret = DBLOCK_SIZE;
if (node->offset + (unsigned long long) ret
- > node->ctx->total)
+ > node->ctx->total)
ret = (unsigned int) (node->ctx->total - node->offset);
#if DEBUG_DOWNLOAD
GE_LOG(node->ctx->rm->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Node at offset %llu and level %d has size %u\n",
- node->offset,
- node->level,
- ret);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Node at offset %llu and level %d has size %u\n",
+ node->offset,
+ node->level,
+ ret);
#endif
return ret;
}
@@ -718,11 +718,11 @@
ret++; /* need to round up! */
#if DEBUG_DOWNLOAD
GE_LOG(node->ctx->rm->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Node at offset %llu and level %d has size %u\n",
- node->offset,
- node->level,
- ret * sizeof(CHK));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Node at offset %llu and level %d has size %u\n",
+ node->offset,
+ node->level,
+ ret * sizeof(CHK));
#endif
return ret * sizeof(CHK);
}
@@ -732,8 +732,8 @@
* request manager structures, like ttl.
*/
static void updateProgress(const NodeClosure * node,
- const char * data,
- unsigned int size) {
+ const char * data,
+ unsigned int size) {
RequestManager * rm;
RequestEntry * entry;
int pos;
@@ -747,17 +747,17 @@
eta = get_time();
if (node->ctx->completed > 0) {
eta = (cron_t) (node->ctx->startTime +
- (((double)(eta -
node->ctx->startTime)/(double)node->ctx->completed))
- * (double)node->ctx->length);
+ (((double)(eta -
node->ctx->startTime)/(double)node->ctx->completed))
+ * (double)node->ctx->length);
}
if (node->ctx->dpcb != NULL) {
node->ctx->dpcb(node->ctx->length,
- node->ctx->completed,
- eta,
- node->offset,
- data,
- size,
- node->ctx->dpcbClosure);
+ node->ctx->completed,
+ eta,
+ node->offset,
+ data,
+ size,
+ node->ctx->dpcbClosure);
}
}
rm = node->ctx->rm;
@@ -786,11 +786,11 @@
unsigned int weight = 15;
unsigned int ettl = entry->lastTimeout - entry->lasttime;
if ( (ettl > 4 * rm->initialTTL) &&
- ( (get_time() - entry->lasttime) < rm->initialTTL) ) {
+ ( (get_time() - entry->lasttime) < rm->initialTTL) ) {
weight = 127;
/* eTTL is MUCH bigger than what we currently expect AND the time
- between the last query and the reply was in the range of the
- expected TTL => don't take ettl too much into account! */
+ between the last query and the reply was in the range of the
+ expected TTL => don't take ettl too much into account! */
}
rm->initialTTL = ((rm->initialTTL) * weight + ettl) / (weight+1);
@@ -807,15 +807,15 @@
TIME(&nowTT);
if ( (nowTT - rm->initialTTL) > rm->lastDET) {
/* only consider congestion control every
- "average" TTL seconds, otherwise the system
- reacts to events that are far too old! */
+ "average" TTL seconds, otherwise the system
+ reacts to events that are far too old! */
/* we performed retransmission, treat as congestion (RFC 2001) */
rm->ssthresh
- = rm->congestionWindow / 2;
+ = rm->congestionWindow / 2;
if (rm->ssthresh < 2)
- rm->ssthresh = 2;
+ rm->ssthresh = 2;
rm->congestionWindow
- = rm->ssthresh + 1;
+ = rm->ssthresh + 1;
rm->lastDET = nowTT;
}
}
@@ -829,8 +829,8 @@
* @param rm the node that should downloaded
*/
static void iblock_download_children(NodeClosure * node,
- char * data,
- unsigned int size);
+ char * data,
+ unsigned int size);
/**
* Check if this block is already present on the drive. If the block
@@ -860,28 +860,28 @@
this for level-0 nodes */
if ( (node->level == 0) &&
( (node->offset + size < node->ctx->offset) ||
- (node->offset > node->ctx->offset + node->ctx->length) ) )
+ (node->offset > node->ctx->offset + node->ctx->length) ) )
return YES;
data = MALLOC(size);
res = readFromIOC(node->ctx->ioc,
- node->level,
- node->offset,
- data,
- size);
+ node->level,
+ node->offset,
+ data,
+ size);
if (res == size) {
hash(data,
- size,
- &hc);
+ size,
+ &hc);
if (equalsHashCode512(&hc,
- &node->chk.key)) {
+ &node->chk.key)) {
updateProgress(node,
- data,
- size);
+ data,
+ size);
if (node->level > 0)
- iblock_download_children(node,
- data,
- size);
+ iblock_download_children(node,
+ data,
+ size);
ret = YES;
} else
@@ -891,11 +891,11 @@
FREE(data);
#if DEBUG_DOWNLOAD
GE_LOG(node->ctx->rm->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Checked presence of block at %llu level %u. Result: %s\n",
- node->offset,
- node->level,
- ret == YES ? "YES" : "NO");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Checked presence of block at %llu level %u. Result: %s\n",
+ node->offset,
+ node->level,
+ ret == YES ? "YES" : "NO");
#endif
return ret;
@@ -907,8 +907,8 @@
* @param this the node that should downloaded
*/
static void iblock_download_children(NodeClosure * node,
- char * data,
- unsigned int size) {
+ char * data,
+ unsigned int size) {
struct GE_Context * ectx = node->ctx->rm->ectx;
int i;
NodeClosure * child;
@@ -918,7 +918,7 @@
unsigned long long baseOffset;
GE_ASSERT(ectx,
- node->level > 0);
+ node->level > 0);
childcount = size / sizeof(CHK);
if (size != childcount * sizeof(CHK)) {
GE_BREAK(ectx, 0);
@@ -940,10 +940,10 @@
GE_ASSERT(ectx, child->offset < node->ctx->total);
child->level = node->level - 1;
GE_ASSERT(ectx, (child->level != 0) ||
- ( (child->offset % DBLOCK_SIZE) == 0) );
+ ( (child->offset % DBLOCK_SIZE) == 0) );
if (NO == checkPresent(child))
addRequest(node->ctx->rm,
- child);
+ child);
else
FREE(child); /* done already! */
}
@@ -960,23 +960,23 @@
* @returns OK on success, SYSERR on error
*/
static int decryptContent(const char * data,
- unsigned int size,
- const HashCode512 * hashcode,
- char * result){
+ unsigned int size,
+ const HashCode512 * hashcode,
+ char * result){
INITVECTOR iv;
SESSIONKEY skey;
GE_ASSERT(NULL,
- (data!=NULL) && (hashcode != NULL) && (result != NULL));
+ (data!=NULL) && (hashcode != NULL) && (result != NULL));
/* get key and init value from the hash code */
hashToKey(hashcode,
- &skey,
- &iv);
+ &skey,
+ &iv);
return decryptBlock(&skey,
- data,
- size,
- &iv,
- result);
+ data,
+ size,
+ &iv,
+ result);
}
@@ -994,8 +994,8 @@
* @return OK if the reply was valid, SYSERR on error
*/
static int nodeReceive(const HashCode512 * query,
- const Datastore_Value * reply,
- void * cls) {
+ const Datastore_Value * reply,
+ void * cls) {
NodeClosure * node = cls;
struct GE_Context * ectx = node->ctx->rm->ectx;
HashCode512 hc;
@@ -1006,17 +1006,17 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Receiving reply to query `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Receiving reply to query `%s'\n",
+ &enc);
#endif
GE_ASSERT(ectx,
- equalsHashCode512(query,
- &node->chk.query));
+ equalsHashCode512(query,
+ &node->chk.query));
size = ntohl(reply->size) - sizeof(Datastore_Value);
if ( (size <= sizeof(DBlock)) ||
(size - sizeof(DBlock) != getNodeSize(node)) ) {
@@ -1026,59 +1026,59 @@
size -= sizeof(DBlock);
data = MALLOC(size);
if (SYSERR == decryptContent((char*)&((DBlock*)&reply[1])[1],
- size,
- &node->chk.key,
- data))
+ size,
+ &node->chk.key,
+ data))
GE_ASSERT(ectx, 0);
hash(data,
size,
&hc);
if (! equalsHashCode512(&hc,
- &node->chk.key)) {
+ &node->chk.key)) {
delRequest(node->ctx->rm,
- node);
+ node);
FREE(data);
GE_BREAK(ectx, 0);
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Decrypted content does not match key. "
- "This is either a bug or a maliciously inserted "
- "file. Download aborted.\n"));
+ _("Decrypted content does not match key. "
+ "This is either a bug or a maliciously inserted "
+ "file. Download aborted.\n"));
node->ctx->rm->abortFlag = YES;
return SYSERR;
}
if (size != writeToIOC(node->ctx->ioc,
- node->level,
- node->offset,
- data,
- size)) {
+ node->level,
+ node->offset,
+ data,
+ size)) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "WRITE");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "WRITE");
node->ctx->rm->abortFlag = YES;
return SYSERR;
}
updateProgress(node,
- data,
- size);
+ data,
+ size);
if (node->level > 0)
iblock_download_children(node,
- data,
- size);
+ data,
+ size);
/* request satisfied, stop requesting! */
delRequest(node->ctx->rm,
- node);
+ node);
for (i=0;i<10;i++) {
if ( (node->ctx->completed * 10000L >
- node->ctx->length * (10000L - (1024 >> i)) ) &&
- ( (node->ctx->completed-size) * 10000L <=
- node->ctx->length * (10000L - (1024 >> i)) ) ) {
+ node->ctx->length * (10000L - (1024 >> i)) ) &&
+ ( (node->ctx->completed-size) * 10000L <=
+ node->ctx->length * (10000L - (1024 >> i)) ) ) {
/* end-game boundary crossed, slaughter TTLs */
requestManagerEndgame(node->ctx->rm);
}
}
GE_ASSERT(node->ctx->rm->ectx,
- node->ctx->rm->requestThread != NULL);
+ node->ctx->rm->requestThread != NULL);
PTHREAD_STOP_SLEEP(node->ctx->rm->requestThread);
FREE(data);
FREE(node);
@@ -1094,7 +1094,7 @@
* @param requestIndex the index of the Request to issue
*/
static void issueRequest(RequestManager * rm,
- int requestIndex) {
+ int requestIndex) {
static unsigned int lastmpriority;
static cron_t lastmpritime;
RequestEntry * entry;
@@ -1118,7 +1118,7 @@
struct ClientServerConnection * sock;
sock = client_connection_create(rm->ectx,
- rm->cfg);
+ rm->cfg);
lastmpriority = FS_getAveragePriority(sock);
lastmpritime = now;
connection_destroy(sock);
@@ -1154,17 +1154,17 @@
/* switch to slow back-off */
unsigned int rd;
if (rm->initialTTL == 0)
- rd = ttl;
+ rd = ttl;
else
- rd = ttl / rm->initialTTL;
+ rd = ttl / rm->initialTTL;
if (rd == 0)
- rd = 1; /* how? */
+ rd = 1; /* how? */
rd = TTL_DECREMENT / rd;
if (rd == 0)
- rd = 1;
+ rd = 1;
ttl += weak_randomi(50 * cronMILLIS + rd);
/* rd == TTL_DECREMENT / (con->ttl / rm->initialTTL) + saveguards
- 50ms: minimum increment */
+ 50ms: minimum increment */
} else {
ttl += weak_randomi(ttl + 2 * TTL_DECREMENT); /* exponential backoff
with random factor */
}
@@ -1175,42 +1175,42 @@
#if DEBUG_DOWNLOAD
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&entry->node->chk.query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&entry->node->chk.query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Starting FS search for %s:%llu:%u `%s'\n",
- entry->node->ctx->ioc->filename,
- entry->node->offset,
- entry->node->level,
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Starting FS search for %s:%llu:%u `%s'\n",
+ entry->node->ctx->ioc->filename,
+ entry->node->offset,
+ entry->node->level,
+ &enc);
#endif
if (entry->searchHandle != NULL)
FS_stop_search(rm->sctx,
- entry->searchHandle);
+ entry->searchHandle);
entry->searchHandle
= FS_start_search(rm->sctx,
- rm->have_target == NO ? NULL : &rm->target,
- D_BLOCK,
- 1,
- &entry->node->chk.query,
- entry->node->ctx->anonymityLevel,
- priority,
- timeout,
- &nodeReceive,
- entry->node);
+ rm->have_target == NO ? NULL : &rm->target,
+ D_BLOCK,
+ 1,
+ &entry->node->chk.query,
+ entry->node->ctx->anonymityLevel,
+ priority,
+ timeout,
+ &nodeReceive,
+ entry->node);
if (entry->searchHandle != NULL) {
entry->lastPriority = priority;
entry->lastTimeout = timeout;
entry->lasttime = now + 2 * TTL_DECREMENT;
if (weak_randomi(1+entry->tries) > 1) {
/* do linear (in tries) extra back-off (in addition to ttl)
- to avoid repeatedly tie-ing with other peers; rm is somewhat
- equivalent to what ethernet is doing, only that 'tries' is our
- (rough) indicator for collisions. For ethernet back-off, see:
- http://www.industrialethernetuniversity.com/courses/101_4.htm
+ to avoid repeatedly tie-ing with other peers; rm is somewhat
+ equivalent to what ethernet is doing, only that 'tries' is our
+ (rough) indicator for collisions. For ethernet back-off, see:
+ http://www.industrialethernetuniversity.com/courses/101_4.htm
*/
entry->lasttime += weak_randomi(TTL_DECREMENT * (1+entry->tries));
}
@@ -1221,14 +1221,14 @@
(entry->tries > 0) ) {
EncName enc;
IF_GELOG(rm->ectx,
- GE_WARNING | GE_BULK | GE_USER,
- hash2enc(&entry->node->chk.key,
- &enc));
+ GE_WARNING | GE_BULK | GE_USER,
+ hash2enc(&entry->node->chk.key,
+ &enc));
GE_LOG(rm->ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Content `%s' seems to be not available on the network (tried %u
times).\n"),
- &enc,
- entry->tries);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Content `%s' seems to be not available on the network (tried %u
times).\n"),
+ &enc,
+ entry->tries);
}
}
@@ -1263,7 +1263,7 @@
pending++;
} else if (rm->requestList[i]->searchHandle != NULL) {
FS_stop_search(rm->sctx,
- rm->requestList[i]->searchHandle);
+ rm->requestList[i]->searchHandle);
rm->requestList[i]->searchHandle = NULL;
}
}
@@ -1276,20 +1276,20 @@
int pOCWCubed;
int pendingOverCWin = pending - rm->congestionWindow;
if (pendingOverCWin <= 0)
- pendingOverCWin = -1; /* avoid 0! */
+ pendingOverCWin = -1; /* avoid 0! */
pOCWCubed = pendingOverCWin *
- pendingOverCWin *
- pendingOverCWin;
+ pendingOverCWin *
+ pendingOverCWin;
if ( (pOCWCubed <= 0) ||
- (pOCWCubed * rm->requestListIndex <= 0) /* see #642 */ ||
- /* avoid no-start: override congestionWindow occasionally... */
- (0 == weak_randomi(rm->requestListIndex *
- pOCWCubed)) ) {
- issueRequest(rm, j);
- delta = (rm->requestList[j]->lastTimeout - now) + TTL_DECREMENT;
- pending++;
- } else {
- delta = 0;
+ (pOCWCubed * rm->requestListIndex <= 0) /* see #642 */ ||
+ /* avoid no-start: override congestionWindow occasionally... */
+ (0 == weak_randomi(rm->requestListIndex *
+ pOCWCubed)) ) {
+ issueRequest(rm, j);
+ delta = (rm->requestList[j]->lastTimeout - now) + TTL_DECREMENT;
+ pending++;
+ } else {
+ delta = 0;
}
} else {
delta = (rm->requestList[j]->lastTimeout + TTL_DECREMENT - now);
@@ -1315,26 +1315,26 @@
* @param filename where to store the file
*/
int ECRS_downloadFile(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const struct ECRS_URI * uri,
- const char * filename,
- unsigned int anonymityLevel,
- ECRS_DownloadProgressCallback dpcb,
- void * dpcbClosure,
- ECRS_TestTerminate tt,
- void * ttClosure) {
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri,
+ const char * filename,
+ unsigned int anonymityLevel,
+ ECRS_DownloadProgressCallback dpcb,
+ void * dpcbClosure,
+ ECRS_TestTerminate tt,
+ void * ttClosure) {
return ECRS_downloadPartialFile(ectx,
- cfg,
- uri,
- filename,
- 0,
- ECRS_fileSize(uri),
- anonymityLevel,
- NO,
- dpcb,
- dpcbClosure,
- tt,
- ttClosure);
+ cfg,
+ uri,
+ filename,
+ 0,
+ ECRS_fileSize(uri),
+ anonymityLevel,
+ NO,
+ dpcb,
+ dpcbClosure,
+ tt,
+ ttClosure);
}
@@ -1358,17 +1358,17 @@
* @param length length of the download (starting at offset)
*/
int ECRS_downloadPartialFile(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const struct ECRS_URI * uri,
- const char * filename,
- unsigned long long offset,
- unsigned long long length,
- unsigned int anonymityLevel,
- int no_temporaries,
- ECRS_DownloadProgressCallback dpcb,
- void * dpcbClosure,
- ECRS_TestTerminate tt,
- void * ttClosure) {
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri,
+ const char * filename,
+ unsigned long long offset,
+ unsigned long long length,
+ unsigned int anonymityLevel,
+ int no_temporaries,
+ ECRS_DownloadProgressCallback dpcb,
+ void * dpcbClosure,
+ ECRS_TestTerminate tt,
+ void * ttClosure) {
IOContext ioc;
RequestManager * rm;
int ret;
@@ -1383,10 +1383,10 @@
#if DEBUG_DOWNLOAD
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' running for file `%s'\n",
- __FUNCTION__,
- filename);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' running for file `%s'\n",
+ __FUNCTION__,
+ filename);
#endif
GE_ASSERT(ectx, filename != NULL);
if ( (filename[strlen(filename)-1] == '/') ||
@@ -1405,17 +1405,17 @@
if (*pos == DIR_SEPARATOR) {
*pos = '\0';
if ( (0 == STAT(path, &buf)) &&
- (! S_ISDIR(buf.st_mode)) ) {
- *pos = DIR_SEPARATOR;
- memmove(pos + strlen(GNUNET_DIRECTORY_EXT),
- pos,
- strlen(pos));
- memcpy(pos,
- GNUNET_DIRECTORY_EXT,
- strlen(GNUNET_DIRECTORY_EXT));
- pos += strlen(GNUNET_DIRECTORY_EXT);
+ (! S_ISDIR(buf.st_mode)) ) {
+ *pos = DIR_SEPARATOR;
+ memmove(pos + strlen(GNUNET_DIRECTORY_EXT),
+ pos,
+ strlen(pos));
+ memcpy(pos,
+ GNUNET_DIRECTORY_EXT,
+ strlen(GNUNET_DIRECTORY_EXT));
+ pos += strlen(GNUNET_DIRECTORY_EXT);
} else {
- *pos = DIR_SEPARATOR;
+ *pos = DIR_SEPARATOR;
}
}
pos++;
@@ -1424,15 +1424,15 @@
realFN = path;
if (SYSERR == disk_directory_create_for_file(ectx,
- realFN)) {
+ realFN)) {
FREE(realFN);
return SYSERR;
}
if (0 == ECRS_fileSize(uri)) {
ret = disk_file_open(ectx,
- realFN,
- O_CREAT | O_WRONLY | O_TRUNC,
- S_IRUSR|S_IWUSR);
+ realFN,
+ O_CREAT | O_WRONLY | O_TRUNC,
+ S_IRUSR|S_IWUSR);
FREE(realFN);
if (ret == -1)
return SYSERR;
@@ -1450,22 +1450,22 @@
}
if (OK != createIOContext(ectx,
- &ioc,
- no_temporaries,
- ntohll(fid.file_length),
- realFN)) {
+ &ioc,
+ no_temporaries,
+ ntohll(fid.file_length),
+ realFN)) {
#if DEBUG_DOWNLOAD
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' aborted for file `%s'\n",
- __FUNCTION__,
- realFN);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' aborted for file `%s'\n",
+ __FUNCTION__,
+ realFN);
#endif
FREE(realFN);
return SYSERR;
}
rm = createRequestManager(ectx,
- cfg);
+ cfg);
if (rm == NULL) {
freeIOC(&ioc, YES);
FREE(realFN);
@@ -1473,8 +1473,8 @@
}
if (ECRS_isLocationUri(uri)) {
hash(&uri->data.loc.peer,
- sizeof(PublicKey),
- &rm->target.hashPubKey);
+ sizeof(PublicKey),
+ &rm->target.hashPubKey);
rm->have_target = YES;
}
@@ -1499,31 +1499,31 @@
else
FREE(top);
while ( (OK == tt(ttClosure)) &&
- (rm->abortFlag == NO) &&
- (rm->requestListIndex != 0) ) {
+ (rm->abortFlag == NO) &&
+ (rm->requestListIndex != 0) ) {
minSleep = processRequests(rm);
if ( (OK == tt(ttClosure)) &&
- (rm->abortFlag == NO) &&
- (rm->requestListIndex != 0) )
+ (rm->abortFlag == NO) &&
+ (rm->requestListIndex != 0) )
PTHREAD_SLEEP(minSleep);
}
if ( (rm->requestListIndex == 0) &&
( (ctx.completed == ctx.total) ||
- ( (ctx.total != ctx.length) &&
- (ctx.completed >= ctx.length) ) ) &&
+ ( (ctx.total != ctx.length) &&
+ (ctx.completed >= ctx.length) ) ) &&
(rm->abortFlag == NO) ) {
ret = OK;
} else {
#if 0
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- "Download ends prematurely: %d %llu == %llu %d TT: %d\n",
- rm->requestListIndex,
- ctx.completed,
- ctx.total,
- rm->abortFlag,
- tt(ttClosure));
+ GE_ERROR | GE_BULK | GE_USER,
+ "Download ends prematurely: %d %llu == %llu %d TT: %d\n",
+ rm->requestListIndex,
+ ctx.completed,
+ ctx.total,
+ rm->abortFlag,
+ tt(ttClosure));
#endif
ret = SYSERR;
}
@@ -1534,9 +1534,9 @@
freeIOC(&ioc, YES);
if (0 != UNLINK(realFN)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "unlink",
- realFN);
+ GE_WARNING | GE_USER | GE_BULK,
+ "unlink",
+ realFN);
} else { /* delete empty directories */
char * rdir;
int len;
@@ -1544,10 +1544,10 @@
rdir = STRDUP(realFN);
len = strlen(rdir);
do {
- while ( (len > 0) &&
- (rdir[len] != DIR_SEPARATOR) )
- len--;
- rdir[len] = '\0';
+ while ( (len > 0) &&
+ (rdir[len] != DIR_SEPARATOR) )
+ len--;
+ rdir[len] = '\0';
} while ( (len > 0) && (0 == rmdir(rdir)) );
FREE(rdir);
}
@@ -1556,11 +1556,11 @@
}
#if DEBUG_DOWNLOAD
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' terminating for file `%s' with result %s\n",
- __FUNCTION__,
- filename,
- ret == OK ? "SUCCESS" : "INCOMPLETE");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' terminating for file `%s' with result %s\n",
+ __FUNCTION__,
+ filename,
+ ret == OK ? "SUCCESS" : "INCOMPLETE");
#endif
FREE(realFN);
return ret;
Modified: GNUnet/src/applications/fs/ecrs/ecrs.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrs.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/ecrs.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -30,8 +30,8 @@
#include "ecrs.h"
void ECRS_encryptInPlace(const HashCode512 * hc,
- void * data,
- unsigned int len) {
+ void * data,
+ unsigned int len) {
char * tmp;
SESSIONKEY skey;
INITVECTOR iv;
@@ -39,19 +39,19 @@
hashToKey(hc, &skey, &iv);
tmp = MALLOC(len);
GE_ASSERT(NULL,
- len ==
- encryptBlock(data,
- len,
- &skey,
- &iv,
- tmp));
+ len ==
+ encryptBlock(data,
+ len,
+ &skey,
+ &iv,
+ tmp));
memcpy(data, tmp, len);
FREE(tmp);
}
void ECRS_decryptInPlace(const HashCode512 * hc,
- void * data,
- unsigned int len) {
+ void * data,
+ unsigned int len) {
char * tmp;
SESSIONKEY skey;
INITVECTOR iv;
@@ -59,12 +59,12 @@
hashToKey(hc, &skey, &iv);
tmp = MALLOC(len);
GE_ASSERT(NULL,
- len ==
- decryptBlock(&skey,
- data,
- len,
- &iv,
- tmp));
+ len ==
+ decryptBlock(&skey,
+ data,
+ len,
+ &iv,
+ tmp));
memcpy(data, tmp, len);
FREE(tmp);
}
Modified: GNUnet/src/applications/fs/ecrs/ecrstest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrstest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/ecrstest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -44,9 +44,9 @@
fn = MALLOC(strlen("/tmp/gnunet-ecrstest/ECRSTEST") + 14);
SNPRINTF(fn,
- strlen("/tmp/gnunet-ecrstest/ECRSTEST") + 14,
- "/tmp/gnunet-ecrstest/ECRSTEST%u",
- i);
+ strlen("/tmp/gnunet-ecrstest/ECRSTEST") + 14,
+ "/tmp/gnunet-ecrstest/ECRSTEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -61,29 +61,29 @@
name = makeName(size);
fd = disk_file_open(NULL,
- name,
- O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+ name,
+ O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
buf = MALLOC(size);
memset(buf, size + size / 253, size);
for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
hash(&buf[i],
- 42,
- (HashCode512*) &buf[i+sizeof(HashCode512)]);
+ 42,
+ (HashCode512*) &buf[i+sizeof(HashCode512)]);
WRITE(fd, buf, size);
FREE(buf);
CLOSE(fd);
ret = ECRS_uploadFile(NULL,
- cfg,
- name,
- YES, /* index */
- 0, /* anon */
- 0, /* prio */
- get_time() + 10 * cronMINUTES, /* expire */
- NULL, /* progress */
- NULL,
- &testTerminate,
- NULL,
- &uri);
+ cfg,
+ name,
+ YES, /* index */
+ 0, /* anon */
+ 0, /* prio */
+ get_time() + 10 * cronMINUTES, /* expire */
+ NULL, /* progress */
+ NULL,
+ &testTerminate,
+ NULL,
+ &uri);
if (ret != SYSERR) {
struct ECRS_MetaData * meta;
struct ECRS_URI * key;
@@ -95,13 +95,13 @@
meta = ECRS_createMetaData();
key = ECRS_keywordsToUri(keywords);
ret = ECRS_addToKeyspace(NULL,
- cfg,
- key,
- 0,
- 0,
- get_time() + 10 * cronMINUTES, /* expire */
- uri,
- meta);
+ cfg,
+ key,
+ 0,
+ 0,
+ get_time() + 10 * cronMINUTES, /* expire */
+ uri,
+ meta);
ECRS_freeMetaData(meta);
ECRS_freeUri(uri);
FREE(name);
@@ -118,17 +118,17 @@
}
static int searchCB(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * closure) {
+ const HashCode512 * key,
+ int isRoot,
+ void * closure) {
struct ECRS_URI ** my = closure;
char * tmp;
tmp = ECRS_uriToString(fi->uri);
GE_LOG(NULL,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Search found URI `%s'\n",
- tmp);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Search found URI `%s'\n",
+ tmp);
FREE(tmp);
GE_ASSERT(NULL, NULL == *my);
*my = ECRS_dupUri(fi->uri);
@@ -145,14 +145,14 @@
myURI = NULL;
ret = ECRS_search(NULL,
- cfg,
- *uri,
- 0,
- 15 * cronSECONDS,
- &searchCB,
- &myURI,
- &testTerminate,
- NULL);
+ cfg,
+ *uri,
+ 0,
+ 15 * cronSECONDS,
+ &searchCB,
+ &myURI,
+ &testTerminate,
+ NULL);
ECRS_freeUri(*uri);
*uri = myURI;
if ( (ret != SYSERR) &&
@@ -163,7 +163,7 @@
}
static int downloadFile(unsigned int size,
- const struct ECRS_URI * uri) {
+ const struct ECRS_URI * uri) {
int ret;
char * tmpName;
int fd;
@@ -174,37 +174,37 @@
tmp = ECRS_uriToString(uri);
GE_LOG(NULL,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Starting download of `%s'\n",
- tmp);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Starting download of `%s'\n",
+ tmp);
FREE(tmp);
tmpName = makeName(0);
ret = SYSERR;
if (OK == ECRS_downloadFile(NULL,
- cfg,
- uri,
- tmpName,
- 0,
- NULL,
- NULL,
- &testTerminate,
- NULL)) {
+ cfg,
+ uri,
+ tmpName,
+ 0,
+ NULL,
+ NULL,
+ &testTerminate,
+ NULL)) {
fd = disk_file_open(NULL,
- tmpName,
- O_RDONLY);
+ tmpName,
+ O_RDONLY);
buf = MALLOC(size);
in = MALLOC(size);
memset(buf, size + size / 253, size);
for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
hash(&buf[i],
- 42,
- (HashCode512*) &buf[i+sizeof(HashCode512)]);
+ 42,
+ (HashCode512*) &buf[i+sizeof(HashCode512)]);
if (size != READ(fd, in, size))
ret = SYSERR;
else if (0 == memcmp(buf,
- in,
- size))
+ in,
+ size))
ret = OK;
FREE(buf);
FREE(in);
@@ -222,12 +222,12 @@
name = makeName(size);
ret = ECRS_unindexFile(NULL,
- cfg,
- name,
- NULL,
- NULL,
- &testTerminate,
- NULL);
+ cfg,
+ name,
+ NULL,
+ NULL,
+ &testTerminate,
+ NULL);
if (0 != UNLINK(name))
ret = SYSERR;
FREE(name);
@@ -258,19 +258,19 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
sock = NULL;
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS));
+ cfg,
+ 30 * cronSECONDS));
ok = YES;
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
sock = client_connection_create(NULL, cfg);
@@ -280,8 +280,8 @@
i = 0;
while (filesizes[i] != 0) {
fprintf(stderr,
- "Testing filesize %u",
- filesizes[i]);
+ "Testing filesize %u",
+ filesizes[i]);
uri = uploadFile(filesizes[i]);
CHECK(NULL != uri);
CHECK(OK == searchFile(&uri));
@@ -289,7 +289,7 @@
ECRS_freeUri(uri);
CHECK(OK == unindexFile(filesizes[i]));
fprintf(stderr,
- " Ok.\n");
+ " Ok.\n");
i++;
}
Modified: GNUnet/src/applications/fs/ecrs/helper.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/helper.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/helper.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -37,7 +37,7 @@
* if keywords is not legal (i.e. empty).
*/
struct ECRS_URI * ECRS_parseCharKeywordURI(struct GE_Context * ectx,
- const char * input) {
+ const char * input) {
char ** keywords;
unsigned int num_Words;
int inWord;
@@ -63,8 +63,8 @@
if (num_Words == 0) {
FREENONNULL(searchString);
GE_LOG(ectx,
- GE_ERROR | GE_IMMEDIATE | GE_USER,
- _("No keywords specified!\n"));
+ GE_ERROR | GE_IMMEDIATE | GE_USER,
+ _("No keywords specified!\n"));
return NULL;
}
keywords = MALLOC(num_Words * sizeof(char *));
@@ -80,8 +80,8 @@
}
}
uri = ECRS_parseArgvKeywordURI(ectx,
- num_Words,
- (const char**) keywords);
+ num_Words,
+ (const char**) keywords);
FREE(keywords);
FREE(searchString);
return uri;
@@ -96,8 +96,8 @@
* if keywords is not legal (i.e. empty).
*/
struct ECRS_URI * ECRS_parseArgvKeywordURI(struct GE_Context * ectx,
- unsigned int num_keywords,
- const char ** keywords) {
+ unsigned int num_keywords,
+ const char ** keywords) {
unsigned int i;
unsigned int uriLen;
char * uriString;
@@ -117,19 +117,19 @@
for (i=0;i<num_keywords;i++) {
if (uriSize < uriLen + strlen(_("AND")) + 1 + strlen(keywords[i]))
GROW(uriString,
- uriSize,
- uriSize + 4096 + strlen(keywords[i]));
+ uriSize,
+ uriSize + 4096 + strlen(keywords[i]));
if ( (i > 0) &&
- (0 == strcmp(keywords[i], _("AND"))) ) {
+ (0 == strcmp(keywords[i], _("AND"))) ) {
strcat(uriString, "+");
if (i == num_keywords-1)
- strcat(uriString, _("AND")); /* last keyword 'AND'? keep it! */
+ strcat(uriString, _("AND")); /* last keyword 'AND'? keep it! */
uriLen += 1;
} else {
if ( (i > 0) &&
- (0 != strcmp(keywords[i-1], _("AND"))) ) {
- strcat(uriString, " ");
- uriLen += 1;
+ (0 != strcmp(keywords[i-1], _("AND"))) ) {
+ strcat(uriString, " ");
+ uriLen += 1;
}
strcat(uriString, keywords[i]);
uriLen += strlen(keywords[i]);
@@ -151,8 +151,8 @@
* if keywords is not legal (i.e. empty).
*/
struct ECRS_URI * ECRS_parseListKeywordURI(struct GE_Context * ectx,
- unsigned int num_keywords,
- const char ** keywords) {
+ unsigned int num_keywords,
+ const char ** keywords) {
unsigned int i;
unsigned int uriLen;
char * uriString;
@@ -172,8 +172,8 @@
for (i=0;i<num_keywords;i++) {
if (uriSize < uriLen + 1 + strlen(keywords[i]))
GROW(uriString,
- uriSize,
- uriSize + 4096 + strlen(keywords[i]));
+ uriSize,
+ uriSize + 4096 + strlen(keywords[i]));
if (i > 0) {
strcat(uriString, "+");
uriLen++;
Modified: GNUnet/src/applications/fs/ecrs/indexinfo.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/indexinfo.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/indexinfo.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -39,21 +39,21 @@
* be notified that 'something is wrong')
*/
int ECRS_isFileIndexed(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * filename) {
+ struct GC_Configuration * cfg,
+ const char * filename) {
HashCode512 hc;
struct ClientServerConnection * sock;
int ret;
if (SYSERR == getFileHash(ectx,
- filename,
- &hc))
+ filename,
+ &hc))
return SYSERR;
sock = client_connection_create(ectx, cfg);
if (sock == NULL)
return SYSERR;
ret = FS_testIndexed(sock,
- &hc);
+ &hc);
connection_destroy(sock);
return ret;
}
@@ -66,8 +66,8 @@
};
static int iiHelper(const char * fn,
- const char * dir,
- void * ptr) {
+ const char * dir,
+ void * ptr) {
struct iiC * cls = ptr;
char * fullName;
char * lnkName;
@@ -82,25 +82,25 @@
lnkName = MALLOC(size);
while (1) {
ret = READLINK(fullName,
- lnkName,
- size - 1);
+ lnkName,
+ size - 1);
if (ret == -1) {
if (errno == ENAMETOOLONG) {
- if (size * 2 < size) {
- FREE(lnkName);
- FREE(fullName);
- return OK; /* error */
- }
- GROW(lnkName,
- size,
- size * 2);
- continue;
+ if (size * 2 < size) {
+ FREE(lnkName);
+ FREE(fullName);
+ return OK; /* error */
+ }
+ GROW(lnkName,
+ size,
+ size * 2);
+ continue;
}
if (errno != EINVAL) {
- GE_LOG_STRERROR_FILE(cls->ectx,
- GE_WARNING | GE_BULK | GE_ADMIN | GE_USER,
- "readlink",
- fullName);
+ GE_LOG_STRERROR_FILE(cls->ectx,
+ GE_WARNING | GE_BULK | GE_ADMIN | GE_USER,
+ "readlink",
+ fullName);
}
FREE(lnkName);
FREE(fullName);
@@ -112,7 +112,7 @@
}
cls->cnt++;
if (OK != cls->iterator(lnkName,
- cls->closure)) {
+ cls->closure)) {
cls->cnt = SYSERR;
FREE(fullName);
FREE(lnkName);
@@ -136,9 +136,9 @@
* @return number of files indexed, SYSERR if iterator aborted
*/
int ECRS_iterateIndexedFiles(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- ECRS_FileIterator iterator,
- void * closure) {
+ struct GC_Configuration * cfg,
+ ECRS_FileIterator iterator,
+ void * closure) {
char * tmp;
char * indexDirectory;
struct ClientServerConnection * sock;
@@ -148,8 +148,8 @@
if (sock == NULL)
return 0;
tmp = getConfigurationOptionValue(sock,
- "FS",
- "INDEX-DIRECTORY");
+ "FS",
+ "INDEX-DIRECTORY");
connection_destroy(sock);
if (tmp == NULL) {
return 0;
@@ -161,9 +161,9 @@
cls.closure = closure;
cls.cnt = 0;
disk_directory_scan(ectx,
- indexDirectory,
- &iiHelper,
- &cls);
+ indexDirectory,
+ &iiHelper,
+ &cls);
FREE(indexDirectory);
return cls.cnt;
}
Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -52,8 +52,8 @@
* @return SYSERR if the entry is malformed
*/
static int verifyKBlock(struct GE_Context * ectx,
- const HashCode512 * key,
- Datastore_Value * value) {
+ const HashCode512 * key,
+ Datastore_Value * value) {
unsigned int type;
ECRS_FileInfo fi;
unsigned int size;
@@ -65,9 +65,9 @@
type = ntohl(value->type);
size = ntohl(value->size) - sizeof(Datastore_Value);
if (OK != getQueryFor(size,
- (DBlock*) &value[1],
- YES,
- &query))
+ (DBlock*) &value[1],
+ YES,
+ &query))
return SYSERR;
GE_ASSERT(ectx, type == K_BLOCK);
@@ -75,11 +75,11 @@
return SYSERR;
kb = (KBlock*) &value[1];
ECRS_decryptInPlace(key,
- &kb[1],
- size - sizeof(KBlock));
+ &kb[1],
+ size - sizeof(KBlock));
j = sizeof(KBlock);
while ( (j < size) &&
- (((const char*)kb)[j] != '\0') )
+ (((const char*)kb)[j] != '\0') )
j++;
if (j == size) {
GE_BREAK(NULL, 0); /* kblock malformed */
@@ -88,14 +88,14 @@
dstURI = (const char*) &kb[1];
j++;
fi.meta = ECRS_deserializeMetaData(ectx,
- &((const char*)kb)[j],
- size - j);
+ &((const char*)kb)[j],
+ size - j);
if (fi.meta == NULL) {
GE_BREAK(ectx, 0); /* kblock malformed */
return SYSERR;
}
fi.uri = ECRS_stringToUri(ectx,
- dstURI);
+ dstURI);
if (fi.uri == NULL) {
GE_BREAK(ectx, 0); /* kblock malformed */
ECRS_freeMetaData(fi.meta);
@@ -119,13 +119,13 @@
* entry?
*/
int ECRS_addToKeyspace(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const struct ECRS_URI * uri,
- unsigned int anonymityLevel,
- unsigned int priority,
- cron_t expirationTime,
- const struct ECRS_URI * dst,
- const struct ECRS_MetaData * md) {
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri,
+ unsigned int anonymityLevel,
+ unsigned int priority,
+ cron_t expirationTime,
+ const struct ECRS_URI * dst,
+ const struct ECRS_MetaData * md) {
struct ClientServerConnection * sock;
Datastore_Value * value;
int ret;
@@ -152,24 +152,24 @@
return SYSERR;
}
mdsize = ECRS_sizeofMetaData(md,
- ECRS_SERIALIZE_PART);
+ ECRS_SERIALIZE_PART);
dstURI = ECRS_uriToString(dst);
size = mdsize + sizeof(KBlock) + strlen(dstURI) + 1;
if (size > MAX_KBLOCK_SIZE) {
size = MAX_KBLOCK_SIZE;
value = MALLOC(sizeof(Datastore_Value) +
- size);
+ size);
kb = (KBlock*) &value[1];
kb->type = htonl(K_BLOCK);
memcpy(&kb[1],
- dstURI,
- strlen(dstURI)+1);
+ dstURI,
+ strlen(dstURI)+1);
mdsize = size - sizeof(KBlock) - strlen(dstURI) - 1;
mdsize = ECRS_serializeMetaData(ectx,
- md,
- &((char*)&kb[1])[strlen(dstURI)+1],
- mdsize,
- ECRS_SERIALIZE_PART);
+ md,
+ &((char*)&kb[1])[strlen(dstURI)+1],
+ mdsize,
+ ECRS_SERIALIZE_PART);
if (mdsize == -1) {
GE_BREAK(ectx, 0);
FREE(dstURI);
@@ -178,19 +178,19 @@
size = sizeof(KBlock) + strlen(dstURI) + 1 + mdsize;
} else {
value = MALLOC(sizeof(Datastore_Value) +
- size);
+ size);
kb = (KBlock*) &value[1];
kb->type = htonl(K_BLOCK);
memcpy(&kb[1],
- dstURI,
- strlen(dstURI)+1);
+ dstURI,
+ strlen(dstURI)+1);
GE_ASSERT(ectx,
- mdsize ==
- ECRS_serializeMetaData(ectx,
- md,
- &((char*)&kb[1])[strlen(dstURI)+1],
- mdsize,
- ECRS_SERIALIZE_FULL));
+ mdsize ==
+ ECRS_serializeMetaData(ectx,
+ md,
+ &((char*)&kb[1])[strlen(dstURI)+1],
+ mdsize,
+ ECRS_SERIALIZE_FULL));
}
value->size = htonl(sizeof(Datastore_Value) + size);
value->type = htonl(K_BLOCK);
@@ -201,9 +201,9 @@
ret = OK;
if (GC_get_configuration_value_yesno(cfg,
- "FS",
- "DISABLE-CREATION-TIME",
- NO) == YES)
+ "FS",
+ "DISABLE-CREATION-TIME",
+ NO) == YES)
xuri = ECRS_dupUri(uri);
else
xuri = ECRS_dateExpandKeywordUri(uri);
@@ -211,50 +211,50 @@
keywordCount = xuri->data.ksk.keywordCount;
cpy = MALLOC(mdsize + strlen(dstURI) + 1);
memcpy(cpy,
- &kb[1],
- mdsize + strlen(dstURI) + 1);
+ &kb[1],
+ mdsize + strlen(dstURI) + 1);
for (i=0;i<keywordCount;i++) {
memcpy(&kb[1], cpy, mdsize + strlen(dstURI) + 1);
hash(keywords[i],
- strlen(keywords[i]),
- &key);
+ strlen(keywords[i]),
+ &key);
#if DEBUG_KEYSPACE
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Encrypting KBlock with key %s.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Encrypting KBlock with key %s.\n",
+ &enc);
#endif
ECRS_encryptInPlace(&key,
- &kb[1],
- mdsize + strlen(dstURI) + 1);
+ &kb[1],
+ mdsize + strlen(dstURI) + 1);
pk = makeKblockKey(&key);
getPublicKey(pk,
- &kb->keyspace);
+ &kb->keyspace);
GE_ASSERT(ectx,
- OK == sign(pk,
- mdsize + strlen(dstURI) + 1,
- &kb[1],
- &kb->signature));
+ OK == sign(pk,
+ mdsize + strlen(dstURI) + 1,
+ &kb[1],
+ &kb->signature));
#if EXTRA_CHECKS
/* extra check: verify sig */
GE_ASSERT(ectx,
- OK == getQueryFor(size,
- (DBlock*) kb,
- YES,
- &hc));
+ OK == getQueryFor(size,
+ (DBlock*) kb,
+ YES,
+ &hc));
#endif
freePrivateKey(pk);
if (OK != FS_insert(sock, value))
ret = SYSERR;
#if EXTRA_CHECKS
GE_ASSERT(ectx,
- OK == verifyKBlock(ectx,
- &key,
- value))
+ OK == verifyKBlock(ectx,
+ &key,
+ value))
#endif
}
ECRS_freeUri(xuri);
Modified: GNUnet/src/applications/fs/ecrs/meta.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/meta.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/meta.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -294,7 +294,7 @@
* of meta-data items obtained
*/
int ECRS_extractMetaData(struct GE_Context * ectx,
- MetaData * md,
+ MetaData * md,
const char * filename,
EXTRACTOR_ExtractorList * extractors) {
EXTRACTOR_KeywordList * head;
@@ -308,7 +308,7 @@
head = EXTRACTOR_getKeywords(extractors,
filename);
head = EXTRACTOR_removeDuplicateKeywords(head,
- EXTRACTOR_DUPLICATES_REMOVE_UNKNOWN);
+ EXTRACTOR_DUPLICATES_REMOVE_UNKNOWN);
pos = head;
ret = 0;
while (pos != NULL) {
@@ -336,10 +336,10 @@
#endif
tmp = MALLOC(dlen);
if (Z_OK == compress2((Bytef*) tmp,
- &dlen,
- (const Bytef*) data,
- oldSize,
- 9)) {
+ &dlen,
+ (const Bytef*) data,
+ oldSize,
+ 9)) {
if (dlen < oldSize) {
memcpy(data, tmp, dlen);
FREE(tmp);
@@ -425,7 +425,7 @@
* space)
*/
int ECRS_serializeMetaData(struct GE_Context * ectx,
- const MetaData * md,
+ const MetaData * md,
char * target,
unsigned int max,
int part) {
@@ -465,7 +465,7 @@
hdr->size = htonl(size);
if ((part & ECRS_SERIALIZE_NO_COMPRESS) == 0) {
pos = tryCompression((char*)&hdr[1],
- size - sizeof(MetaDataHeader));
+ size - sizeof(MetaDataHeader));
} else {
pos = size - sizeof(MetaDataHeader);
}
@@ -497,7 +497,7 @@
{
MetaData * mdx;
mdx = ECRS_deserializeMetaData(ectx,
- target,
+ target,
size);
GE_ASSERT(ectx, NULL != mdx);
ECRS_freeMetaData(mdx);
@@ -512,7 +512,7 @@
* than what is strictly needed.
*/
unsigned int ECRS_sizeofMetaData(const MetaData * md,
- int part) {
+ int part) {
MetaDataHeader * hdr;
size_t size;
size_t pos;
@@ -543,7 +543,7 @@
}
if ((part & ECRS_SERIALIZE_NO_COMPRESS) == 0) {
pos = tryCompression((char*)&hdr[1],
- size - sizeof(MetaDataHeader));
+ size - sizeof(MetaDataHeader));
} else {
pos = size - sizeof(MetaDataHeader);
}
@@ -563,7 +563,7 @@
*/
struct ECRS_MetaData *
ECRS_deserializeMetaData(struct GE_Context * ectx,
- const char * input,
+ const char * input,
unsigned int size) {
MetaData * md;
const MetaDataHeader * hdr;
@@ -735,7 +735,7 @@
* @return the new filename
*/
char * ECRS_suggestFilename(struct GE_Context * ectx,
- const char * filename) {
+ const char * filename) {
EXTRACTOR_ExtractorList * l;
EXTRACTOR_KeywordList * list;
const char * key;
Modified: GNUnet/src/applications/fs/ecrs/metatest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/metatest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/metatest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -40,51 +40,51 @@
m = ECRS_createMetaData();
if (OK != ECRS_addToMetaData(m,
- EXTRACTOR_TITLE,
- "TestTitle"))
+ EXTRACTOR_TITLE,
+ "TestTitle"))
ABORT(m);
if (OK != ECRS_addToMetaData(m,
- EXTRACTOR_AUTHOR,
- "TestTitle"))
+ EXTRACTOR_AUTHOR,
+ "TestTitle"))
ABORT(m);
if (OK == ECRS_addToMetaData(m,
- EXTRACTOR_TITLE,
- "TestTitle")) /* dup! */
+ EXTRACTOR_TITLE,
+ "TestTitle")) /* dup! */
ABORT(m);
if (OK == ECRS_addToMetaData(m,
- EXTRACTOR_AUTHOR,
- "TestTitle")) /* dup! */
+ EXTRACTOR_AUTHOR,
+ "TestTitle")) /* dup! */
ABORT(m);
if (2 != ECRS_getMetaData(m, NULL, NULL))
ABORT(m);
if (OK != ECRS_delFromMetaData(m,
- EXTRACTOR_AUTHOR,
- "TestTitle"))
+ EXTRACTOR_AUTHOR,
+ "TestTitle"))
ABORT(m);
if (OK == ECRS_delFromMetaData(m,
- EXTRACTOR_AUTHOR,
- "TestTitle")) /* already gone */
+ EXTRACTOR_AUTHOR,
+ "TestTitle")) /* already gone */
ABORT(m);
if (1 != ECRS_getMetaData(m, NULL, NULL))
ABORT(m);
if (OK != ECRS_delFromMetaData(m,
- EXTRACTOR_TITLE,
- "TestTitle"))
+ EXTRACTOR_TITLE,
+ "TestTitle"))
ABORT(m);
if (OK == ECRS_delFromMetaData(m,
- EXTRACTOR_TITLE,
- "TestTitle")) /* already gone */
+ EXTRACTOR_TITLE,
+ "TestTitle")) /* already gone */
ABORT(m);
if (0 != ECRS_getMetaData(m, NULL, NULL))
ABORT(m);
val = MALLOC(256);
for (j=0;j<i;j++) {
SNPRINTF(val, 256, "%s.%d",
- "A teststring that should compress well.",
- j);
+ "A teststring that should compress well.",
+ j);
if (OK != ECRS_addToMetaData(m,
- EXTRACTOR_UNKNOWN,
- val)) {
+ EXTRACTOR_UNKNOWN,
+ val)) {
FREE(val);
ABORT(m);
}
@@ -94,31 +94,31 @@
ABORT(m);
size = ECRS_sizeofMetaData(m,
- ECRS_SERIALIZE_FULL);
+ ECRS_SERIALIZE_FULL);
val = MALLOC(size);
if (size != ECRS_serializeMetaData(NULL,
- m,
- val,
- size,
- ECRS_SERIALIZE_FULL)) {
+ m,
+ val,
+ size,
+ ECRS_SERIALIZE_FULL)) {
FREE(val);
ABORT(m);
}
ECRS_freeMetaData(m);
m = ECRS_deserializeMetaData(NULL,
- val,
- size);
+ val,
+ size);
FREE(val);
if (m == NULL)
ABORT(m);
val = MALLOC(256);
for (j=0;j<i;j++) {
SNPRINTF(val, 256, "%s.%d",
- "A teststring that should compress well.",
- j);
+ "A teststring that should compress well.",
+ j);
if (OK != ECRS_delFromMetaData(m,
- EXTRACTOR_UNKNOWN,
- val)) {
+ EXTRACTOR_UNKNOWN,
+ val)) {
FREE(val);
ABORT(m);
}
@@ -141,21 +141,21 @@
meta = ECRS_createMetaData();
for (q=0;q<=i;q++) {
SNPRINTF(txt,
- 128,
- "%u -- %u\n",
- i, q);
+ 128,
+ "%u -- %u\n",
+ i, q);
ECRS_addToMetaData(meta,
- q % EXTRACTOR_getHighestKeywordTypeNumber(),
- txt);
+ q % EXTRACTOR_getHighestKeywordTypeNumber(),
+ txt);
}
size = ECRS_sizeofMetaData(meta,
- ECRS_SERIALIZE_FULL);
+ ECRS_SERIALIZE_FULL);
data = MALLOC(size * 4);
if (size != ECRS_serializeMetaData(NULL,
- meta,
- data,
- size * 4,
- ECRS_SERIALIZE_FULL)) {
+ meta,
+ data,
+ size * 4,
+ ECRS_SERIALIZE_FULL)) {
FREE(data);
ABORT(meta);
}
Modified: GNUnet/src/applications/fs/ecrs/metatest2.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/metatest2.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/metatest2.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -39,33 +39,33 @@
m = ECRS_createMetaData();
if (OK != ECRS_addToMetaData(m,
- EXTRACTOR_UNKNOWN,
- "link")) {
+ EXTRACTOR_UNKNOWN,
+ "link")) {
ECRS_freeMetaData(m);
ABORT();
}
if (OK != ECRS_addToMetaData(m,
- EXTRACTOR_FILENAME,
- "lib-link.m4")) {
+ EXTRACTOR_FILENAME,
+ "lib-link.m4")) {
ECRS_freeMetaData(m);
ABORT();
}
size = ECRS_sizeofMetaData(m,
- ECRS_SERIALIZE_FULL);
+ ECRS_SERIALIZE_FULL);
val = MALLOC(size);
if (size != ECRS_serializeMetaData(NULL,
- m,
- val,
- size,
- ECRS_SERIALIZE_FULL)) {
+ m,
+ val,
+ size,
+ ECRS_SERIALIZE_FULL)) {
ECRS_freeMetaData(m);
FREE(val);
ABORT();
}
ECRS_freeMetaData(m);
m = ECRS_deserializeMetaData(NULL,
- val,
- size);
+ val,
+ size);
FREE(val);
if (m == NULL)
ABORT();
Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -38,16 +38,16 @@
#define MAX_SBLOCK_SIZE 32000
static char * getPseudonymFileName(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * name) {
+ struct GC_Configuration * cfg,
+ const char * name) {
char * gnHome;
char * fileName;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &fileName);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fileName);
gnHome = string_expandFileName(ectx, fileName);
FREE(fileName);
fileName = MALLOC(strlen(gnHome) + strlen(PSEUDODIR) + strlen(name) + 2);
@@ -56,7 +56,7 @@
strcat(fileName, DIR_SEPARATOR_STR);
strcat(fileName, PSEUDODIR);
disk_directory_create(ectx,
- fileName);
+ fileName);
strcat(fileName, name);
return fileName;
}
@@ -67,21 +67,21 @@
* @return OK on success, SYSERR on error
*/
int ECRS_deleteNamespace(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * name) {
+ struct GC_Configuration * cfg,
+ const char * name) {
char * fileName;
fileName = getPseudonymFileName(ectx, cfg, name);
if (YES != disk_file_test(ectx,
- fileName)) {
+ fileName)) {
FREE(fileName);
return SYSERR; /* no such namespace */
}
if (0 != UNLINK(fileName)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "unlink",
- fileName);
+ GE_WARNING | GE_USER | GE_BULK,
+ "unlink",
+ fileName);
FREE(fileName);
return SYSERR;
}
@@ -111,14 +111,14 @@
*/
struct ECRS_URI *
ECRS_createNamespace(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * name,
- const struct ECRS_MetaData * meta,
- unsigned int anonymityLevel,
- unsigned int priority,
- cron_t expiration,
- const struct ECRS_URI * advertisementURI,
- const HashCode512 * rootEntry) {
+ struct GC_Configuration * cfg,
+ const char * name,
+ const struct ECRS_MetaData * meta,
+ unsigned int anonymityLevel,
+ unsigned int priority,
+ cron_t expiration,
+ const struct ECRS_URI * advertisementURI,
+ const HashCode512 * rootEntry) {
struct ECRS_URI * rootURI;
char * fileName;
struct PrivateKey * hk;
@@ -145,15 +145,15 @@
return NULL;
}
fileName = getPseudonymFileName(ectx,
- cfg,
- name);
+ cfg,
+ name);
if (YES == disk_file_test(ectx,
- fileName)) {
+ fileName)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Cannot create pseudonym `%s', file `%s' exists.\n"),
- name,
- fileName);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Cannot create pseudonym `%s', file `%s' exists.\n"),
+ name,
+ fileName);
FREE(fileName);
return NULL;
}
@@ -162,49 +162,49 @@
len = ntohs(hke->len);
dst = (char*) hke;
disk_file_write(ectx,
- fileName,
- dst,
- len,
- "600");
+ fileName,
+ dst,
+ len,
+ "600");
FREE(fileName);
FREE(dst);
/* create advertisements */
mdsize = ECRS_sizeofMetaData(meta,
- ECRS_SERIALIZE_PART);
+ ECRS_SERIALIZE_PART);
size = mdsize + sizeof(NBlock);
if (size > MAX_NBLOCK_SIZE) {
size = MAX_NBLOCK_SIZE;
value = MALLOC(sizeof(Datastore_Value) +
- size);
+ size);
nb = (NBlock*) &value[1];
nb->type = htonl(N_BLOCK);
mdsize = size - sizeof(NBlock);
mdsize = ECRS_serializeMetaData(ectx,
- meta,
- (char*)&nb[1],
- mdsize,
- ECRS_SERIALIZE_PART);
+ meta,
+ (char*)&nb[1],
+ mdsize,
+ ECRS_SERIALIZE_PART);
if (mdsize == -1) {
GE_BREAK(ectx, 0);
ECRS_deleteNamespace(ectx,
- cfg,
- name);
+ cfg,
+ name);
freePrivateKey(hk);
return NULL;
}
size = sizeof(NBlock) + mdsize;
} else {
value = MALLOC(sizeof(Datastore_Value) +
- size);
+ size);
nb = (NBlock*) &value[1];
nb->type = htonl(N_BLOCK);
ECRS_serializeMetaData(ectx,
- meta,
- (char*)&nb[1],
- mdsize,
- ECRS_SERIALIZE_FULL);
+ meta,
+ (char*)&nb[1],
+ mdsize,
+ ECRS_SERIALIZE_FULL);
}
value->size = htonl(sizeof(Datastore_Value) + size);
value->type = htonl(N_BLOCK);
@@ -216,7 +216,7 @@
/* publish NBlock */
memset(&nb->identifier, 0, sizeof(HashCode512));
getPublicKey(hk,
- &nb->subspace);
+ &nb->subspace);
hash(&nb->subspace,
sizeof(PublicKey),
&nb->namespace);
@@ -228,10 +228,10 @@
nb->rootEntry = *rootEntry;
GE_ASSERT(ectx,
- OK == sign(hk,
- mdsize + 3 * sizeof(HashCode512),
- &nb->identifier,
- &nb->signature));
+ OK == sign(hk,
+ mdsize + 3 * sizeof(HashCode512),
+ &nb->identifier,
+ &nb->signature));
if (OK != FS_insert(sock, value)) {
GE_BREAK(ectx, 0);
FREE(rootURI);
@@ -252,51 +252,51 @@
knb = (KNBlock*) &knvalue[1];
knb->type = htonl(KN_BLOCK);
memcpy(&knb->nblock,
- nb,
- sizeof(NBlock) + mdsize);
+ nb,
+ sizeof(NBlock) + mdsize);
if (advertisementURI != NULL) {
keywords = advertisementURI->data.ksk.keywords;
keywordCount = advertisementURI->data.ksk.keywordCount;
cpy = MALLOC(size - sizeof(KBlock) - sizeof(unsigned int));
memcpy(cpy,
- &knb->nblock,
- size - sizeof(KBlock) - sizeof(unsigned int));
+ &knb->nblock,
+ size - sizeof(KBlock) - sizeof(unsigned int));
for (i=0;i<keywordCount;i++) {
hash(keywords[i],
- strlen(keywords[i]),
- &hc);
+ strlen(keywords[i]),
+ &hc);
pk = makeKblockKey(&hc);
getPublicKey(pk,
- &knb->kblock.keyspace);
+ &knb->kblock.keyspace);
GE_ASSERT(ectx, size - sizeof(KBlock) - sizeof(unsigned int)
- == sizeof(NBlock) + mdsize);
+ == sizeof(NBlock) + mdsize);
ECRS_encryptInPlace(&hc,
- &knb->nblock,
- size - sizeof(KBlock) - sizeof(unsigned int));
+ &knb->nblock,
+ size - sizeof(KBlock) - sizeof(unsigned int));
GE_ASSERT(ectx,
- OK == sign(pk,
- sizeof(NBlock) + mdsize,
- &knb->nblock,
- &knb->kblock.signature));
+ OK == sign(pk,
+ sizeof(NBlock) + mdsize,
+ &knb->nblock,
+ &knb->kblock.signature));
/* extra check: verify sig */
freePrivateKey(pk);
if (OK != FS_insert(sock, knvalue)) {
- GE_BREAK(ectx, 0);
- FREE(rootURI);
- ECRS_deleteNamespace(ectx, cfg, name);
- FREE(cpy);
- FREE(knvalue);
- FREE(value);
- connection_destroy(sock);
- freePrivateKey(hk);
- return NULL;
+ GE_BREAK(ectx, 0);
+ FREE(rootURI);
+ ECRS_deleteNamespace(ectx, cfg, name);
+ FREE(cpy);
+ FREE(knvalue);
+ FREE(value);
+ connection_destroy(sock);
+ freePrivateKey(hk);
+ return NULL;
}
/* restore nblock to avoid re-encryption! */
memcpy(&knb->nblock,
- cpy,
- size - sizeof(KBlock) - sizeof(unsigned int));
+ cpy,
+ size - sizeof(KBlock) - sizeof(unsigned int));
}
FREE(cpy);
}
@@ -316,9 +316,9 @@
* @return OK if the namespace exists, SYSERR if not
*/
int ECRS_testNamespaceExists(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * name,
- const HashCode512 * hc) {
+ struct GC_Configuration * cfg,
+ const char * name,
+ const HashCode512 * hc) {
struct PrivateKey * hk;
char * fileName;
PrivateKeyEncoded * hke;
@@ -329,12 +329,12 @@
/* FIRST: read and decrypt pseudonym! */
fileName = getPseudonymFileName(ectx,
- cfg,
- name);
+ cfg,
+ name);
if (OK != disk_file_size(ectx,
- fileName,
- &len,
- YES)) {
+ fileName,
+ &len,
+ YES)) {
FREE(fileName);
return SYSERR;
}
@@ -351,9 +351,9 @@
hke = (PrivateKeyEncoded*) dst;
if ( ntohs(hke->len) != len ) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Format of pseudonym `%s' is invalid.\n"),
- name);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Format of pseudonym `%s' is invalid.\n"),
+ name);
FREE(hke);
return SYSERR;
}
@@ -362,12 +362,12 @@
if (hk == NULL)
return SYSERR;
getPublicKey(hk,
- &pk);
+ &pk);
freePrivateKey(hk);
hash(&pk, sizeof(PublicKey), &namespace);
if ( (hc == NULL) ||
(equalsHashCode512(hc,
- &namespace)))
+ &namespace)))
return OK;
else
return SYSERR;
@@ -384,17 +384,17 @@
*/
struct ECRS_URI *
ECRS_addToNamespace(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * name,
- unsigned int anonymityLevel,
- unsigned int priority,
- cron_t expiration,
- TIME_T creationTime,
- TIME_T updateInterval,
- const HashCode512 * thisId,
- const HashCode512 * nextId,
- const struct ECRS_URI * dstU,
- const struct ECRS_MetaData * md) {
+ struct GC_Configuration * cfg,
+ const char * name,
+ unsigned int anonymityLevel,
+ unsigned int priority,
+ cron_t expiration,
+ TIME_T creationTime,
+ TIME_T updateInterval,
+ const HashCode512 * thisId,
+ const HashCode512 * nextId,
+ const struct ECRS_URI * dstU,
+ const struct ECRS_MetaData * md) {
struct ECRS_URI * uri;
struct ClientServerConnection * sock;
Datastore_Value * value;
@@ -415,9 +415,9 @@
/* FIRST: read pseudonym! */
fileName = getPseudonymFileName(ectx, cfg, name);
if (OK != disk_file_size(ectx,
- fileName,
- &len,
- YES)) {
+ fileName,
+ &len,
+ YES)) {
FREE(fileName);
return NULL;
}
@@ -447,24 +447,24 @@
/* THEN: construct SBlock */
dstURI = ECRS_uriToString(dstU);
mdsize = ECRS_sizeofMetaData(md,
- ECRS_SERIALIZE_PART);
+ ECRS_SERIALIZE_PART);
size = mdsize + sizeof(SBlock) + strlen(dstURI) + 1;
if (size > MAX_SBLOCK_SIZE) {
size = MAX_SBLOCK_SIZE;
value = MALLOC(sizeof(Datastore_Value) +
- size);
+ size);
sb = (SBlock*) &value[1];
sb->type = htonl(S_BLOCK);
destPos = (char*) &sb[1];
memcpy(destPos,
- dstURI,
- strlen(dstURI) + 1);
+ dstURI,
+ strlen(dstURI) + 1);
mdsize = size - sizeof(SBlock) - strlen(dstURI) - 1;
mdsize = ECRS_serializeMetaData(ectx,
- md,
- &destPos[strlen(dstURI)+1],
- mdsize,
- ECRS_SERIALIZE_PART);
+ md,
+ &destPos[strlen(dstURI)+1],
+ mdsize,
+ ECRS_SERIALIZE_PART);
if (mdsize == -1) {
GE_BREAK(ectx, 0);
FREE(dstURI);
@@ -474,18 +474,18 @@
size = sizeof(SBlock) + mdsize + strlen(dstURI) + 1;
} else {
value = MALLOC(sizeof(Datastore_Value) +
- size);
+ size);
sb = (SBlock*) &value[1];
sb->type = htonl(S_BLOCK);
destPos = (char*) &sb[1];
memcpy(destPos,
- dstURI,
- strlen(dstURI) + 1);
+ dstURI,
+ strlen(dstURI) + 1);
ECRS_serializeMetaData(ectx,
- md,
- &destPos[strlen(dstURI)+1],
- mdsize,
- ECRS_SERIALIZE_FULL);
+ md,
+ &destPos[strlen(dstURI)+1],
+ mdsize,
+ ECRS_SERIALIZE_FULL);
}
value->size = htonl(sizeof(Datastore_Value) + size);
value->type = htonl(S_BLOCK);
@@ -499,19 +499,19 @@
sb->nextIdentifier = *nextId;
deltaId(thisId,
- nextId,
- &sb->identifierIncrement);
+ nextId,
+ &sb->identifierIncrement);
hash(thisId,
sizeof(HashCode512),
&hc);
getPublicKey(hk,
- &sb->subspace);
+ &sb->subspace);
hash(&sb->subspace,
sizeof(PublicKey),
&namespace);
xorHashCodes(&hc,
- &namespace,
- &sb->identifier); /* sb->identifier = primary key in query! */
+ &namespace,
+ &sb->identifier); /* sb->identifier = primary key in query! */
uri = MALLOC(sizeof(URI));
uri->type = sks;
@@ -519,21 +519,21 @@
uri->data.sks.identifier = *thisId;
ECRS_encryptInPlace(thisId,
- &sb->creationTime,
- size
- - sizeof(unsigned int)
- - sizeof(Signature)
- - sizeof(PublicKey)
- - sizeof(HashCode512));
+ &sb->creationTime,
+ size
+ - sizeof(unsigned int)
+ - sizeof(Signature)
+ - sizeof(PublicKey)
+ - sizeof(HashCode512));
/* FINALLY: sign & publish SBlock */
GE_ASSERT(ectx,
- OK == sign(hk,
- size
- - sizeof(Signature)
- - sizeof(PublicKey)
- - sizeof(unsigned int),
- &sb->identifier,
- &sb->signature));
+ OK == sign(hk,
+ size
+ - sizeof(Signature)
+ - sizeof(PublicKey)
+ - sizeof(unsigned int),
+ &sb->identifier,
+ &sb->signature));
freePrivateKey(hk);
sock = client_connection_create(ectx, cfg);
@@ -550,7 +550,7 @@
}
struct lNCLS {
- struct GE_Context * ectx;
+ struct GE_Context * ectx;
struct GC_Configuration * cfg;
ECRS_NamespaceInfoCallback cb;
void * cls;
@@ -558,8 +558,8 @@
};
static int processFile_(const char * name,
- const char * dirName,
- void * cls) {
+ const char * dirName,
+ void * cls) {
struct lNCLS * c = cls;
struct PrivateKey * hk;
char * fileName;
@@ -570,34 +570,34 @@
PublicKey pk;
fileName = getPseudonymFileName(c->ectx,
- c->cfg,
- name);
+ c->cfg,
+ name);
if (OK != disk_file_size(c->ectx,
- fileName,
- &len,
- YES)) {
+ fileName,
+ &len,
+ YES)) {
FREE(fileName);
return OK;
}
if (len < 2) {
GE_LOG(c->ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("File `%s' does not contain a pseudonym.\n"),
- fileName);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("File `%s' does not contain a pseudonym.\n"),
+ fileName);
FREE(fileName);
return OK;
}
dst = MALLOC(len);
len = disk_file_read(c->ectx,
- fileName,
- len,
- dst);
+ fileName,
+ len,
+ dst);
hke = (PrivateKeyEncoded*) dst;
if ( ntohs(hke->len) != len ) {
GE_LOG(c->ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Format of file `%s' is invalid.\n"),
- fileName);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Format of file `%s' is invalid.\n"),
+ fileName);
FREE(hke);
FREE(fileName);
return OK;
@@ -606,22 +606,22 @@
FREE(hke);
if (hk == NULL) {
GE_LOG(c->ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Format of file `%s' is invalid.\n"),
- fileName);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Format of file `%s' is invalid.\n"),
+ fileName);
FREE(fileName);
GE_BREAK(c->ectx, 0);
return SYSERR;
}
FREE(fileName);
getPublicKey(hk,
- &pk);
+ &pk);
freePrivateKey(hk);
hash(&pk, sizeof(PublicKey), &namespace);
if (NULL != c->cb) {
if (OK == c->cb(&namespace,
- name,
- c->cls))
+ name,
+ c->cls))
c->cnt++;
else
c->cnt = SYSERR;
@@ -637,9 +637,9 @@
* @return SYSERR on error, otherwise the number of pseudonyms in list
*/
int ECRS_listNamespaces(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- ECRS_NamespaceInfoCallback cb,
- void * cls) {
+ struct GC_Configuration * cfg,
+ ECRS_NamespaceInfoCallback cb,
+ void * cls) {
char * dirName;
struct lNCLS myCLS;
@@ -650,9 +650,9 @@
myCLS.cfg = cfg;
dirName = getPseudonymFileName(ectx, cfg, "");
disk_directory_scan(ectx,
- dirName,
- &processFile_,
- &myCLS);
+ dirName,
+ &processFile_,
+ &myCLS);
FREE(dirName);
return myCLS.cnt;
}
Modified: GNUnet/src/applications/fs/ecrs/namespacetest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespacetest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/ecrs/namespacetest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -41,19 +41,19 @@
static int match;
static int spcb(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * closure) {
+ const HashCode512 * key,
+ int isRoot,
+ void * closure) {
struct ECRS_URI * want = closure;
if (ECRS_equalsUri(want,
- fi->uri))
+ fi->uri))
match = 1;
else
fprintf(stderr,
- "Namespace search returned unexpected result: \nHAVE: %s\nWANT:
%s...\n",
- ECRS_uriToString(fi->uri),
- ECRS_uriToString(want));
+ "Namespace search returned unexpected result: \nHAVE: %s\nWANT: %s...\n",
+ ECRS_uriToString(fi->uri),
+ ECRS_uriToString(want));
return OK;
}
@@ -73,57 +73,57 @@
ECRS_deleteNamespace(NULL,
- cfg,
- CHECKNAME); /* make sure old one is deleted */
+ cfg,
+ CHECKNAME); /* make sure old one is deleted */
meta = ECRS_createMetaData();
adv = ECRS_keywordsToUri(keys);
hash("root", 4, &root);
rootURI =
ECRS_createNamespace(NULL,
- cfg,
- CHECKNAME,
- meta,
- 0,
- 0,
- get_time() + 15 * cronMINUTES,
- adv,
- &root);
+ cfg,
+ CHECKNAME,
+ meta,
+ 0,
+ 0,
+ get_time() + 15 * cronMINUTES,
+ adv,
+ &root);
CHECK(NULL != rootURI);
hash("this", 4, &thisId);
hash("next", 4, &nextId);
uri = rootURI; /* just for fun: NS::this advertises NS::root */
advURI = ECRS_addToNamespace(NULL,
- cfg,
- CHECKNAME,
- 1, /* anonymity */
- 1000, /* priority */
- 5 * cronMINUTES + get_time(),
- TIME(NULL) + 300,
- 0,
- &thisId,
- &nextId,
- uri,
- meta);
+ cfg,
+ CHECKNAME,
+ 1, /* anonymity */
+ 1000, /* priority */
+ 5 * cronMINUTES + get_time(),
+ TIME(NULL) + 300,
+ 0,
+ &thisId,
+ &nextId,
+ uri,
+ meta);
CHECK(NULL != advURI);
fprintf(stderr,
- "Starting namespace search...\n");
+ "Starting namespace search...\n");
CHECK(OK == ECRS_search(NULL,
- cfg,
- advURI,
- 1,
- 60 * cronSECONDS,
- &spcb,
- uri,
- NULL,
- NULL));
+ cfg,
+ advURI,
+ 1,
+ 60 * cronSECONDS,
+ &spcb,
+ uri,
+ NULL,
+ NULL));
fprintf(stderr,
- "Completed namespace search...\n");
+ "Completed namespace search...\n");
CHECK(OK == ECRS_deleteNamespace(NULL,
- cfg,
- CHECKNAME));
+ cfg,
+ CHECKNAME));
CHECK(SYSERR == ECRS_deleteNamespace(NULL,
- cfg,
- CHECKNAME));
+ cfg,
+ CHECKNAME));
ECRS_freeMetaData(meta);
ECRS_freeUri(rootURI);
ECRS_freeUri(advURI);
@@ -137,18 +137,18 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
if (OK != connection_wait_for_running(NULL,
- cfg,
- 60 * cronSECONDS)) {
+ cfg,
+ 60 * cronSECONDS)) {
failureCount++;
} else {
PTHREAD_SLEEP(5 * cronSECONDS);
Modified: GNUnet/src/applications/fs/ecrs/parser.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/parser.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/parser.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -32,9 +32,9 @@
* @param scls must be of type "struct ECRS_URI **"
*/
int gnunet_getopt_configure_set_keywords(CommandLineProcessorContext * ctx,
- void * scls,
- const char * option,
- const char * value) {
+ void * scls,
+ const char * option,
+ const char * value) {
struct ECRS_URI ** uri = scls;
struct ECRS_URI * u = *uri;
@@ -59,9 +59,9 @@
* @param scls must be of type "struct ECRS_MetaData **"
*/
int gnunet_getopt_configure_set_metadata(CommandLineProcessorContext * ctx,
- void * scls,
- const char * option,
- const char * value) {
+ void * scls,
+ const char * option,
+ const char * value) {
struct ECRS_MetaData ** mm = scls;
EXTRACTOR_KeywordType type;
const char * typename;
@@ -76,39 +76,39 @@
}
tmp = string_convertToUtf8(NULL,
- value,
- strlen(value),
+ value,
+ strlen(value),
#if ENABLE_NLS
- nl_langinfo(CODESET)
+ nl_langinfo(CODESET)
#else
- "utf-8"
+ "utf-8"
#endif
- );
+ );
type = EXTRACTOR_getHighestKeywordTypeNumber();
while (type > 0) {
type--;
typename = EXTRACTOR_getKeywordTypeAsString(type);
typename_i18n = dgettext("libextractor", typename);
if ( (strlen(tmp) >= strlen(typename)+1) &&
- (tmp[strlen(typename)] == ':') &&
- (0 == strncmp(typename,
- tmp,
- strlen(typename))) ) {
+ (tmp[strlen(typename)] == ':') &&
+ (0 == strncmp(typename,
+ tmp,
+ strlen(typename))) ) {
ECRS_addToMetaData(meta,
- type,
- &tmp[strlen(typename)+1]);
+ type,
+ &tmp[strlen(typename)+1]);
FREE(tmp);
tmp = NULL;
break;
}
if ( (strlen(tmp) >= strlen(typename_i18n)+1) &&
- (tmp[strlen(typename_i18n)] == ':') &&
- (0 == strncmp(typename_i18n,
- tmp,
- strlen(typename_i18n))) ) {
+ (tmp[strlen(typename_i18n)] == ':') &&
+ (0 == strncmp(typename_i18n,
+ tmp,
+ strlen(typename_i18n))) ) {
ECRS_addToMetaData(meta,
- type,
- &tmp[strlen(typename_i18n)+1]);
+ type,
+ &tmp[strlen(typename_i18n)+1]);
FREE(tmp);
tmp = NULL;
break;
@@ -116,11 +116,11 @@
}
if (tmp != NULL) {
ECRS_addToMetaData(meta,
- EXTRACTOR_UNKNOWN,
- tmp);
+ EXTRACTOR_UNKNOWN,
+ tmp);
FREE(tmp);
printf(_("Unknown metadata type in metadata option `%s'. Using metadata
type `unknown' instead.\n"),
- value);
+ value);
}
return OK;
}
Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/search.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -126,10 +126,10 @@
* Add a query to the SQC.
*/
static void addPS(unsigned int type,
- unsigned int keyCount,
- const HashCode512 * keys,
- const HashCode512 * dkey,
- SendQueriesContext * sqc) {
+ unsigned int keyCount,
+ const HashCode512 * keys,
+ const HashCode512 * dkey,
+ SendQueriesContext * sqc) {
PendingSearch * ps;
ps = MALLOC(sizeof(PendingSearch));
@@ -140,8 +140,8 @@
ps->keyCount = keyCount;
ps->keys = MALLOC(sizeof(HashCode512) * keyCount);
memcpy(ps->keys,
- keys,
- sizeof(HashCode512) * keyCount);
+ keys,
+ sizeof(HashCode512) * keyCount);
ps->decryptKey = *dkey;
ps->handle = NULL;
MUTEX_LOCK(sqc->lock);
@@ -157,31 +157,31 @@
* to the SQC.
*/
static void addQueryForURI(const struct ECRS_URI * uri,
- SendQueriesContext * sqc) {
+ SendQueriesContext * sqc) {
struct GE_Context * ectx = sqc->ectx;
switch (uri->type) {
case chk:
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("CHK URI not allowed for search.\n"));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("CHK URI not allowed for search.\n"));
break;
case sks: {
HashCode512 keys[2];
HashCode512 hk; /* hk = hash(identifier) */
hash(&uri->data.sks.identifier,
- sizeof(HashCode512),
- &hk);
+ sizeof(HashCode512),
+ &hk);
xorHashCodes(&hk,
- &uri->data.sks.namespace,
- &keys[0]); /* compute routing key r = H(identifier) ^
namespace */
+ &uri->data.sks.namespace,
+ &keys[0]); /* compute routing key r = H(identifier) ^ namespace */
keys[1] = uri->data.sks.namespace;
addPS(S_BLOCK,
- 2,
- &keys[0],
- &uri->data.sks.identifier, /* identifier = decryption key */
- sqc);
+ 2,
+ &keys[0],
+ &uri->data.sks.identifier, /* identifier = decryption key */
+ sqc);
break;
}
case ksk: {
@@ -193,37 +193,37 @@
#if DEBUG_SEARCH
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Computing queries (this may take a while).\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Computing queries (this may take a while).\n");
#endif
for (i=0;i<uri->data.ksk.keywordCount;i++) {
hash(uri->data.ksk.keywords[i],
- strlen(uri->data.ksk.keywords[i]),
- &hc);
+ strlen(uri->data.ksk.keywords[i]),
+ &hc);
pk = makeKblockKey(&hc);
getPublicKey(pk,
- &pub);
+ &pub);
hash(&pub,
- sizeof(PublicKey),
- &query);
+ sizeof(PublicKey),
+ &query);
addPS(ANY_BLOCK, /* K_BLOCK, N_BLOCK or KN_BLOCK ok */
- 1,
- &query,
- &hc,
- sqc);
+ 1,
+ &query,
+ &hc,
+ sqc);
freePrivateKey(pk);
- }
+ }
#if DEBUG_SEARCH
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Queries ready.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Queries ready.\n");
#endif
break;
}
case loc:
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("LOC URI not allowed for search.\n"));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("LOC URI not allowed for search.\n"));
break;
default:
GE_BREAK(ectx, 0);
@@ -243,30 +243,30 @@
* @param c the resulting current ID (set)
*/
static int computeIdAtTime(const SBlock * sb,
- TIME_T now,
- HashCode512 * c) {
+ TIME_T now,
+ HashCode512 * c) {
TIME_T pos;
HashCode512 tmp;
unsigned int iter;
if (ntohl(sb->updateInterval) == SBLOCK_UPDATE_SPORADIC) {
memcpy(c,
- &sb->nextIdentifier,
- sizeof(HashCode512));
+ &sb->nextIdentifier,
+ sizeof(HashCode512));
return OK;
}
if (ntohl(sb->updateInterval) == SBLOCK_UPDATE_NONE) {
/* H(N-I)^S is the current routing key, so N-I = k */
deltaId(&sb->identifierIncrement,
- &sb->nextIdentifier,
- c);
+ &sb->nextIdentifier,
+ c);
return OK;
}
GE_ASSERT(NULL, ntohl(sb->updateInterval) != 0);
pos = ntohl(sb->creationTime);
deltaId(&sb->identifierIncrement,
- &sb->nextIdentifier,
- c);
+ &sb->nextIdentifier,
+ c);
iter = (now - (pos + ntohl(sb->updateInterval))) / ntohl(sb->updateInterval);
if (iter > 0xFFFF)
@@ -275,8 +275,8 @@
while (pos + ntohl(sb->updateInterval) < now) {
pos += ntohl(sb->updateInterval);
addHashCodes(c,
- &sb->identifierIncrement,
- &tmp);
+ &sb->identifierIncrement,
+ &tmp);
*c = tmp;
}
return OK;
@@ -288,17 +288,17 @@
* namespace advertisement.
*/
static int processNBlock(const NBlock * nb,
- const HashCode512 * key,
- unsigned int size,
- SendQueriesContext * sqc) {
+ const HashCode512 * key,
+ unsigned int size,
+ SendQueriesContext * sqc) {
struct GE_Context * ectx = sqc->ectx;
ECRS_FileInfo fi;
struct ECRS_URI uri;
int ret;
fi.meta = ECRS_deserializeMetaData(ectx,
- (const char*)&nb[1],
- size - sizeof(NBlock));
+ (const char*)&nb[1],
+ size - sizeof(NBlock));
if (fi.meta == NULL) {
GE_BREAK(ectx, 0); /* nblock malformed */
return SYSERR;
@@ -325,8 +325,8 @@
* @return SYSERR if the entry is malformed
*/
static int receiveReplies(const HashCode512 * key,
- const Datastore_Value * value,
- SendQueriesContext * sqc) {
+ const Datastore_Value * value,
+ SendQueriesContext * sqc) {
struct GE_Context * ectx = sqc->ectx;
unsigned int type;
ECRS_FileInfo fi;
@@ -340,209 +340,209 @@
size = ntohl(value->size) - sizeof(Datastore_Value);
#if DEBUG_SEARCH
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Search received reply of type %u and size %u.\n",
- type, size);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Search received reply of type %u and size %u.\n",
+ type, size);
#endif
if (OK != getQueryFor(size,
- (const DBlock*) &value[1],
- YES,
- &query))
+ (const DBlock*) &value[1],
+ YES,
+ &query))
return SYSERR;
for (i=0;i<sqc->queryCount;i++) {
ps = sqc->queries[i];
if ( equalsHashCode512(&query,
- &ps->keys[0]) &&
- ( (ps->type == type) ||
- (ps->type == ANY_BLOCK) ) &&
- (YES == isDatumApplicable(type,
- size,
- (const DBlock*) &value[1],
- &query,
- ps->keyCount,
- ps->keys)) ) {
+ &ps->keys[0]) &&
+ ( (ps->type == type) ||
+ (ps->type == ANY_BLOCK) ) &&
+ (YES == isDatumApplicable(type,
+ size,
+ (const DBlock*) &value[1],
+ &query,
+ ps->keyCount,
+ ps->keys)) ) {
switch (type) {
case K_BLOCK: {
- KBlock * kb;
- const char * dstURI;
+ KBlock * kb;
+ const char * dstURI;
#if DEBUG_SEARCH
- EncName enc;
+ EncName enc;
#endif
- int j;
-
- if (size < sizeof(KBlock))
- return SYSERR;
- kb = MALLOC(size);
- memcpy(kb, &value[1], size);
+ int j;
+
+ if (size < sizeof(KBlock))
+ return SYSERR;
+ kb = MALLOC(size);
+ memcpy(kb, &value[1], size);
#if DEBUG_SEARCH
- IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&ps->decryptKey,
- &enc));
- GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Decrypting KBlock with key %s.\n",
- &enc);
+ IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&ps->decryptKey,
+ &enc));
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Decrypting KBlock with key %s.\n",
+ &enc);
#endif
- ECRS_decryptInPlace(&ps->decryptKey,
- &kb[1],
- size - sizeof(KBlock));
- j = sizeof(KBlock);
- while ( (j < size) &&
- (((const char*)kb)[j] != '\0') )
- j++;
- if (j == size) {
- GE_BREAK(ectx, 0); /* kblock malformed */
- FREE(kb);
- return SYSERR;
- }
- dstURI = (const char*) &kb[1];
- j++;
- fi.meta = ECRS_deserializeMetaData(ectx,
- &((const char*)kb)[j],
- size - j);
- if (fi.meta == NULL) {
- GE_BREAK(ectx, 0); /* kblock malformed */
- FREE(kb);
- return SYSERR;
- }
- fi.uri = ECRS_stringToUri(ectx,
- dstURI);
- if (fi.uri == NULL) {
- GE_BREAK(ectx, 0); /* kblock malformed */
- ECRS_freeMetaData(fi.meta);
- FREE(kb);
- return SYSERR;
- }
- if (sqc->spcb != NULL) {
- ret = sqc->spcb(&fi,
- &ps->decryptKey,
- NO,
- sqc->spcbClosure);
- if (ret == SYSERR)
- sqc->aborted = YES;
- } else
- ret = OK;
- ECRS_freeUri(fi.uri);
- ECRS_freeMetaData(fi.meta);
- FREE(kb);
- return ret;
+ ECRS_decryptInPlace(&ps->decryptKey,
+ &kb[1],
+ size - sizeof(KBlock));
+ j = sizeof(KBlock);
+ while ( (j < size) &&
+ (((const char*)kb)[j] != '\0') )
+ j++;
+ if (j == size) {
+ GE_BREAK(ectx, 0); /* kblock malformed */
+ FREE(kb);
+ return SYSERR;
+ }
+ dstURI = (const char*) &kb[1];
+ j++;
+ fi.meta = ECRS_deserializeMetaData(ectx,
+ &((const char*)kb)[j],
+ size - j);
+ if (fi.meta == NULL) {
+ GE_BREAK(ectx, 0); /* kblock malformed */
+ FREE(kb);
+ return SYSERR;
+ }
+ fi.uri = ECRS_stringToUri(ectx,
+ dstURI);
+ if (fi.uri == NULL) {
+ GE_BREAK(ectx, 0); /* kblock malformed */
+ ECRS_freeMetaData(fi.meta);
+ FREE(kb);
+ return SYSERR;
+ }
+ if (sqc->spcb != NULL) {
+ ret = sqc->spcb(&fi,
+ &ps->decryptKey,
+ NO,
+ sqc->spcbClosure);
+ if (ret == SYSERR)
+ sqc->aborted = YES;
+ } else
+ ret = OK;
+ ECRS_freeUri(fi.uri);
+ ECRS_freeMetaData(fi.meta);
+ FREE(kb);
+ return ret;
}
case N_BLOCK: {
- const NBlock * nb;
-
- if (size < sizeof(NBlock))
- return SYSERR;
- nb = (const NBlock*) &value[1];
- return processNBlock(nb,
- NULL,
- size,
- sqc);
+ const NBlock * nb;
+
+ if (size < sizeof(NBlock))
+ return SYSERR;
+ nb = (const NBlock*) &value[1];
+ return processNBlock(nb,
+ NULL,
+ size,
+ sqc);
}
case KN_BLOCK: {
- KNBlock * kb;
- int ret;
-
- if (size < sizeof(KNBlock))
- return SYSERR;
- kb = MALLOC(size);
- memcpy(kb, &value[1], size);
- ECRS_decryptInPlace(&ps->decryptKey,
- &kb->nblock,
- size - sizeof(KBlock) - sizeof(unsigned int));
- ret = processNBlock(&kb->nblock,
- &ps->decryptKey,
- size - sizeof(KNBlock) + sizeof(NBlock),
- sqc);
- FREE(kb);
- return ret;
+ KNBlock * kb;
+ int ret;
+
+ if (size < sizeof(KNBlock))
+ return SYSERR;
+ kb = MALLOC(size);
+ memcpy(kb, &value[1], size);
+ ECRS_decryptInPlace(&ps->decryptKey,
+ &kb->nblock,
+ size - sizeof(KBlock) - sizeof(unsigned int));
+ ret = processNBlock(&kb->nblock,
+ &ps->decryptKey,
+ size - sizeof(KNBlock) + sizeof(NBlock),
+ sqc);
+ FREE(kb);
+ return ret;
}
case S_BLOCK: {
- SBlock * sb;
- const char * dstURI;
- int j;
- TIME_T now;
- HashCode512 updateId;
- URI updateURI;
-
- if (size < sizeof(SBlock))
- return SYSERR;
- sb = MALLOC(size);
- memcpy(sb, &value[1], size);
- ECRS_decryptInPlace(&ps->decryptKey,
- &sb->creationTime,
- size
- - sizeof(unsigned int)
- - sizeof(Signature)
- - sizeof(PublicKey)
- - sizeof(HashCode512));
- j = 0;
- dstURI = (const char*) &sb[1];
- while ( (j < size - sizeof(SBlock)) &&
- (dstURI[j] != '\0') )
- j++;
- if (j == size - sizeof(SBlock)) {
- GE_BREAK(ectx, 0); /* sblock malformed */
- FREE(sb);
- return SYSERR;
- }
- j++;
- /* j == strlen(dstURI) + 1 */
- fi.meta = ECRS_deserializeMetaData(ectx,
- &dstURI[j],
- size - j - sizeof(SBlock));
- if (fi.meta == NULL) {
- GE_BREAK(ectx, 0); /* sblock malformed */
- FREE(sb);
- return SYSERR;
- }
- fi.uri = ECRS_stringToUri(ectx,
- dstURI);
- if (fi.uri == NULL) {
- GE_BREAK(ectx, 0); /* sblock malformed */
- ECRS_freeMetaData(fi.meta);
- FREE(sb);
- return SYSERR;
- }
- if (sqc->spcb != NULL) {
- ret = sqc->spcb(&fi, NULL, NO, sqc->spcbClosure);
- if (ret == SYSERR)
- sqc->aborted = YES;
- } else
- ret = OK;
- ECRS_freeUri(fi.uri);
- ECRS_freeMetaData(fi.meta);
+ SBlock * sb;
+ const char * dstURI;
+ int j;
+ TIME_T now;
+ HashCode512 updateId;
+ URI updateURI;
+
+ if (size < sizeof(SBlock))
+ return SYSERR;
+ sb = MALLOC(size);
+ memcpy(sb, &value[1], size);
+ ECRS_decryptInPlace(&ps->decryptKey,
+ &sb->creationTime,
+ size
+ - sizeof(unsigned int)
+ - sizeof(Signature)
+ - sizeof(PublicKey)
+ - sizeof(HashCode512));
+ j = 0;
+ dstURI = (const char*) &sb[1];
+ while ( (j < size - sizeof(SBlock)) &&
+ (dstURI[j] != '\0') )
+ j++;
+ if (j == size - sizeof(SBlock)) {
+ GE_BREAK(ectx, 0); /* sblock malformed */
+ FREE(sb);
+ return SYSERR;
+ }
+ j++;
+ /* j == strlen(dstURI) + 1 */
+ fi.meta = ECRS_deserializeMetaData(ectx,
+ &dstURI[j],
+ size - j - sizeof(SBlock));
+ if (fi.meta == NULL) {
+ GE_BREAK(ectx, 0); /* sblock malformed */
+ FREE(sb);
+ return SYSERR;
+ }
+ fi.uri = ECRS_stringToUri(ectx,
+ dstURI);
+ if (fi.uri == NULL) {
+ GE_BREAK(ectx, 0); /* sblock malformed */
+ ECRS_freeMetaData(fi.meta);
+ FREE(sb);
+ return SYSERR;
+ }
+ if (sqc->spcb != NULL) {
+ ret = sqc->spcb(&fi, NULL, NO, sqc->spcbClosure);
+ if (ret == SYSERR)
+ sqc->aborted = YES;
+ } else
+ ret = OK;
+ ECRS_freeUri(fi.uri);
+ ECRS_freeMetaData(fi.meta);
- /* compute current/NEXT URI (if updateable SBlock) and issue
- respective query automatically! */
- TIME(&now);
- if (OK != computeIdAtTime(sb,
- now,
- &updateId)) {
- FREE(sb);
- return SYSERR;
- }
- if (equalsHashCode512(&updateId,
- &ps->decryptKey)) {
- FREE(sb);
- return ret; /* have latest version */
- }
- if (ps->keyCount != 2) {
- GE_BREAK(ectx, 0);
- FREE(sb);
- return SYSERR;
- }
+ /* compute current/NEXT URI (if updateable SBlock) and issue
+ respective query automatically! */
+ TIME(&now);
+ if (OK != computeIdAtTime(sb,
+ now,
+ &updateId)) {
+ FREE(sb);
+ return SYSERR;
+ }
+ if (equalsHashCode512(&updateId,
+ &ps->decryptKey)) {
+ FREE(sb);
+ return ret; /* have latest version */
+ }
+ if (ps->keyCount != 2) {
+ GE_BREAK(ectx, 0);
+ FREE(sb);
+ return SYSERR;
+ }
- updateURI.type = sks;
- updateURI.data.sks.namespace = ps->keys[1];
- updateURI.data.sks.identifier = updateId;
- addQueryForURI(&updateURI,
- sqc);
- FREE(sb);
- return ret;
+ updateURI.type = sks;
+ updateURI.data.sks.namespace = ps->keys[1];
+ updateURI.data.sks.identifier = updateId;
+ addQueryForURI(&updateURI,
+ sqc);
+ FREE(sb);
+ return ret;
}
default:
- GE_BREAK(ectx, 0);
- break;
+ GE_BREAK(ectx, 0);
+ break;
} /* end switch */
} /* for all matches */
} /* for all pending queries */
@@ -558,14 +558,14 @@
* @param uri set to the URI of the uploaded file
*/
int ECRS_search(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const struct ECRS_URI * uri,
- unsigned int anonymityLevel,
- cron_t timeout,
- ECRS_SearchProgressCallback spcb,
- void * spcbClosure,
- ECRS_TestTerminate tt,
- void * ttClosure) {
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri,
+ unsigned int anonymityLevel,
+ cron_t timeout,
+ ECRS_SearchProgressCallback spcb,
+ void * spcbClosure,
+ ECRS_TestTerminate tt,
+ void * ttClosure) {
SendQueriesContext ctx;
PendingSearch * ps;
int i;
@@ -587,66 +587,66 @@
ctx.aborted = NO;
ctx.lock = MUTEX_CREATE(YES);
ctx.sctx = FS_SEARCH_makeContext(ectx,
- cfg,
- ctx.lock);
+ cfg,
+ ctx.lock);
addQueryForURI(uri,
- &ctx);
+ &ctx);
while ( ( (NULL == tt) ||
- (OK == tt(ttClosure)) ) &&
- (NO == GNUNET_SHUTDOWN_TEST()) &&
- (timeout > now) &&
- (ctx.aborted == NO) ) {
+ (OK == tt(ttClosure)) ) &&
+ (NO == GNUNET_SHUTDOWN_TEST()) &&
+ (timeout > now) &&
+ (ctx.aborted == NO) ) {
remTime = timeout - now;
MUTEX_LOCK(ctx.lock);
for (i=0;i<ctx.queryCount;i++) {
ps = ctx.queries[i];
if ( (now < ps->timeout) &&
- (ps->timeout != 0) )
- continue;
+ (ps->timeout != 0) )
+ continue;
if (ps->handle != NULL)
- FS_stop_search(ctx.sctx,
- ps->handle);
+ FS_stop_search(ctx.sctx,
+ ps->handle);
/* increase ttl/priority */
new_ttl = ps->timeout - ps->lastTransmission;
if (new_ttl < 4 * 5 * cronSECONDS)
- new_ttl = 4 * 5 * cronSECONDS + weak_randomi(5 * cronSECONDS);
+ new_ttl = 4 * 5 * cronSECONDS + weak_randomi(5 * cronSECONDS);
new_ttl = new_ttl + weak_randomi(5 * cronSECONDS + 2 * new_ttl);
if (new_ttl > 0xFFFFFF)
- new_ttl = weak_randomi(0xFFFFFF); /* if we get to large, reduce! */
+ new_ttl = weak_randomi(0xFFFFFF); /* if we get to large, reduce! */
if (remTime < new_ttl)
- new_ttl = remTime;
+ new_ttl = remTime;
ps->timeout = new_ttl + now;
new_priority = ps->priority;
new_priority = new_priority + weak_randomi(4 + 2 * new_priority);
if (new_priority > 0xFFFFFF)
- new_priority = weak_randomi(0xFFFFFF); /* if we get to large, reduce! */
+ new_priority = weak_randomi(0xFFFFFF); /* if we get to large, reduce! */
ps->priority = new_priority;
ps->lastTransmission = now;
#if DEBUG_SEARCH
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "ECRS initiating FS search with timeout %llus and priority %u.\n",
- (ps->timeout - now) / cronSECONDS,
- ps->priority);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "ECRS initiating FS search with timeout %llus and priority %u.\n",
+ (ps->timeout - now) / cronSECONDS,
+ ps->priority);
#endif
ps->handle
- = FS_start_search(ctx.sctx,
- NULL,
- ps->type,
- ps->keyCount,
- ps->keys,
- anonymityLevel,
- ps->priority,
- ps->timeout,
- (Datum_Iterator) &receiveReplies,
- &ctx);
+ = FS_start_search(ctx.sctx,
+ NULL,
+ ps->type,
+ ps->keyCount,
+ ps->keys,
+ anonymityLevel,
+ ps->priority,
+ ps->timeout,
+ (Datum_Iterator) &receiveReplies,
+ &ctx);
}
MUTEX_UNLOCK(ctx.lock);
if ( ( (NULL != tt) &&
- (OK != tt(ttClosure))) ||
- (timeout <= now) ||
- (ctx.aborted != NO) )
+ (OK != tt(ttClosure))) ||
+ (timeout <= now) ||
+ (ctx.aborted != NO) )
break;
PTHREAD_SLEEP(100 * cronMILLIS);
now = get_time();
@@ -654,7 +654,7 @@
for (i=0;i<ctx.queryCount;i++) {
if (ctx.queries[i]->handle != NULL)
FS_stop_search(ctx.sctx,
- ctx.queries[i]->handle);
+ ctx.queries[i]->handle);
FREE(ctx.queries[i]->keys);
FREE(ctx.queries[i]);
}
Modified: GNUnet/src/applications/fs/ecrs/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/searchtest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/ecrs/searchtest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -40,16 +40,16 @@
static struct GC_Configuration * cfg;
static int searchCB(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * closure) {
+ const HashCode512 * key,
+ int isRoot,
+ void * closure) {
int * cnt = closure;
#if 1
char * st;
st = ECRS_uriToString(fi->uri);
printf("Got result `%s'\n",
- st);
+ st);
FREE(st);
#endif
(*cnt)--;
@@ -63,16 +63,16 @@
* @return OK on success, SYSERR on error
*/
static int searchFile(const struct ECRS_URI * uri,
- int resultCount) {
+ int resultCount) {
ECRS_search(NULL,
- cfg,
- uri,
- 0,
- 60 * 15 * cronSECONDS,
- &searchCB,
- &resultCount,
- &testTerminate,
- NULL);
+ cfg,
+ uri,
+ 0,
+ 60 * 15 * cronSECONDS,
+ &searchCB,
+ &resultCount,
+ &testTerminate,
+ NULL);
if (resultCount > 0)
return SYSERR;
return OK;
@@ -90,19 +90,19 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
sock = NULL;
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS));
+ cfg,
+ 30 * cronSECONDS));
ok = YES;
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
sock = client_connection_create(NULL, cfg);
@@ -113,22 +113,22 @@
printf("Testing search for 'XXtest' with one result.\n");
#endif
uri = ECRS_stringToUri(NULL,
-
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test");
+
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test");
meta = ECRS_createMetaData();
keywords[0] = "XXtest";
keywords[1] = NULL;
key = ECRS_keywordsToUri(keywords);
CHECK(OK == ECRS_addToKeyspace(NULL,
- cfg,
- key,
- 0,
- 0,
- get_time() + 10 * cronMINUTES, /* expire */
- uri,
- meta));
+ cfg,
+ key,
+ 0,
+ 0,
+ get_time() + 10 * cronMINUTES, /* expire */
+ uri,
+ meta));
CHECK(OK == searchFile(key,
- 1));
+ 1));
ECRS_freeUri(key);
ECRS_freeUri(uri);
@@ -138,20 +138,20 @@
printf("Testing search for 'XXtest AND binary' with two results.\n");
#endif
uri = ECRS_stringToUri(NULL,
-
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test-different");
+
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test-different");
keywords[1] = "binary";
keywords[2] = NULL;
key = ECRS_keywordsToUri(keywords);
CHECK(OK == ECRS_addToKeyspace(NULL,
- cfg,
- key,
- 0,
- 0,
- get_time() + 10 * cronMINUTES, /* expire */
- uri,
- meta));
+ cfg,
+ key,
+ 0,
+ 0,
+ get_time() + 10 * cronMINUTES, /* expire */
+ uri,
+ meta));
CHECK(OK == searchFile(key,
- 2));
+ 2));
ECRS_freeUri(key);
ECRS_freeUri(uri);
ECRS_freeMetaData(meta);
@@ -163,7 +163,7 @@
keywords[1] = NULL;
key = ECRS_keywordsToUri(keywords);
CHECK(OK == searchFile(key,
- 2));
+ 2));
ECRS_freeUri(key);
/* END OF TEST CODE */
Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/unindex.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -53,9 +53,9 @@
* FS_delete as argument!).
*/
static int pushBlock(struct ClientServerConnection * sock,
- const CHK * chk,
- unsigned int level,
- Datastore_Value ** iblocks) {
+ const CHK * chk,
+ unsigned int level,
+ Datastore_Value ** iblocks) {
unsigned int size;
unsigned int present;
Datastore_Value * value;
@@ -67,43 +67,43 @@
db = (DBlock*) &iblocks[level][1];
if (present == CHK_PER_INODE) {
fileBlockGetKey(db,
- size,
- &ichk.key);
+ size,
+ &ichk.key);
fileBlockGetQuery(db,
- size,
- &ichk.query);
+ size,
+ &ichk.query);
if (OK != pushBlock(sock,
- &ichk,
- level+1,
- iblocks)) {
+ &ichk,
+ level+1,
+ iblocks)) {
GE_BREAK(NULL, 0);
return SYSERR;
}
fileBlockEncode(db,
- size,
- &ichk.query,
- &value);
+ size,
+ &ichk.query,
+ &value);
#if STRICT_CHECKS
if (SYSERR == FS_delete(sock,
- value)) {
+ value)) {
FREE(value);
GE_BREAK(NULL, 0);
return SYSERR;
}
#else
FS_delete(sock,
- value);
+ value);
#endif
FREE(value);
size = sizeof(DBlock);
}
/* append CHK */
memcpy(&((char*)db)[size],
- chk,
- sizeof(CHK));
+ chk,
+ sizeof(CHK));
iblocks[level]->size = htonl(size +
- sizeof(CHK) +
- sizeof(Datastore_Value));
+ sizeof(CHK) +
+ sizeof(Datastore_Value));
return OK;
}
@@ -115,9 +115,9 @@
* b) delete symbolic link
*/
static int undoSymlinking(struct GE_Context * ectx,
- const char * fn,
- const HashCode512 * fileId,
- struct ClientServerConnection * sock) {
+ const char * fn,
+ const HashCode512 * fileId,
+ struct ClientServerConnection * sock) {
EncName enc;
char * serverDir;
char * serverFN;
@@ -128,11 +128,11 @@
return OK; /* symlinks do not exist? */
#endif
if (0 != LSTAT(fn,
- &buf)) {
+ &buf)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_BULK | GE_USER | GE_ADMIN,
- "stat",
- fn);
+ GE_ERROR | GE_BULK | GE_USER | GE_ADMIN,
+ "stat",
+ fn);
return SYSERR;
}
#ifdef S_ISLNK
@@ -141,27 +141,27 @@
#endif
serverDir
= getConfigurationOptionValue(sock,
- "FS",
- "INDEX-DIRECTORY");
+ "FS",
+ "INDEX-DIRECTORY");
if (serverDir == NULL)
return OK;
serverFN = MALLOC(strlen(serverDir) + 2 + sizeof(EncName));
strcpy(serverFN,
- serverDir);
+ serverDir);
FREE(serverDir);
if (serverFN[strlen(serverFN)-1] != DIR_SEPARATOR)
strcat(serverFN,
- DIR_SEPARATOR_STR);
+ DIR_SEPARATOR_STR);
hash2enc(fileId,
- &enc);
+ &enc);
strcat(serverFN,
- (char*)&enc);
+ (char*)&enc);
if (0 != UNLINK(serverFN)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_BULK | GE_USER | GE_ADMIN,
- "unlink",
- serverFN);
+ GE_ERROR | GE_BULK | GE_USER | GE_ADMIN,
+ "unlink",
+ serverFN);
FREE(serverFN);
return SYSERR;
}
@@ -177,12 +177,12 @@
* @return SYSERR if the unindexing failed (i.e. not indexed)
*/
int ECRS_unindexFile(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * filename,
- ECRS_UploadProgressCallback upcb,
- void * upcbClosure,
- ECRS_TestTerminate tt,
- void * ttClosure) {
+ struct GC_Configuration * cfg,
+ const char * filename,
+ ECRS_UploadProgressCallback upcb,
+ void * upcbClosure,
+ ECRS_TestTerminate tt,
+ void * ttClosure) {
unsigned long long filesize;
unsigned long long pos;
unsigned int treedepth;
@@ -203,14 +203,14 @@
start = get_time();
if (YES != disk_file_test(ectx,
- filename)) {
+ filename)) {
GE_BREAK(ectx, 0);
return SYSERR;
}
if (OK != disk_file_size(ectx,
- filename,
- &filesize,
- YES))
+ filename,
+ &filesize,
+ YES))
return SYSERR;
sock = client_connection_create(ectx, cfg);
if (sock == NULL)
@@ -219,8 +219,8 @@
if (upcb != NULL)
upcb(filesize, 0, eta, upcbClosure);
if (SYSERR == getFileHash(ectx,
- filename,
- &fileId)) {
+ filename,
+ &fileId)) {
connection_destroy(sock);
GE_BREAK(ectx, 0);
return SYSERR;
@@ -239,11 +239,11 @@
/* Test if file is indexed! */
wasIndexed
= FS_testIndexed(sock,
- &fileId);
+ &fileId);
fd = disk_file_open(ectx,
- filename,
- O_RDONLY | O_LARGEFILE);
+ filename,
+ O_RDONLY | O_LARGEFILE);
if (fd == -1)
return SYSERR;
dblock = MALLOC(sizeof(Datastore_Value) + DBLOCK_SIZE + sizeof(DBlock));
@@ -271,68 +271,68 @@
upcb(filesize, pos, eta, upcbClosure);
if (tt != NULL)
if (OK != tt(ttClosure))
- goto FAILURE;
+ goto FAILURE;
size = DBLOCK_SIZE;
if (size > filesize - pos) {
size = filesize - pos;
memset(&db[1],
- 0,
- DBLOCK_SIZE);
+ 0,
+ DBLOCK_SIZE);
}
dblock->size = htonl(sizeof(Datastore_Value) + size + sizeof(DBlock));
if (size != READ(fd,
- &db[1],
- size)) {
+ &db[1],
+ size)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "READ",
- filename);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "READ",
+ filename);
goto FAILURE;
}
if (tt != NULL)
if (OK != tt(ttClosure))
- goto FAILURE;
+ goto FAILURE;
fileBlockGetKey(db,
- size + sizeof(DBlock),
- &chk.key);
+ size + sizeof(DBlock),
+ &chk.key);
fileBlockGetQuery(db,
- size + sizeof(DBlock),
- &chk.query);
+ size + sizeof(DBlock),
+ &chk.query);
if (OK != pushBlock(sock,
- &chk,
- 0, /* dblocks are on level 0 */
- iblocks)) {
+ &chk,
+ 0, /* dblocks are on level 0 */
+ iblocks)) {
GE_BREAK(ectx, 0);
goto FAILURE;
}
if (! wasIndexed) {
if (OK ==
- fileBlockEncode(db,
- size,
- &chk.query,
- &value)) {
- *value = *dblock; /* copy options! */
+ fileBlockEncode(db,
+ size,
+ &chk.query,
+ &value)) {
+ *value = *dblock; /* copy options! */
#if STRICT_CHECKS
- if (OK != FS_delete(sock,
- value)) {
- FREE(value);
- GE_BREAK(ectx, 0);
- goto FAILURE;
- }
+ if (OK != FS_delete(sock,
+ value)) {
+ FREE(value);
+ GE_BREAK(ectx, 0);
+ goto FAILURE;
+ }
#else
- FS_delete(sock,
- value);
+ FS_delete(sock,
+ value);
#endif
- FREE(value);
+ FREE(value);
} else {
- goto FAILURE;
+ goto FAILURE;
}
}
pos += size;
now = get_time();
eta = (cron_t) (start +
- (((double)(now - start)/(double)pos))
- * (double)filesize);
+ (((double)(now - start)/(double)pos))
+ * (double)filesize);
}
if (tt != NULL)
if (OK != tt(ttClosure))
@@ -341,32 +341,32 @@
size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
db = (DBlock*) &iblocks[i][1];
fileBlockGetKey(db,
- size,
- &chk.key);
+ size,
+ &chk.key);
fileBlockGetQuery(db,
- size,
- &chk.query);
+ size,
+ &chk.query);
if (OK != pushBlock(sock,
- &chk,
- i+1,
- iblocks)) {
+ &chk,
+ i+1,
+ iblocks)) {
GE_BREAK(ectx, 0);
goto FAILURE;
}
fileBlockEncode(db,
- size,
- &chk.query,
- &value);
+ size,
+ &chk.query,
+ &value);
#if STRICT_CHECKS
if (OK != FS_delete(sock,
- value)) {
+ value)) {
FREE(value);
GE_BREAK(ectx, 0);
goto FAILURE;
}
#else
FS_delete(sock,
- value);
+ value);
#endif
FREE(value);
FREE(iblocks[i]);
@@ -375,14 +375,14 @@
if (wasIndexed) {
if (OK == undoSymlinking(ectx,
- filename,
- &fileId,
- sock)) {
+ filename,
+ &fileId,
+ sock)) {
if (OK != FS_unindex(sock,
- DBLOCK_SIZE,
- &fileId)) {
- GE_BREAK(ectx, 0);
- goto FAILURE;
+ DBLOCK_SIZE,
+ &fileId)) {
+ GE_BREAK(ectx, 0);
+ goto FAILURE;
}
} else {
GE_BREAK(ectx, 0);
Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/upload.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -50,8 +50,8 @@
const CHK * chk,
unsigned int level,
Datastore_Value ** iblocks,
- unsigned int prio,
- cron_t expirationTime) {
+ unsigned int prio,
+ cron_t expirationTime) {
unsigned int size;
unsigned int present;
Datastore_Value * value;
@@ -78,8 +78,8 @@
&ichk,
level+1,
iblocks,
- prio,
- expirationTime))
+ prio,
+ expirationTime))
return SYSERR;
fileBlockEncode(db,
size,
@@ -122,8 +122,8 @@
* or gnunetd not running)
*/
int ECRS_uploadFile(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * filename,
+ struct GC_Configuration * cfg,
+ const char * filename,
int doIndex,
unsigned int anonymityLevel,
unsigned int priority,
@@ -158,29 +158,29 @@
start = get_time();
memset(&mchk, 0, sizeof(CHK));
if (YES != disk_file_test(ectx,
- filename)) {
+ filename)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' is not a file.\n"),
- filename);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' is not a file.\n"),
+ filename);
return SYSERR;
}
if (OK != disk_file_size(ectx,
- filename,
- &filesize,
- YES)) {
+ filename,
+ &filesize,
+ YES)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Cannot get size of file `%s'"),
- filename);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Cannot get size of file `%s'"),
+ filename);
return SYSERR;
}
sock = client_connection_create(ectx, cfg);
if (sock == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Failed to connect to gnunetd."));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Failed to connect to gnunetd."));
return SYSERR;
}
eta = 0;
@@ -188,12 +188,12 @@
upcb(filesize, 0, eta, upcbClosure);
if (doIndex) {
if (SYSERR == getFileHash(ectx,
- filename,
+ filename,
&fileId)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Cannot hash `%s'.\n"),
- filename);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Cannot hash `%s'.\n"),
+ filename);
connection_destroy(sock);
return SYSERR;
}
@@ -210,16 +210,16 @@
switch (FS_initIndex(sock, &fileId, filename)) {
case SYSERR:
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Initialization for indexing file `%s' failed.\n"),
- filename);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Initialization for indexing file `%s' failed.\n"),
+ filename);
connection_destroy(sock);
return SYSERR;
case NO:
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Indexing file `%s' failed. Trying to insert file...\n"),
- filename);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Indexing file `%s' failed. Trying to insert file...\n"),
+ filename);
doIndex = YES;
break;
default:
@@ -228,8 +228,8 @@
}
treedepth = computeDepth(filesize);
fd = disk_file_open(ectx,
- filename,
- O_RDONLY | O_LARGEFILE);
+ filename,
+ O_RDONLY | O_LARGEFILE);
if (fd == -1) {
GE_LOG(ectx,
GE_ERROR | GE_BULK | GE_USER,
@@ -275,15 +275,15 @@
DBLOCK_SIZE);
}
GE_ASSERT(ectx,
- sizeof(Datastore_Value) + size + sizeof(DBlock) <
MAX_BUFFER_SIZE);
+ sizeof(Datastore_Value) + size + sizeof(DBlock) < MAX_BUFFER_SIZE);
dblock->size = htonl(sizeof(Datastore_Value) + size + sizeof(DBlock));
if (size != READ(fd,
&db[1],
size)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_BULK | GE_ADMIN | GE_USER,
- "READ",
- filename);
+ GE_ERROR | GE_BULK | GE_ADMIN | GE_USER,
+ "READ",
+ filename);
goto FAILURE;
}
if (tt != NULL)
@@ -297,24 +297,24 @@
&mchk.query);
#if DEBUG_UPLOAD
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&mchk.query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&mchk.query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Query for current block of size %u is %s\n",
- size,
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Query for current block of size %u is %s\n",
+ size,
+ &enc);
#endif
if (doIndex) {
if (SYSERR == FS_index(sock,
&fileId,
dblock,
pos)) {
- GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Indexing data failed at position %i.\n"), pos);
- goto FAILURE;
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Indexing data failed at position %i.\n"), pos);
+ goto FAILURE;
}
} else {
value = NULL;
@@ -348,8 +348,8 @@
&mchk,
0, /* dblocks are on level 0 */
iblocks,
- priority,
- expirationTime)) {
+ priority,
+ expirationTime)) {
GE_BREAK(ectx, 0);
goto FAILURE;
}
@@ -359,9 +359,9 @@
goto FAILURE;
#if DEBUG_UPLOAD
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Tree depth is %u, walking up tree.\n",
- treedepth);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Tree depth is %u, walking up tree.\n",
+ treedepth);
#endif
for (i=0;i<treedepth;i++) {
size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
@@ -369,9 +369,9 @@
if (size == sizeof(DBlock)) {
#if DEBUG_UPLOAD
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Level %u is empty\n",
- i);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Level %u is empty\n",
+ i);
#endif
continue;
}
@@ -381,30 +381,30 @@
&mchk.key);
#if DEBUG_UPLOAD
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Computing query for %u bytes content.\n",
- size);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Computing query for %u bytes content.\n",
+ size);
#endif
fileBlockGetQuery(db,
size,
&mchk.query);
#if DEBUG_UPLOAD
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&mchk.query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&mchk.query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Query for current block at level %u is `%s'.\n",
- i,
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Query for current block at level %u is `%s'.\n",
+ i,
+ &enc);
#endif
if (OK != pushBlock(sock,
&mchk,
i+1,
iblocks,
- priority,
- expirationTime)) {
+ priority,
+ expirationTime)) {
GE_BREAK(ectx, 0);
goto FAILURE;
}
@@ -419,7 +419,7 @@
value->expirationTime = htonll(expirationTime);
value->prio = htonl(priority);
if (SYSERR == FS_insert(sock,
- value)) {
+ value)) {
GE_BREAK(ectx, 0);
FREE(value);
goto FAILURE;
@@ -430,9 +430,9 @@
}
#if DEBUG_UPLOAD
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&mchk.query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&mchk.query,
+ &enc));
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
"Query for top block is %s\n",
&enc);
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -91,7 +91,7 @@
*/
static char *
createKeywordURI(char ** keywords,
- unsigned int keywordCount) {
+ unsigned int keywordCount) {
size_t n;
char * ret;
unsigned int i;
@@ -115,7 +115,7 @@
*/
static char *
createSubspaceURI(const HashCode512 * namespace,
- const HashCode512 * identifier) {
+ const HashCode512 * identifier) {
size_t n;
char * ret;
EncName ns;
@@ -126,11 +126,11 @@
hash2enc(namespace, &ns);
hash2enc(identifier, &id);
SNPRINTF(ret, n,
- "%s%s%s/%s",
- ECRS_URI_PREFIX,
- ECRS_SUBSPACE_INFIX,
- (char*) &ns,
- (char*) &id);
+ "%s%s%s/%s",
+ ECRS_URI_PREFIX,
+ ECRS_SUBSPACE_INFIX,
+ (char*) &ns,
+ (char*) &id);
return ret;
}
@@ -152,13 +152,13 @@
n =
strlen(ECRS_URI_PREFIX)+2*sizeof(EncName)+8+16+32+strlen(ECRS_FILE_INFIX);
ret = MALLOC(n);
SNPRINTF(ret,
- n,
- "%s%s%s.%s.%llu",
- ECRS_URI_PREFIX,
- ECRS_FILE_INFIX,
- (char*)&keyhash,
- (char*)&queryhash,
- ntohll(fi->file_length));
+ n,
+ "%s%s%s.%s.%llu",
+ ECRS_URI_PREFIX,
+ ECRS_FILE_INFIX,
+ (char*)&keyhash,
+ (char*)&queryhash,
+ ntohll(fi->file_length));
return ret;
}
@@ -182,21 +182,21 @@
&queryhash);
n = 2148;
peerId = bin2enc(&loc->peer,
- sizeof(PublicKey));
+ sizeof(PublicKey));
peerSig = bin2enc(&loc->contentSignature,
- sizeof(Signature));
+ sizeof(Signature));
ret = MALLOC(n);
SNPRINTF(ret,
- n,
- "%s%s%s.%s.%llu.%s.%s.%u",
- ECRS_URI_PREFIX,
- ECRS_LOCATION_INFIX,
- (char*)&keyhash,
- (char*)&queryhash,
- ntohll(loc->fi.file_length),
- peerId,
- peerSig,
- loc->expirationTime);
+ n,
+ "%s%s%s.%s.%llu.%s.%s.%u",
+ ECRS_URI_PREFIX,
+ ECRS_LOCATION_INFIX,
+ (char*)&keyhash,
+ (char*)&queryhash,
+ ntohll(loc->fi.file_length),
+ peerId,
+ peerSig,
+ loc->expirationTime);
FREE(peerSig);
FREE(peerId);
return ret;
@@ -213,10 +213,10 @@
switch (uri->type) {
case ksk:
return createKeywordURI(uri->data.ksk.keywords,
- uri->data.ksk.keywordCount);
+ uri->data.ksk.keywordCount);
case sks:
return createSubspaceURI(&uri->data.sks.namespace,
- &uri->data.sks.identifier);
+ &uri->data.sks.identifier);
case chk:
return createFileURI(&uri->data.fi);
case loc:
@@ -236,8 +236,8 @@
* the number of keywords placed in the array
*/
static int parseKeywordURI(struct GE_Context * ectx,
- const char * uri,
- char *** keywords) {
+ const char * uri,
+ char *** keywords) {
unsigned int pos;
int ret;
int iret;
@@ -251,12 +251,12 @@
pos = strlen(ECRS_URI_PREFIX);
if (0 != strncmp(uri,
- ECRS_URI_PREFIX,
- pos))
+ ECRS_URI_PREFIX,
+ pos))
return SYSERR;
if (0 != strncmp(&uri[pos],
- ECRS_SEARCH_INFIX,
- strlen(ECRS_SEARCH_INFIX)))
+ ECRS_SEARCH_INFIX,
+ strlen(ECRS_SEARCH_INFIX)))
return SYSERR;
pos += strlen(ECRS_SEARCH_INFIX);
if (slen == pos) {
@@ -273,7 +273,7 @@
if (uri[i] == '+') {
ret++;
if (uri[i-1] == '+')
- return SYSERR; /* "++" not allowed */
+ return SYSERR; /* "++" not allowed */
}
}
iret = ret;
@@ -300,9 +300,9 @@
* @return OK on success, SYSERR if this is not a namespace URI
*/
static int parseSubspaceURI(struct GE_Context * ectx,
- const char * uri,
- HashCode512 * namespace,
- HashCode512 * identifier) {
+ const char * uri,
+ HashCode512 * namespace,
+ HashCode512 * identifier) {
unsigned int pos;
size_t slen;
char * up;
@@ -313,34 +313,34 @@
pos = strlen(ECRS_URI_PREFIX);
if (0 != strncmp(uri,
- ECRS_URI_PREFIX,
- pos))
+ ECRS_URI_PREFIX,
+ pos))
return SYSERR;
if (0 != strncmp(&uri[pos],
- ECRS_SUBSPACE_INFIX,
- strlen(ECRS_SUBSPACE_INFIX)))
+ ECRS_SUBSPACE_INFIX,
+ strlen(ECRS_SUBSPACE_INFIX)))
return SYSERR;
pos += strlen(ECRS_SUBSPACE_INFIX);
if ( (slen < pos+sizeof(EncName)+1) ||
(! ( (uri[pos+sizeof(EncName)-1] == '/') ||
- (uri[pos+sizeof(EncName)-1] == '\\') ) ) )
+ (uri[pos+sizeof(EncName)-1] == '\\') ) ) )
return SYSERR;
up = STRDUP(uri);
up[pos+sizeof(EncName)-1] = '\0';
if ( (OK != enc2hash(&up[pos],
- namespace)) ) {
+ namespace)) ) {
FREE(up);
return SYSERR;
}
if ( (slen != pos+2*sizeof(EncName)-1) ||
(OK != enc2hash(&up[pos+sizeof(EncName)],
- identifier)) ) {
+ identifier)) ) {
if (up[slen-1] == '\\')
up[--slen] = '\0';
hash(&up[pos+sizeof(EncName)],
- slen - (pos+sizeof(EncName)),
- identifier);
+ slen - (pos+sizeof(EncName)),
+ identifier);
}
FREE(up);
return OK;
@@ -354,8 +354,8 @@
* @return OK on success, SYSERR if this is not a file URI
*/
static int parseFileURI(struct GE_Context * ectx,
- const char * uri,
- FileIdentifier * fi) {
+ const char * uri,
+ FileIdentifier * fi) {
unsigned int pos;
size_t slen;
char * dup;
@@ -366,12 +366,12 @@
pos = strlen(ECRS_URI_PREFIX);
if (0 != strncmp(uri,
- ECRS_URI_PREFIX,
- pos))
+ ECRS_URI_PREFIX,
+ pos))
return SYSERR;
if (0 != strncmp(&uri[pos],
- ECRS_FILE_INFIX,
- strlen(ECRS_FILE_INFIX)))
+ ECRS_FILE_INFIX,
+ strlen(ECRS_FILE_INFIX)))
return SYSERR;
pos += strlen(ECRS_FILE_INFIX);
if ( (slen < pos+2*sizeof(EncName)+1) ||
@@ -383,12 +383,12 @@
dup[pos+sizeof(EncName)-1] = '\0';
dup[pos+sizeof(EncName)*2-1] = '\0';
if ( (OK != enc2hash(&dup[pos],
- &fi->chk.key)) ||
+ &fi->chk.key)) ||
(OK != enc2hash(&dup[pos+sizeof(EncName)],
- &fi->chk.query)) ||
+ &fi->chk.query)) ||
(1 != SSCANF(&dup[pos+sizeof(EncName)*2],
- "%llu",
- &fi->file_length)) ) {
+ "%llu",
+ &fi->file_length)) ) {
FREE(dup);
return SYSERR;
}
@@ -406,8 +406,8 @@
* @return OK on success, SYSERR if this is not a file URI
*/
static int parseLocationURI(struct GE_Context * ectx,
- const char * uri,
- Location * loc) {
+ const char * uri,
+ Location * loc) {
unsigned int pos;
unsigned int npos;
int ret;
@@ -422,12 +422,12 @@
pos = strlen(ECRS_URI_PREFIX);
if (0 != strncmp(uri,
- ECRS_URI_PREFIX,
- pos))
+ ECRS_URI_PREFIX,
+ pos))
return SYSERR;
if (0 != strncmp(&uri[pos],
- ECRS_LOCATION_INFIX,
- strlen(ECRS_LOCATION_INFIX)))
+ ECRS_LOCATION_INFIX,
+ strlen(ECRS_LOCATION_INFIX)))
return SYSERR;
pos += strlen(ECRS_LOCATION_INFIX);
if ( (slen < pos+2*sizeof(EncName)+1) ||
@@ -440,22 +440,22 @@
dup[pos+sizeof(EncName)*2-1] = '\0';
npos = pos +sizeof(EncName)*2;
while ( (uri[npos] != '\0') &&
- (uri[npos] != '.') )
+ (uri[npos] != '.') )
npos++;
if (dup[npos] == '\0')
goto ERR;
dup[npos++] = '\0';
if ( (OK != enc2hash(&dup[pos],
- &loc->fi.chk.key)) ||
+ &loc->fi.chk.key)) ||
(OK != enc2hash(&dup[pos+sizeof(EncName)],
- &loc->fi.chk.query)) ||
+ &loc->fi.chk.query)) ||
(1 != SSCANF(&dup[pos+sizeof(EncName)*2],
- "%llu",
- &loc->fi.file_length)) )
+ "%llu",
+ &loc->fi.file_length)) )
goto ERR;
loc->fi.file_length = htonll(loc->fi.file_length);
ret = enc2bin(&dup[npos],
- &loc->peer,
+ &loc->peer,
sizeof(PublicKey));
if (ret == -1)
goto ERR;
@@ -463,24 +463,24 @@
if (dup[npos++] != '.')
goto ERR;
ret = enc2bin(&dup[npos],
- &loc->contentSignature,
- sizeof(Signature));
+ &loc->contentSignature,
+ sizeof(Signature));
if (ret == -1)
goto ERR;
npos += ret;
if (dup[npos++] != '.')
goto ERR;
if (1 != SSCANF(&dup[npos],
- "%u",
- &loc->expirationTime))
+ "%u",
+ &loc->expirationTime))
goto ERR;
/* Finally: verify sigs! */
if (OK != verifySig(&loc->fi,
- sizeof(FileIdentifier) +
- sizeof(PeerIdentity) +
- sizeof(TIME_T),
- &loc->contentSignature,
- &loc->peer))
+ sizeof(FileIdentifier) +
+ sizeof(PeerIdentity) +
+ sizeof(TIME_T),
+ &loc->contentSignature,
+ &loc->peer))
goto ERR;
FREE(dup);
return OK;
@@ -494,33 +494,33 @@
* Convert a UTF-8 String to a URI.
*/
URI * ECRS_stringToUri(struct GE_Context * ectx,
- const char * uri) {
+ const char * uri) {
URI * ret;
int len;
ret = MALLOC(sizeof(URI));
if (OK == parseFileURI(ectx,
- uri,
- &ret->data.fi)) {
+ uri,
+ &ret->data.fi)) {
ret->type = chk;
return ret;
}
if (OK == parseSubspaceURI(ectx,
- uri,
- &ret->data.sks.namespace,
- &ret->data.sks.identifier)) {
+ uri,
+ &ret->data.sks.namespace,
+ &ret->data.sks.identifier)) {
ret->type = sks;
return ret;
}
if (OK == parseLocationURI(ectx,
- uri,
- &ret->data.loc)) {
+ uri,
+ &ret->data.loc)) {
ret->type = loc;
return ret;
}
len = parseKeywordURI(ectx,
- uri,
- &ret->data.ksk.keywords);
+ uri,
+ &ret->data.ksk.keywords);
if (len < 0) {
FREE(ret);
return NULL;
@@ -543,8 +543,8 @@
for (i=0;i<uri->data.ksk.keywordCount;i++)
FREE(uri->data.ksk.keywords[i]);
GROW(uri->data.ksk.keywords,
- uri->data.ksk.keywordCount,
- 0);
+ uri->data.ksk.keywordCount,
+ 0);
break;
case loc:
break;
@@ -573,7 +573,7 @@
ret = MALLOC(sizeof(EncName));
hash2enc(id,
- (EncName*)ret);
+ (EncName*)ret);
return ret;
}
@@ -584,7 +584,7 @@
* @return OK on success
*/
int ECRS_getNamespaceId(const struct ECRS_URI * uri,
- HashCode512 * id) {
+ HashCode512 * id) {
if (! ECRS_isNamespaceUri(uri)) {
GE_BREAK(NULL, 0);
return SYSERR;
@@ -599,7 +599,7 @@
* @return OK on success
*/
int ECRS_getSKSContentHash(const struct ECRS_URI * uri,
- HashCode512 * id) {
+ HashCode512 * id) {
if (! ECRS_isNamespaceUri(uri)) {
GE_BREAK(NULL, 0);
return SYSERR;
@@ -640,18 +640,18 @@
* keywords iterated over until iterator aborted
*/
int ECRS_getKeywordsFromUri(const struct ECRS_URI * uri,
- ECRS_KeywordIterator iterator,
- void * cls) {
+ ECRS_KeywordIterator iterator,
+ void * cls) {
int i;
if (uri->type != ksk) {
return -1;
} else {
for (i=0;i<uri->data.ksk.keywordCount;i++)
if (iterator != NULL)
- if (OK != iterator(uri->data.ksk.keywords[i],
- cls))
- return i;
+ if (OK != iterator(uri->data.ksk.keywords[i],
+ cls))
return i;
+ return i;
}
}
@@ -697,16 +697,16 @@
ret = MALLOC(sizeof(URI));
memcpy(ret,
- uri,
- sizeof(URI));
+ uri,
+ sizeof(URI));
switch (ret->type) {
case ksk:
if (ret->data.ksk.keywordCount > 0) {
ret->data.ksk.keywords
- = MALLOC(ret->data.ksk.keywordCount * sizeof(char*));
+ = MALLOC(ret->data.ksk.keywordCount * sizeof(char*));
for (i=0;i<ret->data.ksk.keywordCount;i++)
- ret->data.ksk.keywords[i]
- = STRDUP(uri->data.ksk.keywords[i]);
+ ret->data.ksk.keywords[i]
+ = STRDUP(uri->data.ksk.keywords[i]);
}
break;
case loc:
@@ -749,16 +749,16 @@
key = uri->data.ksk.keywords[i];
GE_ASSERT(NULL, key != NULL);
ret->data.ksk.keywords[2*i]
- = STRDUP(key);
+ = STRDUP(key);
kd = MALLOC(strlen(key) + 13);
memset(kd, 0, strlen(key) + 13);
strcpy(kd, key);
strftime(&kd[strlen(key)],
- 13,
- "-%Y-%m-%d",
- &t);
+ 13,
+ "-%Y-%m-%d",
+ &t);
ret->data.ksk.keywords[2*i+1]
- = kd;
+ = kd;
}
} else
ret->data.ksk.keywords = NULL;
@@ -791,11 +791,11 @@
havePreview++;
} else {
for (j=md->itemCount-1;j>i;j--) {
- if (0 == strcmp(md->items[i].data,
- md->items[j].data)) {
- havePreview++; /* duplicate! */
- break;
- }
+ if (0 == strcmp(md->items[i].data,
+ md->items[j].data)) {
+ havePreview++; /* duplicate! */
+ break;
+ }
}
}
}
@@ -808,17 +808,17 @@
} else {
add = 1;
for (j=md->itemCount-1;j>i;j--) {
- if (0 == strcmp(md->items[i].data,
- md->items[j].data)) {
- havePreview--;
- add = 0;
- break;
- }
+ if (0 == strcmp(md->items[i].data,
+ md->items[j].data)) {
+ havePreview--;
+ add = 0;
+ break;
+ }
}
if (add == 1) {
- GE_ASSERT(NULL, md->items[i].data != NULL);
- ret->data.ksk.keywords[i-havePreview]
- = STRDUP(md->items[i].data);
+ GE_ASSERT(NULL, md->items[i].data != NULL);
+ ret->data.ksk.keywords[i-havePreview]
+ = STRDUP(md->items[i].data);
}
}
}
@@ -856,7 +856,7 @@
* Are these two URIs equal?
*/
int ECRS_equalsUri(const struct ECRS_URI * uri1,
- const struct ECRS_URI * uri2) {
+ const struct ECRS_URI * uri2) {
int ret;
int i;
int j;
@@ -868,45 +868,45 @@
switch(uri1->type) {
case chk:
if (0 == memcmp(&uri1->data.fi,
- &uri2->data.fi,
- sizeof(FileIdentifier)))
+ &uri2->data.fi,
+ sizeof(FileIdentifier)))
return YES;
return NO;
case sks:
if (equalsHashCode512(&uri1->data.sks.namespace,
- &uri2->data.sks.namespace) &&
- equalsHashCode512(&uri1->data.sks.identifier,
- &uri2->data.sks.identifier) )
-
+ &uri2->data.sks.namespace) &&
+ equalsHashCode512(&uri1->data.sks.identifier,
+ &uri2->data.sks.identifier) )
+
return YES;
return NO;
case ksk:
if (uri1->data.ksk.keywordCount !=
- uri2->data.ksk.keywordCount)
+ uri2->data.ksk.keywordCount)
return NO;
for (i=0;i<uri1->data.ksk.keywordCount;i++) {
ret = NO;
for (j=0;j<uri2->data.ksk.keywordCount;j++) {
- if (0 == strcmp(uri1->data.ksk.keywords[i],
- uri2->data.ksk.keywords[j])) {
- ret = YES;
- break;
- }
+ if (0 == strcmp(uri1->data.ksk.keywords[i],
+ uri2->data.ksk.keywords[j])) {
+ ret = YES;
+ break;
+ }
}
if (ret == NO)
- return NO;
+ return NO;
}
return YES;
case loc:
if (memcmp(&uri1->data.loc,
- &uri2->data.loc,
- sizeof(FileIdentifier) +
- sizeof(PublicKey) +
- sizeof(TIME_T) +
- sizeof(unsigned short) +
- sizeof(unsigned short)) != 0)
+ &uri2->data.loc,
+ sizeof(FileIdentifier) +
+ sizeof(PublicKey) +
+ sizeof(TIME_T) +
+ sizeof(unsigned short) +
+ sizeof(unsigned short)) != 0)
return NO;
- return YES;
+ return YES;
default:
return NO;
}
@@ -917,7 +917,7 @@
* @return -1 if this is not a location URI, otherwise OK
*/
int ECRS_getPeerFromUri(const struct ECRS_URI * uri,
- PeerIdentity * peer) {
+ PeerIdentity * peer) {
if (uri->type != loc)
return -1;
hash(&uri->data.loc.peer,
@@ -958,10 +958,10 @@
*/
struct ECRS_URI *
ECRS_uriFromLocation(const struct ECRS_URI * baseUri,
- const PublicKey * sender,
- TIME_T expirationTime,
- ECRS_SignFunction signer,
- void * signer_cls) {
+ const PublicKey * sender,
+ TIME_T expirationTime,
+ ECRS_SignFunction signer,
+ void * signer_cls) {
struct ECRS_URI * uri;
if (baseUri->type != chk)
@@ -973,11 +973,11 @@
uri->data.loc.peer = *sender;
uri->data.loc.expirationTime = expirationTime;
signer(signer_cls,
- sizeof(FileIdentifier) +
- sizeof(PeerIdentity) +
- sizeof(TIME_T),
- &uri->data.loc.fi,
- &uri->data.loc.contentSignature);
+ sizeof(FileIdentifier) +
+ sizeof(PeerIdentity) +
+ sizeof(TIME_T),
+ &uri->data.loc.fi,
+ &uri->data.loc.contentSignature);
return uri;
}
Modified: GNUnet/src/applications/fs/ecrs/uritest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uritest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs/uritest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -54,7 +54,7 @@
uri = ECRS_uriToString(ret);
if (0 != strcmp(uri,
- "gnunet://ecrs/ksk/foo+bar")) {
+ "gnunet://ecrs/ksk/foo+bar")) {
FREE(uri);
ECRS_freeUri(ret);
ABORT();
@@ -75,12 +75,12 @@
baseURI = ECRS_stringToUri(NULL,
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42");
hk = makePrivateKey();
getPublicKey(hk,
- &pk);
+ &pk);
uri = ECRS_uriFromLocation(baseURI,
- &pk,
- 43,
- (ECRS_SignFunction) &sign,
- hk);
+ &pk,
+ 43,
+ (ECRS_SignFunction) &sign,
+ hk);
freePrivateKey(hk);
if (uri == NULL) {
GE_BREAK(NULL, 0);
@@ -95,7 +95,7 @@
}
uri2 = ECRS_getContentUri(uri);
if (! ECRS_equalsUri(baseURI,
- uri2)) {
+ uri2)) {
GE_BREAK(NULL, 0);
ECRS_freeUri(uri);
ECRS_freeUri(uri2);
@@ -117,7 +117,7 @@
return 1;
}
if (YES != ECRS_equalsUri(uri,
- uri2)) {
+ uri2)) {
GE_BREAK(NULL, 0);
ECRS_freeUri(uri);
ECRS_freeUri(uri2);
@@ -152,7 +152,7 @@
uri = ECRS_uriToString(ret);
if (0 != strcmp(uri,
-
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/TOJB1NAAUVJKJAGQHRHS22N9I8VM32C0ESN4EFS836IT950E1MP7LGC5V2GE3LFO9U4BP23VQPTH8DPIOC2CONT9LM76ULVL00KAHVO"))
{
+
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/TOJB1NAAUVJKJAGQHRHS22N9I8VM32C0ESN4EFS836IT950E1MP7LGC5V2GE3LFO9U4BP23VQPTH8DPIOC2CONT9LM76ULVL00KAHVO"))
{
ECRS_freeUri(ret);
FREE(uri);
ABORT();
@@ -190,7 +190,7 @@
uri = ECRS_uriToString(ret);
if (0 != strcmp(uri,
-
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42"))
{
+
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42"))
{
FREE(uri);
ECRS_freeUri(ret);
ABORT();
Modified: GNUnet/src/applications/fs/ecrs_core.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs_core.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -44,9 +44,9 @@
* match the query
*/
int fileBlockEncode(const DBlock * data,
- unsigned int len,
- const HashCode512 * query,
- Datastore_Value ** value) {
+ unsigned int len,
+ const HashCode512 * query,
+ Datastore_Value ** value) {
HashCode512 hc;
SESSIONKEY skey;
INITVECTOR iv; /* initial value */
@@ -59,8 +59,8 @@
len - sizeof(DBlock),
&hc);
hashToKey(&hc,
- &skey,
- &iv);
+ &skey,
+ &iv);
val = MALLOC(sizeof(Datastore_Value) + len);
val->size = htonl(sizeof(Datastore_Value) + len);
val->type = htonl(D_BLOCK);
@@ -70,19 +70,19 @@
db = (DBlock*) &val[1];
db->type = htonl(D_BLOCK);
GE_ASSERT(NULL,
- len - sizeof(DBlock) < MAX_BUFFER_SIZE);
+ len - sizeof(DBlock) < MAX_BUFFER_SIZE);
GE_ASSERT(NULL,
- len - sizeof(DBlock)
- == encryptBlock(&data[1],
- len - sizeof(DBlock),
- &skey,
- &iv,
- &db[1]));
+ len - sizeof(DBlock)
+ == encryptBlock(&data[1],
+ len - sizeof(DBlock),
+ &skey,
+ &iv,
+ &db[1]));
hash(&db[1],
len - sizeof(DBlock),
&hc);
if (! equalsHashCode512(query,
- &hc)) {
+ &hc)) {
FREE(val);
*value = NULL;
return SYSERR;
@@ -96,8 +96,8 @@
* a certain block of data.
*/
void fileBlockGetKey(const DBlock * data,
- unsigned int len,
- HashCode512 * key) {
+ unsigned int len,
+ HashCode512 * key) {
GE_ASSERT(NULL, len >= sizeof(DBlock));
hash(&data[1],
len - sizeof(DBlock),
@@ -111,8 +111,8 @@
* @param db the block in plaintext
*/
void fileBlockGetQuery(const DBlock * db,
- unsigned int len,
- HashCode512 * query) {
+ unsigned int len,
+ HashCode512 * query) {
char * tmp;
const char * data;
HashCode512 hc;
@@ -125,20 +125,20 @@
GE_ASSERT(NULL, len < MAX_BUFFER_SIZE);
hash(data, len, &hc);
hashToKey(&hc,
- &skey,
- &iv);
+ &skey,
+ &iv);
tmp = MALLOC(len);
GE_ASSERT(NULL, len == encryptBlock(data,
- len,
- &skey,
- &iv,
- tmp));
+ len,
+ &skey,
+ &iv,
+ tmp));
hash(tmp, len, query);
FREE(tmp);
}
unsigned int getTypeOfBlock(unsigned int size,
- const DBlock * data) {
+ const DBlock * data) {
if (size <= 4) {
GE_BREAK(NULL, 0);
return ANY_BLOCK; /* signal error */
@@ -156,9 +156,9 @@
* the content type is not known
*/
int getQueryFor(unsigned int size,
- const DBlock * data,
- int verify,
- HashCode512 * query) {
+ const DBlock * data,
+ int verify,
+ HashCode512 * query) {
unsigned int type;
type = getTypeOfBlock(size, data);
@@ -170,8 +170,8 @@
case D_BLOCK:
/* CHK: hash of content == query */
hash(&data[1],
- size - sizeof(DBlock),
- query);
+ size - sizeof(DBlock),
+ query);
return OK;
case S_BLOCK: {
const SBlock * sb;
@@ -181,13 +181,13 @@
}
sb = (const SBlock*) data;
if ( (verify == YES) &&
- (OK != verifySig(&sb->identifier,
- size
- - sizeof(Signature)
- - sizeof(PublicKey)
- - sizeof(unsigned int),
- &sb->signature,
- &sb->subspace)) ) {
+ (OK != verifySig(&sb->identifier,
+ size
+ - sizeof(Signature)
+ - sizeof(PublicKey)
+ - sizeof(unsigned int),
+ &sb->signature,
+ &sb->subspace)) ) {
GE_BREAK(NULL, 0);
return SYSERR;
}
@@ -202,16 +202,16 @@
}
kb = (const KBlock*) data;
if ( (verify == YES) &&
- ( (OK != verifySig(&kb[1],
- size - sizeof(KBlock),
- &kb->signature,
- &kb->keyspace)) ) ) {
+ ( (OK != verifySig(&kb[1],
+ size - sizeof(KBlock),
+ &kb->signature,
+ &kb->keyspace)) ) ) {
GE_BREAK(NULL, 0);
return SYSERR;
}
hash(&kb->keyspace,
- sizeof(PublicKey),
- query);
+ sizeof(PublicKey),
+ query);
return OK;
}
case N_BLOCK: {
@@ -222,13 +222,13 @@
}
nb = (const NBlock*) data;
if ( (verify == YES) &&
- (OK != verifySig(&nb->identifier,
- size
- - sizeof(Signature)
- - sizeof(PublicKey)
- - sizeof(unsigned int),
- &nb->signature,
- &nb->subspace)) ) {
+ (OK != verifySig(&nb->identifier,
+ size
+ - sizeof(Signature)
+ - sizeof(PublicKey)
+ - sizeof(unsigned int),
+ &nb->signature,
+ &nb->subspace)) ) {
GE_BREAK(NULL, 0);
return SYSERR;
}
@@ -243,18 +243,18 @@
}
kb = (const KNBlock*) data;
if ( (verify == YES) &&
- ( (OK != verifySig(&kb->nblock,
- size
- - sizeof(KBlock)
- - sizeof(unsigned int),
- &kb->kblock.signature,
- &kb->kblock.keyspace)) ) ) {
+ ( (OK != verifySig(&kb->nblock,
+ size
+ - sizeof(KBlock)
+ - sizeof(unsigned int),
+ &kb->kblock.signature,
+ &kb->kblock.keyspace)) ) ) {
GE_BREAK(NULL, 0);
return SYSERR;
}
hash(&kb->kblock.keyspace,
- sizeof(PublicKey),
- query);
+ sizeof(PublicKey),
+ query);
return OK;
}
case ONDEMAND_BLOCK: {
@@ -285,11 +285,11 @@
* query type
*/
int isDatumApplicable(unsigned int type,
- unsigned int size,
- const DBlock * data,
- const HashCode512 * hc,
- unsigned int keyCount,
- const HashCode512 * keys) {
+ unsigned int size,
+ const DBlock * data,
+ const HashCode512 * hc,
+ unsigned int keyCount,
+ const HashCode512 * keys) {
HashCode512 h;
if (type != getTypeOfBlock(size, data)) {
@@ -298,7 +298,7 @@
}
if (! equalsHashCode512(hc, &keys[0])) {
GE_BREAK(NULL, 0); /* mismatch between primary queries,
- we should not even see those here. */
+ we should not even see those here. */
return SYSERR;
}
if (keyCount == 0)
@@ -308,20 +308,20 @@
if (keyCount != 2)
return SYSERR; /* no match */
hash(&((const SBlock*)data)->subspace,
- sizeof(PublicKey),
- &h);
+ sizeof(PublicKey),
+ &h);
if (equalsHashCode512(&keys[1],
- &h))
+ &h))
return OK;
return SYSERR;
case N_BLOCK:
if (keyCount != 2)
return SYSERR; /* no match */
hash(&((const NBlock*)data)->subspace,
- sizeof(PublicKey),
- &h);
+ sizeof(PublicKey),
+ &h);
if (! equalsHashCode512(&keys[1],
- &h))
+ &h))
return SYSERR;
return OK;
case D_BLOCK:
Modified: GNUnet/src/applications/fs/ecrs_core_test.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core_test.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/ecrs_core_test.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -42,32 +42,32 @@
memset(&data[1], rand(), len - sizeof(DBlock));
data->type = htonl(D_BLOCK);
CHECK(D_BLOCK == getTypeOfBlock(len,
- data),
- data);
+ data),
+ data);
fileBlockGetKey(data, len, &key);
fileBlockGetQuery(data, len, &query);
CHECK(OK == fileBlockEncode(data,
- len,
- &query,
- &value),
- data);
+ len,
+ &query,
+ &value),
+ data);
memcpy(data,
- &value[1],
- len);
+ &value[1],
+ len);
FREE(value);
CHECK(YES == isDatumApplicable(D_BLOCK,
- len,
- data,
- &query,
- 1,
- &query),
- data);
+ len,
+ data,
+ &query,
+ 1,
+ &query),
+ data);
FREE(data);
return 0;
}
int main(int argc,
- char * argv[]) {
+ char * argv[]) {
int failureCount = 0;
failureCount += testEC();
Modified: GNUnet/src/applications/fs/fsui/deserialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/deserialize.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/fsui/deserialize.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -33,11 +33,11 @@
static int read_int(int fd,
- int * val) {
+ int * val) {
int big;
if (sizeof(int) != READ(fd, &big, sizeof(int))) \
- return SYSERR; \
+ return SYSERR; \
*val = ntohl(big);
return OK;
}
@@ -45,11 +45,11 @@
#define READINT(a) if (OK != read_int(fd, (int*) &a)) return SYSERR;
static int read_long(int fd,
- long long * val) {
+ long long * val) {
long long big;
if (sizeof(long long) != READ(fd, &big, sizeof(long long))) \
- return SYSERR; \
+ return SYSERR; \
*val = ntohll(big);
return OK;
}
@@ -57,7 +57,7 @@
#define READLONG(a) if (OK != read_long(fd, (long long*) &a)) return SYSERR;
static struct ECRS_URI * read_uri(struct GE_Context * ectx,
- int fd) {
+ int fd) {
char * buf;
struct ECRS_URI * ret;
unsigned int size;
@@ -67,8 +67,8 @@
buf = MALLOC(size+1);
buf[size] = '\0';
if (size != READ(fd,
- buf,
- size)) {
+ buf,
+ size)) {
FREE(buf);
return NULL;
}
@@ -81,7 +81,7 @@
#define READURI(u) if (NULL == (u = read_uri(ectx, fd))) return SYSERR;
static char * read_string(int fd,
- unsigned int maxLen) {
+ unsigned int maxLen) {
char * buf;
unsigned int big;
@@ -133,7 +133,7 @@
*/
static struct ECRS_MetaData *
read_meta(struct GE_Context * ectx,
- int fd) {
+ int fd) {
unsigned int size;
char * buf;
struct ECRS_MetaData * meta;
@@ -148,15 +148,15 @@
}
buf = MALLOC(size);
if (size != READ(fd,
- buf,
- size)) {
+ buf,
+ size)) {
FREE(buf);
GE_BREAK(ectx, 0);
return NULL;
}
meta = ECRS_deserializeMetaData(ectx,
- buf,
- size);
+ buf,
+ size);
if (meta == NULL) {
FREE(buf);
GE_BREAK(ectx, 0);
@@ -172,8 +172,8 @@
* @return OK on success, SYSERR on error
*/
static int readFileInfo(struct GE_Context * ectx,
- int fd,
- ECRS_FileInfo * fi) {
+ int fd,
+ ECRS_FileInfo * fi) {
fi->meta = read_meta(ectx, fd);
if (fi->meta == NULL) {
GE_BREAK(ectx, 0);
@@ -203,9 +203,9 @@
*/
static FSUI_DownloadList *
readDownloadList(struct GE_Context * ectx,
- int fd,
- FSUI_Context * ctx,
- FSUI_DownloadList * parent) {
+ int fd,
+ FSUI_Context * ctx,
+ FSUI_DownloadList * parent) {
FSUI_DownloadList * ret;
FSUI_SearchList * pos;
unsigned int big;
@@ -219,8 +219,8 @@
return NULL;
ret = MALLOC(sizeof(FSUI_DownloadList));
memset(ret,
- 0,
- sizeof(FSUI_DownloadList));
+ 0,
+ sizeof(FSUI_DownloadList));
ret->ctx = ctx;
if ( (OK != read_int(fd, (int*) &soff)) ||
(OK != read_int(fd, (int*) &ret->state)) ||
@@ -247,8 +247,8 @@
return NULL;
}
if (OK != readFileInfo(ectx,
- fd,
- &ret->fi)) {
+ fd,
+ &ret->fi)) {
GE_BREAK(NULL, 0);
FREE(ret->filename);
FREE(ret);
@@ -257,7 +257,7 @@
if (ret->completedDownloadsCount > 0)
ret->completedDownloads
= MALLOC(sizeof(struct ECRS_URI *) *
- ret->completedDownloadsCount);
+ ret->completedDownloadsCount);
ok = YES;
for (i=0;i<ret->completedDownloadsCount;i++) {
ret->completedDownloads[i] = read_uri(ectx, fd);
@@ -272,7 +272,7 @@
ECRS_freeMetaData(ret->fi.meta);
for (i=0;i<ret->completedDownloadsCount;i++) {
if (ret->completedDownloads[i] != NULL)
- ECRS_freeUri(ret->completedDownloads[i]);
+ ECRS_freeUri(ret->completedDownloads[i]);
}
FREE(ret->completedDownloads);
FREE(ret);
@@ -286,34 +286,34 @@
pos = ctx->activeSearches;
while (--soff > 0) {
if (pos == NULL) {
- GE_BREAK(NULL, 0);
- break;
+ GE_BREAK(NULL, 0);
+ break;
}
pos = pos->next;
}
ret->search = pos;
if (pos != NULL) {
GROW(pos->my_downloads,
- pos->my_downloads_size,
- pos->my_downloads_size + 1);
+ pos->my_downloads_size,
+ pos->my_downloads_size + 1);
pos->my_downloads[pos->my_downloads_size -1] = ret;
}
}
ret->next = readDownloadList(ectx,
- fd,
- ctx,
- parent);
+ fd,
+ ctx,
+ parent);
ret->child = readDownloadList(ectx,
- fd,
- ctx,
- ret);
+ fd,
+ ctx,
+ ret);
#if DEBUG_PERSISTENCE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSUI persistence: restoring download `%s': (%llu, %llu)\n",
- ret->filename,
- ret->completed,
- ret->total);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSUI persistence: restoring download `%s': (%llu, %llu)\n",
+ ret->filename,
+ ret->completed,
+ ret->total);
#endif
return ret;
}
@@ -326,8 +326,8 @@
return SYSERR;
}
if (0 != memcmp(magic,
- "FSUI01\n\0",
- 8)) {
+ "FSUI01\n\0",
+ 8)) {
GE_BREAK(NULL, 0);
return SYSERR;
}
@@ -335,7 +335,7 @@
}
static int readCollection(int fd,
- struct FSUI_Context * ctx) {
+ struct FSUI_Context * ctx) {
int big;
/* deserialize collection data */
@@ -353,8 +353,8 @@
= MALLOC(big);
if (big - sizeof(unsigned int) !=
READ(fd,
- &ctx->collectionData[1],
- big - sizeof(unsigned int))) {
+ &ctx->collectionData[1],
+ big - sizeof(unsigned int))) {
FREE(ctx->collectionData);
ctx->collectionData = NULL;
GE_BREAK(NULL, 0);
@@ -364,7 +364,7 @@
}
static int readSearches(int fd,
- struct FSUI_Context * ctx) {
+ struct FSUI_Context * ctx) {
int big;
FSUI_SearchList * list;
FSUI_SearchList * last;
@@ -378,21 +378,21 @@
if (big == 0)
return OK;
list
- = MALLOC(sizeof(FSUI_SearchList));
+ = MALLOC(sizeof(FSUI_SearchList));
memset(list,
- 0,
- sizeof(FSUI_SearchList));
+ 0,
+ sizeof(FSUI_SearchList));
if ( (OK != read_int(fd, (int*) &list->state)) ||
- (OK != read_int(fd, (int*) &list->maxResults)) ||
- (OK != read_long(fd, (long long*) &list->timeout)) ||
- (OK != read_long(fd, (long long*) &list->start_time)) ||
- (OK != read_long(fd, (long long*) &stime)) ||
- (OK != read_int(fd, (int*) &list->anonymityLevel)) ||
- (OK != read_int(fd, (int*) &list->sizeResultsReceived)) ||
- (OK != read_int(fd, (int*) &list->sizeUnmatchedResultsReceived)) ||
- (list->sizeResultsReceived > 1024*1024) ||
- (list->sizeUnmatchedResultsReceived > 1024*1024) ) {
- GE_BREAK(NULL, 0);
+ (OK != read_int(fd, (int*) &list->maxResults)) ||
+ (OK != read_long(fd, (long long*) &list->timeout)) ||
+ (OK != read_long(fd, (long long*) &list->start_time)) ||
+ (OK != read_long(fd, (long long*) &stime)) ||
+ (OK != read_int(fd, (int*) &list->anonymityLevel)) ||
+ (OK != read_int(fd, (int*) &list->sizeResultsReceived)) ||
+ (OK != read_int(fd, (int*) &list->sizeUnmatchedResultsReceived)) ||
+ (list->sizeResultsReceived > 1024*1024) ||
+ (list->sizeUnmatchedResultsReceived > 1024*1024) ) {
+ GE_BREAK(NULL, 0);
break;
}
fixState(&list->state);
@@ -412,69 +412,69 @@
break;
}
if (! ( ECRS_isKeywordUri(list->uri) ||
- ECRS_isNamespaceUri(list->uri)) ) {
- GE_BREAK(NULL, 0);
+ ECRS_isNamespaceUri(list->uri)) ) {
+ GE_BREAK(NULL, 0);
break;
}
list->numberOfURIKeys
= ECRS_countKeywordsOfUri(list->uri);
if (list->sizeResultsReceived > 0) {
list->resultsReceived
- = MALLOC(list->sizeResultsReceived *
- sizeof(ECRS_FileInfo));
+ = MALLOC(list->sizeResultsReceived *
+ sizeof(ECRS_FileInfo));
memset(list->resultsReceived,
- 0,
- list->sizeResultsReceived *
- sizeof(ECRS_FileInfo));
+ 0,
+ list->sizeResultsReceived *
+ sizeof(ECRS_FileInfo));
}
if (list->sizeUnmatchedResultsReceived > 0) {
list->unmatchedResultsReceived
- = MALLOC(list->sizeUnmatchedResultsReceived *
- sizeof(ResultPending));
+ = MALLOC(list->sizeUnmatchedResultsReceived *
+ sizeof(ResultPending));
memset(list->unmatchedResultsReceived,
- 0,
- list->sizeUnmatchedResultsReceived *
- sizeof(ResultPending));
+ 0,
+ list->sizeUnmatchedResultsReceived *
+ sizeof(ResultPending));
}
for (i=0;i<list->sizeResultsReceived;i++)
if (OK != readFileInfo(ctx->ectx,
- fd,
- &list->resultsReceived[i])) {
- GE_BREAK(NULL, 0);
- goto ERR;
+ fd,
+ &list->resultsReceived[i])) {
+ GE_BREAK(NULL, 0);
+ goto ERR;
}
for (i=0;i<list->sizeUnmatchedResultsReceived;i++) {
rp = &list->unmatchedResultsReceived[i];
if (OK != readFileInfo(ctx->ectx,
- fd,
- &rp->fi)) {
- GE_BREAK(NULL, 0);
- goto ERR;
+ fd,
+ &rp->fi)) {
+ GE_BREAK(NULL, 0);
+ goto ERR;
}
if (OK != read_int(fd, (int*) &rp->matchingKeyCount)) {
- GE_BREAK(NULL, 0);
- goto ERR;
+ GE_BREAK(NULL, 0);
+ goto ERR;
}
if ( (rp->matchingKeyCount > 1024) ||
- (rp->matchingKeyCount >= list->numberOfURIKeys) ) {
- GE_BREAK(NULL, 0);
- goto ERR;
+ (rp->matchingKeyCount >= list->numberOfURIKeys) ) {
+ GE_BREAK(NULL, 0);
+ goto ERR;
}
if (rp->matchingKeyCount > 0) {
- rp->matchingKeys
- = MALLOC(sizeof(HashCode512) *
- rp->matchingKeyCount);
- if (sizeof(HashCode512) *
- rp->matchingKeyCount !=
- READ(fd,
- rp->matchingKeys,
- sizeof(HashCode512) *
- rp->matchingKeyCount)) {
- GE_BREAK(NULL, 0);
- goto ERR;
- }
+ rp->matchingKeys
+ = MALLOC(sizeof(HashCode512) *
+ rp->matchingKeyCount);
+ if (sizeof(HashCode512) *
+ rp->matchingKeyCount !=
+ READ(fd,
+ rp->matchingKeys,
+ sizeof(HashCode512) *
+ rp->matchingKeyCount)) {
+ GE_BREAK(NULL, 0);
+ goto ERR;
+ }
}
- }
+ }
list->ctx
= ctx;
list->next
@@ -486,7 +486,7 @@
} else {
last = ctx->activeSearches;
while (last->next != NULL)
- last = last->next;
+ last = last->next;
last->next = list;
}
} /* end OUTER: 'while(1)' */
@@ -495,27 +495,27 @@
if (list->resultsReceived != NULL) {
for (i=0;i<list->sizeResultsReceived;i++) {
if (list->resultsReceived[i].uri != NULL)
- ECRS_freeUri(list->resultsReceived[i].uri);
+ ECRS_freeUri(list->resultsReceived[i].uri);
if (list->resultsReceived[i].meta != NULL)
- ECRS_freeMetaData(list->resultsReceived[i].meta);
+ ECRS_freeMetaData(list->resultsReceived[i].meta);
}
GROW(list->resultsReceived,
- list->sizeResultsReceived,
- 0);
+ list->sizeResultsReceived,
+ 0);
}
if (list->unmatchedResultsReceived != NULL) {
for (i=0;i<list->sizeUnmatchedResultsReceived;i++) {
rp = &list->unmatchedResultsReceived[i];
if (rp->fi.uri != NULL)
- ECRS_freeUri(rp->fi.uri);
+ ECRS_freeUri(rp->fi.uri);
if (rp->fi.meta != NULL)
- ECRS_freeMetaData(rp->fi.meta);
+ ECRS_freeMetaData(rp->fi.meta);
FREENONNULL(rp->matchingKeys);
}
GROW(list->resultsReceived,
- list->sizeResultsReceived,
- 0);
+ list->sizeResultsReceived,
+ 0);
}
if (list->uri != NULL)
ECRS_freeUri(list->uri);
@@ -524,23 +524,23 @@
}
static int readDownloads(int fd,
- struct FSUI_Context * ctx) {
+ struct FSUI_Context * ctx) {
memset(&ctx->activeDownloads,
- 0,
- sizeof(FSUI_DownloadList));
+ 0,
+ sizeof(FSUI_DownloadList));
ctx->activeDownloads.child
= readDownloadList(ctx->ectx,
- fd,
- ctx,
- &ctx->activeDownloads);
+ fd,
+ ctx,
+ &ctx->activeDownloads);
return OK;
}
static int readUploadList(struct FSUI_Context * ctx,
- struct FSUI_UploadList * parent,
- int fd,
- struct FSUI_UploadShared * shared,
- int top) {
+ struct FSUI_UploadList * parent,
+ int fd,
+ struct FSUI_UploadShared * shared,
+ int top) {
struct FSUI_UploadList * list;
struct FSUI_UploadList l;
unsigned long long stime;
@@ -564,8 +564,8 @@
return SYSERR;
}
memset(&l,
- 0,
- sizeof(FSUI_UploadList));
+ 0,
+ sizeof(FSUI_UploadList));
READINT(l.state);
fixState(&l.state);
if (l.state == FSUI_PENDING)
@@ -584,47 +584,47 @@
if ( (big & 4) == 4) {
l.keywords = read_uri(ctx->ectx, fd);
if (l.keywords == NULL) {
- if (l.uri != NULL)
- ECRS_freeUri(l.uri);
- GE_BREAK(NULL, 0);
- break;
+ if (l.uri != NULL)
+ ECRS_freeUri(l.uri);
+ GE_BREAK(NULL, 0);
+ break;
}
}
if ( (big & 8) == 8) {
l.meta = read_meta(ctx->ectx, fd);
if (l.meta == NULL) {
- if (l.uri != NULL)
- ECRS_freeUri(l.uri);
- if (l.keywords != NULL)
- ECRS_freeUri(l.keywords);
- GE_BREAK(NULL, 0);
- break;
+ if (l.uri != NULL)
+ ECRS_freeUri(l.uri);
+ if (l.keywords != NULL)
+ ECRS_freeUri(l.keywords);
+ GE_BREAK(NULL, 0);
+ break;
}
}
l.filename = read_string(fd, 1024*1024);
if (l.filename == NULL) {
if (l.uri != NULL)
- ECRS_freeUri(l.uri);
+ ECRS_freeUri(l.uri);
if (l.meta != NULL)
- ECRS_freeMetaData(l.meta);
+ ECRS_freeMetaData(l.meta);
if (l.keywords != NULL)
- ECRS_freeUri(l.keywords);
+ ECRS_freeUri(l.keywords);
GE_BREAK(NULL, 0);
break;
}
list = MALLOC(sizeof(struct FSUI_UploadList));
memcpy(list,
- &l,
- sizeof(struct FSUI_UploadList));
+ &l,
+ sizeof(struct FSUI_UploadList));
list->shared = shared;
list->parent = parent;
if (OK != readUploadList(ctx,
- list,
- fd,
- shared,
- NO)) {
+ list,
+ fd,
+ shared,
+ NO)) {
if (l.uri != NULL)
- ECRS_freeUri(l.uri);
+ ECRS_freeUri(l.uri);
FREE(l.filename);
FREE(list);
GE_BREAK(NULL, 0);
@@ -640,15 +640,15 @@
static int readUploads(int fd,
- struct FSUI_Context * ctx) {
+ struct FSUI_Context * ctx) {
int big;
int bag;
struct FSUI_UploadShared * shared;
struct FSUI_UploadShared sshared;
memset(&ctx->activeUploads,
- 0,
- sizeof(FSUI_UploadList));
+ 0,
+ sizeof(FSUI_UploadList));
while (1) {
READINT(big);
if (big == 0)
@@ -663,8 +663,8 @@
return SYSERR;
}
memset(&sshared,
- 0,
- sizeof(FSUI_UploadShared));
+ 0,
+ sizeof(FSUI_UploadShared));
READINT(sshared.doIndex);
READINT(sshared.anonymityLevel);
READINT(sshared.priority);
@@ -675,29 +675,29 @@
if ((big & 4) == 4) {
sshared.global_keywords = read_uri(ctx->ectx, fd);
if (sshared.global_keywords == NULL) {
- FREENONNULL(sshared.extractor_config);
- GE_BREAK(NULL, 0);
- return SYSERR;
+ FREENONNULL(sshared.extractor_config);
+ GE_BREAK(NULL, 0);
+ return SYSERR;
}
}
shared = MALLOC(sizeof(FSUI_UploadShared));
memcpy(shared,
- &sshared,
- sizeof(FSUI_UploadShared));
+ &sshared,
+ sizeof(FSUI_UploadShared));
shared->ctx = ctx;
if (OK != readUploadList(ctx,
- &ctx->activeUploads,
- fd,
- shared,
- YES)) {
+ &ctx->activeUploads,
+ fd,
+ shared,
+ YES)) {
GE_BREAK(NULL, 0);
#if 0
/* cannot do this, readUploadList
- may have added *some* uploads that
- still reference shared -- need to
- find and cleanup those first,
- or at least detect their presence
- and not free */
+ may have added *some* uploads that
+ still reference shared -- need to
+ find and cleanup those first,
+ or at least detect their presence
+ and not free */
FREE(shared->extractor_config);
FREE(shared);
#endif
@@ -708,7 +708,7 @@
}
static int readUnindex(int fd,
- struct FSUI_Context * ctx) {
+ struct FSUI_Context * ctx) {
int big;
char * name;
struct FSUI_UnindexList * ul;
@@ -737,8 +737,8 @@
if (0 != ACCESS(ctx->name, R_OK))
return;
fd = disk_file_open(ctx->ectx,
- ctx->name,
- O_RDONLY);
+ ctx->name,
+ O_RDONLY);
if (fd == -1)
return;
@@ -750,10 +750,10 @@
(OK != readUploads(fd, ctx) ) ) {
GE_BREAK(ctx->ectx, 0);
GE_LOG(ctx->ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("FSUI state file `%s' had syntax error at offset %u.\n"),
- ctx->name,
- lseek(fd, 0, SEEK_CUR));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("FSUI state file `%s' had syntax error at offset %u.\n"),
+ ctx->name,
+ lseek(fd, 0, SEEK_CUR));
}
CLOSE(fd);
UNLINK(ctx->name);
Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/fsui/download.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -39,17 +39,17 @@
* in URITRACK.
*/
static int listURIfoundDirectory(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * prnt) {
+ const HashCode512 * key,
+ int isRoot,
+ void * prnt) {
FSUI_DownloadList * dl = prnt;
if (isRoot == YES)
return OK; /* namespace ad, ignore */
URITRACK_addState(dl->ctx->ectx,
- dl->ctx->cfg,
- fi->uri,
- URITRACK_DIRECTORY_FOUND);
+ dl->ctx->cfg,
+ fi->uri,
+ URITRACK_DIRECTORY_FOUND);
return OK;
}
@@ -61,22 +61,22 @@
*/
static FSUI_DownloadList *
startDownload(struct FSUI_Context * ctx,
- unsigned int anonymityLevel,
- int is_recursive,
- const struct ECRS_URI * uri,
- const struct ECRS_MetaData * meta,
- const char * filename,
- struct FSUI_SearchList * psearch,
- FSUI_DownloadList * parent);
+ unsigned int anonymityLevel,
+ int is_recursive,
+ const struct ECRS_URI * uri,
+ const struct ECRS_MetaData * meta,
+ const char * filename,
+ struct FSUI_SearchList * psearch,
+ FSUI_DownloadList * parent);
/**
* Initiate a (recursive) download of the given
* directory entry.
*/
static int triggerRecursiveDownload(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * prnt) {
+ const HashCode512 * key,
+ int isRoot,
+ void * prnt) {
FSUI_DownloadList * parent = prnt;
struct GE_Context * ectx;
int i;
@@ -90,51 +90,51 @@
return OK; /* namespace ad, ignore */
URITRACK_trackURI(ectx,
- parent->ctx->cfg,
- fi);
+ parent->ctx->cfg,
+ fi);
for (i=0;i<parent->completedDownloadsCount;i++)
if (ECRS_equalsUri(parent->completedDownloads[i],
- fi->uri))
+ fi->uri))
return OK; /* already complete! */
pos = parent->child;
while (pos != NULL) {
if (ECRS_equalsUri(pos->fi.uri,
- fi->uri))
+ fi->uri))
return OK; /* already downloading */
pos = pos->next;
}
filename = ECRS_getFromMetaData(fi->meta,
- EXTRACTOR_FILENAME);
+ EXTRACTOR_FILENAME);
if (filename == NULL) {
char * tmp = ECRS_uriToString(fi->uri);
GE_ASSERT(ectx,
- strlen(tmp) >= strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX));
+ strlen(tmp) >= strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX));
filename = STRDUP(&tmp[strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX)]);
FREE(tmp);
}
fullName = MALLOC(strlen(parent->filename) + 2
- + strlen(filename));
+ + strlen(filename));
strcpy(fullName,
- parent->filename);
+ parent->filename);
strcat(fullName,
- filename);
+ filename);
while (NULL != (dotdot = strstr(fullName, "..")))
dotdot[0] = dotdot[1] = '_';
FREE(filename);
#if DEBUG_DTM
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Starting recursive download of `%s'\n",
- fullName);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Starting recursive download of `%s'\n",
+ fullName);
#endif
startDownload(parent->ctx,
- parent->anonymityLevel,
- YES,
- fi->uri,
- fi->meta,
- fullName,
- parent->search,
- parent);
+ parent->anonymityLevel,
+ YES,
+ fi->uri,
+ fi->meta,
+ fullName,
+ parent->search,
+ parent);
FREE(fullName);
return OK;
}
@@ -144,12 +144,12 @@
*/
static void
downloadProgressCallback(unsigned long long totalBytes,
- unsigned long long completedBytes,
- cron_t eta,
- unsigned long long lastBlockOffset,
- const char * lastBlock,
- unsigned int lastBlockSize,
- void * cls) {
+ unsigned long long completedBytes,
+ cron_t eta,
+ unsigned long long lastBlockOffset,
+ const char * lastBlock,
+ unsigned int lastBlockSize,
+ void * cls) {
FSUI_DownloadList * dl = cls;
FSUI_Event event;
struct ECRS_MetaData * md;
@@ -157,7 +157,7 @@
cron_t run_time;
GE_ASSERT(dl->ctx->ectx,
- dl->total == totalBytes);
+ dl->total == totalBytes);
dl->completed = completedBytes;
event.type = FSUI_download_progress;
event.data.DownloadProgress.dc.pos = dl;
@@ -175,8 +175,8 @@
eta = now;
} else {
eta = (cron_t) (dl->startTime +
- (((double)(run_time)/(double)dl->completed))
- * (double)dl->total);
+ (((double)(run_time)/(double)dl->completed))
+ * (double)dl->total);
if (eta < now)
eta = now;
}
@@ -186,14 +186,14 @@
event.data.DownloadProgress.last_block = lastBlock;
event.data.DownloadProgress.last_size = lastBlockSize;
dl->ctx->ecb(dl->ctx->ecbClosure,
- &event);
+ &event);
if ( (lastBlockOffset == 0) &&
(dl->is_directory == SYSERR) ) {
/* check if this is a directory */
if ( (lastBlockSize > strlen(GNUNET_DIRECTORY_MAGIC)) &&
- (0 == strncmp(GNUNET_DIRECTORY_MAGIC,
- lastBlock,
- strlen(GNUNET_DIRECTORY_MAGIC)) ) )
+ (0 == strncmp(GNUNET_DIRECTORY_MAGIC,
+ lastBlock,
+ strlen(GNUNET_DIRECTORY_MAGIC)) ) )
dl->is_directory = YES;
else
dl->is_directory = NO;
@@ -201,11 +201,11 @@
if (dl->is_directory == YES) {
md = NULL;
ECRS_listDirectory(dl->ctx->ectx,
- lastBlock,
- lastBlockSize,
- &md,
- &listURIfoundDirectory,
- dl);
+ lastBlock,
+ lastBlockSize,
+ &md,
+ &listURIfoundDirectory,
+ dl);
if (md != NULL)
ECRS_freeMetaData(md);
}
@@ -214,11 +214,11 @@
md = NULL;
MUTEX_LOCK(dl->ctx->lock);
ECRS_listDirectory(dl->ctx->ectx,
- lastBlock,
- lastBlockSize,
- &md,
- &triggerRecursiveDownload,
- dl);
+ lastBlock,
+ lastBlockSize,
+ &md,
+ &triggerRecursiveDownload,
+ dl);
MUTEX_UNLOCK(dl->ctx->lock);
if (md != NULL)
ECRS_freeMetaData(md);
@@ -255,24 +255,24 @@
ectx = dl->ctx->ectx;
#if DEBUG_DTM
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Download thread for `%s' started...\n",
- dl->filename);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Download thread for `%s' started...\n",
+ dl->filename);
#endif
GE_ASSERT(ectx, dl->ctx != NULL);
GE_ASSERT(ectx, dl->filename != NULL);
mem = GE_memory_create(2);
ee = GE_create_context_memory(GE_USER | GE_ADMIN | GE_ERROR | GE_WARNING |
GE_FATAL | GE_BULK | GE_IMMEDIATE,
- mem);
+ mem);
ret = ECRS_downloadFile(ee,
- dl->ctx->cfg,
- dl->fi.uri,
- dl->filename,
- dl->anonymityLevel,
- &downloadProgressCallback,
- dl,
- &testTerminate,
- dl);
+ dl->ctx->cfg,
+ dl->fi.uri,
+ dl->filename,
+ dl->anonymityLevel,
+ &downloadProgressCallback,
+ dl,
+ &testTerminate,
+ dl);
if (ret == OK) {
dl->state = FSUI_COMPLETED;
event.type = FSUI_download_completed;
@@ -286,11 +286,11 @@
event.data.DownloadCompleted.filename = dl->filename;
event.data.DownloadCompleted.uri = dl->fi.uri;
URITRACK_addState(dl->ctx->ectx,
- dl->ctx->cfg,
- dl->fi.uri,
- URITRACK_DOWNLOAD_COMPLETED);
+ dl->ctx->cfg,
+ dl->fi.uri,
+ URITRACK_DOWNLOAD_COMPLETED);
dl->ctx->ecb(dl->ctx->ecbClosure,
- &event);
+ &event);
} else if (dl->state == FSUI_ACTIVE) {
const char * error;
@@ -308,11 +308,11 @@
error = _("Download failed (no reason given)");
event.data.DownloadError.message = error;
URITRACK_addState(dl->ctx->ectx,
- dl->ctx->cfg,
- dl->fi.uri,
- URITRACK_DOWNLOAD_ABORTED);
+ dl->ctx->cfg,
+ dl->fi.uri,
+ URITRACK_DOWNLOAD_ABORTED);
dl->ctx->ecb(dl->ctx->ecbClosure,
- &event);
+ &event);
} else if (dl->state == FSUI_ABORTED) { /* aborted */
event.type = FSUI_download_aborted;
event.data.DownloadAborted.dc.pos = dl;
@@ -322,11 +322,11 @@
event.data.DownloadAborted.dc.spos = dl->search;
event.data.DownloadAborted.dc.sctx = dl->search == NULL ? NULL :
dl->search->cctx;
URITRACK_addState(dl->ctx->ectx,
- dl->ctx->cfg,
- dl->fi.uri,
- URITRACK_DOWNLOAD_ABORTED);
+ dl->ctx->cfg,
+ dl->fi.uri,
+ URITRACK_DOWNLOAD_ABORTED);
dl->ctx->ecb(dl->ctx->ecbClosure,
- &event);
+ &event);
} else {
/* else: suspended */
GE_BREAK(NULL, dl->state == FSUI_SUSPENDING);
@@ -351,45 +351,45 @@
strcat(fn, GNUNET_DIRECTORY_EXT);
}
fd = disk_file_open(ectx,
- fn,
- O_LARGEFILE | O_RDONLY);
+ fn,
+ O_LARGEFILE | O_RDONLY);
if (fd != -1) {
dirBlock = MMAP(NULL,
- totalBytes,
- PROT_READ,
- MAP_SHARED,
- fd,
- 0);
+ totalBytes,
+ PROT_READ,
+ MAP_SHARED,
+ fd,
+ 0);
if (MAP_FAILED == dirBlock) {
- GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_BULK | GE_ADMIN | GE_USER,
- "mmap",
- fn);
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_ERROR | GE_BULK | GE_ADMIN | GE_USER,
+ "mmap",
+ fn);
} else {
- md = NULL;
- ECRS_listDirectory(dl->ctx->ectx,
- dirBlock,
- totalBytes,
- &md,
- &listURIfoundDirectory,
- dl);
- if (md != NULL)
- ECRS_freeMetaData(md);
-
- if (dl->is_recursive) {
- /* load directory, start downloads */
- md = NULL;
- MUTEX_LOCK(dl->ctx->lock);
- ECRS_listDirectory(dl->ctx->ectx,
- dirBlock,
- totalBytes,
- &md,
- &triggerRecursiveDownload,
- dl);
- MUTEX_UNLOCK(dl->ctx->lock);
- ECRS_freeMetaData(md);
- MUNMAP(dirBlock, totalBytes);
- }
+ md = NULL;
+ ECRS_listDirectory(dl->ctx->ectx,
+ dirBlock,
+ totalBytes,
+ &md,
+ &listURIfoundDirectory,
+ dl);
+ if (md != NULL)
+ ECRS_freeMetaData(md);
+
+ if (dl->is_recursive) {
+ /* load directory, start downloads */
+ md = NULL;
+ MUTEX_LOCK(dl->ctx->lock);
+ ECRS_listDirectory(dl->ctx->ectx,
+ dirBlock,
+ totalBytes,
+ &md,
+ &triggerRecursiveDownload,
+ dl);
+ MUTEX_UNLOCK(dl->ctx->lock);
+ ECRS_freeMetaData(md);
+ MUNMAP(dirBlock, totalBytes);
+ }
}
CLOSE(fd);
}
@@ -397,10 +397,10 @@
}
#if DEBUG_DTM
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Download thread for `%s' terminated (%s)...\n",
- dl->filename,
- ret == OK ? "COMPLETED" : "ABORTED");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Download thread for `%s' terminated (%s)...\n",
+ dl->filename,
+ ret == OK ? "COMPLETED" : "ABORTED");
#endif
dl->runTime = get_time() - dl->startTime;
GE_free_context(ee);
@@ -413,27 +413,27 @@
*/
static FSUI_DownloadList *
startDownload(struct FSUI_Context * ctx,
- unsigned int anonymityLevel,
- int is_recursive,
- const struct ECRS_URI * uri,
- const struct ECRS_MetaData * meta,
- const char * filename,
- struct FSUI_SearchList * psearch,
- FSUI_DownloadList * parent) {
+ unsigned int anonymityLevel,
+ int is_recursive,
+ const struct ECRS_URI * uri,
+ const struct ECRS_MetaData * meta,
+ const char * filename,
+ struct FSUI_SearchList * psearch,
+ FSUI_DownloadList * parent) {
FSUI_DownloadList * dl;
FSUI_Event event;
GE_ASSERT(NULL, ctx != NULL);
GE_ASSERT(NULL, parent != NULL);
if (! (ECRS_isFileUri(uri) ||
- ECRS_isLocationUri(uri)) ) {
+ ECRS_isLocationUri(uri)) ) {
GE_BREAK(NULL, 0); /* wrong type of URI! */
return NULL;
}
dl = MALLOC(sizeof(FSUI_DownloadList));
memset(dl,
- 0,
- sizeof(FSUI_DownloadList));
+ 0,
+ sizeof(FSUI_DownloadList));
dl->startTime = 0; /* not run at all so far! */
dl->runTime = 0; /* not run at all so far! */
dl->state = FSUI_PENDING;
@@ -463,17 +463,17 @@
event.data.DownloadStarted.fi.meta = dl->fi.meta;
event.data.DownloadStarted.anonymityLevel = dl->anonymityLevel;
URITRACK_addState(ctx->ectx,
- ctx->cfg,
- uri,
- URITRACK_DOWNLOAD_STARTED);
+ ctx->cfg,
+ uri,
+ URITRACK_DOWNLOAD_STARTED);
dl->cctx = dl->ctx->ecb(dl->ctx->ecbClosure,
- &event);
+ &event);
dl->next = parent->child;
parent->child = dl;
if (psearch != NULL) {
GROW(psearch->my_downloads,
- psearch->my_downloads_size,
- psearch->my_downloads_size + 1);
+ psearch->my_downloads_size,
+ psearch->my_downloads_size + 1);
psearch->my_downloads[psearch->my_downloads_size -1] = dl;
}
return dl;
@@ -488,26 +488,26 @@
*/
struct FSUI_DownloadList *
FSUI_startDownload(struct FSUI_Context * ctx,
- unsigned int anonymityLevel,
- int doRecursive,
- const struct ECRS_URI * uri,
- const struct ECRS_MetaData * meta,
- const char * filename,
- struct FSUI_SearchList * psearch,
- struct FSUI_DownloadList * pdownload) {
+ unsigned int anonymityLevel,
+ int doRecursive,
+ const struct ECRS_URI * uri,
+ const struct ECRS_MetaData * meta,
+ const char * filename,
+ struct FSUI_SearchList * psearch,
+ struct FSUI_DownloadList * pdownload) {
struct FSUI_DownloadList * ret;
MUTEX_LOCK(ctx->lock);
if (pdownload == NULL)
pdownload = &ctx->activeDownloads;
ret = startDownload(ctx,
- anonymityLevel,
- doRecursive,
- uri,
- meta,
- filename,
- psearch,
- pdownload);
+ anonymityLevel,
+ doRecursive,
+ uri,
+ meta,
+ filename,
+ psearch,
+ pdownload);
MUTEX_UNLOCK(ctx->lock);
return ret;
}
@@ -531,56 +531,56 @@
#if DEBUG_DTM
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Download thread manager investigates pending download of file `%s'
(%u/%u downloads)\n",
- list->filename,
- list->ctx->activeDownloadThreads,
- list->ctx->threadPoolSize);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Download thread manager investigates pending download of file `%s' (%u/%u
downloads)\n",
+ list->filename,
+ list->ctx->activeDownloadThreads,
+ list->ctx->threadPoolSize);
#endif
ret = NO;
/* should this one be started? */
if ( (list->ctx->threadPoolSize
- > list->ctx->activeDownloadThreads) &&
+ > list->ctx->activeDownloadThreads) &&
(list->state == FSUI_PENDING) &&
( (list->total > list->completed) ||
(list->total == 0) ) ) {
#if DEBUG_DTM
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Download thread manager starts download of file `%s'\n",
- list->filename);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Download thread manager starts download of file `%s'\n",
+ list->filename);
#endif
list->state = FSUI_ACTIVE;
list->handle = PTHREAD_CREATE(&downloadThread,
- list,
- 128 * 1024);
+ list,
+ 128 * 1024);
if (list->handle != NULL) {
list->ctx->activeDownloadThreads++;
} else {
GE_LOG_STRERROR(ectx,
- GE_ADMIN | GE_USER | GE_BULK | GE_ERROR,
- "pthread_create");
+ GE_ADMIN | GE_USER | GE_BULK | GE_ERROR,
+ "pthread_create");
list->state = FSUI_ERROR_JOINED;
}
}
/* should this one be stopped? */
if ( (list->ctx->threadPoolSize
- < list->ctx->activeDownloadThreads) &&
+ < list->ctx->activeDownloadThreads) &&
(list->state == FSUI_ACTIVE) ) {
#if DEBUG_DTM
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Download thread manager aborts active download of file `%s' (%u/%u
downloads)\n",
- list->filename,
- list->ctx->activeDownloadThreads,
- list->ctx->threadPoolSize);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Download thread manager aborts active download of file `%s' (%u/%u
downloads)\n",
+ list->filename,
+ list->ctx->activeDownloadThreads,
+ list->ctx->threadPoolSize);
#endif
list->state = FSUI_SUSPENDING;
GE_ASSERT(ectx, list->handle != NULL);
PTHREAD_STOP_SLEEP(list->handle);
PTHREAD_JOIN(list->handle,
- &unused);
+ &unused);
list->handle = NULL;
list->ctx->activeDownloadThreads--;
list->state = FSUI_PENDING;
@@ -593,12 +593,12 @@
(list->state == FSUI_ERROR) ) {
#if DEBUG_DTM
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Download thread manager collects inactive download of file `%s'\n",
- list->filename);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Download thread manager collects inactive download of file `%s'\n",
+ list->filename);
#endif
PTHREAD_JOIN(list->handle,
- &unused);
+ &unused);
list->handle = NULL;
list->ctx->activeDownloadThreads--;
list->state++; /* adds _JOINED */
@@ -622,7 +622,7 @@
* NO if the download has already finished
*/
int FSUI_abortDownload(struct FSUI_Context * ctx,
- struct FSUI_DownloadList * dl) {
+ struct FSUI_DownloadList * dl) {
struct FSUI_DownloadList * c;
GE_ASSERT(ctx->ectx, dl != NULL);
@@ -650,7 +650,7 @@
* @return SYSERR if no such download is pending
*/
int FSUI_stopDownload(struct FSUI_Context * ctx,
- struct FSUI_DownloadList * dl) {
+ struct FSUI_DownloadList * dl) {
void * unused;
struct FSUI_DownloadList * prev;
FSUI_Event event;
@@ -659,18 +659,18 @@
GE_ASSERT(ctx->ectx, dl != NULL);
while (dl->child != NULL)
FSUI_stopDownload(ctx,
- dl->child);
+ dl->child);
MUTEX_LOCK(ctx->lock);
prev = (dl->parent != NULL) ? dl->parent->child : ctx->activeDownloads.child;
while ( (prev != dl) &&
- (prev != NULL) &&
- (prev->next != dl) )
+ (prev != NULL) &&
+ (prev->next != dl) )
prev = prev->next;
if (prev == NULL) {
MUTEX_UNLOCK(ctx->lock);
GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSUI_stopDownload failed to locate download.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSUI_stopDownload failed to locate download.\n");
return SYSERR;
}
if (prev == dl)
@@ -684,7 +684,7 @@
(dl->state == FSUI_ERROR) ) {
GE_ASSERT(ctx->ectx, dl->handle != NULL);
PTHREAD_JOIN(dl->handle,
- &unused);
+ &unused);
MUTEX_LOCK(ctx->lock);
dl->ctx->activeDownloadThreads--;
MUTEX_UNLOCK(ctx->lock);
@@ -704,15 +704,15 @@
event.data.DownloadStopped.dc.spos = dl->search;
event.data.DownloadStopped.dc.sctx = dl->search == NULL ? NULL :
dl->search->cctx;
ctx->ecb(ctx->ecbClosure,
- &event);
+ &event);
if (dl->search != NULL) {
for (i=0;i<dl->search->my_downloads_size;i++) {
if (dl->search->my_downloads[i] == dl) {
- dl->search->my_downloads[i] =
- dl->search->my_downloads[dl->search->my_downloads_size -1];
- GROW(dl->search->my_downloads,
- dl->search->my_downloads_size,
- dl->search->my_downloads_size - 1);
+ dl->search->my_downloads[i] =
+ dl->search->my_downloads[dl->search->my_downloads_size -1];
+ GROW(dl->search->my_downloads,
+ dl->search->my_downloads_size,
+ dl->search->my_downloads_size - 1);
}
}
}
Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -44,9 +44,9 @@
fn = MALLOC(strlen("/tmp/gnunet-fsui-downloadtest/FSUITEST") + 14);
SNPRINTF(fn,
- strlen("/tmp/gnunet-fsui-downloadtest/FSUITEST") + 14,
- "/tmp/gnunet-fsui-downloadtest/FSUITEST%u",
- i);
+ strlen("/tmp/gnunet-fsui-downloadtest/FSUITEST") + 14,
+ "/tmp/gnunet-fsui-downloadtest/FSUITEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -59,7 +59,7 @@
static struct FSUI_DownloadList * download;
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
char * fn;
switch(event->type) {
@@ -87,7 +87,7 @@
#endif
if (download == NULL) {
fprintf(stderr,
- "ERROR: Search completed but download not started!\n");
+ "ERROR: Search completed but download not started!\n");
}
break;
case FSUI_search_result:
@@ -98,11 +98,11 @@
char * u;
if (! ECRS_equalsUri(upURI,
- event->data.SearchResult.fi.uri)) {
+ event->data.SearchResult.fi.uri)) {
#if DEBUG_VERBOSE
- printf("Received search result for different file (download not
started).\n");
+ printf("Received search result for different file (download not
started).\n");
#endif
- return NULL; /* ignore */
+ return NULL; /* ignore */
}
fn = makeName(43);
u = ECRS_uriToString(event->data.SearchResult.fi.uri);
@@ -111,16 +111,16 @@
#endif
FREE(u);
download = FSUI_startDownload(ctx,
- 0,
- NO,
- event->data.SearchResult.fi.uri,
- event->data.SearchResult.fi.meta,
- fn,
- NULL,
- NULL);
+ 0,
+ NO,
+ event->data.SearchResult.fi.uri,
+ event->data.SearchResult.fi.meta,
+ fn,
+ NULL,
+ NULL);
if (download == NULL) {
- GE_BREAK(ectx, 0);
- return NULL;
+ GE_BREAK(ectx, 0);
+ return NULL;
}
FREE(fn);
suspendRestart = 4;
@@ -129,8 +129,8 @@
case FSUI_upload_progress:
#if DEBUG_VERBOSE
printf("Upload is progressing (%llu/%llu)...\n",
- event->data.UploadProgress.completed,
- event->data.UploadProgress.total);
+ event->data.UploadProgress.completed,
+ event->data.UploadProgress.total);
#endif
break;
case FSUI_upload_completed:
@@ -144,23 +144,23 @@
printf("Download complete.\n");
#endif
FSUI_abortSearch(ctx,
- search);
+ search);
FSUI_stopSearch(ctx,
- search);
+ search);
search = NULL;
break;
case FSUI_download_progress:
#if DEBUG_VERBOSE
printf("Download is progressing (%llu/%llu)...\n",
- event->data.DownloadProgress.completed,
- event->data.DownloadProgress.total);
+ event->data.DownloadProgress.completed,
+ event->data.DownloadProgress.total);
#endif
break;
case FSUI_unindex_progress:
#if DEBUG_VERBOSE
printf("Unindex is progressing (%llu/%llu)...\n",
- event->data.UnindexProgress.completed,
- event->data.UnindexProgress.total);
+ event->data.UnindexProgress.completed,
+ event->data.UnindexProgress.total);
#endif
break;
case FSUI_unindex_completed:
@@ -173,8 +173,8 @@
case FSUI_download_error:
case FSUI_search_error:
fprintf(stderr,
- "Received ERROR: %d\n",
- event->type);
+ "Received ERROR: %d\n",
+ event->type);
GE_BREAK(ectx, 0);
break;
case FSUI_download_aborted:
@@ -186,8 +186,8 @@
case FSUI_upload_suspended:
#if DEBUG_VERBOSE
fprintf(stderr,
- "Received SUSPENDING: %d\n",
- event->type);
+ "Received SUSPENDING: %d\n",
+ event->type);
#endif
break;
case FSUI_upload_started:
@@ -202,7 +202,7 @@
break;
default:
printf("Unexpected event: %d\n",
- event->type);
+ event->type);
break;
}
if (lastEvent == waitForEvent)
@@ -240,58 +240,58 @@
ok = YES;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS));
+ cfg,
+ 30 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
#endif
ctx = FSUI_start(NULL,
- cfg,
- "fsuidownloadtest",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "fsuidownloadtest",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
CHECK(ctx != NULL);
fn = makeName(42);
buf = MALLOC(FILESIZE);
for (i=0;i<FILESIZE;i++)
buf[i] = weak_randomi(256);
disk_file_write(ectx,
- fn,
- buf,
- FILESIZE,
- "600");
+ fn,
+ buf,
+ FILESIZE,
+ "600");
FREE(buf);
meta = ECRS_createMetaData();
kuri = ECRS_parseListKeywordURI(ectx,
- 2,
- (const char**)keywords);
+ 2,
+ (const char**)keywords);
waitForEvent = FSUI_upload_completed;
upload = FSUI_startUpload(ctx,
- fn,
- (DirectoryScanCallback) &disk_directory_scan,
- NULL,
- 0,
- 0,
- YES,
- NO,
- NO,
- get_time() + 5 * cronHOURS,
- meta,
- kuri,
- kuri);
+ fn,
+ (DirectoryScanCallback) &disk_directory_scan,
+ NULL,
+ 0,
+ 0,
+ YES,
+ NO,
+ NO,
+ get_time() + 5 * cronHOURS,
+ meta,
+ kuri,
+ kuri);
CHECK(upload != NULL);
ECRS_freeUri(kuri);
kuri = NULL;
@@ -306,19 +306,19 @@
}
FSUI_stopUpload(ctx, upload);
SNPRINTF(keyword,
- 40,
- "%s %s %s",
- keywords[0],
- _("AND"),
- keywords[1]);
+ 40,
+ "%s %s %s",
+ keywords[0],
+ _("AND"),
+ keywords[1]);
uri = ECRS_parseCharKeywordURI(ectx,
- keyword);
+ keyword);
waitForEvent = FSUI_download_completed;
search = FSUI_startSearch(ctx,
- 0,
- 10000,
- 240 * cronSECONDS,
- uri);
+ 0,
+ 10000,
+ 240 * cronSECONDS,
+ uri);
CHECK(search != NULL);
prog = 0;
while (search != NULL) {
@@ -326,22 +326,22 @@
CHECK(prog < 10000);
PTHREAD_SLEEP(50 * cronMILLIS);
if ( (suspendRestart > 0) &&
- (weak_randomi(4) == 0) ) {
+ (weak_randomi(4) == 0) ) {
#if 1
#if DEBUG_VERBOSE
printf("Testing FSUI suspend-resume\n");
#endif
FSUI_stop(ctx); /* download possibly incomplete
- at this point, thus testing resume */
+ at this point, thus testing resume */
CHECK(search == NULL);
CHECK(download == NULL);
ctx = FSUI_start(NULL,
- cfg,
- "fsuidownloadtest",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "fsuidownloadtest",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
#if DEBUG_VERBOSE
printf("Resumed...\n");
#endif
@@ -371,10 +371,10 @@
if (ctx != NULL) {
if (unindex != NULL)
FSUI_stopUnindex(ctx,
- unindex);
+ unindex);
if (download != NULL)
FSUI_stopDownload(ctx,
- download);
+ download);
FSUI_stop(ctx);
}
if (fn != NULL) {
Modified: GNUnet/src/applications/fs/fsui/fsui-loader.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui-loader.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/fsui/fsui-loader.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -29,7 +29,7 @@
#include "gnunet_util_config_impl.h"
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
#if 0
switch(event->type) {
case FSUI_search_result:
@@ -53,7 +53,7 @@
}
int main(int argc,
- char * argv[]) {
+ char * argv[]) {
struct FSUI_Context * ctx;
struct GC_Configuration * cfg;
@@ -61,21 +61,21 @@
cfg = GC_create_C_impl();
if (argc != 2) {
fprintf(stderr,
- "Call with name of FSUI resource file!\n");
+ "Call with name of FSUI resource file!\n");
return -1;
}
ctx = FSUI_start(NULL,
- cfg,
- argv[1],
- 16,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ argv[1],
+ 16,
+ YES,
+ &eventCallback,
+ NULL);
if (ctx != NULL)
FSUI_stop(ctx);
else
fprintf(stderr,
- "FSUI_start failed!\n");
+ "FSUI_start failed!\n");
GC_free(cfg);
return (ctx == NULL);
}
Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/fsui/fsui.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -47,8 +47,8 @@
#if DEBUG_PERSISTENCE
if (dpos != NULL)
GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Download thread manager schedules pending downloads...\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Download thread manager schedules pending downloads...\n");
#endif
while (dpos != NULL) {
FSUI_updateDownloadThread(dpos);
@@ -60,7 +60,7 @@
/* ******************* START code *********************** */
static void signalDownloadResume(struct FSUI_DownloadList * ret,
- FSUI_Context * ctx) {
+ FSUI_Context * ctx) {
FSUI_Event event;
cron_t now;
cron_t eta;
@@ -81,10 +81,10 @@
eta = now;
} else {
eta = (cron_t) (now - ret->runTime +
- (((double)(ret->runTime)/(double)ret->completed))
- * (double)ret->total);
+ (((double)(ret->runTime)/(double)ret->completed))
+ * (double)ret->total);
if (eta < now)
- eta = now;
+ eta = now;
}
event.data.DownloadResumed.eta = eta;
event.data.DownloadResumed.filename = ret->filename;
@@ -94,13 +94,13 @@
ret->cctx = ctx->ecb(ctx->ecbClosure, &event);
if (ret->child != NULL)
signalDownloadResume(ret->child,
- ctx);
+ ctx);
ret = ret->next;
}
}
static void signalUploadResume(struct FSUI_UploadList * ret,
- FSUI_Context * ctx) {
+ FSUI_Context * ctx) {
FSUI_Event event;
cron_t now;
cron_t eta;
@@ -120,10 +120,10 @@
eta = now;
} else {
eta = (cron_t) (ret->start_time +
- (((double)(now - ret->start_time)/(double)ret->completed))
- * (double)ret->total);
+ (((double)(now - ret->start_time)/(double)ret->completed))
+ * (double)ret->total);
if (eta < now)
- eta = now;
+ eta = now;
}
event.data.UploadResumed.eta = eta;
event.data.UploadResumed.anonymityLevel = ret->shared->anonymityLevel;
@@ -131,7 +131,7 @@
ret->cctx = ctx->ecb(ctx->ecbClosure, &event);
if (ret->child != NULL)
signalUploadResume(ret->child,
- ctx);
+ ctx);
ret = ret->next;
}
}
@@ -142,16 +142,16 @@
* threads below are controlled by the parent.
*/
static void doResumeUploads(struct FSUI_UploadList * ret,
- FSUI_Context * ctx) {
+ FSUI_Context * ctx) {
while (ret != NULL) {
if (ret->state == FSUI_ACTIVE) {
ret->shared->handle = PTHREAD_CREATE(&FSUI_uploadThread,
- ret,
- 128 * 1024);
+ ret,
+ 128 * 1024);
if (ret->shared->handle == NULL)
- GE_DIE_STRERROR(ctx->ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "pthread_create");
+ GE_DIE_STRERROR(ctx->ectx,
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "pthread_create");
}
ret = ret->next;
}
@@ -166,12 +166,12 @@
* @return NULL on error
*/
struct FSUI_Context * FSUI_start(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * name,
- unsigned int threadPoolSize,
- int doResume,
- FSUI_EventCallback cb,
- void * closure) {
+ struct GC_Configuration * cfg,
+ const char * name,
+ unsigned int threadPoolSize,
+ int doResume,
+ FSUI_EventCallback cb,
+ void * closure) {
FSUI_Event event;
FSUI_Context * ret;
FSUI_SearchList * list;
@@ -183,8 +183,8 @@
GE_ASSERT(ectx, cfg != NULL);
ret = MALLOC(sizeof(FSUI_Context));
memset(ret,
- 0,
- sizeof(FSUI_Context));
+ 0,
+ sizeof(FSUI_Context));
ret->activeDownloads.state
= FSUI_PENDING; /* !? */
ret->activeDownloads.ctx = ret;
@@ -197,10 +197,10 @@
ret->activeDownloadThreads = 0;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &gh);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &gh);
disk_directory_create(ectx, gh);
fn = MALLOC(strlen(gh) + strlen(name) + 2 + 5);
strcpy(fn, gh);
@@ -212,19 +212,19 @@
/* 1) read state in */
if (doResume) {
ret->ipc = IPC_SEMAPHORE_CREATE(ectx,
- fn,
- 1);
+ fn,
+ 1);
#if DEBUG_PERSISTENCE
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- "Getting IPC lock for FSUI (%s).\n",
- fn);
+ GE_INFO | GE_REQUEST | GE_USER,
+ "Getting IPC lock for FSUI (%s).\n",
+ fn);
#endif
IPC_SEMAPHORE_DOWN(ret->ipc, YES);
#if DEBUG_PERSISTENCE
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- "Aquired IPC lock.\n");
+ GE_INFO | GE_REQUEST | GE_USER,
+ "Aquired IPC lock.\n");
#endif
strcat(fn, ".res");
FSUI_deserialize(ret);
@@ -236,7 +236,7 @@
/* 2) do resume events */
/* 2a) signal download restarts */
signalDownloadResume(ret->activeDownloads.child,
- ret);
+ ret);
/* 2b) signal search restarts */
list = ret->activeSearches;
while (list != NULL) {
@@ -253,14 +253,14 @@
}
/* 2c) signal upload restarts */
signalUploadResume(ret->activeUploads.child,
- ret);
+ ret);
/* 2d) signal unindex restarts */
xlist = ret->unindexOperations;
while (xlist != NULL) {
if (OK != disk_file_size(ectx,
- xlist->filename,
- &size,
- YES))
+ xlist->filename,
+ &size,
+ YES))
size = 0;
event.type = FSUI_unindex_resumed;
event.data.UnindexResumed.uc.pos = xlist;
@@ -270,7 +270,7 @@
event.data.UnindexResumed.eta = get_time();
event.data.UnindexResumed.filename = xlist->filename;
event.data.UnindexResumed.state = xlist->state;
- xlist->cctx = cb(closure, &event);
+ xlist->cctx = cb(closure, &event);
xlist = xlist->next;
}
@@ -278,26 +278,26 @@
ret->cron = cron_create(ectx);
/* 3a) resume downloads */
cron_add_job(ret->cron,
- &updateDownloadThreads,
- 0,
- FSUI_UDT_FREQUENCY,
- ret);
+ &updateDownloadThreads,
+ 0,
+ FSUI_UDT_FREQUENCY,
+ ret);
cron_start(ret->cron);
/* 3b) resume uploads */
doResumeUploads(ret->activeUploads.child,
- ret);
+ ret);
/* 3c) resume unindexing */
xlist = ret->unindexOperations;
while (xlist != NULL) {
if (xlist->state == FSUI_PENDING) {
xlist->state = FSUI_ACTIVE;
xlist->handle = PTHREAD_CREATE(&FSUI_unindexThread,
- xlist,
- 32 * 1024);
+ xlist,
+ 32 * 1024);
if (xlist->handle == NULL)
- GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "pthread_create");
+ GE_DIE_STRERROR(ectx,
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "pthread_create");
}
xlist = xlist->next;
}
@@ -307,12 +307,12 @@
if (list->state == FSUI_PENDING) {
list->state = FSUI_ACTIVE;
list->handle = PTHREAD_CREATE(&FSUI_searchThread,
- list,
- 32 * 1024);
+ list,
+ 32 * 1024);
if (list->handle == NULL)
- GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "pthread_create");
+ GE_DIE_STRERROR(ectx,
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "pthread_create");
}
list = list->next;
}
@@ -326,13 +326,13 @@
* (recursively) signal download suspension.
*/
static void signalDownloadSuspend(struct GE_Context * ectx,
- FSUI_Context * ctx,
- FSUI_DownloadList * list) {
+ FSUI_Context * ctx,
+ FSUI_DownloadList * list) {
FSUI_Event event;
while (list != NULL) {
signalDownloadSuspend(ectx,
- ctx,
- list->child);
+ ctx,
+ list->child);
event.type = FSUI_download_suspended;
event.data.DownloadSuspended.dc.pos = list;
event.data.DownloadSuspended.dc.cctx = list->cctx;
@@ -349,13 +349,13 @@
* (recursively) signal upload suspension.
*/
static void signalUploadSuspend(struct GE_Context * ectx,
- FSUI_Context * ctx,
- FSUI_UploadList * upos) {
+ FSUI_Context * ctx,
+ FSUI_UploadList * upos) {
FSUI_Event event;
while (upos != NULL) {
signalUploadSuspend(ectx,
- ctx,
- upos->child);
+ ctx,
+ upos->child);
event.type = FSUI_upload_suspended;
event.data.UploadSuspended.uc.pos = upos;
event.data.UploadSuspended.uc.cctx = upos->cctx;
@@ -381,8 +381,8 @@
for (i=0;i<list->completedDownloadsCount;i++)
ECRS_freeUri(list->completedDownloads[i]);
GROW(list->completedDownloads,
- list->completedDownloadsCount,
- 0);
+ list->completedDownloadsCount,
+ 0);
next = list->next;
FREE(list);
list = next;
@@ -393,7 +393,7 @@
* (recursively) free upload list
*/
static void freeUploadList(struct FSUI_Context * ctx,
- FSUI_UploadList * list) {
+ FSUI_UploadList * list) {
FSUI_UploadList * next;
FSUI_UploadShared * shared;
@@ -411,7 +411,7 @@
shared = list->shared;
EXTRACTOR_removeAll(shared->extractors);
if (shared->global_keywords != NULL)
- ECRS_freeUri(shared->global_keywords);
+ ECRS_freeUri(shared->global_keywords);
FREENONNULL(shared->extractor_config);
FREE(shared);
}
@@ -437,15 +437,15 @@
ectx = ctx->ectx;
if (ctx->ipc != NULL)
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSUI shutdown. This may take a while.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSUI shutdown. This may take a while.\n");
/* 1) stop everything */
cron_stop(ctx->cron);
cron_del_job(ctx->cron,
- &updateDownloadThreads,
- FSUI_UDT_FREQUENCY,
- ctx);
+ &updateDownloadThreads,
+ FSUI_UDT_FREQUENCY,
+ ctx);
cron_destroy(ctx->cron);
/* 1a) stop downloading */
@@ -459,15 +459,15 @@
spos = ctx->activeSearches;
while (spos != NULL) {
if ( (spos->state == FSUI_ACTIVE) ||
- (spos->state == FSUI_ABORTED) ||
- (spos->state == FSUI_ERROR) ||
- (spos->state == FSUI_COMPLETED) ) {
+ (spos->state == FSUI_ABORTED) ||
+ (spos->state == FSUI_ERROR) ||
+ (spos->state == FSUI_COMPLETED) ) {
if (spos->state == FSUI_ACTIVE)
- spos->state = FSUI_PENDING;
+ spos->state = FSUI_PENDING;
PTHREAD_STOP_SLEEP(spos->handle);
PTHREAD_JOIN(spos->handle, &unused);
if (spos->state != FSUI_PENDING)
- spos->state++; /* _JOINED */
+ spos->state++; /* _JOINED */
}
spos = spos->next;
}
@@ -475,15 +475,15 @@
xpos = ctx->unindexOperations;
while (xpos != NULL) {
if ( (xpos->state == FSUI_ACTIVE) ||
- (xpos->state == FSUI_ABORTED) ||
- (xpos->state == FSUI_ERROR) ||
- (xpos->state == FSUI_COMPLETED) ) {
+ (xpos->state == FSUI_ABORTED) ||
+ (xpos->state == FSUI_ERROR) ||
+ (xpos->state == FSUI_COMPLETED) ) {
if (xpos->state == FSUI_ACTIVE)
- xpos->state = FSUI_PENDING;
+ xpos->state = FSUI_PENDING;
PTHREAD_STOP_SLEEP(xpos->handle);
PTHREAD_JOIN(xpos->handle, &unused);
if (xpos->state != FSUI_PENDING)
- xpos->state++; /* _JOINED */
+ xpos->state++; /* _JOINED */
}
xpos = xpos->next;
}
@@ -491,17 +491,17 @@
upos = ctx->activeUploads.child;
while (upos != NULL) {
if ( (upos->state == FSUI_ACTIVE) ||
- (upos->state == FSUI_ABORTED) ||
- (upos->state == FSUI_ERROR) ||
- (upos->state == FSUI_COMPLETED) ) {
+ (upos->state == FSUI_ABORTED) ||
+ (upos->state == FSUI_ERROR) ||
+ (upos->state == FSUI_COMPLETED) ) {
/* NOTE: will force transitive termination
- of rest of tree! */
+ of rest of tree! */
if (upos->state == FSUI_ACTIVE)
- upos->state = FSUI_PENDING;
+ upos->state = FSUI_PENDING;
PTHREAD_STOP_SLEEP(upos->shared->handle);
PTHREAD_JOIN(upos->shared->handle, &unused);
if (upos->state != FSUI_PENDING)
- upos->state++; /* _JOINED */
+ upos->state++; /* _JOINED */
}
upos = upos->next;
}
@@ -518,12 +518,12 @@
}
/* 2b) signal uploads suspension */
signalUploadSuspend(ectx,
- ctx,
- ctx->activeUploads.child);
+ ctx,
+ ctx->activeUploads.child);
/* 2c) signal downloads suspension */
signalDownloadSuspend(ectx,
- ctx,
- ctx->activeDownloads.child);
+ ctx,
+ ctx->activeDownloads.child);
/* 2d) signal unindex suspension */
xpos = ctx->unindexOperations;
while (xpos != NULL) {
@@ -551,21 +551,21 @@
ECRS_freeUri(fi->uri);
}
GROW(spos->resultsReceived,
- spos->sizeResultsReceived,
- 0);
+ spos->sizeResultsReceived,
+ 0);
for (i=spos->sizeUnmatchedResultsReceived-1;i>=0;i--) {
ResultPending * rp;
rp = &spos->unmatchedResultsReceived[i];
GROW(rp->matchingKeys,
- rp->matchingKeyCount,
- 0);
+ rp->matchingKeyCount,
+ 0);
ECRS_freeMetaData(rp->fi.meta);
ECRS_freeUri(rp->fi.uri);
}
GROW(spos->unmatchedResultsReceived,
- spos->sizeUnmatchedResultsReceived,
- 0);
+ spos->sizeUnmatchedResultsReceived,
+ 0);
FREE(spos);
}
/* 4b) free unindex memory */
@@ -577,7 +577,7 @@
}
/* 4c) free upload memory */
freeUploadList(ctx,
- ctx->activeUploads.child);
+ ctx->activeUploads.child);
/* 4d) free download memory */
freeDownloadList(ctx->activeDownloads.child);
@@ -590,8 +590,8 @@
FREE(ctx->name);
if (ctx->ipc != NULL)
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSUI shutdown complete.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSUI shutdown complete.\n");
FREE(ctx);
}
Modified: GNUnet/src/applications/fs/fsui/fsuitest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsuitest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/fsui/fsuitest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -39,9 +39,9 @@
fn = MALLOC(strlen("/tmp/gnunet-fsui-serializetest/FSUITEST") + 14);
SNPRINTF(fn,
- strlen("/tmp/gnunet-fsui-test/FSUITEST") + 14,
- "/tmp/gnunet-fsui-test/FSUITEST%u",
- i);
+ strlen("/tmp/gnunet-fsui-test/FSUITEST") + 14,
+ "/tmp/gnunet-fsui-test/FSUITEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -53,7 +53,7 @@
static struct FSUI_DownloadList * download;
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
static char unused;
char * fn;
@@ -69,13 +69,13 @@
#endif
fn = makeName(43);
download = FSUI_startDownload(ctx,
- 0,
- NO,
- event->data.SearchResult.fi.uri,
- event->data.SearchResult.fi.meta,
- fn,
- NULL,
- NULL);
+ 0,
+ NO,
+ event->data.SearchResult.fi.uri,
+ event->data.SearchResult.fi.meta,
+ fn,
+ NULL,
+ NULL);
FREE(fn);
break;
case FSUI_upload_completed:
@@ -125,55 +125,55 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 60 * cronSECONDS));
+ cfg,
+ 60 * cronSECONDS));
#endif
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
ok = YES;
/* ACTUAL TEST CODE */
ctx = FSUI_start(NULL,
- cfg,
- "fsuitest",
- 32, /* thread pool size */
- NO, /* no resume */
- &eventCallback,
- NULL);
+ cfg,
+ "fsuitest",
+ 32, /* thread pool size */
+ NO, /* no resume */
+ &eventCallback,
+ NULL);
CHECK(ctx != NULL);
filename = makeName(42);
disk_file_write(NULL,
- filename,
- "foo bar test!",
- strlen("foo bar test!"),
- "600");
+ filename,
+ "foo bar test!",
+ strlen("foo bar test!"),
+ "600");
meta = ECRS_createMetaData();
kuri = ECRS_parseListKeywordURI(NULL,
- 2,
- (const char**)keywords);
+ 2,
+ (const char**)keywords);
upload = FSUI_startUpload(ctx,
- filename,
- (DirectoryScanCallback) &disk_directory_scan,
- NULL,
- 0, /* anonymity */
- 0, /* priority */
- YES,
- NO,
- NO,
- get_time() + 5 * cronHOURS,
- meta,
- kuri,
- kuri);
+ filename,
+ (DirectoryScanCallback) &disk_directory_scan,
+ NULL,
+ 0, /* anonymity */
+ 0, /* priority */
+ YES,
+ NO,
+ NO,
+ get_time() + 5 * cronHOURS,
+ meta,
+ kuri,
+ kuri);
CHECK(upload != NULL);
ECRS_freeUri(kuri);
ECRS_freeMetaData(meta);
@@ -187,18 +187,18 @@
break;
}
SNPRINTF(keyword,
- 40,
- "%s %s %s",
- keywords[0],
- _("AND"),
- keywords[1]);
+ 40,
+ "%s %s %s",
+ keywords[0],
+ _("AND"),
+ keywords[1]);
uri = ECRS_parseCharKeywordURI(NULL,
- keyword);
+ keyword);
search = FSUI_startSearch(ctx,
- 0,
- 100,
- 240 * cronSECONDS,
- uri);
+ 0,
+ 100,
+ 240 * cronSECONDS,
+ uri);
ECRS_freeUri(uri);
CHECK(search != NULL);
prog = 0;
@@ -210,9 +210,9 @@
break;
}
FSUI_abortSearch(ctx,
- search);
+ search);
FSUI_stopSearch(ctx,
- search);
+ search);
unindex = FSUI_startUnindex(ctx, filename);
prog = 0;
while (lastEvent != FSUI_unindex_completed) {
Modified: GNUnet/src/applications/fs/fsui/fsuitest2.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsuitest2.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/fsui/fsuitest2.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -36,7 +36,7 @@
static struct FSUI_Context * ctx;
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
return NULL;
}
@@ -51,40 +51,40 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 60 * cronSECONDS));
+ cfg,
+ 60 * cronSECONDS));
#endif
ok = YES;
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
ctx = FSUI_start(NULL,
- cfg,
- "fsuitest2",
- 32,
- YES, /* do resume! */
- &eventCallback,
- NULL);
+ cfg,
+ "fsuitest2",
+ 32,
+ YES, /* do resume! */
+ &eventCallback,
+ NULL);
CHECK(ctx != NULL);
FSUI_stop(ctx);
ctx = FSUI_start(NULL,
- cfg,
- "fsuitest2",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "fsuitest2",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
CHECK(ctx != NULL);
FAILURE:
if (ctx != NULL)
Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/fsui/search.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -41,7 +41,7 @@
* Pass the result to the client and note it as shown.
*/
static void processResult(const ECRS_FileInfo * fi,
- FSUI_SearchList * pos) {
+ FSUI_SearchList * pos) {
FSUI_Event event;
GROW(pos->resultsReceived,
@@ -58,11 +58,11 @@
event.data.SearchResult.fi = *fi;
event.data.SearchResult.searchURI = pos->uri;
pos->ctx->ecb(pos->ctx->ecbClosure,
- &event);
+ &event);
URITRACK_addState(pos->ctx->ectx,
- pos->ctx->cfg,
- pos->uri,
- URITRACK_SEARCH_RESULT);
+ pos->ctx->cfg,
+ pos->uri,
+ URITRACK_SEARCH_RESULT);
}
@@ -70,9 +70,9 @@
* Process results found by ECRS.
*/
static int spcb(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * cls) {
+ const HashCode512 * key,
+ int isRoot,
+ void * cls) {
FSUI_SearchList * pos = cls;
unsigned int i;
unsigned int j;
@@ -82,25 +82,25 @@
ectx = pos->ctx->ectx;
URITRACK_trackURI(ectx,
- pos->ctx->cfg,
- fi);
+ pos->ctx->cfg,
+ fi);
if (isRoot) {
NS_setNamespaceRoot(ectx,
- pos->ctx->cfg,
- fi->uri);
+ pos->ctx->cfg,
+ fi->uri);
NS_addNamespaceInfo(ectx,
- pos->ctx->cfg,
- fi->uri,
- fi->meta);
+ pos->ctx->cfg,
+ fi->uri,
+ fi->meta);
return OK;
}
for (i=0;i<pos->sizeResultsReceived;i++)
if (ECRS_equalsUri(fi->uri,
- pos->resultsReceived[i].uri)) {
+ pos->resultsReceived[i].uri)) {
#if DEBUG_SEARCH
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received search result that I have seen before.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received search result that I have seen before.\n");
#endif
return OK; /* seen before */
}
@@ -109,87 +109,87 @@
GE_BREAK(ectx, 0);
#if DEBUG_SEARCH
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received search result without key to decrypt.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received search result without key to decrypt.\n");
#endif
return SYSERR;
}
for (i=0;i<pos->sizeUnmatchedResultsReceived;i++) {
rp = &pos->unmatchedResultsReceived[i];
if (ECRS_equalsUri(fi->uri,
- rp->fi.uri)) {
- for (j=0;j<rp->matchingKeyCount;j++)
- if (0 == memcmp(key,
- &rp->matchingKeys[j],
- sizeof(HashCode512))) {
+ rp->fi.uri)) {
+ for (j=0;j<rp->matchingKeyCount;j++)
+ if (0 == memcmp(key,
+ &rp->matchingKeys[j],
+ sizeof(HashCode512))) {
#if DEBUG_SEARCH
- GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received search result that I have seen before (missing
keyword to show client).\n");
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received search result that I have seen before (missing keyword to
show client).\n");
#endif
- return OK;
- }
- if (rp->matchingKeyCount + 1 == pos->numberOfURIKeys) {
+ return OK;
+ }
+ if (rp->matchingKeyCount + 1 == pos->numberOfURIKeys) {
#if DEBUG_SEARCH
- GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received search result (showing client)!\n");
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received search result (showing client)!\n");
#endif
- GROW(rp->matchingKeys,
- rp->matchingKeyCount,
- 0);
- processResult(&rp->fi,
- pos);
- ECRS_freeUri(rp->fi.uri);
- ECRS_freeMetaData(rp->fi.meta);
- pos->unmatchedResultsReceived[i]
- =
pos->unmatchedResultsReceived[pos->sizeUnmatchedResultsReceived-1];
- GROW(pos->unmatchedResultsReceived,
- pos->sizeUnmatchedResultsReceived,
- pos->sizeUnmatchedResultsReceived-1);
- return OK;
- } else {
- GROW(rp->matchingKeys,
- rp->matchingKeyCount,
- rp->matchingKeyCount+1);
- rp->matchingKeys[rp->matchingKeyCount-1] = *key;
+ GROW(rp->matchingKeys,
+ rp->matchingKeyCount,
+ 0);
+ processResult(&rp->fi,
+ pos);
+ ECRS_freeUri(rp->fi.uri);
+ ECRS_freeMetaData(rp->fi.meta);
+ pos->unmatchedResultsReceived[i]
+ = pos->unmatchedResultsReceived[pos->sizeUnmatchedResultsReceived-1];
+ GROW(pos->unmatchedResultsReceived,
+ pos->sizeUnmatchedResultsReceived,
+ pos->sizeUnmatchedResultsReceived-1);
+ return OK;
+ } else {
+ GROW(rp->matchingKeys,
+ rp->matchingKeyCount,
+ rp->matchingKeyCount+1);
+ rp->matchingKeys[rp->matchingKeyCount-1] = *key;
#if DEBUG_SEARCH
- GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received search result (waiting for more %u keys before
showing client).\n",
- pos->numberOfURIKeys - rp->matchingKeyCount);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received search result (waiting for more %u keys before showing
client).\n",
+ pos->numberOfURIKeys - rp->matchingKeyCount);
#endif
- return OK;
- }
+ return OK;
+ }
}
}
GROW(pos->unmatchedResultsReceived,
- pos->sizeUnmatchedResultsReceived,
- pos->sizeUnmatchedResultsReceived+1);
+ pos->sizeUnmatchedResultsReceived,
+ pos->sizeUnmatchedResultsReceived+1);
rp = &pos->unmatchedResultsReceived[pos->sizeUnmatchedResultsReceived-1];
rp->fi.meta = ECRS_dupMetaData(fi->meta);
rp->fi.uri = ECRS_dupUri(fi->uri);
rp->matchingKeys = NULL;
rp->matchingKeyCount = 0;
GROW(rp->matchingKeys,
- rp->matchingKeyCount,
- 1);
+ rp->matchingKeyCount,
+ 1);
rp->matchingKeys[0] = *key;
#if DEBUG_SEARCH
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received search result (waiting for %u more keys before showing
client).\n",
- pos->numberOfURIKeys - rp->matchingKeyCount);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received search result (waiting for %u more keys before showing
client).\n",
+ pos->numberOfURIKeys - rp->matchingKeyCount);
#endif
return OK;
} else {
#if DEBUG_SEARCH
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received search result (showing client)!\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received search result (showing client)!\n");
#endif
processResult(fi,
- pos);
+ pos);
}
return OK;
}
@@ -214,18 +214,18 @@
mem = GE_memory_create(2);
ee = GE_create_context_memory(GE_USER | GE_ADMIN |
- GE_ERROR | GE_WARNING | GE_FATAL |
- GE_BULK | GE_IMMEDIATE,
- mem);
+ GE_ERROR | GE_WARNING | GE_FATAL |
+ GE_BULK | GE_IMMEDIATE,
+ mem);
ret = ECRS_search(ee,
- pos->ctx->cfg,
- pos->uri,
- pos->anonymityLevel,
- pos->timeout,
- &spcb,
- pos,
- &testTerminate,
- pos);
+ pos->ctx->cfg,
+ pos->uri,
+ pos->anonymityLevel,
+ pos->timeout,
+ &spcb,
+ pos,
+ &testTerminate,
+ pos);
if (ret != OK) {
const char * error;
@@ -238,20 +238,20 @@
error = _("Error running search (no reason given).");
event.data.SearchError.message = error;
pos->ctx->ecb(pos->ctx->ecbClosure,
- &event);
+ &event);
} else if (pos->state == FSUI_ABORTED) {
event.type = FSUI_search_aborted;
event.data.SearchAborted.sc.pos = pos;
event.data.SearchAborted.sc.cctx = pos->cctx;
pos->ctx->ecb(pos->ctx->ecbClosure,
- &event);
+ &event);
} else if (pos->state == FSUI_ACTIVE) {
pos->state = FSUI_COMPLETED;
event.type = FSUI_search_completed;
event.data.SearchCompleted.sc.pos = pos;
event.data.SearchCompleted.sc.cctx = pos->cctx;
pos->ctx->ecb(pos->ctx->ecbClosure,
- &event);
+ &event);
} else {
GE_ASSERT(NULL, pos->state == FSUI_PENDING);
/* must be suspending */
@@ -275,7 +275,7 @@
event.data.SearchStarted.searchURI = pos->uri;
event.data.SearchStarted.anonymityLevel = pos->anonymityLevel;
pos->cctx = pos->ctx->ecb(pos->ctx->ecbClosure,
- &event);
+ &event);
return FSUI_searchThread(pos);
}
@@ -284,10 +284,10 @@
*/
struct FSUI_SearchList *
FSUI_startSearch(struct FSUI_Context * ctx,
- unsigned int anonymityLevel,
- unsigned int maxResults,
- cron_t timeout,
- const struct ECRS_URI * uri) {
+ unsigned int anonymityLevel,
+ unsigned int maxResults,
+ cron_t timeout,
+ const struct ECRS_URI * uri) {
FSUI_SearchList * pos;
struct GE_Context * ectx;
@@ -307,12 +307,12 @@
pos->start_time = get_time();
pos->timeout = timeout;
pos->handle = PTHREAD_CREATE(&FSUI_searchThreadSignal,
- pos,
- 32 * 1024);
+ pos,
+ 32 * 1024);
if (pos->handle == NULL) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_IMMEDIATE | GE_USER | GE_ADMIN,
- "PTHREAD_CREATE");
+ GE_ERROR | GE_IMMEDIATE | GE_USER | GE_ADMIN,
+ "PTHREAD_CREATE");
ECRS_freeUri(pos->uri);
FREE(pos);
MUTEX_UNLOCK(ctx->lock);
@@ -328,7 +328,7 @@
* Abort a search.
*/
int FSUI_abortSearch(struct FSUI_Context * ctx,
- struct FSUI_SearchList * sl) {
+ struct FSUI_SearchList * sl) {
if (sl->state == FSUI_PENDING) {
sl->state = FSUI_ABORTED_JOINED;
return OK;
@@ -344,7 +344,7 @@
* Stop a search.
*/
int FSUI_stopSearch(struct FSUI_Context * ctx,
- struct FSUI_SearchList * sl) {
+ struct FSUI_SearchList * sl) {
FSUI_Event event;
FSUI_SearchList * pos;
FSUI_SearchList * prev;
@@ -355,7 +355,7 @@
prev = NULL;
pos = ctx->activeSearches;
while ( (pos != sl) &&
- (pos != NULL) ) {
+ (pos != NULL) ) {
prev = pos;
pos = pos->next;
}
@@ -380,7 +380,7 @@
(pos->state == FSUI_ERROR) ) {
GE_ASSERT(ctx->ectx, pos->handle != NULL);
PTHREAD_JOIN(pos->handle,
- &unused);
+ &unused);
pos->handle = NULL;
if (pos->state == FSUI_ACTIVE)
pos->state = FSUI_PENDING;
@@ -393,7 +393,7 @@
event.data.SearchStopped.sc.pos = pos;
event.data.SearchStopped.sc.cctx = pos->cctx;
pos->ctx->ecb(pos->ctx->ecbClosure,
- &event);
+ &event);
ECRS_freeUri(pos->uri);
@@ -408,8 +408,8 @@
ECRS_freeUri(pos->unmatchedResultsReceived[i].fi.uri);
ECRS_freeMetaData(pos->unmatchedResultsReceived[i].fi.meta);
GROW(pos->unmatchedResultsReceived[i].matchingKeys,
- pos->unmatchedResultsReceived[i].matchingKeyCount,
- 0);
+ pos->unmatchedResultsReceived[i].matchingKeyCount,
+ 0);
}
GROW(pos->unmatchedResultsReceived,
pos->sizeUnmatchedResultsReceived,
Modified: GNUnet/src/applications/fs/fsui/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/searchtest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/fsui/searchtest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -37,9 +37,9 @@
fn = MALLOC(strlen("/tmp/gnunet-fsui-searchtest/FSUITEST") + 14);
SNPRINTF(fn,
- strlen("/tmp/gnunet-fsui-searchtest/FSUITEST") + 14,
- "/tmp/gnunet-fsui-searchtest/FSUITEST%u",
- i);
+ strlen("/tmp/gnunet-fsui-searchtest/FSUITEST") + 14,
+ "/tmp/gnunet-fsui-searchtest/FSUITEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -57,7 +57,7 @@
static volatile enum FSUI_EventType waitForEvent;
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
static char unused;
MUTEX_LOCK(lock);
@@ -130,80 +130,80 @@
ok = YES;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS));
+ cfg,
+ 30 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
#endif
lock = MUTEX_CREATE(NO);
ctx = FSUI_start(NULL,
- cfg,
- "fsuisearchtest",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "fsuisearchtest",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
CHECK(ctx != NULL);
SNPRINTF(keyword,
- 40,
- "%s %s %s",
- keywords[0],
- _("AND"),
- keywords[1]);
+ 40,
+ "%s %s %s",
+ keywords[0],
+ _("AND"),
+ keywords[1]);
luri = ECRS_parseCharKeywordURI(NULL, keyword);
search = FSUI_startSearch(ctx,
- 0,
- 100,
- 240 * cronSECONDS,
- luri);
+ 0,
+ 100,
+ 240 * cronSECONDS,
+ luri);
ECRS_freeUri(luri);
uri = NULL;
CHECK(NULL != search);
FSUI_stop(ctx);
/* resume search! */
ctx = FSUI_start(NULL,
- cfg,
- "fsuisearchtest",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "fsuisearchtest",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
fn = makeName(42);
disk_file_write(NULL,
- fn,
- "foo bar test!",
- strlen("foo bar test!"),
- "600");
+ fn,
+ "foo bar test!",
+ strlen("foo bar test!"),
+ "600");
meta = ECRS_createMetaData();
kuri = ECRS_parseListKeywordURI(NULL,
- 2,
- (const char**)keywords);
+ 2,
+ (const char**)keywords);
waitForEvent = FSUI_upload_completed;
upload =
- FSUI_startUpload(ctx,
- fn,
- (DirectoryScanCallback) &disk_directory_scan,
- NULL,
- 0,
- 0,
- YES,
- NO,
- NO,
- get_time() + 5 * cronHOURS,
- meta,
- kuri,
- kuri);
+ FSUI_startUpload(ctx,
+ fn,
+ (DirectoryScanCallback) &disk_directory_scan,
+ NULL,
+ 0,
+ 0,
+ YES,
+ NO,
+ NO,
+ get_time() + 5 * cronHOURS,
+ meta,
+ kuri,
+ kuri);
CHECK(NULL != upload);
FREE(fn);
fn = NULL;
@@ -214,8 +214,8 @@
prog++;
if (prog == 10000) {
fprintf(stderr,
- "Upload failed to complete -- last event: %u\n",
- lastEvent);
+ "Upload failed to complete -- last event: %u\n",
+ lastEvent);
}
CHECK(prog < 10000)
PTHREAD_SLEEP(50 * cronMILLIS);
@@ -230,21 +230,21 @@
PTHREAD_SLEEP(50 * cronMILLIS);
}
FSUI_abortSearch(ctx,
- search);
+ search);
FSUI_stopSearch(ctx,
- search);
+ search);
CHECK(uri != NULL);
fn = makeName(43);
meta = ECRS_createMetaData();
waitForEvent = FSUI_download_completed;
download = FSUI_startDownload(ctx,
- 0,
- NO,
- uri,
- meta,
- fn,
- NULL,
- NULL);
+ 0,
+ NO,
+ uri,
+ meta,
+ fn,
+ NULL,
+ NULL);
ECRS_freeMetaData(meta);
FREE(fn);
fn = NULL;
Modified: GNUnet/src/applications/fs/fsui/serialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serialize.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/fsui/serialize.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -32,21 +32,21 @@
#include "fsui.h"
static void WRITEINT(int fd,
- int val) {
+ int val) {
int big;
big = htonl(val);
WRITE(fd, &big, sizeof(int));
}
static void WRITELONG(int fd,
- long long val) {
+ long long val) {
long long big;
big = htonll(val);
WRITE(fd, &big, sizeof(long long));
}
static void writeURI(int fd,
- const struct ECRS_URI * uri) {
+ const struct ECRS_URI * uri) {
char * buf;
unsigned int size;
@@ -54,48 +54,48 @@
size = strlen(buf);
WRITEINT(fd, size);
WRITE(fd,
- buf,
- size);
+ buf,
+ size);
FREE(buf);
}
static void WRITESTRING(int fd,
- const char * name) {
+ const char * name) {
GE_BREAK(NULL, name != NULL);
WRITEINT(fd,
- strlen(name));
+ strlen(name));
WRITE(fd,
- name,
- strlen(name));
+ name,
+ strlen(name));
}
static void writeMetaData(struct GE_Context * ectx,
- int fd,
- const struct ECRS_MetaData * meta) {
+ int fd,
+ const struct ECRS_MetaData * meta) {
unsigned int size;
char * buf;
size = ECRS_sizeofMetaData(meta,
- ECRS_SERIALIZE_FULL | ECRS_SERIALIZE_NO_COMPRESS);
+ ECRS_SERIALIZE_FULL | ECRS_SERIALIZE_NO_COMPRESS);
if (size > 1024 * 1024)
size = 1024 * 1024;
buf = MALLOC(size);
ECRS_serializeMetaData(ectx,
- meta,
- buf,
- size,
- ECRS_SERIALIZE_PART | ECRS_SERIALIZE_NO_COMPRESS);
+ meta,
+ buf,
+ size,
+ ECRS_SERIALIZE_PART | ECRS_SERIALIZE_NO_COMPRESS);
WRITEINT(fd, size);
WRITE(fd,
- buf,
- size);
+ buf,
+ size);
FREE(buf);
}
static void writeFileInfo(struct GE_Context * ectx,
- int fd,
- const ECRS_FileInfo * fi) {
+ int fd,
+ const ECRS_FileInfo * fi) {
writeMetaData(ectx, fd, fi->meta);
writeURI(fd, fi->uri);
}
@@ -105,9 +105,9 @@
* (recursively) write a download list.
*/
static void writeDownloadList(struct GE_Context * ectx,
- int fd,
- FSUI_Context * ctx,
- FSUI_DownloadList * list) {
+ int fd,
+ FSUI_Context * ctx,
+ FSUI_DownloadList * list) {
int i;
FSUI_SearchList * pos;
@@ -117,11 +117,11 @@
}
#if DEBUG_PERSISTENCE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Serializing download state of download `%s': (%llu, %llu)\n",
- list->filename,
- list->completed,
- list->total);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Serializing download state of download `%s': (%llu, %llu)\n",
+ list->filename,
+ list->completed,
+ list->total);
#endif
WRITEINT(fd, 1);
if (list->search == NULL) {
@@ -131,18 +131,18 @@
pos = ctx->activeSearches;
while (pos != list->search) {
if ( (pos->sizeResultsReceived <= 1024 * 1024) &&
- (pos->sizeUnmatchedResultsReceived <= 1024 * 1024) )
- i++;
+ (pos->sizeUnmatchedResultsReceived <= 1024 * 1024) )
+ i++;
pos = pos->next;
if (pos == NULL) {
- GE_BREAK(ectx, 0);
- i = 0;
- break;
+ GE_BREAK(ectx, 0);
+ i = 0;
+ break;
}
}
if ( (pos != NULL) &&
- ( (pos->sizeResultsReceived < 1024 * 1024) ||
- (pos->sizeUnmatchedResultsReceived < 1024 * 1024) ) )
+ ( (pos->sizeResultsReceived < 1024 * 1024) ||
+ (pos->sizeUnmatchedResultsReceived < 1024 * 1024) ) )
i = 0;
WRITEINT(fd, i);
}
@@ -157,22 +157,22 @@
WRITESTRING(fd, list->filename);
writeFileInfo(ectx,
- fd,
- &list->fi);
+ fd,
+ &list->fi);
for (i=0;i<list->completedDownloadsCount;i++)
writeURI(fd, list->completedDownloads[i]);
writeDownloadList(ectx,
- fd,
- ctx,
- list->next);
+ fd,
+ ctx,
+ list->next);
writeDownloadList(ectx,
- fd,
- ctx,
- list->child);
+ fd,
+ ctx,
+ list->child);
}
static void writeCollection(int fd,
- struct FSUI_Context * ctx) {
+ struct FSUI_Context * ctx) {
if ( (ctx->collectionData == NULL) ||
(ctx->collectionData->size > 16 * 1024 * 1024) ) {
WRITEINT(fd, 0);
@@ -180,26 +180,26 @@
}
/* serialize collection data */
WRITE(fd,
- ctx->collectionData,
- ntohl(ctx->collectionData->size));
+ ctx->collectionData,
+ ntohl(ctx->collectionData->size));
}
static void writeSearches(int fd,
- struct FSUI_Context * ctx) {
+ struct FSUI_Context * ctx) {
FSUI_SearchList * spos;
int i;
spos = ctx->activeSearches;
while (spos != NULL) {
if ( (spos->sizeResultsReceived > 1024 * 1024) ||
- (spos->sizeUnmatchedResultsReceived > 1024 * 1024) ) {
+ (spos->sizeUnmatchedResultsReceived > 1024 * 1024) ) {
/* too large to serialize - skip! */
spos = spos->next;
continue;
}
GE_ASSERT(ctx->ectx,
- ECRS_isKeywordUri(spos->uri) ||
- ECRS_isNamespaceUri(spos->uri));
+ ECRS_isKeywordUri(spos->uri) ||
+ ECRS_isNamespaceUri(spos->uri));
WRITEINT(fd, 1);
WRITEINT(fd, spos->state);
WRITEINT(fd, spos->maxResults);
@@ -212,25 +212,25 @@
writeURI(fd, spos->uri);
for (i=0;i<spos->sizeResultsReceived;i++)
writeFileInfo(ctx->ectx,
- fd,
- &spos->resultsReceived[i]);
+ fd,
+ &spos->resultsReceived[i]);
for (i=0;i<spos->sizeUnmatchedResultsReceived;i++) {
ResultPending * rp;
rp = &spos->unmatchedResultsReceived[i];
writeFileInfo(ctx->ectx,
- fd,
- &rp->fi);
+ fd,
+ &rp->fi);
GE_ASSERT(ctx->ectx,
- rp->matchingKeyCount < spos->numberOfURIKeys);
+ rp->matchingKeyCount < spos->numberOfURIKeys);
if (rp->matchingKeyCount > 1024) {
- WRITEINT(fd, 0); /* too large to serialize */
- continue;
+ WRITEINT(fd, 0); /* too large to serialize */
+ continue;
}
WRITEINT(fd, rp->matchingKeyCount);
WRITE(fd,
- rp->matchingKeys,
- sizeof(HashCode512) * rp->matchingKeyCount);
+ rp->matchingKeys,
+ sizeof(HashCode512) * rp->matchingKeyCount);
}
spos = spos->next;
}
@@ -238,7 +238,7 @@
}
static void writeUnindexing(int fd,
- struct FSUI_Context * ctx) {
+ struct FSUI_Context * ctx) {
FSUI_UnindexList * xpos;
@@ -254,9 +254,9 @@
}
static void writeUploadList(int fd,
- struct FSUI_Context * ctx,
- struct FSUI_UploadList * upos,
- int top) {
+ struct FSUI_Context * ctx,
+ struct FSUI_UploadList * upos,
+ int top) {
int bits;
while (upos != NULL) {
@@ -290,8 +290,8 @@
}
static void writeUploads(int fd,
- struct FSUI_Context * ctx,
- struct FSUI_UploadList * upos) {
+ struct FSUI_Context * ctx,
+ struct FSUI_UploadList * upos) {
struct FSUI_UploadShared * shared;
int bits;
@@ -307,17 +307,17 @@
WRITEINT(fd, shared->doIndex);
WRITEINT(fd, shared->anonymityLevel);
WRITEINT(fd, shared->priority);
- WRITEINT(fd, shared->individualKeywords);
+ WRITEINT(fd, shared->individualKeywords);
WRITELONG(fd, shared->expiration);
if (shared->extractor_config != NULL)
WRITESTRING(fd,
- shared->extractor_config);
+ shared->extractor_config);
if (shared->global_keywords != NULL)
writeURI(fd, shared->global_keywords);
writeUploadList(fd,
- ctx,
- upos,
- YES);
+ ctx,
+ upos,
+ YES);
upos = upos->next;
}
WRITEINT(fd, 0);
@@ -327,24 +327,24 @@
int fd;
fd = 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 (fd == -1)
return;
WRITE(fd,
- "FSUI01\n\0",
- 8); /* magic */
+ "FSUI01\n\0",
+ 8); /* magic */
writeCollection(fd, ctx);
writeSearches(fd, ctx);
writeDownloadList(ctx->ectx,
- fd,
- ctx,
- ctx->activeDownloads.child);
+ fd,
+ ctx,
+ ctx->activeDownloads.child);
writeUnindexing(fd, ctx);
writeUploads(fd,
- ctx,
- ctx->activeUploads.child);
+ ctx,
+ ctx->activeUploads.child);
CLOSE(fd);
}
Modified: GNUnet/src/applications/fs/fsui/serializetest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/fsui/serializetest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -44,9 +44,9 @@
fn = MALLOC(strlen("/tmp/gnunet-fsui-serializetest/FSUITEST") + 14);
SNPRINTF(fn,
- strlen("/tmp/gnunet-fsui-serializetest/FSUITEST") + 14,
- "/tmp/gnunet-fsui-serializetest/FSUITEST%u",
- i);
+ strlen("/tmp/gnunet-fsui-serializetest/FSUITEST") + 14,
+ "/tmp/gnunet-fsui-serializetest/FSUITEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -60,13 +60,13 @@
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
switch(event->type) {
case FSUI_upload_progress:
#if DEBUG_VERBOSE
printf("Upload is progressing (%llu/%llu)...\n",
- event->data.UploadProgress.completed,
- event->data.UploadProgress.total);
+ event->data.UploadProgress.completed,
+ event->data.UploadProgress.total);
#endif
break;
case FSUI_upload_completed:
@@ -78,8 +78,8 @@
case FSUI_unindex_progress:
#if DEBUG_VERBOSE
printf("Unindex is progressing (%llu/%llu)...\n",
- event->data.UnindexProgress.completed,
- event->data.UnindexProgress.total);
+ event->data.UnindexProgress.completed,
+ event->data.UnindexProgress.total);
#endif
break;
case FSUI_unindex_completed:
@@ -92,8 +92,8 @@
case FSUI_download_error:
case FSUI_search_error:
fprintf(stderr,
- "Received ERROR: %d\n",
- event->type);
+ "Received ERROR: %d\n",
+ event->type);
GE_BREAK(ectx, 0);
break;
case FSUI_download_aborted:
@@ -104,16 +104,16 @@
case FSUI_unindex_resumed:
#if DEBUG_VERBOSE
fprintf(stderr,
- "Received RESUMING: %d\n",
- event->type);
+ "Received RESUMING: %d\n",
+ event->type);
#endif
unindex = event->data.UnindexResumed.uc.pos;
break;
case FSUI_upload_resumed:
#if DEBUG_VERBOSE
fprintf(stderr,
- "Received RESUMING: %d\n",
- event->type);
+ "Received RESUMING: %d\n",
+ event->type);
#endif
upload = event->data.UploadResumed.uc.pos;
break;
@@ -122,16 +122,16 @@
unindex = NULL;
#if DEBUG_VERBOSE
fprintf(stderr,
- "Received SUSPENDING: %d\n",
- event->type);
+ "Received SUSPENDING: %d\n",
+ event->type);
#endif
break;
case FSUI_upload_suspended:
upload = NULL;
#if DEBUG_VERBOSE
fprintf(stderr,
- "Received SUSPENDING: %d\n",
- event->type);
+ "Received SUSPENDING: %d\n",
+ event->type);
#endif
break;
case FSUI_upload_started:
@@ -141,7 +141,7 @@
break;
default:
printf("Unexpected event: %d\n",
- event->type);
+ event->type);
break;
}
if (lastEvent == waitForEvent)
@@ -175,58 +175,58 @@
ok = YES;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS));
+ cfg,
+ 30 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
#endif
ctx = FSUI_start(NULL,
- cfg,
- "fsuiserializetest",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "fsuiserializetest",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
CHECK(ctx != NULL);
fn = makeName(42);
buf = MALLOC(FILESIZE);
for (i=0;i<FILESIZE;i++)
buf[i] = weak_randomi(256);
disk_file_write(ectx,
- fn,
- buf,
- FILESIZE,
- "600");
+ fn,
+ buf,
+ FILESIZE,
+ "600");
FREE(buf);
meta = ECRS_createMetaData();
kuri = ECRS_parseListKeywordURI(ectx,
- 2,
- (const char**)keywords);
+ 2,
+ (const char**)keywords);
waitForEvent = FSUI_upload_completed;
upload = FSUI_startUpload(ctx,
- fn,
- (DirectoryScanCallback) &disk_directory_scan,
- NULL,
- 0,
- 0,
- YES,
- NO,
- NO,
- get_time() + 5 * cronHOURS,
- meta,
- kuri,
- kuri);
+ fn,
+ (DirectoryScanCallback) &disk_directory_scan,
+ NULL,
+ 0,
+ 0,
+ YES,
+ NO,
+ NO,
+ get_time() + 5 * cronHOURS,
+ meta,
+ kuri,
+ kuri);
CHECK(upload != NULL);
ECRS_freeUri(kuri);
kuri = NULL;
@@ -235,20 +235,20 @@
suspendRestart = 4;
while (lastEvent != FSUI_upload_completed) {
if ( (suspendRestart > 0) &&
- (weak_randomi(4) == 0) ) {
+ (weak_randomi(4) == 0) ) {
#if 1
#if DEBUG_VERBOSE
printf("Testing FSUI suspend-resume\n");
#endif
FSUI_stop(ctx); /* download possibly incomplete
- at this point, thus testing resume */
+ at this point, thus testing resume */
ctx = FSUI_start(NULL,
- cfg,
- "fsuiserializetest",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "fsuiserializetest",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
#if DEBUG_VERBOSE
printf("Resumed...\n");
#endif
@@ -269,20 +269,20 @@
suspendRestart = 4;
while (lastEvent != FSUI_unindex_completed) {
if ( (suspendRestart > 0) &&
- (weak_randomi(4) == 0) ) {
+ (weak_randomi(4) == 0) ) {
#if 1
#if DEBUG_VERBOSE
printf("Testing FSUI suspend-resume\n");
#endif
FSUI_stop(ctx); /* download possibly incomplete
- at this point, thus testing resume */
+ at this point, thus testing resume */
ctx = FSUI_start(NULL,
- cfg,
- "fsuiserializetest",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "fsuiserializetest",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
#if DEBUG_VERBOSE
printf("Resumed...\n");
#endif
@@ -302,7 +302,7 @@
if (ctx != NULL) {
if (unindex != NULL)
FSUI_stopUnindex(ctx,
- unindex);
+ unindex);
FSUI_stop(ctx);
}
if (fn != NULL) {
Modified: GNUnet/src/applications/fs/fsui/serializetest2.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest2.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/fsui/serializetest2.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -45,9 +45,9 @@
fn = MALLOC(strlen(UPLOAD_PREFIX "/FSUITEST") + 14);
SNPRINTF(fn,
- strlen(UPLOAD_PREFIX "/FSUITEST") + 14,
- UPLOAD_PREFIX "/FSUITEST%u",
- i);
+ strlen(UPLOAD_PREFIX "/FSUITEST") + 14,
+ UPLOAD_PREFIX "/FSUITEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -66,7 +66,7 @@
static int no_check;
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
if (no_check)
return NULL;
switch(event->type) {
@@ -76,21 +76,21 @@
case FSUI_download_suspended:
if (event->data.DownloadSuspended.dc.spos != search) {
fprintf(stderr,
- "Download suspended but search reference not set correctly.\n");
+ "Download suspended but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadSuspended.dc.pos == download) &&
- (event->data.DownloadSuspended.dc.ppos != NULL) ) {
+ (event->data.DownloadSuspended.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download suspended but parent reference not set to NULL.\n");
+ "Download suspended but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadSuspended.dc.pos != download) &&
- (event->data.DownloadSuspended.dc.ppos != download) ) {
+ (event->data.DownloadSuspended.dc.ppos != download) ) {
fprintf(stderr,
- "Download suspended but parent reference not set correctly (%p
instead of %p).\n",
- event->data.DownloadSuspended.dc.ppos,
- download);
+ "Download suspended but parent reference not set correctly (%p instead
of %p).\n",
+ event->data.DownloadSuspended.dc.ppos,
+ download);
have_error = 1;
}
if (event->data.DownloadSuspended.dc.pos == download)
@@ -107,19 +107,19 @@
download = event->data.DownloadResumed.dc.pos;
if (event->data.DownloadResumed.dc.spos != search) {
fprintf(stderr,
- "Download resuming but search reference not set correctly.\n");
+ "Download resuming but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadResumed.dc.pos == download) &&
- (event->data.DownloadResumed.dc.ppos != NULL) ) {
+ (event->data.DownloadResumed.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download resuming but parent reference not set to NULL.\n");
+ "Download resuming but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadResumed.dc.pos != download) &&
- (event->data.DownloadResumed.dc.ppos != download) ) {
+ (event->data.DownloadResumed.dc.ppos != download) ) {
fprintf(stderr,
- "Download resuming but parent reference not set correctly.\n");
+ "Download resuming but parent reference not set correctly.\n");
have_error = 1;
}
#if DEBUG_VERBOSE
@@ -134,8 +134,8 @@
case FSUI_upload_progress:
#if DEBUG_VERBOSE
printf("Upload is progressing (%llu/%llu)...\n",
- event->data.UploadProgress.completed,
- event->data.UploadProgress.total);
+ event->data.UploadProgress.completed,
+ event->data.UploadProgress.total);
#endif
break;
case FSUI_upload_completed:
@@ -149,19 +149,19 @@
case FSUI_download_completed:
if (event->data.DownloadCompleted.dc.spos != search) {
fprintf(stderr,
- "Download completed but search reference not set correctly.\n");
+ "Download completed but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadCompleted.dc.pos == download) &&
- (event->data.DownloadCompleted.dc.ppos != NULL) ) {
+ (event->data.DownloadCompleted.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download completed but parent reference not set to NULL.\n");
+ "Download completed but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadCompleted.dc.pos != download) &&
- (event->data.DownloadCompleted.dc.ppos != download) ) {
+ (event->data.DownloadCompleted.dc.ppos != download) ) {
fprintf(stderr,
- "Download completed but parent reference not set correctly.\n");
+ "Download completed but parent reference not set correctly.\n");
have_error = 1;
}
#if DEBUG_VERBOSE
@@ -171,32 +171,32 @@
case FSUI_download_progress:
if (event->data.DownloadResumed.dc.spos != search) {
fprintf(stderr,
- "Download progressing but search reference not set correctly.\n");
+ "Download progressing but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadResumed.dc.pos == download) &&
- (event->data.DownloadResumed.dc.ppos != NULL) ) {
+ (event->data.DownloadResumed.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download progressing but parent reference not set to NULL.\n");
+ "Download progressing but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadResumed.dc.pos != download) &&
- (event->data.DownloadResumed.dc.ppos != download) ) {
+ (event->data.DownloadResumed.dc.ppos != download) ) {
fprintf(stderr,
- "Download progressing but parent reference not set correctly.\n");
+ "Download progressing but parent reference not set correctly.\n");
have_error = 1;
}
#if DEBUG_VERBOSE
printf("Download is progressing (%llu/%llu)...\n",
- event->data.DownloadProgress.completed,
- event->data.DownloadProgress.total);
+ event->data.DownloadProgress.completed,
+ event->data.DownloadProgress.total);
#endif
break;
case FSUI_unindex_progress:
#if DEBUG_VERBOSE
printf("Unindex is progressing (%llu/%llu)...\n",
- event->data.UnindexProgress.completed,
- event->data.UnindexProgress.total);
+ event->data.UnindexProgress.completed,
+ event->data.UnindexProgress.total);
#endif
break;
case FSUI_unindex_completed:
@@ -206,30 +206,30 @@
break;
case FSUI_unindex_error:
fprintf(stderr,
- "Received ERROR: %d %s\n",
- event->type,
- event->data.UnindexError.message);
+ "Received ERROR: %d %s\n",
+ event->type,
+ event->data.UnindexError.message);
GE_BREAK(ectx, 0);
break;
case FSUI_upload_error:
fprintf(stderr,
- "Received ERROR: %d %s\n",
- event->type,
- event->data.UploadError.message);
+ "Received ERROR: %d %s\n",
+ event->type,
+ event->data.UploadError.message);
GE_BREAK(ectx, 0);
break;
case FSUI_download_error:
fprintf(stderr,
- "Received ERROR: %d %s\n",
- event->type,
- event->data.DownloadError.message);
+ "Received ERROR: %d %s\n",
+ event->type,
+ event->data.DownloadError.message);
GE_BREAK(ectx, 0);
break;
case FSUI_search_error:
fprintf(stderr,
- "Received ERROR: %d %s\n",
- event->type,
- event->data.SearchError.message);
+ "Received ERROR: %d %s\n",
+ event->type,
+ event->data.SearchError.message);
GE_BREAK(ectx, 0);
break;
case FSUI_download_aborted:
@@ -241,8 +241,8 @@
case FSUI_upload_suspended:
#if DEBUG_VERBOSE
fprintf(stderr,
- "Received SUSPENDING: %d\n",
- event->type);
+ "Received SUSPENDING: %d\n",
+ event->type);
#endif
break;
case FSUI_download_started:
@@ -250,38 +250,38 @@
download = event->data.DownloadStarted.dc.pos;
if (event->data.DownloadStarted.dc.spos != search) {
fprintf(stderr,
- "Download started but search reference not set correctly.\n");
+ "Download started but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadStarted.dc.pos == download) &&
- (event->data.DownloadStarted.dc.ppos != NULL) ) {
+ (event->data.DownloadStarted.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download started but parent reference not set to NULL.\n");
+ "Download started but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadStarted.dc.pos != download) &&
- (event->data.DownloadStarted.dc.ppos != download) ) {
+ (event->data.DownloadStarted.dc.ppos != download) ) {
fprintf(stderr,
- "Download started but parent reference not set correctly.\n");
+ "Download started but parent reference not set correctly.\n");
have_error = 1;
}
break;
case FSUI_download_stopped:
if (event->data.DownloadStopped.dc.spos != search) {
fprintf(stderr,
- "Download stopped but search reference not set correctly.\n");
+ "Download stopped but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadStopped.dc.pos == download) &&
- (event->data.DownloadStopped.dc.ppos != NULL) ) {
+ (event->data.DownloadStopped.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download stopped but parent reference not set to NULL.\n");
+ "Download stopped but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadStopped.dc.pos != download) &&
- (event->data.DownloadStopped.dc.ppos != download) ) {
+ (event->data.DownloadStopped.dc.ppos != download) ) {
fprintf(stderr,
- "Download stopped but parent reference not set correctly.\n");
+ "Download stopped but parent reference not set correctly.\n");
have_error = 1;
}
break;
@@ -295,7 +295,7 @@
break;
default:
printf("Unexpected event: %d\n",
- event->type);
+ event->type);
break;
}
return NULL;
@@ -333,29 +333,29 @@
ok = YES;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS));
+ cfg,
+ 30 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
#endif
ctx = FSUI_start(NULL,
- cfg,
- "serializetest2",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "serializetest2",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
CHECK(ctx != NULL);
for (j=4;j<256;j+=4) {
fn = makeName(j);
@@ -363,60 +363,60 @@
for (i=0;i<FILESIZE;i++)
buf[i] = weak_randomi(256);
disk_file_write(ectx,
- fn,
- buf,
- FILESIZE,
- "600");
+ fn,
+ buf,
+ FILESIZE,
+ "600");
FREE(buf);
FREE(fn);
}
meta = ECRS_createMetaData();
kuri = ECRS_parseListKeywordURI(ectx,
- 2,
- (const char**)keywords);
+ 2,
+ (const char**)keywords);
ECRS_addToMetaData(meta,
- EXTRACTOR_MIMETYPE,
- GNUNET_DIRECTORY_MIME);
+ EXTRACTOR_MIMETYPE,
+ GNUNET_DIRECTORY_MIME);
upload = FSUI_startUpload(ctx,
- UPLOAD_PREFIX,
- (DirectoryScanCallback) &disk_directory_scan,
- NULL,
- 0,
- 0,
- YES,
- NO,
- NO,
- get_time() + 5 * cronHOURS,
- meta,
- kuri,
- kuri);
+ UPLOAD_PREFIX,
+ (DirectoryScanCallback) &disk_directory_scan,
+ NULL,
+ 0,
+ 0,
+ YES,
+ NO,
+ NO,
+ get_time() + 5 * cronHOURS,
+ meta,
+ kuri,
+ kuri);
CHECK(upload != NULL);
ECRS_freeUri(kuri);
kuri = NULL;
FSUI_stopUpload(ctx, upload);
CHECK(upURI != NULL);
SNPRINTF(keyword,
- 40,
- "%s %s %s",
- keywords[0],
- _("AND"),
- keywords[1]);
+ 40,
+ "%s %s %s",
+ keywords[0],
+ _("AND"),
+ keywords[1]);
uri = ECRS_parseCharKeywordURI(ectx,
- keyword);
+ keyword);
search = FSUI_startSearch(ctx,
- 0,
- 100,
- 240 * cronSECONDS,
- uri);
+ 0,
+ 100,
+ 240 * cronSECONDS,
+ uri);
CHECK(search != NULL);
download = FSUI_startDownload(ctx,
- 0,
- YES,
- upURI,
- meta,
- UPLOAD_PREFIX "-download",
- search,
- NULL);
+ 0,
+ YES,
+ upURI,
+ meta,
+ UPLOAD_PREFIX "-download",
+ search,
+ NULL);
ECRS_freeMetaData(meta);
prog = 0;
suspendRestart = 10;
@@ -424,22 +424,22 @@
prog++;
PTHREAD_SLEEP(50 * cronMILLIS);
if ( (suspendRestart > 0) &&
- (weak_randomi(100) == 0) ) {
+ (weak_randomi(100) == 0) ) {
#if 1
#if DEBUG_VERBOSE
printf("Testing FSUI suspend-resume\n");
#endif
FSUI_stop(ctx); /* download possibly incomplete
- at this point, thus testing resume */
+ at this point, thus testing resume */
CHECK(search == NULL);
CHECK(download == NULL);
ctx = FSUI_start(NULL,
- cfg,
- "serializetest2",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "serializetest2",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
#if DEBUG_VERBOSE
printf("Resumed...\n");
#endif
@@ -447,13 +447,13 @@
suspendRestart--;
}
if ( (search != NULL) &&
- (suspendRestart >= 5) ) {
+ (suspendRestart >= 5) ) {
no_check = 1;
PTHREAD_SLEEP(50 * cronMILLIS);
FSUI_abortSearch(ctx,
- search);
+ search);
FSUI_stopSearch(ctx,
- search);
+ search);
search = NULL;
no_check = 0;
}
@@ -461,12 +461,12 @@
break;
}
FSUI_stopDownload(ctx,
- download);
+ download);
for (j=4;j<256;j+=4) {
fn = makeName(j);
unindex = FSUI_startUnindex(ctx, fn);
FSUI_stopUnindex(ctx,
- unindex);
+ unindex);
UNLINK(fn);
FREE(fn);
}
Modified: GNUnet/src/applications/fs/fsui/serializetest3.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest3.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/fsui/serializetest3.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -44,7 +44,7 @@
static int have_error;
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
switch(event->type) {
case FSUI_search_suspended:
search = NULL;
@@ -63,8 +63,8 @@
case FSUI_upload_progress:
#if DEBUG_VERBOSE
printf("Upload is progressing (%llu/%llu)...\n",
- event->data.UploadProgress.completed,
- event->data.UploadProgress.total);
+ event->data.UploadProgress.completed,
+ event->data.UploadProgress.total);
#endif
break;
case FSUI_upload_completed:
@@ -75,8 +75,8 @@
case FSUI_unindex_progress:
#if DEBUG_VERBOSE
printf("Unindex is progressing (%llu/%llu)...\n",
- event->data.UnindexProgress.completed,
- event->data.UnindexProgress.total);
+ event->data.UnindexProgress.completed,
+ event->data.UnindexProgress.total);
#endif
break;
case FSUI_unindex_completed:
@@ -89,8 +89,8 @@
case FSUI_download_error:
case FSUI_search_error:
fprintf(stderr,
- "Received ERROR: %d\n",
- event->type);
+ "Received ERROR: %d\n",
+ event->type);
GE_BREAK(ectx, 0);
break;
case FSUI_download_aborted:
@@ -102,8 +102,8 @@
case FSUI_upload_suspended:
#if DEBUG_VERBOSE
fprintf(stderr,
- "Received SUSPENDING: %d\n",
- event->type);
+ "Received SUSPENDING: %d\n",
+ event->type);
#endif
break;
case FSUI_upload_started:
@@ -117,7 +117,7 @@
break;
default:
printf("Unexpected event: %d\n",
- event->type);
+ event->type);
break;
}
return NULL;
@@ -147,43 +147,43 @@
ok = YES;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS));
+ cfg,
+ 30 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
#endif
ctx = FSUI_start(NULL,
- cfg,
- "serializetest3",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "serializetest3",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
CHECK(ctx != NULL);
SNPRINTF(keyword,
- 40,
- "%s %s %s",
- keywords[0],
- _("AND"),
- keywords[1]);
+ 40,
+ "%s %s %s",
+ keywords[0],
+ _("AND"),
+ keywords[1]);
uri = ECRS_parseCharKeywordURI(ectx,
- keyword);
+ keyword);
search = FSUI_startSearch(ctx,
- 0,
- 100,
- 240 * cronSECONDS,
- uri);
+ 0,
+ 100,
+ 240 * cronSECONDS,
+ uri);
CHECK(search != NULL);
prog = 0;
suspendRestart = 10;
@@ -191,21 +191,21 @@
prog++;
PTHREAD_SLEEP(50 * cronMILLIS);
if ( (suspendRestart > 0) &&
- (weak_randomi(100) == 0) ) {
+ (weak_randomi(100) == 0) ) {
#if 1
#if DEBUG_VERBOSE
printf("Testing FSUI suspend-resume\n");
#endif
FSUI_stop(ctx); /* download possibly incomplete
- at this point, thus testing resume */
+ at this point, thus testing resume */
CHECK(search == NULL);
ctx = FSUI_start(NULL,
- cfg,
- "serializetest3",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "serializetest3",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
#if DEBUG_VERBOSE
printf("Resumed...\n");
#endif
@@ -216,9 +216,9 @@
break;
}
FSUI_abortSearch(ctx,
- search);
+ search);
FSUI_stopSearch(ctx,
- search);
+ search);
search = NULL;
/* END OF TEST CODE */
FAILURE:
@@ -229,7 +229,7 @@
#if START_DAEMON
GE_BREAK(NULL,
- OK == os_daemon_stop(NULL, daemon));
+ OK == os_daemon_stop(NULL, daemon));
#endif
GC_free(cfg);
if (have_error)
Modified: GNUnet/src/applications/fs/fsui/serializetest4.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest4.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/fsui/serializetest4.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -45,9 +45,9 @@
fn = MALLOC(strlen(UPLOAD_PREFIX "/FSUITEST") + 14);
SNPRINTF(fn,
- strlen(UPLOAD_PREFIX "/FSUITEST") + 14,
- UPLOAD_PREFIX "/FSUITEST%u",
- i);
+ strlen(UPLOAD_PREFIX "/FSUITEST") + 14,
+ UPLOAD_PREFIX "/FSUITEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -65,28 +65,28 @@
static int no_check;
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
if (no_check)
return NULL;
switch(event->type) {
case FSUI_download_suspended:
if (event->data.DownloadSuspended.dc.spos != NULL) {
fprintf(stderr,
- "Download suspended but search reference not set correctly.\n");
+ "Download suspended but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadSuspended.dc.pos == download) &&
- (event->data.DownloadSuspended.dc.ppos != NULL) ) {
+ (event->data.DownloadSuspended.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download suspended but parent reference not set to NULL.\n");
+ "Download suspended but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadSuspended.dc.pos != download) &&
- (event->data.DownloadSuspended.dc.ppos != download) ) {
+ (event->data.DownloadSuspended.dc.ppos != download) ) {
fprintf(stderr,
- "Download suspended but parent reference not set correctly (%p
instead of %p).\n",
- event->data.DownloadSuspended.dc.ppos,
- download);
+ "Download suspended but parent reference not set correctly (%p instead
of %p).\n",
+ event->data.DownloadSuspended.dc.ppos,
+ download);
have_error = 1;
}
if (event->data.DownloadSuspended.dc.pos == download)
@@ -97,19 +97,19 @@
download = event->data.DownloadResumed.dc.pos;
if (event->data.DownloadResumed.dc.spos != NULL) {
fprintf(stderr,
- "Download resuming but search reference not set correctly.\n");
+ "Download resuming but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadResumed.dc.pos == download) &&
- (event->data.DownloadResumed.dc.ppos != NULL) ) {
+ (event->data.DownloadResumed.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download resuming but parent reference not set to NULL.\n");
+ "Download resuming but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadResumed.dc.pos != download) &&
- (event->data.DownloadResumed.dc.ppos != download) ) {
+ (event->data.DownloadResumed.dc.ppos != download) ) {
fprintf(stderr,
- "Download resuming but parent reference not set correctly.\n");
+ "Download resuming but parent reference not set correctly.\n");
have_error = 1;
}
#if DEBUG_VERBOSE
@@ -119,8 +119,8 @@
case FSUI_upload_progress:
#if DEBUG_VERBOSE
printf("Upload is progressing (%llu/%llu)...\n",
- event->data.UploadProgress.completed,
- event->data.UploadProgress.total);
+ event->data.UploadProgress.completed,
+ event->data.UploadProgress.total);
#endif
break;
case FSUI_upload_completed:
@@ -134,19 +134,19 @@
case FSUI_download_completed:
if (event->data.DownloadCompleted.dc.spos != NULL) {
fprintf(stderr,
- "Download completed but search reference not set correctly.\n");
+ "Download completed but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadCompleted.dc.pos == download) &&
- (event->data.DownloadCompleted.dc.ppos != NULL) ) {
+ (event->data.DownloadCompleted.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download completed but parent reference not set to NULL.\n");
+ "Download completed but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadCompleted.dc.pos != download) &&
- (event->data.DownloadCompleted.dc.ppos != download) ) {
+ (event->data.DownloadCompleted.dc.ppos != download) ) {
fprintf(stderr,
- "Download completed but parent reference not set correctly.\n");
+ "Download completed but parent reference not set correctly.\n");
have_error = 1;
}
#if DEBUG_VERBOSE
@@ -156,32 +156,32 @@
case FSUI_download_progress:
if (event->data.DownloadResumed.dc.spos != NULL) {
fprintf(stderr,
- "Download progressing but search reference not set correctly.\n");
+ "Download progressing but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadResumed.dc.pos == download) &&
- (event->data.DownloadResumed.dc.ppos != NULL) ) {
+ (event->data.DownloadResumed.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download progressing but parent reference not set to NULL.\n");
+ "Download progressing but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadResumed.dc.pos != download) &&
- (event->data.DownloadResumed.dc.ppos != download) ) {
+ (event->data.DownloadResumed.dc.ppos != download) ) {
fprintf(stderr,
- "Download progressing but parent reference not set correctly.\n");
+ "Download progressing but parent reference not set correctly.\n");
have_error = 1;
}
#if DEBUG_VERBOSE
printf("Download is progressing (%llu/%llu)...\n",
- event->data.DownloadProgress.completed,
- event->data.DownloadProgress.total);
+ event->data.DownloadProgress.completed,
+ event->data.DownloadProgress.total);
#endif
break;
case FSUI_unindex_progress:
#if DEBUG_VERBOSE
printf("Unindex is progressing (%llu/%llu)...\n",
- event->data.UnindexProgress.completed,
- event->data.UnindexProgress.total);
+ event->data.UnindexProgress.completed,
+ event->data.UnindexProgress.total);
#endif
break;
case FSUI_unindex_completed:
@@ -194,8 +194,8 @@
case FSUI_download_error:
case FSUI_search_error:
fprintf(stderr,
- "Received ERROR: %d\n",
- event->type);
+ "Received ERROR: %d\n",
+ event->type);
GE_BREAK(ectx, 0);
break;
case FSUI_download_aborted:
@@ -207,8 +207,8 @@
case FSUI_upload_suspended:
#if DEBUG_VERBOSE
fprintf(stderr,
- "Received SUSPENDING: %d\n",
- event->type);
+ "Received SUSPENDING: %d\n",
+ event->type);
#endif
break;
case FSUI_download_started:
@@ -216,38 +216,38 @@
download = event->data.DownloadStarted.dc.pos;
if (event->data.DownloadStarted.dc.spos != NULL) {
fprintf(stderr,
- "Download started but search reference not set correctly.\n");
+ "Download started but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadStarted.dc.pos == download) &&
- (event->data.DownloadStarted.dc.ppos != NULL) ) {
+ (event->data.DownloadStarted.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download started but parent reference not set to NULL.\n");
+ "Download started but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadStarted.dc.pos != download) &&
- (event->data.DownloadStarted.dc.ppos != download) ) {
+ (event->data.DownloadStarted.dc.ppos != download) ) {
fprintf(stderr,
- "Download started but parent reference not set correctly.\n");
+ "Download started but parent reference not set correctly.\n");
have_error = 1;
}
break;
case FSUI_download_stopped:
if (event->data.DownloadStopped.dc.spos != NULL) {
fprintf(stderr,
- "Download stopped but search reference not set correctly.\n");
+ "Download stopped but search reference not set correctly.\n");
have_error = 1;
}
if ( (event->data.DownloadStopped.dc.pos == download) &&
- (event->data.DownloadStopped.dc.ppos != NULL) ) {
+ (event->data.DownloadStopped.dc.ppos != NULL) ) {
fprintf(stderr,
- "Download stopped but parent reference not set to NULL.\n");
+ "Download stopped but parent reference not set to NULL.\n");
have_error = 1;
}
if ( (event->data.DownloadStopped.dc.pos != download) &&
- (event->data.DownloadStopped.dc.ppos != download) ) {
+ (event->data.DownloadStopped.dc.ppos != download) ) {
fprintf(stderr,
- "Download stopped but parent reference not set correctly.\n");
+ "Download stopped but parent reference not set correctly.\n");
have_error = 1;
}
break;
@@ -261,7 +261,7 @@
break;
default:
printf("Unexpected event: %d\n",
- event->type);
+ event->type);
break;
}
return NULL;
@@ -299,29 +299,29 @@
ok = YES;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS));
+ cfg,
+ 30 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
#endif
ctx = FSUI_start(NULL,
- cfg,
- "serializetest4",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "serializetest4",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
CHECK(ctx != NULL);
for (j=4;j<16;j+=4) {
fn = makeName(j);
@@ -329,53 +329,53 @@
for (i=0;i<FILESIZE;i++)
buf[i] = weak_randomi(256);
disk_file_write(ectx,
- fn,
- buf,
- FILESIZE,
- "600");
+ fn,
+ buf,
+ FILESIZE,
+ "600");
FREE(buf);
FREE(fn);
}
meta = ECRS_createMetaData();
kuri = ECRS_parseListKeywordURI(ectx,
- 2,
- (const char**)keywords);
+ 2,
+ (const char**)keywords);
ECRS_addToMetaData(meta,
- EXTRACTOR_MIMETYPE,
- GNUNET_DIRECTORY_MIME);
+ EXTRACTOR_MIMETYPE,
+ GNUNET_DIRECTORY_MIME);
upload = FSUI_startUpload(ctx,
- UPLOAD_PREFIX,
- (DirectoryScanCallback) &disk_directory_scan,
- NULL,
- 0,
- 0,
- YES,
- NO,
- NO,
- get_time() + 5 * cronHOURS,
- meta,
- kuri,
- kuri);
+ UPLOAD_PREFIX,
+ (DirectoryScanCallback) &disk_directory_scan,
+ NULL,
+ 0,
+ 0,
+ YES,
+ NO,
+ NO,
+ get_time() + 5 * cronHOURS,
+ meta,
+ kuri,
+ kuri);
CHECK(upload != NULL);
ECRS_freeUri(kuri);
kuri = NULL;
FSUI_stopUpload(ctx, upload);
SNPRINTF(keyword,
- 40,
- "%s %s %s",
- keywords[0],
- _("AND"),
- keywords[1]);
+ 40,
+ "%s %s %s",
+ keywords[0],
+ _("AND"),
+ keywords[1]);
uri = ECRS_parseCharKeywordURI(ectx,
- keyword);
+ keyword);
download = FSUI_startDownload(ctx,
- 0,
- YES,
- upURI,
- meta,
- UPLOAD_PREFIX "-download",
- NULL,
- NULL);
+ 0,
+ YES,
+ upURI,
+ meta,
+ UPLOAD_PREFIX "-download",
+ NULL,
+ NULL);
ECRS_freeMetaData(meta);
prog = 0;
suspendRestart = 10;
@@ -383,21 +383,21 @@
prog++;
PTHREAD_SLEEP(50 * cronMILLIS);
if ( (suspendRestart > 0) &&
- (weak_randomi(100) == 0) ) {
+ (weak_randomi(100) == 0) ) {
#if 1
#if DEBUG_VERBOSE
printf("Testing FSUI suspend-resume\n");
#endif
FSUI_stop(ctx); /* download possibly incomplete
- at this point, thus testing resume */
+ at this point, thus testing resume */
CHECK(download == NULL);
ctx = FSUI_start(NULL,
- cfg,
- "serializetest4",
- 32,
- YES,
- &eventCallback,
- NULL);
+ cfg,
+ "serializetest4",
+ 32,
+ YES,
+ &eventCallback,
+ NULL);
#if DEBUG_VERBOSE
printf("Resumed...\n");
#endif
@@ -408,12 +408,12 @@
break;
}
FSUI_stopDownload(ctx,
- download);
+ download);
for (j=4;j<16;j+=4) {
fn = makeName(j);
unindex = FSUI_startUnindex(ctx, fn);
FSUI_stopUnindex(ctx,
- unindex);
+ unindex);
UNLINK(fn);
FREE(fn);
}
Modified: GNUnet/src/applications/fs/fsui/unindex.c
===================================================================
--- GNUnet/src/applications/fs/fsui/unindex.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/fsui/unindex.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -36,9 +36,9 @@
* Transform an ECRS progress callback into an FSUI event.
*/
static void progressCallback(unsigned long long totalBytes,
- unsigned long long completedBytes,
- cron_t eta,
- void * cls) {
+ unsigned long long completedBytes,
+ cron_t eta,
+ void * cls) {
FSUI_UnindexList * utc = cls;
FSUI_Event event;
@@ -50,7 +50,7 @@
event.data.UnindexProgress.eta = eta;
event.data.UnindexProgress.filename = utc->filename;
utc->ctx->ecb(utc->ctx->ecbClosure,
- &event);
+ &event);
}
static int tt(void * cls) {
@@ -72,22 +72,22 @@
struct GE_Context * ee;
if (OK != disk_file_size(utc->ctx->ectx,
- utc->filename,
- &size,
- YES)) {
+ utc->filename,
+ &size,
+ YES)) {
GE_BREAK(utc->ctx->ectx, 0);
size = 0;
}
mem = GE_memory_create(2);
ee = GE_create_context_memory(GE_USER | GE_ADMIN | GE_ERROR | GE_WARNING |
GE_FATAL | GE_BULK | GE_IMMEDIATE,
- mem);
+ mem);
ret = ECRS_unindexFile(ee,
- utc->ctx->cfg,
- utc->filename,
- &progressCallback,
- utc,
- &tt,
- utc);
+ utc->ctx->cfg,
+ utc->filename,
+ &progressCallback,
+ utc,
+ &tt,
+ utc);
if (ret == OK) {
utc->state = FSUI_COMPLETED;
event.type = FSUI_unindex_completed;
@@ -96,7 +96,7 @@
event.data.UnindexCompleted.total = size;
event.data.UnindexCompleted.filename = utc->filename;
utc->ctx->ecb(utc->ctx->ecbClosure,
- &event);
+ &event);
} else if (utc->state == FSUI_ACTIVE) {
const char * error;
@@ -109,23 +109,23 @@
error = _("Unindexing failed (no reason given)");
event.data.UnindexError.message = error;
utc->ctx->ecb(utc->ctx->ecbClosure,
- &event);
+ &event);
} else if (utc->state == FSUI_ABORTED) {
event.type = FSUI_unindex_aborted;
event.data.UnindexAborted.uc.pos = utc;
event.data.UnindexAborted.uc.cctx = utc->cctx;
utc->ctx->ecb(utc->ctx->ecbClosure,
- &event);
+ &event);
} else {
/* must be suspending */
GE_BREAK(NULL,
- utc->state == FSUI_PENDING);
+ utc->state == FSUI_PENDING);
}
#if 0
GE_LOG(utc->ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSUI unindexThread exits in state %u.\n",
- utc->state);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSUI unindexThread exits in state %u.\n",
+ utc->state);
#endif
GE_free_context(ee);
GE_memory_free(mem);
@@ -141,9 +141,9 @@
unsigned long long size;
if (OK != disk_file_size(utc->ctx->ectx,
- utc->filename,
- &size,
- YES)) {
+ utc->filename,
+ &size,
+ YES)) {
GE_BREAK(utc->ctx->ectx, 0);
size = 0;
}
@@ -153,7 +153,7 @@
event.data.UnindexStarted.total = size;
event.data.UnindexStarted.filename = utc->filename;
utc->cctx = utc->ctx->ecb(utc->ctx->ecbClosure,
- &event);
+ &event);
return FSUI_unindexThread(utc);
}
@@ -169,16 +169,16 @@
*/
struct FSUI_UnindexList *
FSUI_startUnindex(struct FSUI_Context * ctx,
- const char * filename) {
+ const char * filename) {
FSUI_UnindexList * utc;
if (YES == disk_directory_test(ctx->ectx,
- filename)) {
+ filename)) {
GE_BREAK(ctx->ectx, 0);
return NULL;
}
if (YES != disk_file_test(ctx->ectx,
- filename)) {
+ filename)) {
GE_BREAK(ctx->ectx, 0);
return NULL;
}
@@ -188,12 +188,12 @@
utc->start_time = get_time();
utc->state = FSUI_ACTIVE;
utc->handle = PTHREAD_CREATE(&FSUI_unindexThreadEvent,
- utc,
- 32 * 1024);
+ utc,
+ 32 * 1024);
if (utc->handle == NULL) {
GE_LOG_STRERROR(ctx->ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_IMMEDIATE,
- "PTHREAD_CREATE");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_IMMEDIATE,
+ "PTHREAD_CREATE");
FREE(utc->filename);
FREE(utc);
return NULL;
@@ -212,7 +212,7 @@
* @return SYSERR if no such unindex is pending
*/
int FSUI_abortUnindex(struct FSUI_Context * ctx,
- struct FSUI_UnindexList * ul) {
+ struct FSUI_UnindexList * ul) {
if ( (ul->state != FSUI_ACTIVE) &&
(ul->state != FSUI_PENDING) )
return NO;
@@ -232,7 +232,7 @@
* @return SYSERR if no such unindex is pending
*/
int FSUI_stopUnindex(struct FSUI_Context * ctx,
- struct FSUI_UnindexList * dl) {
+ struct FSUI_UnindexList * dl) {
FSUI_UnindexList * prev;
struct GE_Context * ectx;
void * unused;
@@ -245,20 +245,20 @@
}
#if 0
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSUI_stopUnindex called.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSUI_stopUnindex called.\n");
#endif
MUTEX_LOCK(ctx->lock);
prev = ctx->unindexOperations;
while ( (prev != dl) &&
- (prev != NULL) &&
- (prev->next != dl) )
+ (prev != NULL) &&
+ (prev->next != dl) )
prev = prev->next;
if (prev == NULL) {
MUTEX_UNLOCK(ctx->lock);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSUI_stopUnindex failed to locate deletion operation.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSUI_stopUnindex failed to locate deletion operation.\n");
return SYSERR;
}
if (prev == dl) {
@@ -273,7 +273,7 @@
(dl->state == FSUI_ERROR) ) {
GE_ASSERT(ctx->ectx, dl->handle != NULL);
PTHREAD_JOIN(dl->handle,
- &unused);
+ &unused);
dl->handle = NULL;
if (dl->state == FSUI_ACTIVE)
dl->state = FSUI_PENDING;
@@ -286,7 +286,7 @@
event.data.UnindexStopped.uc.pos = dl;
event.data.UnindexStopped.uc.cctx = dl->cctx;
dl->ctx->ecb(dl->ctx->ecbClosure,
- &event);
+ &event);
FREE(dl->filename);
FREE(dl);
return OK;
Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/fsui/upload.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -41,9 +41,9 @@
* Transform an ECRS progress callback into an FSUI event.
*/
static void progressCallback(unsigned long long totalBytes,
- unsigned long long completedBytes,
- cron_t eta,
- void * ptr) {
+ unsigned long long completedBytes,
+ cron_t eta,
+ void * ptr) {
FSUI_UploadList * utc = ptr;
FSUI_Event event;
unsigned long long subtotal;
@@ -62,7 +62,7 @@
event.data.UploadProgress.filename = utc->filename;
utc->completed = completedBytes;
utc->shared->ctx->ecb(utc->shared->ctx->ecbClosure,
- &event);
+ &event);
if (utc->parent != &utc->shared->ctx->activeUploads) {
subtotal = 0;
pos = utc->parent->child;
@@ -74,13 +74,13 @@
xeta = now;
if (subtotal > 0) {
xeta = (cron_t) (utc->parent->start_time +
- (((double)(now -
utc->parent->start_time)/(double)subtotal))
- * (double)utc->parent->total);
+ (((double)(now - utc->parent->start_time)/(double)subtotal))
+ * (double)utc->parent->total);
}
progressCallback(utc->parent->total,
- subtotal,
- xeta,
- utc->parent);
+ subtotal,
+ xeta,
+ utc->parent);
}
}
@@ -97,10 +97,10 @@
*/
static char *
createDirectoryHelper(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct FSUI_UploadList * children,
- struct ECRS_MetaData * meta,
- char ** error) {
+ struct GC_Configuration * cfg,
+ struct FSUI_UploadList * children,
+ struct ECRS_MetaData * meta,
+ char ** error) {
ECRS_FileInfo * fis;
unsigned int count;
unsigned int size;
@@ -138,13 +138,13 @@
GE_BREAK(ectx, count == size);
mem = GE_memory_create(2);
ee = GE_create_context_memory(GE_USER | GE_ADMIN | GE_ERROR | GE_WARNING |
GE_FATAL | GE_BULK | GE_IMMEDIATE,
- mem);
+ mem);
ret = ECRS_createDirectory(ee,
- &data,
- &len,
- size,
- fis,
- meta);
+ &data,
+ &len,
+ size,
+ fis,
+ meta);
GROW(fis,
size,
0);
@@ -158,9 +158,9 @@
while (pos != NULL) {
if (pos->uri != NULL)
URITRACK_addState(ectx,
- cfg,
- pos->uri,
- URITRACK_DIRECTORY_ADDED);
+ cfg,
+ pos->uri,
+ URITRACK_DIRECTORY_ADDED);
pos = pos->next;
}
GE_memory_reset(mem);
@@ -168,8 +168,8 @@
handle = mkstemp(tempName);
if (handle == -1) {
GE_LOG_STRERROR_FILE(ee,
- GE_ERROR | GE_USER | GE_BULK,
- "mkstemp",
+ GE_ERROR | GE_USER | GE_BULK,
+ "mkstemp",
tempName);
FREE(tempName);
FREE(data);
@@ -179,12 +179,12 @@
return NULL;
}
if (len != WRITE(handle,
- data,
- len)) {
+ data,
+ len)) {
GE_LOG_STRERROR_FILE(ee,
- GE_ERROR | GE_USER | GE_BULK,
- "write",
- tempName);
+ GE_ERROR | GE_USER | GE_BULK,
+ "write",
+ tempName);
*error = STRDUP(GE_memory_get(mem, 0));
GE_free_context(ee);
GE_memory_free(mem);
@@ -202,7 +202,7 @@
* Signal upload error to client.
*/
static void signalError(FSUI_UploadList * utc,
- const char * message) {
+ const char * message) {
FSUI_Event event;
utc->state = FSUI_ERROR;
@@ -213,11 +213,11 @@
event.data.UploadError.uc.pcctx = utc->parent->cctx;
event.data.UploadError.message = message;
utc->shared->ctx->ecb(utc->shared->ctx->ecbClosure,
- &event);
+ &event);
}
static void signalUploadStarted(struct FSUI_UploadList * utc,
- int first_only) {
+ int first_only) {
FSUI_Event event;
while (utc != NULL) {
@@ -230,7 +230,7 @@
event.data.UploadStarted.anonymityLevel = utc->shared->anonymityLevel;
event.data.UploadStarted.filename = utc->filename;
utc->cctx = utc->shared->ctx->ecb(utc->shared->ctx->ecbClosure,
- &event);
+ &event);
signalUploadStarted(utc->child, 0);
if (first_only)
break;
@@ -269,18 +269,18 @@
if (utc->state != FSUI_ACTIVE)
return NULL; /* aborted or suspended */
if (YES == disk_directory_test(ectx,
- utc->filename)) {
+ utc->filename)) {
error = NULL;
filename = createDirectoryHelper(ectx,
- utc->shared->ctx->cfg,
- utc->child,
- utc->meta,
- &error);
+ utc->shared->ctx->cfg,
+ utc->child,
+ utc->meta,
+ &error);
if (filename == NULL) {
if (error == NULL)
- error = STRDUP(_("Failed to create temporary directory."));
+ error = STRDUP(_("Failed to create temporary directory."));
signalError(utc,
- error);
+ error);
FREE(error);
return NULL;
}
@@ -290,26 +290,26 @@
utc->start_time = get_time();
mem = GE_memory_create(2);
ee = GE_create_context_memory(GE_USER | GE_ADMIN | GE_ERROR | GE_WARNING |
GE_FATAL | GE_BULK | GE_IMMEDIATE,
- mem);
+ mem);
ret = ECRS_uploadFile(ee,
- utc->shared->ctx->cfg,
- filename,
- utc->shared->doIndex == YES ? (utc->child == NULL ? YES
: NO) : NO,
- utc->shared->anonymityLevel,
- utc->shared->priority,
- utc->shared->expiration,
- &progressCallback,
- utc,
- &testTerminate,
- utc,
- &utc->uri);
+ utc->shared->ctx->cfg,
+ filename,
+ utc->shared->doIndex == YES ? (utc->child == NULL ? YES : NO) :
NO,
+ utc->shared->anonymityLevel,
+ utc->shared->priority,
+ utc->shared->expiration,
+ &progressCallback,
+ utc,
+ &testTerminate,
+ utc,
+ &utc->uri);
if (ret != OK) {
if (utc->state == FSUI_ACTIVE) {
const char *err;
err = GE_memory_get(mem, 0);
signalError(utc,
- err ? err : "");
+ err ? err : "");
} else if (utc->state == FSUI_ABORTED) {
event.type = FSUI_upload_aborted;
event.data.UploadAborted.uc.pos = utc;
@@ -317,7 +317,7 @@
event.data.UploadAborted.uc.ppos = utc->parent;
event.data.UploadAborted.uc.pcctx = utc->parent->cctx;
utc->shared->ctx->ecb(utc->shared->ctx->ecbClosure,
- &event);
+ &event);
} else {
/* must be suspended */
GE_BREAK(NULL, utc->state == FSUI_PENDING);
@@ -332,12 +332,12 @@
utc->state = FSUI_COMPLETED;
if (utc->child == NULL)
ECRS_extractMetaData(utc->shared->ctx->ectx,
- utc->meta,
- utc->filename,
- utc->shared->extractors);
+ utc->meta,
+ utc->filename,
+ utc->shared->extractors);
while (OK == ECRS_delFromMetaData(utc->meta,
- EXTRACTOR_FILENAME,
- NULL)) ;
+ EXTRACTOR_FILENAME,
+ NULL)) ;
/* only publish the last part of the path
-- we do not want to publish $HOME or similar
trivially deanonymizing information */
@@ -346,17 +346,17 @@
(tpos > 0) )
tpos--;
while ( (tpos > 0) &&
- (utc->filename[tpos] != DIR_SEPARATOR) )
+ (utc->filename[tpos] != DIR_SEPARATOR) )
tpos--;
pfn = MALLOC(strlen(&utc->filename[tpos+1]) + 2);
strcpy(pfn, &utc->filename[tpos+1]);
if ( (utc->child != NULL) &&
( (strlen(pfn) == 0) ||
- (pfn[strlen(pfn)-1] != DIR_SEPARATOR) ) )
+ (pfn[strlen(pfn)-1] != DIR_SEPARATOR) ) )
strcat(pfn, DIR_SEPARATOR_STR);
ECRS_addToMetaData(utc->meta,
- EXTRACTOR_FILENAME,
- pfn);
+ EXTRACTOR_FILENAME,
+ pfn);
FREE(pfn);
if ( (utc->shared->anonymityLevel == 0) &&
(utc->shared->doIndex == YES) ) {
@@ -365,16 +365,16 @@
P2P_hello_MESSAGE * hello;
sock = client_connection_create(utc->shared->ctx->ectx,
- utc->shared->ctx->cfg);
-
+ utc->shared->ctx->cfg);
+
if (OK == gnunet_identity_get_self(sock,
- &hello)) {
+ &hello)) {
loc = ECRS_uriFromLocation(utc->uri,
- &hello->publicKey,
- ntohl(hello->expirationTime),
- (ECRS_SignFunction)
&gnunet_identity_sign_function,
- sock);
-
+ &hello->publicKey,
+ ntohl(hello->expirationTime),
+ (ECRS_SignFunction) &gnunet_identity_sign_function,
+ sock);
+
FREE(hello);
} else {
/* may happen if no transports are available... */
@@ -388,48 +388,48 @@
}
if (utc->shared->global_keywords != NULL)
ECRS_addToKeyspace(ectx,
- utc->shared->ctx->cfg,
- utc->shared->global_keywords,
- utc->shared->anonymityLevel,
- utc->shared->priority,
- utc->shared->expiration,
- loc,
- utc->meta);
+ utc->shared->ctx->cfg,
+ utc->shared->global_keywords,
+ utc->shared->anonymityLevel,
+ utc->shared->priority,
+ utc->shared->expiration,
+ loc,
+ utc->meta);
if (utc->keywords != NULL)
ECRS_addToKeyspace(ectx,
- utc->shared->ctx->cfg,
- utc->keywords,
- utc->shared->anonymityLevel,
- utc->shared->priority,
- utc->shared->expiration,
- loc,
- utc->meta);
+ utc->shared->ctx->cfg,
+ utc->keywords,
+ utc->shared->anonymityLevel,
+ utc->shared->priority,
+ utc->shared->expiration,
+ loc,
+ utc->meta);
if (utc->shared->individualKeywords == YES) {
uri = ECRS_metaDataToUri(utc->meta);
ECRS_addToKeyspace(ectx,
- utc->shared->ctx->cfg,
- uri,
- utc->shared->anonymityLevel,
- utc->shared->priority,
- utc->shared->expiration,
- loc,
- utc->meta);
+ utc->shared->ctx->cfg,
+ uri,
+ utc->shared->anonymityLevel,
+ utc->shared->priority,
+ utc->shared->expiration,
+ loc,
+ utc->meta);
ECRS_freeUri(uri);
}
ECRS_freeUri(loc);
loc = NULL;
while (OK == ECRS_delFromMetaData(utc->meta,
- EXTRACTOR_SPLIT,
- NULL)) ;
+ EXTRACTOR_SPLIT,
+ NULL)) ;
fi.meta = utc->meta;
fi.uri = utc->uri;
URITRACK_trackURI(ectx,
- utc->shared->ctx->cfg,
- &fi);
+ utc->shared->ctx->cfg,
+ &fi);
URITRACK_addState(ectx,
- utc->shared->ctx->cfg,
- utc->uri,
- utc->shared->doIndex == YES ? URITRACK_INDEXED :
URITRACK_INSERTED);
+ utc->shared->ctx->cfg,
+ utc->uri,
+ utc->shared->doIndex == YES ? URITRACK_INDEXED : URITRACK_INSERTED);
event.type = FSUI_upload_completed;
event.data.UploadCompleted.uc.pos = utc;
event.data.UploadCompleted.uc.cctx = utc->cctx;
@@ -439,7 +439,7 @@
event.data.UploadCompleted.filename = utc->filename;
event.data.UploadCompleted.uri = utc->uri;
utc->shared->ctx->ecb(utc->shared->ctx->ecbClosure,
- &event);
+ &event);
if (utc->child != NULL)
UNLINK(filename);
FREE(filename);
@@ -490,9 +490,9 @@
while (next->next != ul) {
next = next->next;
if (next == NULL) {
- GE_BREAK(NULL, 0);
- MUTEX_UNLOCK(ctx->lock);
- return;
+ GE_BREAK(NULL, 0);
+ MUTEX_UNLOCK(ctx->lock);
+ return;
}
}
next->next = ul->next;
@@ -503,14 +503,14 @@
static struct FSUI_UploadList *
addUploads(struct FSUI_UploadShared * shared,
- const char * filename,
- const struct ECRS_URI * keywords,
- const struct ECRS_MetaData * md,
- struct FSUI_UploadList * parent);
+ const char * filename,
+ const struct ECRS_URI * keywords,
+ const struct ECRS_MetaData * md,
+ struct FSUI_UploadList * parent);
static int addChildUpload(const char * name,
- const char * dirName,
- void * data) {
+ const char * dirName,
+ void * data) {
struct FSUI_UploadList * parent = data;
char * filename;
struct FSUI_UploadList * child;
@@ -522,10 +522,10 @@
strcat(filename, name);
md = ECRS_createMetaData();
child = addUploads(parent->shared,
- filename,
- NULL,
- md,
- parent);
+ filename,
+ NULL,
+ md,
+ parent);
FREE(filename);
ECRS_freeMetaData(md);
if (child == NULL)
@@ -536,10 +536,10 @@
static struct FSUI_UploadList *
addUploads(struct FSUI_UploadShared * shared,
- const char * filename,
- const struct ECRS_URI * keywords,
- const struct ECRS_MetaData * md,
- struct FSUI_UploadList * parent) {
+ const char * filename,
+ const struct ECRS_URI * keywords,
+ const struct ECRS_MetaData * md,
+ struct FSUI_UploadList * parent) {
FSUI_UploadList * utc;
utc = MALLOC(sizeof(FSUI_UploadList));
@@ -554,31 +554,31 @@
utc->cctx = NULL; /* to be set later */
utc->state = FSUI_ACTIVE;
if (YES == disk_file_test(shared->ctx->ectx,
- filename)) {
+ filename)) {
/* add this file */
if (OK != disk_file_size(shared->ctx->ectx,
- filename,
- &utc->total,
- YES)) {
+ filename,
+ &utc->total,
+ YES)) {
FREE(utc);
return NULL;
}
utc->meta = ECRS_dupMetaData(md);
} else {
if (SYSERR == shared->dsc(shared->dscClosure,
- filename,
- &addChildUpload,
- utc)) {
+ filename,
+ &addChildUpload,
+ utc)) {
/* error scanning upload directory */
while (utc->child != NULL)
- freeUploadList(utc->child);
+ freeUploadList(utc->child);
FREE(utc);
return NULL;
}
utc->meta = ECRS_dupMetaData(md);
ECRS_addToMetaData(utc->meta,
- EXTRACTOR_MIMETYPE,
- GNUNET_DIRECTORY_MIME);
+ EXTRACTOR_MIMETYPE,
+ GNUNET_DIRECTORY_MIME);
}
if (keywords != NULL)
utc->keywords = ECRS_dupUri(keywords);
@@ -595,7 +595,7 @@
}
static void signalUploadStopped(struct FSUI_UploadList * ul,
- int first_only) {
+ int first_only) {
FSUI_Event event;
while (ul != NULL) {
@@ -606,7 +606,7 @@
event.data.UploadStopped.uc.ppos = ul->parent;
event.data.UploadStopped.uc.pcctx = ul->parent->cctx;
ul->shared->ctx->ecb(ul->shared->ctx->ecbClosure,
- &event);
+ &event);
if (first_only)
break;
ul = ul->next;
@@ -633,18 +633,18 @@
*/
struct FSUI_UploadList *
FSUI_startUpload(struct FSUI_Context * ctx,
- const char * filename,
- DirectoryScanCallback dsc,
- void * dscClosure,
- unsigned int anonymityLevel,
- unsigned int priority,
- int doIndex,
- int doExtract,
- int individualKeywords,
- cron_t expiration,
- const struct ECRS_MetaData * md,
- const struct ECRS_URI * globalURI,
- const struct ECRS_URI * keyUri) {
+ const char * filename,
+ DirectoryScanCallback dsc,
+ void * dscClosure,
+ unsigned int anonymityLevel,
+ unsigned int priority,
+ int doIndex,
+ int doExtract,
+ int individualKeywords,
+ cron_t expiration,
+ const struct ECRS_MetaData * md,
+ const struct ECRS_URI * globalURI,
+ const struct ECRS_URI * keyUri) {
char * config;
EXTRACTOR_ExtractorList * extractors;
struct FSUI_UploadShared * shared;
@@ -655,16 +655,16 @@
if (doExtract) {
extractors = EXTRACTOR_loadDefaultLibraries();
if (GC_have_configuration_value(ctx->cfg,
- "FS",
- "EXTRACTORS")) {
+ "FS",
+ "EXTRACTORS")) {
GC_get_configuration_value_string(ctx->cfg,
- "FS",
- "EXTRACTORS",
- NULL,
- &config);
+ "FS",
+ "EXTRACTORS",
+ NULL,
+ &config);
if (config != NULL) {
- extractors = EXTRACTOR_loadConfigLibraries(extractors,
- config);
+ extractors = EXTRACTOR_loadConfigLibraries(extractors,
+ config);
}
}
}
@@ -683,21 +683,21 @@
shared->individualKeywords = individualKeywords;
shared->handle = NULL;
ul = addUploads(shared,
- filename,
- keyUri,
- md,
- &ctx->activeUploads);
+ filename,
+ keyUri,
+ md,
+ &ctx->activeUploads);
if (ul == NULL) {
freeShared(shared);
return NULL;
}
shared->handle = PTHREAD_CREATE(&FSUI_uploadThreadEvent,
- ul,
- 128 * 1024);
+ ul,
+ 128 * 1024);
if (shared->handle == NULL) {
GE_LOG_STRERROR(ctx->ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "PTHREAD_CREATE");
+ GE_ERROR | GE_USER | GE_BULK,
+ "PTHREAD_CREATE");
freeUploadList(ul);
freeShared(shared);
return NULL;
@@ -716,7 +716,7 @@
* @return SYSERR on error
*/
int FSUI_abortUpload(struct FSUI_Context * ctx,
- struct FSUI_UploadList * ul) {
+ struct FSUI_UploadList * ul) {
FSUI_UploadList * c;
GE_ASSERT(ctx->ectx, ul != NULL);
@@ -749,7 +749,7 @@
* @return SYSERR on error
*/
int FSUI_stopUpload(struct FSUI_Context * ctx,
- struct FSUI_UploadList * ul) {
+ struct FSUI_UploadList * ul) {
void * unused;
struct FSUI_UploadShared * shared;
@@ -761,7 +761,7 @@
(ul->state == FSUI_ERROR) ) {
GE_ASSERT(ctx->ectx, ul->shared->handle != NULL);
PTHREAD_JOIN(ul->shared->handle,
- &unused);
+ &unused);
ul->shared->handle = NULL;
if (ul->state == FSUI_ACTIVE)
ul->state = FSUI_PENDING;
Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/lib/fslib.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -74,79 +74,79 @@
while (ctx->abort == NO) {
hdr = NULL;
if (OK == connection_read(ctx->sock,
- &hdr)) {
+ &hdr)) {
#if DEBUG_FSLIB
GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSLIB: received message from gnunetd\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSLIB: received message from gnunetd\n");
#endif
delay = 100 * cronMILLIS;
/* verify hdr, if reply, process, otherwise
- signal protocol problem; if ok, find
- matching callback, call on value */
+ signal protocol problem; if ok, find
+ matching callback, call on value */
if ( (ntohs(hdr->size) < sizeof(CS_fs_reply_content_MESSAGE)) ||
- (ntohs(hdr->type) != CS_PROTO_gap_RESULT) ) {
- GE_BREAK(ctx->ectx, 0);
- FREE(hdr);
- continue;
+ (ntohs(hdr->type) != CS_PROTO_gap_RESULT) ) {
+ GE_BREAK(ctx->ectx, 0);
+ FREE(hdr);
+ continue;
}
rep = (const CS_fs_reply_content_MESSAGE*) hdr;
size = ntohs(hdr->size) - sizeof(CS_fs_reply_content_MESSAGE);
if (OK != getQueryFor(size,
- (DBlock*)&rep[1],
- NO, /* gnunetd will have checked already */
- &query)) {
- GE_BREAK(ctx->ectx, 0);
- FREE(hdr);
- continue;
+ (DBlock*)&rep[1],
+ NO, /* gnunetd will have checked already */
+ &query)) {
+ GE_BREAK(ctx->ectx, 0);
+ FREE(hdr);
+ continue;
}
matched = 0;
MUTEX_LOCK(ctx->lock);
for (i=ctx->handleCount-1;i>=0;i--) {
- if (equalsHashCode512(&query,
- &ctx->handles[i]->req->query[0])) {
- Datastore_Value * value;
+ if (equalsHashCode512(&query,
+ &ctx->handles[i]->req->query[0])) {
+ Datastore_Value * value;
- matched++;
- if (ctx->handles[i]->callback != NULL) {
- value = MALLOC(sizeof(Datastore_Value) + size);
- value->size = htonl(size + sizeof(Datastore_Value));
- value->type = htonl(getTypeOfBlock(size,
- (DBlock*) &rep[1]));
- value->prio = htonl(0);
- value->anonymityLevel = rep->anonymityLevel;
- value->expirationTime = rep->expirationTime;
- memcpy(&value[1],
- &rep[1],
- size);
- if (SYSERR == ctx->handles[i]->callback(&query,
- value,
- ctx->handles[i]->closure)) {
- ctx->handles[i]->callback = NULL;
- }
- FREE(value);
- }
- }
+ matched++;
+ if (ctx->handles[i]->callback != NULL) {
+ value = MALLOC(sizeof(Datastore_Value) + size);
+ value->size = htonl(size + sizeof(Datastore_Value));
+ value->type = htonl(getTypeOfBlock(size,
+ (DBlock*) &rep[1]));
+ value->prio = htonl(0);
+ value->anonymityLevel = rep->anonymityLevel;
+ value->expirationTime = rep->expirationTime;
+ memcpy(&value[1],
+ &rep[1],
+ size);
+ if (SYSERR == ctx->handles[i]->callback(&query,
+ value,
+ ctx->handles[i]->closure)) {
+ ctx->handles[i]->callback = NULL;
}
+ FREE(value);
+ }
+ }
+ }
MUTEX_UNLOCK(ctx->lock);
#if DEBUG_FSLIB
if (matched == 0)
- GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSLIB: received content but have no pending request\n");
+ GE_LOG(ctx->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSLIB: received content but have no pending request\n");
#endif
} else {
#if DEBUG_FSLIB
GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSLIB: error communicating with gnunetd; sleeping for %ums\n",
- delay);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSLIB: error communicating with gnunetd; sleeping for %ums\n",
+ delay);
#endif
if (ctx->abort == NO)
- PTHREAD_SLEEP(delay);
+ PTHREAD_SLEEP(delay);
delay *= 2;
if (delay > 5 * cronSECONDS)
- delay = 5 * cronSECONDS;
+ delay = 5 * cronSECONDS;
}
FREENONNULL(hdr);
}
@@ -155,8 +155,8 @@
SEARCH_CONTEXT *
FS_SEARCH_makeContext(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct MUTEX * lock) {
+ struct GC_Configuration * cfg,
+ struct MUTEX * lock) {
SEARCH_CONTEXT * ret;
GE_ASSERT(ectx, lock != NULL);
@@ -174,12 +174,12 @@
ret->handleSize = 0;
ret->abort = NO;
ret->thread = PTHREAD_CREATE(&processReplies,
- ret,
- 128 * 1024);
+ ret,
+ 128 * 1024);
if (ret->thread == NULL)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_BULK,
- "PTHREAD_CREATE");
+ GE_FATAL | GE_ADMIN | GE_BULK,
+ "PTHREAD_CREATE");
return ret;
}
@@ -188,13 +188,13 @@
MUTEX_LOCK(ctx->lock);
GE_ASSERT(ctx->ectx,
- ctx->handleCount == 0);
+ ctx->handleCount == 0);
ctx->abort = YES;
connection_close_forever(ctx->sock);
MUTEX_UNLOCK(ctx->lock);
PTHREAD_STOP_SLEEP(ctx->thread);
PTHREAD_JOIN(ctx->thread,
- &unused);
+ &unused);
ctx->lock = NULL;
connection_destroy(ctx->sock);
GROW(ctx->handles,
@@ -215,15 +215,15 @@
*/
SEARCH_HANDLE *
FS_start_search(SEARCH_CONTEXT * ctx,
- const PeerIdentity * target,
- unsigned int type,
- unsigned int keyCount,
- const HashCode512 * keys,
- unsigned int anonymityLevel,
- unsigned int prio,
- cron_t timeout,
- Datum_Iterator callback,
- void * closure) {
+ const PeerIdentity * target,
+ unsigned int type,
+ unsigned int keyCount,
+ const HashCode512 * keys,
+ unsigned int anonymityLevel,
+ unsigned int prio,
+ cron_t timeout,
+ Datum_Iterator callback,
+ void * closure) {
SEARCH_HANDLE * ret;
CS_fs_request_search_MESSAGE * req;
#if DEBUG_FSLIB
@@ -233,9 +233,9 @@
ret = MALLOC(sizeof(SEARCH_HANDLE));
#if DEBUG_FSLIB
GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSLIB: start search (%p)\n",
- ret);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSLIB: start search (%p)\n",
+ ret);
#endif
req = MALLOC(sizeof(CS_fs_request_search_MESSAGE) + (keyCount-1) *
sizeof(HashCode512));
req->header.size = htons(sizeof(CS_fs_request_search_MESSAGE) + (keyCount-1)
* sizeof(HashCode512));
@@ -248,45 +248,45 @@
req->target = *target;
else
memset(&req->target,
- 0,
- sizeof(PeerIdentity));
+ 0,
+ sizeof(PeerIdentity));
memcpy(&req->query[0],
- keys,
- keyCount * sizeof(HashCode512));
+ keys,
+ keyCount * sizeof(HashCode512));
ret->req = req;
ret->callback = callback;
ret->closure = closure;
MUTEX_LOCK(ctx->lock);
if (ctx->handleCount == ctx->handleSize) {
GROW(ctx->handles,
- ctx->handleSize,
- ctx->handleSize * 2 + 4);
+ ctx->handleSize,
+ ctx->handleSize * 2 + 4);
}
ctx->handles[ctx->handleCount++] = ret;
MUTEX_UNLOCK(ctx->lock);
#if DEBUG_FSLIB
IF_GELOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&req->query[0],
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&req->query[0],
+ &enc));
GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSLIB: initiating search for `%s' of type %u\n",
- &enc,
- type);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSLIB: initiating search for `%s' of type %u\n",
+ &enc,
+ type);
#endif
GE_ASSERT(NULL, ctx->sock != NULL);
if (OK != connection_write(ctx->sock,
- &req->header)) {
+ &req->header)) {
FS_stop_search(ctx,
- ret);
+ ret);
return NULL;
}
#if DEBUG_FSLIB
GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSLIB: search started (%p)\n",
- ret);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSLIB: search started (%p)\n",
+ ret);
#endif
return ret;
}
@@ -295,22 +295,22 @@
* Stop searching.
*/
void FS_stop_search(SEARCH_CONTEXT * ctx,
- SEARCH_HANDLE * handle) {
+ SEARCH_HANDLE * handle) {
int i;
#if DEBUG_FSLIB
GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSLIB: stop search (%p)\n",
- handle);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSLIB: stop search (%p)\n",
+ handle);
#endif
handle->req->header.type = htons(CS_PROTO_gap_QUERY_STOP);
GE_ASSERT(NULL, ctx->sock != NULL);
if (OK != connection_write(ctx->sock,
- &handle->req->header)) {
+ &handle->req->header)) {
GE_LOG(ctx->ectx,
- GE_WARNING | GE_REQUEST | GE_DEVELOPER,
- "FSLIB: failed to request stop search with gnunetd\n");
+ GE_WARNING | GE_REQUEST | GE_DEVELOPER,
+ "FSLIB: failed to request stop search with gnunetd\n");
}
MUTEX_LOCK(ctx->lock);
for (i=ctx->handleCount-1;i>=0;i--)
@@ -322,9 +322,9 @@
FREE(handle->req);
#if DEBUG_FSLIB
GE_LOG(ctx->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FSLIB: search stopped (%p)\n",
- handle);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FSLIB: search stopped (%p)\n",
+ handle);
#endif
FREE(handle);
}
@@ -340,10 +340,10 @@
req.size = htons(sizeof(MESSAGE_HEADER));
req.type = htons(CS_PROTO_gap_GET_AVG_PRIORITY);
if (OK != connection_write(sock,
- &req))
+ &req))
return -1;
if (OK != connection_read_result(sock,
- &ret))
+ &ret))
return -1;
return ret;
}
@@ -355,7 +355,7 @@
* @return OK on success, SYSERR on error, NO on transient error
*/
int FS_insert(struct ClientServerConnection * sock,
- const Datastore_Value * block) {
+ const Datastore_Value * block) {
int ret;
CS_fs_request_insert_MESSAGE * ri;
unsigned int size;
@@ -373,23 +373,23 @@
ri->expiration = block->expirationTime;
ri->anonymityLevel = block->anonymityLevel;
memcpy(&ri[1],
- &block[1],
- size);
+ &block[1],
+ size);
retry = AUTO_RETRY;
do {
if (OK != connection_write(sock,
- &ri->header)) {
+ &ri->header)) {
FREE(ri);
return SYSERR;
}
if (OK != connection_read_result(sock,
- &ret)) {
+ &ret)) {
GE_BREAK(NULL, 0);
FREE(ri);
return SYSERR;
}
} while ( (ret == NO) &&
- (retry-- > 0) );
+ (retry-- > 0) );
FREE(ri);
return ret;
}
@@ -398,8 +398,8 @@
* Initialize to index a file
*/
int FS_initIndex(struct ClientServerConnection * sock,
- const HashCode512 * fileHc,
- const char * fn) {
+ const HashCode512 * fileHc,
+ const char * fn) {
int ret;
CS_fs_request_init_index_MESSAGE * ri;
unsigned int size;
@@ -411,34 +411,34 @@
GE_ASSERT(NULL, size < 65536);
ri = MALLOC(size);
memset(ri,
- 0,
- size);
+ 0,
+ size);
ri->header.size = htons(size);
ri->header.type = htons(CS_PROTO_gap_INIT_INDEX);
ri->reserved = htonl(0);
ri->fileId = *fileHc;
memcpy(&ri[1],
- fn,
- strlen(fn));
+ fn,
+ strlen(fn));
#if DEBUG_FSLIB
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Sending index initialization request to gnunetd\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Sending index initialization request to gnunetd\n");
#endif
if (OK != connection_write(sock,
- &ri->header)) {
+ &ri->header)) {
FREE(ri);
return SYSERR;
}
FREE(ri);
#if DEBUG_FSLIB
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Waiting for confirmation of index initialization request by
gnunetd\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Waiting for confirmation of index initialization request by gnunetd\n");
#endif
if (OK != connection_read_result(sock,
- &ret))
+ &ret))
return SYSERR;
return ret;
}
@@ -452,9 +452,9 @@
* @return OK on success, SYSERR on error
*/
int FS_index(struct ClientServerConnection * sock,
- const HashCode512 * fileHc,
- const Datastore_Value * block,
- unsigned long long offset) {
+ const HashCode512 * fileHc,
+ const Datastore_Value * block,
+ unsigned long long offset) {
int ret;
CS_fs_request_index_MESSAGE * ri;
unsigned int size;
@@ -470,32 +470,32 @@
ri->fileId = *fileHc;
ri->fileOffset = htonll(offset);
memcpy(&ri[1],
- &block[1],
- size);
+ &block[1],
+ size);
#if DEBUG_FSLIB
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Sending index request to gnunetd\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Sending index request to gnunetd\n");
#endif
retry = AUTO_RETRY;
do {
if (OK != connection_write(sock,
- &ri->header)) {
+ &ri->header)) {
FREE(ri);
return SYSERR;
}
#if DEBUG_FSLIB
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Waiting for confirmation of index request by gnunetd\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Waiting for confirmation of index request by gnunetd\n");
#endif
if (OK != connection_read_result(sock,
- &ret)) {
+ &ret)) {
FREE(ri);
return SYSERR;
}
} while ( (ret == NO) &&
- (retry-- > 0) );
+ (retry-- > 0) );
FREE(ri);
return ret;
}
@@ -509,7 +509,7 @@
* SYSERR on error
*/
int FS_delete(struct ClientServerConnection * sock,
- const Datastore_Value * block) {
+ const Datastore_Value * block) {
int ret;
CS_fs_request_delete_MESSAGE * rd;
unsigned int size;
@@ -520,24 +520,24 @@
rd->header.size = htons(sizeof(CS_fs_request_delete_MESSAGE) + size);
rd->header.type = htons(CS_PROTO_gap_DELETE);
memcpy(&rd[1],
- &block[1],
- size);
+ &block[1],
+ size);
retry = AUTO_RETRY;
do {
if (OK != connection_write(sock,
- &rd->header)) {
+ &rd->header)) {
FREE(rd);
GE_BREAK(NULL, 0);
return SYSERR;
}
if (OK != connection_read_result(sock,
- &ret)) {
+ &ret)) {
GE_BREAK(NULL, 0);
FREE(rd);
return SYSERR;
}
} while ( (ret == NO) &&
- (retry-- > 0) );
+ (retry-- > 0) );
FREE(rd);
return ret;
}
@@ -549,8 +549,8 @@
* @return OK on success, SYSERR on error
*/
int FS_unindex(struct ClientServerConnection * sock,
- unsigned int blocksize,
- const HashCode512 * hc) {
+ unsigned int blocksize,
+ const HashCode512 * hc) {
int ret;
CS_fs_request_unindex_MESSAGE ru;
@@ -559,10 +559,10 @@
ru.blocksize = htonl(blocksize);
ru.fileId = *hc;
if (OK != connection_write(sock,
- &ru.header))
+ &ru.header))
return SYSERR;
if (OK != connection_read_result(sock,
- &ret))
+ &ret))
return SYSERR;
return ret;
}
@@ -574,7 +574,7 @@
* @return YES if so, NO if not, SYSERR on error
*/
int FS_testIndexed(struct ClientServerConnection * sock,
- const HashCode512 * hc) {
+ const HashCode512 * hc) {
RequestTestindex ri;
int ret;
@@ -583,10 +583,10 @@
ri.reserved = htonl(0);
ri.fileId = *hc;
if (OK != connection_write(sock,
- &ri.header))
+ &ri.header))
return SYSERR;
if (OK != connection_read_result(sock,
- &ret))
+ &ret))
return SYSERR;
return ret;
}
Modified: GNUnet/src/applications/fs/lib/fslibtest.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslibtest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/lib/fslibtest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -45,9 +45,9 @@
DBlock * db;
block = MALLOC(sizeof(Datastore_Value) +
- sizeof(DBlock) + i);
+ sizeof(DBlock) + i);
block->size = htonl(sizeof(Datastore_Value) +
- sizeof(DBlock) + i);
+ sizeof(DBlock) + i);
block->type = htonl(D_BLOCK);
block->prio = htonl(0);
block->anonymityLevel = htonl(0);
@@ -55,22 +55,22 @@
db = (DBlock*) &block[1];
db->type = htonl(D_BLOCK);
memset(&db[1],
- i + (i /253),
- i);
+ i + (i /253),
+ i);
return block;
}
static Datastore_Value * makeKBlock(unsigned int i,
- const HashCode512 * key,
- HashCode512 * query) {
+ const HashCode512 * key,
+ HashCode512 * query) {
Datastore_Value * block;
KBlock * db;
struct PrivateKey * kkey;
block = MALLOC(sizeof(Datastore_Value) +
- sizeof(KBlock) + i);
+ sizeof(KBlock) + i);
block->size = htonl(sizeof(Datastore_Value) +
- sizeof(KBlock) + i);
+ sizeof(KBlock) + i);
block->type = htonl(K_BLOCK);
block->prio = htonl(0);
block->anonymityLevel = htonl(0);
@@ -78,15 +78,15 @@
db = (KBlock*) &block[1];
db->type = htonl(K_BLOCK);
memset(&db[1],
- i + (i /253),
- i);
+ i + (i /253),
+ i);
kkey = makeKblockKey(key);
sign(kkey,
i,
&db[1],
&db->signature);
getPublicKey(kkey,
- &db->keyspace);
+ &db->keyspace);
hash(&db->keyspace,
sizeof(PublicKey),
query);
@@ -111,8 +111,8 @@
* a counter.
*/
static int countCallback(const HashCode512 * key,
- const Datastore_Value * value,
- void * cls) {
+ const Datastore_Value * value,
+ void * cls) {
int * cnt = cls;
(*cnt)--;
fprintf(stderr, "*");
@@ -123,8 +123,8 @@
static int searchResultCB(const HashCode512 * key,
- const Datastore_Value * value,
- TSC * cls) {
+ const Datastore_Value * value,
+ TSC * cls) {
HashCode512 ekey;
Datastore_Value * blk;
Datastore_Value * eblk;
@@ -132,19 +132,19 @@
blk = makeBlock(cls->i);
fileBlockGetQuery((DBlock*) &blk[1],
- ntohl(blk->size) - sizeof(Datastore_Value),
- &ekey);
+ ntohl(blk->size) - sizeof(Datastore_Value),
+ &ekey);
GE_ASSERT(NULL, OK ==
- fileBlockEncode((DBlock*) &blk[1],
- ntohl(blk->size) - sizeof(Datastore_Value),
- &ekey,
- &eblk));
+ fileBlockEncode((DBlock*) &blk[1],
+ ntohl(blk->size) - sizeof(Datastore_Value),
+ &ekey,
+ &eblk));
if ( (equalsHashCode512(&ekey,
- key)) &&
+ key)) &&
(value->size == blk->size) &&
(0 == memcmp(&value[1],
- &eblk[1],
- ntohl(value->size) - sizeof(Datastore_Value))) ) {
+ &eblk[1],
+ ntohl(value->size) - sizeof(Datastore_Value))) ) {
cls->found = YES;
SEMAPHORE_UP(cls->sem);
ret = SYSERR;
@@ -159,7 +159,7 @@
}
static int trySearch(struct FS_SEARCH_CONTEXT * ctx,
- int i) {
+ int i) {
struct FS_SEARCH_HANDLE * handle;
cron_t now;
HashCode512 query;
@@ -170,34 +170,34 @@
dv = makeBlock(i);
db = (DBlock*) &dv[1];
fileBlockGetQuery(db,
- ntohl(dv->size) - sizeof(Datastore_Value),
- &query);
+ ntohl(dv->size) - sizeof(Datastore_Value),
+ &query);
FREE(dv);
closure.found = NO;
closure.i = i;
closure.sem = SEMAPHORE_CREATE(0);
now = get_time();
handle = FS_start_search(ctx,
- NULL,
- D_BLOCK,
- 1,
- &query,
- 0,
- 0,
- now + 30 * cronSECONDS,
- (Datum_Iterator)&searchResultCB,
- &closure);
+ NULL,
+ D_BLOCK,
+ 1,
+ &query,
+ 0,
+ 0,
+ now + 30 * cronSECONDS,
+ (Datum_Iterator)&searchResultCB,
+ &closure);
cron_add_job(cron,
- &abortSem,
- 30 * cronSECONDS,
- 0,
- closure.sem);
+ &abortSem,
+ 30 * cronSECONDS,
+ 0,
+ closure.sem);
SEMAPHORE_DOWN(closure.sem, YES);
FS_stop_search(ctx,
- handle);
+ handle);
cron_suspend(cron, NO);
cron_del_job(cron,
- &abortSem, 0, closure.sem);
+ &abortSem, 0, closure.sem);
cron_resume_jobs(cron, NO);
SEMAPHORE_DESTROY(closure.sem);
return closure.found;
@@ -225,7 +225,7 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
@@ -233,24 +233,24 @@
cron = cron_create(NULL);
#if START_DAEMON
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
#endif
ok = YES;
cron_start(cron);
lock = MUTEX_CREATE(NO);
GE_ASSERT(NULL,
- OK == connection_wait_for_running(NULL,
- cfg,
- 60 * cronSECONDS));
+ OK == connection_wait_for_running(NULL,
+ cfg,
+ 60 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
sock = client_connection_create(NULL, cfg);
CHECK(sock != NULL);
ctx = FS_SEARCH_makeContext(NULL,
- cfg,
- lock);
+ cfg,
+ lock);
CHECK(ctx != NULL);
/* ACTUAL TEST CODE */
@@ -258,50 +258,50 @@
fprintf(stderr, ".");
block = makeBlock(i);
fileBlockGetQuery((DBlock*) &block[1],
- ntohl(block->size) - sizeof(Datastore_Value),
- &query);
+ ntohl(block->size) - sizeof(Datastore_Value),
+ &query);
CHECK(OK == fileBlockEncode((DBlock*) &block[1],
- ntohl(block->size) - sizeof(Datastore_Value),
- &query,
- &eblock));
+ ntohl(block->size) - sizeof(Datastore_Value),
+ &query,
+ &eblock));
eblock->expirationTime = block->expirationTime;
eblock->prio = block->prio;
CHECK(OK == FS_insert(sock,
- eblock));
+ eblock));
CHECK(OK == trySearch(ctx, i));
CHECK(SYSERR != FS_delete(sock,
- eblock));
+ eblock));
FREE(eblock);
hash(&((DBlock*)&block[1])[1],
- ntohl(block->size) - sizeof(Datastore_Value) - sizeof(DBlock),
- &hc);
+ ntohl(block->size) - sizeof(Datastore_Value) - sizeof(DBlock),
+ &hc);
/* indexing without symlink */
CHECK(OK == FS_index(sock,
- &hc,
- block,
- 0));
+ &hc,
+ block,
+ 0));
CHECK(OK == trySearch(ctx, i));
CHECK(OK == FS_unindex(sock,
- MAX_BUFFER_SIZE,
- &hc));
+ MAX_BUFFER_SIZE,
+ &hc));
/* indexing with symlink */
tmpName = STRDUP("/tmp/symlinkTestXXXXXX");
CHECK(-1 != (fd = mkstemp(tmpName)));
CHECK(-1 != WRITE(fd,
- &((DBlock*)&block[1])[1],
- ntohl(block->size) - sizeof(Datastore_Value) -
sizeof(DBlock)));
+ &((DBlock*)&block[1])[1],
+ ntohl(block->size) - sizeof(Datastore_Value) - sizeof(DBlock)));
CLOSE(fd);
CHECK(FS_initIndex(sock,
- &hc,
- tmpName) == YES);
+ &hc,
+ tmpName) == YES);
CHECK(OK == FS_index(sock,
- &hc,
- block,
- 0));
+ &hc,
+ block,
+ 0));
CHECK(OK == trySearch(ctx, i));
CHECK(OK == FS_unindex(sock,
- MAX_BUFFER_SIZE,
- &hc));
+ MAX_BUFFER_SIZE,
+ &hc));
UNLINK(tmpName);
FREE(tmpName);
FREE(block);
@@ -311,31 +311,31 @@
fprintf(stderr, ".");
block = makeBlock(i);
fileBlockGetQuery((DBlock*) &block[1],
- ntohl(block->size) - sizeof(Datastore_Value),
- &query);
+ ntohl(block->size) - sizeof(Datastore_Value),
+ &query);
CHECK(OK == fileBlockEncode((DBlock*) &block[1],
- ntohl(block->size) - sizeof(Datastore_Value),
- &query,
- &eblock));
+ ntohl(block->size) - sizeof(Datastore_Value),
+ &query,
+ &eblock));
eblock->expirationTime = block->expirationTime;
eblock->prio = block->prio;
CHECK(OK == FS_insert(sock,
- eblock));
+ eblock));
CHECK(OK == trySearch(ctx, i));
CHECK(1 == FS_delete(sock,
- eblock));
+ eblock));
FREE(eblock);
hash(&((DBlock*)&block[1])[1],
- ntohl(block->size) - sizeof(Datastore_Value) - sizeof(DBlock),
- &hc);
+ ntohl(block->size) - sizeof(Datastore_Value) - sizeof(DBlock),
+ &hc);
CHECK(OK == FS_index(sock,
- &hc,
- block,
- 0));
+ &hc,
+ block,
+ 0));
CHECK(OK == trySearch(ctx, i));
CHECK(OK == FS_unindex(sock,
- MAX_BUFFER_SIZE,
- &hc));
+ MAX_BUFFER_SIZE,
+ &hc));
FREE(block);
}
fprintf(stderr, "\n");
@@ -344,30 +344,30 @@
makeRandomId(&hc);
block = makeKBlock(40, &hc, &query);
CHECK(OK == FS_insert(sock,
- block));
+ block));
FREE(block);
block = makeKBlock(60, &hc, &query);
CHECK(OK == FS_insert(sock,
- block));
+ block));
FREE(block);
i = 2;
mainThread = PTHREAD_GET_SELF();
hnd = FS_start_search(ctx,
- NULL,
- ANY_BLOCK,
- 1,
- &query,
- 0,
- 0,
- 10 * cronSECONDS,
- &countCallback,
- &i);
+ NULL,
+ ANY_BLOCK,
+ 1,
+ &query,
+ 0,
+ 0,
+ 10 * cronSECONDS,
+ &countCallback,
+ &i);
CHECK(hnd != NULL);
PTHREAD_SLEEP(10 * cronSECONDS);
FS_stop_search(ctx, hnd);
PTHREAD_REL_SELF(mainThread);
CHECK(i <= 0);
-
+
/* just to check if it crashes... */
FS_getAveragePriority(sock);
Modified: GNUnet/src/applications/fs/module/anonymity.c
===================================================================
--- GNUnet/src/applications/fs/module/anonymity.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/module/anonymity.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -43,8 +43,8 @@
* @return OK if cover traffic is sufficient
*/
int checkCoverTraffic(struct GE_Context * ectx,
- Traffic_ServiceAPI * traffic,
- unsigned int level) {
+ Traffic_ServiceAPI * traffic,
+ unsigned int level) {
unsigned int count;
unsigned int peers;
unsigned int sizes;
@@ -56,48 +56,48 @@
if (traffic == NULL)
return SYSERR;
if (OK != traffic->get(5 * cronSECONDS / TRAFFIC_TIME_UNIT, /*
TTL_DECREMENT/TTU */
- P2P_PROTO_gap_RESULT,
- TC_RECEIVED,
- &count,
- &peers,
- &sizes,
- &timevect)) {
+ P2P_PROTO_gap_RESULT,
+ TC_RECEIVED,
+ &count,
+ &peers,
+ &sizes,
+ &timevect)) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Failed to get traffic stats.\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Failed to get traffic stats.\n"));
return SYSERR;
}
if (level > 1000) {
if (peers < level / 1000) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Not enough cover traffic to satisfy anonymity requirements (%u,
%u peers). "
- "Result dropped.\n",
- level,
- peers);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Not enough cover traffic to satisfy anonymity requirements (%u, %u
peers). "
+ "Result dropped.\n",
+ level,
+ peers);
return SYSERR;
}
if (count < level % 1000) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Not enough cover traffic to satisfy anonymity requirements (%u,
%u messages). "
- "Result dropped.\n",
- level,
- count);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Not enough cover traffic to satisfy anonymity requirements (%u, %u
messages). "
+ "Result dropped.\n",
+ level,
+ count);
return SYSERR;
}
} else {
if (count < level) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Not enough cover traffic to satisfy anonymity requirements (%u,
%u messages). "
- "Result dropped.\n",
- level,
- count);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Not enough cover traffic to satisfy anonymity requirements (%u, %u
messages). "
+ "Result dropped.\n",
+ level,
+ count);
return SYSERR;
}
}
return OK;
}
-
+
/* end of anonymity.c */
Modified: GNUnet/src/applications/fs/module/dht_push.c
===================================================================
--- GNUnet/src/applications/fs/module/dht_push.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/module/dht_push.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -74,8 +74,8 @@
static int push_callback(const HashCode512 * key,
- const Datastore_Value * value,
- void * closure) {
+ const Datastore_Value * value,
+ void * closure) {
cron_t delay;
if (dht == NULL)
@@ -91,10 +91,10 @@
if (dht == NULL)
return SYSERR;
dht->put(key,
- ntohl(value->type),
- ntohl(value->size) - sizeof(Datastore_Value),
- ntohll(value->expirationTime),
- (const char*) &value[1]);
+ ntohl(value->type),
+ ntohl(value->size) - sizeof(Datastore_Value),
+ ntohll(value->expirationTime),
+ (const char*) &value[1]);
if (stats != NULL)
stats->change(stat_push_count, 1);
return OK;
@@ -102,15 +102,15 @@
static void * push_thread(void * cls) {
while ( (dht != NULL) &&
- (sqstore != NULL) ) {
+ (sqstore != NULL) ) {
if (total == 0)
total = 1;
total = sqstore->iterateNonAnonymous(0,
- YES,
- &push_callback,
- NULL);
+ YES,
+ &push_callback,
+ NULL);
if ( (dht != NULL) &&
- (total == 0) )
+ (total == 0) )
PTHREAD_SLEEP(15 * cronMINUTES);
}
return NULL;
@@ -121,7 +121,7 @@
* Initialize the migration module.
*/
void init_dht_push(CoreAPIForApplication * capi,
- DHT_ServiceAPI * d) {
+ DHT_ServiceAPI * d) {
coreAPI = capi;
dht = d;
sqstore = capi->requestService("sqstore");
@@ -135,8 +135,8 @@
= stats->create(gettext_noop("# blocks pushed into DHT"));
if (! NO_PUSH) {
thread = PTHREAD_CREATE(&push_thread,
- NULL,
- 1024 * 128);
+ NULL,
+ 1024 * 128);
}
}
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/fs/module/fs.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -105,7 +105,7 @@
static Datastore_Value *
gapWrapperToDatastoreValue(const DataContainer * value,
- int prio) {
+ int prio) {
Datastore_Value * dv;
const GapWrapper * gw;
unsigned int size;
@@ -123,7 +123,7 @@
dv = MALLOC(size);
dv->size = htonl(size);
dv->type = htonl(getTypeOfBlock(size - sizeof(Datastore_Value),
- (DBlock*) &gw[1]));
+ (DBlock*) &gw[1]));
dv->prio = htonl(prio);
dv->anonymityLevel = htonl(0);
et = ntohll(gw->timeout);
@@ -136,8 +136,8 @@
}
dv->expirationTime = htonll(et);
memcpy(&dv[1],
- &gw[1],
- size - sizeof(Datastore_Value));
+ &gw[1],
+ size - sizeof(Datastore_Value));
return dv;
}
@@ -153,9 +153,9 @@
* SYSERR if the value is malformed
*/
static int gapPut(void * closure,
- const HashCode512 * query,
- const DataContainer * value,
- unsigned int prio) {
+ const HashCode512 * query,
+ const DataContainer * value,
+ unsigned int prio) {
Datastore_Value * dv;
const GapWrapper * gw;
unsigned int size;
@@ -168,9 +168,9 @@
gw = (const GapWrapper*) value;
size = ntohl(gw->dc.size) - sizeof(GapWrapper);
if ( (OK != getQueryFor(size,
- (const DBlock*) &gw[1],
- YES,
- &hc)) ||
+ (const DBlock*) &gw[1],
+ YES,
+ &hc)) ||
(! equalsHashCode512(&hc, query)) ) {
GE_BREAK_OP(ectx, 0); /* value failed verification! */
return SYSERR;
@@ -181,11 +181,11 @@
return SYSERR;
}
if (YES != isDatumApplicable(ntohl(dv->type),
- ntohl(dv->size) - sizeof(Datastore_Value),
- (const DBlock*) &dv[1],
- &hc,
- 0,
- query)) {
+ ntohl(dv->size) - sizeof(Datastore_Value),
+ (const DBlock*) &dv[1],
+ &hc,
+ 0,
+ query)) {
GE_BREAK(ectx, 0);
FREE(dv);
return SYSERR;
@@ -210,17 +210,17 @@
#if DEBUG_FS
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FS received GAP-PUT request (query: `%s')\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FS received GAP-PUT request (query: `%s')\n",
+ &enc);
#endif
if (migration)
ret = datastore->putUpdate(query,
- dv);
+ dv);
else
ret = OK;
FREE(dv);
@@ -228,8 +228,8 @@
}
static int get_result_callback(const HashCode512 * query,
- const DataContainer * value,
- void * ctx) {
+ const DataContainer * value,
+ void * ctx) {
DHT_GET_CLS * cls = ctx;
const GapWrapper * gw;
unsigned int size;
@@ -238,31 +238,31 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Found reply to query `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Found reply to query `%s'.\n",
+ &enc);
#endif
gw = (const GapWrapper*) value;
size = ntohl(gw->dc.size) - sizeof(GapWrapper);
if ( (OK != getQueryFor(size,
- (const DBlock*) &gw[1],
- YES,
- &hc)) ||
+ (const DBlock*) &gw[1],
+ YES,
+ &hc)) ||
(! equalsHashCode512(&hc, query)) ) {
GE_BREAK(NULL, 0);
return OK;
}
gapPut(NULL,
- query,
- value,
- cls->prio);
+ query,
+ value,
+ cls->prio);
return OK;
-}
+}
static void get_complete_callback(void * ctx) {
DHT_GET_CLS * cls = ctx;
@@ -276,7 +276,7 @@
* @return SYSERR if the TCP connection should be closed, otherwise OK
*/
static int csHandleRequestQueryStop(struct ClientHandle * sock,
- const MESSAGE_HEADER * req) {
+ const MESSAGE_HEADER * req) {
const CS_fs_request_search_MESSAGE * rs;
#if DEBUG_FS
EncName enc;
@@ -289,17 +289,17 @@
rs = (const CS_fs_request_search_MESSAGE*) req;
#if DEBUG_FS
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&rs->query[0],
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&rs->query[0],
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FS received QUERY STOP (query: `%s')\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FS received QUERY STOP (query: `%s')\n",
+ &enc);
#endif
gap->get_stop(ntohl(rs->type),
- 1 + (ntohs(req->size) - sizeof(CS_fs_request_search_MESSAGE)) /
sizeof(HashCode512),
- &rs->query[0]);
+ 1 + (ntohs(req->size) - sizeof(CS_fs_request_search_MESSAGE)) /
sizeof(HashCode512),
+ &rs->query[0]);
untrackQuery(&rs->query[0], sock);
return OK;
}
@@ -310,7 +310,7 @@
* @return SYSERR if the TCP connection should be closed, otherwise OK
*/
static int csHandleCS_fs_request_insert_MESSAGE(struct ClientHandle * sock,
- const MESSAGE_HEADER * req) {
+ const MESSAGE_HEADER * req) {
const CS_fs_request_insert_MESSAGE * ri;
Datastore_Value * datum;
struct GE_Context * cectx;
@@ -322,7 +322,7 @@
#endif
cectx = coreAPI->createClientLogContext(GE_USER | GE_EVENTKIND |
GE_ROUTEKIND,
- sock);
+ sock);
if (ntohs(req->size) < sizeof(CS_fs_request_insert_MESSAGE)) {
GE_BREAK(ectx, 0);
GE_BREAK(cectx, 0);
@@ -331,16 +331,16 @@
}
ri = (const CS_fs_request_insert_MESSAGE*) req;
datum = MALLOC(sizeof(Datastore_Value) +
- ntohs(req->size) - sizeof(CS_fs_request_insert_MESSAGE));
+ ntohs(req->size) - sizeof(CS_fs_request_insert_MESSAGE));
datum->size = htonl(sizeof(Datastore_Value) +
- ntohs(req->size) - sizeof(CS_fs_request_insert_MESSAGE));
+ ntohs(req->size) - sizeof(CS_fs_request_insert_MESSAGE));
datum->expirationTime = ri->expiration;
datum->prio = ri->prio;
datum->anonymityLevel = ri->anonymityLevel;
if (OK != getQueryFor(ntohs(ri->header.size) -
sizeof(CS_fs_request_insert_MESSAGE),
- (const DBlock*)&ri[1],
- YES,
- &query)) {
+ (const DBlock*)&ri[1],
+ YES,
+ &query)) {
GE_BREAK(ectx, 0);
GE_BREAK(cectx, 0);
FREE(datum);
@@ -348,31 +348,31 @@
return SYSERR;
}
type = getTypeOfBlock(ntohs(ri->header.size) -
sizeof(CS_fs_request_insert_MESSAGE),
- (const DBlock*) &ri[1]);
+ (const DBlock*) &ri[1]);
#if DEBUG_FS
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FS received REQUEST INSERT (query: `%s', type: %u, priority %u)\n",
- &enc,
- type,
- ntohl(ri->prio));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FS received REQUEST INSERT (query: `%s', type: %u, priority %u)\n",
+ &enc,
+ type,
+ ntohl(ri->prio));
#endif
datum->type = htonl(type);
memcpy(&datum[1],
- &ri[1],
- ntohs(req->size) - sizeof(CS_fs_request_insert_MESSAGE));
+ &ri[1],
+ ntohs(req->size) - sizeof(CS_fs_request_insert_MESSAGE));
MUTEX_LOCK(lock);
if ( (type != D_BLOCK) ||
(0 == datastore->get(&query,
- type,
- NULL,
- NULL)) )
+ type,
+ NULL,
+ NULL)) )
ret = datastore->put(&query,
- datum);
+ datum);
else
ret = OK;
MUTEX_UNLOCK(lock);
@@ -396,40 +396,40 @@
et -= now;
et = et % MAX_MIGRATION_EXP;
if (et > 0)
- et = weak_randomi(et);
+ et = weak_randomi(et);
et = et + now;
}
gw->timeout = htonll(et);
memcpy(&gw[1],
- &ri[1],
- size - sizeof(GapWrapper));
+ &ri[1],
+ size - sizeof(GapWrapper));
/* sanity check */
if ( (OK != getQueryFor(size - sizeof(GapWrapper),
- (const DBlock*) &gw[1],
- YES,
- &hc)) ||
- (! equalsHashCode512(&hc, &query)) ) {
+ (const DBlock*) &gw[1],
+ YES,
+ &hc)) ||
+ (! equalsHashCode512(&hc, &query)) ) {
GE_BREAK(NULL, 0);
} else {
dht->put(&query,
- type,
- size,
- et,
- (const char*) gw);
+ type,
+ size,
+ et,
+ (const char*) gw);
}
FREE(gw);
}
FREE(datum);
GE_free_context(cectx);
return coreAPI->sendValueToClient(sock,
- ret);
+ ret);
}
/**
* Process a request to symlink a file
*/
static int csHandleCS_fs_request_init_index_MESSAGE(struct ClientHandle * sock,
- const MESSAGE_HEADER * req)
{
+ const MESSAGE_HEADER * req) {
int ret;
char *fn;
CS_fs_request_init_index_MESSAGE *ri;
@@ -437,7 +437,7 @@
struct GE_Context * cectx;
cectx = coreAPI->createClientLogContext(GE_USER | GE_EVENTKIND |
GE_ROUTEKIND,
- sock);
+ sock);
if (ntohs(req->size) < sizeof(CS_fs_request_init_index_MESSAGE)) {
GE_BREAK(ectx, 0);
GE_BREAK(cectx, 0);
@@ -459,15 +459,15 @@
strncpy(fn, (char*) &ri[1], fnLen+1);
fn[fnLen] = 0;
ret = ONDEMAND_initIndex(cectx,
- &ri->fileId,
- fn);
+ &ri->fileId,
+ fn);
FREE(fn);
#if DEBUG_FS
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Sending confirmation (%s) of index initialization request to
client\n",
- ret == OK ? "success" : "failure");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Sending confirmation (%s) of index initialization request to client\n",
+ ret == OK ? "success" : "failure");
#endif
GE_free_context(cectx);
return coreAPI->sendValueToClient(sock,
@@ -480,13 +480,13 @@
* @return SYSERR if the TCP connection should be closed, otherwise OK
*/
static int csHandleCS_fs_request_index_MESSAGE(struct ClientHandle * sock,
- const MESSAGE_HEADER * req) {
+ const MESSAGE_HEADER * req) {
int ret;
const CS_fs_request_index_MESSAGE * ri;
struct GE_Context * cectx;
cectx = coreAPI->createClientLogContext(GE_USER | GE_EVENTKIND |
GE_ROUTEKIND,
- sock);
+ sock);
if (ntohs(req->size) < sizeof(CS_fs_request_index_MESSAGE)) {
GE_BREAK(ectx, 0);
GE_BREAK(cectx, 0);
@@ -495,23 +495,23 @@
}
ri = (const CS_fs_request_index_MESSAGE*) req;
ret = ONDEMAND_index(cectx,
- datastore,
- ntohl(ri->prio),
- ntohll(ri->expiration),
- ntohll(ri->fileOffset),
- ntohl(ri->anonymityLevel),
- &ri->fileId,
- ntohs(ri->header.size) -
sizeof(CS_fs_request_index_MESSAGE),
- (const DBlock*) &ri[1]);
+ datastore,
+ ntohl(ri->prio),
+ ntohll(ri->expiration),
+ ntohll(ri->fileOffset),
+ ntohl(ri->anonymityLevel),
+ &ri->fileId,
+ ntohs(ri->header.size) - sizeof(CS_fs_request_index_MESSAGE),
+ (const DBlock*) &ri[1]);
#if DEBUG_FS
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Sending confirmation (%s) of index request to client\n",
- ret == OK ? "success" : "failure");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Sending confirmation (%s) of index request to client\n",
+ ret == OK ? "success" : "failure");
#endif
GE_free_context(cectx);
return coreAPI->sendValueToClient(sock,
- ret);
+ ret);
}
/**
@@ -521,30 +521,30 @@
* continue.
*/
static int completeValue(const HashCode512 * key,
- const Datastore_Value * value,
- void * closure) {
+ const Datastore_Value * value,
+ void * closure) {
Datastore_Value * comp = closure;
if ( (comp->size != value->size) ||
(0 != memcmp(&value[1],
- &comp[1],
- ntohl(value->size) - sizeof(Datastore_Value))) ) {
+ &comp[1],
+ ntohl(value->size) - sizeof(Datastore_Value))) ) {
#if DEBUG_FS
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' found value that does not match (%u, %u).\n",
- __FUNCTION__,
- ntohl(comp->size),
- ntohl(value->size));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' found value that does not match (%u, %u).\n",
+ __FUNCTION__,
+ ntohl(comp->size),
+ ntohl(value->size));
#endif
return OK;
}
*comp = *value; /* make copy! */
#if DEBUG_FS
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' found value that matches.\n",
- __FUNCTION__);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' found value that matches.\n",
+ __FUNCTION__);
#endif
return SYSERR;
}
@@ -555,7 +555,7 @@
* @return SYSERR if the TCP connection should be closed, otherwise OK
*/
static int csHandleCS_fs_request_delete_MESSAGE(struct ClientHandle * sock,
- const MESSAGE_HEADER * req) {
+ const MESSAGE_HEADER * req) {
int ret;
const CS_fs_request_delete_MESSAGE * rd;
Datastore_Value * value;
@@ -567,7 +567,7 @@
struct GE_Context * cectx;
cectx = coreAPI->createClientLogContext(GE_USER | GE_EVENTKIND |
GE_ROUTEKIND,
- sock);
+ sock);
if (ntohs(req->size) < sizeof(CS_fs_request_delete_MESSAGE)) {
GE_BREAK(ectx, 0);
GE_BREAK(cectx, 0);
@@ -576,19 +576,19 @@
}
rd = (const CS_fs_request_delete_MESSAGE*) req;
value = MALLOC(sizeof(Datastore_Value) +
- ntohs(req->size) - sizeof(CS_fs_request_delete_MESSAGE));
+ ntohs(req->size) - sizeof(CS_fs_request_delete_MESSAGE));
value->size = ntohl(sizeof(Datastore_Value) +
- ntohs(req->size) - sizeof(CS_fs_request_delete_MESSAGE));
+ ntohs(req->size) - sizeof(CS_fs_request_delete_MESSAGE));
type = getTypeOfBlock(ntohs(rd->header.size) -
sizeof(CS_fs_request_delete_MESSAGE),
- (const DBlock*)&rd[1]);
+ (const DBlock*)&rd[1]);
value->type = htonl(type);
memcpy(&value[1],
- &rd[1],
- ntohs(req->size) - sizeof(CS_fs_request_delete_MESSAGE));
+ &rd[1],
+ ntohs(req->size) - sizeof(CS_fs_request_delete_MESSAGE));
if (OK != getQueryFor(ntohs(rd->header.size) -
sizeof(CS_fs_request_delete_MESSAGE),
- (const DBlock*)&rd[1],
- NO,
- &query)) {
+ (const DBlock*)&rd[1],
+ NO,
+ &query)) {
FREE(value);
GE_BREAK(ectx, 0);
GE_BREAK(cectx, 0);
@@ -597,48 +597,48 @@
}
#if DEBUG_FS
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FS received REQUEST DELETE (query: `%s', type: %u)\n",
- &enc,
- type);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FS received REQUEST DELETE (query: `%s', type: %u)\n",
+ &enc,
+ type);
#endif
MUTEX_LOCK(lock);
if (SYSERR == datastore->get(&query,
- type,
- &completeValue,
- value)) /* aborted == found! */
+ type,
+ &completeValue,
+ value)) /* aborted == found! */
ret = datastore->del(&query,
- value);
+ value);
else /* not found */
ret = SYSERR;
MUTEX_UNLOCK(lock);
FREE(value);
#if DEBUG_FS
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Sending confirmation (%s) of delete request to client\n",
- ret != SYSERR ? "success" : "failure");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Sending confirmation (%s) of delete request to client\n",
+ ret != SYSERR ? "success" : "failure");
#endif
GE_free_context(cectx);
return coreAPI->sendValueToClient(sock,
- ret);
+ ret);
}
/**
* Process a client request unindex content.
*/
static int csHandleCS_fs_request_unindex_MESSAGE(struct ClientHandle * sock,
- const MESSAGE_HEADER * req) {
+ const MESSAGE_HEADER * req) {
int ret;
const CS_fs_request_unindex_MESSAGE * ru;
struct GE_Context * cectx;
cectx = coreAPI->createClientLogContext(GE_USER | GE_EVENTKIND |
GE_ROUTEKIND,
- sock);
+ sock);
if (ntohs(req->size) != sizeof(CS_fs_request_unindex_MESSAGE)) {
GE_BREAK(ectx, 0);
GE_BREAK(cectx, 0);
@@ -648,16 +648,16 @@
ru = (const CS_fs_request_unindex_MESSAGE*) req;
#if DEBUG_FS
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FS received REQUEST UNINDEX\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FS received REQUEST UNINDEX\n");
#endif
ret = ONDEMAND_unindex(cectx,
- datastore,
- ntohl(ru->blocksize),
- &ru->fileId);
+ datastore,
+ ntohl(ru->blocksize),
+ &ru->fileId);
GE_free_context(cectx);
return coreAPI->sendValueToClient(sock,
- ret);
+ ret);
}
/**
@@ -665,7 +665,7 @@
* data is indexed.
*/
static int csHandleCS_fs_request_test_index_MESSAGEed(struct ClientHandle *
sock,
- const MESSAGE_HEADER *
req) {
+ const MESSAGE_HEADER * req) {
int ret;
const RequestTestindex * ru;
@@ -676,13 +676,13 @@
ru = (const RequestTestindex*) req;
#if DEBUG_FS
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FS received REQUEST TESTINDEXED\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FS received REQUEST TESTINDEXED\n");
#endif
ret = ONDEMAND_testindexed(datastore,
- &ru->fileId);
+ &ru->fileId);
return coreAPI->sendValueToClient(sock,
- ret);
+ ret);
}
/**
@@ -690,14 +690,14 @@
* averge priority.
*/
static int csHandleRequestGetAvgPriority(struct ClientHandle * sock,
- const MESSAGE_HEADER * req) {
+ const MESSAGE_HEADER * req) {
#if DEBUG_FS
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FS received REQUEST GETAVGPRIORITY\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FS received REQUEST GETAVGPRIORITY\n");
#endif
return coreAPI->sendValueToClient(sock,
- gap->getAvgPriority());
+ gap->getAvgPriority());
}
/**
@@ -717,8 +717,8 @@
* gap routing protocol.
*/
static int gapGetConverter(const HashCode512 * key,
- const Datastore_Value * invalue,
- void * cls) {
+ const Datastore_Value * invalue,
+ void * cls) {
GGC * ggc = (GGC*) cls;
GapWrapper * gw;
int ret;
@@ -735,13 +735,13 @@
#if DEBUG_FS
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Converting reply for query `%s' for gap.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Converting reply for query `%s' for gap.\n",
+ &enc);
#endif
et = ntohll(invalue->expirationTime);
now = get_time();
@@ -753,9 +753,9 @@
if (ntohl(invalue->type) == ONDEMAND_BLOCK) {
if (OK != ONDEMAND_getIndexed(datastore,
- invalue,
- key,
- &xvalue))
+ invalue,
+ key,
+ &xvalue))
return SYSERR;
value = xvalue;
} else {
@@ -764,45 +764,45 @@
}
#if EXTRA_CHECKS
if ( (OK != getQueryFor(ntohl(value->size) - sizeof(Datastore_Value),
- (const DBlock*) &value[1],
- YES,
- &hc)) ||
+ (const DBlock*) &value[1],
+ YES,
+ &hc)) ||
(! equalsHashCode512(&hc, key)) ) {
GE_BREAK(ectx, 0); /* value failed verification! */
return SYSERR;
}
#endif
ret = isDatumApplicable(ntohl(value->type),
- ntohl(value->size) - sizeof(Datastore_Value),
- (const DBlock*) &value[1],
- key,
- ggc->keyCount,
- ggc->keys);
+ ntohl(value->size) - sizeof(Datastore_Value),
+ (const DBlock*) &value[1],
+ key,
+ ggc->keyCount,
+ ggc->keys);
if (ret == SYSERR) {
IF_GELOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- hash2enc(key,
- &enc));
+ GE_WARNING | GE_BULK | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- "Converting reply for query `%s' for gap failed (datum not
applicable).\n",
- &enc);
+ GE_WARNING | GE_BULK | GE_USER,
+ "Converting reply for query `%s' for gap failed (datum not
applicable).\n",
+ &enc);
FREENONNULL(xvalue);
return SYSERR; /* no query will ever match */
}
if (ret == NO) {
IF_GELOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- hash2enc(key,
- &enc));
+ GE_WARNING | GE_BULK | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- "Converting reply for query `%s' for gap failed (type not
applicable).\n",
- &enc);
+ GE_WARNING | GE_BULK | GE_USER,
+ "Converting reply for query `%s' for gap failed (type not applicable).\n",
+ &enc);
FREENONNULL(xvalue);
return OK; /* Additional filtering based on type;
- i.e., namespace request and namespace
- in reply does not match namespace in query */
+ i.e., namespace request and namespace
+ in reply does not match namespace in query */
}
size = sizeof(GapWrapper) +
ntohl(value->size) -
@@ -811,20 +811,20 @@
level
= ntohl(value->anonymityLevel);
if (OK != checkCoverTraffic(ectx,
- traffic,
- level)) {
+ traffic,
+ level)) {
/* traffic required by module not loaded;
refuse to hand out data that requires
anonymity! */
FREENONNULL(xvalue);
IF_GELOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- hash2enc(key,
- &enc));
+ GE_WARNING | GE_BULK | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- "Converting reply for query `%s' for gap failed (insufficient cover
traffic).\n",
- &enc);
+ GE_WARNING | GE_BULK | GE_USER,
+ "Converting reply for query `%s' for gap failed (insufficient cover
traffic).\n",
+ &enc);
return OK;
}
gw = MALLOC(size);
@@ -839,13 +839,13 @@
}
gw->timeout = htonll(et);
memcpy(&gw[1],
- &value[1],
- size - sizeof(GapWrapper));
+ &value[1],
+ size - sizeof(GapWrapper));
if (ggc->resultCallback != NULL)
ret = ggc->resultCallback(key,
- &gw->dc,
- ggc->resCallbackClosure);
+ &gw->dc,
+ ggc->resCallbackClosure);
else
ret = OK;
ggc->count++;
@@ -863,26 +863,26 @@
* @return number of results, SYSERR on error
*/
static int gapGet(void * closure,
- unsigned int type,
- unsigned int prio,
- unsigned int keyCount,
- const HashCode512 * keys,
- DataProcessor resultCallback,
- void * resCallbackClosure) {
+ unsigned int type,
+ unsigned int prio,
+ unsigned int keyCount,
+ const HashCode512 * keys,
+ DataProcessor resultCallback,
+ void * resCallbackClosure) {
int ret;
GGC myClosure;
#if DEBUG_FS
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&keys[0],
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&keys[0],
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "GAP requests content for `%s' of type %u\n",
- &enc,
- type);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "GAP requests content for `%s' of type %u\n",
+ &enc,
+ type);
#endif
myClosure.count = 0;
myClosure.keyCount = keyCount;
@@ -892,19 +892,19 @@
ret = OK;
if (type == D_BLOCK) {
ret = datastore->get(&keys[0],
- ONDEMAND_BLOCK,
- &gapGetConverter,
- &myClosure);
+ ONDEMAND_BLOCK,
+ &gapGetConverter,
+ &myClosure);
}
if (ret != SYSERR)
ret = datastore->get(&keys[0],
- type,
- &gapGetConverter,
- &myClosure);
+ type,
+ &gapGetConverter,
+ &myClosure);
if (ret != SYSERR)
ret = myClosure.count; /* return number of actual
- results (unfiltered) that
- were found */
+ results (unfiltered) that
+ were found */
return ret;
}
@@ -916,8 +916,8 @@
* @return OK if the value could be removed, SYSERR if not (i.e. not present)
*/
static int gapDel(void * closure,
- const HashCode512 * key,
- const DataContainer * value) {
+ const HashCode512 * key,
+ const DataContainer * value) {
GE_BREAK(ectx, 0); /* gap does not use 'del'! */
return SYSERR;
}
@@ -929,15 +929,15 @@
* @param cls argument to processor
* @return number of results, SYSERR on error
*/
-static int gapIterate(void * closure,
- DataProcessor processor,
- void * cls) {
+static int gapIterate(void * closure,
+ DataProcessor processor,
+ void * cls) {
GE_BREAK(ectx, 0); /* gap does not use 'iterate' */
return SYSERR;
}
static int replyHashFunction(const DataContainer * content,
- HashCode512 * id) {
+ HashCode512 * id) {
const GapWrapper * gw;
unsigned int size;
@@ -955,9 +955,9 @@
}
static int uniqueReplyIdentifier(const DataContainer * content,
- unsigned int type,
- int verify,
- const HashCode512 * primaryKey) {
+ unsigned int type,
+ int verify,
+ const HashCode512 * primaryKey) {
HashCode512 q;
unsigned int t;
const GapWrapper * gw;
@@ -970,14 +970,14 @@
}
gw = (const GapWrapper*) content;
if ( (OK == getQueryFor(size - sizeof(GapWrapper),
- (const DBlock*) &gw[1],
- verify,
- &q)) &&
+ (const DBlock*) &gw[1],
+ verify,
+ &q)) &&
(equalsHashCode512(&q,
- primaryKey)) &&
+ primaryKey)) &&
( (type == ANY_BLOCK) ||
- (type == (t = getTypeOfBlock(size - sizeof(GapWrapper),
- (const DBlock*)&gw[1]) ) ) ) ) {
+ (type == (t = getTypeOfBlock(size - sizeof(GapWrapper),
+ (const DBlock*)&gw[1]) ) ) ) ) {
switch(type) {
case D_BLOCK:
return YES;
@@ -989,15 +989,15 @@
}
static int fastPathProcessor(const HashCode512 * query,
- const DataContainer * value,
- void * cls) {
+ const DataContainer * value,
+ void * cls) {
Datastore_Value * dv;
dv = gapWrapperToDatastoreValue(value, 0);
if (dv == NULL)
return SYSERR;
processResponse(query,
- dv);
+ dv);
FREE(dv);
return OK;
}
@@ -1008,8 +1008,8 @@
* as true or false.
*/
static int fastPathProcessorFirst(const HashCode512 * query,
- const DataContainer * value,
- void * cls) {
+ const DataContainer * value,
+ void * cls) {
int * done = cls;
Datastore_Value * dv;
@@ -1017,11 +1017,11 @@
if (dv == NULL)
return SYSERR;
processResponse(query,
- dv);
+ dv);
if (YES == uniqueReplyIdentifier(value,
- ntohl(dv->type),
- NO,
- query))
+ ntohl(dv->type),
+ NO,
+ query))
*done = YES;
FREE(dv);
return SYSERR;
@@ -1044,12 +1044,12 @@
lg_jobs = job->next;
MUTEX_UNLOCK(lock);
gapGet(NULL,
- job->type,
- EXTREME_PRIORITY,
- job->keyCount,
- job->queries,
- &fastPathProcessor,
- NULL);
+ job->type,
+ EXTREME_PRIORITY,
+ job->keyCount,
+ job->queries,
+ &fastPathProcessor,
+ NULL);
FREE(job->queries);
FREE(job);
}
@@ -1057,16 +1057,16 @@
}
static void queueLG_Job(unsigned int type,
- unsigned int keyCount,
- const HashCode512 * queries) {
+ unsigned int keyCount,
+ const HashCode512 * queries) {
LG_Job * job;
job = MALLOC(sizeof(LG_Job));
job->keyCount = keyCount;
job->queries = MALLOC(sizeof(HashCode512) * keyCount);
memcpy(job->queries,
- queries,
- sizeof(HashCode512) * keyCount);
+ queries,
+ sizeof(HashCode512) * keyCount);
MUTEX_LOCK(lock);
job->next = lg_jobs;
lg_jobs = job;
@@ -1080,7 +1080,7 @@
* @return SYSERR if the TCP connection should be closed, otherwise OK
*/
static int csHandleRequestQueryStart(struct ClientHandle * sock,
- const MESSAGE_HEADER * req) {
+ const MESSAGE_HEADER * req) {
static PeerIdentity all_zeros;
const CS_fs_request_search_MESSAGE * rs;
unsigned int keyCount;
@@ -1097,60 +1097,60 @@
}
rs = (const CS_fs_request_search_MESSAGE*) req;
if (memcmp(&all_zeros,
- &rs->target,
- sizeof(PeerIdentity)) == 0)
+ &rs->target,
+ sizeof(PeerIdentity)) == 0)
have_target = NO;
else
have_target = YES;
#if DEBUG_FS
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&rs->query[0],
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&rs->query[0],
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FS received QUERY START (query: `%s', ttl %llu, priority %u,
anonymity %u)\n",
- &enc,
- ntohll(rs->expiration) - get_time(),
- ntohl(rs->prio),
- ntohl(rs->anonymityLevel));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FS received QUERY START (query: `%s', ttl %llu, priority %u, anonymity
%u)\n",
+ &enc,
+ ntohll(rs->expiration) - get_time(),
+ ntohl(rs->prio),
+ ntohl(rs->anonymityLevel));
#endif
type = ntohl(rs->type);
trackQuery(&rs->query[0],
- type,
- sock);
+ type,
+ sock);
keyCount = 1 + (ntohs(req->size) - sizeof(CS_fs_request_search_MESSAGE)) /
sizeof(HashCode512);
/* try a "fast path" avoiding gap/dht if unique reply is locally available */
done = NO;
gapGet(NULL,
- type,
- EXTREME_PRIORITY,
- keyCount,
- &rs->query[0],
- &fastPathProcessorFirst,
- &done);
+ type,
+ EXTREME_PRIORITY,
+ keyCount,
+ &rs->query[0],
+ &fastPathProcessorFirst,
+ &done);
if (done == YES) {
#if DEBUG_FS
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "FS successfully took GAP shortcut for `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "FS successfully took GAP shortcut for `%s'.\n",
+ &enc);
#endif
- return OK;
+ return OK;
}
/* run gapGet asynchronously (since it may take a while due to lots of IO) */
queueLG_Job(type,
- keyCount,
- &rs->query[0]);
+ keyCount,
+ &rs->query[0]);
gap->get_start(have_target == NO ? NULL : &rs->target,
- type,
- ntohl(rs->anonymityLevel),
- keyCount,
- &rs->query[0],
- ntohll(rs->expiration),
- ntohl(rs->prio));
+ type,
+ ntohl(rs->anonymityLevel),
+ keyCount,
+ &rs->query[0],
+ ntohll(rs->expiration),
+ ntohl(rs->prio));
if ( (ntohl(rs->anonymityLevel) == 0) &&
(have_target == NO) &&
(dht != NULL) ) {
@@ -1159,12 +1159,12 @@
cls = MALLOC(sizeof(DHT_GET_CLS));
cls->prio = ntohl(rs->prio);
cls->rec = dht->get_start(type,
- &rs->query[0],
- ntohll(rs->expiration),
- &get_result_callback,
- cls,
- &get_complete_callback,
- cls);
+ &rs->query[0],
+ ntohll(rs->expiration),
+ &get_result_callback,
+ cls,
+ &get_complete_callback,
+ cls);
if (cls->rec == NULL)
FREE(cls); /* should never happen...*/
}
@@ -1194,22 +1194,22 @@
GE_ASSERT(ectx, sizeof(NBlock) == 716);
GE_ASSERT(ectx, sizeof(KNBlock) == 1244);
migration = GC_get_configuration_value_yesno(capi->cfg,
- "FS",
- "ACTIVEMIGRATION",
- YES);
+ "FS",
+ "ACTIVEMIGRATION",
+ YES);
if (migration == SYSERR)
return SYSERR;
if (GC_get_configuration_value_number(capi->cfg,
- "FS",
- "QUOTA",
- 1,
- ((unsigned long long)-1)/1024,
- 1024,
- "a) == -1) {
+ "FS",
+ "QUOTA",
+ 1,
+ ((unsigned long long)-1)/1024,
+ 1024,
+ "a) == -1) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("You must specify a postive number for `%s' in the configuration
in section `%s'.\n"),
- "QUOTA", "FS");
+ GE_ERROR | GE_BULK | GE_USER,
+ _("You must specify a postive number for `%s' in the configuration in
section `%s'.\n"),
+ "QUOTA", "FS");
return SYSERR;
}
datastore = capi->requestService("datastore");
@@ -1239,12 +1239,12 @@
init_dht_push(capi, dht);
ltgSignal = SEMAPHORE_CREATE(0);
localGetProcessor = PTHREAD_CREATE(&localGetter,
- NULL,
- 128 * 1024);
+ NULL,
+ 128 * 1024);
if (localGetProcessor == NULL)
GE_DIE_STRERROR(ectx,
- GE_ADMIN | GE_FATAL | GE_BULK,
- "pthread_create");
+ GE_ADMIN | GE_FATAL | GE_BULK,
+ "pthread_create");
coreAPI = capi;
ONDEMAND_init(capi);
lock = MUTEX_CREATE(NO);
@@ -1256,51 +1256,51 @@
dsGap.fast_get = &fastGet;
initQueryManager(capi);
gap->init(&dsGap,
- &uniqueReplyIdentifier,
- (ReplyHashFunction) &replyHashFunction);
+ &uniqueReplyIdentifier,
+ (ReplyHashFunction) &replyHashFunction);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("`%s' registering client handlers %d %d %d %d %d %d %d %d %d\n"),
- "fs",
- CS_PROTO_gap_QUERY_START,
- CS_PROTO_gap_QUERY_STOP,
- CS_PROTO_gap_INSERT,
- CS_PROTO_gap_INDEX,
- CS_PROTO_gap_DELETE,
- CS_PROTO_gap_UNINDEX,
- CS_PROTO_gap_TESTINDEX,
- CS_PROTO_gap_GET_AVG_PRIORITY,
- CS_PROTO_gap_INIT_INDEX);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("`%s' registering client handlers %d %d %d %d %d %d %d %d %d\n"),
+ "fs",
+ CS_PROTO_gap_QUERY_START,
+ CS_PROTO_gap_QUERY_STOP,
+ CS_PROTO_gap_INSERT,
+ CS_PROTO_gap_INDEX,
+ CS_PROTO_gap_DELETE,
+ CS_PROTO_gap_UNINDEX,
+ CS_PROTO_gap_TESTINDEX,
+ CS_PROTO_gap_GET_AVG_PRIORITY,
+ CS_PROTO_gap_INIT_INDEX);
GE_ASSERT(ectx, SYSERR !=
capi->registerClientHandler(CS_PROTO_gap_QUERY_START,
-
&csHandleRequestQueryStart));
+ &csHandleRequestQueryStart));
GE_ASSERT(ectx, SYSERR !=
capi->registerClientHandler(CS_PROTO_gap_QUERY_STOP,
-
&csHandleRequestQueryStop));
+ &csHandleRequestQueryStop));
GE_ASSERT(ectx, SYSERR != capi->registerClientHandler(CS_PROTO_gap_INSERT,
-
&csHandleCS_fs_request_insert_MESSAGE));
+
&csHandleCS_fs_request_insert_MESSAGE));
GE_ASSERT(ectx, SYSERR != capi->registerClientHandler(CS_PROTO_gap_INDEX,
-
&csHandleCS_fs_request_index_MESSAGE));
+
&csHandleCS_fs_request_index_MESSAGE));
GE_ASSERT(ectx, SYSERR !=
capi->registerClientHandler(CS_PROTO_gap_INIT_INDEX,
-
&csHandleCS_fs_request_init_index_MESSAGE));
+
&csHandleCS_fs_request_init_index_MESSAGE));
GE_ASSERT(ectx, SYSERR != capi->registerClientHandler(CS_PROTO_gap_DELETE,
-
&csHandleCS_fs_request_delete_MESSAGE));
+
&csHandleCS_fs_request_delete_MESSAGE));
GE_ASSERT(ectx, SYSERR != capi->registerClientHandler(CS_PROTO_gap_UNINDEX,
-
&csHandleCS_fs_request_unindex_MESSAGE));
+
&csHandleCS_fs_request_unindex_MESSAGE));
GE_ASSERT(ectx, SYSERR != capi->registerClientHandler(CS_PROTO_gap_TESTINDEX,
-
&csHandleCS_fs_request_test_index_MESSAGEed));
+
&csHandleCS_fs_request_test_index_MESSAGEed));
GE_ASSERT(ectx, SYSERR !=
capi->registerClientHandler(CS_PROTO_gap_GET_AVG_PRIORITY,
-
&csHandleRequestGetAvgPriority));
+ &csHandleRequestGetAvgPriority));
initMigration(capi,
- datastore,
- gap,
- dht,
- traffic);
+ datastore,
+ gap,
+ dht,
+ traffic);
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "fs",
- gettext_noop("enables
(anonymous) file-sharing")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "fs",
+ gettext_noop("enables (anonymous)
file-sharing")));
return OK;
}
@@ -1310,23 +1310,23 @@
doneMigration();
GE_ASSERT(ectx, SYSERR !=
coreAPI->unregisterClientHandler(CS_PROTO_gap_QUERY_START,
-
&csHandleRequestQueryStart));
+ &csHandleRequestQueryStart));
GE_ASSERT(ectx, SYSERR !=
coreAPI->unregisterClientHandler(CS_PROTO_gap_QUERY_STOP,
-
&csHandleRequestQueryStop));
+ &csHandleRequestQueryStop));
GE_ASSERT(ectx, SYSERR !=
coreAPI->unregisterClientHandler(CS_PROTO_gap_INSERT,
-
&csHandleCS_fs_request_insert_MESSAGE));
+
&csHandleCS_fs_request_insert_MESSAGE));
GE_ASSERT(ectx, SYSERR !=
coreAPI->unregisterClientHandler(CS_PROTO_gap_INDEX,
-
&csHandleCS_fs_request_index_MESSAGE));
+
&csHandleCS_fs_request_index_MESSAGE));
GE_ASSERT(ectx, SYSERR !=
coreAPI->unregisterClientHandler(CS_PROTO_gap_INIT_INDEX,
-
&csHandleCS_fs_request_init_index_MESSAGE));
+
&csHandleCS_fs_request_init_index_MESSAGE));
GE_ASSERT(ectx, SYSERR !=
coreAPI->unregisterClientHandler(CS_PROTO_gap_DELETE,
-
&csHandleCS_fs_request_delete_MESSAGE));
+
&csHandleCS_fs_request_delete_MESSAGE));
GE_ASSERT(ectx, SYSERR !=
coreAPI->unregisterClientHandler(CS_PROTO_gap_UNINDEX,
-
&csHandleCS_fs_request_unindex_MESSAGE));
+
&csHandleCS_fs_request_unindex_MESSAGE));
GE_ASSERT(ectx, SYSERR !=
coreAPI->unregisterClientHandler(CS_PROTO_gap_TESTINDEX,
-
&csHandleCS_fs_request_test_index_MESSAGEed));
+
&csHandleCS_fs_request_test_index_MESSAGEed));
GE_ASSERT(ectx, SYSERR !=
coreAPI->unregisterClientHandler(CS_PROTO_gap_GET_AVG_PRIORITY,
-
&csHandleRequestGetAvgPriority));
+
&csHandleRequestGetAvgPriority));
doneQueryManager();
while (lg_jobs != NULL) {
job = lg_jobs->next;
@@ -1336,7 +1336,7 @@
}
SEMAPHORE_UP(ltgSignal); /* lg_jobs == NULL => thread will terminate */
PTHREAD_JOIN(localGetProcessor,
- &unused);
+ &unused);
coreAPI->releaseService(datastore);
datastore = NULL;
if (stats != NULL) {
Modified: GNUnet/src/applications/fs/module/migration.c
===================================================================
--- GNUnet/src/applications/fs/module/migration.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/module/migration.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -101,7 +101,7 @@
static struct MigrationRecord content[MAX_RECORDS];
static struct GE_Context * ectx;
-
+
/**
* Callback method for pushing content into the network.
* The method chooses either a "recently" deleted block
@@ -119,8 +119,8 @@
*/
static unsigned int
activeMigrationCallback(const PeerIdentity * receiver,
- void * position,
- unsigned int padding) {
+ void * position,
+ unsigned int padding) {
unsigned int ret;
GapWrapper * gw;
unsigned int size;
@@ -155,46 +155,46 @@
if (ntohl(content[i].value->size) + sizeof(GapWrapper) -
sizeof(Datastore_Value) <= padding) {
match = 0;
for (j=0;j<content[i].sentCount;j++) {
- if (content[i].receiverIndices[j] == index) {
- match = 1;
- break;
- }
+ if (content[i].receiverIndices[j] == index) {
+ match = 1;
+ break;
+ }
}
}
if (match == 0) {
dist = distanceHashCode512(&content[i].key,
- &receiver->hashPubKey);
+ &receiver->hashPubKey);
if (dist <= minDist) {
- entry = i;
- minDist = dist;
- break;
+ entry = i;
+ minDist = dist;
+ break;
}
} else {
if ( (content[i].sentCount > discard_match) ||
- (discard_match == -1) ) {
- discard_match = content[i].sentCount;
- discard_entry = i;
+ (discard_match == -1) ) {
+ discard_match = content[i].sentCount;
+ discard_entry = i;
}
}
}
if (entry == -1) {
entry = discard_entry;
GE_ASSERT(NULL,
- entry != -1);
+ entry != -1);
FREENONNULL(content[entry].value);
content[entry].value = NULL;
content[entry].sentCount = 0;
if (OK != datastore->getRandom(&receiver->hashPubKey,
- padding,
- &content[entry].key,
- &content[entry].value,
- 0)) {
+ padding,
+ &content[entry].key,
+ &content[entry].value,
+ 0)) {
content[entry].value = NULL; /* just to be sure...*/
MUTEX_UNLOCK(lock);
#if DEBUG_MIGRATION
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Migration: random lookup in datastore failed.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Migration: random lookup in datastore failed.\n");
#endif
return 0;
}
@@ -214,15 +214,15 @@
}
#if DEBUG_MIGRATION
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "Migration: random lookup in datastore returned type %d.\n",
- ntohl(value->type));
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Migration: random lookup in datastore returned type %d.\n",
+ ntohl(value->type));
#endif
if (ntohl(value->type) == ONDEMAND_BLOCK) {
if (ONDEMAND_getIndexed(datastore,
- value,
- &content[entry].key,
- &enc) != OK) {
+ value,
+ &content[entry].key,
+ &enc) != OK) {
FREENONNULL(value);
content[entry].value = NULL;
MUTEX_UNLOCK(lock);
@@ -254,24 +254,24 @@
anonymity = 1;
}
if (OK == checkCoverTraffic(ectx,
- traffic,
- anonymity)) {
+ traffic,
+ anonymity)) {
gw = MALLOC(size);
gw->dc.size = htonl(size);
gw->timeout = htonll(et);
memcpy(&gw[1],
- &value[1],
- size - sizeof(GapWrapper));
+ &value[1],
+ size - sizeof(GapWrapper));
ret = gap->tryMigrate(&gw->dc,
- &content[entry].key,
- position,
- padding);
+ &content[entry].key,
+ position,
+ padding);
FREE(gw);
#if DEBUG_MIGRATION
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "gap's tryMigrate returned %u\n",
- ret);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "gap's tryMigrate returned %u\n",
+ ret);
#endif
if (ret != 0)
content[entry].receiverIndices[content[entry].sentCount++] = index;
@@ -285,10 +285,10 @@
}
void initMigration(CoreAPIForApplication * capi,
- Datastore_ServiceAPI * ds,
- GAP_ServiceAPI * g,
- DHT_ServiceAPI * d,
- Traffic_ServiceAPI * t) {
+ Datastore_ServiceAPI * ds,
+ GAP_ServiceAPI * g,
+ DHT_ServiceAPI * d,
+ Traffic_ServiceAPI * t) {
ectx = capi->ectx;
lock = MUTEX_CREATE(NO);
coreAPI = capi;
@@ -297,7 +297,7 @@
dht = d;
traffic = t;
coreAPI->registerSendCallback(GAP_ESTIMATED_DATA_SIZE,
- &activeMigrationCallback);
+ &activeMigrationCallback);
stats = capi->requestService("stats");
if (stats != NULL) {
stat_migration_count
@@ -313,7 +313,7 @@
void doneMigration() {
int i;
coreAPI->unregisterSendCallback(GAP_ESTIMATED_DATA_SIZE,
- &activeMigrationCallback);
+ &activeMigrationCallback);
if (stats != NULL) {
coreAPI->releaseService(stats);
stats = NULL;
Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/module/ondemand.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -79,7 +79,7 @@
char * fn;
hash2enc(fileId,
- &enc);
+ &enc);
fn = MALLOC(strlen(index_directory) + sizeof(EncName) + 1);
strcpy(fn, index_directory);
strcat(fn, DIR_SEPARATOR_STR);
@@ -94,14 +94,14 @@
* by aborting the iteration.
*/
static int checkPresent(const HashCode512 * key,
- const Datastore_Value * value,
- void * closure) {
+ const Datastore_Value * value,
+ void * closure) {
Datastore_Value * comp = closure;
if ( (comp->size != value->size) ||
(0 != memcmp(&value[1],
- &comp[1],
- ntohl(value->size) - sizeof(Datastore_Value))) )
+ &comp[1],
+ ntohl(value->size) - sizeof(Datastore_Value))) )
return OK;
return SYSERR;
}
@@ -115,51 +115,51 @@
* YES on success
*/
int ONDEMAND_initIndex(struct GE_Context * cectx,
- const HashCode512 * fileId,
- const char *fn) {
+ const HashCode512 * fileId,
+ const char *fn) {
EncName enc;
char * serverFN;
char unavail_key[256];
HashCode512 linkId;
if ( (SYSERR == getFileHash(cectx,
- fn,
- &linkId)) ||
+ fn,
+ &linkId)) ||
(! equalsHashCode512(&linkId,
- fileId)) ) {
+ fileId)) ) {
return NO;
}
serverFN = MALLOC(strlen(index_directory) + 2 + sizeof(EncName));
strcpy(serverFN,
- index_directory);
+ index_directory);
strcat(serverFN,
- DIR_SEPARATOR_STR);
+ DIR_SEPARATOR_STR);
hash2enc(fileId,
- &enc);
+ &enc);
strcat(serverFN,
- (char*)&enc);
+ (char*)&enc);
UNLINK(serverFN);
disk_directory_create_for_file(cectx,
- serverFN);
+ serverFN);
if (0 != SYMLINK(fn, serverFN)) {
GE_LOG_STRERROR_FILE(cectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "symlink",
- fn);
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "symlink",
+ fn);
GE_LOG_STRERROR_FILE(cectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "symlink",
- serverFN);
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "symlink",
+ serverFN);
FREE(serverFN);
return NO;
}
SNPRINTF(unavail_key,
- 256,
- "FIRST_UNAVAILABLE-%s",
- (char*)&enc);
+ 256,
+ "FIRST_UNAVAILABLE-%s",
+ (char*)&enc);
state->unlink(ectx,
- unavail_key);
+ unavail_key);
FREE(serverFN);
return YES;
}
@@ -172,14 +172,14 @@
* SYSERR on other error (i.e. datastore full)
*/
int ONDEMAND_index(struct GE_Context * cectx,
- Datastore_ServiceAPI * datastore,
- unsigned int prio,
- cron_t expiration,
- unsigned long long fileOffset,
- unsigned int anonymityLevel,
- const HashCode512 * fileId,
- unsigned int size,
- const DBlock * content) {
+ Datastore_ServiceAPI * datastore,
+ unsigned int prio,
+ cron_t expiration,
+ unsigned long long fileOffset,
+ unsigned int anonymityLevel,
+ const HashCode512 * fileId,
+ unsigned int size,
+ const DBlock * content) {
int ret;
OnDemandBlock odb;
HashCode512 key;
@@ -198,7 +198,7 @@
fn = getOnDemandFile(fileId);
if ( (0 != LSTAT(fn,
- &sbuf))
+ &sbuf))
#ifdef S_ISLNK
|| (! S_ISLNK(sbuf.st_mode))
#endif
@@ -208,31 +208,31 @@
/* not sym-linked, write content to offset! */
#if DEBUG_ONDEMAND
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Storing on-demand encoded data in `%s'.\n",
- fn);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Storing on-demand encoded data in `%s'.\n",
+ fn);
#endif
fd = disk_file_open(cectx,
- fn,
- O_LARGEFILE | O_CREAT|O_WRONLY,
- S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /* 644 */
+ fn,
+ O_LARGEFILE | O_CREAT|O_WRONLY,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /* 644 */
if(fd == -1) {
FREE(fn);
return SYSERR;
}
lseek(fd,
- fileOffset,
- SEEK_SET);
+ fileOffset,
+ SEEK_SET);
ret = WRITE(fd,
- &content[1],
- size - sizeof(DBlock));
+ &content[1],
+ size - sizeof(DBlock));
if (ret == size - sizeof(DBlock)) {
ret = OK;
} else {
GE_LOG_STRERROR_FILE(cectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "write",
- fn);
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "write",
+ fn);
ret = SYSERR;
}
CLOSE(fd);
@@ -254,15 +254,15 @@
odb.fileId = *fileId;
/* compute the primary key */
fileBlockGetQuery(content,
- size,
- &key);
+ size,
+ &key);
#if EXTRA_CHECKS
{
Datastore_Value * dsvalue;
if (OK != fileBlockEncode(content,
- size,
- &key,
- &dsvalue)) {
+ size,
+ &key,
+ &dsvalue)) {
GE_BREAK(cectx, 0);
GE_BREAK(ectx, 0);
} else {
@@ -273,21 +273,21 @@
#if DEBUG_ONDEMAND
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&key, &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&key, &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Storing on-demand content for query `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Storing on-demand content for query `%s'\n",
+ &enc);
#endif
ret = datastore->get(&key,
- ONDEMAND_BLOCK,
- &checkPresent,
- &odb.header);
+ ONDEMAND_BLOCK,
+ &checkPresent,
+ &odb.header);
if (ret >= 0) {
ret = datastore->put(&key,
- &odb.header);
+ &odb.header);
} else {
ret = NO; /* already present! */
}
@@ -303,7 +303,7 @@
static void asyncDelJob(void * cls) {
struct adJ * job = cls;
job->datastore->del(&job->query,
- job->dbv);
+ job->dbv);
FREE(job->dbv);
FREE(job);
}
@@ -314,8 +314,8 @@
* a del operation during "get" would deadlock!
*/
static void asyncDelete(Datastore_ServiceAPI * datastore,
- const Datastore_Value * dbv,
- const HashCode512 * query) {
+ const Datastore_Value * dbv,
+ const HashCode512 * query) {
struct adJ * job;
#if DEBUG_ONDEMAND
EncName enc;
@@ -326,22 +326,22 @@
job->query = *query;
job->dbv = MALLOC(ntohl(dbv->size));
memcpy(job->dbv,
- dbv,
- ntohl(dbv->size));
+ dbv,
+ ntohl(dbv->size));
#if DEBUG_ONDEMAND
hash2enc(query,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("Indexed file disappeared, deleting block for query `%s'\n"),
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("Indexed file disappeared, deleting block for query `%s'\n"),
+ &enc);
#endif
/* schedule for "immediate" execution */
cron_add_job(coreAPI->cron,
- &asyncDelJob,
- 0,
- 0,
- job);
+ &asyncDelJob,
+ 0,
+ 0,
+ job);
}
/**
@@ -354,9 +354,9 @@
* @return OK on success, SYSERR if there was an error
*/
int ONDEMAND_getIndexed(Datastore_ServiceAPI * datastore,
- const Datastore_Value * dbv,
- const HashCode512 * query,
- Datastore_Value ** enc) {
+ const Datastore_Value * dbv,
+ const HashCode512 * query,
+ Datastore_Value ** enc) {
char * fn;
char * iobuf;
int blen;
@@ -372,20 +372,20 @@
odb = (OnDemandBlock*) dbv;
fn = getOnDemandFile(&odb->fileId);
if ( (YES != disk_file_test(ectx,
- fn)) ||
+ fn)) ||
(-1 == (fileHandle = disk_file_open(ectx,
- fn,
- O_LARGEFILE | O_RDONLY,
- 0))) ) {
+ fn,
+ O_LARGEFILE | O_RDONLY,
+ 0))) ) {
char unavail_key[256];
EncName enc;
unsigned long long * first_unavail;
struct stat linkStat;
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
- "open",
- fn);
+ GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+ "open",
+ fn);
/* Is the symlink there? */
if (LSTAT(fn, &linkStat) == -1) {
@@ -393,53 +393,53 @@
} else {
/* For how long has the file been unavailable? */
hash2enc(&odb->fileId,
- &enc);
+ &enc);
SNPRINTF(unavail_key,
- 256,
- "FIRST_UNVAILABLE-%s",
- (char *) &enc);
+ 256,
+ "FIRST_UNVAILABLE-%s",
+ (char *) &enc);
if (state->read(ectx,
- unavail_key,
- (void*)&first_unavail) != sizeof(cron_t)) {
+ unavail_key,
+ (void*)&first_unavail) != sizeof(cron_t)) {
unsigned long long now = htonll(get_time());
state->write(ectx,
- unavail_key,
- sizeof(cron_t),
- (void *) &now);
+ unavail_key,
+ sizeof(cron_t),
+ (void *) &now);
} else {
/* Delete it after 3 days */
if (ntohll(*first_unavail) - get_time() > 3 * cronDAYS) {
- unsigned int len;
- char * ofn;
- int ret;
+ unsigned int len;
+ char * ofn;
+ int ret;
- len = 256;
- ofn = MALLOC(len);
- while ( ((ret = READLINK(fn, ofn, len)) == -1) &&
- (errno == ENAMETOOLONG) &&
- (len < 4 * 1024 * 1024) )
- if (len * 2 < len) {
- GE_BREAK(ectx, 0);
- GROW(ofn, len, 0);
- FREE(fn);
- return SYSERR;
- }
- GROW(ofn,
- len,
- len*2);
-
+ len = 256;
+ ofn = MALLOC(len);
+ while ( ((ret = READLINK(fn, ofn, len)) == -1) &&
+ (errno == ENAMETOOLONG) &&
+ (len < 4 * 1024 * 1024) )
+ if (len * 2 < len) {
+ GE_BREAK(ectx, 0);
+ GROW(ofn, len, 0);
+ FREE(fn);
+ return SYSERR;
+ }
+ GROW(ofn,
+ len,
+ len*2);
+
if (ret != -1) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Because the file `%s' has been unavailable for 3 days"
- " it got removed from your share. Please unindex files
before"
- " deleting them as the index now contains invalid
references!\n"),
- ofn);
- }
- FREE(ofn);
- asyncDelete(datastore, dbv, query);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Because the file `%s' has been unavailable for 3 days"
+ " it got removed from your share. Please unindex files before"
+ " deleting them as the index now contains invalid references!\n"),
+ ofn);
+ }
+ FREE(ofn);
+ asyncDelete(datastore, dbv, query);
state->unlink(ectx,
- unavail_key);
+ unavail_key);
UNLINK(fn);
}
}
@@ -457,32 +457,32 @@
int n;
afsDir = getFileName("FS",
- "DIR",
- _("Configuration file must specify directory for"
- " storage of FS data in section `%s'"
- " under `%s'.\n"));
+ "DIR",
+ _("Configuration file must specify directory for"
+ " storage of FS data in section `%s'"
+ " under `%s'.\n"));
n = strlen(afsDir)+strlen(TRACKFILE)+8;
scratch = MALLOC(n);
SNPRINTF(scratch,
- n,
- "%s/%s", afsDir, TRACKFILE);
+ n,
+ "%s/%s", afsDir, TRACKFILE);
fp = FOPEN(scratch, "a");
FPRINTF(fp,
- "%u %llu\n",
- ntohs(ce->fileNameIndex),
- (unsigned long long)TIME(NULL));
+ "%u %llu\n",
+ ntohs(ce->fileNameIndex),
+ (unsigned long long)TIME(NULL));
fclose(fp);
FREE(scratch);
FREE(afsDir);
}
#endif
if (ntohll(odb->fileOffset) != lseek(fileHandle,
- ntohll(odb->fileOffset),
- SEEK_SET)) {
+ ntohll(odb->fileOffset),
+ SEEK_SET)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
- "lseek",
- fn);
+ GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+ "lseek",
+ fn);
FREE(fn);
CLOSE(fileHandle);
asyncDelete(datastore, dbv, query);
@@ -492,13 +492,13 @@
db->type = htonl(D_BLOCK);
iobuf = (char*) &db[1];
blen = READ(fileHandle,
- iobuf,
- ntohl(odb->blockSize));
+ iobuf,
+ ntohl(odb->blockSize));
if (blen != ntohl(odb->blockSize)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
- "read",
- fn);
+ GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+ "read",
+ fn);
FREE(fn);
FREE(db);
CLOSE(fileHandle);
@@ -507,15 +507,15 @@
}
CLOSE(fileHandle);
ret = fileBlockEncode(db,
- ntohl(odb->blockSize) + sizeof(DBlock),
- query,
- enc);
+ ntohl(odb->blockSize) + sizeof(DBlock),
+ query,
+ enc);
FREE(db);
FREE(fn);
if (ret == SYSERR) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Indexed content changed (does not match its hash).\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Indexed content changed (does not match its hash).\n"));
asyncDelete(datastore, dbv, query);
return SYSERR;
}
@@ -532,14 +532,14 @@
* @return YES if so, NO if not.
*/
int ONDEMAND_testindexed(Datastore_ServiceAPI * datastore,
- const HashCode512 * fileId) {
+ const HashCode512 * fileId) {
char * fn;
int fd;
fn = getOnDemandFile(fileId);
fd = disk_file_open(ectx,
- fn,
- O_RDONLY);
+ fn,
+ O_RDONLY);
FREE(fn);
if(fd == -1)
return NO;
@@ -555,30 +555,30 @@
* continue.
*/
static int completeValue(const HashCode512 * key,
- const Datastore_Value * value,
- void * closure) {
+ const Datastore_Value * value,
+ void * closure) {
Datastore_Value * comp = closure;
if ( (comp->size != value->size) ||
(0 != memcmp(&value[1],
- &comp[1],
- ntohl(value->size) - sizeof(Datastore_Value))) ) {
+ &comp[1],
+ ntohl(value->size) - sizeof(Datastore_Value))) ) {
#if DEBUG_ONDEMAND
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' found value that does not match (%u, %u).\n",
- __FUNCTION__,
- ntohl(comp->size),
- ntohl(value->size));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' found value that does not match (%u, %u).\n",
+ __FUNCTION__,
+ ntohl(comp->size),
+ ntohl(value->size));
#endif
return OK;
}
*comp = *value; /* make copy! */
#if DEBUG_ONDEMAND
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "`%s' found value that matches.\n",
- __FUNCTION__);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "`%s' found value that matches.\n",
+ __FUNCTION__);
#endif
return SYSERR;
}
@@ -594,9 +594,9 @@
* the keys of the odb blocks).
*/
int ONDEMAND_unindex(struct GE_Context * cectx,
- Datastore_ServiceAPI * datastore,
- unsigned int blocksize,
- const HashCode512 * fileId) {
+ Datastore_ServiceAPI * datastore,
+ unsigned int blocksize,
+ const HashCode512 * fileId) {
char * fn;
int fd;
int ret;
@@ -612,23 +612,23 @@
fn = getOnDemandFile(fileId);
#if DEBUG_ONDEMAND
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Removing on-demand encoded data stored in `%s'.\n",
- fn);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Removing on-demand encoded data stored in `%s'.\n",
+ fn);
#endif
fd = disk_file_open(cectx,
- fn,
- O_RDONLY | O_LARGEFILE,
- S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /* 644 */
+ fn,
+ O_RDONLY | O_LARGEFILE,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /* 644 */
if(fd == -1) {
FREE(fn);
return SYSERR;
}
pos = 0;
if (OK != disk_file_size(cectx,
- fn,
- &size,
- YES)) {
+ fn,
+ &size,
+ YES)) {
FREE(fn);
return SYSERR;
}
@@ -639,12 +639,12 @@
if (delta > blocksize)
delta = blocksize;
if (delta != READ(fd,
- &block[1],
- delta)) {
+ &block[1],
+ delta)) {
GE_LOG_STRERROR_FILE(cectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "read",
- fn);
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "read",
+ fn);
CLOSE(fd);
FREE(fn);
FREE(block);
@@ -661,26 +661,26 @@
odb.fileId = *fileId;
/* compute the primary key */
fileBlockGetQuery(block,
- delta + sizeof(DBlock),
- &key);
+ delta + sizeof(DBlock),
+ &key);
if (SYSERR == datastore->get(&key,
- ONDEMAND_BLOCK,
- &completeValue,
- &odb.header)) /* aborted == found! */
+ ONDEMAND_BLOCK,
+ &completeValue,
+ &odb.header)) /* aborted == found! */
ret = datastore->del(&key,
- &odb.header);
+ &odb.header);
else /* not found */
ret = SYSERR;
if (ret == SYSERR) {
IF_GELOG(cectx,
- GE_WARNING | GE_BULK | GE_USER,
- hash2enc(&key,
- &enc));
+ GE_WARNING | GE_BULK | GE_USER,
+ hash2enc(&key,
+ &enc));
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Unindexed ODB block `%s' from offset %llu already missing from
datastore.\n"),
- &enc,
- pos);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Unindexed ODB block `%s' from offset %llu already missing from
datastore.\n"),
+ &enc,
+ pos);
}
pos += delta;
}
@@ -689,13 +689,13 @@
UNLINK(fn);
/* Remove information about unavailability */
hash2enc(fileId,
- &enc);
+ &enc);
SNPRINTF(unavail_key,
- 256,
- "FIRST_UNAVAILABLE-%s",
- (char*)&enc);
+ 256,
+ "FIRST_UNAVAILABLE-%s",
+ (char*)&enc);
state->unlink(ectx,
- unavail_key);
+ unavail_key);
FREE(fn);
return OK;
}
@@ -711,24 +711,24 @@
}
ectx = capi->ectx;
GC_get_configuration_value_filename(capi->cfg,
- "GNUNETD",
- "GNUNETD_HOME",
- VAR_DAEMON_DIRECTORY,
- &tmp);
+ "GNUNETD",
+ "GNUNETD_HOME",
+ VAR_DAEMON_DIRECTORY,
+ &tmp);
GE_ASSERT(ectx,
- NULL != tmp);
+ NULL != tmp);
tmp = REALLOC(tmp,
- strlen(tmp) +
- strlen("/data/shared/") + 1);
+ strlen(tmp) +
+ strlen("/data/shared/") + 1);
strcat(tmp, "/data/shared/");
GC_get_configuration_value_filename(capi->cfg,
- "FS",
- "INDEX-DIRECTORY",
- tmp,
- &index_directory);
+ "FS",
+ "INDEX-DIRECTORY",
+ tmp,
+ &index_directory);
FREE(tmp);
disk_directory_create(ectx,
- index_directory); /* just in case */
+ index_directory); /* just in case */
return OK;
}
Modified: GNUnet/src/applications/fs/module/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/module/querymanager.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/module/querymanager.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -97,14 +97,14 @@
* @param client where did the query come from?
*/
void trackQuery(const HashCode512 * query,
- unsigned int type,
- struct ClientHandle * client) {
+ unsigned int type,
+ struct ClientHandle * client) {
GE_ASSERT(ectx, client != NULL);
MUTEX_LOCK(queryManagerLock);
if (trackerSize == trackerCount)
GROW(trackers,
- trackerSize,
- trackerSize * 2);
+ trackerSize,
+ trackerSize * 2);
trackers[trackerCount] = MALLOC(sizeof(TrackRecord));
trackers[trackerCount]->query = *query;
trackers[trackerCount]->type = type;
@@ -122,14 +122,14 @@
* @param client where did the query come from?
*/
void untrackQuery(const HashCode512 * query,
- struct ClientHandle * client) {
+ struct ClientHandle * client) {
int i;
MUTEX_LOCK(queryManagerLock);
for (i=trackerCount-1;i>=0;i--)
if ( (trackers[i]->client == client) &&
- (equalsHashCode512(&trackers[i]->query,
- query)) ) {
+ (equalsHashCode512(&trackers[i]->query,
+ query)) ) {
removeEntry(i);
MUTEX_UNLOCK(queryManagerLock);
return;
@@ -144,7 +144,7 @@
* @param value the response
*/
void processResponse(const HashCode512 * key,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
int i;
CS_fs_reply_content_MESSAGE * rc;
unsigned int matchCount;
@@ -153,7 +153,7 @@
#endif
GE_ASSERT(ectx,
- ntohl(value->size) > sizeof(Datastore_Value));
+ ntohl(value->size) > sizeof(Datastore_Value));
if ( (ntohll(value->expirationTime) < get_time()) &&
(ntohl(value->type) != D_BLOCK) )
return; /* ignore expired, non-data responses! */
@@ -161,48 +161,48 @@
matchCount = 0;
#if DEBUG_QUERYMANAGER
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(key,
+ &enc));
#endif
MUTEX_LOCK(queryManagerLock);
for (i=trackerCount-1;i>=0;i--) {
if ( (equalsHashCode512(&trackers[i]->query,
- key)) &&
- ( (trackers[i]->type == ANY_BLOCK) ||
- (trackers[i]->type == ntohl(value->type)) ) ) {
+ key)) &&
+ ( (trackers[i]->type == ANY_BLOCK) ||
+ (trackers[i]->type == ntohl(value->type)) ) ) {
matchCount++;
rc = MALLOC(sizeof(CS_fs_reply_content_MESSAGE) +
- ntohl(value->size) - sizeof(Datastore_Value));
+ ntohl(value->size) - sizeof(Datastore_Value));
rc->header.size = htons(sizeof(CS_fs_reply_content_MESSAGE) +
- ntohl(value->size) - sizeof(Datastore_Value));
+ ntohl(value->size) - sizeof(Datastore_Value));
rc->header.type = htons(CS_PROTO_gap_RESULT);
rc->anonymityLevel = value->anonymityLevel;
rc->expirationTime = value->expirationTime;
memcpy(&rc[1],
- &value[1],
- ntohl(value->size) - sizeof(Datastore_Value));
+ &value[1],
+ ntohl(value->size) - sizeof(Datastore_Value));
#if DEBUG_QUERYMANAGER
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Sending reply for `%s' to client waiting in slot %u.\n",
- &enc,
- i);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Sending reply for `%s' to client waiting in slot %u.\n",
+ &enc,
+ i);
#endif
if (stats != NULL)
- stats->change(stat_replies_transmitted,
- 1);
+ stats->change(stat_replies_transmitted,
+ 1);
coreAPI->sendToClient(trackers[i]->client,
- &rc->header);
+ &rc->header);
FREE(rc);
}
}
#if DEBUG_QUERYMANAGER && 0
if (matchCount == 0) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Reply `%s' did not match any request.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Reply `%s' did not match any request.\n",
+ &enc);
}
#endif
MUTEX_UNLOCK(queryManagerLock);
Modified: GNUnet/src/applications/fs/namespace/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/namespace/namespace_info.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/fs/namespace/namespace_info.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -50,29 +50,29 @@
* Internal notification about new tracked URI.
*/
static void internal_notify(const char * name,
- const HashCode512 * id,
- const struct ECRS_MetaData * md,
- int rating) {
+ const HashCode512 * id,
+ const struct ECRS_MetaData * md,
+ int rating) {
struct DiscoveryCallback * pos;
MUTEX_LOCK(lock);
pos = head;
while (pos != NULL) {
pos->callback(pos->closure,
- name,
- id,
- md,
- rating);
+ name,
+ id,
+ md,
+ rating);
pos = pos->next;
}
MUTEX_UNLOCK(lock);
}
static void writeNamespaceInfo(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * namespaceName,
- const struct ECRS_MetaData * meta,
- int ranking) {
+ struct GC_Configuration * cfg,
+ const char * namespaceName,
+ const struct ECRS_MetaData * meta,
+ int ranking) {
unsigned int size;
unsigned int tag;
char * buf;
@@ -81,14 +81,14 @@
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &fnBase);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fnBase);
fn = MALLOC(strlen(fnBase) +
- strlen(NS_DIR) +
- strlen(namespaceName) +
- 6);
+ strlen(NS_DIR) +
+ strlen(namespaceName) +
+ 6);
strcpy(fn, fnBase);
strcat(fn, DIR_SEPARATOR_STR);
strcat(fn, NS_DIR);
@@ -98,30 +98,30 @@
FREE(fnBase);
size = ECRS_sizeofMetaData(meta,
- ECRS_SERIALIZE_FULL);
+ ECRS_SERIALIZE_FULL);
tag = size + sizeof(int);
buf = MALLOC(tag);
((int *) buf)[0] = htonl(ranking); /* ranking */
GE_ASSERT(ectx,
- size == ECRS_serializeMetaData(ectx,
- meta,
- &buf[sizeof(int)],
- size,
- ECRS_SERIALIZE_FULL));
+ size == ECRS_serializeMetaData(ectx,
+ meta,
+ &buf[sizeof(int)],
+ size,
+ ECRS_SERIALIZE_FULL));
disk_file_write(ectx,
- fn,
- buf,
- tag,
- "660");
+ fn,
+ buf,
+ tag,
+ "660");
FREE(fn);
FREE(buf);
}
static int readNamespaceInfo(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * namespaceName,
- struct ECRS_MetaData ** meta,
- int * ranking) {
+ struct GC_Configuration * cfg,
+ const char * namespaceName,
+ struct ECRS_MetaData ** meta,
+ int * ranking) {
unsigned long long len;
unsigned int size;
char * buf;
@@ -130,29 +130,29 @@
*meta = NULL;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &fnBase);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fnBase);
fn = MALLOC(strlen(fnBase) +
- strlen(NS_DIR) +
- strlen(namespaceName) +
- 6);
+ strlen(NS_DIR) +
+ strlen(namespaceName) +
+ 6);
strcpy(fn, fnBase);
strcat(fn, DIR_SEPARATOR_STR);
strcat(fn, NS_DIR);
disk_directory_create(ectx,
- fn);
+ fn);
strcat(fn, DIR_SEPARATOR_STR);
strcat(fn, namespaceName);
FREE(fnBase);
if ( (OK != disk_file_test(ectx,
- fn) ||
- (OK != disk_file_size(ectx,
- fn,
- &len,
- YES)) ) ) {
+ fn) ||
+ (OK != disk_file_size(ectx,
+ fn,
+ &len,
+ YES)) ) ) {
FREE(fn);
return SYSERR;
}
@@ -169,9 +169,9 @@
}
buf = MALLOC(len);
if (len != disk_file_read(ectx,
- fn,
- len,
- buf)) {
+ fn,
+ len,
+ buf)) {
FREE(buf);
FREE(fn);
return SYSERR;
@@ -180,8 +180,8 @@
size = len - sizeof(int);
*ranking = ntohl(((int *) buf)[0]);
*meta = ECRS_deserializeMetaData(ectx,
- &buf[sizeof(int)],
- size);
+ &buf[sizeof(int)],
+ size);
if ((*meta) == NULL) {
/* invalid data! remove! */
GE_BREAK(ectx, 0);
@@ -194,7 +194,7 @@
FREE(buf);
return OK;
}
-
+
/**
* Create a new namespace (and publish an advertismement).
@@ -206,45 +206,45 @@
*/
struct ECRS_URI *
NS_createNamespace(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- unsigned int anonymityLevel,
- unsigned int insertPriority,
- cron_t insertExpiration,
- const char * namespaceName,
- const struct ECRS_MetaData * meta,
- const struct ECRS_URI * advertisementURI,
- const HashCode512 * rootEntry) {
+ struct GC_Configuration * cfg,
+ unsigned int anonymityLevel,
+ unsigned int insertPriority,
+ cron_t insertExpiration,
+ const char * namespaceName,
+ const struct ECRS_MetaData * meta,
+ const struct ECRS_URI * advertisementURI,
+ const HashCode512 * rootEntry) {
struct ECRS_URI * ret;
ret = ECRS_createNamespace(ectx,
- cfg,
- namespaceName,
- meta,
- anonymityLevel,
- insertPriority,
- insertExpiration,
- advertisementURI,
- rootEntry);
+ cfg,
+ namespaceName,
+ meta,
+ anonymityLevel,
+ insertPriority,
+ insertExpiration,
+ advertisementURI,
+ rootEntry);
/* store binding of namespaceName to 'meta' in state DB! */
if (ret != NULL) {
HashCode512 id;
char * name;
NS_setNamespaceRoot(ectx,
- cfg,
- ret);
+ cfg,
+ ret);
ECRS_getNamespaceId(ret,
- &id);
+ &id);
name = ECRS_getNamespaceName(&id);
writeNamespaceInfo(ectx,
- cfg,
- name,
- meta,
- 0);
+ cfg,
+ name,
+ meta,
+ 0);
internal_notify(namespaceName,
- &id,
- meta,
- 0);
+ &id,
+ meta,
+ 0);
FREE(name);
}
return ret;
@@ -257,20 +257,20 @@
* @return OK on success, SYSERR on error
*/
int NS_deleteNamespace(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * namespaceName) {
+ struct GC_Configuration * cfg,
+ const char * namespaceName) {
int ret;
char * tmp;
char * fn;
ret = ECRS_deleteNamespace(ectx, cfg, namespaceName);
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &tmp);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &tmp);
fn = MALLOC(strlen(tmp) + strlen(NS_UPDATE_DIR) +
- strlen(namespaceName) + 20);
+ strlen(namespaceName) + 20);
strcpy(fn, tmp);
FREE(tmp);
strcat(fn, DIR_SEPARATOR_STR);
@@ -294,28 +294,28 @@
* @return new rating of the namespace
*/
int NS_rankNamespace(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * ns,
- int delta) {
+ struct GC_Configuration * cfg,
+ const char * ns,
+ int delta) {
struct ECRS_MetaData * meta;
int ret;
int ranking;
ret = readNamespaceInfo(ectx,
- cfg,
- ns,
- &meta,
- &ranking);
+ cfg,
+ ns,
+ &meta,
+ &ranking);
if (ret == SYSERR) {
ranking = 0;
meta = ECRS_createMetaData();
}
ranking += delta;
writeNamespaceInfo(ectx,
- cfg,
- ns,
- meta,
- ranking);
+ cfg,
+ ns,
+ meta,
+ ranking);
ECRS_freeMetaData(meta);
return ranking;
}
@@ -328,8 +328,8 @@
} LNClosure;
static int localListNamespaceHelper(const HashCode512 * nsid,
- const char * name,
- void * cls) {
+ const char * name,
+ void * cls) {
LNClosure * c = cls;
int ret;
struct ECRS_MetaData * meta;
@@ -338,18 +338,18 @@
meta = NULL;
rating = 0;
readNamespaceInfo(c->ectx,
- c->cfg,
- name,
- &meta,
- &rating);
+ c->cfg,
+ name,
+ &meta,
+ &rating);
if (meta == NULL)
meta = ECRS_createMetaData();
if (c->iterator != NULL) {
ret = c->iterator(c->closure,
- name,
- nsid,
- meta,
- rating);
+ name,
+ nsid,
+ meta,
+ rating);
} else
ret = OK;
ECRS_freeMetaData(meta);
@@ -357,8 +357,8 @@
}
static int listNamespaceHelper(const char * fn,
- const char * dirName,
- void * cls) {
+ const char * dirName,
+ void * cls) {
LNClosure * c = cls;
int ret;
struct ECRS_MetaData * meta;
@@ -366,20 +366,20 @@
HashCode512 id;
if (OK != enc2hash(fn,
- &id))
+ &id))
return OK; /* invalid name */
if (OK != readNamespaceInfo(c->ectx,
- c->cfg,
- fn,
- &meta,
- &rating))
+ c->cfg,
+ fn,
+ &meta,
+ &rating))
return OK; /* ignore entry */
if (c->iterator != NULL) {
ret = c->iterator(c->closure,
- fn,
- &id,
- meta,
- rating);
+ fn,
+ &id,
+ meta,
+ rating);
} else
ret = OK;
ECRS_freeMetaData(meta);
@@ -391,9 +391,9 @@
*
*/
int NS_listNamespaces(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- NS_NamespaceIterator iterator,
- void * closure) {
+ struct GC_Configuration * cfg,
+ NS_NamespaceIterator iterator,
+ void * closure) {
LNClosure cls;
char * fn;
char * fnBase;
@@ -405,28 +405,28 @@
cls.ectx = ectx;
cls.cfg = cfg;
ret1 = ECRS_listNamespaces(ectx,
- cfg,
- &localListNamespaceHelper,
- &cls);
+ cfg,
+ &localListNamespaceHelper,
+ &cls);
if (ret1 == -1)
return ret1;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &fnBase);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fnBase);
fn = MALLOC(strlen(fnBase) +
- strlen(NS_DIR) +
- 4);
+ strlen(NS_DIR) +
+ 4);
strcpy(fn, fnBase);
FREE(fnBase);
strcat(fn, DIR_SEPARATOR_STR);
strcat(fn, NS_DIR);
disk_directory_create(ectx, fn);
ret2 = disk_directory_scan(ectx,
- fn,
- &listNamespaceHelper,
- &cls);
+ fn,
+ &listNamespaceHelper,
+ &cls);
FREE(fn);
if (ret2 == -1)
return ret2;
@@ -439,19 +439,19 @@
* @param lastId maybe NULL
*/
static char * getUpdateDataFilename(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * nsname,
- const HashCode512 * lastId) {
+ struct GC_Configuration * cfg,
+ const char * nsname,
+ const HashCode512 * lastId) {
char * tmp;
char * ret;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &tmp);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &tmp);
ret = MALLOC(strlen(tmp) + strlen(NS_UPDATE_DIR) +
- strlen(nsname) + sizeof(EncName) + 20);
+ strlen(nsname) + sizeof(EncName) + 20);
strcpy(ret, tmp);
FREE(tmp);
strcat(ret, DIR_SEPARATOR_STR);
@@ -483,13 +483,13 @@
* @return OK if update data was found, SYSERR if not.
*/
static int readUpdateData(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * nsname,
- const HashCode512 * lastId,
- HashCode512 * nextId,
- ECRS_FileInfo * fi,
- TIME_T * updateInterval,
- TIME_T * lastPubTime) {
+ struct GC_Configuration * cfg,
+ const char * nsname,
+ const HashCode512 * lastId,
+ HashCode512 * nextId,
+ ECRS_FileInfo * fi,
+ TIME_T * updateInterval,
+ TIME_T * lastPubTime) {
char * fn;
struct UpdateData * buf;
char * uri;
@@ -497,13 +497,13 @@
size_t pos;
fn = getUpdateDataFilename(ectx,
- cfg,
- nsname,
- lastId);
+ cfg,
+ nsname,
+ lastId);
if (OK != disk_file_size(ectx,
- fn,
- &size,
- YES)) {
+ fn,
+ &size,
+ YES)) {
FREE(fn);
return SYSERR;
}
@@ -516,16 +516,16 @@
buf = MALLOC(size);
if (size != disk_file_read(ectx,
- fn,
- size,
- buf)) {
+ fn,
+ size,
+ buf)) {
FREE(buf);
FREE(fn);
return SYSERR;
}
FREE(fn);
if ( ! equalsHashCode512(lastId,
- &buf->thisId)) {
+ &buf->thisId)) {
FREE(buf);
return SYSERR;
}
@@ -533,7 +533,7 @@
size -= sizeof(struct UpdateData);
pos = 0;
while ( (pos < size) &&
- (uri[pos] != '\0') )
+ (uri[pos] != '\0') )
pos++;
pos++;
size -= pos;
@@ -544,15 +544,15 @@
}
if (fi != NULL) {
fi->meta = ECRS_deserializeMetaData(ectx,
- &uri[pos],
- size);
+ &uri[pos],
+ size);
if (fi->meta == NULL) {
FREE(buf);
GE_BREAK(ectx, 0);
return SYSERR;
}
fi->uri = ECRS_stringToUri(ectx,
- uri);
+ uri);
if (fi->uri == NULL) {
ECRS_freeMetaData(fi->meta);
fi->meta = NULL;
@@ -575,13 +575,13 @@
* Write content update information.
*/
static int writeUpdateData(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * nsname,
- const HashCode512 * thisId,
- const HashCode512 * nextId,
- const ECRS_FileInfo * fi,
- const TIME_T updateInterval,
- const TIME_T lastPubTime) {
+ struct GC_Configuration * cfg,
+ const char * nsname,
+ const HashCode512 * thisId,
+ const HashCode512 * nextId,
+ const ECRS_FileInfo * fi,
+ const TIME_T updateInterval,
+ const TIME_T lastPubTime) {
char * fn;
char * uri;
size_t metaSize;
@@ -590,7 +590,7 @@
uri = ECRS_uriToString(fi->uri);
metaSize = ECRS_sizeofMetaData(fi->meta,
- ECRS_SERIALIZE_FULL);
+ ECRS_SERIALIZE_FULL);
size = sizeof(struct UpdateData) + metaSize + strlen(uri) + 1;
buf = MALLOC(size);
buf->nextId = *nextId;
@@ -598,30 +598,30 @@
buf->updateInterval = htonl(updateInterval);
buf->lastPubTime = htonl(lastPubTime);
memcpy(&buf[1],
- uri,
- strlen(uri)+1);
+ uri,
+ strlen(uri)+1);
GE_ASSERT(ectx,
- metaSize ==
- ECRS_serializeMetaData(ectx,
- fi->meta,
- &((char*)&buf[1])[strlen(uri)+1],
- metaSize,
- ECRS_SERIALIZE_FULL));
+ metaSize ==
+ ECRS_serializeMetaData(ectx,
+ fi->meta,
+ &((char*)&buf[1])[strlen(uri)+1],
+ metaSize,
+ ECRS_SERIALIZE_FULL));
FREE(uri);
fn = getUpdateDataFilename(ectx,
- cfg,
- nsname,
- thisId);
+ cfg,
+ nsname,
+ thisId);
disk_file_write(ectx,
- fn,
- buf,
- size,
- "400"); /* no editing, just deletion */
+ fn,
+ buf,
+ size,
+ "400"); /* no editing, just deletion */
FREE(fn);
FREE(buf);
return OK;
}
-
+
/**
* Compute the next ID for peridodically updated content.
@@ -630,12 +630,12 @@
* @return OK on success, SYSERR on error
*/
int NS_computeNextId(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * name,
- const HashCode512 * lastId,
- const HashCode512 * thisId,
- TIME_T updateInterval,
- HashCode512 * nextId) {
+ struct GC_Configuration * cfg,
+ const char * name,
+ const HashCode512 * lastId,
+ const HashCode512 * thisId,
+ TIME_T updateInterval,
+ HashCode512 * nextId) {
HashCode512 delta;
cron_t now;
TIME_T tnow;
@@ -647,25 +647,25 @@
return SYSERR;
if (OK != readUpdateData(ectx,
- cfg,
- name,
- lastId,
- NULL,
- NULL,
- &ui,
- &lastTime))
+ cfg,
+ name,
+ lastId,
+ NULL,
+ NULL,
+ &ui,
+ &lastTime))
return SYSERR;
deltaId(lastId,
- thisId,
- &delta);
+ thisId,
+ &delta);
now = get_time();
TIME(&tnow);
*nextId = *thisId;
while (lastTime < tnow + updateInterval/2) {
lastTime += updateInterval;
addHashCodes(nextId,
- &delta,
- nextId);
+ &delta,
+ nextId);
}
return OK;
}
@@ -687,17 +687,17 @@
*/
struct ECRS_URI *
NS_addToNamespace(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- unsigned int anonymityLevel,
- unsigned int insertPriority,
- cron_t insertExpiration,
- const char * name,
- TIME_T updateInterval,
- const HashCode512 * lastId,
- const HashCode512 * thisId,
- const HashCode512 * nextId,
- const struct ECRS_URI * dst,
- const struct ECRS_MetaData * md) {
+ struct GC_Configuration * cfg,
+ unsigned int anonymityLevel,
+ unsigned int insertPriority,
+ cron_t insertExpiration,
+ const char * name,
+ TIME_T updateInterval,
+ const HashCode512 * lastId,
+ const HashCode512 * thisId,
+ const HashCode512 * nextId,
+ const struct ECRS_URI * dst,
+ const struct ECRS_MetaData * md) {
TIME_T creationTime;
HashCode512 nid;
HashCode512 tid;
@@ -714,71 +714,71 @@
creationTime = TIME(&now);
if (updateInterval != ECRS_SBLOCK_UPDATE_NONE) {
if ( (lastId != NULL) &&
- (OK == readUpdateData(ectx,
- cfg,
- name,
- lastId,
- &tid,
- NULL,
- &lastInterval,
- &lastTime)) ) {
+ (OK == readUpdateData(ectx,
+ cfg,
+ name,
+ lastId,
+ &tid,
+ NULL,
+ &lastInterval,
+ &lastTime)) ) {
if (lastInterval != updateInterval) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Publication interval for periodic publication changed."));
+ GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+ _("Publication interval for periodic publication changed."));
}
/* try to compute tid and/or
- nid based on information read from lastId */
+ nid based on information read from lastId */
if (updateInterval != ECRS_SBLOCK_UPDATE_SPORADIC) {
- HashCode512 delta;
+ HashCode512 delta;
- deltaId(lastId,
- &tid,
- &delta);
+ deltaId(lastId,
+ &tid,
+ &delta);
- creationTime = lastTime + updateInterval;
- while (creationTime < now - updateInterval) {
- creationTime += updateInterval;
- addHashCodes(&tid,
- &delta,
- &tid);
- }
- if (creationTime > get_time() + 7 * cronDAYS) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Publishing update for periodically updated "
- "content more than a week ahead of schedule.\n"));
- }
- if (thisId != NULL)
- tid = *thisId; /* allow override! */
- addHashCodes(&tid,
- &delta,
- &nid);
- if (nextId != NULL)
- nid = *nextId; /* again, allow override */
+ creationTime = lastTime + updateInterval;
+ while (creationTime < now - updateInterval) {
+ creationTime += updateInterval;
+ addHashCodes(&tid,
+ &delta,
+ &tid);
+ }
+ if (creationTime > get_time() + 7 * cronDAYS) {
+ GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+ _("Publishing update for periodically updated "
+ "content more than a week ahead of schedule.\n"));
+ }
+ if (thisId != NULL)
+ tid = *thisId; /* allow override! */
+ addHashCodes(&tid,
+ &delta,
+ &nid);
+ if (nextId != NULL)
+ nid = *nextId; /* again, allow override */
} else {
- /* sporadic ones are unpredictable,
- tid has been obtained from IO, pick random nid if
- not specified */
- if (thisId != NULL)
- tid = *thisId; /* allow user override */
- if (nextId == NULL) {
- makeRandomId(&nid);
- } else {
- nid = *nextId;
- }
+ /* sporadic ones are unpredictable,
+ tid has been obtained from IO, pick random nid if
+ not specified */
+ if (thisId != NULL)
+ tid = *thisId; /* allow user override */
+ if (nextId == NULL) {
+ makeRandomId(&nid);
+ } else {
+ nid = *nextId;
+ }
}
} else { /* no previous ID found or given */
if (nextId == NULL) {
- /* no previous block found and nextId not specified;
- pick random nid */
- makeRandomId(&nid);
+ /* no previous block found and nextId not specified;
+ pick random nid */
+ makeRandomId(&nid);
} else {
- nid = *nextId;
+ nid = *nextId;
}
if (thisId != NULL) {
- tid = *thisId;
+ tid = *thisId;
} else {
- makeRandomId(&tid);
+ makeRandomId(&tid);
}
}
} else {
@@ -790,35 +790,35 @@
}
}
uri = ECRS_addToNamespace(ectx,
- cfg,
- name,
- anonymityLevel,
- insertPriority,
- insertExpiration,
- creationTime,
- updateInterval,
- &tid,
- &nid,
- dst,
- md);
+ cfg,
+ name,
+ anonymityLevel,
+ insertPriority,
+ insertExpiration,
+ creationTime,
+ updateInterval,
+ &tid,
+ &nid,
+ dst,
+ md);
if ( (uri != NULL) &&
(dst != NULL) ) {
fi.uri = ECRS_dupUri(dst);
fi.meta = (struct ECRS_MetaData*) md;
writeUpdateData(ectx,
- cfg,
- name,
- &tid,
- &nid,
- &fi,
- updateInterval,
- creationTime);
+ cfg,
+ name,
+ &tid,
+ &nid,
+ &fi,
+ updateInterval,
+ creationTime);
ECRS_freeUri(fi.uri);
if (lastId != NULL) {
old = getUpdateDataFilename(ectx,
- cfg,
- name,
- lastId);
+ cfg,
+ name,
+ lastId);
UNLINK(old);
FREE(old);
}
@@ -836,8 +836,8 @@
};
static int lNCHelper(const char * fil,
- const char * dir,
- void * ptr) {
+ const char * dir,
+ void * ptr) {
struct lNCC * cls = ptr;
ECRS_FileInfo fi;
HashCode512 lastId;
@@ -848,20 +848,20 @@
TIME_T now;
if (OK != enc2hash(fil,
- &lastId)) {
+ &lastId)) {
GE_BREAK(cls->ectx, 0);
return OK;
}
fi.uri = NULL;
fi.meta = NULL;
if (OK != readUpdateData(cls->ectx,
- cls->cfg,
- cls->name,
- &lastId,
- &nextId,
- &fi,
- &pubFreq,
- &lastTime)) {
+ cls->cfg,
+ cls->name,
+ &lastId,
+ &nextId,
+ &fi,
+ &pubFreq,
+ &lastTime)) {
GE_BREAK(cls->ectx, 0);
return OK;
}
@@ -872,16 +872,16 @@
TIME(&now);
nextTime = lastTime;
if ( (nextTime + pubFreq < now) &&
- (nextTime + pubFreq > nextTime) )
+ (nextTime + pubFreq > nextTime) )
nextTime += pubFreq * ((now - nextTime) / pubFreq);
}
if (cls->it != NULL) {
if (OK != cls->it(cls->closure,
- &fi,
- &lastId,
- &nextId,
- pubFreq,
- nextTime)) {
+ &fi,
+ &lastId,
+ &nextId,
+ pubFreq,
+ nextTime)) {
ECRS_freeUri(fi.uri);
ECRS_freeMetaData(fi.meta);
return SYSERR;
@@ -896,10 +896,10 @@
* List all updateable content in a given namespace.
*/
int NS_listNamespaceContent(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * name,
- NS_UpdateIterator iterator,
- void * closure) {
+ struct GC_Configuration * cfg,
+ const char * name,
+ NS_UpdateIterator iterator,
+ void * closure) {
struct lNCC cls;
char * dirName;
@@ -910,14 +910,14 @@
cls.ectx = ectx;
cls.cfg = cfg;
dirName = getUpdateDataFilename(ectx,
- cfg,
- name,
- NULL);
+ cfg,
+ name,
+ NULL);
disk_directory_create(ectx, dirName);
if (SYSERR == disk_directory_scan(ectx,
- dirName,
- &lNCHelper,
- &cls)) {
+ dirName,
+ &lNCHelper,
+ &cls)) {
FREE(dirName);
return SYSERR;
}
@@ -926,12 +926,12 @@
}
static int mergeMeta(EXTRACTOR_KeywordType type,
- const char * data,
- void * cls) {
+ const char * data,
+ void * cls) {
struct ECRS_MetaData * meta = cls;
ECRS_addToMetaData(meta,
- type,
- data);
+ type,
+ data);
return OK;
}
@@ -943,9 +943,9 @@
* @param ns the namespace identifier
*/
void NS_addNamespaceInfo(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const struct ECRS_URI * uri,
- const struct ECRS_MetaData * meta) {
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri,
+ const struct ECRS_MetaData * meta) {
char * name;
int ranking;
struct ECRS_MetaData * old;
@@ -956,7 +956,7 @@
return;
}
ECRS_getNamespaceId(uri,
- &id);
+ &id);
name = ECRS_getNamespaceName(&id);
if (name == NULL) {
GE_BREAK(ectx, 0);
@@ -964,30 +964,30 @@
}
ranking = 0;
if (OK == readNamespaceInfo(ectx,
- cfg,
- name,
- &old,
- &ranking)) {
+ cfg,
+ name,
+ &old,
+ &ranking)) {
ECRS_getMetaData(meta,
- &mergeMeta,
- old);
+ &mergeMeta,
+ old);
writeNamespaceInfo(ectx,
- cfg,
- name,
- old,
- ranking);
+ cfg,
+ name,
+ old,
+ ranking);
ECRS_freeMetaData(old);
} else {
writeNamespaceInfo(ectx,
- cfg,
- name,
- meta,
- ranking);
+ cfg,
+ name,
+ meta,
+ ranking);
}
internal_notify(name,
- &id,
- meta,
- ranking);
+ &id,
+ meta,
+ ranking);
FREE(name);
}
@@ -997,22 +997,22 @@
* @return SYSERR on error, OK on success
*/
int NS_getNamespaceRoot(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * ns,
- HashCode512 * root) {
+ struct GC_Configuration * cfg,
+ const char * ns,
+ HashCode512 * root) {
char * fn;
char * fnBase;
int ret;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &fnBase);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fnBase);
fn = MALLOC(strlen(fnBase) +
- strlen(NS_ROOTS) +
- strlen(ns) +
- 6);
+ strlen(NS_ROOTS) +
+ strlen(ns) +
+ 6);
strcpy(fn, fnBase);
strcat(fn, DIR_SEPARATOR_STR);
strcat(fn, NS_ROOTS);
@@ -1022,9 +1022,9 @@
FREE(fnBase);
if (sizeof(HashCode512)
== disk_file_read(ectx,
- fn,
- sizeof(HashCode512),
- root))
+ fn,
+ sizeof(HashCode512),
+ root))
ret = OK;
else
ret = SYSERR;
@@ -1033,28 +1033,28 @@
}
void NS_setNamespaceRoot(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const struct ECRS_URI * uri) {
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri) {
char * fn;
char * fnBase;
HashCode512 ns;
char * name;
if (OK != ECRS_getNamespaceId(uri,
- &ns)) {
+ &ns)) {
GE_BREAK(ectx, 0);
return;
}
name = ECRS_getNamespaceName(&ns);
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &fnBase);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fnBase);
fn = MALLOC(strlen(fnBase) +
- strlen(NS_ROOTS) +
- strlen(name) +
- 6);
+ strlen(NS_ROOTS) +
+ strlen(name) +
+ 6);
strcpy(fn, fnBase);
strcat(fn, DIR_SEPARATOR_STR);
strcat(fn, NS_ROOTS);
@@ -1064,12 +1064,12 @@
FREE(name);
FREE(fnBase);
if (OK == ECRS_getSKSContentHash(uri,
- &ns)) {
+ &ns)) {
disk_file_write(ectx,
- fn,
- &ns,
- sizeof(HashCode512),
- "644");
+ fn,
+ &ns,
+ sizeof(HashCode512),
+ "644");
}
FREE(fn);
}
@@ -1079,9 +1079,9 @@
* a new namespace.
*/
int NS_registerDiscoveryCallback(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- NS_NamespaceIterator iterator,
- void * closure) {
+ struct GC_Configuration * cfg,
+ NS_NamespaceIterator iterator,
+ void * closure) {
struct DiscoveryCallback * list;
list = MALLOC(sizeof(struct DiscoveryCallback));
@@ -1091,9 +1091,9 @@
list->next = head;
head = list;
NS_listNamespaces(ectx,
- cfg,
- iterator,
- closure);
+ cfg,
+ iterator,
+ closure);
MUTEX_UNLOCK(lock);
return OK;
}
@@ -1102,7 +1102,7 @@
* Unregister namespace discovery callback.
*/
int NS_unregisterDiscoveryCallback(NS_NamespaceIterator iterator,
- void * closure) {
+ void * closure) {
struct DiscoveryCallback * prev;
struct DiscoveryCallback * pos;
@@ -1110,8 +1110,8 @@
MUTEX_LOCK(lock);
pos = head;
while ( (pos != NULL) &&
- ( (pos->callback != iterator) ||
- (pos->closure != closure) ) ) {
+ ( (pos->callback != iterator) ||
+ (pos->closure != closure) ) ) {
prev = pos;
pos = pos->next;
}
Modified: GNUnet/src/applications/fs/namespace/namespace_infotest.c
===================================================================
--- GNUnet/src/applications/fs/namespace/namespace_infotest.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/fs/namespace/namespace_infotest.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -50,77 +50,77 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
daemon = os_daemon_start(NULL,
- cfg,
- "peer.conf",
- NO);
+ cfg,
+ "peer.conf",
+ NO);
GE_ASSERT(NULL, daemon > 0);
CHECK(OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS));
+ cfg,
+ 30 * cronSECONDS));
ok = YES;
NS_deleteNamespace(ectx,
- cfg,
- "test");
+ cfg,
+ "test");
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
old = NS_listNamespaces(ectx,
- cfg,
- NULL,
- NULL);
-
+ cfg,
+ NULL,
+ NULL);
+
meta = ECRS_createMetaData();
ECRS_addToMetaData(meta,
- 0,
- "test");
+ 0,
+ "test");
makeRandomId(&root);
uri = NS_createNamespace(ectx,
- cfg,
- 1,
- 1,
- get_time() + 10 * cronMINUTES,
- "test",
- meta,
- NULL,
- &root);
+ cfg,
+ 1,
+ 1,
+ get_time() + 10 * cronMINUTES,
+ "test",
+ meta,
+ NULL,
+ &root);
CHECK(uri != NULL);
newVal = NS_listNamespaces(ectx,
- cfg,
- NULL,
- NULL);
+ cfg,
+ NULL,
+ NULL);
CHECK(old < newVal);
old = NS_listNamespaceContent(ectx,
- cfg,
- "test",
- NULL,
- NULL);
+ cfg,
+ "test",
+ NULL,
+ NULL);
euri = NS_addToNamespace(ectx,
- cfg,
- 1,
- 1,
- get_time() + 10 * cronMINUTES,
- "test",
- 42,
- NULL,
- &root,
- NULL,
- uri,
- meta);
+ cfg,
+ 1,
+ 1,
+ get_time() + 10 * cronMINUTES,
+ "test",
+ 42,
+ NULL,
+ &root,
+ NULL,
+ uri,
+ meta);
CHECK(euri != NULL);
newVal = NS_listNamespaceContent(ectx,
- cfg,
- "test",
- NULL,
- NULL);
+ cfg,
+ "test",
+ NULL,
+ NULL);
CHECK(old < newVal);
CHECK(OK == NS_deleteNamespace(ectx,
- cfg,
- "test"));
+ cfg,
+ "test"));
/* END OF TEST CODE */
FAILURE:
if (uri != NULL)
@@ -130,8 +130,8 @@
if (meta != NULL)
ECRS_freeMetaData(meta);
ECRS_deleteNamespace(ectx,
- cfg,
- "test");
+ cfg,
+ "test");
GE_ASSERT(NULL, OK == os_daemon_stop(NULL, daemon));
GC_free(cfg);
Modified: GNUnet/src/applications/fs/tools/gnunet-directory.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-directory.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/tools/gnunet-directory.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -43,25 +43,25 @@
static struct GE_Context * ectx;
static int itemPrinter(EXTRACTOR_KeywordType type,
- const char * data,
- void * closure) {
+ const char * data,
+ void * closure) {
printf("\t%20s: %s\n",
- dgettext("libextractor",
- EXTRACTOR_getKeywordTypeAsString(type)),
- data);
+ dgettext("libextractor",
+ EXTRACTOR_getKeywordTypeAsString(type)),
+ data);
return OK;
}
static void printMeta(const struct ECRS_MetaData * meta) {
ECRS_getMetaData(meta,
- &itemPrinter,
- NULL);
+ &itemPrinter,
+ NULL);
}
static int printNode(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * unused) {
+ const HashCode512 * key,
+ int isRoot,
+ void * unused) {
char * string;
string = ECRS_uriToString(fi->uri);
@@ -81,11 +81,11 @@
name = string_expandFileName(ectx, filename);
printf(_("==> Directory `%s':\n"),
- name);
+ name);
if ( (OK != disk_file_size(ectx,
- name,
- &len,
- YES)) ||
+ name,
+ &len,
+ YES)) ||
(len == 0) ) {
printf(_("=\tError reading directory.\n"));
FREE(name);
@@ -93,30 +93,30 @@
}
md = NULL;
fd = disk_file_open(ectx,
- name,
- O_LARGEFILE | O_RDONLY);
+ name,
+ O_LARGEFILE | O_RDONLY);
if (fd == -1) {
ret = -1;
} else {
data = MMAP(NULL,
- len,
- PROT_READ,
- MAP_SHARED,
- fd,
- 0);
+ len,
+ PROT_READ,
+ MAP_SHARED,
+ fd,
+ 0);
if (data == MAP_FAILED) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "mmap",
- name);
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "mmap",
+ name);
ret = -1;
} else {
ret = ECRS_listDirectory(ectx,
- data,
- len,
- &md,
- &printNode,
- NULL);
+ data,
+ len,
+ &md,
+ &printNode,
+ NULL);
MUNMAP(data, len);
}
CLOSE(fd);
@@ -125,7 +125,7 @@
printf(_("File format error (not a GNUnet directory?)\n"));
else
printf(_("%d files found in directory.\n"),
- ret);
+ ret);
if (md != NULL) {
printMeta(md);
ECRS_freeMetaData(md);
@@ -156,28 +156,28 @@
};
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
int i;
struct GC_Configuration * cfg;
i = GNUNET_init(argc,
- argv,
- "gnunet-directory [OPTIONS] [FILENAMES]",
- &cfgFilename,
- gnunetdirectoryOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-directory [OPTIONS] [FILENAMES]",
+ &cfgFilename,
+ gnunetdirectoryOptions,
+ &ectx,
+ &cfg);
if (i == -1) {
GNUNET_fini(ectx, cfg);
return -1;
}
if (do_list)
printf(_("Listed %d matching entries.\n"),
- URITRACK_listURIs(ectx,
- cfg,
- YES,
- &printNode,
- NULL));
+ URITRACK_listURIs(ectx,
+ cfg,
+ YES,
+ &printNode,
+ NULL));
if (do_kill) {
URITRACK_trackURIS(ectx, cfg, NO);
URITRACK_clearTrackedURIS(ectx, cfg);
Modified: GNUnet/src/applications/fs/tools/gnunet-download.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-download.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -95,19 +95,19 @@
* method exits once the download is complete.
*/
static void * progressModel(void * unused,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
MUTEX_LOCK(lock);
switch (event->type) {
case FSUI_download_progress:
if (verbose) {
PRINTF(_("Download of file `%s' at "
- "%16llu out of %16llu bytes (%8.3f KiB/s)\n"),
- event->data.DownloadProgress.filename,
- event->data.DownloadProgress.completed,
- event->data.DownloadProgress.total,
- (event->data.DownloadProgress.completed/1024.0) /
- (((double)(get_time()-(start_time - 1)))
- / (double)cronSECONDS) );
+ "%16llu out of %16llu bytes (%8.3f KiB/s)\n"),
+ event->data.DownloadProgress.filename,
+ event->data.DownloadProgress.completed,
+ event->data.DownloadProgress.total,
+ (event->data.DownloadProgress.completed/1024.0) /
+ (((double)(get_time()-(start_time - 1)))
+ / (double)cronSECONDS) );
}
break;
case FSUI_download_aborted:
@@ -120,17 +120,17 @@
break;
case FSUI_download_error:
printf(_("Error downloading: %s\n"),
- event->data.DownloadError.message);
+ event->data.DownloadError.message);
errorCode = 3;
GNUNET_SHUTDOWN_INITIATE();
break;
case FSUI_download_completed:
PRINTF(_("Download of file `%s' complete. "
- "Speed was %8.3f KiB per second.\n"),
- event->data.DownloadCompleted.filename,
- (event->data.DownloadCompleted.total/1024.0) /
- (((double)(get_time()-(start_time - 1)))
- / (double)cronSECONDS) );
+ "Speed was %8.3f KiB per second.\n"),
+ event->data.DownloadCompleted.filename,
+ (event->data.DownloadCompleted.total/1024.0) /
+ (((double)(get_time()-(start_time - 1)))
+ / (double)cronSECONDS) );
downloads_running--;
if (downloads_running == 0) {
errorCode = 0;
@@ -140,8 +140,8 @@
case FSUI_download_started:
downloads_running++;
APPEND(downloads,
- downloads_size,
- event->data.DownloadStarted.dc.pos);
+ downloads_size,
+ event->data.DownloadStarted.dc.pos);
case FSUI_download_stopped:
break;
default:
@@ -154,24 +154,24 @@
static int
directoryIterator(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * cls) {
+ const HashCode512 * key,
+ int isRoot,
+ void * cls) {
struct FSUI_Context * ctx = cls;
struct ECRS_MetaData * meta;
char * fn;
char * f;
f = ECRS_getFirstFromMetaData(fi->meta,
- EXTRACTOR_FILENAME,
- EXTRACTOR_TITLE,
- EXTRACTOR_ARTIST,
- EXTRACTOR_AUTHOR,
- EXTRACTOR_PUBLISHER,
- EXTRACTOR_CREATOR,
- EXTRACTOR_PRODUCER,
- EXTRACTOR_UNKNOWN,
- -1);
+ EXTRACTOR_FILENAME,
+ EXTRACTOR_TITLE,
+ EXTRACTOR_ARTIST,
+ EXTRACTOR_AUTHOR,
+ EXTRACTOR_PUBLISHER,
+ EXTRACTOR_CREATOR,
+ EXTRACTOR_PRODUCER,
+ EXTRACTOR_UNKNOWN,
+ -1);
if (f == NULL)
f = STRDUP(_("no name given"));
fn = MALLOC(strlen(filename) + strlen(f) + 4);
@@ -180,17 +180,17 @@
strcat(fn, f);
if (verbose > 1)
printf(_("Starting download `%s'\n"),
- f);
+ f);
FREE(f);
meta = ECRS_createMetaData();
FSUI_startDownload(ctx,
- anonymity,
- do_recursive,
- fi->uri,
- meta,
- fn,
- NULL,
- NULL);
+ anonymity,
+ do_recursive,
+ fi->uri,
+ meta,
+ fn,
+ NULL,
+ NULL);
ECRS_freeMetaData(meta);
FREE(fn);
return OK;
@@ -205,7 +205,7 @@
* @return return value from download file: 0: ok, -1, 1: error
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
int ok;
int try_rename;
struct FSUI_Context * ctx;
@@ -214,42 +214,42 @@
int i;
i = GNUNET_init(argc,
- argv,
- "gnunet-download [OPTIONS] URI",
- &cfgFilename,
- gnunetdownloadOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-download [OPTIONS] URI",
+ &cfgFilename,
+ gnunetdownloadOptions,
+ &ectx,
+ &cfg);
if (i == -1) {
errorCode = -1;
goto quit;
}
if (i == argc) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Not enough arguments. "
- "You must specify a GNUnet file URI\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Not enough arguments. "
+ "You must specify a GNUnet file URI\n"));
errorCode = -1;
goto quit;
}
GC_get_configuration_value_number(cfg,
- "GNUNET",
- "VERBOSE",
- 0,
- 9999,
- 0,
- &verbose);
+ "GNUNET",
+ "VERBOSE",
+ 0,
+ 9999,
+ 0,
+ &verbose);
uri = NULL;
if (! do_directory) {
uri = ECRS_stringToUri(ectx,
- argv[i]);
+ argv[i]);
if ( (NULL == uri) ||
- (! (ECRS_isLocationUri(uri) ||
- ECRS_isFileUri(uri)) ) ) {
+ (! (ECRS_isLocationUri(uri) ||
+ ECRS_isFileUri(uri)) ) ) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("URI `%s' invalid for gnunet-download.\n"),
- argv[i]);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("URI `%s' invalid for gnunet-download.\n"),
+ argv[i]);
errorCode = -1;
goto quit;
}
@@ -259,39 +259,39 @@
if (filename == NULL) {
if (do_directory) {
if (NULL != strstr(argv[i], GNUNET_DIRECTORY_EXT)) {
- filename = STRDUP(argv[i]);
- strstr(filename, GNUNET_DIRECTORY_EXT)[0] = '\0';
+ filename = STRDUP(argv[i]);
+ strstr(filename, GNUNET_DIRECTORY_EXT)[0] = '\0';
} else {
- filename = MALLOC(strlen(argv[i]) + strlen(GNUNET_DIRECTORY_EXT) + 2);
- strcpy(filename, argv[i]);
- strcat(filename, DIR_SEPARATOR_STR);
- strcat(filename, GNUNET_DIRECTORY_EXT);
+ filename = MALLOC(strlen(argv[i]) + strlen(GNUNET_DIRECTORY_EXT) + 2);
+ strcpy(filename, argv[i]);
+ strcat(filename, DIR_SEPARATOR_STR);
+ strcat(filename, GNUNET_DIRECTORY_EXT);
}
try_rename = NO;
} else {
GE_ASSERT(ectx,
- strlen(argv[i]) >
- strlen(ECRS_URI_PREFIX) +
- strlen(ECRS_FILE_INFIX));
+ strlen(argv[i]) >
+ strlen(ECRS_URI_PREFIX) +
+ strlen(ECRS_FILE_INFIX));
filename = string_expandFileName(ectx,
- &argv[i][strlen(ECRS_URI_PREFIX)+
- strlen(ECRS_FILE_INFIX)]);
+ &argv[i][strlen(ECRS_URI_PREFIX)+
+ strlen(ECRS_FILE_INFIX)]);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("No filename specified, using `%s' instead (for now).\n"),
- filename);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("No filename specified, using `%s' instead (for now).\n"),
+ filename);
try_rename = YES;
}
}
ok = NO;
lock = MUTEX_CREATE(NO);
ctx = FSUI_start(ectx,
- cfg,
- "gnunet-download",
- parallelism == 0 ? 1 : parallelism,
- NO,
- &progressModel,
- NULL);
+ cfg,
+ "gnunet-download",
+ parallelism == 0 ? 1 : parallelism,
+ NO,
+ &progressModel,
+ NULL);
start_time = get_time();
errorCode = 1;
if (do_directory) {
@@ -305,25 +305,25 @@
efn = string_expandFileName(ectx, argv[i]);
data = NULL;
if ( (0 != STAT(efn,
- &sbuf)) ||
- (! S_ISREG(sbuf.st_mode)) ||
- (0 != ACCESS(efn,
- R_OK)) ||
- (-1 == (fd = disk_file_open(ectx,
- efn,
- O_LARGEFILE | O_RDONLY)) ) ||
- (MAP_FAILED == (data = MMAP(NULL,
- sbuf.st_size,
- PROT_READ,
- MAP_SHARED,
- fd,
- 0))) ) {
+ &sbuf)) ||
+ (! S_ISREG(sbuf.st_mode)) ||
+ (0 != ACCESS(efn,
+ R_OK)) ||
+ (-1 == (fd = disk_file_open(ectx,
+ efn,
+ O_LARGEFILE | O_RDONLY)) ) ||
+ (MAP_FAILED == (data = MMAP(NULL,
+ sbuf.st_size,
+ PROT_READ,
+ MAP_SHARED,
+ fd,
+ 0))) ) {
if (fd != -1)
- CLOSE(fd);
+ CLOSE(fd);
GE_LOG(ectx,
- GE_ERROR | GE_IMMEDIATE | GE_USER,
- _("Could not access gnunet-directory file `%s'\n"),
- efn);
+ GE_ERROR | GE_IMMEDIATE | GE_USER,
+ _("Could not access gnunet-directory file `%s'\n"),
+ efn);
FSUI_stop(ctx);
MUTEX_DESTROY(lock);
FREE(efn);
@@ -331,34 +331,34 @@
}
meta = ECRS_createMetaData();
count = ECRS_listDirectory(ectx,
- data,
- sbuf.st_size,
- &meta,
- &directoryIterator,
- ctx);
+ data,
+ sbuf.st_size,
+ &meta,
+ &directoryIterator,
+ ctx);
ECRS_freeMetaData(meta);
MUNMAP(data, sbuf.st_size);
CLOSE(fd);
FREE(efn);
if (verbose > 0) {
if (count > 0)
- printf(_("Downloading %d files from directory `%s'.\n"),
- count,
- argv[i]);
+ printf(_("Downloading %d files from directory `%s'.\n"),
+ count,
+ argv[i]);
else
- printf(_("Did not find any files in directory `%s'\n"),
- argv[i]);
- }
+ printf(_("Did not find any files in directory `%s'\n"),
+ argv[i]);
+ }
} else {
meta = ECRS_createMetaData();
dl = FSUI_startDownload(ctx,
- anonymity,
- do_recursive,
- uri,
- meta,
- filename,
- NULL,
- NULL);
+ anonymity,
+ do_recursive,
+ uri,
+ meta,
+ filename,
+ NULL,
+ NULL);
ECRS_freeMetaData(meta);
if (dl == NULL) {
FSUI_stop(ctx);
@@ -383,12 +383,12 @@
(dl != NULL) &&
(try_rename == YES) ) {
char * newname = ECRS_suggestFilename(ectx,
- filename);
+ filename);
if (newname != NULL) {
fprintf(stdout,
- _("File stored as `%s'.\n"),
- newname);
+ _("File stored as `%s'.\n"),
+ newname);
FREE(newname);
}
}
Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -37,8 +37,8 @@
/* hmm. Man says time.h, but that doesn't yield the
prototype. Strange... */
extern char *strptime(const char *s,
- const char *format,
- struct tm *tm);
+ const char *format,
+ struct tm *tm);
static int errorCode;
@@ -93,13 +93,13 @@
static int do_disable_creation_time;
static void convertId(const char * s,
- HashCode512 * id) {
+ HashCode512 * id) {
if ( (s != NULL) &&
(enc2hash(s,
- id) == SYSERR) )
+ id) == SYSERR) )
hash(s,
- strlen(s),
- id);
+ strlen(s),
+ id);
}
/**
@@ -119,35 +119,35 @@
convertId(this_id, &thisId);
convertId(prev_id, &prevId);
nsuri = NS_addToNamespace(ectx,
- cfg,
- anonymity,
- priority,
- get_time() + 2 * cronYEARS,
- pseudonym,
- (TIME_T) interval,
- prev_id == NULL ? NULL : &prevId,
- this_id == NULL ? NULL : &thisId,
- next_id == NULL ? NULL : &nextId,
- uri,
- meta);
+ cfg,
+ anonymity,
+ priority,
+ get_time() + 2 * cronYEARS,
+ pseudonym,
+ (TIME_T) interval,
+ prev_id == NULL ? NULL : &prevId,
+ this_id == NULL ? NULL : &thisId,
+ next_id == NULL ? NULL : &nextId,
+ uri,
+ meta);
if (nsuri != NULL) {
us = ECRS_uriToString(nsuri);
ECRS_freeUri(nsuri);
printf(_("Created entry `%s' in namespace `%s'\n"),
- us,
- pseudonym);
+ us,
+ pseudonym);
FREE(us);
} else {
printf(_("Failed to add entry to namespace `%s' (does it exist?)\n"),
- pseudonym);
+ pseudonym);
}
FREE(pseudonym);
pseudonym = NULL;
}
static int listKeywords(const char * fn,
- const char * dir,
- void * cls) {
+ const char * dir,
+ void * cls) {
EXTRACTOR_ExtractorList * l = cls;
char * fullName;
struct stat buf;
@@ -159,41 +159,41 @@
strcat(fullName, DIR_SEPARATOR_STR);
strcat(fullName, fn);
printf(_("Keywords for file `%s':\n"),
- fullName);
+ fullName);
if (0 != STAT(fullName,
- &buf)) {
+ &buf)) {
FREE(fullName);
return OK;
}
if (S_ISDIR(buf.st_mode)) {
printf("%s - %s\n",
- dgettext("libextractor", "filename"),
- fn);
+ dgettext("libextractor", "filename"),
+ fn);
printf("%s - %s\n",
- dgettext("libextractor", "mimetype"),
- "application/gnunet-directory");
+ dgettext("libextractor", "mimetype"),
+ "application/gnunet-directory");
disk_directory_scan(NULL,
- fullName,
- &listKeywords,
- cls);
+ fullName,
+ &listKeywords,
+ cls);
} else {
list = EXTRACTOR_getKeywords(l, fullName);
list = EXTRACTOR_removeDuplicateKeywords(list,
- EXTRACTOR_DUPLICATES_TYPELESS);
+ EXTRACTOR_DUPLICATES_TYPELESS);
EXTRACTOR_printKeywords(stdout,
- list);
+ list);
EXTRACTOR_freeKeywords(list);
}
FREE(fullName);
return OK;
}
-
+
/**
* Print progess message.
*/
static void * printstatus(void * ctx,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
unsigned long long * verboselevel = ctx;
unsigned long long delta;
char * fstring;
@@ -207,14 +207,14 @@
now = get_time();
delta = event->data.UploadProgress.eta - now;
if (event->data.UploadProgress.eta < now)
- delta = 0;
+ delta = 0;
ret = string_get_fancy_time_interval(delta);
PRINTF(_("%16llu of %16llu bytes inserted "
- "(estimating %6s to completion) - %s\n"),
- event->data.UploadProgress.completed,
- event->data.UploadProgress.total,
- ret,
- event->data.UploadProgress.filename);
+ "(estimating %6s to completion) - %s\n"),
+ event->data.UploadProgress.completed,
+ event->data.UploadProgress.total,
+ ret,
+ event->data.UploadProgress.filename);
FREE(ret);
}
break;
@@ -222,19 +222,19 @@
if (*verboselevel) {
delta = get_time() - start_time;
PRINTF(_("Upload of `%s' complete, "
- "%llu bytes took %llu seconds (%8.3f KiB/s).\n"),
- event->data.UploadCompleted.filename,
- event->data.UploadCompleted.total,
- delta / cronSECONDS,
- (delta == 0)
- ? (double) (-1.0)
- : (double) (event->data.UploadCompleted.total
- / 1024.0 * cronSECONDS / delta));
+ "%llu bytes took %llu seconds (%8.3f KiB/s).\n"),
+ event->data.UploadCompleted.filename,
+ event->data.UploadCompleted.total,
+ delta / cronSECONDS,
+ (delta == 0)
+ ? (double) (-1.0)
+ : (double) (event->data.UploadCompleted.total
+ / 1024.0 * cronSECONDS / delta));
}
- fstring = ECRS_uriToString(event->data.UploadCompleted.uri);
+ fstring = ECRS_uriToString(event->data.UploadCompleted.uri);
printf(_("File `%s' has URI: %s\n"),
- event->data.UploadCompleted.filename,
- fstring);
+ event->data.UploadCompleted.filename,
+ fstring);
FREE(fstring);
if (ul == event->data.UploadCompleted.uc.pos) {
postProcess(event->data.UploadCompleted.uri);
@@ -249,7 +249,7 @@
break;
case FSUI_upload_error:
printf(_("\nError uploading file: %s"),
- event->data.UploadError.message);
+ event->data.UploadError.message);
errorCode = 3;
GNUNET_SHUTDOWN_INITIATE();
break;
@@ -258,7 +258,7 @@
break;
default:
printf(_("\nUnexpected event: %d\n"),
- event->type);
+ event->type);
GE_BREAK(ectx, 0);
break;
}
@@ -275,7 +275,7 @@
COMMAND_LINE_OPTION_CFG_FILE(&cfgFilename), /* -c */
{ 'C', "copy", NULL,
gettext_noop("even if gnunetd is running on the local machine, force the"
- " creation of a copy instead of making a link to the GNUnet
share directory"),
+ " creation of a copy instead of making a link to the GNUnet share
directory"),
0, &gnunet_getopt_configure_set_one, &do_copy },
{ 'd', "disable-creation-time", NULL,
gettext_noop("disable adding the creation time to the metadata of the
uploaded file"),
@@ -290,15 +290,15 @@
COMMAND_LINE_OPTION_HOSTNAME, /* -H */
{ 'i', "interval", "SECONDS",
gettext_noop("set interval for availability of updates to SECONDS"
- " (for namespace insertions only)"),
+ " (for namespace insertions only)"),
1, &gnunet_getopt_configure_set_uint, &interval },
{ 'k', "key", "KEYWORD",
gettext_noop("add an additional keyword for the top-level file or
directory"
- " (this option can be specified multiple times)"),
+ " (this option can be specified multiple times)"),
1, &gnunet_getopt_configure_set_keywords, &topKeywords },
{ 'K', "global-key", "KEYWORD",
gettext_noop("add an additional keyword for all files and directories"
- " (this option can be specified multiple times)"),
+ " (this option can be specified multiple times)"),
1, &gnunet_getopt_configure_set_keywords, &gloKeywords },
COMMAND_LINE_OPTION_LOGGING, /* -L */
{ 'm', "meta", "TYPE:VALUE",
@@ -306,11 +306,11 @@
1, &gnunet_getopt_configure_set_metadata, &meta },
{ 'n', "noindex", NULL,
gettext_noop("do not index, perform full insertion (stores entire "
- "file in encrypted form in GNUnet database)"),
+ "file in encrypted form in GNUnet database)"),
0, &gnunet_getopt_configure_set_one, &do_insert },
{ 'N', "next", "ID",
gettext_noop("specify ID of an updated version to be published in the
future"
- " (for namespace insertions only)"),
+ " (for namespace insertions only)"),
1, &gnunet_getopt_configure_set_string, &next_id },
{ 'p', "priority", "PRIORITY",
gettext_noop("specify the priority of the content"),
@@ -320,18 +320,18 @@
1, &gnunet_getopt_configure_set_string, &pseudonym },
{ 'S', "sporadic", NULL,
gettext_noop("specifies this as an aperiodic but updated publication"
- " (for namespace insertions only)"),
+ " (for namespace insertions only)"),
0, &gnunet_getopt_configure_set_one, &is_sporadic },
{ 't', "this", "ID",
gettext_noop("set the ID of this version of the publication"
- " (for namespace insertions only)"),
+ " (for namespace insertions only)"),
1, &gnunet_getopt_configure_set_string, &this_id },
{ 'T', "time", "TIME",
gettext_noop("specify creation time for SBlock (see man-page for format)"),
1, &gnunet_getopt_configure_set_string, &creation_time },
{ 'u', "update", "ID",
gettext_noop("ID of the previous version of the content"
- " (for namespace update only)"),
+ " (for namespace update only)"),
1, &gnunet_getopt_configure_set_string, &prev_id },
COMMAND_LINE_OPTION_VERSION(PACKAGE_VERSION), /* -v */
COMMAND_LINE_OPTION_VERBOSE,
@@ -346,7 +346,7 @@
* @return return 0 for ok, -1 on error
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
const char * filename;
int i;
char * tmp;
@@ -354,12 +354,12 @@
meta = ECRS_createMetaData();
i = GNUNET_init(argc,
- argv,
- "gnunet-insert [OPTIONS] FILENAME",
- &cfgFilename,
- gnunetinsertOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-insert [OPTIONS] FILENAME",
+ &cfgFilename,
+ gnunetinsertOptions,
+ &ectx,
+ &cfg);
if (i == -1) {
errorCode = -1;
goto quit;
@@ -376,32 +376,32 @@
char * ex;
char * dirname;
char * fname;
-
+
l = EXTRACTOR_loadDefaultLibraries();
ex = NULL;
GC_get_configuration_value_string(cfg,
- "FS",
- "EXTRACTORS",
- "",
- &ex);
+ "FS",
+ "EXTRACTORS",
+ "",
+ &ex);
if (strlen(ex) > 0)
l = EXTRACTOR_loadConfigLibraries(l,
- ex);
+ ex);
FREE(ex);
dirname = string_expandFileName(ectx, filename);
GE_ASSERT(ectx, dirname != NULL);
while ( (strlen(dirname) > 0) &&
- (dirname[strlen(dirname)-1] == DIR_SEPARATOR) )
+ (dirname[strlen(dirname)-1] == DIR_SEPARATOR) )
dirname[strlen(dirname)-1] = '\0';
fname = dirname;
while (strstr(fname, DIR_SEPARATOR_STR) != NULL)
fname = strstr(fname, DIR_SEPARATOR_STR) + 1;
GE_ASSERT(ectx,
- fname != dirname);
+ fname != dirname);
fname[-1] = '\0';
listKeywords(fname,
- dirname,
- l);
+ dirname,
+ l);
FREE(dirname);
EXTRACTOR_removeAll(l);
ECRS_freeMetaData(meta);
@@ -412,20 +412,20 @@
GC_get_configuration_value_number(cfg,
- "GNUNET",
- "VERBOSE",
- 0,
- 9999,
- 0,
- &verbose);
+ "GNUNET",
+ "VERBOSE",
+ 0,
+ 9999,
+ 0,
+ &verbose);
/* check arguments */
if (pseudonym != NULL) {
if (OK != ECRS_testNamespaceExists(ectx,
- cfg,
- pseudonym,
- NULL)) {
+ cfg,
+ pseudonym,
+ NULL)) {
printf(_("Could not access namespace `%s' (does not exist?).\n"),
- pseudonym);
+ pseudonym);
errorCode = -1;
goto quit;
}
@@ -439,46 +439,46 @@
fmt = "%Y-%m-%d";
#endif
if ((NULL == strptime(creation_time,
- fmt,
- &t))) {
- GE_LOG_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "strptime");
- printf(_("Parsing time failed. Use `%s' format.\n"),
- fmt);
- errorCode = -1;
- goto quit;
+ fmt,
+ &t))) {
+ GE_LOG_STRERROR(ectx,
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "strptime");
+ printf(_("Parsing time failed. Use `%s' format.\n"),
+ fmt);
+ errorCode = -1;
+ goto quit;
}
}
} else { /* ordinary insertion checks */
if (NULL != next_id) {
fprintf(stderr,
- _("Option `%s' makes no sense without option `%s'.\n"),
- "-N", "-P");
+ _("Option `%s' makes no sense without option `%s'.\n"),
+ "-N", "-P");
errorCode = -1;
goto quit;
}
if (NULL != prev_id) {
fprintf(stderr, _("Option `%s' makes no sense without option `%s'.\n"),
- "-u", "-P");
+ "-u", "-P");
errorCode = -1;
goto quit;
}
if (NULL != this_id) {
fprintf(stderr, _("Option `%s' makes no sense without option `%s'.\n"),
- "-t", "-P");
+ "-t", "-P");
errorCode = -1;
goto quit;
}
if (0 != interval) {
fprintf(stderr, _("Option `%s' makes no sense without option `%s'.\n"),
- "-i", "-P");
+ "-i", "-P");
errorCode = -1;
goto quit;
}
if (is_sporadic) {
fprintf(stderr, _("Option `%s' makes no sense without option `%s'.\n"),
- "-S", "-P");
+ "-S", "-P");
errorCode = -1;
goto quit;
}
@@ -486,12 +486,12 @@
/* fundamental init */
ctx = FSUI_start(ectx,
- cfg,
- "gnunet-insert",
- NO,
- 32, /* make configurable */
- &printstatus,
- &verbose);
+ cfg,
+ "gnunet-insert",
+ NO,
+ 32, /* make configurable */
+ &printstatus,
+ &verbose);
/* first insert all of the top-level files or directories */
tmp = string_expandFileName(ectx, filename);
@@ -500,18 +500,18 @@
start_time = get_time();
errorCode = 1;
ul = FSUI_startUpload(ctx,
- tmp,
- (DirectoryScanCallback) &disk_directory_scan,
- ectx,
- anonymity,
- priority,
- ! do_insert,
- YES,
- ! do_no_direct_references,
- start_time + 2 * cronYEARS,
- meta,
- gloKeywords,
- topKeywords);
+ tmp,
+ (DirectoryScanCallback) &disk_directory_scan,
+ ectx,
+ anonymity,
+ priority,
+ ! do_insert,
+ YES,
+ ! do_no_direct_references,
+ start_time + 2 * cronYEARS,
+ meta,
+ gloKeywords,
+ topKeywords);
if (gloKeywords != NULL)
ECRS_freeUri(gloKeywords);
if (topKeywords != NULL)
Modified: GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -109,40 +109,40 @@
};
static int itemPrinter(EXTRACTOR_KeywordType type,
- const char * data,
- void * closure) {
+ const char * data,
+ void * closure) {
printf("\t%20s: %s\n",
- dgettext("libextractor",
- EXTRACTOR_getKeywordTypeAsString(type)),
- data);
+ dgettext("libextractor",
+ EXTRACTOR_getKeywordTypeAsString(type)),
+ data);
return OK;
}
static void printMeta(const struct ECRS_MetaData * m) {
ECRS_getMetaData(m,
- &itemPrinter,
- NULL);
+ &itemPrinter,
+ NULL);
}
static int namespacePrinter(void * unused,
- const char * namespaceName,
- const HashCode512 * id,
- const struct ECRS_MetaData * md,
- int rating) {
+ const char * namespaceName,
+ const HashCode512 * id,
+ const struct ECRS_MetaData * md,
+ int rating) {
EncName enc;
int cpos;
hash2enc(id,
- &enc);
+ &enc);
if (0 == strcmp(namespaceName, (char*)&enc))
printf(_("Namespace `%s' has rating %d.\n"),
- namespaceName,
- rating);
+ namespaceName,
+ rating);
else
printf(_("Namespace `%s' (%s) has rating %d.\n"),
- namespaceName,
- (char*) &enc,
- rating);
+ namespaceName,
+ (char*) &enc,
+ rating);
printMeta(md);
if (set_rating != NULL) {
@@ -153,30 +153,30 @@
delta = 0;
cpos = 0;
while ( (set[cpos] != '\0') &&
- (set[cpos] != ':') )
+ (set[cpos] != ':') )
cpos++;
if ( ( ( ( (strlen((char*)&enc)+1 == cpos) &&
- (0 == strncmp(set,
- (char*)&enc,
- cpos)) ) ) ||
- ( (namespaceName != NULL) &&
- (strlen(namespaceName) == cpos) &&
- (0 == strncmp(set,
- namespaceName,
- cpos)) ) ) &&
- (set[cpos] == ':') ) {
+ (0 == strncmp(set,
+ (char*)&enc,
+ cpos)) ) ) ||
+ ( (namespaceName != NULL) &&
+ (strlen(namespaceName) == cpos) &&
+ (0 == strncmp(set,
+ namespaceName,
+ cpos)) ) ) &&
+ (set[cpos] == ':') ) {
delta = strtol(&set[cpos+1],
- NULL, /* no error handling yet */
- 10);
+ NULL, /* no error handling yet */
+ 10);
}
if (delta != 0) {
rating = NS_rankNamespace(ectx,
- cfg,
- namespaceName,
- delta);
+ cfg,
+ namespaceName,
+ delta);
printf(_("\tRating (after update): %d\n"),
- rating);
+ rating);
}
}
printf("\n");
@@ -184,7 +184,7 @@
}
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
int cnt;
int success;
int i;
@@ -192,12 +192,12 @@
meta = ECRS_createMetaData();
i = GNUNET_init(argc,
- argv,
- "gnunet-pseudonym [OPTIONS]",
- &cfgFilename,
- gnunetpseudonymOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-pseudonym [OPTIONS]",
+ &cfgFilename,
+ gnunetpseudonymOptions,
+ &ectx,
+ &cfg);
if (i == -1) {
ECRS_freeMetaData(meta);
GNUNET_fini(ectx, cfg);
@@ -217,14 +217,14 @@
/* delete pseudonyms */
if (delete_name != NULL) {
if (OK == NS_deleteNamespace(ectx,
- cfg,
- delete_name)) {
+ cfg,
+ delete_name)) {
printf(_("Pseudonym `%s' deleted.\n"),
- delete_name);
+ delete_name);
} else {
success += 2;
printf(_("Error deleting pseudonym `%s' (does not exist?).\n"),
- delete_name);
+ delete_name);
}
FREE(delete_name);
}
@@ -233,83 +233,83 @@
if (create_name != NULL) {
if (start_collection) {
ECRS_addToMetaData(meta,
- EXTRACTOR_OWNER,
- create_name);
+ EXTRACTOR_OWNER,
+ create_name);
if (OK == CO_startCollection(anonymity,
- priority,
- ECRS_SBLOCK_UPDATE_SPORADIC, /* FIXME: allow
other update policies */
- create_name,
- meta)) {
- printf(_("Started collection `%s'.\n"),
- create_name);
+ priority,
+ ECRS_SBLOCK_UPDATE_SPORADIC, /* FIXME: allow other
update policies */
+ create_name,
+ meta)) {
+ printf(_("Started collection `%s'.\n"),
+ create_name);
} else {
- printf(_("Failed to start collection.\n"));
- success++;
+ printf(_("Failed to start collection.\n"));
+ success++;
}
ECRS_delFromMetaData(meta,
- EXTRACTOR_OWNER,
- create_name);
+ EXTRACTOR_OWNER,
+ create_name);
} else { /* no collection */
HashCode512 rootEntry;
struct ECRS_URI * rootURI;
char * root;
if (root_name == NULL) {
- memset(&rootEntry, 0, sizeof(HashCode512));
+ memset(&rootEntry, 0, sizeof(HashCode512));
} else {
- if (SYSERR == enc2hash(root_name,
- &hc))
- hash(root_name,
- strlen(root_name),
- &hc);
+ if (SYSERR == enc2hash(root_name,
+ &hc))
+ hash(root_name,
+ strlen(root_name),
+ &hc);
}
if (no_advertisement) {
- if (advertisement != NULL)
- ECRS_freeUri(advertisement);
- advertisement = NULL;
+ if (advertisement != NULL)
+ ECRS_freeUri(advertisement);
+ advertisement = NULL;
} else {
- if (advertisement == NULL)
- advertisement = ECRS_parseCharKeywordURI(ectx,
- "namespace");
+ if (advertisement == NULL)
+ advertisement = ECRS_parseCharKeywordURI(ectx,
+ "namespace");
}
rootURI = NS_createNamespace(ectx,
- cfg,
- anonymity,
- priority,
- expiration + get_time(),
- create_name,
- meta,
- advertisement,
- &rootEntry);
+ cfg,
+ anonymity,
+ priority,
+ expiration + get_time(),
+ create_name,
+ meta,
+ advertisement,
+ &rootEntry);
if (rootURI == NULL) {
- printf(_("Could not create namespace `%s' (exists?).\n"),
- create_name);
- success += 1;
+ printf(_("Could not create namespace `%s' (exists?).\n"),
+ create_name);
+ success += 1;
} else {
- root = ECRS_uriToString(rootURI);
- printf(_("Namespace `%s' created (root: %s).\n"),
- create_name,
- root);
- FREE(root);
- ECRS_freeUri(rootURI);
+ root = ECRS_uriToString(rootURI);
+ printf(_("Namespace `%s' created (root: %s).\n"),
+ create_name,
+ root);
+ FREE(root);
+ ECRS_freeUri(rootURI);
}
if (NULL != advertisement)
- ECRS_freeUri(advertisement);
+ ECRS_freeUri(advertisement);
}
FREE(create_name);
create_name = NULL;
} else {
if (start_collection)
printf(_("You must specify a name for the collection (`%s' option).\n"),
- "-C");
+ "-C");
}
if (0 == be_quiet) {
/* print information about pseudonyms */
cnt = NS_listNamespaces(ectx,
- cfg,
- &namespacePrinter,
- NULL);
+ cfg,
+ &namespacePrinter,
+ NULL);
if (cnt == -1)
printf(_("Could not access namespace information.\n"));
}
Modified: GNUnet/src/applications/fs/tools/gnunet-search.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-search.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/tools/gnunet-search.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -53,26 +53,26 @@
static int itemPrinter(EXTRACTOR_KeywordType type,
- const char * data,
- void * closure) {
+ const char * data,
+ void * closure) {
printf("\t%20s: %s\n",
- dgettext("libextractor",
- EXTRACTOR_getKeywordTypeAsString(type)),
- data);
+ dgettext("libextractor",
+ EXTRACTOR_getKeywordTypeAsString(type)),
+ data);
return OK;
}
static void printMeta(const struct ECRS_MetaData * meta) {
ECRS_getMetaData(meta,
- &itemPrinter,
- NULL);
+ &itemPrinter,
+ NULL);
}
/**
* Handle the search result.
*/
static void * eventCallback(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
char * uri;
char * filename;
@@ -92,8 +92,8 @@
case FSUI_search_result:
/* retain URIs for possible directory dump later */
GROW(fis,
- fiCount,
- fiCount+1);
+ fiCount,
+ fiCount+1);
fis[fiCount-1].uri
= ECRS_dupUri(event->data.SearchResult.fi.uri);
fis[fiCount-1].meta
@@ -101,22 +101,22 @@
uri = ECRS_uriToString(event->data.SearchResult.fi.uri);
printf("%s:\n",
- uri);
+ uri);
filename = ECRS_getFromMetaData(event->data.SearchResult.fi.meta,
- EXTRACTOR_FILENAME);
+ EXTRACTOR_FILENAME);
if (filename != NULL) {
char * dotdot;
while (NULL != (dotdot = strstr(filename, "..")))
- dotdot[0] = dotdot[1] = '_';
+ dotdot[0] = dotdot[1] = '_';
printf("gnunet-download -o \"%s\" %s\n",
- filename,
- uri);
+ filename,
+ uri);
}
else
printf("gnunet-download %s\n",
- uri);
+ uri);
printMeta(event->data.SearchResult.fi.meta);
printf("\n");
FREENONNULL(filename);
@@ -165,28 +165,28 @@
* @return return value from gnunet-search: 0: ok, -1: error
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
struct ECRS_URI * uri;
int i;
struct FSUI_Context * ctx;
struct FSUI_SearchList * s;
i = GNUNET_init(argc,
- argv,
- "gnunet-search [OPTIONS] [KEYWORDS]",
- &cfgFilename,
- gnunetsearchOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-search [OPTIONS] [KEYWORDS]",
+ &cfgFilename,
+ gnunetsearchOptions,
+ &ectx,
+ &cfg);
if (i == SYSERR) {
GNUNET_fini(ectx,
- cfg);
+ cfg);
return -1;
}
/* convert args to URI */
uri = ECRS_parseArgvKeywordURI(ectx,
- argc - i,
- (const char**) &argv[i]);
+ argc - i,
+ (const char**) &argv[i]);
if (uri == NULL) {
printf(_("Error converting arguments to URI!\n"));
errorCode = -1;
@@ -195,12 +195,12 @@
if (max_results == 0)
max_results = (unsigned int)-1; /* infty */
ctx = FSUI_start(ectx,
- cfg,
- "gnunet-search",
- 4,
- NO,
- &eventCallback,
- NULL);
+ cfg,
+ "gnunet-search",
+ 4,
+ NO,
+ &eventCallback,
+ NULL);
if (ctx == NULL) {
ECRS_freeUri(uri);
GNUNET_fini(ectx, cfg);
@@ -208,10 +208,10 @@
}
errorCode = 1;
s = FSUI_startSearch(ctx,
- anonymity,
- max_results,
- delay * cronSECONDS,
- uri);
+ anonymity,
+ max_results,
+ delay * cronSECONDS,
+ uri);
ECRS_freeUri(uri);
if (s == NULL) {
errorCode = 2;
@@ -221,9 +221,9 @@
GNUNET_SHUTDOWN_WAITFOR();
if (errorCode == 1)
FSUI_abortSearch(ctx,
- s);
+ s);
FSUI_stopSearch(ctx,
- s);
+ s);
FSUI_stop(ctx);
if (output_filename != NULL) {
@@ -235,18 +235,18 @@
meta = ECRS_createMetaData();
/* ?: anything here to put into meta? */
if (OK == ECRS_createDirectory(ectx,
- &data,
- &n,
- fiCount,
- fis,
- meta)) {
+ &data,
+ &n,
+ fiCount,
+ fis,
+ meta)) {
outfile = string_expandFileName(ectx,
- output_filename);
+ output_filename);
disk_file_write(ectx,
- outfile,
- data,
- n,
- "600");
+ outfile,
+ data,
+ n,
+ "600");
FREE(outfile);
FREE(data);
}
Modified: GNUnet/src/applications/fs/tools/gnunet-unindex.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-unindex.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/tools/gnunet-unindex.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -46,7 +46,7 @@
* Print progess message.
*/
static void * printstatus(void * cls,
- const FSUI_Event * event) {
+ const FSUI_Event * event) {
unsigned long long * verboselevel = cls;
unsigned long long delta;
@@ -55,9 +55,9 @@
if (*verboselevel) {
delta = event->data.UnindexProgress.eta - get_time();
PRINTF(_("%16llu of %16llu bytes unindexed (estimating %llu seconds to
completion) "),
- event->data.UnindexProgress.completed,
- event->data.UnindexProgress.total,
- delta / cronSECONDS);
+ event->data.UnindexProgress.completed,
+ event->data.UnindexProgress.total,
+ delta / cronSECONDS);
printf("\r");
}
break;
@@ -78,7 +78,7 @@
break;
case FSUI_unindex_error:
printf(_("\nError unindexing file: %s\n"),
- event->data.UnindexError.message);
+ event->data.UnindexError.message);
errorCode = 3;
GNUNET_SHUTDOWN_INITIATE();
break;
@@ -113,7 +113,7 @@
* @return return 0 for ok, -1 on error
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
static struct FSUI_Context * ctx;
char * filename;
int i;
@@ -121,49 +121,49 @@
struct FSUI_UnindexList * ul;
i = GNUNET_init(argc,
- argv,
- "gnunet-unindex [OPTIONS] FILENAME",
- &cfgFilename,
- gnunetunindexOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-unindex [OPTIONS] FILENAME",
+ &cfgFilename,
+ gnunetunindexOptions,
+ &ectx,
+ &cfg);
if (i == -1) {
GNUNET_fini(ectx, cfg);
return -1;
}
if (i == argc) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Not enough arguments. "
- "You must specify a filename.\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Not enough arguments. "
+ "You must specify a filename.\n"));
GNUNET_fini(ectx, cfg);
return -1;
}
GC_get_configuration_value_number(cfg,
- "GNUNET",
- "VERBOSE",
- 0,
- 9999,
- 0,
- &verbose);
+ "GNUNET",
+ "VERBOSE",
+ 0,
+ 9999,
+ 0,
+ &verbose);
/* fundamental init */
ctx = FSUI_start(ectx,
- cfg,
- "gnunet-unindex",
- 2,
- NO,
- &printstatus,
- &verbose);
+ cfg,
+ "gnunet-unindex",
+ 2,
+ NO,
+ &printstatus,
+ &verbose);
errorCode = 1;
start_time = get_time();
filename = string_expandFileName(ectx,
- argv[i]);
+ argv[i]);
ul = FSUI_startUnindex(ctx,
- filename);
+ filename);
if (ul == NULL) {
printf(_("`%s' failed. Is `%s' a file?\n"),
- "FSUI_unindex",
- filename);
+ "FSUI_unindex",
+ filename);
errorCode = 2;
} else {
GNUNET_SHUTDOWN_WAITFOR();
Modified: GNUnet/src/applications/fs/uritrack/callbacks.c
===================================================================
--- GNUnet/src/applications/fs/uritrack/callbacks.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/uritrack/callbacks.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -36,7 +36,7 @@
struct GE_Context * ectx;
struct GC_Configuration * cfg;
-
+
ECRS_SearchProgressCallback iterator;
void * closure;
@@ -53,15 +53,15 @@
static unsigned int callbacks_size;
static int init_iterator(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * closure) {
+ const HashCode512 * key,
+ int isRoot,
+ void * closure) {
Callback * c = closure;
c->iterator(fi,
- key,
- isRoot,
- c->closure);
+ key,
+ isRoot,
+ c->closure);
if (c->abort_init)
return SYSERR;
return OK;
@@ -70,10 +70,10 @@
static void * init_thread(void * arg) {
Callback * c = arg;
URITRACK_listURIs(c->ectx,
- c->cfg,
- YES,
- &init_iterator,
- arg);
+ c->cfg,
+ YES,
+ &init_iterator,
+ arg);
return NULL;
}
@@ -84,9 +84,9 @@
* for all existing URIs as well.
*/
int URITRACK_registerTrackCallback(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- ECRS_SearchProgressCallback iterator,
- void * closure) {
+ struct GC_Configuration * cfg,
+ ECRS_SearchProgressCallback iterator,
+ void * closure) {
Callback * c;
c = MALLOC(sizeof(Callback));
@@ -96,8 +96,8 @@
c->closure = closure;
c->abort_init = NO;
c->init = PTHREAD_CREATE(&init_thread,
- c,
- 16 * 1024);
+ c,
+ 16 * 1024);
MUTEX_LOCK(lock);
GROW(callbacks,
callbacks_size,
@@ -111,7 +111,7 @@
* Unregister a URI callback.
*/
int URITRACK_unregisterTrackCallback(ECRS_SearchProgressCallback iterator,
- void * closure) {
+ void * closure) {
int i;
void * unused;
Callback * c;
@@ -120,13 +120,13 @@
for (i=0;i<callbacks_size;i++) {
c = callbacks[i];
if ( (c->iterator == iterator) &&
- (c->closure == closure) ) {
+ (c->closure == closure) ) {
c->abort_init = YES;
PTHREAD_JOIN(c->init, &unused);
callbacks[i] = callbacks[callbacks_size-1];
GROW(callbacks,
- callbacks_size,
- callbacks_size - 1);
+ callbacks_size,
+ callbacks_size - 1);
FREE(c);
MUTEX_UNLOCK(lock);
return OK;
@@ -145,9 +145,9 @@
MUTEX_LOCK(lock);
for (i=0;i<callbacks_size;i++)
callbacks[i]->iterator(fi,
- NULL,
- NO,
- callbacks[i]->closure);
+ NULL,
+ NO,
+ callbacks[i]->closure);
MUTEX_UNLOCK(lock);
}
Modified: GNUnet/src/applications/fs/uritrack/file_info.c
===================================================================
--- GNUnet/src/applications/fs/uritrack/file_info.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/uritrack/file_info.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -40,65 +40,65 @@
static struct IPC_SEMAPHORE *
createIPC(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * basename;
char * ipcName;
struct IPC_SEMAPHORE * sem;
size_t n;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &basename);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &basename);
n = strlen(basename) + 512;
ipcName = MALLOC(n);
SNPRINTF(ipcName, n, "%s/directory_ipc_lock", basename);
FREE(basename);
sem = IPC_SEMAPHORE_CREATE(ectx, ipcName, 1);
FREE(ipcName);
- return sem;
+ return sem;
}
static char *
getUriDbName(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * nw;
char * pfx;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &pfx);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &pfx);
nw = MALLOC(strlen(pfx) + strlen(STATE_NAME) + 2);
strcpy(nw, pfx);
strcat(nw, DIR_SEPARATOR_STR);
strcat(nw, STATE_NAME);
FREE(pfx);
disk_directory_create_for_file(ectx,
- nw);
+ nw);
return nw;
}
static char *
getToggleName(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * nw;
char * pfx;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &pfx);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &pfx);
nw = MALLOC(strlen(pfx) + strlen(TRACK_OPTION) + 2);
strcpy(nw, pfx);
strcat(nw, DIR_SEPARATOR_STR);
strcat(nw, TRACK_OPTION);
FREE(pfx);
disk_directory_create_for_file(ectx,
- nw);
+ nw);
return nw;
}
@@ -108,27 +108,27 @@
* @return YES of tracking is enabled, NO if not
*/
int URITRACK_trackStatus(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
int status;
char * tn;
tn = getToggleName(ectx,
- cfg);
+ cfg);
if (YES != disk_file_test(ectx,
- tn)) {
+ tn)) {
FREE(tn);
return NO; /* default: off */
}
if ( (sizeof(int) != disk_file_read(ectx,
- tn,
- sizeof(int),
- &status)) ||
+ tn,
+ sizeof(int),
+ &status)) ||
(ntohl(status) != YES) ) {
FREE(tn);
#if DEBUG_FILE_INFO
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("Collecting file identifiers disabled.\n"));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("Collecting file identifiers disabled.\n"));
#endif
return NO;
} else {
@@ -143,12 +143,12 @@
};
static int checkPresent(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * closure) {
+ const HashCode512 * key,
+ int isRoot,
+ void * closure) {
struct CheckPresentClosure * cpc = closure;
if (ECRS_equalsUri(fi->uri,
- cpc->fi->uri)) {
+ cpc->fi->uri)) {
cpc->present = 1;
return SYSERR;
}
@@ -159,8 +159,8 @@
* Makes a URI available for directory building.
*/
void URITRACK_trackURI(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const ECRS_FileInfo * fi) {
+ struct GC_Configuration * cfg,
+ const ECRS_FileInfo * fi) {
struct IPC_SEMAPHORE * sem;
char * data;
unsigned int size;
@@ -174,30 +174,30 @@
cpc.present = 0;
cpc.fi = fi;
URITRACK_listURIs(ectx,
- cfg,
- NO,
- &checkPresent,
- &cpc);
+ cfg,
+ NO,
+ &checkPresent,
+ &cpc);
if (cpc.present == 1)
return;
size = ECRS_sizeofMetaData(fi->meta,
- ECRS_SERIALIZE_FULL | ECRS_SERIALIZE_NO_COMPRESS);
+ ECRS_SERIALIZE_FULL | ECRS_SERIALIZE_NO_COMPRESS);
data = MALLOC(size);
GE_ASSERT(ectx,
- size == ECRS_serializeMetaData(ectx,
- fi->meta,
- data,
- size,
- ECRS_SERIALIZE_FULL |
ECRS_SERIALIZE_NO_COMPRESS));
+ size == ECRS_serializeMetaData(ectx,
+ fi->meta,
+ data,
+ size,
+ ECRS_SERIALIZE_FULL |
ECRS_SERIALIZE_NO_COMPRESS));
size = htonl(size);
suri = ECRS_uriToString(fi->uri);
sem = createIPC(ectx, cfg);
IPC_SEMAPHORE_DOWN(sem, YES);
fn = getUriDbName(ectx, cfg);
fh = disk_file_open(ectx,
- fn,
- O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE,
- S_IRUSR|S_IWUSR);
+ fn,
+ O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE,
+ S_IRUSR|S_IWUSR);
if (fh != -1) {
WRITE(fh, suri, strlen(suri) + 1);
WRITE(fh, &size, sizeof(unsigned int));
@@ -217,7 +217,7 @@
* from the tracking database.
*/
void URITRACK_clearTrackedURIS(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
struct IPC_SEMAPHORE * sem;
char * fn;
@@ -225,12 +225,12 @@
IPC_SEMAPHORE_DOWN(sem, YES);
fn = getUriDbName(ectx, cfg);
if (YES == disk_file_test(ectx,
- fn)) {
+ fn)) {
if (0 != UNLINK(fn))
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "unlink",
- fn);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "unlink",
+ fn);
}
FREE(fn);
IPC_SEMAPHORE_UP(sem);
@@ -244,18 +244,18 @@
* disabling tracking
*/
void URITRACK_trackURIS(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- int onOff) {
+ struct GC_Configuration * cfg,
+ int onOff) {
int o = htonl(onOff);
char * tn;
tn = getToggleName(ectx,
- cfg);
+ cfg);
disk_file_write(ectx,
- tn,
- &o,
- sizeof(int),
- "600");
+ tn,
+ &o,
+ sizeof(int),
+ "600");
FREE(tn);
}
@@ -270,10 +270,10 @@
* @return number of entries found
*/
int URITRACK_listURIs(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- int need_metadata,
- ECRS_SearchProgressCallback iterator,
- void *closure) {
+ struct GC_Configuration * cfg,
+ int need_metadata,
+ ECRS_SearchProgressCallback iterator,
+ void *closure) {
struct IPC_SEMAPHORE *sem;
int rval;
char *result;
@@ -297,30 +297,30 @@
return 0; /* no URI db */
}
fd = disk_file_open(ectx,
- fn,
- O_LARGEFILE | O_RDONLY);
+ fn,
+ O_LARGEFILE | O_RDONLY);
if (fd == -1) {
IPC_SEMAPHORE_UP(sem);
IPC_SEMAPHORE_DESTROY(sem);
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "open",
- fn);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "open",
+ fn);
FREE(fn);
return SYSERR; /* error opening URI db */
}
result = MMAP(NULL,
- buf.st_size,
- PROT_READ,
- MAP_SHARED,
- fd,
- 0);
+ buf.st_size,
+ PROT_READ,
+ MAP_SHARED,
+ fd,
+ 0);
if (result == MAP_FAILED) {
CLOSE(fd);
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "mmap",
- fn);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "mmap",
+ fn);
FREE(fn);
IPC_SEMAPHORE_UP(sem);
IPC_SEMAPHORE_DESTROY(sem);
@@ -339,7 +339,7 @@
goto FORMATERROR;
}
fi.uri = ECRS_stringToUri(ectx,
- &result[pos]);
+ &result[pos]);
if(fi.uri == NULL) {
GE_BREAK(ectx, 0);
goto FORMATERROR;
@@ -354,11 +354,11 @@
}
if (need_metadata == YES) {
fi.meta = ECRS_deserializeMetaData(ectx,
- &result[spos], msize);
+ &result[spos], msize);
if(fi.meta == NULL) {
- GE_BREAK(ectx, 0);
- ECRS_freeUri(fi.uri);
- goto FORMATERROR;
+ GE_BREAK(ectx, 0);
+ ECRS_freeUri(fi.uri);
+ goto FORMATERROR;
}
} else {
fi.meta = NULL;
@@ -366,14 +366,14 @@
pos = spos + msize;
if(iterator != NULL) {
if (OK != iterator(&fi, NULL, NO, closure)) {
- if (fi.meta != NULL)
- ECRS_freeMetaData(fi.meta);
+ if (fi.meta != NULL)
+ ECRS_freeMetaData(fi.meta);
ECRS_freeUri(fi.uri);
if (0 != MUNMAP(result, buf.st_size))
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "munmap",
- fn);
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "munmap",
+ fn);
CLOSE(fd);
FREE(fn);
IPC_SEMAPHORE_UP(sem);
@@ -388,9 +388,9 @@
}
if(0 != MUNMAP(result, buf.st_size))
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "munmap",
- fn);
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "munmap",
+ fn);
CLOSE(fd);
FREE(fn);
IPC_SEMAPHORE_UP(sem);
@@ -398,14 +398,14 @@
return rval;
FORMATERROR:
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Deleted corrupt URI database in `%s'."),
- STATE_NAME);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Deleted corrupt URI database in `%s'."),
+ STATE_NAME);
if(0 != MUNMAP(result, buf.st_size))
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "munmap",
- fn);
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "munmap",
+ fn);
CLOSE(fd);
FREE(fn);
IPC_SEMAPHORE_UP(sem);
Modified: GNUnet/src/applications/fs/uritrack/tracktest.c
===================================================================
--- GNUnet/src/applications/fs/uritrack/tracktest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/uritrack/tracktest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -41,24 +41,24 @@
static unsigned int notifications;
static int notified(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * cls) {
+ const HashCode512 * key,
+ int isRoot,
+ void * cls) {
if ( (fi1.meta != NULL) &&
(fi1.uri != NULL) &&
(ECRS_equalsMetaData(fi->meta,
- fi1.meta)) &&
+ fi1.meta)) &&
(ECRS_equalsUri(fi->uri,
- fi1.uri)) ) {
+ fi1.uri)) ) {
notifications++;
return OK;
}
if ( (fi2.meta != NULL) &&
(fi2.uri != NULL) &&
(ECRS_equalsMetaData(fi->meta,
- fi2.meta)) &&
+ fi2.meta)) &&
(ECRS_equalsUri(fi->uri,
- fi2.uri)) ) {
+ fi2.uri)) ) {
notifications++;
return OK;
}
@@ -66,15 +66,15 @@
}
static int processor(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * cls) {
+ const HashCode512 * key,
+ int isRoot,
+ void * cls) {
if ( (fi1.meta != NULL) &&
(fi1.uri != NULL) &&
(ECRS_equalsMetaData(fi->meta,
- fi1.meta)) &&
+ fi1.meta)) &&
(ECRS_equalsUri(fi->uri,
- fi1.uri)) ) {
+ fi1.uri)) ) {
ECRS_freeUri(fi1.uri);
fi1.uri = NULL;
ECRS_freeMetaData(fi1.meta);
@@ -84,9 +84,9 @@
if ( (fi2.meta != NULL) &&
(fi2.uri != NULL) &&
(ECRS_equalsMetaData(fi->meta,
- fi2.meta)) &&
+ fi2.meta)) &&
(ECRS_equalsUri(fi->uri,
- fi2.uri)) ) {
+ fi2.uri)) ) {
ECRS_freeUri(fi2.uri);
fi2.uri = NULL;
ECRS_freeMetaData(fi2.meta);
@@ -108,86 +108,86 @@
fi1.uri = ECRS_keywordsToUri(k1);
fi1.meta = ECRS_createMetaData();
ECRS_addToMetaData(fi1.meta,
- EXTRACTOR_MIMETYPE,
- "foo/bar");
+ EXTRACTOR_MIMETYPE,
+ "foo/bar");
fi2.uri = ECRS_keywordsToUri(k2);
fi2.meta = ECRS_createMetaData();
ECRS_addToMetaData(fi2.meta,
- EXTRACTOR_MIMETYPE,
- "foo/bar");
+ EXTRACTOR_MIMETYPE,
+ "foo/bar");
URITRACK_clearTrackedURIS(NULL,
- cfg);
+ cfg);
URITRACK_registerTrackCallback(NULL,
- cfg,
- ¬ified,
- NULL);
+ cfg,
+ ¬ified,
+ NULL);
URITRACK_trackURIS(NULL,
- cfg,
- NO);
+ cfg,
+ NO);
URITRACK_clearTrackedURIS(NULL,
- cfg);
+ cfg);
/* test non-tracking */
URITRACK_trackURI(NULL,
- cfg,
- &fi1);
+ cfg,
+ &fi1);
CHECK(0 == URITRACK_listURIs(NULL,
- cfg,
- NO,
- NULL,
- NULL));
+ cfg,
+ NO,
+ NULL,
+ NULL));
CHECK(NO == URITRACK_trackStatus(NULL,
- cfg));
+ cfg));
URITRACK_clearTrackedURIS(NULL,
- cfg);
+ cfg);
URITRACK_trackURIS(NULL,
- cfg,
- YES);
+ cfg,
+ YES);
URITRACK_clearTrackedURIS(NULL,
- cfg);
+ cfg);
CHECK(0 == URITRACK_listURIs(NULL,
- cfg,
- NO,
- NULL,
- NULL));
+ cfg,
+ NO,
+ NULL,
+ NULL));
CHECK(YES == URITRACK_trackStatus(NULL,
- cfg));
+ cfg));
URITRACK_trackURI(NULL,
- cfg,
- &fi1);
+ cfg,
+ &fi1);
CHECK(1 == URITRACK_listURIs(NULL,
- cfg,
- NO,
- NULL,
- NULL));
+ cfg,
+ NO,
+ NULL,
+ NULL));
URITRACK_trackURI(NULL,
- cfg,
- &fi2);
+ cfg,
+ &fi2);
CHECK(2 == URITRACK_listURIs(NULL,
- cfg,
- YES,
- &processor,
- NULL));
+ cfg,
+ YES,
+ &processor,
+ NULL));
URITRACK_trackURIS(NULL,
- cfg,
- NO);
+ cfg,
+ NO);
CHECK(NO == URITRACK_trackStatus(NULL,
- cfg));
+ cfg));
URITRACK_clearTrackedURIS(NULL,
- cfg);
+ cfg);
CHECK(notifications == 2);
URITRACK_unregisterTrackCallback(¬ified,
- NULL);
+ NULL);
return 0;
}
int main(int argc,
- char * argv[]) {
+ char * argv[]) {
int failureCount = 0;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
Modified: GNUnet/src/applications/fs/uritrack/uri_info.c
===================================================================
--- GNUnet/src/applications/fs/uritrack/uri_info.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/fs/uritrack/uri_info.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -40,16 +40,16 @@
size_t n;
GC_get_configuration_value_filename(cfg,
- "GNUNET",
- "GNUNET_HOME",
- GNUNET_HOME_DIRECTORY,
- &basename);
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &basename);
n = strlen(basename) + 512;
ipcName = MALLOC(n);
SNPRINTF(ipcName,
- n,
- "%s/uri_info.db",
- basename);
+ n,
+ "%s/uri_info.db",
+ basename);
FREE(basename);
return ipcName;
}
@@ -60,12 +60,12 @@
value = 1024 * 1024;
GC_get_configuration_value_number(cfg,
- "FS",
- "URI_DB_SIZE",
- 1,
- 1024 * 1024 * 1024,
- 1024 * 1024,
- &value);
+ "FS",
+ "URI_DB_SIZE",
+ 1,
+ 1024 * 1024 * 1024,
+ 1024 * 1024,
+ &value);
return value;
}
@@ -80,8 +80,8 @@
*/
enum URITRACK_STATE
URITRACK_getState(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const struct ECRS_URI * uri) {
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri) {
char * s;
int crc;
int fd;
@@ -94,21 +94,21 @@
FREE(s);
s = getDBName(cfg);
if (NO == disk_file_test(ectx,
- s))
- return URITRACK_FRESH;
+ s))
+ return URITRACK_FRESH;
size = getDBSize(cfg);
fd = disk_file_open(ectx,
- s,
- O_RDONLY);
+ s,
+ O_RDONLY);
FREE(s);
if (fd == -1)
return URITRACK_FRESH;
o = 2 * (crc % size);
if (o != lseek(fd, o, SEEK_SET)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- "lseek",
- s);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ "lseek",
+ s);
CLOSE(fd);
return URITRACK_FRESH;
}
@@ -126,9 +126,9 @@
* Add additional information about a given URI's past.
*/
void URITRACK_addState(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const struct ECRS_URI * uri,
- enum URITRACK_STATE state) {
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri,
+ enum URITRACK_STATE state) {
char * s;
int crc;
int fd;
@@ -142,9 +142,9 @@
s = getDBName(cfg);
size = getDBSize(cfg);
fd = disk_file_open(ectx,
- s,
- O_RDWR | O_CREAT,
- S_IRUSR | S_IWUSR);
+ s,
+ O_RDWR | O_CREAT,
+ S_IRUSR | S_IWUSR);
if (fd == -1) {
FREE(s);
return;
@@ -152,9 +152,9 @@
o = 2 * (crc % size);
if (o != lseek(fd, o, SEEK_SET)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- "lseek",
- s);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ "lseek",
+ s);
CLOSE(fd);
FREE(s);
return;
@@ -169,18 +169,18 @@
io[1] |= state;
if (o != lseek(fd, o, SEEK_SET)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- "lseek",
- s);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ "lseek",
+ s);
CLOSE(fd);
FREE(s);
return;
}
if (2 != write(fd, io, 2))
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- "write",
- s);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ "write",
+ s);
disk_file_close(ectx, s, fd);
FREE(s);
}
Modified: GNUnet/src/applications/gap/gap.c
===================================================================
--- GNUnet/src/applications/gap/gap.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/gap/gap.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -214,9 +214,9 @@
*/
static QUERY_POLICY
evaluateQuery(const PeerIdentity * sender,
- unsigned int * priority) {
+ unsigned int * priority) {
unsigned int netLoad = os_network_monitor_get_load(coreAPI->load_monitor,
- Upload);
+ Upload);
if ( (netLoad == (unsigned int) -1) ||
(netLoad < IDLE_LOAD_THRESHOLD) ) {
@@ -243,13 +243,13 @@
}
static void setBit(QueryRecord * qr,
- int bit) {
+ int bit) {
unsigned char theBit = (1 << (bit & 7));
qr->bitmap[bit>>3] |= theBit;
}
static int getBit(const QueryRecord * qr,
- int bit) {
+ int bit) {
unsigned char theBit = (1 << (bit & 7));
return (qr->bitmap[bit>>3] & theBit) > 0;
}
@@ -274,10 +274,10 @@
/* after 10 minutes, always discard everything */
if (pos->lastReplyReceived < TIME(NULL) - 600) {
while (pos->responseList != NULL) {
- rpos = pos->responseList;
- pos->responseList = rpos->next;
- change_pid_rc(rpos->responder, -1);
- FREE(rpos);
+ rpos = pos->responseList;
+ pos->responseList = rpos->next;
+ change_pid_rc(rpos->responder, -1);
+ FREE(rpos);
}
}
/* otherwise, age reply counts */
@@ -285,20 +285,20 @@
rpos = pos->responseList;
while (rpos != NULL) {
if (stats != NULL)
- stats->change(stat_response_count, rpos->responseCount / 2);
+ stats->change(stat_response_count, rpos->responseCount / 2);
rpos->responseCount = rpos->responseCount / 2;
- if (rpos->responseCount == 0) {
- if (rprev == NULL)
- pos->responseList = rpos->next;
- else
- rprev->next = rpos->next;
- change_pid_rc(rpos->responder, -1);
- FREE(rpos);
- if (rprev == NULL)
- rpos = pos->responseList;
- else
- rpos = rprev->next;
- continue;
+ if (rpos->responseCount == 0) {
+ if (rprev == NULL)
+ pos->responseList = rpos->next;
+ else
+ rprev->next = rpos->next;
+ change_pid_rc(rpos->responder, -1);
+ FREE(rpos);
+ if (rprev == NULL)
+ rpos = pos->responseList;
+ else
+ rpos = rprev->next;
+ continue;
}
rprev = rpos;
rpos = rprev->next;
@@ -307,15 +307,15 @@
free pos entry */
if (pos->responseList == NULL) {
if (prev == NULL)
- rtdList = pos->next;
+ rtdList = pos->next;
else
- prev->next = pos->next;
+ prev->next = pos->next;
change_pid_rc(pos->queryOrigin, -1);
FREE(pos);
if (prev == NULL)
- pos = rtdList;
+ pos = rtdList;
else
- pos = prev->next;
+ pos = prev->next;
continue;
}
prev = pos;
@@ -332,7 +332,7 @@
* @param responder peer that send the reply
*/
static void updateResponseData(PID_INDEX origin,
- PID_INDEX responder) {
+ PID_INDEX responder) {
ReplyTrackData * pos;
ReplyTrackData * prev;
ResponseList * rpos;
@@ -367,7 +367,7 @@
if (responder == rpos->responder) {
rpos->responseCount++;
if (stats != NULL)
- stats->change(stat_response_count, 1);
+ stats->change(stat_response_count, 1);
MUTEX_UNLOCK(lock);
return;
}
@@ -407,8 +407,8 @@
*/
static unsigned int
fillInQuery(const PeerIdentity * receiver,
- void * position,
- unsigned int padding) {
+ void * position,
+ unsigned int padding) {
static unsigned int pos = 0;
unsigned int start;
unsigned int delta;
@@ -424,16 +424,16 @@
while (padding - delta > sizeof(P2P_gap_query_MESSAGE)) {
qr = &queries[pos];
if ( (qr->expires > now) &&
- (0 == getBit(qr, getIndex(receiver))) &&
- (receiverId != qr->noTarget) &&
- (! (equalsHashCode512(&receiver->hashPubKey,
- &qr->msg->returnTo.hashPubKey)) ) &&
- (padding - delta >= ntohs(qr->msg->header.size) ) ) {
+ (0 == getBit(qr, getIndex(receiver))) &&
+ (receiverId != qr->noTarget) &&
+ (! (equalsHashCode512(&receiver->hashPubKey,
+ &qr->msg->returnTo.hashPubKey)) ) &&
+ (padding - delta >= ntohs(qr->msg->header.size) ) ) {
setBit(&queries[pos],
- getIndex(receiver));
+ getIndex(receiver));
memcpy(&((char*)position)[delta],
- qr->msg,
- ntohs(qr->msg->header.size));
+ qr->msg,
+ ntohs(qr->msg->header.size));
qr->sendCount++;
delta += ntohs(qr->msg->header.size);
}
@@ -453,7 +453,7 @@
* on each connected node by the core.
*/
static void hotpathSelectionCode(const PeerIdentity * peer,
- void * cls) {
+ void * cls) {
QueryRecord * qr = cls;
ReplyTrackData * pos;
ResponseList * rp;
@@ -480,19 +480,19 @@
rp = pos->responseList;
while (rp != NULL) {
if (rp->responder == id)
- break;
+ break;
rp = rp->next;
}
if (rp != NULL) {
if (rp->responseCount < 0xFFFF)
- ranking = 0x7FFF * rp->responseCount;
+ ranking = 0x7FFF * rp->responseCount;
else
- ranking = 0x7FFFFFF;
+ ranking = 0x7FFFFFF;
}
}
distance
= distanceHashCode512(&qr->msg->queries[0],
- &peer->hashPubKey) >> 10; /* change to value in
[0:63] */
+ &peer->hashPubKey) >> 10; /* change to value in [0:63] */
if (distance <= 0)
distance = 1;
ranking += weak_randomi(1 + 0xFFFF * 10 / (1 + distance)); /* 0 to 20
"response equivalents" for proximity */
@@ -502,21 +502,21 @@
idx = getIndex(peer);
#if DEBUG_GAP
hash2enc(&qr->msg->queries[0],
- &enc);
+ &enc);
((char*)&enc)[6] = '\0';
hash2enc(&peer->hashPubKey,
- &enc2);
+ &enc2);
((char*)&enc2)[6] = '\0';
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Q %s peer %2u (%s) ranks (responses: %2u, distance %4d): %u%s\n",
- &enc,
- idx,
- &enc2,
- rp == NULL ? 0 : rp->responseCount,
- distance,
- ranking,
- id == qr->noTarget ? " (no target)" : "");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Q %s peer %2u (%s) ranks (responses: %2u, distance %4d): %u%s\n",
+ &enc,
+ idx,
+ &enc2,
+ rp == NULL ? 0 : rp->responseCount,
+ distance,
+ ranking,
+ id == qr->noTarget ? " (no target)" : "");
#endif
qr->rankings[idx] = ranking;
change_pid_rc(id, -1);
@@ -528,11 +528,11 @@
*/
static int loadTooHigh() {
return ( (hardCPULimit > 0) &&
- (os_cpu_get_load(ectx,
- coreAPI->cfg) >= hardCPULimit) ) ||
+ (os_cpu_get_load(ectx,
+ coreAPI->cfg) >= hardCPULimit) ) ||
( (hardUpLimit > 0) &&
(os_network_monitor_get_load(coreAPI->load_monitor,
- Upload) >= hardUpLimit) );
+ Upload) >= hardUpLimit) );
}
/**
@@ -540,7 +540,7 @@
* nodes.
*/
static void sendToSelected(const PeerIdentity * peer,
- void * cls) {
+ void * cls) {
const QueryRecord * qr = cls;
PID_INDEX id;
#if DEBUG_GAP
@@ -549,7 +549,7 @@
#endif
if (equalsHashCode512(&peer->hashPubKey,
- &qr->msg->returnTo.hashPubKey))
+ &qr->msg->returnTo.hashPubKey))
return; /* never send back to source */
/* Load above hard limit? */
@@ -565,23 +565,23 @@
if (getBit(qr, getIndex(peer)) == 1) {
#if DEBUG_GAP
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&peer->hashPubKey,
- &encp);
- hash2enc(&qr->msg->queries[0],
- &encq));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&peer->hashPubKey,
+ &encp);
+ hash2enc(&qr->msg->queries[0],
+ &encq));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Sending query `%s' to `%s'\n",
- &encq,
- &encp);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Sending query `%s' to `%s'\n",
+ &encq,
+ &encp);
#endif
if (stats != NULL)
stats->change(stat_routing_forwards, 1);
coreAPI->unicast(peer,
- &qr->msg->header,
- BASE_QUERY_PRIORITY * ntohl(qr->msg->priority) * 2,
- TTL_DECREMENT);
+ &qr->msg->header,
+ BASE_QUERY_PRIORITY * ntohl(qr->msg->priority) * 2,
+ TTL_DECREMENT);
}
change_pid_rc(id, -1);
}
@@ -591,8 +591,8 @@
* (depending on load, queue, etc).
*/
static void forwardQuery(const P2P_gap_query_MESSAGE * msg,
- const PeerIdentity * target,
- const PeerIdentity * excludePeer) {
+ const PeerIdentity * target,
+ const PeerIdentity * excludePeer) {
cron_t now;
QueryRecord * qr;
QueryRecord dummy;
@@ -610,9 +610,9 @@
if (target != NULL) {
/* connect to target host -- if known */
coreAPI->unicast(target,
- NULL,
- ntohl(msg->priority),
- 0);
+ NULL,
+ ntohl(msg->priority),
+ 0);
}
now = get_time();
MUTEX_LOCK(lock);
@@ -628,44 +628,44 @@
if (queries[i].msg == NULL)
continue;
if ( (queries[i].msg->header.size == msg->header.size) &&
- (0 == memcmp(&queries[i].msg->queries[0],
- &msg->queries[0],
- ntohs(msg->header.size)
- - sizeof(P2P_gap_query_MESSAGE)
- + sizeof(HashCode512))) ) {
+ (0 == memcmp(&queries[i].msg->queries[0],
+ &msg->queries[0],
+ ntohs(msg->header.size)
+ - sizeof(P2P_gap_query_MESSAGE)
+ + sizeof(HashCode512))) ) {
/* We have exactly this query pending already.
- Replace existing query! */
+ Replace existing query! */
oldestIndex = i;
if ( (queries[i].expires > now - 4 * TTL_DECREMENT) && /* not long
expired */
- (weak_randomi(4) != 0) ) {
- /* do not clear the bitmap describing which peers we have
- forwarded the query to already; but do this only with high
- probability since we may want to try again if the query is
- retransmitted lots (this can happen if this is the only
- query; we may forward it to all connected peers and get no
- reply. If the initiator keeps retrying, we want to
- eventually forward it again.
+ (weak_randomi(4) != 0) ) {
+ /* do not clear the bitmap describing which peers we have
+ forwarded the query to already; but do this only with high
+ probability since we may want to try again if the query is
+ retransmitted lots (this can happen if this is the only
+ query; we may forward it to all connected peers and get no
+ reply. If the initiator keeps retrying, we want to
+ eventually forward it again.
- Note that the initial probability here (0.6.0/0.6.1) was
- very low (1:64), which is far too low considering that the
- clients do an exponential back-off. The rule is a pure
- optimization, and as such the probability that we
- eventually forward must be significant. 25% seems to work
- better... (extra-note: in small testbeds, the problem
- is bigger than in a larger network where the case that
- a query stays in the QM indefinitely might be much more
+ Note that the initial probability here (0.6.0/0.6.1) was
+ very low (1:64), which is far too low considering that the
+ clients do an exponential back-off. The rule is a pure
+ optimization, and as such the probability that we
+ eventually forward must be significant. 25% seems to work
+ better... (extra-note: in small testbeds, the problem
+ is bigger than in a larger network where the case that
+ a query stays in the QM indefinitely might be much more
rare; so don't just trust a micro-scale benchmark when
trying to figure out an 'optimal' threshold). */
- noclear = YES;
+ noclear = YES;
}
break; /* this is it, do not scan for other
- 'oldest' entries */
+ 'oldest' entries */
}
}
- if (oldestIndex == -1) {
+ if (oldestIndex == -1) {
memset(&dummy,
- 0,
- sizeof(QueryRecord));
+ 0,
+ sizeof(QueryRecord));
qr = &dummy;
} else {
qr = &queries[oldestIndex];
@@ -676,12 +676,12 @@
qr->transmissionCount = 0;
qr->msg = MALLOC(ntohs(msg->header.size));
memcpy(qr->msg,
- msg,
- ntohs(msg->header.size));
+ msg,
+ ntohs(msg->header.size));
if (noclear == NO)
memset(&qr->bitmap[0],
- 0,
- BITMAP_SIZE);
+ 0,
+ BITMAP_SIZE);
if (qr->noTarget != 0)
change_pid_rc(qr->noTarget, -1);
@@ -704,18 +704,18 @@
/* select 4 peers for forwarding */
for (i=0;i<4;i++) {
if (rankingSum == 0)
- break;
+ break;
sel = weak_randomi64(rankingSum);
- pos = 0;
+ pos = 0;
for (j=0;j<8*BITMAP_SIZE;j++) {
- pos += qr->rankings[j];
- if (pos > sel) {
- setBit(qr, j);
- GE_ASSERT(ectx, rankingSum >= qr->rankings[j]);
- rankingSum -= qr->rankings[j];
- qr->rankings[j] = 0;
- break;
- }
+ pos += qr->rankings[j];
+ if (pos > sel) {
+ setBit(qr, j);
+ GE_ASSERT(ectx, rankingSum >= qr->rankings[j]);
+ rankingSum -= qr->rankings[j];
+ qr->rankings[j] = 0;
+ break;
+ }
}
}
}
@@ -752,10 +752,10 @@
qr = &queries[i];
if( qr->msg != NULL ) {
if (equalsHashCode512(query,
- &qr->msg->queries[0])) {
- qr->expires = 0; /* expire NOW! */
- ret = OK;
- break;
+ &qr->msg->queries[0])) {
+ qr->expires = 0; /* expire NOW! */
+ ret = OK;
+ break;
}
}
}
@@ -781,8 +781,8 @@
int i;
for (i=0;i<65536;i++)
if (histogram[i] != 0) {
- printf("%d: %d\n",
- i, histogram[i]);
+ printf("%d: %d\n",
+ i, histogram[i]);
}
}
#endif
@@ -795,7 +795,7 @@
* NULL for the local peer
*/
static int useContent(const PeerIdentity * hostId,
- const MESSAGE_HEADER * pmsg);
+ const MESSAGE_HEADER * pmsg);
/**
* Call useContent "later" and then free the pmsg.
@@ -803,7 +803,7 @@
static void useContentLater(void * data) {
MESSAGE_HEADER * pmsg = data;
useContent(NULL,
- pmsg);
+ pmsg);
FREE(pmsg);
}
@@ -821,8 +821,8 @@
* the type ID).
*/
static int queueReply(const PeerIdentity * sender,
- const HashCode512 * primaryKey,
- const DataContainer * data) {
+ const HashCode512 * primaryKey,
+ const DataContainer * data) {
P2P_gap_reply_MESSAGE * pmsg;
IndirectionTableEntry * ite;
unsigned int size;
@@ -830,13 +830,13 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(primaryKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(primaryKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Gap queues reply to query `%s' for later use.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Gap queues reply to query `%s' for later use.\n",
+ &enc);
#endif
#if EXTRA_CHECKS
@@ -849,23 +849,23 @@
ite = &ROUTING_indTable_[computeRoutingIndex(primaryKey)];
if (! equalsHashCode512(&ite->primaryKey,
- primaryKey) ) {
+ primaryKey) ) {
#if DEBUG_GAP
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "GAP: Dropping reply, routing table has no query associated with it
(anymore)\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "GAP: Dropping reply, routing table has no query associated with it
(anymore)\n");
#endif
return NO; /* we don't care for the reply (anymore) */
}
if (YES == ite->successful_local_lookup_in_delay_loop) {
#if DEBUG_GAP
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "GAP: Dropping reply, found reply locally during delay\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "GAP: Dropping reply, found reply locally during delay\n");
#endif
return NO; /* wow, really bad concurrent DB lookup and processing for
- the same query. Well, at least we should not also
- queue the delayed reply twice... */
+ the same query. Well, at least we should not also
+ queue the delayed reply twice... */
}
size = sizeof(P2P_gap_reply_MESSAGE) + ntohl(data->size) -
sizeof(DataContainer);
if (size >= MAX_BUFFER_SIZE) {
@@ -881,27 +881,27 @@
pmsg->primaryKey
= *primaryKey;
memcpy(&pmsg[1],
- &data[1],
- size - sizeof(P2P_gap_reply_MESSAGE));
+ &data[1],
+ size - sizeof(P2P_gap_reply_MESSAGE));
/* delay reply, delay longer if we are busy (makes it harder
to predict / analyze, too). */
cron_add_job(coreAPI->cron,
- &useContentLater,
- weak_randomi(TTL_DECREMENT),
- 0,
- pmsg);
+ &useContentLater,
+ weak_randomi(TTL_DECREMENT),
+ 0,
+ pmsg);
return YES;
}
static void addReward(const HashCode512 * query,
- unsigned int prio) {
+ unsigned int prio) {
if (prio == 0)
return;
MUTEX_LOCK(lock);
rewards[rewardPos].query = *query;
if (stats != NULL)
stats->change(stat_pending_rewards,
- prio - rewards[rewardPos].prio);
+ prio - rewards[rewardPos].prio);
rewards[rewardPos].prio = prio;
rewardPos++;
if (rewardPos == rewardSize)
@@ -917,11 +917,11 @@
MUTEX_LOCK(lock);
for (i=0;i<rewardSize;i++) {
if (equalsHashCode512(query,
- &rewards[i].query)) {
+ &rewards[i].query)) {
ret += rewards[i].prio;
if (stats != NULL)
- stats->change(stat_pending_rewards,
- - rewards[i].prio);
+ stats->change(stat_pending_rewards,
+ - rewards[i].prio);
rewards[i].prio = 0;
}
}
@@ -939,7 +939,7 @@
static void resetDestinations(IndirectionTableEntry * ite) {
decrement_pid_rcs(ite->destination,
- ite->hostsWaiting);
+ ite->hostsWaiting);
if (stats != NULL)
stats->change(stat_memory_destinations, - ite->hostsWaiting);
GROW(ite->destination,
@@ -961,25 +961,25 @@
* in the queue
*/
static int addToSlot(int mode,
- IndirectionTableEntry * ite,
- const HashCode512 * query,
- int ttl,
- unsigned int priority,
- PID_INDEX sender) {
+ IndirectionTableEntry * ite,
+ const HashCode512 * query,
+ int ttl,
+ unsigned int priority,
+ PID_INDEX sender) {
unsigned int i;
cron_t now;
#if DEBUG__GAP
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "GAP: Queueing query '%s' in slot %p\n",
- &enc,
- ite);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "GAP: Queueing query '%s' in slot %p\n",
+ &enc,
+ ite);
#endif
GE_ASSERT(ectx, sender != 0); /* do NOT add to RT for local clients! */
now = get_time();
@@ -991,14 +991,14 @@
resetSeen(ite);
ite->seenReplyWasUnique = NO;
if (equalsHashCode512(query,
- &ite->primaryKey)) {
+ &ite->primaryKey)) {
ite->ttl = now + ttl;
ite->priority += priority;
for (i=0;i<ite->hostsWaiting;i++)
- if (ite->destination[i] == sender)
- return SYSERR;
+ if (ite->destination[i] == sender)
+ return SYSERR;
if (ite->hostsWaiting >= MAX_HOSTS_WAITING)
- resetDestinations(ite);
+ resetDestinations(ite);
} else {
ite->successful_local_lookup_in_delay_loop = NO;
/* different request, flush pending queues */
@@ -1010,15 +1010,15 @@
}
} else { /* GROW mode */
GE_ASSERT(ectx,
- equalsHashCode512(query,
- &ite->primaryKey));
+ equalsHashCode512(query,
+ &ite->primaryKey));
/* extend lifetime */
if (ite->ttl < now + ttl)
ite->ttl = now + ttl;
ite->priority += priority;
for (i=0;i<ite->hostsWaiting;i++)
if (sender == ite->destination[i])
- return SYSERR; /* already there! */
+ return SYSERR; /* already there! */
}
if (stats != NULL)
stats->change(stat_memory_destinations, 1);
@@ -1060,11 +1060,11 @@
* @return a case ID for debugging
*/
static int needsForwarding(const HashCode512 * query,
- int ttl,
- unsigned int priority,
- PID_INDEX sender,
- int * isRouted,
- int * doForward) {
+ int ttl,
+ unsigned int priority,
+ PID_INDEX sender,
+ int * isRouted,
+ int * doForward) {
IndirectionTableEntry * ite;
cron_t now;
cron_t new_ttl;
@@ -1112,7 +1112,7 @@
resetSeen(ite);
ite->seenReplyWasUnique = NO;
if ( (equal_to_pending) &&
- (YES == ite-> successful_local_lookup_in_delay_loop) ) {
+ (YES == ite-> successful_local_lookup_in_delay_loop) ) {
*isRouted = NO;
*doForward = NO;
addToSlot(ITE_GROW, ite, query, ttl, priority, sender);
@@ -1121,11 +1121,11 @@
*isRouted = YES;
*doForward = YES;
if ( (stats != NULL) &&
- (equal_to_pending) ) {
- stats->change(stat_routing_request_repeat, 1);
- if (ite->ttl != 0) {
- stats->change(stat_routing_request_repeat_dttl, new_ttl - ite->ttl);
- }
+ (equal_to_pending) ) {
+ stats->change(stat_routing_request_repeat, 1);
+ if (ite->ttl != 0) {
+ stats->change(stat_routing_request_repeat_dttl, new_ttl - ite->ttl);
+ }
}
addToSlot(ITE_REPLACE, ite, query, ttl, priority, sender);
return 2;
@@ -1134,49 +1134,49 @@
if (equal_to_pending) {
if (ite->seenIndex == 0) {
if ( (ite->ttl < new_ttl) &&
- (ite->ttl + (cron_t) TTL_DECREMENT < new_ttl) ) {
- /* ttl of new is SIGNIFICANTLY longer? */
- /* query again */
- if (YES == ite->successful_local_lookup_in_delay_loop) {
- *isRouted = NO; /* don't go again, we are already
- processing a local lookup! */
- *doForward = NO;
- addToSlot(ITE_REPLACE, ite, query, ttl, priority, sender);
- return 3;
- } else {
- *isRouted = YES;
- *doForward = YES;
- if (stats != NULL) {
- stats->change(stat_routing_request_repeat, 1);
- if (ite->ttl != 0) {
- stats->change(stat_routing_request_repeat_dttl, new_ttl -
ite->ttl);
- }
- }
- addToSlot(ITE_REPLACE, ite, query, ttl, priority, sender);
- return 4;
- }
+ (ite->ttl + (cron_t) TTL_DECREMENT < new_ttl) ) {
+ /* ttl of new is SIGNIFICANTLY longer? */
+ /* query again */
+ if (YES == ite->successful_local_lookup_in_delay_loop) {
+ *isRouted = NO; /* don't go again, we are already
+ processing a local lookup! */
+ *doForward = NO;
+ addToSlot(ITE_REPLACE, ite, query, ttl, priority, sender);
+ return 3;
+ } else {
+ *isRouted = YES;
+ *doForward = YES;
+ if (stats != NULL) {
+ stats->change(stat_routing_request_repeat, 1);
+ if (ite->ttl != 0) {
+ stats->change(stat_routing_request_repeat_dttl, new_ttl - ite->ttl);
+ }
+ }
+ addToSlot(ITE_REPLACE, ite, query, ttl, priority, sender);
+ return 4;
+ }
} else {
- /* new TTL is lower than the old one, thus
- just wait for the reply that may come back */
- if (OK == addToSlot(ITE_GROW, ite, query, ttl, priority, sender)) {
- if (YES == ite->successful_local_lookup_in_delay_loop) {
- *isRouted = NO;
- /* don't go again, we are already processing a
- local lookup! */
- *doForward = NO;
- return 5;
- } else {
- *isRouted = YES;
- *doForward = NO;
- return 6;
- }
- } else {
- *isRouted = NO; /* same query with _higher_ TTL has already been
- processed FOR THE SAME recipient! Do NOT do
- the lookup *again*. */
- *doForward = NO;
- return 7;
- }
+ /* new TTL is lower than the old one, thus
+ just wait for the reply that may come back */
+ if (OK == addToSlot(ITE_GROW, ite, query, ttl, priority, sender)) {
+ if (YES == ite->successful_local_lookup_in_delay_loop) {
+ *isRouted = NO;
+ /* don't go again, we are already processing a
+ local lookup! */
+ *doForward = NO;
+ return 5;
+ } else {
+ *isRouted = YES;
+ *doForward = NO;
+ return 6;
+ }
+ } else {
+ *isRouted = NO; /* same query with _higher_ TTL has already been
+ processed FOR THE SAME recipient! Do NOT do
+ the lookup *again*. */
+ *doForward = NO;
+ return 7;
+ }
}
}
/* ok, we've seen at least one reply before, replace
@@ -1185,71 +1185,71 @@
/* pending == new! */
if (ite->seenReplyWasUnique) {
if (ite->ttl < new_ttl) { /* ttl of new is longer? */
- /* go again */
- resetSeen(ite);
- ite->seenReplyWasUnique = NO;
- if (YES == ite->successful_local_lookup_in_delay_loop) {
- *isRouted = NO;
- /* don't go again, we are already processing a local lookup! */
- *doForward = NO;
- addToSlot(ITE_REPLACE, ite, query, ttl, priority, sender);
- return 8;
- } else {
- *isRouted = YES;
- /* only forward if new TTL is significantly higher */
- if (ite->ttl + TTL_DECREMENT < new_ttl) {
- *doForward = YES;
- if (stats != NULL) {
- stats->change(stat_routing_request_repeat, 1);
- if (ite->ttl != 0) {
- stats->change(stat_routing_request_repeat_dttl, new_ttl -
ite->ttl);
- }
- }
- } else
- *doForward = NO;
- addToSlot(ITE_REPLACE, ite, query, ttl, priority, sender);
- return 9;
- }
+ /* go again */
+ resetSeen(ite);
+ ite->seenReplyWasUnique = NO;
+ if (YES == ite->successful_local_lookup_in_delay_loop) {
+ *isRouted = NO;
+ /* don't go again, we are already processing a local lookup! */
+ *doForward = NO;
+ addToSlot(ITE_REPLACE, ite, query, ttl, priority, sender);
+ return 8;
+ } else {
+ *isRouted = YES;
+ /* only forward if new TTL is significantly higher */
+ if (ite->ttl + TTL_DECREMENT < new_ttl) {
+ *doForward = YES;
+ if (stats != NULL) {
+ stats->change(stat_routing_request_repeat, 1);
+ if (ite->ttl != 0) {
+ stats->change(stat_routing_request_repeat_dttl, new_ttl - ite->ttl);
+ }
+ }
+ } else
+ *doForward = NO;
+ addToSlot(ITE_REPLACE, ite, query, ttl, priority, sender);
+ return 9;
+ }
} else {
- /* new TTL is lower than the old one, thus
- just wait for the reply that may come back */
- if (OK == addToSlot(ITE_GROW, ite, query, ttl, priority, sender)) {
- if (YES == ite->successful_local_lookup_in_delay_loop) {
- *isRouted = NO;
- *doForward = NO;
- return 10;
- } else {
- *isRouted = YES;
- *doForward = NO;
- return 11;
- }
- } else {
- *isRouted = NO;
- *doForward = NO;
- return 12;
- }
+ /* new TTL is lower than the old one, thus
+ just wait for the reply that may come back */
+ if (OK == addToSlot(ITE_GROW, ite, query, ttl, priority, sender)) {
+ if (YES == ite->successful_local_lookup_in_delay_loop) {
+ *isRouted = NO;
+ *doForward = NO;
+ return 10;
+ } else {
+ *isRouted = YES;
+ *doForward = NO;
+ return 11;
+ }
+ } else {
+ *isRouted = NO;
+ *doForward = NO;
+ return 12;
+ }
}
} else { /* KSK or SKS, multiple results possible! */
/* It's a pending KSK or SKS that can have multiple
- replies. Do not re-send, just forward the
- answers that we get from now on to this additional
- receiver */
+ replies. Do not re-send, just forward the
+ answers that we get from now on to this additional
+ receiver */
int isttlHigher;
if (ite->ttl < new_ttl)
- isttlHigher = NO;
+ isttlHigher = NO;
else
- isttlHigher = YES;
+ isttlHigher = YES;
if (OK == addToSlot(ITE_GROW, ite, query, ttl, priority, sender)) {
- *isRouted = YES;
- *doForward = NO;
- return 13;
+ *isRouted = YES;
+ *doForward = NO;
+ return 13;
} else {
- *isRouted = isttlHigher;
- /* receiver is the same as the one that already got the
- answer, do not bother to do this again, IF
- the TTL is not higher! */
- *doForward = NO;
- return 14;
+ *isRouted = isttlHigher;
+ /* receiver is the same as the one that already got the
+ answer, do not bother to do this again, IF
+ the TTL is not higher! */
+ *doForward = NO;
+ return 14;
}
}
}
@@ -1317,7 +1317,7 @@
* @param msg the message to route
*/
static void sendReply(IndirectionTableEntry * ite,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
unsigned int j;
unsigned int maxDelay;
cron_t now;
@@ -1328,7 +1328,7 @@
if (stats != NULL)
stats->change(stat_routing_successes,
- 1);
+ 1);
now = get_time();
if (now < ite->ttl)
maxDelay = ite->ttl - now;
@@ -1337,23 +1337,23 @@
/* send to peers */
for (j=0;j<ite->hostsWaiting;j++) {
resolve_pid(ite->destination[j],
- &recv);
+ &recv);
#if DEBUG_GAP
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&recv.hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&recv.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "GAP sending reply to `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "GAP sending reply to `%s'\n",
+ &enc);
#endif
coreAPI->unicast(&recv,
- msg,
- BASE_REPLY_PRIORITY *
- (ite->priority+5),
- /* weigh priority */
- maxDelay);
+ msg,
+ BASE_REPLY_PRIORITY *
+ (ite->priority+5),
+ /* weigh priority */
+ maxDelay);
}
}
@@ -1377,8 +1377,8 @@
*/
static int
queryLocalResultCallback(const HashCode512 * primaryKey,
- const DataContainer * value,
- void * closure) {
+ const DataContainer * value,
+ void * closure) {
struct qLRC * cls = closure;
int i;
@@ -1395,8 +1395,8 @@
return OK; /* statistical drop, too many replies to keep in memory */
for (i=0;i<cls->valueCount;i++)
if (0 == memcmp(value,
- cls->values[i],
- ntohl(value->size)))
+ cls->values[i],
+ ntohl(value->size)))
return OK; /* drop, duplicate entry in DB! */
GROW(cls->values,
cls->valueCount,
@@ -1404,8 +1404,8 @@
cls->values[cls->valueCount-1]
= MALLOC(ntohl(value->size));
memcpy(cls->values[cls->valueCount-1],
- value,
- ntohl(value->size));
+ value,
+ ntohl(value->size));
return OK;
}
@@ -1427,11 +1427,11 @@
* SYSERR if not (out of resources)
*/
static int execQuery(const PeerIdentity * sender,
- const PeerIdentity * target,
- unsigned int prio,
- QUERY_POLICY policy,
- int ttl,
- const P2P_gap_query_MESSAGE * query) {
+ const PeerIdentity * target,
+ unsigned int prio,
+ QUERY_POLICY policy,
+ int ttl,
+ const P2P_gap_query_MESSAGE * query) {
IndirectionTableEntry * ite;
int isRouted;
struct qLRC cls;
@@ -1457,27 +1457,27 @@
i = -1;
if (sender != NULL) {
if ( ( (policy & QUERY_ANSWER) > 0) &&
- ( ((policy & QUERY_INDIRECT) > 0) ||
- (bs->fast_get(&query->queries[0])) ) ) {
+ ( ((policy & QUERY_INDIRECT) > 0) ||
+ (bs->fast_get(&query->queries[0])) ) ) {
i = needsForwarding(&query->queries[0],
- ttl,
- prio,
- senderID,
- &isRouted,
- &doForward);
+ ttl,
+ prio,
+ senderID,
+ &isRouted,
+ &doForward);
} else {
isRouted = NO;
doForward = NO;
if (stats != NULL) {
- if ((policy & QUERY_ANSWER) > 0)
- stats->change(stat_routing_no_route_policy, 1);
- else
- stats->change(stat_routing_no_answer_policy, 1);
+ if ((policy & QUERY_ANSWER) > 0)
+ stats->change(stat_routing_no_route_policy, 1);
+ else
+ stats->change(stat_routing_no_answer_policy, 1);
}
}
} else {
addReward(&query->queries[0],
- prio);
+ prio);
isRouted = YES;
doForward = YES;
}
@@ -1486,17 +1486,17 @@
#if DEBUG_GAP
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&query->queries[0],
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&query->queries[0],
+ &enc));
((char*)&enc)[6] = '\0';
GE_LOG(ectx,
- GE_INFO | GE_IMMEDIATE | GE_USER,
- "GAP is executing request for `%s':%s%s (%d)\n",
- &enc,
- doForward ? " forwarding" : "",
- isRouted ? " routing" : "",
- i);
+ GE_INFO | GE_IMMEDIATE | GE_USER,
+ "GAP is executing request for `%s':%s%s (%d)\n",
+ &enc,
+ doForward ? " forwarding" : "",
+ isRouted ? " routing" : "",
+ i);
#endif
if ( (stats != NULL) &&
(isRouted || doForward) )
@@ -1507,19 +1507,19 @@
if ( (isRouted == YES) && /* if we can't route, lookup useless! */
( (policy & QUERY_ANSWER) > 0) ) {
bs->get(bs->closure,
- ntohl(query->type),
- prio,
- 1 + ( ntohs(query->header.size)
- - sizeof(P2P_gap_query_MESSAGE)) / sizeof(HashCode512),
- &query->queries[0],
- &queryLocalResultCallback,
- &cls);
+ ntohl(query->type),
+ prio,
+ 1 + ( ntohs(query->header.size)
+ - sizeof(P2P_gap_query_MESSAGE)) / sizeof(HashCode512),
+ &query->queries[0],
+ &queryLocalResultCallback,
+ &cls);
}
if (cls.valueCount > 0) {
perm = permute(WEAK, cls.valueCount);
max = os_network_monitor_get_load(coreAPI->load_monitor,
- Download);
+ Download);
if (max > 100)
max = 100;
if (max == -1)
@@ -1528,35 +1528,35 @@
max = 1 + (10 - max);
if (max > cls.valueCount)
max = cls.valueCount; /* can't send more back then
- what we have */
+ what we have */
for (i=0;i<cls.valueCount;i++) {
if ( (i == 0) &&
- (SYSERR == bs->put(bs->closure,
- &query->queries[0],
- cls.values[perm[i]],
- ite->priority)) ) {
- GE_BREAK(NULL, 0);
- FREE(cls.values[perm[i]]);
- continue;
+ (SYSERR == bs->put(bs->closure,
+ &query->queries[0],
+ cls.values[perm[i]],
+ ite->priority)) ) {
+ GE_BREAK(NULL, 0);
+ FREE(cls.values[perm[i]]);
+ continue;
}
if ( (i < max) &&
- (sender != NULL) &&
- (YES == queueReply(sender,
- &query->queries[0],
- cls.values[perm[i]])) &&
- (stats != NULL) )
- stats->change(stat_routing_local_results, 1);
+ (sender != NULL) &&
+ (YES == queueReply(sender,
+ &query->queries[0],
+ cls.values[perm[i]])) &&
+ (stats != NULL) )
+ stats->change(stat_routing_local_results, 1);
/* even for local results, always do 'put'
- (at least to give back results to local client &
- to update priority; but only do this for
- the first result */
+ (at least to give back results to local client &
+ to update priority; but only do this for
+ the first result */
if (uri(cls.values[perm[i]],
- ite->type,
- NO, /* no need to verify local results! */
- &query->queries[0]))
- doForward = NO; /* we have the one and only answer,
- do not bother to forward... */
+ ite->type,
+ NO, /* no need to verify local results! */
+ &query->queries[0]))
+ doForward = NO; /* we have the one and only answer,
+ do not bother to forward... */
FREE(cls.values[perm[i]]);
}
FREE(perm);
@@ -1567,8 +1567,8 @@
MUTEX_UNLOCK(lookup_exclusion);
if (doForward)
forwardQuery(query,
- target,
- sender);
+ target,
+ sender);
change_pid_rc(senderID, -1);
return doForward;
}
@@ -1588,7 +1588,7 @@
* priority of the original request)
*/
static int useContent(const PeerIdentity * host,
- const MESSAGE_HEADER * pmsg) {
+ const MESSAGE_HEADER * pmsg) {
const P2P_gap_reply_MESSAGE * msg;
unsigned int i;
HashCode512 contentHC;
@@ -1611,20 +1611,20 @@
msg = (const P2P_gap_reply_MESSAGE *) pmsg;
#if DEBUG_GAP
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- if (host != NULL)
- hash2enc(&host->hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ if (host != NULL)
+ hash2enc(&host->hashPubKey,
+ &enc));
hash2enc(&msg->primaryKey,
- &enc2);
+ &enc2);
((char*)&enc2)[6] = '\0';
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "GAP received content `%s' from `%s'\n",
- &enc2,
- (host != NULL) ? (const char*)&enc : "myself");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "GAP received content `%s' from `%s'\n",
+ &enc2,
+ (host != NULL) ? (const char*)&enc : "myself");
#endif
-
+
ite = &ROUTING_indTable_[computeRoutingIndex(&msg->primaryKey)];
ite->successful_local_lookup_in_delay_loop = NO;
size = ntohs(msg->header.size) - sizeof(P2P_gap_reply_MESSAGE);
@@ -1638,28 +1638,28 @@
value = MALLOC(size + sizeof(DataContainer));
value->size = htonl(size + sizeof(DataContainer));
memcpy(&value[1],
- &msg[1],
- size);
+ &msg[1],
+ size);
rhf(value,
&contentHC);
/* FIRST: check if valid */
ret = bs->put(bs->closure,
- &msg->primaryKey,
- value,
- 0);
+ &msg->primaryKey,
+ value,
+ 0);
if (ret == SYSERR) {
EncName enc;
IF_GELOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- if (host != NULL)
- hash2enc(&host->hashPubKey,
- &enc));
+ GE_ERROR | GE_BULK | GE_USER,
+ if (host != NULL)
+ hash2enc(&host->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("GAP received invalid content from `%s'\n"),
- (host != NULL) ? (const char*)&enc : _("myself"));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("GAP received invalid content from `%s'\n"),
+ (host != NULL) ? (const char*)&enc : _("myself"));
GE_BREAK_OP(ectx, 0);
FREE(value);
return SYSERR; /* invalid */
@@ -1669,11 +1669,11 @@
MUTEX_LOCK(lookup_exclusion);
for (i=0;i<ite->seenIndex;i++) {
if (equalsHashCode512(&contentHC,
- &ite->seen[i])) {
+ &ite->seen[i])) {
MUTEX_UNLOCK(lookup_exclusion);
FREE(value);
if (stats != NULL)
- stats->change(stat_routing_reply_dups, 1);
+ stats->change(stat_routing_reply_dups, 1);
return 0; /* seen before, useless */
}
}
@@ -1685,52 +1685,52 @@
hostId = intern_pid(host);
MUTEX_LOCK(lookup_exclusion);
if (equalsHashCode512(&ite->primaryKey,
- &msg->primaryKey) ) {
+ &msg->primaryKey) ) {
prio = ite->priority;
ite->priority = 0;
/* remove the sender from the waiting list
(if the sender was waiting for a response) */
if (host != NULL) {
for (i=0;i<ite->hostsWaiting;i++) {
- if (hostId == ite->destination[i]) {
- change_pid_rc(ite->destination[i], -1);
- ite->destination[i] = ite->destination[ite->hostsWaiting-1];
- if (stats != NULL)
- stats->change(stat_memory_destinations, - 1);
- GROW(ite->destination,
- ite->hostsWaiting,
- ite->hostsWaiting - 1);
- }
+ if (hostId == ite->destination[i]) {
+ change_pid_rc(ite->destination[i], -1);
+ ite->destination[i] = ite->destination[ite->hostsWaiting-1];
+ if (stats != NULL)
+ stats->change(stat_memory_destinations, - 1);
+ GROW(ite->destination,
+ ite->hostsWaiting,
+ ite->hostsWaiting - 1);
+ }
}
}
if (stats != NULL)
stats->change(stat_memory_seen, 1);
GROW(ite->seen,
- ite->seenIndex,
- ite->seenIndex+1);
+ ite->seenIndex,
+ ite->seenIndex+1);
ite->seen[ite->seenIndex-1] = contentHC;
if (ite->seenIndex == 1) {
ite->seenReplyWasUnique
- = uri(value,
- ite->type,
- NO, /* already verified */
- &ite->primaryKey);
+ = uri(value,
+ ite->type,
+ NO, /* already verified */
+ &ite->primaryKey);
} else {
ite->seenReplyWasUnique = NO;
}
sendReply(ite,
- &msg->header);
+ &msg->header);
if (ite->seenIndex > MAX_SEEN_VALUES * 2) {
/* kill routing entry -- we have seen so many different
- replies already that we cannot afford to continue
- to keep track of all of the responses seen (#1014) */
+ replies already that we cannot afford to continue
+ to keep track of all of the responses seen (#1014) */
resetDestinations(ite);
resetSeen(ite);
ite->priority = 0;
ite->type = 0;
ite->ttl = 0;
if (stats != NULL)
- stats->change(stat_routing_slots_used, -1);
+ stats->change(stat_routing_slots_used, -1);
}
} else {
if (stats != NULL)
@@ -1742,16 +1742,16 @@
/* FOURTH: update content priority in local datastore */
if (prio > 0) {
bs->put(bs->closure,
- &msg->primaryKey,
- value,
- prio);
+ &msg->primaryKey,
+ value,
+ prio);
}
/* FIFTH: if unique reply, stop querying */
if (uri(value,
- ite->type,
- NO, /* already verified */
- &ite->primaryKey)) {
+ ite->type,
+ NO, /* already verified */
+ &ite->primaryKey)) {
/* unique reply, stop forwarding! */
dequeueQuery(&ite->primaryKey);
}
@@ -1761,14 +1761,14 @@
if (host != NULL) { /* if we are the sender, hostId will be NULL */
preference = (double) prio;
identity->changeHostTrust(host,
- prio);
+ prio);
for (i=0;i<ite->hostsWaiting;i++)
updateResponseData(ite->destination[i],
- hostId);
+ hostId);
if (preference < CONTENT_BANDWIDTH_VALUE)
preference = CONTENT_BANDWIDTH_VALUE;
coreAPI->preferTrafficFrom(host,
- preference);
+ preference);
}
change_pid_rc(hostId, -1);
return OK;
@@ -1783,8 +1783,8 @@
* @return SYSERR on error, OK on success
*/
static int init(Blockstore * datastore,
- UniqueReplyIdentifier uid,
- ReplyHashFunction rh) {
+ UniqueReplyIdentifier uid,
+ ReplyHashFunction rh) {
if (bs != NULL) {
GE_BREAK(ectx, 0);
return SYSERR;
@@ -1813,12 +1813,12 @@
* returned the one and only reply (local hit)
*/
static int get_start(const PeerIdentity * target,
- unsigned int type,
- unsigned int anonymityLevel,
- unsigned int keyCount,
- const HashCode512 * keys,
- cron_t timeout,
- unsigned int prio) {
+ unsigned int type,
+ unsigned int anonymityLevel,
+ unsigned int keyCount,
+ const HashCode512 * keys,
+ cron_t timeout,
+ unsigned int prio) {
P2P_gap_query_MESSAGE * msg;
unsigned int size;
int ret;
@@ -1840,41 +1840,41 @@
anonymityLevel--;
if (traffic == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Cover traffic requested but traffic service not loaded.
Rejecting request.\n"));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Cover traffic requested but traffic service not loaded. Rejecting
request.\n"));
return SYSERR;
}
if (OK != traffic->get((TTL_DECREMENT + timeout) / TRAFFIC_TIME_UNIT,
- P2P_PROTO_gap_QUERY,
- TC_RECEIVED,
- &count,
- &peers,
- &sizes,
- &timevect)) {
+ P2P_PROTO_gap_QUERY,
+ TC_RECEIVED,
+ &count,
+ &peers,
+ &sizes,
+ &timevect)) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Failed to get traffic stats.\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Failed to get traffic stats.\n"));
return SYSERR;
}
if (anonymityLevel > 1000) {
if (peers < anonymityLevel / 1000) {
- GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Cannot satisfy desired level of anonymity, ignoring
request.\n"));
- return SYSERR;
+ GE_LOG(ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Cannot satisfy desired level of anonymity, ignoring request.\n"));
+ return SYSERR;
}
if (count < anonymityLevel % 1000) {
- GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Cannot satisfy desired level of anonymity, ignoring
request.\n"));
- return SYSERR;
+ GE_LOG(ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Cannot satisfy desired level of anonymity, ignoring request.\n"));
+ return SYSERR;
}
} else {
if (count < anonymityLevel) {
- GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Cannot satisfy desired level of anonymity, ignoring
request.\n"));
- return SYSERR;
+ GE_LOG(ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Cannot satisfy desired level of anonymity, ignoring request.\n"));
+ return SYSERR;
}
}
}
@@ -1891,18 +1891,18 @@
= htonl(prio);
msg->ttl
= htonl(adjustTTL((int)timeout - get_time(),
- prio));
+ prio));
memcpy(&msg->queries[0],
- keys,
- sizeof(HashCode512) * keyCount);
+ keys,
+ sizeof(HashCode512) * keyCount);
msg->returnTo
= *coreAPI->myIdentity;
ret = execQuery(NULL,
- target,
- prio,
- QUERY_ANSWER|QUERY_FORWARD|QUERY_INDIRECT,
- timeout - get_time(),
- msg);
+ target,
+ prio,
+ QUERY_ANSWER|QUERY_FORWARD|QUERY_INDIRECT,
+ timeout - get_time(),
+ msg);
FREE(msg);
return ret;
}
@@ -1913,8 +1913,8 @@
* stop it earlier.
*/
static int get_stop(unsigned int type,
- unsigned int keyCount,
- const HashCode512 * keys) {
+ unsigned int keyCount,
+ const HashCode512 * keys) {
if (keyCount < 1)
return SYSERR;
return dequeueQuery(&keys[0]);
@@ -1931,9 +1931,9 @@
*/
static unsigned int
tryMigrate(const DataContainer * data,
- const HashCode512 * primaryKey,
- char * position,
- unsigned int padding) {
+ const HashCode512 * primaryKey,
+ char * position,
+ unsigned int padding) {
P2P_gap_reply_MESSAGE * reply;
unsigned int size;
@@ -1949,8 +1949,8 @@
reply->primaryKey
= *primaryKey;
memcpy(&reply[1],
- &data[1],
- size - sizeof(P2P_gap_reply_MESSAGE));
+ &data[1],
+ size - sizeof(P2P_gap_reply_MESSAGE));
return size;
}
@@ -1959,7 +1959,7 @@
* lookup, forward or even indirect.
*/
static int handleQuery(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
QUERY_POLICY policy;
P2P_gap_query_MESSAGE * qmsg;
unsigned int queries;
@@ -1979,14 +1979,14 @@
#if DEBUG_GAP
if (sender != NULL) {
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&sender->hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&sender->hashPubKey,
+ &enc));
}
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Dropping query from %s, this peer is too busy.\n",
- sender == NULL ? "localhost" : (char*)&enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Dropping query from %s, this peer is too busy.\n",
+ sender == NULL ? "localhost" : (char*)&enc);
#endif
return OK;
}
@@ -1995,7 +1995,7 @@
if ( (queries <= 0) ||
(ntohs(msg->size) < sizeof(P2P_gap_query_MESSAGE)) ||
(ntohs(msg->size) != sizeof(P2P_gap_query_MESSAGE) +
- (queries-1) * sizeof(HashCode512)) ) {
+ (queries-1) * sizeof(HashCode512)) ) {
GE_BREAK_OP(ectx, 0);
return SYSERR; /* malformed query */
}
@@ -2003,7 +2003,7 @@
qmsg = MALLOC(ntohs(msg->size));
memcpy(qmsg, msg, ntohs(msg->size));
if (equalsHashCode512(&qmsg->returnTo.hashPubKey,
- &coreAPI->myIdentity->hashPubKey)) {
+ &coreAPI->myIdentity->hashPubKey)) {
/* A to B, B sends to C without source rewriting,
C sends back to A again without source rewriting;
(or B directly back to A; also should not happen)
@@ -2023,7 +2023,7 @@
if (ttl > 0) { /* integer underflow => drop (should be very rare)! */
FREE(qmsg);
if (stats != NULL)
- stats->change(stat_routing_direct_drops, 1);
+ stats->change(stat_routing_direct_drops, 1);
return OK; /* just abort */
}
} else {
@@ -2031,16 +2031,16 @@
}
prio = ntohl(qmsg->priority);
policy = evaluateQuery(sender,
- &prio);
+ &prio);
#if DEBUG_GAP
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&qmsg->queries[0],
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&qmsg->queries[0],
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received GAP query `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received GAP query `%s'.\n",
+ &enc);
#endif
if ((policy & QUERY_DROPMASK) == 0) {
/* policy says no answer/forward/indirect => direct drop;
@@ -2049,13 +2049,13 @@
#if DEBUG_GAP
if (sender != NULL) {
IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&sender->hashPubKey,
- &enc));
+ hash2enc(&sender->hashPubKey,
+ &enc));
}
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Dropping query from %s, policy decided that this peer is too
busy.\n",
- sender == NULL ? "localhost" : (const char*) &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Dropping query from %s, policy decided that this peer is too busy.\n",
+ sender == NULL ? "localhost" : (const char*) &enc);
#endif
if (stats != NULL)
stats->change(stat_routing_direct_drops, 1);
@@ -2074,7 +2074,7 @@
if (preference < QUERY_BANDWIDTH_VALUE)
preference = QUERY_BANDWIDTH_VALUE;
coreAPI->preferTrafficFrom(sender,
- preference);
+ preference);
/* adjust priority */
qmsg->priority
= htonl(prio);
@@ -2084,12 +2084,12 @@
ttl = ntohl(qmsg->ttl);
if (ttl < 0)
ttl = 0;
- execQuery(sender,
- NULL,
- prio,
- policy,
- ttl,
- qmsg);
+ execQuery(sender,
+ NULL,
+ prio,
+ policy,
+ ttl,
+ qmsg);
FREE(qmsg);
return OK;
}
@@ -2105,7 +2105,7 @@
for (i=indirectionTableSize-1;i>=0;i--) {
ite = &ROUTING_indTable_[i];
if ( (ite->hostsWaiting > 0) &&
- (ite->seenIndex == 0) ) {
+ (ite->seenIndex == 0) ) {
tot += ite->priority;
active++;
}
@@ -2126,26 +2126,26 @@
cfg = capi->cfg;
coreAPI = capi;
if ( (-1 == GC_get_configuration_value_number(cfg,
- "LOAD",
- "HARDCPULIMIT",
- 0,
- 100000, /* 1000 CPUs!? */
- 0, /* 0 == no limit */
- &hardCPULimit)) ||
+ "LOAD",
+ "HARDCPULIMIT",
+ 0,
+ 100000, /* 1000 CPUs!? */
+ 0, /* 0 == no limit */
+ &hardCPULimit)) ||
(-1 == GC_get_configuration_value_number(cfg,
- "LOAD",
- "HARDUPLIMIT",
- 0,
- 999999999,
- 0, /* 0 == no limit */
- &hardUpLimit)) ||
+ "LOAD",
+ "HARDUPLIMIT",
+ 0,
+ 999999999,
+ 0, /* 0 == no limit */
+ &hardUpLimit)) ||
(-1 == GC_get_configuration_value_number(cfg,
- "GAP",
- "TABLESIZE",
- MIN_INDIRECTION_TABLE_SIZE,
- MAX_MALLOC_CHECKED /
sizeof(IndirectionTableEntry),
- MIN_INDIRECTION_TABLE_SIZE,
- &indirectionTableSize)) )
+ "GAP",
+ "TABLESIZE",
+ MIN_INDIRECTION_TABLE_SIZE,
+ MAX_MALLOC_CHECKED /
sizeof(IndirectionTableEntry),
+ MIN_INDIRECTION_TABLE_SIZE,
+ &indirectionTableSize)) )
return NULL;
GE_ASSERT(ectx, sizeof(P2P_gap_reply_MESSAGE) == 68);
GE_ASSERT(ectx, sizeof(P2P_gap_query_MESSAGE) == 144);
@@ -2173,7 +2173,7 @@
stat_response_count = stats->create(gettext_noop("# gap
response weights"));
}
init_pid_table(ectx,
- stats);
+ stats);
GROW(rewards,
rewardSize,
MAX_REWARD_TRACKS);
@@ -2186,17 +2186,17 @@
traffic = coreAPI->requestService("traffic");
if (traffic == NULL) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Traffic service failed to load; gap cannot ensure cover-traffic
availability.\n"));
+ _("Traffic service failed to load; gap cannot ensure cover-traffic
availability.\n"));
}
random_qsel = weak_randomi(0xFFFF);
lookup_exclusion = MUTEX_CREATE(NO);
ROUTING_indTable_
= MALLOC(sizeof(IndirectionTableEntry)
- * indirectionTableSize);
+ * indirectionTableSize);
memset(ROUTING_indTable_,
- 0,
- sizeof(IndirectionTableEntry)
- * indirectionTableSize);
+ 0,
+ sizeof(IndirectionTableEntry)
+ * indirectionTableSize);
for (i=0;i<indirectionTableSize;i++) {
ROUTING_indTable_[i].successful_local_lookup_in_delay_loop = NO;
}
@@ -2207,23 +2207,23 @@
}
lock = coreAPI->getConnectionModuleLock();
cron_add_job(capi->cron,
- &ageRTD,
- 2 * cronMINUTES,
- 2 * cronMINUTES,
- NULL);
+ &ageRTD,
+ 2 * cronMINUTES,
+ 2 * cronMINUTES,
+ NULL);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("`%s' registering handlers %d %d\n"),
- "gap",
- P2P_PROTO_gap_QUERY,
- P2P_PROTO_gap_RESULT);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("`%s' registering handlers %d %d\n"),
+ "gap",
+ P2P_PROTO_gap_QUERY,
+ P2P_PROTO_gap_RESULT);
capi->registerHandler(P2P_PROTO_gap_QUERY,
- &handleQuery);
+ &handleQuery);
capi->registerHandler(P2P_PROTO_gap_RESULT,
- &useContent);
+ &useContent);
coreAPI->registerSendCallback(sizeof(P2P_gap_query_MESSAGE),
- &fillInQuery);
+ &fillInQuery);
api.init = &init;
api.get_start = &get_start;
@@ -2240,16 +2240,16 @@
IndirectionTableEntry * ite;
coreAPI->unregisterHandler(P2P_PROTO_gap_QUERY,
- &handleQuery);
+ &handleQuery);
coreAPI->unregisterHandler(P2P_PROTO_gap_RESULT,
- &useContent);
+ &useContent);
coreAPI->unregisterSendCallback(sizeof(P2P_gap_query_MESSAGE),
- &fillInQuery);
+ &fillInQuery);
cron_del_job(coreAPI->cron,
- &ageRTD,
- 2 * cronMINUTES,
- NULL);
+ &ageRTD,
+ 2 * cronMINUTES,
+ NULL);
for (i=0;i<indirectionTableSize;i++) {
ite = &ROUTING_indTable_[i];
Modified: GNUnet/src/applications/gap/gaptest.c
===================================================================
--- GNUnet/src/applications/gap/gaptest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/gap/gaptest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -44,22 +44,22 @@
static void uprogress(unsigned long long totalBytes,
- unsigned long long completedBytes,
- cron_t eta,
- void * closure) {
+ unsigned long long completedBytes,
+ cron_t eta,
+ void * closure) {
fprintf(stderr,
- totalBytes == completedBytes ? "\n" : ".");
+ totalBytes == completedBytes ? "\n" : ".");
}
static void dprogress(unsigned long long totalBytes,
- unsigned long long completedBytes,
- cron_t eta,
- unsigned long long lastBlockOffset,
- const char * lastBlock,
- unsigned int lastBlockSize,
- void * closure) {
+ unsigned long long completedBytes,
+ cron_t eta,
+ unsigned long long lastBlockOffset,
+ const char * lastBlock,
+ unsigned int lastBlockSize,
+ void * closure) {
fprintf(stderr,
- totalBytes == completedBytes ? "\n" : ".");
+ totalBytes == completedBytes ? "\n" : ".");
}
@@ -68,9 +68,9 @@
fn = MALLOC(strlen("/tmp/gnunet-gaptest/GAPTEST") + 14);
SNPRINTF(fn,
- strlen("/tmp/gnunet-gaptest/GAPTEST") + 14,
- "/tmp/gnunet-gaptest/GAPTEST%u",
- i);
+ strlen("/tmp/gnunet-gaptest/GAPTEST") + 14,
+ "/tmp/gnunet-gaptest/GAPTEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -85,29 +85,29 @@
name = makeName(size);
fd = disk_file_open(ectx,
- name,
- O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+ name,
+ O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
buf = MALLOC(size);
memset(buf, size + size / 253, size);
for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
hash(&buf[i+sizeof(HashCode512)],
- 42,
- (HashCode512*) &buf[i]);
+ 42,
+ (HashCode512*) &buf[i]);
WRITE(fd, buf, size);
FREE(buf);
disk_file_close(ectx, name, fd);
ret = ECRS_uploadFile(ectx,
- cfg,
- name,
- YES, /* index */
- 0, /* anon */
- 0, /* prio */
- get_time() + 10 * cronMINUTES, /* expire */
- &uprogress,
- NULL,
- &testTerminate,
- NULL,
- &uri);
+ cfg,
+ name,
+ YES, /* index */
+ 0, /* anon */
+ 0, /* prio */
+ get_time() + 10 * cronMINUTES, /* expire */
+ &uprogress,
+ NULL,
+ &testTerminate,
+ NULL,
+ &uri);
if (ret != SYSERR) {
struct ECRS_MetaData * meta;
struct ECRS_URI * key;
@@ -119,13 +119,13 @@
meta = ECRS_createMetaData();
key = ECRS_keywordsToUri(keywords);
ret = ECRS_addToKeyspace(ectx,
- cfg,
- key,
- 0,
- 0,
- get_time() + 10 * cronMINUTES, /* expire */
- uri,
- meta);
+ cfg,
+ key,
+ 0,
+ 0,
+ get_time() + 10 * cronMINUTES, /* expire */
+ uri,
+ meta);
ECRS_freeMetaData(meta);
ECRS_freeUri(uri);
FREE(name);
@@ -142,17 +142,17 @@
}
static int searchCB(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * closure) {
+ const HashCode512 * key,
+ int isRoot,
+ void * closure) {
struct ECRS_URI ** my = closure;
char * tmp;
tmp = ECRS_uriToString(fi->uri);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Search found URI `%s'\n",
- tmp);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Search found URI `%s'\n",
+ tmp);
FREE(tmp);
GE_ASSERT(ectx, NULL == *my);
*my = ECRS_dupUri(fi->uri);
@@ -169,14 +169,14 @@
myURI = NULL;
ret = ECRS_search(ectx,
- cfg,
- *uri,
- 0,
- 15 * cronSECONDS,
- &searchCB,
- &myURI,
- &testTerminate,
- NULL);
+ cfg,
+ *uri,
+ 0,
+ 15 * cronSECONDS,
+ &searchCB,
+ &myURI,
+ &testTerminate,
+ NULL);
ECRS_freeUri(*uri);
*uri = myURI;
if ( (ret != SYSERR) &&
@@ -187,7 +187,7 @@
}
static int downloadFile(unsigned int size,
- const struct ECRS_URI * uri) {
+ const struct ECRS_URI * uri) {
int ret;
char * tmpName;
int fd;
@@ -198,37 +198,37 @@
tmp = ECRS_uriToString(uri);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Starting download of `%s'\n",
- tmp);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Starting download of `%s'\n",
+ tmp);
FREE(tmp);
tmpName = makeName(0);
ret = SYSERR;
if (OK == ECRS_downloadFile(ectx,
- cfg,
- uri,
- tmpName,
- 0,
- &dprogress,
- NULL,
- &testTerminate,
- NULL)) {
+ cfg,
+ uri,
+ tmpName,
+ 0,
+ &dprogress,
+ NULL,
+ &testTerminate,
+ NULL)) {
fd = disk_file_open(ectx,
- tmpName,
- O_RDONLY);
+ tmpName,
+ O_RDONLY);
buf = MALLOC(size);
in = MALLOC(size);
memset(buf, size + size / 253, size);
for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
hash(&buf[i+sizeof(HashCode512)],
- 42,
- (HashCode512*) &buf[i]);
+ 42,
+ (HashCode512*) &buf[i]);
if (size != READ(fd, in, size))
ret = SYSERR;
else if (0 == memcmp(buf,
- in,
- size))
+ in,
+ size))
ret = OK;
FREE(buf);
FREE(in);
@@ -245,12 +245,12 @@
name = makeName(size);
ret = ECRS_unindexFile(ectx,
- cfg,
- name,
- NULL,
- NULL,
- &testTerminate,
- NULL);
+ cfg,
+ name,
+ NULL,
+ NULL,
+ &testTerminate,
+ NULL);
if (0 != UNLINK(name))
ret = SYSERR;
FREE(name);
@@ -273,29 +273,29 @@
ret = 0;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_PEERS
peers = gnunet_testing_start_daemons("tcp",
- "advertising topology fs stats",
- "/tmp/gnunet-gap-test",
- 2087,
- 10000,
- 2);
+ "advertising topology fs stats",
+ "/tmp/gnunet-gap-test",
+ 2087,
+ 10000,
+ 2);
if (peers == NULL) {
fprintf(stderr,
- "Failed to start the gnunetd daemons!\n");
+ "Failed to start the gnunetd daemons!\n");
GC_free(cfg);
return -1;
}
#endif
if (OK != gnunet_testing_connect_daemons(2087,
- 12087)) {
+ 12087)) {
gnunet_testing_stop_daemons(peers);
fprintf(stderr,
- "Failed to connect the peers!\n");
+ "Failed to connect the peers!\n");
GC_free(cfg);
return -1;
}
@@ -303,18 +303,18 @@
uri = uploadFile(12345);
CHECK(NULL != uri);
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- "localhost:12087");
+ ectx,
+ "NETWORK",
+ "HOST",
+ "localhost:12087");
CHECK(OK == searchFile(&uri));
CHECK(OK == downloadFile(12345, uri));
ECRS_freeUri(uri);
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- "localhost:2087");
+ ectx,
+ "NETWORK",
+ "HOST",
+ "localhost:2087");
CHECK(OK == unindexFile(12345));
FAILURE:
Modified: GNUnet/src/applications/gap/gaptest2.c
===================================================================
--- GNUnet/src/applications/gap/gaptest2.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/gap/gaptest2.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -50,22 +50,22 @@
}
static void uprogress(unsigned long long totalBytes,
- unsigned long long completedBytes,
- cron_t eta,
- void * closure) {
+ unsigned long long completedBytes,
+ cron_t eta,
+ void * closure) {
fprintf(stderr,
- totalBytes == completedBytes ? "\n" : ".");
+ totalBytes == completedBytes ? "\n" : ".");
}
static void dprogress(unsigned long long totalBytes,
- unsigned long long completedBytes,
- cron_t eta,
- unsigned long long lastBlockOffset,
- const char * lastBlock,
- unsigned int lastBlockSize,
- void * closure) {
+ unsigned long long completedBytes,
+ cron_t eta,
+ unsigned long long lastBlockOffset,
+ const char * lastBlock,
+ unsigned int lastBlockSize,
+ void * closure) {
fprintf(stderr,
- totalBytes == completedBytes ? "\n" : ".");
+ totalBytes == completedBytes ? "\n" : ".");
}
static char * makeName(unsigned int i) {
@@ -73,9 +73,9 @@
fn = MALLOC(strlen("/tmp/gnunet-gaptest/GAPTEST") + 14);
SNPRINTF(fn,
- strlen("/tmp/gnunet-gaptest/GAPTEST") + 14,
- "/tmp/gnunet-gaptest/GAPTEST%u",
- i);
+ strlen("/tmp/gnunet-gaptest/GAPTEST") + 14,
+ "/tmp/gnunet-gaptest/GAPTEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -90,29 +90,29 @@
name = makeName(size);
fd = disk_file_open(ectx,
- name,
- O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+ name,
+ O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
buf = MALLOC(size);
memset(buf, size / 253, sizeof(HashCode512));
for (i=0;i<size - sizeof(HashCode512);i+=sizeof(HashCode512))
hash(&buf[i],
- sizeof(HashCode512),
- (HashCode512*) &buf[i+sizeof(HashCode512)]);
+ sizeof(HashCode512),
+ (HashCode512*) &buf[i+sizeof(HashCode512)]);
WRITE(fd, buf, size);
FREE(buf);
disk_file_close(ectx, name, fd);
ret = ECRS_uploadFile(ectx,
- cfg,
- name,
- YES, /* index */
- 1, /* anon */
- 0, /* prio */
- get_time() + 100 * cronMINUTES, /* expire */
- &uprogress, /* progress */
- NULL,
- &testTerminate,
- NULL,
- &uri);
+ cfg,
+ name,
+ YES, /* index */
+ 1, /* anon */
+ 0, /* prio */
+ get_time() + 100 * cronMINUTES, /* expire */
+ &uprogress, /* progress */
+ NULL,
+ &testTerminate,
+ NULL,
+ &uri);
if (ret != SYSERR) {
struct ECRS_MetaData * meta;
struct ECRS_URI * key;
@@ -124,13 +124,13 @@
meta = ECRS_createMetaData();
key = ECRS_keywordsToUri(keywords);
ret = ECRS_addToKeyspace(ectx,
- cfg,
- key,
- 0,
- 0,
- get_time() + 100 * cronMINUTES, /* expire */
- uri,
- meta);
+ cfg,
+ key,
+ 0,
+ 0,
+ get_time() + 100 * cronMINUTES, /* expire */
+ uri,
+ meta);
ECRS_freeMetaData(meta);
ECRS_freeUri(uri);
FREE(name);
@@ -147,9 +147,9 @@
}
static int searchCB(const ECRS_FileInfo * fi,
- const HashCode512 * key,
- int isRoot,
- void * closure) {
+ const HashCode512 * key,
+ int isRoot,
+ void * closure) {
struct ECRS_URI ** my = closure;
char * tmp;
@@ -173,14 +173,14 @@
myURI = NULL;
ret = ECRS_search(ectx,
- cfg,
- *uri,
- 1,
- 1450 * cronSECONDS,
- &searchCB,
- &myURI,
- &testTerminate,
- NULL);
+ cfg,
+ *uri,
+ 1,
+ 1450 * cronSECONDS,
+ &searchCB,
+ &myURI,
+ &testTerminate,
+ NULL);
ECRS_freeUri(*uri);
*uri = myURI;
if ( (ret != SYSERR) &&
@@ -191,7 +191,7 @@
}
static int downloadFile(unsigned int size,
- const struct ECRS_URI * uri) {
+ const struct ECRS_URI * uri) {
int ret;
char * tmpName;
int fd;
@@ -202,37 +202,37 @@
tmp = ECRS_uriToString(uri);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Starting download of `%s'\n",
- tmp);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Starting download of `%s'\n",
+ tmp);
FREE(tmp);
tmpName = makeName(0);
ret = SYSERR;
if (OK == ECRS_downloadFile(ectx,
- cfg,
- uri,
- tmpName,
- 1,
- &dprogress,
- NULL,
- &testTerminate,
- NULL)) {
+ cfg,
+ uri,
+ tmpName,
+ 1,
+ &dprogress,
+ NULL,
+ &testTerminate,
+ NULL)) {
fd = disk_file_open(ectx,
- tmpName,
- O_RDONLY);
+ tmpName,
+ O_RDONLY);
buf = MALLOC(size);
in = MALLOC(size);
memset(buf, size / 253, sizeof(HashCode512));
for (i=0;i<size - sizeof(HashCode512);i+=sizeof(HashCode512))
hash(&buf[i],
- sizeof(HashCode512),
- (HashCode512*) &buf[i+sizeof(HashCode512)]);
+ sizeof(HashCode512),
+ (HashCode512*) &buf[i+sizeof(HashCode512)]);
if (size != READ(fd, in, size))
ret = SYSERR;
else if (0 == memcmp(buf,
- in,
- size))
+ in,
+ size))
ret = OK;
FREE(buf);
FREE(in);
@@ -249,12 +249,12 @@
name = makeName(size);
ret = ECRS_unindexFile(ectx,
- cfg,
- name,
- NULL,
- NULL,
- &testTerminate,
- NULL);
+ cfg,
+ name,
+ NULL,
+ NULL,
+ &testTerminate,
+ NULL);
if (0 != UNLINK(name))
ret = SYSERR;
FREE(name);
@@ -278,30 +278,30 @@
ret = 0;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_PEERS
peers = gnunet_testing_start_daemons("tcp",
- "advertising topology fs stats",
- "/tmp/gnunet-gap-test2",
- 2087,
- 10,
- PEER_COUNT);
+ "advertising topology fs stats",
+ "/tmp/gnunet-gap-test2",
+ 2087,
+ 10,
+ PEER_COUNT);
if (peers == NULL) {
fprintf(stderr,
- "Failed to start the gnunetd daemons!\n");
+ "Failed to start the gnunetd daemons!\n");
GC_free(cfg);
return -1;
}
#endif
for (i=1;i<PEER_COUNT;i++) {
if (OK != gnunet_testing_connect_daemons(2077 + (10*i),
- 2087 + (10*i))) {
+ 2087 + (10*i))) {
gnunet_testing_stop_daemons(peers);
fprintf(stderr,
- "Failed to connect the peers!\n");
+ "Failed to connect the peers!\n");
GC_free(cfg);
return -1;
}
@@ -311,27 +311,27 @@
uri = uploadFile(SIZE);
CHECK(NULL != uri);
SNPRINTF(buf,
- 128,
- "localhost:%u",
- 2077 + PEER_COUNT * 10);
+ 128,
+ "localhost:%u",
+ 2077 + PEER_COUNT * 10);
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- buf);
+ ectx,
+ "NETWORK",
+ "HOST",
+ buf);
CHECK(OK == searchFile(&uri));
printf("Search successful!\n");
start = get_time();
printf("Downloading...\n");
CHECK(OK == downloadFile(SIZE, uri));
printf("Download successful at %llu kbps!\n",
- (SIZE / 1024) / ((get_time() - start) / cronSECONDS));
+ (SIZE / 1024) / ((get_time() - start) / cronSECONDS));
ECRS_freeUri(uri);
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- "localhost:2087");
+ ectx,
+ "NETWORK",
+ "HOST",
+ "localhost:2087");
CHECK(OK == unindexFile(SIZE));
FAILURE:
Modified: GNUnet/src/applications/gap/gaptest3.c
===================================================================
--- GNUnet/src/applications/gap/gaptest3.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/gap/gaptest3.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -50,22 +50,22 @@
}
static void uprogress(unsigned long long totalBytes,
- unsigned long long completedBytes,
- cron_t eta,
- void * closure) {
+ unsigned long long completedBytes,
+ cron_t eta,
+ void * closure) {
fprintf(stderr,
- totalBytes == completedBytes ? "\n" : ".");
+ totalBytes == completedBytes ? "\n" : ".");
}
static void dprogress(unsigned long long totalBytes,
- unsigned long long completedBytes,
- cron_t eta,
- unsigned long long lastBlockOffset,
- const char * lastBlock,
- unsigned int lastBlockSize,
- void * closure) {
+ unsigned long long completedBytes,
+ cron_t eta,
+ unsigned long long lastBlockOffset,
+ const char * lastBlock,
+ unsigned int lastBlockSize,
+ void * closure) {
fprintf(stderr,
- totalBytes == completedBytes ? "\n" : ".");
+ totalBytes == completedBytes ? "\n" : ".");
}
static char * makeName(unsigned int i) {
@@ -73,9 +73,9 @@
fn = MALLOC(strlen("/tmp/gnunet-gaptest/GAPTEST") + 14);
SNPRINTF(fn,
- strlen("/tmp/gnunet-gaptest/GAPTEST") + 14,
- "/tmp/gnunet-gaptest/GAPTEST%u",
- i);
+ strlen("/tmp/gnunet-gaptest/GAPTEST") + 14,
+ "/tmp/gnunet-gaptest/GAPTEST%u",
+ i);
disk_directory_create_for_file(NULL, fn);
return fn;
}
@@ -90,29 +90,29 @@
name = makeName(size);
fd = disk_file_open(ectx,
- name,
- O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
+ name,
+ O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
buf = MALLOC_LARGE(size);
memset(buf, size + size / 253, size);
for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
hash(&buf[i+sizeof(HashCode512)],
- 42,
- (HashCode512*) &buf[i]);
+ 42,
+ (HashCode512*) &buf[i]);
WRITE(fd, buf, size);
FREE(buf);
disk_file_close(ectx, name, fd);
ret = ECRS_uploadFile(ectx,
- cfg,
- name,
- YES, /* index */
- 1, /* anon */
- 0, /* prio */
- get_time() + 100 * cronMINUTES, /* expire */
- &uprogress,
- NULL,
- &testTerminate,
- NULL,
- &uri);
+ cfg,
+ name,
+ YES, /* index */
+ 1, /* anon */
+ 0, /* prio */
+ get_time() + 100 * cronMINUTES, /* expire */
+ &uprogress,
+ NULL,
+ &testTerminate,
+ NULL,
+ &uri);
FREE(name);
if (ret != SYSERR)
return uri;
@@ -120,7 +120,7 @@
}
static int downloadFile(unsigned int size,
- const struct ECRS_URI * uri) {
+ const struct ECRS_URI * uri) {
int ret;
char * tmpName;
int fd;
@@ -131,37 +131,37 @@
tmp = ECRS_uriToString(uri);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Starting download of `%s'\n",
- tmp);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Starting download of `%s'\n",
+ tmp);
FREE(tmp);
tmpName = makeName(0);
ret = SYSERR;
if (OK == ECRS_downloadFile(ectx,
- cfg,
- uri,
- tmpName,
- 1,
- &dprogress,
- NULL,
- &testTerminate,
- NULL)) {
+ cfg,
+ uri,
+ tmpName,
+ 1,
+ &dprogress,
+ NULL,
+ &testTerminate,
+ NULL)) {
fd = disk_file_open(ectx,
- tmpName,
- O_RDONLY);
+ tmpName,
+ O_RDONLY);
buf = MALLOC(size);
in = MALLOC(size);
memset(buf, size + size / 253, size);
for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
hash(&buf[i+sizeof(HashCode512)],
- 42,
- (HashCode512*) &buf[i]);
+ 42,
+ (HashCode512*) &buf[i]);
if (size != READ(fd, in, size))
ret = SYSERR;
else if (0 == memcmp(buf,
- in,
- size))
+ in,
+ size))
ret = OK;
FREE(buf);
FREE(in);
@@ -178,12 +178,12 @@
static unsigned int goodPeerPos;
static int infoCallback(void * data,
- const PeerIdentity * identity,
- const void * address,
- unsigned int addr_len,
- cron_t last_seen,
- unsigned int trust,
- unsigned int bpmFromPeer) {
+ const PeerIdentity * identity,
+ const void * address,
+ unsigned int addr_len,
+ cron_t last_seen,
+ unsigned int trust,
+ unsigned int bpmFromPeer) {
int i;
int good;
EncName enc;
@@ -191,21 +191,21 @@
good = 0;
for (i=0;i<goodPeerPos;i++)
if (0 == memcmp(&goodPeers[i],
- identity,
- sizeof(PeerIdentity)))
+ identity,
+ sizeof(PeerIdentity)))
good = 1;
hash2enc(&identity->hashPubKey,
- &enc);
+ &enc);
if (good)
printf("Good peer `%8s' has trust %u and bandwidth %u\n",
- (const char*) &enc,
- trust,
- bpmFromPeer);
+ (const char*) &enc,
+ trust,
+ bpmFromPeer);
else
printf("Poor peer `%8s' has trust %u and bandwidth %u\n",
- (const char*) &enc,
- trust,
- bpmFromPeer);
+ (const char*) &enc,
+ trust,
+ bpmFromPeer);
return OK;
}
@@ -227,20 +227,20 @@
ret = 0;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_PEERS
peers = gnunet_testing_start_daemons("tcp",
- "advertising topology fs stats",
- "/tmp/gnunet-gap-test3",
- 2087,
- 10,
- PEER_COUNT);
+ "advertising topology fs stats",
+ "/tmp/gnunet-gap-test3",
+ 2087,
+ 10,
+ PEER_COUNT);
if (peers == NULL) {
fprintf(stderr,
- "Failed to start the gnunetd daemons!\n");
+ "Failed to start the gnunetd daemons!\n");
GC_free(cfg);
return -1;
}
@@ -248,10 +248,10 @@
/* connect as star-topology */
for (i=1;i<PEER_COUNT;i++) {
if (OK != gnunet_testing_connect_daemons(2087,
- 2087 + 10*i)) {
+ 2087 + 10*i)) {
gnunet_testing_stop_daemons(peers);
fprintf(stderr,
- "Failed to connect the peers!\n");
+ "Failed to connect the peers!\n");
GC_free(cfg);
return -1;
}
@@ -261,18 +261,18 @@
goodPeerPos = 0;
for (i=1;i<PEER_COUNT;i+=2) {
SNPRINTF(buf,
- 128,
- "localhost:%u",
- 2087 + i * 10);
+ 128,
+ "localhost:%u",
+ 2087 + i * 10);
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- buf);
+ ectx,
+ "NETWORK",
+ "HOST",
+ buf);
sock = client_connection_create(NULL,
- cfg);
+ cfg);
if (OK != gnunet_identity_get_self(sock,
- &hello)) {
+ &hello)) {
connection_destroy(sock);
GE_BREAK(NULL, 0);
break;
@@ -281,9 +281,9 @@
if (uri != NULL)
ECRS_freeUri(uri);
hash2enc(&hello->senderIdentity.hashPubKey,
- &enc);
+ &enc);
printf("Uploading to peer `%8s'\n",
- (const char*)&enc);
+ (const char*)&enc);
uri = uploadFile(SIZE);
CHECK(NULL != uri);
@@ -292,22 +292,22 @@
}
GC_set_configuration_value_string(cfg,
- ectx,
- "NETWORK",
- "HOST",
- "localhost:2087");
+ ectx,
+ "NETWORK",
+ "HOST",
+ "localhost:2087");
printf("Downloading...\n");
start = get_time();
CHECK(OK == downloadFile(SIZE, uri));
printf("Download complete - %f kbps.\n",
- SIZE/1024 * 1.0 * cronSECONDS / (1 + get_time() - start));
+ SIZE/1024 * 1.0 * cronSECONDS / (1 + get_time() - start));
/* verify trust values have developed as expected */
sock = client_connection_create(NULL,
- cfg);
+ cfg);
gnunet_identity_request_peer_infos(sock,
- &infoCallback,
- NULL);
+ &infoCallback,
+ NULL);
connection_destroy(sock);
FAILURE:
Modified: GNUnet/src/applications/gap/pid_table.c
===================================================================
--- GNUnet/src/applications/gap/pid_table.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/gap/pid_table.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -67,26 +67,26 @@
MUTEX_LOCK(lock);
for (ret=1;ret<size;ret++) {
if (0 == memcmp(&pid->hashPubKey,
- &table[ret].id,
- sizeof(HashCode512))) {
+ &table[ret].id,
+ sizeof(HashCode512))) {
table[ret].rc++;
if (stats != NULL) {
- stats->change(stat_pid_rc, 1);
- if (table[ret].rc == 1)
- stats->change(stat_pid_entries, 1);
+ stats->change(stat_pid_rc, 1);
+ if (table[ret].rc == 1)
+ stats->change(stat_pid_entries, 1);
}
MUTEX_UNLOCK(lock);
return ret;
} else if ( (zero == size) &&
- (table[ret].rc == 0) ) {
+ (table[ret].rc == 0) ) {
zero = ret;
}
}
ret = zero;
if (ret == size) {
GROW(table,
- size,
- size + 16);
+ size,
+ size + 16);
}
if (ret == 0)
ret = 1;
@@ -102,7 +102,7 @@
}
void decrement_pid_rcs(const PID_INDEX * ids,
- unsigned int count) {
+ unsigned int count) {
int i;
PID_INDEX id;
if (count == 0)
@@ -114,7 +114,7 @@
GE_ASSERT(ectx, table[id].rc > 0);
table[id].rc--;
if ( (table[id].rc == 0) &&
- (stats != NULL) )
+ (stats != NULL) )
stats->change(stat_pid_entries, -1);
}
MUTEX_UNLOCK(lock);
@@ -138,7 +138,7 @@
}
void resolve_pid(PID_INDEX id,
- PeerIdentity * pid) {
+ PeerIdentity * pid) {
if (id == 0) {
memset(pid, 0, sizeof(PeerIdentity));
GE_BREAK(ectx, 0);
@@ -153,7 +153,7 @@
void init_pid_table(struct GE_Context * e,
- Stats_ServiceAPI * s) {
+ Stats_ServiceAPI * s) {
ectx = e;
stats = s;
if (stats != NULL) {
Modified: GNUnet/src/applications/getoption/clientapi.c
===================================================================
--- GNUnet/src/applications/getoption/clientapi.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/getoption/clientapi.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -38,38 +38,38 @@
* @return NULL on error (for both option not set and internal errors)
*/
char * getConfigurationOptionValue(struct ClientServerConnection * sock,
- const char * section,
- const char * option) {
+ const char * section,
+ const char * option) {
CS_getoption_request_MESSAGE req;
CS_getoption_reply_MESSAGE * reply;
int res;
char * ret;
memset(&req,
- 0,
- sizeof(CS_getoption_request_MESSAGE));
+ 0,
+ sizeof(CS_getoption_request_MESSAGE));
req.header.type = htons(CS_PROTO_GET_OPTION_REQUEST);
req.header.size = htons(sizeof(CS_getoption_request_MESSAGE));
if ( (strlen(section) >= CS_getoption_request_MESSAGE_OPT_LEN) ||
(strlen(option) >= CS_getoption_request_MESSAGE_OPT_LEN) )
return NULL;
strcpy(&req.section[0],
- section);
+ section);
strcpy(&req.option[0],
- option);
+ option);
res = connection_write(sock,
- &req.header);
+ &req.header);
if (res != OK)
return NULL;
reply = NULL;
res = connection_read(sock,
- (MESSAGE_HEADER**)&reply);
+ (MESSAGE_HEADER**)&reply);
if (res != OK)
return NULL;
ret = MALLOC(ntohs(reply->header.size) - sizeof(MESSAGE_HEADER) + 1);
memcpy(ret,
- &reply->value[0],
- ntohs(reply->header.size) - sizeof(MESSAGE_HEADER));
+ &reply->value[0],
+ ntohs(reply->header.size) - sizeof(MESSAGE_HEADER));
ret[ntohs(reply->header.size) - sizeof(MESSAGE_HEADER)] = '\0';
FREE(reply);
return ret;
Modified: GNUnet/src/applications/getoption/getoption.c
===================================================================
--- GNUnet/src/applications/getoption/getoption.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/getoption/getoption.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -34,7 +34,7 @@
static CoreAPIForApplication * coreAPI;
static int handleGetOption(struct ClientHandle * sock,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
CS_getoption_request_MESSAGE * req;
CS_getoption_reply_MESSAGE * rep;
char * val;
@@ -47,25 +47,25 @@
req->option[CS_getoption_request_MESSAGE_OPT_LEN-1] = '\0';
val = NULL;
if (NO == GC_have_configuration_value(coreAPI->cfg,
- req->section,
- req->option))
+ req->section,
+ req->option))
return SYSERR; /* signal error: option not set */
if ( (0 != GC_get_configuration_value_string(coreAPI->cfg,
- req->section,
- req->option,
- NULL,
- &val)) ||
+ req->section,
+ req->option,
+ NULL,
+ &val)) ||
(val == NULL) )
return SYSERR; /* signal error: option not set */
rep = MALLOC(sizeof(MESSAGE_HEADER) + strlen(val) + 1);
rep->header.size = htons(sizeof(MESSAGE_HEADER) + strlen(val) + 1);
memcpy(rep->value,
- val,
- strlen(val)+1);
+ val,
+ strlen(val)+1);
rep->header.type = htons(CS_PROTO_GET_OPTION_REPLY);
ret = coreAPI->sendToClient(sock,
- &rep->header);
+ &rep->header);
FREE(rep);
FREE(val);
return ret;
@@ -74,24 +74,24 @@
int initialize_module_getoption(CoreAPIForApplication * capi) {
coreAPI = capi;
GE_LOG(capi->ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("`%s' registering client handler %d\n"),
- "getoption",
- CS_PROTO_GET_OPTION_REQUEST);
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("`%s' registering client handler %d\n"),
+ "getoption",
+ CS_PROTO_GET_OPTION_REQUEST);
capi->registerClientHandler(CS_PROTO_GET_OPTION_REQUEST,
- &handleGetOption);
+ &handleGetOption);
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "getoption",
- _("allows clients to
determine gnunetd's"
- " configuration")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "getoption",
+ _("allows clients to determine
gnunetd's"
+ " configuration")));
return OK;
}
void done_module_getoption() {
coreAPI->unregisterClientHandler(CS_PROTO_GET_OPTION_REQUEST,
- &handleGetOption);
+ &handleGetOption);
coreAPI = NULL;
}
Modified: GNUnet/src/applications/identity/clientapi.c
===================================================================
--- GNUnet/src/applications/identity/clientapi.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/identity/clientapi.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -36,29 +36,29 @@
* @return OK on success, SYSERR on error
*/
int gnunet_identity_peer_add(struct ClientServerConnection * sock,
- const P2P_hello_MESSAGE * hello) {
+ const P2P_hello_MESSAGE * hello) {
P2P_hello_MESSAGE * msg;
msg = MALLOC(P2P_hello_MESSAGE_size(hello));
memcpy(msg,
- hello,
- P2P_hello_MESSAGE_size(hello));
+ hello,
+ P2P_hello_MESSAGE_size(hello));
msg->header.type = htons(CS_PROTO_identity_HELLO);
/* check that signature is valid -- internal
sanity check... */
if (SYSERR == verifySig(&msg->senderIdentity,
- P2P_hello_MESSAGE_size(msg)
- - sizeof(Signature)
- - sizeof(PublicKey)
- - sizeof(MESSAGE_HEADER),
- &msg->signature,
- &msg->publicKey)) {
+ P2P_hello_MESSAGE_size(msg)
+ - sizeof(Signature)
+ - sizeof(PublicKey)
+ - sizeof(MESSAGE_HEADER),
+ &msg->signature,
+ &msg->publicKey)) {
GE_BREAK(NULL, 0);
FREE(msg);
return SYSERR;
}
if (SYSERR == connection_write(sock,
- &msg->header)) {
+ &msg->header)) {
FREE(msg);
return SYSERR;
}
@@ -72,9 +72,9 @@
* with the private key of the peer.
*/
int gnunet_identity_sign_function(struct ClientServerConnection * sock,
- unsigned short size,
- const void * data,
- Signature * result) {
+ unsigned short size,
+ const void * data,
+ Signature * result) {
MESSAGE_HEADER * req;
CS_identity_signature_MESSAGE * reply;
@@ -82,16 +82,16 @@
req->size = htons(sizeof(MESSAGE_HEADER) + size);
req->type = htons(CS_PROTO_identity_request_SIGN);
memcpy(&req[1],
- data,
- size);
+ data,
+ size);
if (SYSERR == connection_write(sock,
- req)) {
+ req)) {
FREE(req);
return SYSERR;
}
FREE(req);
if (OK != connection_read(sock,
- (MESSAGE_HEADER**)&reply)) {
+ (MESSAGE_HEADER**)&reply)) {
connection_close_temporarily(sock);
return SYSERR;
}
@@ -113,17 +113,17 @@
* @return SYSERR on error, OK on success
*/
int gnunet_identity_get_self(struct ClientServerConnection * sock,
- P2P_hello_MESSAGE ** msg) {
+ P2P_hello_MESSAGE ** msg) {
MESSAGE_HEADER req;
P2P_hello_MESSAGE * reply;
req.size = htons(sizeof(MESSAGE_HEADER));
req.type = htons(CS_PROTO_identity_request_HELLO);
if (SYSERR == connection_write(sock,
- &req))
+ &req))
return SYSERR;
if (OK != connection_read(sock,
- (MESSAGE_HEADER**)&reply)) {
+ (MESSAGE_HEADER**)&reply)) {
connection_close_temporarily(sock);
return SYSERR;
}
@@ -145,7 +145,7 @@
* NO if connection is not yet present
*/
int gnunet_identity_request_connect(struct ClientServerConnection * sock,
- const PeerIdentity * peer) {
+ const PeerIdentity * peer) {
CS_identity_connect_MESSAGE msg;
int result;
@@ -157,10 +157,10 @@
msg.other
= *peer;
if (SYSERR == connection_write(sock,
- &msg.header))
+ &msg.header))
return SYSERR;
if (SYSERR == connection_read_result(sock,
- &result))
+ &result))
return SYSERR;
return result;
}
@@ -172,8 +172,8 @@
* otherwise number of peers known
*/
int gnunet_identity_request_peer_infos(struct ClientServerConnection * sock,
- GNUnetIdentityPeerInfoCallback callback,
- void * cls) {
+ GNUnetIdentityPeerInfoCallback callback,
+ void * cls) {
MESSAGE_HEADER req;
MESSAGE_HEADER * reply;
CS_identity_peer_info_MESSAGE * info;
@@ -182,11 +182,11 @@
req.size = htons(sizeof(MESSAGE_HEADER));
req.type = htons(CS_PROTO_identity_request_INFO);
if (SYSERR == connection_write(sock,
- &req))
+ &req))
return SYSERR;
count = 0;
while (OK == connection_read(sock,
- &reply)) {
+ &reply)) {
if (ntohs(reply->size) < sizeof(MESSAGE_HEADER)) {
GE_BREAK(NULL, 0);
FREE(reply);
@@ -198,7 +198,7 @@
}
count++;
if ( (ntohs(reply->type) != CS_PROTO_identity_INFO) ||
- (ntohs(reply->size) < sizeof(CS_identity_peer_info_MESSAGE)) ) {
+ (ntohs(reply->size) < sizeof(CS_identity_peer_info_MESSAGE)) ) {
GE_BREAK(NULL, 0);
FREE(reply);
return SYSERR;
@@ -206,14 +206,14 @@
if (callback != NULL) {
info = (CS_identity_peer_info_MESSAGE *) reply;
if (OK != callback(cls,
- &info->peer,
- &info[1],
- ntohs(reply->size) -
sizeof(CS_identity_peer_info_MESSAGE),
- ntohll(info->last_message),
- ntohl(info->trust),
- ntohl(info->bpm))) {
- FREE(reply);
- return SYSERR;
+ &info->peer,
+ &info[1],
+ ntohs(reply->size) - sizeof(CS_identity_peer_info_MESSAGE),
+ ntohll(info->last_message),
+ ntohl(info->trust),
+ ntohl(info->bpm))) {
+ FREE(reply);
+ return SYSERR;
}
}
FREE(reply);
Modified: GNUnet/src/applications/identity/hostkey.c
===================================================================
--- GNUnet/src/applications/identity/hostkey.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/identity/hostkey.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -62,21 +62,21 @@
* @return SYSERR on error, OK on success
*/
int signData(const void * data,
- unsigned short size,
- Signature * result) {
+ unsigned short size,
+ Signature * result) {
int ret;
ret = sign(hostkey,
- size,
- data,
- result);
+ size,
+ data,
+ result);
#if EXTRA_CHECKS
if (ret == OK) {
GE_ASSERT(NULL,
- OK == verifySig(data,
- size,
- result,
- &publicKey));
+ OK == verifySig(data,
+ size,
+ result,
+ &publicKey));
}
#endif
return ret;
@@ -92,16 +92,16 @@
* @returns the size of the decrypted block, -1 on error
*/
int decryptData(const RSAEncryptedData * block,
- void * result,
- unsigned int max) {
+ void * result,
+ unsigned int max) {
return decryptPrivateKey(hostkey,
- block,
- result,
- max);
+ block,
+ result,
+ max);
}
void initPrivateKey(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * gnHome;
char * hostkeyfile;
PrivateKeyEncoded * encPrivateKey;
@@ -109,19 +109,19 @@
int res;
GE_ASSERT(ectx,
- -1 != GC_get_configuration_value_filename(cfg,
- "GNUNETD",
- "GNUNETD_HOME",
- VAR_DAEMON_DIRECTORY,
- &gnHome));
+ -1 != GC_get_configuration_value_filename(cfg,
+ "GNUNETD",
+ "GNUNETD_HOME",
+ VAR_DAEMON_DIRECTORY,
+ &gnHome));
disk_directory_create(ectx,
- gnHome);
+ gnHome);
if (YES != disk_directory_test(ectx,
- gnHome)) {
+ gnHome)) {
GE_LOG(ectx,
- GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
- _("Failed to access GNUnet home directory `%s'\n"),
- gnHome);
+ GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
+ _("Failed to access GNUnet home directory `%s'\n"),
+ gnHome);
abort();
}
@@ -134,45 +134,45 @@
strcat(hostkeyfile, HOSTKEYFILE);
res = 0;
if (YES == disk_file_test(ectx,
- hostkeyfile)) {
+ hostkeyfile)) {
res = disk_file_read(ectx,
- hostkeyfile,
- sizeof(unsigned short),
- &len);
+ hostkeyfile,
+ sizeof(unsigned short),
+ &len);
}
encPrivateKey = NULL;
if (res == sizeof(unsigned short)) {
encPrivateKey = (PrivateKeyEncoded*) MALLOC(ntohs(len));
if (ntohs(len) !=
- disk_file_read(ectx,
- hostkeyfile,
- ntohs(len),
- encPrivateKey)) {
+ disk_file_read(ectx,
+ hostkeyfile,
+ ntohs(len),
+ encPrivateKey)) {
FREE(encPrivateKey);
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_IMMEDIATE | GE_ADMIN,
- _("Existing hostkey in file `%s' failed format check, creating new
hostkey.\n"),
- hostkeyfile);
+ GE_WARNING | GE_USER | GE_IMMEDIATE | GE_ADMIN,
+ _("Existing hostkey in file `%s' failed format check, creating new
hostkey.\n"),
+ hostkeyfile);
encPrivateKey = NULL;
}
}
if (encPrivateKey == NULL) { /* make new hostkey */
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- _("Creating new hostkey (this may take a while).\n"));
+ GE_INFO | GE_USER | GE_BULK,
+ _("Creating new hostkey (this may take a while).\n"));
hostkey = makePrivateKey();
GE_ASSERT(ectx, hostkey != NULL);
encPrivateKey = encodePrivateKey(hostkey);
GE_ASSERT(ectx, encPrivateKey != NULL);
disk_file_write(ectx,
- hostkeyfile,
- encPrivateKey,
- ntohs(encPrivateKey->len),
- "600");
+ hostkeyfile,
+ encPrivateKey,
+ ntohs(encPrivateKey->len),
+ "600");
FREE(encPrivateKey);
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- _("Done creating hostkey.\n"));
+ GE_INFO | GE_USER | GE_BULK,
+ _("Done creating hostkey.\n"));
} else {
hostkey = decodePrivateKey(encPrivateKey);
FREE(encPrivateKey);
@@ -180,7 +180,7 @@
FREE(hostkeyfile);
GE_ASSERT(ectx, hostkey != NULL);
getPublicKey(hostkey,
- &publicKey);
+ &publicKey);
}
Modified: GNUnet/src/applications/identity/identity.c
===================================================================
--- GNUnet/src/applications/identity/identity.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/identity/identity.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -152,21 +152,21 @@
* @return filename of the form DIRECTORY/HOSTID.PROTOCOL
*/
static char * getHostFileName(const PeerIdentity * id,
- unsigned short protocol) {
+ unsigned short protocol) {
EncName fil;
char * fn;
size_t n;
hash2enc(&id->hashPubKey,
- &fil);
+ &fil);
n = strlen(networkIdDirectory) + sizeof(EncName) + 1 + 5 + 1;
fn = MALLOC(n);
SNPRINTF(fn,
- n,
- "%s%s.%u",
- networkIdDirectory,
- (char*) &fil,
- protocol);
+ n,
+ "%s%s.%u",
+ networkIdDirectory,
+ (char*) &fil,
+ protocol);
return fn;
}
@@ -181,8 +181,8 @@
GE_ASSERT(ectx, numberOfHosts_ <= sizeOfHosts_);
for (i=0;i<numberOfHosts_;i++)
if ( (0 == memcmp(id,
- &hosts_[i]->identity,
- sizeof(PeerIdentity))) )
+ &hosts_[i]->identity,
+ sizeof(PeerIdentity))) )
return hosts_[i];
return NULL;
}
@@ -194,7 +194,7 @@
* @param protocol the protocol for the host
*/
static void addHostToKnown(const PeerIdentity * identity,
- unsigned short protocol) {
+ unsigned short protocol) {
HostEntry * entry;
int i;
EncName fil;
@@ -216,17 +216,17 @@
entry->hellos = NULL;
entry->helloCount = 0;
hash2enc(&identity->hashPubKey,
- &fil);
+ &fil);
fn = MALLOC(strlen(trustDirectory)+sizeof(EncName)+1);
strcpy(fn, trustDirectory);
strcat(fn, (char*) &fil);
if ( (disk_file_test(ectx,
- fn) == YES) &&
- (sizeof(unsigned int) ==
- disk_file_read(ectx,
- fn,
- sizeof(unsigned int),
- &trust)) ) {
+ fn) == YES) &&
+ (sizeof(unsigned int) ==
+ disk_file_read(ectx,
+ fn,
+ sizeof(unsigned int),
+ &trust)) ) {
entry->trust = ntohl(trust);
} else {
entry->trust = 0;
@@ -235,8 +235,8 @@
if (numberOfHosts_ == sizeOfHosts_)
GROW(hosts_,
- sizeOfHosts_,
- sizeOfHosts_+32);
+ sizeOfHosts_,
+ sizeOfHosts_+32);
hosts_[numberOfHosts_++] = entry;
}
for (i=0;i<entry->protocolCount;i++) {
@@ -262,7 +262,7 @@
* @returns the actual change in trust (positive or negative)
*/
static int changeHostTrust(const PeerIdentity * hostId,
- int value){
+ int value){
HostEntry * host;
if (value == 0)
@@ -272,7 +272,7 @@
host = findHost(hostId);
if (host == NULL) {
addHostToKnown(hostId,
- NAT_PROTOCOL_NUMBER);
+ NAT_PROTOCOL_NUMBER);
host = findHost(hostId);
if (host == NULL) {
GE_BREAK(ectx, 0);
@@ -314,8 +314,8 @@
static int cronHelper(const char * filename,
- const char * dirname,
- void * unused) {
+ const char * dirname,
+ void * unused) {
PeerIdentity identity;
EncName id;
unsigned int protoNumber;
@@ -324,48 +324,48 @@
GE_ASSERT(ectx, numberOfHosts_ <= sizeOfHosts_);
GE_ASSERT(ectx, sizeof(EncName) == 104);
if (2 == sscanf(filename,
- "%103c.%u",
- (char*)&id,
- &protoNumber)) {
+ "%103c.%u",
+ (char*)&id,
+ &protoNumber)) {
id.encoding[sizeof(EncName)-1] = '\0';
if (OK == enc2hash((char*)&id,
- &identity.hashPubKey)) {
+ &identity.hashPubKey)) {
addHostToKnown(&identity,
- (unsigned short) protoNumber);
+ (unsigned short) protoNumber);
return OK;
}
}
fullname = MALLOC(strlen(filename) +
- strlen(networkIdDirectory) + 1);
+ strlen(networkIdDirectory) + 1);
strcpy(fullname, networkIdDirectory);
strcat(fullname, filename);
if (disk_file_test(ectx, fullname) == YES) {
if (0 == UNLINK(fullname))
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- _("File `%s' in directory `%s' does not match naming convention. "
- "Removed.\n"),
- filename,
- networkIdDirectory);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ _("File `%s' in directory `%s' does not match naming convention. "
+ "Removed.\n"),
+ filename,
+ networkIdDirectory);
else
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "unlink",
- fullname);
+ GE_ERROR | GE_USER | GE_BULK,
+ "unlink",
+ fullname);
} else if (disk_directory_test(ectx, fullname) == YES) {
if (0 == RMDIR(fullname))
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- _("Directory `%s' in directory `%s' does not match naming
convention. "
- "Removed.\n"),
- filename,
- networkIdDirectory);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ _("Directory `%s' in directory `%s' does not match naming convention. "
+ "Removed.\n"),
+ filename,
+ networkIdDirectory);
else
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "rmdir",
- fullname);
+ GE_ERROR | GE_USER | GE_BULK,
+ "rmdir",
+ fullname);
}
FREE(fullname);
return OK;
@@ -383,19 +383,19 @@
now = get_time();
if (lastRun + MAX_DATA_HOST_FREQ > now)
return; /* prevent scanning more than
- once every 5 min */
+ once every 5 min */
lastRun = now;
count = disk_directory_scan(ectx,
- networkIdDirectory,
- &cronHelper,
- NULL);
+ networkIdDirectory,
+ &cronHelper,
+ NULL);
if (count <= 0) {
retries++;
if ((retries & 32) > 0) {
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Still no peers found in `%s'!\n"),
- networkIdDirectory);
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Still no peers found in `%s'!\n"),
+ networkIdDirectory);
}
}
GE_ASSERT(ectx, numberOfHosts_ <= sizeOfHosts_);
@@ -408,15 +408,15 @@
* @param result address where to write the identity of the node
*/
static void getPeerIdentity(const PublicKey * pubKey,
- PeerIdentity * result) {
+ PeerIdentity * result) {
if (pubKey == NULL) {
memset(&result,
- 0,
- sizeof(PeerIdentity));
+ 0,
+ sizeof(PeerIdentity));
} else {
hash(pubKey,
- sizeof(PublicKey),
- &result->hashPubKey);
+ sizeof(PublicKey),
+ &result->hashPubKey);
}
}
@@ -432,10 +432,10 @@
PeerIdentity have;
getPeerIdentity(&tmp->publicKey,
- &have);
+ &have);
if (0 != memcmp(&have,
- &tmp->senderIdentity,
- sizeof(PeerIdentity))) {
+ &tmp->senderIdentity,
+ sizeof(PeerIdentity))) {
GE_BREAK(NULL, 0);
return;
}
@@ -448,13 +448,13 @@
}
msg = MALLOC(P2P_hello_MESSAGE_size(tmp));
memcpy(msg,
- tmp,
- P2P_hello_MESSAGE_size(tmp));
+ tmp,
+ P2P_hello_MESSAGE_size(tmp));
slot = tempHostsNextSlot;
for (i=0;i<MAX_TEMP_HOSTS;i++)
if (0 == memcmp(&tmp->senderIdentity,
- &tempHosts[i].identity,
- sizeof(PeerIdentity)))
+ &tempHosts[i].identity,
+ sizeof(PeerIdentity)))
slot = i;
if (slot == tempHostsNextSlot) {
tempHostsNextSlot++;
@@ -484,7 +484,7 @@
* Delete a host from the list.
*/
static void delHostFromKnown(const PeerIdentity * identity,
- unsigned short protocol) {
+ unsigned short protocol) {
HostEntry * entry;
char * fn;
int i;
@@ -495,52 +495,52 @@
MUTEX_LOCK(lock_);
for (i=0;i<numberOfHosts_;i++) {
if ( (0 == memcmp(identity,
- &hosts_[i]->identity,
- sizeof(PeerIdentity))) ) {
+ &hosts_[i]->identity,
+ sizeof(PeerIdentity))) ) {
entry = hosts_[i];
for (j=0;j<entry->protocolCount;j++) {
- if (protocol == entry->protocols[j]) {
- entry->protocols[j]
- = entry->protocols[entry->protocolCount-1];
- GROW(entry->protocols,
- entry->protocolCount,
- entry->protocolCount-1);
- }
+ if (protocol == entry->protocols[j]) {
+ entry->protocols[j]
+ = entry->protocols[entry->protocolCount-1];
+ GROW(entry->protocols,
+ entry->protocolCount,
+ entry->protocolCount-1);
+ }
}
for (j=0;j<entry->helloCount;j++) {
- if (protocol == ntohs(entry->hellos[j]->protocol)) {
- FREE(entry->hellos[j]);
- entry->hellos[j]
- = entry->hellos[entry->helloCount-1];
- GROW(entry->hellos,
- entry->helloCount,
- entry->helloCount-1);
- }
+ if (protocol == ntohs(entry->hellos[j]->protocol)) {
+ FREE(entry->hellos[j]);
+ entry->hellos[j]
+ = entry->hellos[entry->helloCount-1];
+ GROW(entry->hellos,
+ entry->helloCount,
+ entry->helloCount-1);
+ }
}
/* also remove hello file itself */
fn = getHostFileName(identity,
- protocol);
+ protocol);
if (0 != UNLINK(fn))
- GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "unlink",
- fn);
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_WARNING | GE_USER | GE_BULK,
+ "unlink",
+ fn);
FREE(fn);
if (entry->protocolCount == 0) {
- if (entry->helloCount > 0) {
- for (j=0;j<entry->helloCount;j++)
- FREE(entry->hellos[j]);
- GROW(entry->hellos,
- entry->helloCount,
- 0);
- }
- hosts_[i] = hosts_[--numberOfHosts_];
- FREE(entry);
+ if (entry->helloCount > 0) {
+ for (j=0;j<entry->helloCount;j++)
+ FREE(entry->hellos[j]);
+ GROW(entry->hellos,
+ entry->helloCount,
+ 0);
+ }
+ hosts_[i] = hosts_[--numberOfHosts_];
+ FREE(entry);
}
MUTEX_UNLOCK(lock_);
GE_ASSERT(ectx,
- numberOfHosts_ <= sizeOfHosts_);
+ numberOfHosts_ <= sizeOfHosts_);
return; /* deleted */
}
}
@@ -561,51 +561,51 @@
PeerIdentity have;
getPeerIdentity(&msg->publicKey,
- &have);
+ &have);
if (0 != memcmp(&have,
- &msg->senderIdentity,
- sizeof(PeerIdentity))) {
+ &msg->senderIdentity,
+ sizeof(PeerIdentity))) {
GE_BREAK(NULL, 0);
return;
}
GE_ASSERT(ectx,
- numberOfHosts_ <= sizeOfHosts_);
+ numberOfHosts_ <= sizeOfHosts_);
GE_ASSERT(ectx,
- msg != NULL);
+ msg != NULL);
fn = getHostFileName(&msg->senderIdentity,
- ntohs(msg->protocol));
+ ntohs(msg->protocol));
buffer = MALLOC(MAX_BUFFER_SIZE);
if (disk_file_test(ectx,
- fn) == YES) {
+ fn) == YES) {
size = disk_file_read(ectx,
- fn,
- MAX_BUFFER_SIZE,
- buffer);
+ fn,
+ MAX_BUFFER_SIZE,
+ buffer);
if (size >= sizeof(P2P_hello_MESSAGE)) {
oldMsg = (P2P_hello_MESSAGE*) buffer;
if ((unsigned int)size == P2P_hello_MESSAGE_size(oldMsg)) {
- if (ntohl(oldMsg->expirationTime) > ntohl(msg->expirationTime)) {
- FREE(fn);
- FREE(buffer);
- return; /* have more recent hello in stock */
- }
+ if (ntohl(oldMsg->expirationTime) > ntohl(msg->expirationTime)) {
+ FREE(fn);
+ FREE(buffer);
+ return; /* have more recent hello in stock */
+ }
}
}
}
disk_file_write(ectx,
- fn,
- msg,
- P2P_hello_MESSAGE_size(msg),
- "644");
+ fn,
+ msg,
+ P2P_hello_MESSAGE_size(msg),
+ "644");
FREE(fn);
FREE(buffer);
MUTEX_LOCK(lock_);
addHostToKnown(&msg->senderIdentity,
- ntohs(msg->protocol));
+ ntohs(msg->protocol));
host = findHost(&msg->senderIdentity);
GE_ASSERT(ectx,
- host != NULL);
+ host != NULL);
for (i=0;i<host->helloCount;i++) {
if (msg->protocol == host->hellos[i]->protocol) {
@@ -616,16 +616,16 @@
}
if (i == host->helloCount)
GROW(host->hellos,
- host->helloCount,
- host->helloCount+1);
+ host->helloCount,
+ host->helloCount+1);
host->hellos[i]
= MALLOC(P2P_hello_MESSAGE_size(msg));
memcpy(host->hellos[i],
- msg,
- P2P_hello_MESSAGE_size(msg));
+ msg,
+ P2P_hello_MESSAGE_size(msg));
MUTEX_UNLOCK(lock_);
GE_ASSERT(ectx,
- numberOfHosts_ <= sizeOfHosts_);
+ numberOfHosts_ <= sizeOfHosts_);
}
/**
@@ -642,8 +642,8 @@
*/
static P2P_hello_MESSAGE *
identity2Hello(const PeerIdentity * hostId,
- unsigned short protocol,
- int tryTemporaryList) {
+ unsigned short protocol,
+ int tryTemporaryList) {
P2P_hello_MESSAGE * result;
HostEntry * host;
char * fn;
@@ -654,7 +654,7 @@
int j;
GE_ASSERT(ectx,
- numberOfHosts_ <= sizeOfHosts_);
+ numberOfHosts_ <= sizeOfHosts_);
MUTEX_LOCK(lock_);
if (YES == tryTemporaryList) {
/* ok, then first try temporary hosts
@@ -662,28 +662,28 @@
for (i=0;i<MAX_TEMP_HOSTS;i++) {
host = &tempHosts[i];
if ( (host->helloCount > 0) &&
- (0 == memcmp(hostId,
- &host->identity,
- sizeof(PeerIdentity))) ) {
- if (protocol == ANY_PROTOCOL_NUMBER) {
- j = weak_randomi(host->helloCount);
- } else {
- j = 0;
- while ( (j < host->helloCount) &&
- (host->protocols[j] != protocol) )
- j++;
- }
- if (j == host->helloCount) {
- /* not found */
- MUTEX_UNLOCK(lock_);
- return NULL;
- }
- result = MALLOC(P2P_hello_MESSAGE_size(host->hellos[j]));
- memcpy(result,
- host->hellos[j],
- P2P_hello_MESSAGE_size(host->hellos[j]));
- MUTEX_UNLOCK(lock_);
- return result;
+ (0 == memcmp(hostId,
+ &host->identity,
+ sizeof(PeerIdentity))) ) {
+ if (protocol == ANY_PROTOCOL_NUMBER) {
+ j = weak_randomi(host->helloCount);
+ } else {
+ j = 0;
+ while ( (j < host->helloCount) &&
+ (host->protocols[j] != protocol) )
+ j++;
+ }
+ if (j == host->helloCount) {
+ /* not found */
+ MUTEX_UNLOCK(lock_);
+ return NULL;
+ }
+ result = MALLOC(P2P_hello_MESSAGE_size(host->hellos[j]));
+ memcpy(result,
+ host->hellos[j],
+ P2P_hello_MESSAGE_size(host->hellos[j]));
+ MUTEX_UNLOCK(lock_);
+ return result;
}
}
}
@@ -701,10 +701,10 @@
for (i=0;i<host->helloCount;i++) {
if (ntohs(host->hellos[i]->protocol) == protocol) {
result
- = MALLOC(P2P_hello_MESSAGE_size(host->hellos[i]));
+ = MALLOC(P2P_hello_MESSAGE_size(host->hellos[i]));
memcpy(result,
- host->hellos[i],
- P2P_hello_MESSAGE_size(host->hellos[i]));
+ host->hellos[i],
+ P2P_hello_MESSAGE_size(host->hellos[i]));
MUTEX_UNLOCK(lock_);
return result;
}
@@ -712,56 +712,56 @@
/* do direct read */
fn = getHostFileName(hostId,
- protocol);
+ protocol);
if (1 != disk_file_test(ectx,
- fn)) {
+ fn)) {
FREE(fn);
MUTEX_UNLOCK(lock_);
return NULL;
}
size = disk_file_read(ectx,
- fn,
- sizeof(P2P_hello_MESSAGE),
- &buffer);
+ fn,
+ sizeof(P2P_hello_MESSAGE),
+ &buffer);
if (size != sizeof(P2P_hello_MESSAGE)) {
if (0 == UNLINK(fn))
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Removed file `%s' containing invalid HELLO data.\n"),
- fn);
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Removed file `%s' containing invalid HELLO data.\n"),
+ fn);
else
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "unlink",
- fn);
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "unlink",
+ fn);
FREE(fn);
MUTEX_UNLOCK(lock_);
return NULL;
}
result = MALLOC(P2P_hello_MESSAGE_size(&buffer));
size = disk_file_read(ectx,
- fn,
- P2P_hello_MESSAGE_size(&buffer),
- result);
+ fn,
+ P2P_hello_MESSAGE_size(&buffer),
+ result);
getPeerIdentity(&result->publicKey,
- &have);
+ &have);
if ( ((unsigned int)size != P2P_hello_MESSAGE_size(&buffer)) ||
(0 != memcmp(&have,
- hostId,
- sizeof(PeerIdentity))) ||
+ hostId,
+ sizeof(PeerIdentity))) ||
(0 != memcmp(&have,
- &result->senderIdentity,
- sizeof(PeerIdentity))) ) {
+ &result->senderIdentity,
+ sizeof(PeerIdentity))) ) {
if (0 == UNLINK(fn))
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Removed file `%s' containing invalid HELLO data.\n"),
- fn);
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Removed file `%s' containing invalid HELLO data.\n"),
+ fn);
else
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "unlink",
- fn);
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "unlink",
+ fn);
FREE(fn);
FREE(result);
MUTEX_UNLOCK(lock_);
@@ -774,8 +774,8 @@
host->hellos[host->helloCount-1]
= MALLOC(P2P_hello_MESSAGE_size(&buffer));
memcpy(host->hellos[host->helloCount-1],
- result,
- P2P_hello_MESSAGE_size(&buffer));
+ result,
+ P2P_hello_MESSAGE_size(&buffer));
MUTEX_UNLOCK(lock_);
return result;
}
@@ -790,36 +790,36 @@
* @return OK on success, SYSERR on error (verification failed)
*/
static int verifyPeerSignature(const PeerIdentity * signer,
- const void * message,
- int size,
- const Signature * sig) {
+ const void * message,
+ int size,
+ const Signature * sig) {
P2P_hello_MESSAGE * hello;
int res;
hello = identity2Hello(signer,
- ANY_PROTOCOL_NUMBER,
- YES);
+ ANY_PROTOCOL_NUMBER,
+ YES);
if (hello == NULL) {
#if DEBUG_IDENTITY
EncName enc;
IF_GELOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- hash2enc(&signer->hashPubKey,
- &enc));
+ GE_INFO | GE_USER | GE_BULK,
+ hash2enc(&signer->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- _("Signature failed verification: peer `%s' not known.\n"),
- &enc);
+ GE_INFO | GE_USER | GE_BULK,
+ _("Signature failed verification: peer `%s' not known.\n"),
+ &enc);
#endif
return SYSERR;
}
res = verifySig(message, size, sig,
- &hello->publicKey);
+ &hello->publicKey);
if (res == SYSERR)
GE_LOG(ectx,
- GE_ERROR | GE_REQUEST | GE_DEVELOPER | GE_USER,
- _("Signature failed verification: signature invalid.\n"));
+ GE_ERROR | GE_REQUEST | GE_DEVELOPER | GE_USER,
+ _("Signature failed verification: signature invalid.\n"));
FREE(hello);
return res;
}
@@ -834,24 +834,24 @@
* @return OK on success SYSERR on error
*/
static int blacklistHost(const PeerIdentity * identity,
- unsigned int desperation,
- int strict) {
+ unsigned int desperation,
+ int strict) {
EncName hn;
HostEntry * entry;
int i;
cron_t now;
GE_ASSERT(ectx,
- numberOfHosts_ <= sizeOfHosts_);
+ numberOfHosts_ <= sizeOfHosts_);
MUTEX_LOCK(lock_);
entry = findHost(identity);
if (entry == NULL) {
for (i=0;i<MAX_TEMP_HOSTS;i++) {
if (0 == memcmp(identity,
- &tempHosts[i].identity,
- sizeof(PeerIdentity))) {
- entry = &tempHosts[i];
- break;
+ &tempHosts[i].identity,
+ sizeof(PeerIdentity))) {
+ entry = &tempHosts[i];
+ break;
}
}
}
@@ -871,26 +871,26 @@
} else {
if (entry->until < now)
entry->delta
- = weak_randomi(1+desperation*cronSECONDS);
+ = weak_randomi(1+desperation*cronSECONDS);
else
entry->delta
- += weak_randomi(1+desperation*cronSECONDS);
+ += weak_randomi(1+desperation*cronSECONDS);
}
if (entry->delta > 4 * cronHOURS)
entry->delta = 4 * cronHOURS;
entry->until = now + entry->delta;
entry->strict = strict;
hash2enc(&identity->hashPubKey,
- &hn);
+ &hn);
#if DEBUG_IDENTITY
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_DEVELOPER,
- "Blacklisting host `%s' for %llu seconds"
- " until %llu (strict=%d).\n",
- &hn,
- entry->delta / cronSECONDS,
- entry->until,
- strict);
+ GE_INFO | GE_REQUEST | GE_DEVELOPER,
+ "Blacklisting host `%s' for %llu seconds"
+ " until %llu (strict=%d).\n",
+ &hn,
+ entry->delta / cronSECONDS,
+ entry->until,
+ strict);
#endif
MUTEX_UNLOCK(lock_);
return OK;
@@ -920,14 +920,14 @@
EncName enc;
IF_GELOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- hash2enc(&identity->hashPubKey,
- &enc));
+ GE_INFO | GE_USER | GE_BULK,
+ hash2enc(&identity->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- _("Peer `%s' is currently strictly blacklisted (for another
%llums).\n"),
- &enc,
- entry->until - now);
+ GE_INFO | GE_USER | GE_BULK,
+ _("Peer `%s' is currently strictly blacklisted (for another %llums).\n"),
+ &enc,
+ entry->until - now);
#endif
MUTEX_UNLOCK(lock_);
return YES;
@@ -953,10 +953,10 @@
if (entry == NULL) {
for (i=0;i<MAX_TEMP_HOSTS;i++) {
if (0 == memcmp(identity,
- &tempHosts[i].identity,
- sizeof(PeerIdentity))) {
- entry = &tempHosts[i];
- break;
+ &tempHosts[i].identity,
+ sizeof(PeerIdentity))) {
+ entry = &tempHosts[i];
+ break;
}
}
}
@@ -982,8 +982,8 @@
* @return the number of hosts matching
*/
static int forEachHost(cron_t now,
- HostIterator callback,
- void * data) {
+ HostIterator callback,
+ void * data) {
int i;
int j;
int count;
@@ -994,40 +994,40 @@
ret = OK;
GE_ASSERT(ectx,
- numberOfHosts_ <= sizeOfHosts_);
+ numberOfHosts_ <= sizeOfHosts_);
count = 0;
MUTEX_LOCK(lock_);
for (i=0;i<numberOfHosts_;i++) {
entry = hosts_[i];
if (0 == memcmp(&entry->identity,
- &myIdentity,
- sizeof(PeerIdentity)))
+ &myIdentity,
+ sizeof(PeerIdentity)))
continue;
if ( (now == 0) ||
- (now >= entry->until) ) {
+ (now >= entry->until) ) {
count++;
if (callback != NULL) {
- hi = entry->identity;
- for (j=0;j<entry->protocolCount;j++) {
- proto = entry->protocols[j];
- MUTEX_UNLOCK(lock_);
- ret = callback(&hi,
- proto,
- YES,
- data);
- MUTEX_LOCK(lock_);
- if (ret != OK)
- break;
- /* we gave up the lock,
- need to re-acquire entry (if possible)! */
- if (i >= numberOfHosts_)
- break;
- entry = hosts_[i];
- if (0 == memcmp(&entry->identity,
- &myIdentity,
- sizeof(PeerIdentity)))
- break;
- }
+ hi = entry->identity;
+ for (j=0;j<entry->protocolCount;j++) {
+ proto = entry->protocols[j];
+ MUTEX_UNLOCK(lock_);
+ ret = callback(&hi,
+ proto,
+ YES,
+ data);
+ MUTEX_LOCK(lock_);
+ if (ret != OK)
+ break;
+ /* we gave up the lock,
+ need to re-acquire entry (if possible)! */
+ if (i >= numberOfHosts_)
+ break;
+ entry = hosts_[i];
+ if (0 == memcmp(&entry->identity,
+ &myIdentity,
+ sizeof(PeerIdentity)))
+ break;
+ }
}
} else {
#if 0
@@ -1035,16 +1035,16 @@
EncName enc;
IF_GELOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- hash2enc(&entry->identity.hashPubKey,
- &enc));
+ GE_INFO | GE_USER | GE_BULK,
+ hash2enc(&entry->identity.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- entry->strict ?
- _("Peer `%s' is currently strictly blacklisted (for another
%llums).\n") :
- _("Peer `%s' is currently blacklisted (for another %llums).\n"),
- &enc,
- entry->until - now);
+ GE_INFO | GE_USER | GE_BULK,
+ entry->strict ?
+ _("Peer `%s' is currently strictly blacklisted (for another
%llums).\n") :
+ _("Peer `%s' is currently blacklisted (for another %llums).\n"),
+ &enc,
+ entry->until - now);
#endif
#endif
}
@@ -1059,17 +1059,17 @@
if (entry->helloCount == 0)
continue;
if ( (now == 0) ||
- (now >= entry->until) ) {
+ (now >= entry->until) ) {
count++;
if (callback != NULL) {
- hi = entry->identity;
- proto = entry->protocols[0];
- MUTEX_UNLOCK(lock_);
- ret = callback(&hi,
- proto,
- YES,
- data);
- MUTEX_LOCK(lock_);
+ hi = entry->identity;
+ proto = entry->protocols[0];
+ MUTEX_UNLOCK(lock_);
+ ret = callback(&hi,
+ proto,
+ YES,
+ data);
+ MUTEX_LOCK(lock_);
}
}
}
@@ -1090,24 +1090,24 @@
return; /* unchanged */
host->trust = host->trust & TRUST_ACTUAL_MASK;
hash2enc(&host->identity.hashPubKey,
- &fil);
+ &fil);
fn = MALLOC(strlen(trustDirectory)+sizeof(EncName)+1);
strcpy(fn, trustDirectory);
strcat(fn, (char*) &fil);
if (host->trust == 0) {
if ( (0 != UNLINK(fn)) &&
- (errno != ENOENT) )
+ (errno != ENOENT) )
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "unlink",
- fn);
+ GE_WARNING | GE_USER | GE_BULK,
+ "unlink",
+ fn);
} else {
trust = htonl(host->trust);
disk_file_write(ectx,
- fn,
- &trust,
- sizeof(unsigned int),
- "644");
+ fn,
+ &trust,
+ sizeof(unsigned int),
+ "644");
}
FREE(fn);
}
@@ -1127,21 +1127,21 @@
* @brief delete expired HELLO entries in data/hosts/
*/
static int discardHostsHelper(const char *filename,
- const char *dirname,
- void *now) {
+ const char *dirname,
+ void *now) {
char *fn;
struct stat hostStat;
int hostFile;
fn = MALLOC(strlen(filename) + strlen(dirname) + 2);
sprintf(fn,
- "%s%s%s",
- dirname,
- DIR_SEPARATOR_STR,
- filename);
+ "%s%s%s",
+ dirname,
+ DIR_SEPARATOR_STR,
+ filename);
hostFile = disk_file_open(ectx,
- fn,
- O_WRONLY);
+ fn,
+ O_WRONLY);
if (hostFile != -1) {
if (FSTAT(hostFile, &hostStat) == 0) {
CLOSE(hostFile);
@@ -1163,14 +1163,14 @@
timeNow = time(NULL);
disk_directory_scan(ectx,
- networkIdDirectory,
- &discardHostsHelper,
- (void *) &timeNow);
+ networkIdDirectory,
+ &discardHostsHelper,
+ (void *) &timeNow);
}
static int identityRequestConnectHandler(struct ClientHandle * sock,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
const CS_identity_connect_MESSAGE * msg;
int ret;
@@ -1178,18 +1178,18 @@
return SYSERR;
msg = (const CS_identity_connect_MESSAGE*) message;
coreAPI->unicast(&msg->other,
- NULL,
- 0,
- 0);
+ NULL,
+ 0,
+ 0);
ret = coreAPI->queryPeerStatus(&msg->other,
- NULL,
- NULL);
+ NULL,
+ NULL);
return coreAPI->sendValueToClient(sock,
- ret != OK ? NO : YES);
+ ret != OK ? NO : YES);
}
static int identityHelloHandler(struct ClientHandle * sock,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
const P2P_hello_MESSAGE * msg;
P2P_hello_MESSAGE * hello;
@@ -1204,20 +1204,20 @@
}
hello = MALLOC(ntohs(msg->header.size));
memcpy(hello,
- msg,
- ntohs(msg->header.size));
+ msg,
+ ntohs(msg->header.size));
hello->header.type = htons(p2p_PROTO_hello);
coreAPI->injectMessage(NULL,
- (const char*) hello,
- ntohs(msg->header.size),
- NO,
- NULL);
+ (const char*) hello,
+ ntohs(msg->header.size),
+ NO,
+ NULL);
FREE(hello);
return OK;
}
static int identityRequestHelloHandler(struct ClientHandle * sock,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
/* transport types in order of preference
for location URIs (by best guess at what
people are most likely to actually run) */
@@ -1245,20 +1245,20 @@
hello = NULL;
pos = 0;
while ( (hello == NULL) &&
- (types[pos] != 0) )
+ (types[pos] != 0) )
hello = tapi->createhello(types[pos++]);
coreAPI->releaseService(tapi);
if (hello == NULL)
return SYSERR;
hello->header.type = htons(CS_PROTO_identity_HELLO);
ret = coreAPI->sendToClient(sock,
- &hello->header);
+ &hello->header);
FREE(hello);
return ret;
}
static int identityRequestSignatureHandler(struct ClientHandle * sock,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
CS_identity_signature_MESSAGE reply;
if (ntohs(message->size) <= sizeof(MESSAGE_HEADER))
@@ -1266,17 +1266,17 @@
reply.header.size = htons(sizeof(CS_identity_signature_MESSAGE));
reply.header.type = htons(CS_PROTO_identity_SIGNATURE);
if (OK != signData(&message[1],
- ntohs(message->size) - sizeof(MESSAGE_HEADER),
- &reply.sig))
+ ntohs(message->size) - sizeof(MESSAGE_HEADER),
+ &reply.sig))
return SYSERR;
return coreAPI->sendToClient(sock,
- &reply.header);
+ &reply.header);
}
static int hostInfoIterator(const PeerIdentity * identity,
- unsigned short protocol,
- int confirmed,
- void * data) {
+ unsigned short protocol,
+ int confirmed,
+ void * data) {
struct ClientHandle * sock = data;
Transport_ServiceAPI * transport;
CS_identity_peer_info_MESSAGE * reply;
@@ -1290,8 +1290,8 @@
if (confirmed == NO)
return OK;
hello = identity2Hello(identity,
- protocol,
- YES);
+ protocol,
+ YES);
if (hello == NULL)
return OK; /* ignore -- happens if HELLO just expired */
transport = coreAPI->requestService("transport");
@@ -1303,8 +1303,8 @@
len = 0;
address = NULL;
transport->helloToAddress(hello,
- &address,
- &len);
+ &address,
+ &len);
FREE(hello);
coreAPI->releaseService(transport);
if (len >= MAX_BUFFER_SIZE - sizeof(CS_identity_peer_info_MESSAGE) ) {
@@ -1313,8 +1313,8 @@
len = 0;
}
if (OK != coreAPI->queryPeerStatus(identity,
- &bpm,
- &last)) {
+ &bpm,
+ &last)) {
last = 0;
bpm = 0;
}
@@ -1326,22 +1326,22 @@
reply->trust = htonl(getHostTrust(identity));
reply->bpm = htonl(bpm);
memcpy(&reply[1],
- address,
- len);
+ address,
+ len);
FREENONNULL(address);
ret = coreAPI->sendToClient(sock,
- &reply->header);
+ &reply->header);
FREE(reply);
return ret;
}
static int identityRequestInfoHandler(struct ClientHandle * sock,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
forEachHost(0,
- &hostInfoIterator,
- sock);
+ &hostInfoIterator,
+ sock);
return coreAPI->sendValueToClient(sock,
- OK);
+ OK);
}
@@ -1378,17 +1378,17 @@
for (i=0;i<MAX_TEMP_HOSTS;i++)
memset(&tempHosts[i],
- 0,
- sizeof(HostEntry));
+ 0,
+ sizeof(HostEntry));
numberOfHosts_ = 0;
gnHome = NULL;
GE_ASSERT(ectx,
- -1 != GC_get_configuration_value_filename(coreAPI->cfg,
- "GNUNETD",
- "GNUNETD_HOME",
- VAR_DAEMON_DIRECTORY,
- &gnHome));
+ -1 != GC_get_configuration_value_filename(coreAPI->cfg,
+ "GNUNETD",
+ "GNUNETD_HOME",
+ VAR_DAEMON_DIRECTORY,
+ &gnHome));
if (gnHome == NULL)
return NULL;
disk_directory_create(ectx, gnHome);
@@ -1398,54 +1398,54 @@
strcat(tmp, HOST_DIR);
networkIdDirectory = NULL;
GE_ASSERT(ectx,
- -1 != GC_get_configuration_value_filename(coreAPI->cfg,
- "GNUNETD",
- "HOSTS",
- tmp,
- &networkIdDirectory));
+ -1 != GC_get_configuration_value_filename(coreAPI->cfg,
+ "GNUNETD",
+ "HOSTS",
+ tmp,
+ &networkIdDirectory));
FREE(tmp);
disk_directory_create(ectx,
- networkIdDirectory);
+ networkIdDirectory);
trustDirectory = MALLOC(strlen(gnHome) +
- strlen(TRUSTDIR)+2);
+ strlen(TRUSTDIR)+2);
strcpy(trustDirectory, gnHome);
strcat(trustDirectory, DIR_SEPARATOR_STR);
strcat(trustDirectory, TRUSTDIR);
disk_directory_create(ectx,
- trustDirectory);
+ trustDirectory);
FREE(gnHome);
lock_ = MUTEX_CREATE(YES);
initPrivateKey(capi->ectx,
- capi->cfg);
+ capi->cfg);
getPeerIdentity(getPublicPrivateKey(),
- &myIdentity);
+ &myIdentity);
cronScanDirectoryDataHosts(NULL);
cron_add_job(coreAPI->cron,
- &cronScanDirectoryDataHosts,
- CRON_DATA_HOST_FREQ,
- CRON_DATA_HOST_FREQ,
- NULL);
+ &cronScanDirectoryDataHosts,
+ CRON_DATA_HOST_FREQ,
+ CRON_DATA_HOST_FREQ,
+ NULL);
cron_add_job(coreAPI->cron,
- &cronFlushTrustBuffer,
- CRON_TRUST_FLUSH_FREQ,
- CRON_TRUST_FLUSH_FREQ,
- NULL);
+ &cronFlushTrustBuffer,
+ CRON_TRUST_FLUSH_FREQ,
+ CRON_TRUST_FLUSH_FREQ,
+ NULL);
cron_add_job(coreAPI->cron,
- &cronDiscardHosts,
- 0,
- CRON_DISCARD_HOSTS_INTERVAL,
- NULL);
+ &cronDiscardHosts,
+ 0,
+ CRON_DISCARD_HOSTS_INTERVAL,
+ NULL);
coreAPI->registerClientHandler(CS_PROTO_identity_CONNECT,
- &identityRequestConnectHandler);
+ &identityRequestConnectHandler);
coreAPI->registerClientHandler(CS_PROTO_identity_HELLO,
- &identityHelloHandler);
+ &identityHelloHandler);
coreAPI->registerClientHandler(CS_PROTO_identity_request_HELLO,
- &identityRequestHelloHandler);
+ &identityRequestHelloHandler);
coreAPI->registerClientHandler(CS_PROTO_identity_request_SIGN,
- &identityRequestSignatureHandler);
+ &identityRequestSignatureHandler);
coreAPI->registerClientHandler(CS_PROTO_identity_request_INFO,
- &identityRequestInfoHandler);
+ &identityRequestInfoHandler);
return &id;
}
@@ -1458,38 +1458,38 @@
HostEntry * entry;
coreAPI->unregisterClientHandler(CS_PROTO_identity_CONNECT,
- &identityRequestConnectHandler);
+ &identityRequestConnectHandler);
coreAPI->unregisterClientHandler(CS_PROTO_identity_HELLO,
- &identityHelloHandler);
+ &identityHelloHandler);
coreAPI->unregisterClientHandler(CS_PROTO_identity_request_HELLO,
- &identityRequestHelloHandler);
+ &identityRequestHelloHandler);
coreAPI->unregisterClientHandler(CS_PROTO_identity_request_SIGN,
- &identityRequestSignatureHandler);
+ &identityRequestSignatureHandler);
coreAPI->unregisterClientHandler(CS_PROTO_identity_request_INFO,
- &identityRequestInfoHandler);
+ &identityRequestInfoHandler);
for (i=0;i<MAX_TEMP_HOSTS;i++) {
entry = &tempHosts[i];
for (j=0;j<entry->helloCount;j++)
FREE(entry->hellos[j]);
GROW(entry->hellos,
- entry->helloCount,
- 0);
+ entry->helloCount,
+ 0);
GROW(entry->protocols,
- entry->protocolCount,
- 0);
+ entry->protocolCount,
+ 0);
}
cron_del_job(coreAPI->cron,
- &cronScanDirectoryDataHosts,
- CRON_DATA_HOST_FREQ,
- NULL);
+ &cronScanDirectoryDataHosts,
+ CRON_DATA_HOST_FREQ,
+ NULL);
cron_del_job(coreAPI->cron,
- &cronFlushTrustBuffer,
- CRON_TRUST_FLUSH_FREQ,
- NULL);
+ &cronFlushTrustBuffer,
+ CRON_TRUST_FLUSH_FREQ,
+ NULL);
cron_del_job(coreAPI->cron,
- &cronDiscardHosts,
- CRON_DISCARD_HOSTS_INTERVAL,
- NULL);
+ &cronDiscardHosts,
+ CRON_DISCARD_HOSTS_INTERVAL,
+ NULL);
cronFlushTrustBuffer(NULL);
MUTEX_DESTROY(lock_);
lock_ = NULL;
@@ -1498,11 +1498,11 @@
for (j=0;j<entry->helloCount;j++)
FREE(entry->hellos[j]);
GROW(entry->hellos,
- entry->helloCount,
- 0);
+ entry->helloCount,
+ 0);
GROW(entry->protocols,
- entry->protocolCount,
- 0);
+ entry->protocolCount,
+ 0);
FREE(entry);
}
GROW(hosts_,
Modified: GNUnet/src/applications/identity/identitytest.c
===================================================================
--- GNUnet/src/applications/identity/identitytest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/identity/identitytest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -80,31 +80,31 @@
(&pid,
-identity->getHostTrust(&pid));
ASSERT(4 == identity->changeHostTrust
- (&pid, 4));
+ (&pid, 4));
releaseService(identity);
identity = requestService("identity");
ASSERT(4 == identity->getHostTrust(&pid));
ASSERT(5 == identity->changeHostTrust
- (&pid, 5));
+ (&pid, 5));
ASSERT(-2 == identity->changeHostTrust
- (&pid, -2));
+ (&pid, -2));
ASSERT(7 == identity->getHostTrust(&pid));
ASSERT(-7 == identity->changeHostTrust
- (&pid, -40));
+ (&pid, -40));
pkey = identity->getPublicPrivateKey();
identity->getPeerIdentity(pkey,
- &pid);
+ &pid);
ASSERT(0 == identity->getHostTrust(&pid));
pkey = identity->getPublicPrivateKey();
ASSERT(OK == identity->signData("TestData",
- 8,
- &sig));
+ 8,
+ &sig));
ASSERT(OK == verifySig("TestData",
- 8,
- &sig,
- pkey));
+ 8,
+ &sig,
+ pkey));
/* to test:
hello verification, temporary storage,
@@ -116,12 +116,12 @@
}
static int hcb(void * data,
- const PeerIdentity * identity,
- const void * address,
- unsigned int addr_len,
- cron_t last_message,
- unsigned int trust,
- unsigned int bpmFromPeer) {
+ const PeerIdentity * identity,
+ const void * address,
+ unsigned int addr_len,
+ cron_t last_message,
+ unsigned int trust,
+ unsigned int bpmFromPeer) {
/* TODO: do something meaningful */
return OK;
}
@@ -133,8 +133,8 @@
ret = OK;
sock = client_connection_create(NULL, cfg);
gnunet_identity_request_peer_infos(sock,
- &hcb,
- &ret);
+ &hcb,
+ &ret);
connection_destroy(sock);
return ret;
}
@@ -144,15 +144,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
err = 0;
if (OK != runTest())
err = 1;
Modified: GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c
===================================================================
--- GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -119,8 +119,8 @@
* @param out output
*/
static int sqlite_encode_binary(const unsigned char *in,
- int n,
- unsigned char *out){
+ int n,
+ unsigned char *out){
char c;
unsigned char *start = out;
@@ -149,8 +149,8 @@
* @return number of output bytes, -1 on error
*/
static int sqlite_decode_binary_n(const unsigned char *in,
- unsigned char *out,
- unsigned int num){
+ unsigned char *out,
+ unsigned int num){
unsigned char *start = out;
unsigned char *stop = (unsigned char *) (in + num);
@@ -170,15 +170,15 @@
* @brief Prepare a SQL statement
*/
static int sq_prepare(sqliteHandle *dbh,
- const char *zSql, /* SQL statement, UTF-8 encoded */
- sqlite3_stmt **ppStmt) { /* OUT: Statement handle */
+ const char *zSql, /* SQL statement, UTF-8 encoded */
+ sqlite3_stmt **ppStmt) { /* OUT: Statement handle */
char * dummy;
return sqlite3_prepare(dbh->dbh,
- zSql,
- strlen(zSql),
- ppStmt,
- (const char**) &dummy);
+ zSql,
+ strlen(zSql),
+ ppStmt,
+ (const char**) &dummy);
}
/**
@@ -190,18 +190,18 @@
size_t mem;
GC_get_configuration_value_filename(coreAPI->cfg,
- "KEYVALUE_DATABASE",
- "DIR",
- VAR_DAEMON_DIRECTORY "/kvstore/",
- &dir);
+ "KEYVALUE_DATABASE",
+ "DIR",
+ VAR_DAEMON_DIRECTORY "/kvstore/",
+ &dir);
disk_directory_create(ectx, dir);
mem = strlen(dir) + strlen(name) + 6;
fn = MALLOC(mem);
SNPRINTF(fn,
- mem,
- "%s/%s.dat",
- dir,
- name);
+ mem,
+ "%s/%s.dat",
+ dir,
+ name);
FREE(dir);
return fn;
}
@@ -219,13 +219,13 @@
return dbs[idx];
db = MALLOC(sizeof(sqliteDatabase));
memset(db,
- 0,
- sizeof(sqliteDatabase));
+ 0,
+ sizeof(sqliteDatabase));
db->fn = getDBFileName(name);
db->name = STRDUP(name);
APPEND(dbs,
- databases,
- db);
+ databases,
+ db);
return db;
}
@@ -253,11 +253,11 @@
dbh = MALLOC(sizeof(sqliteHandle));
dbh->tid = PTHREAD_GET_SELF();
if (sqlite3_open(db->fn,
- &dbh->dbh) != SQLITE_OK) {
+ &dbh->dbh) != SQLITE_OK) {
printf("FN: %s\n", db->fn);
- LOG_SQLITE(dbh->dbh,
- GE_ERROR | GE_BULK | GE_USER,
- "sqlite3_open");
+ LOG_SQLITE(dbh->dbh,
+ GE_ERROR | GE_BULK | GE_USER,
+ "sqlite3_open");
sqlite3_close(dbh->dbh);
MUTEX_UNLOCK(lock);
PTHREAD_REL_SELF(dbh->tid);
@@ -265,8 +265,8 @@
return NULL;
}
APPEND(db->handles,
- db->handle_count,
- dbh);
+ db->handle_count,
+ dbh);
sqlite3_exec(dbh->dbh, "PRAGMA temp_store=MEMORY", NULL, NULL, NULL);
sqlite3_exec(dbh->dbh, "PRAGMA synchronous=OFF", NULL, NULL, NULL);
sqlite3_exec(dbh->dbh, "PRAGMA count_changes=OFF", NULL, NULL, NULL);
@@ -283,8 +283,8 @@
PTHREAD_REL_SELF(dbh->tid);
if (sqlite3_close(dbh->dbh) != SQLITE_OK)
LOG_SQLITE(dbh->dbh,
- LOG_ERROR,
- "sqlite_close");
+ LOG_ERROR,
+ "sqlite_close");
FREE(dbh);
}
GROW(db->handles,
@@ -310,8 +310,8 @@
close_database(db);
dbs[idx] = dbs[databases-1];
GROW(dbs,
- databases,
- databases - 1);
+ databases,
+ databases - 1);
break;
}
}
@@ -327,7 +327,7 @@
* @return a handle
*/
static KVHandle *getTable(const char *database,
- const char *table) {
+ const char *table) {
sqlite3_stmt *stmt;
unsigned int len;
KVHandle *ret;
@@ -338,22 +338,22 @@
if (dbh == NULL)
return NULL;
sq_prepare(dbh,
- "Select 1 from sqlite_master where tbl_name = ?",
- &stmt);
+ "Select 1 from sqlite_master where tbl_name = ?",
+ &stmt);
len = strlen(table);
sqlite3_bind_text(stmt, 1, table, len, SQLITE_STATIC);
if (sqlite3_step(stmt) == SQLITE_DONE) {
char * create = MALLOC(len + 58);
sprintf(create,
- "CREATE TABLE %s (gn_key BLOB, gn_val BLOB, gn_age BIGINT)",
- table);
+ "CREATE TABLE %s (gn_key BLOB, gn_val BLOB, gn_age BIGINT)",
+ table);
if (sqlite3_exec(dbh->dbh, create, NULL, NULL, NULL) != SQLITE_OK)
{
LOG_SQLITE(dbh->dbh,
- LOG_ERROR,
- "sqlite_create");
+ LOG_ERROR,
+ "sqlite_create");
sqlite3_finalize(stmt);
FREE(create);
return NULL;
@@ -366,8 +366,8 @@
/* FIXME: more indexes */
idx = MALLOC(len + 34);
sprintf(idx,
- "CREATE INDEX idx_key ON %s (gn_key)",
- table);
+ "CREATE INDEX idx_key ON %s (gn_key)",
+ table);
sqlite3_exec(dbh->dbh, idx, NULL, NULL, NULL);
FREE(idx);
ret = MALLOC(sizeof(KVHandle));
@@ -388,12 +388,12 @@
* @param closure optional parameter for handler
*/
static void *get(KVHandle *kv,
- void *key,
- int keylen,
- unsigned int sort,
- unsigned int limit,
- KVCallback handler,
- void *closure) {
+ void *key,
+ int keylen,
+ unsigned int sort,
+ unsigned int limit,
+ KVCallback handler,
+ void *closure) {
unsigned int len, enclen, retlen;
char *sel, *order, *where, limit_spec[30];
sqlite3_stmt *stmt;
@@ -443,11 +443,11 @@
*limit_spec = 0;
sprintf(sel,
- "SELECT gn_val FROM %s %s %s %s",
- kv->table,
- where,
- order,
- limit_spec);
+ "SELECT gn_val FROM %s %s %s %s",
+ kv->table,
+ where,
+ order,
+ limit_spec);
sq_prepare(dbh, sel, &stmt);
if (key)
@@ -468,7 +468,7 @@
if (handler(closure, ret, retlen) != OK)
{
FREE(sel);
- FREENONNULL(key_enc);
+ FREENONNULL(key_enc);
FREE(ret_dec);
sqlite3_finalize(stmt);
@@ -508,8 +508,8 @@
ins = MALLOC(len + 68);
sprintf(ins,
- "INSERT INTO %s(gn_key, gn_val, gn_age) values (?, ?, ?)",
- kv->table);
+ "INSERT INTO %s(gn_key, gn_val, gn_age) values (?, ?, ?)",
+ kv->table);
key_enc = MALLOC(keylen * 2);
keyenc_len = sqlite_encode_binary(key, keylen, key_enc);
@@ -527,8 +527,8 @@
FREE(key_enc);
FREE(val_enc);
LOG_SQLITE(dbh->dbh,
- LOG_ERROR,
- "put");
+ LOG_ERROR,
+ "put");
sqlite3_finalize(stmt);
return SYSERR;
}
@@ -596,7 +596,7 @@
FREE(del);
FREENONNULL(keyenc);
LOG_SQLITE(dbh->dbh,
- LOG_ERROR, "delete");
+ LOG_ERROR, "delete");
sqlite3_finalize(stmt);
return SYSERR;
@@ -637,7 +637,7 @@
if (sqlite3_step(stmt) != SQLITE_DONE) {
FREE(drop);
LOG_SQLITE(dbh->dbh,
- LOG_ERROR, "drop");
+ LOG_ERROR, "drop");
sqlite3_finalize(stmt);
return SYSERR;
}
@@ -654,8 +654,8 @@
ectx = capi->ectx;
#if DEBUG_SQLITE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "KV-SQLite: initializing database\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "KV-SQLite: initializing database\n");
#endif
lock = MUTEX_CREATE(NO);
@@ -682,8 +682,8 @@
#if DEBUG_SQLITE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite KVStore: database shutdown\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite KVStore: database shutdown\n");
#endif
MUTEX_DESTROY(lock);
Modified: GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c
===================================================================
--- GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -81,15 +81,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("kvstore_sqlite");
if (api != NULL) {
ok = test(api);
Modified: GNUnet/src/applications/pingpong/pingpong.c
===================================================================
--- GNUnet/src/applications/pingpong/pingpong.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/pingpong/pingpong.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -116,28 +116,28 @@
/**
* We received a PING message, send the PONG reply.
- */
+ */
static int pingReceived(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
const P2P_pingpong_MESSAGE * pmsg;
P2P_pingpong_MESSAGE pong;
if (ntohs(msg->size) != sizeof(P2P_pingpong_MESSAGE) ) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
- _("Received malformed `%s' message. Dropping.\n"),
- "ping");
+ GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
+ _("Received malformed `%s' message. Dropping.\n"),
+ "ping");
return SYSERR;
}
if (stats != NULL)
stats->change(stat_pingReceived, 1);
pmsg = (const P2P_pingpong_MESSAGE *) msg;
if (0 != memcmp(coreAPI->myIdentity,
- &pmsg->receiver,
- sizeof(PeerIdentity))) {
+ &pmsg->receiver,
+ sizeof(PeerIdentity))) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- _("Received ping for another peer. Dropping.\n"));
+ GE_WARNING | GE_BULK | GE_ADMIN,
+ _("Received ping for another peer. Dropping.\n"));
return SYSERR; /* not for us */
}
@@ -145,27 +145,27 @@
EncName enc;
hash2enc(&sender->hashPubKey,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received ping from peer %s.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received ping from peer %s.\n",
+ &enc);
#endif
pong = *pmsg;
pong.header.type = htons(p2p_PROTO_PONG);
if (stats != NULL)
stats->change(stat_pingReceived, 1);
coreAPI->unicast(sender,
- &pong.header,
- EXTREME_PRIORITY,
- 0); /* send now! */
+ &pong.header,
+ EXTREME_PRIORITY,
+ 0); /* send now! */
if (stats != NULL)
stats->change(stat_pongSent, 1);
return OK;
}
static int sendPlaintext(const PeerIdentity * peer,
- const P2P_pingpong_MESSAGE * msg) {
+ const P2P_pingpong_MESSAGE * msg) {
TSession * mytsession;
int ret;
@@ -173,8 +173,8 @@
if (mytsession == NULL)
return SYSERR;
ret = coreAPI->sendPlaintext(mytsession,
- (char*)msg,
- sizeof(P2P_pingpong_MESSAGE));
+ (char*)msg,
+ sizeof(P2P_pingpong_MESSAGE));
transport->disconnect(mytsession);
return ret;
}
@@ -182,10 +182,10 @@
/**
* We received a PING message, send the PONG reply and notify the
* connection module that the session is still life.
- */
+ */
static int plaintextPingReceived(const PeerIdentity * sender,
- const MESSAGE_HEADER * hmsg,
- TSession * tsession) {
+ const MESSAGE_HEADER * hmsg,
+ TSession * tsession) {
#if DEBUG_PINGPONG
EncName enc;
#endif
@@ -195,30 +195,30 @@
if (ntohs(hmsg->size) != sizeof(P2P_pingpong_MESSAGE) ) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
- _("Received malformed `%s' message. Dropping.\n"),
- "ping");
+ GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
+ _("Received malformed `%s' message. Dropping.\n"),
+ "ping");
GE_BREAK_OP(NULL, 0);
return SYSERR;
}
pmsg = (const P2P_pingpong_MESSAGE *) hmsg;
if (0 != memcmp(coreAPI->myIdentity,
- &pmsg->receiver,
- sizeof(PeerIdentity))) {
+ &pmsg->receiver,
+ sizeof(PeerIdentity))) {
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_ADMIN,
- _("Received PING not destined for us!\n"));
+ GE_INFO | GE_REQUEST | GE_ADMIN,
+ _("Received PING not destined for us!\n"));
GE_BREAK_OP(NULL, 0);
return SYSERR; /* not for us */
}
#if DEBUG_PINGPONG
hash2enc(&sender->hashPubKey,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received plaintext ping from peer %s.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received plaintext ping from peer %s.\n",
+ &enc);
#endif
pong = *pmsg;
pong.header.type = htons(p2p_PROTO_PONG);
@@ -227,8 +227,8 @@
ret = SYSERR;
if (tsession != NULL)
ret = coreAPI->sendPlaintext(tsession,
- (char*) &pong,
- sizeof(P2P_pingpong_MESSAGE));
+ (char*) &pong,
+ sizeof(P2P_pingpong_MESSAGE));
if (ret != OK)
ret = sendPlaintext(sender, &pong);
if (ret == OK) {
@@ -243,9 +243,9 @@
/**
* Handler for a pong.
- */
+ */
static int pongReceived(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
int i;
const P2P_pingpong_MESSAGE * pmsg;
PingPongEntry * entry;
@@ -257,21 +257,21 @@
pmsg = (const P2P_pingpong_MESSAGE *) msg;
if ( (ntohs(msg->size) != sizeof(P2P_pingpong_MESSAGE)) ||
(0 != memcmp(sender,
- &pmsg->receiver,
- sizeof(PeerIdentity))) ) {
+ &pmsg->receiver,
+ sizeof(PeerIdentity))) ) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
- _("Received malformed `%s' message. Dropping.\n"),
- "pong");
+ GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
+ _("Received malformed `%s' message. Dropping.\n"),
+ "pong");
return SYSERR; /* bad pong */
}
#if DEBUG_PINGPONG
hash2enc(&sender->hashPubKey,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received PONG from `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received PONG from `%s'.\n",
+ &enc);
#endif
matched = 0;
if (stats != NULL)
@@ -280,43 +280,43 @@
for (i=0;i<MAX_PING_PONG;i++) {
entry = &pingPongs[i];
if ( ((int)ntohl(pmsg->challenge) == entry->challenge) &&
- (0 == memcmp(sender,
- &entry->receiverIdentity,
- sizeof(PeerIdentity))) &&
- (entry->plaintext == NO) ) {
+ (0 == memcmp(sender,
+ &entry->receiverIdentity,
+ sizeof(PeerIdentity))) &&
+ (entry->plaintext == NO) ) {
entry->method(entry->data);
/* entry was valid for one time only */
memset(entry,
- 0,
- sizeof(PingPongEntry));
+ 0,
+ sizeof(PingPongEntry));
matched++;
}
}
MUTEX_UNLOCK(pingPongLock);
#if DEBUG_PINGPONG
hash2enc(&sender->hashPubKey,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received PONG from `%s' matched %u peers.\n",
- &enc,
- matched);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received PONG from `%s' matched %u peers.\n",
+ &enc,
+ matched);
#endif
if (matched == 0) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- _("Could not match PONG against any PING. "
- "Try increasing MAX_PING_PONG constant.\n"));
+ GE_WARNING | GE_BULK | GE_ADMIN,
+ _("Could not match PONG against any PING. "
+ "Try increasing MAX_PING_PONG constant.\n"));
}
return OK;
}
/**
* Handler for a pong.
- */
+ */
static int plaintextPongReceived(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg,
- TSession * session) {
+ const MESSAGE_HEADER * msg,
+ TSession * session) {
int i;
const P2P_pingpong_MESSAGE * pmsg;
PingPongEntry * entry;
@@ -328,12 +328,12 @@
pmsg = (const P2P_pingpong_MESSAGE *) msg;
if ( (ntohs(msg->size) != sizeof(P2P_pingpong_MESSAGE)) ||
(0 != memcmp(sender,
- &pmsg->receiver,
- sizeof(PeerIdentity)))) {
+ &pmsg->receiver,
+ sizeof(PeerIdentity)))) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
- _("Received malformed `%s' message. Dropping.\n"),
- "pong");
+ GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
+ _("Received malformed `%s' message. Dropping.\n"),
+ "pong");
return SYSERR; /* bad pong */
}
if (stats != NULL)
@@ -343,33 +343,33 @@
for (i=0;i<MAX_PING_PONG;i++) {
entry = &pingPongs[i];
if ( ((int)ntohl(pmsg->challenge) == entry->challenge) &&
- (0 == memcmp(sender,
- &entry->receiverIdentity,
- sizeof(PeerIdentity))) &&
- (entry->plaintext == YES) ) {
+ (0 == memcmp(sender,
+ &entry->receiverIdentity,
+ sizeof(PeerIdentity))) &&
+ (entry->plaintext == YES) ) {
entry->method(entry->data);
/* entry was valid for one time only */
memset(entry,
- 0,
- sizeof(PingPongEntry));
+ 0,
+ sizeof(PingPongEntry));
matched++;
}
}
MUTEX_UNLOCK(pingPongLock);
#if DEBUG_PINGPONG
hash2enc(&sender->hashPubKey,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received plaintext PONG from `%s' matched %u peers.\n",
- &enc,
- matched);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received plaintext PONG from `%s' matched %u peers.\n",
+ &enc,
+ matched);
#endif
if (matched == 0) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- _("Could not match PONG against any PING. "
- "Try increasing MAX_PING_PONG constant.\n"));
+ GE_WARNING | GE_BULK | GE_ADMIN,
+ _("Could not match PONG against any PING. "
+ "Try increasing MAX_PING_PONG constant.\n"));
}
return OK;
}
@@ -388,10 +388,10 @@
*/
static MESSAGE_HEADER *
createPing(const PeerIdentity * receiver,
- CronJob method,
- void * data,
- int plaintext,
- int challenge) {
+ CronJob method,
+ void * data,
+ int plaintext,
+ int challenge) {
int i;
int j;
TIME_T min;
@@ -410,9 +410,9 @@
}
if (j == -1) { /* all send this second!? */
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- _("Cannot create PING, table full. "
- "Try increasing MAX_PING_PONG.\n"));
+ GE_WARNING | GE_BULK | GE_ADMIN,
+ _("Cannot create PING, table full. "
+ "Try increasing MAX_PING_PONG.\n"));
MUTEX_UNLOCK(pingPongLock);
return NULL;
}
@@ -445,22 +445,22 @@
* @returns OK on success, SYSERR on error
*/
static int initiatePing(const PeerIdentity * receiver,
- CronJob method,
- void * data,
- int usePlaintext,
- int challenge) {
+ CronJob method,
+ void * data,
+ int usePlaintext,
+ int challenge) {
MESSAGE_HEADER * pmsg;
pmsg = createPing(receiver,
- method,
- data,
- usePlaintext,
- challenge);
+ method,
+ data,
+ usePlaintext,
+ challenge);
if (pmsg == NULL)
return SYSERR;
if (usePlaintext == YES) {
if (OK != sendPlaintext(receiver,
- (const P2P_pingpong_MESSAGE*) pmsg)) {
+ (const P2P_pingpong_MESSAGE*) pmsg)) {
FREE(pmsg);
return SYSERR;
}
@@ -468,9 +468,9 @@
stats->change(stat_plaintextPingSent, 1);
} else {
coreAPI->unicast(receiver,
- pmsg,
- EXTREME_PRIORITY,
- 0);
+ pmsg,
+ EXTREME_PRIORITY,
+ 0);
if (stats != NULL)
stats->change(stat_ciphertextPingSent, 1);
}
@@ -487,7 +487,7 @@
ectx = capi->ectx;
GE_ASSERT(ectx,
- sizeof(P2P_pingpong_MESSAGE) == 72);
+ sizeof(P2P_pingpong_MESSAGE) == 72);
coreAPI = capi;
identity = capi->requestService("identity");
if (identity == NULL) {
@@ -525,22 +525,22 @@
pingPongLock = capi->getConnectionModuleLock();
pingPongs = (PingPongEntry*) MALLOC(sizeof(PingPongEntry)*MAX_PING_PONG);
memset(pingPongs,
- 0,
- sizeof(PingPongEntry)*MAX_PING_PONG);
+ 0,
+ sizeof(PingPongEntry)*MAX_PING_PONG);
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- _("`%s' registering handlers %d %d (plaintext and ciphertext)\n"),
- "pingpong",
- p2p_PROTO_PING,
- p2p_PROTO_PONG);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ _("`%s' registering handlers %d %d (plaintext and ciphertext)\n"),
+ "pingpong",
+ p2p_PROTO_PING,
+ p2p_PROTO_PONG);
capi->registerHandler(p2p_PROTO_PING,
- &pingReceived);
+ &pingReceived);
capi->registerHandler(p2p_PROTO_PONG,
- &pongReceived);
+ &pongReceived);
capi->registerPlaintextHandler(p2p_PROTO_PING,
- &plaintextPingReceived);
+ &plaintextPingReceived);
capi->registerPlaintextHandler(p2p_PROTO_PONG,
- &plaintextPongReceived);
+ &plaintextPongReceived);
ret.ping = &initiatePing;
ret.pingUser = &createPing;
ret.ping_size = sizeof(P2P_pingpong_MESSAGE);
@@ -563,13 +563,13 @@
FREENONNULL(pingPongs[i].data);
FREE(pingPongs);
coreAPI->unregisterHandler(p2p_PROTO_PING,
- &pingReceived);
+ &pingReceived);
coreAPI->unregisterHandler(p2p_PROTO_PONG,
- &pongReceived);
+ &pongReceived);
coreAPI->unregisterPlaintextHandler(p2p_PROTO_PING,
- &plaintextPingReceived);
+ &plaintextPingReceived);
coreAPI->unregisterPlaintextHandler(p2p_PROTO_PONG,
- &plaintextPongReceived);
+ &plaintextPongReceived);
coreAPI = NULL;
return OK;
}
Modified: GNUnet/src/applications/rpc/parameters.c
===================================================================
--- GNUnet/src/applications/rpc/parameters.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/rpc/parameters.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -73,7 +73,7 @@
* RPC_paramSize(param) bytes of memory.
*/
void RPC_paramSerialize(RPC_Param * param,
- char * target) {
+ char * target) {
int i;
const char * paramName;
unsigned int dataLength;
@@ -90,18 +90,18 @@
paramName = RPC_paramName(param, i);
paramValue = NULL;
RPC_paramValueByPosition(param,
- i,
- &dataLength,
- ¶mValue);
+ i,
+ &dataLength,
+ ¶mValue);
memcpy(&target[pos],
- paramName,
- strlen(paramName)+1);
+ paramName,
+ strlen(paramName)+1);
pos += strlen(paramName)+1;
*(unsigned int*) &target[pos] = htonl(dataLength);
pos += sizeof(unsigned int);
memcpy(&target[pos],
- paramValue,
- dataLength);
+ paramValue,
+ dataLength);
pos += dataLength;
}
}
@@ -110,7 +110,7 @@
* Deserialize parameters from buffer.
*/
RPC_Param * RPC_paramDeserialize(char * buffer,
- size_t size) {
+ size_t size) {
RPC_Param * ret;
size_t pos;
size_t xpos;
@@ -123,7 +123,7 @@
while (pos < size) {
xpos = pos;
while ( (pos < size) &&
- (buffer[pos] != '\0') )
+ (buffer[pos] != '\0') )
pos++;
pos++;
if (pos + sizeof(unsigned int) > size) {
@@ -133,15 +133,15 @@
dataLength = ntohl(*(unsigned int*)&buffer[pos]);
pos += sizeof(unsigned int);
if ( (pos + dataLength < pos) ||
- (pos + dataLength > size) ) {
+ (pos + dataLength > size) ) {
RPC_paramFree(ret);
return NULL;
}
RPC_paramAdd(ret,
- &buffer[xpos],
- dataLength,
- &buffer[pos]);
+ &buffer[xpos],
+ dataLength,
+ &buffer[pos]);
pos += dataLength;
}
return ret;
@@ -165,9 +165,9 @@
paramName = RPC_paramName(param, i);
paramValue = NULL;
RPC_paramValueByPosition(param,
- i,
- &dataLength,
- ¶mValue);
+ i,
+ &dataLength,
+ ¶mValue);
if (pos + strlen(paramName)+1+sizeof(unsigned int) < pos)
return 0;
pos += strlen(paramName)+1;
@@ -206,9 +206,9 @@
*/
void RPC_paramAdd(RPC_Param *param,
- const char *name,
- unsigned int dataLength,
- const void *data) {
+ const char *name,
+ unsigned int dataLength,
+ const void *data) {
Parameter * new;
if (param == NULL)
@@ -238,8 +238,8 @@
* @param data Value of the parameter
*/
void RPC_paramAddDataContainer(RPC_Param *param,
- const char *name,
- const DataContainer * data) {
+ const char *name,
+ const DataContainer * data) {
Parameter * new;
if (param == NULL)
@@ -252,8 +252,8 @@
} else {
new->data = MALLOC(new->dataLength);
memcpy(new->data,
- &data[1],
- new->dataLength);
+ &data[1],
+ new->dataLength);
}
vectorInsertLast(param, new);
}
@@ -266,7 +266,7 @@
* @return Name of the parameter
*/
const char * RPC_paramName(RPC_Param *param,
- unsigned int i) {
+ unsigned int i) {
Parameter * p;
if (param == NULL)
@@ -287,9 +287,9 @@
* @return SYSERR on error
*/
int RPC_paramValueByName(RPC_Param *param,
- const char *name,
- unsigned int * dataLength,
- void ** value) {
+ const char *name,
+ unsigned int * dataLength,
+ void ** value) {
Parameter *p;
if (param == NULL)
@@ -303,7 +303,7 @@
}
p = vectorGetNext(param);
}
-
+
return SYSERR;
}
@@ -315,7 +315,7 @@
* @return SYSERR on error
*/
DataContainer * RPC_paramDataContainerByName(RPC_Param *param,
- const char *name) {
+ const char *name) {
Parameter * p;
DataContainer * ret;
@@ -325,17 +325,17 @@
while (p != NULL) {
if (!strcmp (p->name, name)) {
ret = MALLOC(sizeof(DataContainer)
- + p->dataLength);
+ + p->dataLength);
ret->size = htonl(sizeof(DataContainer)
- + p->dataLength);
+ + p->dataLength);
memcpy(&ret[1],
- p->data,
- p->dataLength);
+ p->data,
+ p->dataLength);
return ret;
}
p = vectorGetNext(param);
}
-
+
return NULL;
}
@@ -346,9 +346,9 @@
* @param value set to the value of the parameter
*/
int RPC_paramValueByPosition(RPC_Param *param,
- unsigned int i,
- unsigned int * dataLength,
- void ** value) {
+ unsigned int i,
+ unsigned int * dataLength,
+ void ** value) {
Parameter * p;
if (param == NULL)
@@ -370,7 +370,7 @@
*/
DataContainer *
RPC_paramDataContainerByPosition(RPC_Param *param,
- unsigned int i) {
+ unsigned int i) {
Parameter * p;
DataContainer * ret;
@@ -379,12 +379,12 @@
p = vectorGetAt(param, i);
if (p != NULL) {
ret = MALLOC(sizeof(DataContainer)
- + p->dataLength);
+ + p->dataLength);
ret->size = htonl(sizeof(DataContainer)
- + p->dataLength);
+ + p->dataLength);
memcpy(&ret[1],
- p->data,
- p->dataLength);
+ p->data,
+ p->dataLength);
return ret;
}
return NULL;
Modified: GNUnet/src/applications/rpc/parameterstest.c
===================================================================
--- GNUnet/src/applications/rpc/parameterstest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/rpc/parameterstest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -35,34 +35,34 @@
p = RPC_paramNew();
if (SYSERR != RPC_paramValueByPosition(p,
- 0,
- &len,
- &buf))
+ 0,
+ &len,
+ &buf))
return 1;
if (SYSERR != RPC_paramValueByName(p,
- "not there",
- &len,
- &buf))
+ "not there",
+ &len,
+ &buf))
return 1;
if (RPC_paramCount(p) != 0)
return 1;
RPC_paramAdd(p,
- "foo",
- 4,
- "bar");
+ "foo",
+ 4,
+ "bar");
RPC_paramAdd(p,
- "bar",
- 4,
- "foo");
+ "bar",
+ 4,
+ "foo");
if (RPC_paramCount(p) != 2)
return 1;
if (0 != strcmp(RPC_paramName(p, 0),
- "foo"))
+ "foo"))
return 1;
if (0 != strcmp(RPC_paramName(p, 1),
- "bar"))
+ "bar"))
return 1;
size = RPC_paramSize(p);
@@ -70,15 +70,15 @@
RPC_paramSerialize(p, buf);
RPC_paramFree(p);
p = RPC_paramDeserialize(buf,
- size);
+ size);
FREE(buf);
if (p == NULL)
return 1;
buf = NULL;
if (OK != RPC_paramValueByName(p,
- "foo",
- &len,
- &buf))
+ "foo",
+ &len,
+ &buf))
return 1;
if (strcmp("bar", buf) != 0)
return 1;
@@ -86,24 +86,24 @@
if (4 != len)
return 1;
if (OK != RPC_paramValueByPosition(p,
- 1,
- &len,
- &buf))
+ 1,
+ &len,
+ &buf))
return 1;
if (strcmp("foo", buf) != 0)
return 1;
if (4 != len)
return 1;
if (SYSERR != RPC_paramValueByPosition(p,
- 2,
- &len,
- &buf))
+ 2,
+ &len,
+ &buf))
return 1;
if (SYSERR != RPC_paramValueByName(p,
- "not there",
- &len,
- &buf))
+ "not there",
+ &len,
+ &buf))
return 1;
RPC_paramFree(p);
Modified: GNUnet/src/applications/rpc/rpc.c
===================================================================
--- GNUnet/src/applications/rpc/rpc.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/rpc/rpc.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -116,7 +116,7 @@
* (typically if a callback of that name is already in use).
*/
static int RPC_register(const char *name,
- RPC_Function callback) {
+ RPC_Function callback) {
RegisteredRPC * rrpc;
GE_ASSERT(ectx, name != NULL);
@@ -127,10 +127,10 @@
if (0 == strcmp(rrpc->name, name)) {
MUTEX_UNLOCK (rpcLock);
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("%s::%s - RPC %s:%p could not be registered:"
- " another callback is already using this name (%p)\n"),
- __FILE__, __FUNCTION__,
- name, callback, rrpc->callback);
+ _("%s::%s - RPC %s:%p could not be registered:"
+ " another callback is already using this name (%p)\n"),
+ __FILE__, __FUNCTION__,
+ name, callback, rrpc->callback);
return SYSERR;
}
rrpc = vectorGetNext(list_of_callbacks);
@@ -156,7 +156,7 @@
* (typically if a callback of that name is already in use).
*/
static int RPC_register_async(const char *name,
- ASYNC_RPC_Function callback) {
+ ASYNC_RPC_Function callback) {
RegisteredRPC * rrpc;
GE_ASSERT(ectx, name != NULL);
@@ -167,10 +167,10 @@
if (0 == strcmp(rrpc->name, name)) {
MUTEX_UNLOCK (rpcLock);
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("%s::%s - RPC %s:%p could not be registered:"
- " another callback is already using this name (%p)\n"),
- __FILE__, __FUNCTION__,
- name, callback, rrpc->callback);
+ _("%s::%s - RPC %s:%p could not be registered:"
+ " another callback is already using this name (%p)\n"),
+ __FILE__, __FUNCTION__,
+ name, callback, rrpc->callback);
return SYSERR;
}
rrpc = vectorGetNext(list_of_callbacks);
@@ -198,7 +198,7 @@
* bound to a different function).
*/
static int RPC_unregister(const char *name,
- RPC_Function callback) {
+ RPC_Function callback) {
RegisteredRPC * rrpc;
GE_ASSERT(ectx, name != NULL);
@@ -207,23 +207,23 @@
while (rrpc != NULL) {
if (0 == strcmp(rrpc->name, name)) {
if ( (rrpc->callback != callback) &&
- (callback != NULL) ) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("%s::%s - RPC %s:%p could not be unregistered:"
- " another callback registered under that name: %p\n"),
- __FILE__, __FUNCTION__,
- name, callback, rrpc->callback);
- MUTEX_UNLOCK (rpcLock);
- return SYSERR;
+ (callback != NULL) ) {
+ GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+ _("%s::%s - RPC %s:%p could not be unregistered:"
+ " another callback registered under that name: %p\n"),
+ __FILE__, __FUNCTION__,
+ name, callback, rrpc->callback);
+ MUTEX_UNLOCK (rpcLock);
+ return SYSERR;
}
vectorRemoveObject(list_of_callbacks, rrpc);
FREE(rrpc->name);
FREE(rrpc);
MUTEX_UNLOCK(rpcLock);
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "%s::%s - Unregistered RPC %s\n",
- __FILE__, __FUNCTION__,
- name);
+ "%s::%s - Unregistered RPC %s\n",
+ __FILE__, __FUNCTION__,
+ name);
return OK;
}
rrpc = vectorGetNext(list_of_callbacks);
@@ -245,7 +245,7 @@
* bound to a different function).
*/
static int RPC_unregister_async(const char *name,
- ASYNC_RPC_Function callback) {
+ ASYNC_RPC_Function callback) {
RegisteredRPC * rrpc;
GE_ASSERT(ectx, name != NULL);
@@ -254,23 +254,23 @@
while (rrpc != NULL) {
if (0 == strcmp(rrpc->name, name)) {
if ( (rrpc->async_callback != callback) &&
- (callback != NULL) ) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("%s::%s - RPC %s:%p could not be unregistered:"
- " another callback registered under that name: %p\n"),
- __FILE__, __FUNCTION__,
- name, callback, rrpc->callback);
- MUTEX_UNLOCK (rpcLock);
- return SYSERR;
+ (callback != NULL) ) {
+ GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
+ _("%s::%s - RPC %s:%p could not be unregistered:"
+ " another callback registered under that name: %p\n"),
+ __FILE__, __FUNCTION__,
+ name, callback, rrpc->callback);
+ MUTEX_UNLOCK (rpcLock);
+ return SYSERR;
}
vectorRemoveObject(list_of_callbacks, rrpc);
FREE(rrpc->name);
FREE(rrpc);
MUTEX_UNLOCK(rpcLock);
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "%s::%s - Unregistered asynchronous RPC %s\n",
- __FILE__, __FUNCTION__,
- name);
+ "%s::%s - Unregistered asynchronous RPC %s\n",
+ __FILE__, __FUNCTION__,
+ name);
return OK;
}
rrpc = vectorGetNext(list_of_callbacks);
@@ -352,8 +352,8 @@
pi = (PeerInfo*) vectorGetFirst(peerInformation);
while (pi != NULL) {
if (0 == memcmp(id,
- &pi->identity,
- sizeof(PeerIdentity)))
+ &pi->identity,
+ sizeof(PeerIdentity)))
return pi;
pi = (PeerInfo*) vectorGetNext(peerInformation);
}
@@ -390,7 +390,7 @@
pi->agedActivitySend = pi->agedActivitySend / 2;
pi->agedActivityRecv = pi->agedActivityRecv / 2;
if ( (pi->agedActivitySend == 0) &&
- (pi->agedActivityRecv == 0) ) {
+ (pi->agedActivityRecv == 0) ) {
vectorRemoveObject(peerInformation, pi);
FREE(pi);
}
@@ -411,7 +411,7 @@
* @param messageID pseudo-unique ID of the request
*/
static void notifyPeerRequest(PeerIdentity * peer,
- unsigned int messageID) {
+ unsigned int messageID) {
int i;
PeerInfo * pi;
@@ -420,9 +420,9 @@
if (pi != NULL) {
for (i=0;i<MTRACK_COUNT;i++) {
if (pi->lastRequestId[i] == messageID) {
- pi->lastRequestTimes[i] = 0; /* re-send! */
- MUTEX_UNLOCK(rpcLock);
- return;
+ pi->lastRequestTimes[i] = 0; /* re-send! */
+ MUTEX_UNLOCK(rpcLock);
+ return;
}
}
pi->agedActivitySend |= 0x80000000;
@@ -449,7 +449,7 @@
* for
*/
static void notifyPeerReply(const PeerIdentity * peer,
- unsigned int messageID) {
+ unsigned int messageID) {
int i;
PeerInfo * pi;
@@ -457,20 +457,20 @@
pi = vectorGetFirst(peerInformation);
while (pi != NULL) {
if (0 == memcmp(peer,
- &pi->identity,
- sizeof(PeerIdentity))) {
+ &pi->identity,
+ sizeof(PeerIdentity))) {
for (i=0;i<MTRACK_COUNT;i++) {
- if (pi->lastRequestId[i] == messageID) {
- if (pi->lastRequestTimes[i] != 0) { /* resend */
- pi->averageResponseTime
- = (pi->averageResponseTime * (MTRACK_COUNT-1) +
- get_time() - pi->lastRequestTimes[i]) / MTRACK_COUNT;
- pi->agedActivityRecv |= 0x80000000;
- pi->lastRequestTimes[i] = 0;
- }
- MUTEX_UNLOCK(rpcLock);
- return;
- }
+ if (pi->lastRequestId[i] == messageID) {
+ if (pi->lastRequestTimes[i] != 0) { /* resend */
+ pi->averageResponseTime
+ = (pi->averageResponseTime * (MTRACK_COUNT-1) +
+ get_time() - pi->lastRequestTimes[i]) / MTRACK_COUNT;
+ pi->agedActivityRecv |= 0x80000000;
+ pi->lastRequestTimes[i] = 0;
+ }
+ MUTEX_UNLOCK(rpcLock);
+ return;
+ }
}
break;
}
@@ -535,9 +535,9 @@
* @param result the return values, NULL on error
*/
typedef void (*RPCFinishedCallback)(void * context,
- unsigned int sequenceNumber,
- unsigned short errorCode,
- RPC_Param * result);
+ unsigned int sequenceNumber,
+ unsigned short errorCode,
+ RPC_Param * result);
/**
* A per-RPC structure.
@@ -633,78 +633,78 @@
now = get_time();
GE_ASSERT(ectx, (get_time() + 1 * cronMINUTES > call->expirationTime) ||
- (call->expirationTime - get_time() < 1 * cronHOURS) );
+ (call->expirationTime - get_time() < 1 * cronHOURS) );
MUTEX_LOCK(rpcLock);
if (now > call->expirationTime) {
#if DEBUG_RPC
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Completed RPC %p (timeout).\n",
- call);
+ "Completed RPC %p (timeout).\n",
+ call);
#endif
if (call->finishedCallback != NULL) {
call->finishedCallback(call->rpcCallbackArgs,
- call->sequenceNumber,
- RPC_ERROR_TIMEOUT,
- NULL);
+ call->sequenceNumber,
+ RPC_ERROR_TIMEOUT,
+ NULL);
vectorRemoveObject(outgoingCalls, call);
} else {
vectorRemoveObject(incomingCalls, call);
- }
+ }
FREE(call->msg);
FREE(call);
} else {
if ( (coreAPI != NULL) &&
- (call->expirationTime - now > 50 * cronMILLIS) ) {
+ (call->expirationTime - now > 50 * cronMILLIS) ) {
unsigned int maxdelay;
if (call->repetitionFrequency == 0) {
- call->repetitionFrequency
- = getExpectedResponseTime(&call->receiver) * 2;
- if (call->repetitionFrequency == 0)
- call->repetitionFrequency = INITIAL_RPC_FREQUENCY;
- if (call->repetitionFrequency < MIN_RPC_FREQUENCY)
- call->repetitionFrequency = MIN_RPC_FREQUENCY;
+ call->repetitionFrequency
+ = getExpectedResponseTime(&call->receiver) * 2;
+ if (call->repetitionFrequency == 0)
+ call->repetitionFrequency = INITIAL_RPC_FREQUENCY;
+ if (call->repetitionFrequency < MIN_RPC_FREQUENCY)
+ call->repetitionFrequency = MIN_RPC_FREQUENCY;
} else
- call->repetitionFrequency = 2 * call->repetitionFrequency;
+ call->repetitionFrequency = 2 * call->repetitionFrequency;
maxdelay = (now - call->expirationTime)/2;
if (maxdelay > call->repetitionFrequency / 2)
- maxdelay = call->repetitionFrequency / 2;
+ maxdelay = call->repetitionFrequency / 2;
notifyPeerRequest(&call->receiver,
- MINGLE(call->sequenceNumber,
- ntohs(call->msg->header.type)));
+ MINGLE(call->sequenceNumber,
+ ntohs(call->msg->header.type)));
#if DEBUG_RPC
if (ntohs(call->msg->header.type) == P2P_PROTO_rpc_REQ) {
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Sending RPC request %p: '%.*s' (expires in %llums, last attempt
%llums ago; attempt %u).\n",
- call,
- ntohs(call->msg->functionNameLength),
- &((P2P_rpc_MESSAGE_GENERIC*)call->msg)->data[0],
- call->expirationTime - now,
- now - call->lastAttempt,
- call->attempts);
+ GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+ "Sending RPC request %p: '%.*s' (expires in %llums, last attempt %llums
ago; attempt %u).\n",
+ call,
+ ntohs(call->msg->functionNameLength),
+ &((P2P_rpc_MESSAGE_GENERIC*)call->msg)->data[0],
+ call->expirationTime - now,
+ now - call->lastAttempt,
+ call->attempts);
} else {
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Sending RPC reply %p (expires in %llums, last attempt %llums ago,
attempt %u).\n",
- call,
- call->expirationTime - now,
- now - call->lastAttempt,
- call->attempts);
- }
+ GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+ "Sending RPC reply %p (expires in %llums, last attempt %llums ago,
attempt %u).\n",
+ call,
+ call->expirationTime - now,
+ now - call->lastAttempt,
+ call->attempts);
+ }
#endif
call->lastAttempt = now;
call->attempts++;
coreAPI->unicast(&call->receiver,
- &call->msg->header,
- ntohl(call->msg->importance),
- maxdelay);
+ &call->msg->header,
+ ntohl(call->msg->importance),
+ maxdelay);
}
GE_ASSERT(ectx, (get_time() + 1 * cronMINUTES > call->expirationTime) ||
- (call->expirationTime - get_time() < 1 * cronHOURS) );
+ (call->expirationTime - get_time() < 1 * cronHOURS) );
cron_add_job(coreAPI->cron,
- &retryRPCJob,
- call->repetitionFrequency,
- 0,
- call);
+ &retryRPCJob,
+ call->repetitionFrequency,
+ 0,
+ call);
}
MUTEX_UNLOCK(rpcLock);
}
@@ -713,18 +713,18 @@
* Send an ACK message.
*/
static void sendAck(const PeerIdentity * receiver,
- unsigned int sequenceNumber,
- unsigned int importance,
- unsigned int maxDelay) {
+ unsigned int sequenceNumber,
+ unsigned int importance,
+ unsigned int maxDelay) {
RPC_ACK_Message msg;
msg.header.size = htons(sizeof(RPC_ACK_Message));
msg.header.type = htons(P2P_PROTO_rpc_ACK);
msg.sequenceNumber = htonl(sequenceNumber);
coreAPI->unicast(receiver,
- &msg.header,
- importance,
- maxDelay);
+ &msg.header,
+ importance,
+ maxDelay);
}
static char * getFunctionName(P2P_rpc_MESSAGE * req) {
@@ -736,8 +736,8 @@
return NULL; /* invalid! */
ret = MALLOC(slen+1);
memcpy(ret,
- &((P2P_rpc_MESSAGE_GENERIC*)req)->data[0],
- slen);
+ &((P2P_rpc_MESSAGE_GENERIC*)req)->data[0],
+ slen);
ret[slen] = '\0';
return ret;
}
@@ -753,7 +753,7 @@
if (ntohs(req->header.size) < sizeof(P2P_rpc_MESSAGE) + slen)
return NULL; /* invalid! */
ret = RPC_paramDeserialize(&((P2P_rpc_MESSAGE_GENERIC*)req)->data[slen],
- ntohs(req->header.size) - sizeof(P2P_rpc_MESSAGE)
- slen);
+ ntohs(req->header.size) - sizeof(P2P_rpc_MESSAGE) - slen);
if (RPC_paramCount(ret) != ntohs(req->argumentCount)) {
RPC_paramFree(ret);
return NULL; /* invalid! */
@@ -772,10 +772,10 @@
* @return the RPC message to transmit, caller must free
*/
static P2P_rpc_MESSAGE * buildMessage(unsigned short errorCode,
- const char * name,
- unsigned int sequenceNumber,
- unsigned int importance,
- RPC_Param * values) {
+ const char * name,
+ unsigned int sequenceNumber,
+ unsigned int importance,
+ RPC_Param * values) {
P2P_rpc_MESSAGE * ret;
size_t size = sizeof(P2P_rpc_MESSAGE);
int slen;
@@ -801,11 +801,11 @@
ret->argumentCount = htons(RPC_paramCount(values));
if (name != NULL) {
memcpy(&((P2P_rpc_MESSAGE_GENERIC*)ret)->data[0],
- name,
- slen);
+ name,
+ slen);
}
RPC_paramSerialize(values,
- &((P2P_rpc_MESSAGE_GENERIC*)ret)->data[slen]);
+ &((P2P_rpc_MESSAGE_GENERIC*)ret)->data[slen]);
if (name == NULL)
ret->header.type = htons(P2P_PROTO_rpc_RES);
@@ -826,31 +826,31 @@
* case o complete the reply (since it's the same code).
*/
static void async_rpc_complete_callback(RPC_Param * results,
- int errorCode,
- CallInstance * calls) {
+ int errorCode,
+ CallInstance * calls) {
MUTEX_LOCK (rpcLock);
/* build reply message */
calls->msg = buildMessage(errorCode,
- NULL,
- calls->sequenceNumber,
- calls->importance,
- results);
+ NULL,
+ calls->sequenceNumber,
+ calls->importance,
+ results);
if (calls->msg == NULL)
calls->msg = buildMessage(RPC_ERROR_RETURN_VALUE_TOO_LARGE,
- NULL,
- calls->sequenceNumber,
- calls->importance,
- results);
+ NULL,
+ calls->sequenceNumber,
+ calls->importance,
+ results);
vectorInsertLast(incomingCalls, calls);
GE_ASSERT(ectx, (get_time() + 1 * cronMINUTES > calls->expirationTime) ||
- (calls->expirationTime - get_time() < 1 * cronHOURS) );
+ (calls->expirationTime - get_time() < 1 * cronHOURS) );
/* for right now: schedule cron job to send reply! */
cron_add_job(coreAPI->cron,
- &retryRPCJob,
- 0,
- 0,
- calls);
+ &retryRPCJob,
+ 0,
+ 0,
+ calls);
MUTEX_UNLOCK (rpcLock);
}
@@ -861,7 +861,7 @@
* reply.
*/
static int handleRPCMessageReq(const PeerIdentity *sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
P2P_rpc_MESSAGE * req;
CallInstance * calls;
unsigned int sq;
@@ -875,16 +875,16 @@
if ( (ntohs(message->type) != P2P_PROTO_rpc_REQ) ||
(ntohs(message->size) < sizeof(P2P_rpc_MESSAGE)) ) {
GE_LOG(ectx,
- GE_WARNING | GE_REQUEST | GE_ADMIN,
- _("Invalid message of type %u received. Dropping.\n"),
- ntohs(message->type));
+ GE_WARNING | GE_REQUEST | GE_ADMIN,
+ _("Invalid message of type %u received. Dropping.\n"),
+ ntohs(message->type));
return SYSERR;
}
req = (P2P_rpc_MESSAGE *) message;
sq = ntohl(req->sequenceNumber);
#if DEBUG_RPC
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
+ GE_DEBUG | GE_REQUEST | GE_USER,
"Received RPC request with id %u.\n",
sq);
#endif
@@ -903,9 +903,9 @@
if (calls->sequenceNumber < minSQ)
minSQ = calls->sequenceNumber;
if ( (calls->sequenceNumber == sq) &&
- (0 == memcmp(&calls->receiver,
- sender,
- sizeof(PeerIdentity))) )
+ (0 == memcmp(&calls->receiver,
+ sender,
+ sizeof(PeerIdentity))) )
break;
calls = vectorGetNext(incomingCalls);
}
@@ -914,21 +914,21 @@
if (pi != NULL) {
if (pi->averageResponseTime < MAX_RPC_TIMEOUT / 2)
- pi->averageResponseTime *= 2;
+ pi->averageResponseTime *= 2;
}
RPC_STATUS("", "received duplicate request", calls);
calls->expirationTime = get_time() + MAX_RPC_TIMEOUT;
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Dropping RPC request %u, duplicate.\n",
- sq);
+ "Dropping RPC request %u, duplicate.\n",
+ sq);
MUTEX_UNLOCK(rpcLock);
return OK; /* seen before */
}
if (minSQ > sq) {
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Dropping RPC request %u, sequence number too old (current minimum is
%u).\n",
- sq,
- minSQ);
+ "Dropping RPC request %u, sequence number too old (current minimum is
%u).\n",
+ sq,
+ minSQ);
MUTEX_UNLOCK(rpcLock);
return OK; /* seen before */
}
@@ -943,7 +943,7 @@
RPC_paramFree(argumentValues);
MUTEX_UNLOCK(rpcLock);
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Dropping RPC request %u: message malformed.\n"));
+ _("Dropping RPC request %u: message malformed.\n"));
return SYSERR; /* message malformed */
}
@@ -951,7 +951,7 @@
rpc = (RegisteredRPC*) vectorGetFirst(list_of_callbacks);
while (rpc != NULL) {
if (0 == strcmp(functionName,
- rpc->name))
+ rpc->name))
break;
rpc = (RegisteredRPC*) vectorGetNext(list_of_callbacks);
}
@@ -976,23 +976,23 @@
if (rpc->callback == NULL) {
/* asynchronous RPC */
rpc->async_callback(sender,
- argumentValues,
- &async_rpc_complete_callback,
- calls);
+ argumentValues,
+ &async_rpc_complete_callback,
+ calls);
MUTEX_UNLOCK (rpcLock);
return OK;
}
returnValues = RPC_paramNew();
rpc->callback(sender,
- argumentValues,
- returnValues);
+ argumentValues,
+ returnValues);
RPC_paramFree(argumentValues);
errorCode = RPC_ERROR_OK;
}
MUTEX_UNLOCK(rpcLock);
async_rpc_complete_callback(returnValues,
- errorCode,
- calls);
+ errorCode,
+ calls);
return OK;
}
@@ -1002,36 +1002,36 @@
* Also always sends an ACK.
*/
static int handleRPCMessageRes(const PeerIdentity * sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
P2P_rpc_MESSAGE * res;
CallInstance * call;
if ( (ntohs(message->type) != P2P_PROTO_rpc_RES) ||
(ntohs(message->size) < sizeof(P2P_rpc_MESSAGE)) ) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Invalid message of type %u received. Dropping.\n"),
- ntohs(message->type));
+ _("Invalid message of type %u received. Dropping.\n"),
+ ntohs(message->type));
return SYSERR;
}
res = (P2P_rpc_MESSAGE *) message;
#if DEBUG_RPC
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Received RPC reply with id %u.\n",
- ntohl(res->sequenceNumber));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Received RPC reply with id %u.\n",
+ ntohl(res->sequenceNumber));
#endif
cron_suspend(coreAPI->cron,
- NO);
+ NO);
MUTEX_LOCK (rpcLock);
/* Locate the CallInstance structure. */
call = vectorGetFirst(outgoingCalls);
while (call != NULL) {
if ( (0 == memcmp(&call->receiver,
- sender,
- sizeof(PeerIdentity))) &&
- (call->sequenceNumber == ntohl(res->sequenceNumber)) )
+ sender,
+ sizeof(PeerIdentity))) &&
+ (call->sequenceNumber == ntohl(res->sequenceNumber)) )
break;
call = vectorGetNext(outgoingCalls);
}
@@ -1047,41 +1047,41 @@
if (error == RPC_ERROR_OK) {
reply = RPC_paramDeserialize(&gen->data[0],
- ntohs(message->size) -
sizeof(P2P_rpc_MESSAGE));
+ ntohs(message->size) - sizeof(P2P_rpc_MESSAGE));
if (ntohs(res->argumentCount) != RPC_paramCount(reply)) {
- RPC_paramFree(reply);
- reply = NULL;
- error = RPC_ERROR_REPLY_MALFORMED;
+ RPC_paramFree(reply);
+ reply = NULL;
+ error = RPC_ERROR_REPLY_MALFORMED;
}
}
if (call->finishedCallback != NULL) {
call->finishedCallback(call->rpcCallbackArgs,
- call->sequenceNumber,
- error,
- reply);
+ call->sequenceNumber,
+ error,
+ reply);
call->finishedCallback = NULL;
}
vectorRemoveObject(outgoingCalls,
- call);
+ call);
notifyPeerReply(sender,
- MINGLE(call->sequenceNumber,
- P2P_PROTO_rpc_REQ));
+ MINGLE(call->sequenceNumber,
+ P2P_PROTO_rpc_REQ));
cron_del_job(coreAPI->cron,
- &retryRPCJob,
- 0,
- call);
+ &retryRPCJob,
+ 0,
+ call);
FREE(call->msg);
FREE(call);
if (reply != NULL)
RPC_paramFree(reply);
}
sendAck(sender,
- ntohl(res->sequenceNumber),
- 0,/* not important, ACK should be tiny enough to go through anyway */
- 0 /* right away */);
+ ntohl(res->sequenceNumber),
+ 0,/* not important, ACK should be tiny enough to go through anyway */
+ 0 /* right away */);
MUTEX_UNLOCK (rpcLock);
cron_resume_jobs(coreAPI->cron,
- NO);
+ NO);
return OK;
}
@@ -1090,16 +1090,16 @@
* Handle a peer-to-peer message of type P2P_PROTO_rpc_ACK.
*/
static int handleRPCMessageAck(const PeerIdentity *sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
RPC_ACK_Message * ack;
CallInstance *call;
if ( (ntohs(message->type) != P2P_PROTO_rpc_ACK) ||
(ntohs(message->size) != sizeof(RPC_ACK_Message)) ) {
GE_LOG(ectx,
- GE_WARNING | GE_REQUEST | GE_ADMIN,
- _("Invalid message of type %u received. Dropping.\n"),
- ntohs (message->type));
+ GE_WARNING | GE_REQUEST | GE_ADMIN,
+ _("Invalid message of type %u received. Dropping.\n"),
+ ntohs (message->type));
return SYSERR;
}
@@ -1110,16 +1110,16 @@
ntohl(ack->sequenceNumber));
#endif
cron_suspend(coreAPI->cron,
- NO);
+ NO);
MUTEX_LOCK(rpcLock);
/* Locate the CallInstance structure. */
call = (CallInstance*) vectorGetFirst(incomingCalls);
while (call != NULL) {
if ( (0 == memcmp(&call->receiver,
- sender,
- sizeof(PeerIdentity))) &&
- (call->sequenceNumber == ntohl(ack->sequenceNumber)) )
+ sender,
+ sizeof(PeerIdentity))) &&
+ (call->sequenceNumber == ntohl(ack->sequenceNumber)) )
break;
call = (CallInstance*) vectorGetNext(incomingCalls);
}
@@ -1128,31 +1128,31 @@
if (NULL != call) {
RPC_STATUS("", "acknowledged reply", call);
notifyPeerReply(sender,
- MINGLE(ntohl(ack->sequenceNumber),
- P2P_PROTO_rpc_RES));
+ MINGLE(ntohl(ack->sequenceNumber),
+ P2P_PROTO_rpc_RES));
cron_del_job(coreAPI->cron,
- &retryRPCJob,
- 0,
- call);
+ &retryRPCJob,
+ 0,
+ call);
vectorRemoveObject(incomingCalls,
- call);
+ call);
FREE(call->msg);
FREE(call);
} else {
PeerInfo * pi = getPeerInfo(sender);
if (pi != NULL) {
if (pi->averageResponseTime < MAX_RPC_TIMEOUT / 2)
- pi->averageResponseTime *= 2;
+ pi->averageResponseTime *= 2;
}
#if DEBUG_RPC
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "ACK is a duplicate (or invalid).\n");
+ "ACK is a duplicate (or invalid).\n");
#endif
}
MUTEX_UNLOCK (rpcLock);
cron_resume_jobs(coreAPI->cron,
- NO);
+ NO);
return OK;
}
@@ -1169,9 +1169,9 @@
* (timeout, error or success).
*/
static void RPC_execute_callback(RPC_EXEC_CLS * context,
- unsigned int sq,
- unsigned short ec,
- RPC_Param * res) {
+ unsigned int sq,
+ unsigned short ec,
+ RPC_Param * res) {
int i;
unsigned int dl;
void * data;
@@ -1179,14 +1179,14 @@
for (i=RPC_paramCount(res)-1;i>=0;i--) {
data = NULL;
RPC_paramValueByPosition(res,
- i,
- &dl,
- &data);
+ i,
+ &dl,
+ &data);
RPC_paramAdd(context->result,
- RPC_paramName(res,
- i),
- dl,
- data);
+ RPC_paramName(res,
+ i),
+ dl,
+ data);
}
context->ec = ec;
SEMAPHORE_UP(context->sem);
@@ -1203,11 +1203,11 @@
* @return the error code of the operation (0 for success).
*/
static int RPC_execute(const PeerIdentity *receiver,
- const char *name,
- RPC_Param *requestParam,
- RPC_Param *returnParam,
- unsigned int importance,
- cron_t timeout) {
+ const char *name,
+ RPC_Param *requestParam,
+ RPC_Param *returnParam,
+ unsigned int importance,
+ cron_t timeout) {
RPC_EXEC_CLS cls;
CallInstance * call;
@@ -1223,21 +1223,21 @@
call->receiver = *receiver;
call->sequenceNumber = rpcIdentifier++;
call->msg = buildMessage(RPC_ERROR_OK,
- name,
- call->sequenceNumber,
- importance,
- requestParam);
+ name,
+ call->sequenceNumber,
+ importance,
+ requestParam);
call->finishedCallback = (RPCFinishedCallback) &RPC_execute_callback;
call->rpcCallbackArgs = &cls;
vectorInsertLast(outgoingCalls, call);
GE_ASSERT(ectx,
- (get_time() + 1 * cronMINUTES > call->expirationTime) ||
- (call->expirationTime - get_time() < 1 * cronHOURS) );
+ (get_time() + 1 * cronMINUTES > call->expirationTime) ||
+ (call->expirationTime - get_time() < 1 * cronHOURS) );
cron_add_job(coreAPI->cron,
- &retryRPCJob,
- 0,
- 0,
- call);
+ &retryRPCJob,
+ 0,
+ 0,
+ call);
MUTEX_UNLOCK (rpcLock);
SEMAPHORE_DOWN(cls.sem, YES);
SEMAPHORE_DESTROY(cls.sem);
@@ -1254,14 +1254,14 @@
} RPC_Record;
static void RPC_async_callback(RPC_Record * rec,
- unsigned int sequenceNumber,
- unsigned short errorCode,
- RPC_Param * result) {
+ unsigned int sequenceNumber,
+ unsigned short errorCode,
+ RPC_Param * result) {
if ( (errorCode == RPC_ERROR_OK) &&
(rec->callback != NULL) ) {
rec->callback(&rec->peer,
- result,
- rec->closure);
+ result,
+ rec->closure);
rec->callback = NULL; /* never call callback twice */
}
rec->errorCode = errorCode;
@@ -1278,18 +1278,18 @@
* be explicitly stopped to free resources!)
*/
static RPC_Record * RPC_start(const PeerIdentity * receiver,
- const char * name,
- RPC_Param * request_param,
- unsigned int importance,
- cron_t timeout,
- RPC_Complete callback,
- void * closure) {
+ const char * name,
+ RPC_Param * request_param,
+ unsigned int importance,
+ cron_t timeout,
+ RPC_Complete callback,
+ void * closure) {
RPC_Record * ret;
if (timeout > 1 * cronHOURS) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("`%s' called with timeout above 1 hour (bug?)\n"),
- __FUNCTION__);
+ _("`%s' called with timeout above 1 hour (bug?)\n"),
+ __FUNCTION__);
timeout = 1 * cronHOURS;
}
ret = MALLOC(sizeof(RPC_Record));
@@ -1307,21 +1307,21 @@
ret->call->receiver = *receiver;
ret->call->sequenceNumber = rpcIdentifier++;
ret->call->msg = buildMessage(RPC_ERROR_OK,
- name,
- ret->call->sequenceNumber,
- importance,
- request_param);
+ name,
+ ret->call->sequenceNumber,
+ importance,
+ request_param);
ret->call->finishedCallback =
(RPCFinishedCallback) &RPC_async_callback;
ret->call->rpcCallbackArgs = ret;
vectorInsertLast(outgoingCalls, ret->call);
GE_ASSERT(ectx, (get_time() + 1 * cronMINUTES > ret->call->expirationTime)
||
- (ret->call->expirationTime - get_time() < 1 * cronHOURS) );
+ (ret->call->expirationTime - get_time() < 1 * cronHOURS) );
cron_add_job(coreAPI->cron,
- &retryRPCJob,
- 0,
- 0,
- ret->call);
+ &retryRPCJob,
+ 0,
+ 0,
+ ret->call);
MUTEX_UNLOCK (rpcLock);
return ret;
}
@@ -1338,13 +1338,13 @@
RPC_STATUS("", "stopped", record);
cron_suspend(coreAPI->cron,
- YES);
+ YES);
cron_del_job(coreAPI->cron,
- &retryRPCJob,
- 0,
- record->call);
+ &retryRPCJob,
+ 0,
+ record->call);
cron_resume_jobs(coreAPI->cron,
- YES);
+ YES);
MUTEX_LOCK(rpcLock);
if (NULL != vectorRemoveObject(outgoingCalls, record->call)) {
FREE(record->call->msg);
@@ -1366,15 +1366,15 @@
CallInstance * call;
cron_del_job(coreAPI->cron,
- &agePeerStats,
- PEER_TRACKING_TIME_INTERVAL,
- NULL);
+ &agePeerStats,
+ PEER_TRACKING_TIME_INTERVAL,
+ NULL);
coreAPI->unregisterHandler(P2P_PROTO_rpc_REQ,
- &handleRPCMessageReq);
+ &handleRPCMessageReq);
coreAPI->unregisterHandler(P2P_PROTO_rpc_RES,
- &handleRPCMessageRes);
+ &handleRPCMessageRes);
coreAPI->unregisterHandler(P2P_PROTO_rpc_ACK,
- &handleRPCMessageAck);
+ &handleRPCMessageAck);
if (NULL != peerInformation) {
while(vectorSize(peerInformation) > 0)
FREE(vectorRemoveLast(peerInformation));
@@ -1385,9 +1385,9 @@
while(vectorSize (incomingCalls) > 0) {
call = (CallInstance*) vectorRemoveLast(incomingCalls);
cron_del_job(coreAPI->cron,
- &retryRPCJob,
- 0,
- call);
+ &retryRPCJob,
+ 0,
+ call);
FREE(call->msg);
FREE(call);
}
@@ -1398,9 +1398,9 @@
while(vectorSize (outgoingCalls) > 0) {
call = (CallInstance*) vectorRemoveLast(outgoingCalls);
cron_del_job(coreAPI->cron,
- &retryRPCJob,
- 0,
- call);
+ &retryRPCJob,
+ 0,
+ call);
FREE(call->msg);
FREE(call);
}
@@ -1412,8 +1412,8 @@
RegisteredRPC * rpc;
rpc = (RegisteredRPC*) vectorRemoveLast(list_of_callbacks);
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("RPC not unregistered: %s:%p\n"),
- rpc->name, rpc->callback);
+ _("RPC not unregistered: %s:%p\n"),
+ rpc->name, rpc->callback);
FREE(rpc->name);
FREE(rpc);
}
@@ -1446,22 +1446,22 @@
P2P_PROTO_rpc_ACK);
rvalue = OK;
if (capi->registerHandler(P2P_PROTO_rpc_REQ,
- &handleRPCMessageReq) ==
+ &handleRPCMessageReq) ==
SYSERR)
rvalue = SYSERR;
if (capi->registerHandler(P2P_PROTO_rpc_RES,
- &handleRPCMessageRes) ==
+ &handleRPCMessageRes) ==
SYSERR)
rvalue = SYSERR;
if (capi->registerHandler (P2P_PROTO_rpc_ACK,
- &handleRPCMessageAck) ==
+ &handleRPCMessageAck) ==
SYSERR)
rvalue = SYSERR;
if (rvalue == SYSERR) {
release_module_rpc();
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Failed to initialize `%s' service.\n"),
- "rpc");
+ _("Failed to initialize `%s' service.\n"),
+ "rpc");
return NULL;
} else {
rpcAPI.RPC_execute = &RPC_execute;
@@ -1472,10 +1472,10 @@
rpcAPI.RPC_start = &RPC_start;
rpcAPI.RPC_stop = &RPC_stop;
cron_add_job(coreAPI->cron,
- &agePeerStats,
- PEER_TRACKING_TIME_INTERVAL,
- PEER_TRACKING_TIME_INTERVAL,
- NULL);
+ &agePeerStats,
+ PEER_TRACKING_TIME_INTERVAL,
+ PEER_TRACKING_TIME_INTERVAL,
+ NULL);
return &rpcAPI;
}
}
@@ -1483,44 +1483,44 @@
#if PROVIDE_RPC_TEST
static void testCallback(const PeerIdentity * sender,
- RPC_Param * arguments,
- RPC_Param * results) {
+ RPC_Param * arguments,
+ RPC_Param * results) {
unsigned int dl;
char * data;
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
"RPC callback invoked!\n");
if ( (OK == RPC_paramValueByName(arguments,
- "command",
- &dl,
- (void**)&data)) &&
+ "command",
+ &dl,
+ (void**)&data)) &&
(strncmp("Hello", data, dl) == 0) ) {
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "RPC callback received Hello command!\n");
+ "RPC callback received Hello command!\n");
RPC_paramAdd(results,
- "response",
- strlen("Hello RPC World")+1,
- "Hello RPC World");
+ "response",
+ strlen("Hello RPC World")+1,
+ "Hello RPC World");
}
}
static void async_RPC_Complete_callback(RPC_Param * results,
- struct SEMAPHORE * sign) {
+ struct SEMAPHORE * sign) {
unsigned int dl;
char * reply;
SEMAPHORE_DOWN(sign, YES);
if ( (OK != RPC_paramValueByName(results,
- "response",
- &dl,
- (void**)&reply)) ||
+ "response",
+ &dl,
+ (void**)&reply)) ||
(strncmp("Hello RPC World",
- reply, dl) != 0) ) {
+ reply, dl) != 0) ) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("RPC async reply invalid.\n"));
+ _("RPC async reply invalid.\n"));
} else
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "RPC async reply received.\n");
+ "RPC async reply received.\n");
}
int initialize_module_rpc(CoreAPIForApplication * capi) {
@@ -1535,8 +1535,8 @@
struct SEMAPHORE * sign;
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "RPC testcase starting\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "RPC testcase starting\n");
rpcAPI = capi->requestService("rpc");
if (rpcAPI == NULL) {
GE_BREAK(ectx, 0);
@@ -1545,43 +1545,43 @@
ret = OK;
if (OK != rpcAPI->RPC_register("testFunction",
- &testCallback)) {
+ &testCallback)) {
GE_BREAK(ectx, 0);
ret = SYSERR;
}
args = RPC_paramNew();
RPC_paramAdd(args,
- "command",
- strlen("Hello")+1,
- "Hello");
+ "command",
+ strlen("Hello")+1,
+ "Hello");
sign = SEMAPHORE_CREATE(0);
record = rpcAPI->RPC_start(coreAPI->myIdentity,
- "testFunction",
- args,
- 0,
- 5 * cronSECONDS,
- (RPC_Complete) &async_RPC_Complete_callback,
- sign);
+ "testFunction",
+ args,
+ 0,
+ 5 * cronSECONDS,
+ (RPC_Complete) &async_RPC_Complete_callback,
+ sign);
SEMAPHORE_UP(sign); /* allow callback now - forces async! */
rets = RPC_paramNew();
code = rpcAPI->RPC_execute(coreAPI->myIdentity,
- "testFunction",
- args,
- rets,
- 0,
- 5 * cronSECONDS);
+ "testFunction",
+ args,
+ rets,
+ 0,
+ 5 * cronSECONDS);
if (code != RPC_ERROR_OK) {
GE_BREAK(ectx, 0);
ret = SYSERR;
}
RPC_paramFree(args);
if ( (OK != RPC_paramValueByName(rets,
- "response",
- &dl,
- (void**)&reply)) ||
+ "response",
+ &dl,
+ (void**)&reply)) ||
(strncmp("Hello RPC World",
- reply, dl) != 0) ) {
+ reply, dl) != 0) ) {
GE_BREAK(ectx, 0);
ret = SYSERR;
}
@@ -1589,10 +1589,10 @@
PTHREAD_SLEEP(1 * cronSECONDS);
if (RPC_ERROR_OK != rpcAPI->RPC_stop(record))
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("async RPC reply not received.\n"));
+ _("async RPC reply not received.\n"));
if (OK != rpcAPI->RPC_unregister("testFunction",
- &testCallback)) {
+ &testCallback)) {
GE_BREAK(ectx, 0);
ret = SYSERR;
}
Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/session/connect.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -135,9 +135,9 @@
strcpy(r, "");
for (i=0;i<SESSIONKEY_LEN;i++) {
SNPRINTF(t,
- 12,
- "%02x",
- sk->key[i]);
+ 12,
+ "%02x",
+ sk->key[i]);
strcat(r,t);
}
return r;
@@ -158,19 +158,19 @@
GE_ASSERT(ectx, hostId != NULL);
#if DEBUG_SESSION
IF_GELOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- hash2enc(&hostId->hashPubKey,
- &enc));
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ hash2enc(&hostId->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Received `%s' from `%s', marking session as up.\n",
- "PONG",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Received `%s' from `%s', marking session as up.\n",
+ "PONG",
+ &enc);
#endif
GE_ASSERT(ectx, hostId != NULL);
if (stats != NULL)
stats->change(stat_sessionEstablished,
- 1);
+ 1);
coreAPI->confirmSessionUp(hostId);
FREE(hostId);
}
@@ -187,8 +187,8 @@
* connections are disallowed
*/
static int verifySKS(const PeerIdentity * hostId,
- const P2P_setkey_MESSAGE * sks,
- const Signature * signature) {
+ const P2P_setkey_MESSAGE * sks,
+ const Signature * signature) {
char * limited;
EncName enc;
unsigned int rsize;
@@ -202,20 +202,20 @@
from that peer */
limited = NULL;
GC_get_configuration_value_string(coreAPI->cfg,
- "GNUNETD",
- "LIMIT-ALLOW",
- "",
- &limited);
+ "GNUNETD",
+ "LIMIT-ALLOW",
+ "",
+ &limited);
if (strlen(limited) > 0) {
hash2enc(&hostId->hashPubKey,
- &enc);
+ &enc);
if (NULL == strstr(limited,
- (char*) &enc)) {
+ (char*) &enc)) {
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Connection from peer `%s' was rejected (not allowed).\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Connection from peer `%s' was rejected (not allowed).\n",
+ &enc);
#endif
FREE(limited);
return NO;
@@ -224,20 +224,20 @@
FREE(limited);
limited = NULL;
GC_get_configuration_value_string(coreAPI->cfg,
- "GNUNETD",
- "LIMIT-DENY",
- "",
- &limited);
+ "GNUNETD",
+ "LIMIT-DENY",
+ "",
+ &limited);
if (strlen(limited) > 0) {
hash2enc(&hostId->hashPubKey,
- &enc);
+ &enc);
if (NULL != strstr(limited,
- (char*) &enc)) {
+ (char*) &enc)) {
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Connection from peer `%s' was rejected (explicitly denied).\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Connection from peer `%s' was rejected (explicitly denied).\n",
+ &enc);
#endif
FREE(limited);
return NO;
@@ -253,30 +253,30 @@
GE_BREAK_OP(ectx, 0);
IF_GELOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- hash2enc(&hostId->hashPubKey,
- &enc));
+ GE_INFO | GE_USER | GE_REQUEST,
+ hash2enc(&hostId->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("Session key from peer `%s' could not be verified.\n"),
- &enc);
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("Session key from peer `%s' could not be verified.\n"),
+ &enc);
return SYSERR;
}
if (OK != identity->verifyPeerSignature(hostId,
- sks,
- rsize - sizeof(Signature),
- signature)) {
+ sks,
+ rsize - sizeof(Signature),
+ signature)) {
#if DEBUG_SESSION
EncName enc;
IF_GELOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- hash2enc(&hostId->hashPubKey,
- &enc));
+ GE_INFO | GE_USER | GE_REQUEST,
+ hash2enc(&hostId->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("Session key from peer `%s' could not be verified.\n"),
- &enc);
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("Session key from peer `%s' could not be verified.\n"),
+ &enc);
#endif
return SYSERR; /*reject!*/
}
@@ -297,10 +297,10 @@
*/
static P2P_new_setkey_MESSAGE *
makeSessionKeySigned(const PeerIdentity * hostId,
- const SESSIONKEY * sk,
- TIME_T created,
- const MESSAGE_HEADER * ping,
- const MESSAGE_HEADER * pong) {
+ const SESSIONKEY * sk,
+ TIME_T created,
+ const MESSAGE_HEADER * ping,
+ const MESSAGE_HEADER * pong) {
P2P_hello_MESSAGE * foreignHello;
int size;
P2P_new_setkey_MESSAGE * msg;
@@ -310,34 +310,34 @@
GE_ASSERT(ectx, sk != NULL);
foreignHello = identity->identity2Hello(hostId,
- ANY_PROTOCOL_NUMBER,
- YES);
+ ANY_PROTOCOL_NUMBER,
+ YES);
/* create and encrypt sessionkey */
if (NULL == foreignHello) {
hash2enc(&hostId->hashPubKey,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("Cannot encrypt sessionkey, peer `%s' not known!\n"),
- &enc);
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("Cannot encrypt sessionkey, peer `%s' not known!\n"),
+ &enc);
return NULL; /* other host not known */
}
identity->getPeerIdentity(&foreignHello->publicKey,
- &hc);
+ &hc);
if ( (0 != memcmp(&hc,
- hostId,
- sizeof(PeerIdentity))) ||
+ hostId,
+ sizeof(PeerIdentity))) ||
(0 != memcmp(&hc,
- &foreignHello->senderIdentity,
- sizeof(PeerIdentity))) ) {
+ &foreignHello->senderIdentity,
+ sizeof(PeerIdentity))) ) {
GE_BREAK_OP(NULL,
- 0 == memcmp(&hc,
- &foreignHello->senderIdentity,
- sizeof(PeerIdentity)));
+ 0 == memcmp(&hc,
+ &foreignHello->senderIdentity,
+ sizeof(PeerIdentity)));
GE_BREAK_OP(NULL,
- 0 == memcmp(&hc,
- hostId,
- sizeof(PeerIdentity)));
+ 0 == memcmp(&hc,
+ hostId,
+ sizeof(PeerIdentity)));
GE_BREAK_OP(NULL, 0);
FREE(foreignHello);
return NULL;
@@ -352,9 +352,9 @@
msg = MALLOC(size);
msg->target = *hostId;
if (SYSERR == encryptPrivateKey(sk,
- sizeof(SESSIONKEY),
- &foreignHello->publicKey,
- &msg->key)) {
+ sizeof(SESSIONKEY),
+ &foreignHello->publicKey,
+ &msg->key)) {
GE_BREAK_OP(ectx, 0);
FREE(foreignHello);
FREE(msg);
@@ -367,17 +367,17 @@
msg->header.type = htons(P2P_PROTO_setkey);
msg->creationTime = htonl(created);
GE_ASSERT(ectx,
- SYSERR !=
- identity->signData(msg,
- sizeof(P2P_new_setkey_MESSAGE)
- - sizeof(Signature),
- &msg->signature));
+ SYSERR !=
+ identity->signData(msg,
+ sizeof(P2P_new_setkey_MESSAGE)
+ - sizeof(Signature),
+ &msg->signature));
#if EXTRA_CHECKS
/* verify signature/SKS */
GE_ASSERT(ectx,
- SYSERR != verifySKS(coreAPI->myIdentity,
- (const P2P_setkey_MESSAGE*) msg,
- &msg->signature));
+ SYSERR != verifySKS(coreAPI->myIdentity,
+ (const P2P_setkey_MESSAGE*) msg,
+ &msg->signature));
#endif
size = 0;
@@ -390,30 +390,30 @@
size = 0;
if (ping != NULL) {
memcpy(&pt[size],
- ping,
- ntohs(ping->size));
+ ping,
+ ntohs(ping->size));
size += ntohs(ping->size);
}
if (pong != NULL) {
memcpy(&pt[size],
- pong,
- ntohs(pong->size));
+ pong,
+ ntohs(pong->size));
size += ntohs(pong->size);
}
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Encrypting %d bytes of PINGPONG with key %s and IV %u\n",
- size,
- printSKEY(sk),
- *(int*)&msg->signature);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Encrypting %d bytes of PINGPONG with key %s and IV %u\n",
+ size,
+ printSKEY(sk),
+ *(int*)&msg->signature);
#endif
GE_ASSERT(ectx,
- -1 != encryptBlock(pt,
- size,
- sk,
- (const INITVECTOR*) &msg->signature,
- (char*)&msg[1]));
+ -1 != encryptBlock(pt,
+ size,
+ sk,
+ (const INITVECTOR*) &msg->signature,
+ (char*)&msg[1]));
FREE(pt);
}
return msg;
@@ -429,8 +429,8 @@
* @param pong pong to include (maybe NULL)
*/
static int exchangeKey(const PeerIdentity * receiver,
- TSession * tsession,
- MESSAGE_HEADER * pong) {
+ TSession * tsession,
+ MESSAGE_HEADER * pong) {
P2P_hello_MESSAGE * hello;
P2P_new_setkey_MESSAGE * skey;
SESSIONKEY sk;
@@ -440,11 +440,11 @@
EncName enc;
GE_ASSERT(ectx,
- receiver != NULL);
+ receiver != NULL);
if ( (tsession != NULL) &&
(0 != memcmp(&tsession->peer,
- receiver,
- sizeof(PeerIdentity))) ) {
+ receiver,
+ sizeof(PeerIdentity))) ) {
GE_BREAK(ectx, 0);
tsession = NULL;
}
@@ -452,18 +452,18 @@
(topology->allowConnectionFrom(receiver) == SYSERR) )
return SYSERR;
hash2enc(&receiver->hashPubKey,
- &enc);
+ &enc);
/* then try to connect on the transport level */
if ( (tsession == NULL) ||
(transport->associate(tsession) == SYSERR) )
tsession = transport->connectFreely(receiver,
- YES);
+ YES);
if (tsession == NULL) {
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Key exchange with `%s' failed: could not connect.\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Key exchange with `%s' failed: could not connect.\n",
+ &enc);
#endif
return SYSERR; /* failed to connect */
}
@@ -472,10 +472,10 @@
sndr = MALLOC(sizeof(PeerIdentity));
*sndr = *receiver;
ping = pingpong->pingUser(receiver,
- ¬ifyPONG,
- sndr,
- NO,
- rand());
+ ¬ifyPONG,
+ sndr,
+ NO,
+ rand());
if (ping == NULL) {
FREE(sndr);
transport->disconnect(tsession);
@@ -484,26 +484,26 @@
/* get or create our session key */
if (OK != coreAPI->getCurrentSessionKey(receiver,
- &sk,
- &age,
- YES)) {
+ &sk,
+ &age,
+ YES)) {
age = TIME(NULL);
makeSessionkey(&sk);
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Created fresh sessionkey `%s' for peer `%s'.\n",
- printSKEY(&sk),
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Created fresh sessionkey `%s' for peer `%s'.\n",
+ printSKEY(&sk),
+ &enc);
#endif
}
/* build SKEY message */
skey = makeSessionKeySigned(receiver,
- &sk,
- age,
- ping,
- pong);
+ &sk,
+ age,
+ ping,
+ pong);
FREE(ping);
if (skey == NULL) {
transport->disconnect(tsession);
@@ -516,15 +516,15 @@
hello = transport->createhello(ANY_PROTOCOL_NUMBER);
if (NULL == hello) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Could not create any HELLO for myself!\n"));
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Could not create any HELLO for myself!\n"));
}
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Sending session key `%s' to peer `%s'.\n",
- printSKEY(&sk),
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Sending session key `%s' to peer `%s'.\n",
+ printSKEY(&sk),
+ &enc);
#endif
if (stats != NULL) {
stats->change(stat_pingSent, 1);
@@ -534,28 +534,28 @@
}
if (hello != NULL) {
coreAPI->sendPlaintext(tsession,
- (const char*) hello,
- P2P_hello_MESSAGE_size(hello));
+ (const char*) hello,
+ P2P_hello_MESSAGE_size(hello));
FREE(hello);
hello = NULL;
coreAPI->sendPlaintext(tsession,
- (const char*) skey,
- ntohs(skey->header.size));
+ (const char*) skey,
+ ntohs(skey->header.size));
}
FREE(skey);
if (0 != memcmp(receiver,
- &tsession->peer,
- sizeof(PeerIdentity))) {
+ &tsession->peer,
+ sizeof(PeerIdentity))) {
GE_BREAK(NULL, 0);
transport->disconnect(tsession);
} else {
coreAPI->offerTSessionFor(receiver,
- tsession);
+ tsession);
}
coreAPI->assignSessionKey(&sk,
- receiver,
- age,
- YES);
+ receiver,
+ age,
+ YES);
return OK;
}
@@ -572,8 +572,8 @@
* @return SYSERR or OK
*/
static int acceptSessionKey(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg,
- TSession * tsession) {
+ const MESSAGE_HEADER * msg,
+ TSession * tsession) {
SESSIONKEY key;
MESSAGE_HEADER * ping;
MESSAGE_HEADER * pong;
@@ -592,34 +592,34 @@
return SYSERR;
}
hash2enc(&sender->hashPubKey,
- &enc);
+ &enc);
if ( (topology != NULL) &&
(topology->allowConnectionFrom(sender) == SYSERR) ) {
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Topology rejected session key from peer `%s'.\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Topology rejected session key from peer `%s'.\n",
+ &enc);
#endif
return SYSERR;
}
if (equalsHashCode512(&sender->hashPubKey,
- &coreAPI->myIdentity->hashPubKey)) {
+ &coreAPI->myIdentity->hashPubKey)) {
GE_BREAK(ectx, 0);
return SYSERR;
}
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Received session key from peer `%s'.\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Received session key from peer `%s'.\n",
+ &enc);
#endif
if (ntohs(msg->size) < sizeof(P2P_setkey_MESSAGE)) {
GE_LOG(ectx,
- GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
- _("Session key received from peer `%s' has invalid format
(discarded).\n"),
- &enc);
+ GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
+ _("Session key received from peer `%s' has invalid format
(discarded).\n"),
+ &enc);
return SYSERR;
}
sessionkeySigned = (const P2P_setkey_MESSAGE *) msg;
@@ -630,15 +630,15 @@
newMsg = (const P2P_new_setkey_MESSAGE *) msg;
if (!equalsHashCode512(&coreAPI->myIdentity->hashPubKey,
- &newMsg->target.hashPubKey)) {
+ &newMsg->target.hashPubKey)) {
EncName ta;
hash2enc(&newMsg->target.hashPubKey,
- &ta);
+ &ta);
GE_LOG(ectx,
- GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
- _("Session key received from peer `%s' is for `%s' and not for
me!\n"),
- &enc,
- &ta);
+ GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
+ _("Session key received from peer `%s' is for `%s' and not for me!\n"),
+ &enc,
+ &ta);
return SYSERR; /* not for us! */
}
sig = &newMsg->signature;
@@ -647,76 +647,76 @@
newMsg = NULL;
}
ret = verifySKS(sender,
- sessionkeySigned,
- sig);
+ sessionkeySigned,
+ sig);
if (OK != ret) {
#if DEBUG_SESSION
if (ret == SYSERR)
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST | GE_DEVELOPER,
- "Signature of session key from `%s' failed"
- " verification (discarded).\n",
- &enc);
+ GE_INFO | GE_USER | GE_REQUEST | GE_DEVELOPER,
+ "Signature of session key from `%s' failed"
+ " verification (discarded).\n",
+ &enc);
#endif
if (stats != NULL)
stats->change(stat_skeyRejected,
- 1);
+ 1);
return SYSERR; /* rejected */
}
memset(&key, 0, sizeof(SESSIONKEY));
size = identity->decryptData(&sessionkeySigned->key,
- &key,
- sizeof(SESSIONKEY));
+ &key,
+ sizeof(SESSIONKEY));
if (size != sizeof(SESSIONKEY)) {
GE_LOG(ectx,
- GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
- _("Invalid `%s' message received from peer `%s'.\n"),
- "setkey",
- &enc);
+ GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
+ _("Invalid `%s' message received from peer `%s'.\n"),
+ "setkey",
+ &enc);
return SYSERR;
}
if (key.crc32 !=
htonl(crc32N(&key, SESSIONKEY_LEN))) {
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
- _("setkey `%s' from `%s' fails CRC check (have: %u, want %u).\n"),
- printSKEY(&key),
- &enc,
- ntohl(key.crc32),
- crc32N(&key, SESSIONKEY_LEN));
+ GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
+ _("setkey `%s' from `%s' fails CRC check (have: %u, want %u).\n"),
+ printSKEY(&key),
+ &enc,
+ ntohl(key.crc32),
+ crc32N(&key, SESSIONKEY_LEN));
#endif
GE_BREAK_OP(ectx, 0);
stats->change(stat_skeyRejected,
- 1);
+ 1);
return SYSERR;
}
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Received setkey message from `%s' with %u bytes of data and key
`%s'.\n",
- &enc,
- ntohs(sessionkeySigned->header.size),
- printSKEY(&key));
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Received setkey message from `%s' with %u bytes of data and key `%s'.\n",
+ &enc,
+ ntohs(sessionkeySigned->header.size),
+ printSKEY(&key));
#endif
if (stats != NULL)
stats->change(stat_skeyAccepted,
- 1);
+ 1);
/* notify core about session key */
coreAPI->assignSessionKey(&key,
- sender,
- ntohl(sessionkeySigned->creationTime),
- NO);
+ sender,
+ ntohl(sessionkeySigned->creationTime),
+ NO);
pos = sizeof(P2P_setkey_MESSAGE);
ping = NULL;
pong = NULL;
plaintext = NULL;
size = ntohs(sessionkeySigned->header.size);
if ( ( (newMsg == NULL) &&
- (sizeof(P2P_setkey_MESSAGE) < size) ) ||
+ (sizeof(P2P_setkey_MESSAGE) < size) ) ||
( (newMsg != NULL) &&
- (sizeof(P2P_new_setkey_MESSAGE) < size) ) ) {
+ (sizeof(P2P_new_setkey_MESSAGE) < size) ) ) {
if (newMsg == NULL) {
size -= sizeof(P2P_setkey_MESSAGE);
end = &sessionkeySigned[1];
@@ -727,19 +727,19 @@
plaintext = MALLOC(size);
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Decrypting %d bytes of PINGPONG from `%s' with key `%s' and IV
%u\n",
- size,
- &enc,
- printSKEY(&key),
- *(int*)sig);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Decrypting %d bytes of PINGPONG from `%s' with key `%s' and IV %u\n",
+ size,
+ &enc,
+ printSKEY(&key),
+ *(int*)sig);
#endif
GE_ASSERT(ectx,
- -1 != decryptBlock(&key,
- end,
- size,
- (const INITVECTOR*) sig,
- plaintext));
+ -1 != decryptBlock(&key,
+ end,
+ size,
+ (const INITVECTOR*) sig,
+ plaintext));
pos = 0;
/* find pings & pongs! */
while (pos + sizeof(MESSAGE_HEADER) < size) {
@@ -747,24 +747,24 @@
hdr = (MESSAGE_HEADER*) &plaintext[pos];
if (htons(hdr->size) + pos > size) {
- GE_LOG(ectx,
- GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
- _("Error parsing encrypted session key from `%s', "
- "given message part size is invalid.\n"),
- &enc);
- break;
+ GE_LOG(ectx,
+ GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
+ _("Error parsing encrypted session key from `%s', "
+ "given message part size is invalid.\n"),
+ &enc);
+ break;
}
if (htons(hdr->type) == p2p_PROTO_PING)
- ping = hdr;
+ ping = hdr;
else if (htons(hdr->type) == p2p_PROTO_PONG)
- pong = hdr;
+ pong = hdr;
else
- GE_LOG(ectx,
- GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
- _("Unknown type in embedded message from `%s': %u (size: %u)\n"),
- &enc,
- htons(hdr->type),
- htons(hdr->size));
+ GE_LOG(ectx,
+ GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
+ _("Unknown type in embedded message from `%s': %u (size: %u)\n"),
+ &enc,
+ htons(hdr->type),
+ htons(hdr->size));
pos += ntohs(hdr->size);
}
}
@@ -773,47 +773,47 @@
/* notify ourselves about encapsulated pong */
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Received PONG in session key from `%s', injecting!\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Received PONG in session key from `%s', injecting!\n",
+ &enc);
#endif
coreAPI->injectMessage(sender,
- (char*) pong,
- ntohs(pong->size),
- YES,
- tsession);
+ (char*) pong,
+ ntohs(pong->size),
+ YES,
+ tsession);
if (ping != NULL) { /* should always be true for well-behaved peers */
/* pong can go out over ordinary channels */
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Received PING in session key from `%s', "
- "sending PONG over normal encrypted session!\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Received PING in session key from `%s', "
+ "sending PONG over normal encrypted session!\n",
+ &enc);
#endif
ping->type = htons(p2p_PROTO_PONG);
if (stats != NULL)
- stats->change(stat_pongSent, 1);
+ stats->change(stat_pongSent, 1);
coreAPI->unicast(sender,
- ping,
- EXTREME_PRIORITY,
- 0);
+ ping,
+ EXTREME_PRIORITY,
+ 0);
}
} else {
if (ping != NULL) {
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Received ping in session key from `%s', "
- "sending pong together with my session key!\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Received ping in session key from `%s', "
+ "sending pong together with my session key!\n",
+ &enc);
#endif
ping->type = htons(p2p_PROTO_PONG);
if (stats != NULL)
- stats->change(stat_pongSent, 1);
+ stats->change(stat_pongSent, 1);
exchangeKey(sender,
- tsession,
- ping); /* ping is now pong */
+ tsession,
+ ping); /* ping is now pong */
} else {
GE_BREAK_OP(ectx, 0);
/* PING not included in SKEY - bug (in other peer!?) */
@@ -835,34 +835,34 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- hash2enc(&peer->hashPubKey,
- &enc));
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ hash2enc(&peer->hashPubKey,
+ &enc));
#endif
if ( (topology != NULL) &&
(topology->allowConnectionFrom(peer) == SYSERR) ) {
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Topology rejected connecting to `%s'.\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Topology rejected connecting to `%s'.\n",
+ &enc);
#endif
return SYSERR;
}
if (coreAPI->queryPeerStatus(peer, NULL, NULL) == OK) {
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Connection to `%s' already up\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Connection to `%s' already up\n",
+ &enc);
#endif
return YES; /* trivial case */
}
#if DEBUG_SESSION
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Trying to exchange key with `%s'.\n",
- &enc);
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Trying to exchange key with `%s'.\n",
+ &enc);
#endif
if (OK == exchangeKey(peer, NULL, NULL))
return NO;
@@ -875,10 +875,10 @@
* value. (Rekeying).
*/
static int acceptSessionKeyUpdate(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
acceptSessionKey(sender,
- msg,
- NULL);
+ msg,
+ NULL);
return OK;
}
@@ -932,14 +932,14 @@
}
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("`%s' registering handler %d (plaintext and ciphertext)\n"),
- "session",
- P2P_PROTO_setkey);
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("`%s' registering handler %d (plaintext and ciphertext)\n"),
+ "session",
+ P2P_PROTO_setkey);
coreAPI->registerPlaintextHandler(P2P_PROTO_setkey,
- &acceptSessionKey);
+ &acceptSessionKey);
coreAPI->registerHandler(P2P_PROTO_setkey,
- &acceptSessionKeyUpdate);
+ &acceptSessionKeyUpdate);
ret.tryConnect = &tryConnect;
return &ret;
}
@@ -949,9 +949,9 @@
*/
int release_module_session() {
coreAPI->unregisterPlaintextHandler(P2P_PROTO_setkey,
- &acceptSessionKey);
+ &acceptSessionKey);
coreAPI->unregisterHandler(P2P_PROTO_setkey,
- &acceptSessionKeyUpdate);
+ &acceptSessionKeyUpdate);
if (topology != NULL) {
coreAPI->releaseService(topology);
topology = NULL;
Modified: GNUnet/src/applications/session/sessiontest.c
===================================================================
--- GNUnet/src/applications/session/sessiontest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/session/sessiontest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -67,76 +67,76 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_PEERS
peers = gnunet_testing_start_daemons(NULL == strstr(argv[0], "_udp") ? "tcp"
: "udp",
- "advertising stats",
- "/tmp/gnunet-session-test",
- 2087,
- 10000,
- 2);
+ "advertising stats",
+ "/tmp/gnunet-session-test",
+ 2087,
+ 10000,
+ 2);
if (peers == NULL) {
GC_free(cfg);
return -1;
}
#endif
gnunet_testing_connect_daemons(2087,
- 12087);
+ 12087);
if (OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS)) {
+ cfg,
+ 30 * cronSECONDS)) {
sock1 = client_connection_create(NULL,
- cfg);
+ cfg);
GC_set_configuration_value_string(cfg,
- NULL,
- "NETWORK",
- "HOST",
- "localhost:12087");
+ NULL,
+ "NETWORK",
+ "HOST",
+ "localhost:12087");
sock2 = client_connection_create(NULL,
- cfg);
+ cfg);
left = 30; /* how many iterations should we wait? */
while (OK == STATS_getStatistics(NULL,
- sock1,
- &waitForConnect,
- NULL)) {
+ sock1,
+ &waitForConnect,
+ NULL)) {
printf("Waiting for peers to connect (%u iterations left)...\n",
- left);
+ left);
sleep(5);
left--;
if (left == 0) {
- ret = 1;
- break;
+ ret = 1;
+ break;
}
}
#if 0
if (ok == 1) {
for (left=0;left<10;left++) {
- ok = 0;
- while (GNUNET_SHUTDOWN_TEST() == NO) {
- printf("Checking that peers are staying connected 1...\n");
- STATS_getStatistics(NULL,
- sock1,
- &waitForConnect,
- NULL);
- sleep(1);
- if (ok == 0) {
- printf("Peers disconnected!\n");
- break;
- }
- printf("Checking that peers are staying connected 2...\n");
- STATS_getStatistics(NULL,
- sock2,
- &waitForConnect,
- NULL);
- sleep(1);
- if (ok == 0) {
- printf("Peers disconnected!\n");
- break;
- }
- }
+ ok = 0;
+ while (GNUNET_SHUTDOWN_TEST() == NO) {
+ printf("Checking that peers are staying connected 1...\n");
+ STATS_getStatistics(NULL,
+ sock1,
+ &waitForConnect,
+ NULL);
+ sleep(1);
+ if (ok == 0) {
+ printf("Peers disconnected!\n");
+ break;
+ }
+ printf("Checking that peers are staying connected 2...\n");
+ STATS_getStatistics(NULL,
+ sock2,
+ &waitForConnect,
+ NULL);
+ sleep(1);
+ if (ok == 0) {
+ printf("Peers disconnected!\n");
+ break;
+ }
+ }
}
} else {
printf("Peers failed to connect!\n");
Modified: GNUnet/src/applications/session/sessiontest2.c
===================================================================
--- GNUnet/src/applications/session/sessiontest2.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/session/sessiontest2.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -57,7 +57,7 @@
* @return OK on success, SYSERR on failure
*/
static int connect_daemons(unsigned short port1,
- unsigned short port2) {
+ unsigned short port2) {
char host[128];
GC_Configuration * cfg1 = GC_create_C_impl();
GC_Configuration * cfg2 = GC_create_C_impl();
@@ -68,39 +68,39 @@
ret = SYSERR;
SNPRINTF(host,
- 128,
- "localhost:%u",
- port1);
+ 128,
+ "localhost:%u",
+ port1);
GC_set_configuration_value_string(cfg1,
- NULL,
- "NETWORK",
- "HOST",
- host);
+ NULL,
+ "NETWORK",
+ "HOST",
+ host);
SNPRINTF(host,
- 128,
- "localhost:%u",
- port2);
+ 128,
+ "localhost:%u",
+ port2);
GC_set_configuration_value_string(cfg2,
- NULL,
- "NETWORK",
- "HOST",
- host);
+ NULL,
+ "NETWORK",
+ "HOST",
+ host);
if ( (OK == connection_wait_for_running(NULL,
- cfg1,
- 300 * cronSECONDS) ) &&
+ cfg1,
+ 300 * cronSECONDS) ) &&
(OK == connection_wait_for_running(NULL,
- cfg2,
- 300 * cronSECONDS) ) ) {
+ cfg2,
+ 300 * cronSECONDS) ) ) {
sock1 = client_connection_create(NULL,
- cfg1);
+ cfg1);
sock2 = client_connection_create(NULL,
- cfg2);
+ cfg2);
h1 = NULL;
fprintf(stderr, "Notifying NATed peer about other peer");
if ( (OK == gnunet_identity_get_self(sock1,
- &h1)) &&
- (OK == gnunet_identity_peer_add(sock2,
- h1)) ) {
+ &h1)) &&
+ (OK == gnunet_identity_peer_add(sock2,
+ h1)) ) {
fprintf(stderr, "!\n");
ret = OK;
} else
@@ -110,7 +110,7 @@
connection_destroy(sock2);
} else {
fprintf(stderr,
- "Failed to establish connection with peers.\n");
+ "Failed to establish connection with peers.\n");
}
GC_free(cfg1);
GC_free(cfg2);
@@ -137,23 +137,23 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_PEERS
peer1 = os_daemon_start(NULL,
- cfg,
- "tcp-peer.conf",
- NO);
+ cfg,
+ "tcp-peer.conf",
+ NO);
if (peer1 == -1) {
GC_free(cfg);
return -1;
}
peer2 = os_daemon_start(NULL,
- cfg,
- "nat-peer.conf",
- NO);
+ cfg,
+ "nat-peer.conf",
+ NO);
if (peer2 == -1) {
os_daemon_stop(NULL, peer1);
GC_free(cfg);
@@ -161,24 +161,24 @@
}
#endif
connect_daemons(2087,
- 12087);
+ 12087);
if (OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS)) {
+ cfg,
+ 30 * cronSECONDS)) {
sock = client_connection_create(NULL,
- cfg);
+ cfg);
left = 30; /* how many iterations should we wait? */
while (OK == STATS_getStatistics(NULL,
- sock,
- &waitForConnect,
- NULL)) {
+ sock,
+ &waitForConnect,
+ NULL)) {
printf("Waiting for peers to connect (%u iterations left)...\n",
- left);
+ left);
sleep(5);
left--;
if (left == 0) {
- ret = 1;
- break;
+ ret = 1;
+ break;
}
}
connection_destroy(sock);
Modified: GNUnet/src/applications/session/sessiontest_http.c
===================================================================
--- GNUnet/src/applications/session/sessiontest_http.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/session/sessiontest_http.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -57,7 +57,7 @@
* @return OK on success, SYSERR on failure
*/
static int connect_daemons(unsigned short port1,
- unsigned short port2) {
+ unsigned short port2) {
char host[128];
GC_Configuration * cfg1 = GC_create_C_impl();
GC_Configuration * cfg2 = GC_create_C_impl();
@@ -68,39 +68,39 @@
ret = SYSERR;
SNPRINTF(host,
- 128,
- "localhost:%u",
- port1);
+ 128,
+ "localhost:%u",
+ port1);
GC_set_configuration_value_string(cfg1,
- NULL,
- "NETWORK",
- "HOST",
- host);
+ NULL,
+ "NETWORK",
+ "HOST",
+ host);
SNPRINTF(host,
- 128,
- "localhost:%u",
- port2);
+ 128,
+ "localhost:%u",
+ port2);
GC_set_configuration_value_string(cfg2,
- NULL,
- "NETWORK",
- "HOST",
- host);
+ NULL,
+ "NETWORK",
+ "HOST",
+ host);
if ( (OK == connection_wait_for_running(NULL,
- cfg1,
- 300 * cronSECONDS) ) &&
+ cfg1,
+ 300 * cronSECONDS) ) &&
(OK == connection_wait_for_running(NULL,
- cfg2,
- 300 * cronSECONDS) ) ) {
+ cfg2,
+ 300 * cronSECONDS) ) ) {
sock1 = client_connection_create(NULL,
- cfg1);
+ cfg1);
sock2 = client_connection_create(NULL,
- cfg2);
+ cfg2);
h1 = NULL;
fprintf(stderr, "Notifying NATed peer about other peer");
if ( (OK == gnunet_identity_get_self(sock1,
- &h1)) &&
- (OK == gnunet_identity_peer_add(sock2,
- h1)) ) {
+ &h1)) &&
+ (OK == gnunet_identity_peer_add(sock2,
+ h1)) ) {
fprintf(stderr, "!\n");
ret = OK;
} else
@@ -110,7 +110,7 @@
connection_destroy(sock2);
} else {
fprintf(stderr,
- "Failed to establish connection with peers.\n");
+ "Failed to establish connection with peers.\n");
}
GC_free(cfg1);
GC_free(cfg2);
@@ -137,23 +137,23 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_PEERS
peer1 = os_daemon_start(NULL,
- cfg,
- "http-peer.conf",
- NO);
+ cfg,
+ "http-peer.conf",
+ NO);
if (peer1 == -1) {
GC_free(cfg);
return -1;
}
peer2 = os_daemon_start(NULL,
- cfg,
- "nat-http-peer.conf",
- NO);
+ cfg,
+ "nat-http-peer.conf",
+ NO);
if (peer2 == -1) {
os_daemon_stop(NULL, peer1);
GC_free(cfg);
@@ -161,24 +161,24 @@
}
#endif
connect_daemons(2087,
- 12087);
+ 12087);
if (OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS)) {
+ cfg,
+ 30 * cronSECONDS)) {
sock = client_connection_create(NULL,
- cfg);
+ cfg);
left = 30; /* how many iterations should we wait? */
while (OK == STATS_getStatistics(NULL,
- sock,
- &waitForConnect,
- NULL)) {
+ sock,
+ &waitForConnect,
+ NULL)) {
printf("Waiting for peers to connect (%u iterations left)...\n",
- left);
+ left);
sleep(5);
left--;
if (left == 0) {
- ret = 1;
- break;
+ ret = 1;
+ break;
}
}
connection_destroy(sock);
Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -231,8 +231,8 @@
*
*/
static Datastore_Datum * assembleDatum(MYSQL_RES * res,
- MYSQL_ROW sql_row,
- mysqlHandle * dbhI) {
+ MYSQL_ROW sql_row,
+ mysqlHandle * dbhI) {
Datastore_Datum * datum;
int contentSize;
unsigned long * lens;
@@ -254,20 +254,20 @@
(SSCANF(sql_row[4], "%llu", &exp) != 1) ) {
mysql_free_result(res);
if ( (lens[5] != sizeof(HashCode512)) ||
- (lens[6] != contentSize) ) {
+ (lens[6] != contentSize) ) {
char scratch[512];
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Invalid data in %s. Trying to fix (by deletion).\n"),
- _("mysql datastore"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Invalid data in %s. Trying to fix (by deletion).\n"),
+ _("mysql datastore"));
SNPRINTF(scratch,
- 512,
- "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
- sizeof(HashCode512),
- sizeof(Datastore_Value));
+ 512,
+ "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
+ sizeof(HashCode512),
+ sizeof(Datastore_Value));
if (0 != mysql_query(dbhI->dbf, scratch))
- LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbhI);
+ LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbhI);
} else {
GE_BREAK(ectx, 0); /* should really never happen */
}
@@ -280,11 +280,11 @@
datum->value.anonymityLevel = htonl(level);
datum->value.expirationTime = htonll(exp);
memcpy(&datum->key,
- sql_row[5],
- sizeof(HashCode512));
+ sql_row[5],
+ sizeof(HashCode512));
memcpy(&datum[1],
sql_row[6],
- contentSize);
+ contentSize);
return datum;
}
@@ -295,7 +295,7 @@
* @return OK on success
*/
static int iopen(mysqlHandle * dbhI,
- int prepare) {
+ int prepare) {
char * dbname;
my_bool reconnect = 0;
unsigned int timeout = 5; /* in seconds */
@@ -306,76 +306,76 @@
if (dbhI->dbf == NULL)
return SYSERR;
mysql_options(dbhI->dbf,
- MYSQL_READ_DEFAULT_FILE,
- dbh->cnffile);
+ MYSQL_READ_DEFAULT_FILE,
+ dbh->cnffile);
mysql_options(dbhI->dbf,
- MYSQL_READ_DEFAULT_GROUP,
- "client");
+ MYSQL_READ_DEFAULT_GROUP,
+ "client");
mysql_options(dbhI->dbf,
- MYSQL_OPT_RECONNECT,
- &reconnect);
+ MYSQL_OPT_RECONNECT,
+ &reconnect);
mysql_options(dbhI->dbf,
- MYSQL_OPT_CONNECT_TIMEOUT,
- (const void*) &timeout);
+ MYSQL_OPT_CONNECT_TIMEOUT,
+ (const void*) &timeout);
mysql_options(dbhI->dbf,
- MYSQL_OPT_READ_TIMEOUT,
- (const void*) &timeout);
+ MYSQL_OPT_READ_TIMEOUT,
+ (const void*) &timeout);
mysql_options(dbhI->dbf,
- MYSQL_OPT_WRITE_TIMEOUT,
- (const void*) &timeout);
+ MYSQL_OPT_WRITE_TIMEOUT,
+ (const void*) &timeout);
dbname = NULL;
GC_get_configuration_value_string(coreAPI->cfg,
- "MYSQL",
- "DATABASE",
- "gnunet",
- &dbname);
+ "MYSQL",
+ "DATABASE",
+ "gnunet",
+ &dbname);
GE_ASSERT(ectx, dbname != NULL);
mysql_real_connect(dbhI->dbf,
- NULL,
- NULL,
- NULL,
- dbname,
- 0,
- NULL,
- 0);
+ NULL,
+ NULL,
+ NULL,
+ dbname,
+ 0,
+ NULL,
+ 0);
FREE(dbname);
if (mysql_error(dbhI->dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_real_connect",
- dbhI);
+ "mysql_real_connect",
+ dbhI);
dbhI->dbf = NULL;
return SYSERR;
}
if (prepare) {
mysql_query(dbhI->dbf,
- "CREATE TABLE IF NOT EXISTS gn070 ("
- " size INT(11) NOT NULL DEFAULT 0,"
- " type INT(11) NOT NULL DEFAULT 0,"
- " prio INT(11) NOT NULL DEFAULT 0,"
- " anonLevel INT(11) NOT NULL DEFAULT 0,"
- " expire BIGINT NOT NULL DEFAULT 0,"
- " hash TINYBLOB NOT NULL DEFAULT '',"
- " value BLOB NOT NULL DEFAULT '',"
- " INDEX (hash(64)),"
- " INDEX (prio),"
- " INDEX (expire),"
- " INDEX (expire,anonLevel,type)"
- ") TYPE=InnoDB");
+ "CREATE TABLE IF NOT EXISTS gn070 ("
+ " size INT(11) NOT NULL DEFAULT 0,"
+ " type INT(11) NOT NULL DEFAULT 0,"
+ " prio INT(11) NOT NULL DEFAULT 0,"
+ " anonLevel INT(11) NOT NULL DEFAULT 0,"
+ " expire BIGINT NOT NULL DEFAULT 0,"
+ " hash TINYBLOB NOT NULL DEFAULT '',"
+ " value BLOB NOT NULL DEFAULT '',"
+ " INDEX (hash(64)),"
+ " INDEX (prio),"
+ " INDEX (expire),"
+ " INDEX (expire,anonLevel,type)"
+ ") TYPE=InnoDB");
if (mysql_error(dbhI->dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- dbhI);
+ "mysql_query",
+ dbhI);
mysql_close(dbhI->dbf);
dbhI->dbf = NULL;
return SYSERR;
}
mysql_query(dbhI->dbf,
- "SET AUTOCOMMIT = 1");
+ "SET AUTOCOMMIT = 1");
if (mysql_error(dbhI->dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- dbhI);
+ "mysql_query",
+ dbhI);
mysql_close(dbhI->dbf);
dbhI->dbf = NULL;
return SYSERR;
@@ -389,66 +389,66 @@
dbhI->deleteh = mysql_stmt_init(dbhI->dbf);
dbhI->deleteg = mysql_stmt_init(dbhI->dbf);
if ( (dbhI->insert == NULL) ||
- (dbhI->update == NULL) ||
- (dbhI->select == NULL) ||
- (dbhI->selectc == NULL) ||
- (dbhI->selects == NULL) ||
- (dbhI->selectsc == NULL) ||
- (dbhI->deleteh == NULL) ||
- (dbhI->deleteg == NULL) ) {
+ (dbhI->update == NULL) ||
+ (dbhI->select == NULL) ||
+ (dbhI->selectc == NULL) ||
+ (dbhI->selects == NULL) ||
+ (dbhI->selectsc == NULL) ||
+ (dbhI->deleteh == NULL) ||
+ (dbhI->deleteg == NULL) ) {
GE_BREAK(ectx, 0);
if (dbhI->insert != NULL)
- mysql_stmt_close(dbhI->insert);
+ mysql_stmt_close(dbhI->insert);
if (dbhI->update != NULL)
- mysql_stmt_close(dbhI->update);
+ mysql_stmt_close(dbhI->update);
if (dbhI->select != NULL)
- mysql_stmt_close(dbhI->select);
+ mysql_stmt_close(dbhI->select);
if (dbhI->selectc != NULL)
- mysql_stmt_close(dbhI->selectc);
+ mysql_stmt_close(dbhI->selectc);
if (dbhI->selects != NULL)
- mysql_stmt_close(dbhI->selects);
+ mysql_stmt_close(dbhI->selects);
if (dbhI->selectsc != NULL)
- mysql_stmt_close(dbhI->selectsc);
+ mysql_stmt_close(dbhI->selectsc);
mysql_close(dbhI->dbf);
dbhI->dbf = NULL;
return SYSERR;
}
if (mysql_stmt_prepare(dbhI->insert,
- INSERT_SAMPLE,
- strlen(INSERT_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->select,
- SELECT_SAMPLE,
- strlen(SELECT_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->selectc,
- SELECT_SAMPLE_COUNT,
- strlen(SELECT_SAMPLE_COUNT)) ||
- mysql_stmt_prepare(dbhI->selects,
- SELECT_TYPE_SAMPLE,
- strlen(SELECT_TYPE_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->selectsc,
- SELECT_TYPE_SAMPLE_COUNT,
- strlen(SELECT_TYPE_SAMPLE_COUNT)) ||
- mysql_stmt_prepare(dbhI->update,
- UPDATE_SAMPLE,
- strlen(UPDATE_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->deleteh,
- SELECT_HASH_SAMPLE,
- strlen(SELECT_HASH_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->deleteg,
- DELETE_GENERIC_SAMPLE,
- strlen(DELETE_GENERIC_SAMPLE)) ) {
+ INSERT_SAMPLE,
+ strlen(INSERT_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->select,
+ SELECT_SAMPLE,
+ strlen(SELECT_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->selectc,
+ SELECT_SAMPLE_COUNT,
+ strlen(SELECT_SAMPLE_COUNT)) ||
+ mysql_stmt_prepare(dbhI->selects,
+ SELECT_TYPE_SAMPLE,
+ strlen(SELECT_TYPE_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->selectsc,
+ SELECT_TYPE_SAMPLE_COUNT,
+ strlen(SELECT_TYPE_SAMPLE_COUNT)) ||
+ mysql_stmt_prepare(dbhI->update,
+ UPDATE_SAMPLE,
+ strlen(UPDATE_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->deleteh,
+ SELECT_HASH_SAMPLE,
+ strlen(SELECT_HASH_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->deleteg,
+ DELETE_GENERIC_SAMPLE,
+ strlen(DELETE_GENERIC_SAMPLE)) ) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: I/%s S/%s SC/%s SS/%s SSC/%s U/%s
D/%s DG/%s\n"),
- "mysql_stmt_prepare",
- __FILE__, __LINE__,
- mysql_stmt_error(dbhI->insert),
- mysql_stmt_error(dbhI->select),
- mysql_stmt_error(dbhI->selectc),
- mysql_stmt_error(dbhI->selects),
- mysql_stmt_error(dbhI->selectsc),
- mysql_stmt_error(dbhI->update),
- mysql_stmt_error(dbhI->deleteh),
- mysql_stmt_error(dbhI->deleteg));
+ _("`%s' failed at %s:%d with error: I/%s S/%s SC/%s SS/%s SSC/%s U/%s D/%s
DG/%s\n"),
+ "mysql_stmt_prepare",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbhI->insert),
+ mysql_stmt_error(dbhI->select),
+ mysql_stmt_error(dbhI->selectc),
+ mysql_stmt_error(dbhI->selects),
+ mysql_stmt_error(dbhI->selectsc),
+ mysql_stmt_error(dbhI->update),
+ mysql_stmt_error(dbhI->deleteh),
+ mysql_stmt_error(dbhI->deleteg));
mysql_stmt_close(dbhI->insert);
mysql_stmt_close(dbhI->select);
mysql_stmt_close(dbhI->selectc);
@@ -462,8 +462,8 @@
return SYSERR;
}
memset(dbhI->bind,
- 0,
- sizeof(dbhI->bind));
+ 0,
+ sizeof(dbhI->bind));
dbhI->bind[0].buffer_type = MYSQL_TYPE_LONG; /* size */
dbhI->bind[1].buffer_type = MYSQL_TYPE_LONG; /* type */
dbhI->bind[2].buffer_type = MYSQL_TYPE_LONG; /* prio */
@@ -472,13 +472,13 @@
dbhI->bind[5].buffer_type = MYSQL_TYPE_TINY_BLOB; /* hash */
dbhI->bind[6].buffer_type = MYSQL_TYPE_BLOB; /* value */
memset(dbhI->sbind,
- 0,
- sizeof(dbhI->sbind));
+ 0,
+ sizeof(dbhI->sbind));
dbhI->sbind[0].buffer_type = MYSQL_TYPE_TINY_BLOB; /* hash */
dbhI->sbind[1].buffer_type = MYSQL_TYPE_LONG; /* type */
memset(dbhI->dbind,
- 0,
- sizeof(dbhI->dbind));
+ 0,
+ sizeof(dbhI->dbind));
dbhI->dbind[0].buffer_type = MYSQL_TYPE_TINY_BLOB; /* hash */
dbhI->dbind[1].buffer_type = MYSQL_TYPE_LONG; /* size */
dbhI->dbind[2].buffer_type = MYSQL_TYPE_LONG; /* type */
@@ -487,8 +487,8 @@
dbhI->dbind[5].buffer_type = MYSQL_TYPE_LONGLONG; /* expiration */
dbhI->dbind[6].buffer_type = MYSQL_TYPE_BLOB; /* value */
memset(dbhI->ubind,
- 0,
- sizeof(dbhI->ubind));
+ 0,
+ sizeof(dbhI->ubind));
dbhI->ubind[0].buffer_type = MYSQL_TYPE_LONG;
dbhI->ubind[1].buffer_type = MYSQL_TYPE_LONG;
dbhI->ubind[2].buffer_type = MYSQL_TYPE_LONG;
@@ -498,7 +498,7 @@
} else {
dbhI->prepare = NO;
mysql_query(dbhI->dbf,
- "SET SESSION net_read_timeout=28800, SESSION
net_write_timeout=28800");
+ "SET SESSION net_read_timeout=28800, SESSION net_write_timeout=28800");
}
dbhI->valid = YES;
return OK;
@@ -553,9 +553,9 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateHelper(unsigned int type,
- const char * query,
- Datum_Iterator iter,
- void * closure) {
+ const char * query,
+ Datum_Iterator iter,
+ void * closure) {
MYSQL_RES *sql_res;
MYSQL_ROW sql_row;
Datastore_Datum * datum;
@@ -571,31 +571,31 @@
mysql_thread_init();
mysql_query(dbhI.dbf,
- "SET AUTOCOMMIT = 0");
+ "SET AUTOCOMMIT = 0");
mysql_query(dbhI.dbf,
- "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED");
+ "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED");
if (type==0) {
typestr[0] = '\0';
} else {
SNPRINTF(typestr,
32,
"WHERE type=%u ",
- type);
+ type);
}
now = get_time();
scratch = MALLOC(256);
SNPRINTF(scratch,
- 256,
- query,
- typestr,
- now);
+ 256,
+ query,
+ typestr,
+ now);
mysql_query(dbhI.dbf,
- scratch);
+ scratch);
FREE(scratch);
if (mysql_error(dbhI.dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- &dbhI);
+ "mysql_query",
+ &dbhI);
mysql_thread_end();
iclose(&dbhI);
return SYSERR;
@@ -606,17 +606,17 @@
}
while ((sql_row=mysql_fetch_row(sql_res))) {
datum = assembleDatum(sql_res,
- sql_row,
- &dbhI);
+ sql_row,
+ &dbhI);
if (datum == NULL) {
mysql_thread_end();
iclose(&dbhI);
return count;
}
if ( (iter != NULL) &&
- (SYSERR == iter(&datum->key,
- &datum->value,
- closure) ) ) {
+ (SYSERR == iter(&datum->key,
+ &datum->value,
+ closure) ) ) {
count = SYSERR;
FREE(datum);
break;
@@ -626,13 +626,13 @@
}
if (mysql_error(dbhI.dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- &dbhI);
+ "mysql_query",
+ &dbhI);
mysql_free_result(sql_res);
mysql_thread_end();
iclose(&dbhI);
return SYSERR;
- }
+ }
mysql_free_result(sql_res);
mysql_thread_end();
iclose(&dbhI);
@@ -650,14 +650,14 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateLowPriority(unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ Datum_Iterator iter,
+ void * closure) {
return iterateHelper(type,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %s"
- "ORDER BY prio ASC",
- iter,
- closure);
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %s"
+ "ORDER BY prio ASC",
+ iter,
+ closure);
}
/**
@@ -671,25 +671,25 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateNonAnonymous(unsigned int type,
- int on_demand,
- Datum_Iterator iter,
- void * closure) {
+ int on_demand,
+ Datum_Iterator iter,
+ void * closure) {
char limit[512];
if (on_demand == YES)
SNPRINTF(limit,
- 512,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %%s WHERE expire > %%llu AND anonLevel = 0 AND type != %d",
- ONDEMAND_BLOCK);
+ 512,
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %%s WHERE expire > %%llu AND anonLevel = 0 AND type != %d",
+ ONDEMAND_BLOCK);
else
strcpy(limit,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %s WHERE expire > %llu AND anonLevel = 0");
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %s WHERE expire > %llu AND anonLevel = 0");
return iterateHelper(type,
- limit,
- iter,
- closure);
+ limit,
+ iter,
+ closure);
}
/**
@@ -703,14 +703,14 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateExpirationTime(unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ Datum_Iterator iter,
+ void * closure) {
return iterateHelper(type,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %s"
- " ORDER BY expire ASC",
- iter,
- closure);
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %s"
+ " ORDER BY expire ASC",
+ iter,
+ closure);
}
/**
@@ -722,13 +722,13 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateMigrationOrder(Datum_Iterator iter,
- void * closure) {
+ void * closure) {
return iterateHelper(0,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %s WHERE expire > %llu"
- " ORDER BY expire DESC",
- iter,
- closure);
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %s WHERE expire > %llu"
+ " ORDER BY expire DESC",
+ iter,
+ closure);
}
/**
@@ -740,11 +740,11 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateAllNow(Datum_Iterator iter,
- void * closure) {
+ void * closure) {
return iterateHelper(0,
- "SELECT SQL_NO_CACHE * FROM gn070",
- iter,
- closure);
+ "SELECT SQL_NO_CACHE * FROM gn070",
+ iter,
+ closure);
}
#define MAX_DATUM_SIZE 65536
@@ -761,9 +761,9 @@
* iter is non-NULL and aborted the iteration
*/
static int get(const HashCode512 * query,
- unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ unsigned int type,
+ Datum_Iterator iter,
+ void * closure) {
MYSQL_RES * sql_res;
int count;
MYSQL_STMT * stmt;
@@ -786,14 +786,14 @@
#if DEBUG_MYSQL
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL looks for `%s' of type %u\n",
- &enc,
- type);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL looks for `%s' of type %u\n",
+ &enc,
+ type);
#endif
MUTEX_LOCK(lock);
mysql_thread_init();
@@ -821,11 +821,11 @@
sql_res = mysql_stmt_result_metadata(stmt);
if (! sql_res) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_result_metadata",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_result_metadata",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -840,13 +840,13 @@
return SYSERR;
}
if (mysql_stmt_bind_param(stmt,
- dbh->sbind)) {
+ dbh->sbind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -854,11 +854,11 @@
}
if (mysql_stmt_execute(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -885,13 +885,13 @@
dbh->bind[5].buffer_length = sizeof(HashCode512);
dbh->bind[6].buffer_length = MAX_DATUM_SIZE;
if (mysql_stmt_bind_result(stmt,
- dbh->bind)) {
+ dbh->bind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_result",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_result",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -900,11 +900,11 @@
}
if (mysql_stmt_store_result(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_store_result",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_store_result",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -915,23 +915,23 @@
count = 0;
while (0 == mysql_stmt_fetch(stmt)) {
if ( (twenty != sizeof(HashCode512)) ||
- (datasize != size - sizeof(Datastore_Value)) ) {
+ (datasize != size - sizeof(Datastore_Value)) ) {
char scratch[512];
mysql_free_result(sql_res);
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Invalid data in %s. Trying to fix (by deletion).\n"),
- _("mysql datastore"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Invalid data in %s. Trying to fix (by deletion).\n"),
+ _("mysql datastore"));
SNPRINTF(scratch,
- 512,
- "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
- sizeof(HashCode512),
- sizeof(Datastore_Value));
+ 512,
+ "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
+ sizeof(HashCode512),
+ sizeof(Datastore_Value));
if (0 != mysql_query(dbh->dbf, scratch))
- LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- dbh);
+ LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
+ "mysql_query",
+ dbh);
FREE(datum);
iclose(dbh);
@@ -947,13 +947,13 @@
datum->expirationTime = htonll(expiration);
#if DEBUG_MYSQL
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Found in database block with type %u.\n",
- ntohl(*(int*)&datum[1]));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Found in database block with type %u.\n",
+ ntohl(*(int*)&datum[1]));
#endif
if (SYSERR == iter(&key,
- datum,
- closure) ) {
+ datum,
+ closure) ) {
count = SYSERR;
break;
}
@@ -961,11 +961,11 @@
}
if (mysql_stmt_errno(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_fetch",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_fetch",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_free_result(sql_res);
FREE(datum);
iclose(dbh);
@@ -980,22 +980,22 @@
#if DEBUG_MYSQL
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
if (count > 0) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL found %d results for `%s' of type %u.\n",
- count,
- &enc,
- type);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL found %d results for `%s' of type %u.\n",
+ count,
+ &enc,
+ type);
} else {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL iteration aborted looking for `%s' of type %u.\n",
- &enc,
- type);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL iteration aborted looking for `%s' of type %u.\n",
+ &enc,
+ type);
}
#endif
return count;
@@ -1007,7 +1007,7 @@
* @return OK on success, SYSERR on error
*/
static int put(const HashCode512 * key,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
unsigned long contentSize;
unsigned long hashSize;
unsigned int size;
@@ -1039,14 +1039,14 @@
expiration = ntohll(value->expirationTime);
#if DEBUG_MYSQL
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Storing in database block with type %u and key %s.\n",
- type,
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Storing in database block with type %u and key %s.\n",
+ type,
+ &enc);
#endif
dbh->bind[0].buffer = (char*) &size;
dbh->bind[1].buffer = (char*) &type;
@@ -1059,13 +1059,13 @@
dbh->bind[6].length = &contentSize;
if (mysql_stmt_bind_param(dbh->insert,
- dbh->bind)) {
+ dbh->bind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(dbh->insert));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbh->insert));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1074,11 +1074,11 @@
if (mysql_stmt_execute(dbh->insert)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(dbh->insert));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbh->insert));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1099,7 +1099,7 @@
* none were found, SYSERR on errors
*/
static int del(const HashCode512 * key,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
int count;
unsigned long twenty;
MYSQL_STMT * stmt;
@@ -1118,14 +1118,14 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL is executing deletion request for content of query `%s' and
type %u\n",
- &enc,
- value == NULL ? 0 : ntohl(value->type));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL is executing deletion request for content of query `%s' and type
%u\n",
+ &enc,
+ value == NULL ? 0 : ntohl(value->type));
#endif
twenty = sizeof(HashCode512);
svalue = NULL;
@@ -1145,11 +1145,11 @@
sql_res = mysql_stmt_result_metadata(stmt);
if (! sql_res) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_result_metadata",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_result_metadata",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1163,13 +1163,13 @@
return SYSERR;
}
if (mysql_stmt_bind_param(stmt,
- dbh->dbind)) {
+ dbh->dbind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1177,11 +1177,11 @@
}
if (mysql_stmt_execute(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1201,13 +1201,13 @@
dbh->bind[5].buffer_length = sizeof(HashCode512);
dbh->bind[6].buffer_length = MAX_DATUM_SIZE;
if (mysql_stmt_bind_result(stmt,
- dbh->bind)) {
+ dbh->bind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_result",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_result",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1216,13 +1216,13 @@
}
if (mysql_stmt_store_result(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_store_result",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_store_result",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
- mysql_thread_end();
+ mysql_thread_end();
MUTEX_UNLOCK(lock);
FREE(svalue);
return SYSERR;
@@ -1230,11 +1230,11 @@
datasize = MAX_DATUM_SIZE;
if (0 != mysql_stmt_fetch(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_fetch",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_fetch",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1242,22 +1242,22 @@
return SYSERR;
}
if ( (twenty != sizeof(HashCode512)) ||
- (datasize != size - sizeof(Datastore_Value)) ) {
+ (datasize != size - sizeof(Datastore_Value)) ) {
char scratch[512];
mysql_free_result(sql_res);
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Invalid data in %s. Trying to fix (by deletion).\n"),
- _("mysql datastore"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Invalid data in %s. Trying to fix (by deletion).\n"),
+ _("mysql datastore"));
SNPRINTF(scratch,
- 512,
- "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
- sizeof(HashCode512),
- sizeof(Datastore_Value));
+ 512,
+ "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
+ sizeof(HashCode512),
+ sizeof(Datastore_Value));
if (0 != mysql_query(dbh->dbf, scratch))
- LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query", dbh);
+ LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
+ "mysql_query", dbh);
FREE(svalue);
iclose(dbh);
mysql_thread_end();
@@ -1295,13 +1295,13 @@
#endif
GE_ASSERT(ectx, mysql_stmt_param_count(stmt) <= 7);
if (mysql_stmt_bind_param(stmt,
- dbh->dbind)) {
+ dbh->dbind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1311,11 +1311,11 @@
}
if (mysql_stmt_execute(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1327,9 +1327,9 @@
mysql_thread_end();
#if DEBUG_MYSQL
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL DELETE operation affected %d rows.\n",
- count);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL DELETE operation affected %d rows.\n",
+ count);
#endif
content_size -= ntohl(value->size);
MUTEX_UNLOCK(lock);
@@ -1343,9 +1343,9 @@
* in the datastore.
*/
static int update(const HashCode512 * key,
- const Datastore_Value * value,
- int delta,
- cron_t expire) {
+ const Datastore_Value * value,
+ int delta,
+ cron_t expire) {
unsigned long contentSize;
unsigned long twenty;
@@ -1366,15 +1366,15 @@
dbh->ubind[4].buffer = (char*) &value[1];
dbh->ubind[4].length = &contentSize;
GE_ASSERT(ectx,
- mysql_stmt_param_count(dbh->update) <= 5);
+ mysql_stmt_param_count(dbh->update) <= 5);
if (mysql_stmt_bind_param(dbh->update,
- dbh->ubind)) {
+ dbh->ubind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(dbh->update));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbh->update));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1387,11 +1387,11 @@
*/
if (mysql_stmt_execute(dbh->update)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(dbh->update));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbh->update));
iclose(dbh);
mysql_thread_end();
MUTEX_UNLOCK(lock);
@@ -1432,11 +1432,11 @@
return;
}
mysql_query(dbh->dbf,
- "DROP TABLE gn070");
+ "DROP TABLE gn070");
if (mysql_error(dbh->dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- dbh);
+ "mysql_query",
+ dbh);
iclose(dbh);
} else {
content_size = 0;
@@ -1470,8 +1470,8 @@
pw = getpwuid(getuid());
if(!pw)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "getpwuid");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "getpwuid");
home_dir = STRDUP(pw->pw_dir);
#else
home_dir = (char *) MALLOC(_MAX_PATH + 1);
@@ -1480,27 +1480,27 @@
nX = strlen(home_dir)+10;
cnffile = MALLOC(nX);
SNPRINTF(cnffile,
- nX,
- "%s/.my.cnf",
- home_dir);
+ nX,
+ "%s/.my.cnf",
+ home_dir);
FREE(home_dir);
GC_get_configuration_value_filename(capi->cfg,
- "MYSQL",
- "CONFIG",
- cnffile,
- &home_dir);
+ "MYSQL",
+ "CONFIG",
+ cnffile,
+ &home_dir);
FREE(cnffile);
cnffile = home_dir;
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("Trying to use file `%s' for MySQL configuration.\n"),
- cnffile);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("Trying to use file `%s' for MySQL configuration.\n"),
+ cnffile);
fp = FOPEN(cnffile, "r");
if (!fp) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "fopen",
- cnffile);
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "fopen",
+ cnffile);
if (stats != NULL)
coreAPI->releaseService(stats);
FREE(cnffile);
@@ -1514,8 +1514,8 @@
FREE(cnffile);
FREE(dbh);
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Failed to load MySQL database module. Check that MySQL is
running and configured properly!\n"));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Failed to load MySQL database module. Check that MySQL is running and
configured properly!\n"));
dbh = NULL;
if (stats != NULL)
coreAPI->releaseService(stats);
@@ -1527,33 +1527,33 @@
sb = NULL;
if (sizeof(unsigned long long)
!= state->read(ectx,
- "mysql-size",
- (void*) &sb)) {
+ "mysql-size",
+ (void*) &sb)) {
/* need to recompute! */
sql_res = NULL;
mysql_query(dbh->dbf,
- SELECT_SIZE);
+ SELECT_SIZE);
if ( (mysql_error(dbh->dbf)[0]) ||
- (!(sql_res=mysql_use_result(dbh->dbf))) ||
- (!(sql_row=mysql_fetch_row(sql_res))) ) {
+ (!(sql_res=mysql_use_result(dbh->dbf))) ||
+ (!(sql_row=mysql_fetch_row(sql_res))) ) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- dbh);
+ "mysql_query",
+ dbh);
content_size = 0;
iclose(dbh);
} else {
if ( (mysql_num_fields(sql_res) != 1) ||
- (sql_row[0] == NULL) ) {
- GE_BREAK(ectx, mysql_num_fields(sql_res) == 1);
- content_size = 0;
+ (sql_row[0] == NULL) ) {
+ GE_BREAK(ectx, mysql_num_fields(sql_res) == 1);
+ content_size = 0;
} else {
- if (1 != SSCANF(sql_row[0],
- "%llu",
- &content_size)) {
- GE_BREAK(ectx, 0);
- content_size = 0;
- }
+ if (1 != SSCANF(sql_row[0],
+ "%llu",
+ &content_size)) {
+ GE_BREAK(ectx, 0);
+ content_size = 0;
+ }
}
}
if (sql_res != NULL)
@@ -1564,7 +1564,7 @@
/* no longer valid! remember it by deleting
the outdated state file! */
state->unlink(ectx,
- "mysql-size");
+ "mysql-size");
}
coreAPI->releaseService(state);
api.getSize = &getSize;
@@ -1596,9 +1596,9 @@
MUTEX_DESTROY(lock);
state = coreAPI->requestService("state");
state->write(ectx,
- "mysql-size",
- sizeof(unsigned long long),
- &content_size);
+ "mysql-size",
+ sizeof(unsigned long long),
+ &content_size);
coreAPI->releaseService(state);
mysql_library_end();
ectx = NULL;
Modified: GNUnet/src/applications/sqstore_mysql/mysqltest.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -49,8 +49,8 @@
}
static int checkValue(const HashCode512 * key,
- const Datastore_Value * val,
- void * closure) {
+ const Datastore_Value * val,
+ void * closure) {
int i;
int ret;
Datastore_Value * value;
@@ -59,15 +59,15 @@
value = initValue(i);
if ( ( value->size == val->size) &&
(0 == memcmp(val,
- value,
- ntohl(val->size)) ) )
+ value,
+ ntohl(val->size)) ) )
ret = OK;
else {
/*
printf("Wanted: %u, %llu; got %u, %llu - %d\n",
- ntohl(value->size), ntohll(value->expirationTime),
- ntohl(val->size), ntohll(val->expirationTime),
- memcmp(val, value, ntohl(val->size))); */
+ ntohl(value->size), ntohll(value->expirationTime),
+ ntohl(val->size), ntohll(val->expirationTime),
+ memcmp(val, value, ntohl(val->size))); */
ret = SYSERR;
}
FREE(value);
@@ -75,8 +75,8 @@
}
static int iterateUp(const HashCode512 * key,
- const Datastore_Value * val,
- int * closure) {
+ const Datastore_Value * val,
+ int * closure) {
int ret;
ret = checkValue(key, val, closure);
@@ -85,8 +85,8 @@
}
static int iterateDown(const HashCode512 * key,
- const Datastore_Value * val,
- int * closure) {
+ const Datastore_Value * val,
+ int * closure) {
int ret;
(*closure) -= 2;
@@ -95,17 +95,17 @@
}
static int iterateDelete(const HashCode512 * key,
- const Datastore_Value * val,
- SQstore_ServiceAPI * api) {
+ const Datastore_Value * val,
+ SQstore_ServiceAPI * api) {
if (1 == api->del(key, val))
- return OK;
+ return OK;
else
- return SYSERR;
+ return SYSERR;
}
static int priorityCheck(const HashCode512 * key,
- const Datastore_Value * val,
- int * closure) {
+ const Datastore_Value * val,
+ int * closure) {
int id;
id = (*closure);
@@ -116,20 +116,20 @@
}
static int multipleCheck(const HashCode512 * key,
- const Datastore_Value * val,
- Datastore_Value ** last) {
+ const Datastore_Value * val,
+ Datastore_Value ** last) {
if (*last != NULL) {
if ( ((*last)->size == val->size) &&
- (0 == memcmp(*last,
- val,
- ntohl(val->size)) ) )
+ (0 == memcmp(*last,
+ val,
+ ntohl(val->size)) ) )
return SYSERR; /* duplicate! */
FREE(*last);
}
*last = MALLOC(ntohl(val->size));
memcpy(*last,
- val,
- ntohl(val->size));
+ val,
+ ntohl(val->size));
return OK;
}
@@ -153,11 +153,11 @@
}
ASSERT(oldSize < api->getSize());
ASSERT(256 == api->iterateLowPriority(ANY_BLOCK,
- NULL,
- NULL));
+ NULL,
+ NULL));
ASSERT(256 == api->iterateExpirationTime(ANY_BLOCK,
- NULL,
- NULL));
+ NULL,
+ NULL));
for (i=255;i>=0;i--) {
memset(&key, 256-i, sizeof(HashCode512));
ASSERT(1 == api->get(&key, i, &checkValue, (void*) &i));
@@ -173,35 +173,35 @@
ASSERT(oldSize > api->getSize());
i = 0;
ASSERT(128 == api->iterateLowPriority(ANY_BLOCK,
- (Datum_Iterator) &iterateUp,
- &i));
+ (Datum_Iterator) &iterateUp,
+ &i));
ASSERT(256 == i);
ASSERT(128 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &iterateDown,
- &i));
+ (Datum_Iterator) &iterateDown,
+ &i));
ASSERT(0 == i);
ASSERT(128 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &iterateDelete,
- api));
+ (Datum_Iterator) &iterateDelete,
+ api));
ASSERT(0 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &iterateDown,
- &i));
+ (Datum_Iterator) &iterateDown,
+ &i));
i = 42;
value = initValue(i);
memset(&key, 256-i, sizeof(HashCode512));
api->put(&key, value);
ASSERT(1 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &priorityCheck,
- &i));
+ (Datum_Iterator) &priorityCheck,
+ &i));
api->update(&key,
- value,
- 4,
- 0);
+ value,
+ 4,
+ 0);
i += 4;
ASSERT(1 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &priorityCheck,
- &i));
+ (Datum_Iterator) &priorityCheck,
+ &i));
FREE(value);
/* test multiple results */
@@ -211,16 +211,16 @@
value = NULL;
ASSERT(2 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &multipleCheck,
- &value));
+ (Datum_Iterator) &multipleCheck,
+ &value));
FREE(value);
api->del(&key,
- NULL);
+ NULL);
api->del(&key,
- NULL);
+ NULL);
ASSERT(0 == api->iterateExpirationTime(ANY_BLOCK,
- NULL,
- NULL));
+ NULL,
+ NULL));
api->drop();
return OK;
@@ -238,15 +238,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("sqstore");
if (api != NULL) {
ok = test(api);
Modified: GNUnet/src/applications/sqstore_mysql/mysqltest2.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest2.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest2.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -124,7 +124,7 @@
static cron_t start_time;
static int putValue(SQstore_ServiceAPI * api,
- int i) {
+ int i) {
Datastore_Value * value;
size_t size;
static HashCode512 key;
@@ -147,8 +147,8 @@
value->anonymityLevel = htonl(i);
value->expirationTime = htonll(get_time() + weak_randomi(1000));
memset(&value[1],
- i,
- size - sizeof(Datastore_Value));
+ i,
+ size - sizeof(Datastore_Value));
if (OK != api->put(&key, value)) {
FREE(value);
fprintf(stderr, "E");
@@ -168,8 +168,8 @@
static int
iterateDelete(const HashCode512 * key,
- const Datastore_Value * val,
- void * cls) {
+ const Datastore_Value * val,
+ void * cls) {
SQstore_ServiceAPI * api = cls;
static int dc;
@@ -208,7 +208,7 @@
for (j=0;j<PUT_10;j++) {
ASSERT(OK == putValue(api, j));
if (GNUNET_SHUTDOWN_TEST() == YES)
- break;
+ break;
}
/* trim down below MAX_SIZE again */
@@ -220,20 +220,20 @@
size = 0;
if (have_file)
disk_file_size(NULL,
- DB_NAME,
- &size,
- NO);
+ DB_NAME,
+ &size,
+ NO);
printf(
#if REPORT_ID
- "\n"
+ "\n"
#endif
- "Useful %llu, API %llu, disk %llu (%.2f%%) / %lluk ops / %llu
ops/s\n",
- stored_bytes / 1024, /* used size in k */
- api->getSize() / 1024, /* API-reported size in k */
- size / 1024, /* disk size in kb */
- (100.0 * size / stored_bytes) - 100, /* overhead */
- (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k)
*/
- 1000 * (stored_ops * 2 - stored_entries) / (1 + get_time() -
start_time)); /* operations per second */
+ "Useful %llu, API %llu, disk %llu (%.2f%%) / %lluk ops / %llu ops/s\n",
+ stored_bytes / 1024, /* used size in k */
+ api->getSize() / 1024, /* API-reported size in k */
+ size / 1024, /* disk size in kb */
+ (100.0 * size / stored_bytes) - 100, /* overhead */
+ (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k) */
+ 1000 * (stored_ops * 2 - stored_entries) / (1 + get_time() -
start_time)); /* operations per second */
if (GNUNET_SHUTDOWN_TEST() == YES)
break;
}
@@ -253,15 +253,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("sqstore");
if (api != NULL) {
start_time = get_time();
Modified: GNUnet/src/applications/sqstore_mysql/mysqltest3.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest3.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest3.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -56,7 +56,7 @@
static cron_t start_time;
static int putValue(SQstore_ServiceAPI * api,
- int i) {
+ int i) {
Datastore_Value * value;
size_t size;
static HashCode512 key;
@@ -79,8 +79,8 @@
value->anonymityLevel = htonl(i);
value->expirationTime = htonll(get_time() + 60 * cronHOURS +
weak_randomi(1000));
memset(&value[1],
- i,
- size - sizeof(Datastore_Value));
+ i,
+ size - sizeof(Datastore_Value));
if (OK != api->put(&key, value)) {
FREE(value);
fprintf(stderr, "E");
@@ -96,8 +96,8 @@
static int
iterateDummy(const HashCode512 * key,
- const Datastore_Value * val,
- void * cls) {
+ const Datastore_Value * val,
+ void * cls) {
if (GNUNET_SHUTDOWN_TEST() == YES)
return SYSERR;
return OK;
@@ -114,9 +114,9 @@
start = get_time();
for (j=0;j<PUT_10;j++) {
if (OK != putValue(api, j))
- break;
+ break;
if (GNUNET_SHUTDOWN_TEST() == YES)
- break;
+ break;
}
end = get_time();
printf("%3u insertion took %20llums\n", i, end-start);
@@ -171,15 +171,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("sqstore");
if (api != NULL) {
start_time = get_time();
Modified: GNUnet/src/applications/sqstore_mysql_embedded/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql_embedded/mysql.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/sqstore_mysql_embedded/mysql.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -230,8 +230,8 @@
*
*/
static Datastore_Datum * assembleDatum(MYSQL_RES * res,
- MYSQL_ROW sql_row,
- mysqlHandle * dbhI) {
+ MYSQL_ROW sql_row,
+ mysqlHandle * dbhI) {
Datastore_Datum * datum;
int contentSize;
unsigned long * lens;
@@ -253,20 +253,20 @@
(SSCANF(sql_row[4], "%llu", &exp) != 1) ) {
mysql_free_result(res);
if ( (lens[5] != sizeof(HashCode512)) ||
- (lens[6] != contentSize) ) {
+ (lens[6] != contentSize) ) {
char scratch[512];
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Invalid data in %s. Trying to fix (by deletion).\n"),
- _("mysql datastore"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Invalid data in %s. Trying to fix (by deletion).\n"),
+ _("mysql datastore"));
SNPRINTF(scratch,
- 512,
- "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
- sizeof(HashCode512),
- sizeof(Datastore_Value));
+ 512,
+ "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
+ sizeof(HashCode512),
+ sizeof(Datastore_Value));
if (0 != mysql_query(dbhI->dbf, scratch))
- LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbhI);
+ LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbhI);
} else {
GE_BREAK(ectx, 0); /* should really never happen */
}
@@ -279,11 +279,11 @@
datum->value.anonymityLevel = htonl(level);
datum->value.expirationTime = htonll(exp);
memcpy(&datum->key,
- sql_row[5],
- sizeof(HashCode512));
+ sql_row[5],
+ sizeof(HashCode512));
memcpy(&datum[1],
sql_row[6],
- contentSize);
+ contentSize);
return datum;
}
@@ -294,7 +294,7 @@
* @return OK on success
*/
static int iopen(mysqlHandle * dbhI,
- int prepare) {
+ int prepare) {
char * dbname;
if (dbhI->cnffile == NULL)
@@ -303,62 +303,62 @@
if (dbhI->dbf == NULL)
return SYSERR;
mysql_options(dbhI->dbf,
- MYSQL_READ_DEFAULT_FILE,
- dbh->cnffile);
+ MYSQL_READ_DEFAULT_FILE,
+ dbh->cnffile);
mysql_options(dbhI->dbf,
- MYSQL_READ_DEFAULT_GROUP,
- "client");
+ MYSQL_READ_DEFAULT_GROUP,
+ "client");
dbname = NULL;
GC_get_configuration_value_string(coreAPI->cfg,
- "MYSQL",
- "DATABASE",
- "gnunet",
- &dbname);
+ "MYSQL",
+ "DATABASE",
+ "gnunet",
+ &dbname);
GE_ASSERT(ectx, dbname != NULL);
mysql_real_connect(dbhI->dbf,
- NULL,
- NULL,
- NULL,
- dbname,
- 0,
- NULL,
- 0);
+ NULL,
+ NULL,
+ NULL,
+ dbname,
+ 0,
+ NULL,
+ 0);
FREE(dbname);
if (mysql_error(dbhI->dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_real_connect",
- dbhI);
+ "mysql_real_connect",
+ dbhI);
dbhI->dbf = NULL;
return SYSERR;
}
if (prepare) {
mysql_query(dbhI->dbf,
- "CREATE TABLE IF NOT EXISTS gn070 ("
- " size INT(11) NOT NULL DEFAULT 0,"
- " type INT(11) NOT NULL DEFAULT 0,"
- " prio INT(11) NOT NULL DEFAULT 0,"
- " anonLevel INT(11) NOT NULL DEFAULT 0,"
- " expire BIGINT NOT NULL DEFAULT 0,"
- " hash TINYBLOB NOT NULL DEFAULT '',"
- " value BLOB NOT NULL DEFAULT '',"
- " INDEX (hash(64)),"
- " INDEX (prio),"
- " INDEX (expire)"
- ") TYPE=InnoDB");
+ "CREATE TABLE IF NOT EXISTS gn070 ("
+ " size INT(11) NOT NULL DEFAULT 0,"
+ " type INT(11) NOT NULL DEFAULT 0,"
+ " prio INT(11) NOT NULL DEFAULT 0,"
+ " anonLevel INT(11) NOT NULL DEFAULT 0,"
+ " expire BIGINT NOT NULL DEFAULT 0,"
+ " hash TINYBLOB NOT NULL DEFAULT '',"
+ " value BLOB NOT NULL DEFAULT '',"
+ " INDEX (hash(64)),"
+ " INDEX (prio),"
+ " INDEX (expire)"
+ ") TYPE=InnoDB");
if (mysql_error(dbhI->dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- dbhI);
+ "mysql_query",
+ dbhI);
mysql_close(dbhI->dbf);
dbhI->dbf = NULL;
return SYSERR;
}
mysql_query(dbhI->dbf,
- "SET AUTOCOMMIT = 1");
+ "SET AUTOCOMMIT = 1");
if (mysql_error(dbhI->dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- dbhI);
+ "mysql_query",
+ dbhI);
mysql_close(dbhI->dbf);
dbhI->dbf = NULL;
return SYSERR;
@@ -372,66 +372,66 @@
dbhI->deleteh = mysql_stmt_init(dbhI->dbf);
dbhI->deleteg = mysql_stmt_init(dbhI->dbf);
if ( (dbhI->insert == NULL) ||
- (dbhI->update == NULL) ||
- (dbhI->select == NULL) ||
- (dbhI->selectc == NULL) ||
- (dbhI->selects == NULL) ||
- (dbhI->selectsc == NULL) ||
- (dbhI->deleteh == NULL) ||
- (dbhI->deleteg == NULL) ) {
+ (dbhI->update == NULL) ||
+ (dbhI->select == NULL) ||
+ (dbhI->selectc == NULL) ||
+ (dbhI->selects == NULL) ||
+ (dbhI->selectsc == NULL) ||
+ (dbhI->deleteh == NULL) ||
+ (dbhI->deleteg == NULL) ) {
GE_BREAK(ectx, 0);
if (dbhI->insert != NULL)
- mysql_stmt_close(dbhI->insert);
+ mysql_stmt_close(dbhI->insert);
if (dbhI->update != NULL)
- mysql_stmt_close(dbhI->update);
+ mysql_stmt_close(dbhI->update);
if (dbhI->select != NULL)
- mysql_stmt_close(dbhI->select);
+ mysql_stmt_close(dbhI->select);
if (dbhI->selectc != NULL)
- mysql_stmt_close(dbhI->selectc);
+ mysql_stmt_close(dbhI->selectc);
if (dbhI->selects != NULL)
- mysql_stmt_close(dbhI->selects);
+ mysql_stmt_close(dbhI->selects);
if (dbhI->selectsc != NULL)
- mysql_stmt_close(dbhI->selectsc);
+ mysql_stmt_close(dbhI->selectsc);
mysql_close(dbhI->dbf);
dbhI->dbf = NULL;
return SYSERR;
}
if (mysql_stmt_prepare(dbhI->insert,
- INSERT_SAMPLE,
- strlen(INSERT_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->select,
- SELECT_SAMPLE,
- strlen(SELECT_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->selectc,
- SELECT_SAMPLE_COUNT,
- strlen(SELECT_SAMPLE_COUNT)) ||
- mysql_stmt_prepare(dbhI->selects,
- SELECT_TYPE_SAMPLE,
- strlen(SELECT_TYPE_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->selectsc,
- SELECT_TYPE_SAMPLE_COUNT,
- strlen(SELECT_TYPE_SAMPLE_COUNT)) ||
- mysql_stmt_prepare(dbhI->update,
- UPDATE_SAMPLE,
- strlen(UPDATE_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->deleteh,
- SELECT_HASH_SAMPLE,
- strlen(SELECT_HASH_SAMPLE)) ||
- mysql_stmt_prepare(dbhI->deleteg,
- DELETE_GENERIC_SAMPLE,
- strlen(DELETE_GENERIC_SAMPLE)) ) {
+ INSERT_SAMPLE,
+ strlen(INSERT_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->select,
+ SELECT_SAMPLE,
+ strlen(SELECT_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->selectc,
+ SELECT_SAMPLE_COUNT,
+ strlen(SELECT_SAMPLE_COUNT)) ||
+ mysql_stmt_prepare(dbhI->selects,
+ SELECT_TYPE_SAMPLE,
+ strlen(SELECT_TYPE_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->selectsc,
+ SELECT_TYPE_SAMPLE_COUNT,
+ strlen(SELECT_TYPE_SAMPLE_COUNT)) ||
+ mysql_stmt_prepare(dbhI->update,
+ UPDATE_SAMPLE,
+ strlen(UPDATE_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->deleteh,
+ SELECT_HASH_SAMPLE,
+ strlen(SELECT_HASH_SAMPLE)) ||
+ mysql_stmt_prepare(dbhI->deleteg,
+ DELETE_GENERIC_SAMPLE,
+ strlen(DELETE_GENERIC_SAMPLE)) ) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: I/%s S/%s SC/%s SS/%s SSC/%s U/%s
D/%s DG/%s\n"),
- "mysql_stmt_prepare",
- __FILE__, __LINE__,
- mysql_stmt_error(dbhI->insert),
- mysql_stmt_error(dbhI->select),
- mysql_stmt_error(dbhI->selectc),
- mysql_stmt_error(dbhI->selects),
- mysql_stmt_error(dbhI->selectsc),
- mysql_stmt_error(dbhI->update),
- mysql_stmt_error(dbhI->deleteh),
- mysql_stmt_error(dbhI->deleteg));
+ _("`%s' failed at %s:%d with error: I/%s S/%s SC/%s SS/%s SSC/%s U/%s D/%s
DG/%s\n"),
+ "mysql_stmt_prepare",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbhI->insert),
+ mysql_stmt_error(dbhI->select),
+ mysql_stmt_error(dbhI->selectc),
+ mysql_stmt_error(dbhI->selects),
+ mysql_stmt_error(dbhI->selectsc),
+ mysql_stmt_error(dbhI->update),
+ mysql_stmt_error(dbhI->deleteh),
+ mysql_stmt_error(dbhI->deleteg));
mysql_stmt_close(dbhI->insert);
mysql_stmt_close(dbhI->select);
mysql_stmt_close(dbhI->selectc);
@@ -445,8 +445,8 @@
return SYSERR;
}
memset(dbhI->bind,
- 0,
- sizeof(dbhI->bind));
+ 0,
+ sizeof(dbhI->bind));
dbhI->bind[0].buffer_type = MYSQL_TYPE_LONG; /* size */
dbhI->bind[1].buffer_type = MYSQL_TYPE_LONG; /* type */
dbhI->bind[2].buffer_type = MYSQL_TYPE_LONG; /* prio */
@@ -455,13 +455,13 @@
dbhI->bind[5].buffer_type = MYSQL_TYPE_TINY_BLOB; /* hash */
dbhI->bind[6].buffer_type = MYSQL_TYPE_BLOB; /* value */
memset(dbhI->sbind,
- 0,
- sizeof(dbhI->sbind));
+ 0,
+ sizeof(dbhI->sbind));
dbhI->sbind[0].buffer_type = MYSQL_TYPE_TINY_BLOB; /* hash */
dbhI->sbind[1].buffer_type = MYSQL_TYPE_LONG; /* type */
memset(dbhI->dbind,
- 0,
- sizeof(dbhI->dbind));
+ 0,
+ sizeof(dbhI->dbind));
dbhI->dbind[0].buffer_type = MYSQL_TYPE_TINY_BLOB; /* hash */
dbhI->dbind[1].buffer_type = MYSQL_TYPE_LONG; /* size */
dbhI->dbind[2].buffer_type = MYSQL_TYPE_LONG; /* type */
@@ -470,8 +470,8 @@
dbhI->dbind[5].buffer_type = MYSQL_TYPE_LONGLONG; /* expiration */
dbhI->dbind[6].buffer_type = MYSQL_TYPE_BLOB; /* value */
memset(dbhI->ubind,
- 0,
- sizeof(dbhI->ubind));
+ 0,
+ sizeof(dbhI->ubind));
dbhI->ubind[0].buffer_type = MYSQL_TYPE_LONG;
dbhI->ubind[1].buffer_type = MYSQL_TYPE_LONG;
dbhI->ubind[2].buffer_type = MYSQL_TYPE_LONG;
@@ -527,9 +527,9 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateHelper(unsigned int type,
- const char * query,
- Datum_Iterator iter,
- void * closure) {
+ const char * query,
+ Datum_Iterator iter,
+ void * closure) {
MYSQL_RES *sql_res;
MYSQL_ROW sql_row;
Datastore_Datum * datum;
@@ -546,31 +546,31 @@
MUTEX_LOCK(dbhI.DATABASE_Lock_);
mysql_thread_init();
mysql_query(dbhI.dbf,
- "SET AUTOCOMMIT = 0");
+ "SET AUTOCOMMIT = 0");
mysql_query(dbhI.dbf,
- "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED");
+ "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED");
if (type==0) {
typestr[0] = '\0';
} else {
SNPRINTF(typestr,
32,
"WHERE type=%u ",
- type);
+ type);
}
now = get_time();
scratch = MALLOC(256);
SNPRINTF(scratch,
- 256,
- query,
- typestr,
- now);
+ 256,
+ query,
+ typestr,
+ now);
mysql_query(dbhI.dbf,
- scratch);
+ scratch);
FREE(scratch);
if (mysql_error(dbhI.dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- &dbhI);
+ "mysql_query",
+ &dbhI);
mysql_thread_end();
MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
iclose(&dbhI);
@@ -583,8 +583,8 @@
}
while ((sql_row=mysql_fetch_row(sql_res))) {
datum = assembleDatum(sql_res,
- sql_row,
- &dbhI);
+ sql_row,
+ &dbhI);
if (datum == NULL) {
mysql_thread_end();
MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
@@ -592,9 +592,9 @@
return count;
}
if ( (iter != NULL) &&
- (SYSERR == iter(&datum->key,
- &datum->value,
- closure) ) ) {
+ (SYSERR == iter(&datum->key,
+ &datum->value,
+ closure) ) ) {
count = SYSERR;
FREE(datum);
break;
@@ -604,14 +604,14 @@
}
if (mysql_error(dbhI.dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- &dbhI);
+ "mysql_query",
+ &dbhI);
mysql_free_result(sql_res);
mysql_thread_end();
MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
iclose(&dbhI);
return SYSERR;
- }
+ }
mysql_free_result(sql_res);
mysql_thread_end();
MUTEX_UNLOCK(dbhI.DATABASE_Lock_);
@@ -630,14 +630,14 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateLowPriority(unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ Datum_Iterator iter,
+ void * closure) {
return iterateHelper(type,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %s"
- "ORDER BY prio ASC",
- iter,
- closure);
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %s"
+ "ORDER BY prio ASC",
+ iter,
+ closure);
}
/**
@@ -651,25 +651,25 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateNonAnonymous(unsigned int type,
- int on_demand,
- Datum_Iterator iter,
- void * closure) {
+ int on_demand,
+ Datum_Iterator iter,
+ void * closure) {
char limit[512];
if (on_demand == YES)
SNPRINTF(limit,
- 512,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %%s WHERE expire > %%llu AND anonLevel = 0 AND type != %d",
- ONDEMAND_BLOCK);
+ 512,
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %%s WHERE expire > %%llu AND anonLevel = 0 AND type != %d",
+ ONDEMAND_BLOCK);
else
strcpy(limit,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %s WHERE expire > %llu AND anonLevel = 0");
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %s WHERE expire > %llu AND anonLevel = 0");
return iterateHelper(type,
- limit,
- iter,
- closure);
+ limit,
+ iter,
+ closure);
}
/**
@@ -683,14 +683,14 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateExpirationTime(unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ Datum_Iterator iter,
+ void * closure) {
return iterateHelper(type,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %s"
- " ORDER BY expire ASC",
- iter,
- closure);
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %s"
+ " ORDER BY expire ASC",
+ iter,
+ closure);
}
/**
@@ -702,13 +702,13 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateMigrationOrder(Datum_Iterator iter,
- void * closure) {
+ void * closure) {
return iterateHelper(0,
- "SELECT SQL_NO_CACHE * FROM gn070"
- " %s WHERE expire > %llu"
- " ORDER BY expire DESC",
- iter,
- closure);
+ "SELECT SQL_NO_CACHE * FROM gn070"
+ " %s WHERE expire > %llu"
+ " ORDER BY expire DESC",
+ iter,
+ closure);
}
/**
@@ -720,11 +720,11 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateAllNow(Datum_Iterator iter,
- void * closure) {
+ void * closure) {
return iterateHelper(0,
- "SELECT SQL_NO_CACHE * FROM gn070",
- iter,
- closure);
+ "SELECT SQL_NO_CACHE * FROM gn070",
+ iter,
+ closure);
}
#define MAX_DATUM_SIZE 65536
@@ -741,9 +741,9 @@
* iter is non-NULL and aborted the iteration
*/
static int get(const HashCode512 * query,
- unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ unsigned int type,
+ Datum_Iterator iter,
+ void * closure) {
MYSQL_RES * sql_res;
int count;
MYSQL_STMT * stmt;
@@ -766,14 +766,14 @@
#if DEBUG_MYSQL
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL looks for `%s' of type %u\n",
- &enc,
- type);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL looks for `%s' of type %u\n",
+ &enc,
+ type);
#endif
MUTEX_LOCK(dbh->DATABASE_Lock_);
mysql_thread_init();
@@ -796,11 +796,11 @@
sql_res = mysql_stmt_result_metadata(stmt);
if (! sql_res) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_result_metadata",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_result_metadata",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
@@ -812,24 +812,24 @@
return SYSERR;
}
if (mysql_stmt_bind_param(stmt,
- dbh->sbind)) {
+ dbh->sbind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
}
if (mysql_stmt_execute(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
@@ -849,13 +849,13 @@
dbh->bind[5].buffer_length = sizeof(HashCode512);
dbh->bind[6].buffer_length = MAX_DATUM_SIZE;
if (mysql_stmt_bind_result(stmt,
- dbh->bind)) {
+ dbh->bind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_result",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_result",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
FREE(datum);
@@ -863,11 +863,11 @@
}
if (mysql_stmt_store_result(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_store_result",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_store_result",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
FREE(datum);
@@ -877,21 +877,21 @@
count = 0;
while (0 == mysql_stmt_fetch(stmt)) {
if ( (twenty != sizeof(HashCode512)) ||
- (datasize != size - sizeof(Datastore_Value)) ) {
+ (datasize != size - sizeof(Datastore_Value)) ) {
char scratch[512];
mysql_free_result(sql_res);
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Invalid data in %s. Trying to fix (by deletion).\n"),
- _("mysql datastore"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Invalid data in %s. Trying to fix (by deletion).\n"),
+ _("mysql datastore"));
SNPRINTF(scratch,
- 512,
- "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
- sizeof(HashCode512),
- sizeof(Datastore_Value));
+ 512,
+ "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
+ sizeof(HashCode512),
+ sizeof(Datastore_Value));
if (0 != mysql_query(dbh->dbf, scratch))
- LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbh);
+ LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbh);
FREE(datum);
mysql_thread_end();
@@ -907,26 +907,26 @@
datum->expirationTime = htonll(expiration);
#if DEBUG_MYSQL
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Found in database block with type %u.\n",
- ntohl(*(int*)&datum[1]));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Found in database block with type %u.\n",
+ ntohl(*(int*)&datum[1]));
#endif
if( SYSERR == iter(&key,
- datum,
- closure) ) {
+ datum,
+ closure) ) {
count = SYSERR;
- break;
+ break;
}
}
datasize = MAX_DATUM_SIZE;
}
if (mysql_stmt_errno(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_fetch",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_fetch",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
}
mysql_free_result(sql_res);
FREE(datum);
@@ -935,22 +935,22 @@
#if DEBUG_MYSQL
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
if (count > 0) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL found %d results for `%s' of type %u.\n",
- count,
- &enc,
- type);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL found %d results for `%s' of type %u.\n",
+ count,
+ &enc,
+ type);
} else {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL iteration aborted looking for `%s' of type %u.\n",
- &enc,
- type);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL iteration aborted looking for `%s' of type %u.\n",
+ &enc,
+ type);
}
#endif
return count;
@@ -962,7 +962,7 @@
* @return OK on success, SYSERR on error
*/
static int put(const HashCode512 * key,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
unsigned long contentSize;
unsigned long hashSize;
unsigned int size;
@@ -989,14 +989,14 @@
expiration = ntohll(value->expirationTime);
#if DEBUG_MYSQL
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Storing in database block with type %u and key %s.\n",
- type,
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Storing in database block with type %u and key %s.\n",
+ type,
+ &enc);
#endif
dbh->bind[0].buffer = (char*) &size;
dbh->bind[1].buffer = (char*) &type;
@@ -1009,13 +1009,13 @@
dbh->bind[6].length = &contentSize;
if (mysql_stmt_bind_param(dbh->insert,
- dbh->bind)) {
+ dbh->bind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(dbh->insert));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbh->insert));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
@@ -1023,11 +1023,11 @@
if (mysql_stmt_execute(dbh->insert)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(dbh->insert));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbh->insert));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
@@ -1049,7 +1049,7 @@
* none were found, SYSERR on errors
*/
static int del(const HashCode512 * key,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
int count;
unsigned long twenty;
MYSQL_STMT * stmt;
@@ -1068,14 +1068,14 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL is executing deletion request for content of query `%s' and
type %u\n",
- &enc,
- value == NULL ? 0 : ntohl(value->type));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL is executing deletion request for content of query `%s' and type
%u\n",
+ &enc,
+ value == NULL ? 0 : ntohl(value->type));
#endif
MUTEX_LOCK(dbh->DATABASE_Lock_);
mysql_thread_init();
@@ -1090,11 +1090,11 @@
sql_res = mysql_stmt_result_metadata(stmt);
if (! sql_res) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_result_metadata",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_result_metadata",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
@@ -1105,24 +1105,24 @@
return SYSERR;
}
if (mysql_stmt_bind_param(stmt,
- dbh->dbind)) {
+ dbh->dbind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
}
if (mysql_stmt_execute(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
@@ -1141,13 +1141,13 @@
dbh->bind[5].buffer_length = sizeof(HashCode512);
dbh->bind[6].buffer_length = MAX_DATUM_SIZE;
if (mysql_stmt_bind_result(stmt,
- dbh->bind)) {
+ dbh->bind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_result",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_result",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
FREE(svalue);
@@ -1155,12 +1155,12 @@
}
if (mysql_stmt_store_result(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_store_result",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
- mysql_thread_end();
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_store_result",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
+ mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
FREE(svalue);
return SYSERR;
@@ -1168,33 +1168,33 @@
datasize = MAX_DATUM_SIZE;
if (0 != mysql_stmt_fetch(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_fetch",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_fetch",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
FREE(svalue);
return SYSERR;
}
if ( (twenty != sizeof(HashCode512)) ||
- (datasize != size - sizeof(Datastore_Value)) ) {
+ (datasize != size - sizeof(Datastore_Value)) ) {
char scratch[512];
mysql_free_result(sql_res);
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Invalid data in %s. Trying to fix (by deletion).\n"),
- _("mysql datastore"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Invalid data in %s. Trying to fix (by deletion).\n"),
+ _("mysql datastore"));
SNPRINTF(scratch,
- 512,
- "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
- sizeof(HashCode512),
- sizeof(Datastore_Value));
+ 512,
+ "DELETE FROM gn070 WHERE NOT ((LENGTH(hash)=%u) AND (size=%u +
LENGTH(value)))",
+ sizeof(HashCode512),
+ sizeof(Datastore_Value));
if (0 != mysql_query(dbh->dbf, scratch))
- LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query", dbh);
+ LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
+ "mysql_query", dbh);
FREE(svalue);
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
@@ -1231,13 +1231,13 @@
#endif
GE_ASSERT(ectx, mysql_stmt_param_count(stmt) <= 7);
if (mysql_stmt_bind_param(stmt,
- dbh->dbind)) {
+ dbh->dbind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
if (svalue != NULL)
@@ -1246,11 +1246,11 @@
}
if (mysql_stmt_execute(stmt)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(stmt));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(stmt));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
if (svalue != NULL)
@@ -1262,9 +1262,9 @@
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
#if DEBUG_MYSQL
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "MySQL DELETE operation affected %d rows.\n",
- count);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "MySQL DELETE operation affected %d rows.\n",
+ count);
#endif
MUTEX_LOCK(lock);
content_size -= ntohl(value->size);
@@ -1279,9 +1279,9 @@
* in the datastore.
*/
static int update(const HashCode512 * key,
- const Datastore_Value * value,
- int delta,
- cron_t expire) {
+ const Datastore_Value * value,
+ int delta,
+ cron_t expire) {
unsigned long contentSize;
unsigned long twenty;
@@ -1297,15 +1297,15 @@
dbh->ubind[4].buffer = (char*) &value[1];
dbh->ubind[4].length = &contentSize;
GE_ASSERT(ectx,
- mysql_stmt_param_count(dbh->update) <= 5);
+ mysql_stmt_param_count(dbh->update) <= 5);
if (mysql_stmt_bind_param(dbh->update,
- dbh->ubind)) {
+ dbh->ubind)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_bind_param",
- __FILE__, __LINE__,
- mysql_stmt_error(dbh->update));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbh->update));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
@@ -1317,11 +1317,11 @@
*/
if (mysql_stmt_execute(dbh->update)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: %s\n"),
- "mysql_stmt_execute",
- __FILE__, __LINE__,
- mysql_stmt_error(dbh->update));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute",
+ __FILE__, __LINE__,
+ mysql_stmt_error(dbh->update));
mysql_thread_end();
MUTEX_UNLOCK(dbh->DATABASE_Lock_);
return SYSERR;
@@ -1354,11 +1354,11 @@
*/
static void drop() {
mysql_query(dbh->dbf,
- "DROP TABLE gn070");
+ "DROP TABLE gn070");
if (mysql_error(dbh->dbf)[0]) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- dbh);
+ "mysql_query",
+ dbh);
} else
content_size = 0;
}
@@ -1388,8 +1388,8 @@
pw = getpwuid(getuid());
if(!pw)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "getpwuid");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "getpwuid");
home_dir = STRDUP(pw->pw_dir);
#else
home_dir = (char *) MALLOC(_MAX_PATH + 1);
@@ -1398,27 +1398,27 @@
nX = strlen(home_dir)+10;
cnffile = MALLOC(nX);
SNPRINTF(cnffile,
- nX,
- "%s/.my.cnf",
- home_dir);
+ nX,
+ "%s/.my.cnf",
+ home_dir);
FREE(home_dir);
GC_get_configuration_value_filename(capi->cfg,
- "MYSQL",
- "CONFIG",
- cnffile,
- &home_dir);
+ "MYSQL",
+ "CONFIG",
+ cnffile,
+ &home_dir);
FREE(cnffile);
cnffile = home_dir;
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("Trying to use file `%s' for MySQL configuration.\n"),
- cnffile);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("Trying to use file `%s' for MySQL configuration.\n"),
+ cnffile);
fp = FOPEN(cnffile, "r");
if (!fp) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "fopen",
- cnffile);
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "fopen",
+ cnffile);
if (stats != NULL)
coreAPI->releaseService(stats);
FREE(cnffile);
@@ -1432,8 +1432,8 @@
FREE(cnffile);
FREE(dbh);
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Failed to load MySQL database module. Check that MySQL is
running and configured properly!\n"));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Failed to load MySQL database module. Check that MySQL is running and
configured properly!\n"));
dbh = NULL;
if (stats != NULL)
coreAPI->releaseService(stats);
@@ -1445,32 +1445,32 @@
sb = NULL;
if (sizeof(unsigned long long)
!= state->read(ectx,
- "mysql-size",
- (void*) &sb)) {
+ "mysql-size",
+ (void*) &sb)) {
/* need to recompute! */
sql_res = NULL;
mysql_query(dbh->dbf,
- SELECT_SIZE);
+ SELECT_SIZE);
if ( (mysql_error(dbh->dbf)[0]) ||
- (!(sql_res=mysql_use_result(dbh->dbf))) ||
- (!(sql_row=mysql_fetch_row(sql_res))) ) {
+ (!(sql_res=mysql_use_result(dbh->dbf))) ||
+ (!(sql_row=mysql_fetch_row(sql_res))) ) {
LOG_MYSQL(GE_ERROR | GE_ADMIN | GE_BULK,
- "mysql_query",
- dbh);
+ "mysql_query",
+ dbh);
content_size = 0;
} else {
if ( (mysql_num_fields(sql_res) != 1) ||
- (sql_row[0] == NULL) ) {
- GE_BREAK(ectx, mysql_num_fields(sql_res) == 1);
- content_size = 0;
+ (sql_row[0] == NULL) ) {
+ GE_BREAK(ectx, mysql_num_fields(sql_res) == 1);
+ content_size = 0;
} else {
- if (1 != SSCANF(sql_row[0],
- "%llu",
- &content_size)) {
- GE_BREAK(ectx, 0);
- content_size = 0;
- }
+ if (1 != SSCANF(sql_row[0],
+ "%llu",
+ &content_size)) {
+ GE_BREAK(ectx, 0);
+ content_size = 0;
+ }
}
}
if (sql_res != NULL)
@@ -1481,7 +1481,7 @@
/* no longer valid! remember it by deleting
the outdated state file! */
state->unlink(ectx,
- "mysql-size");
+ "mysql-size");
}
coreAPI->releaseService(state);
api.getSize = &getSize;
@@ -1513,9 +1513,9 @@
MUTEX_DESTROY(lock);
state = coreAPI->requestService("state");
state->write(ectx,
- "mysql-size",
- sizeof(unsigned long long),
- &content_size);
+ "mysql-size",
+ sizeof(unsigned long long),
+ &content_size);
coreAPI->releaseService(state);
mysql_library_end();
ectx = NULL;
Modified: GNUnet/src/applications/sqstore_mysql_embedded/mysqltest.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql_embedded/mysqltest.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/sqstore_mysql_embedded/mysqltest.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -49,8 +49,8 @@
}
static int checkValue(const HashCode512 * key,
- const Datastore_Value * val,
- void * closure) {
+ const Datastore_Value * val,
+ void * closure) {
int i;
int ret;
Datastore_Value * value;
@@ -59,15 +59,15 @@
value = initValue(i);
if ( ( value->size == val->size) &&
(0 == memcmp(val,
- value,
- ntohl(val->size)) ) )
+ value,
+ ntohl(val->size)) ) )
ret = OK;
else {
/*
printf("Wanted: %u, %llu; got %u, %llu - %d\n",
- ntohl(value->size), ntohll(value->expirationTime),
- ntohl(val->size), ntohll(val->expirationTime),
- memcmp(val, value, ntohl(val->size))); */
+ ntohl(value->size), ntohll(value->expirationTime),
+ ntohl(val->size), ntohll(val->expirationTime),
+ memcmp(val, value, ntohl(val->size))); */
ret = SYSERR;
}
FREE(value);
@@ -75,8 +75,8 @@
}
static int iterateUp(const HashCode512 * key,
- const Datastore_Value * val,
- int * closure) {
+ const Datastore_Value * val,
+ int * closure) {
int ret;
ret = checkValue(key, val, closure);
@@ -85,8 +85,8 @@
}
static int iterateDown(const HashCode512 * key,
- const Datastore_Value * val,
- int * closure) {
+ const Datastore_Value * val,
+ int * closure) {
int ret;
(*closure) -= 2;
@@ -95,17 +95,17 @@
}
static int iterateDelete(const HashCode512 * key,
- const Datastore_Value * val,
- SQstore_ServiceAPI * api) {
+ const Datastore_Value * val,
+ SQstore_ServiceAPI * api) {
if (1 == api->del(key, val))
- return OK;
+ return OK;
else
- return SYSERR;
+ return SYSERR;
}
static int priorityCheck(const HashCode512 * key,
- const Datastore_Value * val,
- int * closure) {
+ const Datastore_Value * val,
+ int * closure) {
int id;
id = (*closure);
@@ -116,20 +116,20 @@
}
static int multipleCheck(const HashCode512 * key,
- const Datastore_Value * val,
- Datastore_Value ** last) {
+ const Datastore_Value * val,
+ Datastore_Value ** last) {
if (*last != NULL) {
if ( ((*last)->size == val->size) &&
- (0 == memcmp(*last,
- val,
- ntohl(val->size)) ) )
+ (0 == memcmp(*last,
+ val,
+ ntohl(val->size)) ) )
return SYSERR; /* duplicate! */
FREE(*last);
}
*last = MALLOC(ntohl(val->size));
memcpy(*last,
- val,
- ntohl(val->size));
+ val,
+ ntohl(val->size));
return OK;
}
@@ -153,11 +153,11 @@
}
ASSERT(oldSize < api->getSize());
ASSERT(256 == api->iterateLowPriority(ANY_BLOCK,
- NULL,
- NULL));
+ NULL,
+ NULL));
ASSERT(256 == api->iterateExpirationTime(ANY_BLOCK,
- NULL,
- NULL));
+ NULL,
+ NULL));
for (i=255;i>=0;i--) {
memset(&key, 256-i, sizeof(HashCode512));
ASSERT(1 == api->get(&key, i, &checkValue, (void*) &i));
@@ -173,35 +173,35 @@
ASSERT(oldSize > api->getSize());
i = 0;
ASSERT(128 == api->iterateLowPriority(ANY_BLOCK,
- (Datum_Iterator) &iterateUp,
- &i));
+ (Datum_Iterator) &iterateUp,
+ &i));
ASSERT(256 == i);
ASSERT(128 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &iterateDown,
- &i));
+ (Datum_Iterator) &iterateDown,
+ &i));
ASSERT(0 == i);
ASSERT(128 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &iterateDelete,
- api));
+ (Datum_Iterator) &iterateDelete,
+ api));
ASSERT(0 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &iterateDown,
- &i));
+ (Datum_Iterator) &iterateDown,
+ &i));
i = 42;
value = initValue(i);
memset(&key, 256-i, sizeof(HashCode512));
api->put(&key, value);
ASSERT(1 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &priorityCheck,
- &i));
+ (Datum_Iterator) &priorityCheck,
+ &i));
api->update(&key,
- value,
- 4,
- 0);
+ value,
+ 4,
+ 0);
i += 4;
ASSERT(1 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &priorityCheck,
- &i));
+ (Datum_Iterator) &priorityCheck,
+ &i));
FREE(value);
/* test multiple results */
@@ -211,16 +211,16 @@
value = NULL;
ASSERT(2 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &multipleCheck,
- &value));
+ (Datum_Iterator) &multipleCheck,
+ &value));
FREE(value);
api->del(&key,
- NULL);
+ NULL);
api->del(&key,
- NULL);
+ NULL);
ASSERT(0 == api->iterateExpirationTime(ANY_BLOCK,
- NULL,
- NULL));
+ NULL,
+ NULL));
api->drop();
return OK;
@@ -238,15 +238,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("sqstore");
if (api != NULL) {
ok = test(api);
Modified: GNUnet/src/applications/sqstore_mysql_embedded/mysqltest2.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql_embedded/mysqltest2.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/sqstore_mysql_embedded/mysqltest2.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -124,7 +124,7 @@
static cron_t start_time;
static int putValue(SQstore_ServiceAPI * api,
- int i) {
+ int i) {
Datastore_Value * value;
size_t size;
static HashCode512 key;
@@ -147,8 +147,8 @@
value->anonymityLevel = htonl(i);
value->expirationTime = htonll(get_time() + weak_randomi(1000));
memset(&value[1],
- i,
- size - sizeof(Datastore_Value));
+ i,
+ size - sizeof(Datastore_Value));
if (OK != api->put(&key, value)) {
FREE(value);
fprintf(stderr, "E");
@@ -168,8 +168,8 @@
static int
iterateDelete(const HashCode512 * key,
- const Datastore_Value * val,
- void * cls) {
+ const Datastore_Value * val,
+ void * cls) {
SQstore_ServiceAPI * api = cls;
static int dc;
@@ -208,7 +208,7 @@
for (j=0;j<PUT_10;j++) {
ASSERT(OK == putValue(api, j));
if (GNUNET_SHUTDOWN_TEST() == YES)
- break;
+ break;
}
/* trim down below MAX_SIZE again */
@@ -220,20 +220,20 @@
size = 0;
if (have_file)
disk_file_size(NULL,
- DB_NAME,
- &size,
- NO);
+ DB_NAME,
+ &size,
+ NO);
printf(
#if REPORT_ID
- "\n"
+ "\n"
#endif
- "Useful %llu, API %llu, disk %llu (%.2f%%) / %lluk ops / %llu
ops/s\n",
- stored_bytes / 1024, /* used size in k */
- api->getSize() / 1024, /* API-reported size in k */
- size / 1024, /* disk size in kb */
- (100.0 * size / stored_bytes) - 100, /* overhead */
- (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k)
*/
- 1000 * (stored_ops * 2 - stored_entries) / (1 + get_time() -
start_time)); /* operations per second */
+ "Useful %llu, API %llu, disk %llu (%.2f%%) / %lluk ops / %llu ops/s\n",
+ stored_bytes / 1024, /* used size in k */
+ api->getSize() / 1024, /* API-reported size in k */
+ size / 1024, /* disk size in kb */
+ (100.0 * size / stored_bytes) - 100, /* overhead */
+ (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k) */
+ 1000 * (stored_ops * 2 - stored_entries) / (1 + get_time() -
start_time)); /* operations per second */
if (GNUNET_SHUTDOWN_TEST() == YES)
break;
}
@@ -253,15 +253,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("sqstore");
if (api != NULL) {
start_time = get_time();
Modified: GNUnet/src/applications/sqstore_mysql_embedded/mysqltest3.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql_embedded/mysqltest3.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/sqstore_mysql_embedded/mysqltest3.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -56,7 +56,7 @@
static cron_t start_time;
static int putValue(SQstore_ServiceAPI * api,
- int i) {
+ int i) {
Datastore_Value * value;
size_t size;
static HashCode512 key;
@@ -79,8 +79,8 @@
value->anonymityLevel = htonl(i);
value->expirationTime = htonll(get_time() + 60 * cronHOURS +
weak_randomi(1000));
memset(&value[1],
- i,
- size - sizeof(Datastore_Value));
+ i,
+ size - sizeof(Datastore_Value));
if (OK != api->put(&key, value)) {
FREE(value);
fprintf(stderr, "E");
@@ -96,8 +96,8 @@
static int
iterateDummy(const HashCode512 * key,
- const Datastore_Value * val,
- void * cls) {
+ const Datastore_Value * val,
+ void * cls) {
if (GNUNET_SHUTDOWN_TEST() == YES)
return SYSERR;
return OK;
@@ -114,9 +114,9 @@
start = get_time();
for (j=0;j<PUT_10;j++) {
if (OK != putValue(api, j))
- break;
+ break;
if (GNUNET_SHUTDOWN_TEST() == YES)
- break;
+ break;
}
end = get_time();
printf("%3u insertion took %20llums\n", i, end-start);
@@ -171,15 +171,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("sqstore");
if (api != NULL) {
start_time = get_time();
Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -135,14 +135,14 @@
* @brief Prepare a SQL statement
*/
static int sq_prepare(sqlite3 * dbh,
- const char *zSql, /* SQL statement, UTF-8 encoded */
- sqlite3_stmt **ppStmt) { /* OUT: Statement handle */
+ const char *zSql, /* SQL statement, UTF-8 encoded */
+ sqlite3_stmt **ppStmt) { /* OUT: Statement handle */
char * dummy;
return sqlite3_prepare(dbh,
- zSql,
- strlen(zSql),
- ppStmt,
- (const char**) &dummy);
+ zSql,
+ strlen(zSql),
+ ppStmt,
+ (const char**) &dummy);
}
#if 1
@@ -157,25 +157,25 @@
static void createIndices(sqlite3 * dbh) {
/* create indices */
CHECK(SQLITE_OK ==
- sqlite3_exec(dbh,
- "CREATE INDEX idx_hash ON gn070 (hash)",
- NULL, NULL, ENULL));
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_hash ON gn070 (hash)",
+ NULL, NULL, ENULL));
CHECK(SQLITE_OK ==
- sqlite3_exec(dbh,
- "CREATE INDEX idx_prio ON gn070 (prio)",
- NULL, NULL, ENULL));
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_prio ON gn070 (prio)",
+ NULL, NULL, ENULL));
CHECK(SQLITE_OK ==
- sqlite3_exec(dbh,
- "CREATE INDEX idx_expire ON gn070 (expire)",
- NULL, NULL, ENULL));
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_expire ON gn070 (expire)",
+ NULL, NULL, ENULL));
CHECK(SQLITE_OK ==
- sqlite3_exec(dbh,
- "CREATE INDEX idx_comb1 ON gn070 (prio,expire,hash)",
- NULL, NULL, ENULL));
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_comb1 ON gn070 (prio,expire,hash)",
+ NULL, NULL, ENULL));
CHECK(SQLITE_OK ==
- sqlite3_exec(dbh,
- "CREATE INDEX idx_comb2 ON gn070 (expire,prio,hash)",
- NULL, NULL, ENULL));
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_comb2 ON gn070 (expire,prio,hash)",
+ NULL, NULL, ENULL));
}
/**
@@ -203,51 +203,51 @@
/* Open database and precompile statements */
if (sqlite3_open(db->fn, &ret->dbh) != SQLITE_OK) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Unable to initialize SQLite: %s.\n"),
- sqlite3_errmsg(ret->dbh));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Unable to initialize SQLite: %s.\n"),
+ sqlite3_errmsg(ret->dbh));
sqlite3_close(ret->dbh);
FREE(ret);
return NULL;
}
CHECK(SQLITE_OK ==
- sqlite3_exec(ret->dbh,
- "PRAGMA temp_store=MEMORY", NULL, NULL, ENULL));
+ sqlite3_exec(ret->dbh,
+ "PRAGMA temp_store=MEMORY", NULL, NULL, ENULL));
CHECK(SQLITE_OK ==
- sqlite3_exec(ret->dbh,
- "PRAGMA synchronous=OFF", NULL, NULL, ENULL));
+ sqlite3_exec(ret->dbh,
+ "PRAGMA synchronous=OFF", NULL, NULL, ENULL));
CHECK(SQLITE_OK ==
- sqlite3_exec(ret->dbh,
- "PRAGMA count_changes=OFF", NULL, NULL, ENULL));
+ sqlite3_exec(ret->dbh,
+ "PRAGMA count_changes=OFF", NULL, NULL, ENULL));
CHECK(SQLITE_OK ==
- sqlite3_exec(ret->dbh,
- "PRAGMA page_size=4092", NULL, NULL, ENULL));
+ sqlite3_exec(ret->dbh,
+ "PRAGMA page_size=4092", NULL, NULL, ENULL));
CHECK(SQLITE_OK ==
- sqlite3_busy_timeout(ret->dbh,
- BUSY_TIMEOUT_MS));
+ sqlite3_busy_timeout(ret->dbh,
+ BUSY_TIMEOUT_MS));
/* We have to do it here, because otherwise precompiling SQL might fail */
CHECK(SQLITE_OK ==
- sq_prepare(ret->dbh,
- "Select 1 from sqlite_master where tbl_name = 'gn070'",
- &stmt));
+ sq_prepare(ret->dbh,
+ "Select 1 from sqlite_master where tbl_name = 'gn070'",
+ &stmt));
if (sqlite3_step(stmt) == SQLITE_DONE) {
if (sqlite3_exec(ret->dbh,
- "CREATE TABLE gn070 ("
- " size INTEGER NOT NULL DEFAULT 0,"
- " type INTEGER NOT NULL DEFAULT 0,"
- " prio INTEGER NOT NULL DEFAULT 0,"
- " anonLevel INTEGER NOT NULL DEFAULT 0,"
- " expire INTEGER NOT NULL DEFAULT 0,"
- " hash TEXT NOT NULL DEFAULT '',"
- " value BLOB NOT NULL DEFAULT '')", NULL, NULL,
- NULL) != SQLITE_OK) {
+ "CREATE TABLE gn070 ("
+ " size INTEGER NOT NULL DEFAULT 0,"
+ " type INTEGER NOT NULL DEFAULT 0,"
+ " prio INTEGER NOT NULL DEFAULT 0,"
+ " anonLevel INTEGER NOT NULL DEFAULT 0,"
+ " expire INTEGER NOT NULL DEFAULT 0,"
+ " hash TEXT NOT NULL DEFAULT '',"
+ " value BLOB NOT NULL DEFAULT '')", NULL, NULL,
+ NULL) != SQLITE_OK) {
LOG_SQLITE(ret,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_create");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_create");
sqlite3_finalize(stmt);
FREE(ret);
return NULL;
@@ -257,24 +257,24 @@
sqlite3_finalize(stmt);
if ( (sq_prepare(ret->dbh,
- "SELECT COUNT(*) FROM gn070 WHERE hash=?",
- &ret->countContent) != SQLITE_OK) ||
+ "SELECT COUNT(*) FROM gn070 WHERE hash=?",
+ &ret->countContent) != SQLITE_OK) ||
(sq_prepare(ret->dbh,
- "SELECT LENGTH(hash), LENGTH(value), size, type, prio,
anonLevel, expire "
- "FROM gn070 WHERE hash=?",
- &ret->exists) != SQLITE_OK) ||
+ "SELECT LENGTH(hash), LENGTH(value), size, type, prio, anonLevel,
expire "
+ "FROM gn070 WHERE hash=?",
+ &ret->exists) != SQLITE_OK) ||
(sq_prepare(ret->dbh,
- "UPDATE gn070 SET prio = prio + ?, expire = MAX(expire,?)
WHERE "
- "hash = ? AND value = ? AND prio + ? < ?",
- &ret->updPrio) != SQLITE_OK) ||
+ "UPDATE gn070 SET prio = prio + ?, expire = MAX(expire,?) WHERE "
+ "hash = ? AND value = ? AND prio + ? < ?",
+ &ret->updPrio) != SQLITE_OK) ||
(sq_prepare(ret->dbh,
- "INSERT INTO gn070 (size, type, prio, "
- "anonLevel, expire, hash, value) VALUES "
- "(?, ?, ?, ?, ?, ?, ?)",
- &ret->insertContent) != SQLITE_OK) ) {
+ "INSERT INTO gn070 (size, type, prio, "
+ "anonLevel, expire, hash, value) VALUES "
+ "(?, ?, ?, ?, ?, ?, ?)",
+ &ret->insertContent) != SQLITE_OK) ) {
LOG_SQLITE(ret,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "precompiling");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "precompiling");
if (ret->countContent != NULL)
sqlite3_finalize(ret->countContent);
if (ret->exists != NULL)
@@ -290,8 +290,8 @@
MUTEX_LOCK(db->DATABASE_Lock_);
APPEND(db->handles,
- db->handle_count,
- ret);
+ db->handle_count,
+ ret);
MUTEX_UNLOCK(db->DATABASE_Lock_);
return ret;
}
@@ -303,15 +303,15 @@
if ((l & 0x7FFFFFFFFFFFLL) == l)
if ((l & 0x7FFFFFFF) == l)
if ((l & 0x7FFFFF) == l)
- if ((l & 0x7FFF) == l)
- if ((l & 0x7F) == l)
- return 1;
- else
- return 2;
- else
- return 3;
+ if ((l & 0x7FFF) == l)
+ if ((l & 0x7F) == l)
+ return 1;
+ else
+ return 2;
+ else
+ return 3;
else
- return 4;
+ return 4;
else
return 6;
else
@@ -357,7 +357,7 @@
*/
static Datastore_Datum *
assembleDatum(sqliteHandle * handle,
- sqlite3_stmt *stmt) {
+ sqlite3_stmt *stmt) {
Datastore_Datum * datum;
Datastore_Value * value;
int contentSize;
@@ -375,19 +375,19 @@
sqlite3_stmt * stmt;
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Invalid data in %s (NCS). Trying to fix (by deletion).\n"),
- _("sqlite datastore"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Invalid data in %s (NCS). Trying to fix (by deletion).\n"),
+ _("sqlite datastore"));
if (sq_prepare(dbh,
- "DELETE FROM gn070 WHERE size < ?", &stmt) == SQLITE_OK) {
+ "DELETE FROM gn070 WHERE size < ?", &stmt) == SQLITE_OK) {
sqlite3_bind_int(stmt,
- 1,
- sizeof(Datastore_Value));
+ 1,
+ sizeof(Datastore_Value));
sqlite3_step(stmt);
sqlite3_finalize(stmt);
} else
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sq_prepare");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sq_prepare");
return NULL; /* error */
}
@@ -396,24 +396,24 @@
sqlite3_stmt * stmt;
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Invalid data in %s. Trying to fix (by deletion).\n"),
- _("sqlite datastore"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Invalid data in %s. Trying to fix (by deletion).\n"),
+ _("sqlite datastore"));
if (sq_prepare(dbh,
- "DELETE FROM gn070 WHERE NOT ((LENGTH(hash) = ?) AND (size =
LENGTH(value) + ?))",
+ "DELETE FROM gn070 WHERE NOT ((LENGTH(hash) = ?) AND (size =
LENGTH(value) + ?))",
&stmt) == SQLITE_OK) {
sqlite3_bind_int(stmt,
- 1,
- sizeof(HashCode512));
+ 1,
+ sizeof(HashCode512));
sqlite3_bind_int(stmt,
- 2,
- sizeof(Datastore_Value));
+ 2,
+ sizeof(Datastore_Value));
sqlite3_step(stmt);
sqlite3_finalize(stmt);
} else
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sq_prepare");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sq_prepare");
return NULL;
}
@@ -426,11 +426,11 @@
value->anonymityLevel = htonl(sqlite3_column_int(stmt, 3));
value->expirationTime = htonll(sqlite3_column_int64(stmt, 4));
memcpy(&datum->key,
- sqlite3_column_blob(stmt, 5),
- sizeof(HashCode512));
+ sqlite3_column_blob(stmt, 5),
+ sizeof(HashCode512));
memcpy(&value[1],
- sqlite3_column_blob(stmt, 6),
- contentSize);
+ sqlite3_column_blob(stmt, 6),
+ contentSize);
return datum;
}
@@ -441,20 +441,20 @@
* @return SYSERR on error, the value otherwise
*/
static unsigned long long getStat(sqliteHandle * handle,
- const char * key) {
+ const char * key) {
int i;
sqlite3_stmt *stmt;
unsigned long long ret = SYSERR;
i = sq_prepare(handle->dbh,
- "SELECT expire FROM gn070 WHERE hash = ?",
- &stmt);
+ "SELECT expire FROM gn070 WHERE hash = ?",
+ &stmt);
if (i == SQLITE_OK) {
sqlite3_bind_text(stmt,
- 1,
- key,
- strlen(key),
- SQLITE_STATIC);
+ 1,
+ key,
+ strlen(key),
+ SQLITE_STATIC);
i = sqlite3_step(stmt);
if (i == SQLITE_DONE) {
@@ -470,8 +470,8 @@
return SYSERR;
if (i != SQLITE_OK) {
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_getStat");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_getStat");
return SYSERR;
}
return ret;
@@ -484,42 +484,42 @@
* @return SYSERR on error, OK otherwise
*/
static int setStat(sqliteHandle * handle,
- const char *key,
- unsigned long long val) {
+ const char *key,
+ unsigned long long val) {
sqlite3_stmt *stmt;
sqlite3 * dbh;
dbh = handle->dbh;
if (sq_prepare(dbh,
- "DELETE FROM gn070 where hash = ?", &stmt) == SQLITE_OK) {
+ "DELETE FROM gn070 where hash = ?", &stmt) == SQLITE_OK) {
sqlite3_bind_text(stmt,
- 1,
- key,
- strlen(key),
- SQLITE_STATIC);
+ 1,
+ key,
+ strlen(key),
+ SQLITE_STATIC);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
if (sq_prepare(dbh,
- "INSERT INTO gn070(hash, expire, type) VALUES (?, ?, ?)",
- &stmt) != SQLITE_OK)
+ "INSERT INTO gn070(hash, expire, type) VALUES (?, ?, ?)",
+ &stmt) != SQLITE_OK)
return SYSERR;
sqlite3_bind_text(stmt,
- 1,
- key,
- strlen(key),
- SQLITE_STATIC);
+ 1,
+ key,
+ strlen(key),
+ SQLITE_STATIC);
sqlite3_bind_int64(stmt,
- 2,
- val);
+ 2,
+ val);
sqlite3_bind_int(stmt,
- 3,
- RESERVED_BLOCK);
+ 3,
+ RESERVED_BLOCK);
if (sqlite3_step(stmt) != SQLITE_DONE) {
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_setStat");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_setStat");
sqlite3_finalize(stmt);
return SYSERR;
}
@@ -533,8 +533,8 @@
*/
static void syncStats(sqliteHandle * handle) {
setStat(handle,
- "PAYLOAD",
- db->payload);
+ "PAYLOAD",
+ db->payload);
db->lastSync = 0;
}
@@ -550,13 +550,13 @@
* @return the number of items stored in the content database
*/
static int sqlite_iterate(unsigned int type,
- Datum_Iterator iter,
- void * closure,
- int sortByPriority,
- int inverseOrder,
- int include_expired,
- int limit_nonanonymous,
- int limit_ondemand) {
+ Datum_Iterator iter,
+ void * closure,
+ int sortByPriority,
+ int inverseOrder,
+ int include_expired,
+ int limit_nonanonymous,
+ int limit_ondemand) {
sqlite3_stmt * stmt;
int count;
char scratch[512];
@@ -574,39 +574,39 @@
/* For the rowid trick see
http://permalink.gmane.org/gmane.network.gnunet.devel/1363 */
strcpy(scratch,
- "SELECT size, type, prio, anonLevel, expire, hash, value FROM gn070"
- " WHERE rowid IN (SELECT rowid FROM gn070"
- " WHERE ((hash > :1 AND expire == :2 AND prio == :3) OR ");
+ "SELECT size, type, prio, anonLevel, expire, hash, value FROM gn070"
+ " WHERE rowid IN (SELECT rowid FROM gn070"
+ " WHERE ((hash > :1 AND expire == :2 AND prio == :3) OR ");
if (sortByPriority) {
if (inverseOrder)
strcat(scratch,
- "(expire < :4 AND prio == :5) OR prio < :6)");
+ "(expire < :4 AND prio == :5) OR prio < :6)");
else
strcat(scratch,
- "(expire > :4 AND prio == :5) OR prio > :6)");
+ "(expire > :4 AND prio == :5) OR prio > :6)");
} else {
if (inverseOrder)
strcat(scratch,
- "(prio < :4 AND expire == :5) OR expire < :6)");
+ "(prio < :4 AND expire == :5) OR expire < :6)");
else
strcat(scratch,
- "(prio > :4 AND expire == :5) OR expire > :6)");
+ "(prio > :4 AND expire == :5) OR expire > :6)");
}
if (type != 0) {
strcat(scratch, " AND type = :7");
} else if (limit_ondemand == YES) {
SNPRINTF(&scratch[strlen(scratch)],
- 512 - strlen(scratch),
- " AND type != %d AND type != %d",
- RESERVED_BLOCK,
- ONDEMAND_BLOCK);
+ 512 - strlen(scratch),
+ " AND type != %d AND type != %d",
+ RESERVED_BLOCK,
+ ONDEMAND_BLOCK);
} else {
SNPRINTF(&scratch[strlen(scratch)],
- 512 - strlen(scratch),
- " AND type != %d",
- RESERVED_BLOCK); /* otherwise we iterate over
- the stats entry, which would
- be bad */
+ 512 - strlen(scratch),
+ " AND type != %d",
+ RESERVED_BLOCK); /* otherwise we iterate over
+ the stats entry, which would
+ be bad */
}
if (NO == include_expired) {
if (type != 0)
@@ -627,11 +627,11 @@
}
strcat(scratch, " LIMIT 1)");
if (sq_prepare(dbh,
- scratch,
- &stmt) != SQLITE_OK) {
+ scratch,
+ &stmt) != SQLITE_OK) {
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite3_prepare");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite3_prepare");
return SYSERR;
}
count = 0;
@@ -645,78 +645,78 @@
memset(&key, 0, sizeof(HashCode512));
while (1) {
sqlite3_bind_blob(stmt,
- 1,
- &key,
- sizeof(HashCode512),
- SQLITE_TRANSIENT);
+ 1,
+ &key,
+ sizeof(HashCode512),
+ SQLITE_TRANSIENT);
sqlite3_bind_int64(stmt,
- 2,
- lastExp);
+ 2,
+ lastExp);
sqlite3_bind_int(stmt,
- 3,
- lastPrio);
+ 3,
+ lastPrio);
if (sortByPriority) {
sqlite3_bind_int64(stmt,
- 4,
- lastExp);
+ 4,
+ lastExp);
sqlite3_bind_int(stmt,
- 5,
- lastPrio);
+ 5,
+ lastPrio);
sqlite3_bind_int(stmt,
- 6,
- lastPrio);
+ 6,
+ lastPrio);
} else {
sqlite3_bind_int64(stmt,
- 4,
- lastExp);
+ 4,
+ lastExp);
sqlite3_bind_int(stmt,
- 5,
- lastPrio);
+ 5,
+ lastPrio);
sqlite3_bind_int64(stmt,
- 6,
- lastExp);
+ 6,
+ lastExp);
}
if (type)
sqlite3_bind_int(stmt,
- 7,
- type);
+ 7,
+ type);
if (NO == include_expired) {
now = get_time();
if (type)
- sqlite3_bind_int64(stmt,
- 8,
- now);
+ sqlite3_bind_int64(stmt,
+ 8,
+ now);
else
- sqlite3_bind_int64(stmt,
- 7,
- now);
+ sqlite3_bind_int64(stmt,
+ 7,
+ now);
}
if ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
datum = assembleDatum(handle,
- stmt);
+ stmt);
sqlite3_reset(stmt);
if (datum == NULL)
- continue;
+ continue;
#if 0
printf("FOUND %4u prio %4u exp %20llu old: %4u, %20llu\n",
- (ntohl(datum->value.size) - sizeof(Datastore_Value)),
- ntohl(datum->value.prio),
- ntohll(datum->value.expirationTime),
- lastPrio,
- lastExp);
+ (ntohl(datum->value.size) - sizeof(Datastore_Value)),
+ ntohl(datum->value.prio),
+ ntohll(datum->value.expirationTime),
+ lastPrio,
+ lastExp);
#endif
if ( (NO == limit_nonanonymous) ||
- (ntohl(datum->value.anonymityLevel) == 0) ) {
- count++;
- if (iter != NULL) {
- if (SYSERR == iter(&datum->key,
- &datum->value,
- closure) ) {
- FREE(datum);
- count = SYSERR;
- break;
- }
- }
+ (ntohl(datum->value.anonymityLevel) == 0) ) {
+ count++;
+ if (iter != NULL) {
+ if (SYSERR == iter(&datum->key,
+ &datum->value,
+ closure) ) {
+ FREE(datum);
+ count = SYSERR;
+ break;
+ }
+ }
}
key = datum->key;
lastPrio = ntohl(datum->value.prio);
@@ -724,11 +724,11 @@
FREE(datum);
} else {
if (ret != SQLITE_DONE) {
- LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_query");
- sqlite3_finalize(stmt);
- return SYSERR;
+ LOG_SQLITE(handle,
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_query");
+ sqlite3_finalize(stmt);
+ return SYSERR;
}
sqlite3_reset(stmt);
break;
@@ -750,8 +750,8 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateLowPriority(unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ Datum_Iterator iter,
+ void * closure) {
return sqlite_iterate(type, iter, closure, YES, NO, YES, NO, NO);
}
@@ -768,9 +768,9 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateNonAnonymous(unsigned int type,
- int on_demand,
- Datum_Iterator iter,
- void * closure) {
+ int on_demand,
+ Datum_Iterator iter,
+ void * closure) {
return sqlite_iterate(0, iter, closure, NO, NO, NO, YES, on_demand);
}
@@ -784,8 +784,8 @@
* @return the number of items stored in the content database
*/
static int iterateExpirationTime(unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ Datum_Iterator iter,
+ void * closure) {
return sqlite_iterate(type, iter, closure, NO, NO, YES, NO, NO);
}
@@ -798,7 +798,7 @@
* iter is non-NULL and aborted the iteration
*/
static int iterateMigrationOrder(Datum_Iterator iter,
- void * closure) {
+ void * closure) {
return sqlite_iterate(0, iter, closure, NO, YES, NO, NO, NO);
}
@@ -812,7 +812,7 @@
* @return the number of items stored in the content database
*/
static int iterateAllNow(Datum_Iterator iter,
- void * closure) {
+ void * closure) {
sqlite3_stmt * stmt;
int count;
Datastore_Datum * datum;
@@ -827,27 +827,27 @@
/* For the rowid trick see
http://permalink.gmane.org/gmane.network.gnunet.devel/1363 */
if (sq_prepare(dbh,
- "SELECT size, type, prio, anonLevel, expire, hash, value FROM
gn070",
- &stmt) != SQLITE_OK) {
+ "SELECT size, type, prio, anonLevel, expire, hash, value FROM gn070",
+ &stmt) != SQLITE_OK) {
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite3_prepare");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite3_prepare");
return SYSERR;
}
count = 0;
while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
datum = assembleDatum(handle,
- stmt);
+ stmt);
if (datum == NULL)
continue;
payload += getContentDatastoreSize(&datum->value);
if (iter != NULL) {
if (SYSERR == iter(&datum->key,
- &datum->value,
- closure) ) {
- FREE(datum);
- count = SYSERR;
- break;
+ &datum->value,
+ closure) ) {
+ FREE(datum);
+ count = SYSERR;
+ break;
}
}
FREE(datum);
@@ -855,8 +855,8 @@
}
if (ret != SQLITE_DONE) {
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_query");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_query");
sqlite3_finalize(stmt);
return SYSERR;
}
@@ -864,10 +864,10 @@
if (count != SYSERR) {
/* re-computed payload! */
GE_LOG(ectx,
- GE_INFO | GE_IMMEDIATE | GE_USER | GE_ADMIN,
- "SQLite database size recomputed. New estimate is %llu, old
estimate was %llu\n",
- payload,
- db->payload);
+ GE_INFO | GE_IMMEDIATE | GE_USER | GE_ADMIN,
+ "SQLite database size recomputed. New estimate is %llu, old estimate was
%llu\n",
+ payload,
+ db->payload);
db->payload = payload;
syncStats(handle);
}
@@ -882,8 +882,8 @@
#if DEBUG_SQLITE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: closing database\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: closing database\n");
#endif
if (! db)
return;
@@ -900,8 +900,8 @@
sqlite3_finalize(h->insertContent);
if (sqlite3_close(h->dbh) != SQLITE_OK)
LOG_SQLITE(h,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_close");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_close");
FREE(h);
}
FREE(db->handles);
@@ -937,9 +937,9 @@
* iter is non-NULL and aborted the iteration
*/
static int get(const HashCode512 * key,
- unsigned int type,
- Datum_Iterator iter,
- void * closure) {
+ unsigned int type,
+ Datum_Iterator iter,
+ void * closure) {
int ret, count = 0;
sqlite3_stmt *stmt;
char scratch[256];
@@ -951,13 +951,13 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: retrieving content `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: retrieving content `%s'\n",
+ &enc);
#endif
handle = getDBHandle();
dbh = handle->dbh;
@@ -973,7 +973,7 @@
if (type) {
strcat(scratch, "type = :1");
if (key)
- strcat(scratch, " and ");
+ strcat(scratch, " and ");
}
if (key)
strcat(scratch, "hash = :2");
@@ -981,65 +981,65 @@
strcat(scratch, " ORDER BY expire DESC");
if (sq_prepare(dbh,
- scratch,
- &stmt) != SQLITE_OK) {
+ scratch,
+ &stmt) != SQLITE_OK) {
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_query");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_query");
return SYSERR;
}
if (type)
ret = sqlite3_bind_int(stmt,
- bind++,
- type);
+ bind++,
+ type);
else
ret = SQLITE_OK;
-
+
if (key && (ret == SQLITE_OK)) {
ret = sqlite3_bind_blob(stmt,
- bind,
- key,
- sizeof(HashCode512),
- SQLITE_TRANSIENT);
+ bind,
+ key,
+ sizeof(HashCode512),
+ SQLITE_TRANSIENT);
}
if (ret == SQLITE_OK) {
while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
if (iter != NULL) {
- datum = assembleDatum(handle,
- stmt);
-
- if (datum == NULL)
- continue;
- if ( (key != NULL) &&
- (0 != memcmp(&datum->key,
- key,
- sizeof(HashCode512))) ) {
- GE_BREAK(NULL, 0);
- FREE(datum);
- continue;
- }
+ datum = assembleDatum(handle,
+ stmt);
+
+ if (datum == NULL)
+ continue;
+ if ( (key != NULL) &&
+ (0 != memcmp(&datum->key,
+ key,
+ sizeof(HashCode512))) ) {
+ GE_BREAK(NULL, 0);
+ FREE(datum);
+ continue;
+ }
#if DEBUG_SQLITE
- GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Found in database block with type %u.\n",
- ntohl(*(int*)&((&datum->value)[1])));
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Found in database block with type %u.\n",
+ ntohl(*(int*)&((&datum->value)[1])));
#endif
- if (SYSERR == iter(&datum->key,
- &datum->value,
- closure) ) {
-
- count = SYSERR;
- FREE(datum);
- ret = SQLITE_DONE;
- break;
- }
- FREE(datum);
- count++;
+ if (SYSERR == iter(&datum->key,
+ &datum->value,
+ closure) ) {
+
+ count = SYSERR;
+ FREE(datum);
+ ret = SQLITE_DONE;
+ break;
+ }
+ FREE(datum);
+ count++;
} else
- count += sqlite3_column_int(stmt, 0);
+ count += sqlite3_column_int(stmt, 0);
}
if (ret == SQLITE_BUSY) {
sqlite3_finalize(stmt);
@@ -1047,8 +1047,8 @@
}
if (ret != SQLITE_DONE) {
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_query");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_query");
sqlite3_finalize(stmt);
return SYSERR;
}
@@ -1056,13 +1056,13 @@
sqlite3_finalize(stmt);
} else
LOG_SQLITE(handle,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_query");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_query");
#if DEBUG_SQLITE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: done reading content\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: done reading content\n");
#endif
return count;
@@ -1075,7 +1075,7 @@
* @return SYSERR on error, NO on temporary error, OK if ok.
*/
static int put(const HashCode512 * key,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
int n;
sqlite3_stmt *stmt;
unsigned int contentSize;
@@ -1086,16 +1086,16 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_BULK | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "Storing in database block with type %u/key `%s'/priority
%u/expiration %llu.\n",
- ntohl(*(int*)&value[1]),
- &enc,
- ntohl(value->prio),
- ntohll(value->expirationTime));
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Storing in database block with type %u/key `%s'/priority %u/expiration
%llu.\n",
+ ntohl(*(int*)&value[1]),
+ &enc,
+ ntohl(value->prio),
+ ntohll(value->expirationTime));
#endif
if ( (ntohl(value->size) < sizeof(Datastore_Value)) ) {
@@ -1126,8 +1126,8 @@
return NO;
}
LOG_SQLITE(dbh,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_query");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_query");
sqlite3_reset(stmt);
return SYSERR;
}
@@ -1136,8 +1136,8 @@
db->payload += getContentDatastoreSize(value);
#if DEBUG_SQLITE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: done writing content\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: done writing content\n");
#endif
return OK;
}
@@ -1151,7 +1151,7 @@
* none were found, SYSERR on errors
*/
static int del(const HashCode512 * key,
- const Datastore_Value * value) {
+ const Datastore_Value * value) {
size_t n;
sqlite3_stmt *stmt;
int deleted;
@@ -1167,13 +1167,13 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: deleting block with key `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: deleting block with key `%s'\n",
+ &enc);
#endif
dbh = getDBHandle();
@@ -1182,25 +1182,25 @@
if (NULL == value) {
if (sq_prepare(dbh->dbh,
- "SELECT size, type, prio, anonLevel, expire, hash, value "
- "FROM gn070 WHERE hash = ? ORDER BY prio ASC",
- &stmt) != SQLITE_OK) {
+ "SELECT size, type, prio, anonLevel, expire, hash, value "
+ "FROM gn070 WHERE hash = ? ORDER BY prio ASC",
+ &stmt) != SQLITE_OK) {
LOG_SQLITE(dbh,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_query");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_query");
return SYSERR;
}
sqlite3_bind_blob(stmt,
- 1,
- key,
- sizeof(HashCode512),
- SQLITE_TRANSIENT);
+ 1,
+ key,
+ sizeof(HashCode512),
+ SQLITE_TRANSIENT);
if (sqlite3_step(stmt) != SQLITE_ROW) {
sqlite3_finalize(stmt);
return NO;
}
dvalue = assembleDatum(dbh,
- stmt);
+ stmt);
if (dvalue == NULL) {
sqlite3_finalize(stmt);
return SYSERR;
@@ -1209,13 +1209,13 @@
value = &dvalue->value;
} else {
dvalue = NULL;
- }
+ }
contentSize = ntohl(value->size)-sizeof(Datastore_Value);
n = sq_prepare(dbh->dbh,
- "DELETE FROM gn070 WHERE hash = ? and "
- "value = ? AND size = ? AND type = ? AND prio = ? AND
anonLevel = ? "
- "AND expire = ?", /* ORDER BY prio ASC LIMIT 1" -- not
available in sqlite */
- &stmt);
+ "DELETE FROM gn070 WHERE hash = ? and "
+ "value = ? AND size = ? AND type = ? AND prio = ? AND anonLevel = ? "
+ "AND expire = ?", /* ORDER BY prio ASC LIMIT 1" -- not available in
sqlite */
+ &stmt);
if (n == SQLITE_OK) {
size = ntohl(value->size);
type = ntohl(value->type);
@@ -1235,8 +1235,8 @@
db->payload -= getContentDatastoreSize(value);
} else {
LOG_SQLITE(dbh,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite3_prepare");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite3_prepare");
}
FREENONNULL(dvalue);
deleted = ( (n == SQLITE_DONE) || (n == SQLITE_ROW) ) ?
sqlite3_changes(dbh->dbh) : SYSERR;
@@ -1245,8 +1245,8 @@
if (n != SQLITE_DONE) {
if (n != SQLITE_BUSY) {
LOG_SQLITE(dbh,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_query");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_query");
return SYSERR;
} else {
return NO;
@@ -1256,9 +1256,9 @@
#if DEBUG_SQLITE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: %d block(s) deleted\n",
- deleted);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: %d block(s) deleted\n",
+ deleted);
#endif
return deleted;
@@ -1269,9 +1269,9 @@
* in the datastore.
*/
static int update(const HashCode512 * key,
- const Datastore_Value * value,
- int delta,
- cron_t expire) {
+ const Datastore_Value * value,
+ int delta,
+ cron_t expire) {
int n;
unsigned long contentSize;
sqliteHandle *dbh;
@@ -1279,47 +1279,47 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(key,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: updating block with key `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: updating block with key `%s'\n",
+ &enc);
#endif
dbh = getDBHandle();
contentSize = ntohl(value->size)-sizeof(Datastore_Value);
sqlite3_bind_int(dbh->updPrio,
- 1,
- delta);
+ 1,
+ delta);
sqlite3_bind_int64(dbh->updPrio,
- 2,
- expire);
+ 2,
+ expire);
sqlite3_bind_blob(dbh->updPrio,
- 3,
- key,
- sizeof(HashCode512),
- SQLITE_TRANSIENT);
+ 3,
+ key,
+ sizeof(HashCode512),
+ SQLITE_TRANSIENT);
sqlite3_bind_blob(dbh->updPrio,
- 4,
- &value[1],
- contentSize,
- SQLITE_TRANSIENT);
+ 4,
+ &value[1],
+ contentSize,
+ SQLITE_TRANSIENT);
sqlite3_bind_int(dbh->updPrio,
- 5,
- delta);
+ 5,
+ delta);
sqlite3_bind_int(dbh->updPrio,
- 6,
- MAX_PRIO);
+ 6,
+ MAX_PRIO);
n = sqlite3_step(dbh->updPrio);
sqlite3_reset(dbh->updPrio);
#if DEBUG_SQLITE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: block updated\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: block updated\n");
#endif
if (n == SQLITE_BUSY)
return NO;
@@ -1337,29 +1337,29 @@
ectx = capi->ectx;
#if DEBUG_SQLITE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: initializing database\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: initializing database\n");
#endif
db = MALLOC(sizeof(sqliteDatabase));
memset(db,
- 0,
- sizeof(sqliteDatabase));
+ 0,
+ sizeof(sqliteDatabase));
db->payload = 0;
db->lastSync = 0;
afsdir = NULL;
GC_get_configuration_value_filename(capi->cfg,
- "FS",
- "DIR",
- VAR_DAEMON_DIRECTORY "/data/fs/",
- &afsdir);
+ "FS",
+ "DIR",
+ VAR_DAEMON_DIRECTORY "/data/fs/",
+ &afsdir);
dir = MALLOC(strlen(afsdir) + strlen("/content/gnunet.dat") + 2);
strcpy(dir, afsdir);
strcat(dir, "/content/gnunet.dat");
FREE(afsdir);
if (OK != disk_directory_create_for_file(ectx,
- dir)) {
+ dir)) {
GE_BREAK(ectx, 0);
FREE(dir);
FREE(db);
@@ -1380,8 +1380,8 @@
if (db->payload == SYSERR) {
GE_BREAK(ectx, 0);
LOG_SQLITE(dbh,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "sqlite_payload");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "sqlite_payload");
MUTEX_DESTROY(db->DATABASE_Lock_);
FREE(db->fn);
FREE(db);
@@ -1417,8 +1417,8 @@
sqlite_shutdown();
#if DEBUG_SQLITE
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SQLite: database shutdown\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SQLite: database shutdown\n");
#endif
coreAPI = NULL;
}
@@ -1437,22 +1437,22 @@
db = MALLOC(sizeof(sqliteDatabase));
memset(db,
- 0,
- sizeof(sqliteDatabase));
+ 0,
+ sizeof(sqliteDatabase));
db->payload = 0;
db->lastSync = 0;
afsdir = NULL;
GC_get_configuration_value_filename(uapi->cfg,
- "FS",
- "DIR",
- VAR_DAEMON_DIRECTORY "/data/fs/",
- &afsdir);
+ "FS",
+ "DIR",
+ VAR_DAEMON_DIRECTORY "/data/fs/",
+ &afsdir);
dir = MALLOC(strlen(afsdir) + 8 + 2); /* 8 = "content/" */
strcpy(dir, afsdir);
strcat(dir, "/content/");
FREE(afsdir);
if (OK != disk_directory_create(ectx,
- dir)) {
+ dir)) {
FREE(dir);
FREE(db);
return;
Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -49,8 +49,8 @@
}
static int checkValue(const HashCode512 * key,
- const Datastore_Value * val,
- void * closure) {
+ const Datastore_Value * val,
+ void * closure) {
int i;
int ret;
Datastore_Value * value;
@@ -59,15 +59,15 @@
value = initValue(i);
if ( ( value->size == val->size) &&
(0 == memcmp(val,
- value,
- ntohl(val->size)) ) )
+ value,
+ ntohl(val->size)) ) )
ret = OK;
else {
/*
printf("Wanted: %u, %llu; got %u, %llu - %d\n",
- ntohl(value->size), ntohll(value->expirationTime),
- ntohl(val->size), ntohll(val->expirationTime),
- memcmp(val, value, ntohl(val->size))); */
+ ntohl(value->size), ntohll(value->expirationTime),
+ ntohl(val->size), ntohll(val->expirationTime),
+ memcmp(val, value, ntohl(val->size))); */
ret = SYSERR;
}
FREE(value);
@@ -75,8 +75,8 @@
}
static int iterateUp(const HashCode512 * key,
- const Datastore_Value * val,
- int * closure) {
+ const Datastore_Value * val,
+ int * closure) {
int ret;
ret = checkValue(key, val, closure);
@@ -85,8 +85,8 @@
}
static int iterateDown(const HashCode512 * key,
- const Datastore_Value * val,
- int * closure) {
+ const Datastore_Value * val,
+ int * closure) {
int ret;
(*closure) -= 2;
@@ -95,17 +95,17 @@
}
static int iterateDelete(const HashCode512 * key,
- const Datastore_Value * val,
- SQstore_ServiceAPI * api) {
+ const Datastore_Value * val,
+ SQstore_ServiceAPI * api) {
if (1 == api->del(key, val))
- return OK;
+ return OK;
else
- return SYSERR;
+ return SYSERR;
}
static int priorityCheck(const HashCode512 * key,
- const Datastore_Value * val,
- int * closure) {
+ const Datastore_Value * val,
+ int * closure) {
int id;
id = (*closure);
@@ -116,20 +116,20 @@
}
static int multipleCheck(const HashCode512 * key,
- const Datastore_Value * val,
- Datastore_Value ** last) {
+ const Datastore_Value * val,
+ Datastore_Value ** last) {
if (*last != NULL) {
if ( ((*last)->size == val->size) &&
- (0 == memcmp(*last,
- val,
- ntohl(val->size)) ) )
+ (0 == memcmp(*last,
+ val,
+ ntohl(val->size)) ) )
return SYSERR; /* duplicate! */
FREE(*last);
}
*last = MALLOC(ntohl(val->size));
memcpy(*last,
- val,
- ntohl(val->size));
+ val,
+ ntohl(val->size));
return OK;
}
@@ -153,11 +153,11 @@
}
ASSERT(oldSize < api->getSize());
ASSERT(256 == api->iterateLowPriority(ANY_BLOCK,
- NULL,
- NULL));
+ NULL,
+ NULL));
ASSERT(256 == api->iterateExpirationTime(ANY_BLOCK,
- NULL,
- NULL));
+ NULL,
+ NULL));
for (i=255;i>=0;i--) {
memset(&key, 256-i, sizeof(HashCode512));
ASSERT(1 == api->get(&key, i, &checkValue, (void*) &i));
@@ -173,35 +173,35 @@
ASSERT(oldSize > api->getSize());
i = 0;
ASSERT(128 == api->iterateLowPriority(ANY_BLOCK,
- (Datum_Iterator) &iterateUp,
- &i));
+ (Datum_Iterator) &iterateUp,
+ &i));
ASSERT(256 == i);
ASSERT(128 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &iterateDown,
- &i));
+ (Datum_Iterator) &iterateDown,
+ &i));
ASSERT(0 == i);
ASSERT(128 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &iterateDelete,
- api));
+ (Datum_Iterator) &iterateDelete,
+ api));
ASSERT(0 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &iterateDown,
- &i));
+ (Datum_Iterator) &iterateDown,
+ &i));
i = 42;
value = initValue(i);
memset(&key, 256-i, sizeof(HashCode512));
api->put(&key, value);
ASSERT(1 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &priorityCheck,
- &i));
+ (Datum_Iterator) &priorityCheck,
+ &i));
api->update(&key,
- value,
- 4,
- 0);
+ value,
+ 4,
+ 0);
i += 4;
ASSERT(1 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &priorityCheck,
- &i));
+ (Datum_Iterator) &priorityCheck,
+ &i));
FREE(value);
/* test multiple results */
@@ -211,16 +211,16 @@
value = NULL;
ASSERT(2 == api->iterateExpirationTime(ANY_BLOCK,
- (Datum_Iterator) &multipleCheck,
- &value));
+ (Datum_Iterator) &multipleCheck,
+ &value));
FREE(value);
api->del(&key,
- NULL);
+ NULL);
api->del(&key,
- NULL);
+ NULL);
ASSERT(0 == api->iterateExpirationTime(ANY_BLOCK,
- NULL,
- NULL));
+ NULL,
+ NULL));
api->drop();
return OK;
@@ -238,15 +238,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("sqstore");
if (api != NULL) {
ok = test(api);
Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -88,7 +88,7 @@
static cron_t start_time;
static int putValue(SQstore_ServiceAPI * api,
- int i) {
+ int i) {
Datastore_Value * value;
size_t size;
static HashCode512 key;
@@ -111,8 +111,8 @@
value->anonymityLevel = htonl(i);
value->expirationTime = htonll(get_time() + weak_randomi(1000));
memset(&value[1],
- i,
- size - sizeof(Datastore_Value));
+ i,
+ size - sizeof(Datastore_Value));
if (OK != api->put(&key, value)) {
FREE(value);
fprintf(stderr, "E");
@@ -132,8 +132,8 @@
static int
iterateDelete(const HashCode512 * key,
- const Datastore_Value * val,
- void * cls) {
+ const Datastore_Value * val,
+ void * cls) {
SQstore_ServiceAPI * api = cls;
static int dc;
@@ -164,7 +164,7 @@
lops = 0;
have_file = OK == disk_file_test(NULL,
- DB_NAME);
+ DB_NAME);
for (i=0;i<ITERATIONS;i++) {
#if REPORT_ID
@@ -174,7 +174,7 @@
for (j=0;j<PUT_10;j++) {
ASSERT(OK == putValue(api, j));
if (GNUNET_SHUTDOWN_TEST() == YES)
- break;
+ break;
}
/* trim down below MAX_SIZE again */
@@ -187,21 +187,21 @@
size = 0;
if (have_file)
disk_file_size(NULL,
- DB_NAME,
- &size,
- NO);
+ DB_NAME,
+ &size,
+ NO);
printf(
#if REPORT_ID
- "\n"
+ "\n"
#endif
- "%u: Useful %llu, API %llu, disk %llu (%.2f%%) / %lluk ops / %llu
ops/s\n",
- i,
- stored_bytes / 1024, /* used size in k */
- api->getSize() / 1024, /* API-reported size in k */
- size / 1024, /* disk size in kb */
- (100.0 * size / stored_bytes) - 100, /* overhead */
- (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k)
*/
- 1000 * ((stored_ops * 2 - stored_entries) - lops) / (1 + get_time()
- start_time)); /* operations per second */
+ "%u: Useful %llu, API %llu, disk %llu (%.2f%%) / %lluk ops / %llu
ops/s\n",
+ i,
+ stored_bytes / 1024, /* used size in k */
+ api->getSize() / 1024, /* API-reported size in k */
+ size / 1024, /* disk size in kb */
+ (100.0 * size / stored_bytes) - 100, /* overhead */
+ (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k) */
+ 1000 * ((stored_ops * 2 - stored_entries) - lops) / (1 + get_time() -
start_time)); /* operations per second */
lops = stored_ops * 2 - stored_entries;
start_time = get_time();
if (GNUNET_SHUTDOWN_TEST() == YES)
@@ -223,15 +223,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("sqstore");
if (api != NULL) {
start_time = get_time();
Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c 2007-07-05
19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c 2007-07-05
21:12:30 UTC (rev 5249)
@@ -56,7 +56,7 @@
static cron_t start_time;
static int putValue(SQstore_ServiceAPI * api,
- int i) {
+ int i) {
Datastore_Value * value;
size_t size;
static HashCode512 key;
@@ -68,7 +68,7 @@
size = sizeof(Datastore_Value) + weak_randomi(32 * 1024);
size = size - (size & 7); /* always multiple of 8 */
GE_ASSERT(NULL,
- size >= sizeof(Datastore_Value));
+ size >= sizeof(Datastore_Value));
/* generate random key */
hash(&key,
sizeof(HashCode512),
@@ -80,8 +80,8 @@
value->anonymityLevel = htonl(i);
value->expirationTime = htonll(get_time() + 60 * cronHOURS +
weak_randomi(1000));
memset(&value[1],
- i,
- size - sizeof(Datastore_Value));
+ i,
+ size - sizeof(Datastore_Value));
if (OK != api->put(&key, value)) {
FREE(value);
fprintf(stderr, "E");
@@ -101,8 +101,8 @@
static int
iterateDummy(const HashCode512 * key,
- const Datastore_Value * val,
- void * cls) {
+ const Datastore_Value * val,
+ void * cls) {
if (GNUNET_SHUTDOWN_TEST() == YES)
return SYSERR;
return OK;
@@ -119,9 +119,9 @@
start = get_time();
for (j=0;j<PUT_10;j++) {
if (OK != putValue(api, j))
- break;
+ break;
if (GNUNET_SHUTDOWN_TEST() == YES)
- break;
+ break;
}
end = get_time();
printf("%3u insertion took %20llums\n", i, end-start);
@@ -176,15 +176,15 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
cron = cron_create(NULL);
initCore(NULL,
- cfg,
- cron,
- NULL);
+ cfg,
+ cron,
+ NULL);
api = requestService("sqstore");
if (api != NULL) {
start_time = get_time();
Modified: GNUnet/src/applications/state/state.c
===================================================================
--- GNUnet/src/applications/state/state.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/state/state.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -51,8 +51,8 @@
* @return the number of bytes read on success, -1 on failure
*/
static int stateReadContent(struct GE_Context * ectx,
- const char * name,
- void ** result) {
+ const char * name,
+ void ** result) {
/* open file, must exist, open read only */
char * dbh = handle;
int fd;
@@ -62,37 +62,37 @@
size_t n;
GE_ASSERT(ectx,
- handle != NULL);
+ handle != NULL);
if (result == NULL)
return -1;
n = strlen(dbh) + strlen(name) + 2;
fil = MALLOC(n);
SNPRINTF(fil,
- n,
- "%s/%s",
- dbh,
- name);
+ n,
+ "%s/%s",
+ dbh,
+ name);
if ( (OK != disk_file_test(ectx,
- fil)) ||
+ fil)) ||
(OK != disk_file_size(ectx,
- fil,
- &fsize,
- YES)) ||
+ fil,
+ &fsize,
+ YES)) ||
(fsize == 0) ||
(-1 == (fd = disk_file_open(ectx,
- fil,
- O_RDONLY,
- S_IRUSR) )) ) {
+ fil,
+ O_RDONLY,
+ S_IRUSR) )) ) {
FREE(fil);
return -1;
}
*result = MALLOC_LARGE(fsize);
size = READ(fd,
- *result,
- fsize);
+ *result,
+ fsize);
disk_file_close(ectx,
- fil,
- fd);
+ fil,
+ fd);
FREE(fil);
if (size == -1) {
FREE(*result);
@@ -111,44 +111,44 @@
* @return SYSERR on error, OK if ok.
*/
static int stateAppendContent(struct GE_Context * ectx,
- const char * name,
- int len,
- const void * block) {
+ const char * name,
+ int len,
+ const void * block) {
char * dbh = handle;
char * fil;
int fd;
size_t n;
GE_ASSERT(ectx,
- handle != NULL);
+ handle != NULL);
n = strlen(dbh) + strlen(name) + 2;
fil = MALLOC(n);
SNPRINTF(fil,
- n,
- "%s/%s",
- dbh,
- name);
+ n,
+ "%s/%s",
+ dbh,
+ name);
fd = disk_file_open(ectx,
- fil,
- O_RDWR|O_CREAT,
- S_IRUSR|S_IWUSR);
+ fil,
+ O_RDWR|O_CREAT,
+ S_IRUSR|S_IWUSR);
if (fd == -1) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- "open",
- fil);
+ GE_WARNING | GE_BULK | GE_USER,
+ "open",
+ fil);
FREE(fil);
return SYSERR; /* failed! */
}
lseek(fd,
- 0,
- SEEK_END);
+ 0,
+ SEEK_END);
WRITE(fd,
- block,
- len);
+ block,
+ len);
disk_file_close(ectx,
- fil,
- fd);
+ fil,
+ fd);
FREE(fil);
return OK;
}
@@ -162,9 +162,9 @@
* @return SYSERR on error, OK if ok.
*/
static int stateWriteContent(struct GE_Context * ectx,
- const char * name,
- int len,
- const void * block) {
+ const char * name,
+ int len,
+ const void * block) {
char * dbh = handle;
char * fil;
int fd;
@@ -174,33 +174,33 @@
n = strlen(dbh) + strlen(name) + 2;
fil = MALLOC(n);
SNPRINTF(fil,
- n,
- "%s/%s",
- dbh,
- name);
+ n,
+ "%s/%s",
+ dbh,
+ name);
fd = disk_file_open(ectx,
- fil,
- O_RDWR|O_CREAT,
- S_IRUSR|S_IWUSR);
+ fil,
+ O_RDWR|O_CREAT,
+ S_IRUSR|S_IWUSR);
if (fd == -1) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- "open",
- fil);
+ GE_WARNING | GE_BULK | GE_USER,
+ "open",
+ fil);
FREE(fil);
return SYSERR; /* failed! */
}
WRITE(fd,
- block,
- len);
+ block,
+ len);
if (0 != ftruncate(fd, len))
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- "ftruncate",
- fil);
+ GE_WARNING | GE_BULK | GE_ADMIN,
+ "ftruncate",
+ fil);
disk_file_close(ectx,
- fil,
- fd);
+ fil,
+ fd);
FREE(fil);
return OK;
}
@@ -211,7 +211,7 @@
* (without directory)
*/
static int stateUnlinkFromDB(struct GE_Context * ectx,
- const char * name) {
+ const char * name) {
char * dbh = handle;
char * fil;
size_t n;
@@ -220,10 +220,10 @@
n = strlen(dbh) + strlen(name) + 2;
fil = MALLOC(n);
SNPRINTF(fil,
- n,
- "%s/%s",
- dbh,
- name);
+ n,
+ "%s/%s",
+ dbh,
+ name);
UNLINK(fil);
FREE(fil);
return OK;
@@ -238,22 +238,22 @@
dbh = NULL;
if (-1 == GC_get_configuration_value_filename(capi->cfg,
- "GNUNETD",
- "GNUNETD_HOME",
- VAR_DAEMON_DIRECTORY,
- &dbh))
+ "GNUNETD",
+ "GNUNETD_HOME",
+ VAR_DAEMON_DIRECTORY,
+ &dbh))
return NULL;
GE_ASSERT(capi->ectx, dbh != NULL);
n = strlen(dbh) + strlen(DIR_EXT) + 5;
handle = MALLOC(n);
SNPRINTF(handle,
- n,
- "%s/%s/",
- dbh,
- DIR_EXT);
+ n,
+ "%s/%s/",
+ dbh,
+ DIR_EXT);
FREE(dbh);
if (SYSERR == disk_directory_create(capi->ectx,
- handle)) {
+ handle)) {
FREE(handle);
handle = NULL;
return NULL;
Modified: GNUnet/src/applications/state/statetest.c
===================================================================
--- GNUnet/src/applications/state/statetest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/state/statetest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -11,7 +11,7 @@
* Perform option parsing from the command line.
*/
static int parseCommandLine(int argc,
- char * argv[]) {
+ char * argv[]) {
char c;
while (1) {
@@ -22,10 +22,10 @@
};
c = GNgetopt_long(argc,
- argv,
- "c:",
- long_options,
- &option_index);
+ argv,
+ "c:",
+ long_options,
+ &option_index);
if (c == -1)
break; /* No more flags to process */
@@ -33,14 +33,14 @@
switch(c) {
case 'c':
FREENONNULL(setConfigurationString("FILES",
- "gnunet.conf",
- GNoptarg));
+ "gnunet.conf",
+ GNoptarg));
break;
} /* end of parsing commandline */
}
FREENONNULL(setConfigurationString("GNUNETD",
- "LOGLEVEL",
- "NOTHING"));
+ "LOGLEVEL",
+ "NOTHING"));
return OK;
}
@@ -52,16 +52,16 @@
stateUnlinkFromDB(TH); /* go to defined state */
if (SYSERR == stateWriteContent(TH,
- 5,
- testString))
+ 5,
+ testString))
return 1;
if (SYSERR == stateAppendContent(TH,
- 6,
- &testString[5]))
+ 6,
+ &testString[5]))
return 2;
ret = NULL;
if (SYSERR == stateReadContent(TH,
- (void**)&ret))
+ (void**)&ret))
return 3;
if (0 != strncmp(ret, testString, 11))
return 4;
Modified: GNUnet/src/applications/stats/clientapi.c
===================================================================
--- GNUnet/src/applications/stats/clientapi.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/stats/clientapi.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -79,49 +79,49 @@
name = "P2P_PROTO_tracekit_REPLY";
break;
- case P2P_PROTO_tbench_REQUEST :
+ case P2P_PROTO_tbench_REQUEST :
name = "P2P_PROTO_tbench_REQUEST";
break;
- case P2P_PROTO_tbench_REPLY :
+ case P2P_PROTO_tbench_REPLY :
name = "P2P_PROTO_tbench_REPLY";
break;
- case P2P_PROTO_rpc_REQ :
+ case P2P_PROTO_rpc_REQ :
name = "P2P_PROTO_rpc_REQ";
break;
- case P2P_PROTO_rpc_RES :
+ case P2P_PROTO_rpc_RES :
name = "P2P_PROTO_rpc_RES";
break;
- case P2P_PROTO_rpc_ACK :
+ case P2P_PROTO_rpc_ACK :
name = "P2P_PROTO_rpc_ACK";
break;
- case P2P_PROTO_DHT_DISCOVERY :
+ case P2P_PROTO_DHT_DISCOVERY :
name = "P2P_PROTO_DHT_DISCOVERY";
break;
- case P2P_PROTO_DHT_ASK_HELLO :
+ case P2P_PROTO_DHT_ASK_HELLO :
name = "P2P_PROTO_DHT_ASK_HELLO";
break;
- case P2P_PROTO_DHT_GET :
+ case P2P_PROTO_DHT_GET :
name = "P2P_PROTO_DHT_GET";
break;
- case P2P_PROTO_DHT_PUT :
+ case P2P_PROTO_DHT_PUT :
name = "P2P_PROTO_DHT_PUT";
break;
- case P2P_PROTO_DHT_RESULT :
+ case P2P_PROTO_DHT_RESULT :
name = "P2P_PROTO_DHT_RESULT";
break;
- case P2P_PROTO_aip_IP :
+ case P2P_PROTO_aip_IP :
name = "P2P_PROTO_aip_IP";
break;
- case P2P_PROTO_aip_ROUTE :
+ case P2P_PROTO_aip_ROUTE :
name = "P2P_PROTO_aip_ROUTE";
break;
- case P2P_PROTO_aip_ROUTES :
+ case P2P_PROTO_aip_ROUTES :
name = "P2P_PROTO_aip_ROUTES";
break;
- case P2P_PROTO_aip_GETROUTE :
+ case P2P_PROTO_aip_GETROUTE :
name = "P2P_PROTO_aip_GETROUTE";
break;
@@ -286,9 +286,9 @@
* @return OK on success, SYSERR on error
*/
int STATS_getStatistics(struct GE_Context * ectx,
- struct ClientServerConnection * sock,
- STATS_StatProcessor processor,
- void * cls) {
+ struct ClientServerConnection * sock,
+ STATS_StatProcessor processor,
+ void * cls) {
CS_stats_reply_MESSAGE * statMsg;
MESSAGE_HEADER csHdr;
unsigned int count;
@@ -302,7 +302,7 @@
csHdr.type
= htons(CS_PROTO_stats_GET_STATISTICS);
if (SYSERR == connection_write(sock,
- &csHdr))
+ &csHdr))
return SYSERR;
statMsg
= MALLOC(sizeof(CS_stats_reply_MESSAGE));
@@ -315,10 +315,10 @@
/* printf("reading from socket starting %u of %d\n",
count, ntohl(statMsg->totalCounters) );*/
if (SYSERR == connection_read(sock,
- (MESSAGE_HEADER**)&statMsg))
+ (MESSAGE_HEADER**)&statMsg))
return SYSERR;
if ( (ntohs(statMsg->header.size) < sizeof(CS_stats_reply_MESSAGE)) ||
- (((char*)statMsg)[ntohs(statMsg->header.size)-1] != '\0') ) {
+ (((char*)statMsg)[ntohs(statMsg->header.size)-1] != '\0') ) {
GE_BREAK(ectx, 0);
ret = SYSERR;
break;
@@ -326,21 +326,21 @@
mpos = sizeof(unsigned long long) * ntohl(statMsg->statCounters);
if (count == 0) {
ret = processor(_("Uptime (seconds)"),
- (unsigned long long)
- ((get_time() - ntohll(statMsg->startTime))/cronSECONDS),
- cls);
+ (unsigned long long)
+ ((get_time() - ntohll(statMsg->startTime))/cronSECONDS),
+ cls);
}
for (i=0;i<ntohl(statMsg->statCounters);i++) {
if
(mpos+strlen(&((char*)(((CS_stats_reply_MESSAGE_GENERIC*)statMsg)->values))[mpos])+1
>
- ntohs(statMsg->header.size) - sizeof(CS_stats_reply_MESSAGE)) {
- GE_BREAK(ectx, 0);
- ret = SYSERR;
- break; /* out of bounds! */
+ ntohs(statMsg->header.size) - sizeof(CS_stats_reply_MESSAGE)) {
+ GE_BREAK(ectx, 0);
+ ret = SYSERR;
+ break; /* out of bounds! */
}
if (ret != SYSERR) {
- ret =
processor(&((char*)(((CS_stats_reply_MESSAGE_GENERIC*)statMsg)->values))[mpos],
-
ntohll(((CS_stats_reply_MESSAGE_GENERIC*)statMsg)->values[i]),
- cls);
+ ret =
processor(&((char*)(((CS_stats_reply_MESSAGE_GENERIC*)statMsg)->values))[mpos],
+ ntohll(((CS_stats_reply_MESSAGE_GENERIC*)statMsg)->values[i]),
+ cls);
}
mpos +=
strlen(&((char*)(((CS_stats_reply_MESSAGE_GENERIC*)statMsg)->values))[mpos])+1;
}
@@ -358,9 +358,9 @@
* @return OK on success, SYSERR on error
*/
int STATS_getAvailableProtocols(struct GE_Context * ectx,
- struct ClientServerConnection * sock,
- STATS_ProtocolProcessor processor,
- void * cls) {
+ struct ClientServerConnection * sock,
+ STATS_ProtocolProcessor processor,
+ void * cls) {
CS_stats_get_supported_MESSAGE csStatMsg;
unsigned short i;
unsigned short j;
@@ -377,17 +377,17 @@
for (i=0;i<65535;i++) {
csStatMsg.type = htons(i);
if (SYSERR == connection_write(sock,
- &csStatMsg.header))
- return SYSERR;
+ &csStatMsg.header))
+ return SYSERR;
if (SYSERR == connection_read_result(sock,
- &supported))
- return SYSERR;
- if (supported == YES) {
- ret = processor(i,
- (j == 2) ? YES : NO,
- cls);
- if (ret != OK)
- break;
+ &supported))
+ return SYSERR;
+ if (supported == YES) {
+ ret = processor(i,
+ (j == 2) ? YES : NO,
+ cls);
+ if (ret != OK)
+ break;
}
}
}
Modified: GNUnet/src/applications/stats/gnunet-stats.c
===================================================================
--- GNUnet/src/applications/stats/gnunet-stats.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/stats/gnunet-stats.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -43,30 +43,30 @@
* @return OK on success, SYSERR on error
*/
static int printStatistics(const char * name,
- unsigned long long value,
- void * cls) {
+ unsigned long long value,
+ void * cls) {
FILE * stream = cls;
FPRINTF(stream,
- "%-60s: %16llu\n",
- dgettext("GNUnet", name),
- value);
+ "%-60s: %16llu\n",
+ dgettext("GNUnet", name),
+ value);
return OK;
}
static int printProtocols(unsigned short type,
- int isP2P,
- void * cls) {
+ int isP2P,
+ void * cls) {
FILE * stream = cls;
const char *name = NULL;
if (isP2P != lastIp2p) {
if (isP2P)
fprintf(stream,
- _("Supported peer-to-peer messages:\n"));
+ _("Supported peer-to-peer messages:\n"));
else
fprintf(stream,
- _("Supported client-server messages:\n"));
+ _("Supported client-server messages:\n"));
lastIp2p = isP2P;
}
if (isP2P)
@@ -75,13 +75,13 @@
name = STATS_csMessageName(type);
if (name == NULL)
fprintf(stream,
- "\t%d\n",
- type);
+ "\t%d\n",
+ type);
else
fprintf(stream,
- "\t%d\t(%s)\n",
- type,
- name);
+ "\t%d\t(%s)\n",
+ type,
+ name);
return OK;
}
@@ -109,47 +109,47 @@
* @return 0 ok, 1 on error
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
int res;
struct ClientServerConnection * sock;
struct GC_Configuration * cfg;
struct GE_Context * ectx;
res = GNUNET_init(argc,
- argv,
- "gnunet-stats",
- &cfgFilename,
- gnunetstatsOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-stats",
+ &cfgFilename,
+ gnunetstatsOptions,
+ &ectx,
+ &cfg);
if (res == -1) {
GNUNET_fini(ectx, cfg);
return -1;
}
sock = client_connection_create(ectx,
- cfg);
+ cfg);
if (sock == NULL) {
fprintf(stderr,
- _("Error establishing connection with gnunetd.\n"));
+ _("Error establishing connection with gnunetd.\n"));
return 1;
}
res = STATS_getStatistics(ectx,
- sock,
- &printStatistics,
- stdout);
+ sock,
+ &printStatistics,
+ stdout);
if ( (YES == GC_get_configuration_value_yesno(cfg,
- "STATS",
- "PRINT-PROTOCOLS",
- NO)) &&
+ "STATS",
+ "PRINT-PROTOCOLS",
+ NO)) &&
(res == OK) ) {
res = STATS_getAvailableProtocols(ectx,
- sock,
- &printProtocols,
- stdout);
+ sock,
+ &printProtocols,
+ stdout);
}
if (res != OK)
fprintf(stderr,
- _("Error reading information from gnunetd.\n"));
+ _("Error reading information from gnunetd.\n"));
connection_destroy(sock);
GNUNET_fini(ectx, cfg);
Modified: GNUnet/src/applications/stats/sqstats.c
===================================================================
--- GNUnet/src/applications/stats/sqstats.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/stats/sqstats.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -50,8 +50,8 @@
};
static int iter(const HashCode512 * key,
- const Datastore_Value * value,
- void * cls) {
+ const Datastore_Value * value,
+ void * cls) {
struct CD * data = cls;
cron_t expire;
cron_t now;
@@ -124,22 +124,22 @@
int i;
memset(&data,
- 0,
- sizeof(struct CD));
+ 0,
+ sizeof(struct CD));
sq->iterateAllNow(&iter,
- &data);
+ &data);
for (i=0;i<8;i++)
stats->set(stat_block[i],
- data.stat_block[i]);
+ data.stat_block[i]);
for (i=0;i<5;i++)
stats->set(stat_expire[i],
- data.stat_expire[i]);
+ data.stat_expire[i]);
for (i=0;i<6;i++)
stats->set(stat_prio[i],
- data.stat_prio[i]);
+ data.stat_prio[i]);
for (i=0;i<3;i++)
stats->set(stat_anon[i],
- data.stat_anon[i]);
+ data.stat_anon[i]);
}
static int init_sqstore_stats() {
Modified: GNUnet/src/applications/stats/statistics.c
===================================================================
--- GNUnet/src/applications/stats/statistics.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/stats/statistics.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -111,7 +111,7 @@
* @param value to what the value should be set
*/
static void statSet(const int handle,
- const unsigned long long value) {
+ const unsigned long long value) {
MUTEX_LOCK(statLock);
if ( (handle < 0) ||
(handle >= statCounters) ) {
@@ -145,7 +145,7 @@
* @param delta by how much should the value be changed
*/
static void statChange(const int handle,
- const int delta) {
+ const int delta) {
MUTEX_LOCK(statLock);
if ( (handle < 0) ||
(handle >= statCounters) ) {
@@ -231,31 +231,31 @@
update_sqstore_stats();
#endif
load = os_cpu_get_load(coreAPI->ectx,
- coreAPI->cfg);
+ coreAPI->cfg);
if (load == -1)
load = 0;
statSet(stat_handle_cpu_load,
- load);
+ load);
load = os_disk_get_load(coreAPI->ectx,
- coreAPI->cfg);
+ coreAPI->cfg);
if (load == -1)
load = 0;
statSet(stat_handle_io_load,
- load);
+ load);
load = os_network_monitor_get_load(coreAPI->load_monitor,
- Upload);
+ Upload);
if (load == -1)
load = 0;
statSet(stat_handle_network_load_up,
- load);
+ load);
load = os_network_monitor_get_load(coreAPI->load_monitor,
- Download);
+ Download);
if (load == -1)
load = 0;
statSet(stat_handle_network_load_down,
- load);
+ load);
statSet(stat_connected,
- coreAPI->forAllConnectedNodes(NULL, NULL));
+ coreAPI->forAllConnectedNodes(NULL, NULL));
}
@@ -266,7 +266,7 @@
* @param originalRequestMessage ignored at this point.
*/
static int sendStatistics(struct ClientHandle * sock,
- const MESSAGE_HEADER * originalRequestMessage) {
+ const MESSAGE_HEADER * originalRequestMessage) {
CS_stats_reply_MESSAGE * statMsg;
int pos; /* position in the values-descriptions */
int start;
@@ -291,9 +291,9 @@
and their descriptions we can send in one message */
mpos = 0;
while ( (pos < statCounters) &&
- (mpos + sizeof(unsigned long long)
- + entries[pos].descStrLen + 1
- < MAX_BUFFER_SIZE - sizeof(CS_stats_reply_MESSAGE)) ) {
+ (mpos + sizeof(unsigned long long)
+ + entries[pos].descStrLen + 1
+ < MAX_BUFFER_SIZE - sizeof(CS_stats_reply_MESSAGE)) ) {
mpos += sizeof(unsigned long long); /* value */
mpos += entries[pos].descStrLen + 1;
pos++;
@@ -305,8 +305,8 @@
mpos = sizeof(unsigned long long) * (end - start);
for (pos=start;pos<end;pos++) {
memcpy(&((char*)(((CS_stats_reply_MESSAGE_GENERIC*)statMsg))->values)[mpos],
- entries[pos].description,
- entries[pos].descStrLen+1);
+ entries[pos].description,
+ entries[pos].descStrLen+1);
mpos += entries[pos].descStrLen+1;
}
statMsg->statCounters = htonl(end - start);
@@ -317,7 +317,7 @@
ntohs(statMsg->header.size),
start, end, statCounters);*/
if (SYSERR == coreAPI->sendToClient(sock,
- &statMsg->header))
+ &statMsg->header))
break; /* abort, socket error! */
start = end;
}
@@ -329,7 +329,7 @@
* Handle a request to see if a particular p2p message is supported.
*/
static int handleMessageSupported(struct ClientHandle * sock,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
unsigned short type;
unsigned short htype;
int supported;
@@ -355,7 +355,7 @@
* @returns OK if ok, SYSERR if not.
*/
static int processGetConnectionCountRequest(struct ClientHandle * client,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
if (ntohs(msg->size) != sizeof(MESSAGE_HEADER)) {
GE_BREAK(NULL, 0);
return SYSERR;
@@ -369,16 +369,16 @@
* Handler for processing noise.
*/
static int processNoise(const PeerIdentity * sender,
- const MESSAGE_HEADER * msg) {
+ const MESSAGE_HEADER * msg) {
statChange(stat_bytes_noise_received,
- ntohs(msg->size));
+ ntohs(msg->size));
return OK;
}
int initialize_module_stats(CoreAPIForApplication * capi) {
GE_ASSERT(capi->ectx,
- myCoreAPI == NULL);
+ myCoreAPI == NULL);
myCoreAPI = capi;
stats = capi->requestService("stats");
if (stats == NULL) {
@@ -388,29 +388,29 @@
}
initializeStats();
GE_LOG(capi->ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("`%s' registering client handlers %d %d %d and p2p handler %d\n"),
- "stats",
- CS_PROTO_traffic_COUNT,
- CS_PROTO_stats_GET_STATISTICS,
- CS_PROTO_stats_GET_P2P_MESSAGE_SUPPORTED,
- P2P_PROTO_noise);
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("`%s' registering client handlers %d %d %d and p2p handler %d\n"),
+ "stats",
+ CS_PROTO_traffic_COUNT,
+ CS_PROTO_stats_GET_STATISTICS,
+ CS_PROTO_stats_GET_P2P_MESSAGE_SUPPORTED,
+ P2P_PROTO_noise);
capi->registerClientHandler(CS_PROTO_stats_GET_STATISTICS,
- &sendStatistics);
+ &sendStatistics);
capi->registerClientHandler(CS_PROTO_stats_GET_P2P_MESSAGE_SUPPORTED,
- &handleMessageSupported);
+ &handleMessageSupported);
capi->registerClientHandler(CS_PROTO_stats_GET_CS_MESSAGE_SUPPORTED,
- &handleMessageSupported);
+ &handleMessageSupported);
capi->registerClientHandler(CS_PROTO_traffic_COUNT,
- &processGetConnectionCountRequest);
+ &processGetConnectionCountRequest);
capi->registerHandler(P2P_PROTO_noise,
- &processNoise);
+ &processNoise);
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "stats",
- gettext_noop("keeps
statistics about gnunetd's operation")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "stats",
+ gettext_noop("keeps statistics about
gnunetd's operation")));
#if HAVE_SQSTATS
init_sqstore_stats();
#endif
@@ -424,15 +424,15 @@
#endif
GE_ASSERT(NULL, myCoreAPI != NULL);
coreAPI->unregisterClientHandler(CS_PROTO_stats_GET_STATISTICS,
- &sendStatistics);
+ &sendStatistics);
coreAPI->unregisterClientHandler(CS_PROTO_stats_GET_P2P_MESSAGE_SUPPORTED,
- &handleMessageSupported);
+ &handleMessageSupported);
coreAPI->unregisterClientHandler(CS_PROTO_stats_GET_CS_MESSAGE_SUPPORTED,
- &handleMessageSupported);
+ &handleMessageSupported);
coreAPI->unregisterClientHandler(CS_PROTO_traffic_COUNT,
- &processGetConnectionCountRequest);
+ &processGetConnectionCountRequest);
coreAPI->unregisterHandler(P2P_PROTO_noise,
- &processNoise);
+ &processNoise);
myCoreAPI->releaseService(stats);
stats = NULL;
myCoreAPI = NULL;
Modified: GNUnet/src/applications/tbench/gnunet-tbench.c
===================================================================
--- GNUnet/src/applications/tbench/gnunet-tbench.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/tbench/gnunet-tbench.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -31,9 +31,9 @@
#include "gnunet_util_crypto.h"
#include "tbench.h"
-#define DEFAULT_MESSAGE_SIZE 10
-#define DEFAULT_TIMEOUT (2 * cronSECONDS)
-#define DEFAULT_SPACING 0
+#define DEFAULT_MESSAGE_SIZE 10
+#define DEFAULT_TIMEOUT (2 * cronSECONDS)
+#define DEFAULT_SPACING 0
#define OF_HUMAN_READABLE 0
#define OF_GNUPLOT_INPUT 1
@@ -101,7 +101,7 @@
* @return return value from gnunetsearch: 0: ok, -1: error
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
struct ClientServerConnection * sock;
CS_tbench_request_MESSAGE msg;
CS_tbench_reply_MESSAGE * buffer;
@@ -111,21 +111,21 @@
int res;
res = GNUNET_init(argc,
- argv,
- "gnunet-tbench",
- &cfgFilename,
- gnunettbenchOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-tbench",
+ &cfgFilename,
+ gnunettbenchOptions,
+ &ectx,
+ &cfg);
if (res == -1) {
GNUNET_fini(ectx, cfg);
return -1;
}
sock = client_connection_create(ectx,
- cfg);
+ cfg);
if (sock == NULL) {
fprintf(stderr,
- _("Error establishing connection with gnunetd.\n"));
+ _("Error establishing connection with gnunetd.\n"));
GNUNET_fini(ectx, cfg);
return 1;
}
@@ -141,16 +141,16 @@
msg.priority = htonl(5);
if (messageReceiver == NULL) {
fprintf(stderr,
- _("You must specify a receiver!\n"));
+ _("You must specify a receiver!\n"));
connection_destroy(sock);
GNUNET_fini(ectx, cfg);
return 1;
}
if (OK != enc2hash(messageReceiver,
- &msg.receiverId.hashPubKey)) {
+ &msg.receiverId.hashPubKey)) {
fprintf(stderr,
- _("Invalid receiver peer ID specified (`%s' is not valid name).\n"),
- messageReceiver);
+ _("Invalid receiver peer ID specified (`%s' is not valid name).\n"),
+ messageReceiver);
FREE(messageReceiver);
connection_destroy(sock);
GNUNET_fini(ectx, cfg);
@@ -159,7 +159,7 @@
FREE(messageReceiver);
if (SYSERR == connection_write(sock,
- &msg.header)) {
+ &msg.header)) {
connection_destroy(sock);
GNUNET_fini(ectx, cfg);
return -1;
@@ -167,10 +167,10 @@
buffer = NULL;
if (OK == connection_read(sock,
- (MESSAGE_HEADER**)&buffer)) {
+ (MESSAGE_HEADER**)&buffer)) {
GE_ASSERT(ectx,
- ntohs(buffer->header.size) ==
- sizeof(CS_tbench_reply_MESSAGE));
+ ntohs(buffer->header.size) ==
+ sizeof(CS_tbench_reply_MESSAGE));
if ((float)buffer->mean_loss < 0){
GE_BREAK(ectx, 0);
messagesPercentLoss = 0.0;
@@ -181,28 +181,28 @@
case OF_HUMAN_READABLE:
printf(_("Time:\n"));
PRINTF(_("\tmax %llums\n"),
- ntohll(buffer->max_time));
+ ntohll(buffer->max_time));
PRINTF(_("\tmin %llums\n"),
- ntohll(buffer->min_time));
+ ntohll(buffer->min_time));
printf(_("\tmean %8.4fms\n"),
- buffer->mean_time);
+ buffer->mean_time);
printf(_("\tvariance %8.4fms\n"),
- buffer->variance_time);
+ buffer->variance_time);
printf(_("Loss:\n"));
printf(_("\tmax %u\n"),
- ntohl(buffer->max_loss));
+ ntohl(buffer->max_loss));
printf(_("\tmin %u\n"),
- ntohl(buffer->min_loss));
+ ntohl(buffer->min_loss));
printf(_("\tmean %8.4f\n"),
- buffer->mean_loss);
+ buffer->mean_loss);
printf(_("\tvariance %8.4f\n"),
- buffer->variance_loss);
+ buffer->variance_loss);
break;
case OF_GNUPLOT_INPUT:
printf("%f %f\n",
- buffer->mean_time,
- 1.0-messagesPercentLoss);
+ buffer->mean_time,
+ 1.0-messagesPercentLoss);
break;
default:
printf(_("Output format not known, this should not happen.\n"));
Modified: GNUnet/src/applications/tbench/tbench.c
===================================================================
--- GNUnet/src/applications/tbench/tbench.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/tbench/tbench.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -89,14 +89,14 @@
* around and send it back.
*/
static int handleTBenchReq(const PeerIdentity * sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
MESSAGE_HEADER * reply;
const P2P_tbench_MESSAGE * msg;
#if DEBUG_TBENCH
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "Received tbench request\n");
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Received tbench request\n");
#endif
if ( ntohs(message->size) < sizeof(P2P_tbench_MESSAGE)) {
GE_BREAK(ectx, 0);
@@ -104,7 +104,7 @@
}
msg = (const P2P_tbench_MESSAGE*) message;
if (crc32N(&msg[1],
- ntohs(message->size) - sizeof(P2P_tbench_MESSAGE))
+ ntohs(message->size) - sizeof(P2P_tbench_MESSAGE))
!= ntohl(msg->crc)) {
GE_BREAK(ectx, 0);
return SYSERR;
@@ -112,21 +112,21 @@
#if DEBUG_TBENCH
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "Received request %u from iteration %u/%u\n",
- htonl(msg->packetNum),
- htonl(msg->iterationNum),
- htonl(msg->nounce));
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Received request %u from iteration %u/%u\n",
+ htonl(msg->packetNum),
+ htonl(msg->iterationNum),
+ htonl(msg->nounce));
#endif
reply = MALLOC(ntohs(message->size));
memcpy(reply,
- message,
- ntohs(message->size));
+ message,
+ ntohs(message->size));
reply->type = htons(P2P_PROTO_tbench_REPLY);
coreAPI->unicast(sender,
- reply,
- ntohl(msg->priority),
- 0); /* no delay */
+ reply,
+ ntohl(msg->priority),
+ 0); /* no delay */
FREE(reply);
return OK;
}
@@ -135,7 +135,7 @@
* We received a tbench-reply. Check and count stats.
*/
static int handleTBenchReply(const PeerIdentity * sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
const P2P_tbench_MESSAGE * pmsg;
unsigned int lastPacketNumber;
IterationData * res;
@@ -146,7 +146,7 @@
}
pmsg = (const P2P_tbench_MESSAGE*) message;
if (crc32N(&pmsg[1],
- ntohs(message->size) - sizeof(P2P_tbench_MESSAGE))
+ ntohs(message->size) - sizeof(P2P_tbench_MESSAGE))
!= ntohl(pmsg->crc)) {
GE_BREAK(ectx, 0);
return SYSERR;
@@ -160,29 +160,29 @@
lastPacketNumber = ntohl(pmsg->packetNum);
if (lastPacketNumber <= res->maxPacketNumber) {
if (0 == res->packetsReceived[lastPacketNumber]++) {
- res->lossCount--;
- if (res->lossCount == 0)
- earlyEnd = get_time();
+ res->lossCount--;
+ if (res->lossCount == 0)
+ earlyEnd = get_time();
} else {
- res->duplicateCount++;
+ res->duplicateCount++;
}
}
#if DEBUG_TBENCH
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "Received response %u from iteration %u/%u on time!\n",
- htonl(pmsg->packetNum),
- htonl(pmsg->iterationNum),
- htonl(pmsg->nounce));
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Received response %u from iteration %u/%u on time!\n",
+ htonl(pmsg->packetNum),
+ htonl(pmsg->iterationNum),
+ htonl(pmsg->nounce));
#endif
} else {
#if DEBUG_TBENCH
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "Received message %u from iteration %u too late (now at iteration
%u)\n",
- ntohl(pmsg->packetNum),
- ntohl(pmsg->iterationNum),
- currIteration);
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Received message %u from iteration %u too late (now at iteration %u)\n",
+ ntohl(pmsg->packetNum),
+ ntohl(pmsg->iterationNum),
+ currIteration);
#endif
}
MUTEX_UNLOCK(lock);
@@ -202,7 +202,7 @@
* Handle client request (main function)
*/
static int csHandleTBenchRequest(struct ClientHandle * client,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
CS_tbench_request_MESSAGE * msg;
CS_tbench_reply_MESSAGE reply;
P2P_tbench_MESSAGE * p2p;
@@ -226,11 +226,11 @@
#if DEBUG_TBENCH
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Tbench received request from client.\n",
- msgCnt,
- size,
- iterations);
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Tbench received request from client.\n",
+ msgCnt,
+ size,
+ iterations);
#endif
if ( ntohs(message->size) != sizeof(CS_tbench_request_MESSAGE) )
return SYSERR;
@@ -244,17 +244,17 @@
msgCnt = ntohl(msg->msgCnt);
#if DEBUG_TBENCH
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- "Tbench runs %u test messages of size %u in %u iterations.\n",
- msgCnt,
- size,
- iterations);
+ GE_INFO | GE_USER | GE_BULK,
+ "Tbench runs %u test messages of size %u in %u iterations.\n",
+ msgCnt,
+ size,
+ iterations);
#endif
MUTEX_LOCK(lock);
if (results != NULL) {
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_IMMEDIATE,
- "Cannot run multiple tbench sessions at the same time!\n");
+ GE_WARNING | GE_USER | GE_IMMEDIATE,
+ "Cannot run multiple tbench sessions at the same time!\n");
MUTEX_UNLOCK(lock);
return SYSERR;
}
@@ -262,8 +262,8 @@
p2p = MALLOC(size);
memset(p2p,
- 0,
- size);
+ 0,
+ size);
p2p->header.size = htons(size);
p2p->header.type = htons(P2P_PROTO_tbench_REQUEST);
p2p->priority = msg->priority;
@@ -272,8 +272,8 @@
results[iteration].maxPacketNumber = msgCnt;
results[iteration].packetsReceived = MALLOC(msgCnt);
memset(results[iteration].packetsReceived,
- 0,
- msgCnt);
+ 0,
+ msgCnt);
results[iteration].lossCount = msgCnt;
results[iteration].duplicateCount = 0;
@@ -286,11 +286,11 @@
p2p->iterationNum
= htonl(currIteration);
memset(&p2p[1],
- weak_randomi(256),
- size - sizeof(P2P_tbench_MESSAGE));
+ weak_randomi(256),
+ size - sizeof(P2P_tbench_MESSAGE));
p2p->crc
= htonl(crc32N(&p2p[1],
- size - sizeof(P2P_tbench_MESSAGE)));
+ size - sizeof(P2P_tbench_MESSAGE)));
MUTEX_UNLOCK(lock); /* allow receiving */
startTime = get_time();
@@ -298,29 +298,29 @@
timeoutOccured = NO;
cron_add_job(coreAPI->cron,
- &semaUp,
- ntohll(msg->timeOut) * cronMILLIS,
- 0,
- postsem);
+ &semaUp,
+ ntohll(msg->timeOut) * cronMILLIS,
+ 0,
+ postsem);
for (packetNum=0;packetNum<msgCnt;packetNum++){
now = get_time();
p2p->packetNum = htonl(packetNum);
#if DEBUG_TBENCH
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "Sending message %u of size %u in iteration %u\n",
- packetNum,
- size,
- iteration);
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Sending message %u of size %u in iteration %u\n",
+ packetNum,
+ size,
+ iteration);
#endif
coreAPI->unicast(&msg->receiverId,
- &p2p->header,
- ntohl(msg->priority),
- 0); /* no delay */
+ &p2p->header,
+ ntohl(msg->priority),
+ 0); /* no delay */
if ( (delay != 0) &&
- (htonl(msg->trainSize) != 0) &&
- (packetNum % htonl(msg->trainSize)) == 0)
- PTHREAD_SLEEP(delay);
+ (htonl(msg->trainSize) != 0) &&
+ (packetNum % htonl(msg->trainSize)) == 0)
+ PTHREAD_SLEEP(delay);
}
SEMAPHORE_DOWN(postsem, YES);
MUTEX_LOCK(lock);
@@ -336,11 +336,11 @@
FREE(p2p);
#if DEBUG_TBENCH
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "Done waiting for response.\n",
- packetNum,
- size,
- iteration);
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Done waiting for response.\n",
+ packetNum,
+ size,
+ iteration);
#endif
sum_loss = 0;
@@ -389,7 +389,7 @@
FREE(results);
results = NULL;
return coreAPI->sendToClient(client,
- &reply.header);
+ &reply.header);
}
/**
@@ -404,32 +404,32 @@
lock = MUTEX_CREATE(NO);
coreAPI = capi;
if (SYSERR == capi->registerHandler(P2P_PROTO_tbench_REPLY,
- &handleTBenchReply))
+ &handleTBenchReply))
ok = SYSERR;
if (SYSERR == capi->registerHandler(P2P_PROTO_tbench_REQUEST,
- &handleTBenchReq))
+ &handleTBenchReq))
ok = SYSERR;
if (SYSERR == capi->registerClientHandler(CS_PROTO_tbench_REQUEST,
- &csHandleTBenchRequest))
+ &csHandleTBenchRequest))
ok = SYSERR;
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "tbench",
- gettext_noop("allows
profiling of direct "
- "peer-to-peer
connections")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "tbench",
+ gettext_noop("allows profiling of
direct "
+ "peer-to-peer
connections")));
return ok;
}
void done_module_tbench() {
coreAPI->unregisterHandler(P2P_PROTO_tbench_REQUEST,
- &handleTBenchReq);
+ &handleTBenchReq);
coreAPI->unregisterHandler(P2P_PROTO_tbench_REPLY,
- &handleTBenchReply);
+ &handleTBenchReply);
coreAPI->unregisterClientHandler(CS_PROTO_tbench_REQUEST,
- &csHandleTBenchRequest);
+ &csHandleTBenchRequest);
MUTEX_DESTROY(lock);
lock = NULL;
coreAPI = NULL;
Modified: GNUnet/src/applications/tbench/tbenchtest.c
===================================================================
--- GNUnet/src/applications/tbench/tbenchtest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/tbench/tbenchtest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -39,21 +39,21 @@
static PeerIdentity peer2;
static int test(struct ClientServerConnection * sock,
- unsigned int messageSize,
- unsigned int messageCnt,
- unsigned int messageIterations,
- cron_t messageSpacing,
- unsigned int messageTrainSize,
- cron_t messageTimeOut /* in milli-seconds */) {
+ unsigned int messageSize,
+ unsigned int messageCnt,
+ unsigned int messageIterations,
+ cron_t messageSpacing,
+ unsigned int messageTrainSize,
+ cron_t messageTimeOut /* in milli-seconds */) {
int ret;
CS_tbench_request_MESSAGE msg;
CS_tbench_reply_MESSAGE * buffer;
float messagesPercentLoss;
printf(_("Using %u messages of size %u for %u times.\n"),
- messageCnt,
- messageSize,
- messageIterations);
+ messageCnt,
+ messageSize,
+ messageIterations);
msg.header.size = htons(sizeof(CS_tbench_request_MESSAGE));
msg.header.type = htons(CS_PROTO_tbench_REQUEST);
msg.msgSize = htonl(messageSize);
@@ -66,7 +66,7 @@
msg.receiverId = peer2;
if (SYSERR == connection_write(sock,
- &msg.header))
+ &msg.header))
return -1;
ret = 0;
@@ -78,15 +78,15 @@
messagesPercentLoss = (buffer->mean_loss/((float)htons(msg.msgCnt)));
}
printf(_("Times: max %16llu min %16llu mean %12.3f variance %12.3f\n"),
- ntohll(buffer->max_time),
- ntohll(buffer->min_time),
- buffer->mean_time,
- buffer->variance_time);
+ ntohll(buffer->max_time),
+ ntohll(buffer->min_time),
+ buffer->mean_time,
+ buffer->variance_time);
printf(_("Loss: max %16u min %16u mean %12.3f variance %12.3f\n"),
- ntohl(buffer->max_loss),
- ntohl(buffer->min_loss),
- buffer->mean_loss,
- buffer->variance_loss);
+ ntohl(buffer->max_loss),
+ ntohl(buffer->min_loss),
+ buffer->mean_loss,
+ buffer->variance_loss);
} else {
printf(_("\nFailed to receive reply from gnunetd.\n"));
ret = -1;
@@ -117,17 +117,17 @@
ok = 1;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
#if START_PEERS
peers = gnunet_testing_start_daemons(NULL == strstr(argv[0], "_udp") ? "tcp"
: "udp",
- "advertising tbench topology stats",
- "/tmp/gnunet-tbench-test",
- 2087,
- 10000,
- 2);
+ "advertising tbench topology stats",
+ "/tmp/gnunet-tbench-test",
+ 2087,
+ 10000,
+ 2);
if (peers == NULL) {
GC_free(cfg);
return -1;
@@ -136,15 +136,15 @@
peer1 = peers->peer;
peer2 = peers->next->peer;
if (OK != gnunet_testing_connect_daemons(2087,
- 12087)) {
+ 12087)) {
gnunet_testing_stop_daemons(peers);
fprintf(stderr,
- "Failed to connect the peers!\n");
+ "Failed to connect the peers!\n");
GC_free(cfg);
return -1;
}
sock = client_connection_create(NULL,
- cfg);
+ cfg);
printf(_("Running benchmark...\n"));
/* 'slow' pass: wait for bandwidth negotiation! */
if (ret == 0)
Modified: GNUnet/src/applications/template/gnunet-template.c
===================================================================
--- GNUnet/src/applications/template/gnunet-template.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/template/gnunet-template.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -53,7 +53,7 @@
buffer = MALLOC(MAX_BUFFER_SIZE);
while (OK == connection_read(sock,
- (MESSAGE_HEADER**)&buffer)) {
+ (MESSAGE_HEADER**)&buffer)) {
/* process */
}
FREE(buffer);
@@ -67,7 +67,7 @@
* @return return value from gnunet-template: 0: ok, -1: error
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
struct ClientServerConnection * sock;
struct PTHREAD * messageReceiveThread;
void * unused;
@@ -76,32 +76,32 @@
int i;
i = GNUNET_init(argc,
- argv,
- "gnunet-template",
- &cfgFilename,
- gnunettemplateOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-template",
+ &cfgFilename,
+ gnunettemplateOptions,
+ &ectx,
+ &cfg);
if (-1 == i) {
GNUNET_fini(ectx, cfg);
return -1;
}
sock = client_connection_create(ectx,
- cfg);
+ cfg);
if (sock == NULL) {
fprintf(stderr,
- _("Error establishing connection with gnunetd.\n"));
+ _("Error establishing connection with gnunetd.\n"));
GNUNET_fini(ectx, cfg);
return 1;
}
messageReceiveThread = PTHREAD_CREATE(&receiveThread,
- sock,
- 128 * 1024);
+ sock,
+ 128 * 1024);
if (messageReceiveThread == NULL) {
GE_DIE_STRERROR(ectx,
- GE_IMMEDIATE | GE_FATAL | GE_USER | GE_ADMIN,
- "pthread_create");
+ GE_IMMEDIATE | GE_FATAL | GE_USER | GE_ADMIN,
+ "pthread_create");
}
/* wait for shutdown... */
Modified: GNUnet/src/applications/template/template.c
===================================================================
--- GNUnet/src/applications/template/template.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/template/template.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -34,12 +34,12 @@
static struct MUTEX * lock;
static int handlep2pMSG(const PeerIdentity * sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
return OK;
}
static int csHandle(struct ClientHandle * client,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
return OK;
}
@@ -58,28 +58,28 @@
coreAPI = capi;
GE_LOG(capi->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _("`%s' registering client handler %d and %d\n"),
- "template",
- CS_PROTO_MAX_USED,
- P2P_PROTO_MAX_USED);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("`%s' registering client handler %d and %d\n"),
+ "template",
+ CS_PROTO_MAX_USED,
+ P2P_PROTO_MAX_USED);
if (SYSERR == capi->registerHandler(P2P_PROTO_MAX_USED,
- &handlep2pMSG))
+ &handlep2pMSG))
ok = SYSERR;
if (SYSERR == capi->registerClientExitHandler(&clientExitHandler))
ok = SYSERR;
if (SYSERR == capi->registerClientHandler(CS_PROTO_MAX_USED,
- &csHandle))
+ &csHandle))
ok = SYSERR;
return ok;
}
void done_module_template() {
coreAPI->unregisterHandler(P2P_PROTO_MAX_USED,
- &handlep2pMSG);
+ &handlep2pMSG);
coreAPI->unregisterClientExitHandler(&clientExitHandler);
coreAPI->unregisterClientHandler(CS_PROTO_MAX_USED,
- &csHandle);
+ &csHandle);
MUTEX_DESTROY(lock);
coreAPI = NULL;
}
Modified: GNUnet/src/applications/testbed/commands.c
===================================================================
--- GNUnet/src/applications/testbed/commands.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/testbed/commands.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -45,11 +45,11 @@
*/
typedef struct {
/** IP address of the peer */
- IPaddr ip;
+ IPaddr ip;
/** CS port of the peer */
unsigned short port;
/** string describing the peer address */
- char * ips;
+ char * ips;
/** socket to communicate with the peer */
struct ClientServerConnection sock;
/** hello message identifying the peer in the network */
@@ -79,23 +79,23 @@
* respectively. Aborts the method containing the macro with an error
* message if the peer-IDs are not within range.
*/
-#define CHECK_SRC_DST(s, d, ss, ds) \
- s = atoi(ss); \
- d = atoi(ds); \
+#define CHECK_SRC_DST(s, d, ss, ds) \
+ s = atoi(ss); \
+ d = atoi(ds); \
if (s < 0 || s >= nnodes || d < 0 || d >= nnodes) { \
XPRINTF("Invalid src (%s) or dst (%s)\n", ss, ds); \
- return -1; \
+ return -1; \
}
/**
* Convert the string ps to a peer-id p and abort the current method
* with an error message if ps is not a valid peer-id.
*/
-#define CHECK_PEER(p, ps) \
- p = atoi(ps); \
- if (p < 0 || p >= nnodes) { \
- XPRINTF("Invalid peer value %s\n", ps); \
- return -1; \
+#define CHECK_PEER(p, ps) \
+ p = atoi(ps); \
+ if (p < 0 || p >= nnodes) { \
+ XPRINTF("Invalid peer value %s\n", ps); \
+ return -1; \
}
/**
@@ -103,16 +103,16 @@
* the given size and data.
*/
static int sendMessage(unsigned msgType,
- int peer,
- unsigned short argSize,
- void *arg) {
+ int peer,
+ unsigned short argSize,
+ void *arg) {
TESTBED_CS_MESSAGE * msg;
int msgsz;
/* Assume peer value is valid. */
if (argSize + sizeof(TESTBED_CS_MESSAGE) > 65535)
errexit("Message body too big for sendMessage: %s\n",
- argSize);
+ argSize);
msgsz = sizeof(TESTBED_CS_MESSAGE)+argSize;
msg = MALLOC(msgsz);
@@ -123,14 +123,14 @@
msg->msgType
= htonl(msgType);
memcpy(&((TESTBED_CS_MESSAGE_GENERIC*)msg)->data[0],
- arg,
- argSize);
+ arg,
+ argSize);
msgsz = connection_write(&nodes[peer].sock,
- &msg->header);
+ &msg->header);
FREE(msg);
if (msgsz == SYSERR) {
XPRINTF(" Could not send message to peer %s.\n",
- nodes[peer].ips);
+ nodes[peer].ips);
return SYSERR;
}
return OK;
@@ -143,11 +143,11 @@
* @return OK on success, SYSERR on error
*/
static int readResult(int peer,
- int * result) {
+ int * result) {
if (OK != connection_read_result(&nodes[peer].sock,
- result)) {
+ result)) {
XPRINTF(" peer %s is not responding.\n",
- nodes[peer].ips);
+ nodes[peer].ips);
return SYSERR;
}
return OK;
@@ -174,8 +174,8 @@
port = atoi(argv[1]);
for (i=0;i<nnodes;i++) {
if ( (0 == strcmp(argv[0],
- nodes[i].ips)) &&
- (port == nodes[i].port) ) {
+ nodes[i].ips)) &&
+ (port == nodes[i].port) ) {
XPRINTF("Node already in use!\n");
return -1;
}
@@ -197,33 +197,33 @@
#endif
if (SYSERR == initGNUnetClientSocket(nodes[currindex].port,
- nodes[currindex].ips,
- &nodes[currindex].sock)) {
+ nodes[currindex].ips,
+ &nodes[currindex].sock)) {
XPRINTF(" could not connect to %s:%d.\n",
- nodes[currindex].ips,
- nodes[currindex].port);
+ nodes[currindex].ips,
+ nodes[currindex].port);
return -1;
}
/* request hello */
if (OK != sendMessage(TESTBED_GET_hello,
- currindex,
-
sizeof(TESTBED_GET_hello_MESSAGE)-sizeof(TESTBED_CS_MESSAGE),
- &req.proto)) {
+ currindex,
+ sizeof(TESTBED_GET_hello_MESSAGE)-sizeof(TESTBED_CS_MESSAGE),
+ &req.proto)) {
/* send message already printed an error message */
destroySocket(&nodes[currindex].sock);
FREE(nodes[currindex].ips);
GROW(nodes,
- nnodes,
- nnodes-1);
+ nnodes,
+ nnodes-1);
return -1;
}
hdr = NULL;
if (SYSERR == connection_read(&nodes[currindex].sock,
- (CS_MESSAGE_HEADER**)&hdr)) {
+ (CS_MESSAGE_HEADER**)&hdr)) {
XPRINTF(" peer %s is not responding.\n",
- nodes[currindex].ips);
+ nodes[currindex].ips);
destroySocket(&nodes[currindex].sock);
FREE(nodes[currindex].ips);
GROW(nodes, nnodes, nnodes-1);
@@ -237,20 +237,20 @@
nodes[currindex].helo
= MALLOC(P2P_hello_MESSAGE_size(&hdr->helo));
memcpy(nodes[currindex].helo,
- &hdr->helo,
- P2P_hello_MESSAGE_size(&hdr->helo));
+ &hdr->helo,
+ P2P_hello_MESSAGE_size(&hdr->helo));
} else {
FREE(hdr);
destroySocket(&nodes[currindex].sock);
XPRINTF(" peer %s did not respond with proper hello.\n",
- nodes[currindex].ips);
+ nodes[currindex].ips);
FREE(nodes[currindex].ips);
GROW(nodes, nnodes, nnodes-1);
return -1;
}
FREE(hdr);
XPRINTF("%d\n",
- currindex);
+ currindex);
return 0;
}
@@ -280,8 +280,8 @@
port = atoi(argv[2]);
for (i=0;i<nnodes;i++) {
if ( (0 == strcmp(argv[1],
- nodes[i].ips)) &&
- (port == nodes[i].port) ) {
+ nodes[i].ips)) &&
+ (port == nodes[i].port) ) {
XPRINTF("Node already in use!\n");
return -1;
}
@@ -296,17 +296,17 @@
s = SOCKET(PF_INET, SOCK_STREAM, 0);
if (s == -1) {
XPRINTF("Cannot open socket: %s\n",
- STRERROR(errno));
+ STRERROR(errno));
return -1;
}
if ( SETSOCKOPT(s,
- SOL_SOCKET,
- SO_REUSEADDR,
- &on, sizeof(on)) < 0 )
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ &on, sizeof(on)) < 0 )
perror("setsockopt");
memset(&addr,
- 0,
- sizeof(addr));
+ 0,
+ sizeof(addr));
addr.sin_family
= AF_INET;
addr.sin_addr.s_addr
@@ -314,8 +314,8 @@
addr.sin_port
= htons(lport);
if (0 == BIND(s,
- (const struct sockaddr *) &addr,
- sizeof(struct sockaddr_in))) {
+ (const struct sockaddr *) &addr,
+ sizeof(struct sockaddr_in))) {
closefile(s);
break; /* found port! */
} else {
@@ -336,24 +336,24 @@
sargv[2] = argv[0]; /* login */
sargv[3] = "-L";
SNPRINTF(pohopo,
- 64,
- "%d:%s:%d",
- lport, /* local port */
- "localhost", /* loopback on remote host */
- port /* remote port */);
+ 64,
+ "%d:%s:%d",
+ lport, /* local port */
+ "localhost", /* loopback on remote host */
+ port /* remote port */);
sargv[4] = pohopo;
sargv[5] = argv[1]; /* remote hostname */
sargv[6] = NULL; /* last argument */
execvp("ssh",
- sargv);
+ sargv);
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- " execvp failed: %s\n",
- STRERROR(errno));
+ " execvp failed: %s\n",
+ STRERROR(errno));
exit(-1);
}
if (pid == -1) {
XPRINTF("Failed to fork: %s\n",
- STRERROR(errno));
+ STRERROR(errno));
return -1;
}
@@ -376,8 +376,8 @@
rtc = 0; /* number of retries */
while (rtc < 5) {
ret = initGNUnetClientSocket(nodes[currindex].port,
- nodes[currindex].ips,
- &nodes[currindex].sock);
+ nodes[currindex].ips,
+ &nodes[currindex].sock);
if (ret == OK)
break;
rtc++;
@@ -385,50 +385,50 @@
}
if (ret == SYSERR) {
XPRINTF(" could not connect to %s:%d.\n",
- nodes[currindex].ips,
- nodes[currindex].port);
+ nodes[currindex].ips,
+ nodes[currindex].port);
kill(nodes[currindex].ssh,
- SIGTERM);
+ SIGTERM);
waitpid(nodes[currindex].ssh,
- &status,
- 0);
+ &status,
+ 0);
GROW(nodes, nnodes, nnodes-1);
return -1;
}
/* request hello */
if (OK != sendMessage(TESTBED_GET_hello,
- currindex,
-
sizeof(TESTBED_GET_hello_MESSAGE)-sizeof(TESTBED_CS_MESSAGE),
- &req.proto)) {
+ currindex,
+ sizeof(TESTBED_GET_hello_MESSAGE)-sizeof(TESTBED_CS_MESSAGE),
+ &req.proto)) {
/* send message already printed an error message */
destroySocket(&nodes[currindex].sock);
FREE(nodes[currindex].ips);
/* fixme: check error conditions on kill/waidpid! */
kill(nodes[currindex].ssh,
- SIGTERM);
+ SIGTERM);
waitpid(nodes[currindex].ssh,
- &status,
- 0);
+ &status,
+ 0);
GROW(nodes,
- nnodes,
- nnodes-1);
+ nnodes,
+ nnodes-1);
return -1;
}
hdr = NULL;
if (SYSERR == connection_read(&nodes[currindex].sock,
- (CS_MESSAGE_HEADER**)&hdr)) {
+ (CS_MESSAGE_HEADER**)&hdr)) {
XPRINTF(" peer %s is not responding.\n",
- nodes[currindex].ips);
+ nodes[currindex].ips);
destroySocket(&nodes[currindex].sock);
FREE(nodes[currindex].ips);
/* fixme: check error conditions on kill/waidpid! */
kill(nodes[currindex].ssh,
- SIGTERM);
+ SIGTERM);
waitpid(nodes[currindex].ssh,
- &status,
- 0);
+ &status,
+ 0);
GROW(nodes, nnodes, nnodes-1);
return -1;
}
@@ -440,26 +440,26 @@
nodes[currindex].helo
= MALLOC(P2P_hello_MESSAGE_size(&hdr->helo));
memcpy(nodes[currindex].helo,
- &hdr->helo,
- P2P_hello_MESSAGE_size(&hdr->helo));
+ &hdr->helo,
+ P2P_hello_MESSAGE_size(&hdr->helo));
} else {
FREE(hdr);
destroySocket(&nodes[currindex].sock);
XPRINTF(" peer %s did not respond with proper hello.\n",
- nodes[currindex].ips);
+ nodes[currindex].ips);
FREE(nodes[currindex].ips);
/* fixme: check error conditions on kill/waidpid! */
kill(nodes[currindex].ssh,
- SIGTERM);
+ SIGTERM);
waitpid(nodes[currindex].ssh,
- &status,
- 0);
+ &status,
+ 0);
GROW(nodes, nnodes, nnodes-1);
return -1;
}
FREE(hdr);
XPRINTF("%d\n",
- currindex);
+ currindex);
return 0;
}
@@ -468,7 +468,7 @@
* Tear down the connection between two peers.
*/
static int delConnection(int argc,
- char * argv[]) {
+ char * argv[]) {
int src, dst, ack;
if (argc != 2) {
@@ -477,12 +477,12 @@
}
CHECK_SRC_DST(src, dst, argv[0], argv[1]);
if (OK != sendMessage(TESTBED_DEL_PEER,
- src,
- sizeof(PeerIdentity),
- &nodes[dst].helo->senderIdentity))
+ src,
+ sizeof(PeerIdentity),
+ &nodes[dst].helo->senderIdentity))
return -1;
if (OK != readResult(src,
- &ack))
+ &ack))
return -1;
if (ack == OK) {
XPRINTF("OK.\n");
@@ -497,7 +497,7 @@
* Tear down all connections of a peer.
*/
static int delAllConnections(int argc,
- char * argv[]) {
+ char * argv[]) {
int dst, ack;
if (argc != 1) {
@@ -506,12 +506,12 @@
}
CHECK_PEER(dst, argv[0]);
if (OK != sendMessage(TESTBED_DEL_ALL_PEERS,
- dst,
- 0,
- NULL))
+ dst,
+ 0,
+ NULL))
return -1;
if (OK != readResult(dst,
- &ack))
+ &ack))
return -1;
if (ack == OK) {
XPRINTF("OK.\n");
@@ -526,7 +526,7 @@
* Add a connection between two peers.
*/
static int addConnection(int argc,
- char * argv[]) {
+ char * argv[]) {
int src, dst, ack;
if (argc != 2) {
@@ -535,12 +535,12 @@
}
CHECK_SRC_DST(src, dst, argv[0], argv[1]);
if (SYSERR == sendMessage(TESTBED_ADD_PEER,
- src,
- P2P_hello_MESSAGE_size(nodes[dst].helo),
- nodes[dst].helo))
+ src,
+ P2P_hello_MESSAGE_size(nodes[dst].helo),
+ nodes[dst].helo))
return -1;
if (OK != readResult(src,
- &ack))
+ &ack))
return -1;
if (ack == OK) {
XPRINTF("OK.\n");
@@ -567,15 +567,15 @@
value = atoi(argv[2]);
msg.trust = htonl(value);
memcpy(&msg.otherPeer,
- &nodes[dst].helo->senderIdentity,
- sizeof(PeerIdentity));
+ &nodes[dst].helo->senderIdentity,
+ sizeof(PeerIdentity));
if (SYSERR == sendMessage(TESTBED_SET_TVALUE,
- src,
- sizeof(PeerIdentity)+sizeof(unsigned int),
- &msg.otherPeer))
+ src,
+ sizeof(PeerIdentity)+sizeof(unsigned int),
+ &msg.otherPeer))
return -1;
if (OK != readResult(src,
- &ack))
+ &ack))
return -1;
if (htonl(ack) != OK) {
XPRINTF(" peer could not set trust value.\n");
@@ -598,9 +598,9 @@
}
CHECK_SRC_DST(src, dst, argv[0], argv[1]);
if (SYSERR == sendMessage(TESTBED_GET_TVALUE,
- src,
- sizeof(PeerIdentity),
- &nodes[dst].helo->senderIdentity))
+ src,
+ sizeof(PeerIdentity),
+ &nodes[dst].helo->senderIdentity))
return -1;
if (SYSERR == readResult(src, &value))
return -1;
@@ -609,7 +609,7 @@
return -1;
} else {
XPRINTF("%d\n",
- value);
+ value);
return 0;
}
}
@@ -626,9 +626,9 @@
}
CHECK_PEER(dst, argv[0]);
if (SYSERR == sendMessage(TESTBED_DISABLE_hello,
- dst,
- 0,
- NULL))
+ dst,
+ 0,
+ NULL))
return -1;
if (SYSERR == readResult(dst, &value))
return -1;
@@ -653,9 +653,9 @@
}
CHECK_PEER(dst, argv[0]);
if (SYSERR == sendMessage(TESTBED_ENABLE_hello,
- dst,
- 0,
- NULL))
+ dst,
+ 0,
+ NULL))
return -1;
if (SYSERR == readResult(dst, &value))
return -1;
@@ -680,9 +680,9 @@
}
CHECK_PEER(dst, argv[0]);
if (SYSERR == sendMessage(TESTBED_DISABLE_AUTOCONNECT,
- dst,
- 0,
- NULL))
+ dst,
+ 0,
+ NULL))
return -1;
if (SYSERR == readResult(dst, &value))
return -1;
@@ -707,9 +707,9 @@
}
CHECK_PEER(dst, argv[0]);
if (SYSERR == sendMessage(TESTBED_ENABLE_AUTOCONNECT,
- dst,
- 0,
- NULL))
+ dst,
+ 0,
+ NULL))
return -1;
if (SYSERR == readResult(dst, &value))
return -1;
@@ -724,8 +724,8 @@
static int allowDenyConnectHelper(unsigned int argc,
- char * argv[],
- int type) {
+ char * argv[],
+ int type) {
int dst, value;
PeerIdentity * list;
int i;
@@ -745,13 +745,13 @@
for (i=1;i<argc;i++) {
CHECK_PEER(idx, argv[i]);
memcpy(&list[i-1],
- &nodes[idx].helo->senderIdentity,
- sizeof(PeerIdentity));
+ &nodes[idx].helo->senderIdentity,
+ sizeof(PeerIdentity));
}
if (SYSERR == sendMessage(type,
- dst,
- sizeof(PeerIdentity)*(argc-1),
- list)) {
+ dst,
+ sizeof(PeerIdentity)*(argc-1),
+ list)) {
FREENONNULL(list);
return -1;
}
@@ -776,7 +776,7 @@
return -1;
}
return allowDenyConnectHelper(argc, argv,
- TESTBED_DENY_CONNECT);
+ TESTBED_DENY_CONNECT);
}
/**
@@ -788,7 +788,7 @@
return -1;
}
return allowDenyConnectHelper(argc, argv,
- TESTBED_ALLOW_CONNECT);
+ TESTBED_ALLOW_CONNECT);
}
/**
@@ -796,22 +796,22 @@
* @param type load or unload requested?
*/
static int loadModuleHelper(unsigned short type,
- char * peerId,
- char * modulename) {
+ char * peerId,
+ char * modulename) {
int ok, dst;
CHECK_PEER(dst, peerId);
if (OK != sendMessage(type,
- dst,
- strlen(modulename),
- modulename))
+ dst,
+ strlen(modulename),
+ modulename))
return -1;
if (OK != readResult(dst,
- &ok))
+ &ok))
return -1;
if (ok != OK) {
XPRINTF(" peer %s refused.\n",
- nodes[dst].ips);
+ nodes[dst].ips);
return -1;
}
XPRINTF("OK.\n");
@@ -827,8 +827,8 @@
return -1;
}
return loadModuleHelper(TESTBED_LOAD_MODULE,
- argv[0],
- argv[1]);
+ argv[0],
+ argv[1]);
}
/**
@@ -840,8 +840,8 @@
return -1;
}
return loadModuleHelper(TESTBED_UNLOAD_MODULE,
- argv[0],
- argv[1]);
+ argv[0],
+ argv[1]);
}
/**
@@ -850,7 +850,7 @@
* using process-signal. The process identifier is printed.
*/
static int startProcess(int argc,
- char *argv[]) {
+ char *argv[]) {
char * cmdLine;
int size;
int i;
@@ -870,25 +870,25 @@
pos = 0;
for (i=1;i<argc;i++) {
memcpy(&cmdLine[pos],
- argv[i],
- strlen(argv[i])+1);
+ argv[i],
+ strlen(argv[i])+1);
pos += strlen(argv[i])+1;
}
if (OK != sendMessage(TESTBED_EXEC,
- dst,
- size,
- cmdLine)) {
+ dst,
+ size,
+ cmdLine)) {
FREE(cmdLine);
return -1;
}
FREE(cmdLine);
if (OK != readResult(dst,
- &ack))
+ &ack))
return -1;
if (ack != SYSERR) {
XPRINTF("%d\n",
- ack);
+ ack);
return 0;
} else {
XPRINTF(" Peer could not fork process.\n");
@@ -919,12 +919,12 @@
msg.pid = htonl(atoi(argv[1]));
msg.signal = htonl(atoi(argv[2]));
if (OK != sendMessage(TESTBED_SIGNAL,
- dst,
- sizeof(TESTBED_SIGNAL_MESSAGE) -
sizeof(TESTBED_CS_MESSAGE),
- &msg.pid))
+ dst,
+ sizeof(TESTBED_SIGNAL_MESSAGE) - sizeof(TESTBED_CS_MESSAGE),
+ &msg.pid))
return -1;
if (OK != readResult(dst,
- &ack))
+ &ack))
return -1;
if (ntohl(msg.signal) == -1) {
XPRINTF("%d\n", ack);
@@ -943,7 +943,7 @@
* Get the recorded output of a process.
*/
static int dumpProcessOutput(int argc,
- char * argv[]) {
+ char * argv[]) {
int dst;
int pid;
unsigned int ack;
@@ -955,12 +955,12 @@
CHECK_PEER(dst, argv[0]);
pid = htonl(atoi(argv[1]));
if (OK != sendMessage(TESTBED_GET_OUTPUT,
- dst,
- sizeof(int),
- &pid))
+ dst,
+ sizeof(int),
+ &pid))
return -1;
if (OK != readResult(dst,
- (int*) &ack))
+ (int*) &ack))
return -1;
if (ack != SYSERR) {
char * tmp;
@@ -971,22 +971,22 @@
reply = NULL;
if (SYSERR == connection_read(&nodes[dst].sock,
- (CS_MESSAGE_HEADER**)&reply)) {
- XPRINTF(" peer %s is not responding after %d of %d bytes.\n",
- nodes[dst].ips,
- pos,
- ack);
- return -1;
+ (CS_MESSAGE_HEADER**)&reply)) {
+ XPRINTF(" peer %s is not responding after %d of %d bytes.\n",
+ nodes[dst].ips,
+ pos,
+ ack);
+ return -1;
}
/* FIXME: check that this is the correct reply format */
size = ntohs(reply->header.header.size) -
sizeof(TESTBED_OUTPUT_REPLY_MESSAGE);
tmp = MALLOC(size+1);
memcpy(tmp,
- &((TESTBED_OUTPUT_REPLY_MESSAGE_GENERIC*)reply)->data[0],
- size);
+ &((TESTBED_OUTPUT_REPLY_MESSAGE_GENERIC*)reply)->data[0],
+ size);
tmp[size] = '\0';
XPRINTF("%s",
- tmp);
+ tmp);
FREE(tmp);
FREE(reply);
pos += size;
@@ -1019,9 +1019,9 @@
msg.in_bw = htonl(in);
msg.out_bw = htonl(out);
if (SYSERR == sendMessage(TESTBED_SET_BW,
- dst,
- sizeof(TESTBED_SET_BW_MESSAGE) -
sizeof(TESTBED_CS_MESSAGE),
- &msg.in_bw))
+ dst,
+ sizeof(TESTBED_SET_BW_MESSAGE) - sizeof(TESTBED_CS_MESSAGE),
+ &msg.in_bw))
return -1;
if (OK != readResult(dst, &ack))
return -1;
@@ -1053,9 +1053,9 @@
= htonl(atoi(argv[2]));
if (SYSERR == sendMessage(TESTBED_SET_LOSS_RATE,
- dst,
- sizeof(TESTBED_SET_LOSS_RATE_MESSAGE) -
sizeof(TESTBED_CS_MESSAGE),
- &msg.percentageLossInbound))
+ dst,
+ sizeof(TESTBED_SET_LOSS_RATE_MESSAGE) -
sizeof(TESTBED_CS_MESSAGE),
+ &msg.percentageLossInbound))
return -1;
if (OK != readResult(dst, &ack))
return -1;
@@ -1069,12 +1069,12 @@
}
static int printStatistic(const char * name,
- unsigned long long value,
- const char * arg) {
+ unsigned long long value,
+ const char * arg) {
if (0 == strcmp(name,
- arg))
+ arg))
XPRINTF("%llu\n",
- value);
+ value);
return OK;
}
@@ -1095,8 +1095,8 @@
}
CHECK_PEER(peer, argv[0]);
res = requestStatistics(&nodes[peer].sock,
- (StatisticsProcessor) &printStatistic,
- argv[1]);
+ (StatisticsProcessor) &printStatistic,
+ argv[1]);
if (res == OK)
return 0;
else
@@ -1110,19 +1110,19 @@
* @return OK on success, SYSERR on error
*/
static int printStatistics(const char * name,
- unsigned long long value,
- void * unused) {
+ unsigned long long value,
+ void * unused) {
XPRINTF("%-60s: %16llu\n",
- name,
- value);
+ name,
+ value);
return OK;
}
static int lastIp2p;
static int printProtocols(unsigned short type,
- int isP2P,
- void * unused) {
+ int isP2P,
+ void * unused) {
const char *name = NULL;
if (isP2P != lastIp2p) {
@@ -1138,11 +1138,11 @@
name = csMessageName(type);
if (name == NULL)
XPRINTF("\t%d\n",
- type);
+ type);
else
XPRINTF("\t%d\t(%s)\n",
- type,
- name);
+ type,
+ name);
return OK;
}
@@ -1170,14 +1170,14 @@
} else
CHECK_PEER(peer, argv[0]);
res = requestStatistics(&nodes[peer].sock,
- (StatisticsProcessor) &printStatistics,
- NULL);
+ (StatisticsProcessor) &printStatistics,
+ NULL);
if ( (printProtocolsOpt == YES) &&
(res == OK)) {
lastIp2p = 42; /* not YES or NO */
res = requestAvailableProtocols(&nodes[peer].sock,
- (ProtocolProcessor) &printProtocols,
- NULL);
+ (ProtocolProcessor) &printProtocols,
+ NULL);
}
if (res == OK)
return 0;
@@ -1203,15 +1203,15 @@
}
CHECK_PEER(peer, argv[0]);
opt = getConfigurationOptionValue(&nodes[peer].sock,
- argv[1],
- argv[2]);
+ argv[1],
+ argv[2]);
if (opt == NULL) {
XPRINTF("Error sending request to peer %d\n",
- peer);
+ peer);
return -1;
}
XPRINTF("%s\n",
- opt);
+ opt);
FREE(opt);
return 0;
}
@@ -1221,7 +1221,7 @@
* Upload a file to a peer.
*/
static int uploadFile(int argc,
- char *argv[]) {
+ char *argv[]) {
int peer, nbytes, flen, ack;
char * buf;
FILE * infile;
@@ -1235,14 +1235,14 @@
infile = FOPEN(argv[1], "r");
if (infile == NULL) {
XPRINTF(" Could not open file %s\n",
- argv[1]);
+ argv[1]);
return -1;
}
flen = strlen(argv[2]) + 1; /* '\0' added in the flen */
if (flen > TESTBED_FILE_BLK_SIZE) {
XPRINTF(" destination file name too long (%d characters, limit %d).\n",
- flen-1,
- TESTBED_FILE_BLK_SIZE);
+ flen-1,
+ TESTBED_FILE_BLK_SIZE);
return -1;
}
@@ -1258,11 +1258,11 @@
memcpy(((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC*)msg)->buf, argv[2], flen);
if (SYSERR == connection_write(&nodes[peer].sock,
- &msg->header.header)) {
+ &msg->header.header)) {
fclose(infile);
FREE(msg);
XPRINTF(" Could not send message to peer %s.\n",
- nodes[peer].ips);
+ nodes[peer].ips);
return -1;
}
/* Read ack from the peer */
@@ -1281,18 +1281,18 @@
msg->type = htonl(TESTBED_FILE_APPEND);
buf = ((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC*)msg)->buf + flen;
while ((nbytes = GN_FREAD(buf, 1,
- (TESTBED_FILE_BLK_SIZE -
- sizeof(TESTBED_UPLOAD_FILE_MESSAGE) - flen),
- infile)) > 0) {
+ (TESTBED_FILE_BLK_SIZE -
+ sizeof(TESTBED_UPLOAD_FILE_MESSAGE) - flen),
+ infile)) > 0) {
if (ferror(infile))
break;
msg->header.header.size = htons(sizeof(TESTBED_UPLOAD_FILE_MESSAGE) +
- nbytes + flen);
+ nbytes + flen);
if (SYSERR == connection_write(&nodes[peer].sock, &msg->header.header)) {
fclose(infile);
FREE(msg);
XPRINTF(" could not send file to node %s.\n",
- nodes[peer].ips);
+ nodes[peer].ips);
return -1;
}
if (OK != readResult(peer, &ack)) {
@@ -1323,20 +1323,20 @@
* Print the list of commands.
*/
static int printOnlineHelp(int argc,
- char * argv[]) {
+ char * argv[]) {
int i;
i = 0;
while (commands[i].command != NULL) {
XPRINTF("%-30s%s\n",
- commands[i].command,
- commands[i].help);
+ commands[i].command,
+ commands[i].help);
i++;
}
return 0;
}
static int processCommands(char * buffer,
- unsigned int * available) {
+ unsigned int * available) {
int ip[4];
int port;
unsigned int end;
@@ -1349,81 +1349,81 @@
start = 0;
while (end < *available) {
while ( (buffer[end] != '\n') &&
- (end < *available) )
+ (end < *available) )
end++;
if (buffer[end] != '\n') {
if (start == 0) {
- XPRINTF("Received invalid response from HTTP server!\n");
- return -1;
+ XPRINTF("Received invalid response from HTTP server!\n");
+ return -1;
} else {
- memmove(buffer,
- &buffer[start],
- *available - start);
- *available -= start;
- return 0;
+ memmove(buffer,
+ &buffer[start],
+ *available - start);
+ *available -= start;
+ return 0;
}
}
up = MALLOC(end-start+1);
memcpy(up,
- &buffer[start],
- end - start);
+ &buffer[start],
+ end - start);
up[end-start] = '\0';
port = 2087; /* default port */
if (4 <= sscanf(up,
- "add-node %d %d %d %d %d",
- &ip[0],
- &ip[1],
- &ip[2],
- &ip[3],
- &port)) {
+ "add-node %d %d %d %d %d",
+ &ip[0],
+ &ip[1],
+ &ip[2],
+ &ip[3],
+ &port)) {
char ports[12];
char ips[128];
char * argv[2];
SNPRINTF(ports,
- 12,
- "%d",
- port);
+ 12,
+ "%d",
+ port);
SNPRINTF(ips,
- 128,
- "%u.%u.%u.%u",
- ip[0],
- ip[1],
- ip[2],
- ip[3]);
+ 128,
+ "%u.%u.%u.%u",
+ ip[0],
+ ip[1],
+ ip[2],
+ ip[3]);
argv[0] = ips;
argv[1] = ports;
if (0 != addNode(2, argv))
- err = 2;
+ err = 2;
} else {
char * login;
login = MALLOC(64);
if (5 <= sscanf(up,
- "add-node %63s %d %d %d %d %d",
- login,
- &ip[0],
- &ip[1],
- &ip[2],
- &ip[3],
- &port)) {
- char ports[12];
- char ips[128];
- char * argv[3];
- SNPRINTF(ports,
- 12,
- "%d",
- port);
- SNPRINTF(ips,
- 128,
- "%u.%u.%u.%u",
- ip[0],
- ip[1],
- ip[2],
- ip[3]);
- argv[0] = login;
- argv[1] = ips;
- argv[2] = ports;
- if (0 != addSshNode(3, argv))
- err = 2;
+ "add-node %63s %d %d %d %d %d",
+ login,
+ &ip[0],
+ &ip[1],
+ &ip[2],
+ &ip[3],
+ &port)) {
+ char ports[12];
+ char ips[128];
+ char * argv[3];
+ SNPRINTF(ports,
+ 12,
+ "%d",
+ port);
+ SNPRINTF(ips,
+ 128,
+ "%u.%u.%u.%u",
+ ip[0],
+ ip[1],
+ ip[2],
+ ip[3]);
+ argv[0] = login;
+ argv[1] = ips;
+ argv[2] = ports;
+ if (0 != addSshNode(3, argv))
+ err = 2;
}
FREE(login);
}
@@ -1445,7 +1445,7 @@
* value from the configuration file value).
*/
static int addAvailable(int argc,
- char * argv[]) {
+ char * argv[]) {
char * reg = NULL;
long int port;
char * hostname;
@@ -1467,7 +1467,7 @@
if (argc == 0) {
reg = getConfigurationString("GNUNET-TESTBED",
- "REGISTERURL");
+ "REGISTERURL");
if (reg == NULL) {
XPRINTF(" no testbed registration URL given.\n");
return -1;
@@ -1478,24 +1478,24 @@
proxy = getConfigurationString("GNUNETD",
- "HTTP-PROXY");
+ "HTTP-PROXY");
if (proxy != NULL) {
if (OK != get_host_by_name(ectx, proxy,
- &ip)) {
+ &ip)) {
XPRINTF(" Couldn't resolve name of HTTP proxy '%s'\n",
- proxy);
+ proxy);
theProxy.sin_addr.s_addr = 0;
} else {
memcpy(&theProxy.sin_addr.s_addr,
- &ip,
- sizeof(IPaddr));
+ &ip,
+ sizeof(IPaddr));
proxyPort = getConfigurationString("GNUNETD",
- "HTTP-PROXY-PORT");
+ "HTTP-PROXY-PORT");
if (proxyPort == NULL) {
- theProxy.sin_port = htons(8080);
+ theProxy.sin_port = htons(8080);
} else {
- theProxy.sin_port = htons(atoi(proxyPort));
- FREE(proxyPort);
+ theProxy.sin_port = htons(atoi(proxyPort));
+ FREE(proxyPort);
}
}
FREE(proxy);
@@ -1504,11 +1504,11 @@
}
if (0 != strncmp(HTTP_URL,
- reg,
- strlen(HTTP_URL)) ) {
+ reg,
+ strlen(HTTP_URL)) ) {
XPRINTF(" invalid URL %s (must begin with %s)\n",
- reg,
- HTTP_URL);
+ reg,
+ HTTP_URL);
return -1;
}
port = 80; /* default http port */
@@ -1523,7 +1523,7 @@
if (hostname[i] == '/') {
k = i;
if (j == -1)
- j = i;
+ j = i;
break;
}
}
@@ -1532,21 +1532,21 @@
if (k == -1) {
pstring = MALLOC(strlen(hostname)-j+1);
memcpy(pstring,
- &hostname[j],
- strlen(hostname)-j+1);
+ &hostname[j],
+ strlen(hostname)-j+1);
pstring[strlen(hostname)-j] = '\0';
} else {
pstring = MALLOC(k-j+1);
memcpy(pstring,
- &hostname[j],
- k-j);
+ &hostname[j],
+ k-j);
pstring[k-j] = '\0';
}
port = strtol(pstring, &buffer, 10);
if ( (port < 0) || (port > 65536) ) {
XPRINTF(" malformed http URL: %s at %s.\n",
- reg,
- buffer);
+ reg,
+ buffer);
FREE(hostname);
FREE(reg);
FREE(pstring);
@@ -1565,11 +1565,11 @@
sock = SOCKET(PF_INET,
- SOCK_STREAM,
- 0);
+ SOCK_STREAM,
+ 0);
if (sock < 0) {
XPRINTF(" could not open socket for hostlist download (%s).\n",
- STRERROR(errno));
+ STRERROR(errno));
FREE(hostname);
FREE(reg);
return -1;
@@ -1579,16 +1579,16 @@
if (theProxy.sin_addr.s_addr == 0) {
/* no proxy */
if (OK != get_host_by_name(ectx, hostname,
- &ip)) {
+ &ip)) {
XPRINTF(" could not download hostlist, host '%s' unknown\n",
- hostname);
+ hostname);
FREE(reg);
FREE(hostname);
return -1;
}
memcpy(&soaddr.sin_addr.s_addr,
- &ip,
- sizeof(IPaddr));
+ &ip,
+ sizeof(IPaddr));
soaddr.sin_port
= htons((unsigned short)port);
} else {
@@ -1600,11 +1600,11 @@
}
soaddr.sin_family = AF_INET;
if (CONNECT(sock,
- (struct sockaddr*)&soaddr,
- sizeof(soaddr)) < 0 && errno != EWOULDBLOCK) {
+ (struct sockaddr*)&soaddr,
+ sizeof(soaddr)) < 0 && errno != EWOULDBLOCK) {
XPRINTF(" failed to send HTTP request to host %s: %s\n",
- hostname,
- STRERROR(errno));
+ hostname,
+ STRERROR(errno));
FREE(reg);
FREE(hostname);
closefile(sock);
@@ -1614,21 +1614,21 @@
n = strlen(GET_COMMAND) + strlen(reg);
command = MALLOC(n);
SNPRINTF(command,
- n,
- GET_COMMAND,
- reg);
+ n,
+ GET_COMMAND,
+ reg);
FREE(reg);
curpos = strlen(command)+1;
curpos = SEND_BLOCKING_ALL(sock,
- command,
- curpos);
+ command,
+ curpos);
if (SYSERR == (int)curpos) {
XPRINTF(" failed so send HTTP request %s to host %s (%u - %d) - %s\n",
- command,
- hostname,
- curpos,
- sock,
- STRERROR(errno));
+ command,
+ hostname,
+ curpos,
+ sock,
+ STRERROR(errno));
FREE(command);
FREE(hostname);
closefile(sock);
@@ -1647,9 +1647,9 @@
if (start + 5 * cronMINUTES < get_time())
break; /* exit after 5m */
success = RECV_NONBLOCKING(sock,
- &c,
- sizeof(c),
- &ret);
+ &c,
+ sizeof(c),
+ &ret);
if ( success == NO ) {
PTHREAD_SLEEP(100 * cronMILLIS);
continue;
@@ -1679,23 +1679,23 @@
curpos = 0;
while (curpos < 65536) {
if (start + 300 * cronSECONDS < get_time())
- break; /* exit after 300s */
+ break; /* exit after 300s */
success = RECV_NONBLOCKING(sock,
- &buffer[curpos],
- 65536-curpos,
- &ret);
+ &buffer[curpos],
+ 65536-curpos,
+ &ret);
if ( success == NO ) {
PTHREAD_SLEEP(20);
- continue;
+ continue;
}
if ( (ret == 0) || (ret == (size_t)-1) )
- break; /* end of file or error*/
+ break; /* end of file or error*/
curpos += ret;
if (0 != processCommands(buffer, &curpos)) {
- FREE(buffer);
- closefile(sock);
- return -1;
+ FREE(buffer);
+ closefile(sock);
+ return -1;
}
}
}
@@ -1716,9 +1716,9 @@
int i;
for (i=0;i<nnodes;i++)
XPRINTF("%4d - %s:%d\n",
- i,
- nodes[i].ips,
- nodes[i].port);
+ i,
+ nodes[i].ips,
+ nodes[i].port);
return 0;
}
Modified: GNUnet/src/applications/testbed/gnunet-testbed.c
===================================================================
--- GNUnet/src/applications/testbed/gnunet-testbed.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/testbed/gnunet-testbed.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -45,14 +45,14 @@
typedef void (*sighandler_t)(int);
#endif
-#define TESTBED_VERSION "0.0.5"
+#define TESTBED_VERSION "0.0.5"
#define HELPER "==HELPER=="
/* we may want to change SHELL and PORT into values
obtained from the configuration... */
-#define SHELL (NULL == getenv("BASH") ? "/bin/bash" : getenv("BASH"))
+#define SHELL (NULL == getenv("BASH") ? "/bin/bash" : getenv("BASH"))
#define PORT 4242
@@ -84,8 +84,8 @@
int c, option_index;
FREENONNULL(setConfigurationString("GNUNETD",
- "LOGFILE",
- NULL));
+ "LOGFILE",
+ NULL));
while (1) {
static struct GNoption long_options[] = {
LONG_DEFAULT_OPTIONS,
@@ -94,10 +94,10 @@
option_index = 0;
c = GNgetopt_long(argc,
- argv,
- "vhdc:L:",
- long_options,
- &option_index);
+ argv,
+ "vhdc:L:",
+ long_options,
+ &option_index);
if (c == -1)
break; /* No more flags to process */
if (YES == parseDefaultOptions(c, GNoptarg))
@@ -105,30 +105,30 @@
switch(c) {
case 'v':
printf("GNUnet v%s, gnunet-testbed v%s\n",
- VERSION,
- TESTBED_VERSION);
+ VERSION,
+ TESTBED_VERSION);
return SYSERR;
case 'h': {
static Help help[] = {
- HELP_CONFIG,
- HELP_HELP,
- HELP_LOGLEVEL,
- HELP_VERSION,
- HELP_END,
+ HELP_CONFIG,
+ HELP_HELP,
+ HELP_LOGLEVEL,
+ HELP_VERSION,
+ HELP_END,
};
formatHelp("gnunet-testbed ==HELPER== [OPTIONS] [COMMAND]",
- _("Start GNUnet-testbed helper."),
- help);
+ _("Start GNUnet-testbed helper."),
+ help);
return SYSERR;
}
default:
GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER,
- _("Use --help to get a list of options.\n"));
+ _("Use --help to get a list of options.\n"));
return -1;
} /* end of parsing commandline */
} /* while (1) */
setConfigurationStringList(&argv[GNoptind],
- argc - GNoptind);
+ argc - GNoptind);
return OK;
}
@@ -142,7 +142,7 @@
* to bash.
*/
static int helper_main(int argc,
- char * argv[]) {
+ char * argv[]) {
int i;
int retVal;
unsigned int len;
@@ -151,20 +151,20 @@
struct sockaddr_in soaddr;
if (SYSERR == initUtil(argc,
- argv,
- &helperParseOptions))
+ argv,
+ &helperParseOptions))
return -1;
argc = getConfigurationStringList(&argv);
if (argc == 0) {
fprintf(stderr,
- " must have at least one argument!\n");
+ " must have at least one argument!\n");
return -1;
}
sock = SOCKET(PF_INET,
- SOCK_STREAM,
- 6); /* 6: TCP */
+ SOCK_STREAM,
+ 6); /* 6: TCP */
if (sock == -1) {
LOG_STRERROR(LOG_FAILURE, "socket");
return SYSERR;
@@ -176,14 +176,14 @@
soaddr.sin_port
= htons(PORT);
res = CONNECT(sock,
- (struct sockaddr*)&soaddr,
- sizeof(soaddr));
+ (struct sockaddr*)&soaddr,
+ sizeof(soaddr));
if ( (res < 0) &&
(errno != EINPROGRESS) && (errno != EWOULDBLOCK) ) {
GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER,
- _("Cannot connect to LOOPBACK port %d: %s\n"),
- PORT,
- STRERROR(errno));
+ _("Cannot connect to LOOPBACK port %d: %s\n"),
+ PORT,
+ STRERROR(errno));
closefile(sock);
sock = -1;
return SYSERR;
@@ -191,20 +191,20 @@
/* write command to socket */
socketSend(strlen(argv[0]),
- SOCKET_BEGIN_COMMAND,
- argv[0]);
+ SOCKET_BEGIN_COMMAND,
+ argv[0]);
FREE(argv[0]);
/* write args to socket */
for (i=1;i<argc;i++) {
socketSend(strlen(argv[i]),
- SOCKET_ADD_ARGUMENT,
- argv[i]);
+ SOCKET_ADD_ARGUMENT,
+ argv[i]);
FREE(argv[i]);
}
FREE(argv);
socketSend(0,
- SOCKET_END_COMMAND,
- NULL);
+ SOCKET_END_COMMAND,
+ NULL);
/* read result from socket, print to stderr, obtain retVal */
i = SOCKET_PRINTF;
@@ -215,9 +215,9 @@
i = readSocket(&buf, &len);
if (i == SOCKET_PRINTF)
fprintf(stdout,
- "%.*s",
- (int) len,
- buf);
+ "%.*s",
+ (int) len,
+ buf);
}
retVal = *(int*)buf;
FREE(buf);
@@ -230,8 +230,8 @@
* too.
*/
static void sigChildHandler(int signal,
- siginfo_t * info,
- void * extra) {
+ siginfo_t * info,
+ void * extra) {
do_quit = YES;
}
@@ -244,7 +244,7 @@
FILE *aliases;
char * configFile;
char *argv[] = {
- NULL, /* replaced by SHELL */
+ NULL, /* replaced by SHELL */
"--init-file",
TB_ALIASES,
"-i",
@@ -252,26 +252,26 @@
};
configFile = getConfigurationString("FILES",
- "gnunet.conf");
+ "gnunet.conf");
GE_ASSERT(ectx, configFile != NULL);
argv[0] = SHELL;
aliases = FOPEN(TB_ALIASES, "w+");
fprintf(aliases,
- "export PS1=\"[GTB]%% \"\n");
+ "export PS1=\"[GTB]%% \"\n");
i=0;
while (commands[i].command != NULL) {
if (0 == strcmp("exit", commands[i].command)) {
fprintf(aliases,
- "alias exit=\"%s ==HELPER== -c %s exit ; exit\"\n",
- testbedArg0,
- configFile);
+ "alias exit=\"%s ==HELPER== -c %s exit ; exit\"\n",
+ testbedArg0,
+ configFile);
} else {
fprintf(aliases,
- "alias %s=\"%s ==HELPER== -c %s %s\"\n",
- commands[i].command,
- testbedArg0,
- configFile,
- commands[i].command);
+ "alias %s=\"%s ==HELPER== -c %s %s\"\n",
+ commands[i].command,
+ testbedArg0,
+ configFile,
+ commands[i].command);
}
i++;
}
@@ -280,9 +280,9 @@
doneUtil();
execvp(SHELL, argv);
fprintf(stderr,
- _("Could not execute `%s': %s\n"),
- SHELL,
- STRERROR(errno));
+ _("Could not execute `%s': %s\n"),
+ SHELL,
+ STRERROR(errno));
}
/**
@@ -295,7 +295,7 @@
*/
static int isWhitelisted(IPaddr ip) {
return checkIPListed(trustedNetworks_,
- ip);
+ ip);
}
/**
@@ -323,7 +323,7 @@
while ( (ssock = SOCKET(PF_INET, SOCK_STREAM, 0)) < 0) {
LOG_STRERROR(LOG_ERROR, "socket");
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("No client service started. Trying again in 30 seconds.\n"));
+ _("No client service started. Trying again in 30 seconds.\n"));
sleep(30);
}
@@ -335,23 +335,23 @@
= htons(PORT);
if (SETSOCKOPT(ssock,
- SOL_SOCKET,
- SO_REUSEADDR,
- &on,
- sizeof(on)) < 0)
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ &on,
+ sizeof(on)) < 0)
LOG_STRERROR(LOG_ERROR, "setsockopt");
/* bind the socket */
if (BIND(ssock,
- (struct sockaddr*)&serverAddr,
- sizeof(serverAddr)) < 0) {
+ (struct sockaddr*)&serverAddr,
+ sizeof(serverAddr)) < 0) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Error (%s) binding the TCP listener to "
- "port %d. No proxy service started.\nTrying "
- "again in %d seconds...\n"),
- STRERROR(errno),
- PORT,
- secs);
+ _("Error (%s) binding the TCP listener to "
+ "port %d. No proxy service started.\nTrying "
+ "again in %d seconds...\n"),
+ STRERROR(errno),
+ PORT,
+ secs);
sleep(secs);
secs += 5; /* slow progression... */
closefile(ssock);
@@ -365,20 +365,20 @@
sigfillset(&newAct.sa_mask);
newAct.sa_flags = SA_NOCLDSTOP | SA_SIGINFO | SA_RESTART;
if (0 != sigaction(SIGCHLD,
- &newAct,
- &oldAct))
+ &newAct,
+ &oldAct))
DIE_STRERROR("sigaction");
sigemptyset(&set);
sigaddset(&set, SIGCHLD);
if (0 != sigprocmask(SIG_UNBLOCK,
- &set,
- &oset))
+ &set,
+ &oset))
DIE_STRERROR("sigprocmask");
LISTEN(ssock, 5);
while ( (do_quit == NO) &&
- (0 == waitpid(bash_pid,
- &status,
- WNOHANG)) ) {
+ (0 == waitpid(bash_pid,
+ &status,
+ WNOHANG)) ) {
unsigned int argc;
char *command;
char **args;
@@ -400,8 +400,8 @@
if (sock == -1)
continue;
sock = ACCEPT(ssock,
- (struct sockaddr *)&clientAddr,
- &lenOfIncomingAddr);
+ (struct sockaddr *)&clientAddr,
+ &lenOfIncomingAddr);
if (sock < 0) {
LOG_STRERROR(LOG_ERROR, "accept");
continue;
@@ -409,12 +409,12 @@
/* access control! */
GE_ASSERT(ectx, sizeof(struct in_addr) == sizeof(IPaddr));
memcpy(&ipaddr,
- &clientAddr.sin_addr,
- sizeof(struct in_addr));
+ &clientAddr.sin_addr,
+ sizeof(struct in_addr));
if (NO == isWhitelisted(ipaddr)) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Rejected unauthorized connection from %u.%u.%u.%u.\n"),
- PRIP(ntohl(*(int*)&clientAddr.sin_addr)));
+ _("Rejected unauthorized connection from %u.%u.%u.%u.\n"),
+ PRIP(ntohl(*(int*)&clientAddr.sin_addr)));
closefile(sock);
continue;
}
@@ -426,8 +426,8 @@
buf = NULL;
if (SOCKET_BEGIN_COMMAND != readSocket(&buf, &len)) {
fprintf(stderr,
- _("Protocol violation on socket. "
- "Expected command.\n"));
+ _("Protocol violation on socket. "
+ "Expected command.\n"));
return -1;
}
command = MALLOC(len+1);
@@ -440,7 +440,7 @@
while (SOCKET_ADD_ARGUMENT == readSocket(&buf, &len)) {
GROW(args, argc, argc+1);
args[argc-1] = MALLOC(len+1);
- memcpy(args[argc-1], buf, len);
+ memcpy(args[argc-1], buf, len);
args[argc-1][len] = '\0';
FREE(buf);
buf = NULL;
@@ -449,12 +449,12 @@
i = 0;
while (commands[i].command != NULL) {
if (0 == strcmp(commands[i].command, command)) {
- int ret;
- ret = commands[i].handler(argc, args);
- socketSend(sizeof(unsigned int),
- SOCKET_RETVAL,
- &ret);
- break;
+ int ret;
+ ret = commands[i].handler(argc, args);
+ socketSend(sizeof(unsigned int),
+ SOCKET_RETVAL,
+ &ret);
+ break;
}
i++;
}
@@ -463,13 +463,13 @@
GROW(args, argc, 0);
if (commands[i].command == NULL) {
/* should never happen unless the user
- plays by hand with the aliases... */
+ plays by hand with the aliases... */
i = -1;
PRINTF(_("Command `%s' not found!\n"),
- command);
+ command);
socketSend(sizeof(unsigned int),
- SOCKET_RETVAL,
- &i);
+ SOCKET_RETVAL,
+ &i);
}
FREE(command);
closefile(sock);
@@ -478,12 +478,12 @@
/* just to be certain, we could have
left the main loop due to doExit... */
waitpid(bash_pid,
- &status,
- WNOHANG);
+ &status,
+ WNOHANG);
/* restore... */
if (0 != sigaction(SIGCHLD,
- &oldAct,
- &newAct))
+ &oldAct,
+ &newAct))
LOG_STRERROR(LOG_WARNING, "sigaction");
return status;
}
@@ -504,8 +504,8 @@
int c, option_index;
FREENONNULL(setConfigurationString("GNUNETD",
- "LOGFILE",
- NULL));
+ "LOGFILE",
+ NULL));
while (1) {
static struct GNoption long_options[] = {
LONG_DEFAULT_OPTIONS,
@@ -514,10 +514,10 @@
option_index = 0;
c = GNgetopt_long(argc,
- argv,
- "vhdc:L:",
- long_options,
- &option_index);
+ argv,
+ "vhdc:L:",
+ long_options,
+ &option_index);
if (c == -1)
break; /* No more flags to process */
if (YES == parseDefaultOptions(c, GNoptarg))
@@ -525,26 +525,26 @@
switch(c) {
case 'v':
printf("GNUnet v%s, gnunet-testbed v%s\n",
- VERSION,
- TESTBED_VERSION);
+ VERSION,
+ TESTBED_VERSION);
return SYSERR;
case 'h': {
static Help help[] = {
- HELP_CONFIG,
- HELP_HELP,
- HELP_LOGLEVEL,
- HELP_VERSION,
- HELP_END,
+ HELP_CONFIG,
+ HELP_HELP,
+ HELP_LOGLEVEL,
+ HELP_VERSION,
+ HELP_END,
};
formatHelp("gnunet-testbed [OPTIONS]",
- _("Start GNUnet testbed controller."),
- help);
+ _("Start GNUnet testbed controller."),
+ help);
return SYSERR;
}
default:
GE_LOG(ectx, GE_ERROR | GE_IMMEDIATE | GE_USER,
- _("Use --help to get a list of options.\n"));
+ _("Use --help to get a list of options.\n"));
return -1;
} /* end of parsing commandline */
} /* while (1) */
@@ -586,16 +586,16 @@
return -1;
ch = getConfigurationString("GNUNET-TESTBED",
- "TRUSTED");
+ "TRUSTED");
if (ch == NULL) {
trustedNetworks_ = parseRoutes("127.0.0.0/8;"); /* by default, trust
localhost only */
} else {
trustedNetworks_ = parseRoutes(ch);
if (trustedNetworks_ == NULL)
errexit(_("Malformed entry in the configuration in section %s under %s:
%s\n"),
- "GNUNET-TESTBED",
- "TRUSTED",
- ch);
+ "GNUNET-TESTBED",
+ "TRUSTED",
+ ch);
FREE(ch);
}
Modified: GNUnet/src/applications/testbed/socket.c
===================================================================
--- GNUnet/src/applications/testbed/socket.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/testbed/socket.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -37,8 +37,8 @@
int sock = -1;
static void writeAll(int fd,
- char * data,
- unsigned int len) {
+ char * data,
+ unsigned int len) {
unsigned int pos;
int ret;
pos = 0;
@@ -61,8 +61,8 @@
} ExchangeBuffer;
void socketSend(unsigned int len,
- unsigned int type,
- void * data) {
+ unsigned int type,
+ void * data) {
ExchangeBuffer * buf;
unsigned int tlen;
#if DEBUG
@@ -92,7 +92,7 @@
* @return the type of the message
*/
unsigned int readSocket(char ** rbuf,
- unsigned int * len) {
+ unsigned int * len) {
unsigned int type;
ExchangeBuffer * buf;
unsigned int pos;
@@ -143,8 +143,8 @@
* Print a message in the testbed-shell.
*/
void XPRINTF(const char * fmt,
- ...) {
- va_list args;
+ ...) {
+ va_list args;
int n;
unsigned int size = 1024;
char * p;
Modified: GNUnet/src/applications/testbed/testbed.c
===================================================================
--- GNUnet/src/applications/testbed/testbed.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/testbed/testbed.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -44,10 +44,10 @@
static Identity_ServiceAPI * identity;
static void sendAcknowledgement(ClientHandle client,
- int ack) {
+ int ack) {
if (OK != coreAPI->sendValueToClient(client, ack)) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Could not send acknowledgement back to client.\n"));
+ _("Could not send acknowledgement back to client.\n"));
}
}
@@ -55,7 +55,7 @@
* Handler that is called for "message not understood" cases.
*/
static void tb_undefined(ClientHandle client,
- TESTBED_CS_MESSAGE * msg) {
+ TESTBED_CS_MESSAGE * msg) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
_("Received unknown testbed message of type %u.\n"),
ntohl(msg->msgType));
@@ -65,7 +65,7 @@
* Connect to another peer.
*/
static void tb_ADD_PEER(ClientHandle client,
- TESTBED_CS_MESSAGE * msg) {
+ TESTBED_CS_MESSAGE * msg) {
MESSAGE_HEADER noise;
TESTBED_ADD_PEER_MESSAGE * hm
= (TESTBED_ADD_PEER_MESSAGE*) msg;
@@ -75,15 +75,15 @@
if (sizeof(TESTBED_ADD_PEER_MESSAGE) >
ntohs(msg->header.size) ) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("size of `%s' message is too short. Ignoring.\n"),
- "ADD_PEER");
+ _("size of `%s' message is too short. Ignoring.\n"),
+ "ADD_PEER");
return;
}
if (P2P_hello_MESSAGE_size(&hm->helo) !=
ntohs(msg->header.size) - sizeof(TESTBED_CS_MESSAGE) ) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("size of `%s' message is wrong. Ignoring.\n"),
- "_ADD_PEER");
+ _("size of `%s' message is wrong. Ignoring.\n"),
+ "_ADD_PEER");
return;
}
@@ -91,9 +91,9 @@
noise.size = htons(sizeof(MESSAGE_HEADER));
noise.type = htons(P2P_PROTO_noise);
coreAPI->unicast(&hm->helo.senderIdentity,
- &noise,
- EXTREME_PRIORITY,
- 0);
+ &noise,
+ EXTREME_PRIORITY,
+ 0);
sendAcknowledgement(client, OK);
}
@@ -101,13 +101,13 @@
* Disconnect from another peer.
*/
static void tb_DEL_PEER(ClientHandle client,
- TESTBED_DEL_PEER_MESSAGE * msg) {
+ TESTBED_DEL_PEER_MESSAGE * msg) {
coreAPI->disconnectFromPeer(&msg->host);
sendAcknowledgement(client, OK);
}
static void doDisconnect(const PeerIdentity * id,
- void * unused) {
+ void * unused) {
coreAPI->disconnectFromPeer(id);
}
@@ -115,9 +115,9 @@
* Disconnect from all other peers.
*/
static void tb_DEL_ALL_PEERS(ClientHandle client,
- TESTBED_DEL_ALL_PEERS_MESSAGE * msg) {
+ TESTBED_DEL_ALL_PEERS_MESSAGE * msg) {
coreAPI->forAllConnectedNodes(&doDisconnect,
- NULL);
+ NULL);
sendAcknowledgement(client, OK);
}
@@ -125,17 +125,17 @@
* Get a hello message for this peer.
*/
static void tb_GET_hello(ClientHandle client,
- TESTBED_GET_hello_MESSAGE * msg) {
+ TESTBED_GET_hello_MESSAGE * msg) {
P2P_hello_MESSAGE * helo;
unsigned int proto = ntohs(msg->proto);
helo = identity->identity2Helo(coreAPI->myIdentity,
- proto,
- NO);
+ proto,
+ NO);
if (NULL == helo) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("TESTBED could not generate hello message for protocol %u\n"),
- proto);
+ _("TESTBED could not generate hello message for protocol %u\n"),
+ proto);
sendAcknowledgement(client, SYSERR);
} else {
TESTBED_hello_MESSAGE * reply
@@ -147,13 +147,13 @@
reply->header.msgType
= htonl(TESTBED_hello_RESPONSE);
memcpy(&reply->helo,
- helo,
- ntohs(helo->header.size));
+ helo,
+ ntohs(helo->header.size));
coreAPI->sendToClient(client,
- &reply->header.header);
+ &reply->header.header);
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "%s: returning from sendToClient\n",
- __FUNCTION__);
+ "%s: returning from sendToClient\n",
+ __FUNCTION__);
FREE(helo);
FREE(reply);
}
@@ -163,48 +163,48 @@
* Set a trust value.
*/
static void tb_SET_TVALUE(ClientHandle client,
- TESTBED_SET_TVALUE_MESSAGE * msg) {
+ TESTBED_SET_TVALUE_MESSAGE * msg) {
int trust;
trust = ntohl(msg->trust);
identity->changeHostTrust(&msg->otherPeer,
- trust);
+ trust);
sendAcknowledgement(client, OK);
-}
-
+}
+
/**
* Get a trust value.
*/
static void tb_GET_TVALUE(ClientHandle client,
- TESTBED_GET_TVALUE_MESSAGE * msg) {
+ TESTBED_GET_TVALUE_MESSAGE * msg) {
unsigned int trust;
trust = identity->getHostTrust(&msg->otherPeer);
sendAcknowledgement(client, trust);
-}
+}
/**
* Change the bandwidth limitations.
*/
static void tb_SET_BW(ClientHandle client,
- TESTBED_SET_BW_MESSAGE * msg) {
+ TESTBED_SET_BW_MESSAGE * msg) {
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
"gnunet-testbed: tb_SET_BW\n");
setConfigurationInt("LOAD",
- "MAXNETDOWNBPSTOTAL",
- ntohl(msg->in_bw));
+ "MAXNETDOWNBPSTOTAL",
+ ntohl(msg->in_bw));
setConfigurationInt("LOAD",
- "MAXNETUPBPSTOTAL",
- ntohl(msg->out_bw));
+ "MAXNETUPBPSTOTAL",
+ ntohl(msg->out_bw));
triggerGlobalConfigurationRefresh();
sendAcknowledgement(client, OK);
-}
+}
/**
* Load an application module.
*/
static void tb_LOAD_MODULE(ClientHandle client,
- TESTBED_CS_MESSAGE * msg) {
+ TESTBED_CS_MESSAGE * msg) {
unsigned short size;
char * name;
int ok;
@@ -212,31 +212,31 @@
size = ntohs(msg->header.size);
if (size <= sizeof(TESTBED_CS_MESSAGE) ) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid `%s' message\n"),
- "LOAD_MODULE");
+ _("received invalid `%s' message\n"),
+ "LOAD_MODULE");
return;
}
if (! testConfigurationString("TESTBED",
- "ALLOW_MODULE_LOADING",
- "YES")) {
+ "ALLOW_MODULE_LOADING",
+ "YES")) {
sendAcknowledgement(client, SYSERR);
return;
}
name = STRNDUP(&((TESTBED_LOAD_MODULE_MESSAGE_GENERIC*)msg)->modulename[0],
- size - sizeof(TESTBED_CS_MESSAGE));
+ size - sizeof(TESTBED_CS_MESSAGE));
if (strlen(name) == 0) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid `%s' message (empty module name)\n"),
- "LOAD_MODULE");
+ _("received invalid `%s' message (empty module name)\n"),
+ "LOAD_MODULE");
return;
}
ok = coreAPI->loadApplicationModule(name);
if (ok != OK)
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("loading module `%s' failed. Notifying client.\n"),
- name);
+ _("loading module `%s' failed. Notifying client.\n"),
+ name);
FREE(name);
sendAcknowledgement(client, ok);
}
@@ -245,7 +245,7 @@
* Unload an application module.
*/
static void tb_UNLOAD_MODULE(ClientHandle client,
- TESTBED_CS_MESSAGE * msg) {
+ TESTBED_CS_MESSAGE * msg) {
unsigned short size;
char * name;
int ok;
@@ -253,29 +253,29 @@
size = ntohs(msg->header.size);
if (size <= sizeof(TESTBED_CS_MESSAGE) ) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid `%s' message\n"),
- "UNLOAD_MODULE");
+ _("received invalid `%s' message\n"),
+ "UNLOAD_MODULE");
return;
}
if (! testConfigurationString("TESTBED",
- "ALLOW_MODULE_LOADING",
- "YES")) {
+ "ALLOW_MODULE_LOADING",
+ "YES")) {
sendAcknowledgement(client, SYSERR);
return;
}
name = STRNDUP(&((TESTBED_UNLOAD_MODULE_MESSAGE_GENERIC*)msg)->modulename[0],
- size - sizeof(TESTBED_CS_MESSAGE));
+ size - sizeof(TESTBED_CS_MESSAGE));
if (strlen(name) == 0) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid `%s' message (empty module name)\n"),
- "UNLOAD_MODULE");
+ _("received invalid `%s' message (empty module name)\n"),
+ "UNLOAD_MODULE");
return;
}
ok = coreAPI->unloadApplicationModule(name);
if (ok != OK)
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("unloading module failed. Notifying client.\n"));
+ _("unloading module failed. Notifying client.\n"));
FREE(name);
sendAcknowledgement(client, ok);
}
@@ -286,10 +286,10 @@
* random).
*/
static void tb_DISABLE_AUTOCONNECT(ClientHandle client,
- TESTBED_DISABLE_AUTOCONNECT_MESSAGE * msg) {
+ TESTBED_DISABLE_AUTOCONNECT_MESSAGE * msg) {
FREENONNULL(setConfigurationString("GNUNETD",
- "DISABLE-AUTOCONNECT",
- "YES"));
+ "DISABLE-AUTOCONNECT",
+ "YES"));
triggerGlobalConfigurationRefresh();
sendAcknowledgement(client, OK);
}
@@ -300,10 +300,10 @@
* random).
*/
static void tb_ENABLE_AUTOCONNECT(ClientHandle client,
- TESTBED_ENABLE_AUTOCONNECT_MESSAGE * msg) {
+ TESTBED_ENABLE_AUTOCONNECT_MESSAGE * msg) {
FREENONNULL(setConfigurationString("GNUNETD",
- "DISABLE-AUTOCONNECT",
- "NO"));
+ "DISABLE-AUTOCONNECT",
+ "NO"));
triggerGlobalConfigurationRefresh();
sendAcknowledgement(client, OK);
}
@@ -314,13 +314,13 @@
* random).
*/
static void tb_DISABLE_hello(ClientHandle client,
- TESTBED_DISABLE_hello_MESSAGE * msg) {
+ TESTBED_DISABLE_hello_MESSAGE * msg) {
FREENONNULL(setConfigurationString("NETWORK",
- "DISABLE-ADVERTISEMENTS",
- "YES"));
+ "DISABLE-ADVERTISEMENTS",
+ "YES"));
FREENONNULL(setConfigurationString("NETWORK",
- "HELLOEXCHANGE",
- "NO"));
+ "HELLOEXCHANGE",
+ "NO"));
triggerGlobalConfigurationRefresh();
sendAcknowledgement(client, OK);
}
@@ -331,13 +331,13 @@
* random).
*/
static void tb_ENABLE_hello(ClientHandle client,
- TESTBED_ENABLE_hello_MESSAGE * msg) {
+ TESTBED_ENABLE_hello_MESSAGE * msg) {
FREENONNULL(setConfigurationString("NETWORK",
- "DISABLE-ADVERTISEMENTS",
- "NO"));
+ "DISABLE-ADVERTISEMENTS",
+ "NO"));
FREENONNULL(setConfigurationString("NETWORK",
- "HELLOEXCHANGE",
- "YES"));
+ "HELLOEXCHANGE",
+ "YES"));
triggerGlobalConfigurationRefresh();
sendAcknowledgement(client, OK);
}
@@ -346,7 +346,7 @@
* Allow only certain peers to connect.
*/
static void tb_ALLOW_CONNECT(ClientHandle client,
- TESTBED_ALLOW_CONNECT_MESSAGE * msg) {
+ TESTBED_ALLOW_CONNECT_MESSAGE * msg) {
char * value;
unsigned short size;
unsigned int count;
@@ -356,15 +356,15 @@
size = ntohs(msg->header.header.size);
if (size <= sizeof(TESTBED_CS_MESSAGE) ) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid `%s' message\n"),
- "ALLOW_CONNECT");
+ _("received invalid `%s' message\n"),
+ "ALLOW_CONNECT");
return;
}
count = (size - sizeof(TESTBED_CS_MESSAGE)) / sizeof(PeerIdentity);
if (count * sizeof(PeerIdentity) + sizeof(TESTBED_CS_MESSAGE) != size) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid `%s' message\n"),
- "ALLOW_CONNECT");
+ _("received invalid `%s' message\n"),
+ "ALLOW_CONNECT");
return;
}
if (count == 0) {
@@ -374,13 +374,13 @@
value[0] = '\0';
for (i=0;i<count;i++) {
hash2enc(&((TESTBED_ALLOW_CONNECT_MESSAGE_GENERIC*)msg)->peers[i].hashPubKey,
- &enc);
+ &enc);
strcat(value, (char*)&enc);
}
}
FREENONNULL(setConfigurationString("GNUNETD",
- "LIMIT-ALLOW",
- value));
+ "LIMIT-ALLOW",
+ value));
FREENONNULL(value);
triggerGlobalConfigurationRefresh();
sendAcknowledgement(client, OK);
@@ -390,7 +390,7 @@
* Deny certain peers the right to connect.
*/
static void tb_DENY_CONNECT(ClientHandle client,
- TESTBED_DENY_CONNECT_MESSAGE * msg) {
+ TESTBED_DENY_CONNECT_MESSAGE * msg) {
char * value;
unsigned short size;
unsigned int count;
@@ -400,15 +400,15 @@
size = ntohs(msg->header.header.size);
if (size <= sizeof(TESTBED_CS_MESSAGE) ) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid `%s' message\n"),
- "DENY_CONNECT");
+ _("received invalid `%s' message\n"),
+ "DENY_CONNECT");
return;
}
count = (size - sizeof(TESTBED_CS_MESSAGE)) / sizeof(PeerIdentity);
if (count * sizeof(PeerIdentity) + sizeof(TESTBED_CS_MESSAGE) != size) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid `%s' message\n"),
- "DENY_CONNECT");
+ _("received invalid `%s' message\n"),
+ "DENY_CONNECT");
return;
}
if (count == 0) {
@@ -418,13 +418,13 @@
value[0] = '\0';
for (i=0;i<count;i++) {
hash2enc(&((TESTBED_DENY_CONNECT_MESSAGE_GENERIC*)msg)->peers[i].hashPubKey,
- &enc);
+ &enc);
strcat(value, (char*)&enc);
}
}
FREENONNULL(setConfigurationString("GNUNETD",
- "LIMIT-DENY",
- value));
+ "LIMIT-DENY",
+ value));
FREENONNULL(value);
triggerGlobalConfigurationRefresh();
sendAcknowledgement(client, OK);
@@ -506,10 +506,10 @@
pi->argc-1);
for (i=1;i<pi->argc;i++)
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "exec argument %d is %s\n",
- i, pi->argv[i]);
+ "exec argument %d is %s\n",
+ i, pi->argv[i]);
tmp = getConfigurationString("TESTBED",
- "UPLOAD-DIR");
+ "UPLOAD-DIR");
if (tmp == NULL)
tmp = STRDUP(DIR_SEPARATOR_STR);
dir = expandFileName(tmp);
@@ -533,13 +533,13 @@
CHDIR(dir);
FREE(dir);
execvp(pi->argv[0],
- &pi->argv[0]);
+ &pi->argv[0]);
GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "execvp", pi->argv[0]);
fprintf(stderr,
- _("`%s' %s failed: %s\n"),
- "execvp",
- pi->argv[0],
- STRERROR(errno));
+ _("`%s' %s failed: %s\n"),
+ "execvp",
+ pi->argv[0],
+ STRERROR(errno));
exit(errno);
} /* end pi->pid == 0 */
FREE(dir);
@@ -571,8 +571,8 @@
buffer = MALLOC(PRT_BUFSIZE);
while (ret > 0) {
ret = READ(pi->outputPipe,
- buffer,
- PRT_BUFSIZE);
+ buffer,
+ PRT_BUFSIZE);
if (ret <= 0)
break;
MUTEX_LOCK(&lock);
@@ -581,19 +581,19 @@
break;
}
GROW(pi->output,
- pi->outputSize,
- pi->outputSize + ret);
+ pi->outputSize,
+ pi->outputSize + ret);
memcpy(&pi->output[pi->outputSize-ret],
- buffer,
- ret);
+ buffer,
+ ret);
MUTEX_UNLOCK(&lock);
}
closefile(pi->outputPipe);
MUTEX_LOCK(&lock);
ret = waitpid(pi->pid,
- &pi->exitStatus,
- 0);
+ &pi->exitStatus,
+ 0);
if (ret != pi->pid) {
LOG_STRERROR(LOG_WARNING, "waitpid");
pi->exitStatus = errno;
@@ -607,7 +607,7 @@
* Execute a command.
*/
static void tb_EXEC(ClientHandle client,
- TESTBED_CS_MESSAGE * msg) {
+ TESTBED_CS_MESSAGE * msg) {
int argc2;
unsigned short size;
unsigned int uid;
@@ -622,11 +622,11 @@
if ( (size <= sizeof(TESTBED_CS_MESSAGE)) ||
(((TESTBED_EXEC_MESSAGE_GENERIC*)emsg)->commandLine[size-sizeof(TESTBED_CS_MESSAGE)-1]
!= '\0') ) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid `%s' message: %s.\n"),
- "EXEC",
- (size <= sizeof(TESTBED_CS_MESSAGE))
- ? "size smaller or equal than TESTBED_CS_MESSAGE"
- : "last character in command line is not zero-terminator");
+ _("received invalid `%s' message: %s.\n"),
+ "EXEC",
+ (size <= sizeof(TESTBED_CS_MESSAGE))
+ ? "size smaller or equal than TESTBED_CS_MESSAGE"
+ : "last character in command line is not zero-terminator");
sendAcknowledgement(client, SYSERR);
return;
}
@@ -639,10 +639,10 @@
mainName = STRDUP(&((TESTBED_EXEC_MESSAGE_GENERIC*)emsg)->commandLine[0]);
clientConfig = NULL;
if (0 == strncmp("gnunet",
- mainName,
- strlen("gnunet")))
+ mainName,
+ strlen("gnunet")))
clientConfig = getConfigurationString("TESTBED",
- "CLIENTCONFIG");
+ "CLIENTCONFIG");
if (clientConfig != NULL)
pi->argc +=2;
argc2 = pi->argc;
@@ -660,9 +660,9 @@
pi->sem = SEMAPHORE_CREATE(0);
if (0 != PTHREAD_CREATE(&pi->reader,
- (PThreadMain) &pipeReaderThread,
- pi,
- 8*1024)) {
+ (PThreadMain) &pipeReaderThread,
+ pi,
+ 8*1024)) {
LOG_STRERROR(LOG_WARNING, "pthread_create");
SEMAPHORE_DESTROY(pi->sem);
MUTEX_UNLOCK(&lock);
@@ -688,7 +688,7 @@
* process on exit.
*/
static void tb_SIGNAL(ClientHandle client,
- TESTBED_SIGNAL_MESSAGE * msg) {
+ TESTBED_SIGNAL_MESSAGE * msg) {
int ret;
int i;
unsigned int uid;
@@ -704,30 +704,30 @@
pi = pt[i];
if (pi->uid != uid)
continue;
- if (sig == -1) {
+ if (sig == -1) {
if (pi->hasExited == NO) {
- ret = SYSERR;
- } else {
- ret = WEXITSTATUS(pi->exitStatus);
- /* free resources... */
- GROW(pi->output,
- pi->outputSize,
- 0);
- PTHREAD_JOIN(&pi->reader,
- &unused);
- FREE(pi);
- pt[i] = pt[ptSize-1];
- GROW(pt,
- ptSize,
- ptSize-1);
+ ret = SYSERR;
+ } else {
+ ret = WEXITSTATUS(pi->exitStatus);
+ /* free resources... */
+ GROW(pi->output,
+ pi->outputSize,
+ 0);
+ PTHREAD_JOIN(&pi->reader,
+ &unused);
+ FREE(pi);
+ pt[i] = pt[ptSize-1];
+ GROW(pt,
+ ptSize,
+ ptSize-1);
}
} else {
if (pi->hasExited == NO) {
- if (0 == kill(pi->pid,
- ntohl(msg->signal)))
- ret = OK;
- else
- LOG_STRERROR(LOG_WARNING, "kill");
+ if (0 == kill(pi->pid,
+ ntohl(msg->signal)))
+ ret = OK;
+ else
+ LOG_STRERROR(LOG_WARNING, "kill");
}
}
break;
@@ -740,7 +740,7 @@
* Get the output of a process.
*/
static void tb_GET_OUTPUT(ClientHandle client,
- TESTBED_GET_OUTPUT_MESSAGE * msg) {
+ TESTBED_GET_OUTPUT_MESSAGE * msg) {
int i;
unsigned int uid;
@@ -756,30 +756,30 @@
msg = MALLOC(65532);
msg->header.header.type
- = htons(CS_PROTO_testbed_REPLY);
+ = htons(CS_PROTO_testbed_REPLY);
msg->header.msgType
- = htonl(TESTBED_OUTPUT_RESPONSE);
+ = htonl(TESTBED_OUTPUT_RESPONSE);
sendAcknowledgement(client, pi->outputSize);
pos = 0;
- while (pos < pi->outputSize) {
- unsigned int run = pi->outputSize - pos;
- if (run > 65532 - sizeof(TESTBED_OUTPUT_REPLY_MESSAGE))
- run = 65532 - sizeof(TESTBED_OUTPUT_REPLY_MESSAGE);
- msg->header.header.size
- = htons(run+sizeof(TESTBED_OUTPUT_REPLY_MESSAGE));
- memcpy(&((TESTBED_OUTPUT_REPLY_MESSAGE_GENERIC*)msg)->data[0],
- &pi->output[pos],
- run);
- coreAPI->sendToClient(client,
- &msg->header.header);
- pos += run;
+ while (pos < pi->outputSize) {
+ unsigned int run = pi->outputSize - pos;
+ if (run > 65532 - sizeof(TESTBED_OUTPUT_REPLY_MESSAGE))
+ run = 65532 - sizeof(TESTBED_OUTPUT_REPLY_MESSAGE);
+ msg->header.header.size
+ = htons(run+sizeof(TESTBED_OUTPUT_REPLY_MESSAGE));
+ memcpy(&((TESTBED_OUTPUT_REPLY_MESSAGE_GENERIC*)msg)->data[0],
+ &pi->output[pos],
+ run);
+ coreAPI->sendToClient(client,
+ &msg->header.header);
+ pos += run;
}
FREE(msg);
/* reset output buffer */
GROW(pi->output,
- pi->outputSize,
- 0);
+ pi->outputSize,
+ 0);
MUTEX_UNLOCK(&lock);
return;
}
@@ -792,7 +792,7 @@
* The client is uploading a file to this peer.
*/
static void tb_UPLOAD_FILE(ClientHandle client,
- TESTBED_UPLOAD_FILE_MESSAGE * msg) {
+ TESTBED_UPLOAD_FILE_MESSAGE * msg) {
int ack;
unsigned int size;
char * filename, *gnHome, *s;
@@ -804,8 +804,8 @@
"tb_UPLOAD_FILE\n");
if (sizeof(TESTBED_UPLOAD_FILE_MESSAGE) > ntohs(msg->header.header.size)) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("size of `%s' message is too short. Ignoring.\n"),
- "UPLOAD_FILE");
+ _("size of `%s' message is too short. Ignoring.\n"),
+ "UPLOAD_FILE");
sendAcknowledgement(client, SYSERR);
return;
}
@@ -814,8 +814,8 @@
while ( (*s) && (s != end) ) {
if (*s == '.' && *(s+1) == '.') {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("\'..\' is not allowed in file name (%s).\n"),
- filename);
+ _("\'..\' is not allowed in file name (%s).\n"),
+ filename);
return;
}
s++;
@@ -823,22 +823,22 @@
if (s == filename) {
/* filename empty, not allowed! */
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Empty filename for UPLOAD_FILE message is invalid!\n"));
+ _("Empty filename for UPLOAD_FILE message is invalid!\n"));
sendAcknowledgement(client, SYSERR);
return;
}
if (s == end) {
/* filename empty, not allowed! */
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Filename for UPLOAD_FILE message is not null-terminated
(invalid!)\n"));
+ _("Filename for UPLOAD_FILE message is not null-terminated (invalid!)\n"));
sendAcknowledgement(client, SYSERR);
return;
}
tmp = getConfigurationString("TESTBED",
- "UPLOAD-DIR");
+ "UPLOAD-DIR");
if (tmp == NULL) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Upload refused!"));
+ _("Upload refused!"));
sendAcknowledgement(client, SYSERR);
return;
}
@@ -850,8 +850,8 @@
strcpy(filename, gnHome);
strcat(filename, DIR_SEPARATOR_STR);
strncat(filename,
- ((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC*)msg)->buf,
- end - ((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC*)msg)->buf);
+ ((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC*)msg)->buf,
+ end - ((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC*)msg)->buf);
if (htonl(msg->type) == TESTBED_FILE_DELETE) {
if (REMOVE(filename) && errno != ENOENT) {
GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "remove", filename);
@@ -864,9 +864,9 @@
}
if (htonl(msg->type) != TESTBED_FILE_APPEND) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Invalid message received at %s:%d."),
- __FILE__,
- __LINE__);
+ _("Invalid message received at %s:%d."),
+ __FILE__,
+ __LINE__);
FREE(filename);
return;
}
@@ -894,9 +894,9 @@
/**
* General type of a message handler.
- */
+ */
typedef void (*THandler)(ClientHandle client,
- TESTBED_CS_MESSAGE * msg);
+ TESTBED_CS_MESSAGE * msg);
/**
* @brief Entry in the handlers array that describes a testbed message handler.
@@ -931,14 +931,14 @@
#define TBDENTRY(a) {(THandler)&tb_##a, 0, "##a##", TESTBED_##a }
#define TBSENTRY(a) {(THandler)&tb_##a, sizeof(TESTBED_##a##_MESSAGE),\
- "##a##", TESTBED_##a}
+ "##a##", TESTBED_##a}
/**
* The array of message handlers. Add new handlers here.
*/
static HD handlers[] = {
- TBSENTRY(undefined), /* For IDs that should never be received */
- TBDENTRY(ADD_PEER), /* RF: Why was this as TBDENTRY? Because hello is
variable size! */
+ TBSENTRY(undefined), /* For IDs that should never be received */
+ TBDENTRY(ADD_PEER), /* RF: Why was this as TBDENTRY? Because hello is
variable size! */
TBSENTRY(DEL_PEER),
TBSENTRY(DEL_ALL_PEERS),
TBSENTRY(GET_hello),
@@ -958,10 +958,10 @@
TBDENTRY(EXEC),
TBSENTRY(SIGNAL),
TBSENTRY(GET_OUTPUT),
- { NULL, 0, NULL, 0 }, /* this entry is used to ensure that
- a wrong TESTBED_MAX_MSG will abort
- insted of possibly segfaulting.
- This must always be the LAST entry. */
+ { NULL, 0, NULL, 0 }, /* this entry is used to ensure that
+ a wrong TESTBED_MAX_MSG will abort
+ insted of possibly segfaulting.
+ This must always be the LAST entry. */
};
@@ -970,7 +970,7 @@
* on the testbed-message type.
*/
static void csHandleTestbedRequest(ClientHandle client,
- CS_MESSAGE_HEADER * message) {
+ CS_MESSAGE_HEADER * message) {
TESTBED_CS_MESSAGE * msg;
unsigned short size;
unsigned int id;
@@ -982,27 +982,27 @@
size = ntohs(message->size);
if (size < sizeof(TESTBED_CS_MESSAGE)) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("received invalid testbed message of size %u\n"),
- size);
+ _("received invalid testbed message of size %u\n"),
+ size);
return;
}
msg = (TESTBED_CS_MESSAGE *)message;
id = ntohl(msg->msgType);
if (id < TESTBED_MAX_MSG) {
if ( (handlers[id].expectedSize == 0) ||
- (handlers[id].expectedSize == size) ) {
+ (handlers[id].expectedSize == size) ) {
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "TESTBED received message of type %u.\n",
- id);
+ "TESTBED received message of type %u.\n",
+ id);
handlers[id].handler(client, msg);
} else {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Received testbed message of type %u but unexpected size %u,
expected %u\n"),
- id,
- size,
- handlers[id].expectedSize);
+ _("Received testbed message of type %u but unexpected size %u, expected
%u\n"),
+ id,
+ size,
+ handlers[id].expectedSize);
}
} else {
tb_undefined(client, msg);
@@ -1039,32 +1039,32 @@
size_t n;
reg = getConfigurationString("TESTBED",
- "REGISTERURL");
+ "REGISTERURL");
if (reg == NULL) {
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- _("No testbed URL given, not registered.\n"));
+ _("No testbed URL given, not registered.\n"));
return;
}
proxy = getConfigurationString("GNUNETD",
- "HTTP-PROXY");
+ "HTTP-PROXY");
if (proxy != NULL) {
if (OK != get_host_by_name(ectx, proxy, &ip_info)) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Could not resolve name of HTTP proxy `%s'.\n"),
- proxy);
+ _("Could not resolve name of HTTP proxy `%s'.\n"),
+ proxy);
theProxy.sin_addr.s_addr = 0;
} else {
memcpy(&theProxy.sin_addr.s_addr,
- &ip_info,
- sizeof(IPaddr));
+ &ip_info,
+ sizeof(IPaddr));
proxyPort = getConfigurationString("GNUNETD",
- "HTTP-PROXY-PORT");
+ "HTTP-PROXY-PORT");
if (proxyPort == NULL) {
- theProxy.sin_port = htons(8080);
+ theProxy.sin_port = htons(8080);
} else {
- theProxy.sin_port = htons(atoi(proxyPort));
- FREE(proxyPort);
+ theProxy.sin_port = htons(atoi(proxyPort));
+ FREE(proxyPort);
}
}
FREE(proxy);
@@ -1073,12 +1073,12 @@
}
if (0 != strncmp(HTTP_URL,
- reg,
- strlen(HTTP_URL)) ) {
+ reg,
+ strlen(HTTP_URL)) ) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Invalid URL `%s' (must begin with `%s')\n"),
- reg,
- HTTP_URL);
+ _("Invalid URL `%s' (must begin with `%s')\n"),
+ reg,
+ HTTP_URL);
return;
}
port = 80; /* default http port */
@@ -1093,7 +1093,7 @@
if (hostname[i] == '/') {
k = i;
if (j == -1)
- j = i;
+ j = i;
break;
}
}
@@ -1102,22 +1102,22 @@
if (k == -1) {
pstring = MALLOC(strlen(hostname)-j+1);
memcpy(pstring,
- &hostname[j],
- strlen(hostname)-j+1);
+ &hostname[j],
+ strlen(hostname)-j+1);
pstring[strlen(hostname)-j] = '\0';
} else {
pstring = MALLOC(k-j+1);
memcpy(pstring,
- &hostname[j],
- k-j);
+ &hostname[j],
+ k-j);
pstring[k-j] = '\0';
}
port = strtol(pstring, &buffer, 10);
if ( (port < 0) || (port > 65536) ) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Malformed http URL: `%s' at `%s'. Testbed-client not
registered.\n"),
- reg,
- buffer);
+ _("Malformed http URL: `%s' at `%s'. Testbed-client not registered.\n"),
+ reg,
+ buffer);
FREE(hostname);
FREE(reg);
FREE(pstring);
@@ -1136,8 +1136,8 @@
sock = SOCKET(PF_INET,
- SOCK_STREAM,
- 0);
+ SOCK_STREAM,
+ 0);
if (sock < 0) {
LOG_STRERROR(LOG_ERROR, "socket");
FREE(hostname);
@@ -1149,17 +1149,17 @@
if (theProxy.sin_addr.s_addr == 0) {
/* no proxy */
if (OK != get_host_by_name(ectx, hostname,
- &ip_info)) {
+ &ip_info)) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Could not register testbed, host `%s' unknown\n"),
- hostname);
+ _("Could not register testbed, host `%s' unknown\n"),
+ hostname);
FREE(reg);
FREE(hostname);
return;
}
memcpy(&soaddr.sin_addr.s_addr,
- &ip_info,
- sizeof(IPaddr));
+ &ip_info,
+ sizeof(IPaddr));
soaddr.sin_port
= htons((unsigned short)port);
} else {
@@ -1171,12 +1171,12 @@
}
soaddr.sin_family = AF_INET;
if (CONNECT(sock,
- (struct sockaddr*)&soaddr,
- sizeof(soaddr)) < 0 && errno != EWOULDBLOCK) {
+ (struct sockaddr*)&soaddr,
+ sizeof(soaddr)) < 0 && errno != EWOULDBLOCK) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Failed to send HTTP request to host `%s': %s\n"),
- hostname,
- STRERROR(errno));
+ _("Failed to send HTTP request to host `%s': %s\n"),
+ hostname,
+ STRERROR(errno));
FREE(reg);
FREE(hostname);
closefile(sock);
@@ -1185,7 +1185,7 @@
trusted = getConfigurationString("NETWORK",
- "TRUSTED");
+ "TRUSTED");
if (trusted == NULL)
trusted = STRDUP("127.0.0.0/8;");
i = 0;
@@ -1196,11 +1196,11 @@
}
tport = getGNUnetPort();
SNPRINTF(sport,
- 6,
- "%u",
- tport);
+ 6,
+ "%u",
+ tport);
secure = getConfigurationString("TESTBED",
- "LOGIN");
+ "LOGIN");
if (secure == NULL)
secure = STRDUP("");
n = strlen(GET_COMMAND)
@@ -1211,26 +1211,26 @@
+ strlen(secure) + 1;
command = MALLOC(n);
SNPRINTF(command,
- n,
- GET_COMMAND,
- reg,
- cmd,
- trusted,
- sport,
- secure);
+ n,
+ GET_COMMAND,
+ reg,
+ cmd,
+ trusted,
+ sport,
+ secure);
FREE(trusted);
FREE(secure);
FREE(reg);
curpos = strlen(command)+1;
curpos = SEND_BLOCKING_ALL(sock,
- command,
- curpos);
+ command,
+ curpos);
if (SYSERR == (int)curpos) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Failed so send HTTP request `%s' to host `%s': %s\n"),
- command,
- hostname,
- STRERROR(errno));
+ _("Failed so send HTTP request `%s' to host `%s': %s\n"),
+ command,
+ hostname,
+ STRERROR(errno));
FREE(command);
FREE(hostname);
closefile(sock);
@@ -1249,9 +1249,9 @@
if (start + 5 * cronMINUTES < get_time())
break; /* exit after 5m */
success = RECV_NONBLOCKING(sock,
- &c,
- sizeof(c),
- &ret);
+ &c,
+ sizeof(c),
+ &ret);
if ( success == NO ) {
PTHREAD_SLEEP(100 * cronMILLIS);
continue;
@@ -1266,7 +1266,7 @@
closefile(sock);
if (curpos < 4) { /* invalid response */
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Exit register (error: no http response read).\n"));
+ _("Exit register (error: no http response read).\n"));
}
#if DEBUG_TESTBED
GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER,
@@ -1290,7 +1290,7 @@
if (pt[i]->client == client) {
pding++;
if (pt[i]->hasExited == NO)
- kill(pt[i]->pid, SIGKILL); /* die NOW */
+ kill(pt[i]->pid, SIGKILL); /* die NOW */
}
}
MUTEX_UNLOCK(&lock);
@@ -1305,20 +1305,20 @@
MUTEX_LOCK(&lock);
for (i=ptSize-1;i>=0;i--) {
if (pt[i]->client == client) {
- if (pt[i]->hasExited == YES) {
- PTHREAD_JOIN(&pt[i]->reader,
- &unused);
- GROW(pt[i]->output,
- pt[i]->outputSize,
- 0);
- FREE(pt[i]);
- pt[i] = pt[ptSize-1];
- GROW(pt,
- ptSize,
- ptSize-1);
- } else {
- pding++;
- }
+ if (pt[i]->hasExited == YES) {
+ PTHREAD_JOIN(&pt[i]->reader,
+ &unused);
+ GROW(pt[i]->output,
+ pt[i]->outputSize,
+ 0);
+ FREE(pt[i]);
+ pt[i] = pt[ptSize-1];
+ GROW(pt,
+ ptSize,
+ ptSize-1);
+ } else {
+ pding++;
+ }
}
}
MUTEX_UNLOCK(&lock);
@@ -1336,7 +1336,7 @@
/* some checks */
for (i=0;i<TESTBED_MAX_MSG;i++)
if ( (handlers[i].msgId != i) &&
- (handlers[i].handler != &tb_undefined) )
+ (handlers[i].handler != &tb_undefined) )
GE_ASSERT(ectx, 0);
GE_ASSERT(ectx, handlers[TESTBED_MAX_MSG].handler == NULL);
identity = capi->requestService("identity");
@@ -1350,16 +1350,16 @@
coreAPI = capi;
GE_ASSERT(ectx, SYSERR !=
capi->registerClientExitHandler(&testbedClientExitHandler));
GE_ASSERT(ectx, SYSERR !=
capi->registerClientHandler(CS_PROTO_testbed_REQUEST,
-
(CSHandler)&csHandleTestbedRequest));
+
(CSHandler)&csHandleTestbedRequest));
httpRegister("startup");
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "testbed",
- gettext_noop("allows
construction of a P2P-testbed"
- "
(incomplete)")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "testbed",
+ gettext_noop("allows construction of
a P2P-testbed"
+ " (incomplete)")));
return OK;
}
@@ -1378,7 +1378,7 @@
if (pi->hasExited != NO)
kill(pi->pid, SIGKILL);
PTHREAD_JOIN(&pi->reader,
- &unused);
+ &unused);
FREENONNULL(pi->output);
FREE(pi);
}
@@ -1392,7 +1392,7 @@
"TESTBED unregistering handler %d\n",
CS_PROTO_testbed_REQUEST);
coreAPI->unregisterClientHandler(CS_PROTO_testbed_REQUEST,
- (CSHandler)&csHandleTestbedRequest);
+ (CSHandler)&csHandleTestbedRequest);
coreAPI->unregisterClientExitHandler(&testbedClientExitHandler);
coreAPI->releaseService(identity);
identity = NULL;
Modified: GNUnet/src/applications/testing/testing.c
===================================================================
--- GNUnet/src/applications/testing/testing.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/testing/testing.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -31,27 +31,27 @@
#include "gnunet_testing_lib.h"
static void updatePort(struct GC_Configuration *cfg,
- const char * section,
- unsigned short offset) {
+ const char * section,
+ unsigned short offset) {
unsigned long long old;
if ( (YES == GC_have_configuration_value(cfg,
- section,
- "PORT")) &&
+ section,
+ "PORT")) &&
(0 == GC_get_configuration_value_number(cfg,
- section,
- "PORT",
- 0,
- 65535,
- 65535,
- &old)) ) {
+ section,
+ "PORT",
+ 0,
+ 65535,
+ 65535,
+ &old)) ) {
old += offset;
GE_ASSERT(NULL,
- 0 == GC_set_configuration_value_number(cfg,
- NULL,
- section,
- "PORT",
- old));
+ 0 == GC_set_configuration_value_number(cfg,
+ NULL,
+ section,
+ "PORT",
+ old));
}
}
@@ -68,13 +68,13 @@
* @return OK on success, SYSERR on error
*/
int gnunet_testing_start_daemon(unsigned short app_port,
- unsigned short tra_offset,
- const char * gnunetd_home,
- const char * transports,
- const char * applications,
- pid_t * pid,
- PeerIdentity * peer,
- char ** configFile) {
+ unsigned short tra_offset,
+ const char * gnunetd_home,
+ const char * transports,
+ const char * applications,
+ pid_t * pid,
+ PeerIdentity * peer,
+ char ** configFile) {
int ret;
char * ipath;
char * dpath;
@@ -85,8 +85,8 @@
int round;
fprintf(stderr,
- "Starting peer on port %u\n",
- app_port);
+ "Starting peer on port %u\n",
+ app_port);
#if 0
/* do not usually do this -- may easily
exhaust entropy pool for hostkey generation... */
@@ -101,10 +101,10 @@
strcat(dpath, DIR_SEPARATOR_STR "gnunet-testing.conf");
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- dpath)) {
+ dpath)) {
fprintf(stderr,
- "Failed to read default configuration file `%s'\n",
- dpath);
+ "Failed to read default configuration file `%s'\n",
+ dpath);
GC_free(cfg);
FREE(dpath);
return SYSERR;
@@ -116,45 +116,45 @@
updatePort(cfg, "UDP6", tra_offset);
updatePort(cfg, "HTTP", tra_offset);
updatePort(cfg, "SMTP", tra_offset);
- GC_set_configuration_value_string(cfg,
- NULL,
- "PATHS",
- "GNUNETD_HOME",
- gnunetd_home);
+ GC_set_configuration_value_string(cfg,
+ NULL,
+ "PATHS",
+ "GNUNETD_HOME",
+ gnunetd_home);
if (transports != NULL)
- GC_set_configuration_value_string(cfg,
- NULL,
- "GNUNETD",
- "TRANSPORTS",
- transports);
+ GC_set_configuration_value_string(cfg,
+ NULL,
+ "GNUNETD",
+ "TRANSPORTS",
+ transports);
if (applications != NULL)
GC_set_configuration_value_string(cfg,
- NULL,
- "GNUNETD",
- "APPLICATIONS",
- applications);
+ NULL,
+ "GNUNETD",
+ "APPLICATIONS",
+ applications);
GC_set_configuration_value_number(cfg,
- NULL,
- "NETWORK",
- "PORT",
- app_port);
+ NULL,
+ "NETWORK",
+ "PORT",
+ app_port);
dpath = STRDUP("/tmp/gnunet-config.XXXXXX");
ret = mkstemp(dpath);
if (ret == -1) {
GE_LOG_STRERROR_FILE(NULL,
GE_ERROR | GE_USER | GE_BULK,
"mkstemp",
- dpath);
+ dpath);
FREE(dpath);
GC_free(cfg);
return SYSERR;
}
CLOSE(ret);
if (0 != GC_write_configuration(cfg,
- dpath)) {
+ dpath)) {
fprintf(stderr,
- "Failed to write peer configuration file `%s'\n",
- dpath);
+ "Failed to write peer configuration file `%s'\n",
+ dpath);
FREE(dpath);
GC_free(cfg);
return SYSERR;
@@ -164,22 +164,22 @@
cfg = GC_create_C_impl();
/* cfg is now client CFG for os_daemon_start */
SNPRINTF(host,
- 128,
- "localhost:%u",
- app_port);
+ 128,
+ "localhost:%u",
+ app_port);
GC_set_configuration_value_string(cfg,
- NULL,
- "NETWORK",
- "HOST",
- host);
+ NULL,
+ "NETWORK",
+ "HOST",
+ host);
ret = os_daemon_start(NULL,
- cfg,
- dpath,
- NO);
+ cfg,
+ dpath,
+ NO);
if (ret == -1) {
fprintf(stderr,
- "Failed to start daemon!\n");
+ "Failed to start daemon!\n");
GC_free(cfg);
return SYSERR;
}
@@ -190,10 +190,10 @@
maybe creating public keys and waiting for
entropy! */
if (OK != connection_wait_for_running(NULL,
- cfg,
- 15 * cronMINUTES)) {
+ cfg,
+ 15 * cronMINUTES)) {
fprintf(stderr,
- "Failed to confirm daemon running!\n");
+ "Failed to confirm daemon running!\n");
GC_free(cfg);
UNLINK(dpath);
FREE(dpath);
@@ -204,15 +204,15 @@
round = 0;
ret = SYSERR;
while ( (round++ < 10) &&
- (ret == SYSERR) ) {
+ (ret == SYSERR) ) {
sock = client_connection_create(NULL,
- cfg);
+ cfg);
ret = gnunet_identity_get_self(sock,
- &hello);
+ &hello);
if (ret == OK) {
hash(&hello->publicKey,
- sizeof(PublicKey),
- &peer->hashPubKey);
+ sizeof(PublicKey),
+ &peer->hashPubKey);
FREE(hello);
} else {
PTHREAD_SLEEP(2 * cronSECONDS);
@@ -222,7 +222,7 @@
GC_free(cfg);
if (ret == SYSERR)
fprintf(stderr,
- "Failed to obtain daemon's identity (is a transport loaded?)!\n");
+ "Failed to obtain daemon's identity (is a transport loaded?)!\n");
return ret;
@@ -237,7 +237,7 @@
* @return OK on success, SYSERR on failure
*/
int gnunet_testing_connect_daemons(unsigned short port1,
- unsigned short port2) {
+ unsigned short port2) {
char host[128];
GC_Configuration * cfg1 = GC_create_C_impl();
GC_Configuration * cfg2 = GC_create_C_impl();
@@ -249,60 +249,60 @@
ret = SYSERR;
SNPRINTF(host,
- 128,
- "localhost:%u",
- port1);
+ 128,
+ "localhost:%u",
+ port1);
GC_set_configuration_value_string(cfg1,
- NULL,
- "NETWORK",
- "HOST",
- host);
+ NULL,
+ "NETWORK",
+ "HOST",
+ host);
SNPRINTF(host,
- 128,
- "localhost:%u",
- port2);
+ 128,
+ "localhost:%u",
+ port2);
GC_set_configuration_value_string(cfg2,
- NULL,
- "NETWORK",
- "HOST",
- host);
+ NULL,
+ "NETWORK",
+ "HOST",
+ host);
if ( (OK == connection_wait_for_running(NULL,
- cfg1,
- 300 * cronSECONDS) ) &&
+ cfg1,
+ 300 * cronSECONDS) ) &&
(OK == connection_wait_for_running(NULL,
- cfg2,
- 300 * cronSECONDS) ) ) {
+ cfg2,
+ 300 * cronSECONDS) ) ) {
sock1 = client_connection_create(NULL,
- cfg1);
+ cfg1);
sock2 = client_connection_create(NULL,
- cfg2);
+ cfg2);
ret = - 10;
fprintf(stderr,
- _("Waiting for peers to connect"));
+ _("Waiting for peers to connect"));
while ( (ret++ < -1) &&
- (GNUNET_SHUTDOWN_TEST() == NO) ) {
+ (GNUNET_SHUTDOWN_TEST() == NO) ) {
h1 = NULL;
h2 = NULL;
if ( (OK == gnunet_identity_get_self(sock1,
- &h1)) &&
- (OK == gnunet_identity_get_self(sock2,
- &h2)) &&
- (OK == gnunet_identity_peer_add(sock1,
- h2)) &&
- (OK == gnunet_identity_peer_add(sock2,
- h1)) ) {
- fprintf(stderr, ".");
- if (YES == gnunet_identity_request_connect(sock1,
- &h2->senderIdentity)) {
- ret = OK;
- break;
- }
- if (YES == gnunet_identity_request_connect(sock2,
- &h1->senderIdentity)) {
- ret = OK;
- break;
- }
- PTHREAD_SLEEP(100 * cronMILLIS);
+ &h1)) &&
+ (OK == gnunet_identity_get_self(sock2,
+ &h2)) &&
+ (OK == gnunet_identity_peer_add(sock1,
+ h2)) &&
+ (OK == gnunet_identity_peer_add(sock2,
+ h1)) ) {
+ fprintf(stderr, ".");
+ if (YES == gnunet_identity_request_connect(sock1,
+ &h2->senderIdentity)) {
+ ret = OK;
+ break;
+ }
+ if (YES == gnunet_identity_request_connect(sock2,
+ &h1->senderIdentity)) {
+ ret = OK;
+ break;
+ }
+ PTHREAD_SLEEP(100 * cronMILLIS);
}
FREENONNULL(h1);
FREENONNULL(h2);
@@ -312,7 +312,7 @@
connection_destroy(sock2);
} else {
fprintf(stderr,
- "Failed to establish connection with peers.\n");
+ "Failed to establish connection with peers.\n");
}
GC_free(cfg1);
GC_free(cfg2);
@@ -327,7 +327,7 @@
* @return OK on success, SYSERR on failure
*/
int gnunet_testing_stop_daemon(unsigned short port,
- pid_t pid) {
+ pid_t pid) {
if (os_daemon_stop(NULL, pid) != YES)
return SYSERR;
return OK;
@@ -343,11 +343,11 @@
*/
struct DaemonContext *
gnunet_testing_start_daemons(const char * transports,
- const char * applications,
- const char * gnunetd_home_prefix,
- unsigned short app_baseport,
- unsigned short delta,
- unsigned int count) {
+ const char * applications,
+ const char * gnunetd_home_prefix,
+ unsigned short app_baseport,
+ unsigned short delta,
+ unsigned int count) {
struct DaemonContext * ret;
struct DaemonContext * nxt;
unsigned int pos;
@@ -362,18 +362,18 @@
home = MALLOC(max);
for (pos=0;pos<count;pos++) {
SNPRINTF(home,
- max,
- "%s.%u",
- gnunetd_home_prefix,
- pos);
+ max,
+ "%s.%u",
+ gnunetd_home_prefix,
+ pos);
if (OK != gnunet_testing_start_daemon(app_baseport + pos * delta,
- delta * pos,
- home,
- transports,
- applications,
- &pid,
- &peer,
- &cf)) {
+ delta * pos,
+ home,
+ transports,
+ applications,
+ &pid,
+ &peer,
+ &cf)) {
gnunet_testing_stop_daemons(ret);
ret = NULL;
break;
@@ -398,7 +398,7 @@
while (peers != NULL) {
next = peers->next;
if (OK != gnunet_testing_stop_daemon(peers->port,
- peers->pid))
+ peers->pid))
ret = SYSERR;
UNLINK(peers->configFile);
FREE(peers->configFile);
@@ -407,7 +407,7 @@
}
return ret;
}
-
+
Modified: GNUnet/src/applications/testing/testingtest.c
===================================================================
--- GNUnet/src/applications/testing/testingtest.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/testing/testingtest.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -33,7 +33,7 @@
* @return 0: ok, -1: error
*/
int main(int argc,
- const char ** argv) {
+ const char ** argv) {
pid_t daemon1;
pid_t daemon2;
PeerIdentity p1;
@@ -43,31 +43,31 @@
int ret = 0;
if (OK != gnunet_testing_start_daemon(12087,
- 10000,
- "/tmp/gnunet-testing-1",
- "tcp",
- "advertising stats",
- &daemon1,
- &p1,
- &c1))
+ 10000,
+ "/tmp/gnunet-testing-1",
+ "tcp",
+ "advertising stats",
+ &daemon1,
+ &p1,
+ &c1))
ret |= 1;
if (OK != gnunet_testing_start_daemon(22087,
- 20000,
- "/tmp/gnunet-testing-2",
- "tcp",
- "advertising stats",
- &daemon2,
- &p2,
- &c2))
+ 20000,
+ "/tmp/gnunet-testing-2",
+ "tcp",
+ "advertising stats",
+ &daemon2,
+ &p2,
+ &c2))
ret |= 2;
if (OK != gnunet_testing_connect_daemons(12087,
- 22087))
+ 22087))
ret |= 4;
if (OK != gnunet_testing_stop_daemon(12087,
- daemon1))
+ daemon1))
ret |= 8;
if (OK != gnunet_testing_stop_daemon(22087,
- daemon2))
+ daemon2))
ret |= 16;
if (c1 != NULL) {
UNLINK(c1);
Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/topology_default/topology.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -104,14 +104,14 @@
* @param im updated structure used to select the peer
*/
static int scanHelperCount(const PeerIdentity * id,
- unsigned short proto,
- int confirmed,
- void * data) {
+ unsigned short proto,
+ int confirmed,
+ void * data) {
IndexMatch * im = data;
if (0 == memcmp(coreAPI->myIdentity,
- id,
- sizeof(PeerIdentity)))
+ id,
+ sizeof(PeerIdentity)))
return OK;
if (coreAPI->computeIndex(id) != im->index)
return OK;
@@ -133,14 +133,14 @@
* @param im structure responsible for the selection process
*/
static int scanHelperSelect(const PeerIdentity * id,
- unsigned short proto,
- int confirmed,
- void * data) {
+ unsigned short proto,
+ int confirmed,
+ void * data) {
IndexMatch * im = data;
if (0 == memcmp(coreAPI->myIdentity,
- id,
- sizeof(PeerIdentity)))
+ id,
+ sizeof(PeerIdentity)))
return OK;
if (coreAPI->computeIndex(id) != im->index)
return OK;
@@ -149,7 +149,7 @@
if (YES == transport->isAvailable(proto)) {
im->costSelector -= transport->getCost(proto);
if ( (im->matchCount == 0) ||
- (im->costSelector < 0) ) {
+ (im->costSelector < 0) ) {
im->match = *id;
return SYSERR;
}
@@ -174,22 +174,22 @@
#endif
if (os_network_monitor_get_load(coreAPI->load_monitor,
- Upload) > 100)
+ Upload) > 100)
return; /* bandwidth saturated, do not
- push it higher! */
+ push it higher! */
now = get_time();
indexMatch.index = index;
indexMatch.matchCount = 0;
indexMatch.costSelector = 0;
identity->forEachHost(now,
- &scanHelperCount,
- &indexMatch);
+ &scanHelperCount,
+ &indexMatch);
if (indexMatch.matchCount == 0) {
#if DEBUG_TOPOLOGY
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "No peers found for slot %u\n",
- index);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "No peers found for slot %u\n",
+ index);
#endif
return; /* no matching peers found! */
}
@@ -198,11 +198,11 @@
= weak_randomi64(indexMatch.costSelector);
indexMatch.match = *(coreAPI->myIdentity);
identity->forEachHost(now,
- &scanHelperSelect,
- &indexMatch);
+ &scanHelperSelect,
+ &indexMatch);
if (0 == memcmp(coreAPI->myIdentity,
- &indexMatch.match,
- sizeof(PeerIdentity)))
+ &indexMatch.match,
+ sizeof(PeerIdentity)))
return; /* should happen really rarely */
if (coreAPI->computeIndex(&indexMatch.match) != index) {
GE_BREAK(NULL, 0); /* should REALLY not happen */
@@ -215,22 +215,22 @@
#if DEBUG_TOPOLOGY
IF_GELOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER | GE_DEVELOPER,
- hash2enc(&indexMatch.match.hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER | GE_DEVELOPER,
+ hash2enc(&indexMatch.match.hashPubKey,
+ &enc));
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER | GE_DEVELOPER,
- "Trying to connect to peer `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER | GE_DEVELOPER,
+ "Trying to connect to peer `%s'\n",
+ &enc);
#endif
if (NO == identity->isBlacklistedStrict(&indexMatch.match)) {
coreAPI->unicast(&indexMatch.match,
- NULL,
- 0,
- 0);
+ NULL,
+ 0,
+ 0);
identity->blacklistHost(&indexMatch.match,
- (unsigned int) (saturation * 5 * 60 * 60), /* 5
hours at full saturation */
- NO);
+ (unsigned int) (saturation * 5 * 60 * 60), /* 5 hours at
full saturation */
+ NO);
}
}
@@ -245,13 +245,13 @@
EncName enc;
IF_GELOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- hash2enc(&hostId->hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ hash2enc(&hostId->hashPubKey,
+ &enc));
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Received liveness confirmation from `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Received liveness confirmation from `%s'.\n",
+ &enc);
#endif
coreAPI->confirmSessionUp(hostId);
@@ -262,7 +262,7 @@
* Check the liveness of the peer and possibly ping it.
*/
static void checkNeedForPing(const PeerIdentity * peer,
- void * unused) {
+ void * unused) {
cron_t now;
cron_t act;
PeerIdentity * hi;
@@ -285,24 +285,24 @@
EncName enc;
IF_GELOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- hash2enc(&peer->hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ hash2enc(&peer->hashPubKey,
+ &enc));
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Peer `%s' was inactive for %llus. Sending PING.\n",
- &enc,
- (now-act)/cronSECONDS);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Peer `%s' was inactive for %llus. Sending PING.\n",
+ &enc,
+ (now-act)/cronSECONDS);
#endif
hi = MALLOC(sizeof(PeerIdentity));
*hi = *peer;
if (OK != pingpong->ping(peer,
- ¬ifyPONG,
- hi,
- NO,
- rand()))
+ ¬ifyPONG,
+ hi,
+ NO,
+ rand()))
FREE(hi);
}
}
@@ -322,9 +322,9 @@
int autoconnect;
autoconnect = GC_get_configuration_value_yesno(coreAPI->cfg,
- "GNUNETD",
- "DISABLE-AUTOCONNECT",
- NO);
+ "GNUNETD",
+ "DISABLE-AUTOCONNECT",
+ NO);
slotCount = coreAPI->getSlotCount();
if ( (NO == autoconnect) &&
(saturation < 1) ) {
@@ -334,13 +334,13 @@
minint = MAX_PEERS_PER_SLOT; /* never put more than 10 peers into a slot
*/
for (i=slotCount-1;i>=0;i--) {
if (weak_randomi(LIVE_SCAN_EFFECTIVENESS) != 0)
- continue;
- if (minint > coreAPI->isSlotUsed(i))
- scanForHosts(i);
+ continue;
+ if (minint > coreAPI->isSlotUsed(i))
+ scanForHosts(i);
}
}
active = coreAPI->forAllConnectedNodes(&checkNeedForPing,
- NULL);
+ NULL);
saturation = 1.0 * active / slotCount;
}
@@ -352,8 +352,8 @@
if (active == 0)
return 0;
known = identity->forEachHost(0,
- NULL,
- NULL);
+ NULL,
+ NULL);
if (active > known)
return active; /* should not be possible */
/* Assumption:
@@ -386,8 +386,8 @@
static int allowConnection(const PeerIdentity * peer) {
if ( (coreAPI->myIdentity != NULL) &&
(0 == memcmp(coreAPI->myIdentity,
- peer,
- sizeof(PeerIdentity))) )
+ peer,
+ sizeof(PeerIdentity))) )
return SYSERR; /* disallow connections to self */
return OK; /* allow everything else */
}
@@ -419,10 +419,10 @@
return NULL;
}
cron_add_job(capi->cron,
- &cronCheckLiveness,
- LIVE_SCAN_FREQUENCY,
- LIVE_SCAN_FREQUENCY,
- NULL);
+ &cronCheckLiveness,
+ LIVE_SCAN_FREQUENCY,
+ LIVE_SCAN_FREQUENCY,
+ NULL);
api.estimateNetworkSize = &estimateNetworkSize;
api.getSaturation = &estimateSaturation;
api.allowConnectionFrom = &allowConnection;
@@ -431,9 +431,9 @@
int release_module_topology_default() {
cron_del_job(coreAPI->cron,
- &cronCheckLiveness,
- LIVE_SCAN_FREQUENCY,
- NULL);
+ &cronCheckLiveness,
+ LIVE_SCAN_FREQUENCY,
+ NULL);
coreAPI->releaseService(identity);
identity = NULL;
coreAPI->releaseService(transport);
@@ -465,7 +465,7 @@
anyway) */
state = uapi->requestService("state");
state->unlink(NULL,
- TOPOLOGY_TAG_FILE);
+ TOPOLOGY_TAG_FILE);
uapi->releaseService(state);
state = NULL;
}
@@ -478,13 +478,13 @@
myCapi = capi;
myTopology = capi->requestService("topology");
GE_ASSERT(capi->ectx,
- myTopology != NULL);
+ myTopology != NULL);
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "topology",
- gettext_noop("maintains
GNUnet default mesh topology")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "topology",
+ gettext_noop("maintains GNUnet
default mesh topology")));
return OK;
}
Modified: GNUnet/src/applications/topology_f2f/topology.c
===================================================================
--- GNUnet/src/applications/topology_f2f/topology.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/topology_f2f/topology.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -103,13 +103,13 @@
if ( (coreAPI->myIdentity != NULL) &&
(0 == memcmp(coreAPI->myIdentity,
- peer,
- sizeof(PeerIdentity))) )
+ peer,
+ sizeof(PeerIdentity))) )
return SYSERR; /* disallow connections to self */
for (i=friendCount-1;i>=0;i--)
if (0 == memcmp(&friends[i],
- peer,
- sizeof(PeerIdentity)))
+ peer,
+ sizeof(PeerIdentity)))
return OK;
return SYSERR;
}
@@ -124,14 +124,14 @@
* @param im updated structure used to select the peer
*/
static int scanHelperCount(const PeerIdentity * id,
- const unsigned short proto,
- int confirmed,
- void * cls) {
+ const unsigned short proto,
+ int confirmed,
+ void * cls) {
IndexMatch * im = cls;
if (0 == memcmp(coreAPI->myIdentity,
- id,
- sizeof(PeerIdentity)))
+ id,
+ sizeof(PeerIdentity)))
return OK;
if (coreAPI->computeIndex(id) != im->index)
return OK;
@@ -152,13 +152,13 @@
* @param im structure responsible for the selection process
*/
static int scanHelperSelect(const PeerIdentity * id,
- const unsigned short proto,
- int confirmed,
- void * cls) {
+ const unsigned short proto,
+ int confirmed,
+ void * cls) {
IndexMatch * im = cls;
if (0 == memcmp(coreAPI->myIdentity,
- id,
- sizeof(PeerIdentity)))
+ id,
+ sizeof(PeerIdentity)))
return OK;
if (coreAPI->computeIndex(id) != im->index)
return OK;
@@ -166,7 +166,7 @@
(YES == transport->isAvailable(proto)) ) {
im->costSelector -= transport->getCost(proto);
if ( (im->matchCount == 0) ||
- (im->costSelector < 0) ) {
+ (im->costSelector < 0) ) {
im->match = *id;
return SYSERR; /* abort iteration */
}
@@ -192,8 +192,8 @@
indexMatch.matchCount = 0;
indexMatch.costSelector = 0;
identity->forEachHost(now,
- &scanHelperCount,
- &indexMatch);
+ &scanHelperCount,
+ &indexMatch);
if (indexMatch.matchCount == 0)
return; /* no matching peers found! */
if (indexMatch.costSelector > 0)
@@ -201,11 +201,11 @@
= weak_randomi(indexMatch.costSelector/4)*4;
indexMatch.match = *(coreAPI->myIdentity);
identity->forEachHost(now,
- &scanHelperSelect,
- &indexMatch);
+ &scanHelperSelect,
+ &indexMatch);
if (0 == memcmp(coreAPI->myIdentity,
- &indexMatch.match,
- sizeof(PeerIdentity))) {
+ &indexMatch.match,
+ sizeof(PeerIdentity))) {
GE_BREAK(ectx, 0); /* should not happen, at least not often... */
return;
}
@@ -214,18 +214,18 @@
return;
}
hash2enc(&indexMatch.match.hashPubKey,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Topology: trying to connect to `%s'.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Topology: trying to connect to `%s'.\n",
+ &enc);
coreAPI->unicast(&indexMatch.match,
- NULL,
- 0,
- 0);
+ NULL,
+ 0,
+ 0);
identity->blacklistHost(&indexMatch.match,
- (unsigned int) 5 * 60 * 60 * saturation, /* 5h at
full saturation */
- NO);
+ (unsigned int) 5 * 60 * 60 * saturation, /* 5h at full
saturation */
+ NO);
}
/**
@@ -252,7 +252,7 @@
* Check the liveness of the ping and possibly ping it.
*/
static void checkNeedForPing(const PeerIdentity * peer,
- void * unused) {
+ void * unused) {
cron_t now;
cron_t act;
#if DEBUG_TOPOLOGY
@@ -280,11 +280,11 @@
"Sending ping to `%s' to prevent connection timeout.\n",
(char*)&enc);
#endif
- if (OK != pingpong->ping(peer,
- ¬ifyPONG,
- hi,
- NO,
- rand()))
+ if (OK != pingpong->ping(peer,
+ ¬ifyPONG,
+ hi,
+ NO,
+ rand()))
FREE(hi);
}
}
@@ -303,13 +303,13 @@
if (saturation < 1) {
for (i=slotCount-1;i>=0;i--) {
if (weak_randomi(LIVE_SCAN_EFFECTIVENESS) != 0)
- continue;
- if (0 == coreAPI->isSlotUsed(i))
- scanForHosts(i);
+ continue;
+ if (0 == coreAPI->isSlotUsed(i))
+ scanForHosts(i);
}
}
active = coreAPI->forAllConnectedNodes(&checkNeedForPing,
- NULL);
+ NULL);
saturation = 1.0 * active / slotCount;
}
@@ -322,10 +322,10 @@
}
static int rereadConfiguration(void * ctx,
- struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option) {
+ struct GC_Configuration * cfg,
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option) {
char * fn;
char * data;
unsigned long long size;
@@ -340,25 +340,25 @@
0);
fn = NULL;
GC_get_configuration_value_filename(cfg,
- "F2F",
- "FRIENDS",
- VAR_DAEMON_DIRECTORY "/friends",
- &fn);
+ "F2F",
+ "FRIENDS",
+ VAR_DAEMON_DIRECTORY "/friends",
+ &fn);
if ( (0 == disk_file_test(ectx, fn)) ||
(OK != disk_file_size(ectx, fn, &size, YES)) ) {
GE_LOG(ectx,
- GE_USER | GE_ADMIN | GE_ERROR | GE_IMMEDIATE,
- "Could not read friends list `%s'\n",
- fn);
+ GE_USER | GE_ADMIN | GE_ERROR | GE_IMMEDIATE,
+ "Could not read friends list `%s'\n",
+ fn);
FREE(fn);
return SYSERR;
}
data = MALLOC(size);
if (size != disk_file_read(ectx, fn, size, data)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Failed to read friends list from `%s'\n"),
- fn);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Failed to read friends list from `%s'\n"),
+ fn);
FREE(fn);
FREE(data);
return SYSERR;
@@ -366,34 +366,34 @@
FREE(fn);
pos = 0;
while ( (pos < size) &&
- isspace(data[pos]))
+ isspace(data[pos]))
pos++;
while (pos <= size - sizeof(EncName)) {
memcpy(&enc,
- &data[pos],
- sizeof(EncName));
+ &data[pos],
+ sizeof(EncName));
if (! isspace(enc.encoding[sizeof(EncName)-1])) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Syntax error in topology specification, skipping bytes.\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Syntax error in topology specification, skipping bytes.\n"));
continue;
}
enc.encoding[sizeof(EncName)-1] = '\0';
if (OK == enc2hash((char*)&enc,
- &hc)) {
+ &hc)) {
GROW(friends,
- friendCount,
- friendCount+1);
+ friendCount,
+ friendCount+1);
friends[friendCount-1].hashPubKey = hc;
} else {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Syntax error in topology specification, skipping bytes
`%s'.\n"),
- &enc);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Syntax error in topology specification, skipping bytes `%s'.\n"),
+ &enc);
}
pos = pos + sizeof(EncName);
while ( (pos < size) &&
- isspace(data[pos]))
+ isspace(data[pos]))
pos++;
}
return OK;
@@ -427,8 +427,8 @@
return NULL;
}
if (0 != GC_attach_change_listener(coreAPI->cfg,
- &rereadConfiguration,
- NULL)) {
+ &rereadConfiguration,
+ NULL)) {
capi->releaseService(identity);
identity = NULL;
capi->releaseService(transport);
@@ -439,10 +439,10 @@
}
cron_add_job(coreAPI->cron,
- &cronCheckLiveness,
- LIVE_SCAN_FREQUENCY,
- LIVE_SCAN_FREQUENCY,
- NULL);
+ &cronCheckLiveness,
+ LIVE_SCAN_FREQUENCY,
+ LIVE_SCAN_FREQUENCY,
+ NULL);
api.estimateNetworkSize = &estimateNetworkSize;
api.getSaturation = &estimateSaturation;
api.allowConnectionFrom = &allowConnection;
@@ -451,12 +451,12 @@
int release_module_topology_f2f() {
cron_del_job(coreAPI->cron,
- &cronCheckLiveness,
- LIVE_SCAN_FREQUENCY,
- NULL);
+ &cronCheckLiveness,
+ LIVE_SCAN_FREQUENCY,
+ NULL);
GC_detach_change_listener(coreAPI->cfg,
- &rereadConfiguration,
- NULL);
+ &rereadConfiguration,
+ NULL);
coreAPI->releaseService(identity);
identity = NULL;
coreAPI->releaseService(transport);
@@ -478,11 +478,11 @@
myTopology = capi->requestService("topology");
GE_ASSERT(ectx, myTopology != NULL);
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "topology",
- gettext_noop("maintains a
friend-to-friend restricted topology")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "topology",
+ gettext_noop("maintains a
friend-to-friend restricted topology")));
return OK;
}
Modified: GNUnet/src/applications/tracekit/gnunet-tracekit.c
===================================================================
--- GNUnet/src/applications/tracekit/gnunet-tracekit.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/tracekit/gnunet-tracekit.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -65,17 +65,17 @@
static unsigned int
getConfigurationInt(const char * sec,
- const char * opt,
- unsigned int max) {
+ const char * opt,
+ unsigned int max) {
unsigned long long val;
GC_get_configuration_value_number(cfg,
- sec,
- opt,
- 0,
- max,
- 0,
- &val);
+ sec,
+ opt,
+ 0,
+ max,
+ 0,
+ &val);
return (unsigned int) val;
}
@@ -106,14 +106,14 @@
buffer = MALLOC(MAX_BUFFER_SIZE);
if (-1 ==
GC_get_configuration_value_number(cfg,
- "GNUNET-TRACEKIT",
- "FORMAT",
- 0,
- 2,
- 0,
- &format)) {
+ "GNUNET-TRACEKIT",
+ "FORMAT",
+ 0,
+ 2,
+ 0,
+ &format)) {
printf(_("Format specification invalid. "
- "Use 0 for user-readable, 1 for dot, 2 for vcg.\n"));
+ "Use 0 for user-readable, 1 for dot, 2 for vcg.\n"));
SEMAPHORE_UP(doneSem);
FREE(peersResponding);
FREE(peersSeen);
@@ -125,7 +125,7 @@
if (format == 2)
printf("graph: {\n");
while (OK == connection_read(sock,
- (MESSAGE_HEADER**)&buffer)) {
+ (MESSAGE_HEADER**)&buffer)) {
int count;
EncName enc;
@@ -135,84 +135,84 @@
break; /* faulty reply */
}
hash2enc(&buffer->responderId.hashPubKey,
- &enc);
+ &enc);
match = NO;
for (j=0;j<prCount;j++)
if (equalsHashCode512(&buffer->responderId.hashPubKey,
- &peersResponding[j].hashPubKey))
- match = YES;
+ &peersResponding[j].hashPubKey))
+ match = YES;
if (match == NO) {
if (prCount == prSize)
- GROW(peersResponding,
- prSize,
- prSize*2);
+ GROW(peersResponding,
+ prSize,
+ prSize*2);
memcpy(&peersResponding[prCount++],
- &buffer->responderId.hashPubKey,
- sizeof(PeerIdentity));
+ &buffer->responderId.hashPubKey,
+ sizeof(PeerIdentity));
}
count = count / sizeof(PeerIdentity);
if (ntohs(buffer->header.size) !=
- sizeof(CS_tracekit_reply_MESSAGE) +
- count * sizeof(PeerIdentity)) {
+ sizeof(CS_tracekit_reply_MESSAGE) +
+ count * sizeof(PeerIdentity)) {
GE_BREAK(ectx, 0);
break;
}
if (count == 0) {
switch (format) {
case 0:
- printf(_("`%s' is not connected to any peer.\n"),
- (char*)&enc);
- break;
+ printf(_("`%s' is not connected to any peer.\n"),
+ (char*)&enc);
+ break;
case 1:
- printf(" %.*s;\n",
- 4, (char*)&enc);
- break;
+ printf(" %.*s;\n",
+ 4, (char*)&enc);
+ break;
case 2:
- /* deferred -- vcg needs all node data in one line */
- break;
+ /* deferred -- vcg needs all node data in one line */
+ break;
}
} else {
EncName other;
for (i=0;i<count;i++) {
- match = NO;
- for (j=0;j<psCount;j++)
- if
(equalsHashCode512(&((CS_tracekit_reply_MESSAGE_GENERIC*)buffer)->peerList[i].hashPubKey,
- &peersSeen[j].hashPubKey))
- match = YES;
- if (match == NO) {
- if (psCount == psSize)
- GROW(peersSeen,
- psSize,
- psSize * 2);
- memcpy(&peersSeen[psCount++],
-
&((CS_tracekit_reply_MESSAGE_GENERIC*)buffer)->peerList[i].hashPubKey,
- sizeof(PeerIdentity));
- }
+ match = NO;
+ for (j=0;j<psCount;j++)
+ if
(equalsHashCode512(&((CS_tracekit_reply_MESSAGE_GENERIC*)buffer)->peerList[i].hashPubKey,
+ &peersSeen[j].hashPubKey))
+ match = YES;
+ if (match == NO) {
+ if (psCount == psSize)
+ GROW(peersSeen,
+ psSize,
+ psSize * 2);
+ memcpy(&peersSeen[psCount++],
+ &((CS_tracekit_reply_MESSAGE_GENERIC*)buffer)->peerList[i].hashPubKey,
+ sizeof(PeerIdentity));
+ }
-
hash2enc(&((CS_tracekit_reply_MESSAGE_GENERIC*)buffer)->peerList[i].hashPubKey,
- &other);
- switch (format) {
- case 0:
- printf(_("`%s' connected to `%s'.\n"),
- (char*)&enc,
- (char*)&other);
- break;
- case 1: /* dot */
- printf(" \"%.*s\" -> \"%.*s\";\n",
- 4, (char*)&enc,
- 4, (char*)&other);
- break;
- case 2: /* vcg */
- printf("\tedge: { sourcename: \"%s\" targetname: \"%s\" }\n",
- (char*)&enc,
- (char*)&other);
- break;
- default: /* undef */
- printf(_("Format specification invalid. "
- "Use 0 for user-readable, 1 for dot\n"));
- break;
- }
+
hash2enc(&((CS_tracekit_reply_MESSAGE_GENERIC*)buffer)->peerList[i].hashPubKey,
+ &other);
+ switch (format) {
+ case 0:
+ printf(_("`%s' connected to `%s'.\n"),
+ (char*)&enc,
+ (char*)&other);
+ break;
+ case 1: /* dot */
+ printf(" \"%.*s\" -> \"%.*s\";\n",
+ 4, (char*)&enc,
+ 4, (char*)&other);
+ break;
+ case 2: /* vcg */
+ printf("\tedge: { sourcename: \"%s\" targetname: \"%s\" }\n",
+ (char*)&enc,
+ (char*)&other);
+ break;
+ default: /* undef */
+ printf(_("Format specification invalid. "
+ "Use 0 for user-readable, 1 for dot\n"));
+ break;
+ }
}
}
}
@@ -223,41 +223,41 @@
match = NO;
for (j=0;j<prCount;j++)
if (equalsHashCode512(&peersResponding[j].hashPubKey,
- &peersSeen[i].hashPubKey)) {
- match = YES;
- break;
+ &peersSeen[i].hashPubKey)) {
+ match = YES;
+ break;
}
if (match == NO) {
hash2enc(&peersSeen[i].hashPubKey,
- &enc);
+ &enc);
switch (format) {
case 0:
- printf(_("Peer `%s' did not report back.\n"),
- (char*)&enc);
- break;
+ printf(_("Peer `%s' did not report back.\n"),
+ (char*)&enc);
+ break;
case 1:
- printf(" \"%.*s\" [style=filled,color=\".7 .3 1.0\"];\n",
- 4,
- (char*)&enc);
- break;
+ printf(" \"%.*s\" [style=filled,color=\".7 .3 1.0\"];\n",
+ 4,
+ (char*)&enc);
+ break;
case 2:
- printf("\tnode: { title: \"%s\" label: \"%.*s\" shape: \"ellipse\" }\n",
- (char*)&enc,
- 4, (char*) &enc);
- break;
+ printf("\tnode: { title: \"%s\" label: \"%.*s\" shape: \"ellipse\" }\n",
+ (char*)&enc,
+ 4, (char*) &enc);
+ break;
default:
- break;
+ break;
}
} else {
switch (format) {
case 2:
- hash2enc(&peersSeen[i].hashPubKey,
- &enc);
- printf("\tnode: { title: \"%s\" label: \"%.*s\" }\n",
- (char*)&enc, 4, (char*)&enc);
- break;
+ hash2enc(&peersSeen[i].hashPubKey,
+ &enc);
+ printf("\tnode: { title: \"%s\" label: \"%.*s\" }\n",
+ (char*)&enc, 4, (char*)&enc);
+ break;
default:
- break;
+ break;
}
}
}
@@ -286,7 +286,7 @@
* @return return value from gnunet-tracekit: 0: ok, -1: error
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
struct ClientServerConnection * sock;
struct PTHREAD * messageReceiveThread;
void * unused;
@@ -297,12 +297,12 @@
int res;
res = GNUNET_init(argc,
- argv,
- "gnunet-tracekit",
- &cfgFilename,
- gnunettracekitOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-tracekit",
+ &cfgFilename,
+ gnunettracekitOptions,
+ &ectx,
+ &cfg);
if (res == -1) {
GNUNET_fini(ectx, cfg);
return -1;
@@ -310,19 +310,19 @@
sock = client_connection_create(ectx, cfg);
if (sock == NULL) {
fprintf(stderr,
- _("Error establishing connection with gnunetd.\n"));
+ _("Error establishing connection with gnunetd.\n"));
GNUNET_fini(ectx, cfg);
return 1;
}
doneSem = SEMAPHORE_CREATE(0);
messageReceiveThread = PTHREAD_CREATE(&receiveThread,
- sock,
- 128 * 1024);
+ sock,
+ 128 * 1024);
if (messageReceiveThread == NULL)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_IMMEDIATE | GE_ADMIN,
- "pthread_create");
+ GE_FATAL | GE_IMMEDIATE | GE_ADMIN,
+ "pthread_create");
probe.header.size
= htons(sizeof(CS_tracekit_probe_MESSAGE));
@@ -330,31 +330,31 @@
= htons(CS_PROTO_tracekit_PROBE);
probe.hops
= htonl(getConfigurationInt("GNUNET-TRACEKIT",
- "HOPS",
- 0xFFFFFFFF));
+ "HOPS",
+ 0xFFFFFFFF));
probe.priority
= htonl(getConfigurationInt("GNUNET-TRACEKIT",
- "PRIORITY",
- 0xFFFFFFFF));
+ "PRIORITY",
+ 0xFFFFFFFF));
if (SYSERR == connection_write(sock,
- &probe.header)) {
+ &probe.header)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Could not send request to gnunetd.\n"));
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Could not send request to gnunetd.\n"));
return -1;
}
cron = cron_create(ectx);
cron_start(cron);
sleepTime = getConfigurationInt("GNUNET-TRACEKIT",
"WAIT",
- 0xFFFFFFFF);
+ 0xFFFFFFFF);
if (sleepTime == 0)
sleepTime = 5;
cron_add_job(cron,
- &run_shutdown,
- cronSECONDS * sleepTime,
- 0,
- NULL);
+ &run_shutdown,
+ cronSECONDS * sleepTime,
+ 0,
+ NULL);
GNUNET_SHUTDOWN_WAITFOR();
connection_close_forever(sock);
SEMAPHORE_DOWN(doneSem, YES);
Modified: GNUnet/src/applications/tracekit/tracekit.c
===================================================================
--- GNUnet/src/applications/tracekit/tracekit.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/tracekit/tracekit.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -51,7 +51,7 @@
static RTE * routeTable[MAXROUTE];
static int handlep2pReply(const PeerIdentity * sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
unsigned int i;
unsigned int hostCount;
P2P_tracekit_reply_MESSAGE * reply;
@@ -59,84 +59,84 @@
EncName sen;
hash2enc(&sender->hashPubKey,
- &sen);
+ &sen);
hostCount =
(ntohs(message->size)-sizeof(P2P_tracekit_reply_MESSAGE))/sizeof(PeerIdentity);
if (ntohs(message->size) !=
sizeof(P2P_tracekit_reply_MESSAGE)+hostCount*sizeof(PeerIdentity)) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Received invalid `%s' message from `%s'.\n"),
- "P2P_tracekit_probe_MESSAGE",
- &sen);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Received invalid `%s' message from `%s'.\n"),
+ "P2P_tracekit_probe_MESSAGE",
+ &sen);
return SYSERR;
}
reply = (P2P_tracekit_reply_MESSAGE*)message;
hash2enc(&reply->initiatorId.hashPubKey,
- &initiator);
+ &initiator);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: Sending reply back to initiator `%s'.\n",
- &initiator);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: Sending reply back to initiator `%s'.\n",
+ &initiator);
MUTEX_LOCK(lock);
for (i=0;i<MAXROUTE;i++) {
if (routeTable[i] == NULL)
continue;
if ( (routeTable[i]->timestamp ==
(TIME_T)ntohl(reply->initiatorTimestamp)) &&
- (0 == memcmp(&routeTable[i]->initiator.hashPubKey,
- &reply->initiatorId.hashPubKey,
- sizeof(HashCode512)) ) ) {
+ (0 == memcmp(&routeTable[i]->initiator.hashPubKey,
+ &reply->initiatorId.hashPubKey,
+ sizeof(HashCode512)) ) ) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: found matching entry in routing table\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: found matching entry in routing table\n");
if (0 == memcmp(&coreAPI->myIdentity->hashPubKey,
- &routeTable[i]->replyTo.hashPubKey,
- sizeof(HashCode512)) ) {
- unsigned int idx;
- CS_tracekit_reply_MESSAGE * csReply;
+ &routeTable[i]->replyTo.hashPubKey,
+ sizeof(HashCode512)) ) {
+ unsigned int idx;
+ CS_tracekit_reply_MESSAGE * csReply;
- idx = ntohl(reply->clientId);
- GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: I am initiator, sending to client.\n");
- if (idx >= clientCount) {
- GE_BREAK(ectx, 0);
- continue; /* discard */
- }
- if (clients[idx] == NULL) {
- GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: received response on slot %u, but client already
exited.\n",
- idx);
- continue; /* discard */
- }
-
- csReply =
MALLOC(sizeof(CS_tracekit_reply_MESSAGE)+hostCount*sizeof(PeerIdentity));
- /* build msg */
- csReply->header.size
- =
htons(sizeof(CS_tracekit_reply_MESSAGE)+hostCount*sizeof(PeerIdentity));
- csReply->header.type
- = htons(CS_PROTO_tracekit_REPLY);
- csReply->responderId
- = reply->responderId;
- memcpy(&((CS_tracekit_reply_MESSAGE_GENERIC*)csReply)->peerList[0],
- &((P2P_tracekit_reply_MESSAGE_GENERIC*)reply)->peerList[0],
- hostCount * sizeof(PeerIdentity));
- coreAPI->sendToClient(clients[idx],
- &csReply->header);
- FREE(csReply);
+ idx = ntohl(reply->clientId);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: I am initiator, sending to client.\n");
+ if (idx >= clientCount) {
+ GE_BREAK(ectx, 0);
+ continue; /* discard */
+ }
+ if (clients[idx] == NULL) {
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: received response on slot %u, but client already exited.\n",
+ idx);
+ continue; /* discard */
+ }
+
+ csReply =
MALLOC(sizeof(CS_tracekit_reply_MESSAGE)+hostCount*sizeof(PeerIdentity));
+ /* build msg */
+ csReply->header.size
+ = htons(sizeof(CS_tracekit_reply_MESSAGE)+hostCount*sizeof(PeerIdentity));
+ csReply->header.type
+ = htons(CS_PROTO_tracekit_REPLY);
+ csReply->responderId
+ = reply->responderId;
+ memcpy(&((CS_tracekit_reply_MESSAGE_GENERIC*)csReply)->peerList[0],
+ &((P2P_tracekit_reply_MESSAGE_GENERIC*)reply)->peerList[0],
+ hostCount * sizeof(PeerIdentity));
+ coreAPI->sendToClient(clients[idx],
+ &csReply->header);
+ FREE(csReply);
} else {
- EncName hop;
+ EncName hop;
- hash2enc(&routeTable[i]->replyTo.hashPubKey,
- &hop);
- GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: forwarding to next hop `%s'\n",
- &hop);
- coreAPI->unicast(&routeTable[i]->replyTo,
- message,
- routeTable[i]->priority,
- 0);
+ hash2enc(&routeTable[i]->replyTo.hashPubKey,
+ &hop);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: forwarding to next hop `%s'\n",
+ &hop);
+ coreAPI->unicast(&routeTable[i]->replyTo,
+ message,
+ routeTable[i]->priority,
+ 0);
}
}
}
@@ -152,12 +152,12 @@
} Tracekit_Collect_Trace_Closure;
static void getPeerCallback(const PeerIdentity * id,
- void * cls) {
+ void * cls) {
Tracekit_Collect_Trace_Closure * closure = cls;
if (closure->pos == closure->max) {
GROW(closure->peers,
- closure->max,
- closure->max + 32);
+ closure->max,
+ closure->max + 32);
}
if (closure->pos < closure->max) {
/* check needed since #connections may change anytime! */
@@ -166,19 +166,19 @@
}
static void transmit(const PeerIdentity * id,
- void * cls) {
+ void * cls) {
P2P_tracekit_probe_MESSAGE * pro = cls;
if (0 != memcmp(id,
- &pro->initiatorId,
- sizeof(PeerIdentity)))
+ &pro->initiatorId,
+ sizeof(PeerIdentity)))
coreAPI->unicast(id,
- &pro->header,
- ntohl(pro->priority),
- 0);
+ &pro->header,
+ ntohl(pro->priority),
+ 0);
}
static int handlep2pProbe(const PeerIdentity * sender,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
P2P_tracekit_reply_MESSAGE * reply;
P2P_tracekit_probe_MESSAGE * msg;
Tracekit_Collect_Trace_Closure closure;
@@ -193,46 +193,46 @@
TIME_T now;
hash2enc(&sender->hashPubKey,
- &sen);
+ &sen);
if (ntohs(message->size) !=
sizeof(P2P_tracekit_probe_MESSAGE)) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Received invalid `%s' message from `%s'.\n"),
- "P2P_tracekit_probe_MESSAGE",
- &sen);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Received invalid `%s' message from `%s'.\n"),
+ "P2P_tracekit_probe_MESSAGE",
+ &sen);
return SYSERR;
}
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: received probe\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: received probe\n");
TIME(&now);
msg = (P2P_tracekit_probe_MESSAGE*) message;
if ((TIME_T)ntohl(msg->timestamp) > 3600 + now) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: probe has timestamp in the far future (%d > %d),
dropping\n",
- ntohl(msg->timestamp),
- 3600 + now);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: probe has timestamp in the far future (%d > %d), dropping\n",
+ ntohl(msg->timestamp),
+ 3600 + now);
return SYSERR; /* Timestamp is more than 1h in the future. Invalid! */
}
hash2enc(&msg->initiatorId.hashPubKey,
- &init);
+ &init);
MUTEX_LOCK(lock);
/* test if already processed */
for (i=0;i<MAXROUTE;i++) {
if (routeTable[i] == NULL)
continue;
if ( (routeTable[i]->timestamp == (TIME_T)ntohl(msg->timestamp)) &&
- 0 == memcmp(&routeTable[i]->initiator.hashPubKey,
- &msg->initiatorId.hashPubKey,
- sizeof(HashCode512)) ) {
+ 0 == memcmp(&routeTable[i]->initiator.hashPubKey,
+ &msg->initiatorId.hashPubKey,
+ sizeof(HashCode512)) ) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT-PROBE %d from `%s' received twice (slot %d), ignored\n",
- ntohl(msg->timestamp),
- &init,
- i);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT-PROBE %d from `%s' received twice (slot %d), ignored\n",
+ ntohl(msg->timestamp),
+ &init,
+ i);
MUTEX_UNLOCK(lock);
return OK;
}
@@ -259,8 +259,8 @@
if (sel == -1) {
MUTEX_UNLOCK(lock);
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- _("TRACEKIT: routing table full, trace request dropped\n"));
+ GE_INFO | GE_REQUEST | GE_USER,
+ _("TRACEKIT: routing table full, trace request dropped\n"));
return OK;
}
if (routeTable[sel] == NULL)
@@ -275,24 +275,24 @@
= *sender;
MUTEX_UNLOCK(lock);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT-PROBE started at %d by peer `%s' received, processing in
slot %d with %u hops\n",
- ntohl(msg->timestamp),
- &init,
- sel,
- ntohl(msg->hopsToGo));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT-PROBE started at %d by peer `%s' received, processing in slot %d
with %u hops\n",
+ ntohl(msg->timestamp),
+ &init,
+ sel,
+ ntohl(msg->hopsToGo));
hops = ntohl(msg->hopsToGo);
/* forward? */
if (hops > 0) {
msg->hopsToGo = htonl(hops-1);
coreAPI->forAllConnectedNodes(&transmit,
- msg);
+ msg);
}
closure.peers = NULL;
closure.max = 0;
closure.pos = 0;
coreAPI->forAllConnectedNodes(&getPeerCallback,
- &closure);
+ &closure);
/* build local reply */
while (closure.pos > 0) {
count = closure.pos;
@@ -313,17 +313,17 @@
reply->clientId
= msg->clientId;
memcpy(&reply[1],
- &closure.peers[closure.pos - count],
- count * sizeof(PeerIdentity));
+ &closure.peers[closure.pos - count],
+ count * sizeof(PeerIdentity));
if (equalsHashCode512(&coreAPI->myIdentity->hashPubKey,
- &sender->hashPubKey)) {
+ &sender->hashPubKey)) {
handlep2pReply(coreAPI->myIdentity,
- &reply->header);
+ &reply->header);
} else {
coreAPI->unicast(sender,
- &reply->header,
- ntohl(msg->priority),
- 0);
+ &reply->header,
+ ntohl(msg->priority),
+ 0);
}
closure.pos -= count;
FREE(reply);
@@ -335,24 +335,24 @@
}
static int csHandle(struct ClientHandle * client,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
int i;
int idx;
CS_tracekit_probe_MESSAGE * csProbe;
P2P_tracekit_probe_MESSAGE p2pProbe;
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: client sends probe request\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: client sends probe request\n");
/* build probe, broadcast */
csProbe = (CS_tracekit_probe_MESSAGE*) message;
if (ntohs(csProbe->header.size) !=
sizeof(CS_tracekit_probe_MESSAGE) ) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("TRACEKIT: received invalid `%s' message\n"),
- "CS_tracekit_probe_MESSAGE");
+ GE_WARNING | GE_BULK | GE_USER,
+ _("TRACEKIT: received invalid `%s' message\n"),
+ "CS_tracekit_probe_MESSAGE");
return SYSERR;
}
@@ -364,23 +364,23 @@
break;
}
if ( (clients[i] == NULL) &&
- (idx == -1) ) {
+ (idx == -1) ) {
idx = i;
break;
}
}
if (idx == -1) {
GROW(clients,
- clientCount,
- clientCount+1);
+ clientCount,
+ clientCount+1);
idx = clientCount-1;
}
clients[idx] = client;
MUTEX_UNLOCK(lock);
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: client joins in slot %u.\n",
- idx);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: client joins in slot %u.\n",
+ idx);
p2pProbe.header.size
= htons(sizeof(P2P_tracekit_probe_MESSAGE));
@@ -395,10 +395,10 @@
p2pProbe.priority
= csProbe->priority;
memcpy(&p2pProbe.initiatorId,
- coreAPI->myIdentity,
- sizeof(PeerIdentity));
+ coreAPI->myIdentity,
+ sizeof(PeerIdentity));
handlep2pProbe(coreAPI->myIdentity,
- &p2pProbe.header); /* FIRST send to myself! */
+ &p2pProbe.header); /* FIRST send to myself! */
return OK;
}
@@ -409,21 +409,21 @@
for (i=0;i<clientCount;i++)
if (clients[i] == c) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT: client in slot %u exits.\n",
- i);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT: client in slot %u exits.\n",
+ i);
clients[i] = NULL;
break;
}
i=clientCount-1;
while ( (i >= 0) &&
- (clients[i] == NULL) )
+ (clients[i] == NULL) )
i--;
i++;
if (i != clientCount)
GROW(clients,
- clientCount,
- i);
+ clientCount,
+ i);
MUTEX_UNLOCK(lock);
}
@@ -434,31 +434,31 @@
lock = MUTEX_CREATE(NO);
coreAPI = capi;
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "TRACEKIT registering handlers %d %d and %d\n",
- P2P_PROTO_tracekit_PROBE,
- P2P_PROTO_tracekit_REPLY,
- CS_PROTO_tracekit_PROBE);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "TRACEKIT registering handlers %d %d and %d\n",
+ P2P_PROTO_tracekit_PROBE,
+ P2P_PROTO_tracekit_REPLY,
+ CS_PROTO_tracekit_PROBE);
memset(routeTable,
- 0,
- MAXROUTE*sizeof(RTE*));
+ 0,
+ MAXROUTE*sizeof(RTE*));
if (SYSERR == capi->registerHandler(P2P_PROTO_tracekit_PROBE,
- &handlep2pProbe))
+ &handlep2pProbe))
ok = SYSERR;
if (SYSERR == capi->registerHandler(P2P_PROTO_tracekit_REPLY,
- &handlep2pReply))
+ &handlep2pReply))
ok = SYSERR;
if (SYSERR == capi->registerClientExitHandler(&clientExitHandler))
ok = SYSERR;
if (SYSERR == capi->registerClientHandler(CS_PROTO_tracekit_PROBE,
- (CSHandler)&csHandle))
+ (CSHandler)&csHandle))
ok = SYSERR;
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "tracekit",
- gettext_noop("allows mapping
of the network topology")));
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "tracekit",
+ gettext_noop("allows mapping of the
network topology")));
return ok;
}
@@ -466,12 +466,12 @@
int i;
coreAPI->unregisterHandler(P2P_PROTO_tracekit_PROBE,
- &handlep2pProbe);
+ &handlep2pProbe);
coreAPI->unregisterHandler(P2P_PROTO_tracekit_REPLY,
- &handlep2pReply);
+ &handlep2pReply);
coreAPI->unregisterClientExitHandler(&clientExitHandler);
coreAPI->unregisterClientHandler(CS_PROTO_tracekit_PROBE,
- &csHandle);
+ &csHandle);
for (i=0;i<MAXROUTE;i++) {
FREENONNULL(routeTable[i]);
routeTable[i] = NULL;
Modified: GNUnet/src/applications/traffic/clientapi.c
===================================================================
--- GNUnet/src/applications/traffic/clientapi.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/traffic/clientapi.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -44,13 +44,13 @@
* @return OK on success, SYSERR on error
*/
int gnunet_traffic_poll(struct ClientServerConnection * sock,
- unsigned int timeframe,
- unsigned short type,
- unsigned short direction,
- unsigned int * count,
- unsigned int * avg_size,
- unsigned int * peers,
- unsigned int * time) {
+ unsigned int timeframe,
+ unsigned short type,
+ unsigned short direction,
+ unsigned int * count,
+ unsigned int * avg_size,
+ unsigned int * peers,
+ unsigned int * time) {
CS_traffic_info_MESSAGE * info;
CS_traffic_request_MESSAGE req;
int i;
@@ -62,16 +62,16 @@
req.timePeriod
= htonl(timeframe);
if (SYSERR == connection_write(sock,
- &req.header))
+ &req.header))
return SYSERR;
info = NULL;
if (SYSERR == connection_read(sock,
- (MESSAGE_HEADER**)&info))
+ (MESSAGE_HEADER**)&info))
return SYSERR;
if ( (ntohs(info->header.type) !=
- CS_PROTO_traffic_INFO) ||
+ CS_PROTO_traffic_INFO) ||
(ntohs(info->header.size) !=
- sizeof(CS_traffic_info_MESSAGE) +
ntohl(info->count)*sizeof(TRAFFIC_COUNTER)) ) {
+ sizeof(CS_traffic_info_MESSAGE) +
ntohl(info->count)*sizeof(TRAFFIC_COUNTER)) ) {
GE_BREAK(NULL, 0);
return SYSERR;
}
Modified: GNUnet/src/applications/traffic/traffic.c
===================================================================
--- GNUnet/src/applications/traffic/traffic.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/traffic/traffic.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -168,9 +168,9 @@
* the given peerId.
*/
static void updateUse(DirectedTrafficCounter * dtc,
- unsigned short size,
- int peerId,
- int expireOnly) {
+ unsigned short size,
+ int peerId,
+ int expireOnly) {
cron_t now;
cron_t delta;
unsigned int unitNow;
@@ -192,11 +192,11 @@
minPeerId = 0;
for (i=0;i<MAX_PEER_IDs;i++) {
if (dtc->peers[i].time < minPeerTime)
- minPeerId = i;
+ minPeerId = i;
if (dtc->peers[i].peerIdentity_a == peerId) {
- minPeerId = i;
- break; /* if the peer is already listed, re-use
- that slot & update the time! */
+ minPeerId = i;
+ break; /* if the peer is already listed, re-use
+ that slot & update the time! */
}
}
dtc->peers[minPeerId].time = unitNow;
@@ -240,10 +240,10 @@
* @param msgType what is the type of the message that the dtc is for?
*/
static void buildSummary(TRAFFIC_COUNTER * res,
- DirectedTrafficCounter * dtc,
- unsigned int tcType,
- unsigned int countTimeUnits,
- unsigned short msgType) {
+ DirectedTrafficCounter * dtc,
+ unsigned int tcType,
+ unsigned int countTimeUnits,
+ unsigned short msgType) {
unsigned int i;
unsigned short peerCount;
cron_t now;
@@ -294,31 +294,31 @@
for (i=0;i<max_message_type;i++)
if (counters[i] != NULL) {
if (counters[i]->send.slots != 0)
- count++;
+ count++;
if (counters[i]->receive.slots != 0)
- count++;
+ count++;
}
reply = MALLOC(sizeof(CS_traffic_info_MESSAGE)+
- count * sizeof(TRAFFIC_COUNTER));
+ count * sizeof(TRAFFIC_COUNTER));
reply->header.type = htons(CS_PROTO_traffic_INFO);
reply->header.size = htons(sizeof(CS_traffic_info_MESSAGE)+
- count * sizeof(TRAFFIC_COUNTER));
+ count * sizeof(TRAFFIC_COUNTER));
reply->count = htonl(count);
count = 0;
for (i=0;i<max_message_type;i++)
if (counters[i] != NULL) {
if (counters[i]->send.slots != 0)
-
buildSummary(&((CS_traffic_info_MESSAGE_GENERIC*)reply)->counters[count++],
- &counters[i]->send,
- TC_SENT,
- countTimeUnits,
- i);
+ buildSummary(&((CS_traffic_info_MESSAGE_GENERIC*)reply)->counters[count++],
+ &counters[i]->send,
+ TC_SENT,
+ countTimeUnits,
+ i);
if (counters[i]->receive.slots != 0)
-
buildSummary(&((CS_traffic_info_MESSAGE_GENERIC*)reply)->counters[count++],
- &counters[i]->receive,
- TC_RECEIVED,
- countTimeUnits,
- i);
+ buildSummary(&((CS_traffic_info_MESSAGE_GENERIC*)reply)->counters[count++],
+ &counters[i]->receive,
+ TC_RECEIVED,
+ countTimeUnits,
+ i);
}
MUTEX_UNLOCK(lock);
@@ -326,7 +326,7 @@
}
static int trafficQueryHandler(struct ClientHandle * sock,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
const CS_traffic_request_MESSAGE * msg;
CS_traffic_info_MESSAGE * reply;
int ret;
@@ -357,12 +357,12 @@
* @return OK on success, SYSERR on error
*/
static int getTrafficStats(unsigned int timePeriod,
- unsigned short messageType,
- unsigned short sendReceive,
- unsigned int * messageCount,
- unsigned int * peerCount,
- unsigned int * avgMessageSize,
- unsigned int * timeDistribution) {
+ unsigned short messageType,
+ unsigned short sendReceive,
+ unsigned int * messageCount,
+ unsigned int * peerCount,
+ unsigned int * avgMessageSize,
+ unsigned int * timeDistribution) {
DirectedTrafficCounter * dtc;
unsigned int i;
unsigned int nowUnit;
@@ -419,70 +419,70 @@
static void checkPort(unsigned short port) {
if (port >= max_message_type)
GROW(counters,
- max_message_type,
- port + 1);
+ max_message_type,
+ port + 1);
if (counters[port] == NULL) {
counters[port] = MALLOC(sizeof(TrafficCounter));
memset(counters[port],
- 0,
- sizeof(TrafficCounter));
+ 0,
+ sizeof(TrafficCounter));
}
}
static void updateTrafficSendCounter(unsigned short ptyp,
- unsigned short plen) {
+ unsigned short plen) {
if (ptyp >= P2P_PROTO_MAX_USED)
return; /* not tracked */
if (0 == stat_traffic_transmitted_by_type[ptyp]) {
char * s;
s = MALLOC(256);
SNPRINTF(s,
- 256,
- _("# bytes transmitted of type %d"),
- ptyp);
+ 256,
+ _("# bytes transmitted of type %d"),
+ ptyp);
stat_traffic_transmitted_by_type[ptyp]
= stats->create(s);
FREE(s);
}
stats->change(stat_traffic_transmitted_by_type[ptyp],
- plen);
+ plen);
}
static void updateTrafficReceiveCounter(unsigned short ptyp,
- unsigned short plen) {
+ unsigned short plen) {
if (ptyp < P2P_PROTO_MAX_USED) {
if (0 == stat_traffic_received_by_type[ptyp]) {
char * s;
s = MALLOC(256);
SNPRINTF(s,
- 256,
- _("# bytes received of type %d"),
- ptyp);
+ 256,
+ _("# bytes received of type %d"),
+ ptyp);
stat_traffic_received_by_type[ptyp]
- = stats->create(s);
+ = stats->create(s);
FREE(s);
}
stats->change(stat_traffic_received_by_type[ptyp],
- plen);
+ plen);
}
}
static void updatePlaintextTrafficReceiveCounter(unsigned short ptyp,
- unsigned short plen) {
+ unsigned short plen) {
if (ptyp < P2P_PROTO_MAX_USED) {
if (0 == stat_pt_traffic_received_by_type[ptyp]) {
char * s;
s = MALLOC(256);
SNPRINTF(s,
- 256,
- _("# bytes received in plaintext of type %d"),
- ptyp);
+ 256,
+ _("# bytes received in plaintext of type %d"),
+ ptyp);
stat_pt_traffic_received_by_type[ptyp]
- = stats->create(s);
+ = stats->create(s);
FREE(s);
}
stats->change(stat_pt_traffic_received_by_type[ptyp],
- plen);
+ plen);
}
}
@@ -493,18 +493,18 @@
* @param sender the identity of the sender
*/
static int trafficReceive(const PeerIdentity * sender,
- const MESSAGE_HEADER * header) {
+ const MESSAGE_HEADER * header) {
unsigned short port;
port = ntohs(header->type);
updateTrafficReceiveCounter(port,
- ntohs(header->size));
+ ntohs(header->size));
MUTEX_LOCK(lock);
checkPort(port);
updateUse(&counters[port]->receive,
- ntohs(header->size),
- sender->hashPubKey.bits[0],
- NO);
+ ntohs(header->size),
+ sender->hashPubKey.bits[0],
+ NO);
MUTEX_UNLOCK(lock);
return OK;
}
@@ -517,18 +517,18 @@
* @param receiver the identity of the receiver
*/
static int trafficSend(const PeerIdentity * receiver,
- const MESSAGE_HEADER * header) {
+ const MESSAGE_HEADER * header) {
unsigned short port;
port = ntohs(MAKE_UNALIGNED(header->type));
updateTrafficSendCounter(port,
- ntohs(MAKE_UNALIGNED(header->size)));
+ ntohs(MAKE_UNALIGNED(header->size)));
MUTEX_LOCK(lock);
checkPort(port);
updateUse(&counters[port]->send,
- ntohs(MAKE_UNALIGNED(header->size)),
- receiver->hashPubKey.bits[0],
- NO);
+ ntohs(MAKE_UNALIGNED(header->size)),
+ receiver->hashPubKey.bits[0],
+ NO);
MUTEX_UNLOCK(lock);
return OK;
}
@@ -540,13 +540,13 @@
* @param receiver the identity of the receiver
*/
static int plaintextReceive(const PeerIdentity * receiver,
- const MESSAGE_HEADER * header,
- TSession * session) {
+ const MESSAGE_HEADER * header,
+ TSession * session) {
unsigned short port;
port = ntohs(MAKE_UNALIGNED(header->type));
updatePlaintextTrafficReceiveCounter(port,
- ntohs(MAKE_UNALIGNED(header->size)));
+ ntohs(MAKE_UNALIGNED(header->size)));
return OK;
}
@@ -562,12 +562,12 @@
coreAPI = capi;
#if DEBUG
GC_get_configuration_value_number(capi->cfg,
- "NETWORK",
- "PORT",
- 0,
- 65536,
- 2087,
- &server_port);
+ "NETWORK",
+ "PORT",
+ 0,
+ 65536,
+ 2087,
+ &server_port);
#endif
api.get = &getTrafficStats;
for (i=0;i<P2P_PROTO_MAX_USED;i++)
@@ -576,9 +576,9 @@
for (i=0;i<P2P_PROTO_MAX_USED;i++) {
stat_traffic_received_by_type[i] = 0;
coreAPI->registerHandler(i,
- &trafficReceive);
+ &trafficReceive);
coreAPI->registerPlaintextHandler(i,
- &plaintextReceive);
+ &plaintextReceive);
}
GE_ASSERT(coreAPI->ectx, counters == NULL);
@@ -595,9 +595,9 @@
for (i=0;i<P2P_PROTO_MAX_USED;i++) {
coreAPI->unregisterHandler(i,
- &trafficReceive);
+ &trafficReceive);
coreAPI->unregisterPlaintextHandler(i,
- &plaintextReceive);
+ &plaintextReceive);
}
coreAPI->unregisterSendNotify(&trafficSend);
coreAPI->releaseService(stats);
@@ -630,14 +630,14 @@
return SYSERR;
}
capi->registerClientHandler(CS_PROTO_traffic_QUERY,
- &trafficQueryHandler);
+ &trafficQueryHandler);
GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "traffic",
- gettext_noop("tracks
bandwidth utilization by gnunetd")));
- return OK;
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "traffic",
+ gettext_noop("tracks bandwidth
utilization by gnunetd")));
+ return OK;
}
/**
@@ -646,8 +646,8 @@
void done_module_traffic() {
GE_ASSERT(NULL, myCoreAPI != NULL);
GE_ASSERT(myCoreAPI->ectx,
- SYSERR != myCoreAPI->unregisterClientHandler(CS_PROTO_traffic_QUERY,
- &trafficQueryHandler));
+ SYSERR != myCoreAPI->unregisterClientHandler(CS_PROTO_traffic_QUERY,
+ &trafficQueryHandler));
myCoreAPI->releaseService(myApi);
myApi = NULL;
myCoreAPI = NULL;
Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c 2007-07-05 19:56:14 UTC
(rev 5248)
+++ GNUnet/src/applications/transport/transport.c 2007-07-05 21:12:30 UTC
(rev 5249)
@@ -73,11 +73,11 @@
return;
}
memcpy(&tapi->hello->publicKey,
- identity->getPublicPrivateKey(),
- sizeof(PublicKey));
+ identity->getPublicPrivateKey(),
+ sizeof(PublicKey));
memcpy(&tapi->hello->senderIdentity,
- coreAPI->myIdentity,
- sizeof(PeerIdentity));
+ coreAPI->myIdentity,
+ sizeof(PeerIdentity));
tapi->hello->expirationTime
= htonl(TIME(NULL) + hello_live);
tapi->hello->header.type
@@ -85,11 +85,11 @@
tapi->hello->header.size
= htons(P2P_hello_MESSAGE_size(tapi->hello));
if (SYSERR == identity->signData(&(tapi->hello)->senderIdentity,
- P2P_hello_MESSAGE_size(tapi->hello)
- - sizeof(Signature)
- - sizeof(PublicKey)
- - sizeof(MESSAGE_HEADER),
- &tapi->hello->signature)) {
+ P2P_hello_MESSAGE_size(tapi->hello)
+ - sizeof(Signature)
+ - sizeof(PublicKey)
+ - sizeof(MESSAGE_HEADER),
+ &tapi->hello->signature)) {
FREE(tapi->hello);
tapi->hello = NULL;
GE_BREAK(ectx, 0);
@@ -115,8 +115,8 @@
static int addTransport(TransportAPI * tapi) {
if (tapi->protocolNumber >= tapis_count)
GROW(tapis,
- tapis_count,
- tapi->protocolNumber+1);
+ tapis_count,
+ tapi->protocolNumber+1);
if (tapis[tapi->protocolNumber] != NULL) {
GE_BREAK(ectx, 0);
return SYSERR;
@@ -124,10 +124,10 @@
tapis[tapi->protocolNumber] = tapi;
tapi->hello = NULL;
cron_add_job(coreAPI->cron,
- &createSignedhello,
- HELLO_RECREATE_FREQ,
- HELLO_RECREATE_FREQ,
- tapi);
+ &createSignedhello,
+ HELLO_RECREATE_FREQ,
+ HELLO_RECREATE_FREQ,
+ tapi);
return OK;
}
@@ -136,22 +136,22 @@
*/
static int
helloToAddress(const P2P_hello_MESSAGE * hello,
- void ** sa,
- unsigned int * sa_len) {
+ void ** sa,
+ unsigned int * sa_len) {
unsigned short prot;
prot = ntohs(hello->protocol);
if ( (prot >= tapis_count) ||
(tapis[prot] == NULL) ) {
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- _("Converting peer address to string failed, transport type %d not
supported\n"),
- ntohs(hello->protocol));
+ GE_INFO | GE_REQUEST | GE_USER,
+ _("Converting peer address to string failed, transport type %d not
supported\n"),
+ ntohs(hello->protocol));
return SYSERR;
}
return tapis[prot]->helloToAddress(hello,
- sa,
- sa_len);
+ sa,
+ sa_len);
}
/**
@@ -160,7 +160,7 @@
* @param data second argument to callback
*/
static int forEachTransport(TransportCallback callback,
- void * data) {
+ void * data) {
int i;
int ret;
@@ -169,7 +169,7 @@
if (tapis[i] != NULL) {
ret++;
if (callback != NULL)
- callback(tapis[i], data);
+ callback(tapis[i], data);
}
}
return ret;
@@ -192,14 +192,14 @@
if ( (prot >= tapis_count) ||
(tapis[prot] == NULL) ) {
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER | GE_ADMIN,
- _("Transport connection attempt failed, transport type %d not
supported\n"),
- prot);
+ GE_INFO | GE_REQUEST | GE_USER | GE_ADMIN,
+ _("Transport connection attempt failed, transport type %d not
supported\n"),
+ prot);
return NULL;
}
tsession = NULL;
if (OK != tapis[prot]->connect(hello,
- &tsession))
+ &tsession))
return NULL;
tsession->ttype = prot;
return tsession;
@@ -207,7 +207,7 @@
static TSession *
transportConnectFreely(const PeerIdentity * peer,
- int useTempList) {
+ int useTempList) {
int i;
P2P_hello_MESSAGE * hello;
int * perm;
@@ -224,8 +224,8 @@
if (tapis[perm[i]] == NULL)
continue;
hello = identity->identity2Hello(peer,
- perm[i],
- useTempList);
+ perm[i],
+ useTempList);
if (hello == NULL)
continue;
hc++;
@@ -240,12 +240,12 @@
if (ret == NULL) {
#if DEBUG_TRANSPORT
hash2enc(&peer->hashPubKey,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- _("Transport failed to connect to peer `%s' (%u HELLOs known, none
worked)\n"),
- &enc,
- hc);
+ GE_WARNING | GE_BULK | GE_ADMIN,
+ _("Transport failed to connect to peer `%s' (%u HELLOs known, none
worked)\n"),
+ &enc,
+ hc);
#endif
}
return ret;
@@ -290,28 +290,28 @@
* temporary error
*/
static int transportSend(TSession * tsession,
- const void * msg,
- unsigned int size,
- int important) {
+ const void * msg,
+ unsigned int size,
+ int important) {
if (tsession == NULL) {
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Transmission attempted on uni-directional pipe, failing.\n");
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Transmission attempted on uni-directional pipe, failing.\n");
return SYSERR; /* can't do that, can happen for unidirectional pipes
- that call core with TSession being NULL. */
+ that call core with TSession being NULL. */
}
if ( (tsession->ttype >= tapis_count) ||
(tapis[tsession->ttype] == NULL) ) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("Transmission attempt failed, transport type %d unknown.\n"),
- tsession->ttype);
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Transmission attempt failed, transport type %d unknown.\n"),
+ tsession->ttype);
return SYSERR;
}
return tapis[tsession->ttype]->send(tsession,
- msg,
- size,
- important);
+ msg,
+ size,
+ important);
}
/**
@@ -376,9 +376,9 @@
perm = permute(WEAK, tapis_count);
ttype = tapis_count-1;
while ( (ttype < tapis_count) &&
- ( (tapis[perm[ttype]] == NULL) ||
- (tapis[perm[ttype]] != NULL &&
- tapis[perm[ttype]]->hello == NULL) ) )
+ ( (tapis[perm[ttype]] == NULL) ||
+ (tapis[perm[ttype]] != NULL &&
+ tapis[perm[ttype]]->hello == NULL) ) )
ttype--; /* unsigned, will wrap around! */
if (ttype >= tapis_count) {
FREE(perm);
@@ -391,9 +391,9 @@
if ( (ttype >= tapis_count) ||
(tapis[ttype] == NULL) ) {
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- _("No transport of type %d known.\n"),
- ttype);
+ GE_DEBUG | GE_BULK | GE_USER,
+ _("No transport of type %d known.\n"),
+ ttype);
MUTEX_UNLOCK(tapis_lock);
return NULL;
}
@@ -404,8 +404,8 @@
}
hello = MALLOC(P2P_hello_MESSAGE_size(tapi->hello));
memcpy(hello,
- tapi->hello,
- P2P_hello_MESSAGE_size(tapi->hello));
+ tapi->hello,
+ P2P_hello_MESSAGE_size(tapi->hello));
MUTEX_UNLOCK(tapis_lock);
return hello;
}
@@ -424,7 +424,7 @@
* @return the number of bytes written to buff, -1 on error
*/
static int getAdvertisedhellos(unsigned int maxLen,
- char * buff) {
+ char * buff) {
int i;
int tcount;
P2P_hello_MESSAGE ** hellos;
@@ -442,14 +442,14 @@
if (tapis[i] != NULL) {
hellos[tcount] = transportCreatehello(i);
if (NULL != hellos[tcount])
- tcount++;
+ tcount++;
}
}
MUTEX_UNLOCK(tapis_lock);
if (tcount == 0) {
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("No transport succeeded in creating a hello!\n"));
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("No transport succeeded in creating a hello!\n"));
FREE(hellos);
return SYSERR;
}
@@ -458,8 +458,8 @@
i = weak_randomi(tcount); /* select a hello at random */
if ((unsigned int)P2P_hello_MESSAGE_size(hellos[i]) <= maxLen - used) {
memcpy(&buff[used],
- hellos[i],
- P2P_hello_MESSAGE_size(hellos[i]));
+ hellos[i],
+ P2P_hello_MESSAGE_size(hellos[i]));
used += P2P_hello_MESSAGE_size(hellos[i]);
}
FREE(hellos[i]);
@@ -470,9 +470,9 @@
FREE(hellos);
if (used == 0)
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- "No HELLOs fit in %u bytes.\n",
- maxLen);
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ "No HELLOs fit in %u bytes.\n",
+ maxLen);
return used;
}
@@ -490,14 +490,14 @@
static void doneHelper(TransportAPI * tapi,
- void * unused) {
+ void * unused) {
/* In the (rare) case that we shutdown transports
before the cron-jobs had a chance to run, stop
the cron-jobs */
cron_del_job(coreAPI->cron,
- &initHello,
- 0,
- tapi);
+ &initHello,
+ 0,
+ tapi);
}
static void unloadTransport(int i) {
@@ -505,12 +505,12 @@
doneHelper(tapis[i], NULL);
cron_del_job(coreAPI->cron,
- &createSignedhello,
- HELLO_RECREATE_FREQ,
- tapis[i]);
+ &createSignedhello,
+ HELLO_RECREATE_FREQ,
+ tapis[i]);
ptr = os_plugin_resolve_function(tapis[i]->libHandle,
- "donetransport_",
- NO);
+ "donetransport_",
+ NO);
if (ptr != NULL)
ptr();
FREE(tapis[i]->transName);
@@ -532,7 +532,7 @@
for (i=0;i<tapis_count;i++)
if (tapis[i] != NULL) {
if (OK != tapis[i]->startTransportServer())
- unloadTransport(i);
+ unloadTransport(i);
}
}
@@ -549,7 +549,7 @@
}
static void initHelper(TransportAPI * tapi,
- void * unused) {
+ void * unused) {
/* Creation of HELLOs takes longer if a locally
unresolvable hostname ((Dyn)DNS) was specified
as this host's address and we have no network
@@ -558,10 +558,10 @@
This is why we create the HELLOs in another
thread. */
cron_add_job(coreAPI->cron,
- &initHello,
- 0,
- 0,
- tapi);
+ &initHello,
+ 0,
+ 0,
+ tapi);
}
/**
@@ -578,16 +578,16 @@
* SYSERR if the size/session is invalid
*/
static int testWouldTry(TSession * tsession,
- unsigned int size,
- int important) {
+ unsigned int size,
+ int important) {
if (tsession == NULL)
return SYSERR;
if ( (tsession->ttype >= tapis_count) ||
(tapis[tsession->ttype] == NULL) )
return SYSERR;
return tapis[tsession->ttype]->testWouldTry(tsession,
- size,
- important);
+ size,
+ important);
}
/**
@@ -606,17 +606,17 @@
ectx = capi->ectx;
if (-1 == GC_get_configuration_value_number(capi->cfg,
- "GNUNETD",
- "HELLOEXPIRES",
- 1,
- MAX_HELLO_EXPIRES / 60,
- 60,
- &hello_live))
+ "GNUNETD",
+ "HELLOEXPIRES",
+ 1,
+ MAX_HELLO_EXPIRES / 60,
+ 60,
+ &hello_live))
return NULL;
hello_live *= 60;
GE_ASSERT(ectx,
- sizeof(P2P_hello_MESSAGE) == 600);
+ sizeof(P2P_hello_MESSAGE) == 600);
identity = capi->requestService("identity");
if (identity == NULL) {
GE_BREAK(ectx, 0);
@@ -642,86 +642,86 @@
/* now load transports */
dso = NULL;
GE_ASSERT(ectx,
- -1 != GC_get_configuration_value_string(capi->cfg,
- "GNUNETD",
- "TRANSPORTS",
- "udp tcp nat",
- &dso));
+ -1 != GC_get_configuration_value_string(capi->cfg,
+ "GNUNETD",
+ "TRANSPORTS",
+ "udp tcp nat",
+ &dso));
if (strlen(dso) != 0) {
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- _("Loading transports `%s'\n"),
- dso);
+ GE_INFO | GE_USER | GE_BULK,
+ _("Loading transports `%s'\n"),
+ dso);
next = dso;
do {
pos = next;
while ( (*next != '\0') &&
- (*next != ' ') )
- next++;
+ (*next != ' ') )
+ next++;
if (*next == '\0')
- next = NULL; /* terminate! */
+ next = NULL; /* terminate! */
else {
- *next = '\0'; /* add 0-termination for pos */
- next++;
+ *next = '\0'; /* add 0-termination for pos */
+ next++;
}
lib = os_plugin_load(ectx,
- "libgnunettransport_",
- pos);
+ "libgnunettransport_",
+ pos);
if (lib == NULL) {
- GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- _("Could not load transport plugin `%s'\n"),
- pos);
- continue;
+ GE_LOG(ectx,
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("Could not load transport plugin `%s'\n"),
+ pos);
+ continue;
}
tptr = os_plugin_resolve_function(lib,
- "inittransport_",
- YES);
+ "inittransport_",
+ YES);
if (tptr == NULL) {
- GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
- _("Transport library `%s' did not provide required function
'%s%s'.\n"),
- pos,
- "inittransport_",
- pos);
- os_plugin_unload(lib);
- continue;
+ GE_LOG(ectx,
+ GE_ERROR | GE_ADMIN | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
+ _("Transport library `%s' did not provide required function
'%s%s'.\n"),
+ pos,
+ "inittransport_",
+ pos);
+ os_plugin_unload(lib);
+ continue;
}
tapi = tptr(&ctapi);
if (tapi == NULL) {
- os_plugin_unload(lib);
- continue;
+ os_plugin_unload(lib);
+ continue;
}
tapi->libHandle = lib;
tapi->transName = STRDUP(pos);
if (OK != addTransport(tapi)) {
- void (*ptr)();
+ void (*ptr)();
- FREE(tapi->transName);
- ptr = os_plugin_resolve_function(lib,
- "donetransport_",
- NO);
- if (ptr != NULL)
- ptr();
- os_plugin_unload(lib);
+ FREE(tapi->transName);
+ ptr = os_plugin_resolve_function(lib,
+ "donetransport_",
+ NO);
+ if (ptr != NULL)
+ ptr();
+ os_plugin_unload(lib);
} else {
- GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- _("Loaded transport `%s'\n"),
- pos);
+ GE_LOG(ectx,
+ GE_INFO | GE_USER | GE_BULK,
+ _("Loaded transport `%s'\n"),
+ pos);
}
} while (next != NULL);
}
FREE(dso);
IF_GELOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- hash2enc(&coreAPI->myIdentity->hashPubKey,
- &myself));
+ GE_INFO | GE_REQUEST | GE_USER,
+ hash2enc(&coreAPI->myIdentity->hashPubKey,
+ &myself));
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- _("I am peer `%s'.\n"),
- &myself);
+ GE_INFO | GE_REQUEST | GE_USER,
+ _("I am peer `%s'.\n"),
+ &myself);
forEachTransport(&initHelper, NULL);
ret.start = &startTransports;
@@ -769,4 +769,4 @@
}
-/* end of transport.c */
+/* end of transport.c */
Modified: GNUnet/src/applications/vpn/gnunet-vpn.c
===================================================================
--- GNUnet/src/applications/vpn/gnunet-vpn.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/applications/vpn/gnunet-vpn.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -66,46 +66,46 @@
/* buffer = MALLOC(MAX_BUFFER_SIZE); */
while (OK == connection_read(sock, &bufp)) {
- switch (ntohs(buf->type)) {
- case CS_PROTO_VPN_DEBUGOFF:
- case CS_PROTO_VPN_DEBUGON:
- case CS_PROTO_VPN_TUNNELS:
- case CS_PROTO_VPN_ROUTES:
- case CS_PROTO_VPN_REALISED:
- case CS_PROTO_VPN_RESET:
- case CS_PROTO_VPN_REALISE:
- case CS_PROTO_VPN_ADD:
- case CS_PROTO_VPN_TRUST:
- if (ntohs(buf->size) > sizeof(MESSAGE_HEADER)) {
- fwrite( buffer+sizeof(MESSAGE_HEADER),
- sizeof(char),
- ntohs(buf->size)-sizeof(MESSAGE_HEADER),
- stdout);
- }
+ switch (ntohs(buf->type)) {
+ case CS_PROTO_VPN_DEBUGOFF:
+ case CS_PROTO_VPN_DEBUGON:
+ case CS_PROTO_VPN_TUNNELS:
+ case CS_PROTO_VPN_ROUTES:
+ case CS_PROTO_VPN_REALISED:
+ case CS_PROTO_VPN_RESET:
+ case CS_PROTO_VPN_REALISE:
+ case CS_PROTO_VPN_ADD:
+ case CS_PROTO_VPN_TRUST:
+ if (ntohs(buf->size) > sizeof(MESSAGE_HEADER)) {
+ fwrite( buffer+sizeof(MESSAGE_HEADER),
+ sizeof(char),
+ ntohs(buf->size)-sizeof(MESSAGE_HEADER),
+ stdout);
+ }
- SEMAPHORE_UP(cmdAck);
- SEMAPHORE_DOWN(exitCheck, YES);
- MUTEX_LOCK(lock);
- if (wantExit == YES) {
- MUTEX_UNLOCK(lock);
- SEMAPHORE_UP(doneSem);
- return NULL;
- }
- MUTEX_UNLOCK(lock);
- break;;
- case CS_PROTO_VPN_MSG:
- if (silent == YES) break;;
- case CS_PROTO_VPN_REPLY:
-
- if (ntohs(buf->size) > sizeof(MESSAGE_HEADER)) {
- fwrite( buffer+sizeof(MESSAGE_HEADER),
- sizeof(char),
- ntohs(buf->size)-sizeof(MESSAGE_HEADER),
- stdout);
- }
- break;;
- }
+ SEMAPHORE_UP(cmdAck);
+ SEMAPHORE_DOWN(exitCheck, YES);
+ MUTEX_LOCK(lock);
+ if (wantExit == YES) {
+ MUTEX_UNLOCK(lock);
+ SEMAPHORE_UP(doneSem);
+ return NULL;
+ }
+ MUTEX_UNLOCK(lock);
+ break;;
+ case CS_PROTO_VPN_MSG:
+ if (silent == YES) break;;
+ case CS_PROTO_VPN_REPLY:
+
+ if (ntohs(buf->size) > sizeof(MESSAGE_HEADER)) {
+ fwrite( buffer+sizeof(MESSAGE_HEADER),
+ sizeof(char),
+ ntohs(buf->size)-sizeof(MESSAGE_HEADER),
+ stdout);
+ }
+ break;;
}
+ }
/* FREE(buffer); */
SEMAPHORE_UP(doneSem);
return NULL;
@@ -117,7 +117,7 @@
* @return return value from gnunet-template: 0: ok, -1: error
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
struct ClientServerConnection * sock;
struct PTHREAD * messageReceiveThread;
void * unused;
@@ -128,21 +128,21 @@
int i;
i = GNUNET_init(argc,
- argv,
- "gnunet-vpn",
- &cfgFilename,
- gnunetvpnOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-vpn",
+ &cfgFilename,
+ gnunetvpnOptions,
+ &ectx,
+ &cfg);
if (i == -1) {
GNUNET_fini(ectx, cfg);
return -1;
}
sock = client_connection_create(ectx,
- cfg);
+ cfg);
if (sock == NULL) {
fprintf(stderr,
- _("Error establishing connection with gnunetd.\n"));
+ _("Error establishing connection with gnunetd.\n"));
GNUNET_fini(ectx, cfg);
return 1;
}
@@ -154,85 +154,85 @@
wantExit = NO;
messageReceiveThread = PTHREAD_CREATE(&receiveThread,
- sock,
- 128 * 1024);
+ sock,
+ 128 * 1024);
if (messageReceiveThread == NULL)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
- "pthread_create");
+ GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
+ "pthread_create");
/* accept keystrokes from user and send to gnunetd */
while (NULL != fgets(buffer, 1024, stdin)) {
- if (rancommand) {
- rancommand = 0;
- SEMAPHORE_UP(exitCheck);
- }
- if (strncmp(buffer, "debug0", 6) == 0) {
- ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_DEBUGOFF);
- ((MESSAGE_HEADER*)&buffer)->size =
htons(sizeof(MESSAGE_HEADER));
- if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer))
return -1;
- rancommand = 1;
- SEMAPHORE_DOWN(cmdAck, YES);
- } else if (strncmp(buffer, "debug1", 6) == 0) {
- ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_DEBUGON);
- ((MESSAGE_HEADER*)&buffer)->size =
htons(sizeof(MESSAGE_HEADER));
- if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer))
return -1;
- rancommand = 1;
- SEMAPHORE_DOWN(cmdAck, YES);
- } else if (strncmp(buffer, "tunnels", 7) == 0) {
- ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_TUNNELS);
- ((MESSAGE_HEADER*)&buffer)->size =
htons(sizeof(MESSAGE_HEADER));
- if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer))
return -1;
- rancommand = 1;
- SEMAPHORE_DOWN(cmdAck, YES);
- } else if (strncmp(buffer, "route", 5) == 0) {
- ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_ROUTES);
- ((MESSAGE_HEADER*)&buffer)->size =
htons(sizeof(MESSAGE_HEADER));
- if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer))
return -1;
- rancommand = 1;
- SEMAPHORE_DOWN(cmdAck, YES);
- } else if (strncmp(buffer, "realised", 8) == 0) {
- ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_REALISED);
- ((MESSAGE_HEADER*)&buffer)->size =
htons(sizeof(MESSAGE_HEADER));
- if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer))
return -1;
- rancommand = 1;
- SEMAPHORE_DOWN(cmdAck, YES);
- } else if (strncmp(buffer, "reset", 5) == 0) {
- ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_RESET);
- ((MESSAGE_HEADER*)&buffer)->size =
htons(sizeof(MESSAGE_HEADER));
- if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer))
return -1;
- rancommand = 1;
- SEMAPHORE_DOWN(cmdAck, YES);
- } else if (strncmp(buffer, "realise", 7) == 0) {
- ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_REALISE);
- ((MESSAGE_HEADER*)&buffer)->size =
htons(sizeof(MESSAGE_HEADER));
- if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer))
return -1;
- rancommand = 1;
- SEMAPHORE_DOWN(cmdAck, YES);
- } else if (strncmp(buffer, "trust", 5) == 0) {
- ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_TRUST);
- ((MESSAGE_HEADER*)&buffer)->size =
htons(sizeof(MESSAGE_HEADER));
- if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer))
return -1;
- rancommand = 1;
- SEMAPHORE_DOWN(cmdAck, YES);
- } else if (strncmp(buffer, "add ", 4) == 0) {
- /* message header is 4 bytes long, we overwrite "add " with it
- * also don't include \r or \n in the message
- */
- if (strlen(&buffer[4]) > 1) {
- ((MESSAGE_HEADER*)&buffer)->type =
htons(CS_PROTO_VPN_ADD);
- ((MESSAGE_HEADER*)&buffer)->size =
htons(sizeof(MESSAGE_HEADER) + strlen(&buffer[5]));
- if (SYSERR == connection_write(sock,
(MESSAGE_HEADER*)&buffer)) return -1;
- rancommand = 1;
- SEMAPHORE_DOWN(cmdAck, YES);
- } else {
- printf("add requires hash as a parameter!\n");
- }
- } else {
- printf("debug0, debug1, tunnels, route, realise, realised,
reset, trust, add <hash>\n");
- }
+ if (rancommand) {
+ rancommand = 0;
+ SEMAPHORE_UP(exitCheck);
}
+ if (strncmp(buffer, "debug0", 6) == 0) {
+ ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_DEBUGOFF);
+ ((MESSAGE_HEADER*)&buffer)->size = htons(sizeof(MESSAGE_HEADER));
+ if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer)) return
-1;
+ rancommand = 1;
+ SEMAPHORE_DOWN(cmdAck, YES);
+ } else if (strncmp(buffer, "debug1", 6) == 0) {
+ ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_DEBUGON);
+ ((MESSAGE_HEADER*)&buffer)->size = htons(sizeof(MESSAGE_HEADER));
+ if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer)) return
-1;
+ rancommand = 1;
+ SEMAPHORE_DOWN(cmdAck, YES);
+ } else if (strncmp(buffer, "tunnels", 7) == 0) {
+ ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_TUNNELS);
+ ((MESSAGE_HEADER*)&buffer)->size = htons(sizeof(MESSAGE_HEADER));
+ if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer)) return
-1;
+ rancommand = 1;
+ SEMAPHORE_DOWN(cmdAck, YES);
+ } else if (strncmp(buffer, "route", 5) == 0) {
+ ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_ROUTES);
+ ((MESSAGE_HEADER*)&buffer)->size = htons(sizeof(MESSAGE_HEADER));
+ if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer)) return
-1;
+ rancommand = 1;
+ SEMAPHORE_DOWN(cmdAck, YES);
+ } else if (strncmp(buffer, "realised", 8) == 0) {
+ ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_REALISED);
+ ((MESSAGE_HEADER*)&buffer)->size = htons(sizeof(MESSAGE_HEADER));
+ if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer)) return
-1;
+ rancommand = 1;
+ SEMAPHORE_DOWN(cmdAck, YES);
+ } else if (strncmp(buffer, "reset", 5) == 0) {
+ ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_RESET);
+ ((MESSAGE_HEADER*)&buffer)->size = htons(sizeof(MESSAGE_HEADER));
+ if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer)) return
-1;
+ rancommand = 1;
+ SEMAPHORE_DOWN(cmdAck, YES);
+ } else if (strncmp(buffer, "realise", 7) == 0) {
+ ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_REALISE);
+ ((MESSAGE_HEADER*)&buffer)->size = htons(sizeof(MESSAGE_HEADER));
+ if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer)) return
-1;
+ rancommand = 1;
+ SEMAPHORE_DOWN(cmdAck, YES);
+ } else if (strncmp(buffer, "trust", 5) == 0) {
+ ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_TRUST);
+ ((MESSAGE_HEADER*)&buffer)->size = htons(sizeof(MESSAGE_HEADER));
+ if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer)) return
-1;
+ rancommand = 1;
+ SEMAPHORE_DOWN(cmdAck, YES);
+ } else if (strncmp(buffer, "add ", 4) == 0) {
+ /* message header is 4 bytes long, we overwrite "add " with it
+ * also don't include \r or \n in the message
+ */
+ if (strlen(&buffer[4]) > 1) {
+ ((MESSAGE_HEADER*)&buffer)->type = htons(CS_PROTO_VPN_ADD);
+ ((MESSAGE_HEADER*)&buffer)->size = htons(sizeof(MESSAGE_HEADER)
+ strlen(&buffer[5]));
+ if (SYSERR == connection_write(sock, (MESSAGE_HEADER*)&buffer))
return -1;
+ rancommand = 1;
+ SEMAPHORE_DOWN(cmdAck, YES);
+ } else {
+ printf("add requires hash as a parameter!\n");
+ }
+ } else {
+ printf("debug0, debug1, tunnels, route, realise, realised, reset,
trust, add <hash>\n");
+ }
+ }
/* wait for shutdown... */
if (rancommand) {
MUTEX_LOCK(lock);
Modified: GNUnet/src/applications/vpn/vpn.c
===================================================================
--- GNUnet/src/applications/vpn/vpn.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/applications/vpn/vpn.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -70,9 +70,9 @@
#include <asm/types.h>
#ifndef _LINUX_IN6_H
struct in6_ifreq {
- struct in6_addr ifr6_addr;
- __u32 ifr6_prefixlen;
- unsigned int ifr6_ifindex;
+ struct in6_addr ifr6_addr;
+ __u32 ifr6_prefixlen;
+ unsigned int ifr6_ifindex;
};
#endif
@@ -124,13 +124,13 @@
* ifindex = linux internal number to identify an interface
*/
typedef struct {
-/* char name[IFNAMSIZ]; */
- int id;
- int fd;
- int active;
- int route_entry;
- int ifindex;
- PeerIdentity peer;
+/* char name[IFNAMSIZ]; */
+ int id;
+ int fd;
+ int active;
+ int route_entry;
+ int ifindex;
+ PeerIdentity peer;
} tunnel_info;
/* from bluetooth agent */
@@ -161,12 +161,12 @@
/* This is an entry in the routing table */
typedef struct {
- /** owner's public key */
- PublicKey owner;
- /** hops to owner 1 = have a tunnel to owner, 0 = I am the owner.*/
- int hops;
- /** which tunnel entry in tunnels array */
- int tunnel;
+ /** owner's public key */
+ PublicKey owner;
+ /** hops to owner 1 = have a tunnel to owner, 0 = I am the owner.*/
+ int hops;
+ /** which tunnel entry in tunnels array */
+ int tunnel;
} route_info;
/* here we define a constant to limit the growth of your routing tables, and
hence memory consumption
@@ -183,10 +183,10 @@
* also the fields here are network byte order.
*/
typedef struct {
- PublicKey owner;
- int hops;
+ PublicKey owner;
+ int hops;
} transit_route;
-
+
static route_info *route_store = NULL;
static int route_entries = 0;
static int route_capacity = 0;
@@ -197,79 +197,79 @@
/** send given string to client */
static void cprintf(struct ClientHandle * c, int t, const char* format, ...) {
- va_list args;
- int r = -1;
- int size = 100;
- MESSAGE_HEADER *b = NULL, *nb = NULL;
+ va_list args;
+ int r = -1;
+ int size = 100;
+ MESSAGE_HEADER *b = NULL, *nb = NULL;
- if ((b = MALLOC(sizeof(MESSAGE_HEADER)+size)) == NULL) {
- return;
- }
- while (1) {
- va_start(args, format);
- r = VSNPRINTF((char*)(b+1), size, format, args);
- va_end(args);
- if (r > -1 && r < size)
- break;
- if (r > -1) {
- size = r + 1;
- } else {
- size *= 2;
- }
- if ((nb = REALLOC(b, sizeof(MESSAGE_HEADER) + size)) == NULL) {
- FREE(b);
- return;
- } else {
- b = nb;
- }
- }
- b->type=htons(t);
- b->size=htons(sizeof(MESSAGE_HEADER) + strlen((char*)(b+1)));
- if (c != NULL) {
- coreAPI->sendToClient(c, b);
- } else {
- for(r = 0; r < clients_entries; r++) {
- coreAPI->sendToClient(*(clients_store+r), b);
- }
- }
- FREE(b);
+ if ((b = MALLOC(sizeof(MESSAGE_HEADER)+size)) == NULL) {
+ return;
+ }
+ while (1) {
+ va_start(args, format);
+ r = VSNPRINTF((char*)(b+1), size, format, args);
+ va_end(args);
+ if (r > -1 && r < size)
+ break;
+ if (r > -1) {
+ size = r + 1;
+ } else {
+ size *= 2;
+ }
+ if ((nb = REALLOC(b, sizeof(MESSAGE_HEADER) + size)) == NULL) {
+ FREE(b);
+ return;
+ } else {
+ b = nb;
+ }
+ }
+ b->type=htons(t);
+ b->size=htons(sizeof(MESSAGE_HEADER) + strlen((char*)(b+1)));
+ if (c != NULL) {
+ coreAPI->sendToClient(c, b);
+ } else {
+ for(r = 0; r < clients_entries; r++) {
+ coreAPI->sendToClient(*(clients_store+r), b);
+ }
+ }
+ FREE(b);
}
#define VLOG if ((cdebug & (GE_DEBUG | GE_DEVELOPER | GE_REQUEST)) > 0)
cprintf(NULL,CS_PROTO_VPN_MSG,
/** Test if two PublicKey are equal or not */
static int isEqualP(const PublicKey *first, const PublicKey *second) {
- int i;
- int ln = maxi(first->sizen, second->sizen);
- int sn = mini(first->sizen, second->sizen);
-
- /* compare common mode modulus */
- if (memcmp( (first->key)+((first->sizen)-sn),
(second->key)+((second->sizen)-sn), sn) != 0)
- return NO;
+ int i;
+ int ln = maxi(first->sizen, second->sizen);
+ int sn = mini(first->sizen, second->sizen);
+
+ /* compare common mode modulus */
+ if (memcmp( (first->key)+((first->sizen)-sn),
(second->key)+((second->sizen)-sn), sn) != 0)
+ return NO;
- /* difference before n should be 0 */
- for(i = 0; i < (first->sizen)-sn; i++) {
- if (*(first->key+i) != 0)
- return NO;
- }
- for(i = 0; i < (second->sizen)-sn; i++) {
- if (*(second->key+i) != 0)
- return NO;
- }
+ /* difference before n should be 0 */
+ for(i = 0; i < (first->sizen)-sn; i++) {
+ if (*(first->key+i) != 0)
+ return NO;
+ }
+ for(i = 0; i < (second->sizen)-sn; i++) {
+ if (*(second->key+i) != 0)
+ return NO;
+ }
- /* compare common mode exponent */
- if (memcmp( (first->key)+ln, (second->key)+ln, RSA_KEY_LEN-ln) != 0)
- return NO;
+ /* compare common mode exponent */
+ if (memcmp( (first->key)+ln, (second->key)+ln, RSA_KEY_LEN-ln) != 0)
+ return NO;
- for(i = first->sizen; i < ln; i++) {
- if (*(first->key+i) != 0)
- return NO;
- }
- for(i = second->sizen; i < ln; i++) {
- if (*(second->key+i) != 0)
- return NO;
- }
+ for(i = first->sizen; i < ln; i++) {
+ if (*(first->key+i) != 0)
+ return NO;
+ }
+ for(i = second->sizen; i < ln; i++) {
+ if (*(second->key+i) != 0)
+ return NO;
+ }
- return YES;
+ return YES;
}
/**
@@ -277,93 +277,93 @@
* called at start or when we know a peer changes its route table.
*/
static void init_router() {
- int reqcapacity;
- route_info *reqstore;
- reqcapacity = sizeof(route_info);
- if (reqcapacity > route_capacity) {
- reqstore = REALLOC(route_store, reqcapacity);
- if (reqstore == NULL) return; /* not enough ram, cannot init! */
- route_store = reqstore;
- route_capacity = reqcapacity;
- }
- route_entries = 1;
- route_store->hops = 0; /* us! */
- route_store->tunnel = -1; /* n/a! */
- route_store->owner = *(identity->getPublicPrivateKey()); /* us! */
+ int reqcapacity;
+ route_info *reqstore;
+ reqcapacity = sizeof(route_info);
+ if (reqcapacity > route_capacity) {
+ reqstore = REALLOC(route_store, reqcapacity);
+ if (reqstore == NULL) return; /* not enough ram, cannot init! */
+ route_store = reqstore;
+ route_capacity = reqcapacity;
+ }
+ route_entries = 1;
+ route_store->hops = 0; /* us! */
+ route_store->tunnel = -1; /* n/a! */
+ route_store->owner = *(identity->getPublicPrivateKey()); /* us! */
}
/**
* clear out the actual route at startup only
*/
static void init_realised() {
- int reqcapacity;
- route_info *reqstore;
- reqcapacity = sizeof(route_info);
- if (reqcapacity > realised_capacity) {
- reqstore = REALLOC(realised_store, reqcapacity);
- if (reqstore == NULL) return; /* not enough ram, cannot init! */
- realised_store = reqstore;
- realised_capacity = reqcapacity;
- }
- realised_entries = 1;
- realised_store->hops = 0; /* us! */
- realised_store->tunnel = -1; /* n/a! */
- realised_store->owner = *(identity->getPublicPrivateKey()); /* us! */
+ int reqcapacity;
+ route_info *reqstore;
+ reqcapacity = sizeof(route_info);
+ if (reqcapacity > realised_capacity) {
+ reqstore = REALLOC(realised_store, reqcapacity);
+ if (reqstore == NULL) return; /* not enough ram, cannot init! */
+ realised_store = reqstore;
+ realised_capacity = reqcapacity;
+ }
+ realised_entries = 1;
+ realised_store->hops = 0; /* us! */
+ realised_store->tunnel = -1; /* n/a! */
+ realised_store->owner = *(identity->getPublicPrivateKey()); /* us! */
}
/* adds a route to prototype route table, unless it has same PublicKey and
tunnel as another entry */
static void add_route(PublicKey* them, int hops, int tunnel) {
- int i;
- route_info *rstore;
- int rcapacity;
+ int i;
+ route_info *rstore;
+ int rcapacity;
- for (i = 0; i < route_entries; i++) {
- if (isEqualP(them, &(route_store+i)->owner)) {
- if ((route_store+i)->hops == 0) {
- /* we don't store alternative routes to
ourselves,
- * as we already know how to route to ourself
- */
- VLOG _("Not storing route to myself from peer %d\n"),
tunnel);
- return;
- }
- if ((route_store+i)->tunnel == tunnel) {
- /* also, we only keep one route to a node per
peer,
- * but store the lowest hop count that the peer
is advertising for that node.
- */
- (route_store+i)->hops =
mini((route_store+i)->hops, hops);
- VLOG _("Duplicate route to node from peer %d,
choosing minimum hops"), tunnel);
- return;
- }
- }
- }
+ for (i = 0; i < route_entries; i++) {
+ if (isEqualP(them, &(route_store+i)->owner)) {
+ if ((route_store+i)->hops == 0) {
+ /* we don't store alternative routes to ourselves,
+ * as we already know how to route to ourself
+ */
+ VLOG _("Not storing route to myself from peer %d\n"), tunnel);
+ return;
+ }
+ if ((route_store+i)->tunnel == tunnel) {
+ /* also, we only keep one route to a node per peer,
+ * but store the lowest hop count that the peer is
advertising for that node.
+ */
+ (route_store+i)->hops = mini((route_store+i)->hops,
hops);
+ VLOG _("Duplicate route to node from peer %d, choosing
minimum hops"), tunnel);
+ return;
+ }
+ }
+ }
- route_entries++;
+ route_entries++;
rcapacity = route_entries * sizeof(route_info);
if (rcapacity > route_capacity) {
- rstore = REALLOC(route_store, rcapacity);
- if (rstore == NULL) {
- route_entries--;
- return; /* not enough ram, we will have to drop this
route. */
- }
- route_capacity = rcapacity;
- route_store = rstore;
- }
- /*
- * we really should keep the route table in ascending hop count order...
- */
- if (route_entries > 0) {
- i = route_entries - 1; /* i = insert location */
- while ((i > 0) && ((route_store+(i-1))->hops > hops)) {
- (route_store+i)->hops = (route_store+(i-1))->hops;
- (route_store+i)->tunnel = (route_store+(i-1))->hops;
- (route_store+i)->owner = (route_store+(i-1))->owner;
- i--;
- }
- VLOG _("Inserting route from peer %d in route table at location
%d\n"), tunnel, i);
- (route_store+i)->hops = hops;
- (route_store+i)->tunnel = tunnel;
- (route_store+i)->owner = *them;
- }
+ rstore = REALLOC(route_store, rcapacity);
+ if (rstore == NULL) {
+ route_entries--;
+ return; /* not enough ram, we will have to drop this route. */
+ }
+ route_capacity = rcapacity;
+ route_store = rstore;
+ }
+ /*
+ * we really should keep the route table in ascending hop count order...
+ */
+ if (route_entries > 0) {
+ i = route_entries - 1; /* i = insert location */
+ while ((i > 0) && ((route_store+(i-1))->hops > hops)) {
+ (route_store+i)->hops = (route_store+(i-1))->hops;
+ (route_store+i)->tunnel = (route_store+(i-1))->hops;
+ (route_store+i)->owner = (route_store+(i-1))->owner;
+ i--;
+ }
+ VLOG _("Inserting route from peer %d in route table at location %d\n"),
tunnel, i);
+ (route_store+i)->hops = hops;
+ (route_store+i)->tunnel = tunnel;
+ (route_store+i)->owner = *them;
+ }
}
/**
@@ -373,69 +373,69 @@
struct in_addr fr4;
struct in_addr to4;
- if ((((const struct iphdr*)fp)->version == 4)) {
- fr4.s_addr = ((const struct iphdr*)fp)->saddr;
- to4.s_addr = ((const struct iphdr*)fp)->daddr;
- sprintf(info, "IPv4 %s -> ", inet_ntoa(fr4));
- strcat(info, inet_ntoa(to4));
- return;
- }
- if ((((const struct iphdr*)fp)->version == 6)) {
- sprintf(info, "IPv6 %x:%x:%x:%x:%x:%x:%x:%x ->
%x:%x:%x:%x:%x:%x:%x:%x",
- ntohs(fp->ip6_src.s6_addr16[0]),
- ntohs(fp->ip6_src.s6_addr16[1]),
- ntohs(fp->ip6_src.s6_addr16[2]),
- ntohs(fp->ip6_src.s6_addr16[3]),
- ntohs(fp->ip6_src.s6_addr16[4]),
- ntohs(fp->ip6_src.s6_addr16[5]),
- ntohs(fp->ip6_src.s6_addr16[6]),
- ntohs(fp->ip6_src.s6_addr16[7]),
- ntohs(fp->ip6_dst.s6_addr16[0]),
- ntohs(fp->ip6_dst.s6_addr16[1]),
- ntohs(fp->ip6_dst.s6_addr16[2]),
- ntohs(fp->ip6_dst.s6_addr16[3]),
- ntohs(fp->ip6_dst.s6_addr16[4]),
- ntohs(fp->ip6_dst.s6_addr16[5]),
- ntohs(fp->ip6_dst.s6_addr16[6]),
- ntohs(fp->ip6_dst.s6_addr16[7])
- );
- return;
- }
- sprintf(info, "IPv%d ?", ((const struct iphdr*)fp)->version);
+ if ((((const struct iphdr*)fp)->version == 4)) {
+ fr4.s_addr = ((const struct iphdr*)fp)->saddr;
+ to4.s_addr = ((const struct iphdr*)fp)->daddr;
+ sprintf(info, "IPv4 %s -> ", inet_ntoa(fr4));
+ strcat(info, inet_ntoa(to4));
+ return;
+ }
+ if ((((const struct iphdr*)fp)->version == 6)) {
+ sprintf(info, "IPv6 %x:%x:%x:%x:%x:%x:%x:%x -> %x:%x:%x:%x:%x:%x:%x:%x",
+ ntohs(fp->ip6_src.s6_addr16[0]),
+ ntohs(fp->ip6_src.s6_addr16[1]),
+ ntohs(fp->ip6_src.s6_addr16[2]),
+ ntohs(fp->ip6_src.s6_addr16[3]),
+ ntohs(fp->ip6_src.s6_addr16[4]),
+ ntohs(fp->ip6_src.s6_addr16[5]),
+ ntohs(fp->ip6_src.s6_addr16[6]),
+ ntohs(fp->ip6_src.s6_addr16[7]),
+ ntohs(fp->ip6_dst.s6_addr16[0]),
+ ntohs(fp->ip6_dst.s6_addr16[1]),
+ ntohs(fp->ip6_dst.s6_addr16[2]),
+ ntohs(fp->ip6_dst.s6_addr16[3]),
+ ntohs(fp->ip6_dst.s6_addr16[4]),
+ ntohs(fp->ip6_dst.s6_addr16[5]),
+ ntohs(fp->ip6_dst.s6_addr16[6]),
+ ntohs(fp->ip6_dst.s6_addr16[7])
+ );
+ return;
+ }
+ sprintf(info, "IPv%d ?", ((const struct iphdr*)fp)->version);
}
/** check that ethertype matches ip version for incoming packets from linux
specific code */
static int valid_incoming(int len, struct tun_pi* tp, struct ip6_hdr* fp) {
- char info[100];
- if (len > (65535 - sizeof(struct tun_pi))) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("RFC4193 Frame
length %d is too big for GNUnet!\n"), len);
- return NO;
- }
- if (len < sizeof(struct tun_pi)) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("RFC4193 Frame
length %d too small\n"), len);
- return NO;
- }
- if ((ntohs(tp->proto) == ETH_P_IP) && (((struct iphdr*)fp)->version ==
4)) {
- return YES;
- } else if ((ntohs(tp->proto) == ETH_P_IPV6) && (((struct
iphdr*)fp)->version == 6)) {
- ipinfo(info, fp);
- VLOG "-> GNUnet(%d) : %s\n", len - sizeof(struct tun_pi), info);
- return YES;
- }
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("RFC4193 Ethertype %x and
IP version %x do not match!\n"),
- ntohs(tp->proto), ((struct iphdr*)fp)->version);
- return NO;
+ char info[100];
+ if (len > (65535 - sizeof(struct tun_pi))) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("RFC4193 Frame length %d
is too big for GNUnet!\n"), len);
+ return NO;
+ }
+ if (len < sizeof(struct tun_pi)) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("RFC4193 Frame length %d
too small\n"), len);
+ return NO;
+ }
+ if ((ntohs(tp->proto) == ETH_P_IP) && (((struct iphdr*)fp)->version == 4)) {
+ return YES;
+ } else if ((ntohs(tp->proto) == ETH_P_IPV6) && (((struct iphdr*)fp)->version
== 6)) {
+ ipinfo(info, fp);
+ VLOG "-> GNUnet(%d) : %s\n", len - sizeof(struct tun_pi), info);
+ return YES;
+ }
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("RFC4193 Ethertype %x and IP
version %x do not match!\n"),
+ ntohs(tp->proto), ((struct iphdr*)fp)->version);
+ return NO;
}
/** Test if two PeerIdentity are equal or not */
static int isEqual(const PeerIdentity *first, const PeerIdentity *second) {
- int i;
- for (i = 0; i < 512/8/sizeof(unsigned int); i++) {
- if (first->hashPubKey.bits[i] != second->hashPubKey.bits[i]) {
- return 0;
- }
- }
- return -1;
+ int i;
+ for (i = 0; i < 512/8/sizeof(unsigned int); i++) {
+ if (first->hashPubKey.bits[i] != second->hashPubKey.bits[i]) {
+ return 0;
+ }
+ }
+ return -1;
}
/**
@@ -443,190 +443,190 @@
* actually we make the first 40 bits of the hash into the prefix!
*/
static void id2ip(struct ClientHandle * cx, const PeerIdentity* them) {
- unsigned char a,b,c,d,e;
- a = (them->hashPubKey.bits[0] >> 8) & 0xff;
- b = (them->hashPubKey.bits[0] >> 0) & 0xff;
- c = (them->hashPubKey.bits[1] >> 8) & 0xff;
- d = (them->hashPubKey.bits[1] >> 0) & 0xff;
- e = (them->hashPubKey.bits[2] >> 8) & 0xff;
- cprintf(cx, CS_PROTO_VPN_REPLY, "fd%02x:%02x%02x:%02x%02x",a,b,c,d,e);
+ unsigned char a,b,c,d,e;
+ a = (them->hashPubKey.bits[0] >> 8) & 0xff;
+ b = (them->hashPubKey.bits[0] >> 0) & 0xff;
+ c = (them->hashPubKey.bits[1] >> 8) & 0xff;
+ d = (them->hashPubKey.bits[1] >> 0) & 0xff;
+ e = (them->hashPubKey.bits[2] >> 8) & 0xff;
+ cprintf(cx, CS_PROTO_VPN_REPLY, "fd%02x:%02x%02x:%02x%02x",a,b,c,d,e);
}
/* convert PeerIdentity into network octet order IPv6 address */
static void id2net(struct in6_addr* buf, const PeerIdentity* them) {
- unsigned char a,b,c,d,e;
- a = (them->hashPubKey.bits[0] >> 8) & 0xff;
- b = (them->hashPubKey.bits[0] >> 0) & 0xff;
- c = (them->hashPubKey.bits[1] >> 8) & 0xff;
- d = (them->hashPubKey.bits[1] >> 0) & 0xff;
- e = (them->hashPubKey.bits[2] >> 8) & 0xff;
+ unsigned char a,b,c,d,e;
+ a = (them->hashPubKey.bits[0] >> 8) & 0xff;
+ b = (them->hashPubKey.bits[0] >> 0) & 0xff;
+ c = (them->hashPubKey.bits[1] >> 8) & 0xff;
+ d = (them->hashPubKey.bits[1] >> 0) & 0xff;
+ e = (them->hashPubKey.bits[2] >> 8) & 0xff;
- /* we are unique random */
- buf->s6_addr16[0] = htons(0xfd00 + a);
- buf->s6_addr16[1] = htons(b * 256 + c);
- buf->s6_addr16[2] = htons(d * 256 + e);
-
- /* IPv6 /48 subnet number is zero */
- buf->s6_addr16[3] = 0;
+ /* we are unique random */
+ buf->s6_addr16[0] = htons(0xfd00 + a);
+ buf->s6_addr16[1] = htons(b * 256 + c);
+ buf->s6_addr16[2] = htons(d * 256 + e);
+
+ /* IPv6 /48 subnet number is zero */
+ buf->s6_addr16[3] = 0;
- /* IPV6 /64 interface is zero */
- buf->s6_addr16[4] = 0;
- buf->s6_addr16[5] = 0;
- buf->s6_addr16[6] = 0;
- buf->s6_addr16[7] = 0;
+ /* IPV6 /64 interface is zero */
+ buf->s6_addr16[4] = 0;
+ buf->s6_addr16[5] = 0;
+ buf->s6_addr16[6] = 0;
+ buf->s6_addr16[7] = 0;
}
static void setup_tunnel(int n, const PeerIdentity *them) {
- struct ifreq ifr;
- struct in6_ifreq ifr6;
- struct in6_rtmsg rt;
- int i, used, fd, id = 0;
+ struct ifreq ifr;
+ struct in6_ifreq ifr6;
+ struct in6_rtmsg rt;
+ int i, used, fd, id = 0;
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Going to
try and make a tunnel in slot %d\n"), n);
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Going to try
and make a tunnel in slot %d\n"), n);
- fd = open("/dev/net/tun", O_RDWR);
- if (fd < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot open
tunnel device because of %s"), strerror(fd));
- GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_BULK,
- "open");
- }
- memset(&ifr, 0, sizeof(ifr));
+ fd = open("/dev/net/tun", O_RDWR);
+ if (fd < 0) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot open tunnel device
because of %s"), strerror(fd));
+ GE_DIE_STRERROR(ectx,
+ GE_FATAL | GE_ADMIN | GE_BULK,
+ "open");
+ }
+ memset(&ifr, 0, sizeof(ifr));
- /* IFF_TUN = IP Packets
- * IFF_TAP = Ethernet packets
- *
- * IFF_NO_PI = Do not provide packet information
- */
+ /* IFF_TUN = IP Packets
+ * IFF_TAP = Ethernet packets
+ *
+ * IFF_NO_PI = Do not provide packet information
+ */
- /* we know its going to be ipv6 cause the version tells us.
- * except that linux *assumes* it will be sent IPv4 frames
- * unless we configure IFF_PI.... hmmmm.... :-/
- * lets see the tun linux module source
- *
- * this needs PI as type = htons(0x86DD)
- * ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
- * We do need PI otherwise TUNTAP assumes it is receiving IPv4...
- */
- ifr.ifr_flags = IFF_TUN;
+ /* we know its going to be ipv6 cause the version tells us.
+ * except that linux *assumes* it will be sent IPv4 frames
+ * unless we configure IFF_PI.... hmmmm.... :-/
+ * lets see the tun linux module source
+ *
+ * this needs PI as type = htons(0x86DD)
+ * ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
+ * We do need PI otherwise TUNTAP assumes it is receiving IPv4...
+ */
+ ifr.ifr_flags = IFF_TUN;
- /* try various names until we find a free one */
- do {
- used = 0;
- for (i = 0; i < entries1; i++) {
- if ((store1+i)->id == id) {
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER |
GE_REQUEST, _("RFC4193 Create skips gnu%d as we are already using it\n"), id);
- id++;
- used = 1;
- }
- }
- if (used == 0) {
- sprintf(ifr.ifr_name, "gnu%d", id);
- if ( ioctl(fd, TUNSETIFF, (void *) &ifr) < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
_("Cannot set tunnel name to %s because of %s\n"), ifr.ifr_name,
strerror(errno));
- id++;
- used = 1;
- } else {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
_("Configured tunnel name to %s\n"), ifr.ifr_name);
- }
- }
- } while (used);
+ /* try various names until we find a free one */
+ do {
+ used = 0;
+ for (i = 0; i < entries1; i++) {
+ if ((store1+i)->id == id) {
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
_("RFC4193 Create skips gnu%d as we are already using it\n"), id);
+ id++;
+ used = 1;
+ }
+ }
+ if (used == 0) {
+ sprintf(ifr.ifr_name, "gnu%d", id);
+ if ( ioctl(fd, TUNSETIFF, (void *) &ifr) < 0) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot
set tunnel name to %s because of %s\n"), ifr.ifr_name, strerror(errno));
+ id++;
+ used = 1;
+ } else {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
_("Configured tunnel name to %s\n"), ifr.ifr_name);
+ }
+ }
+ } while (used);
- ioctl(fd, TUNSETNOCSUM, 1);
- memcpy(&((store1+n)->peer), them, sizeof(PeerIdentity));
- (store1+n)->id = id;
- (store1+n)->fd = fd;
- (store1+n)->active = YES;
- (store1+n)->route_entry = 0;
+ ioctl(fd, TUNSETNOCSUM, 1);
+ memcpy(&((store1+n)->peer), them, sizeof(PeerIdentity));
+ (store1+n)->id = id;
+ (store1+n)->fd = fd;
+ (store1+n)->active = YES;
+ (store1+n)->route_entry = 0;
- /* tun_alloc can change the tunnel name */
- /* strncpy((store1+n)->name, ifr.ifr_name,IFNAMSIZ); */
+ /* tun_alloc can change the tunnel name */
+ /* strncpy((store1+n)->name, ifr.ifr_name,IFNAMSIZ); */
- /* here we should give the tunnel an IPv6 address and fake up a route
to the other end
- * the format looks like this, and the net/host split is fixed at /48
as in rfc4193
- * local /64
- * net: my PeerIdentity
- * subnet: interface number+2
- * interface: NULL
- *
- * remote /48
- * net: their PeerIdentity
- * host: NULL (it's not needed for routes)
- */
+ /* here we should give the tunnel an IPv6 address and fake up a route to the
other end
+ * the format looks like this, and the net/host split is fixed at /48 as in
rfc4193
+ * local /64
+ * net: my PeerIdentity
+ * subnet: interface number+2
+ * interface: NULL
+ *
+ * remote /48
+ * net: their PeerIdentity
+ * host: NULL (it's not needed for routes)
+ */
- /* Run some system commands to set it up... */
-/* sprintf(cmd, "sudo ifconfig %s up", name);
- * GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Calling
%s\n"), cmd);
- * system(cmd);
+ /* Run some system commands to set it up... */
+/* sprintf(cmd, "sudo ifconfig %s up", name);
+ * GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Calling
%s\n"), cmd);
+ * system(cmd);
*/
- /* Bring interface up, like system("sudo ifconfig %s up"); */
-
- /* not needed, we already have the iface name ... strncpy(ifr.ifr_name,
name, IFNAMSIZ); */
- if (ioctl(admin_fd, SIOCGIFFLAGS, &ifr) < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot get socket
flags for gnu%d because %s\n"), id, strerror(errno));
- } else {
- ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
- if (ioctl(admin_fd, SIOCSIFFLAGS, &ifr) < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot
set socket flags for gnu%d because %s\n"), id, strerror(errno));
- }
- }
-
- /* Seems to go better with lower mtu, aka system("sudo ifconfig %s mtu
1280") */
- ifr.ifr_mtu = 1280;
- if (ioctl(admin_fd, SIOCSIFMTU, &ifr) < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot set MTU
for gnu%d because %s\n"), id, strerror(errno));
- }
+ /* Bring interface up, like system("sudo ifconfig %s up"); */
+
+ /* not needed, we already have the iface name ... strncpy(ifr.ifr_name,
name, IFNAMSIZ); */
+ if (ioctl(admin_fd, SIOCGIFFLAGS, &ifr) < 0) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot get socket flags
for gnu%d because %s\n"), id, strerror(errno));
+ } else {
+ ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
+ if (ioctl(admin_fd, SIOCSIFFLAGS, &ifr) < 0) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot set socket
flags for gnu%d because %s\n"), id, strerror(errno));
+ }
+ }
+
+ /* Seems to go better with lower mtu, aka system("sudo ifconfig %s mtu
1280") */
+ ifr.ifr_mtu = 1280;
+ if (ioctl(admin_fd, SIOCSIFMTU, &ifr) < 0) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot set MTU for gnu%d
because %s\n"), id, strerror(errno));
+ }
- /* lets add an IP address... aka "sudo ifconfig %s add %s:%04x::1/64" */
- if (ioctl(admin_fd, SIOCGIFINDEX, &ifr) < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot get
interface index for gnu%d because %s\n"), id, strerror(errno));
- } else {
- /* note to self... htons(64) = kernel oops. */
- (store1+n)->ifindex = ifr.ifr_ifindex;
- ifr6.ifr6_prefixlen = 64;
- ifr6.ifr6_ifindex = ifr.ifr_ifindex;
- id2net(&ifr6.ifr6_addr, coreAPI->myIdentity);
- ifr6.ifr6_addr.s6_addr16[3] = htons(n+VC_START);
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("IPv6
ifaddr gnu%d - %x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
- id,
- ntohs(ifr6.ifr6_addr.s6_addr16[0]),
- ntohs(ifr6.ifr6_addr.s6_addr16[1]),
- ntohs(ifr6.ifr6_addr.s6_addr16[2]),
- ntohs(ifr6.ifr6_addr.s6_addr16[3]),
- ntohs(ifr6.ifr6_addr.s6_addr16[4]),
- ntohs(ifr6.ifr6_addr.s6_addr16[5]),
- ntohs(ifr6.ifr6_addr.s6_addr16[6]),
- ntohs(ifr6.ifr6_addr.s6_addr16[7]),
- ifr6.ifr6_prefixlen);
- if (ioctl(admin_fd, SIOCSIFADDR, &ifr6) < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot
set interface IPv6 address for gnu%d because %s\n"), id, strerror(errno));
- }
-
- /* lets add a route to the peer, aka "#sudo route -A inet6 add
%s::/48 dev %s" */
- memset((char*)&rt, 0, sizeof(struct in6_rtmsg));
- /* rtmsg_ifindex would be zero for routes not specifying a
device, such as by gateway */
- rt.rtmsg_ifindex = ifr.ifr_ifindex;
- id2net(&rt.rtmsg_dst, them);
- rt.rtmsg_flags = RTF_UP;
- rt.rtmsg_metric = 1; /* how many hops to owner of public key
*/
- rt.rtmsg_dst_len = 48; /* network prefix len is 48 by standard
*/
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("IPv6
route gnu%d - destination %x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
- id,
- ntohs(rt.rtmsg_dst.s6_addr16[0]),
- ntohs(rt.rtmsg_dst.s6_addr16[1]),
- ntohs(rt.rtmsg_dst.s6_addr16[2]),
- ntohs(rt.rtmsg_dst.s6_addr16[3]),
- ntohs(rt.rtmsg_dst.s6_addr16[4]),
- ntohs(rt.rtmsg_dst.s6_addr16[5]),
- ntohs(rt.rtmsg_dst.s6_addr16[6]),
- ntohs(rt.rtmsg_dst.s6_addr16[7]),
- rt.rtmsg_dst_len);
- if (ioctl(admin_fd, SIOCADDRT, &rt) < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot
add route IPv6 address for gnu%s because %s\n"), id, strerror(errno));
- }
- }
+ /* lets add an IP address... aka "sudo ifconfig %s add %s:%04x::1/64" */
+ if (ioctl(admin_fd, SIOCGIFINDEX, &ifr) < 0) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot get interface
index for gnu%d because %s\n"), id, strerror(errno));
+ } else {
+ /* note to self... htons(64) = kernel oops. */
+ (store1+n)->ifindex = ifr.ifr_ifindex;
+ ifr6.ifr6_prefixlen = 64;
+ ifr6.ifr6_ifindex = ifr.ifr_ifindex;
+ id2net(&ifr6.ifr6_addr, coreAPI->myIdentity);
+ ifr6.ifr6_addr.s6_addr16[3] = htons(n+VC_START);
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("IPv6 ifaddr gnu%d
- %x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
+ id,
+ ntohs(ifr6.ifr6_addr.s6_addr16[0]),
+ ntohs(ifr6.ifr6_addr.s6_addr16[1]),
+ ntohs(ifr6.ifr6_addr.s6_addr16[2]),
+ ntohs(ifr6.ifr6_addr.s6_addr16[3]),
+ ntohs(ifr6.ifr6_addr.s6_addr16[4]),
+ ntohs(ifr6.ifr6_addr.s6_addr16[5]),
+ ntohs(ifr6.ifr6_addr.s6_addr16[6]),
+ ntohs(ifr6.ifr6_addr.s6_addr16[7]),
+ ifr6.ifr6_prefixlen);
+ if (ioctl(admin_fd, SIOCSIFADDR, &ifr6) < 0) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot set
interface IPv6 address for gnu%d because %s\n"), id, strerror(errno));
+ }
+
+ /* lets add a route to the peer, aka "#sudo route -A inet6 add %s::/48
dev %s" */
+ memset((char*)&rt, 0, sizeof(struct in6_rtmsg));
+ /* rtmsg_ifindex would be zero for routes not specifying a device, such
as by gateway */
+ rt.rtmsg_ifindex = ifr.ifr_ifindex;
+ id2net(&rt.rtmsg_dst, them);
+ rt.rtmsg_flags = RTF_UP;
+ rt.rtmsg_metric = 1; /* how many hops to owner of public key */
+ rt.rtmsg_dst_len = 48; /* network prefix len is 48 by standard */
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("IPv6 route gnu%d
- destination %x:%x:%x:%x:%x:%x:%x:%x/%d\n"),
+ id,
+ ntohs(rt.rtmsg_dst.s6_addr16[0]),
+ ntohs(rt.rtmsg_dst.s6_addr16[1]),
+ ntohs(rt.rtmsg_dst.s6_addr16[2]),
+ ntohs(rt.rtmsg_dst.s6_addr16[3]),
+ ntohs(rt.rtmsg_dst.s6_addr16[4]),
+ ntohs(rt.rtmsg_dst.s6_addr16[5]),
+ ntohs(rt.rtmsg_dst.s6_addr16[6]),
+ ntohs(rt.rtmsg_dst.s6_addr16[7]),
+ rt.rtmsg_dst_len);
+ if (ioctl(admin_fd, SIOCADDRT, &rt) < 0) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot add route
IPv6 address for gnu%s because %s\n"), id, strerror(errno));
+ }
+ }
}
/**
@@ -634,163 +634,163 @@
* PeerIdentity and the filehandle and name of the TUN/TAP in an array so we
remember we did it.
*/
static void checkensure_peer(const PeerIdentity *them, void *callerinfo) {
- int i;
- tunnel_info* rstore1;
- int rcapacity1;
+ int i;
+ tunnel_info* rstore1;
+ int rcapacity1;
- /* GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Going
to checkensure peer %x then\n"), them->hashPubKey.bits[0]); */
- /* first entry in array will be known as gnu0 */
+ /* GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Going to
checkensure peer %x then\n"), them->hashPubKey.bits[0]); */
+ /* first entry in array will be known as gnu0 */
- /* if a tunnel is already setup, we don't setup another */
- for (i = 0; i < entries1; i++) {
- if (isEqual(them, &((store1+i)->peer))) {
- (store1+i)->active = YES;
- return;
- }
- }
+ /* if a tunnel is already setup, we don't setup another */
+ for (i = 0; i < entries1; i++) {
+ if (isEqual(them, &((store1+i)->peer))) {
+ (store1+i)->active = YES;
+ return;
+ }
+ }
- /*
- * append it at the end.
- */
- entries1++;
- rcapacity1 = entries1 * sizeof(tunnel_info);
- if (rcapacity1 > capacity1) {
- rstore1 = REALLOC(store1, rcapacity1);
- if (rstore1 == NULL) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("RFC4193
We have run out of memory and so I can't store a tunnel for this peer.\n"));
- entries1--;
- return;
- }
- store1 = rstore1;
- capacity1 = rcapacity1;
- }
+ /*
+ * append it at the end.
+ */
+ entries1++;
+ rcapacity1 = entries1 * sizeof(tunnel_info);
+ if (rcapacity1 > capacity1) {
+ rstore1 = REALLOC(store1, rcapacity1);
+ if (rstore1 == NULL) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("RFC4193 We have
run out of memory and so I can't store a tunnel for this peer.\n"));
+ entries1--;
+ return;
+ }
+ store1 = rstore1;
+ capacity1 = rcapacity1;
+ }
- /* GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193
Extending array for new tunnel\n")); */
- setup_tunnel((entries1 - 1), them);
+ /* GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Extending
array for new tunnel\n")); */
+ setup_tunnel((entries1 - 1), them);
}
/* make new thread...
* repeat {
- * call forAllConnectedNodes, create/destroy tunnels to match connected
peers, 1 per peer.
- * Give new tunnels their IPv6 addresses like "ifconfig gnu0 add
fdXX:XXXX:XXXX::/48"
- * SELECT for incoming packets, unicast those thru gnunet, or (pipe
activity = exit this thread) or timeout.
+ * call forAllConnectedNodes, create/destroy tunnels to match connected
peers, 1 per peer.
+ * Give new tunnels their IPv6 addresses like "ifconfig gnu0 add
fdXX:XXXX:XXXX::/48"
+ * SELECT for incoming packets, unicast those thru gnunet, or (pipe activity
= exit this thread) or timeout.
* }
* own IPv6 addr is fdXX:XXXX:XXXX::P/48 where X= 40 bits own key, P = gnu0 + 2
* route add -net fdXX(remote key) dev gnu0 is then used.
*/
static void * tunThread(void* arg) {
- fd_set readSet;
- fd_set errorSet;
- fd_set writeSet;
- int i, ret, max;
- char tmp[MAXSIG_BUF];
- struct stat statinfo;
+ fd_set readSet;
+ fd_set errorSet;
+ fd_set writeSet;
+ int i, ret, max;
+ char tmp[MAXSIG_BUF];
+ struct stat statinfo;
- /**
- * IP frames are preceeded by the TUN/TAP header (for Linux) or by the
GNUnet header
- * other systems like HURD, etc may use different headers
- */
- char frame[IP_FRAME + HEADER_FRAME];
- struct ip6_hdr* fp;
- struct tun_pi* tp;
- MESSAGE_HEADER* gp;
- struct timeval timeout;
+ /**
+ * IP frames are preceeded by the TUN/TAP header (for Linux) or by the
GNUnet header
+ * other systems like HURD, etc may use different headers
+ */
+ char frame[IP_FRAME + HEADER_FRAME];
+ struct ip6_hdr* fp;
+ struct tun_pi* tp;
+ MESSAGE_HEADER* gp;
+ struct timeval timeout;
- /* need the cast otherwise it increments by HEADER_FRAME *
sizeof(frame) rather than HEADER_FRAME */
- fp = (struct ip6_hdr*)(((char*)&frame) + HEADER_FRAME);
+ /* need the cast otherwise it increments by HEADER_FRAME * sizeof(frame)
rather than HEADER_FRAME */
+ fp = (struct ip6_hdr*)(((char*)&frame) + HEADER_FRAME);
- /* this trick decrements the pointer by the sizes of the respective
structs */
- tp = ((struct tun_pi*)fp)-1;
- gp = ((MESSAGE_HEADER*)fp)-1;
- running = 1;
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Thread
running (frame %d tunnel %d f2f %d) ...\n"), fp, tp, gp);
+ /* this trick decrements the pointer by the sizes of the respective structs
*/
+ tp = ((struct tun_pi*)fp)-1;
+ gp = ((MESSAGE_HEADER*)fp)-1;
+ running = 1;
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Thread running
(frame %d tunnel %d f2f %d) ...\n"), fp, tp, gp);
- MUTEX_LOCK(lock);
- while (running) {
+ MUTEX_LOCK(lock);
+ while (running) {
- FD_ZERO(&readSet);
- FD_ZERO(&errorSet);
- FD_ZERO(&writeSet);
+ FD_ZERO(&readSet);
+ FD_ZERO(&errorSet);
+ FD_ZERO(&writeSet);
- max = signalingPipe[0];
+ max = signalingPipe[0];
- if (-1 != FSTAT(signalingPipe[0], &statinfo)) {
- FD_SET(signalingPipe[0], &readSet);
- } else {
- GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_BULK,
- "fstat");
- }
- for (i = 0; i < entries1; i++) {
- FD_SET(((store1+i)->fd), &readSet);
- max = maxi(max,(store1+i)->fd);
- }
- MUTEX_UNLOCK(lock);
- timeout.tv_sec = interval;
- timeout.tv_usec = 0;
+ if (-1 != FSTAT(signalingPipe[0], &statinfo)) {
+ FD_SET(signalingPipe[0], &readSet);
+ } else {
+ GE_DIE_STRERROR(ectx,
+ GE_FATAL | GE_ADMIN | GE_BULK,
+ "fstat");
+ }
+ for (i = 0; i < entries1; i++) {
+ FD_SET(((store1+i)->fd), &readSet);
+ max = maxi(max,(store1+i)->fd);
+ }
+ MUTEX_UNLOCK(lock);
+ timeout.tv_sec = interval;
+ timeout.tv_usec = 0;
- ret = SELECT(max+1,
- &readSet,
- &writeSet,
- &errorSet,
- &timeout);
- if (ret < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, "From the
vpn select: %s\n", strerror(errno));
- running = 0;
- break;
- }
- if (FD_ISSET(signalingPipe[0], &readSet)) {
- if (0 >= READ(signalingPipe[0],
- &tmp[0],
- MAXSIG_BUF))
- GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- "vpn could not read from exit control
pipe\n");
- }
- MUTEX_LOCK(lock);
- for (i = 0; i < entries1; i++) {
- if (FD_ISSET(((store1+i)->fd), &readSet)) {
- ret = read(((store1+i)->fd), tp, IP_FRAME);
+ ret = SELECT(max+1,
+ &readSet,
+ &writeSet,
+ &errorSet,
+ &timeout);
+ if (ret < 0) {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, "From the vpn
select: %s\n", strerror(errno));
+ running = 0;
+ break;
+ }
+ if (FD_ISSET(signalingPipe[0], &readSet)) {
+ if (0 >= READ(signalingPipe[0],
+ &tmp[0],
+ MAXSIG_BUF))
+ GE_LOG_STRERROR(ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ "vpn could not read from exit control
pipe\n");
+ }
+ MUTEX_LOCK(lock);
+ for (i = 0; i < entries1; i++) {
+ if (FD_ISSET(((store1+i)->fd), &readSet)) {
+ ret = read(((store1+i)->fd), tp, IP_FRAME);
- /* goodbye IPv6 packet, enjoy the GNUnet... :-)
- * IP is of course very important so it will
enjoy
- * the very highest priority
- */
- if (valid_incoming(ret, tp, fp)) {
- gp->type = htons(P2P_PROTO_aip_IP);
- gp->size = htons(sizeof(MESSAGE_HEADER)
+ ret - sizeof(struct tun_pi));
-
coreAPI->unicast(&((store1+i)->peer),gp,EXTREME_PRIORITY,1);
-
coreAPI->preferTrafficFrom(&((store1+i)->peer),1000);
- }
- }
- /* we do this here as we get a race if the p2p handler
tries it */
- if (((store1+i)->active) == 0) {
- if ( close( (store1+i)->fd ) == 0) {
- GE_LOG(ectx, GE_INFO | GE_REQUEST |
GE_USER, _("VPN dropping connection %x\n"), i);
- *(store1+i) = *(store1+(entries1-1));
- entries1--;
- } else {
- GE_LOG(ectx, GE_ERROR | GE_BULK |
GE_USER, _("VPN cannot drop connection %x\n"), i);
- }
- }
- }
+ /* goodbye IPv6 packet, enjoy the GNUnet... :-)
+ * IP is of course very important so it will enjoy
+ * the very highest priority
+ */
+ if (valid_incoming(ret, tp, fp)) {
+ gp->type = htons(P2P_PROTO_aip_IP);
+ gp->size = htons(sizeof(MESSAGE_HEADER) + ret -
sizeof(struct tun_pi));
+
coreAPI->unicast(&((store1+i)->peer),gp,EXTREME_PRIORITY,1);
+
coreAPI->preferTrafficFrom(&((store1+i)->peer),1000);
+ }
+ }
+ /* we do this here as we get a race if the p2p handler tries it
*/
+ if (((store1+i)->active) == 0) {
+ if ( close( (store1+i)->fd ) == 0) {
+ GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER,
_("VPN dropping connection %x\n"), i);
+ *(store1+i) = *(store1+(entries1-1));
+ entries1--;
+ } else {
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
_("VPN cannot drop connection %x\n"), i);
+ }
+ }
+ }
/*
- if (timeout.tv_sec < (interval / 2)) {
- for (i = 0; i < entries1; i++) {
- if (((store1+i)->active) > 0) {
- if
(identity->isBlacklistedStrict(&((store1+i)->peer))) {
- GE_LOG(ectx, GE_INFO |
GE_REQUEST | GE_USER, _("RFC4193 --- whitelist of peer %x\n"),
-
(store1+i)->peer.hashPubKey.bits[0]);
-
identity->whitelistHost(&((store1+i)->peer));
- }
- }
- }
- }
+ if (timeout.tv_sec < (interval / 2)) {
+ for (i = 0; i < entries1; i++) {
+ if (((store1+i)->active) > 0) {
+ if
(identity->isBlacklistedStrict(&((store1+i)->peer))) {
+ GE_LOG(ectx, GE_INFO | GE_REQUEST |
GE_USER, _("RFC4193 --- whitelist of peer %x\n"),
+
(store1+i)->peer.hashPubKey.bits[0]);
+
identity->whitelistHost(&((store1+i)->peer));
+ }
+ }
+ }
+ }
*/
- }
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Thread
exiting\n"));
- MUTEX_UNLOCK(lock);
- return NULL;
+ }
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 Thread
exiting\n"));
+ MUTEX_UNLOCK(lock);
+ return NULL;
}
/**
@@ -802,533 +802,533 @@
* for a TUN/TAP header for writing it to TUNTAP.
*/
static int handlep2pMSG(const PeerIdentity * sender, const MESSAGE_HEADER *
gp) {
- int i = 0, fd;
- char loginfo[100];
+ int i = 0, fd;
+ char loginfo[100];
- MESSAGE_HEADER * rgp = NULL;
- char frame[IP_FRAME + sizeof(struct tun_pi)];
+ MESSAGE_HEADER * rgp = NULL;
+ char frame[IP_FRAME + sizeof(struct tun_pi)];
const struct ip6_hdr* fp = (struct ip6_hdr*)(gp+1);
struct ip6_hdr* new_fp = (struct ip6_hdr*)(((char*)&frame) +
sizeof(struct tun_pi));
struct tun_pi* tp = (struct tun_pi*)(&frame);
- switch (ntohs(gp->type)) {
- case P2P_PROTO_aip_IP:
- tp->flags = 0;
+ switch (ntohs(gp->type)) {
+ case P2P_PROTO_aip_IP:
+ tp->flags = 0;
- /* better check src/dst IP for anonymity preservation
requirements here...
- * I.e. in fd::/8 and check next header as well.
- *
- * Also permit multicast [ RFC 3306 ]
ff3x:0030:fdnn:nnnn:nnnn::/96
- * where x = diameter. n are the random bits from the
allocater's IP
- * (and must match the sender's )
- * 30 = usual bit length of a sender's node/network-prefix,
- * we allow longer, and that must match sender if specified.
- */
- switch (((struct iphdr*)fp)->version) {
- case 6:
- tp->proto = htons(ETH_P_IPV6);
- if ( ntohs(fp->ip6_src.s6_addr16[0]) < 0xFD00 )
{
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER |
GE_REQUEST, _("VPN IP src not anonymous. drop..\n"));
- return OK;
- }
- if ( ntohs(fp->ip6_dst.s6_addr16[0]) < 0xFD00 )
{
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER |
GE_REQUEST, _("VPN IP not anonymous, drop.\n"));
- return OK;
- }
- break;
- case 4:
- tp->proto = htons(ETH_P_IP);
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER |
GE_REQUEST, _("VPN Received, not anonymous, drop.\n"));
- return OK;
- default:
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
_("VPN Received unknown IP version %d...\n"), ((struct iphdr*)fp)->version);
- return OK;
- }
+ /* better check src/dst IP for anonymity preservation requirements
here...
+ * I.e. in fd::/8 and check next header as well.
+ *
+ * Also permit multicast [ RFC 3306 ] ff3x:0030:fdnn:nnnn:nnnn::/96
+ * where x = diameter. n are the random bits from the allocater's IP
+ * (and must match the sender's )
+ * 30 = usual bit length of a sender's node/network-prefix,
+ * we allow longer, and that must match sender if specified.
+ */
+ switch (((struct iphdr*)fp)->version) {
+ case 6:
+ tp->proto = htons(ETH_P_IPV6);
+ if ( ntohs(fp->ip6_src.s6_addr16[0]) < 0xFD00 ) {
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER |
GE_REQUEST, _("VPN IP src not anonymous. drop..\n"));
+ return OK;
+ }
+ if ( ntohs(fp->ip6_dst.s6_addr16[0]) < 0xFD00 ) {
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER |
GE_REQUEST, _("VPN IP not anonymous, drop.\n"));
+ return OK;
+ }
+ break;
+ case 4:
+ tp->proto = htons(ETH_P_IP);
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
_("VPN Received, not anonymous, drop.\n"));
+ return OK;
+ default:
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("VPN
Received unknown IP version %d...\n"), ((struct iphdr*)fp)->version);
+ return OK;
+ }
- ipinfo(loginfo, fp);
+ ipinfo(loginfo, fp);
- /* do packet memcpy outside of mutex for speed */
- memcpy(new_fp, fp, ntohs(gp->size)-sizeof(MESSAGE_HEADER));
+ /* do packet memcpy outside of mutex for speed */
+ memcpy(new_fp, fp, ntohs(gp->size)-sizeof(MESSAGE_HEADER));
- MUTEX_LOCK(lock);
- VLOG _("<- GNUnet(%d) : %s\n"), ntohs(gp->size) -
sizeof(MESSAGE_HEADER), loginfo);
- for (i = 0; i < entries1; i++) {
- if (isEqual(sender, &((store1+i)->peer))) {
- fd = ((store1+i)->fd);
-
- (store1+i)->active = YES;
+ MUTEX_LOCK(lock);
+ VLOG _("<- GNUnet(%d) : %s\n"), ntohs(gp->size) -
sizeof(MESSAGE_HEADER), loginfo);
+ for (i = 0; i < entries1; i++) {
+ if (isEqual(sender, &((store1+i)->peer))) {
+ fd = ((store1+i)->fd);
+
+ (store1+i)->active = YES;
- /* We are only allowed one call to write() per
packet.
- * We need to write packet and packetinfo
together in one go.
- */
- write(fd, tp, ntohs(gp->size) + sizeof(struct
tun_pi) - sizeof(MESSAGE_HEADER));
-
coreAPI->preferTrafficFrom(&((store1+i)->peer),1000);
- MUTEX_UNLOCK(lock);
- return OK;
- }
- }
- /* do not normally get here... but checkensure so any future
packets could be routed... */
- checkensure_peer(sender, NULL);
- MUTEX_UNLOCK(lock);
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("Could not
write the tunnelled IP to the OS... Did to setup a tunnel?\n"));
- return OK;
- case p2p_PROTO_PONG:
- MUTEX_LOCK(lock);
- checkensure_peer(sender, NULL);
- MUTEX_UNLOCK(lock);
- return OK;
- case P2P_PROTO_hangup:
- MUTEX_LOCK(lock);
- for (i = 0; i < entries1; i++) {
- if (
- (((store1+i)->fd) > 0) &&
- isEqual(sender, &((store1+i)->peer))
- ) {
- (store1+i)->active = NO;
- }
- }
- MUTEX_UNLOCK(lock);
- return OK;
- case P2P_PROTO_aip_GETROUTE:
- /** peer wants an entry from our routing table */
- VLOG _("Receive route request\n"));
- if (ntohs(gp->size) == (sizeof(MESSAGE_HEADER) + sizeof(int))) {
- i = ntohl(*((int*)fp));
- MUTEX_LOCK(lock);
- if (i < realised_entries) {
- VLOG _("Prepare route announcement level
%d\n"), i);
- rgp = MALLOC(sizeof(MESSAGE_HEADER) +
sizeof(transit_route));
- if (rgp == NULL) {
- MUTEX_UNLOCK(lock);
- return OK;
- }
- rgp->size = htons(sizeof(MESSAGE_HEADER) +
sizeof(transit_route));
- rgp->type = htons(P2P_PROTO_aip_ROUTE);
- ((transit_route*)(rgp+1))->owner =
(realised_store+i)->owner;
- ((transit_route*)(rgp+1))->hops =
htonl((realised_store+i)->hops);
- MUTEX_UNLOCK(lock);
- VLOG _("Send route announcement %d with route
announce\n"), i);
- /* it must be delivered if possible, but it can
wait longer than IP */
- coreAPI->unicast(sender, rgp, EXTREME_PRIORITY,
15);
- FREE(rgp);
- return OK;
- }
- VLOG _("Send outside table info %d\n"), i);
- rgp = MALLOC(sizeof(MESSAGE_HEADER) + sizeof(int));
- if (rgp == NULL) {
- MUTEX_UNLOCK(lock);
- return OK;
- }
- rgp->size = htons(sizeof(MESSAGE_HEADER) + sizeof(int));
- rgp->type = htons(P2P_PROTO_aip_ROUTES);
- *((int*)(rgp+1)) = htonl(realised_entries);
- MUTEX_UNLOCK(lock);
- coreAPI->unicast(sender, rgp, EXTREME_PRIORITY, 15);
- FREE(rgp);
- return OK;
- }
- return OK;
- case P2P_PROTO_aip_ROUTE:
- VLOG _("Receive route announce.\n"));
- /** peer sent us a route, insert it into routing table, then
req next entry */
- if (ntohs(gp->size) == (sizeof(MESSAGE_HEADER) +
sizeof(transit_route))) {
- MUTEX_LOCK(lock);
- VLOG _("Going to try insert route into local
table.\n"));
- for (i = 0; i < entries1; i++) {
- if (isEqual(sender, &((store1+i)->peer))) {
- (store1+i)->active = YES;
- VLOG _("Inserting with hops %d\n"),
ntohl( ((transit_route*)(gp+1))->hops));
- add_route( &(
((transit_route*)(gp+1))->owner ),
- 1 + ntohl(
((transit_route*)(gp+1))->hops),
- i);
- if ((store1+i)->route_entry <
GNUNET_VIEW_LIMIT) {
- (store1+i)->route_entry++;
- rgp =
MALLOC(sizeof(MESSAGE_HEADER) + sizeof(int));
- if (rgp == NULL) {
- MUTEX_UNLOCK(lock);
- return OK;
- }
- rgp->type =
htons(P2P_PROTO_aip_GETROUTE);
- rgp->size =
htons(sizeof(MESSAGE_HEADER) + sizeof(int));
- *((int*)(rgp+1)) =
htonl((store1+i)->route_entry);
- VLOG _("Request level %d from
peer %d\n"), (store1+i)->route_entry, i);
-
coreAPI->unicast(&((store1+i)->peer),rgp,EXTREME_PRIORITY,60);
- FREE(rgp);
- }
- break;
- }
- }
- MUTEX_UNLOCK(lock);
- }
- return OK;
- case P2P_PROTO_aip_ROUTES:
- if (ntohs(gp->size) == (sizeof(MESSAGE_HEADER) + sizeof(int))) {
- /* if this is the last route message, we do route
realisation
- * that is, insert the routes into the operating system.
- */
- VLOG _("Receive table limit on peer reached %d\n"),
ntohl( *((int*)fp)) );
-/* MUTEX_LOCK(lock);
- for (i = 0; i < entries1; i++) {
- if (isEqual(sender, &((store1+i)->peer))) {
- VLOG _("Storing table limit %d for peer
%d\n"), ntohl( *((int*)fp)), i );
- (store1+i)->route_limit = ntohl(
*((int*)fp));
- break;
- }
- }
- MUTEX_UNLOCK(lock);
-*/ }
- return OK;
- }
- return OK;
+ /* We are only allowed one call to write() per packet.
+ * We need to write packet and packetinfo together in
one go.
+ */
+ write(fd, tp, ntohs(gp->size) + sizeof(struct tun_pi) -
sizeof(MESSAGE_HEADER));
+ coreAPI->preferTrafficFrom(&((store1+i)->peer),1000);
+ MUTEX_UNLOCK(lock);
+ return OK;
+ }
+ }
+ /* do not normally get here... but checkensure so any future packets
could be routed... */
+ checkensure_peer(sender, NULL);
+ MUTEX_UNLOCK(lock);
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("Could not write
the tunnelled IP to the OS... Did to setup a tunnel?\n"));
+ return OK;
+ case p2p_PROTO_PONG:
+ MUTEX_LOCK(lock);
+ checkensure_peer(sender, NULL);
+ MUTEX_UNLOCK(lock);
+ return OK;
+ case P2P_PROTO_hangup:
+ MUTEX_LOCK(lock);
+ for (i = 0; i < entries1; i++) {
+ if (
+ (((store1+i)->fd) > 0) &&
+ isEqual(sender, &((store1+i)->peer))
+ ) {
+ (store1+i)->active = NO;
+ }
+ }
+ MUTEX_UNLOCK(lock);
+ return OK;
+ case P2P_PROTO_aip_GETROUTE:
+ /** peer wants an entry from our routing table */
+ VLOG _("Receive route request\n"));
+ if (ntohs(gp->size) == (sizeof(MESSAGE_HEADER) + sizeof(int))) {
+ i = ntohl(*((int*)fp));
+ MUTEX_LOCK(lock);
+ if (i < realised_entries) {
+ VLOG _("Prepare route announcement level %d\n"), i);
+ rgp = MALLOC(sizeof(MESSAGE_HEADER) +
sizeof(transit_route));
+ if (rgp == NULL) {
+ MUTEX_UNLOCK(lock);
+ return OK;
+ }
+ rgp->size = htons(sizeof(MESSAGE_HEADER) +
sizeof(transit_route));
+ rgp->type = htons(P2P_PROTO_aip_ROUTE);
+ ((transit_route*)(rgp+1))->owner =
(realised_store+i)->owner;
+ ((transit_route*)(rgp+1))->hops =
htonl((realised_store+i)->hops);
+ MUTEX_UNLOCK(lock);
+ VLOG _("Send route announcement %d with route
announce\n"), i);
+ /* it must be delivered if possible, but it can wait
longer than IP */
+ coreAPI->unicast(sender, rgp, EXTREME_PRIORITY, 15);
+ FREE(rgp);
+ return OK;
+ }
+ VLOG _("Send outside table info %d\n"), i);
+ rgp = MALLOC(sizeof(MESSAGE_HEADER) + sizeof(int));
+ if (rgp == NULL) {
+ MUTEX_UNLOCK(lock);
+ return OK;
+ }
+ rgp->size = htons(sizeof(MESSAGE_HEADER) + sizeof(int));
+ rgp->type = htons(P2P_PROTO_aip_ROUTES);
+ *((int*)(rgp+1)) = htonl(realised_entries);
+ MUTEX_UNLOCK(lock);
+ coreAPI->unicast(sender, rgp, EXTREME_PRIORITY, 15);
+ FREE(rgp);
+ return OK;
+ }
+ return OK;
+ case P2P_PROTO_aip_ROUTE:
+ VLOG _("Receive route announce.\n"));
+ /** peer sent us a route, insert it into routing table, then req next
entry */
+ if (ntohs(gp->size) == (sizeof(MESSAGE_HEADER) +
sizeof(transit_route))) {
+ MUTEX_LOCK(lock);
+ VLOG _("Going to try insert route into local table.\n"));
+ for (i = 0; i < entries1; i++) {
+ if (isEqual(sender, &((store1+i)->peer))) {
+ (store1+i)->active = YES;
+ VLOG _("Inserting with hops %d\n"), ntohl(
((transit_route*)(gp+1))->hops));
+ add_route( &(
((transit_route*)(gp+1))->owner ),
+ 1 + ntohl(
((transit_route*)(gp+1))->hops),
+ i);
+ if ((store1+i)->route_entry <
GNUNET_VIEW_LIMIT) {
+ (store1+i)->route_entry++;
+ rgp = MALLOC(sizeof(MESSAGE_HEADER) +
sizeof(int));
+ if (rgp == NULL) {
+ MUTEX_UNLOCK(lock);
+ return OK;
+ }
+ rgp->type =
htons(P2P_PROTO_aip_GETROUTE);
+ rgp->size =
htons(sizeof(MESSAGE_HEADER) + sizeof(int));
+ *((int*)(rgp+1)) =
htonl((store1+i)->route_entry);
+ VLOG _("Request level %d from peer
%d\n"), (store1+i)->route_entry, i);
+
coreAPI->unicast(&((store1+i)->peer),rgp,EXTREME_PRIORITY,60);
+ FREE(rgp);
+ }
+ break;
+ }
+ }
+ MUTEX_UNLOCK(lock);
+ }
+ return OK;
+ case P2P_PROTO_aip_ROUTES:
+ if (ntohs(gp->size) == (sizeof(MESSAGE_HEADER) + sizeof(int))) {
+ /* if this is the last route message, we do route realisation
+ * that is, insert the routes into the operating system.
+ */
+ VLOG _("Receive table limit on peer reached %d\n"), ntohl(
*((int*)fp)) );
+/* MUTEX_LOCK(lock);
+ for (i = 0; i < entries1; i++) {
+ if (isEqual(sender, &((store1+i)->peer))) {
+ VLOG _("Storing table limit %d for peer %d\n"),
ntohl( *((int*)fp)), i );
+ (store1+i)->route_limit = ntohl( *((int*)fp));
+ break;
+ }
+ }
+ MUTEX_UNLOCK(lock);
+*/ }
+ return OK;
+ }
+ return OK;
}
/* here we copy the prototype route table we are collecting from peers to the
actual
* "realised" route table we distribute to peers, and to the kernel's table.
*/
static void realise(struct ClientHandle * c) {
- int i, j, found;
- PeerIdentity id;
- int reqcapacity;
- route_info *reqstore;
- struct in6_rtmsg rt;
+ int i, j, found;
+ PeerIdentity id;
+ int reqcapacity;
+ route_info *reqstore;
+ struct in6_rtmsg rt;
MUTEX_LOCK(lock);
- /* make sure realised table can take the new routes - if it wont, abort
now! */
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("realise alloc
ram\n"));
- if (route_entries > realised_entries) {
- reqcapacity = sizeof(route_info) * route_entries;
- if (reqcapacity > realised_capacity) {
- reqstore = REALLOC(realised_store, reqcapacity);
- if (reqstore == NULL) {
- cprintf(c, CS_PROTO_VPN_REPLY, "I cannot up the
ram for realised routes.\n");
- MUTEX_UNLOCK(lock);
- return;
- }
- realised_store = reqstore;
- realised_capacity = reqcapacity;
- }
- }
- /* add routes that are in the new table but not the old */
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("realise add
routes\n"));
- for (i = 0; i < route_entries; i++) {
- found = 0;
- for (j = 0; j < realised_entries; j++) {
- /* compare public key */
- if
(isEqualP(&(route_store+i)->owner,&(realised_store+j)->owner) &&
- ((route_store+i)->hops ==
(realised_store+j)->hops) &&
- ((route_store+i)->tunnel ==
(realised_store+j)->tunnel)
- ) {
- found = 1;
- }
- }
- /* we are hops == 0
- * hops == 1 auto added by tunneler
- * hops >= 2 added here!
- */
- if (!(found) && ((route_store+i)->hops > 1)) {
- /* lets add a route to this long remote node */
- memset((char*)&rt, 0, sizeof(struct in6_rtmsg));
- /* rtmsg_ifindex would be zero for routes not
specifying a device, such as by gateway */
- rt.rtmsg_ifindex =
(store1+((route_store+i)->tunnel))->ifindex;
- identity->getPeerIdentity(&(route_store+i)->owner, &id);
- id2net(&rt.rtmsg_dst, &id);
- rt.rtmsg_flags = RTF_UP;
- rt.rtmsg_metric = (route_store+i)->hops;
- /* how many hops to owner of public key */
- rt.rtmsg_dst_len = 48; /* always 48 as per RFC4193 */
- cprintf(c, CS_PROTO_VPN_REPLY, "Add route gnu%d hops %d
dst %x:%x:%x:%x:%x:%x:%x:%x/%d\n",
- id,
- rt.rtmsg_metric,
- ntohs(rt.rtmsg_dst.s6_addr16[0]),
- ntohs(rt.rtmsg_dst.s6_addr16[1]),
- ntohs(rt.rtmsg_dst.s6_addr16[2]),
- ntohs(rt.rtmsg_dst.s6_addr16[3]),
- ntohs(rt.rtmsg_dst.s6_addr16[4]),
- ntohs(rt.rtmsg_dst.s6_addr16[5]),
- ntohs(rt.rtmsg_dst.s6_addr16[6]),
- ntohs(rt.rtmsg_dst.s6_addr16[7]),
- rt.rtmsg_dst_len);
- if (ioctl(admin_fd, SIOCADDRT, &rt) < 0) {
- cprintf(c, CS_PROTO_VPN_REPLY, "Cannot add
route IPv6 address for gnu%s because %s\n", id, strerror(errno));
- }
- }
- }
- cprintf(c, CS_PROTO_VPN_REPLY, "Removing routes\n");
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("realise pull
routes\n"));
- /* pull routes that are in the old table but not the new */
- for (i = 0; i < realised_entries; i++) {
- found = 0;
- for (j = 0; j < route_entries; j++) {
- /* compare public key */
- if
(isEqualP(&(realised_store+i)->owner,&(route_store+j)->owner) &&
- ((realised_store+i)->hops ==
(route_store+j)->hops) &&
- ((realised_store+i)->tunnel ==
(route_store+j)->tunnel)
- ) {
- found = 1;
- }
- }
- /* we are hops == 0
- * hops == 1 auto added by tunneler
- * hops >= 2 added here!
- */
- if (!(found) && ((realised_store+i)->hops > 1)) {
- /* remove the route to this long remote node */
- memset((char*)&rt, 0, sizeof(struct in6_rtmsg));
- /* rtmsg_ifindex would be zero for routes not
specifying a device, such as by gateway */
- rt.rtmsg_ifindex =
(store1+((realised_store+i)->tunnel))->ifindex;
- identity->getPeerIdentity(&(realised_store+i)->owner,
&id);
- id2net(&rt.rtmsg_dst, &id);
- rt.rtmsg_flags = RTF_UP;
- rt.rtmsg_metric = (realised_store+i)->hops;
- /* how many hops to owner of public key */
- rt.rtmsg_dst_len = 48; /* always 48 as per RFC4193 */
- cprintf(c, CS_PROTO_VPN_REPLY, "Delete route gnu%d hops
%d dst %x:%x:%x:%x:%x:%x:%x:%x/%d\n",
- id,
- rt.rtmsg_metric,
- ntohs(rt.rtmsg_dst.s6_addr16[0]),
- ntohs(rt.rtmsg_dst.s6_addr16[1]),
- ntohs(rt.rtmsg_dst.s6_addr16[2]),
- ntohs(rt.rtmsg_dst.s6_addr16[3]),
- ntohs(rt.rtmsg_dst.s6_addr16[4]),
- ntohs(rt.rtmsg_dst.s6_addr16[5]),
- ntohs(rt.rtmsg_dst.s6_addr16[6]),
- ntohs(rt.rtmsg_dst.s6_addr16[7]),
- rt.rtmsg_dst_len);
- if (ioctl(admin_fd, SIOCDELRT, &rt) < 0) {
- cprintf(c, CS_PROTO_VPN_REPLY, "Cannot del
route IPv6 address for gnu%s because %s\n", id, strerror(errno));
- }
- }
- }
- cprintf(c, CS_PROTO_VPN_REPLY, "Copying table\n");
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("realise copy
table\n"));
- realised_entries = route_entries;
- memcpy(realised_store,route_store, sizeof(route_info) * route_entries);
+ /* make sure realised table can take the new routes - if it wont, abort now!
*/
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("realise alloc ram\n"));
+ if (route_entries > realised_entries) {
+ reqcapacity = sizeof(route_info) * route_entries;
+ if (reqcapacity > realised_capacity) {
+ reqstore = REALLOC(realised_store, reqcapacity);
+ if (reqstore == NULL) {
+ cprintf(c, CS_PROTO_VPN_REPLY, "I cannot up the ram for
realised routes.\n");
+ MUTEX_UNLOCK(lock);
+ return;
+ }
+ realised_store = reqstore;
+ realised_capacity = reqcapacity;
+ }
+ }
+ /* add routes that are in the new table but not the old */
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("realise add
routes\n"));
+ for (i = 0; i < route_entries; i++) {
+ found = 0;
+ for (j = 0; j < realised_entries; j++) {
+ /* compare public key */
+ if
(isEqualP(&(route_store+i)->owner,&(realised_store+j)->owner) &&
+ ((route_store+i)->hops == (realised_store+j)->hops) &&
+ ((route_store+i)->tunnel == (realised_store+j)->tunnel)
+ ) {
+ found = 1;
+ }
+ }
+ /* we are hops == 0
+ * hops == 1 auto added by tunneler
+ * hops >= 2 added here!
+ */
+ if (!(found) && ((route_store+i)->hops > 1)) {
+ /* lets add a route to this long remote node */
+ memset((char*)&rt, 0, sizeof(struct in6_rtmsg));
+ /* rtmsg_ifindex would be zero for routes not specifying a
device, such as by gateway */
+ rt.rtmsg_ifindex = (store1+((route_store+i)->tunnel))->ifindex;
+ identity->getPeerIdentity(&(route_store+i)->owner, &id);
+ id2net(&rt.rtmsg_dst, &id);
+ rt.rtmsg_flags = RTF_UP;
+ rt.rtmsg_metric = (route_store+i)->hops;
+ /* how many hops to owner of public key */
+ rt.rtmsg_dst_len = 48; /* always 48 as per RFC4193 */
+ cprintf(c, CS_PROTO_VPN_REPLY, "Add route gnu%d hops %d dst
%x:%x:%x:%x:%x:%x:%x:%x/%d\n",
+ id,
+ rt.rtmsg_metric,
+ ntohs(rt.rtmsg_dst.s6_addr16[0]),
+ ntohs(rt.rtmsg_dst.s6_addr16[1]),
+ ntohs(rt.rtmsg_dst.s6_addr16[2]),
+ ntohs(rt.rtmsg_dst.s6_addr16[3]),
+ ntohs(rt.rtmsg_dst.s6_addr16[4]),
+ ntohs(rt.rtmsg_dst.s6_addr16[5]),
+ ntohs(rt.rtmsg_dst.s6_addr16[6]),
+ ntohs(rt.rtmsg_dst.s6_addr16[7]),
+ rt.rtmsg_dst_len);
+ if (ioctl(admin_fd, SIOCADDRT, &rt) < 0) {
+ cprintf(c, CS_PROTO_VPN_REPLY, "Cannot add route IPv6
address for gnu%s because %s\n", id, strerror(errno));
+ }
+ }
+ }
+ cprintf(c, CS_PROTO_VPN_REPLY, "Removing routes\n");
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("realise pull
routes\n"));
+ /* pull routes that are in the old table but not the new */
+ for (i = 0; i < realised_entries; i++) {
+ found = 0;
+ for (j = 0; j < route_entries; j++) {
+ /* compare public key */
+ if
(isEqualP(&(realised_store+i)->owner,&(route_store+j)->owner) &&
+ ((realised_store+i)->hops == (route_store+j)->hops) &&
+ ((realised_store+i)->tunnel == (route_store+j)->tunnel)
+ ) {
+ found = 1;
+ }
+ }
+ /* we are hops == 0
+ * hops == 1 auto added by tunneler
+ * hops >= 2 added here!
+ */
+ if (!(found) && ((realised_store+i)->hops > 1)) {
+ /* remove the route to this long remote node */
+ memset((char*)&rt, 0, sizeof(struct in6_rtmsg));
+ /* rtmsg_ifindex would be zero for routes not specifying a
device, such as by gateway */
+ rt.rtmsg_ifindex =
(store1+((realised_store+i)->tunnel))->ifindex;
+ identity->getPeerIdentity(&(realised_store+i)->owner, &id);
+ id2net(&rt.rtmsg_dst, &id);
+ rt.rtmsg_flags = RTF_UP;
+ rt.rtmsg_metric = (realised_store+i)->hops;
+ /* how many hops to owner of public key */
+ rt.rtmsg_dst_len = 48; /* always 48 as per RFC4193 */
+ cprintf(c, CS_PROTO_VPN_REPLY, "Delete route gnu%d hops %d dst
%x:%x:%x:%x:%x:%x:%x:%x/%d\n",
+ id,
+ rt.rtmsg_metric,
+ ntohs(rt.rtmsg_dst.s6_addr16[0]),
+ ntohs(rt.rtmsg_dst.s6_addr16[1]),
+ ntohs(rt.rtmsg_dst.s6_addr16[2]),
+ ntohs(rt.rtmsg_dst.s6_addr16[3]),
+ ntohs(rt.rtmsg_dst.s6_addr16[4]),
+ ntohs(rt.rtmsg_dst.s6_addr16[5]),
+ ntohs(rt.rtmsg_dst.s6_addr16[6]),
+ ntohs(rt.rtmsg_dst.s6_addr16[7]),
+ rt.rtmsg_dst_len);
+ if (ioctl(admin_fd, SIOCDELRT, &rt) < 0) {
+ cprintf(c, CS_PROTO_VPN_REPLY, "Cannot del route IPv6
address for gnu%s because %s\n", id, strerror(errno));
+ }
+ }
+ }
+ cprintf(c, CS_PROTO_VPN_REPLY, "Copying table\n");
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("realise copy
table\n"));
+ realised_entries = route_entries;
+ memcpy(realised_store,route_store, sizeof(route_info) * route_entries);
- MUTEX_UNLOCK(lock);
+ MUTEX_UNLOCK(lock);
}
static void add_client(struct ClientHandle * c) {
struct ClientHandle ** rstore;
- int i, rcapacity;
+ int i, rcapacity;
- /* we already have them, equality is assumed if the filehandles match */
- for (i = 0; i < clients_entries; i++) {
- if (*(clients_store+i) == c) return;
- }
+ /* we already have them, equality is assumed if the filehandles match */
+ for (i = 0; i < clients_entries; i++) {
+ if (*(clients_store+i) == c) return;
+ }
- clients_entries++;
- /* do we need more ram to hold the client handle? */
- rcapacity = clients_entries * sizeof(struct ClientHandle *);
- if (rcapacity > clients_capacity) {
- rstore = REALLOC(clients_store, rcapacity);
- if (rstore == NULL) {
- clients_entries--;
- /* not enough ram, warn in the logs that they
- * will forego receiving logging
- */
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot
store client info\n"));
- return;
- }
- clients_capacity = rcapacity;
- clients_store = rstore;
- }
- *(clients_store+(clients_entries-1)) = c;
+ clients_entries++;
+ /* do we need more ram to hold the client handle? */
+ rcapacity = clients_entries * sizeof(struct ClientHandle *);
+ if (rcapacity > clients_capacity) {
+ rstore = REALLOC(clients_store, rcapacity);
+ if (rstore == NULL) {
+ clients_entries--;
+ /* not enough ram, warn in the logs that they
+ * will forego receiving logging
+ */
+ GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot store
client info\n"));
+ return;
+ }
+ clients_capacity = rcapacity;
+ clients_store = rstore;
+ }
+ *(clients_store+(clients_entries-1)) = c;
}
static void remove_client(struct ClientHandle * c) {
- int i;
- for (i = 0; i < clients_entries; i++) {
- if (*(clients_store+i) == c) {
- *(clients_store+i) =
*(clients_store+(clients_entries-1));
- clients_entries--;
- return;
- }
- }
+ int i;
+ for (i = 0; i < clients_entries; i++) {
+ if (*(clients_store+i) == c) {
+ *(clients_store+i) = *(clients_store+(clients_entries-1));
+ clients_entries--;
+ return;
+ }
+ }
}
/** The console client is used to admin/debug vpn */
static int csHandle(struct ClientHandle * c,
- const MESSAGE_HEADER * message) {
- MESSAGE_HEADER * rgp = NULL;
- int i;
- PeerIdentity id;
- int parameter = ntohs(message->size) - sizeof(MESSAGE_HEADER);
- char* ccmd = (char*)(message+1);
- char* parm;
+ const MESSAGE_HEADER * message) {
+ MESSAGE_HEADER * rgp = NULL;
+ int i;
+ PeerIdentity id;
+ int parameter = ntohs(message->size) - sizeof(MESSAGE_HEADER);
+ char* ccmd = (char*)(message+1);
+ char* parm;
- MUTEX_LOCK(lock);
- add_client(c);
- MUTEX_UNLOCK(lock);
- /* issued command from client */
- if (ntohs(message->type) == CS_PROTO_VPN_MSG) {
- if (ntohs(message->size) == 0) return OK;
- }
- /* while ((l < ll) && (*(ccmd+cl) > 32)) cl++; */
+ MUTEX_LOCK(lock);
+ add_client(c);
+ MUTEX_UNLOCK(lock);
+ /* issued command from client */
+ if (ntohs(message->type) == CS_PROTO_VPN_MSG) {
+ if (ntohs(message->size) == 0) return OK;
+ }
+ /* while ((l < ll) && (*(ccmd+cl) > 32)) cl++; */
- if (ntohs(message->type) == CS_PROTO_VPN_DEBUGOFF) {
- MUTEX_LOCK(lock);
- cdebug = 0;
- MUTEX_UNLOCK(lock);
- cprintf(c, CS_PROTO_VPN_DEBUGOFF, "LOG NOTHING\n");
- return OK;
- }
- if (ntohs(message->type) == CS_PROTO_VPN_DEBUGON) {
- MUTEX_LOCK(lock);
- cdebug = GE_DEBUG | GE_DEVELOPER | GE_REQUEST;
- MUTEX_UNLOCK(lock);
- cprintf(c, CS_PROTO_VPN_DEBUGON, "LOG DEBUG\n");
- return OK;
- }
- if (ntohs(message->type) == CS_PROTO_VPN_TUNNELS) {
- MUTEX_LOCK(lock);
- id2ip(c, coreAPI->myIdentity);
- cprintf(c, CS_PROTO_VPN_REPLY, "::/48 This Node\n");
- for (i = 0; i < entries1; i++) {
- id2ip(c, &(store1+i)->peer);
- cprintf(c, CS_PROTO_VPN_REPLY, "::/48 gnu%d active=%s
routeentry=%d\n",
- (store1+i)->id,
- (store1+i)->active ? _("Yes") : _("No"),
- (store1+i)->route_entry);
- }
- cprintf(c, CS_PROTO_VPN_TUNNELS, "%d Tunnels\n", entries1);
- MUTEX_UNLOCK(lock);
- }
- if (ntohs(message->type) == CS_PROTO_VPN_ROUTES) {
- MUTEX_LOCK(lock);
- for (i = 0; i < route_entries; i++) {
- identity->getPeerIdentity(&(route_store+i)->owner, &id);
- id2ip(c, &id);
- if ((route_store+i)->hops == 0) {
- cprintf(c, CS_PROTO_VPN_REPLY, "::/48 hops 0
(This Node)\n");
- } else {
- cprintf(c, CS_PROTO_VPN_REPLY, "::/48 hops %d
tunnel gnu%d\n", (route_store+i)->hops,
- (store1+((route_store+i)->tunnel))->id);
- }
- }
- cprintf(c, CS_PROTO_VPN_ROUTES, "%d Routes\n", route_entries);
- MUTEX_UNLOCK(lock);
- }
- if (ntohs(message->type) == CS_PROTO_VPN_REALISED) {
- MUTEX_LOCK(lock);
- for (i = 0; i < realised_entries; i++) {
- identity->getPeerIdentity(&(realised_store+i)->owner,
&id);
- id2ip(c, &id);
- if ((realised_store+i)->hops == 0) {
- cprintf(c, CS_PROTO_VPN_REPLY, "::/48 hops 0
(This Node)\n");
- } else {
- cprintf(c, CS_PROTO_VPN_REPLY, "::/48 hops %d
tunnel gnu%d\n", (realised_store+i)->hops,
-
(store1+((realised_store+i)->tunnel))->id);
- }
- }
- cprintf(c, CS_PROTO_VPN_REALISED, "%d Realised\n",
realised_entries);
- MUTEX_UNLOCK(lock);
- }
- /* add routes in route but not realised to OS
- * delete routes in realised but not route from OS
- * memcpy routes to realised metric
- */
- if (ntohs(message->type) == CS_PROTO_VPN_REALISE) {
- realise(c);
- cprintf(c, CS_PROTO_VPN_REALISE, "Realise done\n");
- }
- if (ntohs(message->type) == CS_PROTO_VPN_RESET) {
- MUTEX_LOCK(lock);
- init_router();
- for (i = 0; i < entries1; i++) {
- (store1+i)->route_entry = 0;
- /* lets send it to everyone - expect response only from
VPN enabled nodes tho :-) */
-/* if ((store1+i)->active == YES) { */
- rgp = MALLOC(sizeof(MESSAGE_HEADER) +
sizeof(int));
- if (rgp == NULL) { break; }
- rgp->type = htons(P2P_PROTO_aip_GETROUTE);
- rgp->size = htons(sizeof(MESSAGE_HEADER) +
sizeof(int));
- *((int*)(rgp+1)) =
htonl((store1+i)->route_entry);
- cprintf(c, CS_PROTO_VPN_REPLY, "Request level
%d from peer %d ", (store1+i)->route_entry, i);
- id2ip(c, &((store1+i)->peer));
- cprintf(c, CS_PROTO_VPN_REPLY, "\n");
-
coreAPI->unicast(&((store1+i)->peer),rgp,EXTREME_PRIORITY,60);
- FREE(rgp);
-/* } */
- }
- MUTEX_UNLOCK(lock);
- cprintf(c, CS_PROTO_VPN_RESET, "Rebuilding routing tables
done\n");
- }
- if (ntohs(message->type) == CS_PROTO_VPN_TRUST) {
- MUTEX_LOCK(lock);
- for (i = 0; i < entries1; i++) {
- if ((store1+i)->active == YES) {
- cprintf(c, CS_PROTO_VPN_REPLY, "Uprating peer
");
- id2ip(c, &(store1+i)->peer);
- cprintf(c, CS_PROTO_VPN_REPLY, " with credit
%d\n", identity->changeHostTrust(&(store1+i)->peer, 1000));
- }
- }
- cprintf(c, CS_PROTO_VPN_TRUST, "Gave credit to active nodes of
%d nodes...\n", entries1);
- MUTEX_UNLOCK(lock);
- }
- if (ntohs(message->type) == CS_PROTO_VPN_ADD) {
- if (parameter > 0) {
- if ((parm = MALLOC(parameter+1)) != NULL) {
- strncpy(parm, ccmd, parameter);
- *(parm+parameter) = 0;
- cprintf(c, CS_PROTO_VPN_REPLY, "Connect ");
- if (OK == enc2hash(parm, &(id.hashPubKey))) {
- id2ip(c, &id);
+ if (ntohs(message->type) == CS_PROTO_VPN_DEBUGOFF) {
+ MUTEX_LOCK(lock);
+ cdebug = 0;
+ MUTEX_UNLOCK(lock);
+ cprintf(c, CS_PROTO_VPN_DEBUGOFF, "LOG NOTHING\n");
+ return OK;
+ }
+ if (ntohs(message->type) == CS_PROTO_VPN_DEBUGON) {
+ MUTEX_LOCK(lock);
+ cdebug = GE_DEBUG | GE_DEVELOPER | GE_REQUEST;
+ MUTEX_UNLOCK(lock);
+ cprintf(c, CS_PROTO_VPN_DEBUGON, "LOG DEBUG\n");
+ return OK;
+ }
+ if (ntohs(message->type) == CS_PROTO_VPN_TUNNELS) {
+ MUTEX_LOCK(lock);
+ id2ip(c, coreAPI->myIdentity);
+ cprintf(c, CS_PROTO_VPN_REPLY, "::/48 This Node\n");
+ for (i = 0; i < entries1; i++) {
+ id2ip(c, &(store1+i)->peer);
+ cprintf(c, CS_PROTO_VPN_REPLY, "::/48 gnu%d active=%s
routeentry=%d\n",
+ (store1+i)->id,
+ (store1+i)->active ? _("Yes") : _("No"),
+ (store1+i)->route_entry);
+ }
+ cprintf(c, CS_PROTO_VPN_TUNNELS, "%d Tunnels\n", entries1);
+ MUTEX_UNLOCK(lock);
+ }
+ if (ntohs(message->type) == CS_PROTO_VPN_ROUTES) {
+ MUTEX_LOCK(lock);
+ for (i = 0; i < route_entries; i++) {
+ identity->getPeerIdentity(&(route_store+i)->owner, &id);
+ id2ip(c, &id);
+ if ((route_store+i)->hops == 0) {
+ cprintf(c, CS_PROTO_VPN_REPLY, "::/48 hops 0 (This
Node)\n");
+ } else {
+ cprintf(c, CS_PROTO_VPN_REPLY, "::/48 hops %d tunnel
gnu%d\n", (route_store+i)->hops,
+ (store1+((route_store+i)->tunnel))->id);
+ }
+ }
+ cprintf(c, CS_PROTO_VPN_ROUTES, "%d Routes\n", route_entries);
+ MUTEX_UNLOCK(lock);
+ }
+ if (ntohs(message->type) == CS_PROTO_VPN_REALISED) {
+ MUTEX_LOCK(lock);
+ for (i = 0; i < realised_entries; i++) {
+ identity->getPeerIdentity(&(realised_store+i)->owner, &id);
+ id2ip(c, &id);
+ if ((realised_store+i)->hops == 0) {
+ cprintf(c, CS_PROTO_VPN_REPLY, "::/48 hops 0 (This
Node)\n");
+ } else {
+ cprintf(c, CS_PROTO_VPN_REPLY, "::/48 hops %d tunnel
gnu%d\n", (realised_store+i)->hops,
+ (store1+((realised_store+i)->tunnel))->id);
+ }
+ }
+ cprintf(c, CS_PROTO_VPN_REALISED, "%d Realised\n", realised_entries);
+ MUTEX_UNLOCK(lock);
+ }
+ /* add routes in route but not realised to OS
+ * delete routes in realised but not route from OS
+ * memcpy routes to realised metric
+ */
+ if (ntohs(message->type) == CS_PROTO_VPN_REALISE) {
+ realise(c);
+ cprintf(c, CS_PROTO_VPN_REALISE, "Realise done\n");
+ }
+ if (ntohs(message->type) == CS_PROTO_VPN_RESET) {
+ MUTEX_LOCK(lock);
+ init_router();
+ for (i = 0; i < entries1; i++) {
+ (store1+i)->route_entry = 0;
+ /* lets send it to everyone - expect response only from VPN
enabled nodes tho :-) */
+/* if ((store1+i)->active == YES) { */
+ rgp = MALLOC(sizeof(MESSAGE_HEADER) + sizeof(int));
+ if (rgp == NULL) { break; }
+ rgp->type = htons(P2P_PROTO_aip_GETROUTE);
+ rgp->size = htons(sizeof(MESSAGE_HEADER) + sizeof(int));
+ *((int*)(rgp+1)) = htonl((store1+i)->route_entry);
+ cprintf(c, CS_PROTO_VPN_REPLY, "Request level %d from
peer %d ", (store1+i)->route_entry, i);
+ id2ip(c, &((store1+i)->peer));
+ cprintf(c, CS_PROTO_VPN_REPLY, "\n");
+
coreAPI->unicast(&((store1+i)->peer),rgp,EXTREME_PRIORITY,60);
+ FREE(rgp);
+/* } */
+ }
+ MUTEX_UNLOCK(lock);
+ cprintf(c, CS_PROTO_VPN_RESET, "Rebuilding routing tables done\n");
+ }
+ if (ntohs(message->type) == CS_PROTO_VPN_TRUST) {
+ MUTEX_LOCK(lock);
+ for (i = 0; i < entries1; i++) {
+ if ((store1+i)->active == YES) {
+ cprintf(c, CS_PROTO_VPN_REPLY, "Uprating peer ");
+ id2ip(c, &(store1+i)->peer);
+ cprintf(c, CS_PROTO_VPN_REPLY, " with credit %d\n",
identity->changeHostTrust(&(store1+i)->peer, 1000));
+ }
+ }
+ cprintf(c, CS_PROTO_VPN_TRUST, "Gave credit to active nodes of %d
nodes...\n", entries1);
+ MUTEX_UNLOCK(lock);
+ }
+ if (ntohs(message->type) == CS_PROTO_VPN_ADD) {
+ if (parameter > 0) {
+ if ((parm = MALLOC(parameter+1)) != NULL) {
+ strncpy(parm, ccmd, parameter);
+ *(parm+parameter) = 0;
+ cprintf(c, CS_PROTO_VPN_REPLY, "Connect ");
+ if (OK == enc2hash(parm, &(id.hashPubKey))) {
+ id2ip(c, &id);
- /* this does not seem to work,
strangeness with threads and capabilities?
- * MUTEX_LOCK(lock);
- * checkensure_peer(&id, NULL);
- * MUTEX_UNLOCK(lock);
- */
+ /* this does not seem to work, strangeness with
threads and capabilities?
+ * MUTEX_LOCK(lock);
+ * checkensure_peer(&id, NULL);
+ * MUTEX_UNLOCK(lock);
+ */
- /* get it off the local blacklist */
- identity->whitelistHost(&id);
-
- switch (session->tryConnect(&id)) {
- case YES:
- cprintf(c, CS_PROTO_VPN_REPLY,
" already connected.\n");
- break;
- case NO:
- cprintf(c, CS_PROTO_VPN_REPLY,
" schedule connection.\n");
- break;
- case SYSERR:
- cprintf(c, CS_PROTO_VPN_REPLY,
" core refused.\n");
- break;
- default:
- cprintf(c, CS_PROTO_VPN_REPLY,
" misc error.\n");
- break;
- }
+ /* get it off the local blacklist */
+ identity->whitelistHost(&id);
+
+ switch (session->tryConnect(&id)) {
+ case YES:
+ cprintf(c, CS_PROTO_VPN_REPLY, "
already connected.\n");
+ break;
+ case NO:
+ cprintf(c, CS_PROTO_VPN_REPLY, "
schedule connection.\n");
+ break;
+ case SYSERR:
+ cprintf(c, CS_PROTO_VPN_REPLY, " core
refused.\n");
+ break;
+ default:
+ cprintf(c, CS_PROTO_VPN_REPLY, " misc
error.\n");
+ break;
+ }
- /* req route level 0
- rgp = MALLOC(sizeof(MESSAGE_HEADER) +
sizeof(int));
- if (rgp != NULL) {
- rgp->type =
htons(P2P_PROTO_aip_GETROUTE);
- rgp->size =
htons(sizeof(MESSAGE_HEADER) + sizeof(int));
- *((int*)(rgp+1)) = 0;
-
coreAPI->unicast(&id,rgp,EXTREME_PRIORITY,4);
- cprintf(c, " Sent");
- FREE(rgp);
- } */
+ /* req route level 0
+ rgp = MALLOC(sizeof(MESSAGE_HEADER) +
sizeof(int));
+ if (rgp != NULL) {
+ rgp->type =
htons(P2P_PROTO_aip_GETROUTE);
+ rgp->size =
htons(sizeof(MESSAGE_HEADER) + sizeof(int));
+ *((int*)(rgp+1)) = 0;
+
coreAPI->unicast(&id,rgp,EXTREME_PRIORITY,4);
+ cprintf(c, " Sent");
+ FREE(rgp);
+ } */
- cprintf(c, CS_PROTO_VPN_ADD, "\n");
- } else {
- cprintf(c, CS_PROTO_VPN_ADD, "Could not
decode PeerId %s from parameter.\n", parm);
-
- }
- FREE(parm);
- } else {
- cprintf(c, CS_PROTO_VPN_ADD, "Could not
allocate for key.\n");
- }
- } else {
- cprintf(c, CS_PROTO_VPN_ADD, "Require key for
parameter\n");
- }
- }
- return OK;
+ cprintf(c, CS_PROTO_VPN_ADD, "\n");
+ } else {
+ cprintf(c, CS_PROTO_VPN_ADD, "Could not decode
PeerId %s from parameter.\n", parm);
+
+ }
+ FREE(parm);
+ } else {
+ cprintf(c, CS_PROTO_VPN_ADD, "Could not allocate for
key.\n");
+ }
+ } else {
+ cprintf(c, CS_PROTO_VPN_ADD, "Require key for parameter\n");
+ }
+ }
+ return OK;
}
static void clientExitHandler(struct ClientHandle * c) {
- MUTEX_LOCK(lock);
- remove_client(c);
- MUTEX_UNLOCK(lock);
+ MUTEX_LOCK(lock);
+ remove_client(c);
+ MUTEX_UNLOCK(lock);
}
@@ -1338,8 +1338,8 @@
mode = 1;
if (ioctlsocket(handle,
- FIONBIO,
- &mode == SOCKET_ERROR) {
+ FIONBIO,
+ &mode == SOCKET_ERROR) {
SetErrnoFromWinsockError(WSAGetLastError());
return SYSERR;
} else {
@@ -1350,11 +1350,11 @@
int flags = fcntl(handle, F_GETFL);
flags |= O_NONBLOCK;
if (-1 == fcntl(handle,
- F_SETFL,
- flags)) {
+ F_SETFL,
+ flags)) {
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "fcntl");
+ GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "fcntl");
return SYSERR;
}
#endif
@@ -1369,157 +1369,157 @@
*
*/
int initialize_module_vpn(CoreAPIForApplication * capi) {
- int pfd;
- char* str = "OK\r\n";
+ int pfd;
+ char* str = "OK\r\n";
- ectx = capi->ectx;
- lock = MUTEX_CREATE(NO);
+ ectx = capi->ectx;
+ lock = MUTEX_CREATE(NO);
- coreAPI = capi;
+ coreAPI = capi;
- /* Signal to the root init script we want cap_net_admin
- */
- pfd = open("/var/lib/GNUnet/gnunet.vpn", O_WRONLY);
- if (pfd > -1) {
- write(pfd, str, strlen(str));
- close(pfd);
- }
- pfd = open("/var/lib/GNUnet/gnunet.vpn", O_RDONLY);
- if (pfd > -1) {
- read(pfd, str, strlen(str));
- close(pfd);
- }
- unlink("/var/lib/GNUnet/gnunet.vpn");
+ /* Signal to the root init script we want cap_net_admin
+ */
+ pfd = open("/var/lib/GNUnet/gnunet.vpn", O_WRONLY);
+ if (pfd > -1) {
+ write(pfd, str, strlen(str));
+ close(pfd);
+ }
+ pfd = open("/var/lib/GNUnet/gnunet.vpn", O_RDONLY);
+ if (pfd > -1) {
+ read(pfd, str, strlen(str));
+ close(pfd);
+ }
+ unlink("/var/lib/GNUnet/gnunet.vpn");
- /* system("sudo setpcaps cap_net_admin+eip `pidof gnunetd`"); */
+ /* system("sudo setpcaps cap_net_admin+eip `pidof gnunetd`"); */
- admin_fd = socket(AF_INET6, SOCK_DGRAM, 0);
-
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("`%s' initialising
RFC4913 module %d and %d\n"), "template", CS_PROTO_MAX_USED,
P2P_PROTO_MAX_USED);
- GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 my First
4 hex digits of host id are %x\n"), capi->myIdentity->hashPubKey.bits[0]);
+ admin_fd = socket(AF_INET6, SOCK_DGRAM, 0);
+
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("`%s' initialising
RFC4913 module %d and %d\n"), "template", CS_PROTO_MAX_USED,
P2P_PROTO_MAX_USED);
+ GE_LOG(ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST, _("RFC4193 my First 4 hex
digits of host id are %x\n"), capi->myIdentity->hashPubKey.bits[0]);
- /* core calls us to receive messages */
- /* get a PONG = peer is online */
- /* get a HANGUP = peer is offline */
- if (SYSERR == capi->registerHandler(P2P_PROTO_aip_IP, &handlep2pMSG))
return SYSERR;
- if (SYSERR == capi->registerHandler(P2P_PROTO_aip_GETROUTE,
&handlep2pMSG)) return SYSERR;
- if (SYSERR == capi->registerHandler(P2P_PROTO_aip_ROUTE,
&handlep2pMSG)) return SYSERR;
- if (SYSERR == capi->registerHandler(P2P_PROTO_aip_ROUTES,
&handlep2pMSG)) return SYSERR;
- if (SYSERR == capi->registerHandler(p2p_PROTO_PONG, &handlep2pMSG))
return SYSERR;
- if (SYSERR == capi->registerHandler(P2P_PROTO_hangup, &handlep2pMSG))
return SYSERR;
- if (SYSERR == capi->registerClientExitHandler(&clientExitHandler))
return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_MSG, &csHandle))
return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_DEBUGOFF,
&csHandle)) return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_DEBUGON,
&csHandle)) return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_TUNNELS,
&csHandle)) return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_ROUTES,
&csHandle)) return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_REALISED,
&csHandle)) return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_RESET,
&csHandle)) return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_REALISE,
&csHandle)) return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_ADD, &csHandle))
return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_TRUST,
&csHandle)) return SYSERR;
- if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_REPLY,
&csHandle)) return SYSERR;
+ /* core calls us to receive messages */
+ /* get a PONG = peer is online */
+ /* get a HANGUP = peer is offline */
+ if (SYSERR == capi->registerHandler(P2P_PROTO_aip_IP, &handlep2pMSG)) return
SYSERR;
+ if (SYSERR == capi->registerHandler(P2P_PROTO_aip_GETROUTE, &handlep2pMSG))
return SYSERR;
+ if (SYSERR == capi->registerHandler(P2P_PROTO_aip_ROUTE, &handlep2pMSG))
return SYSERR;
+ if (SYSERR == capi->registerHandler(P2P_PROTO_aip_ROUTES, &handlep2pMSG))
return SYSERR;
+ if (SYSERR == capi->registerHandler(p2p_PROTO_PONG, &handlep2pMSG)) return
SYSERR;
+ if (SYSERR == capi->registerHandler(P2P_PROTO_hangup, &handlep2pMSG)) return
SYSERR;
+ if (SYSERR == capi->registerClientExitHandler(&clientExitHandler)) return
SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_MSG, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_DEBUGOFF, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_DEBUGON, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_TUNNELS, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_ROUTES, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_REALISED, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_RESET, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_REALISE, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_ADD, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_TRUST, &csHandle))
return SYSERR;
+ if (SYSERR == capi->registerClientHandler(CS_PROTO_VPN_REPLY, &csHandle))
return SYSERR;
- identity = coreAPI->requestService("identity");
- session = coreAPI->requestService("session");
+ identity = coreAPI->requestService("identity");
+ session = coreAPI->requestService("session");
- GE_ASSERT(ectx, identity != NULL);
- GE_ASSERT(ectx, session != NULL);
+ GE_ASSERT(ectx, identity != NULL);
+ GE_ASSERT(ectx, session != NULL);
- init_router(); /* reqire identity */
- init_realised(); /* reqire identity */
+ init_router(); /* reqire identity */
+ init_realised(); /* reqire identity */
- PIPE(signalingPipe);
- /* important: make signalingPipe non-blocking
- to avoid stalling on signaling! */
- makeNonblocking(signalingPipe[1]);
+ PIPE(signalingPipe);
+ /* important: make signalingPipe non-blocking
+ to avoid stalling on signaling! */
+ makeNonblocking(signalingPipe[1]);
- /* Yes we have to make our own thread, cause the GUNnet API is
- * missing some callbacks (Namely CanReadThisFd - SELECT()) that I
would like ;-(
- * They may go in the thread that usually monitors the GUI port.
- */
- tunThreadInfo = PTHREAD_CREATE((PThreadMain) &tunThread, NULL, 128 *
1024);
+ /* Yes we have to make our own thread, cause the GUNnet API is
+ * missing some callbacks (Namely CanReadThisFd - SELECT()) that I would
like ;-(
+ * They may go in the thread that usually monitors the GUI port.
+ */
+ tunThreadInfo = PTHREAD_CREATE((PThreadMain) &tunThread, NULL, 128 * 1024);
- /* use capi->unicast to send messages to connected peers */
- GE_ASSERT(capi->ectx,
- 0 == GC_set_configuration_value_string(capi->cfg,
- capi->ectx,
- "ABOUT",
- "vpn",
- _("enables IPv6 over GNUnet
(incomplete)")));
+ /* use capi->unicast to send messages to connected peers */
+ GE_ASSERT(capi->ectx,
+ 0 == GC_set_configuration_value_string(capi->cfg,
+ capi->ectx,
+ "ABOUT",
+ "vpn",
+ _("enables IPv6 over GNUnet
(incomplete)")));
- return OK;
+ return OK;
}
/**
* Module uninserted.
*/
void done_module_vpn() {
- int i;
- int ret;
- void *returnval;
+ int i;
+ int ret;
+ void *returnval;
- coreAPI->unregisterHandler(P2P_PROTO_aip_IP, &handlep2pMSG);
- coreAPI->unregisterHandler(P2P_PROTO_aip_GETROUTE, &handlep2pMSG);
- coreAPI->unregisterHandler(P2P_PROTO_aip_ROUTE, &handlep2pMSG);
- coreAPI->unregisterHandler(P2P_PROTO_aip_ROUTES, &handlep2pMSG);
- coreAPI->unregisterHandler(p2p_PROTO_PONG, &handlep2pMSG);
- coreAPI->unregisterHandler(P2P_PROTO_hangup, &handlep2pMSG);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_MSG, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_DEBUGOFF, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_DEBUGON, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_TUNNELS, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_ROUTES, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_REALISED, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_RESET, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_REALISE, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_ADD, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_TRUST, &csHandle);
- coreAPI->unregisterClientHandler(CS_PROTO_VPN_REPLY, &csHandle);
- coreAPI->unregisterClientExitHandler(&clientExitHandler);
+ coreAPI->unregisterHandler(P2P_PROTO_aip_IP, &handlep2pMSG);
+ coreAPI->unregisterHandler(P2P_PROTO_aip_GETROUTE, &handlep2pMSG);
+ coreAPI->unregisterHandler(P2P_PROTO_aip_ROUTE, &handlep2pMSG);
+ coreAPI->unregisterHandler(P2P_PROTO_aip_ROUTES, &handlep2pMSG);
+ coreAPI->unregisterHandler(p2p_PROTO_PONG, &handlep2pMSG);
+ coreAPI->unregisterHandler(P2P_PROTO_hangup, &handlep2pMSG);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_MSG, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_DEBUGOFF, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_DEBUGON, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_TUNNELS, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_ROUTES, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_REALISED, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_RESET, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_REALISE, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_ADD, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_TRUST, &csHandle);
+ coreAPI->unregisterClientHandler(CS_PROTO_VPN_REPLY, &csHandle);
+ coreAPI->unregisterClientExitHandler(&clientExitHandler);
- GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER, _("RFC4193 Waiting for tun
thread to end\n"));
+ GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER, _("RFC4193 Waiting for tun
thread to end\n"));
- running = 0;
- /* thread should wake up and exit */
- ret = write(signalingPipe[1], &running, sizeof(char));
- if (ret != sizeof(char))
- if (errno != EAGAIN)
- GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- "RFC4193 can not tell thread to exit");
+ running = 0;
+ /* thread should wake up and exit */
+ ret = write(signalingPipe[1], &running, sizeof(char));
+ if (ret != sizeof(char))
+ if (errno != EAGAIN)
+ GE_LOG_STRERROR(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ "RFC4193 can not tell thread to exit");
- /* wait for it to exit */
- PTHREAD_JOIN(tunThreadInfo, &returnval);
- GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER, _("RFC4193 The tun thread
has ended\n"));
+ /* wait for it to exit */
+ PTHREAD_JOIN(tunThreadInfo, &returnval);
+ GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER, _("RFC4193 The tun thread has
ended\n"));
- coreAPI->releaseService(identity);
- coreAPI->releaseService(session);
+ coreAPI->releaseService(identity);
+ coreAPI->releaseService(session);
- identity = NULL;
+ identity = NULL;
- CLOSE(signalingPipe[0]);
- CLOSE(signalingPipe[1]);
+ CLOSE(signalingPipe[0]);
+ CLOSE(signalingPipe[1]);
- /* bye bye TUNTAP ... */
- for (i = 0; i < entries1; i++) {
- if (((store1+i)->fd) != 0) {
- GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- _("RFC4193 Closing tunnel %d fd %d\n"), i,
(store1+i)->fd);
- close((store1+i)->fd);
- (store1+i)->fd = 0;
- }
- }
- if (store1 != NULL) {
- entries1 = 0;
- capacity1 = 0;
- FREE(store1);
- }
- close(admin_fd);
+ /* bye bye TUNTAP ... */
+ for (i = 0; i < entries1; i++) {
+ if (((store1+i)->fd) != 0) {
+ GE_LOG(ectx,
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ _("RFC4193 Closing tunnel %d fd %d\n"), i,
(store1+i)->fd);
+ close((store1+i)->fd);
+ (store1+i)->fd = 0;
+ }
+ }
+ if (store1 != NULL) {
+ entries1 = 0;
+ capacity1 = 0;
+ FREE(store1);
+ }
+ close(admin_fd);
- MUTEX_DESTROY(lock);
- coreAPI = NULL;
+ MUTEX_DESTROY(lock);
+ coreAPI = NULL;
}
/* end of template.c */
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/server/connection.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -509,7 +509,7 @@
* @param data context for callee
*/
typedef void (*BufferEntryCallback) (BufferEntry * be,
- void *data);
+ void *data);
/* ***************** globals ********************** */
@@ -677,21 +677,21 @@
return; /* avoid loosing > 1% due to rounding */
if (stats != NULL)
stats->change(stat_total_allowed_inc,
- increment);
+ increment);
be->available_send_window
+= increment;
#if 0
printf("Have %u bpm over %llu ms, adding %lld bytes\n",
- be->max_bpm,
- delta,
- increment);
+ be->max_bpm,
+ delta,
+ increment);
#endif
limit = (long long) be->max_bpm * MAX_BUF_FACT;
if (be->available_send_window > limit) {
if (stats != NULL)
stats->change(stat_total_lost_sent,
- be->available_send_window
- - limit);
+ be->available_send_window
+ - limit);
be->available_send_window = limit;
}
be->last_bps_update = now;
@@ -730,7 +730,7 @@
*/
static unsigned int
approximateKnapsack(BufferEntry * be,
- unsigned int available) {
+ unsigned int available) {
unsigned int i;
unsigned int count;
SendEntry **entries;
@@ -768,7 +768,7 @@
* @return the overall priority that was achieved
*/
static unsigned int solveKnapsack(BufferEntry * be,
- unsigned int available) {
+ unsigned int available) {
unsigned int i;
int j;
int max;
@@ -877,7 +877,7 @@
* @return OK if the packet should be handled, SYSERR if the packet should be
dropped.
*/
static int outgoingCheck(unsigned int priority,
- unsigned int overhead) {
+ unsigned int overhead) {
int load;
unsigned int delta;
@@ -906,23 +906,23 @@
if (delta * delta * delta > priority) {
#if DEBUG_POLICY
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Network load is too high (%d%%, priority is %u, require %d), "
- "dropping outgoing.\n",
- load,
- priority,
- delta * delta * delta);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Network load is too high (%d%%, priority is %u, require %d), "
+ "dropping outgoing.\n",
+ load,
+ priority,
+ delta * delta * delta);
#endif
return SYSERR; /* drop */
} else {
#if DEBUG_POLICY
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Network load is ok (%d%%, priority is %u >= %d), "
- "sending outgoing.\n",
- load,
- priority,
- delta * delta * delta);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Network load is ok (%d%%, priority is %u >= %d), "
+ "sending outgoing.\n",
+ load,
+ priority,
+ delta * delta * delta);
#endif
return OK; /* allow */
}
@@ -968,8 +968,8 @@
if (be->lastSendAttempt + msf > get_time()) {
#if DEBUG_CONNECTION
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Send frequency too high (CPU load), send deferred.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Send frequency too high (CPU load), send deferred.\n");
#endif
return NO; /* frequency too high, wait */
}
@@ -985,7 +985,7 @@
*/
static unsigned int
selectMessagesToSend(BufferEntry * be,
- unsigned int *priority) {
+ unsigned int *priority) {
unsigned int totalMessageSize;
SendEntry *entry;
int i;
@@ -1008,10 +1008,10 @@
while (i < be->sendBufferSize) {
entry = be->sendBuffer[i];
if ( (totalMessageSize + entry->len < MAX_BUFFER_SIZE - 64) &&
- (entry->pri >= EXTREME_PRIORITY)) {
+ (entry->pri >= EXTREME_PRIORITY)) {
entry->knapsackSolution = YES;
- if (entry->transmissionTime < deadline)
- deadline = entry->transmissionTime;
+ if (entry->transmissionTime < deadline)
+ deadline = entry->transmissionTime;
(*priority) += entry->pri;
totalMessageSize += entry->len;
} else {
@@ -1021,19 +1021,19 @@
i++;
}
if ( (i == 0) &&
- (be->sendBuffer[i]->len > be->available_send_window)) {
+ (be->sendBuffer[i]->len > be->available_send_window)) {
return 0; /* always wait for the highest-priority
message (otherwise large messages may
starve! */
}
while ( (i < be->sendBufferSize) &&
- (be->available_send_window > totalMessageSize)) {
+ (be->available_send_window > totalMessageSize)) {
entry = be->sendBuffer[i];
if ( (entry->len + totalMessageSize <= be->available_send_window) &&
- (totalMessageSize + entry->len < MAX_BUFFER_SIZE - 64)) {
+ (totalMessageSize + entry->len < MAX_BUFFER_SIZE - 64)) {
entry->knapsackSolution = YES;
- if (entry->transmissionTime < deadline)
- deadline = entry->transmissionTime;
+ if (entry->transmissionTime < deadline)
+ deadline = entry->transmissionTime;
totalMessageSize += entry->len;
(*priority) += entry->pri;
} else {
@@ -1049,10 +1049,10 @@
i++;
}
if ( (totalMessageSize == sizeof(P2P_PACKET_HEADER)) ||
- ( ((*priority) < EXTREME_PRIORITY) &&
- ((totalMessageSize / sizeof(P2P_PACKET_HEADER)) < 4) &&
- (deadline > get_time() + 500 * cronMILLIS) &&
- (weak_randomi(16) != 0) ) ) {
+ ( ((*priority) < EXTREME_PRIORITY) &&
+ ((totalMessageSize / sizeof(P2P_PACKET_HEADER)) < 4) &&
+ (deadline > get_time() + 500 * cronMILLIS) &&
+ (weak_randomi(16) != 0) ) ) {
/* randomization necessary to ensure we eventually send
a small message if there is nothing else to do! */
return 0;
@@ -1074,9 +1074,9 @@
sizeof(P2P_PACKET_HEADER));
#if DEBUG_COLLECT_PRIO == YES
FPRINTF(prioFile,
- "%llu 0 %d\n",
- get_time(),
- priority);
+ "%llu 0 %d\n",
+ get_time(),
+ priority);
#endif
} else {
(*priority) = solveKnapsack(be,
@@ -1084,9 +1084,9 @@
sizeof(P2P_PACKET_HEADER));
#if DEBUG_COLLECT_PRIO == YES
FPRINTF(prioFile,
- "%llu 1 %d\n",
- get_time(),
- priority);
+ "%llu 1 %d\n",
+ get_time(),
+ priority);
#endif
}
} else { /* never approximate < 50% CPU load */
@@ -1095,37 +1095,37 @@
sizeof(P2P_PACKET_HEADER));
#if DEBUG_COLLECT_PRIO == YES
FPRINTF(prioFile,
- "%llu 2 %d\n",
- get_time(),
- priority);
+ "%llu 2 %d\n",
+ get_time(),
+ priority);
#endif
}
j = 0;
totalMessageSize = 0;
for (i = 0; i < be->sendBufferSize; i++) {
if (be->sendBuffer[i]->knapsackSolution == YES) {
- totalMessageSize += be->sendBuffer[i]->len;
+ totalMessageSize += be->sendBuffer[i]->len;
j++;
}
}
if ( (j == 0) ||
- (totalMessageSize > be->session.mtu - sizeof(P2P_PACKET_HEADER)) ) {
+ (totalMessageSize > be->session.mtu - sizeof(P2P_PACKET_HEADER)) ) {
GE_BREAK(ectx, 0);
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_DEVELOPER,
- _("`%s' selected %d out of %d messages (MTU: %d).\n"),
- __FUNCTION__,
- j,
- be->sendBufferSize,
- be->session.mtu - sizeof(P2P_PACKET_HEADER));
+ GE_ERROR | GE_BULK | GE_DEVELOPER,
+ _("`%s' selected %d out of %d messages (MTU: %d).\n"),
+ __FUNCTION__,
+ j,
+ be->sendBufferSize,
+ be->session.mtu - sizeof(P2P_PACKET_HEADER));
for (j = 0; j < be->sendBufferSize; j++)
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_DEVELOPER,
- _("Message details: %u: length %d, priority: %d\n"),
- j,
- be->sendBuffer[j]->len,
- be->sendBuffer[j]->pri);
+ GE_ERROR | GE_BULK | GE_DEVELOPER,
+ _("Message details: %u: length %d, priority: %d\n"),
+ j,
+ be->sendBuffer[j]->len,
+ be->sendBuffer[j]->pri);
return 0;
}
@@ -1136,9 +1136,9 @@
if ((*priority) < EXTREME_PRIORITY) {
#if DEBUG_CONNECTION
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "bandwidth limits prevent sending (send window %u too small).\n",
- be->available_send_window);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "bandwidth limits prevent sending (send window %u too small).\n",
+ be->available_send_window);
#endif
return 0; /* can not send, BPS available is too small */
}
@@ -1188,13 +1188,13 @@
continue;
if ( (entry->transmissionTime <= expired) ||
- (usedBytes > msgCap) ) {
+ (usedBytes > msgCap) ) {
#if DEBUG_CONNECTION
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "expiring message, expired %ds ago, queue size is %llu (bandwidth
stressed)\n",
- (int) ((get_time() - entry->transmissionTime) / cronSECONDS),
- usedBytes);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "expiring message, expired %ds ago, queue size is %llu (bandwidth
stressed)\n",
+ (int) ((get_time() - entry->transmissionTime) / cronSECONDS),
+ usedBytes);
#endif
if (stats != NULL) {
stats->change(stat_messagesDropped, 1);
@@ -1244,8 +1244,8 @@
if (entry->callback != NULL) {
tmpMsg = MALLOC(entry->len);
if (OK == entry->callback(tmpMsg,
- entry->closure,
- entry->len)) {
+ entry->closure,
+ entry->len)) {
entry->callback = NULL;
entry->closure = tmpMsg;
ret++;
@@ -1266,15 +1266,15 @@
hdr = (MESSAGE_HEADER *) entry->closure;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&be->session.sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&be->session.sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Core selected message of type %u and size %u for sending to
peer `%s'.\n",
- ntohs(hdr->type),
- ntohs(hdr->size),
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Core selected message of type %u and size %u for sending to peer
`%s'.\n",
+ ntohs(hdr->type),
+ ntohs(hdr->size),
+ &enc);
}
#endif
}
@@ -1294,7 +1294,7 @@
*/
static SendEntry **
permuteSendBuffer(BufferEntry * be,
- unsigned int * selected_total) {
+ unsigned int * selected_total) {
unsigned int tailpos;
unsigned int headpos;
unsigned int rnd;
@@ -1370,7 +1370,7 @@
FREE(entry);
be->sendBuffer[i] = NULL;
} else if ( (entry->callback == NULL) &&
- (entry->closure == NULL) ) {
+ (entry->closure == NULL) ) {
FREE(entry);
be->sendBuffer[i] = NULL;
}
@@ -1402,22 +1402,22 @@
for (i=0;i<ret;i++) {
entry = entries[i];
if (entry->len <= be->session.mtu - sizeof(P2P_PACKET_HEADER))
- continue;
+ continue;
ret--;
for (j = i; j < ret; j++)
- entries[j] = entries[j + 1]; /* preserve ordering */
+ entries[j] = entries[j + 1]; /* preserve ordering */
GROW(be->sendBuffer,
- be->sendBufferSize,
- ret);
+ be->sendBufferSize,
+ ret);
/* calling fragment will change be->sendBuffer;
- thus we need to restart from the beginning afterwards... */
+ thus we need to restart from the beginning afterwards... */
fragmentation->fragment(&be->session.sender,
- be->session.mtu - sizeof(P2P_PACKET_HEADER),
- entry->pri,
- entry->transmissionTime,
- entry->len,
- entry->callback,
- entry->closure);
+ be->session.mtu - sizeof(P2P_PACKET_HEADER),
+ entry->pri,
+ entry->transmissionTime,
+ entry->len,
+ entry->callback,
+ entry->closure);
FREE(entry);
changed = YES;
break; /* "entries" changed as side-effect of fragment call */
@@ -1496,16 +1496,16 @@
return NO; /* deferr further */
}
GE_ASSERT(ectx,
- totalMessageSize > sizeof(P2P_PACKET_HEADER));
+ totalMessageSize > sizeof(P2P_PACKET_HEADER));
if ( (be->session.mtu != 0) &&
(totalMessageSize > be->session.mtu) ) {
GE_BREAK(ectx, 0);
be->inSendBuffer = NO;
return NO;
}
- ret = transport->testWouldTry(be->session.tsession,
- totalMessageSize,
- (priority >= EXTREME_PRIORITY) ? YES : NO);
+ ret = transport->testWouldTry(be->session.tsession,
+ totalMessageSize,
+ (priority >= EXTREME_PRIORITY) ? YES : NO);
/* ret: YES: ok to send, NO: not ready yet, SYSERR: session down
or serious internal error */
if (ret == SYSERR) {
@@ -1530,7 +1530,7 @@
if so, trigger callbacks on selected entries; if either
fails, return (but clean up garbage) */
if ( (SYSERR == outgoingCheck(priority,
- totalMessageSize / sizeof(P2P_PACKET_HEADER)))
||
+ totalMessageSize / sizeof(P2P_PACKET_HEADER))) ||
(0 == prepareSelectedMessages(be)) ) {
expireSendBufferEntries(be);
be->inSendBuffer = NO;
@@ -1558,13 +1558,13 @@
SendEntry * entry = entries[i];
GE_ASSERT(ectx,
- (entry != NULL) &&
- (entry->knapsackSolution == YES) &&
- (entry->callback == NULL) &&
- (p + entry->len <= totalMessageSize));
+ (entry != NULL) &&
+ (entry->knapsackSolution == YES) &&
+ (entry->callback == NULL) &&
+ (p + entry->len <= totalMessageSize));
memcpy(&plaintextMsg[p],
- entry->closure,
- entry->len);
+ entry->closure,
+ entry->len);
p += entry->len;
}
FREE(entries);
@@ -1578,27 +1578,27 @@
/* still room left? try callbacks! */
pos = scl_nextHead;
while ( (pos != NULL) &&
- (p < totalMessageSize) ) {
+ (p < totalMessageSize) ) {
if ( (pos->minimumPadding + p >= p) &&
- (pos->minimumPadding + p <= totalMessageSize) ) {
+ (pos->minimumPadding + p <= totalMessageSize) ) {
rsi = pos->callback(&be->session.sender,
- &plaintextMsg[p],
- totalMessageSize - p);
+ &plaintextMsg[p],
+ totalMessageSize - p);
GE_BREAK(ectx,
- rsi + p <= totalMessageSize);
+ rsi + p <= totalMessageSize);
if ( (rsi + p < p) ||
- (rsi + p > totalMessageSize) ) {
- GE_BREAK(ectx, 0);
- FREE(plaintextMsg);
- be->inSendBuffer = NO;
- return NO;
+ (rsi + p > totalMessageSize) ) {
+ GE_BREAK(ectx, 0);
+ FREE(plaintextMsg);
+ be->inSendBuffer = NO;
+ return NO;
}
p += rsi;
}
pos = pos->next;
}
if ( ( (be->session.mtu != 0) &&
- (p > be->session.mtu) )
+ (p > be->session.mtu) )
|| (p > totalMessageSize) ) {
GE_BREAK(ectx, 0);
FREE(plaintextMsg);
@@ -1617,7 +1617,7 @@
part.type = htons(P2P_PROTO_noise);
memcpy(&plaintextMsg[p],
&part,
- sizeof(MESSAGE_HEADER));
+ sizeof(MESSAGE_HEADER));
for (i = p + sizeof(MESSAGE_HEADER); i < totalMessageSize; i++)
plaintextMsg[i] = (char) rand();
p = totalMessageSize;
@@ -1625,7 +1625,7 @@
stats->change(stat_noise_sent, noiseLen);
}
if ( ( (be->session.mtu != 0) &&
- (p > be->session.mtu) )
+ (p > be->session.mtu) )
|| (p > totalMessageSize) ) {
GE_BREAK(ectx, 0);
FREE(plaintextMsg);
@@ -1638,24 +1638,24 @@
p - sizeof(HashCode512),
(HashCode512 *) encryptedMsg);
ret = encryptBlock(&p2pHdr->sequenceNumber,
- p - sizeof(HashCode512),
- &be->skey_local,
- (const INITVECTOR *) encryptedMsg, /* IV */
+ p - sizeof(HashCode512),
+ &be->skey_local,
+ (const INITVECTOR *) encryptedMsg, /* IV */
&((P2P_PACKET_HEADER *) encryptedMsg)->sequenceNumber);
if(stats != NULL)
stats->change(stat_encrypted,
- p - sizeof(HashCode512));
+ p - sizeof(HashCode512));
GE_ASSERT(ectx, be->session.tsession != NULL);
ret = transport->send(be->session.tsession,
- encryptedMsg,
- p,
- NO);
+ encryptedMsg,
+ p,
+ NO);
if ( (ret == NO) &&
(priority >= EXTREME_PRIORITY) ) {
ret = transport->send(be->session.tsession,
- encryptedMsg,
- p,
- YES);
+ encryptedMsg,
+ p,
+ YES);
}
if (ret == YES) {
if(stats != NULL)
@@ -1704,7 +1704,7 @@
* @param se what to transmit (with meta-data)
*/
static void appendToBuffer(BufferEntry * be,
- SendEntry * se) {
+ SendEntry * se) {
#if DEBUG_CONNECTION
EncName enc;
#endif
@@ -1728,8 +1728,8 @@
se->pri,
se->transmissionTime,
se->len,
- se->callback,
- se->closure);
+ se->callback,
+ se->closure);
FREE(se);
return;
}
@@ -1740,13 +1740,13 @@
connection, do NOT queue messages! */
#if DEBUG_CONNECTION
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&be->session.sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&be->session.sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "not connected to `%s', message dropped\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "not connected to `%s', message dropped\n",
+ &enc);
#endif
FREE(se->closure);
FREE(se);
@@ -1828,7 +1828,7 @@
*/
static BufferEntry *
addHost(const PeerIdentity * hostId,
- int establishSession) {
+ int establishSession) {
BufferEntry *root;
BufferEntry *prev;
unsigned int index;
@@ -1842,8 +1842,8 @@
while (NULL != root) {
/* settle for entry in the linked list that is down */
if ( (root->status == STAT_DOWN) ||
- (equalsHashCode512(&hostId->hashPubKey,
- &root->session.sender.hashPubKey)))
+ (equalsHashCode512(&hostId->hashPubKey,
+ &root->session.sender.hashPubKey)))
break;
prev = root;
root = root->overflowChain;
@@ -1875,7 +1875,7 @@
* @return the number of connected hosts
*/
static int forAllConnectedHosts(BufferEntryCallback method,
- void *arg) {
+ void *arg) {
unsigned int i;
int count = 0;
BufferEntry * be;
@@ -1902,7 +1902,7 @@
* to call
*/
static void fENHCallback(BufferEntry * be,
- void *arg) {
+ void *arg) {
fENHWrap *wrap;
wrap = (fENHWrap *) arg;
@@ -1927,13 +1927,13 @@
ENTRY();
#if DEBUG_CONNECTION
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&be->session.sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&be->session.sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Shutting down connection with `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Shutting down connection with `%s'\n",
+ &enc);
#endif
if(be->status == STAT_DOWN)
return; /* nothing to do */
@@ -1953,8 +1953,8 @@
se->closure = MALLOC(sizeof(P2P_hangup_MESSAGE));
se->knapsackSolution = NO;
memcpy(se->closure,
- &hangup,
- sizeof(P2P_hangup_MESSAGE));
+ &hangup,
+ sizeof(P2P_hangup_MESSAGE));
appendToBuffer(be, se);
if(stats != NULL)
stats->change(stat_hangupSent, 1);
@@ -1984,7 +1984,7 @@
/* ******** inbound bandwidth scheduling ************* */
static void gatherEntries(BufferEntry * be,
- void * cls) {
+ void * cls) {
UTL_Closure * utl = cls;
utl->e[utl->pos++] = be;
}
@@ -2086,7 +2086,7 @@
utl.pos = 0;
utl.e = entries;
forAllConnectedHosts(&gatherEntries,
- &utl);
+ &utl);
/* compute latest shares based on traffic preferences */
shares = MALLOC(sizeof(double) * activePeerCount);
@@ -2119,13 +2119,13 @@
minCon = max_bpm / MIN_BPM_PER_PEER;
}
load = os_network_monitor_get_load(load_monitor,
- Download);
+ Download);
if (load > 100) /* take counter measure */
schedulableBandwidth = schedulableBandwidth * 100 / load;
/* compute recent activity profile of the peer */
adjustedRR = MALLOC(sizeof(long long) * activePeerCount);
GE_ASSERT(ectx,
- timeDifference != 0);
+ timeDifference != 0);
for (u=0;u<activePeerCount;u++) {
adjustedRR[u]
= entries[u]->recently_received * cronMINUTES / timeDifference / 2;
@@ -2133,15 +2133,15 @@
#if DEBUG_CONNECTION
if (adjustedRR[u] > entries[u]->idealized_limit) {
IF_GELOG(ectx,
- GE_INFO | GE_BULK | GE_USER,
- hash2enc(&entries[u]->session.sender.hashPubKey,
- &enc));
+ GE_INFO | GE_BULK | GE_USER,
+ hash2enc(&entries[u]->session.sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_INFO | GE_BULK | GE_USER,
- "peer `%s' transmitted above limit: %llu bpm > %u bpm\n",
- &enc,
- adjustedRR[u],
- entries[u]->idealized_limit);
+ GE_INFO | GE_BULK | GE_USER,
+ "peer `%s' transmitted above limit: %llu bpm > %u bpm\n",
+ &enc,
+ adjustedRR[u],
+ entries[u]->idealized_limit);
}
#endif
/* Check for peers grossly exceeding send limits. Be a bit
@@ -2149,28 +2149,28 @@
* sent to this peer (assume announcements may have got lost).
*/
if ( (earlyRun == 0) &&
- (adjustedRR[u] > 2 * MAX_BUF_FACT *
- entries[u]->max_transmitted_limit) &&
- (adjustedRR[u] > 2 * MAX_BUF_FACT * entries[u]->idealized_limit)) {
+ (adjustedRR[u] > 2 * MAX_BUF_FACT *
+ entries[u]->max_transmitted_limit) &&
+ (adjustedRR[u] > 2 * MAX_BUF_FACT * entries[u]->idealized_limit)) {
entries[u]->violations++;
entries[u]->recently_received = 0; /* "clear" slate */
if (entries[u]->violations > 10) {
#if DEBUG_CONNECTION
IF_GELOG(ectx,
- GE_INFO | GE_BULK | GE_DEVELOPER,
- hash2enc(&entries[u]->session.sender.hashPubKey,
- &enc));
+ GE_INFO | GE_BULK | GE_DEVELOPER,
+ hash2enc(&entries[u]->session.sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_INFO | GE_BULK | GE_DEVELOPER,
- "blacklisting `%s': sent repeatedly %llu bpm "
- "(limit %u bpm, target %u bpm)\n",
- &enc,
- adjustedRR[u],
- entries[u]->max_transmitted_limit, entries[u]->idealized_limit);
+ GE_INFO | GE_BULK | GE_DEVELOPER,
+ "blacklisting `%s': sent repeatedly %llu bpm "
+ "(limit %u bpm, target %u bpm)\n",
+ &enc,
+ adjustedRR[u],
+ entries[u]->max_transmitted_limit, entries[u]->idealized_limit);
#endif
identity->blacklistHost(&entries[u]->session.sender,
24 * 60 * 60, /* 1 day */
- YES);
+ YES);
shutdownConnection(entries[u]);
activePeerCount--;
entries[u] = entries[activePeerCount];
@@ -2181,8 +2181,8 @@
}
} else {
if ( (earlyRun == 0) &&
- (adjustedRR[u] < entries[u]->max_transmitted_limit / 2) &&
- (entries[u]->violations > 0)) {
+ (adjustedRR[u] < entries[u]->max_transmitted_limit / 2) &&
+ (entries[u]->violations > 0)) {
/* allow very low traffic volume to
balance out (rare) times of high
volume */
@@ -2216,25 +2216,25 @@
for (u = 0; u < activePeerCount; u++)
entries[u]->idealized_limit = 0;
while ( (schedulableBandwidth > activePeerCount * 100) &&
- (activePeerCount > 0) &&
- (didAssign == YES) ) {
+ (activePeerCount > 0) &&
+ (didAssign == YES) ) {
didAssign = NO;
decrementSB = 0;
for (u = 0; u < activePeerCount; u++) {
if ( (firstRound == NO) ||
- (entries[u]->idealized_limit < adjustedRR[u] * 2) ) {
+ (entries[u]->idealized_limit < adjustedRR[u] * 2) ) {
unsigned int share;
- share =
+ share =
entries[u]->idealized_limit +
(unsigned int) (shares[u] * schedulableBandwidth);
if (share < entries[u]->idealized_limit)
share = 0xFFFFFFFF; /* int overflow */
if ( (share > adjustedRR[u] * 2) && (firstRound == YES) )
share = adjustedRR[u] * 2;
- /* always allow allocating MIN_BPM_PER_PEER */
+ /* always allow allocating MIN_BPM_PER_PEER */
if ( (share < MIN_BPM_PER_PEER) &&
- (minCon > 0) ) {
+ (minCon > 0) ) {
/* use one of the minCon's to keep the connection! */
share += MIN_BPM_PER_PEER;
decrementSB -= MIN_BPM_PER_PEER; /* do not count */
@@ -2243,8 +2243,8 @@
if (share > entries[u]->idealized_limit) {
decrementSB += share - entries[u]->idealized_limit;
didAssign = YES;
- entries[u]->idealized_limit = share;
- }
+ entries[u]->idealized_limit = share;
+ }
}
} /* end for all peers */
@@ -2255,13 +2255,13 @@
break;
}
if ( (activePeerCount > 0) &&
- (didAssign == NO) ) {
+ (didAssign == NO) ) {
perm = permute(WEAK, activePeerCount);
/* assign also to random "worthless" (zero-share) peers */
for (u = 0; u < activePeerCount; u++) {
unsigned int v = perm[u]; /* use perm to avoid preference to
low-numbered slots */
if ( (firstRound == NO) ||
- (entries[v]->idealized_limit < adjustedRR[v] * 2)) {
+ (entries[v]->idealized_limit < adjustedRR[v] * 2)) {
unsigned int share;
share =
@@ -2271,10 +2271,10 @@
share = 0xFFFFFFFF; /* int overflow */
if ( (firstRound == YES) && (share > adjustedRR[v] * 2) )
share = adjustedRR[v] * 2;
- if (share > entries[v]->idealized_limit) {
- schedulableBandwidth -= share - entries[v]->idealized_limit;
- entries[v]->idealized_limit = share;
- }
+ if (share > entries[v]->idealized_limit) {
+ schedulableBandwidth -= share - entries[v]->idealized_limit;
+ entries[v]->idealized_limit = share;
+ }
}
}
FREE(perm);
@@ -2297,12 +2297,12 @@
unsigned int v = perm[u]; /* use perm to avoid preference to
low-numbered slots */
share =
- entries[v]->idealized_limit +
- (unsigned int) (schedulableBandwidth / activePeerCount);
+ entries[v]->idealized_limit +
+ (unsigned int) (schedulableBandwidth / activePeerCount);
if (share >= entries[v]->idealized_limit) { /* no int-overflow? */
- entries[v]->idealized_limit = share;
+ entries[v]->idealized_limit = share;
} else {
- entries[v]->idealized_limit = 0xFFFF0000;
+ entries[v]->idealized_limit = 0xFFFF0000;
}
}
schedulableBandwidth = 0;
@@ -2323,22 +2323,22 @@
for (u=0;u<activePeerCount;u++) {
#if DEBUG_CONNECTION
IF_GELOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- hash2enc(&entries[u]->session.sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_BULK | GE_USER,
+ hash2enc(&entries[u]->session.sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- "inbound limit for peer %u: %s set to %u bpm\n",
- u,
- &enc,
- entries[u]->idealized_limit);
+ GE_DEBUG | GE_BULK | GE_USER,
+ "inbound limit for peer %u: %s set to %u bpm\n",
+ u,
+ &enc,
+ entries[u]->idealized_limit);
#endif
if ( (timeDifference > 50) &&
- (weak_randomi(timeDifference + 1) > 50) )
+ (weak_randomi(timeDifference + 1) > 50) )
entries[u]->current_connection_value *= 0.9; /* age */
decrementSB = entries[u]->idealized_limit * timeDifference / cronMINUTES /
2;
if ( (decrementSB == 0) &&
- (weak_randomi(timeDifference + 1) != 0) )
+ (weak_randomi(timeDifference + 1) != 0) )
decrementSB = 1;
if (entries[u]->recently_received >= decrementSB)
entries[u]->recently_received -= decrementSB;
@@ -2356,29 +2356,29 @@
if (be->idealized_limit < MIN_BPM_PER_PEER) {
#if DEBUG_CONNECTION
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- hash2enc(&be->session.sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ hash2enc(&be->session.sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Number of connections too high, shutting down low-traffic
connection to `%s' (had only %u bpm)\n",
- &enc,
- be->idealized_limit);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Number of connections too high, shutting down low-traffic connection
to `%s' (had only %u bpm)\n",
+ &enc,
+ be->idealized_limit);
#endif
/* We need to avoid giving a too low limit (especially 0, which
- would indicate a plaintext msg). So we set the limit to the
- minimum value AND try to shutdown the connection. */
+ would indicate a plaintext msg). So we set the limit to the
+ minimum value AND try to shutdown the connection. */
be->idealized_limit = MIN_BPM_PER_PEER;
/* do not try to reconnect any time soon! */
identity->blacklistHost(&be->session.sender,
- SECONDS_BLACKLIST_AFTER_DISCONNECT,
- YES);
+ SECONDS_BLACKLIST_AFTER_DISCONNECT,
+ YES);
shutdownConnection(be);
} else {
#if 0
printf("Assigned %u bytes to peer %u\n",
- be->idealized_limit,
- u);
+ be->idealized_limit,
+ u);
#endif
}
}
@@ -2419,7 +2419,7 @@
load_cpu = os_cpu_get_load(ectx, cfg);
load_nup = os_network_monitor_get_load(load_monitor,
- Upload);
+ Upload);
scheduleInboundTraffic();
now = get_time();
total_allowed_sent = 0;
@@ -2444,67 +2444,67 @@
FREE(tmp);
continue; /* no need to call 'send buffer' */
case STAT_UP:
- updateCurBPS(root);
- total_allowed_sent += root->max_bpm;
- total_allowed_recv += root->idealized_limit;
- total_allowed_now += root->available_send_window;
+ updateCurBPS(root);
+ total_allowed_sent += root->max_bpm;
+ total_allowed_recv += root->idealized_limit;
+ total_allowed_now += root->available_send_window;
if ( (now > root->isAlive) && /* concurrency might make this false...
*/
- (now - root->isAlive > SECONDS_INACTIVE_DROP * cronSECONDS) ) {
+ (now - root->isAlive > SECONDS_INACTIVE_DROP * cronSECONDS) ) {
#if DEBUG_CONNECTION
EncName enc;
/* switch state form UP to DOWN: too much inactivity */
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- hash2enc(&root->session.sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ hash2enc(&root->session.sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Closing connection with `%s': "
- "too much inactivity (%llu ms)\n",
- &enc,
- now - root->isAlive);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Closing connection with `%s': "
+ "too much inactivity (%llu ms)\n",
+ &enc,
+ now - root->isAlive);
#endif
- /* peer timed out -- shutdown connection */
- identity->blacklistHost(&root->session.sender,
- SECONDS_BLACKLIST_AFTER_DISCONNECT,
- YES);
+ /* peer timed out -- shutdown connection */
+ identity->blacklistHost(&root->session.sender,
+ SECONDS_BLACKLIST_AFTER_DISCONNECT,
+ YES);
shutdownConnection(root);
}
if ( (root->available_send_window > 35 * 1024) &&
- (root->sendBufferSize < 4) &&
- (scl_nextHead != NULL) &&
- (load_nup < IDLE_LOAD_THRESHOLD) &&
- (load_cpu < IDLE_LOAD_THRESHOLD) ) {
+ (root->sendBufferSize < 4) &&
+ (scl_nextHead != NULL) &&
+ (load_nup < IDLE_LOAD_THRESHOLD) &&
+ (load_cpu < IDLE_LOAD_THRESHOLD) ) {
/* create some traffic by force! */
char * msgBuf;
unsigned int mSize;
SendCallbackList *pos;
- unsigned int hSize;
+ unsigned int hSize;
- hSize = root->available_send_window;
- if (hSize > 63 * 1024)
- hSize = 63 * 1024;
+ hSize = root->available_send_window;
+ if (hSize > 63 * 1024)
+ hSize = 63 * 1024;
msgBuf = MALLOC(hSize);
pos = scl_nextHead;
while ( (pos != NULL) &&
- (hSize > 0) ) {
+ (hSize > 0) ) {
if (pos->minimumPadding <= hSize) {
mSize = pos->callback(&root->session.sender,
- msgBuf,
- hSize);
+ msgBuf,
+ hSize);
if (mSize > 0) {
unicast(&root->session.sender,
(MESSAGE_HEADER *) msgBuf,
- 0,
- 5 * cronMINUTES);
- if (mSize > hSize) {
- GE_BREAK(ectx, 0);
- hSize = 0;
- } else {
- hSize -= mSize;
- }
- }
+ 0,
+ 5 * cronMINUTES);
+ if (mSize > hSize) {
+ GE_BREAK(ectx, 0);
+ hSize = 0;
+ } else {
+ hSize -= mSize;
+ }
+ }
}
pos = pos->next;
}
@@ -2513,27 +2513,27 @@
break;
default: /* not up, not down - partial SETKEY exchange */
if ( (now > root->isAlive) &&
- (now - root->isAlive > SECONDS_NOPINGPONG_DROP * cronSECONDS)) {
+ (now - root->isAlive > SECONDS_NOPINGPONG_DROP * cronSECONDS)) {
#if DEBUG_CONNECTION
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- hash2enc(&root->session.sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ hash2enc(&root->session.sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "closing connection to %s: %s not answered.\n",
- &enc,
- (root->status == STAT_SETKEY_SENT) ? "SETKEY" : "PING");
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "closing connection to %s: %s not answered.\n",
+ &enc,
+ (root->status == STAT_SETKEY_SENT) ? "SETKEY" : "PING");
#endif
- /* do not try to reconnect any time soon,
- but allow the other peer to connect to
- us -- after all, we merely failed to
- establish a session in the first place! */
- identity->blacklistHost(&root->session.sender,
- SECONDS_BLACKLIST_AFTER_FAILED_CONNECT,
- NO);
+ /* do not try to reconnect any time soon,
+ but allow the other peer to connect to
+ us -- after all, we merely failed to
+ establish a session in the first place! */
+ identity->blacklistHost(&root->session.sender,
+ SECONDS_BLACKLIST_AFTER_FAILED_CONNECT,
+ NO);
shutdownConnection(root);
}
break;
@@ -2548,13 +2548,13 @@
if (total_allowed_sent > max_bpm_up)
total_allowed_sent = max_bpm_up;
stats->set(stat_total_allowed_sent,
- total_allowed_sent / 60); /* bpm to bps */
+ total_allowed_sent / 60); /* bpm to bps */
stats->set(stat_total_allowed_recv,
- total_allowed_recv / 60); /* bpm to bps */
+ total_allowed_recv / 60); /* bpm to bps */
stats->set(stat_total_allowed_now,
- total_allowed_now);
+ total_allowed_now);
stats->set(stat_total_send_buffer_size,
- total_send_buffer_size);
+ total_send_buffer_size);
}
}
@@ -2572,7 +2572,7 @@
*/
int checkHeader(const PeerIdentity * sender,
P2P_PACKET_HEADER * msg,
- unsigned short size) {
+ unsigned short size) {
BufferEntry *be;
int res;
unsigned int sequenceNumber;
@@ -2587,20 +2587,20 @@
hash2enc(&sender->hashPubKey, &enc);
if(size < sizeof(P2P_PACKET_HEADER)) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_DEVELOPER,
- _("Message from `%s' discarded: invalid format.\n"),
- &enc);
+ GE_WARNING | GE_BULK | GE_DEVELOPER,
+ _("Message from `%s' discarded: invalid format.\n"),
+ &enc);
return SYSERR;
}
if (stats != NULL)
stats->change(stat_received, size);
hash2enc(&sender->hashPubKey,
- &enc);
+ &enc);
hash(&msg->sequenceNumber,
size - sizeof(HashCode512),
&hc);
if (equalsHashCode512(&hc,
- &msg->hash) &&
+ &msg->hash) &&
(msg->sequenceNumber == 0) &&
(msg->bandwidth == 0) &&
(msg->timeStamp == 0) )
@@ -2612,9 +2612,9 @@
(be->status == STAT_DOWN) || (be->status == STAT_SETKEY_SENT)) {
#if DEBUG_CONNECTION
GE_LOG(ectx,
- GE_INFO | GE_BULK | GE_DEVELOPER,
- "Decrypting message from host `%s' failed, no sessionkey (yet)!\n",
- &enc);
+ GE_INFO | GE_BULK | GE_DEVELOPER,
+ "Decrypting message from host `%s' failed, no sessionkey (yet)!\n",
+ &enc);
#endif
/* try to establish a connection, that way, we don't keep
getting bogus messages until the other one times out. */
@@ -2625,16 +2625,16 @@
}
tmp = MALLOC(size - sizeof(HashCode512));
res = decryptBlock(&be->skey_remote,
- &msg->sequenceNumber,
- size - sizeof(HashCode512),
- (const INITVECTOR *) &msg->hash, /* IV */
+ &msg->sequenceNumber,
+ size - sizeof(HashCode512),
+ (const INITVECTOR *) &msg->hash, /* IV */
tmp);
hash(tmp, size - sizeof(HashCode512), &hc);
if(!((res != OK) && equalsHashCode512(&hc, &msg->hash))) {
GE_LOG(ectx,
- GE_INFO | GE_BULK | GE_DEVELOPER,
- "Decrypting message from host `%s' failed, wrong sessionkey!\n",
- &enc);
+ GE_INFO | GE_BULK | GE_DEVELOPER,
+ "Decrypting message from host `%s' failed, wrong sessionkey!\n",
+ &enc);
addHost(sender, YES);
MUTEX_UNLOCK(lock);
FREE(tmp);
@@ -2649,7 +2649,7 @@
if (be->lastSequenceNumberReceived >= sequenceNumber) {
res = SYSERR;
if ( (be->lastSequenceNumberReceived - sequenceNumber <= 32) &&
- (be->lastSequenceNumberReceived != sequenceNumber) ) {
+ (be->lastSequenceNumberReceived != sequenceNumber) ) {
unsigned int rotbit =
1 << (be->lastSequenceNumberReceived - sequenceNumber - 1);
if ((be->lastPacketsBitmap & rotbit) == 0) {
@@ -2659,10 +2659,10 @@
}
if (res == SYSERR) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- _("Invalid sequence number"
- " %u <= %u, dropping message.\n"),
- sequenceNumber, be->lastSequenceNumberReceived);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ _("Invalid sequence number"
+ " %u <= %u, dropping message.\n"),
+ sequenceNumber, be->lastSequenceNumberReceived);
MUTEX_UNLOCK(lock);
return SYSERR;
}
@@ -2676,8 +2676,8 @@
stamp = ntohl(msg->timeStamp);
if(stamp + 1 * cronDAYS < TIME(NULL)) {
GE_LOG(ectx,
- GE_INFO | GE_BULK | GE_USER,
- _("Message received more than one day old. Dropped.\n"));
+ GE_INFO | GE_BULK | GE_USER,
+ _("Message received more than one day old. Dropped.\n"));
MUTEX_UNLOCK(lock);
return SYSERR;
}
@@ -2686,8 +2686,8 @@
if (be->available_send_window > (long long) be->max_bpm * MAX_BUF_FACT) {
if (stats != NULL)
stats->change(stat_total_lost_sent,
- be->available_send_window
- - (long long) be->max_bpm * MAX_BUF_FACT);
+ be->available_send_window
+ - (long long) be->max_bpm * MAX_BUF_FACT);
be->available_send_window = (long long) be->max_bpm * MAX_BUF_FACT;
be->last_bps_update = get_time();
}
@@ -2715,18 +2715,18 @@
if (ntohs(msg->size) != sizeof(P2P_hangup_MESSAGE))
return SYSERR;
if(0 != memcmp(sender,
- &((P2P_hangup_MESSAGE *) msg)->sender,
- sizeof(PeerIdentity)))
+ &((P2P_hangup_MESSAGE *) msg)->sender,
+ sizeof(PeerIdentity)))
return SYSERR;
#if DEBUG_CONNECTION
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- hash2enc(&sender->hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ hash2enc(&sender->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "received HANGUP from `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "received HANGUP from `%s'\n",
+ &enc);
#endif
MUTEX_LOCK(lock);
be = lookForHost(sender);
@@ -2736,8 +2736,8 @@
}
/* do not try to reconnect any time soon! */
identity->blacklistHost(&be->session.sender,
- SECONDS_BLACKLIST_AFTER_DISCONNECT,
- YES);
+ SECONDS_BLACKLIST_AFTER_DISCONNECT,
+ YES);
shutdownConnection(be);
MUTEX_UNLOCK(lock);
return OK;
@@ -2756,8 +2756,8 @@
*/
void assignSessionKey(const SESSIONKEY * key,
const PeerIdentity * peer,
- TIME_T age,
- int forSending) {
+ TIME_T age,
+ int forSending) {
BufferEntry *be;
MUTEX_LOCK(lock);
@@ -2772,10 +2772,10 @@
be->status = STAT_SETKEY_SENT | (be->status & STAT_SETKEY_RECEIVED);
} else { /* for receiving */
if ( ((be->status & STAT_SETKEY_RECEIVED) == 0) ||
- (be->skey_remote_created < age) ) {
+ (be->skey_remote_created < age) ) {
if (0 != memcmp(key,
- &be->skey_remote,
- sizeof(SESSIONKEY))) {
+ &be->skey_remote,
+ sizeof(SESSIONKEY))) {
be->skey_remote = *key;
be->lastSequenceNumberReceived = 0;
}
@@ -2801,19 +2801,19 @@
be->isAlive = get_time();
identity->whitelistHost(peer);
if( ((be->status & STAT_SETKEY_SENT) > 0) &&
- ((be->status & STAT_SETKEY_RECEIVED) > 0) &&
- (OK == ensureTransportConnected(be)) &&
- (be->status != STAT_UP) ) {
+ ((be->status & STAT_SETKEY_RECEIVED) > 0) &&
+ (OK == ensureTransportConnected(be)) &&
+ (be->status != STAT_UP) ) {
#if DEBUG_CONNECTION
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- hash2enc(&peer->hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ hash2enc(&peer->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Received confirmation that session is UP for `%s'\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Received confirmation that session is UP for `%s'\n",
+ &enc);
#endif
be->status = STAT_UP;
be->lastSequenceNumberReceived = 0;
@@ -2861,7 +2861,7 @@
* @return SYSERR if we are not connected to the peer at the moment
*/
int getLastActivityOf(const PeerIdentity * peer,
- cron_t * time) {
+ cron_t * time) {
int ret;
BufferEntry *be;
@@ -2892,8 +2892,8 @@
*/
int getCurrentSessionKey(const PeerIdentity * peer,
SESSIONKEY * key,
- TIME_T * age,
- int forSending) {
+ TIME_T * age,
+ int forSending) {
int ret;
BufferEntry *be;
@@ -2935,7 +2935,7 @@
* @param sender the identity of the other node
*/
void considerTakeover(const PeerIdentity * sender,
- TSession * tsession) {
+ TSession * tsession) {
BufferEntry * be;
unsigned int cost;
@@ -2943,8 +2943,8 @@
if (tsession == NULL)
return;
if (0 != memcmp(sender,
- &tsession->peer,
- sizeof(PeerIdentity))) {
+ &tsession->peer,
+ sizeof(PeerIdentity))) {
GE_BREAK(NULL, 0);
return;
}
@@ -2988,30 +2988,30 @@
* accordingly.
*/
static int connectionConfigChangeCallback(void * ctx,
- struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option) {
+ struct GC_Configuration * cfg,
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option) {
unsigned long long new_max_bpm;
unsigned int i;
if (0 != strcmp(section, "LOAD"))
return 0; /* fast path */
if (-1 == GC_get_configuration_value_number(cfg,
- "LOAD",
- "MAXNETDOWNBPSTOTAL",
- 0,
- ((unsigned long long)-1)/60,
- 50000, /* default: 50 kbps */
- &new_max_bpm))
+ "LOAD",
+ "MAXNETDOWNBPSTOTAL",
+ 0,
+ ((unsigned long long)-1)/60,
+ 50000, /* default: 50 kbps */
+ &new_max_bpm))
return SYSERR;
GC_get_configuration_value_number(cfg,
- "LOAD",
- "MAXNETUPBPSTOTAL",
- 0,
- ((unsigned long long)-1)/60,
- 50000, /* default: 50 kbps */
- &max_bpm_up);
+ "LOAD",
+ "MAXNETUPBPSTOTAL",
+ 0,
+ ((unsigned long long)-1)/60,
+ 50000, /* default: 50 kbps */
+ &max_bpm_up);
max_bpm_up *= 60; /* bps -> bpm */
MUTEX_LOCK(lock);
new_max_bpm = 60 * new_max_bpm;
@@ -3034,11 +3034,11 @@
olen = CONNECTION_MAX_HOSTS_;
CONNECTION_MAX_HOSTS_ = newMAXHOSTS;
GE_BREAK(ectx,
- 0 == GC_set_configuration_value_number(cfg,
- ectx,
- "gnunetd",
- "connection-max-hosts",
- CONNECTION_MAX_HOSTS_));
+ 0 == GC_set_configuration_value_number(cfg,
+ ectx,
+ "gnunetd",
+ "connection-max-hosts",
+ CONNECTION_MAX_HOSTS_));
newBuffer =
(BufferEntry **) MALLOC(sizeof(BufferEntry *) * newMAXHOSTS);
for(i = 0; i < CONNECTION_MAX_HOSTS_; i++)
@@ -3064,18 +3064,18 @@
CONNECTION_buffer_ = newBuffer;
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "connection goal is %s%d peers (%llu BPM bandwidth downstream)\n",
- (olen == 0) ? "" : "now ",
- CONNECTION_MAX_HOSTS_,
- max_bpm);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "connection goal is %s%d peers (%llu BPM bandwidth downstream)\n",
+ (olen == 0) ? "" : "now ",
+ CONNECTION_MAX_HOSTS_,
+ max_bpm);
}
}
disable_random_padding = GC_get_configuration_value_yesno(cfg,
-
"GNUNETD-EXPERIMENTAL",
- "PADDING",
- NO);
+ "GNUNETD-EXPERIMENTAL",
+ "PADDING",
+ NO);
MUTEX_UNLOCK(lock);
return 0;
}
@@ -3084,9 +3084,9 @@
* Initialize this module.
*/
void initConnection(struct GE_Context * e,
- struct GC_Configuration * c,
- struct LoadMonitor * m,
- struct CronManager * cm) {
+ struct GC_Configuration * c,
+ struct LoadMonitor * m,
+ struct CronManager * cm) {
ectx = e;
cfg = c;
load_monitor = m;
@@ -3097,22 +3097,22 @@
scl_nextHead = NULL;
scl_nextTail = NULL;
connectionConfigChangeCallback(NULL,
- cfg,
- ectx,
- "LOAD",
- "NOTHING");
+ cfg,
+ ectx,
+ "LOAD",
+ "NOTHING");
GE_ASSERT(ectx,
- 0 == GC_attach_change_listener(cfg,
- &connectionConfigChangeCallback,
- NULL));
+ 0 == GC_attach_change_listener(cfg,
+ &connectionConfigChangeCallback,
+ NULL));
GE_ASSERT(ectx,
- CONNECTION_MAX_HOSTS_ != 0);
+ CONNECTION_MAX_HOSTS_ != 0);
registerp2pHandler(P2P_PROTO_hangup, &handleHANGUP);
cron_add_job(cron,
- &cronDecreaseLiveness,
- CDL_FREQUENCY,
- CDL_FREQUENCY,
- NULL);
+ &cronDecreaseLiveness,
+ CDL_FREQUENCY,
+ CDL_FREQUENCY,
+ NULL);
#if DEBUG_COLLECT_PRIO
prioFile = FOPEN("/tmp/knapsack_prio.txt", "w");
#endif
@@ -3131,28 +3131,28 @@
if(stats != NULL) {
stat_messagesDropped
= stats->create(gettext_noop(/* number of messages dropped by GNUnet core
- due to resource constraints */
- "# outgoing messages dropped"));
+ due to resource constraints */
+ "# outgoing messages dropped"));
stat_sizeMessagesDropped
= stats->create(gettext_noop(/* bytes of messages dropped by GNUnet core
- due to resource constraints */
- "# bytes of outgoing messages dropped"));
+ due to resource constraints */
+ "# bytes of outgoing messages dropped"));
stat_hangupSent
= stats->create(gettext_noop("# connections closed (HANGUP sent)"));
stat_encrypted = stats->create(gettext_noop(/* includes encrypted but then
- not transmitted data */
- "# bytes encrypted"));
+ not transmitted data */
+ "# bytes encrypted"));
stat_transmitted = stats->create(gettext_noop(/* encrypted data, confirmed
by
- transport, without transport
- headers */
- "# bytes transmitted"));
+ transport, without transport
+ headers */
+ "# bytes transmitted"));
stat_received = stats->create(gettext_noop(/* encrypted data received
- (incl. invalid/undecryptable
data)
- without transport headers */
- "# bytes received"));
+ (incl. invalid/undecryptable data)
+ without transport headers */
+ "# bytes received"));
stat_decrypted
= stats->create(gettext_noop(/* bytes successfully decrypted */
- "# bytes decrypted"));
+ "# bytes decrypted"));
stat_noise_sent
= stats->create(gettext_noop("# bytes noise sent"));
stat_total_allowed_sent
@@ -3182,12 +3182,12 @@
ENTRY();
GC_detach_change_listener(cfg,
- &connectionConfigChangeCallback,
- NULL);
+ &connectionConfigChangeCallback,
+ NULL);
cron_del_job(cron,
- &cronDecreaseLiveness,
- CDL_FREQUENCY,
- NULL);
+ &cronDecreaseLiveness,
+ CDL_FREQUENCY,
+ NULL);
for(i = 0; i < CONNECTION_MAX_HOSTS_; i++) {
BufferEntry *prev;
@@ -3196,8 +3196,8 @@
while(be != NULL) {
#if DEBUG_CONNECTION
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Closing connection: shutdown\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Closing connection: shutdown\n");
#endif
shutdownConnection(be);
prev = be;
@@ -3276,11 +3276,11 @@
tmp = CONNECTION_buffer_[i];
while(tmp != NULL) {
if(tmp->status != STAT_DOWN) {
- hash2enc(&tmp->session.sender.hashPubKey,
- &hostName);
- hash2enc((HashCode512 *) & tmp->skey_local,
- &skey_local);
- hash2enc((HashCode512 *) & tmp->skey_remote, &skey_remote);
+ hash2enc(&tmp->session.sender.hashPubKey,
+ &hostName);
+ hash2enc((HashCode512 *) & tmp->skey_local,
+ &skey_local);
+ hash2enc((HashCode512 *) & tmp->skey_remote, &skey_remote);
hostName.encoding[4] = '\0';
skey_local.encoding[4] = '\0';
skey_remote.encoding[4] = '\0';
@@ -3288,20 +3288,20 @@
if(tmp->session.tsession != NULL)
ttype = tmp->session.tsession->ttype;
GE_LOG(ectx,
- GE_INFO | GE_REQUEST | GE_USER,
- "CONNECTION-TABLE: %3d-%1d-%2d-%4ds"
- " (of %ds) BPM %4llu %8ut-%3u: %s-%s-%s\n",
- i,
- tmp->status,
- ttype,
- (int) ((get_time() - tmp->isAlive) / cronSECONDS),
- SECONDS_INACTIVE_DROP,
- tmp->recently_received,
- tmp->idealized_limit,
- tmp->sendBufferSize,
- &hostName,
- &skey_local,
- &skey_remote);
+ GE_INFO | GE_REQUEST | GE_USER,
+ "CONNECTION-TABLE: %3d-%1d-%2d-%4ds"
+ " (of %ds) BPM %4llu %8ut-%3u: %s-%s-%s\n",
+ i,
+ tmp->status,
+ ttype,
+ (int) ((get_time() - tmp->isAlive) / cronSECONDS),
+ SECONDS_INACTIVE_DROP,
+ tmp->recently_received,
+ tmp->idealized_limit,
+ tmp->sendBufferSize,
+ &hostName,
+ &skey_local,
+ &skey_remote);
}
tmp = tmp->overflowChain;
}
@@ -3374,7 +3374,7 @@
pos = scl_nextHead;
while(pos != NULL) {
if ( (pos->callback == callback) &&
- (pos->minimumPadding == minimumPadding) ) {
+ (pos->minimumPadding == minimumPadding) ) {
if(prev == NULL)
scl_nextHead = pos->next;
else
@@ -3405,8 +3405,8 @@
* @return OK on success, SYSERR on failure, NO on temporary failure
*/
int sendPlaintext(TSession * tsession,
- const char *msg,
- unsigned int size) {
+ const char *msg,
+ unsigned int size) {
char *buf;
int ret;
P2P_PACKET_HEADER *hdr;
@@ -3414,7 +3414,7 @@
GE_ASSERT(ectx, tsession != NULL);
if ( (transport->getMTU(tsession->ttype) > 0) &&
(transport->getMTU(tsession->ttype) <
- size + sizeof(P2P_PACKET_HEADER)) ) {
+ size + sizeof(P2P_PACKET_HEADER)) ) {
GE_BREAK(ectx, 0);
return SYSERR;
}
@@ -3427,9 +3427,9 @@
hash(&hdr->sequenceNumber,
size + sizeof(P2P_PACKET_HEADER) - sizeof(HashCode512), &hdr->hash);
ret = transport->send(tsession,
- buf,
- size + sizeof(P2P_PACKET_HEADER),
- NO);
+ buf,
+ size + sizeof(P2P_PACKET_HEADER),
+ NO);
FREE(buf);
return ret;
}
@@ -3450,7 +3450,7 @@
void * closure,
unsigned short len,
unsigned int importance,
- unsigned int maxdelay) {
+ unsigned int maxdelay) {
BufferEntry *be;
ENTRY();
@@ -3487,7 +3487,7 @@
void unicast(const PeerIdentity * receiver,
const MESSAGE_HEADER * msg,
unsigned int importance,
- unsigned int maxdelay) {
+ unsigned int maxdelay) {
char *closure;
unsigned short len;
@@ -3499,18 +3499,18 @@
len = ntohs(msg->size);
if (len == 0) {
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_DEVELOPER,
- "Empty message send (hopefully used to initiate connection
attempt)\n");
+ GE_DEBUG | GE_BULK | GE_DEVELOPER,
+ "Empty message send (hopefully used to initiate connection attempt)\n");
return;
}
closure = MALLOC(len);
memcpy(closure, msg, len);
unicastCallback(receiver,
NULL,
- closure,
- len,
- importance,
- maxdelay);
+ closure,
+ len,
+ importance,
+ maxdelay);
}
/**
@@ -3523,7 +3523,7 @@
unsigned int res = (((unsigned int) hostId->hashPubKey.bits[0]) &
((unsigned int) (CONNECTION_MAX_HOSTS_ - 1)));
GE_ASSERT(ectx,
- res < CONNECTION_MAX_HOSTS_);
+ res < CONNECTION_MAX_HOSTS_);
return res;
}
@@ -3538,8 +3538,8 @@
}
int getBandwidthAssignedTo(const PeerIdentity * node,
- unsigned int * bpm,
- cron_t * last_seen) {
+ unsigned int * bpm,
+ cron_t * last_seen) {
BufferEntry *be;
unsigned int ret;
@@ -3566,7 +3566,7 @@
* @param preference how much should the traffic preference be increased?
*/
void updateTrafficPreference(const PeerIdentity * node,
- double preference) {
+ double preference) {
BufferEntry *be;
ENTRY();
@@ -3594,18 +3594,18 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- hash2enc(&node->hashPubKey,
- &enc));
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ hash2enc(&node->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
- "Closing connection to `%s' as requested by application.\n",
- &enc);
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Closing connection to `%s' as requested by application.\n",
+ &enc);
#endif
/* do not try to reconnect any time soon! */
identity->blacklistHost(&be->session.sender,
- SECONDS_BLACKLIST_AFTER_DISCONNECT,
- YES);
+ SECONDS_BLACKLIST_AFTER_DISCONNECT,
+ YES);
shutdownConnection(be);
}
MUTEX_UNLOCK(lock);
Modified: GNUnet/src/server/core.c
===================================================================
--- GNUnet/src/server/core.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/server/core.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -103,10 +103,10 @@
pos = NULL;
if (-1 == GC_get_configuration_value_string(applicationCore.cfg,
- "MODULES",
- rpos,
- rpos,
- &pos))
+ "MODULES",
+ rpos,
+ rpos,
+ &pos))
return SYSERR;
GE_ASSERT(applicationCore.ectx, pos != NULL);
name = MALLOC(strlen(pos) + strlen("module_") + 1);
@@ -117,42 +117,42 @@
nxt = shutdownList;
while (nxt != NULL) {
if (0 == strcmp(name,
- nxt->dsoName)) {
+ nxt->dsoName)) {
if (nxt->applicationInitialized == YES) {
- GE_LOG(applicationCore.ectx,
- GE_WARNING | GE_DEVELOPER | GE_BULK,
- _("Application module `%s' already initialized!\n"),
- name);
- FREE(name);
- return SYSERR;
+ GE_LOG(applicationCore.ectx,
+ GE_WARNING | GE_DEVELOPER | GE_BULK,
+ _("Application module `%s' already initialized!\n"),
+ name);
+ FREE(name);
+ return SYSERR;
} else {
- mptr = os_plugin_resolve_function(nxt->library,
- "initialize_",
- YES);
- if (mptr == NULL) {
- FREE(name);
- return SYSERR;
- }
- ok = mptr(&applicationCore);
- if (ok == OK)
- nxt->applicationInitialized = YES;
- FREE(name);
- return ok;
+ mptr = os_plugin_resolve_function(nxt->library,
+ "initialize_",
+ YES);
+ if (mptr == NULL) {
+ FREE(name);
+ return SYSERR;
+ }
+ ok = mptr(&applicationCore);
+ if (ok == OK)
+ nxt->applicationInitialized = YES;
+ FREE(name);
+ return ok;
}
}
nxt = nxt->next;
}
library = os_plugin_load(applicationCore.ectx,
- DSO_PREFIX,
- name);
+ DSO_PREFIX,
+ name);
if (library == NULL) {
FREE(name);
return SYSERR;
}
mptr = os_plugin_resolve_function(library,
- "initialize_",
- YES);
+ "initialize_",
+ YES);
if (mptr == NULL) {
os_plugin_unload(library);
FREE(name);
@@ -170,9 +170,9 @@
if (OK != ok) {
/* undo loading */
GE_LOG(applicationCore.ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- _("Failed to load plugin `%s' at %s:%d. Unloading plugin.\n"),
- name, __FILE__, __LINE__);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ _("Failed to load plugin `%s' at %s:%d. Unloading plugin.\n"),
+ name, __FILE__, __LINE__);
/* Note: we cannot assert that shutdownList == nxt here,
so we have to traverse the list again! */
nxt->applicationInitialized = NO;
@@ -181,11 +181,11 @@
} else {
spos = shutdownList;
while (spos->next != nxt) {
- spos = spos->next;
- if (spos == NULL) {
- GE_BREAK(applicationCore.ectx, 0); /* should never happen! */
- return ok;
- }
+ spos = spos->next;
+ if (spos == NULL) {
+ GE_BREAK(applicationCore.ectx, 0); /* should never happen! */
+ return ok;
+ }
}
}
if (spos == NULL)
@@ -207,35 +207,35 @@
prev = NULL;
pos = shutdownList;
while ( (pos != NULL) &&
- (0 != strcmp(name,
- pos->dsoName) ) )
+ (0 != strcmp(name,
+ pos->dsoName) ) )
pos = pos->next;
if (pos == NULL) {
GE_LOG(applicationCore.ectx,
- GE_ERROR | GE_USER | GE_BULK | GE_DEVELOPER,
- _("Could not shutdown `%s': application not loaded\n"),
- name);
+ GE_ERROR | GE_USER | GE_BULK | GE_DEVELOPER,
+ _("Could not shutdown `%s': application not loaded\n"),
+ name);
return SYSERR;
}
if (pos->applicationInitialized != YES) {
GE_LOG(applicationCore.ectx,
- GE_WARNING | GE_USER | GE_BULK | GE_DEVELOPER,
- _("Could not shutdown application `%s': not initialized\n"),
- name);
+ GE_WARNING | GE_USER | GE_BULK | GE_DEVELOPER,
+ _("Could not shutdown application `%s': not initialized\n"),
+ name);
return SYSERR;
}
mptr = os_plugin_resolve_function(pos->library,
- "done_",
- YES);
+ "done_",
+ YES);
if (mptr == NULL) {
GE_LOG(applicationCore.ectx,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- _("Could not find '%s%s' method in library `%s'.\n"),
- "done_",
- pos->dsoName,
- pos->dsoName);
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ _("Could not find '%s%s' method in library `%s'.\n"),
+ "done_",
+ pos->dsoName,
+ pos->dsoName);
return SYSERR;
}
mptr();
@@ -272,10 +272,10 @@
/* subtyping, GNUnet style */
pos = NULL;
if (-1 == GC_get_configuration_value_string(applicationCore.cfg,
- "MODULES",
- rpos,
- rpos,
- &pos))
+ "MODULES",
+ rpos,
+ rpos,
+ &pos))
return NULL;
GE_ASSERT(applicationCore.ectx, pos != NULL);
name = MALLOC(strlen(pos) + strlen("module_") + 1);
@@ -285,44 +285,44 @@
nxt = shutdownList;
while (nxt != NULL) {
if (0 == strcmp(name,
- nxt->dsoName)) {
+ nxt->dsoName)) {
if (nxt->serviceCount > 0) {
- if (nxt->servicePTR != NULL)
- nxt->serviceCount++;
- FREE(name);
- FREE(pos);
- return nxt->servicePTR;
+ if (nxt->servicePTR != NULL)
+ nxt->serviceCount++;
+ FREE(name);
+ FREE(pos);
+ return nxt->servicePTR;
} else {
- mptr = os_plugin_resolve_function(nxt->library,
- "provide_",
- YES);
- if (mptr == NULL) {
- FREE(name);
- FREE(pos);
- return NULL;
- }
- nxt->servicePTR = mptr(&applicationCore);
- if (nxt->servicePTR != NULL)
- nxt->serviceCount++;
- FREE(name);
- FREE(pos);
- return nxt->servicePTR;
+ mptr = os_plugin_resolve_function(nxt->library,
+ "provide_",
+ YES);
+ if (mptr == NULL) {
+ FREE(name);
+ FREE(pos);
+ return NULL;
+ }
+ nxt->servicePTR = mptr(&applicationCore);
+ if (nxt->servicePTR != NULL)
+ nxt->serviceCount++;
+ FREE(name);
+ FREE(pos);
+ return nxt->servicePTR;
}
}
nxt = nxt->next;
}
library = os_plugin_load(applicationCore.ectx,
- DSO_PREFIX,
- name);
+ DSO_PREFIX,
+ name);
if (library == NULL) {
FREE(name);
FREE(pos);
return NULL;
}
mptr = os_plugin_resolve_function(library,
- "provide_",
- YES);
+ "provide_",
+ YES);
if (mptr == NULL) {
os_plugin_unload(library);
FREE(name);
@@ -338,17 +338,17 @@
nxt->servicePTR = NULL;
shutdownList = nxt;
GE_LOG(applicationCore.ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- "Loading service `%s'\n",
- pos);
+ GE_INFO | GE_USER | GE_REQUEST,
+ "Loading service `%s'\n",
+ pos);
api = mptr(&applicationCore);
if (api != NULL) {
nxt->servicePTR = api;
} else {
GE_LOG(applicationCore.ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_IMMEDIATE,
- "Failed to load service `%s'\n",
- pos);
+ GE_WARNING | GE_ADMIN | GE_USER | GE_IMMEDIATE,
+ "Failed to load service `%s'\n",
+ pos);
nxt->serviceCount = 0;
}
FREE(pos);
@@ -365,14 +365,14 @@
prev = NULL;
pos = shutdownList;
while ( (pos != NULL) &&
- (pos->servicePTR != service) )
+ (pos->servicePTR != service) )
pos = pos->next;
if (pos == NULL) {
GE_LOG(applicationCore.ectx,
- GE_BULK | GE_DEVELOPER | GE_ERROR,
- _("Could not release %p: service not loaded\n"),
- service);
+ GE_BULK | GE_DEVELOPER | GE_ERROR,
+ _("Could not release %p: service not loaded\n"),
+ service);
return SYSERR;
}
if (pos->serviceCount > 1) {
@@ -380,12 +380,12 @@
return OK; /* service still in use elsewhere! */
}
GE_LOG(applicationCore.ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- "Unloading service `%s'.\n",
- pos->dsoName);
+ GE_INFO | GE_USER | GE_REQUEST,
+ "Unloading service `%s'.\n",
+ pos->dsoName);
mptr = os_plugin_resolve_function(pos->library,
- "release_",
- YES);
+ "release_",
+ YES);
if (mptr == NULL)
return SYSERR;
mptr();
@@ -421,10 +421,10 @@
ok = OK;
dso = NULL;
if (-1 == GC_get_configuration_value_string(applicationCore.cfg,
- "GNUNETD",
- "APPLICATIONS",
- "advertising fs getoption stats
traffic",
- &dso))
+ "GNUNETD",
+ "APPLICATIONS",
+ "advertising fs getoption stats traffic",
+ &dso))
return SYSERR;
GE_ASSERT(applicationCore.ectx, dso != NULL);
next = dso;
@@ -433,7 +433,7 @@
next++;
pos = next;
while ( (*next != '\0') &&
- (*next != ' ') )
+ (*next != ' ') )
next++;
if (*next == '\0') {
next = NULL; /* terminate! */
@@ -443,11 +443,11 @@
}
if (strlen(pos) > 0) {
GE_LOG(applicationCore.ectx,
- GE_INFO | GE_USER | GE_BULK,
- "Loading application `%s'\n",
- pos);
+ GE_INFO | GE_USER | GE_BULK,
+ "Loading application `%s'\n",
+ pos);
if (OK != loadApplicationModule(pos))
- ok = SYSERR;
+ ok = SYSERR;
}
} while (next != NULL);
FREE(dso);
@@ -464,11 +464,11 @@
while (pos != NULL) {
nxt = pos->next;
if ( (pos->applicationInitialized == YES) &&
- (OK != unloadApplicationModule(pos->dsoName)) ) {
+ (OK != unloadApplicationModule(pos->dsoName)) ) {
GE_LOG(applicationCore.ectx,
- GE_ERROR | GE_DEVELOPER | GE_BULK,
- _("Could not properly shutdown application `%s'.\n"),
- pos->dsoName);
+ GE_ERROR | GE_DEVELOPER | GE_BULK,
+ _("Could not properly shutdown application `%s'.\n"),
+ pos->dsoName);
ok = SYSERR;
}
pos = nxt;
@@ -480,9 +480,9 @@
* Initialize the CORE's globals.
*/
int initCore(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct CronManager * cron,
- struct LoadMonitor * monitor) {
+ struct GC_Configuration * cfg,
+ struct CronManager * cron,
+ struct LoadMonitor * monitor) {
applicationCore.ectx = ectx;
applicationCore.cfg = cfg;
applicationCore.load_monitor = monitor;
@@ -539,10 +539,10 @@
if (identity == NULL)
return SYSERR;
identity->getPeerIdentity(identity->getPublicPrivateKey(),
- &myIdentity);
+ &myIdentity);
applicationCore.myIdentity = &myIdentity; /* core.c */
if (initTCPServer(ectx,
- cfg) != OK) {
+ cfg) != OK) {
releaseService(identity);
return SYSERR;
}
@@ -574,29 +574,29 @@
change = 0;
while (pos != NULL) {
if ( (pos->applicationInitialized == NO) &&
- (pos->serviceCount == 0) ) {
- change = 1;
- os_plugin_unload(pos->library);
- nxt = pos->next;
- if (prev == NULL)
- shutdownList = nxt;
- else
- prev->next = nxt;
- FREE(pos->dsoName);
- FREE(pos);
- pos = nxt;
+ (pos->serviceCount == 0) ) {
+ change = 1;
+ os_plugin_unload(pos->library);
+ nxt = pos->next;
+ if (prev == NULL)
+ shutdownList = nxt;
+ else
+ prev->next = nxt;
+ FREE(pos->dsoName);
+ FREE(pos);
+ pos = nxt;
} else {
- prev = pos;
- pos = pos->next;
+ prev = pos;
+ pos = pos->next;
}
}
}
pos = shutdownList;
while (pos != NULL) {
GE_LOG(applicationCore.ectx,
- GE_ERROR | GE_DEVELOPER | GE_BULK,
- _("Could not properly unload service `%s'!\n"),
- pos->dsoName);
+ GE_ERROR | GE_DEVELOPER | GE_BULK,
+ _("Could not properly unload service `%s'!\n"),
+ pos->dsoName);
pos = pos->next;
}
doneTCPServer();
Modified: GNUnet/src/server/gnunet-peer-info.c
===================================================================
--- GNUnet/src/server/gnunet-peer-info.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/server/gnunet-peer-info.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -65,9 +65,9 @@
* Prepass just to resolve DNS entries.
*/
static int resolveHostInfo(const PeerIdentity * id,
- const unsigned short proto,
- int verified,
- void * data) {
+ const unsigned short proto,
+ int verified,
+ void * data) {
P2P_hello_MESSAGE * hello;
void * addr;
unsigned int addr_len;
@@ -77,20 +77,20 @@
if (GNUNET_SHUTDOWN_TEST()==YES)
return SYSERR;
hello = identity->identity2Hello(id,
- proto,
- NO);
+ proto,
+ NO);
if (NULL == hello)
return OK;
addr = NULL;
addr_len = 0;
have_addr = transport->helloToAddress(hello,
- &addr,
- &addr_len);
+ &addr,
+ &addr_len);
FREE(hello);
if (have_addr == OK) {
info = network_get_ip_as_string(addr,
- addr_len,
- ! no_resolve);
+ addr_len,
+ ! no_resolve);
FREE(addr);
addr = NULL;
FREENONNULL(info);
@@ -106,9 +106,9 @@
* Could of course do more (e.g. resolve via DNS).
*/
static int printHostInfo(const PeerIdentity * id,
- const unsigned short proto,
- int verified,
- void * data) {
+ const unsigned short proto,
+ int verified,
+ void * data) {
P2P_hello_MESSAGE * hello;
void * addr;
unsigned int addr_len;
@@ -119,81 +119,81 @@
if (GNUNET_SHUTDOWN_TEST()==YES)
return SYSERR;
hash2enc(&id->hashPubKey,
- &enc);
+ &enc);
hello = identity->identity2Hello(id,
- proto,
- NO);
+ proto,
+ NO);
if (NULL == hello) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Could not get address of peer `%s'.\n"),
- &enc);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Could not get address of peer `%s'.\n"),
+ &enc);
return OK;
}
if (SYSERR == verifySig(&hello->senderIdentity,
- P2P_hello_MESSAGE_size(hello) - sizeof(Signature) -
sizeof(PublicKey) - sizeof(MESSAGE_HEADER),
- &hello->signature,
- &hello->publicKey)) {
+ P2P_hello_MESSAGE_size(hello) - sizeof(Signature) -
sizeof(PublicKey) - sizeof(MESSAGE_HEADER),
+ &hello->signature,
+ &hello->publicKey)) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("hello message invalid (signature invalid).\n"));
+ GE_WARNING | GE_BULK | GE_USER,
+ _("hello message invalid (signature invalid).\n"));
}
addr = NULL;
addr_len = 0;
have_addr = transport->helloToAddress(hello,
- &addr,
- &addr_len);
+ &addr,
+ &addr_len);
FREE(hello);
if (have_addr != OK) {
info = STRDUP("NAT"); /* most likely */
} else {
info = network_get_ip_as_string(addr,
- addr_len,
- ! no_resolve);
+ addr_len,
+ ! no_resolve);
FREE(addr);
addr = NULL;
}
if (info == NULL) {
GE_LOG(ectx,
- GE_DEBUG | GE_BULK | GE_USER,
- _("Could not get address of peer `%s'.\n"),
- &enc);
+ GE_DEBUG | GE_BULK | GE_USER,
+ _("Could not get address of peer `%s'.\n"),
+ &enc);
printf(_("Peer `%s' with trust %8u\n"),
- (char*)&enc,
- identity->getHostTrust(id));
+ (char*)&enc,
+ identity->getHostTrust(id));
return OK;
}
printf(_("Peer `%s' with trust %8u and address `%s'\n"),
- (char*)&enc,
- identity->getHostTrust(id),
- info);
+ (char*)&enc,
+ identity->getHostTrust(id),
+ info);
FREE(info);
return OK;
}
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
struct GC_Configuration * cfg;
struct CronManager * cron;
int ret;
ret = GNUNET_init(argc,
- argv,
- "gnunet-peer-info",
- &cfgFilename,
- gnunetpeerinfoOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-peer-info",
+ &cfgFilename,
+ gnunetpeerinfoOptions,
+ &ectx,
+ &cfg);
if (ret == -1) {
GNUNET_fini(ectx, cfg);
return -1;
}
GE_ASSERT(ectx,
- 0 == GC_set_configuration_value_string(cfg,
- ectx,
- "TCPSERVER",
- "DISABLE",
- "YES"));
+ 0 == GC_set_configuration_value_string(cfg,
+ ectx,
+ "TCPSERVER",
+ "DISABLE",
+ "YES"));
cron = cron_create(ectx);
initCore(ectx, cfg, cron, NULL);
identity = requestService("identity");
@@ -201,15 +201,15 @@
if (no_resolve != YES) {
#if HAVE_ADNS
identity->forEachHost(0, /* no timeout */
- &resolveHostInfo,
- NULL);
+ &resolveHostInfo,
+ NULL);
/* give GNU ADNS time to resolve... */
PTHREAD_SLEEP(2 * cronSECONDS);
#endif
}
identity->forEachHost(0, /* no timeout */
- &printHostInfo,
- NULL);
+ &printHostInfo,
+ NULL);
releaseService(identity);
releaseService(transport);
doneCore();
Modified: GNUnet/src/server/gnunet-transport-check.c
===================================================================
--- GNUnet/src/server/gnunet-transport-check.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/server/gnunet-transport-check.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -81,13 +81,13 @@
}
static int noiseHandler(const PeerIdentity *peer,
- const MESSAGE_HEADER * msg,
- TSession * s) {
+ const MESSAGE_HEADER * msg,
+ TSession * s) {
if ( (ntohs(msg->size) ==
- sizeof(MESSAGE_HEADER) + expectedSize) &&
+ sizeof(MESSAGE_HEADER) + expectedSize) &&
(0 == memcmp(expectedValue,
- &msg[1],
- expectedSize)) )
+ &msg[1],
+ expectedSize)) )
ok = YES;
SEMAPHORE_UP(sem);
return OK;
@@ -97,7 +97,7 @@
* Test the given transport API.
*/
static void testTAPI(TransportAPI * tapi,
- void * ctx) {
+ void * ctx) {
int * res = ctx;
P2P_hello_MESSAGE * helo;
TSession * tsession;
@@ -115,29 +115,29 @@
helo = tapi->createhello();
if (helo == NULL) {
fprintf(stderr,
- _("`%s': Could not create hello.\n"),
- tapi->transName);
+ _("`%s': Could not create hello.\n"),
+ tapi->transName);
*res = SYSERR;
return;
}
tsession = NULL;
if (OK != tapi->connect(helo,
- &tsession)) {
+ &tsession)) {
fprintf(stderr,
- _("`%s': Could not connect.\n"),
- tapi->transName);
+ _("`%s': Could not connect.\n"),
+ tapi->transName);
*res = SYSERR;
FREE(helo);
return;
}
FREE(helo);
if (-1 == GC_get_configuration_value_number(cfg,
- "TRANSPORT-CHECK",
- "REPEAT",
- 1,
- (unsigned long) -1,
- 1,
- &repeat)) {
+ "TRANSPORT-CHECK",
+ "REPEAT",
+ 1,
+ (unsigned long) -1,
+ 1,
+ &repeat)) {
*res = SYSERR;
return;
}
@@ -148,18 +148,18 @@
noise->type = htons(P2P_PROTO_noise);
noise->size = htons(expectedSize + sizeof(MESSAGE_HEADER));
memcpy(&noise[1],
- expectedValue,
- expectedSize);
+ expectedValue,
+ expectedSize);
while ( (repeat > 0) &&
- (GNUNET_SHUTDOWN_TEST() == NO) ) {
+ (GNUNET_SHUTDOWN_TEST() == NO) ) {
repeat--;
ok = NO;
if (OK != sendPlaintext(tsession,
- (char*)noise,
- ntohs(noise->size))) {
+ (char*)noise,
+ ntohs(noise->size))) {
fprintf(stderr,
- _("`%s': Could not send.\n"),
- tapi->transName);
+ _("`%s': Could not send.\n"),
+ tapi->transName);
*res = SYSERR;
tapi->disconnect(tsession);
SEMAPHORE_DESTROY(sem);
@@ -167,22 +167,22 @@
return;
}
cron_add_job(cron,
- &semUp,
- timeout,
- 0,
- sem);
+ &semUp,
+ timeout,
+ 0,
+ sem);
SEMAPHORE_DOWN(sem, YES);
cron_suspend(cron, NO);
cron_del_job(cron,
- &semUp,
- 0,
- sem);
+ &semUp,
+ 0,
+ sem);
cron_resume_jobs(cron, NO);
if (ok != YES) {
FPRINTF(stderr,
- _("`%s': Did not receive message within %llu ms.\n"),
- tapi->transName,
- timeout);
+ _("`%s': Did not receive message within %llu ms.\n"),
+ tapi->transName,
+ timeout);
*res = SYSERR;
tapi->disconnect(tsession);
SEMAPHORE_DESTROY(sem);
@@ -194,18 +194,18 @@
end = get_time();
if (OK != tapi->disconnect(tsession)) {
fprintf(stderr,
- _("`%s': Could not disconnect.\n"),
- tapi->transName);
+ _("`%s': Could not disconnect.\n"),
+ tapi->transName);
*res = SYSERR;
SEMAPHORE_DESTROY(sem);
return;
}
SEMAPHORE_DESTROY(sem);
printf(_("`%s' transport OK. It took %ums to transmit %llu messages of %llu
bytes each.\n"),
- tapi->transName,
- (unsigned int) ((end - start)/cronMILLIS),
- total,
- expectedSize);
+ tapi->transName,
+ (unsigned int) ((end - start)/cronMILLIS),
+ total,
+ expectedSize);
}
static void pingCallback(void * unused) {
@@ -214,7 +214,7 @@
}
static void testPING(const P2P_hello_MESSAGE * xhello,
- void * arg) {
+ void * arg) {
int * stats = arg;
TSession * tsession;
P2P_hello_MESSAGE * hello;
@@ -228,9 +228,9 @@
stats[0]++; /* one more seen */
if (NO == transport->isAvailable(ntohs(xhello->protocol))) {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- _(" Transport %d is not being tested\n"),
- ntohs(xhello->protocol));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _(" Transport %d is not being tested\n"),
+ ntohs(xhello->protocol));
return;
}
if (ntohs(xhello->protocol) == NAT_PROTOCOL_NUMBER)
@@ -238,12 +238,12 @@
stats[1]++; /* one more with transport 'available' */
GC_get_configuration_value_number(cfg,
- "GNUNET",
- "VERBOSE",
- 0,
- (unsigned long long) -1,
- 0,
- &verbose);
+ "GNUNET",
+ "VERBOSE",
+ 0,
+ (unsigned long long) -1,
+ 0,
+ &verbose);
if (verbose > 0) {
char * str;
void * addr;
@@ -251,26 +251,26 @@
int have_addr;
have_addr = transport->helloToAddress(xhello,
- &addr,
- &addr_len);
+ &addr,
+ &addr_len);
if (have_addr == NO) {
str = STRDUP("NAT"); /* most likely */
} else {
str = network_get_ip_as_string(addr,
- addr_len,
- YES);
+ addr_len,
+ YES);
FREE(addr);
}
fprintf(stderr,
- _("\nContacting `%s'."),
- str);
+ _("\nContacting `%s'."),
+ str);
FREE(str);
} else
fprintf(stderr, ".");
hello = MALLOC(ntohs(xhello->header.size));
memcpy(hello,
- xhello,
- ntohs(xhello->header.size));
+ xhello,
+ ntohs(xhello->header.size));
myHello = transport->createhello(ntohs(xhello->protocol));
if (myHello == NULL)
@@ -288,13 +288,13 @@
FREE(hello);
if (tsession == NULL) {
fprintf(stderr,
- _(" Connection failed\n"));
+ _(" Connection failed\n"));
return;
}
if (tsession == NULL) {
GE_BREAK(ectx, 0);
fprintf(stderr,
- _(" Connection failed (bug?)\n"));
+ _(" Connection failed (bug?)\n"));
return;
}
if (verbose > 0)
@@ -302,27 +302,27 @@
sem = SEMAPHORE_CREATE(0);
ping = pingpong->pingUser(&peer,
- &pingCallback,
- NULL,
- YES,
- rand());
+ &pingCallback,
+ NULL,
+ YES,
+ rand());
len = ntohs(ping->size) + ntohs(myHello->header.size);
msg = MALLOC(len);
memcpy(msg,
- myHello,
- ntohs(myHello->header.size));
+ myHello,
+ ntohs(myHello->header.size));
memcpy(&msg[ntohs(myHello->header.size)],
- ping,
- ntohs(ping->size));
+ ping,
+ ntohs(ping->size));
FREE(myHello);
FREE(ping);
/* send ping */
ok = NO;
if (OK != sendPlaintext(tsession,
- msg,
- len)) {
+ msg,
+ len)) {
fprintf(stderr,
- "Send failed.\n");
+ "Send failed.\n");
FREE(msg);
transport->disconnect(tsession);
return;
@@ -333,34 +333,34 @@
/* check: received pong? */
#if DEBUG_TRANSPORT_CHECK
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Waiting for PONG\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Waiting for PONG\n");
#endif
terminate = NO;
cron_add_job(cron,
- &semUp,
- timeout,
- 5 * cronSECONDS,
- sem);
+ &semUp,
+ timeout,
+ 5 * cronSECONDS,
+ sem);
SEMAPHORE_DOWN(sem, YES);
if (verbose > 0) {
if (ok != YES)
FPRINTF(stderr,
- _("Timeout after %llums.\n"),
- timeout);
+ _("Timeout after %llums.\n"),
+ timeout);
else
fprintf(stderr,
- _("OK!\n"));
+ _("OK!\n"));
}
cron_suspend(cron,
- NO);
+ NO);
cron_del_job(cron,
- &semUp,
- 5 * cronSECONDS,
- sem);
+ &semUp,
+ 5 * cronSECONDS,
+ sem);
cron_resume_jobs(cron,
- NO);
+ NO);
SEMAPHORE_DESTROY(sem);
sem = NULL;
transport->disconnect(tsession);
@@ -396,10 +396,10 @@
1, &gnunet_getopt_configure_set_option, "GNUNETD:TRANSPORTS" },
{ 'T', "timeout", "MS",
gettext_noop("specifies after how many MS to time-out"),
- 1, &gnunet_getopt_configure_set_option, "TRANSPORT-CHECK:TIMEOUT" },
+ 1, &gnunet_getopt_configure_set_option, "TRANSPORT-CHECK:TIMEOUT" },
{ 'u', "user", "LOGIN",
gettext_noop("run as user LOGIN"),
- 1, &gnunet_getopt_configure_set_option, "GNUNETD:USER" },
+ 1, &gnunet_getopt_configure_set_option, "GNUNETD:USER" },
COMMAND_LINE_OPTION_VERSION(PACKAGE_VERSION), /* -v */
COMMAND_LINE_OPTION_VERBOSE,
{ 'X', "Xrepeat", "X",
@@ -409,7 +409,7 @@
};
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
int res;
unsigned long long Xrepeat;
char * trans;
@@ -417,12 +417,12 @@
int pos;
res = GNUNET_init(argc,
- argv,
- "gnunet-transport-check",
- &cfgFilename,
- gnunettransportcheckOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-transport-check",
+ &cfgFilename,
+ gnunettransportcheckOptions,
+ &ectx,
+ &cfg);
if ( (res == -1) ||
(OK != changeUser(ectx, cfg)) ) {
GNUNET_fini(ectx, cfg);
@@ -430,22 +430,22 @@
}
if (-1 == GC_get_configuration_value_number(cfg,
- "TRANSPORT-CHECK",
- "SIZE",
- 1,
- 60000,
- 12,
- &expectedSize)) {
+ "TRANSPORT-CHECK",
+ "SIZE",
+ 1,
+ 60000,
+ 12,
+ &expectedSize)) {
GNUNET_fini(ectx, cfg);
return 1;
}
if (-1 == GC_get_configuration_value_number(cfg,
- "TRANSPORT-CHECK",
- "TIMEOUT",
- 1,
- 60 * cronSECONDS,
- 3 * cronSECONDS,
- &timeout)) {
+ "TRANSPORT-CHECK",
+ "TIMEOUT",
+ 1,
+ 60 * cronSECONDS,
+ 3 * cronSECONDS,
+ &timeout)) {
GNUNET_fini(ectx, cfg);
return 1;
}
@@ -458,10 +458,10 @@
trans = NULL;
if (-1 == GC_get_configuration_value_string(cfg,
- "GNUNETD",
- "TRANSPORTS",
- "udp tcp http",
- &trans)) {
+ "GNUNETD",
+ "TRANSPORTS",
+ "udp tcp http",
+ &trans)) {
FREE(expectedValue);
GNUNET_fini(ectx, cfg);
return 1;
@@ -469,38 +469,38 @@
GE_ASSERT(ectx, trans != NULL);
if (ping)
printf(_("Testing transport(s) %s\n"),
- trans);
+ trans);
else
printf(_("Available transport(s): %s\n"),
- trans);
+ trans);
FREE(trans);
if (! ping) {
/* disable blacklists (loopback is often blacklisted)... */
GC_set_configuration_value_string(cfg,
- ectx,
- "TCP",
- "BLACKLIST",
- "");
+ ectx,
+ "TCP",
+ "BLACKLIST",
+ "");
GC_set_configuration_value_string(cfg,
- ectx,
- "TCP6",
- "BLACKLIST",
- "");
+ ectx,
+ "TCP6",
+ "BLACKLIST",
+ "");
GC_set_configuration_value_string(cfg,
- ectx,
- "UDP",
- "BLACKLIST",
- "");
+ ectx,
+ "UDP",
+ "BLACKLIST",
+ "");
GC_set_configuration_value_string(cfg,
- ectx,
- "UDP6",
- "BLACKLIST",
- "");
+ ectx,
+ "UDP6",
+ "BLACKLIST",
+ "");
GC_set_configuration_value_string(cfg,
- ectx,
- "HTTP",
- "BLACKLIST",
- "");
+ ectx,
+ "HTTP",
+ "BLACKLIST",
+ "");
}
cron = cron_create(ectx);
if (OK != initCore(ectx, cfg, cron, NULL)) {
@@ -511,7 +511,7 @@
}
initConnection(ectx, cfg, NULL, cron);
registerPlaintextHandler(P2P_PROTO_noise,
- &noiseHandler);
+ &noiseHandler);
enableCoreProcessing();
identity = requestService("identity");
transport = requestService("transport");
@@ -519,12 +519,12 @@
cron_start(cron);
GC_get_configuration_value_number(cfg,
- "TRANSPORT-CHECK",
- "X-REPEAT",
- 1,
- (unsigned long long) -1,
- 1,
- &Xrepeat);
+ "TRANSPORT-CHECK",
+ "X-REPEAT",
+ 1,
+ (unsigned long long) -1,
+ 1,
+ &Xrepeat);
res = OK;
if (ping) {
bootstrap = requestService("bootstrap");
@@ -533,19 +533,19 @@
stats[1] = 0;
stats[2] = 0;
bootstrap->bootstrap(&testPING,
- &stats[0],
- &testTerminate,
- NULL);
+ &stats[0],
+ &testTerminate,
+ NULL);
printf(_("\n%d out of %d peers contacted successfully (%d times transport
unavailable).\n"),
- stats[2],
- stats[1],
- stats[0] - stats[1]);
+ stats[2],
+ stats[1],
+ stats[0] - stats[1]);
releaseService(bootstrap);
} else {
while ( (Xrepeat-- > 0) &&
- (GNUNET_SHUTDOWN_TEST() == NO) )
+ (GNUNET_SHUTDOWN_TEST() == NO) )
transport->forEach(&testTAPI,
- &res);
+ &res);
}
cron_stop(cron);
releaseService(identity);
@@ -553,7 +553,7 @@
releaseService(pingpong);
disableCoreProcessing();
unregisterPlaintextHandler(P2P_PROTO_noise,
- &noiseHandler);
+ &noiseHandler);
doneConnection();
doneCore();
FREE(expectedValue);
Modified: GNUnet/src/server/gnunet-update.c
===================================================================
--- GNUnet/src/server/gnunet-update.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/server/gnunet-update.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -76,10 +76,10 @@
pos = NULL;
if (-1 == GC_get_configuration_value_string(cfg,
- "MODULES",
- rpos,
- rpos,
- &pos))
+ "MODULES",
+ rpos,
+ rpos,
+ &pos))
return SYSERR;
GE_ASSERT(ectx, pos != NULL);
@@ -88,15 +88,15 @@
strcat(name, pos);
FREE(pos);
library = os_plugin_load(ectx,
- DSO_PREFIX,
- name);
+ DSO_PREFIX,
+ name);
if (library == NULL) {
FREE(name);
return SYSERR;
}
mptr = os_plugin_resolve_function(library,
- "update_",
- NO);
+ "update_",
+ NO);
if (mptr == NULL) {
os_plugin_unload(library);
FREE(name);
@@ -119,17 +119,17 @@
dso = NULL;
if (-1 == GC_get_configuration_value_string(cfg,
- "GNUNETD",
- "APPLICATIONS",
- "advertising fs getoption stats
traffic",
- &dso))
+ "GNUNETD",
+ "APPLICATIONS",
+ "advertising fs getoption stats traffic",
+ &dso))
return;
GE_ASSERT(ectx, dso != NULL);
next = dso;
do {
pos = next;
while ( (*next != '\0') &&
- (*next != ' ') )
+ (*next != ' ') )
next++;
if (*next == '\0') {
next = NULL; /* terminate! */
@@ -139,14 +139,14 @@
}
if (strlen(pos) > 0) {
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- _("Updating data for module `%s'\n"),
- pos);
+ GE_INFO | GE_USER | GE_BULK,
+ _("Updating data for module `%s'\n"),
+ pos);
if (OK != updateModule(pos))
- GE_LOG(ectx,
- GE_ERROR | GE_DEVELOPER | GE_BULK | GE_USER,
- _("Failed to update data for module `%s'\n"),
- pos);
+ GE_LOG(ectx,
+ GE_ERROR | GE_DEVELOPER | GE_BULK | GE_USER,
+ _("Failed to update data for module `%s'\n"),
+ pos);
}
} while (next != NULL);
FREE(dso);
@@ -160,22 +160,22 @@
sec = get;
ent = get;
while ( ( (*ent) != ':') &&
- ( (*ent) != '\0') )
+ ( (*ent) != '\0') )
ent++;
if (*ent == ':') {
*ent = '\0';
ent++;
}
if (YES == GC_have_configuration_value(cfg,
- sec,
- ent)) {
+ sec,
+ ent)) {
GC_get_configuration_value_string(cfg,
- sec,
- ent,
- NULL,
- &val);
+ sec,
+ ent,
+ NULL,
+ &val);
printf("%s\n",
- val);
+ val);
FREE(val);
}
}
@@ -192,10 +192,10 @@
cron = cron_create(ectx);
if (initCore(ectx, cfg, cron, NULL) != OK) {
- GE_LOG(ectx, GE_FATAL | GE_USER | GE_IMMEDIATE,
- _("Core initialization failed.\n"));
-
- return;
+ GE_LOG(ectx, GE_FATAL | GE_USER | GE_IMMEDIATE,
+ _("Core initialization failed.\n"));
+
+ return;
}
/* enforce filesystem limits */
@@ -220,13 +220,13 @@
}
static int set_client_config(CommandLineProcessorContext * ctx,
- void * scls,
- const char * option,
- const char * value) {
+ void * scls,
+ const char * option,
+ const char * value) {
cfgFilename = DEFAULT_CLIENT_CONFIG_FILE;
return OK;
}
-
+
/**
* All gnunet-update command line options
@@ -241,10 +241,10 @@
COMMAND_LINE_OPTION_LOGGING, /* -L */
{ 'u', "user", "LOGIN",
gettext_noop("run as user LOGIN"),
- 1, &gnunet_getopt_configure_set_option, "GNUNETD:USER" },
+ 1, &gnunet_getopt_configure_set_option, "GNUNETD:USER" },
{ 'U', "client", NULL,
gettext_noop("run in client mode (for getting client configuration
values)"),
- 0, &set_client_config, NULL },
+ 0, &set_client_config, NULL },
COMMAND_LINE_OPTION_VERSION(PACKAGE_VERSION), /* -v */
COMMAND_LINE_OPTION_VERBOSE,
COMMAND_LINE_OPTION_END,
@@ -252,17 +252,17 @@
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
char * get;
int ret;
ret = GNUNET_init(argc,
- argv,
- "gnunet-update",
- &cfgFilename,
- gnunetupdateOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunet-update",
+ &cfgFilename,
+ gnunetupdateOptions,
+ &ectx,
+ &cfg);
if ( (ret == -1) ||
(OK != changeUser(ectx, cfg)) ) {
GNUNET_fini(ectx, cfg);
@@ -270,10 +270,10 @@
}
get = NULL;
GC_get_configuration_value_string(cfg,
- "GNUNET-UPDATE",
- "GET",
- "",
- &get);
+ "GNUNET-UPDATE",
+ "GET",
+ "",
+ &get);
if (strlen(get) > 0)
doGet(get);
else
Modified: GNUnet/src/server/gnunetd.c
===================================================================
--- GNUnet/src/server/gnunetd.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/server/gnunetd.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -59,7 +59,7 @@
static void reread_config_helper(void * unused) {
GE_ASSERT(NULL, cfgFilename != NULL);
GC_parse_configuration(cfg,
- cfgFilename);
+ cfgFilename);
}
/**
@@ -68,10 +68,10 @@
*/
static void reread_config() {
cron_add_job(cron,
- &reread_config_helper,
- 1 * cronSECONDS,
- 0,
- NULL);
+ &reread_config_helper,
+ 1 * cronSECONDS,
+ 0,
+ NULL);
}
#endif
@@ -80,14 +80,14 @@
*/
static void waitForSignalHandler(struct GE_Context * ectx) {
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("`%s' startup complete.\n"),
- "gnunetd");
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("`%s' startup complete.\n"),
+ "gnunetd");
GNUNET_SHUTDOWN_WAITFOR();
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_REQUEST,
- _("`%s' is shutting down.\n"),
- "gnunetd");
+ GE_INFO | GE_USER | GE_REQUEST,
+ _("`%s' is shutting down.\n"),
+ "gnunetd");
}
@@ -97,7 +97,7 @@
if (OK != checkPermissions(ectx, cfg))
return SYSERR;
mon = os_network_monitor_create(ectx,
- cfg);
+ cfg);
if (mon == NULL)
return SYSERR;
return OK;
@@ -112,48 +112,48 @@
if ( (NO == debug_flag) &&
(OK != os_terminal_detach(ectx,
- cfg,
- filedes)) )
+ cfg,
+ filedes)) )
return SYSERR;
if (NO != debug_flag)
os_write_pid_file(ectx,
- cfg,
- (unsigned int)getpid());
+ cfg,
+ (unsigned int)getpid());
if (OK != post_detach()) {
if (NO == debug_flag)
os_terminal_detach_complete(ectx,
- filedes,
- NO);
+ filedes,
+ NO);
else
os_delete_pid_file(ectx, cfg);
return SYSERR;
}
cron = cron_create(ectx);
GE_ASSERT(ectx,
- cron != NULL);
+ cron != NULL);
#ifndef WINDOWS
shc_hup = signal_handler_install(SIGHUP,
- &reread_config);
+ &reread_config);
#endif
if (OK != initCore(ectx,
- cfg,
- cron,
- mon)) {
- GE_LOG(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- _("Core initialization failed.\n"));
-
+ cfg,
+ cron,
+ mon)) {
+ GE_LOG(ectx,
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ _("Core initialization failed.\n"));
+
cron_destroy(cron);
os_network_monitor_destroy(mon);
#ifndef WINDOWS
signal_handler_uninstall(SIGHUP,
- &reread_config,
- shc_hup);
+ &reread_config,
+ shc_hup);
#endif
if (NO == debug_flag)
os_terminal_detach_complete(ectx,
- filedes,
- NO);
+ filedes,
+ NO);
return SYSERR;
}
@@ -164,8 +164,8 @@
loadApplicationModules();
if (NO == debug_flag)
os_terminal_detach_complete(ectx,
- filedes,
- YES);
+ filedes,
+ YES);
cron_start(cron);
enableCoreProcessing();
waitForSignalHandler(ectx);
@@ -179,8 +179,8 @@
os_network_monitor_destroy(mon);
#ifndef WINDOWS
signal_handler_uninstall(SIGHUP,
- &reread_config,
- shc_hup);
+ &reread_config,
+ shc_hup);
#endif
cron_destroy(cron);
return OK;
@@ -204,8 +204,8 @@
&gnunet_getopt_configure_set_option, "GNUNETD:WINSERVICE" },
{ 'd', "debug", NULL,
gettext_noop("run in debug mode; gnunetd will "
- "not daemonize and error messages will "
- "be written to stderr instead of a logfile"),
+ "not daemonize and error messages will "
+ "be written to stderr instead of a logfile"),
0, &gnunet_getopt_configure_set_one, &debug_flag },
COMMAND_LINE_OPTION_HELP(gettext_noop("Starts the gnunetd daemon.")), /* -h
*/
COMMAND_LINE_OPTION_LOGGING, /* -L */
@@ -229,22 +229,22 @@
* call the main routine.
*/
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
int ret;
if ( (4 != sizeof(MESSAGE_HEADER)) ||
(600 != sizeof(P2P_hello_MESSAGE)) ) {
fprintf(stderr,
- "Sorry, your C compiler did not properly align the C structs.
Aborting.\n");
+ "Sorry, your C compiler did not properly align the C structs.
Aborting.\n");
return -1;
}
ret = GNUNET_init(argc,
- argv,
- "gnunetd [OPTIONS]",
- &cfgFilename,
- gnunetdOptions,
- &ectx,
- &cfg);
+ argv,
+ "gnunetd [OPTIONS]",
+ &cfgFilename,
+ gnunetdOptions,
+ &ectx,
+ &cfg);
if (ret == -1) {
GNUNET_fini(ectx, cfg);
return 1;
@@ -257,45 +257,45 @@
GE_setDefaultContext(NULL);
GE_free_context(ectx);
GC_get_configuration_value_string(cfg,
- "LOGGING",
- "USER-LEVEL",
- "WARNING",
- &user_log_level);
+ "LOGGING",
+ "USER-LEVEL",
+ "WARNING",
+ &user_log_level);
dev = GC_get_configuration_value_yesno(cfg,
- "LOGGING",
- "DEVELOPER",
- NO);
+ "LOGGING",
+ "DEVELOPER",
+ NO);
ull = GE_getKIND(user_log_level);
ull |= (ull - 1); /* set bits for all lower log-levels */
if (dev == YES)
ull |= GE_DEVELOPER | GE_REQUEST;
if (loud_flag == 1)
ectx = GE_create_context_stderr(YES,
- GE_ALL);
+ GE_ALL);
else
ectx = GE_create_context_stderr(YES,
- GE_USER | GE_ADMIN
- | ull
- | GE_BULK | GE_IMMEDIATE);
+ GE_USER | GE_ADMIN
+ | ull
+ | GE_BULK | GE_IMMEDIATE);
GE_setDefaultContext(ectx);
FREE(user_log_level);
}
setFdLimit(ectx, cfg);
if (OK != checkUpToDate(ectx,
- cfg)) {
+ cfg)) {
GE_LOG(ectx,
- GE_USER | GE_FATAL | GE_IMMEDIATE,
- _("Configuration or GNUnet version changed. You need to run
`%s'!\n"),
- "gnunet-update");
+ GE_USER | GE_FATAL | GE_IMMEDIATE,
+ _("Configuration or GNUnet version changed. You need to run `%s'!\n"),
+ "gnunet-update");
GNUNET_fini(ectx, cfg);
return 1;
}
#ifdef MINGW
if (GC_get_configuration_value_yesno(cfg,
- "GNUNETD",
- "WINSERVICE",
- NO) == YES) {
+ "GNUNETD",
+ "WINSERVICE",
+ NO) == YES) {
SERVICE_TABLE_ENTRY DispatchTable[] =
{{"GNUnet", ServiceMain}, {NULL, NULL}};
ret = (GNStartServiceCtrlDispatcher(DispatchTable) != 0);
Modified: GNUnet/src/server/handler.c
===================================================================
--- GNUnet/src/server/handler.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/server/handler.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -143,7 +143,7 @@
* and updates to the handler list are illegal!
*/
int registerp2pHandler(unsigned short type,
- MessagePartHandler callback) {
+ MessagePartHandler callback) {
unsigned int last;
if (threads_running == YES) {
@@ -154,13 +154,13 @@
if (type >= max_registeredType) {
unsigned int ort = max_registeredType;
GROW(handlers,
- max_registeredType,
- type + 32);
+ max_registeredType,
+ type + 32);
while (ort < max_registeredType) {
unsigned int zero = 0;
GROW(handlers[ort],
- zero,
- 1);
+ zero,
+ 1);
ort++;
}
}
@@ -185,7 +185,7 @@
* and updates to the handler list are illegal!
*/
int unregisterp2pHandler(unsigned short type,
- MessagePartHandler callback) {
+ MessagePartHandler callback) {
unsigned int pos;
unsigned int last;
@@ -197,7 +197,7 @@
if (type < max_registeredType) {
pos = 0;
while ( (handlers[type][pos] != NULL) &&
- (handlers[type][pos] != callback) )
+ (handlers[type][pos] != callback) )
pos++;
last = pos;
while (handlers[type][last] != NULL)
@@ -232,7 +232,7 @@
* and updates to the handler list are illegal!
*/
int registerPlaintextHandler(unsigned short type,
- PlaintextMessagePartHandler callback) {
+ PlaintextMessagePartHandler callback) {
unsigned int last;
if (threads_running == YES) {
@@ -243,13 +243,13 @@
if (type >= plaintextmax_registeredType) {
unsigned int ort = plaintextmax_registeredType;
GROW(plaintextHandlers,
- plaintextmax_registeredType,
- type + 32);
+ plaintextmax_registeredType,
+ type + 32);
while (ort < plaintextmax_registeredType) {
unsigned int zero = 0;
GROW(plaintextHandlers[ort],
- zero,
- 1);
+ zero,
+ 1);
ort++;
}
}
@@ -274,7 +274,7 @@
* and updates to the handler list are illegal!
*/
int unregisterPlaintextHandler(unsigned short type,
- PlaintextMessagePartHandler callback) {
+ PlaintextMessagePartHandler callback) {
unsigned int pos;
unsigned int last;
@@ -286,7 +286,7 @@
if (type < plaintextmax_registeredType) {
pos = 0;
while ( (plaintextHandlers[type][pos] != NULL) &&
- (plaintextHandlers[type][pos] != callback) )
+ (plaintextHandlers[type][pos] != callback) )
pos++;
last = pos;
while (plaintextHandlers[type][last] != NULL)
@@ -321,7 +321,7 @@
* and updates to the handler list are illegal!
*/
int isHandlerRegistered(unsigned short type,
- unsigned short handlerType) {
+ unsigned short handlerType) {
int pos;
int ret;
@@ -338,7 +338,7 @@
while (plaintextHandlers[type][pos] != NULL)
pos++;
if ( (handlerType == 0) ||
- (handlerType == 2) )
+ (handlerType == 2) )
ret += pos;
}
if (type < max_registeredType) {
@@ -346,7 +346,7 @@
while (handlers[type][pos] != NULL)
pos++;
if ( (handlerType == 1) ||
- (handlerType == 2) )
+ (handlerType == 2) )
ret += pos;
}
MUTEX_UNLOCK(handlerLock);
@@ -364,10 +364,10 @@
* @param session NULL if not available
*/
void injectMessage(const PeerIdentity * sender,
- const char * msg,
- unsigned int size,
- int wasEncrypted,
- TSession * session) {
+ const char * msg,
+ unsigned int size,
+ int wasEncrypted,
+ TSession * session) {
unsigned int pos;
const MESSAGE_HEADER * part;
MESSAGE_HEADER cpart;
@@ -387,36 +387,36 @@
FREENONNULL(copy);
copy = NULL;
memcpy(&cpart,
- &msg[pos],
- sizeof(MESSAGE_HEADER));
+ &msg[pos],
+ sizeof(MESSAGE_HEADER));
plen = htons(cpart.size);
if (pos + plen > size) {
if (sender != NULL) {
- IF_GELOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- hash2enc(&sender->hashPubKey,
- &enc));
- GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Received corrupt message from peer `%s'in %s:%d.\n"),
- &enc,
- __FILE__, __LINE__);
+ IF_GELOG(ectx,
+ GE_WARNING | GE_USER | GE_BULK,
+ hash2enc(&sender->hashPubKey,
+ &enc));
+ GE_LOG(ectx,
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Received corrupt message from peer `%s'in %s:%d.\n"),
+ &enc,
+ __FILE__, __LINE__);
} else {
- GE_BREAK(ectx, 0);
+ GE_BREAK(ectx, 0);
}
return;
}
if ( (pos % sizeof(int)) != 0) {
/* correct misalignment; we allow messages to _not_ be a
- multiple of 4 bytes (if absolutely necessary; it should be
- avoided where the cost for doing so is not prohibitive);
- however we also (need to) guaranteed word-alignment for the
- handlers; so we must re-align the message if it is
- misaligned. */
+ multiple of 4 bytes (if absolutely necessary; it should be
+ avoided where the cost for doing so is not prohibitive);
+ however we also (need to) guaranteed word-alignment for the
+ handlers; so we must re-align the message if it is
+ misaligned. */
copy = MALLOC(plen);
memcpy(copy,
- &msg[pos],
- plen);
+ &msg[pos],
+ plen);
part = copy;
} else {
part = (const MESSAGE_HEADER*) &msg[pos];
@@ -427,88 +427,88 @@
#if DEBUG_HANDLER
if (sender != NULL) {
IF_GELOG(ectx,
- GE_DEBUG,
- hash2enc(&sender->hashPubKey,
- &enc));
+ GE_DEBUG,
+ hash2enc(&sender->hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG,
- "Received %s message of type %u from peer `%s'\n",
- wasEncrypted ? "encrypted" : "plaintext",
- ptyp,
- &enc);
+ GE_DEBUG,
+ "Received %s message of type %u from peer `%s'\n",
+ wasEncrypted ? "encrypted" : "plaintext",
+ ptyp,
+ &enc);
}
#endif
if (YES == wasEncrypted) {
MessagePartHandler callback;
if ( (ptyp >= max_registeredType) ||
- (NULL == handlers[ptyp][0]) ) {
- GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "Encrypted message of type '%d' not understood (no handler
registered).\n",
- ptyp);
- continue; /* no handler registered, go to next part */
+ (NULL == handlers[ptyp][0]) ) {
+ GE_LOG(ectx,
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "Encrypted message of type '%d' not understood (no handler
registered).\n",
+ ptyp);
+ continue; /* no handler registered, go to next part */
}
#if MEASURE_TIME
now = get_time();
#endif
last = 0;
while (NULL != (callback = handlers[ptyp][last])) {
- if (SYSERR == callback(sender,
- part)) {
+ if (SYSERR == callback(sender,
+ part)) {
#if DEBUG_HANDLER
- GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Handler aborted message processing after receiving message of
type '%d'.\n",
- ptyp);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Handler aborted message processing after receiving message of type
'%d'.\n",
+ ptyp);
#endif
- FREENONNULL(copy);
- copy = NULL;
- return; /* handler says: do not process the rest of the message */
- }
- last++;
+ FREENONNULL(copy);
+ copy = NULL;
+ return; /* handler says: do not process the rest of the message */
+ }
+ last++;
}
#if MEASURE_TIME
if (ptyp < P2P_PROTO_MAX_USED) {
- time_by_type[ptyp] += get_time() - now;
- count_by_type[ptyp]++;
+ time_by_type[ptyp] += get_time() - now;
+ count_by_type[ptyp]++;
}
#endif
} else { /* isEncrypted == NO */
PlaintextMessagePartHandler callback;
if ( (ptyp >= plaintextmax_registeredType) ||
- (NULL == plaintextHandlers[ptyp][0]) ) {
- GE_LOG(ectx,
- GE_REQUEST | GE_DEBUG | GE_USER,
- "Plaintext message of type '%d' not understood (no handler
registered).\n",
- ptyp);
- continue; /* no handler registered, go to next part */
+ (NULL == plaintextHandlers[ptyp][0]) ) {
+ GE_LOG(ectx,
+ GE_REQUEST | GE_DEBUG | GE_USER,
+ "Plaintext message of type '%d' not understood (no handler
registered).\n",
+ ptyp);
+ continue; /* no handler registered, go to next part */
}
#if MEASURE_TIME
now = get_time();
#endif
last = 0;
while (NULL != (callback = plaintextHandlers[ptyp][last])) {
- if (SYSERR == callback(sender,
- part,
- session)) {
+ if (SYSERR == callback(sender,
+ part,
+ session)) {
#if DEBUG_HANDLER
- GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Handler aborted message processing after receiving message of
type '%d'.\n",
- ptyp);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Handler aborted message processing after receiving message of type
'%d'.\n",
+ ptyp);
#endif
- FREENONNULL(copy);
- copy = NULL;
- return; /* handler says: do not process the rest of the message */
- }
- last++;
+ FREENONNULL(copy);
+ copy = NULL;
+ return; /* handler says: do not process the rest of the message */
+ }
+ last++;
}
#if MEASURE_TIME
if (ptyp < P2P_PROTO_MAX_USED) {
- time_by_type[ptyp] += get_time() - now;
- count_by_type[ptyp]++;
+ time_by_type[ptyp] += get_time() - now;
+ count_by_type[ptyp]++;
}
#endif
@@ -527,22 +527,22 @@
* @param size the size of the message
*/
static void handleMessage(TSession * tsession,
- const PeerIdentity * sender,
- const char * msg,
- unsigned int size) {
+ const PeerIdentity * sender,
+ const char * msg,
+ unsigned int size) {
int ret;
if ( (tsession != NULL) &&
(sender != NULL) &&
(0 != memcmp(sender,
- &tsession->peer,
- sizeof(PeerIdentity))) ) {
+ &tsession->peer,
+ sizeof(PeerIdentity))) ) {
GE_BREAK(NULL, 0);
return;
}
ret = checkHeader(sender,
- (P2P_PACKET_HEADER*) msg,
- size);
+ (P2P_PACKET_HEADER*) msg,
+ size);
if (ret == SYSERR)
return; /* message malformed */
if ( (ret == YES) &&
@@ -551,10 +551,10 @@
(OK == transport->associate(tsession)) )
considerTakeover(sender, tsession);
injectMessage(sender,
- &msg[sizeof(P2P_PACKET_HEADER)],
- size - sizeof(P2P_PACKET_HEADER),
- ret,
- tsession);
+ &msg[sizeof(P2P_PACKET_HEADER)],
+ size - sizeof(P2P_PACKET_HEADER),
+ ret,
+ tsession);
}
/**
@@ -581,9 +581,9 @@
SEMAPHORE_UP(bufferQueueWrite_);
/* handle buffer - now out of sync */
handleMessage(mp->tsession,
- &mp->sender,
- mp->msg,
- mp->size);
+ &mp->sender,
+ mp->msg,
+ mp->size);
if (mp->tsession != NULL)
transport->disconnect(mp->tsession);
FREE(mp->msg);
@@ -600,8 +600,8 @@
void core_receive(P2P_PACKET * mp) {
if ( (mp->tsession != NULL) &&
(0 != memcmp(&mp->sender,
- &mp->tsession->peer,
- sizeof(PeerIdentity))) ) {
+ &mp->tsession->peer,
+ sizeof(PeerIdentity))) ) {
GE_BREAK(NULL, 0);
FREE(mp->msg);
FREE(mp);
@@ -615,12 +615,12 @@
discarded++;
if (0 == discarded % 64)
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- "Accepted: %u discarded: %u blacklisted: %u, ratio: %f\n",
- accepted,
- discarded,
- blacklisted,
- 1.0 * accepted / (blacklisted + discarded + 1));
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ "Accepted: %u discarded: %u blacklisted: %u, ratio: %f\n",
+ accepted,
+ discarded,
+ blacklisted,
+ 1.0 * accepted / (blacklisted + discarded + 1));
if (globalLock_ != NULL)
MUTEX_UNLOCK(globalLock_);
#endif
@@ -630,25 +630,25 @@
#if DEBUG_HANDLER
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- hash2enc(&mp->sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ hash2enc(&mp->sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- "Strictly blacklisted peer `%s' sent message, dropping for now.\n",
- (char*)&enc);
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ "Strictly blacklisted peer `%s' sent message, dropping for now.\n",
+ (char*)&enc);
#endif
#if TRACK_DISCARD
MUTEX_LOCK(globalLock_);
blacklisted++;
if (0 == blacklisted % 64)
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- "Accepted: %u discarded: %u blacklisted: %u, ratio: %f\n",
- accepted,
- discarded,
- blacklisted,
- 1.0 * accepted / (blacklisted + discarded + 1));
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ "Accepted: %u discarded: %u blacklisted: %u, ratio: %f\n",
+ accepted,
+ discarded,
+ blacklisted,
+ 1.0 * accepted / (blacklisted + discarded + 1));
MUTEX_UNLOCK(globalLock_);
#endif
FREE(mp->msg);
@@ -662,9 +662,9 @@
we're shut down! */
#if 0
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- "Discarding message of size %u -- buffer full!\n",
- mp->size);
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ "Discarding message of size %u -- buffer full!\n",
+ mp->size);
#endif
FREE(mp->msg);
FREE(mp);
@@ -674,12 +674,12 @@
discarded++;
if (0 == discarded % 64)
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- "Accepted: %u discarded: %u blacklisted: %u, ratio: %f\n",
- accepted,
- discarded,
- blacklisted,
- 1.0 * accepted / (blacklisted + discarded + 1));
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ "Accepted: %u discarded: %u blacklisted: %u, ratio: %f\n",
+ accepted,
+ discarded,
+ blacklisted,
+ 1.0 * accepted / (blacklisted + discarded + 1));
if (globalLock_ != NULL)
MUTEX_UNLOCK(globalLock_);
#endif
@@ -697,12 +697,12 @@
accepted++;
if (0 == accepted % 64)
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- "Accepted: %u discarded: %u blacklisted: %u, ratio: %f\n",
- accepted,
- discarded,
- blacklisted,
- 1.0 * accepted / (blacklisted + discarded + 1));
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ "Accepted: %u discarded: %u blacklisted: %u, ratio: %f\n",
+ accepted,
+ discarded,
+ blacklisted,
+ 1.0 * accepted / (blacklisted + discarded + 1));
#endif
MUTEX_UNLOCK(globalLock_);
SEMAPHORE_UP(bufferQueueRead_);
@@ -724,12 +724,12 @@
threads_running = YES;
for (i=0;i<THREAD_COUNT;i++) {
threads_[i] = PTHREAD_CREATE(&threadMain,
- &i,
- 128 * 1024);
+ &i,
+ 128 * 1024);
if (threads_[i] == NULL)
GE_LOG_STRERROR(ectx,
- GE_ERROR,
- "pthread_create");
+ GE_ERROR,
+ "pthread_create");
}
}
@@ -797,8 +797,8 @@
last++;
last++;
GROW(handlers[i],
- last,
- 0);
+ last,
+ 0);
}
GROW(handlers,
max_registeredType,
@@ -808,8 +808,8 @@
while (plaintextHandlers[i][last] != NULL)
last++;
GROW(plaintextHandlers[i],
- last,
- 0);
+ last,
+ 0);
}
GROW(plaintextHandlers,
plaintextmax_registeredType,
@@ -823,13 +823,13 @@
if (count_by_type[i] == 0)
continue;
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- "%10u msgs of type %2u took %16llu ms (%llu on average)\n",
- count_by_type[i],
- i,
- time_by_type[i],
- time_by_type[i] / count_by_type[i]);
- }
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ "%10u msgs of type %2u took %16llu ms (%llu on average)\n",
+ count_by_type[i],
+ i,
+ time_by_type[i],
+ time_by_type[i] / count_by_type[i]);
+ }
#endif
}
Modified: GNUnet/src/server/startup.c
===================================================================
--- GNUnet/src/server/startup.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/server/startup.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -51,32 +51,32 @@
* @param sig signal code that causes shutdown, optional
*/
void shutdown_gnunetd(struct GC_Configuration * cfg,
- int sig) {
+ int sig) {
#ifdef MINGW
if (!cfg || GC_get_configuration_value_yesno(cfg,
- "GNUNETD",
- "WINSERVICE",
- NO) == YES) {
+ "GNUNETD",
+ "WINSERVICE",
+ NO) == YES) {
/* If GNUnet runs as service, only the
Service Control Manager is allowed
to kill us. */
if (sig != SERVICE_CONTROL_STOP)
{
- SERVICE_STATUS theStat;
-
- /* Init proper shutdown through the SCM */
- if (GNControlService(hService, SERVICE_CONTROL_STOP, &theStat))
- {
- /* Success */
-
- /* The Service Control Manager will call
- gnunetd.c::ServiceCtrlHandler(), which calls
- this function again. We then stop the gnunetd. */
- return;
- }
- /* We weren't able to tell the SCM to stop the service,
- but we don't care.
- Just shut the gnunetd process down. */
+ SERVICE_STATUS theStat;
+
+ /* Init proper shutdown through the SCM */
+ if (GNControlService(hService, SERVICE_CONTROL_STOP, &theStat))
+ {
+ /* Success */
+
+ /* The Service Control Manager will call
+ gnunetd.c::ServiceCtrlHandler(), which calls
+ this function again. We then stop the gnunetd. */
+ return;
+ }
+ /* We weren't able to tell the SCM to stop the service,
+ but we don't care.
+ Just shut the gnunetd process down. */
}
/* Acknowledge the shutdown request */
@@ -122,17 +122,17 @@
int changeUser(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * user;
user = NULL;
if (0 == GC_get_configuration_value_string(cfg,
- "GNUNETD",
- "USER",
- "",
- &user) && strlen(user)) {
+ "GNUNETD",
+ "USER",
+ "",
+ &user) && strlen(user)) {
if (OK != os_change_user(ectx,
- user)) {
+ user)) {
FREE(user);
return SYSERR;
}
@@ -147,14 +147,14 @@
limit = 0;
if (0 == GC_get_configuration_value_number(cfg,
- "GNUNETD",
- "FDLIMIT",
- 0,
- 65536,
- 1024,
- &limit)) {
+ "GNUNETD",
+ "FDLIMIT",
+ 0,
+ 65536,
+ 1024,
+ &limit)) {
if (OK != os_set_fd_limit(ectx,
- (int)limit)) {
+ (int)limit)) {
return SYSERR;
}
}
@@ -251,20 +251,20 @@
}
int checkPermission(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- const char * def,
- int is_directory,
- int mode) {
+ struct GC_Configuration * cfg,
+ const char * section,
+ const char * option,
+ const char * def,
+ int is_directory,
+ int mode) {
char * fn;
int i;
GC_get_configuration_value_filename(cfg,
- section,
- option,
- def,
- &fn);
+ section,
+ option,
+ def,
+ &fn);
if (is_directory)
disk_directory_create(ectx, fn);
else
@@ -274,17 +274,17 @@
/* adjust check to see if directory is writable */
i = strlen(fn);
while ( (i > 1) &&
- (fn[i] != DIR_SEPARATOR) )
+ (fn[i] != DIR_SEPARATOR) )
i--;
fn[i] = '\0';
mode = X_OK | W_OK;
}
if (0 != ACCESS(fn, mode)) {
GE_LOG(ectx,
- GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- _("Insufficient access permissions for `%s': %s\n"),
- fn,
- STRERROR(errno));
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("Insufficient access permissions for `%s': %s\n"),
+ fn,
+ STRERROR(errno));
FREE(fn);
return SYSERR;
}
@@ -292,20 +292,20 @@
return OK;
}
-#define CHECK(a,b,c,d,e) if (OK != checkPermission(ectx, cfg, a, b, c, d, e))
return SYSERR;
+#define CHECK(a,b,c,d,e) if (OK != checkPermission(ectx, cfg, a, b, c, d, e))
return SYSERR;
int checkPermissions(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
CHECK("PATHS",
- "GNUNETD_HOME",
- "/var/lib/gnunet",
- YES,
- W_OK | X_OK);
+ "GNUNETD_HOME",
+ "/var/lib/gnunet",
+ YES,
+ W_OK | X_OK);
CHECK("GNUNETD",
- "LOGFILE",
- "$GNUNETD_HOME/daemon-logs",
- NO,
- W_OK);
+ "LOGFILE",
+ "$GNUNETD_HOME/daemon-logs",
+ NO,
+ W_OK);
/* these should only be checked if "fs" is actually
loaded; we clearly should not check everything here
that just might be used (MYSQL-CONFIG, F2F-FRIENDS),
@@ -314,15 +314,15 @@
keep things decentralized and still do a nice job
with reporting errors... */
CHECK("FS",
- "DIR",
- "$GNUNETD_HOME/data/fs",
- YES,
- W_OK | X_OK);
+ "DIR",
+ "$GNUNETD_HOME/data/fs",
+ YES,
+ W_OK | X_OK);
CHECK("FS",
- "INDEX-DIRECTORY",
- "$GNUNETD_HOME/data/shared",
- YES,
- W_OK | X_OK);
+ "INDEX-DIRECTORY",
+ "$GNUNETD_HOME/data/shared",
+ YES,
+ W_OK | X_OK);
return OK;
}
Modified: GNUnet/src/server/tcpserver.c
===================================================================
--- GNUnet/src/server/tcpserver.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/server/tcpserver.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -92,7 +92,7 @@
*/
static int isWhitelisted(IPaddr ip) {
return check_ipv4_listed(trustedNetworks_,
- ip);
+ ip);
}
static int shutdownHandler(struct ClientHandle * client,
@@ -101,16 +101,16 @@
if (ntohs(msg->size) != sizeof(MESSAGE_HEADER)) {
GE_LOG(NULL,
- GE_WARNING | GE_USER | GE_BULK,
- _("The `%s' request received from client is malformed.\n"),
- "shutdown");
+ GE_WARNING | GE_USER | GE_BULK,
+ _("The `%s' request received from client is malformed.\n"),
+ "shutdown");
return SYSERR;
}
GE_LOG(NULL,
- GE_INFO | GE_USER | GE_REQUEST,
- "shutdown request accepted from client\n");
+ GE_INFO | GE_USER | GE_REQUEST,
+ "shutdown request accepted from client\n");
ret = sendTCPResultToClient(client,
- OK);
+ OK);
shutdown_gnunetd(cfg, 0);
return ret;
}
@@ -133,8 +133,8 @@
if (exitHandlers[i] == callback) {
exitHandlers[i] = exitHandlers[exitHandlerCount-1];
GROW(exitHandlers,
- exitHandlerCount,
- exitHandlerCount-1);
+ exitHandlerCount,
+ exitHandlerCount-1);
MUTEX_UNLOCK(handlerlock);
return OK;
}
@@ -144,10 +144,10 @@
}
static void * select_accept_handler(void * ah_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- const void * addr,
- unsigned int addr_len) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ const void * addr,
+ unsigned int addr_len) {
struct ClientHandle * session;
IPaddr ip;
struct sockaddr_in * a;
@@ -156,8 +156,8 @@
return NULL;
a = (struct sockaddr_in *) addr;
memcpy(&ip,
- &a->sin_addr,
- sizeof(IPaddr));
+ &a->sin_addr,
+ sizeof(IPaddr));
if (! isWhitelisted(ip))
return NULL;
session = MALLOC(sizeof(ClientHandle));
@@ -166,9 +166,9 @@
}
static void select_close_handler(void * ch_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * sock_ctx) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ void * sock_ctx) {
ClientHandle * session = sock_ctx;
int i;
@@ -187,30 +187,30 @@
* transfer happens asynchronously.
*/
int sendToClient(struct ClientHandle * handle,
- const MESSAGE_HEADER * message) {
+ const MESSAGE_HEADER * message) {
#if DEBUG_TCPHANDLER
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
- "%s: sending reply to client\n",
- __FUNCTION__);
+ GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
+ "%s: sending reply to client\n",
+ __FUNCTION__);
#endif
return select_write(selector,
- handle->sock,
- message,
- NO,
- YES);
+ handle->sock,
+ message,
+ NO,
+ YES);
}
void terminateClientConnection(struct ClientHandle * sock) {
select_disconnect(selector,
- sock->sock);
+ sock->sock);
}
static int select_message_handler(void * mh_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * sock_ctx,
- const MESSAGE_HEADER * msg) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ void * sock_ctx,
+ const MESSAGE_HEADER * msg) {
struct ClientHandle * sender = sock_ctx;
unsigned short ptyp;
CSHandler callback;
@@ -222,21 +222,21 @@
MUTEX_LOCK(handlerlock);
if (ptyp >= max_registeredType) {
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- "%s: Message of type %d not understood: no handler registered\n",
- __FUNCTION__,
- ptyp,
- max_registeredType);
+ GE_INFO | GE_USER | GE_BULK,
+ "%s: Message of type %d not understood: no handler registered\n",
+ __FUNCTION__,
+ ptyp,
+ max_registeredType);
MUTEX_UNLOCK(handlerlock);
return SYSERR;
}
callback = handlers[ptyp];
if (callback == NULL) {
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- "%s: Message of type %d not understood: no handler registered\n",
- __FUNCTION__,
- ptyp);
+ GE_INFO | GE_USER | GE_BULK,
+ "%s: Message of type %d not understood: no handler registered\n",
+ __FUNCTION__,
+ ptyp);
MUTEX_UNLOCK(handlerlock);
return SYSERR;
} else {
@@ -244,13 +244,13 @@
start = get_time();
#endif
if (OK != callback(sender,
- msg)) {
+ msg)) {
#if 0
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- "%s: Message of type %d caused error in handler\n",
- __FUNCTION__,
- ptyp);
+ GE_INFO | GE_USER | GE_BULK,
+ "%s: Message of type %d caused error in handler\n",
+ __FUNCTION__,
+ ptyp);
#endif
MUTEX_UNLOCK(handlerlock);
return SYSERR;
@@ -258,10 +258,10 @@
#if TIME_HANDLERS
if (get_time() - start > cronSECONDS)
GE_LOG(ectx,
- GE_INFO | GE_DEVELOPER | GE_IMMEDIATE,
- "Handling message of type %u took %llu s\n",
- ptyp,
- (get_time()-start) / cronSECONDS);
+ GE_INFO | GE_DEVELOPER | GE_IMMEDIATE,
+ "Handling message of type %u took %llu s\n",
+ ptyp,
+ (get_time()-start) / cronSECONDS);
#endif
}
MUTEX_UNLOCK(handlerlock);
@@ -275,12 +275,12 @@
unsigned long long port;
if (-1 == GC_get_configuration_value_number(cfg,
- "NETWORK",
- "PORT",
- 1,
- 65535,
- 2087,
- &port))
+ "NETWORK",
+ "PORT",
+ 1,
+ 65535,
+ 2087,
+ &port))
port = 0;
return (unsigned short) port;
}
@@ -295,18 +295,18 @@
if (listenerPort == 0)
return SYSERR;
listenerFD = SOCKET(PF_INET,
- SOCK_STREAM,
- 0);
+ SOCK_STREAM,
+ 0);
if (listenerFD < 0) {
GE_LOG_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
- "socket");
+ GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
+ "socket");
return SYSERR;
}
/* fill in the inet address structure */
memset(&serverAddr,
- 0,
- sizeof(serverAddr));
+ 0,
+ sizeof(serverAddr));
serverAddr.sin_family
= AF_INET;
serverAddr.sin_addr.s_addr
@@ -314,47 +314,47 @@
serverAddr.sin_port
= htons(listenerPort);
if ( SETSOCKOPT(listenerFD,
- SOL_SOCKET,
- SO_REUSEADDR,
- &on,
- sizeof(on)) < 0 )
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ &on,
+ sizeof(on)) < 0 )
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "setsockopt");
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "setsockopt");
/* bind the socket */
if (BIND(listenerFD,
- (struct sockaddr *) &serverAddr,
- sizeof(serverAddr)) < 0) {
+ (struct sockaddr *) &serverAddr,
+ sizeof(serverAddr)) < 0) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
- "bind");
+ GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
+ "bind");
GE_LOG(ectx,
- GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
- _("`%s' failed for port %d. Is gnunetd already running?\n"),
- "bind",
- listenerPort);
+ GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
+ _("`%s' failed for port %d. Is gnunetd already running?\n"),
+ "bind",
+ listenerPort);
CLOSE(listenerFD);
return SYSERR;
}
selector = select_create("tcpserver",
- NO,
- ectx,
- NULL,
- listenerFD,
- sizeof(struct sockaddr_in),
- 0, /* no timeout */
- &select_message_handler,
- NULL,
- &select_accept_handler,
- NULL,
- &select_close_handler,
- NULL,
- 0 /* no memory quota */,
- 256 /* max sockets */);
+ NO,
+ ectx,
+ NULL,
+ listenerFD,
+ sizeof(struct sockaddr_in),
+ 0, /* no timeout */
+ &select_message_handler,
+ NULL,
+ &select_accept_handler,
+ NULL,
+ &select_close_handler,
+ NULL,
+ 0 /* no memory quota */,
+ 256 /* max sockets */);
if (selector == NULL) {
CLOSE(listenerFD); /* maybe closed already
- depending on how select_create
- failed... */
+ depending on how select_create
+ failed... */
return SYSERR;
}
return OK;
@@ -363,11 +363,11 @@
int doneTCPServer() {
if (selector != NULL)
stopTCPServer(); /* just to be sure; used mostly
- for the benefit of gnunet-update
- and other gnunet-tools that are
- not gnunetd */
+ for the benefit of gnunet-update
+ and other gnunet-tools that are
+ not gnunetd */
unregisterCSHandler(CS_PROTO_SHUTDOWN_REQUEST,
- &shutdownHandler);
+ &shutdownHandler);
GROW(handlers,
max_registeredType,
0);
@@ -391,7 +391,7 @@
* Initialize the TCP port and listen for incoming client connections.
*/
int initTCPServer(struct GE_Context * e,
- struct GC_Configuration * c) {
+ struct GC_Configuration * c) {
char * ch;
cfg = c;
@@ -400,32 +400,32 @@
/* move to reload-configuration method! */
ch = NULL;
if (-1 == GC_get_configuration_value_string(cfg,
- "NETWORK",
- "TRUSTED",
- "127.0.0.0/8;",
- &ch))
+ "NETWORK",
+ "TRUSTED",
+ "127.0.0.0/8;",
+ &ch))
return SYSERR;
GE_ASSERT(ectx, ch != NULL);
trustedNetworks_ = parse_ipv4_network_specification(ectx,
- ch);
+ ch);
if (trustedNetworks_ == NULL) {
GE_LOG(ectx,
- GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- _("Malformed network specification in the configuration in section
`%s' for entry `%s': %s\n"),
- "NETWORK",
- "TRUSTED",
- ch);
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("Malformed network specification in the configuration in section `%s'
for entry `%s': %s\n"),
+ "NETWORK",
+ "TRUSTED",
+ ch);
FREE(ch);
return SYSERR;
}
FREE(ch);
registerCSHandler(CS_PROTO_SHUTDOWN_REQUEST,
- &shutdownHandler);
+ &shutdownHandler);
if ( (NO == GC_get_configuration_value_yesno(cfg,
- "TCPSERVER",
- "DISABLE",
- NO)) &&
+ "TCPSERVER",
+ "DISABLE",
+ NO)) &&
(OK != startTCPServer()) ) {
doneTCPServer();
return SYSERR;
@@ -456,22 +456,22 @@
* handler for that type
*/
int registerCSHandler(unsigned short type,
- CSHandler callback) {
+ CSHandler callback) {
MUTEX_LOCK(handlerlock);
if (type < max_registeredType) {
if (handlers[type] != NULL) {
MUTEX_UNLOCK(handlerlock);
GE_LOG(ectx,
- GE_WARNING | GE_DEVELOPER | GE_BULK,
- _("%s failed, message type %d already in use.\n"),
- __FUNCTION__,
- type);
+ GE_WARNING | GE_DEVELOPER | GE_BULK,
+ _("%s failed, message type %d already in use.\n"),
+ __FUNCTION__,
+ type);
return SYSERR;
}
} else
GROW(handlers,
- max_registeredType,
- type + 8);
+ max_registeredType,
+ type + 8);
handlers[type] = callback;
MUTEX_UNLOCK(handlerlock);
return OK;
@@ -490,7 +490,7 @@
* handler for that type
*/
int unregisterCSHandler(unsigned short type,
- CSHandler callback) {
+ CSHandler callback) {
MUTEX_LOCK(handlerlock);
if (type < max_registeredType) {
if (handlers[type] != callback) {
@@ -516,7 +516,7 @@
* send successfully
*/
int sendTCPResultToClient(struct ClientHandle * sock,
- int ret) {
+ int ret) {
RETURN_VALUE_MESSAGE rv;
rv.header.size
@@ -526,7 +526,7 @@
rv.return_value
= htonl(ret);
return sendToClient(sock,
- &rv.header);
+ &rv.header);
}
/**
@@ -538,8 +538,8 @@
* send successfully
*/
int sendTCPErrorToClient(struct ClientHandle * sock,
- GE_KIND kind,
- const char * message) {
+ GE_KIND kind,
+ const char * message) {
RETURN_ERROR_MESSAGE * rv;
size_t msgLen;
int ret;
@@ -550,8 +550,8 @@
msgLen = 60000;
rv = MALLOC(sizeof(RETURN_ERROR_MESSAGE) + msgLen);
memset(rv,
- 0,
- sizeof(RETURN_ERROR_MESSAGE) + msgLen);
+ 0,
+ sizeof(RETURN_ERROR_MESSAGE) + msgLen);
rv->header.size
= htons(sizeof(MESSAGE_HEADER) + msgLen);
rv->header.type
@@ -559,14 +559,14 @@
rv->kind
= htonl(kind);
memcpy(&rv[1],
- message,
- strlen(message));
+ message,
+ strlen(message));
ret = sendToClient(sock,
- &rv->header);
+ &rv->header);
FREE(rv);
return ret;
}
-
+
/**
* Check if a handler is registered for a given
* message type.
@@ -591,22 +591,22 @@
static void confirmClientLogContext(void * ctx) { }
static void logClientLogContext(void * ctx,
- GE_KIND kind,
- const char * date,
- const char * msg) {
+ GE_KIND kind,
+ const char * date,
+ const char * msg) {
sendTCPErrorToClient(ctx,
- kind,
- msg);
+ kind,
+ msg);
}
struct GE_Context *
createClientLogContext(GE_KIND mask,
- struct ClientHandle * handle) {
+ struct ClientHandle * handle) {
return GE_create_context_callback(mask,
- &logClientLogContext,
- handle,
- &freeClientLogContext,
- &confirmClientLogContext);
+ &logClientLogContext,
+ handle,
+ &freeClientLogContext,
+ &confirmClientLogContext);
}
/* end of tcpserver.c */
Modified: GNUnet/src/server/version.c
===================================================================
--- GNUnet/src/server/version.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/server/version.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -39,9 +39,9 @@
* configuration file.
*/
static void dyncat(struct GC_Configuration * cfg,
- char ** string,
- const char * section,
- const char * part) {
+ char ** string,
+ const char * section,
+ const char * part) {
int len;
char * tmp;
char * val;
@@ -51,10 +51,10 @@
len += strlen(part) + 1;
val = NULL;
GC_get_configuration_value_string(cfg,
- section,
- part,
- "",
- &val);
+ section,
+ part,
+ "",
+ &val);
if (val == NULL)
val = STRDUP("");
len += strlen(val) + 2;
@@ -80,7 +80,7 @@
* require us to run gnunet-update!
*/
static void getVersionHash(struct GC_Configuration * cfg,
- EncName * enc) {
+ EncName * enc) {
HashCode512 hc;
char * string;
@@ -91,17 +91,17 @@
simple alternative would be to require gnunet-update for any
configuration change, but that again would be too strict. */
dyncat(cfg,
- &string,
- "GNUNETD",
- "APPLICATIONS");
+ &string,
+ "GNUNETD",
+ "APPLICATIONS");
dyncat(cfg,
- &string,
- "FS",
- "QUOTA");
+ &string,
+ "FS",
+ "QUOTA");
dyncat(cfg,
- &string,
- "MODULES",
- "sqstore");
+ &string,
+ "MODULES",
+ "sqstore");
hash(string,
strlen(string),
&hc);
@@ -110,16 +110,16 @@
}
static char * getVersionFileName(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * en;
char * cn;
en = NULL;
if (-1 == GC_get_configuration_value_filename(cfg,
- "GNUNETD",
- "GNUNETD_HOME",
- VAR_DAEMON_DIRECTORY,
- &en))
+ "GNUNETD",
+ "GNUNETD_HOME",
+ VAR_DAEMON_DIRECTORY,
+ &en))
return NULL;
GE_ASSERT(ectx, en != NULL);
cn = MALLOC(strlen(en) + strlen(VERSIONFILE) + 1);
@@ -139,7 +139,7 @@
* @return OK if we are
*/
int checkUpToDate(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char version[MAX_VS];
int len;
EncName enc;
@@ -148,36 +148,36 @@
fn = getVersionFileName(ectx, cfg);
if (fn == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("Failed to determine filename used to store GNUnet version
information!\n"));
+ GE_ERROR | GE_USER | GE_BULK,
+ _("Failed to determine filename used to store GNUnet version
information!\n"));
return OK; /* uh uh */
}
if (disk_file_test(ectx,
- fn) != YES) {
+ fn) != YES) {
FREE(fn);
upToDate(ectx, cfg); /* first start */
return OK;
}
len = disk_file_read(ectx,
- fn,
- MAX_VS,
- version);
+ fn,
+ MAX_VS,
+ version);
FREE(fn);
if (len == -1) { /* should never happen -- file should exist */
upToDate(ectx,
- cfg); /* first start */
+ cfg); /* first start */
return OK;
}
if ( (len != strlen(VERSION) + 1 + sizeof(EncName)) ||
(0 != memcmp(VERSION,
- version,
- strlen(VERSION)+1)) )
+ version,
+ strlen(VERSION)+1)) )
return SYSERR; /* wrong version */
getVersionHash(cfg,
- &enc);
+ &enc);
if (0 != memcmp(&enc,
- &version[strlen(VERSION)+1],
- sizeof(EncName)))
+ &version[strlen(VERSION)+1],
+ sizeof(EncName)))
return SYSERR; /* wrong hash */
return OK;
}
@@ -187,7 +187,7 @@
* Writes the version tag
*/
void upToDate(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char version[MAX_VS];
int len;
EncName enc;
@@ -198,17 +198,17 @@
GE_ASSERT(ectx, len < MAX_VS);
memcpy(version, VERSION, strlen(VERSION)+1);
getVersionHash(cfg,
- &enc);
+ &enc);
memcpy(&version[strlen(VERSION)+1],
- &enc,
- sizeof(EncName));
+ &enc,
+ sizeof(EncName));
UNLINK(fn);
disk_file_write(ectx,
- fn,
- version,
- len,
- "600");
+ fn,
+ version,
+ len,
+ "600");
FREE(fn);
}
-
+
/* end of version.c */
Modified: GNUnet/src/setup/gnunet-setup.c
===================================================================
--- GNUnet/src/setup/gnunet-setup.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/gnunet-setup.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -33,13 +33,13 @@
#include "platform.h"
typedef int (*ConfigurationPluginMain)(int argc,
- char * const * argv,
- struct PluginHandle * self,
- struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct GNS_Context * gns,
- const char * filename,
- int is_daemon);
+ char * const * argv,
+ struct PluginHandle * self,
+ struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ struct GNS_Context * gns,
+ const char * filename,
+ int is_daemon);
static int config_daemon;
@@ -82,37 +82,37 @@
(pos->option == NULL) )
return;
if (NO == GC_have_configuration_value(cfg,
- pos->section,
- pos->option)) {
+ pos->section,
+ pos->option)) {
val = GNS_get_default_value_as_string(pos->type,
- &pos->value);
+ &pos->value);
if (val != NULL) {
GC_set_configuration_value_string(cfg,
- ectx,
- pos->section,
- pos->option,
- val);
+ ectx,
+ pos->section,
+ pos->option,
+ val);
FREE(val);
}
}
}
static int dyn_config(const char * module,
- const char * mainfunc,
- int argc,
- char * const * argv,
- const char * filename) {
+ const char * mainfunc,
+ int argc,
+ char * const * argv,
+ const char * filename) {
ConfigurationPluginMain mptr;
struct PluginHandle * library;
library = os_plugin_load(ectx,
- "libgnunet",
- module);
+ "libgnunet",
+ module);
if (!library)
return SYSERR;
mptr = os_plugin_resolve_function(library,
- mainfunc,
- YES);
+ mainfunc,
+ YES);
if (! mptr) {
os_plugin_unload(library);
return SYSERR;
@@ -156,7 +156,7 @@
int main(int argc,
- char * const * argv) {
+ char * const * argv) {
const char * operation;
int done;
char * dirname;
@@ -164,19 +164,19 @@
int i;
ectx = GE_create_context_stderr(NO,
- GE_WARNING | GE_ERROR | GE_FATAL |
- GE_USER | GE_ADMIN | GE_DEVELOPER |
- GE_IMMEDIATE | GE_BULK);
+ GE_WARNING | GE_ERROR | GE_FATAL |
+ GE_USER | GE_ADMIN | GE_DEVELOPER |
+ GE_IMMEDIATE | GE_BULK);
GE_setDefaultContext(ectx);
os_init(ectx);
cfg = GC_create_C_impl();
GE_ASSERT(ectx, cfg != NULL);
i = gnunet_parse_options(INFO,
- ectx,
- cfg,
- gnunetsetupOptions,
- (unsigned int) argc,
- argv);
+ ectx,
+ cfg,
+ gnunetsetupOptions,
+ (unsigned int) argc,
+ argv);
if (i < 0) {
GC_free(cfg);
GE_free_context(ectx);
@@ -185,12 +185,12 @@
if (i != argc - 1) {
if (i < argc - 1) {
fprintf(stderr,
- _("Too many arguments.\n"));
+ _("Too many arguments.\n"));
return -1;
}
GE_LOG(ectx,
- GE_WARNING | GE_REQUEST | GE_USER,
- _("No interface specified, using default\n"));
+ GE_WARNING | GE_REQUEST | GE_USER,
+ _("No interface specified, using default\n"));
operation = "config";
#if HAVE_DIALOG
operation = "menuconfig";
@@ -221,17 +221,17 @@
}
disk_directory_create(ectx, dirname);
if ( ( (0 != ACCESS(cfgFilename, W_OK)) &&
- ( (errno != ENOENT) ||
- (0 != ACCESS(dirname, W_OK))) ) )
+ ( (errno != ENOENT) ||
+ (0 != ACCESS(dirname, W_OK))) ) )
GE_DIE_STRERROR_FILE(ectx,
- GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "access",
- dirname);
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "access",
+ dirname);
FREE(dirname);
if (0 == ACCESS(cfgFilename, F_OK))
GC_parse_configuration(cfg,
- cfgFilename);
+ cfgFilename);
dirname = os_get_installation_path(IPK_DATADIR);
GE_ASSERT(ectx, dirname != NULL);
specname = MALLOC(strlen(dirname) + strlen("config-daemon.scm") + 1);
@@ -242,8 +242,8 @@
else
strcat(specname, "config-client.scm");
gns = GNS_load_specification(ectx,
- cfg,
- specname);
+ cfg,
+ specname);
FREE(specname);
if (gns == NULL) {
GC_free(cfg);
@@ -256,24 +256,24 @@
done = NO;
i = 0;
while ( (done == NO) &&
- (modules[i] != NULL) ) {
+ (modules[i] != NULL) ) {
if (strcmp(operation, modules[i]) == 0) {
if (dyn_config(modules[i+1],
- modules[i+2],
- argc,
- argv,
- cfgFilename) != YES) {
- GE_LOG(ectx,
- GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- _("`%s' is not available."),
- operation);
- GNS_free_specification(gns);
- GC_free(cfg);
- GE_free_context(ectx);
- FREE(cfgFilename);
- return -1;
+ modules[i+2],
+ argc,
+ argv,
+ cfgFilename) != YES) {
+ GE_LOG(ectx,
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("`%s' is not available."),
+ operation);
+ GNS_free_specification(gns);
+ GC_free(cfg);
+ GE_free_context(ectx);
+ FREE(cfgFilename);
+ return -1;
} else {
- done = YES;
+ done = YES;
}
}
i += 3;
@@ -281,10 +281,10 @@
FREE(cfgFilename);
if (done == NO) {
fprintf(stderr,
- _("Unknown operation `%s'\n"),
- operation);
+ _("Unknown operation `%s'\n"),
+ operation);
fprintf(stderr,
- _("Use --help to get a list of options.\n"));
+ _("Use --help to get a list of options.\n"));
GNS_free_specification(gns);
GC_free(cfg);
GE_free_context(ectx);
Modified: GNUnet/src/setup/gnunet-win-tool.c
===================================================================
--- GNUnet/src/setup/gnunet-win-tool.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/gnunet-win-tool.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -115,26 +115,26 @@
*/
void Install()
{
- switch(InstallAsService(NULL))
- {
- case 0:
- printf(_("GNUnet service installed successfully.\n"));
- break;
- case 1:
- printf(_("This version of Windows doesn't support
services.\n"));
- break;
- case 2:
- SetErrnoFromWinError(GetLastError());
- printf(_("Error: can't open Service Control Manager: %s\n"),
- _win_strerror(errno));
- break;
- case 3:
- SetErrnoFromWinError(GetLastError());
- printf(_("Error: can't create service: %s\n"),
_win_strerror(errno));
- break;
- default:
- printf(_("Unknown error.\n"));
- }
+ switch(InstallAsService(NULL))
+ {
+ case 0:
+ printf(_("GNUnet service installed successfully.\n"));
+ break;
+ case 1:
+ printf(_("This version of Windows doesn't support
services.\n"));
+ break;
+ case 2:
+ SetErrnoFromWinError(GetLastError());
+ printf(_("Error: can't open Service Control Manager: %s\n"),
+ _win_strerror(errno));
+ break;
+ case 3:
+ SetErrnoFromWinError(GetLastError());
+ printf(_("Error: can't create service: %s\n"), _win_strerror(errno));
+ break;
+ default:
+ printf(_("Unknown error.\n"));
+ }
}
/**
@@ -142,30 +142,30 @@
*/
void Uninstall()
{
- switch(UninstallService())
- {
- case 0:
- printf(_("Service deleted.\n"));
- break;
- case 1:
- printf(_("This version of Windows doesn't support
services.\n"));
- break;
- case 2:
- SetErrnoFromWinError(GetLastError());
- printf(_("Error: can't open Service Control Manager: %s\n"),
- _win_strerror(errno));
- break;
- case 3:
- SetErrnoFromWinError(GetLastError());
- printf(_("Error: can't access service: %s\n"),
_win_strerror(errno));
- break;
- case 4:
- SetErrnoFromWinError(GetLastError());
- printf(_("Error: can't delete service: %s\n"),
_win_strerror(errno));
- break;
- default:
- printf(_("Unknown error.\n"));
- }
+ switch(UninstallService())
+ {
+ case 0:
+ printf(_("Service deleted.\n"));
+ break;
+ case 1:
+ printf(_("This version of Windows doesn't support
services.\n"));
+ break;
+ case 2:
+ SetErrnoFromWinError(GetLastError());
+ printf(_("Error: can't open Service Control Manager: %s\n"),
+ _win_strerror(errno));
+ break;
+ case 3:
+ SetErrnoFromWinError(GetLastError());
+ printf(_("Error: can't access service: %s\n"), _win_strerror(errno));
+ break;
+ case 4:
+ SetErrnoFromWinError(GetLastError());
+ printf(_("Error: can't delete service: %s\n"), _win_strerror(errno));
+ break;
+ default:
+ printf(_("Unknown error.\n"));
+ }
}
void PatchSys(char *szFn)
@@ -174,7 +174,7 @@
unsigned long lMem;
char *pMem;
int iCrc;
-
+
pFile = fopen(szFn, "r+b");
if (!pFile)
{
@@ -207,11 +207,11 @@
memcpy(pMem + 0x4F322, chunk2, 4);
break;
case 3886810835:
- memcpy(pMem + 0x130, chunk3, 4);
+ memcpy(pMem + 0x130, chunk3, 4);
memcpy(pMem + 0x4f5a2, chunk2, 4);
break;
case 3246854107:
- memcpy(pMem + 0x130, chunk4, 4);
+ memcpy(pMem + 0x130, chunk4, 4);
memcpy(pMem + 0x4f5a2, chunk2, 4);
break;
case 2437296753:
Modified: GNUnet/src/setup/gtk/about.c
===================================================================
--- GNUnet/src/setup/gtk/about.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/gtk/about.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -33,7 +33,7 @@
* This displays an about window
*/
void on_aboutButton_activatesetup_gtk(GtkWidget * dummy,
- gpointer data) {
+ gpointer data) {
GtkWidget * ad;
GladeXML * axml;
@@ -41,7 +41,7 @@
= load_xml("aboutdialog");
ad
= glade_xml_get_widget(axml,
- "aboutdialog");
+ "aboutdialog");
gtk_dialog_run(GTK_DIALOG(ad));
g_object_unref(axml);
}
Modified: GNUnet/src/setup/gtk/gconf.c
===================================================================
--- GNUnet/src/setup/gtk/gconf.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/gtk/gconf.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -63,8 +63,8 @@
static const char * cfg_filename;
static void addToTree(GtkTreeStore * model,
- GtkTreeIter * parent,
- struct GNS_Tree * pos) {
+ GtkTreeIter * parent,
+ struct GNS_Tree * pos) {
GtkTreeIter it;
GtkTreeIter it2;
int i;
@@ -79,35 +79,35 @@
if (! pos->visible)
return;
gtk_tree_store_append(model,
- &it,
- parent);
+ &it,
+ parent);
gtk_tree_store_set(model,
- &it,
- SETUP_SECTION, pos->section,
- SETUP_OPTION, pos->option,
- SETUP_TREENODE, pos,
- SETUP_ZERO, 0,
- SETUP_FALSE, FALSE,
- SETUP_TRUE, TRUE,
- SETUP_DWIDTH, 120,
- SETUP_HWIDTH, 400,
- SETUP_WRAP, PANGO_WRAP_WORD_CHAR,
- SETUP_EDIT_BGCOLOR, "yellow",
- SETUP_DEFAULT_VALUE, "",
- SETUP_TEXT_VALUE, "",
- SETUP_COMBO_MODEL, no_model,
- SETUP_TEXT_VIS, FALSE,
- SETUP_COMBO_VIS, FALSE,
- SETUP_DESCRIPTION, pos->description,
- SETUP_HELPTEXT, pos->help,
- -1);
+ &it,
+ SETUP_SECTION, pos->section,
+ SETUP_OPTION, pos->option,
+ SETUP_TREENODE, pos,
+ SETUP_ZERO, 0,
+ SETUP_FALSE, FALSE,
+ SETUP_TRUE, TRUE,
+ SETUP_DWIDTH, 120,
+ SETUP_HWIDTH, 400,
+ SETUP_WRAP, PANGO_WRAP_WORD_CHAR,
+ SETUP_EDIT_BGCOLOR, "yellow",
+ SETUP_DEFAULT_VALUE, "",
+ SETUP_TEXT_VALUE, "",
+ SETUP_COMBO_MODEL, no_model,
+ SETUP_TEXT_VIS, FALSE,
+ SETUP_COMBO_VIS, FALSE,
+ SETUP_DESCRIPTION, pos->description,
+ SETUP_HELPTEXT, pos->help,
+ -1);
switch (pos->type & GNS_KindMask) {
case GNS_Node:
i = 0;
while (pos->children[i] != NULL) {
addToTree(model,
- &it,
- pos->children[i]);
+ &it,
+ pos->children[i]);
i++;
}
break;
@@ -115,179 +115,179 @@
switch (pos->type & GNS_TypeMask) {
case GNS_Boolean:
cmodel = gtk_list_store_new(1,
- G_TYPE_STRING);
+ G_TYPE_STRING);
gtk_list_store_insert_with_values(cmodel,
- &it2,
- -1,
- 0, "YES",
- -1);
+ &it2,
+ -1,
+ 0, "YES",
+ -1);
gtk_list_store_insert_with_values(cmodel,
- &it2,
- -1,
- 0, "NO",
- -1);
+ &it2,
+ -1,
+ 0, "NO",
+ -1);
gtk_tree_store_set(model,
- &it,
- SETUP_COMBO_MODEL, cmodel,
- SETUP_COMBO_VIS, TRUE,
- SETUP_DEFAULT_VALUE, pos->value.Boolean.def ? "YES" :
"NO",
- SETUP_TEXT_VALUE, pos->value.Boolean.val ? "YES" :
"NO",
- -1);
+ &it,
+ SETUP_COMBO_MODEL, cmodel,
+ SETUP_COMBO_VIS, TRUE,
+ SETUP_DEFAULT_VALUE, pos->value.Boolean.def ? "YES" : "NO",
+ SETUP_TEXT_VALUE, pos->value.Boolean.val ? "YES" : "NO",
+ -1);
break;
case GNS_String:
cmodel = gtk_list_store_new(1,
- G_TYPE_STRING);
+ G_TYPE_STRING);
gtk_tree_store_set(model,
- &it,
- SETUP_DEFAULT_VALUE, pos->value.String.def,
- SETUP_TEXT_VALUE, pos->value.String.val,
- SETUP_COMBO_MODEL, cmodel,
- -1);
+ &it,
+ SETUP_DEFAULT_VALUE, pos->value.String.def,
+ SETUP_TEXT_VALUE, pos->value.String.val,
+ SETUP_COMBO_MODEL, cmodel,
+ -1);
i = 0;
while (pos->value.String.legalRange[i] != NULL) {
- gtk_list_store_insert_with_values(cmodel,
- &it2,
- -1,
- 0, pos->value.String.legalRange[i],
- -1);
- i++;
+ gtk_list_store_insert_with_values(cmodel,
+ &it2,
+ -1,
+ 0, pos->value.String.legalRange[i],
+ -1);
+ i++;
}
gtk_tree_store_set(model,
- &it,
- SETUP_TEXT_VIS, TRUE,
- SETUP_COMBO_VIS, TRUE,
- -1);
+ &it,
+ SETUP_TEXT_VIS, TRUE,
+ SETUP_COMBO_VIS, TRUE,
+ -1);
break;
case GNS_MC:
cmodel = gtk_list_store_new(1,
- G_TYPE_STRING);
+ G_TYPE_STRING);
gtk_tree_store_set(model,
- &it,
- SETUP_DEFAULT_VALUE, pos->value.String.def,
- SETUP_TEXT_VALUE, pos->value.String.val,
- SETUP_COMBO_MODEL, cmodel,
- -1);
+ &it,
+ SETUP_DEFAULT_VALUE, pos->value.String.def,
+ SETUP_TEXT_VALUE, pos->value.String.val,
+ SETUP_COMBO_MODEL, cmodel,
+ -1);
i = 0;
j = 1;
tmpl = 2;
while (pos->value.String.legalRange[i] != NULL) {
- tmpl += strlen(pos->value.String.legalRange[i]) + 1;
- i++;
- j *= 2;
+ tmpl += strlen(pos->value.String.legalRange[i]) + 1;
+ i++;
+ j *= 2;
}
tmp = MALLOC(tmpl);
/* For now, only allow multiple choice for less than 12 entries...
- (10 are needed for applications!) */
+ (10 are needed for applications!) */
if (i < 12) {
- while (--j >= 0) {
- tmp[0] = '\0';
- for (k=0;k<i;k++) {
- if ((j & (1 << k)) == 0)
- continue;
- strcat(tmp, pos->value.String.legalRange[k]);
- strcat(tmp, " ");
- }
- if (strlen(tmp) > 0)
- tmp[strlen(tmp)-1] = '\0';
- gtk_list_store_insert_with_values(cmodel,
- &it2,
- -1,
- 0, tmp,
- -1);
- }
+ while (--j >= 0) {
+ tmp[0] = '\0';
+ for (k=0;k<i;k++) {
+ if ((j & (1 << k)) == 0)
+ continue;
+ strcat(tmp, pos->value.String.legalRange[k]);
+ strcat(tmp, " ");
+ }
+ if (strlen(tmp) > 0)
+ tmp[strlen(tmp)-1] = '\0';
+ gtk_list_store_insert_with_values(cmodel,
+ &it2,
+ -1,
+ 0, tmp,
+ -1);
+ }
} else {
- fprintf(stderr,
- "Too many choices in multiple choice for `%s': %d\n",
- pos->option,
- i);
- GE_BREAK(NULL, 0);
+ fprintf(stderr,
+ "Too many choices in multiple choice for `%s': %d\n",
+ pos->option,
+ i);
+ GE_BREAK(NULL, 0);
}
FREE(tmp);
gtk_tree_store_set(model,
- &it,
- SETUP_TEXT_VIS, TRUE,
- SETUP_COMBO_VIS, TRUE,
- -1);
+ &it,
+ SETUP_TEXT_VIS, TRUE,
+ SETUP_COMBO_VIS, TRUE,
+ -1);
break;
case GNS_SC:
cmodel = gtk_list_store_new(1,
- G_TYPE_STRING);
+ G_TYPE_STRING);
gtk_tree_store_set(model,
- &it,
- SETUP_DEFAULT_VALUE, pos->value.String.def,
- SETUP_TEXT_VALUE, pos->value.String.val,
- SETUP_COMBO_MODEL, cmodel,
- -1);
+ &it,
+ SETUP_DEFAULT_VALUE, pos->value.String.def,
+ SETUP_TEXT_VALUE, pos->value.String.val,
+ SETUP_COMBO_MODEL, cmodel,
+ -1);
i = 0;
while (pos->value.String.legalRange[i] != NULL) {
- gtk_list_store_insert_with_values(cmodel,
- &it2,
- -1,
- 0, pos->value.String.legalRange[i],
- -1);
- i++;
+ gtk_list_store_insert_with_values(cmodel,
+ &it2,
+ -1,
+ 0, pos->value.String.legalRange[i],
+ -1);
+ i++;
}
gtk_tree_store_set(model,
- &it,
- SETUP_COMBO_VIS, TRUE,
- -1);
+ &it,
+ SETUP_COMBO_VIS, TRUE,
+ -1);
break;
case GNS_Double:
cmodel = gtk_list_store_new(1,
- G_TYPE_STRING);
+ G_TYPE_STRING);
SNPRINTF(defStr, 128, "%f", pos->value.Double.def);
SNPRINTF(valStr, 128, "%f", pos->value.Double.val);
gtk_list_store_insert_with_values(cmodel,
- &it2,
- -1,
- 0, valStr,
- -1);
+ &it2,
+ -1,
+ 0, valStr,
+ -1);
if (0 != strcmp(valStr, defStr)) {
- gtk_list_store_insert_with_values(cmodel,
- &it2,
- -1,
- 0, valStr,
- -1);
+ gtk_list_store_insert_with_values(cmodel,
+ &it2,
+ -1,
+ 0, valStr,
+ -1);
}
gtk_tree_store_set(model,
- &it,
- SETUP_DEFAULT_VALUE, defStr,
- SETUP_TEXT_VALUE, valStr,
- SETUP_COMBO_VIS, TRUE,
- SETUP_TEXT_VIS, TRUE,
- SETUP_COMBO_MODEL, cmodel,
- -1);
+ &it,
+ SETUP_DEFAULT_VALUE, defStr,
+ SETUP_TEXT_VALUE, valStr,
+ SETUP_COMBO_VIS, TRUE,
+ SETUP_TEXT_VIS, TRUE,
+ SETUP_COMBO_MODEL, cmodel,
+ -1);
break;
case GNS_UInt64:
cmodel = gtk_list_store_new(1,
- G_TYPE_STRING);
+ G_TYPE_STRING);
SNPRINTF(defStr, 128, "%llu", pos->value.UInt64.def);
SNPRINTF(valStr, 128, "%llu", pos->value.UInt64.val);
gtk_list_store_insert_with_values(cmodel,
- &it2,
- -1,
- 0, valStr,
- -1);
+ &it2,
+ -1,
+ 0, valStr,
+ -1);
if (0 != strcmp(valStr, defStr)) {
- gtk_list_store_insert_with_values(cmodel,
- &it2,
- -1,
- 0, valStr,
- -1);
+ gtk_list_store_insert_with_values(cmodel,
+ &it2,
+ -1,
+ 0, valStr,
+ -1);
}
gtk_tree_store_set(model,
- &it,
- SETUP_DEFAULT_VALUE, defStr,
- SETUP_COMBO_VIS, TRUE,
- SETUP_TEXT_VALUE, valStr,
- SETUP_TEXT_VIS, TRUE,
- SETUP_COMBO_MODEL, cmodel,
- -1);
+ &it,
+ SETUP_DEFAULT_VALUE, defStr,
+ SETUP_COMBO_VIS, TRUE,
+ SETUP_TEXT_VALUE, valStr,
+ SETUP_TEXT_VIS, TRUE,
+ SETUP_COMBO_MODEL, cmodel,
+ -1);
break;
default:
GE_ASSERT(NULL, 0);
gtk_tree_store_remove(model,
- &it);
+ &it);
return;
}
break;
@@ -295,9 +295,9 @@
default:
GE_ASSERT(NULL, 0);
gtk_tree_store_remove(model,
- &it);
+ &it);
return;
- }
+ }
}
typedef struct {
@@ -306,8 +306,8 @@
} CR_Context;
static void collectRows(GtkTreeView * tree_view,
- GtkTreePath * path,
- gpointer user_data) {
+ GtkTreePath * path,
+ gpointer user_data) {
CR_Context * ctx = user_data;
GROW(ctx->paths,
@@ -326,30 +326,30 @@
/* create new model */
model = gtk_tree_store_new(SETUP_NUM,
- G_TYPE_STRING, /* section */
- G_TYPE_STRING, /* option */
- G_TYPE_POINTER, /* node */
- G_TYPE_INT, /* always 0 */
- G_TYPE_BOOLEAN, /* always FALSE */
- G_TYPE_BOOLEAN, /* always TRUE */
- G_TYPE_INT, /* dwidth */
- G_TYPE_INT, /* hwidth */
- G_TYPE_INT, /* wrap */
- G_TYPE_STRING, /* edit bg color */
- G_TYPE_STRING, /* default value */
- G_TYPE_STRING, /* current text value */
- GTK_TYPE_LIST_STORE, /* combo model */
- G_TYPE_BOOLEAN, /* text visible? */
- G_TYPE_BOOLEAN, /* combo visible? */
- G_TYPE_STRING, /* description */
- G_TYPE_STRING); /* help text */
+ G_TYPE_STRING, /* section */
+ G_TYPE_STRING, /* option */
+ G_TYPE_POINTER, /* node */
+ G_TYPE_INT, /* always 0 */
+ G_TYPE_BOOLEAN, /* always FALSE */
+ G_TYPE_BOOLEAN, /* always TRUE */
+ G_TYPE_INT, /* dwidth */
+ G_TYPE_INT, /* hwidth */
+ G_TYPE_INT, /* wrap */
+ G_TYPE_STRING, /* edit bg color */
+ G_TYPE_STRING, /* default value */
+ G_TYPE_STRING, /* current text value */
+ GTK_TYPE_LIST_STORE, /* combo model */
+ G_TYPE_BOOLEAN, /* text visible? */
+ G_TYPE_BOOLEAN, /* combo visible? */
+ G_TYPE_STRING, /* description */
+ G_TYPE_STRING); /* help text */
tree = GNS_get_tree(gns);
i = 0;
while (tree->children[i] != NULL) {
addToTree(model,
- NULL,
- tree->children[i]);
+ NULL,
+ tree->children[i]);
i++;
}
/* capture paths that are currently expanded */
@@ -357,18 +357,18 @@
crCTX.paths = NULL;
treeView = lookup_widget("configTreeView");
gtk_tree_view_map_expanded_rows(GTK_TREE_VIEW(treeView),
- &collectRows,
- &crCTX);
+ &collectRows,
+ &crCTX);
/* update model */
gtk_tree_view_set_model(GTK_TREE_VIEW(treeView),
- GTK_TREE_MODEL(model));
+ GTK_TREE_MODEL(model));
g_object_unref(model);
/* restore expanded paths */
for (i=0;i<crCTX.size;i++) {
path = gtk_tree_path_new_from_string(crCTX.paths[i]);
gtk_tree_view_expand_row(GTK_TREE_VIEW(treeView),
- path,
- FALSE);
+ path,
+ FALSE);
gtk_tree_path_free(path);
free(crCTX.paths[i]);
}
@@ -378,9 +378,9 @@
}
static void editedTextHandler(GtkCellRendererToggle * rdner,
- gchar * path,
- gchar * new_value,
- gpointer user_data) {
+ gchar * path,
+ gchar * new_value,
+ gpointer user_data) {
struct GNS_Context * gns = user_data;
GtkTreePath * gtk_path;
GtkTreeIter iter;
@@ -393,23 +393,23 @@
model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeView));
gtk_path = gtk_tree_path_new_from_string(path);
if (TRUE != gtk_tree_model_get_iter(model,
- &iter,
- gtk_path)) {
+ &iter,
+ gtk_path)) {
GE_BREAK(ectx, 0);
gtk_tree_path_free(gtk_path);
return;
}
gtk_tree_path_free(gtk_path);
gtk_tree_model_get(model,
- &iter,
- SETUP_SECTION, §ion,
- SETUP_OPTION, &option,
- -1);
+ &iter,
+ SETUP_SECTION, §ion,
+ SETUP_OPTION, &option,
+ -1);
GC_set_configuration_value_string(cfg,
- ectx,
- section,
- option,
- new_value);
+ ectx,
+ section,
+ option,
+ new_value);
updateTreeModel(gns);
free(section);
free(option);
@@ -426,92 +426,92 @@
renderer = gtk_cell_renderer_text_new();
col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeView),
- -1,
- _("Description"),
- renderer,
- "text", SETUP_DESCRIPTION,
- "wrap-width", SETUP_DWIDTH,
- "wrap-mode", SETUP_WRAP,
- NULL);
+ -1,
+ _("Description"),
+ renderer,
+ "text", SETUP_DESCRIPTION,
+ "wrap-width", SETUP_DWIDTH,
+ "wrap-mode", SETUP_WRAP,
+ NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeView),
- col - 1);
+ col - 1);
gtk_tree_view_column_set_resizable(column, TRUE);
renderer = gtk_cell_renderer_combo_new();
g_signal_connect(renderer,
- "edited",
- G_CALLBACK(&editedTextHandler),
- gns);
+ "edited",
+ G_CALLBACK(&editedTextHandler),
+ gns);
col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeView),
- -1,
- _("Value"),
- renderer,
- "text", SETUP_TEXT_VALUE,
- "visible", SETUP_COMBO_VIS,
- "model", SETUP_COMBO_MODEL,
- "text-column", SETUP_ZERO,
- "has-entry", SETUP_TEXT_VIS,
- "background",
SETUP_EDIT_BGCOLOR,
- "background-set",
SETUP_TRUE,
- "editable", SETUP_TRUE,
- "wrap-width", SETUP_DWIDTH,
- "wrap-mode", SETUP_WRAP,
- NULL);
+ -1,
+ _("Value"),
+ renderer,
+ "text", SETUP_TEXT_VALUE,
+ "visible", SETUP_COMBO_VIS,
+ "model", SETUP_COMBO_MODEL,
+ "text-column", SETUP_ZERO,
+ "has-entry", SETUP_TEXT_VIS,
+ "background", SETUP_EDIT_BGCOLOR,
+ "background-set", SETUP_TRUE,
+ "editable", SETUP_TRUE,
+ "wrap-width", SETUP_DWIDTH,
+ "wrap-mode", SETUP_WRAP,
+ NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeView),
- col - 1);
+ col - 1);
gtk_tree_view_column_set_resizable(column, TRUE);
renderer = gtk_cell_renderer_text_new();
col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeView),
- -1,
- _("Default"),
- renderer,
- "text", SETUP_DEFAULT_VALUE,
- "wrap-width", SETUP_DWIDTH,
- "wrap-mode", SETUP_WRAP,
- NULL);
+ -1,
+ _("Default"),
+ renderer,
+ "text", SETUP_DEFAULT_VALUE,
+ "wrap-width", SETUP_DWIDTH,
+ "wrap-mode", SETUP_WRAP,
+ NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeView),
- col - 1);
+ col - 1);
gtk_tree_view_column_set_resizable(column, TRUE);
renderer = gtk_cell_renderer_text_new();
col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeView),
- -1,
- _("Help"),
- renderer,
- "text", SETUP_HELPTEXT,
- "wrap-width", SETUP_HWIDTH,
- "wrap-mode", SETUP_WRAP,
- NULL);
+ -1,
+ _("Help"),
+ renderer,
+ "text", SETUP_HELPTEXT,
+ "wrap-width", SETUP_HWIDTH,
+ "wrap-mode", SETUP_WRAP,
+ NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeView),
- col - 1);
+ col - 1);
gtk_tree_view_column_set_resizable(column, TRUE);
renderer = gtk_cell_renderer_text_new();
col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeView),
- -1,
- _("Section"),
- renderer,
- "text", SETUP_SECTION,
- NULL);
+ -1,
+ _("Section"),
+ renderer,
+ "text", SETUP_SECTION,
+ NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeView),
- col - 1);
+ col - 1);
gtk_tree_view_column_set_resizable(column, TRUE);
renderer = gtk_cell_renderer_text_new();
col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeView),
- -1,
- _("Option"),
- renderer,
- "text", SETUP_OPTION,
- NULL);
+ -1,
+ _("Option"),
+ renderer,
+ "text", SETUP_OPTION,
+ NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeView),
- col - 1);
+ col - 1);
gtk_tree_view_column_set_resizable(column, TRUE);
}
@@ -523,20 +523,20 @@
GtkWidget * dialog;
if (0 == GC_write_configuration(cfg,
- cfg_filename)) {
+ cfg_filename)) {
dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_OK,
- _("Configuration saved."));
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ _("Configuration saved."));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
} else {
dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Failed to save configuration."));
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Failed to save configuration."));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
@@ -556,23 +556,23 @@
if (GC_test_dirty(cfg)) {
dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- _("Configuration changed. Save?"));
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ _("Configuration changed. Save?"));
ret = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
switch (ret) {
case GTK_RESPONSE_YES:
if (0 != GC_write_configuration(cfg,
- cfg_filename)) {
- dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Error saving configuration."));
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+ cfg_filename)) {
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Error saving configuration."));
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
}
return FALSE;
case GTK_RESPONSE_NO:
@@ -595,18 +595,18 @@
int gconf_main_post_init(struct PluginHandle * self,
- struct GE_Context * e,
- struct GC_Configuration * c,
- struct GNS_Context * gns,
- const char * filename,
- int is_daemon) {
+ struct GE_Context * e,
+ struct GC_Configuration * c,
+ struct GNS_Context * gns,
+ const char * filename,
+ int is_daemon) {
GtkWidget * mainWindow;
cfg = c;
ectx = e;
cfg_filename = filename;
no_model = gtk_list_store_new(1,
- G_TYPE_STRING);
+ G_TYPE_STRING);
setLibrary(self);
mainWindow = get_xml("setupWindow");
updateTreeModel(gns);
@@ -629,13 +629,13 @@
/* Main */
int gconf_mainsetup_gtk(int argc,
- const char ** argv,
- struct PluginHandle * self,
- struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct GNS_Context * gns,
- const char * filename,
- int is_daemon) {
+ const char ** argv,
+ struct PluginHandle * self,
+ struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ struct GNS_Context * gns,
+ const char * filename,
+ int is_daemon) {
g_thread_init(NULL);
gtk_init(&argc, (char***) &argv);
#if ENABLE_NLS
@@ -645,9 +645,9 @@
FreeConsole();
#endif
return gconf_main_post_init(self,
- ectx,
- cfg,
- gns,
- filename,
- is_daemon);
+ ectx,
+ cfg,
+ gns,
+ filename,
+ is_daemon);
}
Modified: GNUnet/src/setup/gtk/glade_support.c
===================================================================
--- GNUnet/src/setup/gtk/glade_support.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/setup/gtk/glade_support.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -56,24 +56,24 @@
static void connector(const gchar *handler_name,
- GObject *object,
- const gchar *signal_name,
- const gchar *signal_data,
- GObject *connect_object,
- gboolean after,
- gpointer user_data) {
+ GObject *object,
+ const gchar *signal_name,
+ const gchar *signal_data,
+ GObject *connect_object,
+ gboolean after,
+ gpointer user_data) {
GladeXML * xml = user_data;
void * method;
GE_ASSERT(NULL, xml != NULL);
method = os_plugin_resolve_function(library,
- handler_name,
- YES);
+ handler_name,
+ YES);
if (method == NULL)
return;
glade_xml_signal_connect(xml,
- handler_name,
- (GCallback) method);
+ handler_name,
+ (GCallback) method);
}
GladeXML * load_xml(const char * dialog_name) {
@@ -82,13 +82,13 @@
gladeFile = get_glade_filename();
ret = glade_xml_new(gladeFile,
- dialog_name,
- PACKAGE_NAME);
+ dialog_name,
+ PACKAGE_NAME);
if (ret == NULL)
GE_DIE_STRERROR_FILE(NULL,
- GE_USER | GE_ADMIN | GE_FATAL | GE_IMMEDIATE,
- "open",
- gladeFile);
+ GE_USER | GE_ADMIN | GE_FATAL | GE_IMMEDIATE,
+ "open",
+ gladeFile);
FREE(gladeFile);
glade_xml_signal_autoconnect_full(ret, &connector, ret);
return ret;
@@ -101,7 +101,7 @@
GtkWidget * get_xml(const char * dialog_name) {
mainXML_ = load_xml(dialog_name);
return glade_xml_get_widget(mainXML_,
- dialog_name);
+ dialog_name);
}
/**
@@ -115,17 +115,17 @@
gladeFile = get_glade_filename();
myXML = glade_xml_new(gladeFile,
- name,
- PACKAGE_NAME);
+ name,
+ PACKAGE_NAME);
if (mainXML_ == NULL)
GE_DIE_STRERROR_FILE(NULL,
- GE_USER | GE_ADMIN | GE_FATAL | GE_IMMEDIATE,
- "open",
- gladeFile);
+ GE_USER | GE_ADMIN | GE_FATAL | GE_IMMEDIATE,
+ "open",
+ gladeFile);
FREE(gladeFile);
glade_xml_signal_autoconnect_full(myXML, &connector, myXML);
msgSave = glade_xml_get_widget(myXML,
- name);
+ name);
gtk_widget_show(msgSave);
g_object_unref(myXML);
}
Modified: GNUnet/src/setup/gtk/wizard_gtk.c
===================================================================
--- GNUnet/src/setup/gtk/wizard_gtk.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/gtk/wizard_gtk.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -77,7 +77,7 @@
}
void on_assi_destroysetup_gtk (GtkObject * object,
- gpointer user_data) {
+ gpointer user_data) {
/* Don't terminate if the user just clicked "Next" */
if (quit)
gtk_main_quit();
@@ -90,7 +90,7 @@
};
void on_cmbNIC_changedsetup_gtk (GtkComboBox * combobox,
- gpointer user_data) {
+ gpointer user_data) {
GtkTreeIter iter;
GValue val;
char *entry;
@@ -121,20 +121,20 @@
nic = entry;
#endif
GC_set_configuration_value_string(editCfg,
- err_ctx,
- "NETWORK",
- "INTERFACE",
- nic);
+ err_ctx,
+ "NETWORK",
+ "INTERFACE",
+ nic);
GC_set_configuration_value_string(editCfg,
- err_ctx,
- "LOAD",
- "INTERFACES",
- nic);
+ err_ctx,
+ "LOAD",
+ "INTERFACES",
+ nic);
}
static int insert_nic(const char *name,
- int defaultNIC,
- void * cls) {
+ int defaultNIC,
+ void * cls) {
gchar *utf8_name;
gsize unused;
struct insert_nic_cls * inc = cls;
@@ -154,7 +154,7 @@
}
void load_step2setup_gtk(GtkButton * button,
- gpointer prev_window) {
+ gpointer prev_window) {
GtkWidget * entIP;
GtkWidget * chkFW;
GtkTreeIter iter;
@@ -163,24 +163,24 @@
char * val;
destroyCurrentWindow();
- curwnd = get_xml("assi_step2");
+ curwnd = get_xml("assi_step2");
cls.cmbNIC = lookup_widget("cmbNIC");
GE_ASSERT(err_ctx, cls.cmbNIC != NULL);
cls.nic_item_count = 0;
model = gtk_list_store_new(1, G_TYPE_STRING);
gtk_combo_box_set_model(GTK_COMBO_BOX(cls.cmbNIC),
- GTK_TREE_MODEL(model));
+ GTK_TREE_MODEL(model));
gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(cls.cmbNIC),
- 0);
+ 0);
os_list_network_interfaces(err_ctx, &insert_nic, &cls);
if (cls.nic_item_count != 0) {
GC_get_configuration_value_string(editCfg,
- "NETWORK",
- "INTERFACE",
- "eth0",
- &val);
+ "NETWORK",
+ "INTERFACE",
+ "eth0",
+ &val);
gtk_combo_box_append_text(GTK_COMBO_BOX(cls.cmbNIC), val);
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),
&iter);
@@ -193,25 +193,25 @@
entIP = lookup_widget("entIP");
GC_get_configuration_value_string(editCfg,
- "NETWORK",
- "IP",
- "",
- &val);
+ "NETWORK",
+ "IP",
+ "",
+ &val);
gtk_entry_set_text(GTK_ENTRY(entIP), val);
FREE(val);
chkFW = lookup_widget("chkFW");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkFW),
GC_get_configuration_value_yesno(editCfg,
- "NAT",
- "LIMITED",
- NO) == YES);
+ "NAT",
+ "LIMITED",
+ NO) == YES);
gtk_widget_show(curwnd);
}
void load_step3setup_gtk(GtkButton * button,
- gpointer prev_window) {
+ gpointer prev_window) {
GtkWidget * entUp;
GtkWidget * entDown;
GtkWidget * radGNUnet;
@@ -225,35 +225,35 @@
entDown = lookup_widget("entDown");
radGNUnet = lookup_widget("radGNUnet");
radShare = lookup_widget("radShare");
- entCPU = lookup_widget("entCPU");
+ entCPU = lookup_widget("entCPU");
GC_get_configuration_value_string(editCfg,
- "LOAD",
- "MAXNETUPBPSTOTAL",
- "50000",
- &val);
+ "LOAD",
+ "MAXNETUPBPSTOTAL",
+ "50000",
+ &val);
gtk_entry_set_text(GTK_ENTRY(entUp), val);
FREE(val);
GC_get_configuration_value_string(editCfg,
- "LOAD",
- "MAXNETDOWNBPSTOTAL",
- "50000",
- &val);
+ "LOAD",
+ "MAXNETDOWNBPSTOTAL",
+ "50000",
+ &val);
gtk_entry_set_text(GTK_ENTRY(entDown), val);
FREE(val);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON
((GC_get_configuration_value_yesno(editCfg,
- "LOAD",
- "BASICLIMITING",
- NO) == YES)
+ "LOAD",
+ "BASICLIMITING",
+ NO) == YES)
? radGNUnet
: radShare ),
TRUE);
GC_get_configuration_value_string(editCfg,
- "LOAD",
- "MAXCPULOAD",
- "50",
- &val);
+ "LOAD",
+ "MAXCPULOAD",
+ "50",
+ &val);
gtk_entry_set_text(GTK_ENTRY(entCPU), val);
FREE(val);
@@ -261,7 +261,7 @@
}
void load_step4setup_gtk(GtkButton * button,
- gpointer prev_window) {
+ gpointer prev_window) {
GtkWidget * entUser;
GtkWidget * entGroup;
char * uname = NULL;
@@ -275,18 +275,18 @@
if (NULL != user_name) {
GC_get_configuration_value_string(editCfg,
- "GNUNETD",
- "USER",
- "gnunet",
- &uname);
+ "GNUNETD",
+ "USER",
+ "gnunet",
+ &uname);
}
if (NULL != group_name) {
GC_get_configuration_value_string(editCfg,
- "GNUNETD",
- "GROUP",
- "gnunet",
- &gname);
+ "GNUNETD",
+ "GROUP",
+ "gnunet",
+ &gname);
}
#ifndef MINGW
@@ -296,9 +296,9 @@
else {
uname = getenv("USER");
if (uname != NULL)
- user_name = STRDUP(uname);
+ user_name = STRDUP(uname);
else
- user_name = NULL;
+ user_name = NULL;
}
} else {
user_name = STRDUP(uname);
@@ -311,10 +311,10 @@
else {
grp = getgrgid(getegid());
if ( (grp != NULL) &&
- (grp->gr_name != NULL) )
- group_name = STRDUP(grp->gr_name);
+ (grp->gr_name != NULL) )
+ group_name = STRDUP(grp->gr_name);
else
- group_name = NULL;
+ group_name = NULL;
}
} else {
group_name = STRDUP(gname);
@@ -336,11 +336,11 @@
if (group_name != NULL)
gtk_entry_set_text(GTK_ENTRY(entGroup), group_name);
cap = os_modify_autostart(err_ctx,
- 1,
- 1,
- NULL,
- NULL,
- NULL);
+ 1,
+ 1,
+ NULL,
+ NULL,
+ NULL);
gtk_widget_set_sensitive(entUser, cap);
#ifdef WINDOWS
cap = FALSE;
@@ -352,7 +352,7 @@
void load_step5setup_gtk(GtkButton * button,
- gpointer prev_window) {
+ gpointer prev_window) {
GtkWidget * chkMigr;
GtkWidget * entQuota;
GtkWidget * chkEnh;
@@ -367,18 +367,18 @@
chkEnh = lookup_widget("chkEnh");
GC_get_configuration_value_string(editCfg,
- "FS",
- "QUOTA",
- "1024",
- &val);
+ "FS",
+ "QUOTA",
+ "1024",
+ &val);
gtk_entry_set_text(GTK_ENTRY(entQuota), val);
FREE(val);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkMigr),
- GC_get_configuration_value_yesno(editCfg,
- "FS",
-
"ACTIVEMIGRATION",
- YES) == YES);
+ GC_get_configuration_value_yesno(editCfg,
+ "FS",
+ "ACTIVEMIGRATION",
+ YES) == YES);
if (os_modify_autostart(err_ctx, 1, 1, NULL, NULL, NULL))
gtk_widget_set_sensitive(chkStart, TRUE);
@@ -388,18 +388,18 @@
GC_get_configuration_value_yesno(editCfg, "GNUNETD", "AUTOSTART", NO) ==
YES);
if (doOpenEnhConfigurator)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkEnh), 1);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkEnh), 1);
gtk_widget_show(curwnd);
}
void do_destroy_widgetsetup_gtk(GtkButton * button,
- gpointer user_data) {
+ gpointer user_data) {
GtkWidget * msgSaveFailed = user_data;
gtk_widget_destroy(msgSaveFailed);
}
static void showErr(const char * prefix,
- const char * error) {
+ const char * error) {
GtkWidget * dialog;
char *err;
@@ -437,7 +437,7 @@
}
void on_abort_clickedsetup_gtk(GtkButton * button,
- gpointer user_data) {
+ gpointer user_data) {
GtkWidget * dialog;
int ok, ret;
@@ -470,27 +470,27 @@
}
void on_finish_clickedsetup_gtk (GtkButton * button,
- gpointer user_data) {
+ gpointer user_data) {
char * gup;
char * bin;
if (doAutoStart && (user_name != NULL))
if (!wiz_createGroupUser(group_name,
- user_name)) {
+ user_name)) {
#ifndef MINGW
showErr(_("Unable to create user account:"),
- STRERROR(errno));
+ STRERROR(errno));
#endif
return;
}
if (wiz_autostartService(doAutoStart,
- user_name,
- group_name) != OK) {
+ user_name,
+ group_name) != OK) {
#ifndef MINGW
showErr(_("Unable to change startup process:"),
- STRERROR(errno));
+ STRERROR(errno));
#endif
- }
+ }
if (OK != save_conf())
return;
@@ -503,93 +503,93 @@
strcat(gup, cfg_fn);
if (system(gup) != 0)
showErr(_("Running gnunet-update failed.\n"
- "This maybe due to insufficient permissions, please check your
configuration.\n"
- "Finally, run gnunet-update manually."), "");
+ "This maybe due to insufficient permissions, please check your
configuration.\n"
+ "Finally, run gnunet-update manually."), "");
FREE(gup);
}
gtk_widget_destroy(curwnd);
}
void on_updateFailedOK_clickedsetup_gtk (GtkButton * button,
- gpointer user_data) {
+ gpointer user_data) {
GtkWidget * dialog = user_data;
gtk_widget_destroy(dialog);
}
void on_entIP_changedsetup_gtk (GtkEditable * editable,
- gpointer user_data) {
+ gpointer user_data) {
gchar * ret;
ret = gtk_editable_get_chars(editable, 0, -1);
GC_set_configuration_value_string(editCfg,
- err_ctx,
- "NETWORK",
- "IP",
- ret);
+ err_ctx,
+ "NETWORK",
+ "IP",
+ ret);
g_free(ret);
}
void on_chkFW_toggledsetup_gtk (GtkToggleButton * togglebutton,
- gpointer user_data) {
+ gpointer user_data) {
GC_set_configuration_value_choice(editCfg, err_ctx, "LIMITED", "NAT",
gtk_toggle_button_get_active(togglebutton) ? "YES" : "NO");
}
void on_entUp_changedsetup_gtk (GtkEditable * editable,
- gpointer user_data) {
+ gpointer user_data) {
gchar * ret;
ret = gtk_editable_get_chars(editable, 0, -1);
GC_set_configuration_value_string(editCfg,
- err_ctx,
- "LOAD",
- "MAXNETUPBPSTOTAL",
- ret);
+ err_ctx,
+ "LOAD",
+ "MAXNETUPBPSTOTAL",
+ ret);
g_free(ret);
}
void on_entDown_changedsetup_gtk (GtkEditable * editable,
- gpointer user_data) {
+ gpointer user_data) {
gchar * ret;
ret = gtk_editable_get_chars(editable, 0, -1);
GC_set_configuration_value_string(editCfg,
- err_ctx,
- "LOAD",
- "MAXNETDOWNBPSTOTAL",
- ret);
+ err_ctx,
+ "LOAD",
+ "MAXNETDOWNBPSTOTAL",
+ ret);
g_free(ret);
}
void on_radGNUnet_toggledsetup_gtk(GtkToggleButton * togglebutton,
- gpointer user_data) {
+ gpointer user_data) {
GC_set_configuration_value_choice(editCfg,
- err_ctx,
- "LOAD",
- "BASICLIMITING",
- gtk_toggle_button_get_active(togglebutton)
- ? "YES"
- : "NO");
+ err_ctx,
+ "LOAD",
+ "BASICLIMITING",
+ gtk_toggle_button_get_active(togglebutton)
+ ? "YES"
+ : "NO");
}
void on_radShare_toggledsetup_gtk (GtkToggleButton * togglebutton,
- gpointer user_data) {
+ gpointer user_data) {
GC_set_configuration_value_choice(editCfg,
- err_ctx,
- "LOAD",
- "BASICLIMITING",
- gtk_toggle_button_get_active(togglebutton)
- ? "NO"
- : "YES");
+ err_ctx,
+ "LOAD",
+ "BASICLIMITING",
+ gtk_toggle_button_get_active(togglebutton)
+ ? "NO"
+ : "YES");
}
void on_entCPU_changedsetup_gtk (GtkEditable * editable,
- gpointer user_data) {
+ gpointer user_data) {
gchar * ret;
int num;
@@ -600,18 +600,18 @@
}
void on_chkMigr_toggledsetup_gtk (GtkToggleButton * togglebutton,
- gpointer user_data) {
+ gpointer user_data) {
GC_set_configuration_value_choice(editCfg,
- err_ctx,
- "FS",
- "ACTIVEMIGRATION",
- gtk_toggle_button_get_active(togglebutton)
- ? "YES"
- : "NO");
+ err_ctx,
+ "FS",
+ "ACTIVEMIGRATION",
+ gtk_toggle_button_get_active(togglebutton)
+ ? "YES"
+ : "NO");
}
void on_entQuota_changedsetup_gtk (GtkEditable * editable,
- gpointer user_data) {
+ gpointer user_data) {
gchar * ret;
ret = gtk_editable_get_chars(editable, 0, -1);
@@ -621,28 +621,28 @@
void on_chkStart_toggledsetup_gtk (GtkToggleButton * togglebutton,
- gpointer user_data) {
+ gpointer user_data) {
doAutoStart = gtk_toggle_button_get_active(togglebutton);
GC_set_configuration_value_choice(editCfg,
- err_ctx,
- "AUTOSTART",
- "GNUNETD",
- doAutoStart ? "YES" : "NO");
+ err_ctx,
+ "AUTOSTART",
+ "GNUNETD",
+ doAutoStart ? "YES" : "NO");
}
void on_chkEnh_toggledsetup_gtk (GtkToggleButton * togglebutton,
- gpointer user_data) {
+ gpointer user_data) {
doOpenEnhConfigurator = gtk_toggle_button_get_active(togglebutton);
}
void on_chkUpdate_toggledsetup_gtk(GtkToggleButton * togglebutton,
- gpointer user_data) {
+ gpointer user_data) {
doUpdate = gtk_toggle_button_get_active(togglebutton);
}
void on_entUser_changedsetup_gtk (GtkEditable * editable,
- gpointer user_data) {
+ gpointer user_data) {
gchar * ret;
ret = gtk_editable_get_chars(editable, 0, -1);
@@ -658,17 +658,17 @@
}
void on_entGroup_changedsetup_gtk (GtkEditable * editable,
- gpointer user_data) {
+ gpointer user_data) {
gchar * ret;
FREENONNULL(group_name);
ret = gtk_editable_get_chars(editable, 0, -1);
GE_ASSERT(err_ctx, ret != NULL);
GC_set_configuration_value_string(editCfg,
- err_ctx,
- "GNUNETD",
- "GROUP",
- ret);
+ err_ctx,
+ "GNUNETD",
+ "GROUP",
+ ret);
if (strlen(ret) != 0)
group_name = STRDUP(ret);
else
@@ -677,13 +677,13 @@
}
int gtk_wizard_mainsetup_gtk(int argc,
- char * const * argv,
- struct PluginHandle * self,
- struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct GNS_Context * gns,
- const char * filename,
- int is_daemon) {
+ char * const * argv,
+ struct PluginHandle * self,
+ struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ struct GNS_Context * gns,
+ const char * filename,
+ int is_daemon) {
GE_ASSERT(ectx, is_daemon);
g_thread_init(NULL);
gtk_init(&argc, (char ***) &argv);
@@ -707,11 +707,11 @@
destroyMainXML();
if (doOpenEnhConfigurator)
gconf_main_post_init(self,
- ectx,
- cfg,
- gns,
- filename,
- is_daemon);
+ ectx,
+ cfg,
+ gns,
+ filename,
+ is_daemon);
FREENONNULL(user_name);
FREENONNULL(group_name);
setLibrary(NULL);
Modified: GNUnet/src/setup/lib/gns.c
===================================================================
--- GNUnet/src/setup/lib/gns.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/lib/gns.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -58,7 +58,7 @@
};
static void notify_listeners(void * ctx,
- struct GNS_Tree * tree) {
+ struct GNS_Tree * tree) {
struct GNS_Context * g = ctx;
GNS_TCL * lpos;
@@ -84,31 +84,31 @@
* refused
*/
int configChangeListener(void * ctx,
- struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option) {
+ struct GC_Configuration * cfg,
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option) {
struct GNS_Context * g = ctx;
struct GNS_Tree * pos;
pos = tree_lookup(g->root,
- section,
- option);
+ section,
+ option);
if (pos == NULL) {
GE_LOG(g->ectx,
- GE_DEVELOPER | GE_BULK | GE_ERROR,
- "Tree lookup for unknown option `%s' in section `%s'!\n",
- option,
- section);
+ GE_DEVELOPER | GE_BULK | GE_ERROR,
+ "Tree lookup for unknown option `%s' in section `%s'!\n",
+ option,
+ section);
return 0; /* or refuse? */
}
/* first, check if value is valid */
if ((pos->type & GNS_KindMask) != GNS_Leaf) {
GE_LOG(g->ectx,
- GE_DEVELOPER | GE_BULK | GE_ERROR,
- "Tree value change for non-leaf option `%s' in section `%s'!\n",
- option,
- section);
+ GE_DEVELOPER | GE_BULK | GE_ERROR,
+ "Tree value change for non-leaf option `%s' in section `%s'!\n",
+ option,
+ section);
return 0;
}
switch (pos->type & GNS_TypeMask) {
@@ -116,9 +116,9 @@
int val;
val = GC_get_configuration_value_yesno(cfg,
- section,
- option,
- pos->value.Boolean.def);
+ section,
+ option,
+ pos->value.Boolean.def);
if (val == SYSERR) {
return SYSERR;
}
@@ -129,12 +129,12 @@
unsigned long long val;
if (SYSERR == GC_get_configuration_value_number(cfg,
- section,
- option,
- pos->value.UInt64.min,
- pos->value.UInt64.max,
- pos->value.UInt64.def,
- &val)) {
+ section,
+ option,
+ pos->value.UInt64.min,
+ pos->value.UInt64.max,
+ pos->value.UInt64.def,
+ &val)) {
return SYSERR;
}
pos->value.UInt64.val = val;
@@ -146,20 +146,20 @@
s = NULL;
GC_get_configuration_value_string(cfg,
- section,
- option,
- NULL,
- &s);
+ section,
+ option,
+ NULL,
+ &s);
if (s == NULL) {
pos->value.Double.val = pos->value.Double.def;
} else {
if (1 != sscanf(s, "%lf", &d)) {
- GE_LOG(ectx,
- GE_USER | GE_ERROR | GE_IMMEDIATE,
- "`%s' is not a valid double-precision floating point number.\n",
- s);
- FREE(s);
- return SYSERR;
+ GE_LOG(ectx,
+ GE_USER | GE_ERROR | GE_IMMEDIATE,
+ "`%s' is not a valid double-precision floating point number.\n",
+ s);
+ FREE(s);
+ return SYSERR;
}
pos->value.Double.val = d;
FREE(s);
@@ -171,10 +171,10 @@
char * val;
if (SYSERR == GC_get_configuration_value_string(cfg,
- section,
- option,
- pos->value.String.def,
- &val))
+ section,
+ option,
+ pos->value.String.def,
+ &val))
return SYSERR;
FREE(pos->value.String.val);
pos->value.String.val = val;
@@ -184,11 +184,11 @@
const char * ival;
if (SYSERR == GC_get_configuration_value_choice(cfg,
- section,
- option,
- (const char**)
pos->value.String.legalRange,
- pos->value.String.def,
- &ival))
+ section,
+ option,
+ (const char**)
pos->value.String.legalRange,
+ pos->value.String.def,
+ &ival))
return SYSERR;
FREE(pos->value.String.val);
pos->value.String.val = STRDUP(ival);
@@ -201,11 +201,11 @@
/* allow tree to update visibility */
tree_notify_change(cfg,
- ¬ify_listeners,
- g,
- g->ectx,
- g->root,
- pos);
+ ¬ify_listeners,
+ g,
+ g->ectx,
+ g->root,
+ pos);
return 0;
}
@@ -257,8 +257,8 @@
*/
struct GNS_Context *
GNS_load_specification(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * specification) {
+ struct GC_Configuration * cfg,
+ const char * specification) {
struct GNS_Context * ctx;
struct GNS_Tree * root;
@@ -271,12 +271,12 @@
ctx->root = root;
ctx->in_notify = 0;
if (-1 == GC_attach_change_listener(cfg,
- &configChangeListener,
- ctx)) {
+ &configChangeListener,
+ ctx)) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Configuration does not satisfy constraints of configuration
specification file `%s'!\n"),
- specification);
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Configuration does not satisfy constraints of configuration
specification file `%s'!\n"),
+ specification);
FREE(ctx);
free_tree(root);
return NULL;
@@ -303,8 +303,8 @@
void
GNS_free_specification(struct GNS_Context * ctx) {
GC_detach_change_listener(ctx->cfg,
- &configChangeListener,
- ctx);
+ &configChangeListener,
+ ctx);
free_tree(ctx->root);
GE_ASSERT(ctx->ectx, ctx->listeners == NULL);
FREE(ctx);
@@ -317,8 +317,8 @@
*/
void
GNS_register_tree_change_listener(struct GNS_Context * ctx,
- GNS_TreeChangeListener listener,
- void * cls) {
+ GNS_TreeChangeListener listener,
+ void * cls) {
GNS_TCL * n;
n = MALLOC(sizeof(GNS_TCL));
@@ -334,8 +334,8 @@
*/
void
GNS_unregister_tree_change_listener(struct GNS_Context * ctx,
- GNS_TreeChangeListener listener,
- void * cls) {
+ GNS_TreeChangeListener listener,
+ void * cls) {
GNS_TCL * pos;
GNS_TCL * prev;
@@ -343,11 +343,11 @@
pos = ctx->listeners;
while (pos != NULL) {
if ( (pos->l == listener) &&
- (pos->c == cls)) {
+ (pos->c == cls)) {
if (prev == NULL)
- ctx->listeners = pos->next;
+ ctx->listeners = pos->next;
else
- prev->next = pos->next;
+ prev->next = pos->next;
FREE(pos);
return; /* only unregister one! */
}
@@ -364,7 +364,7 @@
*/
char *
GNS_get_default_value_as_string(GNS_Type type,
- const GNS_Value * value) {
+ const GNS_Value * value) {
char buf[48];
if (value == NULL)
Modified: GNUnet/src/setup/lib/tree.c
===================================================================
--- GNUnet/src/setup/lib/tree.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/lib/tree.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -67,8 +67,8 @@
static int
print_tc(SCM tc_smob,
- SCM port,
- scm_print_state *pstate) {
+ SCM port,
+ scm_print_state *pstate) {
/* TC * tc = (TC *) SCM_SMOB_DATA (tc_smob); */
scm_puts ("TC", port);
/* non-zero means success */
@@ -77,8 +77,8 @@
static int
print_tree(SCM tree_smob,
- SCM port,
- scm_print_state *pstate) {
+ SCM port,
+ scm_print_state *pstate) {
/* struct GNS_Tree * tree = (struct GNS_Tree *) SCM_SMOB_DATA (tree_smob); */
scm_puts ("Tree", port);
@@ -90,8 +90,8 @@
struct GNS_Tree *
tree_lookup(struct GNS_Tree * root,
- const char * section,
- const char * option) {
+ const char * section,
+ const char * option) {
int i;
struct GNS_Tree * ret;
@@ -103,8 +103,8 @@
i = 0;
while (root->children[i] != NULL) {
ret = tree_lookup(root->children[i],
- section,
- option);
+ section,
+ option);
if (ret != NULL)
return ret;
i++;
@@ -113,8 +113,8 @@
}
SCM get_option(SCM smob,
- SCM section,
- SCM option) {
+ SCM section,
+ SCM option) {
TC * tc;
char * opt;
char * sec;
@@ -127,8 +127,8 @@
opt = scm_to_locale_string(option);
sec = scm_to_locale_string(section);
t = tree_lookup(tc->root,
- sec,
- opt);
+ sec,
+ opt);
if (t == NULL)
return SCM_EOL;
switch (t->type & GNS_TypeMask) {
@@ -148,15 +148,15 @@
GE_BREAK(NULL, 0);
return SCM_EOL;
}
-
+
/**
* Change the visibility of an entry in the
* tree (and notify listeners about change).
*/
SCM change_visible(SCM smob,
- SCM section,
- SCM option,
- SCM yesno) {
+ SCM section,
+ SCM option,
+ SCM yesno) {
TC * tc;
char * opt;
char * sec;
@@ -178,17 +178,17 @@
return SCM_EOL;
}
t = tree_lookup(tc->root,
- sec,
- opt);
+ sec,
+ opt);
if (t != NULL) {
t->visible = val;
tc->vcl(tc->ctx,
- t);
+ t);
} else {
fprintf(stderr,
- _("Internal error: entry `%s' in section `%s' not found for
visibility change!\n"),
- opt,
- sec);
+ _("Internal error: entry `%s' in section `%s' not found for visibility
change!\n"),
+ opt,
+ sec);
}
free(sec);
free(opt);
@@ -199,9 +199,9 @@
* Set an option.
*/
SCM set_option(SCM smob,
- SCM section,
- SCM option,
- SCM value) {
+ SCM section,
+ SCM option,
+ SCM value) {
TC * tc;
char * opt;
char * sec;
@@ -216,10 +216,10 @@
sec = scm_to_locale_string(section);
val = scm_to_locale_string(value);
GC_set_configuration_value_string(tc->cfg,
- NULL,
- sec,
- opt,
- val);
+ NULL,
+ sec,
+ opt,
+ val);
if (sec != NULL)
free(sec);
if (val != NULL)
@@ -238,13 +238,13 @@
* min/max for integers
*/
SCM build_tree_node(SCM section,
- SCM option,
- SCM description,
- SCM help,
- SCM children,
- SCM visible,
- SCM value,
- SCM range) {
+ SCM option,
+ SCM description,
+ SCM help,
+ SCM children,
+ SCM visible,
+ SCM value,
+ SCM range) {
struct GNS_Tree * tree;
SCM child;
int i;
@@ -262,7 +262,7 @@
for (i=0;i<clen;i++) {
child = scm_list_ref(children, scm_from_signed_integer(i));
SCM_ASSERT(SCM_SMOB_PREDICATE(tree_tag, child),
- children, SCM_ARG5, "build_tree_node");
+ children, SCM_ARG5, "build_tree_node");
}
SCM_ASSERT(scm_boolean_p(visible), visible, SCM_ARG6, "build_tree_node");
if (scm_is_string(value)) {
@@ -270,24 +270,24 @@
len = scm_to_int(scm_length(range));
for (i=0;i<len;i++)
SCM_ASSERT(scm_string_p(scm_list_ref(range,
- scm_from_signed_integer(i))),
- range, SCM_ARGn, "build_tree_node");
+ scm_from_signed_integer(i))),
+ range, SCM_ARGn, "build_tree_node");
} else if (scm_is_integer(value)) {
SCM_ASSERT(scm_pair_p(range),
- range, SCM_ARGn, "build_tree_node");
+ range, SCM_ARGn, "build_tree_node");
SCM_ASSERT(scm_is_integer(SCM_CAR(range)),
- range, SCM_ARGn, "build_tree_node");
+ range, SCM_ARGn, "build_tree_node");
SCM_ASSERT(scm_is_integer(SCM_CDR(range)),
- range, SCM_ARGn, "build_tree_node");
+ range, SCM_ARGn, "build_tree_node");
} else if (scm_is_true(scm_real_p(value))) {
/* no checks */
} else if (scm_is_true(scm_boolean_p(value))) {
/* no checks */
} else {
SCM_ASSERT(0,
- range,
- SCM_ARG7,
- "build_tree_node"); /* invalid type */
+ range,
+ SCM_ARG7,
+ "build_tree_node"); /* invalid type */
}
/* construct C object */
@@ -312,23 +312,23 @@
tree->value.String.legalRange = MALLOC(sizeof(char*) * (len+1));
for (i=0;i<len-1;i++)
tree->value.String.legalRange[i]
- = scm_to_locale_string(scm_list_ref(range,
- scm_from_signed_integer(i+1)));
+ = scm_to_locale_string(scm_list_ref(range,
+ scm_from_signed_integer(i+1)));
if (len == 0)
tree->value.String.legalRange[len] = NULL;
else
tree->value.String.legalRange[len-1] = NULL;
if (len > 0)
type = scm_to_locale_string(scm_list_ref(range,
- scm_from_signed_integer(0)));
+ scm_from_signed_integer(0)));
else
type = STRDUP("*");
GE_ASSERT(NULL, type != NULL);
if (0 == strcasecmp(type,
- "MC")) {
+ "MC")) {
tree->type |= GNS_MC;
} else if (0 == strcasecmp(type,
- "SC")) {
+ "SC")) {
tree->type |= GNS_SC;
} else {
GE_BREAK(NULL, 0 == strcasecmp(type, "*"));
@@ -373,7 +373,7 @@
struct GNS_Tree *
tree_parse(struct GE_Context * ectx,
- const char * specification) {
+ const char * specification) {
struct GNS_Tree * ret;
ret = parse_internal((void*) specification);
@@ -402,11 +402,11 @@
* Update visibility (and notify about changes).
*/
void tree_notify_change(struct GC_Configuration * cfg,
- VisibilityChangeListener vcl,
- void * ctx,
- struct GE_Context * ectx,
- struct GNS_Tree * root,
- struct GNS_Tree * change) {
+ VisibilityChangeListener vcl,
+ void * ctx,
+ struct GE_Context * ectx,
+ struct GNS_Tree * root,
+ struct GNS_Tree * change) {
TC tc;
tc.cfg = cfg;
@@ -459,17 +459,17 @@
scm_set_smob_free (tree_tag, free_box);
scm_set_smob_print (tree_tag, print_tree);
scm_c_define_gsubr("change-visible",
- 4, 0, 0,
- &change_visible);
+ 4, 0, 0,
+ &change_visible);
scm_c_define_gsubr("build-tree-node",
- 8, 0, 0,
- &build_tree_node);
+ 8, 0, 0,
+ &build_tree_node);
scm_c_define_gsubr("get-option",
- 3, 0, 0,
- &get_option);
+ 3, 0, 0,
+ &get_option);
scm_c_define_gsubr("set-option",
- 4, 0, 0,
- &set_option);
+ 4, 0, 0,
+ &set_option);
}
void __attribute__ ((destructor)) gns_scheme_fin() {
Modified: GNUnet/src/setup/lib/wizard_util.c
===================================================================
--- GNUnet/src/setup/lib/wizard_util.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/lib/wizard_util.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -38,10 +38,10 @@
#ifdef WINDOWS
/* default NIC for unixes */
- if (strcmp(nic, "eth0") == 0)
+ if (strcmp(nic, "eth0") == 0)
{
FREE(nic);
- nic = NULL;
+ nic = NULL;
}
#endif
@@ -116,20 +116,20 @@
break;
case 5:
err = winErrorStr(_("Can't access the service"),
- GetLastError());
- break;
+ GetLastError());
+ break;
case 6:
err = winErrorStr(_("Can't delete the service"),
- GetLastError());
+ GetLastError());
break;
default:
err = winErrorStr(_("Unknown error"), GetLastError());
}
if (err) {
MessageBox(GetActiveWindow(),
- err,
- _("Error"),
- MB_ICONSTOP | MB_OK);
+ err,
+ _("Error"),
+ MB_ICONSTOP | MB_OK);
free(err);
}
#endif
@@ -157,7 +157,7 @@
switch(ret) {
case 1:
err = _("This version of Windows does not support "
- "multiple users.");
+ "multiple users.");
break;
case 2:
err = winErrorStr(_("Error creating user"), GetLastError());
Modified: GNUnet/src/setup/ncurses/mconf.c
===================================================================
--- GNUnet/src/setup/ncurses/mconf.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/ncurses/mconf.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -41,19 +41,19 @@
static struct GE_Context * ectx;
static void show_help(const char * option,
- const char * helptext) {
+ const char * helptext) {
dialog_vars.help_button = 0;
dialog_msgbox(option,
- gettext(helptext),
- 20,
- 70,
- TRUE);
+ gettext(helptext),
+ 20,
+ 70,
+ TRUE);
dialog_vars.help_button = 1;
}
static void run_menu(struct GNS_Context * ctx,
- struct GNS_Tree * pos,
- struct GC_Configuration * cfg) {
+ struct GNS_Tree * pos,
+ struct GC_Configuration * cfg) {
int st;
int i;
DIALOG_LISTITEM * items;
@@ -98,383 +98,383 @@
st = 0;
i = 0;
while (pos->children[i] != NULL) {
- if (pos->children[i]->visible)
- st++;
- i++;
+ if (pos->children[i]->visible)
+ st++;
+ i++;
}
if (st == 0)
- return; /* no visible entries */
+ return; /* no visible entries */
items = MALLOC(sizeof(DIALOG_LISTITEM) * st);
i = 0;
st = 0;
while (pos->children[i] != NULL) {
- if (pos->children[i]->visible) {
- items[st].name = pos->children[i]->option;
- items[st].text = gettext(pos->children[i]->description);
- items[st].help = gettext(pos->children[i]->help);
- if (st == msel)
- items[st].state = 1;
- else
- items[st].state = 0;
- st++;
- }
- i++;
+ if (pos->children[i]->visible) {
+ items[st].name = pos->children[i]->option;
+ items[st].text = gettext(pos->children[i]->description);
+ items[st].help = gettext(pos->children[i]->help);
+ if (st == msel)
+ items[st].state = 1;
+ else
+ items[st].state = 0;
+ st++;
+ }
+ i++;
}
st = dlg_menu(gettext(pos->description),
- "Select configuration option to change",
- 20,
- 70,
- 13,
- st,
- items,
- &msel,
- NULL);
+ "Select configuration option to change",
+ 20,
+ 70,
+ 13,
+ st,
+ items,
+ &msel,
+ NULL);
FREE(items);
switch (st) {
case DLG_EXIT_OK:
- i = 0;
- st = msel;
- while (pos->children[i] != NULL) {
- if (pos->children[i]->visible) {
- if (st == 0)
- run_menu(ctx,
- pos->children[i],
- cfg);
- st--;
- }
- i++;
- }
- break;
+ i = 0;
+ st = msel;
+ while (pos->children[i] != NULL) {
+ if (pos->children[i]->visible) {
+ if (st == 0)
+ run_menu(ctx,
+ pos->children[i],
+ cfg);
+ st--;
+ }
+ i++;
+ }
+ break;
case DLG_EXIT_HELP:
- show_help(pos->children[msel]->option,
- pos->children[msel]->help);
- break;
+ show_help(pos->children[msel]->option,
+ pos->children[msel]->help);
+ break;
case DLG_EXIT_ESC:
case DLG_EXIT_ERROR:
case DLG_EXIT_CANCEL:
default:
- return;
+ return;
}
break;
case GNS_Leaf:
switch (pos->type & GNS_TypeMask) {
case GNS_Boolean:
- st = dialog_yesno(pos->option,
- gettext(pos->description),
- 5, 60);
- switch (st) {
- case DLG_EXIT_OK:
- case DLG_EXIT_CANCEL:
- if (0 != GC_set_configuration_value_string(cfg,
- ectx,
- pos->section,
- pos->option,
- st == DLG_EXIT_OK ? "YES"
: "NO")) {
- show_help(pos->option,
- gettext_noop("Internal error! (Choice invalid?)"));
- break;
- }
- return;
- case DLG_EXIT_HELP:
- show_help(pos->option, pos->help);
- break;
- case DLG_EXIT_ESC:
- return;
- default:
- GE_BREAK(ectx, 0);
- return;
- }
- break;
+ st = dialog_yesno(pos->option,
+ gettext(pos->description),
+ 5, 60);
+ switch (st) {
+ case DLG_EXIT_OK:
+ case DLG_EXIT_CANCEL:
+ if (0 != GC_set_configuration_value_string(cfg,
+ ectx,
+ pos->section,
+ pos->option,
+ st == DLG_EXIT_OK ? "YES" : "NO"))
{
+ show_help(pos->option,
+ gettext_noop("Internal error! (Choice invalid?)"));
+ break;
+ }
+ return;
+ case DLG_EXIT_HELP:
+ show_help(pos->option, pos->help);
+ break;
+ case DLG_EXIT_ESC:
+ return;
+ default:
+ GE_BREAK(ectx, 0);
+ return;
+ }
+ break;
case GNS_String:
- /* free form */
- fitem.text = MALLOC(65536);
- strcpy(fitem.text,
- pos->value.String.val);
- fitem.text_len = strlen(fitem.text);
- fitem.help = pos->help;
- msel = 0;
- st = dlg_form(pos->option,
- "",
- 20,
- 70,
- 15,
- 1,
- &fitem,
- &msel);
- switch (st) {
- case DLG_EXIT_OK:
- if (0 != GC_set_configuration_value_string(cfg,
- ectx,
- pos->section,
- pos->option,
- fitem.text)) {
- show_help(pos->option,
- gettext_noop("Internal error! (Value invalid?)"));
- break;
- }
- FREE(fitem.text);
- return;
- case DLG_EXIT_HELP:
- show_help(pos->option, pos->help);
- break;
- case DLG_EXIT_CANCEL:
- case DLG_EXIT_ERROR:
- case DLG_EXIT_ESC:
- FREE(fitem.text);
- return;
- default:
- break;
- }
- FREE(fitem.text);
- /* end free form */
- break;
+ /* free form */
+ fitem.text = MALLOC(65536);
+ strcpy(fitem.text,
+ pos->value.String.val);
+ fitem.text_len = strlen(fitem.text);
+ fitem.help = pos->help;
+ msel = 0;
+ st = dlg_form(pos->option,
+ "",
+ 20,
+ 70,
+ 15,
+ 1,
+ &fitem,
+ &msel);
+ switch (st) {
+ case DLG_EXIT_OK:
+ if (0 != GC_set_configuration_value_string(cfg,
+ ectx,
+ pos->section,
+ pos->option,
+ fitem.text)) {
+ show_help(pos->option,
+ gettext_noop("Internal error! (Value invalid?)"));
+ break;
+ }
+ FREE(fitem.text);
+ return;
+ case DLG_EXIT_HELP:
+ show_help(pos->option, pos->help);
+ break;
+ case DLG_EXIT_CANCEL:
+ case DLG_EXIT_ERROR:
+ case DLG_EXIT_ESC:
+ FREE(fitem.text);
+ return;
+ default:
+ break;
+ }
+ FREE(fitem.text);
+ /* end free form */
+ break;
case GNS_SC:
- /* begin single choice */
- val = &pos->value;
- i = 0;
- while (val->String.legalRange[i] != NULL)
- i++;
- GE_ASSERT(ectx, i != 0);
- items = MALLOC(sizeof(DIALOG_LISTITEM) * i);
- i = 0;
- msel = -1;
-
- while (val->String.legalRange[i] != NULL) {
- items[i].name = "";
- items[i].text = val->String.legalRange[i];
- items[i].help = "";
- items[i].state = 0;
- if (0 == strcmp(val->String.legalRange[i],
- val->String.val)) {
- items[i].state = 1;
- msel = i;
- }
- if ( (msel == -1) &&
- (0 == strcmp(val->String.legalRange[i],
- val->String.def)) )
- msel = i;
- i++;
- }
- st = dlg_checklist(gettext(pos->option),
- gettext(pos->description),
- 20,
- 70,
- 13,
- i,
- items,
- " *",
- FLAG_RADIO,
- &msel);
- FREE(items);
- switch (st) {
- case DLG_EXIT_OK:
- if (0 != GC_set_configuration_value_choice(cfg,
- ectx,
- pos->section,
- pos->option,
-
val->String.legalRange[msel])) {
- show_help(pos->option,
- gettext_noop("Internal error! (Choice invalid?)"));
- break;
- }
- return;
- case DLG_EXIT_HELP:
- show_help(pos->option,
- pos->help);
- break;
- case DLG_EXIT_ESC:
- case DLG_EXIT_ERROR:
- case DLG_EXIT_CANCEL:
- default:
- return;
- }
- break;
+ /* begin single choice */
+ val = &pos->value;
+ i = 0;
+ while (val->String.legalRange[i] != NULL)
+ i++;
+ GE_ASSERT(ectx, i != 0);
+ items = MALLOC(sizeof(DIALOG_LISTITEM) * i);
+ i = 0;
+ msel = -1;
+
+ while (val->String.legalRange[i] != NULL) {
+ items[i].name = "";
+ items[i].text = val->String.legalRange[i];
+ items[i].help = "";
+ items[i].state = 0;
+ if (0 == strcmp(val->String.legalRange[i],
+ val->String.val)) {
+ items[i].state = 1;
+ msel = i;
+ }
+ if ( (msel == -1) &&
+ (0 == strcmp(val->String.legalRange[i],
+ val->String.def)) )
+ msel = i;
+ i++;
+ }
+ st = dlg_checklist(gettext(pos->option),
+ gettext(pos->description),
+ 20,
+ 70,
+ 13,
+ i,
+ items,
+ " *",
+ FLAG_RADIO,
+ &msel);
+ FREE(items);
+ switch (st) {
+ case DLG_EXIT_OK:
+ if (0 != GC_set_configuration_value_choice(cfg,
+ ectx,
+ pos->section,
+ pos->option,
+ val->String.legalRange[msel])) {
+ show_help(pos->option,
+ gettext_noop("Internal error! (Choice invalid?)"));
+ break;
+ }
+ return;
+ case DLG_EXIT_HELP:
+ show_help(pos->option,
+ pos->help);
+ break;
+ case DLG_EXIT_ESC:
+ case DLG_EXIT_ERROR:
+ case DLG_EXIT_CANCEL:
+ default:
+ return;
+ }
+ break;
case GNS_MC:
- /* begin multiple choice */
- val = &pos->value;
- i = 0;
- tlen = 2;
- while (val->String.legalRange[i] != NULL)
- i++;
- GE_ASSERT(ectx, i != 0);
- items = MALLOC(sizeof(DIALOG_LISTITEM) * i);
- i = 0;
- msel = 0;
- while (val->String.legalRange[i] != NULL) {
- items[i].name = "";
- items[i].text = val->String.legalRange[i];
- tlen += strlen(val->String.legalRange[i]) + 1;
- items[i].help = "";
- items[i].state = 0;
-
- tmp = val->String.val;
- while (NULL != (tmp = strstr(tmp,
- val->String.legalRange[i]))) {
- if ( ( (tmp == val->String.val) ||
- (tmp[-1] == ' ') ) &&
- ( (strlen(tmp) == strlen(val->String.legalRange[i])) ||
- (tmp[strlen(val->String.legalRange[i])] == ' ') ) ) {
- items[i].state = 1;
- break;
- }
- tmp++; /* make sure strstr advances */
- }
- i++;
- }
- st = dlg_checklist(gettext(pos->option),
- gettext(pos->description),
- 20,
- 70,
- 13,
- i,
- items,
- " *",
- FLAG_CHECK,
- &msel);
- switch (st) {
- case DLG_EXIT_OK:
- tmp = MALLOC(tlen);
- tmp[0] = '\0';
- i = 0;
- while (val->String.legalRange[i] != NULL) {
- if (items[i].state == 1) {
- strcat(tmp, items[i].text);
- strcat(tmp, " ");
- }
- i++;
- }
- if (strlen(tmp) > 0)
- tmp[strlen(tmp)-1] = '\0';
- if (0 != GC_set_configuration_value_choice(cfg,
- ectx,
- pos->section,
- pos->option,
- tmp)) {
- FREE(tmp);
- show_help(pos->option,
- gettext_noop("Internal error! (Choice invalid?)"));
- break;
- }
- FREE(tmp);
- FREE(items);
- return;
- case DLG_EXIT_HELP:
- show_help(pos->option,
- pos->help);
- break;
- case DLG_EXIT_ESC:
- case DLG_EXIT_ERROR:
- case DLG_EXIT_CANCEL:
- default:
- FREE(items);
- return;
- }
- FREE(items);
- break;
+ /* begin multiple choice */
+ val = &pos->value;
+ i = 0;
+ tlen = 2;
+ while (val->String.legalRange[i] != NULL)
+ i++;
+ GE_ASSERT(ectx, i != 0);
+ items = MALLOC(sizeof(DIALOG_LISTITEM) * i);
+ i = 0;
+ msel = 0;
+ while (val->String.legalRange[i] != NULL) {
+ items[i].name = "";
+ items[i].text = val->String.legalRange[i];
+ tlen += strlen(val->String.legalRange[i]) + 1;
+ items[i].help = "";
+ items[i].state = 0;
+
+ tmp = val->String.val;
+ while (NULL != (tmp = strstr(tmp,
+ val->String.legalRange[i]))) {
+ if ( ( (tmp == val->String.val) ||
+ (tmp[-1] == ' ') ) &&
+ ( (strlen(tmp) == strlen(val->String.legalRange[i])) ||
+ (tmp[strlen(val->String.legalRange[i])] == ' ') ) ) {
+ items[i].state = 1;
+ break;
+ }
+ tmp++; /* make sure strstr advances */
+ }
+ i++;
+ }
+ st = dlg_checklist(gettext(pos->option),
+ gettext(pos->description),
+ 20,
+ 70,
+ 13,
+ i,
+ items,
+ " *",
+ FLAG_CHECK,
+ &msel);
+ switch (st) {
+ case DLG_EXIT_OK:
+ tmp = MALLOC(tlen);
+ tmp[0] = '\0';
+ i = 0;
+ while (val->String.legalRange[i] != NULL) {
+ if (items[i].state == 1) {
+ strcat(tmp, items[i].text);
+ strcat(tmp, " ");
+ }
+ i++;
+ }
+ if (strlen(tmp) > 0)
+ tmp[strlen(tmp)-1] = '\0';
+ if (0 != GC_set_configuration_value_choice(cfg,
+ ectx,
+ pos->section,
+ pos->option,
+ tmp)) {
+ FREE(tmp);
+ show_help(pos->option,
+ gettext_noop("Internal error! (Choice invalid?)"));
+ break;
+ }
+ FREE(tmp);
+ FREE(items);
+ return;
+ case DLG_EXIT_HELP:
+ show_help(pos->option,
+ pos->help);
+ break;
+ case DLG_EXIT_ESC:
+ case DLG_EXIT_ERROR:
+ case DLG_EXIT_CANCEL:
+ default:
+ FREE(items);
+ return;
+ }
+ FREE(items);
+ break;
case GNS_Double:
- fitem.text = MALLOC(64);
- SNPRINTF(fitem.text,
- 64,
- "%f",
- pos->value.Double.val);
- fitem.text_len = strlen(fitem.text);
- fitem.help = pos->help;
- st = DLG_EXIT_HELP;
- msel = 0;
- st = dlg_form(pos->option,
- "",
- 20,
- 70,
- 15,
- 1,
- &fitem,
- &msel);
- switch (st) {
- case DLG_EXIT_OK:
- if (1 != sscanf(fitem.text,
- "%lf",
- &dval)) {
- show_help(pos->option,
- gettext_noop("Invalid input, expecting floating point
value."));
- break;
- }
- if (0 != GC_set_configuration_value_string(cfg,
- ectx,
- pos->section,
- pos->option,
- fitem.text)) {
- show_help(pos->option,
- gettext_noop("Internal error! (Value invalid?)"));
- break;
- }
- FREE(fitem.text);
- return;
- case DLG_EXIT_HELP:
- show_help(pos->option, pos->help);
- break;
- default:
- break;
- }
- FREE(fitem.text);
- break;
+ fitem.text = MALLOC(64);
+ SNPRINTF(fitem.text,
+ 64,
+ "%f",
+ pos->value.Double.val);
+ fitem.text_len = strlen(fitem.text);
+ fitem.help = pos->help;
+ st = DLG_EXIT_HELP;
+ msel = 0;
+ st = dlg_form(pos->option,
+ "",
+ 20,
+ 70,
+ 15,
+ 1,
+ &fitem,
+ &msel);
+ switch (st) {
+ case DLG_EXIT_OK:
+ if (1 != sscanf(fitem.text,
+ "%lf",
+ &dval)) {
+ show_help(pos->option,
+ gettext_noop("Invalid input, expecting floating point value."));
+ break;
+ }
+ if (0 != GC_set_configuration_value_string(cfg,
+ ectx,
+ pos->section,
+ pos->option,
+ fitem.text)) {
+ show_help(pos->option,
+ gettext_noop("Internal error! (Value invalid?)"));
+ break;
+ }
+ FREE(fitem.text);
+ return;
+ case DLG_EXIT_HELP:
+ show_help(pos->option, pos->help);
+ break;
+ default:
+ break;
+ }
+ FREE(fitem.text);
+ break;
case GNS_UInt64:
- fitem.text = MALLOC(64);
- SNPRINTF(fitem.text,
- 64,
- "%llu",
- pos->value.UInt64.val);
- fitem.text_len = strlen(fitem.text);
- fitem.help = pos->help;
- st = DLG_EXIT_HELP;
- msel = 0;
- while (st == DLG_EXIT_HELP) {
- st = dlg_form(pos->option,
- "",
- 20,
- 70,
- 15,
- 1,
- &fitem,
- &msel);
- switch (st) {
- case DLG_EXIT_OK:
- if (1 != sscanf(fitem.text,
- "%llu",
- &lval)) {
- show_help(pos->option,
- gettext_noop("Invalid input, expecting integer."));
- continue;
- }
- if ( (lval < pos->value.UInt64.min) ||
- (lval > pos->value.UInt64.max)) {
- show_help(pos->option,
- gettext_noop("Value is not in legal range."));
- continue;
- }
- if (0 != GC_set_configuration_value_number(cfg,
- ectx,
- pos->section,
- pos->option,
- lval)) {
- show_help(pos->option,
- gettext_noop("Internal error! (Choice invalid?)"));
- continue;
- }
- break;
- case DLG_EXIT_HELP:
- show_help(pos->option, pos->help);
- break;
- default:
- break;
- }
- }
- FREE(fitem.text);
- return;
+ fitem.text = MALLOC(64);
+ SNPRINTF(fitem.text,
+ 64,
+ "%llu",
+ pos->value.UInt64.val);
+ fitem.text_len = strlen(fitem.text);
+ fitem.help = pos->help;
+ st = DLG_EXIT_HELP;
+ msel = 0;
+ while (st == DLG_EXIT_HELP) {
+ st = dlg_form(pos->option,
+ "",
+ 20,
+ 70,
+ 15,
+ 1,
+ &fitem,
+ &msel);
+ switch (st) {
+ case DLG_EXIT_OK:
+ if (1 != sscanf(fitem.text,
+ "%llu",
+ &lval)) {
+ show_help(pos->option,
+ gettext_noop("Invalid input, expecting integer."));
+ continue;
+ }
+ if ( (lval < pos->value.UInt64.min) ||
+ (lval > pos->value.UInt64.max)) {
+ show_help(pos->option,
+ gettext_noop("Value is not in legal range."));
+ continue;
+ }
+ if (0 != GC_set_configuration_value_number(cfg,
+ ectx,
+ pos->section,
+ pos->option,
+ lval)) {
+ show_help(pos->option,
+ gettext_noop("Internal error! (Choice invalid?)"));
+ continue;
+ }
+ break;
+ case DLG_EXIT_HELP:
+ show_help(pos->option, pos->help);
+ break;
+ default:
+ break;
+ }
+ }
+ FREE(fitem.text);
+ return;
default:
- GE_BREAK(ectx, 0);
- return;
+ GE_BREAK(ectx, 0);
+ return;
} /* end switch type & type */
break;
@@ -488,13 +488,13 @@
int mconf_mainsetup_curses(int argc,
- const char **argv,
- struct PluginHandle * self,
- struct GE_Context * e,
- struct GC_Configuration * cfg,
- struct GNS_Context * gns,
- const char * filename,
- int is_daemon) {
+ const char **argv,
+ struct PluginHandle * self,
+ struct GE_Context * e,
+ struct GC_Configuration * cfg,
+ struct GNS_Context * gns,
+ const char * filename,
+ int is_daemon) {
int ret;
struct termios ios_org;
@@ -509,8 +509,8 @@
init_dialog(stdin, stderr);
run_menu(gns,
- GNS_get_tree(gns),
- cfg);
+ GNS_get_tree(gns),
+ cfg);
ret = 0;
if ( (0 == GC_test_dirty(cfg)) &&
@@ -520,16 +520,16 @@
} else {
dialog_vars.help_button = 0;
ret = dialog_yesno(NULL,
- _("Do you wish to save your new configuration?"),
- 5, 60);
+ _("Do you wish to save your new configuration?"),
+ 5, 60);
end_dialog();
if (ret == DLG_EXIT_OK) {
if (0 != GC_write_configuration(cfg,
- filename)) {
- /* error message already printed... */
- ret = 1;
+ filename)) {
+ /* error message already printed... */
+ ret = 1;
} else {
- ret = 0;
+ ret = 0;
}
printf(_("\nEnd of configuration.\n"));
} else {
Modified: GNUnet/src/setup/ncurses/wizard_curs.c
===================================================================
--- GNUnet/src/setup/ncurses/wizard_curs.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/setup/ncurses/wizard_curs.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -56,45 +56,45 @@
static const char * cfg_fn;
static void showCursErr(const char * prefix,
- const char * error) {
+ const char * error) {
char * err;
-
+
err = MALLOC(strlen(prefix) + strlen(error) + 2);
sprintf(err,
- "%s %s",
- prefix,
- error);
+ "%s %s",
+ prefix,
+ error);
dialog_msgbox(_("Error"),
- err,
- 70,
- 15,
- 1);
- FREE(err);
+ err,
+ 70,
+ 15,
+ 1);
+ FREE(err);
}
static void show_help(const char * helptext) {
dialog_vars.help_button = 0;
dialog_msgbox(_("Help"),
- helptext,
- 20,
- 70,
- TRUE);
+ helptext,
+ 20,
+ 70,
+ TRUE);
}
static void show_error(const char * msg) {
dialog_vars.help_button = 0;
dialog_msgbox(_("Error!"),
- msg,
- 20,
- 70,
- TRUE);
+ msg,
+ 20,
+ 70,
+ TRUE);
}
static int query_yesno(const char * title,
- const char * question,
- const char * help,
- const char * section,
- const char * option) {
+ const char * question,
+ const char * help,
+ const char * section,
+ const char * option) {
int ret;
if (help == NULL)
@@ -104,22 +104,22 @@
dialog_vars.cancel_label = _("No");
dialog_vars.ok_label = _("Yes");
while (true) {
- ret = dialog_yesno(title,
- question,
- 20,
- 70);
+ ret = dialog_yesno(title,
+ question,
+ 20,
+ 70);
switch(ret) {
case DLG_EXIT_OK:
case DLG_EXIT_CANCEL:
if (0 != GC_set_configuration_value_string(cfg,
- ectx,
- section,
- option,
- ret == DLG_EXIT_OK
- ? "YES"
- : "NO")) {
- show_error(_("Internal error! (Choice invalid?)"));
- break;
+ ectx,
+ section,
+ option,
+ ret == DLG_EXIT_OK
+ ? "YES"
+ : "NO")) {
+ show_error(_("Internal error! (Choice invalid?)"));
+ break;
}
return 1; /* advance */
case DLG_EXIT_ESC:
@@ -137,11 +137,11 @@
}
static int query_string(const char * title,
- const char * question,
- const char * help,
- const char * section,
- const char * option,
- const char * def) {
+ const char * question,
+ const char * help,
+ const char * section,
+ const char * option,
+ const char * def) {
int ret;
int msel;
DIALOG_FORMITEM fitem;
@@ -166,7 +166,7 @@
fitem.help_free = 0;
fitem.text = MALLOC(65536);
strcpy(fitem.text,
- def);
+ def);
fitem.text_len = strlen(fitem.text);
fitem.help = STRDUP(help);
msel = 0;
@@ -174,24 +174,24 @@
ret = 2;
while (ret == 2) {
ret = dlg_form(title,
- "",
- 20,
- 70,
- 15,
- 1,
- &fitem,
- &msel);
+ "",
+ 20,
+ 70,
+ 15,
+ 1,
+ &fitem,
+ &msel);
switch(ret) {
case DLG_EXIT_OK:
if (0 != GC_set_configuration_value_string(cfg,
- ectx,
- section,
- option,
- fitem.text)) {
- show_error(_("Internal error! (Choice invalid?)"));
- ret = 2;
+ ectx,
+ section,
+ option,
+ fitem.text)) {
+ show_error(_("Internal error! (Choice invalid?)"));
+ ret = 2;
} else {
- ret = 1; /* advance */
+ ret = 1; /* advance */
}
break;
case DLG_EXIT_CANCEL:
@@ -220,28 +220,28 @@
static int welcome() {
dialog_vars.help_button = 0;
dialog_msgbox(_("GNUnet configuration"),
- _("Welcome to GNUnet!\n\nThis assistant will ask you a few
basic questions "
- "in order to configure GNUnet.\n\nPlease visit our homepage
at\n\t"
- "http://gnunet.org/\nand join our community at\n\t"
- "http://gnunet.org/drupal/\n\nHave a lot of fun,\n\nthe
GNUnet team"),
- 20,
- 70,
- TRUE);
+ _("Welcome to GNUnet!\n\nThis assistant will ask you a few basic
questions "
+ "in order to configure GNUnet.\n\nPlease visit our homepage at\n\t"
+ "http://gnunet.org/\nand join our community at\n\t"
+ "http://gnunet.org/drupal/\n\nHave a lot of fun,\n\nthe GNUnet team"),
+ 20,
+ 70,
+ TRUE);
return 1;
}
#define MAX_NIC 64
static int insert_nic_curs(const char * name,
- int defaultNIC,
- void * cls) {
+ int defaultNIC,
+ void * cls) {
DIALOG_LISTITEM * nic_items = cls;
DIALOG_LISTITEM * item;
unsigned int pos;
pos = 0;
while ( (pos < MAX_NIC) &&
- (nic_items[pos].text != NULL) )
+ (nic_items[pos].text != NULL) )
pos++;
if (pos == MAX_NIC)
return SYSERR;
@@ -273,14 +273,14 @@
fitem.text_free = 0;
fitem.help_free = 0;
memset(nic_items,
- 0,
- sizeof(DIALOG_LISTITEM) * MAX_NIC);
+ 0,
+ sizeof(DIALOG_LISTITEM) * MAX_NIC);
os_list_network_interfaces(NULL,
- &insert_nic_curs,
- nic_items);
+ &insert_nic_curs,
+ nic_items);
total = 0;
while ( (total < MAX_NIC) &&
- (nic_items[total].text != NULL) ) {
+ (nic_items[total].text != NULL) ) {
if (nic_items[total].state)
msel = total;
total++;
@@ -288,165 +288,165 @@
if (total > 0) {
while (true) {
ret = dlg_menu(_("GNUnet configuration"),
- _("Choose the network interface that connects your
computer to "
- "the internet from the list below."),
- 20,
- 70,
- 10,
- total,
- nic_items,
- &msel,
- NULL);
+ _("Choose the network interface that connects your computer to "
+ "the internet from the list below."),
+ 20,
+ 70,
+ 10,
+ total,
+ nic_items,
+ &msel,
+ NULL);
switch (ret) {
case DLG_EXIT_OK:
- if (0 != GC_set_configuration_value_choice(cfg,
- ectx,
- "NETWORK",
- "INTERFACE",
- nic_items[msel].name)) {
- show_error(_("Internal error! (Choice invalid?)"));
- break;
- }
- return 1;
+ if (0 != GC_set_configuration_value_choice(cfg,
+ ectx,
+ "NETWORK",
+ "INTERFACE",
+ nic_items[msel].name)) {
+ show_error(_("Internal error! (Choice invalid?)"));
+ break;
+ }
+ return 1;
case DLG_EXIT_HELP:
- show_help(_("The \"Network interface\" is the device "
- "that connects your computer to the internet. This is
usually a modem, "
- "an ISDN card or a network card in case you are using
DSL."));
- break;
+ show_help(_("The \"Network interface\" is the device "
+ "that connects your computer to the internet. This is usually a
modem, "
+ "an ISDN card or a network card in case you are using DSL."));
+ break;
case DLG_EXIT_ESC:
case DLG_EXIT_ERROR:
case DLG_EXIT_CANCEL:
- return 0;
+ return 0;
}
}
}
return query_string(_("Network configuration: interface"),
- _("What is the name of the network interface that
connects your computer to the Internet?"),
- _("The \"Network interface\" is the device "
- "that connects your computer to the internet. This is
usually a modem, "
- "an ISDN card or a network card in case you are using
DSL."),
- "NETWORK",
- "INTERFACE",
- "eth0");
+ _("What is the name of the network interface that connects your
computer to the Internet?"),
+ _("The \"Network interface\" is the device "
+ "that connects your computer to the internet. This is usually a
modem, "
+ "an ISDN card or a network card in case you are using DSL."),
+ "NETWORK",
+ "INTERFACE",
+ "eth0");
}
static int nat_limited() {
/* TODO: try autodetect! */
return query_yesno(_("Network configuration: NAT"),
- _("Is this machine behind "
- "NAT?\n\nIf you are connected to the internet through
another computer "
- "doing SNAT, a router or a \"hardware firewall\" and
other computers "
- "on the internet cannot connect to this computer, say
\"yes\" here. "
- "Answer \"no\" on direct connections through modems,
ISDN cards and "
- "DNAT (also known as \"port forwarding\")."),
- NULL,
- "NAT",
- "LIMITED");
+ _("Is this machine behind "
+ "NAT?\n\nIf you are connected to the internet through another
computer "
+ "doing SNAT, a router or a \"hardware firewall\" and other
computers "
+ "on the internet cannot connect to this computer, say \"yes\"
here. "
+ "Answer \"no\" on direct connections through modems, ISDN cards
and "
+ "DNAT (also known as \"port forwarding\")."),
+ NULL,
+ "NAT",
+ "LIMITED");
}
static int ip_address() {
/* TODO: try autodetect! */
return query_string(_("Network configuration: IP"),
- _("What is this computer's public IP address or
hostname?"),
- _("If your provider always assigns the same "
- "IP-Address to you (a \"static\" IP-Address), enter it
into the "
- "\"IP-Address\" field. If your IP-Address changes every
now and then "
- "(\"dynamic\" IP-Address) but there's a hostname that
always points "
- "to your actual IP-Address (\"Dynamic DNS\"), you can
also enter it "
- "here.\n"
- "If left empty, GNUnet will try to automatically detect
the IP.\n"
- "You can specify a hostname, GNUnet will then use DNS
to resolve it.\n"
- "If in doubt, leave this empty."),
- "NETWORK",
- "IP",
- "");
+ _("What is this computer's public IP address or hostname?"),
+ _("If your provider always assigns the same "
+ "IP-Address to you (a \"static\" IP-Address), enter it into the
"
+ "\"IP-Address\" field. If your IP-Address changes every now and
then "
+ "(\"dynamic\" IP-Address) but there's a hostname that always
points "
+ "to your actual IP-Address (\"Dynamic DNS\"), you can also
enter it "
+ "here.\n"
+ "If left empty, GNUnet will try to automatically detect the
IP.\n"
+ "You can specify a hostname, GNUnet will then use DNS to
resolve it.\n"
+ "If in doubt, leave this empty."),
+ "NETWORK",
+ "IP",
+ "");
}
static int network_load_up() {
return query_string(_("Bandwidth configuration: upload"),
- _("How much upstream bandwidth (in bytes/s) may be
used?"),
- _("You can limit GNUnet's resource usage "
- "here.\n\nThe \"upstream\" is the data channel through
which data "
- "is *sent* to the internet. The limit is the maximum
amount"
- "which GNUnet is allowed to use. If you have a
flatrate, you can set it to "
- "the maximum speed of your internet connection. You
should not use a value "
- "that is higher than what your actual connection
allows."),
- "LOAD",
- "MAXNETUPBPSTOTAL",
- "50000");
+ _("How much upstream bandwidth (in bytes/s) may be used?"),
+ _("You can limit GNUnet's resource usage "
+ "here.\n\nThe \"upstream\" is the data channel through which
data "
+ "is *sent* to the internet. The limit is the maximum amount"
+ "which GNUnet is allowed to use. If you have a flatrate, you
can set it to "
+ "the maximum speed of your internet connection. You should not
use a value "
+ "that is higher than what your actual connection allows."),
+ "LOAD",
+ "MAXNETUPBPSTOTAL",
+ "50000");
}
static int network_load_down() {
return query_string(_("Bandwidth configuration: download"),
- _("How much downstream bandwidth (in bytes/s) may be
used?"),
- _("You can limit GNUnet's resource usage "
- "here.\n\nThe \"downstream\" is the data channel
through which data "
- "is *received* from the internet. The limit is the
maximum amount"
- "which GNUnet is allowed to use. If you have a
flatrate, you can set it to "
- "the maximum speed of your internet connection. You
should not use a value "
- "that is higher than what your actual connection
allows."),
- "LOAD",
- "MAXNETDOWNBPSTOTAL",
- "50000");
+ _("How much downstream bandwidth (in bytes/s) may be used?"),
+ _("You can limit GNUnet's resource usage "
+ "here.\n\nThe \"downstream\" is the data channel through which
data "
+ "is *received* from the internet. The limit is the maximum
amount"
+ "which GNUnet is allowed to use. If you have a flatrate, you
can set it to "
+ "the maximum speed of your internet connection. You should not
use a value "
+ "that is higher than what your actual connection allows."),
+ "LOAD",
+ "MAXNETDOWNBPSTOTAL",
+ "50000");
}
static int disk_quota() {
return query_string(_("Quota configuration"),
- _("What is the maximum size of the datastore in MB?"),
- _("The GNUnet datastore contains all content that "
- "GNUnet needs to store (indexed, inserted and migrated
content)."),
- "FS",
- "QUOTA",
- "1024");
+ _("What is the maximum size of the datastore in MB?"),
+ _("The GNUnet datastore contains all content that "
+ "GNUnet needs to store (indexed, inserted and migrated
content)."),
+ "FS",
+ "QUOTA",
+ "1024");
}
static int user() {
if (YES != os_modify_user(YES,
- YES,
- "gnunet",
- "gnunet"))
+ YES,
+ "gnunet",
+ "gnunet"))
return last; /* ignore option */
return query_string(_("Daemon configuration: user account"),
- _("As which user should gnunetd be run?"),
- _("For security reasons, it is a good idea to let this
setup create "
- "a new user account under which the GNUnet service is
started "
- "at system startup.\n\n"
- "However, GNUnet may not be able to access files other
than its own. "
- "This includes files you want to publish in GNUnet.
You'll have to "
- "grant read permissions to the user specified
below.\n\n"
- "Leave the field empty to run GNUnet with system
privileges.\n"),
- "GNUNETD",
- "USER",
- "gnunet");
+ _("As which user should gnunetd be run?"),
+ _("For security reasons, it is a good idea to let this setup
create "
+ "a new user account under which the GNUnet service is started "
+ "at system startup.\n\n"
+ "However, GNUnet may not be able to access files other than its
own. "
+ "This includes files you want to publish in GNUnet. You'll have
to "
+ "grant read permissions to the user specified below.\n\n"
+ "Leave the field empty to run GNUnet with system
privileges.\n"),
+ "GNUNETD",
+ "USER",
+ "gnunet");
}
static int group() {
if (YES != os_modify_user(YES,
- YES,
- "gnunet",
- "gnunet"))
+ YES,
+ "gnunet",
+ "gnunet"))
return last; /* ignore option */
return query_string(_("Daemon configuration: group account"),
- _("As which group should gnunetd be run?"),
- _("For security reasons, it is a good idea to let this
setup create "
- "a new group for the chosen user account.\n\n"
- "You can also specify a already existant group
here.\n\n"
- "Only members of this group will be allowed to start
and stop the "
- "the GNUnet server and have access to GNUnet server
data.\n"),
- "GNUNETD",
- "GROUP",
- "gnunet");
+ _("As which group should gnunetd be run?"),
+ _("For security reasons, it is a good idea to let this setup
create "
+ "a new group for the chosen user account.\n\n"
+ "You can also specify a already existant group here.\n\n"
+ "Only members of this group will be allowed to start and stop
the "
+ "the GNUnet server and have access to GNUnet server data.\n"),
+ "GNUNETD",
+ "GROUP",
+ "gnunet");
}
static int autostart() {
return query_yesno(_("GNUnet configuration"),
- _("Do you want to automatically launch GNUnet as a system
service?"),
- _("If you say \"yes\" here, the GNUnet background process
will be "
- "automatically started when you turn on your computer.
If you say \"no\""
- " here, you have to launch GNUnet yourself each time you
want to use it."),
- "GNUNETD",
- "AUTOSTART");
+ _("Do you want to automatically launch GNUnet as a system
service?"),
+ _("If you say \"yes\" here, the GNUnet background process will be "
+ "automatically started when you turn on your computer. If you
say \"no\""
+ " here, you have to launch GNUnet yourself each time you want to
use it."),
+ "GNUNETD",
+ "AUTOSTART");
}
/**
@@ -471,41 +471,41 @@
}
user_name = NULL;
GC_get_configuration_value_string(cfg,
- "GNUNETD",
- "USER",
- "",
- &user_name);
+ "GNUNETD",
+ "USER",
+ "",
+ &user_name);
GC_get_configuration_value_string(cfg,
- "GNUNETD",
- "GROUP",
- "",
- &group_name);
+ "GNUNETD",
+ "GROUP",
+ "",
+ &group_name);
if ( ( (strlen(user_name) > 0) ||
- (strlen(group_name) > 0) ) &&
+ (strlen(group_name) > 0) ) &&
(OK == os_modify_user(YES,
- YES,
- user_name,
- group_name)) &&
+ YES,
+ user_name,
+ group_name)) &&
(OK != os_modify_user(NO,
- YES,
- user_name,
- group_name)) ) {
+ YES,
+ user_name,
+ group_name)) ) {
showCursErr(_("Unable to create user account for daemon."),
- "");
+ "");
ret = SYSERR;
- }
+ }
if ( (YES == GC_get_configuration_value_yesno(cfg,
- "GNUNETD",
- "AUTOSTART",
- NO)) &&
+ "GNUNETD",
+ "AUTOSTART",
+ NO)) &&
(YES != os_modify_autostart(ectx,
- NO,
- YES,
- "gnunetd", /* specify full path? */
- user_name,
- group_name)) ) {
+ NO,
+ YES,
+ "gnunetd", /* specify full path? */
+ user_name,
+ group_name)) ) {
showCursErr(_("Unable to setup autostart for daemon."),
- "");
+ "");
ret = SYSERR;
}
FREE(user_name);
@@ -519,9 +519,9 @@
/* TODO: check configuration changed! */
dialog_vars.help_button = 0;
ret = dialog_yesno(_("Save configuration?"),
- _("Save configuration now?"),
- 5,
- 60);
+ _("Save configuration now?"),
+ 5,
+ 60);
switch(ret) {
case DLG_EXIT_OK:
if (OK != finish())
@@ -541,13 +541,13 @@
}
int wizard_curs_mainsetup_curses(int argc,
- const char **argv,
- struct PluginHandle * self,
- struct GE_Context * e,
- struct GC_Configuration * c,
- struct GNS_Context * gns,
- const char * filename,
- int is_daemon) {
+ const char **argv,
+ struct PluginHandle * self,
+ struct GE_Context * e,
+ struct GC_Configuration * c,
+ struct GNS_Context * gns,
+ const char * filename,
+ int is_daemon) {
struct termios ios_org;
unsigned int phase;
int ret;
Modified: GNUnet/src/setup/text/conf.c
===================================================================
--- GNUnet/src/setup/text/conf.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/setup/text/conf.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -52,8 +52,8 @@
* printf with indentation
*/
static void iprintf(int indent,
- const char * format,
- ...) {
+ const char * format,
+ ...) {
int i;
va_list va;
@@ -66,7 +66,7 @@
}
static char * getValueAsString(GNS_Type type,
- GNS_Value * val) {
+ GNS_Value * val) {
char buf[92];
switch (type & GNS_TypeMask) {
@@ -80,32 +80,32 @@
return STRDUP(val->String.val);
case GNS_Double:
SNPRINTF(buf, 92,
- "%f",
- val->Double.val);
+ "%f",
+ val->Double.val);
return STRDUP(buf);
case GNS_UInt64:
SNPRINTF(buf, 92,
- "%llu",
- val->UInt64.val);
+ "%llu",
+ val->UInt64.val);
return STRDUP(buf);
}
return STRDUP("Internal error.");
}
static void printChoice(int indent,
- GNS_Type type,
- GNS_Value * val) {
+ GNS_Type type,
+ GNS_Value * val) {
int i;
char defLet;
switch (type & GNS_TypeMask) {
case GNS_Boolean:
iprintf(indent,
- _("\tEnter yes (%s), no (%s) or help (%s): "),
- val->Boolean.def ? "Y" : "y",
- val->Boolean.def ? "n" : "N",
- "d",
- "?");
+ _("\tEnter yes (%s), no (%s) or help (%s): "),
+ val->Boolean.def ? "Y" : "y",
+ val->Boolean.def ? "n" : "N",
+ "d",
+ "?");
break;
case GNS_String:
case GNS_MC:
@@ -113,53 +113,53 @@
defLet = '\0';
if (val->String.legalRange[0] != NULL)
iprintf(indent,
- _("\tPossible choices:\n"));
+ _("\tPossible choices:\n"));
while (val->String.legalRange[i] != NULL) {
iprintf(indent,
- "\t %s\n",
- val->String.legalRange[i]);
+ "\t %s\n",
+ val->String.legalRange[i]);
i++;
}
iprintf(indent,
- _("\tUse single space prefix to avoid conflicts with hotkeys!\n"));
+ _("\tUse single space prefix to avoid conflicts with hotkeys!\n"));
iprintf(indent,
- _("\tEnter string (type '%s' for default value `%s'): "),
- "d",
- val->String.def);
+ _("\tEnter string (type '%s' for default value `%s'): "),
+ "d",
+ val->String.def);
break;
case GNS_SC:
i = 0;
defLet = '\0';
while (val->String.legalRange[i] != NULL) {
iprintf(indent,
- "\t (%c) %s\n",
- (i < 10) ? '0' + i : 'a' + i - 10,
- val->String.legalRange[i]);
+ "\t (%c) %s\n",
+ (i < 10) ? '0' + i : 'a' + i - 10,
+ val->String.legalRange[i]);
if (0 == strcmp(val->String.legalRange[i],
- val->String.def))
- defLet = (i < 10) ? '0' + i : 'a' + i - 10;
+ val->String.def))
+ defLet = (i < 10) ? '0' + i : 'a' + i - 10;
i++;
}
GE_ASSERT(NULL, defLet != '\0');
iprintf(indent,
- "\n\t (?) Help\n");
+ "\n\t (?) Help\n");
iprintf(indent,
- _("\t Enter choice (default is %c): "),
- defLet);
+ _("\t Enter choice (default is %c): "),
+ defLet);
break;
case GNS_Double:
iprintf(indent,
- _("\tEnter floating point (type '%s' for default value %f): "),
- "d",
- val->Double.def);
+ _("\tEnter floating point (type '%s' for default value %f): "),
+ "d",
+ val->Double.def);
break;
case GNS_UInt64:
iprintf(indent,
- _("\tEnter unsigned integer in interval [%llu,%llu] (type '%s' for
default value %llu): "),
- val->UInt64.min,
- val->UInt64.max,
- "d",
- val->UInt64.def);
+ _("\tEnter unsigned integer in interval [%llu,%llu] (type '%s' for
default value %llu): "),
+ val->UInt64.min,
+ val->UInt64.max,
+ "d",
+ val->UInt64.def);
break;
default:
return;
@@ -170,7 +170,7 @@
* @return OK on success, NO to display help, SYSERR to abort
*/
static int readValue(GNS_Type type,
- GNS_Value * val) {
+ GNS_Value * val) {
int c;
char buf[1024];
int i;
@@ -183,26 +183,26 @@
c = rd();
switch (c) {
case '\n':
- printf("\n");
- return YES; /* skip */
+ printf("\n");
+ return YES; /* skip */
case 'y':
case 'Y':
- val->Boolean.val = 1;
- printf(_("Yes\n"));
- return YES;
+ val->Boolean.val = 1;
+ printf(_("Yes\n"));
+ return YES;
case 'n':
case 'N':
- val->Boolean.val = 0;
- printf(_("No\n"));
- return YES;
+ val->Boolean.val = 0;
+ printf(_("No\n"));
+ return YES;
case '?':
- printf(_("Help\n"));
- return NO;
+ printf(_("Help\n"));
+ return NO;
case 'q':
- printf(_("Abort\n"));
- return SYSERR;
+ printf(_("Abort\n"));
+ return SYSERR;
default:
- break;
+ break;
}
}
break;
@@ -212,41 +212,41 @@
while (1) {
buf[i] = rd();
if (buf[i] == 'q') {
- printf(_("Abort\n"));
- return SYSERR;
+ printf(_("Abort\n"));
+ return SYSERR;
}
#if 0
if (buf[i] == '\b') {
- if (i > 0) {
- printf("\b"); /* this does not work */
- i--;
- }
- continue;
+ if (i > 0) {
+ printf("\b"); /* this does not work */
+ i--;
+ }
+ continue;
}
-#endif
+#endif
if ( (buf[i] == 'd') && (i == 0) ) {
- printf("%s\n",
- val->String.def);
- FREE(val->String.val);
- val->String.val = STRDUP(val->String.def);
- return YES;
+ printf("%s\n",
+ val->String.def);
+ FREE(val->String.val);
+ val->String.val = STRDUP(val->String.def);
+ return YES;
}
if ( (buf[i] == '?') && (i == 0) ) {
- printf(_("Help\n"));
- return NO;
+ printf(_("Help\n"));
+ return NO;
}
if ( (buf[i] == '\n') && (i == 0) ) {
- printf("%s\n",
- val->String.val);
- return YES; /* keep */
+ printf("%s\n",
+ val->String.val);
+ return YES; /* keep */
}
if (buf[i] != '\n') {
- if (i < 1023) {
- printf("%c", buf[i]);
- fflush(stdout);
- i++;
- }
- continue;
+ if (i < 1023) {
+ printf("%c", buf[i]);
+ fflush(stdout);
+ i++;
+ }
+ continue;
}
break;
}
@@ -258,36 +258,36 @@
while (1) {
c = rd();
if (c == '?') {
- printf(_("Help\n"));
- return NO;
+ printf(_("Help\n"));
+ return NO;
}
if (c == '\n') {
- printf("%s\n",
- val->String.val);
- return YES;
+ printf("%s\n",
+ val->String.val);
+ return YES;
}
if (c == 'q') {
- printf(_("Abort\n"));
- return SYSERR;
+ printf(_("Abort\n"));
+ return SYSERR;
}
i = -1;
if ( (c >= '0') && (c <= '9') )
- i = c - '0';
+ i = c - '0';
else if ( (c >= 'a') && (c <= 'z') )
- i = c - 'a' + 10;
+ i = c - 'a' + 10;
else
- continue; /* invalid entry */
+ continue; /* invalid entry */
for (j=0;j<=i;j++)
- if (val->String.legalRange[j] == NULL) {
- i = -1;
- break;
- }
+ if (val->String.legalRange[j] == NULL) {
+ i = -1;
+ break;
+ }
if (i == -1)
- continue; /* invalid entry */
+ continue; /* invalid entry */
FREE(val->String.val);
val->String.val = STRDUP(val->String.legalRange[i]);
printf("%s\n",
- val->String.val);
+ val->String.val);
return OK;
}
/* unreachable */
@@ -296,47 +296,47 @@
while (1) {
buf[i] = rd();
if (buf[i] == 'q') {
- printf(_("Abort\n"));
- return SYSERR;
+ printf(_("Abort\n"));
+ return SYSERR;
}
#if 0
if (buf[i] == '\b') {
- if (i > 0) {
- printf("\b"); /* this does not work */
- i--;
- }
- continue;
+ if (i > 0) {
+ printf("\b"); /* this does not work */
+ i--;
+ }
+ continue;
}
#endif
if ( (buf[i] == 'd') && (i == 0) ) {
- val->Double.val = val->Double.def;
- printf("%f\n",
- val->Double.val);
- return YES; /* default */
+ val->Double.val = val->Double.def;
+ printf("%f\n",
+ val->Double.val);
+ return YES; /* default */
}
if (buf[i] == '?') {
- printf(_("Help\n"));
- return NO;
+ printf(_("Help\n"));
+ return NO;
}
if (buf[i] != '\n') {
- if (i < 1023) {
- printf("%c", buf[i]);
- fflush(stdout);
- i++;
- }
- continue;
+ if (i < 1023) {
+ printf("%c", buf[i]);
+ fflush(stdout);
+ i++;
+ }
+ continue;
}
if (i == 0) {
- printf("%f\n",
- val->Double.val);
- return YES; /* keep */
+ printf("%f\n",
+ val->Double.val);
+ return YES; /* keep */
}
buf[i+1] = '\0';
if (1 == sscanf(buf,
- "%lf",
- &val->Double.val)) {
- printf("\n");
- return OK;
+ "%lf",
+ &val->Double.val)) {
+ printf("\n");
+ return OK;
}
i = 0;
printf(_("\nInvalid entry, try again (use '?' for help): "));
@@ -348,50 +348,50 @@
while (1) {
buf[i] = rd();
if (buf[i] == 'q') {
- printf(_("Abort\n"));
- return SYSERR;
+ printf(_("Abort\n"));
+ return SYSERR;
}
#if 0
if (buf[i] == '\b') {
- if (i > 0) {
- printf("\b"); /* does not work */
- i--;
- }
- continue;
+ if (i > 0) {
+ printf("\b"); /* does not work */
+ i--;
+ }
+ continue;
}
#endif
if ( (buf[i] == 'd') && (i == 0) ) {
- val->UInt64.val = val->UInt64.def;
- printf("%llu\n",
- val->UInt64.val);
- return YES; /* default */
+ val->UInt64.val = val->UInt64.def;
+ printf("%llu\n",
+ val->UInt64.val);
+ return YES; /* default */
}
if (buf[i] == '?') {
- printf(_("Help\n"));
- return NO;
+ printf(_("Help\n"));
+ return NO;
}
if (buf[i] != '\n') {
- if (i < 1023) {
- printf("%c", buf[i]);
- fflush(stdout);
- i++;
- }
- continue;
+ if (i < 1023) {
+ printf("%c", buf[i]);
+ fflush(stdout);
+ i++;
+ }
+ continue;
}
if (i == 0) {
- printf("%llu\n",
- val->UInt64.val);
- return YES; /* keep */
+ printf("%llu\n",
+ val->UInt64.val);
+ return YES; /* keep */
}
buf[i+1] = '\0';
if ( (1 == sscanf(buf,
- "%llu",
- &l)) &&
- (l >= val->UInt64.min) &&
- (l <= val->UInt64.max) ) {
- val->UInt64.val = l;
- printf("\n");
- return OK;
+ "%llu",
+ &l)) &&
+ (l >= val->UInt64.min) &&
+ (l <= val->UInt64.max) ) {
+ val->UInt64.val = l;
+ printf("\n");
+ return OK;
}
i = 0;
printf(_("\nInvalid entry, try again (use '?' for help): "));
@@ -400,17 +400,17 @@
break;
default:
fprintf(stderr,
- _("Unknown kind %x (internal error). Skipping option.\n"),
- type & GNS_TypeMask);
+ _("Unknown kind %x (internal error). Skipping option.\n"),
+ type & GNS_TypeMask);
return OK;
}
return OK;
}
static int conf(int indent,
- struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- struct GNS_Tree * tree) {
+ struct GC_Configuration * cfg,
+ struct GE_Context * ectx,
+ struct GNS_Tree * tree) {
char choice;
char * value;
char * ovalue;
@@ -421,47 +421,47 @@
switch (tree->type & GNS_KindMask) {
case GNS_Leaf:
ovalue = getValueAsString(tree->type,
- &tree->value);
+ &tree->value);
while (1) {
iprintf(indent,
- "[%s] %s = \"%s\"\n",
- tree->section,
- tree->option,
- ovalue);
+ "[%s] %s = \"%s\"\n",
+ tree->section,
+ tree->option,
+ ovalue);
iprintf(indent,
- "%s\n",
- gettext(tree->description));
+ "%s\n",
+ gettext(tree->description));
printChoice(indent,
- tree->type,
- &tree->value);
+ tree->type,
+ &tree->value);
i = readValue(tree->type,
- &tree->value);
+ &tree->value);
if (i == SYSERR) {
- FREE(ovalue);
- return SYSERR;
+ FREE(ovalue);
+ return SYSERR;
}
if (i == OK)
- break;
+ break;
printf("\n\n");
iprintf(0,
- "%s\n",
- gettext(tree->help));
+ "%s\n",
+ gettext(tree->help));
printf("\n");
}
value = getValueAsString(tree->type,
- &tree->value);
+ &tree->value);
if ( (0 != strcmp(value, ovalue)) &&
- (0 != GC_set_configuration_value_string(cfg,
- ectx,
- tree->section,
- tree->option,
- value)) ) {
+ (0 != GC_set_configuration_value_string(cfg,
+ ectx,
+ tree->section,
+ tree->option,
+ value)) ) {
FREE(value);
FREE(ovalue);
return conf(indent,
- cfg,
- ectx,
- tree); /* try again */
+ cfg,
+ ectx,
+ tree); /* try again */
}
FREE(value);
FREE(ovalue);
@@ -470,46 +470,46 @@
choice = '\0';
while (choice == '\0') {
iprintf(indent,
- "%s\n",
- gettext(tree->description));
+ "%s\n",
+ gettext(tree->description));
iprintf(indent,
- _(/* do not translate y/n/? */
- "\tDescend? (y/n/?) "));
+ _(/* do not translate y/n/? */
+ "\tDescend? (y/n/?) "));
choice = rd();
switch(choice) {
case 'N':
case 'n':
- iprintf(indent,
- "%c\n",
- choice);
- return OK;
+ iprintf(indent,
+ "%c\n",
+ choice);
+ return OK;
case 'q':
- iprintf(indent,
- _("Aborted.\n"));
- return SYSERR; /* escape */
+ iprintf(indent,
+ _("Aborted.\n"));
+ return SYSERR; /* escape */
case '?':
- iprintf(indent,
- "%c\n",
- choice);
- iprintf(indent,
- "%s\n",
- gettext(tree->help));
- choice = '\0';
- break;
+ iprintf(indent,
+ "%c\n",
+ choice);
+ iprintf(indent,
+ "%s\n",
+ gettext(tree->help));
+ choice = '\0';
+ break;
case 'Y':
case 'y':
- iprintf(indent,
- "%c\n",
- choice);
- break;
+ iprintf(indent,
+ "%c\n",
+ choice);
+ break;
default:
- iprintf(indent,
- "%c\n",
- choice);
- iprintf(indent,
- _("Invalid entry.\n"));
- choice = '\0';
- break;
+ iprintf(indent,
+ "%c\n",
+ choice);
+ iprintf(indent,
+ _("Invalid entry.\n"));
+ choice = '\0';
+ break;
}
}
/* fall-through! */
@@ -517,30 +517,30 @@
i = 0;
while (tree->children[i] != NULL) {
if (SYSERR == conf(indent + 1,
- cfg,
- ectx,
- tree->children[i]))
- return SYSERR;
+ cfg,
+ ectx,
+ tree->children[i]))
+ return SYSERR;
i++;
}
return OK;
default:
fprintf(stderr,
- _("Unknown kind %x (internal error). Aborting.\n"),
- tree->type & GNS_KindMask);
+ _("Unknown kind %x (internal error). Aborting.\n"),
+ tree->type & GNS_KindMask);
return SYSERR;
}
return SYSERR;
}
int main_setup_text(int argc,
- const char **argv,
- struct PluginHandle * self,
- struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct GNS_Context * gns,
- const char * filename,
- int is_daemon) {
+ const char **argv,
+ struct PluginHandle * self,
+ struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ struct GNS_Context * gns,
+ const char * filename,
+ int is_daemon) {
struct GNS_Tree * root;
struct termios oldT;
struct termios newT;
@@ -559,19 +559,19 @@
printf(_("You can always press ENTER to keep the current value.\n"));
printf(_("Use the '%s' key to abort.\n"),
- "q");
+ "q");
root = GNS_get_tree(gns);
c = 'r';
while (c == 'r') {
if (OK != conf(-1,
- cfg,
- ectx,
- root)) {
+ cfg,
+ ectx,
+ root)) {
ioctl(0, TCSETS, &oldT);
return 1;
}
if ( (0 == GC_test_dirty(cfg)) &&
- (0 == ACCESS(filename, R_OK)) ) {
+ (0 == ACCESS(filename, R_OK)) ) {
printf(_("Configuration unchanged, no need to save.\n"));
ioctl(0, TCSETS, &oldT);
return 0;
@@ -587,7 +587,7 @@
}
if (c == 'y') {
ret = GC_write_configuration(cfg,
- filename);
+ filename);
if (ret == 1) {
printf(_("Configuration was unchanged, no need to save.\n"));
} else if (ret == -1) { /* error */
@@ -595,7 +595,7 @@
return 1;
} else {
printf(_("Configuration file `%s' written.\n"),
- filename);
+ filename);
}
}
ioctl(0, TCSETS, &oldT);
@@ -607,13 +607,13 @@
* Generate defaults, runs without user interaction.
*/
int dump_setup_text(int argc,
- const char **argv,
- struct PluginHandle * self,
- struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- struct GNS_Context * gns,
- const char * filename,
- int is_daemon) {
+ const char **argv,
+ struct PluginHandle * self,
+ struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ struct GNS_Context * gns,
+ const char * filename,
+ int is_daemon) {
return GC_write_configuration(cfg,
- filename);
+ filename);
}
Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/http.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -297,25 +297,25 @@
* Check if we are allowed to connect to the given IP.
*/
static int acceptPolicyCallback(void * cls,
- const struct sockaddr * addr,
- socklen_t addr_len) {
+ const struct sockaddr * addr,
+ socklen_t addr_len) {
IPaddr ip;
int ret;
if (addr_len == sizeof(struct sockaddr_in)) {
memcpy(&ip,
- &((struct sockaddr_in*) addr)->sin_addr,
- sizeof(IPaddr));
+ &((struct sockaddr_in*) addr)->sin_addr,
+ sizeof(IPaddr));
} else if (addr_len == sizeof(IPaddr)) {
memcpy(&ip,
- addr,
- addr_len);
+ addr,
+ addr_len);
} else {
return MHD_NO;
}
MUTEX_LOCK(httplock);
ret = check_ipv4_listed(filteredNetworks_,
- ip);
+ ip);
MUTEX_UNLOCK(httplock);
if (YES == ret)
return MHD_NO;
@@ -360,14 +360,14 @@
MUTEX_UNLOCK(httplock);
if (httpsession->is_client) {
curl_multi_remove_handle(curl_multi,
- httpsession->cs.client.get);
+ httpsession->cs.client.get);
curl_easy_cleanup(httpsession->cs.client.get);
FREE(httpsession->cs.client.url);
pos = httpsession->cs.client.puts;
while (pos != NULL) {
next = pos->next;
curl_multi_remove_handle(curl_multi,
- pos->curl_put);
+ pos->curl_put);
curl_easy_cleanup(pos->curl_put);
FREE(pos->msg);
FREE(pos);
@@ -397,12 +397,12 @@
unsigned long long port;
if (-1 == GC_get_configuration_value_number(coreAPI->cfg,
- "HTTP",
- "PORT",
- 0,
- 65535,
- 1080,
- &port))
+ "HTTP",
+ "PORT",
+ 0,
+ 65535,
+ 1080,
+ &port))
port = 1080;
return (unsigned short) port;
}
@@ -463,8 +463,8 @@
(ntohs(hello->header.type) != p2p_PROTO_hello) ||
(ntohs(hello->protocol) != HTTP_PROTOCOL_NUMBER) ||
(MHD_NO == acceptPolicyCallback(NULL,
- (const struct sockaddr*) haddr,
- sizeof(IPaddr))) )
+ (const struct sockaddr*) haddr,
+ sizeof(IPaddr))) )
return SYSERR; /* obviously invalid */
return OK;
}
@@ -484,31 +484,31 @@
port = getGNUnetHTTPPort();
if (0 == port) {
GE_LOG(NULL,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "HTTP port is 0, will only send using HTTP.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "HTTP port is 0, will only send using HTTP.\n");
return NULL; /* HTTP transport is configured SEND-only! */
}
msg = MALLOC(sizeof(P2P_hello_MESSAGE) + sizeof(HostAddress));
haddr = (HostAddress*) &msg[1];
if (! ( ( (upnp != NULL) &&
- (OK == upnp->get_ip(port,
- "TCP",
- &haddr->ip)) ) ||
- (SYSERR != getPublicIPAddress(coreAPI->cfg,
- coreAPI->ectx,
- &haddr->ip)) ) ) {
+ (OK == upnp->get_ip(port,
+ "TCP",
+ &haddr->ip)) ) ||
+ (SYSERR != getPublicIPAddress(coreAPI->cfg,
+ coreAPI->ectx,
+ &haddr->ip)) ) ) {
FREE(msg);
GE_LOG(coreAPI->ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
- _("HTTP: Could not determine my public IP address.\n"));
+ GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+ _("HTTP: Could not determine my public IP address.\n"));
return NULL;
}
#if DEBUG_HTTP
GE_LOG(coreAPI->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "HTTP uses IP address %u.%u.%u.%u.\n",
- PRIP(ntohl(*(int*)&haddr->ip)));
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "HTTP uses IP address %u.%u.%u.%u.\n",
+ PRIP(ntohl(*(int*)&haddr->ip)));
#endif
haddr->port = htons(port);
haddr->reserved = htons(0);
@@ -531,8 +531,8 @@
MUTEX_LOCK(httplock);
if (tsessionCount == tsessionArrayLength)
GROW(tsessions,
- tsessionArrayLength,
- tsessionArrayLength * 2);
+ tsessionArrayLength,
+ tsessionArrayLength * 2);
i = tsessionCount;
tsessions[tsessionCount++] = tsession;
MUTEX_UNLOCK(httplock);
@@ -540,9 +540,9 @@
}
static int contentReaderCallback(void * cls,
- size_t pos,
- char * buf,
- int max) {
+ size_t pos,
+ char * buf,
+ int max) {
HTTPSession * session = cls;
MUTEX_LOCK(session->lock);
@@ -553,8 +553,8 @@
if (session->wpos < max)
max = session->wpos;
memcpy(buf,
- &session->wbuff[session->woff],
- max);
+ &session->wbuff[session->woff],
+ max);
session->wpos -= max;
session->woff += max;
session->lastUse = get_time();
@@ -580,11 +580,11 @@
* by the select thread.
*/
static int accessHandlerCallback(void * cls,
- struct MHD_Session * session,
- const char * url,
- const char * method,
- const char * upload_data,
- unsigned int * upload_data_size) {
+ struct MHD_Session * session,
+ const char * url,
+ const char * method,
+ const char * upload_data,
+ unsigned int * upload_data_size) {
TSession * tsession;
struct MHD_Response * response;
HTTPSession * httpSession;
@@ -598,7 +598,7 @@
if ( (strlen(url) < 2) ||
(OK != enc2hash(&url[1],
- &client)) ) {
+ &client)) ) {
return MHD_NO;
}
@@ -608,8 +608,8 @@
tsession = tsessions[i];
httpSession = tsession->internal;
if (0 == memcmp(&httpSession->sender,
- &client,
- sizeof(HashCode512)))
+ &client,
+ sizeof(HashCode512)))
break;
tsession = NULL;
httpSession = NULL;
@@ -624,8 +624,8 @@
if (httpSession == NULL) {
httpSession = MALLOC(sizeof(HTTPSession));
memset(httpSession,
- 0,
- sizeof(HTTPSession));
+ 0,
+ sizeof(HTTPSession));
httpSession->sender = *(coreAPI->myIdentity);
httpSession->lock = MUTEX_CREATE(YES);
httpSession->users = 1; /* us only, core has not seen this tsession! */
@@ -640,13 +640,13 @@
if (0 == strcmp("GET", method)) {
/* handle get */
response = MHD_create_response_from_callback(-1,
- contentReaderCallback,
- httpSession,
- contentReaderFreeCallback);
+ contentReaderCallback,
+ httpSession,
+ contentReaderFreeCallback);
httpSession->cs.client.get = response;
MHD_queue_response(session,
- MHD_HTTP_OK,
- response);
+ MHD_HTTP_OK,
+ response);
} else if (0 == strcmp("PUT", method)) {
/* handle put (upload_data!) */
MUTEX_LOCK(httpSession->lock);
@@ -655,36 +655,36 @@
*upload_data_size = 0; /* we will always process everything */
while (have > 0) {
if (httpSession->rpos1 < sizeof(MESSAGE_HEADER)) {
- cpy = sizeof(MESSAGE_HEADER) - httpSession->rpos1;
- if (cpy > have)
- cpy = have;
- memcpy(&httpSession->rbuff1[httpSession->rpos1],
- &upload_data[poff],
- cpy);
- httpSession->rpos1 += cpy;
- have -= cpy;
- poff += cpy;
- httpSession->rpos2 = 0;
+ cpy = sizeof(MESSAGE_HEADER) - httpSession->rpos1;
+ if (cpy > have)
+ cpy = have;
+ memcpy(&httpSession->rbuff1[httpSession->rpos1],
+ &upload_data[poff],
+ cpy);
+ httpSession->rpos1 += cpy;
+ have -= cpy;
+ poff += cpy;
+ httpSession->rpos2 = 0;
}
if (httpSession->rpos1 < sizeof(MESSAGE_HEADER))
- break;
+ break;
hdr = (MESSAGE_HEADER *) httpSession->rbuff1;
GROW(httpSession->rbuff2,
- httpSession->rsize2,
- ntohs(hdr->size) - sizeof(MESSAGE_HEADER));
+ httpSession->rsize2,
+ ntohs(hdr->size) - sizeof(MESSAGE_HEADER));
if (httpSession->rpos2 < ntohs(hdr->size) - sizeof(MESSAGE_HEADER)) {
- cpy = ntohs(hdr->size) - sizeof(MESSAGE_HEADER) - httpSession->rpos2;
- if (cpy > have)
- cpy = have;
- memcpy(&httpSession->rbuff2[httpSession->rpos2],
- &upload_data[poff],
- cpy);
- have -= cpy;
- poff += cpy;
- httpSession->rpos2 += cpy;
+ cpy = ntohs(hdr->size) - sizeof(MESSAGE_HEADER) - httpSession->rpos2;
+ if (cpy > have)
+ cpy = have;
+ memcpy(&httpSession->rbuff2[httpSession->rpos2],
+ &upload_data[poff],
+ cpy);
+ have -= cpy;
+ poff += cpy;
+ httpSession->rpos2 += cpy;
}
if (httpSession->rpos2 < ntohs(hdr->size) - sizeof(MESSAGE_HEADER))
- break;
+ break;
mp = MALLOC(sizeof(P2P_PACKET));
mp->msg = httpSession->rbuff2;
mp->sender = httpSession->sender;
@@ -708,9 +708,9 @@
*/
static size_t
receiveContentCallback(void * ptr,
- size_t size,
- size_t nmemb,
- void * ctx) {
+ size_t size,
+ size_t nmemb,
+ void * ctx) {
HTTPSession * httpSession = ctx;
const char * inbuf = ptr;
size_t have = size * nmemb;
@@ -720,15 +720,15 @@
P2P_PACKET * mp;
printf("Receiving %u bytes from GET\n",
- have);
+ have);
while (have > 0) {
if (httpSession->rpos1 < sizeof(MESSAGE_HEADER)) {
cpy = sizeof(MESSAGE_HEADER) - httpSession->rpos1;
if (cpy > have)
- cpy = have;
+ cpy = have;
memcpy(&httpSession->rbuff1[httpSession->rpos1],
- &inbuf[poff],
- cpy);
+ &inbuf[poff],
+ cpy);
httpSession->rpos1 += cpy;
have -= cpy;
poff += cpy;
@@ -738,17 +738,17 @@
return size * nmemb;
hdr = (MESSAGE_HEADER *) httpSession->rbuff1;
GROW(httpSession->rbuff2,
- httpSession->rsize2,
- ntohs(hdr->size) - sizeof(MESSAGE_HEADER));
+ httpSession->rsize2,
+ ntohs(hdr->size) - sizeof(MESSAGE_HEADER));
printf("Expecting message of %u bytes via GET\n",
- ntohs(hdr->size));
+ ntohs(hdr->size));
if (httpSession->rpos2 < ntohs(hdr->size) - sizeof(MESSAGE_HEADER)) {
cpy = ntohs(hdr->size) - sizeof(MESSAGE_HEADER) - httpSession->rpos2;
if (cpy > have)
- cpy = have;
+ cpy = have;
memcpy(&httpSession->rbuff2[httpSession->rpos2],
- &inbuf[poff],
- cpy);
+ &inbuf[poff],
+ cpy);
have -= cpy;
poff += cpy;
httpSession->rpos2 += cpy;
@@ -775,17 +775,17 @@
*/
static size_t
sendContentCallback(void * ptr,
- size_t size,
- size_t nmemb,
- void * ctx) {
+ size_t size,
+ size_t nmemb,
+ void * ctx) {
struct HTTPPutData * put = ctx;
size_t max = size * nmemb;
if (max > put->size - put->pos)
max = put->size - put->pos;
memcpy(ptr,
- &put->msg[put->pos],
- max);
+ &put->msg[put->pos],
+ max);
put->pos += max;
return max;
}
@@ -800,7 +800,7 @@
* @return OK on success, SYSERR if the operation failed
*/
static int httpConnect(const P2P_hello_MESSAGE * hello,
- TSession ** tsessionPtr) {
+ TSession ** tsessionPtr) {
const HostAddress * haddr = (const HostAddress*) &hello[1];
TSession * tsession;
HTTPSession * httpSession;
@@ -816,8 +816,8 @@
MUTEX_LOCK(httplock);
for (i=0;i<tsessionCount;i++) {
if (0 == memcmp(&hello->senderIdentity,
- &tsessions[i]->peer,
- sizeof(PeerIdentity))) {
+ &tsessions[i]->peer,
+ sizeof(PeerIdentity))) {
tsession = tsessions[i];
break;
}
@@ -836,64 +836,64 @@
return SYSERR;
hash2enc(&hello->senderIdentity.hashPubKey,
- &enc);
+ &enc);
url = MALLOC(64 + sizeof(EncName));
SNPRINTF(url,
- 64 + sizeof(EncName),
- "http://%u.%u.%u.%u:%u/%s",
- PRIP(ntohl(*(int*)&haddr->ip.addr)),
- ntohs(haddr->port),
- &enc);
+ 64 + sizeof(EncName),
+ "http://%u.%u.%u.%u:%u/%s",
+ PRIP(ntohl(*(int*)&haddr->ip.addr)),
+ ntohs(haddr->port),
+ &enc);
/* create GET */
CURL_EASY_SETOPT(curl_get,
- CURLOPT_FAILONERROR,
- 1);
+ CURLOPT_FAILONERROR,
+ 1);
CURL_EASY_SETOPT(curl_get,
- CURLOPT_URL,
- url);
+ CURLOPT_URL,
+ url);
if (strlen(proxy) > 0)
CURL_EASY_SETOPT(curl_get,
- CURLOPT_PROXY,
- proxy);
+ CURLOPT_PROXY,
+ proxy);
CURL_EASY_SETOPT(curl_get,
- CURLOPT_BUFFERSIZE,
- 32 * 1024);
+ CURLOPT_BUFFERSIZE,
+ 32 * 1024);
if (0 == strncmp(url,
- "http",
- 4))
+ "http",
+ 4))
CURL_EASY_SETOPT(curl_get,
- CURLOPT_USERAGENT,
- "GNUnet-http");
+ CURLOPT_USERAGENT,
+ "GNUnet-http");
CURL_EASY_SETOPT(curl_get,
- CURLOPT_CONNECTTIMEOUT,
- 150L);
+ CURLOPT_CONNECTTIMEOUT,
+ 150L);
CURL_EASY_SETOPT(curl_get,
- CURLOPT_TIMEOUT,
- 150L);
+ CURLOPT_TIMEOUT,
+ 150L);
CURL_EASY_SETOPT(curl_get,
- CURLOPT_WRITEFUNCTION,
- &receiveContentCallback);
+ CURLOPT_WRITEFUNCTION,
+ &receiveContentCallback);
httpSession = MALLOC(sizeof(HTTPSession));
memset(httpSession,
- 0,
- sizeof(HTTPSession));
+ 0,
+ sizeof(HTTPSession));
httpSession->cs.client.url = url;
CURL_EASY_SETOPT(curl_get,
- CURLOPT_WRITEDATA,
- httpSession);
+ CURLOPT_WRITEDATA,
+ httpSession);
if (ret != CURLE_OK)
goto cleanup;
mret = curl_multi_add_handle(curl_multi, curl_get);
if (mret != CURLM_OK) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_multi_add_handle",
- __FILE__,
- __LINE__,
- curl_multi_strerror(mret));
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_multi_add_handle",
+ __FILE__,
+ __LINE__,
+ curl_multi_strerror(mret));
goto cleanup;
}
@@ -921,8 +921,8 @@
static CURL *
create_curl_put(HTTPSession * httpSession,
- struct HTTPPutData * put,
- unsigned int size) {
+ struct HTTPPutData * put,
+ unsigned int size) {
CURL * curl_put;
CURLcode ret;
@@ -930,39 +930,39 @@
if (curl_put == NULL)
return NULL;
CURL_EASY_SETOPT(curl_put,
- CURLOPT_FAILONERROR,
- 1);
+ CURLOPT_FAILONERROR,
+ 1);
CURL_EASY_SETOPT(curl_put,
- CURLOPT_URL,
- httpSession->cs.client.url);
+ CURLOPT_URL,
+ httpSession->cs.client.url);
if (strlen(proxy) > 0)
CURL_EASY_SETOPT(curl_put,
- CURLOPT_PROXY,
- proxy);
+ CURLOPT_PROXY,
+ proxy);
CURL_EASY_SETOPT(curl_put,
- CURLOPT_BUFFERSIZE,
- 32 * 1024);
+ CURLOPT_BUFFERSIZE,
+ 32 * 1024);
if (0 == strncmp(httpSession->cs.client.url,
- "http",
- 4))
+ "http",
+ 4))
CURL_EASY_SETOPT(curl_put,
- CURLOPT_USERAGENT,
- "GNUnet-http");
+ CURLOPT_USERAGENT,
+ "GNUnet-http");
CURL_EASY_SETOPT(curl_put,
- CURLOPT_UPLOAD,
- 1);
+ CURLOPT_UPLOAD,
+ 1);
CURL_EASY_SETOPT(curl_put,
- CURLOPT_CONNECTTIMEOUT,
- 150L);
+ CURLOPT_CONNECTTIMEOUT,
+ 150L);
CURL_EASY_SETOPT(curl_put,
- CURLOPT_INFILESIZE_LARGE,
- size);
+ CURLOPT_INFILESIZE_LARGE,
+ size);
CURL_EASY_SETOPT(curl_put,
- CURLOPT_READFUNCTION,
- &sendContentCallback);
+ CURLOPT_READFUNCTION,
+ &sendContentCallback);
CURL_EASY_SETOPT(curl_put,
- CURLOPT_READDATA,
- put);
+ CURLOPT_READDATA,
+ put);
if (ret != CURLE_OK) {
curl_easy_cleanup(curl_put);
return NULL;
@@ -979,9 +979,9 @@
* @return SYSERR on error, OK on success, NO if queue is full
*/
static int httpSend(TSession * tsession,
- const void * msg,
- unsigned int size,
- int important) {
+ const void * msg,
+ unsigned int size,
+ int important) {
HTTPSession * httpSession = tsession->internal;
struct HTTPPutData * putData;
CURL * curl_put;
@@ -998,20 +998,20 @@
}
putData = MALLOC(sizeof(struct HTTPPutData));
memset(putData,
- 0,
- sizeof(struct HTTPPutData));
+ 0,
+ sizeof(struct HTTPPutData));
putData->msg = MALLOC(size + sizeof(MESSAGE_HEADER));
hdr = (MESSAGE_HEADER*) putData->msg;
hdr->size = htons(size + sizeof(MESSAGE_HEADER));
hdr->type = htons(0);
memcpy(&putData->msg[sizeof(MESSAGE_HEADER)],
- msg,
- size);
+ msg,
+ size);
putData->size = size + sizeof(MESSAGE_HEADER);
MUTEX_LOCK(httpSession->lock);
curl_put = create_curl_put(httpSession,
- putData,
- size + sizeof(MESSAGE_HEADER));
+ putData,
+ size + sizeof(MESSAGE_HEADER));
if (curl_put == NULL) {
MUTEX_UNLOCK(httpSession->lock);
FREE(putData->msg);
@@ -1026,12 +1026,12 @@
mret = curl_multi_add_handle(curl_multi, curl_put);
if (mret != CURLM_OK) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_multi_add_handle",
- __FILE__,
- __LINE__,
- curl_multi_strerror(mret));
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_multi_add_handle",
+ __FILE__,
+ __LINE__,
+ curl_multi_strerror(mret));
putData->done = YES;
MUTEX_UNLOCK(httplock);
return SYSERR;
@@ -1042,18 +1042,18 @@
MUTEX_LOCK(httpSession->lock);
if (httpSession->wsize == 0)
GROW(httpSession->wbuff,
- httpSession->wsize,
- HTTP_BUF_SIZE);
+ httpSession->wsize,
+ HTTP_BUF_SIZE);
if (httpSession->wpos + size > httpSession->wsize) {
/* need to grow or discard */
if (! important) {
- MUTEX_UNLOCK(httpSession->lock);
- return NO;
+ MUTEX_UNLOCK(httpSession->lock);
+ return NO;
}
tmp = MALLOC(httpSession->wpos + size);
memcpy(tmp,
- &httpSession->wbuff[httpSession->woff],
- httpSession->wpos);
+ &httpSession->wbuff[httpSession->woff],
+ httpSession->wpos);
FREE(httpSession->wbuff);
httpSession->wbuff = tmp;
httpSession->wsize = httpSession->wpos + size;
@@ -1062,16 +1062,16 @@
} else {
/* fits without growing */
if (httpSession->wpos + httpSession->woff + size > httpSession->wsize) {
- /* need to compact first */
- memmove(httpSession->wbuff,
- &httpSession->wbuff[httpSession->woff],
- httpSession->wpos);
- httpSession->woff = 0;
+ /* need to compact first */
+ memmove(httpSession->wbuff,
+ &httpSession->wbuff[httpSession->woff],
+ httpSession->wpos);
+ httpSession->woff = 0;
}
/* append */
memcpy(&httpSession->wbuff[httpSession->woff + httpSession->wpos],
- msg,
- size);
+ msg,
+ size);
httpSession->wpos += size;
}
MUTEX_UNLOCK(httpSession->lock);
@@ -1099,37 +1099,37 @@
prev = NULL;
pos = s->cs.client.puts;
while (pos != NULL) {
- /* FIXME: check if CURL has timed out
- the GET operation! If so, clean up!
- (and make sure we re-establish GET
- as needed!) */
-
+ /* FIXME: check if CURL has timed out
+ the GET operation! If so, clean up!
+ (and make sure we re-establish GET
+ as needed!) */
+
- if (pos->done) {
- if (prev == NULL)
- s->cs.client.puts = pos->next;
- else
- prev->next = pos->next;
- FREE(pos->msg);
- curl_multi_remove_handle(curl_multi,
- pos->curl_put);
- curl_easy_cleanup(pos->curl_put);
- FREE(pos);
- if (prev == NULL)
- pos = s->cs.client.puts;
- else
- pos = pos->next;
- continue;
- }
- prev = pos;
- pos = pos->next;
+ if (pos->done) {
+ if (prev == NULL)
+ s->cs.client.puts = pos->next;
+ else
+ prev->next = pos->next;
+ FREE(pos->msg);
+ curl_multi_remove_handle(curl_multi,
+ pos->curl_put);
+ curl_easy_cleanup(pos->curl_put);
+ FREE(pos);
+ if (prev == NULL)
+ pos = s->cs.client.puts;
+ else
+ pos = pos->next;
+ continue;
+ }
+ prev = pos;
+ pos = pos->next;
}
} else {
/* FIXME: add code to close MHD connection
- from the server side (timeout!); need
- to
- A) tell GET callback to return "end of transmission"
- B) destroy response object
+ from the server side (timeout!); need
+ to
+ A) tell GET callback to return "end of transmission"
+ B) destroy response object
*/
}
MUTEX_UNLOCK(s->lock);
@@ -1153,34 +1153,34 @@
FD_ZERO(&ws);
FD_ZERO(&es);
mret = curl_multi_fdset(curl_multi,
- &rs,
- &ws,
- &es,
- &max);
+ &rs,
+ &ws,
+ &es,
+ &max);
if (mret != CURLM_OK) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_multi_fdset",
- __FILE__,
- __LINE__,
- curl_multi_strerror(mret));
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_multi_fdset",
+ __FILE__,
+ __LINE__,
+ curl_multi_strerror(mret));
break;
}
if (mhd_daemon != NULL)
MHD_get_fdset(mhd_daemon,
- &rs,
- &ws,
- &es,
- &max);
+ &rs,
+ &ws,
+ &es,
+ &max);
/* CURL requires a regular timeout... */
tv.tv_sec = 0;
tv.tv_usec = 1000;
SELECT(max + 1,
- &rs,
- &ws,
- &es,
- &tv);
+ &rs,
+ &ws,
+ &es,
+ &tv);
if (YES != http_running)
break;
running = 0;
@@ -1209,20 +1209,20 @@
if ( (mhd_daemon == NULL) &&
(port != 0) ) {
mhd_daemon = MHD_start_daemon(MHD_USE_IPv4,
- port,
- &acceptPolicyCallback,
- NULL,
- &accessHandlerCallback,
- NULL);
+ port,
+ &acceptPolicyCallback,
+ NULL,
+ &accessHandlerCallback,
+ NULL);
}
http_running = YES;
curl_thread = PTHREAD_CREATE(&curl_runner,
- NULL,
- 32 * 1024);
+ NULL,
+ 32 * 1024);
if (curl_thread == NULL)
GE_DIE_STRERROR(coreAPI->ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "pthread_create");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "pthread_create");
return OK;
}
@@ -1253,10 +1253,10 @@
* configuration on error, syslog errors!)
*/
static int reloadConfiguration(void * ctx,
- struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option) {
+ struct GC_Configuration * cfg,
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option) {
char * ch;
if (0 != strcmp(section, "HTTP"))
@@ -1265,12 +1265,12 @@
FREENONNULL(filteredNetworks_);
ch = NULL;
GC_get_configuration_value_string(cfg,
- "HTTP",
- "BLACKLIST",
- "",
- &ch);
+ "HTTP",
+ "BLACKLIST",
+ "",
+ &ch);
filteredNetworks_ = parse_ipv4_network_specification(ectx,
- ch);
+ ch);
FREE(ch);
MUTEX_UNLOCK(httplock);
return 0;
@@ -1281,8 +1281,8 @@
*/
static int
helloToAddress(const P2P_hello_MESSAGE * hello,
- void ** sa,
- unsigned int * sa_len) {
+ void ** sa,
+ unsigned int * sa_len) {
const HostAddress * haddr = (const HostAddress*) &hello[1];
struct sockaddr_in * serverAddr;
@@ -1290,12 +1290,12 @@
serverAddr = MALLOC(sizeof(struct sockaddr_in));
*sa = serverAddr;
memset(serverAddr,
- 0,
- sizeof(struct sockaddr_in));
+ 0,
+ sizeof(struct sockaddr_in));
serverAddr->sin_family = AF_INET;
memcpy(&serverAddr->sin_addr,
- haddr,
- sizeof(IPaddr));
+ haddr,
+ sizeof(IPaddr));
serverAddr->sin_port = haddr->port;
return OK;
}
@@ -1314,16 +1314,16 @@
coreAPI = core;
httplock = MUTEX_CREATE(YES);
if (0 != GC_attach_change_listener(coreAPI->cfg,
- &reloadConfiguration,
- NULL)) {
+ &reloadConfiguration,
+ NULL)) {
MUTEX_DESTROY(httplock);
return NULL;
}
if (0 != curl_global_init(CURL_GLOBAL_WIN32)) {
GE_BREAK(NULL, 0);
GC_detach_change_listener(coreAPI->cfg,
- &reloadConfiguration,
- NULL);
+ &reloadConfiguration,
+ NULL);
MUTEX_DESTROY(httplock);
return NULL;
}
@@ -1333,16 +1333,16 @@
tsessionArrayLength,
32);
if (GC_get_configuration_value_yesno(coreAPI->cfg,
- "HTTP",
- "UPNP",
- YES) == YES) {
+ "HTTP",
+ "UPNP",
+ YES) == YES) {
upnp = coreAPI->requestService("upnp");
if (upnp == NULL) {
GE_LOG(coreAPI->ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("The UPnP service could not be loaded. To disable UPnP, set the
" \
- "configuration option \"UPNP\" in section \"HTTP\" to
\"NO\"\n"));
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("The UPnP service could not be loaded. To disable UPnP, set the " \
+ "configuration option \"UPNP\" in section \"HTTP\" to \"NO\"\n"));
}
}
@@ -1356,10 +1356,10 @@
= stats->create(gettext_noop("# bytes dropped by HTTP (outgoing)"));
}
GC_get_configuration_value_string(coreAPI->cfg,
- "GNUNETD",
- "HTTP-PROXY",
- "",
- &proxy);
+ "GNUNETD",
+ "HTTP-PROXY",
+ "",
+ &proxy);
httpAPI.protocolNumber = HTTP_PROTOCOL_NUMBER;
httpAPI.mtu = 0;
@@ -1379,8 +1379,8 @@
void donetransport_http() {
GC_detach_change_listener(coreAPI->cfg,
- &reloadConfiguration,
- NULL);
+ &reloadConfiguration,
+ NULL);
coreAPI->releaseService(stats);
stats = NULL;
if (upnp != NULL) {
Modified: GNUnet/src/transports/ip.c
===================================================================
--- GNUnet/src/transports/ip.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/ip.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -38,8 +38,8 @@
* @return SYSERR on error, OK on success
*/
int getPublicIPAddress(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- IPaddr * address) {
+ struct GE_Context * ectx,
+ IPaddr * address) {
static IPaddr myAddress;
static cron_t last;
static cron_t lastError;
@@ -51,13 +51,13 @@
if (lastError + 30 * cronSECONDS > now)
return SYSERR;
ips = network_get_local_ip(cfg,
- ectx,
- &myAddress);
+ ectx,
+ &myAddress);
if (ips == NULL) {
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Failed to obtain my (external) %s address!\n"),
- "IP");
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Failed to obtain my (external) %s address!\n"),
+ "IP");
lastError = now;
return SYSERR;
}
@@ -65,8 +65,8 @@
last = now;
}
memcpy(address,
- &myAddress,
- sizeof(IPaddr));
+ &myAddress,
+ sizeof(IPaddr));
return OK;
}
@@ -97,9 +97,9 @@
FREE(pos->address);
FREE(pos);
if (prev == NULL)
- pi_head = next;
+ pi_head = next;
else
- prev->next = next;
+ prev->next = next;
} else
prev = pos;
pos = next;
@@ -117,8 +117,8 @@
* @return OK if we found an address, SYSERR if not
*/
int getIPaddressFromPID(const PeerIdentity * peer,
- void ** sa,
- unsigned int * salen) {
+ void ** sa,
+ unsigned int * salen) {
struct PICache * cache;
MUTEX_LOCK(lock);
@@ -126,13 +126,13 @@
cache = pi_head;
while (cache != NULL) {
if (0 == memcmp(peer,
- &cache->peer,
- sizeof(PeerIdentity))) {
+ &cache->peer,
+ sizeof(PeerIdentity))) {
*salen = cache->len;
*sa = MALLOC(cache->len);
memcpy(*sa,
- cache->address,
- cache->len);
+ cache->address,
+ cache->len);
MUTEX_UNLOCK(lock);
return OK;
}
@@ -151,30 +151,30 @@
* us to validate the address).
*/
void setIPaddressFromPID(const PeerIdentity * peer,
- const void * sa,
- unsigned int salen) {
+ const void * sa,
+ unsigned int salen) {
struct PICache * next;
MUTEX_LOCK(lock);
next = pi_head;
while (next != NULL) {
if (0 == memcmp(peer,
- &next->peer,
- sizeof(PeerIdentity))) {
+ &next->peer,
+ sizeof(PeerIdentity))) {
next->expire = get_time() + 12 * cronHOURS;
if ( (salen == next->len) &&
- (0 == memcmp(sa,
- next->address,
- salen)) ) {
- MUTEX_UNLOCK(lock);
- return;
+ (0 == memcmp(sa,
+ next->address,
+ salen)) ) {
+ MUTEX_UNLOCK(lock);
+ return;
}
FREE(next->address);
next->address = MALLOC(salen);
next->len = salen;
memcpy(next->address,
- sa,
- salen);
+ sa,
+ salen);
MUTEX_UNLOCK(lock);
return;
}
@@ -184,8 +184,8 @@
next->peer = *peer;
next->address = MALLOC(salen);
memcpy(next->address,
- sa,
- salen);
+ sa,
+ salen);
next->len = salen;
next->expire = get_time() + 12 * cronHOURS;
expirePICache();
Modified: GNUnet/src/transports/ip6.c
===================================================================
--- GNUnet/src/transports/ip6.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/ip6.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -51,14 +51,14 @@
* @return SYSERR on failure, OK on success
*/
static int getAddress6FromHostname(struct GE_Context * ectx,
- IP6addr * identity) {
+ IP6addr * identity) {
char hostname[MAX_HOSTNAME];
struct hostent * ip;
if (0 != gethostname(hostname, MAX_HOSTNAME)) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "gethostname");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "gethostname");
return SYSERR;
}
/* GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
@@ -68,42 +68,42 @@
ip = gethostbyname2(hostname, AF_INET6);
if (ip == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- _("Could not find IP of host `%s': %s\n"),
- hostname,
- hstrerror(h_errno));
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ _("Could not find IP of host `%s': %s\n"),
+ hostname,
+ hstrerror(h_errno));
return SYSERR;
}
if (ip->h_addrtype != AF_INET6) {
GE_BREAK(ectx,
- 0);
+ 0);
return SYSERR;
}
GE_ASSERT(ectx,
- sizeof(struct in6_addr) == sizeof(identity->addr));
+ sizeof(struct in6_addr) == sizeof(identity->addr));
memcpy(&identity->addr[0],
- ip->h_addr_list[0],
- sizeof(struct in6_addr));
+ ip->h_addr_list[0],
+ sizeof(struct in6_addr));
return OK;
}
#if HAVE_GETIFADDRS && HAVE_FREEIFADDRS
static int getAddress6FromGetIfAddrs(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- IP6addr * identity) {
+ struct GE_Context * ectx,
+ IP6addr * identity) {
char * interfaces;
struct ifaddrs *ifa_first;
if (-1 == GC_get_configuration_value_string(cfg,
- "NETWORK",
- "INTERFACE",
- "eth0",
- &interfaces)) {
+ "NETWORK",
+ "INTERFACE",
+ "eth0",
+ &interfaces)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("No interface specified in section `%s' under `%s'!\n"),
- "NETWORK",
- "INTERFACE");
+ GE_ERROR | GE_BULK | GE_USER,
+ _("No interface specified in section `%s' under `%s'!\n"),
+ "NETWORK",
+ "INTERFACE");
return SYSERR; /* that won't work! */
}
@@ -130,10 +130,10 @@
freeifaddrs(ifa_first);
}
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Could not obtain IP for interface `%s' using `%s'.\n"),
- interfaces,
- "getifaddrs");
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Could not obtain IP for interface `%s' using `%s'.\n"),
+ interfaces,
+ "getifaddrs");
FREE(interfaces);
return SYSERR;
}
@@ -144,42 +144,42 @@
* @return SYSERR on error, OK on success
*/
static int getAddress6(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- IP6addr * address){
+ struct GE_Context * ectx,
+ IP6addr * address){
char * ipString;
int retval;
struct hostent * ip; /* for the lookup of the IP in gnunet.conf */
retval = SYSERR;
if (GC_have_configuration_value(cfg,
- "NETWORK",
- "IP6")) {
+ "NETWORK",
+ "IP6")) {
ipString = NULL;
GC_get_configuration_value_string(cfg,
- "NETWORK",
- "IP6",
- "",
- &ipString);
+ "NETWORK",
+ "IP6",
+ "",
+ &ipString);
if (strlen(ipString) > 0) {
ip = gethostbyname2(ipString,
- AF_INET6);
+ AF_INET6);
if (ip == NULL) {
- GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("Could not resolve `%s': %s\n"),
- ipString,
- hstrerror(h_errno));
+ GE_LOG(ectx,
+ GE_ERROR | GE_USER | GE_BULK,
+ _("Could not resolve `%s': %s\n"),
+ ipString,
+ hstrerror(h_errno));
} else if (ip->h_addrtype != AF_INET6) {
- GE_ASSERT(ectx,
- 0);
- retval = SYSERR;
+ GE_ASSERT(ectx,
+ 0);
+ retval = SYSERR;
} else {
- GE_ASSERT(ectx,
- sizeof(struct in6_addr) == sizeof(address->addr));
- memcpy(&address->addr[0],
- ip->h_addr_list[0],
- sizeof(struct in6_addr));
- retval = OK;
+ GE_ASSERT(ectx,
+ sizeof(struct in6_addr) == sizeof(address->addr));
+ memcpy(&address->addr[0],
+ ip->h_addr_list[0],
+ sizeof(struct in6_addr));
+ retval = OK;
}
}
FREE(ipString);
@@ -193,7 +193,7 @@
#endif
if (retval == SYSERR)
retval = getAddress6FromHostname(ectx,
- address);
+ address);
return retval;
}
@@ -202,8 +202,8 @@
* @return SYSERR on error, OK on success
*/
int getPublicIP6Address(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- IP6addr * address) {
+ struct GE_Context * ectx,
+ IP6addr * address) {
static IP6addr myAddress;
static cron_t last;
static cron_t lastError;
@@ -214,20 +214,20 @@
if (lastError + 30 * cronSECONDS > now)
return SYSERR;
if (SYSERR == getAddress6(cfg,
- ectx,
- &myAddress)) {
+ ectx,
+ &myAddress)) {
lastError = now;
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Failed to obtain my (external) %s address!\n"),
- "IPv6");
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Failed to obtain my (external) %s address!\n"),
+ "IPv6");
return SYSERR;
}
last = now;
}
memcpy(address,
- &myAddress,
- sizeof(IP6addr));
+ &myAddress,
+ sizeof(IP6addr));
return OK;
}
Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/nat.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -64,14 +64,14 @@
(ntohs(hello->header.type) != p2p_PROTO_hello) )
return SYSERR; /* obviously invalid */
if (YES == GC_get_configuration_value_yesno(coreAPI->cfg,
- "NAT",
- "LIMITED",
- NO)) {
+ "NAT",
+ "LIMITED",
+ NO)) {
/* if WE are a NAT and this is not our hello,
it is invalid since NAT-to-NAT is not possible! */
if (0 == memcmp(&coreAPI->myIdentity->hashPubKey,
- &hello->senderIdentity.hashPubKey,
- sizeof(HashCode512)))
+ &hello->senderIdentity.hashPubKey,
+ sizeof(HashCode512)))
return OK;
return SYSERR;
}
@@ -89,9 +89,9 @@
P2P_hello_MESSAGE * msg;
if (NO == GC_get_configuration_value_yesno(coreAPI->cfg,
- "NAT",
- "LIMITED",
- NO))
+ "NAT",
+ "LIMITED",
+ NO))
return NULL;
msg = MALLOC(sizeof(P2P_hello_MESSAGE) + sizeof(HostAddress));
msg->senderAddressSize = htons(sizeof(HostAddress));
@@ -107,7 +107,7 @@
* @return always fails (returns SYSERR)
*/
static int natConnect(const P2P_hello_MESSAGE * hello,
- TSession ** tsessionPtr) {
+ TSession ** tsessionPtr) {
return SYSERR;
}
@@ -135,9 +135,9 @@
* @return SYSERR (always fails)
*/
static int natSend(TSession * tsession,
- const void * message,
- const unsigned int size,
- int important) {
+ const void * message,
+ const unsigned int size,
+ int important) {
return SYSERR;
}
@@ -172,16 +172,16 @@
* Convert NAT address to a string.
*/
static int helloToAddress(const P2P_hello_MESSAGE * hello,
- void ** sa,
- unsigned int * sa_len) {
+ void ** sa,
+ unsigned int * sa_len) {
return getIPaddressFromPID(&hello->senderIdentity,
- sa,
- sa_len);
+ sa,
+ sa_len);
}
static int testWouldTry(TSession * tsession,
- unsigned int size,
- int important) {
+ unsigned int size,
+ int important) {
return SYSERR;
}
Modified: GNUnet/src/transports/smtp.c
===================================================================
--- GNUnet/src/transports/smtp.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/smtp.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -126,8 +126,8 @@
* @return the size of the output
*/
static unsigned int base64_encode(char * data,
- unsigned int len,
- char ** output) {
+ unsigned int len,
+ char ** output) {
unsigned int i;
char c;
unsigned int ret;
@@ -139,7 +139,7 @@
}
ret = 0;
*output = MALLOC( (((len * 4 / 3) + 8) * (MAX_CHAR_PER_LINE+2))/
- MAX_CHAR_PER_LINE);
+ MAX_CHAR_PER_LINE);
for (i = 0; i < len; ++i) {
c = (data[i] >> 2) & 0x3f;
(*output)[ret++] = cvt[(int)c];
@@ -152,7 +152,7 @@
if (i < len) {
c = (data[i] << 2) & 0x3f;
if (++i < len)
- c |= (data[i] >> 6) & 0x03;
+ c |= (data[i] >> 6) & 0x03;
(*output)[ret++] = cvt[(int)c];
CHECKLINE;
} else {
@@ -176,8 +176,8 @@
#define cvtfind(a)( (((a) >= 'A')&&((a) <= 'Z'))? (a)-'A'\
:(((a)>='a')&&((a)<='z')) ? (a)-'a'+26\
:(((a)>='0')&&((a)<='9')) ? (a)-'0'+52\
- :((a) == '+') ? 62\
- :((a) == '/') ? 63 : -1)
+ :((a) == '+') ? 62\
+ :((a) == '/') ? 63 : -1)
/**
* Decode from Base64.
*
@@ -188,18 +188,18 @@
* @return the size of the output
*/
static unsigned int base64_decode(char * data,
- unsigned int len,
- char ** output) {
+ unsigned int len,
+ char ** output) {
unsigned int i;
char c;
char c1;
unsigned int ret=0;
-#define CHECK_CRLF while (data[i] == '\r' || data[i] == '\n') {\
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
"ignoring CR/LF\n"); \
- i++; \
- if (i >= len) goto END; \
- }
+#define CHECK_CRLF while (data[i] == '\r' || data[i] == '\n') {\
+ GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, "ignoring
CR/LF\n"); \
+ i++; \
+ if (i >= len) goto END; \
+ }
*output = MALLOC((len * 3 / 4) + 8);
#if DEBUG_SMTP
@@ -208,7 +208,7 @@
for (i = 0; i < len; ++i) {
CHECK_CRLF;
if (data[i] == FILLCHAR)
- break;
+ break;
c = (char) cvtfind(data[i]);
++i;
CHECK_CRLF;
@@ -219,7 +219,7 @@
CHECK_CRLF;
c = data[i];
if (FILLCHAR == c)
- break;
+ break;
c = (char) cvtfind(c);
c1 = ((c1 << 4) & 0xf0) | ((c >> 2) & 0xf);
(*output)[ret++] = c1;
@@ -228,7 +228,7 @@
CHECK_CRLF;
c1 = data[i];
if (FILLCHAR == c1)
- break;
+ break;
c1 = (char) cvtfind(c1);
c = ((c << 6) & 0xc0) | c1;
@@ -253,16 +253,16 @@
SMTPMessage * mp;
pipename = getFileName("SMTP",
- "PIPE",
- _("You must specify the name of a "
- "pipe for the SMTP transport in section `%s' under
`%s'.\n"));
+ "PIPE",
+ _("You must specify the name of a "
+ "pipe for the SMTP transport in section `%s' under
`%s'.\n"));
GE_ASSERT(ectx, pipename != NULL);
UNLINK(pipename);
if (0 != mkfifo(pipename,
- S_IWUSR|S_IRUSR))
+ S_IWUSR|S_IRUSR))
GE_DIE_STRERROR(ectx,
- GE_ADMIN | GE_BULK | GE_FATAL,
- "mkfifo");
+ GE_ADMIN | GE_BULK | GE_FATAL,
+ "mkfifo");
LINESIZE = ((smtpAPI.mtu * 4 / 3) + 8) * (MAX_CHAR_PER_LINE+2)/
MAX_CHAR_PER_LINE; /* maximum size of a line supported */
line = MALLOC(LINESIZE + 2); /* 2 bytes for off-by-one errors, just to be
safe... */
@@ -270,7 +270,7 @@
#define READLINE(l,limit) \
do { retl = fgets(l, limit, fdes); \
if ( (retl == NULL) || (smtp_shutdown == YES)) {\
- goto END; \
+ goto END; \
}\
incrementBytesReceived(strlen(retl));\
} while (0)
@@ -286,71 +286,71 @@
int fd;
fd = disk_file_open(ectx,
- pipename,
- O_RDONLY);
+ pipename,
+ O_RDONLY);
if (fd == -1) {
if (smtp_shutdown == NO)
- PTHREAD_SLEEP(5 * cronSECONDS);
+ PTHREAD_SLEEP(5 * cronSECONDS);
continue;
}
fdes = fdopen(fd, "r");
while (smtp_shutdown == NO ) {
do {
- READLINE(line, LINESIZE);
+ READLINE(line, LINESIZE);
} while (0 != strAUTOncmp(line, CONTENT_TYPE_MULTIPART));
READLINE(line, LINESIZE);
if (strlen(line) < strlen(" boundary=\"")) {
- goto END;
+ goto END;
}
boundary = STRDUP(&line[strlen(" boundary=\"")-2]);
if (boundary[strlen(boundary)-2] != '\"') {
- FREE(boundary);
- goto END; /* format error */
+ FREE(boundary);
+ goto END; /* format error */
} else {
- boundary[strlen(boundary)-2] = '\0';
- boundary[0] = boundary[1] = '-';
+ boundary[strlen(boundary)-2] = '\0';
+ boundary[0] = boundary[1] = '-';
}
do {
- READLINE(line, LINESIZE);
+ READLINE(line, LINESIZE);
} while (0 != strAUTOncmp(line, boundary));
do {
- READLINE(line, LINESIZE); /* content type, etc. */
+ READLINE(line, LINESIZE); /* content type, etc. */
} while (0 != strAUTOncmp(line, ""));
READLINE(line, LINESIZE); /* read base64 encoded message; decode,
process */
while ( (line[strlen(line)-2] != FILLCHAR) &&
- (strlen(line) < LINESIZE) )
- READLINE(&line[strlen(line)-1], LINESIZE - strlen(line));
+ (strlen(line) < LINESIZE) )
+ READLINE(&line[strlen(line)-1], LINESIZE - strlen(line));
size = base64_decode(line, strlen(line)-1, &out);
if (size < sizeof(SMTPMessage)) {
- GE_BREAK(ectx, 0);
- FREE(out);
- goto END;
+ GE_BREAK(ectx, 0);
+ FREE(out);
+ goto END;
}
mp = (SMTPMessage*)&out[size-sizeof(SMTPMessage)];
if (ntohs(mp->size) != size) {
- GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Received malformed message via SMTP (size mismatch).\n"));
+ GE_LOG(ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Received malformed message via SMTP (size mismatch).\n"));
#if DEBUG_SMTP
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Size returned by base64=%d, in the msg=%d.\n",
- size,
- ntohl(mp->size));
+ GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+ "Size returned by base64=%d, in the msg=%d.\n",
+ size,
+ ntohl(mp->size));
#endif
- goto END;
+ goto END;
}
coreMP = MALLOC(sizeof(P2P_PACKET));
coreMP->msg = out;
coreMP->size = size - sizeof(SMTPMessage);
coreMP->tsession = NULL;
memcpy(&coreMP->sender,
- &mp->sender,
- sizeof(PeerIdentity));
+ &mp->sender,
+ sizeof(PeerIdentity));
#if DEBUG_SMTP
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SMTP message passed to the core.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SMTP message passed to the core.\n");
#endif
coreAPI->receive(coreMP);
@@ -359,8 +359,8 @@
END:
#if DEBUG_SMTP
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "SMTP message processed.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "SMTP message processed.\n");
#endif
if (fdes != NULL)
fclose(fdes);
@@ -394,8 +394,8 @@
} else {
#if DEBUG_SMTP
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Verified SMTP helo from `%s'.\n",
- &maddr->senderAddress[0]);
+ "Verified SMTP helo from `%s'.\n",
+ &maddr->senderAddress[0]);
#endif
return OK;
}
@@ -416,44 +416,44 @@
int i;
email = getConfigurationString("SMTP",
- "EMAIL");
+ "EMAIL");
if (email == NULL) {
static int once;
if (once == 0) {
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- "No email-address specified, cannot create SMTP advertisement.\n");
+ "No email-address specified, cannot create SMTP advertisement.\n");
once = 1;
}
return NULL;
}
filter = getConfigurationString("SMTP",
- "FILTER");
+ "FILTER");
if (filter == NULL) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("No filter for E-mail specified, cannot create SMTP
advertisement.\n"));
+ _("No filter for E-mail specified, cannot create SMTP advertisement.\n"));
FREE(email);
return NULL;
}
if (strlen(filter) > FILTER_STRING_SIZE) {
filter[FILTER_STRING_SIZE] = '\0';
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("SMTP filter string to long, capped to `%s'\n"),
- filter);
+ _("SMTP filter string to long, capped to `%s'\n"),
+ filter);
}
i = (strlen(email) + 8) & (~7); /* make multiple of 8 */
msg = MALLOC(sizeof(P2P_hello_MESSAGE) + sizeof(EmailAddress) + i);
memset(msg,
- 0,
- sizeof(P2P_hello_MESSAGE) + sizeof(EmailAddress) + i);
+ 0,
+ sizeof(P2P_hello_MESSAGE) + sizeof(EmailAddress) + i);
haddr = (EmailAddress*) &msg[1];
memset(&haddr->filter[0],
- 0,
- FILTER_STRING_SIZE);
+ 0,
+ FILTER_STRING_SIZE);
strcpy(&haddr->filter[0],
- filter);
+ filter);
memcpy(&haddr->senderAddress[0],
- email,
- strlen(email)+1);
+ email,
+ strlen(email)+1);
msg->senderAddressSize = htons(strlen(email)+1+sizeof(EmailAddress));
msg->protocol = htons(SMTP_PROTOCOL_NUMBER);
msg->MTU = htonl(smtpAPI.mtu);
@@ -472,15 +472,15 @@
* @return OK on success, SYSERR if the operation failed
*/
static int smtpConnect(const P2P_hello_MESSAGE * hello,
- TSession ** tsessionPtr) {
+ TSession ** tsessionPtr) {
TSession * tsession;
tsession = MALLOC(sizeof(TSession));
tsession->internal = MALLOC(P2P_hello_MESSAGE_size(hello));
tsession->peer = hello->senderIdentity;
memcpy(tsession->internal,
- hello,
- P2P_hello_MESSAGE_size(hello));
+ hello,
+ P2P_hello_MESSAGE_size(hello));
tsession->ttype = smtpAPI.protocolNumber;
(*tsessionPtr) = tsession;
return OK;
@@ -512,9 +512,9 @@
* @return SYSERR on error, OK on success
*/
static int smtpSend(TSession * tsession,
- const void * message,
- const unsigned int size,
- int important) {
+ const void * message,
+ const unsigned int size,
+ int important) {
char * msg;
SMTPMessage * mp;
P2P_hello_MESSAGE * helo;
@@ -543,9 +543,9 @@
smtp_sock = smtp_create_session();
if (smtp_sock == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_IMMEDIATE,
- _("Failed to initialize libesmtp: %s.\n"),
- smtp_strerror(smtp_errno(), ebuf, EBUF_LEN));
+ GE_ERROR | GE_ADMIN | GE_USER | GE_IMMEDIATE,
+ _("Failed to initialize libesmtp: %s.\n"),
+ smtp_strerror(smtp_errno(), ebuf, EBUF_LEN));
return NULL;
}
smtpServer = "localhost:587"; /* fixme */
@@ -559,21 +559,21 @@
mp->size = htons(ssize);
mp->sender = *coreAPI->myIdentity;
memcpy(msg,
- message,
- size);
+ message,
+ size);
ebody = NULL;
#if DEBUG_SMTP
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Base64-encoding %d byte message.\n",
- ssize);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Base64-encoding %d byte message.\n",
+ ssize);
#endif
ssize = base64_encode(msg, ssize, &ebody);
#if DEBUG_SMTP
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Base64-encoded message size is %d bytes.\n",
- ssize);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Base64-encoded message size is %d bytes.\n",
+ ssize);
#endif
FREE(msg);
res = SYSERR;
@@ -581,35 +581,35 @@
message = smtp_add_message(smtp_sock);
if (message == NULL) {
GE_LOG(ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
- "Failed to create smtp message: %s\n",
- smtp_strerror(smtp_errno(), ebuf, EBUF_LEN));
+ GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+ "Failed to create smtp message: %s\n",
+ smtp_strerror(smtp_errno(), ebuf, EBUF_LEN));
return SYSERR;
}
smtp_size_set_estimate(message,
- ssize);
+ ssize);
smtp_set_messagecb(message,
- &getMessage,
- &msg);
+ &getMessage,
+ &msg);
#if 0
if (OK == writeSMTPLine(smtp_sock,
- "%-*s\r\n",
- MIN(FILTER_STRING_SIZE,
- strlen(&haddr->filter[0])),
- &haddr->filter[0])) {
+ "%-*s\r\n",
+ MIN(FILTER_STRING_SIZE,
+ strlen(&haddr->filter[0])),
+ &haddr->filter[0])) {
}
#endif
recipient = smtp_add_recipient(message,
- haddr->senderAddress);
+ haddr->senderAddress);
if (recipient == NULL) {
/* FIXME */
}
if (res != OK)
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Sending E-mail to `%s' failed.\n"),
- &haddr->senderAddress[0]);
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Sending E-mail to `%s' failed.\n"),
+ &haddr->senderAddress[0]);
incrementBytesSent(ssize);
FREE(ebody);
smtp_destroy_session(smtp_sock);
@@ -641,12 +641,12 @@
smtp_shutdown = NO;
/* initialize SMTP network */
dispatchThread = PTHREAD_CREATE(&listenAndDistribute,
- NULL,
- 1024*4);
+ NULL,
+ 1024*4);
if (dispatchThread == NULL)
GE_DIE_STRERROR(ectx,
- GE_ADMIN | GE_BULK | GE_FATAL,
- "pthread_create");
+ GE_ADMIN | GE_BULK | GE_FATAL,
+ "pthread_create");
return OK;
}
@@ -675,11 +675,11 @@
n = FILTER_STRING_SIZE + strlen(addr->senderAddress) + 16;
ret = MALLOC(n);
SNPRINTF(ret,
- n,
- _("%.*s filter %s (SMTP)"),
- FILTER_STRING_SIZE,
- addr->filter,
- addr->senderAddress);
+ n,
+ _("%.*s filter %s (SMTP)"),
+ FILTER_STRING_SIZE,
+ addr->filter,
+ addr->senderAddress);
return ret;
}
@@ -698,14 +698,14 @@
coreAPI = core;
ectx = core->ectx;
mtu = getConfigurationInt("SMTP",
- "MTU");
+ "MTU");
if (mtu == 0)
mtu = MESSAGE_SIZE;
if (mtu < 1200)
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("MTU for `%s' is probably too low (fragmentation not
implemented!)\n"),
- "SMTP");
+ GE_ERROR | GE_BULK | GE_USER,
+ _("MTU for `%s' is probably too low (fragmentation not implemented!)\n"),
+ "SMTP");
if (mtu > MESSAGE_SIZE)
mtu = MESSAGE_SIZE;
smtpAPI.protocolNumber = SMTP_PROTOCOL_NUMBER;
Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/tcp.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -95,37 +95,37 @@
* Check if we are allowed to connect to the given IP.
*/
static int isBlacklisted(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
IPaddr ip;
int ret;
if (addr_len == sizeof(struct sockaddr_in)) {
memcpy(&ip,
- &((struct sockaddr_in*) addr)->sin_addr,
- sizeof(IPaddr));
+ &((struct sockaddr_in*) addr)->sin_addr,
+ sizeof(IPaddr));
} else if (addr_len == sizeof(IPaddr)) {
memcpy(&ip,
- addr,
- addr_len);
+ addr,
+ addr_len);
} else {
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_ADMIN | GE_BULK,
- "Rejecting connection (invalid address length %u)\n",
- addr_len);
+ GE_DEBUG | GE_ADMIN | GE_BULK,
+ "Rejecting connection (invalid address length %u)\n",
+ addr_len);
#endif
return SYSERR;
}
MUTEX_LOCK(tcpblacklistlock);
ret = check_ipv4_listed(filteredNetworks_,
- ip);
+ ip);
MUTEX_UNLOCK(tcpblacklistlock);
#if DEBUG_TCP
if (ret != NO)
GE_LOG(ectx,
- GE_DEBUG | GE_ADMIN | GE_BULK,
- "Rejecting connection from address %u.%u.%u.%u (blacklisted)\n",
- PRIP(ntohl(*(int*)addr)));
+ GE_DEBUG | GE_ADMIN | GE_BULK,
+ "Rejecting connection from address %u.%u.%u.%u (blacklisted)\n",
+ PRIP(ntohl(*(int*)addr)));
#endif
return ret;
}
@@ -134,24 +134,24 @@
* Check if we are allowed to connect to the given IP.
*/
static int isWhitelisted(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
IPaddr ip;
int ret;
if (addr_len == sizeof(struct sockaddr_in)) {
memcpy(&ip,
- &((struct sockaddr_in*) addr)->sin_addr,
- sizeof(IPaddr));
+ &((struct sockaddr_in*) addr)->sin_addr,
+ sizeof(IPaddr));
} else if (addr_len == sizeof(IPaddr)) {
memcpy(&ip,
- addr,
- addr_len);
+ addr,
+ addr_len);
} else {
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_ADMIN | GE_BULK,
- "Rejecting connection (invalid address length %u)\n",
- addr_len);
+ GE_DEBUG | GE_ADMIN | GE_BULK,
+ "Rejecting connection (invalid address length %u)\n",
+ addr_len);
#endif
return SYSERR;
}
@@ -159,25 +159,25 @@
MUTEX_LOCK(tcpblacklistlock);
if (allowedNetworks_ != NULL)
ret = check_ipv4_listed(allowedNetworks_,
- ip);
+ ip);
MUTEX_UNLOCK(tcpblacklistlock);
if (ret != YES) {
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_ADMIN | GE_BULK,
- "Rejecting HELLO from address %u.%u.%u.%u (not whitelisted)\n",
- PRIP(ntohl(*(int*)addr)));
+ GE_DEBUG | GE_ADMIN | GE_BULK,
+ "Rejecting HELLO from address %u.%u.%u.%u (not whitelisted)\n",
+ PRIP(ntohl(*(int*)addr)));
#endif
}
return ret;
}
static int isRejected(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
if ((NO != isBlacklisted(addr,
- addr_len)) ||
+ addr_len)) ||
(YES != isWhitelisted(addr,
- addr_len)))
+ addr_len)))
return YES;
return NO;
}
@@ -188,16 +188,16 @@
* the config file.
*/
static unsigned short getGNUnetTCPPort() {
- struct servent * pse; /* pointer to service information entry */
+ struct servent * pse; /* pointer to service information entry */
unsigned long long port;
if (-1 == GC_get_configuration_value_number(cfg,
- "TCP",
- "PORT",
- 0,
- 65535,
- 2086,
- &port)) {
+ "TCP",
+ "PORT",
+ 0,
+ 65535,
+ 2086,
+ &port)) {
if ((pse = getservbyname("gnunet", "tcp")))
port = htons(pse->s_port);
else
@@ -224,18 +224,18 @@
(ntohs(hello->header.type) != p2p_PROTO_hello) ||
(ntohs(hello->protocol) != TCP_PROTOCOL_NUMBER) ||
(YES == isBlacklisted(&haddr->ip,
- sizeof(IPaddr))) ||
+ sizeof(IPaddr))) ||
(YES != isWhitelisted(&haddr->ip,
- sizeof(IPaddr))) ) {
+ sizeof(IPaddr))) ) {
#if DEBUG_TCP
EncName enc;
hash2enc(&hello->senderIdentity.hashPubKey,
- &enc);
+ &enc);
GE_LOG(ectx,
- GE_DEBUG | GE_ADMIN | GE_BULK,
- "Rejecting HELLO from `%s'\n",
- &enc);
+ GE_DEBUG | GE_ADMIN | GE_BULK,
+ "Rejecting HELLO from `%s'\n",
+ &enc);
#endif
return SYSERR; /* obviously invalid */
}
@@ -261,8 +261,8 @@
once = 1;
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "TCP port is 0, will only send using TCP.\n");
+ GE_DEBUG | GE_USER | GE_BULK,
+ "TCP port is 0, will only send using TCP.\n");
#endif
}
return NULL; /* TCP transport is configured SEND-only! */
@@ -271,22 +271,22 @@
haddr = (HostAddress*) &msg[1];
if (! ( ( (upnp != NULL) &&
- (OK == upnp->get_ip(port,
- "TCP",
- &haddr->ip)) ) ||
- (SYSERR != getPublicIPAddress(cfg,
- ectx,
- &haddr->ip)) ) ) {
+ (OK == upnp->get_ip(port,
+ "TCP",
+ &haddr->ip)) ) ||
+ (SYSERR != getPublicIPAddress(cfg,
+ ectx,
+ &haddr->ip)) ) ) {
FREE(msg);
GE_LOG(ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
- _("TCP: Could not determine my public IP address.\n"));
+ GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+ _("TCP: Could not determine my public IP address.\n"));
return NULL;
}
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- "TCP uses IP address %u.%u.%u.%u.\n",
- PRIP(ntohl(*(int*)&haddr->ip)));
+ GE_INFO | GE_USER | GE_BULK,
+ "TCP uses IP address %u.%u.%u.%u.\n",
+ PRIP(ntohl(*(int*)&haddr->ip)));
haddr->port = htons(port);
haddr->reserved = htons(0);
msg->senderAddressSize = htons(sizeof(HostAddress));
@@ -303,7 +303,7 @@
* @return OK on success, SYSERR if the operation failed
*/
static int tcpConnect(const P2P_hello_MESSAGE * hello,
- TSession ** tsessionPtr) {
+ TSession ** tsessionPtr) {
static int zero = 0;
HostAddress * haddr;
int sock;
@@ -318,15 +318,15 @@
session = sessions;
while (session != NULL) {
if (0 == memcmp(&session->sender,
- &hello->senderIdentity,
- sizeof(PeerIdentity))) {
+ &hello->senderIdentity,
+ sizeof(PeerIdentity))) {
MUTEX_LOCK(session->lock);
if (session->in_select) {
- session->users++;
- MUTEX_UNLOCK(session->lock);
- MUTEX_UNLOCK(tcplock);
- *tsessionPtr = session->tsession;
- return OK;
+ session->users++;
+ MUTEX_UNLOCK(session->lock);
+ MUTEX_UNLOCK(tcplock);
+ *tsessionPtr = session->tsession;
+ return OK;
}
MUTEX_UNLOCK(session->lock);
}
@@ -336,72 +336,72 @@
haddr = (HostAddress*) &hello[1];
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Creating TCP connection to %u.%u.%u.%u:%u.\n",
- PRIP(ntohl(*(int*)&haddr->ip.addr)),
- ntohs(haddr->port));
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Creating TCP connection to %u.%u.%u.%u:%u.\n",
+ PRIP(ntohl(*(int*)&haddr->ip.addr)),
+ ntohs(haddr->port));
#endif
sock = SOCKET(PF_INET,
- SOCK_STREAM,
- 6); /* 6: TCP */
+ SOCK_STREAM,
+ 6); /* 6: TCP */
if (sock == -1) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "socket");
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "socket");
return SYSERR;
}
s = socket_create(ectx,
- coreAPI->load_monitor,
- sock);
+ coreAPI->load_monitor,
+ sock);
#if TCP_SYNCNT
/* only try a single packet to establish connection,
if that does not work, abort instantly */
setsockopt(sock,
- IPPROTO_TCP,
- TCP_SYNCNT,
- &zero,
- sizeof(zero));
+ IPPROTO_TCP,
+ TCP_SYNCNT,
+ &zero,
+ sizeof(zero));
#endif
if (-1 == socket_set_blocking(s, NO)) {
socket_destroy(s);
return SYSERR;
}
memset(&soaddr,
- 0,
- sizeof(soaddr));
+ 0,
+ sizeof(soaddr));
soaddr.sin_family = AF_INET;
GE_ASSERT(ectx,
- sizeof(struct in_addr) == sizeof(IPaddr));
+ sizeof(struct in_addr) == sizeof(IPaddr));
memcpy(&soaddr.sin_addr,
- &haddr->ip,
- sizeof(IPaddr));
+ &haddr->ip,
+ sizeof(IPaddr));
soaddr.sin_port = haddr->port;
i = CONNECT(sock,
- (struct sockaddr*)&soaddr,
- sizeof(soaddr));
+ (struct sockaddr*)&soaddr,
+ sizeof(soaddr));
if ( (i < 0) &&
(errno != EINPROGRESS) && (errno != EWOULDBLOCK) ) {
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- _("Cannot connect to %u.%u.%u.%u:%u: %s\n"),
- PRIP(ntohl(*(int*)&haddr->ip)),
- ntohs(haddr->port),
- STRERROR(errno));
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ _("Cannot connect to %u.%u.%u.%u:%u: %s\n"),
+ PRIP(ntohl(*(int*)&haddr->ip)),
+ ntohs(haddr->port),
+ STRERROR(errno));
socket_destroy(s);
return SYSERR;
}
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_USER | GE_BULK,
- "Establishing connection to %u.%u.%u.%u:%u\n",
- PRIP(ntohl(*(int*)&haddr->ip)),
- ntohs(haddr->port));
+ GE_DEBUG | GE_DEVELOPER | GE_USER | GE_BULK,
+ "Establishing connection to %u.%u.%u.%u:%u\n",
+ PRIP(ntohl(*(int*)&haddr->ip)),
+ ntohs(haddr->port));
#endif
return tcpConnectHelper(hello,
- s,
- tcpAPI.protocolNumber,
- tsessionPtr);
+ s,
+ tcpAPI.protocolNumber,
+ tsessionPtr);
}
/**
@@ -421,62 +421,62 @@
port = getGNUnetTCPPort();
if (port != 0) {
s = SOCKET(PF_INET,
- SOCK_STREAM,
- 0);
+ SOCK_STREAM,
+ 0);
if (s < 0) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "socket");
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "socket");
return SYSERR;
}
if (SETSOCKOPT(s,
- SOL_SOCKET,
- SO_REUSEADDR,
- &on,
- sizeof(on)) < 0 )
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ &on,
+ sizeof(on)) < 0 )
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "setsockopt");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "setsockopt");
memset((char *) &serverAddr,
- 0,
- sizeof(serverAddr));
+ 0,
+ sizeof(serverAddr));
serverAddr.sin_family = AF_INET;
serverAddr.sin_addr.s_addr = htonl(INADDR_ANY);
serverAddr.sin_port = htons(getGNUnetTCPPort());
if (BIND(s,
- (struct sockaddr *) &serverAddr,
- sizeof(serverAddr)) < 0) {
+ (struct sockaddr *) &serverAddr,
+ sizeof(serverAddr)) < 0) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
- "bind");
+ GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
+ "bind");
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
- _("Failed to start transport service on port %d.\n"),
- getGNUnetTCPPort());
+ GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
+ _("Failed to start transport service on port %d.\n"),
+ getGNUnetTCPPort());
if (0 != CLOSE(s))
- GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "close");
+ GE_LOG_STRERROR(ectx,
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "close");
return SYSERR;
}
} else {
s = -1; /* no listening! */
}
selector = select_create("tcp",
- NO,
- ectx,
- coreAPI->load_monitor,
- s,
- sizeof(struct sockaddr_in),
- TCP_FAST_TIMEOUT,
- &select_message_handler,
- NULL,
- &select_accept_handler,
- &isRejected,
- &select_close_handler,
- NULL,
- 128 * 1024 /* max memory */,
- 128 /* max sockets */);
+ NO,
+ ectx,
+ coreAPI->load_monitor,
+ s,
+ sizeof(struct sockaddr_in),
+ TCP_FAST_TIMEOUT,
+ &select_message_handler,
+ NULL,
+ &select_accept_handler,
+ &isRejected,
+ &select_close_handler,
+ NULL,
+ 128 * 1024 /* max memory */,
+ 128 /* max sockets */);
return OK;
}
@@ -485,36 +485,36 @@
* configuration on error, syslog errors!)
*/
static int reloadConfiguration(void * ctx,
- struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option) {
+ struct GC_Configuration * cfg,
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option) {
char * ch;
if (0 != strcmp(section, "TCP"))
return 0; /* fast path */
-
+
MUTEX_LOCK(tcpblacklistlock);
FREENONNULL(filteredNetworks_);
FREENONNULL(allowedNetworks_);
ch = NULL;
GC_get_configuration_value_string(cfg,
- "TCP",
- "BLACKLIST",
- "",
- &ch);
+ "TCP",
+ "BLACKLIST",
+ "",
+ &ch);
filteredNetworks_ = parse_ipv4_network_specification(ectx,
- ch);
+ ch);
FREE(ch);
ch = NULL;
GC_get_configuration_value_string(cfg,
- "TCP",
- "WHITELIST",
- "",
- &ch);
+ "TCP",
+ "WHITELIST",
+ "",
+ &ch);
if (strlen(ch) > 0)
allowedNetworks_ = parse_ipv4_network_specification(ectx,
- ch);
+ ch);
else
allowedNetworks_ = NULL;
FREE(ch);
@@ -528,8 +528,8 @@
*/
static int
helloToAddress(const P2P_hello_MESSAGE * hello,
- void ** sa,
- unsigned int * sa_len) {
+ void ** sa,
+ unsigned int * sa_len) {
const HostAddress * haddr = (const HostAddress*) &hello[1];
struct sockaddr_in * serverAddr;
@@ -537,12 +537,12 @@
serverAddr = MALLOC(sizeof(struct sockaddr_in));
*sa = serverAddr;
memset(serverAddr,
- 0,
- sizeof(struct sockaddr_in));
+ 0,
+ sizeof(struct sockaddr_in));
serverAddr->sin_family = AF_INET;
memcpy(&serverAddr->sin_addr,
- haddr,
- sizeof(IPaddr));
+ haddr,
+ sizeof(IPaddr));
serverAddr->sin_port = haddr->port;
return OK;
}
@@ -563,8 +563,8 @@
tcplock = MUTEX_CREATE(YES);
tcpblacklistlock = MUTEX_CREATE(YES);
if (0 != GC_attach_change_listener(cfg,
- &reloadConfiguration,
- NULL)) {
+ &reloadConfiguration,
+ NULL)) {
MUTEX_DESTROY(tcplock);
MUTEX_DESTROY(tcpblacklistlock);
tcplock = NULL;
@@ -573,16 +573,16 @@
}
coreAPI = core;
if (GC_get_configuration_value_yesno(cfg,
- "TCP",
- "UPNP",
- YES) == YES) {
+ "TCP",
+ "UPNP",
+ YES) == YES) {
upnp = coreAPI->requestService("upnp");
if (upnp == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("The UPnP service could not be loaded. To disable UPnP, set the
" \
- "configuration option \"UPNP\" in section \"TCP\" to
\"NO\"\n"));
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("The UPnP service could not be loaded. To disable UPnP, set the " \
+ "configuration option \"UPNP\" in section \"TCP\" to \"NO\"\n"));
}
}
@@ -614,8 +614,8 @@
void donetransport_tcp() {
GC_detach_change_listener(cfg,
- &reloadConfiguration,
- NULL);
+ &reloadConfiguration,
+ NULL);
if (stats != NULL) {
coreAPI->releaseService(stats);
stats = NULL;
Modified: GNUnet/src/transports/tcp6.c
===================================================================
--- GNUnet/src/transports/tcp6.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/tcp6.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -95,24 +95,24 @@
* Check if we are allowed to connect to the given IP.
*/
static int isBlacklisted(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
IP6addr ip;
int ret;
if (addr_len == sizeof(IP6addr)) {
memcpy(&ip,
- addr,
- sizeof(IP6addr));
+ addr,
+ sizeof(IP6addr));
} else if (addr_len == sizeof(struct sockaddr_in6)) {
memcpy(&ip,
- &((struct sockaddr_in6*) addr)->sin6_addr,
- sizeof(IP6addr));
+ &((struct sockaddr_in6*) addr)->sin6_addr,
+ sizeof(IP6addr));
} else {
return SYSERR;
}
MUTEX_LOCK(tcpblacklistlock);
ret = check_ipv6_listed(filteredNetworks_,
- ip);
+ ip);
MUTEX_UNLOCK(tcpblacklistlock);
return ret;
}
@@ -121,18 +121,18 @@
* Check if we are allowed to connect to the given IP.
*/
static int isWhitelisted(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
IP6addr ip;
int ret;
if (addr_len == sizeof(IP6addr)) {
memcpy(&ip,
- addr,
- sizeof(IP6addr));
+ addr,
+ sizeof(IP6addr));
} else if (addr_len == sizeof(struct sockaddr_in6)) {
memcpy(&ip,
- &((struct sockaddr_in6*) addr)->sin6_addr,
- sizeof(IP6addr));
+ &((struct sockaddr_in6*) addr)->sin6_addr,
+ sizeof(IP6addr));
} else {
return SYSERR;
}
@@ -140,17 +140,17 @@
MUTEX_LOCK(tcpblacklistlock);
if (allowedNetworks_ != NULL)
ret = check_ipv6_listed(filteredNetworks_,
- ip);
+ ip);
MUTEX_UNLOCK(tcpblacklistlock);
return ret;
}
static int isRejected(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
if ((YES == isBlacklisted(addr,
- addr_len)) ||
+ addr_len)) ||
(YES != isWhitelisted(addr,
- addr_len)))
+ addr_len)))
return YES;
return NO;
}
@@ -161,16 +161,16 @@
* the config file.
*/
static unsigned short getGNUnetTCP6Port() {
- struct servent * pse; /* pointer to service information entry */
+ struct servent * pse; /* pointer to service information entry */
unsigned long long port;
if (-1 == GC_get_configuration_value_number(cfg,
- "TCP6",
- "PORT",
- 1,
- 65535,
- 2086,
- &port)) {
+ "TCP6",
+ "PORT",
+ 1,
+ 65535,
+ 2086,
+ &port)) {
if ((pse = getservbyname("gnunet", "tcp6")))
port = htons(pse->s_port);
else
@@ -197,9 +197,9 @@
(ntohs(hello->header.type) != p2p_PROTO_hello) ||
(ntohs(hello->protocol) != TCP6_PROTOCOL_NUMBER) ||
(YES == isBlacklisted(&haddr->ip,
- sizeof(IP6addr))) ||
+ sizeof(IP6addr))) ||
(YES != isWhitelisted(&haddr->ip,
- sizeof(IP6addr))) )
+ sizeof(IP6addr))) )
return SYSERR; /* obviously invalid */
else
return OK;
@@ -220,20 +220,20 @@
port = getGNUnetTCP6Port();
if (0 == port) {
GE_LOG(ectx,
- GE_DEBUG,
- "TCP6 port is 0, will only send using TCP6\n");
+ GE_DEBUG,
+ "TCP6 port is 0, will only send using TCP6\n");
return NULL; /* TCP6 transport is configured SEND-only! */
}
msg = (P2P_hello_MESSAGE *) MALLOC(sizeof(P2P_hello_MESSAGE) +
sizeof(Host6Address));
haddr = (Host6Address*) &msg[1];
if (SYSERR == getPublicIP6Address(cfg,
- ectx,
- &haddr->ip)) {
+ ectx,
+ &haddr->ip)) {
FREE(msg);
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Could not determine my public IPv6 address.\n"));
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Could not determine my public IPv6 address.\n"));
return NULL;
}
haddr->port = htons(port);
@@ -252,7 +252,7 @@
* @return OK on success, SYSERR if the operation failed
*/
static int tcp6Connect(const P2P_hello_MESSAGE * hello,
- TSession ** tsessionPtr) {
+ TSession ** tsessionPtr) {
int i;
Host6Address * haddr;
int sock;
@@ -268,15 +268,15 @@
session = sessions;
while (session != NULL) {
if (0 == memcmp(&session->sender,
- &hello->senderIdentity,
- sizeof(PeerIdentity))) {
+ &hello->senderIdentity,
+ sizeof(PeerIdentity))) {
MUTEX_LOCK(session->lock);
if (session->in_select) {
- session->users++;
- MUTEX_UNLOCK(session->lock);
- MUTEX_UNLOCK(tcplock);
- *tsessionPtr = session->tsession;
- return OK;
+ session->users++;
+ MUTEX_UNLOCK(session->lock);
+ MUTEX_UNLOCK(tcplock);
+ *tsessionPtr = session->tsession;
+ return OK;
}
MUTEX_UNLOCK(session->lock);
}
@@ -288,28 +288,28 @@
hints.ai_family = PF_INET6;
hints.ai_socktype = SOCK_STREAM;
inet_ntop(AF_INET6,
- haddr,
- hostname,
- INET6_ADDRSTRLEN);
+ haddr,
+ hostname,
+ INET6_ADDRSTRLEN);
rtn = getaddrinfo(hostname, NULL, &hints, &res0);
if (rtn != 0) {
GE_LOG(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- _("`%s': unknown service: %s\n"),
- __FUNCTION__,
- gai_strerror(rtn));
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ _("`%s': unknown service: %s\n"),
+ __FUNCTION__,
+ gai_strerror(rtn));
return SYSERR;
}
#if DEBUG_TCP6
GE_LOG(ectx,
- GE_DEBUG,
- "Creating TCP6 connection to %s:%d\n",
- inet_ntop(AF_INET6,
- haddr,
- &hostname,
- INET6_ADDRSTRLEN),
- ntohs(haddr->port));
+ GE_DEBUG,
+ "Creating TCP6 connection to %s:%d\n",
+ inet_ntop(AF_INET6,
+ haddr,
+ &hostname,
+ INET6_ADDRSTRLEN),
+ ntohs(haddr->port));
#endif
sock = -1;
@@ -318,18 +318,18 @@
if (res->ai_family != PF_INET6)
continue;
sock = SOCKET(res->ai_family,
- res->ai_socktype,
- res->ai_protocol);
+ res->ai_socktype,
+ res->ai_protocol);
if (sock < 0) {
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "socket");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "socket");
sock = -1;
continue;
}
s = socket_create(ectx,
- coreAPI->load_monitor,
- sock);
+ coreAPI->load_monitor,
+ sock);
if (-1 == socket_set_blocking(s, NO)) {
socket_destroy(s);
freeaddrinfo(res0);
@@ -337,13 +337,13 @@
}
((struct sockaddr_in6*)(res->ai_addr))->sin6_port = haddr->port;
i = CONNECT(sock,
- res->ai_addr,
- res->ai_addrlen);
+ res->ai_addr,
+ res->ai_addrlen);
if ( (i < 0) &&
- (errno != EINPROGRESS) && (errno != EWOULDBLOCK) ) {
+ (errno != EINPROGRESS) && (errno != EWOULDBLOCK) ) {
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "connect");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "connect");
socket_destroy(s);
s = NULL;
sock = -1;
@@ -356,9 +356,9 @@
return SYSERR;
GE_ASSERT(ectx, s != NULL);
return tcpConnectHelper(hello,
- s,
- tcp6API.protocolNumber,
- tsessionPtr);
+ s,
+ tcp6API.protocolNumber,
+ tsessionPtr);
}
/**
@@ -378,63 +378,63 @@
port = getGNUnetTCP6Port();
if (port != 0) {
s = SOCKET(PF_INET6,
- SOCK_STREAM,
- 0);
+ SOCK_STREAM,
+ 0);
if (s < 0) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "socket");
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "socket");
return SYSERR;
}
if (SETSOCKOPT(s,
- SOL_SOCKET,
- SO_REUSEADDR,
- &on,
- sizeof(on)) < 0 )
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ &on,
+ sizeof(on)) < 0 )
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "setsockopt");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "setsockopt");
memset((char *) &serverAddr,
- 0,
- sizeof(serverAddr));
+ 0,
+ sizeof(serverAddr));
serverAddr.sin6_family = AF_INET6;
serverAddr.sin6_flowinfo = 0;
serverAddr.sin6_addr = in6addr_any;
serverAddr.sin6_port = htons(getGNUnetTCP6Port());
if (BIND(s,
- (struct sockaddr *) &serverAddr,
- sizeof(serverAddr)) < 0) {
+ (struct sockaddr *) &serverAddr,
+ sizeof(serverAddr)) < 0) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
- "bind");
+ GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
+ "bind");
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
- _("Failed to start transport service on port %d.\n"),
- getGNUnetTCP6Port());
+ GE_ERROR | GE_ADMIN | GE_IMMEDIATE,
+ _("Failed to start transport service on port %d.\n"),
+ getGNUnetTCP6Port());
if (0 != CLOSE(s))
- GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "close");
+ GE_LOG_STRERROR(ectx,
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "close");
return SYSERR;
}
} else {
s = -1;
}
selector = select_create("tcp6",
- NO,
- ectx,
- coreAPI->load_monitor,
- s,
- sizeof(IPaddr),
- TCP_FAST_TIMEOUT,
- &select_message_handler,
- NULL,
- &select_accept_handler,
- &isRejected,
- &select_close_handler,
- NULL,
- 128 * 1024 /* max memory */,
- 128 /* max sockets */);
+ NO,
+ ectx,
+ coreAPI->load_monitor,
+ s,
+ sizeof(IPaddr),
+ TCP_FAST_TIMEOUT,
+ &select_message_handler,
+ NULL,
+ &select_accept_handler,
+ &isRejected,
+ &select_close_handler,
+ NULL,
+ 128 * 1024 /* max memory */,
+ 128 /* max sockets */);
return OK;
}
@@ -443,10 +443,10 @@
* configuration on error, syslog errors!)
*/
static int reloadConfiguration(void * ctx,
- struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option) {
+ struct GC_Configuration * cfg,
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option) {
char * ch;
if (0 != strcmp(section, "TCP6"))
@@ -455,21 +455,21 @@
FREENONNULL(filteredNetworks_);
FREENONNULL(allowedNetworks_);
GC_get_configuration_value_string(cfg,
- "TCP6",
- "BLACKLIST",
- "",
- &ch);
+ "TCP6",
+ "BLACKLIST",
+ "",
+ &ch);
filteredNetworks_ = parse_ipv6_network_specification(ectx,
- ch);
+ ch);
FREE(ch);
GC_get_configuration_value_string(cfg,
- "TCP6",
- "WHITELIST",
- "",
- &ch);
+ "TCP6",
+ "WHITELIST",
+ "",
+ &ch);
if (strlen(ch) > 0)
allowedNetworks_ = parse_ipv6_network_specification(ectx,
- ch);
+ ch);
else
allowedNetworks_ = NULL;
FREE(ch);
@@ -483,8 +483,8 @@
*/
static int
helloToAddress(const P2P_hello_MESSAGE * hello,
- void ** sa,
- unsigned int * sa_len) {
+ void ** sa,
+ unsigned int * sa_len) {
const Host6Address * haddr = (const Host6Address*) &hello[1];
struct sockaddr_in6 * serverAddr;
@@ -492,12 +492,12 @@
serverAddr = MALLOC(sizeof(struct sockaddr_in6));
*sa = serverAddr;
memset(serverAddr,
- 0,
- sizeof(struct sockaddr_in6));
+ 0,
+ sizeof(struct sockaddr_in6));
serverAddr->sin6_family = AF_INET6;
memcpy(&serverAddr->sin6_addr,
- haddr,
- sizeof(IP6addr));
+ haddr,
+ sizeof(IP6addr));
serverAddr->sin6_port = haddr->port;
return OK;
}
@@ -515,8 +515,8 @@
tcplock = MUTEX_CREATE(YES);
tcpblacklistlock = MUTEX_CREATE(YES);
if (0 != GC_attach_change_listener(cfg,
- &reloadConfiguration,
- NULL)) {
+ &reloadConfiguration,
+ NULL)) {
MUTEX_DESTROY(tcplock);
MUTEX_DESTROY(tcpblacklistlock);
tcplock = NULL;
@@ -552,8 +552,8 @@
void donetransport_tcp6() {
GC_detach_change_listener(cfg,
- &reloadConfiguration,
- NULL);
+ &reloadConfiguration,
+ NULL);
coreAPI->releaseService(stats);
stats = NULL;
FREENONNULL(filteredNetworks_);
Modified: GNUnet/src/transports/tcp_helper.c
===================================================================
--- GNUnet/src/transports/tcp_helper.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/tcp_helper.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -25,7 +25,7 @@
*/
typedef int (*BlacklistedTester)(const void * addr,
- unsigned int addr_len);
+ unsigned int addr_len);
/**
* Initial handshake message. Note that the beginning
@@ -129,9 +129,9 @@
while (pos != NULL) {
if (pos == tcpsession) {
if (prev == NULL)
- sessions = pos->next;
+ sessions = pos->next;
else
- prev->next = pos->next;
+ prev->next = pos->next;
break;
}
prev = pos;
@@ -153,19 +153,19 @@
(tcpsession->in_select == YES) ) {
if (tcpsession->users == 0)
select_change_timeout(selector,
- tcpsession->sock,
- TCP_FAST_TIMEOUT);
+ tcpsession->sock,
+ TCP_FAST_TIMEOUT);
MUTEX_UNLOCK(tcpsession->lock);
MUTEX_UNLOCK(tcplock);
return OK;
}
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "TCP disconnect closes socket session.\n");
+ GE_DEBUG | GE_USER | GE_BULK,
+ "TCP disconnect closes socket session.\n");
#endif
select_disconnect(selector,
- tcpsession->sock);
+ tcpsession->sock);
MUTEX_UNLOCK(tcpsession->lock);
freeTCPSession(tcpsession);
MUTEX_UNLOCK(tcplock);
@@ -200,8 +200,8 @@
if ( (tcpSession->users == 0) &&
(tcpSession->in_select == YES) )
select_change_timeout(selector,
- tcpSession->sock,
- TCP_TIMEOUT);
+ tcpSession->sock,
+ TCP_TIMEOUT);
tcpSession->users++;
MUTEX_UNLOCK(tcpSession->lock);
@@ -215,10 +215,10 @@
* already held by the caller.
*/
static int select_message_handler(void * mh_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * sock_ctx,
- const MESSAGE_HEADER * msg) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ void * sock_ctx,
+ const MESSAGE_HEADER * msg) {
TSession * tsession = sock_ctx;
TCPSession * tcpSession;
TCPSession * pos;
@@ -233,19 +233,19 @@
len = ntohs(msg->size);
if (stats != NULL)
stats->change(stat_bytesReceived,
- len);
+ len);
tcpSession = tsession->internal;
if (YES == tcpSession->expectingWelcome) {
/* at this point, we should be the only user! */
GE_ASSERT(NULL,
- tcpSession->users == 1);
+ tcpSession->users == 1);
welcome = (const TCPWelcome*) msg;
if ( (ntohs(welcome->header.type) != 0) ||
- (len != sizeof(TCPWelcome)) ) {
+ (len != sizeof(TCPWelcome)) ) {
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Received malformed message instead of welcome message.
Closing.\n"));
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Received malformed message instead of welcome message. Closing.\n"));
tcpDisconnect(tsession);
return SYSERR;
}
@@ -254,8 +254,8 @@
tsession->peer = welcome->clientIdentity;
if (tcpSession->accept_addr != NULL)
setIPaddressFromPID(&welcome->clientIdentity,
- tcpSession->accept_addr,
- tcpSession->addr_len);
+ tcpSession->accept_addr,
+ tcpSession->addr_len);
/* check that we do not already have
a connection from this peer; if so,
close the old one! */
@@ -263,44 +263,44 @@
pos = sessions;
while (pos != NULL) {
if (pos == tcpSession) {
- pos = pos->next;
- continue;
+ pos = pos->next;
+ continue;
}
if (0 == memcmp(&pos->sender,
- &tcpSession->sender,
- sizeof(PeerIdentity))) {
- /* replace existing socket in pos with
- the new socket in tcpSession; then
- delete the new tcpSession -- we have
- the old one! */
- MUTEX_LOCK(pos->lock);
- if (SYSERR == tcpAssociate(pos->tsession)) {
- GE_BREAK(ectx, 0);
- MUTEX_UNLOCK(pos->lock);
- MUTEX_UNLOCK(tcplock);
- return SYSERR;
- }
- if (pos->in_select)
- select_disconnect(sh,
- pos->sock);
- pos->in_select = YES;
- pos->sock = tcpSession->sock;
- select_update_closure(sh,
- pos->sock,
- tsession,
- pos->tsession);
- FREENONNULL(pos->accept_addr);
- pos->accept_addr = tcpSession->accept_addr;
- pos->addr_len = tcpSession->addr_len;
- tcpSession->accept_addr = NULL;
- tcpSession->addr_len = 0;
- tcpDisconnect(tsession);
- tcpSession->in_select = NO;
- freeTCPSession(tcpSession);
- tcpSession = pos;
- tsession = pos->tsession;
- MUTEX_UNLOCK(pos->lock);
- break;
+ &tcpSession->sender,
+ sizeof(PeerIdentity))) {
+ /* replace existing socket in pos with
+ the new socket in tcpSession; then
+ delete the new tcpSession -- we have
+ the old one! */
+ MUTEX_LOCK(pos->lock);
+ if (SYSERR == tcpAssociate(pos->tsession)) {
+ GE_BREAK(ectx, 0);
+ MUTEX_UNLOCK(pos->lock);
+ MUTEX_UNLOCK(tcplock);
+ return SYSERR;
+ }
+ if (pos->in_select)
+ select_disconnect(sh,
+ pos->sock);
+ pos->in_select = YES;
+ pos->sock = tcpSession->sock;
+ select_update_closure(sh,
+ pos->sock,
+ tsession,
+ pos->tsession);
+ FREENONNULL(pos->accept_addr);
+ pos->accept_addr = tcpSession->accept_addr;
+ pos->addr_len = tcpSession->addr_len;
+ tcpSession->accept_addr = NULL;
+ tcpSession->addr_len = 0;
+ tcpDisconnect(tsession);
+ tcpSession->in_select = NO;
+ freeTCPSession(tcpSession);
+ tcpSession = pos;
+ tsession = pos->tsession;
+ MUTEX_UNLOCK(pos->lock);
+ break;
}
pos = pos->next;
}
@@ -310,16 +310,16 @@
/* send msg to core! */
if (len <= sizeof(MESSAGE_HEADER)) {
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Received malformed message from tcp-peer connection.
Closing.\n"));
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Received malformed message from tcp-peer connection. Closing.\n"));
tcpDisconnect(tsession);
return SYSERR;
}
mp = MALLOC(sizeof(P2P_PACKET));
mp->msg = MALLOC(len - sizeof(MESSAGE_HEADER));
memcpy(mp->msg,
- &msg[1],
- len - sizeof(MESSAGE_HEADER));
+ &msg[1],
+ len - sizeof(MESSAGE_HEADER));
mp->sender = tcpSession->sender;
mp->size = len - sizeof(MESSAGE_HEADER);
mp->tsession = tsession;
@@ -336,10 +336,10 @@
* by the select thread.
*/
static void * select_accept_handler(void * ah_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- const void * addr,
- unsigned int addr_len) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ const void * addr,
+ unsigned int addr_len) {
BlacklistedTester blt = ah_cls;
TSession * tsession;
TCPSession * tcpSession;
@@ -347,15 +347,15 @@
if (NO != blt(addr, addr_len)) {
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Rejecting TCP connection (blacklisted).\n");
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Rejecting TCP connection (blacklisted).\n");
#endif
return NULL;
}
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Accepting TCP connection.\n");
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Accepting TCP connection.\n");
#endif
tcpSession = MALLOC(sizeof(TCPSession));
tcpSession->sock = sock;
@@ -375,8 +375,8 @@
if (addr_len > sizeof(IPaddr)) {
tcpSession->accept_addr = MALLOC(addr_len);
memcpy(tcpSession->accept_addr,
- (struct sockaddr_in*) addr,
- sizeof(struct sockaddr_in));
+ (struct sockaddr_in*) addr,
+ sizeof(struct sockaddr_in));
tcpSession->addr_len = addr_len;
} else {
GE_BREAK(NULL, 0);
@@ -388,12 +388,12 @@
sessions = tcpSession;
MUTEX_UNLOCK(tcplock);
return tsession;
-}
+}
static void select_close_handler(void * ch_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * sock_ctx) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ void * sock_ctx) {
TSession * tsession = sock_ctx;
TCPSession * tcpSession = tsession->internal;
@@ -401,13 +401,13 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- hash2enc(&tcpSession->sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ hash2enc(&tcpSession->sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Closed TCP socket of `%s'.\n",
- &enc);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Closed TCP socket of `%s'.\n",
+ &enc);
#endif
MUTEX_LOCK(tcplock);
MUTEX_LOCK(tcpSession->lock);
@@ -430,9 +430,9 @@
* @return SYSERR on error, OK on success
*/
static int tcpSend(TSession * tsession,
- const void * msg,
- unsigned int size,
- int important) {
+ const void * msg,
+ unsigned int size,
+ int important) {
TCPSession * tcpSession;
MESSAGE_HEADER * mp;
int ok;
@@ -447,24 +447,24 @@
EncName enc;
IF_GELOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- hash2enc(&tcpSession->sender.hashPubKey,
- &enc));
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ hash2enc(&tcpSession->sender.hashPubKey,
+ &enc));
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Cannot send message - TCP socket of `%s' already closed!\n",
- &enc);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Cannot send message - TCP socket of `%s' already closed!\n",
+ &enc);
#endif
return SYSERR;
}
if (selector == NULL) {
if (stats != NULL)
stats->change(stat_bytesDropped,
- size);
+ size);
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Could not sent TCP message -- tcp transport is down.\n");
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Could not sent TCP message -- tcp transport is down.\n");
#endif
return SYSERR;
}
@@ -475,11 +475,11 @@
if (tcpSession->sock == NULL) {
if (stats != NULL)
stats->change(stat_bytesDropped,
- size);
+ size);
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Could not sent TCP message -- other side closed connection.\n");
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Could not sent TCP message -- other side closed connection.\n");
#endif
return SYSERR; /* other side closed connection */
}
@@ -487,23 +487,23 @@
mp->size = htons(size + sizeof(MESSAGE_HEADER));
mp->type = 0;
memcpy(&mp[1],
- msg,
- size);
+ msg,
+ size);
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Transport asks select to queue message of size %u\n",
- size);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Transport asks select to queue message of size %u\n",
+ size);
#endif
ok = select_write(selector,
- tcpSession->sock,
- mp,
- NO,
- important);
+ tcpSession->sock,
+ mp,
+ NO,
+ important);
if ( (OK == ok) &&
(stats != NULL) )
stats->change(stat_bytesSent,
- size + sizeof(MESSAGE_HEADER));
+ size + sizeof(MESSAGE_HEADER));
FREE(mp);
return ok;
@@ -523,8 +523,8 @@
* SYSERR if the size/session is invalid
*/
static int tcpTestWouldTry(TSession * tsession,
- const unsigned int size,
- int important) {
+ const unsigned int size,
+ int important) {
TCPSession * tcpSession = tsession->internal;
if (size >= MAX_BUFFER_SIZE - sizeof(MESSAGE_HEADER)) {
@@ -540,10 +540,10 @@
if (tcpSession->sock == NULL)
return SYSERR; /* other side closed connection */
return select_would_try(selector,
- tcpSession->sock,
- size,
- NO,
- important);
+ tcpSession->sock,
+ size,
+ NO,
+ important);
}
@@ -555,9 +555,9 @@
* @return OK on success, SYSERR if the operation failed
*/
static int tcpConnectHelper(const P2P_hello_MESSAGE * hello,
- struct SocketHandle * s,
- unsigned int protocolNumber,
- TSession ** tsessionPtr) {
+ struct SocketHandle * s,
+ unsigned int protocolNumber,
+ TSession ** tsessionPtr) {
TCPWelcome welcome;
TSession * tsession;
TCPSession * tcpSession;
@@ -579,8 +579,8 @@
MUTEX_LOCK(tcplock);
if (OK ==
select_connect(selector,
- tcpSession->sock,
- tsession))
+ tcpSession->sock,
+ tsession))
tcpSession->in_select = YES;
/* send our node identity to the other side to fully establish the
@@ -592,14 +592,14 @@
welcome.clientIdentity
= *(coreAPI->myIdentity);
if (OK != select_write(selector,
- s,
- &welcome.header,
- NO,
- YES)) {
+ s,
+ &welcome.header,
+ NO,
+ YES)) {
#if DEBUG_TCP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Could not sent TCP welcome message, closing connection.\n");
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Could not sent TCP welcome message, closing connection.\n");
#endif
/* disconnect caller -- error! */
tcpDisconnect(tsession);
@@ -607,7 +607,7 @@
return SYSERR;
} else if (stats != NULL)
stats->change(stat_bytesSent,
- sizeof(TCPWelcome));
+ sizeof(TCPWelcome));
tcpSession->next = sessions;
sessions = tcpSession;
MUTEX_UNLOCK(tcplock);
Modified: GNUnet/src/transports/udp.c
===================================================================
--- GNUnet/src/transports/udp.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/udp.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -76,16 +76,16 @@
* @return the port in host byte order
*/
static unsigned short getGNUnetUDPPort() {
- struct servent * pse; /* pointer to service information entry */
+ struct servent * pse; /* pointer to service information entry */
unsigned long long port;
if (-1 == GC_get_configuration_value_number(cfg,
- "UDP",
- "PORT",
- 1,
- 65535,
- 2086,
- &port)) {
+ "UDP",
+ "PORT",
+ 1,
+ 65535,
+ 2086,
+ &port)) {
if ((pse = getservbyname("gnunet", "udp")))
port = htons(pse->s_port);
else
@@ -105,40 +105,40 @@
sock = SOCKET(PF_INET, SOCK_DGRAM, 17);
if (sock < 0) {
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "socket");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "socket");
return -1;
}
if ( SETSOCKOPT(sock,
- SOL_SOCKET,
- SO_REUSEADDR,
- &on,
- sizeof(on)) < 0 ) {
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ &on,
+ sizeof(on)) < 0 ) {
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "setsockopt");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "setsockopt");
return -1;
}
GE_ASSERT(NULL, port != 0);
memset(&sin,
- 0,
- sizeof(sin));
+ 0,
+ sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons(port);
if (BIND(sock,
- (struct sockaddr *)&sin,
- sizeof(sin)) < 0) {
+ (struct sockaddr *)&sin,
+ sizeof(sin)) < 0) {
GE_LOG_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "bind");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "bind");
GE_LOG(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- _("Failed to bind to UDP port %d.\n"),
- port);
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ _("Failed to bind to UDP port %d.\n"),
+ port);
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "bind");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "bind");
return -1;
}
/* do not bind if port == 0, then we use
@@ -150,24 +150,24 @@
* Check if we are explicitly forbidden to communicate with this IP.
*/
static int isBlacklisted(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
IPaddr ip;
int ret;
if (addr_len == sizeof(struct sockaddr_in)) {
memcpy(&ip,
- &((struct sockaddr_in*) addr)->sin_addr,
- sizeof(IPaddr));
+ &((struct sockaddr_in*) addr)->sin_addr,
+ sizeof(IPaddr));
} else if (addr_len == sizeof(IPaddr)) {
memcpy(&ip,
- addr,
- addr_len);
+ addr,
+ addr_len);
} else {
return SYSERR;
}
MUTEX_LOCK(configLock);
ret = check_ipv4_listed(filteredNetworks_,
- ip);
+ ip);
MUTEX_UNLOCK(configLock);
return ret;
}
@@ -176,18 +176,18 @@
* Check if we are allowed to connect to the given IP.
*/
static int isWhitelisted(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
IPaddr ip;
int ret;
if (addr_len == sizeof(struct sockaddr_in)) {
memcpy(&ip,
- &((struct sockaddr_in*) addr)->sin_addr,
- sizeof(IPaddr));
+ &((struct sockaddr_in*) addr)->sin_addr,
+ sizeof(IPaddr));
} else if (addr_len == sizeof(IPaddr)) {
memcpy(&ip,
- addr,
- addr_len);
+ addr,
+ addr_len);
} else {
return SYSERR;
}
@@ -195,22 +195,22 @@
MUTEX_LOCK(configLock);
if (allowedNetworks_ != NULL)
ret = check_ipv4_listed(allowedNetworks_,
- ip);
+ ip);
MUTEX_UNLOCK(configLock);
return ret;
}
static int isRejected(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
if ((YES == isBlacklisted(addr,
- addr_len)) ||
+ addr_len)) ||
(YES != isWhitelisted(addr,
- addr_len))) {
+ addr_len))) {
#if DEBUG_UDP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Rejecting traffic from %u.%u.%u.%u.\n",
- PRIP(ntohl(*(int*)addr)));
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Rejecting traffic from %u.%u.%u.%u.\n",
+ PRIP(ntohl(*(int*)addr)));
#endif
return YES;
}
@@ -238,24 +238,24 @@
return SYSERR;
}
if ( (YES == isBlacklisted(&haddr->ip,
- sizeof(IPaddr))) ||
+ sizeof(IPaddr))) ||
(YES != isWhitelisted(&haddr->ip,
- sizeof(IPaddr))) ) {
+ sizeof(IPaddr))) ) {
#if DEBUG_UDP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Rejecting UDP HELLO from %u.%u.%u.%u:%u due to configuration.\n",
- PRIP(ntohl(*(int*)&haddr->ip.addr)),
- ntohs(haddr->port));
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Rejecting UDP HELLO from %u.%u.%u.%u:%u due to configuration.\n",
+ PRIP(ntohl(*(int*)&haddr->ip.addr)),
+ ntohs(haddr->port));
#endif
return SYSERR; /* obviously invalid */
}
#if DEBUG_UDP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Verified UDP HELLO from %u.%u.%u.%u:%u.\n",
- PRIP(ntohl(*(int*)&haddr->ip.addr)),
- ntohs(haddr->port));
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Verified UDP HELLO from %u.%u.%u.%u:%u.\n",
+ PRIP(ntohl(*(int*)&haddr->ip.addr)),
+ ntohs(haddr->port));
#endif
return OK;
}
@@ -281,22 +281,22 @@
if (! ( ( (upnp != NULL) &&
- (OK == upnp->get_ip(port,
- "UDP",
- &haddr->ip)) ) ||
- (SYSERR != getPublicIPAddress(cfg,
- ectx,
- &haddr->ip)) ) ) {
+ (OK == upnp->get_ip(port,
+ "UDP",
+ &haddr->ip)) ) ||
+ (SYSERR != getPublicIPAddress(cfg,
+ ectx,
+ &haddr->ip)) ) ) {
FREE(msg);
GE_LOG(ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
- _("UDP: Could not determine my public IP address.\n"));
+ GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+ _("UDP: Could not determine my public IP address.\n"));
return NULL;
}
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_BULK,
- "UDP uses IP address %u.%u.%u.%u.\n",
- PRIP(ntohl(*(int*)&haddr->ip)));
+ GE_INFO | GE_USER | GE_BULK,
+ "UDP uses IP address %u.%u.%u.%u.\n",
+ PRIP(ntohl(*(int*)&haddr->ip)));
haddr->port = htons(port);
haddr->reserved = htons(0);
msg->senderAddressSize = htons(sizeof(HostAddress));
@@ -314,9 +314,9 @@
* @return SYSERR on error, OK on success
*/
static int udpSend(TSession * tsession,
- const void * message,
- const unsigned int size,
- int important) {
+ const void * message,
+ const unsigned int size,
+ int important) {
UDPMessage * mp;
P2P_hello_MESSAGE * hello;
HostAddress * haddr;
@@ -346,8 +346,8 @@
mp->header.type = 0;
mp->sender = *(coreAPI->myIdentity);
memcpy(&mp[1],
- message,
- size);
+ message,
+ size);
ok = SYSERR;
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
@@ -355,24 +355,24 @@
GE_ASSERT(ectx, sizeof(struct in_addr) == sizeof(IPaddr));
memcpy(&sin.sin_addr,
- &haddr->ip,
- sizeof(IPaddr));
+ &haddr->ip,
+ sizeof(IPaddr));
#if DEBUG_UDP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Sending message of %d bytes via UDP to %u.%u.%u.%u:%u.\n",
- ssize,
- PRIP(ntohl(*(int*)&sin.sin_addr)),
- ntohs(sin.sin_port));
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Sending message of %d bytes via UDP to %u.%u.%u.%u:%u.\n",
+ ssize,
+ PRIP(ntohl(*(int*)&sin.sin_addr)),
+ ntohs(sin.sin_port));
#endif
#ifndef MINGW
if (YES == socket_send_to(udp_sock,
- NC_Nonblocking,
- mp,
- ssize,
- &sent,
- (const char *) &sin,
- sizeof(sin)))
+ NC_Nonblocking,
+ mp,
+ ssize,
+ &sent,
+ (const char *) &sin,
+ sizeof(sin)))
#else
sent = win_ols_sendto(udp_sock, mp, ssize, (const char *) &sin, sizeof(sin));
if (sent != SOCKET_ERROR)
@@ -381,18 +381,18 @@
ok = OK;
if (stats != NULL)
stats->change(stat_bytesSent,
- sent);
+ sent);
} else {
GE_LOG(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- _("Failed to send message of size %d via UDP to %u.%u.%u.%u:%u:
%s\n"),
- ssize,
- PRIP(ntohl(*(int*)&sin.sin_addr)),
- ntohs(sin.sin_port),
- STRERROR(errno));
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ _("Failed to send message of size %d via UDP to %u.%u.%u.%u:%u: %s\n"),
+ ssize,
+ PRIP(ntohl(*(int*)&sin.sin_addr)),
+ ntohs(sin.sin_port),
+ STRERROR(errno));
if (stats != NULL)
stats->change(stat_bytesDropped,
- ssize);
+ ssize);
}
FREE(mp);
return ok;
@@ -415,20 +415,20 @@
if (sock == -1)
return SYSERR;
selector = select_create("udp",
- YES,
- ectx,
- load_monitor,
- sock,
- sizeof(struct sockaddr_in),
- 0, /* timeout */
- &select_message_handler,
- NULL,
- &select_accept_handler,
- &isRejected,
- &select_close_handler,
- NULL,
- 64 * 1024,
- 16 /* max sockets */);
+ YES,
+ ectx,
+ load_monitor,
+ sock,
+ sizeof(struct sockaddr_in),
+ 0, /* timeout */
+ &select_message_handler,
+ NULL,
+ &select_accept_handler,
+ &isRejected,
+ &select_close_handler,
+ NULL,
+ 64 * 1024,
+ 16 /* max sockets */);
if (selector == NULL)
return SYSERR;
}
@@ -439,15 +439,15 @@
#endif
if (sock == -1) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "socket");
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "socket");
select_destroy(selector);
selector = NULL;
return SYSERR;
}
udp_sock = socket_create(ectx,
- load_monitor,
- sock);
+ load_monitor,
+ sock);
GE_ASSERT(ectx, udp_sock != NULL);
return OK;
}
@@ -463,22 +463,22 @@
FREENONNULL(allowedNetworks_);
ch = NULL;
GC_get_configuration_value_string(cfg,
- "UDP",
- "BLACKLIST",
- "",
- &ch);
+ "UDP",
+ "BLACKLIST",
+ "",
+ &ch);
filteredNetworks_ = parse_ipv4_network_specification(ectx,
- ch);
+ ch);
FREE(ch);
ch = NULL;
GC_get_configuration_value_string(cfg,
- "UDP",
- "WHITELIST",
- "",
- &ch);
+ "UDP",
+ "WHITELIST",
+ "",
+ &ch);
if (strlen(ch) > 0)
allowedNetworks_ = parse_ipv4_network_specification(ectx,
- ch);
+ ch);
else
allowedNetworks_ = NULL;
FREE(ch);
@@ -491,8 +491,8 @@
*/
static int
helloToAddress(const P2P_hello_MESSAGE * hello,
- void ** sa,
- unsigned int * sa_len) {
+ void ** sa,
+ unsigned int * sa_len) {
const HostAddress * haddr = (const HostAddress*) &hello[1];
struct sockaddr_in * serverAddr;
@@ -500,12 +500,12 @@
serverAddr = MALLOC(sizeof(struct sockaddr_in));
*sa = serverAddr;
memset(serverAddr,
- 0,
- sizeof(struct sockaddr_in));
+ 0,
+ sizeof(struct sockaddr_in));
serverAddr->sin_family = AF_INET;
memcpy(&serverAddr->sin_addr,
- haddr,
- sizeof(IPaddr));
+ haddr,
+ sizeof(IPaddr));
serverAddr->sin_port = haddr->port;
return OK;
}
@@ -531,34 +531,34 @@
GE_ASSERT(ectx, sizeof(UDPMessage) == 68);
coreAPI = core;
if (-1 == GC_get_configuration_value_number(cfg,
- "UDP",
- "MTU",
- sizeof(UDPMessage)
- + P2P_MESSAGE_OVERHEAD
- + sizeof(MESSAGE_HEADER) + 32,
- 65500,
- MESSAGE_SIZE,
- &mtu)) {
+ "UDP",
+ "MTU",
+ sizeof(UDPMessage)
+ + P2P_MESSAGE_OVERHEAD
+ + sizeof(MESSAGE_HEADER) + 32,
+ 65500,
+ MESSAGE_SIZE,
+ &mtu)) {
return NULL;
}
if (mtu < 1200)
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("MTU %llu for `%s' is probably too low!\n"),
- mtu,
- "UDP");
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("MTU %llu for `%s' is probably too low!\n"),
+ mtu,
+ "UDP");
if (GC_get_configuration_value_yesno(cfg,
- "UDP",
- "UPNP",
- YES) == YES) {
+ "UDP",
+ "UPNP",
+ YES) == YES) {
upnp = coreAPI->requestService("upnp");
if (upnp == NULL)
- GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- "The UPnP service could not be loaded. To disable UPnP,
set the " \
- "configuration option \"UPNP\" in section \"UDP\" to
\"NO\"\n");
- }
+ GE_LOG(ectx,
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ "The UPnP service could not be loaded. To disable UPnP, set the
" \
+ "configuration option \"UPNP\" in section \"UDP\" to
\"NO\"\n");
+ }
stats = coreAPI->requestService("stats");
if (stats != NULL) {
stat_bytesReceived
Modified: GNUnet/src/transports/udp6.c
===================================================================
--- GNUnet/src/transports/udp6.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/udp6.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -76,16 +76,16 @@
* @return the port in host byte order
*/
static unsigned short getGNUnetUDP6Port() {
- struct servent * pse; /* pointer to service information entry */
+ struct servent * pse; /* pointer to service information entry */
unsigned long long port;
if (-1 == GC_get_configuration_value_number(cfg,
- "UDP6",
- "PORT",
- 1,
- 65535,
- 2086,
- &port)) {
+ "UDP6",
+ "PORT",
+ 1,
+ 65535,
+ 2086,
+ &port)) {
if ((pse = getservbyname("gnunet", "udp")))
port = htons(pse->s_port);
else
@@ -103,34 +103,34 @@
const int on = 1;
sock = SOCKET(PF_INET6,
- SOCK_DGRAM,
- 17);
+ SOCK_DGRAM,
+ 17);
if (sock < 0)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "socket");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "socket");
if ( SETSOCKOPT(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0 )
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "setsockopt");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "setsockopt");
if (port != 0) {
memset(&sin, 0, sizeof(sin));
sin.sin6_family = AF_INET6;
sin.sin6_port = htons(port);
memcpy(&sin.sin6_addr,
- &in6addr_any,
- sizeof(IP6addr));
+ &in6addr_any,
+ sizeof(IP6addr));
if (BIND(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
GE_LOG_STRERROR(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- "bind");
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ "bind");
GE_LOG(ectx,
- GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
- _("Failed to bind to UDP port %d.\n"),
- port);
+ GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
+ _("Failed to bind to UDP port %d.\n"),
+ port);
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "bind");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "bind");
}
} /* do not bind if port == 0, then we use send-only! */
return sock;
@@ -140,24 +140,24 @@
* Check if we are explicitly forbidden to communicate with this IP.
*/
static int isBlacklisted(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
IP6addr ip;
int ret;
if (addr_len == sizeof(IP6addr)) {
memcpy(&ip,
- addr,
- sizeof(IP6addr));
+ addr,
+ sizeof(IP6addr));
} else if (addr_len == sizeof(struct sockaddr_in6)) {
memcpy(&ip,
- &((struct sockaddr_in6*) addr)->sin6_addr,
- sizeof(IP6addr));
+ &((struct sockaddr_in6*) addr)->sin6_addr,
+ sizeof(IP6addr));
} else {
return SYSERR;
}
MUTEX_LOCK(configLock);
ret = check_ipv6_listed(filteredNetworks_,
- ip);
+ ip);
MUTEX_UNLOCK(configLock);
return ret;
}
@@ -166,18 +166,18 @@
* Check if we are allowed to connect to the given IP.
*/
static int isWhitelisted(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
IP6addr ip;
int ret;
if (addr_len == sizeof(IP6addr)) {
memcpy(&ip,
- addr,
- sizeof(IP6addr));
+ addr,
+ sizeof(IP6addr));
} else if (addr_len == sizeof(struct sockaddr_in6)) {
memcpy(&ip,
- &((struct sockaddr_in6*) addr)->sin6_addr,
- sizeof(IP6addr));
+ &((struct sockaddr_in6*) addr)->sin6_addr,
+ sizeof(IP6addr));
} else {
return SYSERR;
}
@@ -185,18 +185,18 @@
MUTEX_LOCK(configLock);
if (allowedNetworks_ != NULL)
ret = check_ipv6_listed(filteredNetworks_,
- ip);
+ ip);
MUTEX_UNLOCK(configLock);
return ret;
}
static int isRejected(const void * addr,
- unsigned int addr_len) {
+ unsigned int addr_len) {
if ((YES == isBlacklisted(addr,
- addr_len)) ||
+ addr_len)) ||
(YES != isWhitelisted(addr,
- addr_len)))
+ addr_len)))
return YES;
return NO;
}
@@ -221,20 +221,20 @@
(ntohs(hello->header.size) != P2P_hello_MESSAGE_size(hello)) ||
(ntohs(hello->header.type) != p2p_PROTO_hello) ||
(YES == isBlacklisted(&haddr->ip,
- sizeof(IP6addr))) ||
+ sizeof(IP6addr))) ||
(YES != isWhitelisted(&haddr->ip,
- sizeof(IP6addr))) )
+ sizeof(IP6addr))) )
return SYSERR; /* obviously invalid */
else {
#if DEBUG_UDP6
char inet6[INET6_ADDRSTRLEN];
GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Verified UDP6 hello from %u.%u.%u.%u:%u.\n",
- inet_ntop(AF_INET6,
- &haddr->ip,
- inet6,
- INET6_ADDRSTRLEN),
- ntohs(haddr->port));
+ "Verified UDP6 hello from %u.%u.%u.%u:%u.\n",
+ inet_ntop(AF_INET6,
+ &haddr->ip,
+ inet6,
+ INET6_ADDRSTRLEN),
+ ntohs(haddr->port));
#endif
return OK;
}
@@ -260,12 +260,12 @@
haddr = (Host6Address*) &msg[1];
if (SYSERR == getPublicIP6Address(cfg,
- ectx,
- &haddr->ip)) {
+ ectx,
+ &haddr->ip)) {
FREE(msg);
GE_LOG(ectx,
- GE_WARNING,
- _("UDP6: Could not determine my public IPv6 address.\n"));
+ GE_WARNING,
+ _("UDP6: Could not determine my public IPv6 address.\n"));
return NULL;
}
haddr->port = htons(port);
@@ -285,9 +285,9 @@
* @return SYSERR on error, OK on success
*/
static int udp6Send(TSession * tsession,
- const void * message,
- const unsigned int size,
- int importance) {
+ const void * message,
+ const unsigned int size,
+ int importance) {
UDPMessage * mp;
P2P_hello_MESSAGE * hello;
Host6Address * haddr;
@@ -319,44 +319,44 @@
mp->header.type = 0;
mp->sender = *coreAPI->myIdentity;
memcpy(&mp[1],
- message,
- size);
+ message,
+ size);
ok = SYSERR;
memset(&sin, 0, sizeof(sin));
sin.sin6_family = AF_INET6;
sin.sin6_port = haddr->port;
memcpy(&sin.sin6_addr,
- &haddr->ip.addr,
- sizeof(IP6addr));
+ &haddr->ip.addr,
+ sizeof(IP6addr));
#if DEBUG_UDP6
GE_LOG(ectx,
- GE_DEBUG,
- "Sending message of %u bytes via UDP6 to %s:%d..\n",
- ssize,
- inet_ntop(AF_INET6,
- &sin,
- inet6,
- INET6_ADDRSTRLEN),
- ntohs(sin.sin_port));
+ GE_DEBUG,
+ "Sending message of %u bytes via UDP6 to %s:%d..\n",
+ ssize,
+ inet_ntop(AF_INET6,
+ &sin,
+ inet6,
+ INET6_ADDRSTRLEN),
+ ntohs(sin.sin_port));
#endif
if (YES == socket_send_to(udp_sock,
- NC_Nonblocking,
- mp,
- ssize,
- &ssize,
- (const char*) &sin,
- sizeof(sin))) {
+ NC_Nonblocking,
+ mp,
+ ssize,
+ &ssize,
+ (const char*) &sin,
+ sizeof(sin))) {
ok = OK;
if (stats != NULL)
stats->change(stat_bytesSent,
- ssize);
+ ssize);
} else {
GE_LOG_STRERROR(ectx,
- GE_WARNING,
- "sendto");
+ GE_WARNING,
+ "sendto");
if (stats != NULL)
stats->change(stat_bytesDropped,
- ssize);
+ ssize);
}
FREE(mp);
return ok;
@@ -378,35 +378,35 @@
if (sock == -1)
return SYSERR;
selector = select_create("udp6",
- YES,
- ectx,
- load_monitor,
- sock,
- sizeof(struct sockaddr_in6),
- 0, /* timeout */
- &select_message_handler,
- NULL,
- &select_accept_handler,
- &isRejected,
- &select_close_handler,
- NULL,
- 64 * 1024,
- 16 /* max sockets */);
+ YES,
+ ectx,
+ load_monitor,
+ sock,
+ sizeof(struct sockaddr_in6),
+ 0, /* timeout */
+ &select_message_handler,
+ NULL,
+ &select_accept_handler,
+ &isRejected,
+ &select_close_handler,
+ NULL,
+ 64 * 1024,
+ 16 /* max sockets */);
if (selector == NULL)
return SYSERR;
}
sock = SOCKET(PF_INET, SOCK_DGRAM, 17);
if (sock == -1) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "socket");
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "socket");
select_destroy(selector);
selector = NULL;
return SYSERR;
}
udp_sock = socket_create(ectx,
- load_monitor,
- sock);
+ load_monitor,
+ sock);
return OK;
}
@@ -419,21 +419,21 @@
MUTEX_LOCK(configLock);
FREENONNULL(filteredNetworks_);
GC_get_configuration_value_string(cfg,
- "UDP6",
- "BLACKLIST",
- "",
- &ch);
+ "UDP6",
+ "BLACKLIST",
+ "",
+ &ch);
filteredNetworks_ = parse_ipv6_network_specification(ectx,
- ch);
+ ch);
FREE(ch);
GC_get_configuration_value_string(cfg,
- "UDP6",
- "WHITELIST",
- "",
- &ch);
+ "UDP6",
+ "WHITELIST",
+ "",
+ &ch);
if (strlen(ch) > 0)
allowedNetworks_ = parse_ipv6_network_specification(ectx,
- ch);
+ ch);
else
allowedNetworks_ = NULL;
FREE(ch);
@@ -446,8 +446,8 @@
*/
static int
helloToAddress(const P2P_hello_MESSAGE * hello,
- void ** sa,
- unsigned int * sa_len) {
+ void ** sa,
+ unsigned int * sa_len) {
const Host6Address * haddr = (const Host6Address*) &hello[1];
struct sockaddr_in6 * serverAddr;
@@ -455,12 +455,12 @@
serverAddr = MALLOC(sizeof(struct sockaddr_in6));
*sa = serverAddr;
memset(serverAddr,
- 0,
- sizeof(struct sockaddr_in6));
+ 0,
+ sizeof(struct sockaddr_in6));
serverAddr->sin6_family = AF_INET6;
memcpy(&serverAddr->sin6_addr,
- haddr,
- sizeof(IP6addr));
+ haddr,
+ sizeof(IP6addr));
serverAddr->sin6_port = haddr->port;
return OK;
}
@@ -486,20 +486,20 @@
reloadConfiguration();
if (-1 == GC_get_configuration_value_number(cfg,
- "UDP6",
- "MTU",
- sizeof(UDPMessage) +
P2P_MESSAGE_OVERHEAD + sizeof(MESSAGE_HEADER) + 32,
- 65500,
- MESSAGE_SIZE,
- &mtu)) {
+ "UDP6",
+ "MTU",
+ sizeof(UDPMessage) + P2P_MESSAGE_OVERHEAD
+ sizeof(MESSAGE_HEADER) + 32,
+ 65500,
+ MESSAGE_SIZE,
+ &mtu)) {
return NULL;
}
if (mtu < 1200)
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("MTU %llu for `%s' is probably too low!\n"),
- mtu,
- "UDP6");
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("MTU %llu for `%s' is probably too low!\n"),
+ mtu,
+ "UDP6");
udpAPI.protocolNumber = UDP6_PROTOCOL_NUMBER;
udpAPI.mtu = mtu - sizeof(UDPMessage);
Modified: GNUnet/src/transports/udp_helper.c
===================================================================
--- GNUnet/src/transports/udp_helper.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/udp_helper.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -25,7 +25,7 @@
*/
typedef int (*BlacklistedTester)(const void * addr,
- unsigned int addr_len);
+ unsigned int addr_len);
/**
* Message-Packet header.
@@ -76,10 +76,10 @@
* already held by the caller.
*/
static int select_message_handler(void * mh_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * sock_ctx,
- const MESSAGE_HEADER * msg) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ void * sock_ctx,
+ const MESSAGE_HEADER * msg) {
unsigned int len;
P2P_PACKET * mp;
const UDPMessage * um;
@@ -87,41 +87,41 @@
len = ntohs(msg->size);
if (len <= sizeof(UDPMessage)) {
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Received malformed message from udp-peer connection.
Closing.\n"));
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Received malformed message from udp-peer connection. Closing.\n"));
return SYSERR;
}
#if DEBUG_UDP
GE_LOG(ectx,
- GE_DEBUG | GE_USER | GE_BULK,
- "Received %d bytes via UDP\n",
- len);
+ GE_DEBUG | GE_USER | GE_BULK,
+ "Received %d bytes via UDP\n",
+ len);
#endif
um = (const UDPMessage*) msg;
mp = MALLOC(sizeof(P2P_PACKET));
mp->msg = MALLOC(len - sizeof(UDPMessage));
memcpy(mp->msg,
- &um[1],
- len - sizeof(UDPMessage));
+ &um[1],
+ len - sizeof(UDPMessage));
mp->sender = um->sender;
mp->size = len - sizeof(UDPMessage);
mp->tsession = NULL;
coreAPI->receive(mp);
if (stats != NULL)
stats->change(stat_bytesReceived,
- len);
+ len);
return OK;
}
static void * select_accept_handler(void * ah_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- const void * addr,
- unsigned int addr_len) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ const void * addr,
+ unsigned int addr_len) {
static int nonnullpointer;
BlacklistedTester blt = ah_cls;
if (NO != blt(addr,
- addr_len))
+ addr_len))
return NULL;
return &nonnullpointer;
}
@@ -131,9 +131,9 @@
* Free the associated context.
*/
static void select_close_handler(void * ch_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * sock_ctx) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ void * sock_ctx) {
/* do nothing */
}
@@ -145,14 +145,14 @@
* @return OK on success, SYSERR if the operation failed
*/
static int udpConnect(const P2P_hello_MESSAGE * hello,
- TSession ** tsessionPtr) {
+ TSession ** tsessionPtr) {
TSession * tsession;
tsession = MALLOC(sizeof(TSession));
tsession->internal = MALLOC(P2P_hello_MESSAGE_size(hello));
memcpy(tsession->internal,
- hello,
- P2P_hello_MESSAGE_size(hello));
+ hello,
+ P2P_hello_MESSAGE_size(hello));
tsession->ttype = udpAPI.protocolNumber;
tsession->peer = hello->senderIdentity;
*tsessionPtr = tsession;
@@ -218,8 +218,8 @@
* SYSERR if the size/session is invalid
*/
static int testWouldTry(TSession * tsession,
- unsigned int size,
- int important) {
+ unsigned int size,
+ int important) {
const P2P_hello_MESSAGE * hello;
if (udp_sock == NULL)
Modified: GNUnet/src/transports/upnp/error.c
===================================================================
--- GNUnet/src/transports/upnp/error.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/upnp/error.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -5,25 +5,25 @@
* Map gaim logger to GNUnet logger.
*/
void gaim_debug_error(char * facility,
- char * format,
- ...) {
+ char * format,
+ ...) {
GE_LOG(NULL,
- GE_WARNING | GE_DEVELOPER | GE_ADMIN | GE_BULK,
- "%s: %s\n",
- facility,
- format);
+ GE_WARNING | GE_DEVELOPER | GE_ADMIN | GE_BULK,
+ "%s: %s\n",
+ facility,
+ format);
}
/**
* Map gaim logger to GNUnet logger.
*/
void gaim_debug_info(char * facility,
- char * format,
- ...) {
+ char * format,
+ ...) {
GE_LOG(NULL,
- GE_INFO | GE_ADMIN | GE_BULK,
- "%s: %s\n",
- facility,
- format);
+ GE_INFO | GE_ADMIN | GE_BULK,
+ "%s: %s\n",
+ facility,
+ format);
}
Modified: GNUnet/src/transports/upnp/init.c
===================================================================
--- GNUnet/src/transports/upnp/init.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/upnp/init.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -64,8 +64,8 @@
if (ip == NULL)
return SYSERR;
return get_host_by_name(ectx,
- ip,
- address);
+ ip,
+ address);
}
static void kill_discovery() {
@@ -93,8 +93,8 @@
if (discovery_socket == -1)
return;
discovery = PTHREAD_CREATE(&discover_thread,
- NULL,
- 1024 * 128);
+ NULL,
+ 1024 * 128);
}
/**
@@ -106,10 +106,10 @@
MUTEX_LOCK(lock);
for (i=0;i<maps_size;i++)
gaim_upnp_change_port_mapping(ectx,
- cfg,
- NO,
- maps[i].port,
- maps[i].proto);
+ cfg,
+ NO,
+ maps[i].port,
+ maps[i].proto);
MUTEX_UNLOCK(lock);
}
@@ -120,27 +120,27 @@
* @return SYSERR on error, OK on success
*/
static int gnunet_upnp_get_ip(unsigned short port,
- const char * protocol,
- IPaddr * address) {
+ const char * protocol,
+ IPaddr * address) {
unsigned int i;
MUTEX_LOCK(lock);
for (i=0;i<maps_size;i++)
if ( (0 == strcmp(maps[i].proto, protocol)) &&
- (maps[i].port == port) )
+ (maps[i].port == port) )
break;
if (i == maps_size) {
/* new entry! */
GROW(maps,
- maps_size,
- maps_size + 1);
+ maps_size,
+ maps_size + 1);
maps[i].proto = protocol;
maps[i].port = port;
gaim_upnp_change_port_mapping(ectx,
- cfg,
- YES,
- port,
- protocol);
+ cfg,
+ YES,
+ port,
+ protocol);
}
MUTEX_UNLOCK(lock);
return gnunet_upnp_get_public_ip(address);
@@ -160,15 +160,15 @@
lock = MUTEX_CREATE(NO);
cron_start(cron);
cron_add_job(cron,
- &discover,
- 0,
- 5 * cronMINUTES,
- NULL);
+ &discover,
+ 0,
+ 5 * cronMINUTES,
+ NULL);
cron_add_job(cron,
- &portmap,
- 150 * cronSECONDS,
- 5 * cronMINUTES,
- NULL);
+ &portmap,
+ 150 * cronSECONDS,
+ 5 * cronMINUTES,
+ NULL);
api.get_ip = gnunet_upnp_get_ip;
return &api;
}
@@ -183,19 +183,19 @@
return SYSERR; /* not loaded! */
for (i=0;i<maps_size;i++)
gaim_upnp_change_port_mapping(ectx,
- cfg,
- NO,
- maps[i].port,
- maps[i].proto);
+ cfg,
+ NO,
+ maps[i].port,
+ maps[i].proto);
cron_stop(cron);
cron_del_job(cron,
- &discover,
- 5 * cronMINUTES,
- NULL);
+ &discover,
+ 5 * cronMINUTES,
+ NULL);
cron_del_job(cron,
- &portmap,
- 5 * cronMINUTES,
- NULL);
+ &portmap,
+ 5 * cronMINUTES,
+ NULL);
cron_destroy(cron);
kill_discovery();
cron = NULL;
Modified: GNUnet/src/transports/upnp/ip.c
===================================================================
--- GNUnet/src/transports/upnp/ip.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/upnp/ip.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -35,12 +35,12 @@
* @return NULL on error
*/
char * gaim_upnp_get_internal_ip(struct GC_Configuration * cfg,
- struct GE_Context * ectx) {
+ struct GE_Context * ectx) {
IPaddr address;
return network_get_local_ip(cfg,
- ectx,
- &address);
+ ectx,
+ &address);
}
Modified: GNUnet/src/transports/upnp/upnp.c
===================================================================
--- GNUnet/src/transports/upnp/upnp.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/upnp/upnp.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -43,46 +43,46 @@
#define HTTPMU_HOST_PORT 1900
#define SEARCH_REQUEST_DEVICE "urn:schemas-upnp-org:service:%s"
#define SEARCH_REQUEST_STRING \
- "M-SEARCH * HTTP/1.1\r\n" \
- "MX: 2\r\n" \
- "HOST: 239.255.255.250:1900\r\n" \
- "MAN: \"ssdp:discover\"\r\n" \
- "ST: urn:schemas-upnp-org:service:%s\r\n" \
- "\r\n"
+ "M-SEARCH * HTTP/1.1\r\n" \
+ "MX: 2\r\n" \
+ "HOST: 239.255.255.250:1900\r\n" \
+ "MAN: \"ssdp:discover\"\r\n" \
+ "ST: urn:schemas-upnp-org:service:%s\r\n" \
+ "\r\n"
#define WAN_IP_CONN_SERVICE "WANIPConnection:1"
#define WAN_PPP_CONN_SERVICE "WANPPPConnection:1"
#define HTTP_POST_SOAP_HEADER \
"SOAPACTION: \"urn:schemas-upnp-org:service:%s#%s\""
#define HTTP_POST_SIZE_HEADER "CONTENT-LENGTH: %u"
#define SOAP_ACTION \
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" \
- "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" " \
-
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" \
- "<s:Body>\r\n" \
- "<u:%s xmlns:u=\"urn:schemas-upnp-org:service:%s\">\r\n" \
- "%s" \
- "</u:%s>\r\n" \
- "</s:Body>\r\n" \
- "</s:Envelope>"
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" \
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" " \
+ "s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" \
+ "<s:Body>\r\n" \
+ "<u:%s xmlns:u=\"urn:schemas-upnp-org:service:%s\">\r\n" \
+ "%s" \
+ "</u:%s>\r\n" \
+ "</s:Body>\r\n" \
+ "</s:Envelope>"
#define PORT_MAPPING_LEASE_TIME "0"
#define PORT_MAPPING_DESCRIPTION "GNUNET_UPNP_PORT_FORWARD"
#define ADD_PORT_MAPPING_PARAMS \
- "<NewRemoteHost></NewRemoteHost>\r\n" \
- "<NewExternalPort>%i</NewExternalPort>\r\n" \
- "<NewProtocol>%s</NewProtocol>\r\n" \
- "<NewInternalPort>%i</NewInternalPort>\r\n" \
- "<NewInternalClient>%s</NewInternalClient>\r\n" \
- "<NewEnabled>1</NewEnabled>\r\n" \
- "<NewPortMappingDescription>" \
- PORT_MAPPING_DESCRIPTION \
- "</NewPortMappingDescription>\r\n" \
- "<NewLeaseDuration>" \
- PORT_MAPPING_LEASE_TIME \
- "</NewLeaseDuration>\r\n"
+ "<NewRemoteHost></NewRemoteHost>\r\n" \
+ "<NewExternalPort>%i</NewExternalPort>\r\n" \
+ "<NewProtocol>%s</NewProtocol>\r\n" \
+ "<NewInternalPort>%i</NewInternalPort>\r\n" \
+ "<NewInternalClient>%s</NewInternalClient>\r\n" \
+ "<NewEnabled>1</NewEnabled>\r\n" \
+ "<NewPortMappingDescription>" \
+ PORT_MAPPING_DESCRIPTION \
+ "</NewPortMappingDescription>\r\n" \
+ "<NewLeaseDuration>" \
+ PORT_MAPPING_LEASE_TIME \
+ "</NewLeaseDuration>\r\n"
#define DELETE_PORT_MAPPING_PARAMS \
- "<NewRemoteHost></NewRemoteHost>\r\n" \
- "<NewExternalPort>%i</NewExternalPort>\r\n" \
- "<NewProtocol>%s</NewProtocol>\r\n"
+ "<NewRemoteHost></NewRemoteHost>\r\n" \
+ "<NewExternalPort>%i</NewExternalPort>\r\n" \
+ "<NewProtocol>%s</NewProtocol>\r\n"
typedef enum {
GAIM_UPNP_STATUS_UNDISCOVERED = -1,
@@ -118,15 +118,15 @@
* to CURL.
*/
typedef size_t (*GaimUtilFetchUrlCallback)(void *url_data,
- size_t size,
- size_t nmemb,
- void * user_data);
+ size_t size,
+ size_t nmemb,
+ void * user_data);
static char * g_strstr_len (const char *haystack,
- int haystack_len,
- const char *needle) {
+ int haystack_len,
+ const char *needle) {
int i;
g_return_val_if_fail (haystack != NULL, NULL);
@@ -161,13 +161,13 @@
static int
gaim_upnp_compare_device(const xmlnode* device,
- const char* deviceType) {
+ const char* deviceType) {
xmlnode * deviceTypeNode = xmlnode_get_child(device, "deviceType");
char * tmp;
int ret;
if (deviceTypeNode == NULL)
- return FALSE;
+ return FALSE;
tmp = xmlnode_get_data(deviceTypeNode);
ret = !strcasecmp(tmp, deviceType);
FREE(tmp);
@@ -176,13 +176,13 @@
static int
gaim_upnp_compare_service(const xmlnode* service,
- const char* serviceType) {
+ const char* serviceType) {
xmlnode * serviceTypeNode;
char *tmp;
int ret;
if (service == NULL)
- return FALSE;
+ return FALSE;
serviceTypeNode = xmlnode_get_child(service, "serviceType");
if(serviceTypeNode == NULL)
return FALSE;
@@ -194,9 +194,9 @@
static char*
gaim_upnp_parse_description_response(const char* httpResponse,
- size_t len,
- const char* httpURL,
- const char* serviceType) {
+ size_t len,
+ const char* httpURL,
+ const char* serviceType) {
char *xmlRoot, *baseURL, *controlURL, *service;
xmlnode *xmlRootNode, *serviceTypeNode, *controlURLNode, *baseURLNode;
char *tmp;
@@ -210,7 +210,7 @@
/* create the xml root node */
xmlRootNode = xmlnode_from_str(xmlRoot,
- len - (xmlRoot - httpResponse));
+ len - (xmlRoot - httpResponse));
if (xmlRootNode == NULL)
return NULL;
@@ -226,8 +226,8 @@
/* get urn:schemas-upnp-org:device:InternetGatewayDevice:1 and its
devicelist */
serviceTypeNode = xmlnode_get_child(xmlRootNode, "device");
while(!gaim_upnp_compare_device(serviceTypeNode,
-
"urn:schemas-upnp-org:device:InternetGatewayDevice:1") &&
- serviceTypeNode != NULL) {
+
"urn:schemas-upnp-org:device:InternetGatewayDevice:1") &&
+ serviceTypeNode != NULL) {
serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode);
}
if(serviceTypeNode == NULL) {
@@ -245,8 +245,8 @@
/* get urn:schemas-upnp-org:device:WANDevice:1 and its devicelist */
serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device");
while(!gaim_upnp_compare_device(serviceTypeNode,
- "urn:schemas-upnp-org:device:WANDevice:1") &&
- serviceTypeNode != NULL) {
+ "urn:schemas-upnp-org:device:WANDevice:1") &&
+ serviceTypeNode != NULL) {
serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode);
}
if(serviceTypeNode == NULL) {
@@ -264,7 +264,7 @@
/* get urn:schemas-upnp-org:device:WANConnectionDevice:1 and its servicelist
*/
serviceTypeNode = xmlnode_get_child(serviceTypeNode, "device");
while(serviceTypeNode && !gaim_upnp_compare_device(serviceTypeNode,
-
"urn:schemas-upnp-org:device:WANConnectionDevice:1")) {
+
"urn:schemas-upnp-org:device:WANConnectionDevice:1")) {
serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode);
}
if(serviceTypeNode == NULL) {
@@ -283,7 +283,7 @@
service = g_strdup_printf(SEARCH_REQUEST_DEVICE, serviceType);
serviceTypeNode = xmlnode_get_child(serviceTypeNode, "service");
while(!gaim_upnp_compare_service(serviceTypeNode, service) &&
- serviceTypeNode != NULL) {
+ serviceTypeNode != NULL) {
serviceTypeNode = xmlnode_get_next_twin(serviceTypeNode);
}
@@ -296,7 +296,7 @@
/* get the controlURL of the service */
if ((controlURLNode = xmlnode_get_child(serviceTypeNode,
- "controlURL")) == NULL) {
+ "controlURL")) == NULL) {
FREE(baseURL);
xmlnode_free(xmlRootNode);
return NULL;
@@ -310,15 +310,15 @@
const char * end;
/* absolute path */
end = strstr(&baseURL[strlen("http://")],
- "/");
+ "/");
if (end == NULL)
- len = strlen(&baseURL[strlen("http://")]);
+ len = strlen(&baseURL[strlen("http://")]);
else
- len = end - &baseURL[strlen("http://")];
+ len = end - &baseURL[strlen("http://")];
controlURL = g_strdup_printf("http://%.*s%s",
- len,
- &baseURL[strlen("http://")],
- tmp);
+ len,
+ &baseURL[strlen("http://")],
+ tmp);
} else {
controlURL = g_strdup_printf("%s%s", baseURL, tmp);
}
@@ -338,38 +338,38 @@
* Do the generic curl setup.
*/
static int setup_curl(const char * proxy,
- CURL * curl) {
+ CURL * curl) {
int ret;
CURL_EASY_SETOPT(curl,
- CURLOPT_FAILONERROR,
- 1);
+ CURLOPT_FAILONERROR,
+ 1);
if (strlen(proxy) > 0)
CURL_EASY_SETOPT(curl,
- CURLOPT_PROXY,
- proxy);
+ CURLOPT_PROXY,
+ proxy);
CURL_EASY_SETOPT(curl,
- CURLOPT_BUFFERSIZE,
- 1024); /* a bit more than one HELLO */
+ CURLOPT_BUFFERSIZE,
+ 1024); /* a bit more than one HELLO */
CURL_EASY_SETOPT(curl,
- CURLOPT_CONNECTTIMEOUT,
- 150L);
+ CURLOPT_CONNECTTIMEOUT,
+ 150L);
/* NOTE: use of CONNECTTIMEOUT without also
setting NOSIGNAL results in really weird
crashes on my system! */
CURL_EASY_SETOPT(curl,
- CURLOPT_NOSIGNAL,
- 1);
+ CURLOPT_NOSIGNAL,
+ 1);
return OK;
}
static int
gaim_upnp_generate_action_message_and_send(const char * proxy,
- const char* actionName,
- const char* actionParams,
- GaimUtilFetchUrlCallback cb,
- void * cb_data) {
- CURL * curl;
+ const char* actionName,
+ const char* actionParams,
+ GaimUtilFetchUrlCallback cb,
+ void * cb_data) {
+ CURL * curl;
int ret;
char * soapHeader;
char * sizeHeader;
@@ -381,72 +381,72 @@
return SYSERR;
/* set the soap message */
soapMessage = g_strdup_printf(SOAP_ACTION,
- actionName,
- control_info.service_type,
- actionParams,
- actionName);
+ actionName,
+ control_info.service_type,
+ actionParams,
+ actionName);
soapHeader = g_strdup_printf(HTTP_POST_SOAP_HEADER,
- control_info.service_type,
- actionName);
+ control_info.service_type,
+ actionName);
sizeHeader = g_strdup_printf(HTTP_POST_SIZE_HEADER,
- strlen(soapMessage));
+ strlen(soapMessage));
curl = curl_easy_init();
setup_curl(proxy, curl);
CURL_EASY_SETOPT(curl,
- CURLOPT_URL,
- control_info.control_url);
+ CURLOPT_URL,
+ control_info.control_url);
CURL_EASY_SETOPT(curl,
- CURLOPT_WRITEFUNCTION,
- cb);
+ CURLOPT_WRITEFUNCTION,
+ cb);
CURL_EASY_SETOPT(curl,
- CURLOPT_WRITEDATA,
- cb_data);
+ CURLOPT_WRITEDATA,
+ cb_data);
CURL_EASY_SETOPT(curl,
- CURLOPT_POST,
- 1);
+ CURLOPT_POST,
+ 1);
headers = curl_slist_append(headers,
- "CONTENT-TYPE: text/xml ; charset=\"utf-8\"");
+ "CONTENT-TYPE: text/xml ; charset=\"utf-8\"");
headers = curl_slist_append(headers,
- soapHeader);
+ soapHeader);
headers = curl_slist_append(headers,
- sizeHeader);
+ sizeHeader);
CURL_EASY_SETOPT(curl,
- CURLOPT_HTTPHEADER,
- headers);
+ CURLOPT_HTTPHEADER,
+ headers);
CURL_EASY_SETOPT(curl,
- CURLOPT_POSTFIELDS,
- soapMessage);
+ CURLOPT_POSTFIELDS,
+ soapMessage);
CURL_EASY_SETOPT(curl,
- CURLOPT_POSTFIELDSIZE,
- strlen(soapMessage));
+ CURLOPT_POSTFIELDSIZE,
+ strlen(soapMessage));
CURL_EASY_SETOPT(curl,
- CURLOPT_MAXREDIRS,
- 1L);
+ CURLOPT_MAXREDIRS,
+ 1L);
CURL_EASY_SETOPT(curl,
- CURLOPT_CONNECTTIMEOUT,
- 1L);
+ CURLOPT_CONNECTTIMEOUT,
+ 1L);
CURL_EASY_SETOPT(curl,
- CURLOPT_TIMEOUT,
- 2L);
+ CURLOPT_TIMEOUT,
+ 2L);
/* NOTE: use of CONNECTTIMEOUT without also
setting NOSIGNAL results in really weird
crashes on my system! */
CURL_EASY_SETOPT(curl,
- CURLOPT_NOSIGNAL,
- 1);
+ CURLOPT_NOSIGNAL,
+ 1);
if (ret == CURLE_OK)
ret = curl_easy_perform(curl);
#if 0
if (ret != CURLE_OK)
GE_LOG(NULL,
- GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
- _("%s failed for url `%s' and post-data `%s' at %s:%d: `%s'\n"),
- "curl_easy_perform",
- control_info.control_url,
- soapMessage,
- __FILE__,
- __LINE__,
- curl_easy_strerror(ret));
+ GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
+ _("%s failed for url `%s' and post-data `%s' at %s:%d: `%s'\n"),
+ "curl_easy_perform",
+ control_info.control_url,
+ soapMessage,
+ __FILE__,
+ __LINE__,
+ curl_easy_strerror(ret));
#endif
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
@@ -462,9 +462,9 @@
static size_t
looked_up_public_ip_cb(void *url_data,
- size_t size,
- size_t nmemb,
- void * user_data) {
+ size_t size,
+ size_t nmemb,
+ void * user_data) {
UPnPDiscoveryData * dd = user_data;
size_t len = size * nmemb;
const char * temp;
@@ -476,42 +476,42 @@
dd->buf_len,
dd->buf_len + len);
memcpy(&dd->buf[dd->buf_len - len],
- url_data,
- len);
+ url_data,
+ len);
if (dd->buf_len == 0)
return len;
/* extract the ip, or see if there is an error */
if ((temp = g_strstr_len(dd->buf,
- dd->buf_len,
- "<NewExternalIPAddress")) == NULL)
+ dd->buf_len,
+ "<NewExternalIPAddress")) == NULL)
return len;
if (!(temp = g_strstr_len(temp,
- dd->buf_len - (temp - dd->buf), ">")))
+ dd->buf_len - (temp - dd->buf), ">")))
return len;
if (!(temp2 = g_strstr_len(temp,
- dd->buf_len - (temp - dd->buf), "<")))
+ dd->buf_len - (temp - dd->buf), "<")))
return len;
memset(control_info.publicip,
- 0,
- sizeof(control_info.publicip));
+ 0,
+ sizeof(control_info.publicip));
if (temp2 - temp >= sizeof(control_info.publicip))
temp2 = temp + sizeof(control_info.publicip) - 1;
memcpy(control_info.publicip,
- temp + 1,
- temp2 - (temp + 1));
+ temp + 1,
+ temp2 - (temp + 1));
GE_LOG(NULL,
- GE_INFO | GE_USER | GE_BULK,
- _("upnp: NAT Returned IP: %s\n"),
- control_info.publicip);
+ GE_INFO | GE_USER | GE_BULK,
+ _("upnp: NAT Returned IP: %s\n"),
+ control_info.publicip);
return len;
}
static size_t
ignore_response(void *url_data,
- size_t size,
- size_t nmemb,
- void * user_data) {
+ size_t size,
+ size_t nmemb,
+ void * user_data) {
return size * nmemb;
}
@@ -520,9 +520,9 @@
*/
static size_t
upnp_parse_description_cb(void * httpResponse,
- size_t size,
- size_t nmemb,
- void * user_data) {
+ size_t size,
+ size_t nmemb,
+ void * user_data) {
UPnPDiscoveryData * dd = user_data;
size_t len = size * nmemb;
char * control_url = NULL;
@@ -533,13 +533,13 @@
dd->buf_len,
dd->buf_len + len);
memcpy(&dd->buf[dd->buf_len - len],
- httpResponse,
- len);
+ httpResponse,
+ len);
if (dd->buf_len > 0)
control_url = gaim_upnp_parse_description_response(dd->buf,
- dd->buf_len,
- dd->full_url,
- dd->service_type);
+ dd->buf_len,
+ dd->full_url,
+ dd->service_type);
control_info.status = control_url ? GAIM_UPNP_STATUS_DISCOVERED
: GAIM_UPNP_STATUS_UNABLE_TO_DISCOVER;
FREENONNULL(control_info.control_url);
@@ -550,8 +550,8 @@
static int
gaim_upnp_parse_description(char * proxy,
- UPnPDiscoveryData * dd) {
- CURL * curl;
+ UPnPDiscoveryData * dd) {
+ CURL * curl;
int ret;
if (0 != curl_global_init(CURL_GLOBAL_WIN32))
@@ -560,39 +560,39 @@
setup_curl(proxy, curl);
ret = CURLE_OK;
CURL_EASY_SETOPT(curl,
- CURLOPT_URL,
- dd->full_url);
+ CURLOPT_URL,
+ dd->full_url);
CURL_EASY_SETOPT(curl,
- CURLOPT_WRITEFUNCTION,
- &upnp_parse_description_cb);
+ CURLOPT_WRITEFUNCTION,
+ &upnp_parse_description_cb);
CURL_EASY_SETOPT(curl,
- CURLOPT_WRITEDATA,
- dd);
+ CURLOPT_WRITEDATA,
+ dd);
CURL_EASY_SETOPT(curl,
- CURLOPT_MAXREDIRS,
- 1L);
+ CURLOPT_MAXREDIRS,
+ 1L);
CURL_EASY_SETOPT(curl,
- CURLOPT_CONNECTTIMEOUT,
- 1L);
+ CURLOPT_CONNECTTIMEOUT,
+ 1L);
CURL_EASY_SETOPT(curl,
- CURLOPT_TIMEOUT,
- 2L);
+ CURLOPT_TIMEOUT,
+ 2L);
/* NOTE: use of CONNECTTIMEOUT without also
setting NOSIGNAL results in really weird
crashes on my system! */
CURL_EASY_SETOPT(curl,
- CURLOPT_NOSIGNAL,
- 1);
+ CURLOPT_NOSIGNAL,
+ 1);
ret = curl_easy_perform(curl);
if (ret != CURLE_OK)
GE_LOG(NULL,
- GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
- _("%s failed at %s:%d: `%s'\n"),
- "curl_easy_perform",
- __FILE__,
- __LINE__,
- curl_easy_strerror(ret));
+ GE_ERROR | GE_ADMIN | GE_DEVELOPER | GE_BULK,
+ _("%s failed at %s:%d: `%s'\n"),
+ "curl_easy_perform",
+ __FILE__,
+ __LINE__,
+ curl_easy_strerror(ret));
curl_easy_cleanup(curl);
curl_global_cleanup();
if (control_info.control_url == NULL)
@@ -602,8 +602,8 @@
int
gaim_upnp_discover(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- int sock) {
+ struct GC_Configuration * cfg,
+ int sock) {
char * proxy;
struct hostent* hp;
struct sockaddr_in server;
@@ -619,8 +619,8 @@
UPnPDiscoveryData dd;
memset(&dd,
- 0,
- sizeof(UPnPDiscoveryData));
+ 0,
+ sizeof(UPnPDiscoveryData));
if (control_info.status == GAIM_UPNP_STATUS_DISCOVERING)
return NO;
dd.sock = sock;
@@ -630,12 +630,12 @@
return SYSERR;
}
memset(&server,
- 0,
- sizeof(struct sockaddr));
+ 0,
+ sizeof(struct sockaddr));
server.sin_family = AF_INET;
memcpy(&server.sin_addr,
- hp->h_addr_list[0],
- hp->h_length);
+ hp->h_addr_list[0],
+ hp->h_length);
server.sin_port = htons(HTTPMU_HOST_PORT);
control_info.status = GAIM_UPNP_STATUS_DISCOVERING;
@@ -649,20 +649,20 @@
else
dd.service_type = WAN_PPP_CONN_SERVICE;
sendMessage = g_strdup_printf(SEARCH_REQUEST_STRING,
- dd.service_type);
+ dd.service_type);
totalSize = strlen(sendMessage);
do {
if (SENDTO(dd.sock,
- sendMessage,
- totalSize,
- 0,
- (struct sockaddr*) &server,
- sizeof(struct sockaddr_in)) == totalSize) {
- sentSuccess = TRUE;
- break;
+ sendMessage,
+ totalSize,
+ 0,
+ (struct sockaddr*) &server,
+ sizeof(struct sockaddr_in)) == totalSize) {
+ sentSuccess = TRUE;
+ break;
}
} while ( ((errno == EINTR) || (errno == EAGAIN)) &&
- (GNUNET_SHUTDOWN_TEST() == NO));
+ (GNUNET_SHUTDOWN_TEST() == NO));
FREE(sendMessage);
if (sentSuccess)
break;
@@ -673,9 +673,9 @@
/* try to read response */
do {
buf_len = recv(dd.sock,
- buf,
- sizeof(buf) - 1,
- 0);
+ buf,
+ sizeof(buf) - 1,
+ 0);
if (buf_len > 0) {
buf[buf_len] = '\0';
break;
@@ -683,7 +683,7 @@
continue;
}
} while ( (errno == EINTR) &&
- (GNUNET_SHUTDOWN_TEST() == NO) );
+ (GNUNET_SHUTDOWN_TEST() == NO) );
/* parse the response, and see if it was a success */
if (g_strstr_len(buf, buf_len, HTTP_OK) == NULL)
@@ -692,38 +692,38 @@
return SYSERR;
endDescURL = g_strstr_len(startDescURL,
- buf_len - (startDescURL - buf),
- "\r");
+ buf_len - (startDescURL - buf),
+ "\r");
if (endDescURL == NULL)
endDescURL = g_strstr_len(startDescURL,
- buf_len - (startDescURL - buf), "\n");
+ buf_len - (startDescURL - buf), "\n");
if(endDescURL == NULL)
return SYSERR;
if (endDescURL == startDescURL)
return SYSERR;
dd.full_url = STRNDUP(startDescURL,
- endDescURL - startDescURL);
+ endDescURL - startDescURL);
proxy = NULL;
GC_get_configuration_value_string(cfg,
- "GNUNETD",
- "HTTP-PROXY",
- "",
- &proxy);
+ "GNUNETD",
+ "HTTP-PROXY",
+ "",
+ &proxy);
ret = gaim_upnp_parse_description(proxy,
- &dd);
+ &dd);
FREE(dd.full_url);
GROW(dd.buf,
dd.buf_len,
0);
if (ret == OK) {
ret = gaim_upnp_generate_action_message_and_send(proxy,
- "GetExternalIPAddress",
- "",
- looked_up_public_ip_cb,
- &dd);
+ "GetExternalIPAddress",
+ "",
+ looked_up_public_ip_cb,
+ &dd);
GROW(dd.buf,
- dd.buf_len,
- 0);
+ dd.buf_len,
+ 0);
}
FREE(proxy);
return ret;
@@ -740,10 +740,10 @@
int
gaim_upnp_change_port_mapping(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- int do_add,
- unsigned short portmap,
- const char* protocol) {
+ struct GC_Configuration * cfg,
+ int do_add,
+ unsigned short portmap,
+ const char* protocol) {
const char * action_name;
char * action_params;
char * internal_ip;
@@ -751,39 +751,39 @@
int ret;
if (control_info.status != GAIM_UPNP_STATUS_DISCOVERED)
- return NO;
+ return NO;
if (do_add) {
internal_ip = gaim_upnp_get_internal_ip(cfg,
- ectx);
+ ectx);
if (internal_ip == NULL) {
gaim_debug_error("upnp",
- "gaim_upnp_set_port_mapping(): couldn't get local ip\n");
+ "gaim_upnp_set_port_mapping(): couldn't get local ip\n");
return NO;
}
action_name = "AddPortMapping";
action_params = g_strdup_printf(ADD_PORT_MAPPING_PARAMS,
- portmap,
- protocol,
- portmap,
- internal_ip);
+ portmap,
+ protocol,
+ portmap,
+ internal_ip);
FREE(internal_ip);
} else {
action_name = "DeletePortMapping";
action_params = g_strdup_printf(DELETE_PORT_MAPPING_PARAMS,
- portmap,
- protocol);
+ portmap,
+ protocol);
}
proxy = NULL;
GC_get_configuration_value_string(cfg,
- "GNUNETD",
- "HTTP-PROXY",
- "",
- &proxy);
+ "GNUNETD",
+ "HTTP-PROXY",
+ "",
+ &proxy);
ret = gaim_upnp_generate_action_message_and_send(proxy,
- action_name,
- action_params,
- &ignore_response,
- NULL);
+ action_name,
+ action_params,
+ &ignore_response,
+ NULL);
FREE(action_params);
FREE(proxy);
Modified: GNUnet/src/transports/upnp/upnptest.c
===================================================================
--- GNUnet/src/transports/upnp/upnptest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/transports/upnp/upnptest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -33,7 +33,7 @@
int main(int argc,
- const char *argv[]) {
+ const char *argv[]) {
static CoreAPIForApplication capi;
struct GE_Context * ectx;
struct GC_Configuration * cfg;
@@ -45,9 +45,9 @@
ServiceDoneMethod done;
ectx = GE_create_context_stderr(NO,
- GE_WARNING | GE_ERROR | GE_FATAL |
- GE_USER | GE_ADMIN | GE_DEVELOPER |
- GE_IMMEDIATE | GE_BULK);
+ GE_WARNING | GE_ERROR | GE_FATAL |
+ GE_USER | GE_ADMIN | GE_DEVELOPER |
+ GE_IMMEDIATE | GE_BULK);
GE_setDefaultContext(ectx);
cfg = GC_create_C_impl();
GE_ASSERT(ectx, cfg != NULL);
@@ -61,8 +61,8 @@
return 1;
}
init = os_plugin_resolve_function(plug,
- "provide_",
- YES);
+ "provide_",
+ YES);
if (init == NULL) {
os_plugin_unload(plug);
GC_free(cfg);
@@ -80,21 +80,21 @@
if (GNUNET_SHUTDOWN_TEST() != NO)
break;
if (OK == upnp->get_ip(2086,
- "TCP",
- &addr)) {
+ "TCP",
+ &addr)) {
printf("UPnP returned external IP %u.%u.%u.%u\n",
- PRIP(ntohl(*(int*)&addr)));
+ PRIP(ntohl(*(int*)&addr)));
} else {
/* we cannot be sure that there is a UPnP-capable
- NAT-box out there, so test should not fail
- just because of this! */
+ NAT-box out there, so test should not fail
+ just because of this! */
printf("No UPnP response (yet).\n");
}
PTHREAD_SLEEP(2 * cronSECONDS);
}
done = os_plugin_resolve_function(plug,
- "release_",
- YES);
+ "release_",
+ YES);
if (done != NULL)
done();
os_plugin_unload(plug);
Modified: GNUnet/src/transports/upnp/util.c
===================================================================
--- GNUnet/src/transports/upnp/util.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/transports/upnp/util.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -29,7 +29,7 @@
* (eg. &, < & etc.) starting at s. Returns NULL on failure.*/
static char *
detect_entity(const char *text,
- int *length) {
+ int *length) {
const char *pln;
int len;
int pound;
@@ -56,12 +56,12 @@
else if(IS_ENTITY("'"))
pln = "\'";
else if(*(text+1) == '#' && (sscanf(text, "&#%u;", £) == 1) &&
- pound != 0 && *(text+3+(int)log10(pound)) == ';') {
+ pound != 0 && *(text+3+(int)log10(pound)) == ';') {
char b[7];
char * buf = string_convertToUtf8(NULL,
- (const char*) £,
- 2,
- "UNICODE");
+ (const char*) £,
+ 2,
+ "UNICODE");
if (strlen(buf) > 6)
buf[6] = '\0';
strcpy(b, buf);
@@ -81,7 +81,7 @@
char *
g_strdup_printf(const char * fmt,
- ...) {
+ ...) {
size_t size;
char * buf;
va_list va;
@@ -107,21 +107,21 @@
char *ent;
if ((ent = detect_entity(c, &len)) != NULL) {
- app = g_strdup_printf("%s%s", ret, ent);
- FREE(ret);
- ret = app;
- c += len;
- FREE(ent);
+ app = g_strdup_printf("%s%s", ret, ent);
+ FREE(ret);
+ ret = app;
+ c += len;
+ FREE(ent);
} else if (!strncmp(c, "<br>", 4)) {
- app = g_strdup_printf("%s%s", ret, "\n");
- FREE(ret);
- ret = app;
- c += 4;
+ app = g_strdup_printf("%s%s", ret, "\n");
+ FREE(ret);
+ ret = app;
+ c += 4;
} else {
- app = g_strdup_printf("%s%c", ret, *c);
- FREE(ret);
- ret = app;
- c++;
+ app = g_strdup_printf("%s%c", ret, *c);
+ FREE(ret);
+ ret = app;
+ c++;
}
}
return ret;
Modified: GNUnet/src/transports/upnp/xmlnode.c
===================================================================
--- GNUnet/src/transports/upnp/xmlnode.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/transports/upnp/xmlnode.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -53,9 +53,9 @@
* The valid types for an xmlnode
*/
typedef enum _XMLNodeType {
- XMLNODE_TYPE_TAG, /**< Just a tag */
- XMLNODE_TYPE_ATTRIB, /**< Has attributes */
- XMLNODE_TYPE_DATA /**< Has data */
+ XMLNODE_TYPE_TAG, /**< Just a tag */
+ XMLNODE_TYPE_ATTRIB, /**< Has attributes */
+ XMLNODE_TYPE_DATA /**< Has data */
} XMLNodeType;
typedef struct {
@@ -66,22 +66,22 @@
} XMLNodePool;
struct _xmlnode {
- char *name; /**< The name of the node. */
- char *xmlns; /**< The namespace of the node */
- XMLNodeType type; /**< The type of the node. */
- char *data; /**< The data for the node. */
- size_t data_sz; /**< The size of the data. */
- struct _xmlnode *parent; /**< The parent node or @c NULL.*/
- struct _xmlnode *child; /**< The child node or @c NULL.*/
- struct _xmlnode *lastchild; /**< The last child node or @c NULL.*/
- struct _xmlnode *next; /**< The next node or @c NULL. */
+ char *name; /**< The name of the node. */
+ char *xmlns; /**< The namespace of the node */
+ XMLNodeType type; /**< The type of the node. */
+ char *data; /**< The data for the node. */
+ size_t data_sz; /**< The size of the data. */
+ struct _xmlnode *parent; /**< The parent node or @c NULL.*/
+ struct _xmlnode *child; /**< The child node or @c NULL.*/
+ struct _xmlnode *lastchild; /**< The last child node or @c NULL.*/
+ struct _xmlnode *next; /**< The next node or @c NULL. */
XMLNodePool * pool;
int free_pool; /* set to YES for the root node, which must free the pool */
};
static void * g_memdup(const void * data,
- size_t s) {
+ size_t s) {
void * ret;
ret = MALLOC(s);
@@ -90,22 +90,22 @@
}
static char * g_string_append_len(char * prefix,
- const void * data,
- size_t s) {
+ const void * data,
+ size_t s) {
char * ret;
ret = g_strdup_printf("%s%.*s",
- prefix,
- s,
- data);
+ prefix,
+ s,
+ data);
FREE(prefix);
return ret;
}
static xmlnode*
new_node(const char *name,
- XMLNodeType type,
- void * user_data) {
+ XMLNodeType type,
+ void * user_data) {
xmlnode *node = MALLOC(sizeof(xmlnode));
node->name = name == NULL ? NULL : STRDUP(name);
@@ -113,8 +113,8 @@
node->pool = user_data;
if (node->pool->size == node->pool->pos)
GROW(node->pool->nodes,
- node->pool->size,
- node->pool->size * 2 + 64);
+ node->pool->size,
+ node->pool->size * 2 + 64);
node->pool->nodes[node->pool->pos++] = node;
node->free_pool = 0;
return node;
@@ -122,16 +122,16 @@
static xmlnode*
xmlnode_new(const char *name,
- void * user_data) {
+ void * user_data) {
g_return_val_if_fail(name != NULL, NULL);
return new_node(name,
- XMLNODE_TYPE_TAG,
- user_data);
+ XMLNODE_TYPE_TAG,
+ user_data);
}
static void
xmlnode_insert_child(xmlnode *parent,
- xmlnode *child) {
+ xmlnode *child) {
g_return_if_fail(parent != NULL);
g_return_if_fail(child != NULL);
@@ -145,8 +145,8 @@
static xmlnode *
xmlnode_new_child(xmlnode *parent,
- const char *name,
- void * user_data) {
+ const char *name,
+ void * user_data) {
xmlnode *node;
g_return_val_if_fail(parent != NULL, NULL);
@@ -158,9 +158,9 @@
static void
xmlnode_insert_data(xmlnode *node,
- const char *data,
- int size,
- void * user_data) {
+ const char *data,
+ int size,
+ void * user_data) {
xmlnode *child;
size_t real_size;
@@ -176,7 +176,7 @@
static void
xmlnode_remove_attrib(xmlnode *node,
- const char *attr) {
+ const char *attr) {
xmlnode *attr_node, *sibling = NULL;
g_return_if_fail(node != NULL);
@@ -186,12 +186,12 @@
if(attr_node->type == XMLNODE_TYPE_ATTRIB &&
!strcmp(attr_node->name, attr)) {
if(node->child == attr_node) {
- node->child = attr_node->next;
+ node->child = attr_node->next;
} else {
- sibling->next = attr_node->next;
+ sibling->next = attr_node->next;
}
if (node->lastchild == attr_node) {
- node->lastchild = sibling;
+ node->lastchild = sibling;
}
xmlnode_free(attr_node);
return;
@@ -202,9 +202,9 @@
static void
xmlnode_set_attrib(xmlnode *node,
- const char *attr,
- const char *value,
- void * user_data) {
+ const char *attr,
+ const char *value,
+ void * user_data) {
xmlnode *attrib_node;
g_return_if_fail(node != NULL);
@@ -217,7 +217,7 @@
}
static void xmlnode_set_namespace(xmlnode *node,
- const char *xmlns) {
+ const char *xmlns) {
g_return_if_fail(node != NULL);
FREENONNULL(node->xmlns);
node->xmlns = STRDUP(xmlns);
@@ -256,8 +256,8 @@
static xmlnode *
xmlnode_get_child_with_namespace(const xmlnode *parent,
- const char *name,
- const char *ns) {
+ const char *name,
+ const char *ns) {
xmlnode *x;
xmlnode *ret = NULL;
char *parent_name;
@@ -273,7 +273,7 @@
if (child_name != NULL) {
child_name[0] = '\0';
child_name++;
- }
+ }
for(x = parent->child; x; x = x->next) {
const char *xmlns = NULL;
@@ -296,10 +296,10 @@
xmlnode*
xmlnode_get_child(const xmlnode *parent,
- const char *name) {
+ const char *name) {
return xmlnode_get_child_with_namespace(parent,
- name,
- NULL);
+ name,
+ NULL);
}
char *
@@ -312,7 +312,7 @@
for(c = node->child; c; c = c->next) {
if(c->type == XMLNODE_TYPE_DATA) {
if(!str)
- str = STRDUP("");
+ str = STRDUP("");
str = g_string_append_len(str, c->data, c->data_sz);
}
}
@@ -324,14 +324,14 @@
static void
xmlnode_parser_element_start_libxml(void *user_data,
- const xmlChar *element_name,
- const xmlChar *prefix,
- const xmlChar *xmlns,
- int nb_namespaces,
- const xmlChar **namespaces,
- int nb_attributes,
- int nb_defaulted,
- const xmlChar **attributes) {
+ const xmlChar *element_name,
+ const xmlChar *prefix,
+ const xmlChar *xmlns,
+ int nb_namespaces,
+ const xmlChar **namespaces,
+ int nb_attributes,
+ int nb_defaulted,
+ const xmlChar **attributes) {
XMLNodePool *xpd = user_data;
xmlnode *node;
int i;
@@ -362,9 +362,9 @@
static void
xmlnode_parser_element_end_libxml(void *user_data,
- const xmlChar *element_name,
- const xmlChar *prefix,
- const xmlChar *xmlns) {
+ const xmlChar *element_name,
+ const xmlChar *prefix,
+ const xmlChar *xmlns) {
XMLNodePool *xpd = user_data;
if(!element_name || !xpd->current)
@@ -377,56 +377,56 @@
static void
xmlnode_parser_element_text_libxml(void *user_data,
- const xmlChar *text,
- int text_len) {
+ const xmlChar *text,
+ int text_len) {
XMLNodePool *xpd = user_data;
if (!xpd->current || !text || !text_len)
return;
xmlnode_insert_data(xpd->current,
- (const char*) text,
- text_len,
- user_data);
+ (const char*) text,
+ text_len,
+ user_data);
}
static xmlSAXHandler xmlnode_parser_libxml = {
- .internalSubset = NULL,
- .isStandalone = NULL,
- .hasInternalSubset = NULL,
- .hasExternalSubset = NULL,
- .resolveEntity = NULL,
- .getEntity = NULL,
- .entityDecl = NULL,
- .notationDecl = NULL,
- .attributeDecl = NULL,
- .elementDecl = NULL,
- .unparsedEntityDecl = NULL,
- .setDocumentLocator = NULL,
- .startDocument = NULL,
- .endDocument = NULL,
- .startElement = NULL,
- .endElement = NULL,
- .reference = NULL,
- .characters = xmlnode_parser_element_text_libxml,
- .ignorableWhitespace = NULL,
- .processingInstruction = NULL,
- .comment = NULL,
- .warning = NULL,
- .error = NULL,
- .fatalError = NULL,
- .getParameterEntity = NULL,
- .cdataBlock = NULL,
- .externalSubset = NULL,
- .initialized = XML_SAX2_MAGIC,
- ._private = NULL,
- .startElementNs = xmlnode_parser_element_start_libxml,
- .endElementNs = xmlnode_parser_element_end_libxml,
- .serror = NULL
+ .internalSubset = NULL,
+ .isStandalone = NULL,
+ .hasInternalSubset = NULL,
+ .hasExternalSubset = NULL,
+ .resolveEntity = NULL,
+ .getEntity = NULL,
+ .entityDecl = NULL,
+ .notationDecl = NULL,
+ .attributeDecl = NULL,
+ .elementDecl = NULL,
+ .unparsedEntityDecl = NULL,
+ .setDocumentLocator = NULL,
+ .startDocument = NULL,
+ .endDocument = NULL,
+ .startElement = NULL,
+ .endElement = NULL,
+ .reference = NULL,
+ .characters = xmlnode_parser_element_text_libxml,
+ .ignorableWhitespace = NULL,
+ .processingInstruction = NULL,
+ .comment = NULL,
+ .warning = NULL,
+ .error = NULL,
+ .fatalError = NULL,
+ .getParameterEntity = NULL,
+ .cdataBlock = NULL,
+ .externalSubset = NULL,
+ .initialized = XML_SAX2_MAGIC,
+ ._private = NULL,
+ .startElementNs = xmlnode_parser_element_start_libxml,
+ .endElementNs = xmlnode_parser_element_end_libxml,
+ .serror = NULL
};
xmlnode *
xmlnode_from_str(const char *str,
- int size) {
+ int size) {
XMLNodePool *xpd;
xmlnode *ret;
size_t real_size;
@@ -436,12 +436,12 @@
real_size = size < 0 ? strlen(str) : size;
xpd = MALLOC(sizeof(XMLNodePool));
memset(xpd,
- 0,
- sizeof(XMLNodePool));
+ 0,
+ sizeof(XMLNodePool));
if (xmlSAXUserParseMemory(&xmlnode_parser_libxml,
- xpd,
- str,
- real_size) < 0) {
+ xpd,
+ str,
+ real_size) < 0) {
freePool(xpd);
return NULL;
}
Modified: GNUnet/src/util/boot/startup.c
===================================================================
--- GNUnet/src/util/boot/startup.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/boot/startup.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -57,7 +57,7 @@
* @return 0 on success, 1 on error
*/
static int configure_logging(struct GE_Context ** ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * admin_log_file;
char * admin_log_level;
char * user_log_level;
@@ -74,34 +74,34 @@
user_log_level = NULL;
logrotate = 7;
if (-1 == GC_get_configuration_value_number(cfg,
- "GNUNETD",
- "KEEPLOG",
- 0,
- 36500,
- 3,
- &logrotate))
+ "GNUNETD",
+ "KEEPLOG",
+ 0,
+ 36500,
+ 3,
+ &logrotate))
return 1; /* error! */
GC_get_configuration_value_filename(cfg,
- "GNUNETD",
- "LOGFILE",
- VAR_DAEMON_DIRECTORY "/logs",
- &admin_log_file);
+ "GNUNETD",
+ "LOGFILE",
+ VAR_DAEMON_DIRECTORY "/logs",
+ &admin_log_file);
disk_directory_create_for_file(*ectx,
- admin_log_file);
+ admin_log_file);
GC_get_configuration_value_string(cfg,
- "LOGGING",
- "ADMIN-LEVEL",
- "WARNING",
- &admin_log_level);
+ "LOGGING",
+ "ADMIN-LEVEL",
+ "WARNING",
+ &admin_log_level);
GC_get_configuration_value_string(cfg,
- "LOGGING",
- "USER-LEVEL",
- "WARNING",
- &user_log_level);
+ "LOGGING",
+ "USER-LEVEL",
+ "WARNING",
+ &user_log_level);
dev = GC_get_configuration_value_yesno(cfg,
- "LOGGING",
- "DEVELOPER",
- NO);
+ "LOGGING",
+ "DEVELOPER",
+ NO);
all = convertLogLevel(admin_log_level);
ull = convertLogLevel(user_log_level);
if (dev == YES) {
@@ -112,26 +112,26 @@
FREE(user_log_level);
if (all != 0) {
nctx = GE_create_context_logfile(NULL,
- all
- | GE_ADMIN
- | GE_BULK
- | GE_IMMEDIATE,
- admin_log_file,
- YES,
- (int) logrotate);
+ all
+ | GE_ADMIN
+ | GE_BULK
+ | GE_IMMEDIATE,
+ admin_log_file,
+ YES,
+ (int) logrotate);
}
FREE(admin_log_file);
if (ull != 0) {
tetx = GE_create_context_stderr(YES,
- ull
- | GE_USERKIND
- | GE_BULK
- | GE_IMMEDIATE);
+ ull
+ | GE_USERKIND
+ | GE_BULK
+ | GE_IMMEDIATE);
if (nctx == NULL)
nctx = tetx;
else
nctx = GE_create_context_multiplexer(nctx,
- tetx);
+ tetx);
}
GE_setDefaultContext(nctx);
GE_free_context(*ectx);
@@ -149,12 +149,12 @@
* otherwise
*/
int GNUNET_init(int argc,
- char * const * argv,
- const char * binaryName,
- char ** cfgFileName,
- const struct CommandLineOption * options,
- struct GE_Context ** ectx,
- struct GC_Configuration ** cfg) {
+ char * const * argv,
+ const char * binaryName,
+ char ** cfgFileName,
+ const struct CommandLineOption * options,
+ struct GE_Context ** ectx,
+ struct GC_Configuration ** cfg) {
int i;
char * path;
int is_daemon;
@@ -174,23 +174,23 @@
/* during startup, log all warnings and higher
for anybody to stderr */
*ectx = GE_create_context_stderr(YES,
- GE_WARNING | GE_ERROR | GE_FATAL |
- GE_USER | GE_ADMIN | GE_DEVELOPER |
- GE_IMMEDIATE | GE_BULK);
+ GE_WARNING | GE_ERROR | GE_FATAL |
+ GE_USER | GE_ADMIN | GE_DEVELOPER |
+ GE_IMMEDIATE | GE_BULK);
GE_setDefaultContext(*ectx);
os_init(*ectx);
*cfg = GC_create_C_impl();
GE_ASSERT(*ectx, *cfg != NULL);
i = gnunet_parse_options(binaryName,
- *ectx,
- *cfg,
- options,
- (unsigned int) argc,
- argv);
+ *ectx,
+ *cfg,
+ options,
+ (unsigned int) argc,
+ argv);
if (i == -1)
return -1;
if ( (YES != disk_file_test(*ectx,
- *cfgFileName)) &&
+ *cfgFileName)) &&
(! is_daemon) ) {
char * run;
char * bindir;
@@ -200,37 +200,37 @@
max = 128 + strlen(*cfgFileName) + strlen(bindir);
run = MALLOC(max);
SNPRINTF(run,
- max,
- "%sgnunet-setup -c %s generate-defaults",
- bindir,
- *cfgFileName);
+ max,
+ "%sgnunet-setup -c %s generate-defaults",
+ bindir,
+ *cfgFileName);
FREE(bindir);
ret = system(run);
if (0 != ret)
GE_LOG(*ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Failed to run %s: %s %d\n"),
- run,
- strerror(errno),
- WEXITSTATUS(ret));
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Failed to run %s: %s %d\n"),
+ run,
+ strerror(errno),
+ WEXITSTATUS(ret));
FREE(run);
}
if (0 != GC_parse_configuration(*cfg,
- *cfgFileName))
+ *cfgFileName))
return -1;
/* if PATHS/GNUNETD_HOME is not set, set it to
the default value! */
GC_get_configuration_value_string(*cfg,
- "PATHS",
- "GNUNETD_HOME",
- "/var/lib/gnunet",
- &path);
+ "PATHS",
+ "GNUNETD_HOME",
+ "/var/lib/gnunet",
+ &path);
FREE(path);
GC_get_configuration_value_string(*cfg,
- "PATHS",
- "GNUNET_HOME",
- "~/.gnunet",
- &path);
+ "PATHS",
+ "GNUNET_HOME",
+ "~/.gnunet",
+ &path);
FREE(path);
if (configure_logging(ectx, *cfg) != 0)
return -1;
@@ -241,10 +241,10 @@
* Free resources allocated during GNUnet_init.
*/
void GNUNET_fini(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
GC_free(cfg);
GE_setDefaultContext(NULL);
GE_free_context(ectx);
}
-
+
/* end of startup.c */
Modified: GNUnet/src/util/config/config.c
===================================================================
--- GNUnet/src/util/config/config.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/config/config.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -45,7 +45,7 @@
* be reported
*/
void GC_set_error_context(struct GC_Configuration * cfg,
- struct GE_Context * ectx) {
+ struct GE_Context * ectx) {
cfg->set_error_context(cfg, ectx);
}
@@ -55,7 +55,7 @@
* @return 0 on success, -1 on error
*/
int GC_parse_configuration(struct GC_Configuration * cfg,
- const char * filename) {
+ const char * filename) {
return cfg->parse_configuration(cfg, filename);
}
@@ -74,7 +74,7 @@
* @return 0 on success, -1 on error
*/
int GC_write_configuration(struct GC_Configuration * cfg,
- const char * filename) {
+ const char * filename) {
return cfg->write_configuration(cfg, filename);
}
@@ -88,19 +88,19 @@
* @return YES, NO or SYSERR
*/
int GC_get_configuration_value_yesno(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- int def) {
+ const char * section,
+ const char * option,
+ int def) {
static const char * yesno[] = { "YES" , "NO", NULL };
const char * val;
int ret;
ret = GC_get_configuration_value_choice(cfg,
- section,
- option,
- yesno,
- def == YES ? "YES" : "NO",
- &val);
+ section,
+ option,
+ yesno,
+ def == YES ? "YES" : "NO",
+ &val);
if (ret == -1)
return SYSERR;
if (val == yesno[0])
@@ -117,7 +117,7 @@
* @return $-expanded string
*/
char * GC_configuration_expand_dollar(struct GC_Configuration * cfg,
- char * old) {
+ char * old) {
return cfg->configuration_expand_dollar(cfg, old);
}
@@ -129,12 +129,12 @@
* @return 0 on success, -1 on error, 1 for default
*/
int GC_get_configuration_value_number(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- unsigned long long min,
- unsigned long long max,
- unsigned long long def,
- unsigned long long * number) {
+ const char * section,
+ const char * option,
+ unsigned long long min,
+ unsigned long long max,
+ unsigned long long def,
+ unsigned long long * number) {
return cfg->get_configuration_value_number(cfg, section, option, min, max,
def, number);
}
@@ -148,18 +148,18 @@
* @return 0 on success, -1 on error, 1 for default
*/
int GC_get_configuration_value_string(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- const char * def,
- char ** value) {
+ const char * section,
+ const char * option,
+ const char * def,
+ char ** value) {
return cfg->get_configuration_value_string(cfg, section, option, def, value);
}
int GC_get_configuration_value_filename(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- const char * def,
- char ** value) {
+ const char * section,
+ const char * option,
+ const char * def,
+ char ** value) {
return cfg->get_configuration_value_filename(cfg, section, option, def,
value);
}
@@ -175,11 +175,11 @@
* @return 0 on success, -1 on error, 1 for default
*/
int GC_get_configuration_value_choice(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- const char ** choices,
- const char * def,
- const char ** value) {
+ const char * section,
+ const char * option,
+ const char ** choices,
+ const char * def,
+ const char ** value) {
return cfg->get_configuration_value_choice(cfg, section, option, choices,
def, value);
}
@@ -189,10 +189,10 @@
* or update refused by registered callback)
*/
int GC_set_configuration_value_number(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option,
- unsigned long long number) {
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option,
+ unsigned long long number) {
return cfg->set_configuration_value_number(cfg, ectx, section, option,
number);
}
@@ -204,10 +204,10 @@
* or update refused by registered callback)
*/
int GC_set_configuration_value_string(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option,
- const char * value) {
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option,
+ const char * value) {
return cfg->set_configuration_value_string(cfg, ectx, section, option,
value);
}
@@ -219,10 +219,10 @@
* or update refused by registered callback)
*/
int GC_set_configuration_value_choice(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option,
- const char * choice) {
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option,
+ const char * choice) {
return cfg->set_configuration_value_choice(cfg, ectx, section, option,
choice);
}
@@ -232,8 +232,8 @@
* @return 0 on success, -1 on error
*/
int GC_attach_change_listener(struct GC_Configuration * cfg,
- GC_ChangeListener callback,
- void * ctx) {
+ GC_ChangeListener callback,
+ void * ctx) {
return cfg->attach_change_listener(cfg, callback, ctx);
}
@@ -243,15 +243,15 @@
* @return 0 on success, -1 on error, 1 for no such handler registered
*/
int GC_detach_change_listener(struct GC_Configuration * cfg,
- GC_ChangeListener callback,
- void * ctx) {
+ GC_ChangeListener callback,
+ void * ctx) {
return cfg->detach_change_listener(cfg, callback, ctx);
}
int GC_have_configuration_value(struct GC_Configuration * cfg,
- const char * section,
- const char * option) {
+ const char * section,
+ const char * option) {
return cfg->have_configuration_value(cfg,
- section,
- option);
+ section,
+ option);
}
Modified: GNUnet/src/util/config_impl/configtest.c
===================================================================
--- GNUnet/src/util/config_impl/configtest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/config_impl/configtest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -35,53 +35,53 @@
unsigned long long l;
if (0 != GC_get_configuration_value_string(cfg,
- "test",
- "b",
- NULL,
- &c))
+ "test",
+ "b",
+ NULL,
+ &c))
return 1;
if (0 != strcmp("b",
- c))
+ c))
return 1;
FREE(c);
if (0 != GC_get_configuration_value_number(cfg,
- "test",
- "five",
- 0,
- 10,
- 9,
- &l))
+ "test",
+ "five",
+ 0,
+ 10,
+ 9,
+ &l))
return 1;
if (5 != l)
return 1;
GC_set_configuration_value_string(cfg,
- NULL,
- "more",
- "c",
- "YES");
+ NULL,
+ "more",
+ "c",
+ "YES");
if (NO == GC_get_configuration_value_yesno(cfg,
- "more",
- "c",
- NO))
+ "more",
+ "c",
+ NO))
return 1;
return 0;
}
int main(int argc,
- char * argv[]) {
+ char * argv[]) {
struct GE_Context * ectx;
int failureCount = 0;
ectx = GE_create_context_stderr(NO,
- GE_WARNING | GE_ERROR | GE_FATAL |
- GE_USER | GE_ADMIN | GE_DEVELOPER |
- GE_IMMEDIATE | GE_BULK);
+ GE_WARNING | GE_ERROR | GE_FATAL |
+ GE_USER | GE_ADMIN | GE_DEVELOPER |
+ GE_IMMEDIATE | GE_BULK);
GE_setDefaultContext(ectx);
cfg = GC_create_C_impl();
if (0 != GC_parse_configuration(cfg,
- "testconfig.conf")) {
+ "testconfig.conf")) {
fprintf(stderr,
- "Failed to parse configuration file\n");
+ "Failed to parse configuration file\n");
return 1;
}
GE_ASSERT(ectx, cfg != NULL);
Modified: GNUnet/src/util/config_impl/impl.c
===================================================================
--- GNUnet/src/util/config_impl/impl.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/config_impl/impl.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -143,31 +143,31 @@
FREE(e->key);
FREENONNULL(e->val);
GE_ASSERT(cfg->data->ectx,
- e->dirty_val == NULL);
+ e->dirty_val == NULL);
}
GROW(sec->entries,
- sec->size,
- 0);
+ sec->size,
+ 0);
FREE(sec->name);
}
GROW(cfg->data->sections,
cfg->data->ssize,
0);
GE_ASSERT(cfg->data->ectx,
- cfg->data->listeners == 0);
+ cfg->data->listeners == 0);
MUTEX_DESTROY(cfg->data->lock);
FREE(cfg->data);
FREE(cfg);
}
static void _set_error_context(struct GC_Configuration * cfg,
- struct GE_Context * ectx) {
+ struct GE_Context * ectx) {
cfg->data->ectx = ectx;
}
static int
_parse_configuration(struct GC_Configuration * cfg,
- const char * filename) {
+ const char * filename) {
int dirty;
char line[256];
char tag[64];
@@ -181,14 +181,14 @@
char * fn;
fn = string_expandFileName(NULL,
- filename);
+ filename);
MUTEX_LOCK(cfg->data->lock);
dirty = cfg->data->dirty; /* back up value! */
if (NULL == (fp = FOPEN(fn, "r"))) {
GE_LOG_STRERROR_FILE(cfg->data->ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK |
GE_REQUEST,
- "fopen",
- fn);
+ GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK | GE_REQUEST,
+ "fopen",
+ fn);
MUTEX_UNLOCK(cfg->data->lock);
FREE(fn);
return -1;
@@ -197,21 +197,21 @@
ret = 0;
section = STRDUP("");
memset(line,
- 0,
- 256);
+ 0,
+ 256);
nr = 0;
while (NULL != fgets(line, 255, fp)) {
nr++;
for (i=0;i<255;i++)
if (line[i] == '\t')
- line[i] = ' ';
+ line[i] = ' ';
if (line[0] == '\n' || line[0] == '#' || line[0] == '%' ||
- line[0] == '\r')
+ line[0] == '\r')
continue;
emptyline = 1;
for (i=0;(i<255 && line[i] != 0);i++)
if (line[i] != ' ' && line[i] != '\n' && line[i] != '\r')
- emptyline = 0;
+ emptyline = 0;
if (emptyline == 1)
continue;
/* remove tailing whitespace */
@@ -220,20 +220,20 @@
if (1 == sscanf(line, "@INLINE@ %191[^\n]", value) ) {
/* @INLINE@ value */
char * expanded = string_expandFileName(cfg->data->ectx,
- value);
+ value);
if (0 != _parse_configuration(cfg,
- expanded))
- ret = -1; /* failed to parse included config */
+ expanded))
+ ret = -1; /* failed to parse included config */
} else if (1 == sscanf(line,
- "[%99[^]]]",
- value)) {
+ "[%99[^]]]",
+ value)) {
/* [value] */
FREE(section);
section = STRDUP(value);
} else if (2 == sscanf(line,
- " %63[^= ] = %191[^\n]",
- tag,
- value)) {
+ " %63[^= ] = %191[^\n]",
+ tag,
+ value)) {
/* tag = value */
/* Strip LF */
i = strlen(value) - 1;
@@ -242,61 +242,61 @@
/* remove quotes */
i = 0;
if (value[0] == '"') {
- i = 1;
- while ( (value[i] != '\0') &&
- (value[i] != '"') )
- i++;
- if (value[i] == '"') {
- value[i] = '\0';
- i = 1;
- } else
- i = 0;
+ i = 1;
+ while ( (value[i] != '\0') &&
+ (value[i] != '"') )
+ i++;
+ if (value[i] == '"') {
+ value[i] = '\0';
+ i = 1;
+ } else
+ i = 0;
}
/* first check if we have this value already;
- this could happen if the value was changed
- using a command-line option; only set it
- if we do not have a value already... */
+ this could happen if the value was changed
+ using a command-line option; only set it
+ if we do not have a value already... */
if ( (NO == GC_have_configuration_value(cfg,
- section,
- tag)) &&
- (0 != GC_set_configuration_value_string(cfg,
- cfg->data->ectx,
- section,
- tag,
- &value[i])) )
- ret = -1; /* could not set value */
+ section,
+ tag)) &&
+ (0 != GC_set_configuration_value_string(cfg,
+ cfg->data->ectx,
+ section,
+ tag,
+ &value[i])) )
+ ret = -1; /* could not set value */
} else if (1 == sscanf(line,
- " %63[^= ] =[^\n]",
- tag)) {
+ " %63[^= ] =[^\n]",
+ tag)) {
/* tag = */
/* first check if we have this value already;
- this could happen if the value was changed
- using a command-line option; only set it
- if we do not have a value already... */
+ this could happen if the value was changed
+ using a command-line option; only set it
+ if we do not have a value already... */
if ( (NO == GC_have_configuration_value(cfg,
- section,
- tag)) &&
- (0 != GC_set_configuration_value_string(cfg,
- cfg->data->ectx,
- section,
- tag,
- "")) )
- ret = -1; /* could not set value */
+ section,
+ tag)) &&
+ (0 != GC_set_configuration_value_string(cfg,
+ cfg->data->ectx,
+ section,
+ tag,
+ "")) )
+ ret = -1; /* could not set value */
} else {
/* parse error */
GE_LOG(cfg->data->ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK,
- _("Syntax error in configuration file `%s' at line %d.\n"),
- filename, nr);
+ GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK,
+ _("Syntax error in configuration file `%s' at line %d.\n"),
+ filename, nr);
ret = -1;
break;
}
}
if (0 != fclose(fp)) {
GE_LOG_STRERROR_FILE(cfg->data->ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK
| GE_REQUEST,
- "fclose",
- filename);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK |
GE_REQUEST,
+ "fclose",
+ filename);
ret = -1;
}
/* restore dirty flag - anything we set in the meantime
@@ -314,7 +314,7 @@
static int
_write_configuration(struct GC_Configuration * cfg,
- const char * filename) {
+ const char * filename) {
GC_ConfigurationData * data;
GC_Section * sec;
GC_Entry * e;
@@ -332,9 +332,9 @@
data = cfg->data;
if (NULL == (fp = FOPEN(fn, "w"))) {
GE_LOG_STRERROR_FILE(data->ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- "fopen",
- fn);
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ "fopen",
+ fn);
FREE(fn);
return -1;
}
@@ -345,34 +345,34 @@
for (i=0;i<data->ssize;i++) {
sec = &data->sections[i];
if (0 > fprintf(fp,
- "[%s]\n",
- sec->name)) {
+ "[%s]\n",
+ sec->name)) {
error = 1;
break;
}
for (j=0;j<sec->size;j++) {
e = &sec->entries[j];
GE_ASSERT(data->ectx,
- e->dirty_val == NULL);
+ e->dirty_val == NULL);
if (e->val != NULL) {
- val = MALLOC(strlen(e->val) * 2 + 1);
- strcpy(val, e->val);
- while (NULL != (pos = strstr(val, "\n"))) {
- memmove(&pos[2],
- &pos[1],
- strlen(&pos[1]));
- pos[0] = '\\';
- pos[1] = 'n';
- }
- if (0 > fprintf(fp,
- "%s = %s\n",
- e->key,
- val)) {
- error = 1;
- FREE(val);
- break;
- }
- FREE(val);
+ val = MALLOC(strlen(e->val) * 2 + 1);
+ strcpy(val, e->val);
+ while (NULL != (pos = strstr(val, "\n"))) {
+ memmove(&pos[2],
+ &pos[1],
+ strlen(&pos[1]));
+ pos[0] = '\\';
+ pos[1] = 'n';
+ }
+ if (0 > fprintf(fp,
+ "%s = %s\n",
+ e->key,
+ val)) {
+ error = 1;
+ FREE(val);
+ break;
+ }
+ FREE(val);
}
}
if (error != 0)
@@ -384,14 +384,14 @@
}
if (error != 0)
GE_LOG_STRERROR_FILE(data->ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK |
GE_REQUEST,
- "fprintf",
- filename);
+ GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK | GE_REQUEST,
+ "fprintf",
+ filename);
if (0 != fclose(fp)) {
GE_LOG_STRERROR_FILE(data->ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK
| GE_REQUEST,
- "fclose",
- filename);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK |
GE_REQUEST,
+ "fclose",
+ filename);
error = 1;
}
if (error == 0) {
@@ -410,13 +410,13 @@
*/
static GC_Section *
findSection(GC_ConfigurationData * data,
- const char * section) {
+ const char * section) {
int i;
for (i=data->ssize-1;i>=0;i--)
if (0 == strcmp(section,
- data->sections[i].name))
+ data->sections[i].name))
return &data->sections[i];
- return NULL;
+ return NULL;
}
/**
@@ -424,8 +424,8 @@
*/
static GC_Entry *
findEntry(GC_ConfigurationData * data,
- const char * section,
- const char * key) {
+ const char * section,
+ const char * key) {
int i;
GC_Section * sec;
@@ -434,17 +434,17 @@
return NULL;
for (i=sec->size-1;i>=0;i--)
if (0 == strcmp(key,
- sec->entries[i].key))
+ sec->entries[i].key))
return &sec->entries[i];
- return NULL;
+ return NULL;
}
static int
_set_configuration_value_string(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option,
- const char * value) {
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option,
+ const char * value) {
GC_ConfigurationData * data;
GC_Section * sec;
GC_Section nsec;
@@ -463,21 +463,21 @@
nsec.size = 0;
nsec.entries = NULL;
APPEND(data->sections,
- data->ssize,
- nsec);
+ data->ssize,
+ nsec);
sec = findSection(data, section);
}
ne.key = STRDUP(option);
ne.val = NULL;
ne.dirty_val = NULL;
APPEND(sec->entries,
- sec->size,
- ne);
+ sec->size,
+ ne);
e = findEntry(data, section, option);
}
if (e->dirty_val != NULL) {
if (0 == strcmp(e->dirty_val,
- value)) {
+ value)) {
ret = 0;
} else {
/* recursive update to different value -- not allowed! */
@@ -489,11 +489,11 @@
i = data->lsize - 1;
while (i >= 0) {
if (0 != data->listeners[i].listener(data->listeners[i].ctx,
- cfg,
- ectx,
- section,
- option))
- break; /* update refused */
+ cfg,
+ ectx,
+ section,
+ option))
+ break; /* update refused */
i--;
e = findEntry(data, section, option); /* side-effects of callback are
possible! */
}
@@ -504,22 +504,22 @@
e->dirty_val = NULL;
i++; /* the callback that refused does not need refreshing */
while (i < data->lsize) {
- if (0 != data->listeners[i].listener(data->listeners[i].ctx,
- cfg,
- ectx,
- section,
- option))
- GE_ASSERT(ectx, 0); /* refused the refusal!? */
- e = findEntry(data, section, option); /* side-effects of callback are
possible! */
- i++;
+ if (0 != data->listeners[i].listener(data->listeners[i].ctx,
+ cfg,
+ ectx,
+ section,
+ option))
+ GE_ASSERT(ectx, 0); /* refused the refusal!? */
+ e = findEntry(data, section, option); /* side-effects of callback are
possible! */
+ i++;
}
ret = -1; /* error -- update refused */
} else {
/* all confirmed, commit! */
if ( (e->val == NULL) ||
- (0 != strcmp(e->val,
- e->dirty_val)) )
- data->dirty = 1;
+ (0 != strcmp(e->val,
+ e->dirty_val)) )
+ data->dirty = 1;
FREENONNULL(e->val);
e->val = e->dirty_val;
e->dirty_val = NULL;
@@ -528,21 +528,21 @@
}
if (ret == -1)
GE_LOG(ectx,
- GE_USER | GE_BULK | GE_WARNING,
- _("Setting option `%s' in section `%s' to value `%s' was
refused.\n"),
- option,
- section,
- value);
+ GE_USER | GE_BULK | GE_WARNING,
+ _("Setting option `%s' in section `%s' to value `%s' was refused.\n"),
+ option,
+ section,
+ value);
MUTEX_UNLOCK(data->lock);
return ret;
}
static int
_set_configuration_value_number(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option,
- unsigned long long number) {
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option,
+ unsigned long long number) {
char s[64];
SNPRINTF(s, 64, "%llu", number);
return _set_configuration_value_string(cfg, ectx, section, option, s);
@@ -550,59 +550,59 @@
static int
_get_configuration_value_number(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- unsigned long long min,
- unsigned long long max,
- unsigned long long def,
- unsigned long long * number) {
+ const char * section,
+ const char * option,
+ unsigned long long min,
+ unsigned long long max,
+ unsigned long long def,
+ unsigned long long * number) {
GC_Entry * e;
const char * val;
int ret;
MUTEX_LOCK(cfg->data->lock);
e = findEntry(cfg->data,
- section,
- option);
+ section,
+ option);
if (e != NULL) {
val = (e->dirty_val != NULL) ? e->dirty_val : e->val;
if (1 == SSCANF(val,
- "%llu",
- number)) {
+ "%llu",
+ number)) {
if ( (*number >= min) &&
- (*number <= max) ) {
- ret = 0;
+ (*number <= max) ) {
+ ret = 0;
} else {
- GE_LOG(cfg->data->ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("Configuration value '%llu' for '%s' "
- "in section '%s' is out of legal bounds [%llu,%llu]\n"),
- *number,
- option,
- section,
- min,
- max);
- ret = -1; /* error */
+ GE_LOG(cfg->data->ectx,
+ GE_ERROR | GE_USER | GE_BULK,
+ _("Configuration value '%llu' for '%s' "
+ "in section '%s' is out of legal bounds [%llu,%llu]\n"),
+ *number,
+ option,
+ section,
+ min,
+ max);
+ ret = -1; /* error */
}
} else {
GE_LOG(cfg->data->ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("Configuration value '%s' for '%s'"
- " in section '%s' should be a number\n"),
- val,
- option,
- section,
- min,
- max);
+ GE_ERROR | GE_USER | GE_BULK,
+ _("Configuration value '%s' for '%s'"
+ " in section '%s' should be a number\n"),
+ val,
+ option,
+ section,
+ min,
+ max);
ret = -1; /* error */
}
} else {
*number = def;
_set_configuration_value_number(cfg,
- cfg->data->ectx,
- section,
- option,
- def);
+ cfg->data->ectx,
+ section,
+ option,
+ def);
ret = 1; /* default */
}
MUTEX_UNLOCK(cfg->data->lock);
@@ -611,18 +611,18 @@
static int
_get_configuration_value_string(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- const char * def,
- char ** value) {
+ const char * section,
+ const char * option,
+ const char * def,
+ char ** value) {
GC_Entry * e;
const char * val;
int ret;
MUTEX_LOCK(cfg->data->lock);
e = findEntry(cfg->data,
- section,
- option);
+ section,
+ option);
if (e != NULL) {
val = (e->dirty_val != NULL) ? e->dirty_val : e->val;
*value = STRDUP(val);
@@ -631,18 +631,18 @@
if (def == NULL) {
MUTEX_UNLOCK(cfg->data->lock);
GE_LOG(cfg->data->ectx,
- GE_USER | GE_IMMEDIATE | GE_ERROR,
- "Configuration value for option `%s' in section `%s' required.\n",
- option,
- section);
+ GE_USER | GE_IMMEDIATE | GE_ERROR,
+ "Configuration value for option `%s' in section `%s' required.\n",
+ option,
+ section);
return -1;
}
*value = STRDUP(def);
_set_configuration_value_string(cfg,
- cfg->data->ectx,
- section,
- option,
- def);
+ cfg->data->ectx,
+ section,
+ option,
+ def);
ret = 1; /* default */
}
MUTEX_UNLOCK(cfg->data->lock);
@@ -651,11 +651,11 @@
static int
_get_configuration_value_choice(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- const char ** choices,
- const char * def,
- const char ** value) {
+ const char * section,
+ const char * option,
+ const char ** choices,
+ const char * def,
+ const char ** value) {
GC_Entry * e;
const char * val;
int i;
@@ -663,25 +663,25 @@
MUTEX_LOCK(cfg->data->lock);
e = findEntry(cfg->data,
- section,
- option);
+ section,
+ option);
if (e != NULL) {
val = (e->dirty_val != NULL) ? e->dirty_val : e->val;
i = 0;
while (choices[i] != NULL) {
if (0 == strcasecmp(choices[i],
- val))
- break;
+ val))
+ break;
i++;
}
if (choices[i] == NULL) {
GE_LOG(cfg->data->ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("Configuration value '%s' for '%s'"
- " in section '%s' is not in set of legal choices\n"),
- val,
- option,
- section);
+ GE_ERROR | GE_USER | GE_BULK,
+ _("Configuration value '%s' for '%s'"
+ " in section '%s' is not in set of legal choices\n"),
+ val,
+ option,
+ section);
ret = -1; /* error */
} else {
*value = choices[i];
@@ -704,15 +704,15 @@
*/
static int
_have_configuration_value(struct GC_Configuration * cfg,
- const char * section,
- const char * option) {
+ const char * section,
+ const char * option) {
GC_Entry * e;
int ret;
MUTEX_LOCK(cfg->data->lock);
e = findEntry(cfg->data,
- section,
- option);
+ section,
+ option);
if (e == NULL)
ret = NO;
else
@@ -731,7 +731,7 @@
*/
static char *
_configuration_expand_dollar(struct GC_Configuration * cfg,
- char * orig) {
+ char * orig) {
int i;
char * prefix;
char * result;
@@ -741,7 +741,7 @@
return orig;
i = 0;
while ( (orig[i] != '/') &&
- (orig[i] != '\\') &&
+ (orig[i] != '\\') &&
(orig[i] != '\0') )
i++;
if (orig[i] == '\0') {
@@ -752,13 +752,13 @@
}
prefix = NULL;
if (YES == _have_configuration_value(cfg,
- "PATHS",
- &orig[1])) {
+ "PATHS",
+ &orig[1])) {
if (0 != _get_configuration_value_string(cfg,
- "PATHS",
- &orig[1],
- NULL,
- &prefix)) {
+ "PATHS",
+ &orig[1],
+ NULL,
+ &prefix)) {
GE_BREAK(NULL, 0);
return orig;
}
@@ -794,10 +794,10 @@
*/
static int
_get_configuration_value_filename(struct GC_Configuration * cfg,
- const char * section,
- const char * option,
- const char * def,
- char ** value) {
+ const char * section,
+ const char * option,
+ const char * def,
+ char ** value) {
GC_ConfigurationData * data;
int ret;
char * tmp;
@@ -805,15 +805,15 @@
data = cfg->data;
tmp = NULL;
ret = _get_configuration_value_string(cfg,
- section,
- option,
- def,
- &tmp);
+ section,
+ option,
+ def,
+ &tmp);
if (tmp != NULL) {
tmp = _configuration_expand_dollar(cfg,
- tmp);
+ tmp);
*value = string_expandFileName(data->ectx,
- tmp);
+ tmp);
FREE(tmp);
} else {
*value = NULL;
@@ -823,17 +823,17 @@
static int
_set_configuration_value_choice(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * section,
- const char * option,
- const char * choice) {
+ struct GE_Context * ectx,
+ const char * section,
+ const char * option,
+ const char * choice) {
return _set_configuration_value_string(cfg, ectx, section, option, choice);
}
static int
_attach_change_listener(struct GC_Configuration * cfg,
- GC_ChangeListener callback,
- void * ctx) {
+ GC_ChangeListener callback,
+ void * ctx) {
GC_Listener l;
int i;
int j;
@@ -844,12 +844,12 @@
for (j=0;j<s->size;j++) {
GC_Entry * e = &s->entries[j];
if (0 != callback(ctx,
- cfg,
- cfg->data->ectx,
- s->name,
- e->key)) {
- MUTEX_UNLOCK(cfg->data->lock);
- return -1;
+ cfg,
+ cfg->data->ectx,
+ s->name,
+ e->key)) {
+ MUTEX_UNLOCK(cfg->data->lock);
+ return -1;
}
s = &cfg->data->sections[i]; /* side-effects of callback are possible! */
}
@@ -857,16 +857,16 @@
l.listener = callback;
l.ctx = ctx;
APPEND(cfg->data->listeners,
- cfg->data->lsize,
- l);
+ cfg->data->lsize,
+ l);
MUTEX_UNLOCK(cfg->data->lock);
return 0;
}
static int
_detach_change_listener(struct GC_Configuration * cfg,
- GC_ChangeListener callback,
- void * ctx) {
+ GC_ChangeListener callback,
+ void * ctx) {
int i;
GC_Listener * l;
@@ -874,12 +874,12 @@
for (i=cfg->data->lsize-1;i>=0;i--) {
l = &cfg->data->listeners[i];
if ( (l->listener == callback) &&
- (l->ctx == ctx) ) {
+ (l->ctx == ctx) ) {
cfg->data->listeners[i]
- = cfg->data->listeners[cfg->data->lsize-1];
+ = cfg->data->listeners[cfg->data->lsize-1];
GROW(cfg->data->listeners,
- cfg->data->lsize,
- cfg->data->lsize-1);
+ cfg->data->lsize,
+ cfg->data->lsize-1);
MUTEX_UNLOCK(cfg->data->lock);
return 0;
}
Modified: GNUnet/src/util/containers/bloomfilter.c
===================================================================
--- GNUnet/src/util/containers/bloomfilter.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/containers/bloomfilter.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -91,7 +91,7 @@
* @param bitIdx which bit to set
*/
static void setBit(char * bitArray,
- unsigned int bitIdx) {
+ unsigned int bitIdx) {
unsigned int arraySlot;
unsigned int targetBit;
@@ -108,7 +108,7 @@
* @param bitIdx which bit to unset
*/
static void clearBit(char * bitArray,
- unsigned int bitIdx) {
+ unsigned int bitIdx) {
unsigned int slot;
unsigned int targetBit;
@@ -125,7 +125,7 @@
* @return YES if the bit is set, NO if not.
*/
static int testBit(char * bitArray,
- unsigned int bitIdx) {
+ unsigned int bitIdx) {
unsigned int slot;
unsigned int targetBit;
@@ -147,8 +147,8 @@
* @param fd A file to keep the 4 bit address usage counters in
*/
static void incrementBit(char * bitArray,
- unsigned int bitIdx,
- int fd) {
+ unsigned int bitIdx,
+ int fd) {
unsigned int fileSlot;
unsigned char value;
unsigned int high;
@@ -164,8 +164,8 @@
if (fileSlot != (unsigned int) lseek(fd, fileSlot, SEEK_SET))
GE_DIE_STRERROR(NULL,
- GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
- "lseek");
+ GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
+ "lseek");
value = 0;
READ(fd,
&value,
@@ -184,12 +184,12 @@
value = ((high<<4) | low);
if (fileSlot != (unsigned int) lseek(fd, fileSlot, SEEK_SET))
GE_DIE_STRERROR(NULL,
- GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
- "lseek");
+ GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
+ "lseek");
if (1 != WRITE(fd, &value, 1))
GE_DIE_STRERROR(NULL,
- GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
- "write");
+ GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
+ "write");
}
@@ -202,8 +202,8 @@
* @param fd A file to keep the 4bit address usage counters in
*/
static void decrementBit(char * bitArray,
- unsigned int bitIdx,
- int fd) {
+ unsigned int bitIdx,
+ int fd) {
unsigned int fileSlot;
unsigned char value;
unsigned int high;
@@ -241,8 +241,8 @@
lseek(fd, fileSlot, SEEK_SET);
if (1 != WRITE(fd, &value, 1))
GE_DIE_STRERROR(NULL,
- GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
- "write");
+ GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
+ "write");
}
#define BUFFSIZE 65536
@@ -255,7 +255,7 @@
* @return OK if created ok, SYSERR otherwise
*/
static int makeEmptyFile(int fd,
- unsigned int size) {
+ unsigned int size) {
char * buffer;
unsigned int bytesleft=size;
int res = 0;
@@ -276,8 +276,8 @@
}
if(res == -1) {
GE_DIE_STRERROR(NULL,
- GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
- "write");
+ GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
+ "write");
FREE(buffer);
return SYSERR;
}
@@ -298,9 +298,9 @@
* @param additional context specific argument
*/
typedef void (*BitIterator)(Bloomfilter * bf,
- unsigned int bit,
- void * arg);
-
+ unsigned int bit,
+ void * arg);
+
/**
* Call an iterator for each bit that the bloomfilter
* must test or set for this element.
@@ -311,9 +311,9 @@
* @param key the key for which we iterate over the BF bits
*/
static void iterateBits(Bloomfilter * bf,
- BitIterator callback,
- void * arg,
- const HashCode512 * key) {
+ BitIterator callback,
+ void * arg,
+ const HashCode512 * key) {
HashCode512 tmp[2];
int bitCount;
int round;
@@ -321,23 +321,23 @@
bitCount = bf->addressesPerElement;
memcpy(&tmp[0],
- key,
- sizeof(HashCode512));
+ key,
+ sizeof(HashCode512));
round = 0;
while (bitCount > 0) {
while (slot < (sizeof(HashCode512)/sizeof(unsigned int))) {
callback(bf,
- (((unsigned int*)&tmp[round&1])[slot]) &
((bf->bitArraySize*8)-1),
- arg);
+ (((unsigned int*)&tmp[round&1])[slot]) & ((bf->bitArraySize*8)-1),
+ arg);
slot++;
bitCount--;
if (bitCount == 0)
- break;
+ break;
}
if (bitCount > 0) {
hash(&tmp[round & 1],
- sizeof(HashCode512),
- &tmp[(round+1) & 1]);
+ sizeof(HashCode512),
+ &tmp[(round+1) & 1]);
round++;
slot = 0;
}
@@ -352,11 +352,11 @@
* @param arg not used
*/
static void incrementBitCallback(Bloomfilter * bf,
- unsigned int bit,
- void * arg) {
+ unsigned int bit,
+ void * arg) {
incrementBit(bf->bitArray,
- bit,
- bf->fd);
+ bit,
+ bf->fd);
}
/**
@@ -367,11 +367,11 @@
* @param arg not used
*/
static void decrementBitCallback(Bloomfilter * bf,
- unsigned int bit,
- void * arg) {
+ unsigned int bit,
+ void * arg) {
decrementBit(bf->bitArray,
- bit,
- bf->fd);
+ bit,
+ bf->fd);
}
/**
@@ -382,11 +382,11 @@
* @param arg pointer set to NO if bit is not set
*/
static void testBitCallback(Bloomfilter * bf,
- unsigned int bit,
- void * cls) {
+ unsigned int bit,
+ void * cls) {
int * arg = cls;
if (NO == testBit(bf->bitArray,
- bit))
+ bit))
*arg = NO;
}
@@ -403,9 +403,9 @@
* @return the bloomfilter
*/
Bloomfilter * loadBloomfilter(struct GE_Context * ectx,
- const char * filename,
- unsigned int size,
- unsigned int k) {
+ const char * filename,
+ unsigned int size,
+ unsigned int k) {
Bloomfilter * bf;
char * rbuff;
unsigned int pos;
@@ -428,14 +428,14 @@
if (filename != NULL) {
#ifndef _MSC_VER
bf->fd = disk_file_open(ectx,
- filename,
- O_RDWR|O_CREAT,
- S_IRUSR|S_IWUSR);
+ filename,
+ O_RDWR|O_CREAT,
+ S_IRUSR|S_IWUSR);
#else
bf->fd = disk_file_open(ectx,
- filename,
- O_WRONLY|O_CREAT,
- S_IREAD|S_IWRITE);
+ filename,
+ O_WRONLY|O_CREAT,
+ S_IREAD|S_IWRITE);
#endif
if (-1 == bf->fd) {
FREE(bf);
@@ -452,8 +452,8 @@
bf->bitArraySize = size;
bf->addressesPerElement = k;
memset(bf->bitArray,
- 0,
- bf->bitArraySize);
+ 0,
+ bf->bitArraySize);
if (bf->fd != -1) {
/* Read from the file what bits we can */
@@ -463,20 +463,20 @@
int res;
res = READ(bf->fd,
- rbuff,
- BUFFSIZE);
+ rbuff,
+ BUFFSIZE);
if (res == 0)
- break; /* is ok! we just did not use that many bits yet */
+ break; /* is ok! we just did not use that many bits yet */
for (i=0;i<res;i++) {
- if ( (rbuff[i] & 0x0F) != 0)
- setBit(bf->bitArray,
- pos + i*2);
- if ( (rbuff[i] & 0xF0) != 0)
- setBit(bf->bitArray,
- pos + i*2 + 1);
+ if ( (rbuff[i] & 0x0F) != 0)
+ setBit(bf->bitArray,
+ pos + i*2);
+ if ( (rbuff[i] & 0xF0) != 0)
+ setBit(bf->bitArray,
+ pos + i*2 + 1);
}
if (res < BUFFSIZE)
- break;
+ break;
pos += BUFFSIZE * 2; /* 2 bits per byte in the buffer */
}
FREE(rbuff);
@@ -497,8 +497,8 @@
MUTEX_DESTROY(bf->lock);
if (bf->fd != -1)
disk_file_close(bf->ectx,
- bf->filename,
- bf->fd);
+ bf->filename,
+ bf->fd);
FREENONNULL(bf->filename);
FREE(bf->bitArray);
FREE(bf);
@@ -515,11 +515,11 @@
MUTEX_LOCK(bf->lock);
memset(bf->bitArray,
- 0,
- bf->bitArraySize);
+ 0,
+ bf->bitArraySize);
if (bf->fd != -1)
makeEmptyFile(bf->fd,
- bf->bitArraySize * 4);
+ bf->bitArraySize * 4);
MUTEX_UNLOCK(bf->lock);
}
@@ -532,7 +532,7 @@
* @return YES if the element is in the filter, NO if not
*/
int testBloomfilter(Bloomfilter * bf,
- const HashCode512 * e) {
+ const HashCode512 * e) {
int res;
if (NULL == bf)
@@ -540,9 +540,9 @@
MUTEX_LOCK(bf->lock);
res = YES;
iterateBits(bf,
- &testBitCallback,
- &res,
- e);
+ &testBitCallback,
+ &res,
+ e);
MUTEX_UNLOCK(bf->lock);
return res;
}
@@ -554,15 +554,15 @@
* @param e the element
*/
void addToBloomfilter(Bloomfilter * bf,
- const HashCode512 * e) {
+ const HashCode512 * e) {
if (NULL == bf)
return;
MUTEX_LOCK(bf->lock);
iterateBits(bf,
- &incrementBitCallback,
- NULL,
- e);
+ &incrementBitCallback,
+ NULL,
+ e);
MUTEX_UNLOCK(bf->lock);
}
@@ -573,14 +573,14 @@
* @param e the element to remove
*/
void delFromBloomfilter(Bloomfilter * bf,
- const HashCode512 * e) {
+ const HashCode512 * e) {
if(NULL == bf)
return;
MUTEX_LOCK(bf->lock);
iterateBits(bf,
- &decrementBitCallback,
- NULL,
- e);
+ &decrementBitCallback,
+ NULL,
+ e);
MUTEX_UNLOCK(bf->lock);
}
@@ -596,10 +596,10 @@
* @param k the new number of hash-function to apply per element
*/
void resizeBloomfilter(Bloomfilter * bf,
- ElementIterator iterator,
- void * iterator_arg,
- unsigned int size,
- unsigned int k) {
+ ElementIterator iterator,
+ void * iterator_arg,
+ unsigned int size,
+ unsigned int k) {
HashCode512 * e;
unsigned int i;
@@ -613,15 +613,15 @@
bf->bitArraySize = size;
bf->bitArray = MALLOC(size);
memset(bf->bitArray,
- 0,
- bf->bitArraySize);
+ 0,
+ bf->bitArraySize);
if (bf->fd != -1)
makeEmptyFile(bf->fd,
- bf->bitArraySize * 4);
+ bf->bitArraySize * 4);
e = iterator(iterator_arg);
while (e != NULL) {
addToBloomfilter(bf,
- e);
+ e);
FREE(e);
e = iterator(iterator_arg);
}
Modified: GNUnet/src/util/containers/bloomtest.c
===================================================================
--- GNUnet/src/util/containers/bloomtest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/containers/bloomtest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -48,9 +48,9 @@
srand(1);
UNLINK("/tmp/bloomtest.dat");
bf = loadBloomfilter(NULL,
- "/tmp/bloomtest.dat",
- SIZE,
- K);
+ "/tmp/bloomtest.dat",
+ SIZE,
+ K);
for(i=0;i<200;i++) {
nextHC(&tmp);
@@ -65,17 +65,17 @@
}
if (ok != 200) {
printf(" Got %d elements out of"
- "200 expected after insertion.\n",
- ok);
+ "200 expected after insertion.\n",
+ ok);
return -1;
}
freeBloomfilter(bf);
bf=loadBloomfilter(NULL,
- "/tmp/bloomtest.dat",
- SIZE,
- K);
+ "/tmp/bloomtest.dat",
+ SIZE,
+ K);
srand(1);
ok=0;
@@ -86,8 +86,8 @@
}
if (ok != 200) {
printf(" Got %d elements out of 200"
- "expected after reloading.\n",
- ok);
+ "expected after reloading.\n",
+ ok);
return -1;
}
@@ -108,8 +108,8 @@
if (ok != 100) {
printf(" Expected 100 elements in filter"
- " after adding 200 and deleting 100, got %d\n",
- ok);
+ " after adding 200 and deleting 100, got %d\n",
+ ok);
return -1;
}
Modified: GNUnet/src/util/containers/hashtable.c
===================================================================
--- GNUnet/src/util/containers/hashtable.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/containers/hashtable.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -148,7 +148,7 @@
for (i=0; i < hashTable->numOfBuckets; i++) {
KeyValuePair *pair = hashTable->bucketArray[i];
while (pair != NULL) {
- KeyValuePair *nextPair = pair->next;
+ KeyValuePair *nextPair = pair->next;
FREE(pair->key);
FREE(pair->value);
FREE(pair);
@@ -168,8 +168,8 @@
* specified key
*/
int ht_containsKey(const struct HashTable *hashTable,
- const void *key,
- const unsigned int keylen) {
+ const void *key,
+ const unsigned int keylen) {
void *ret;
unsigned int retlen;
@@ -184,15 +184,15 @@
* specified value
*/
int ht_containsValue(const struct HashTable *hashTable,
- const void *value,
- const unsigned int valuelen) {
+ const void *value,
+ const unsigned int valuelen) {
int i;
for (i=0; i<hashTable->numOfBuckets; i++) {
KeyValuePair *pair = hashTable->bucketArray[i];
while (pair != NULL) {
- if ( (pair->valuelen == valuelen) &&
- (memcmp(value, pair->value, valuelen) == 0) )
+ if ( (pair->valuelen == valuelen) &&
+ (memcmp(value, pair->value, valuelen) == 0) )
return 1;
pair = pair->next;
}
@@ -209,10 +209,10 @@
* @return YES if successful, NO if an error was encountered
*/
int ht_put(struct HashTable *hashTable,
- const void *key,
- const unsigned int keylen,
- void *value,
- const unsigned int valuelen) {
+ const void *key,
+ const unsigned int keylen,
+ void *value,
+ const unsigned int valuelen) {
long hashValue;
KeyValuePair *pair;
@@ -271,10 +271,10 @@
* @return YES if found, NO otherwise
*/
int ht_get(const struct HashTable *hashTable,
- const void *key,
- const unsigned int keylen,
- void **value,
- unsigned int *valuelen) {
+ const void *key,
+ const unsigned int keylen,
+ void **value,
+ unsigned int *valuelen) {
long hashValue = weakHash(key, keylen) % hashTable->numOfBuckets;
KeyValuePair *pair = hashTable->bucketArray[hashValue];
@@ -296,8 +296,8 @@
* @param key the key specifying the key/value pair to be removed
*/
void ht_remove(struct HashTable *hashTable,
- const void *key,
- const unsigned int keylen) {
+ const void *key,
+ const unsigned int keylen) {
long hashValue = weakHash(key, keylen) % hashTable->numOfBuckets;
KeyValuePair *pair = hashTable->bucketArray[hashValue];
KeyValuePair *previousPair = NULL;
@@ -446,9 +446,9 @@
* be specified.
*/
void ht_setIdealRatio(struct HashTable *hashTable,
- float idealRatio,
- float lowerRehashThreshold,
- float upperRehashThreshold) {
+ float idealRatio,
+ float lowerRehashThreshold,
+ float upperRehashThreshold) {
if (idealRatio <= 0.0 || lowerRehashThreshold >= idealRatio ||
(upperRehashThreshold != 0.0 || upperRehashThreshold <= idealRatio))
Modified: GNUnet/src/util/containers/hashtest.c
===================================================================
--- GNUnet/src/util/containers/hashtest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/containers/hashtest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -10,7 +10,7 @@
* Perform option parsing from the command line.
*/
static int parseCommandLine(int argc,
- char * argv[]) {
+ char * argv[]) {
return OK;
}
@@ -25,11 +25,11 @@
(hc.bits[3] != ntohl(-234043098)) ||
(hc.bits[4] != ntohl(-182141268)) ) {
printf("Hash of TEST wrong (%d, %d, %d, %d, %d).\n",
- ntohl(hc.bits[0]),
- ntohl(hc.bits[1]),
- ntohl(hc.bits[2]),
- ntohl(hc.bits[3]),
- ntohl(hc.bits[4]));
+ ntohl(hc.bits[0]),
+ ntohl(hc.bits[1]),
+ ntohl(hc.bits[2]),
+ ntohl(hc.bits[3]),
+ ntohl(hc.bits[4]));
return -1;
}
hash(NULL, 0, &hc);
@@ -39,11 +39,11 @@
(hc.bits[3] != ntohl(-697466873)) ||
(hc.bits[4] != ntohl(-702487547)) ) {
printf("Hash of nothing (0-size) wrong (%d, %d, %d, %d, %d).\n",
- ntohl(hc.bits[0]),
- ntohl(hc.bits[1]),
- ntohl(hc.bits[2]),
- ntohl(hc.bits[3]),
- ntohl(hc.bits[4]));
+ ntohl(hc.bits[0]),
+ ntohl(hc.bits[1]),
+ ntohl(hc.bits[2]),
+ ntohl(hc.bits[3]),
+ ntohl(hc.bits[4]));
return -1;
}
doneUtil();
Modified: GNUnet/src/util/containers/vector.c
===================================================================
--- GNUnet/src/util/containers/vector.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/containers/vector.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -71,22 +71,22 @@
for (vs = v->segmentsHead; vs; vs = vs->next) {
fprintf(stderr,
- "Segment-size: %3llu / %llu [%llu...%llu]: ",
- (unsigned long long) vs->size,
- (unsigned long long) v->VECTOR_SEGMENT_SIZE,
- (unsigned long long) sum,
- (unsigned long long) (sum + vs->size - 1));
+ "Segment-size: %3llu / %llu [%llu...%llu]: ",
+ (unsigned long long) vs->size,
+ (unsigned long long) v->VECTOR_SEGMENT_SIZE,
+ (unsigned long long) sum,
+ (unsigned long long) (sum + vs->size - 1));
for (n=0;n<vs->size;n++) {
fprintf(stderr,
- "%p, ",
- vs->data[n]);
+ "%p, ",
+ vs->data[n]);
}
fprintf(stderr, "\n");
sum += vs->size;
}
fprintf(stderr,
- "Vector size: %u\n",
- sum);
+ "Vector size: %u\n",
+ sum);
}
/**
@@ -94,7 +94,7 @@
* trailing pointers in the array, if any, are moved backwards to fill the gap.
*/
static void *vectorSegmentRemoveAtIndex(VectorSegment *vs,
- int index) {
+ int index) {
void *rvalue = vs->data[index];
while (index < vs->size) {
@@ -109,7 +109,7 @@
* Split the full segment vs into two half-full segments.
*/
static void vectorSegmentSplit(Vector *v,
- VectorSegment *vs) {
+ VectorSegment *vs) {
VectorSegment *oldNext;
int moveCount;
@@ -124,8 +124,8 @@
v->segmentsTail = vs->next;
moveCount = vs->size / 2;
memcpy(vs->next->data,
- vs->data + (vs->size - moveCount),
- moveCount * sizeof (void *));
+ vs->data + (vs->size - moveCount),
+ moveCount * sizeof (void *));
vs->next->size = moveCount;
vs->size -= moveCount;
}
@@ -135,12 +135,12 @@
* be empty enough to store the data of both segments.
*/
static void vectorSegmentJoin(Vector *v,
- VectorSegment *vs) {
+ VectorSegment *vs) {
VectorSegment *oldNext = vs->next->next;
memcpy(vs->data + vs->size,
- vs->next->data,
- vs->next->size * sizeof (void *));
+ vs->next->data,
+ vs->next->size * sizeof (void *));
vs->size += vs->next->size;
FREE(vs->next->data);
FREE(vs->next);
@@ -155,7 +155,7 @@
* Free an empty segment, _unless_ it is the only segment.
*/
static void vectorSegmentRemove(Vector *v,
- VectorSegment *vs) {
+ VectorSegment *vs) {
if ( (vs->previous == NULL) &&
(vs->next == NULL) )
return;
@@ -179,8 +179,8 @@
* is also a requirement for adding data in an empty vector.
*/
static int vectorFindNewIndex(Vector * v,
- unsigned int index,
- VectorSegment **vs) {
+ unsigned int index,
+ VectorSegment **vs) {
VectorSegment *segment;
int segmentStartIndex;
@@ -213,8 +213,8 @@
* with the given index.
*/
static int vectorFindIndex(Vector *v,
- unsigned int index,
- VectorSegment **vs) {
+ unsigned int index,
+ VectorSegment **vs) {
VectorSegment *segment;
int segmentStartIndex;
@@ -249,9 +249,9 @@
* not found, *vs is set to NULL.
*/
static void vectorFindObject(Vector *v,
- void *object,
- VectorSegment **vs,
- int *segmentIndex) {
+ void *object,
+ VectorSegment **vs,
+ int *segmentIndex) {
VectorSegment *segment;
int i;
@@ -259,9 +259,9 @@
while (NULL != segment) {
for (i=0;i<segment->size;i++) {
if (segment->data[i] == object) {
- *vs = segment;
- *segmentIndex = i;
- return;
+ *vs = segment;
+ *segmentIndex = i;
+ return;
}
}
segment = segment->next;
@@ -323,8 +323,8 @@
* OK on success, SYSERR if the index is out of bounds.
*/
int vectorInsertAt(Vector *v,
- void *object,
- unsigned int index) {
+ void *object,
+ unsigned int index) {
VectorSegment *segment;
int segmentIndex;
int i;
@@ -361,13 +361,13 @@
* of bounds. The iterator is set to point to the returned element.
*/
void * vectorGetAt(Vector *v,
- unsigned int index) {
+ unsigned int index) {
int ret;
if ( (index < 0) || (index >= v->size) )
return NULL;
ret = vectorFindIndex(v,
- index,
- &v->iteratorSegment);
+ index,
+ &v->iteratorSegment);
if (ret == -1)
return NULL;
v->iteratorIndex = ret;
@@ -444,7 +444,7 @@
* out of bounds.
*/
void * vectorRemoveAt(Vector *v,
- unsigned int index) {
+ unsigned int index) {
VectorSegment * segment;
int segmentIndex;
void *rvalue;
@@ -456,16 +456,16 @@
if (segmentIndex == -1)
return NULL;
rvalue = vectorSegmentRemoveAtIndex(segment,
- segmentIndex);
+ segmentIndex);
/* If the segment ends empty remove it, otherwise
try to join it with its neighbors. */
if (--segment->size == 0)
vectorSegmentRemove(v, segment);
else if (segment->next &&
- segment->size + segment->next->size < v->VECTOR_SEGMENT_SIZE)
+ segment->size + segment->next->size < v->VECTOR_SEGMENT_SIZE)
vectorSegmentJoin(v, segment);
else if (segment->previous &&
- segment->size + segment->previous->size < v->VECTOR_SEGMENT_SIZE)
+ segment->size + segment->previous->size < v->VECTOR_SEGMENT_SIZE)
vectorSegmentJoin(v, segment->previous);
v->size--;
return rvalue;
@@ -486,8 +486,8 @@
if (--v->segmentsTail->size == 0)
vectorSegmentRemove(v, v->segmentsTail);
else if ( (v->segmentsTail->previous != NULL) &&
- (v->segmentsTail->size + v->segmentsTail->previous->size
- < v->VECTOR_SEGMENT_SIZE) )
+ (v->segmentsTail->size + v->segmentsTail->previous->size
+ < v->VECTOR_SEGMENT_SIZE) )
vectorSegmentJoin (v, v->segmentsTail->previous);
v->size--;
return rvalue;
@@ -511,10 +511,10 @@
if (--segment->size == 0)
vectorSegmentRemove (v, segment);
else if ( (segment->next != NULL) &&
- (segment->size + segment->next->size < v->VECTOR_SEGMENT_SIZE) )
+ (segment->size + segment->next->size < v->VECTOR_SEGMENT_SIZE) )
vectorSegmentJoin (v, segment);
else if ( (segment->previous != NULL) &&
- (segment->size + segment->previous->size < v->VECTOR_SEGMENT_SIZE) )
+ (segment->size + segment->previous->size < v->VECTOR_SEGMENT_SIZE) )
vectorSegmentJoin (v, segment->previous);
v->size--;
return rvalue;
@@ -525,8 +525,8 @@
* returned, or NULL if the index is out of bounds.
*/
void *vectorSetAt (Vector *v,
- void *object,
- unsigned int index) {
+ void *object,
+ unsigned int index) {
VectorSegment *segment;
int segmentIndex;
void *rvalue;
@@ -548,8 +548,8 @@
* The old object is returned, or NULL if it's not found.
*/
void *vectorSetObject(Vector *v,
- void *object,
- void *oldObject) {
+ void *object,
+ void *oldObject) {
VectorSegment *segment;
int segmentIndex;
void *rvalue;
@@ -569,8 +569,8 @@
* on success, SYSERR if either index is out of bounds.
*/
int vectorSwap(Vector *v,
- unsigned int index1,
- unsigned int index2) {
+ unsigned int index1,
+ unsigned int index2) {
VectorSegment * segment1;
VectorSegment * segment2;
int segmentIndex1;
@@ -596,7 +596,7 @@
* Return the index of given element or -1 if the element is not found.
*/
unsigned int vectorIndexOf(Vector *v,
- void *object) {
+ void *object) {
VectorSegment * segment;
unsigned int i;
unsigned int segmentStartIndex;
@@ -606,7 +606,7 @@
while (NULL != segment) {
for (i = 0; i < segment->size; i++)
if (segment->data[i] == object)
- return segmentStartIndex + i;
+ return segmentStartIndex + i;
segmentStartIndex += segment->size;
segment = segment->next;
}
@@ -628,8 +628,8 @@
rvalue = MALLOC_LARGE(v->size * sizeof (void *));
for (vs = v->segmentsHead; vs; vs = vs->next) {
memcpy (rvalue + i,
- vs->data,
- vs->size * sizeof (void *));
+ vs->data,
+ vs->size * sizeof (void *));
i += vs->size;
}
return rvalue;
Modified: GNUnet/src/util/containers/vectortest.c
===================================================================
--- GNUnet/src/util/containers/vectortest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/containers/vectortest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -116,7 +116,7 @@
int main(int argc,
- char * argv[]) {
+ char * argv[]) {
if (NULL != vectorNew(0))
{ printf("At %d\n", __LINE__); return 1; }
if (NULL != vectorNew(1))
Modified: GNUnet/src/util/cron/cron.c
===================================================================
--- GNUnet/src/util/cron/cron.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/cron/cron.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -204,8 +204,8 @@
static void noJob(void * unused) {
#if DEBUG_CRON
GE_LOG(NULL,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "In noJob.\n");
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "In noJob.\n");
#endif
}
@@ -214,23 +214,23 @@
#if DEBUG_CRON
GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "Stopping cron\n");
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "Stopping cron\n");
#endif
cron->cron_shutdown = YES;
cron_add_job(cron,
- &noJob,
- 0,
- 0,
- NULL);
+ &noJob,
+ 0,
+ 0,
+ NULL);
SEMAPHORE_DOWN(cron->cron_signal, YES);
SEMAPHORE_DESTROY(cron->cron_signal);
cron->cron_signal = NULL;
PTHREAD_JOIN(cron->cron_handle, &unused);
#if DEBUG_CRON
GE_LOG(NULL,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "Cron stopped\n");
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "Cron stopped\n");
#endif
}
@@ -253,9 +253,9 @@
MUTEX_UNLOCK(cron->inBlockLock_);
}
}
-
+
void cron_suspend(struct CronManager * cron,
- int checkSelf) {
+ int checkSelf) {
if ( (YES == checkSelf) &&
(cron->cron_shutdown == NO) &&
(NO != PTHREAD_TEST_SELF(cron->cron_handle)) )
@@ -266,10 +266,10 @@
if (cron->inBlock == 1) {
cron->sig = SEMAPHORE_CREATE(0);
cron_add_job(cron,
- &block,
- 0,
- 0,
- cron);
+ &block,
+ 0,
+ 0,
+ cron);
SEMAPHORE_DOWN(cron->sig, YES);
SEMAPHORE_DESTROY(cron->sig);
cron->sig = NULL;
@@ -285,7 +285,7 @@
}
void cron_resume_jobs(struct CronManager * cron,
- int checkSelf) {
+ int checkSelf) {
if ( (YES == checkSelf) &&
(cron->cron_shutdown == NO) &&
(NO != PTHREAD_TEST_SELF(cron->cron_handle)) )
@@ -317,12 +317,12 @@
while (jobId != -1) {
tab = &cron->deltaList_[jobId];
GE_LOG(NULL,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "%3u: delta %8lld CU --- method %p --- repeat %8u CU\n",
- jobId,
- tab->delta - now,
- (int)tab->method,
- tab->deltaRepeat);
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "%3u: delta %8lld CU --- method %p --- repeat %8u CU\n",
+ jobId,
+ tab->delta - now,
+ (int)tab->method,
+ tab->deltaRepeat);
jobId = tab->next;
}
MUTEX_UNLOCK(cron->deltaListLock_);
@@ -330,19 +330,19 @@
#endif
void cron_advance_job(struct CronManager * cron,
- CronJob method,
- unsigned int deltaRepeat,
- void * data) {
+ CronJob method,
+ unsigned int deltaRepeat,
+ void * data) {
UTIL_cron_DeltaListEntry * job;
UTIL_cron_DeltaListEntry * last;
int jobId;
#if DEBUG_CRON
GE_LOG(NULL,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "Advancing job %p-%p\n",
- method,
- data);
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "Advancing job %p-%p\n",
+ method,
+ data);
#endif
MUTEX_LOCK(cron->deltaListLock_);
jobId = cron->firstUsed_;
@@ -354,19 +354,19 @@
last = NULL;
job = &cron->deltaList_[jobId];
while ( (job->method != method) ||
- (job->data != data) ||
- (job->deltaRepeat != deltaRepeat) ) {
+ (job->data != data) ||
+ (job->deltaRepeat != deltaRepeat) ) {
last = job;
if (job->next == -1) {
/* not in queue; add if not running */
if ( (method != cron->runningJob_) ||
- (data != cron->runningData_) ||
- (deltaRepeat != cron->runningRepeat_) ) {
- cron_add_job(cron,
- method,
- 0,
- deltaRepeat,
- data);
+ (data != cron->runningData_) ||
+ (deltaRepeat != cron->runningRepeat_) ) {
+ cron_add_job(cron,
+ method,
+ 0,
+ deltaRepeat,
+ data);
}
MUTEX_UNLOCK(cron->deltaListLock_);
return;
@@ -376,22 +376,22 @@
}
/* ok, found it; remove, re-add with time 0 */
cron_del_job(cron,
- method,
- deltaRepeat,
- data);
+ method,
+ deltaRepeat,
+ data);
cron_add_job(cron,
- method,
- 0,
- deltaRepeat,
- data);
+ method,
+ 0,
+ deltaRepeat,
+ data);
MUTEX_UNLOCK(cron->deltaListLock_);
}
void cron_add_job(struct CronManager * cron,
- CronJob method,
- unsigned int delta,
- unsigned int deltaRepeat,
- void * data) {
+ CronJob method,
+ unsigned int delta,
+ unsigned int deltaRepeat,
+ void * data) {
UTIL_cron_DeltaListEntry * entry;
UTIL_cron_DeltaListEntry * pos;
int last;
@@ -399,11 +399,11 @@
#if DEBUG_CRON
GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "Adding job %p-%p to fire in %d CU\n",
- method,
- data,
- delta);
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "Adding job %p-%p to fire in %d CU\n",
+ method,
+ data,
+ delta);
#endif
MUTEX_LOCK(cron->deltaListLock_);
@@ -411,8 +411,8 @@
unsigned int i;
GROW(cron->deltaList_,
- cron->deltaListSize_,
- cron->deltaListSize_ * 2);
+ cron->deltaListSize_,
+ cron->deltaListSize_ * 2);
for (i=cron->deltaListSize_/2;i<cron->deltaListSize_;i++)
cron->deltaList_[i].next = i-1;
cron->deltaList_[cron->deltaListSize_/2].next = -1;
@@ -447,7 +447,7 @@
} else { /* append */
pos->next = cron->firstFree_;
cron->firstFree_
- = entry->next;
+ = entry->next;
entry->next = -1;
MUTEX_UNLOCK(cron->deltaListLock_);
#if HAVE_PRINT_CRON_TAB
@@ -508,35 +508,35 @@
if (repeat > 0) {
#if DEBUG_CRON
GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "adding periodic job %p-%p to run again in %u\n",
- method,
- data,
- repeat);
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "adding periodic job %p-%p to run again in %u\n",
+ method,
+ data,
+ repeat);
#endif
cron_add_job(cron,
- method,
- repeat,
- repeat,
- data);
+ method,
+ repeat,
+ repeat,
+ data);
}
/* run */
#if DEBUG_CRON
GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "running job %p-%p\n",
- method,
- data);
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "running job %p-%p\n",
+ method,
+ data);
#endif
method(data);
MUTEX_LOCK(cron->deltaListLock_);
cron->runningJob_ = NULL;
#if DEBUG_CRON
GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "job %p-%p done\n",
- method,
- data);
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "job %p-%p done\n",
+ method,
+ data);
#endif
}
@@ -556,36 +556,36 @@
next = now + 0xFFFFFFFF;
MUTEX_LOCK(cron->deltaListLock_);
while ( (cron->cron_shutdown == NO) &&
- (cron->firstUsed_ != -1) ) {
+ (cron->firstUsed_ != -1) ) {
now = get_time();
next = cron->deltaList_[cron->firstUsed_].delta;
if (next <= now) {
#if DEBUG_CRON
- GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "running cron job, table is\n");
- printCronTab(cron);
+ GE_LOG(cron->ectx,
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "running cron job, table is\n");
+ printCronTab(cron);
#endif
- runJob(cron);
+ runJob(cron);
#if DEBUG_CRON
- GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "job run, new table is\n");
- printCronTab(cron);
+ GE_LOG(cron->ectx,
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "job run, new table is\n");
+ printCronTab(cron);
#endif
} else
- break;
+ break;
}
MUTEX_UNLOCK(cron->deltaListLock_);
next = next - now; /* how long to sleep */
#if DEBUG_CRON
GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "Sleeping at %llu for %llu CU (%llu s, %llu CU)\n",
- now,
- next,
- next / cronSECONDS,
- next);
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "Sleeping at %llu for %llu CU (%llu s, %llu CU)\n",
+ now,
+ next,
+ next / cronSECONDS,
+ next);
#endif
if (next > MAXSLEEP)
next = MAXSLEEP;
@@ -593,17 +593,17 @@
PTHREAD_SLEEP(next);
#if DEBUG_CRON
GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "woke up at %llu - %lld CS late\n",
- get_time(),
- get_time() - (now+next));
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "woke up at %llu - %lld CS late\n",
+ get_time(),
+ get_time() - (now+next));
#endif
}
SEMAPHORE_UP(cron->cron_signal);
#if DEBUG_CRON
GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "Cron thread exits.\n");
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "Cron thread exits.\n");
printCronTab(cron);
#endif
return NULL;
@@ -617,7 +617,7 @@
int i;
GE_ASSERT(cron->ectx,
- cron->cron_signal == NULL);
+ cron->cron_signal == NULL);
i = cron->firstUsed_;
while (i != -1) {
FREENONNULL(cron->deltaList_[i].data);
@@ -635,34 +635,34 @@
*/
void cron_start(struct CronManager * cron) {
GE_ASSERT(cron->ectx,
- cron->cron_signal == NULL);
+ cron->cron_signal == NULL);
cron->cron_shutdown = NO;
cron->cron_signal = SEMAPHORE_CREATE(0);
/* large stack, we don't know for sure
what the cron jobs may be doing */
cron->cron_handle = PTHREAD_CREATE(&cron_main_method,
- cron,
- 256 * 1024);
+ cron,
+ 256 * 1024);
if (cron->cron_handle == 0)
GE_DIE_STRERROR(cron->ectx,
- GE_FATAL | GE_ADMIN | GE_USER | GE_BULK,
- "pthread_create");
+ GE_FATAL | GE_ADMIN | GE_USER | GE_BULK,
+ "pthread_create");
}
int cron_del_job(struct CronManager * cron,
- CronJob method,
- unsigned int repeat,
- void * data) {
+ CronJob method,
+ unsigned int repeat,
+ void * data) {
UTIL_cron_DeltaListEntry * job;
UTIL_cron_DeltaListEntry * last;
int jobId;
#if DEBUG_CRON
GE_LOG(cron->ectx,
- GE_STATUS | GE_DEVELOPER | GE_BULK,
- "deleting job %p-%p\n",
- method,
- data);
+ GE_STATUS | GE_DEVELOPER | GE_BULK,
+ "deleting job %p-%p\n",
+ method,
+ data);
#endif
MUTEX_LOCK(cron->deltaListLock_);
jobId = cron->firstUsed_;
@@ -673,8 +673,8 @@
last = NULL;
job = &cron->deltaList_[jobId];
while ( (job->method != method) ||
- (job->data != data) ||
- (job->deltaRepeat != repeat) ) {
+ (job->data != data) ||
+ (job->deltaRepeat != repeat) ) {
last = job;
if (job->next == -1) {
MUTEX_UNLOCK(cron->deltaListLock_);
Modified: GNUnet/src/util/cron/crontest.c
===================================================================
--- GNUnet/src/util/cron/crontest.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/cron/crontest.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -52,11 +52,11 @@
global2 = -1;
global3 = -1;
cron_add_job(cron,
- &cronJob, cronSECONDS*1, cronSECONDS*1, NULL);
+ &cronJob, cronSECONDS*1, cronSECONDS*1, NULL);
cron_add_job(cron,
- &cronJob2, cronSECONDS*4, cronSECONDS*4, NULL);
+ &cronJob2, cronSECONDS*4, cronSECONDS*4, NULL);
cron_add_job(cron,
- &cronJob3, cronSECONDS*16, cronSECONDS*16, NULL);
+ &cronJob3, cronSECONDS*16, cronSECONDS*16, NULL);
for (i=0;i<10;i++) {
/* fprintf(stderr,"."); */
sleep(1);
@@ -74,29 +74,29 @@
}
}
cron_del_job(cron,
- &cronJob, cronSECONDS*1, NULL);
+ &cronJob, cronSECONDS*1, NULL);
cron_del_job(cron,
- &cronJob2, cronSECONDS*4, NULL);
+ &cronJob2, cronSECONDS*4, NULL);
cron_del_job(cron,
- &cronJob3, cronSECONDS*16, NULL);
+ &cronJob3, cronSECONDS*16, NULL);
return 0;
}
static void delJob(void * unused) {
cron_del_job(cron,
- &cronJob, 42, NULL);
+ &cronJob, 42, NULL);
}
static int testDelCron() {
global = 0;
cron_add_job(cron,
- &cronJob, cronSECONDS*1, 42, NULL);
+ &cronJob, cronSECONDS*1, 42, NULL);
cron_add_job(cron,
- &delJob, 500 * cronMILLIS, 0, NULL);
+ &delJob, 500 * cronMILLIS, 0, NULL);
PTHREAD_SLEEP(1 * cronSECONDS);
if (global != 0) {
fprintf(stderr,
- "cron job was supposed to be deleted, but ran anyway!\n");
+ "cron job was supposed to be deleted, but ran anyway!\n");
return 1;
}
return 0;
Modified: GNUnet/src/util/cron/timertest.c
===================================================================
--- GNUnet/src/util/cron/timertest.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/cron/timertest.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -49,10 +49,10 @@
for (i=50;i<MAXV2+50;i+=INCR2) {
last = get_time();
cron_add_job(cron,
- &semaphore_up,
- i * cronMILLIS,
- 0,
- sem);
+ &semaphore_up,
+ i * cronMILLIS,
+ 0,
+ sem);
SEMAPHORE_DOWN(sem, YES);
now = get_time();
if (now < last + i)
@@ -62,26 +62,26 @@
cumDelta += now;
#if VERBOSE
FPRINTF(stderr,
- "Sleep interrupted by signal within %llu ms of deadline (intended
delay: %d ms).\n",
- now,
- i);
+ "Sleep interrupted by signal within %llu ms of deadline (intended delay:
%d ms).\n",
+ now,
+ i);
#endif
}
FPRINTF(stdout,
- "Sleep interrupt precision is %llums. ",
- cumDelta / (MAXV2/INCR2) );
+ "Sleep interrupt precision is %llums. ",
+ cumDelta / (MAXV2/INCR2) );
if (cumDelta <= 10 * cronMILLIS * MAXV2 / INCR2)
fprintf(stdout,
- "Timer precision is excellent.\n");
+ "Timer precision is excellent.\n");
else if (cumDelta <= 50 * cronMILLIS * MAXV2 / INCR2) /* 50ms average
deviation */
fprintf(stdout,
- "Timer precision is good.\n");
+ "Timer precision is good.\n");
else if (cumDelta > 250 * cronMILLIS * MAXV2 / INCR2)
fprintf(stdout,
- "Timer precision is awful.\n");
+ "Timer precision is awful.\n");
else
fprintf(stdout,
- "Timer precision is acceptable.\n");
+ "Timer precision is acceptable.\n");
SEMAPHORE_DESTROY(sem);
return 0;
Modified: GNUnet/src/util/crypto/crc32.c
===================================================================
--- GNUnet/src/util/crypto/crc32.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/crypto/crc32.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -75,8 +75,8 @@
* property of detecting all burst errors of length 32 bits or less.
*/
static uLong crc32(uLong crc,
- const char *buf,
- size_t len) {
+ const char *buf,
+ size_t len) {
GE_ASSERT(NULL, crc_table[255] != 0);
crc ^= 0xffffffff;
while (len--)
Modified: GNUnet/src/util/crypto/hashing.c
===================================================================
--- GNUnet/src/util/crypto/hashing.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/crypto/hashing.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -43,19 +43,19 @@
};
static unsigned long long Ch(unsigned long long x,
- unsigned long long y,
- unsigned long long z) {
+ unsigned long long y,
+ unsigned long long z) {
return z ^ (x & (y ^ z));
}
static unsigned long long Maj(unsigned long long x,
- unsigned long long y,
- unsigned long long z) {
+ unsigned long long y,
+ unsigned long long z) {
return (x & y) | (z & (x | y));
}
static unsigned long long RORu64(unsigned long long x,
- unsigned long long y) {
+ unsigned long long y) {
return (x >> y) | (x << (64 - y));
}
@@ -138,7 +138,7 @@
static void
sha512_transform(unsigned long long *state,
- const unsigned char *input) {
+ const unsigned char *input) {
unsigned long long a, b, c, d, e, f, g, h, t1, t2;
unsigned long long W[80];
unsigned long long t0;
@@ -201,8 +201,8 @@
static void
sha512_update(struct sha512_ctx * sctx,
- const unsigned char *data,
- unsigned int len) {
+ const unsigned char *data,
+ unsigned int len) {
unsigned int i, index, part_len;
/* Compute number of bytes mod 128 */
@@ -212,7 +212,7 @@
if ((sctx->count[0] += (len << 3)) < (len << 3)) {
if ((sctx->count[1] += 1) < 1)
if ((sctx->count[2] += 1) < 1)
- sctx->count[3]++;
+ sctx->count[3]++;
sctx->count[1] += (len >> 29);
}
@@ -237,7 +237,7 @@
static void
sha512_final(struct sha512_ctx * sctx,
- unsigned char *hash) {
+ unsigned char *hash) {
static unsigned char padding[128] = { 0x80, };
unsigned int t;
@@ -304,8 +304,8 @@
* @param ret pointer to where to write the hashcode
*/
void hash(const void * block,
- unsigned int size,
- HashCode512 * ret) {
+ unsigned int size,
+ HashCode512 * ret) {
struct sha512_ctx ctx;
sha512_init(&ctx);
@@ -321,8 +321,8 @@
* @return OK on success, SYSERR on error
*/
int getFileHash(struct GE_Context * ectx,
- const char * filename,
- HashCode512 * ret) {
+ const char * filename,
+ HashCode512 * ret) {
unsigned char * buf;
unsigned long long len;
unsigned long long pos;
@@ -331,21 +331,21 @@
struct sha512_ctx ctx;
if (OK != disk_file_test(ectx,
- filename))
+ filename))
return SYSERR;
if (OK != disk_file_size(ectx,
- filename,
- &len,
- NO))
+ filename,
+ &len,
+ NO))
return SYSERR;
fh = disk_file_open(ectx,
- filename,
- O_RDONLY | O_LARGEFILE);
+ filename,
+ O_RDONLY | O_LARGEFILE);
if (fh == -1) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_REQUEST,
- "open",
- filename);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_REQUEST,
+ "open",
+ filename);
return SYSERR;
}
sha512_init(&ctx);
@@ -356,23 +356,23 @@
if (len - pos < delta)
delta = len-pos;
if (delta != READ(fh,
- buf,
- delta)) {
+ buf,
+ delta)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "read",
- filename);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "read",
+ filename);
if (0 != CLOSE(fh))
- GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "close",
- filename);
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "close",
+ filename);
FREE(buf);
return SYSERR;
}
sha512_update(&ctx,
- buf,
- delta);
+ buf,
+ delta);
if (pos + delta > pos)
pos += delta;
else
@@ -380,11 +380,11 @@
}
if (0 != CLOSE(fh))
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "close",
- filename);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "close",
+ filename);
sha512_final(&ctx,
- (unsigned char*) ret);
+ (unsigned char*) ret);
FREE(buf);
return OK;
}
@@ -417,7 +417,7 @@
* safely cast to char*, a '\0' termination is set).
*/
void hash2enc(const HashCode512 * block,
- EncName * result) {
+ EncName * result) {
unsigned int wpos;
unsigned int rpos;
unsigned int bits;
@@ -430,9 +430,9 @@
rpos = 0;
bits = 0;
while ( (rpos < sizeof(HashCode512)) ||
- (vbit > 0) ) {
+ (vbit > 0) ) {
if ( (rpos < sizeof(HashCode512)) &&
- (vbit < 5) ) {
+ (vbit < 5) ) {
bits = (bits << 8) | ((unsigned char*)block)[rpos++]; /* eat 8 more bits
*/
vbit += 8;
}
@@ -458,7 +458,7 @@
* @return OK on success, SYSERR if result has the wrong encoding
*/
int enc2hash(const char * enc,
- HashCode512 * result) {
+ HashCode512 * result) {
unsigned int rpos;
unsigned int wpos;
unsigned int bits;
@@ -477,7 +477,7 @@
vbit += 5;
if (vbit >= 8) {
((unsigned char*)result)[--wpos]
- = (unsigned char) bits;
+ = (unsigned char) bits;
bits >>= 8;
vbit -= 8;
}
@@ -497,7 +497,7 @@
* hashcode proximity.
*/
unsigned int distanceHashCode512(const HashCode512 * a,
- const HashCode512 * b) {
+ const HashCode512 * b) {
unsigned int x = (a->bits[1] - b->bits[1])>>16;
return ((x*x)>>16);
}
@@ -507,7 +507,7 @@
* @return 1 if they are equal, 0 if not.
*/
int equalsHashCode512(const HashCode512 * a,
- const HashCode512 * b) {
+ const HashCode512 * b) {
return (0 == memcmp(a,b,sizeof(HashCode512)));
}
@@ -518,24 +518,24 @@
}
void deltaId(const HashCode512 * a,
- const HashCode512 * b,
- HashCode512 * result) {
+ const HashCode512 * b,
+ HashCode512 * result) {
int i;
for (i=(sizeof(HashCode512)/sizeof(unsigned int))-1;i>=0;i--)
result->bits[i] = b->bits[i] - a->bits[i];
}
void addHashCodes(const HashCode512 * a,
- const HashCode512 * delta,
- HashCode512 * result) {
+ const HashCode512 * delta,
+ HashCode512 * result) {
int i;
for (i=(sizeof(HashCode512)/sizeof(unsigned int))-1;i>=0;i--)
result->bits[i] = delta->bits[i] + a->bits[i];
}
void xorHashCodes(const HashCode512 * a,
- const HashCode512 * b,
- HashCode512 * result) {
+ const HashCode512 * b,
+ HashCode512 * result) {
int i;
for (i=(sizeof(HashCode512)/sizeof(unsigned int))-1;i>=0;i--)
result->bits[i] = a->bits[i] ^ b->bits[i];
@@ -545,20 +545,20 @@
* Convert a hashcode into a key.
*/
void hashToKey(const HashCode512 * hc,
- SESSIONKEY * skey,
- INITVECTOR * iv) {
+ SESSIONKEY * skey,
+ INITVECTOR * iv) {
GE_ASSERT(NULL,
- sizeof(HashCode512) >=
- SESSIONKEY_LEN +
- sizeof(INITVECTOR));
+ sizeof(HashCode512) >=
+ SESSIONKEY_LEN +
+ sizeof(INITVECTOR));
memcpy(skey,
- hc,
- SESSIONKEY_LEN);
+ hc,
+ SESSIONKEY_LEN);
skey->crc32 = htonl(crc32N(skey,
- SESSIONKEY_LEN));
+ SESSIONKEY_LEN));
memcpy(iv,
- &((char *)hc)[SESSIONKEY_LEN],
- sizeof(INITVECTOR));
+ &((char *)hc)[SESSIONKEY_LEN],
+ sizeof(INITVECTOR));
}
/**
@@ -568,10 +568,10 @@
* @return Bit \a bit from hashcode \a code, -1 for invalid index
*/
int getHashCodeBit(const HashCode512 * code,
- unsigned int bit) {
+ unsigned int bit) {
if (bit >= 8 * sizeof(HashCode512)) {
GE_ASSERT(NULL,
- 0);
+ 0);
return -1; /* error */
}
return (((unsigned char*)code)[bit >> 3] & (1 << bit & 7)) > 0;
@@ -583,7 +583,7 @@
* @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
*/
int hashCodeCompare(const HashCode512 * h1,
- const HashCode512 * h2) {
+ const HashCode512 * h2) {
unsigned int * i1;
unsigned int * i2;
int i;
@@ -605,8 +605,8 @@
* @return -1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2.
*/
int hashCodeCompareDistance(const HashCode512 * h1,
- const HashCode512 * h2,
- const HashCode512 * target) {
+ const HashCode512 * h2,
+ const HashCode512 * target) {
int i;
unsigned int d1;
unsigned int d2;
Modified: GNUnet/src/util/crypto/hashingtest.c
===================================================================
--- GNUnet/src/util/crypto/hashingtest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/crypto/hashingtest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -34,8 +34,8 @@
EncName enc;
memset(&h1,
- number,
- sizeof(HashCode512));
+ number,
+ sizeof(HashCode512));
hash2enc(&h1, &enc);
if (OK != enc2hash((char*)&enc, &h2)) {
printf("enc2hash failed!\n");
Modified: GNUnet/src/util/crypto/hashperf.c
===================================================================
--- GNUnet/src/util/crypto/hashperf.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/crypto/hashperf.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -40,14 +40,14 @@
hash("foo", 3, &hc1);
for (i=0;i<1024;i++) {
hash(&hc1,
- sizeof(HashCode512),
- &hc2);
+ sizeof(HashCode512),
+ &hc2);
hash(&hc2,
- sizeof(HashCode512),
- &hc1);
+ sizeof(HashCode512),
+ &hc1);
hash(buf,
- 1024 * 64,
- &hc3);
+ 1024 * 64,
+ &hc3);
}
FREE(buf);
}
@@ -58,7 +58,7 @@
start = get_time();
perfHash();
printf("Hash perf took %llu ms\n",
- get_time() - start);
+ get_time() - start);
return 0;
}
Modified: GNUnet/src/util/crypto/hostkey_gcrypt.c
===================================================================
--- GNUnet/src/util/crypto/hostkey_gcrypt.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/crypto/hostkey_gcrypt.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -77,15 +77,15 @@
* first target-size bytes.
*/
static void adjust(unsigned char * buf,
- size_t size,
- size_t target) {
+ size_t size,
+ size_t target) {
if (size < target) {
memmove(&buf[target-size],
- buf,
- size);
+ buf,
+ size);
memset(buf,
- 0,
- target-size);
+ 0,
+ target-size);
}
}
@@ -100,25 +100,25 @@
lockGcrypt();
rc = gcry_sexp_build(&s_keyparam,
- NULL,
- "(genkey(rsa(nbits %d)(rsa-use-e 3:257)))",
- HOSTKEY_LEN);
+ NULL,
+ "(genkey(rsa(nbits %d)(rsa-use-e 3:257)))",
+ HOSTKEY_LEN);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_sexp_build",
- rc);
+ LOG_ERROR,
+ "gcry_sexp_build",
+ rc);
unlockGcrypt();
return NULL;
}
rc = gcry_pk_genkey(&s_key,
- s_keyparam);
+ s_keyparam);
gcry_sexp_release(s_keyparam);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_pk_genkey",
- rc);
+ LOG_ERROR,
+ "gcry_pk_genkey",
+ rc);
unlockGcrypt();
return NULL;
}
@@ -126,9 +126,9 @@
#if EXTRA_CHECKS
if ((rc=gcry_pk_testkey(s_key))) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_pk_testkey",
- rc);
+ LOG_ERROR,
+ "gcry_pk_testkey",
+ rc);
unlockGcrypt();
return NULL;
}
@@ -150,9 +150,9 @@
}
static int key_from_sexp( gcry_mpi_t *array,
- gcry_sexp_t sexp,
- const char *topname,
- const char *elems ) {
+ gcry_sexp_t sexp,
+ const char *topname,
+ const char *elems ) {
gcry_sexp_t list, l2;
const char *s;
int i, idx;
@@ -176,8 +176,8 @@
l2 = gcry_sexp_find_token( list, s, 1 );
if( !l2 ) {
for(i=0; i<idx; i++) {
- gcry_free( array[i] );
- array[i] = NULL;
+ gcry_free( array[i] );
+ array[i] = NULL;
}
gcry_sexp_release ( list );
unlockGcrypt();
@@ -187,8 +187,8 @@
gcry_sexp_release ( l2 );
if( !array[idx] ) {
for(i=0; i<idx; i++) {
- gcry_free( array[i] );
- array[i] = NULL;
+ gcry_free( array[i] );
+ array[i] = NULL;
}
gcry_sexp_release ( list );
unlockGcrypt();
@@ -206,26 +206,26 @@
* @param result where to write the result.
*/
void getPublicKey(const struct PrivateKey * hostkey,
- PublicKey * result) {
+ PublicKey * result) {
gcry_mpi_t skey[2];
size_t size;
int rc;
lockGcrypt();
rc = key_from_sexp(skey,
- hostkey->sexp,
- "public-key",
- "ne");
+ hostkey->sexp,
+ "public-key",
+ "ne");
if (rc)
rc = key_from_sexp(skey,
- hostkey->sexp,
- "private-key",
- "ne");
+ hostkey->sexp,
+ "private-key",
+ "ne");
if (rc)
rc = key_from_sexp(skey,
- hostkey->sexp,
- "rsa",
- "ne");
+ hostkey->sexp,
+ "rsa",
+ "ne");
if (rc)
DIE_GCRY(NULL, "key_from_sexp", rc);
@@ -234,24 +234,24 @@
result->padding = 0;
size = RSA_ENC_LEN;
rc = gcry_mpi_print(GCRYMPI_FMT_USG,
- &result->key[0],
- size,
- &size,
- skey[0]);
+ &result->key[0],
+ size,
+ &size,
+ skey[0]);
if (rc)
DIE_GCRY(NULL, "gcry_mpi_print", rc);
adjust(&result->key[0], size, RSA_ENC_LEN);
size = RSA_KEY_LEN - RSA_ENC_LEN;
rc = gcry_mpi_print(GCRYMPI_FMT_USG,
- &result->key[RSA_ENC_LEN],
- size,
- &size,
- skey[1]);
+ &result->key[RSA_ENC_LEN],
+ size,
+ &size,
+ skey[1]);
if (rc)
DIE_GCRY(NULL, "gcry_mpi_print", rc);
adjust(&result->key[RSA_ENC_LEN],
- size,
- RSA_KEY_LEN - RSA_ENC_LEN);
+ size,
+ RSA_KEY_LEN - RSA_ENC_LEN);
gcry_mpi_release(skey[0]);
gcry_mpi_release(skey[1]);
unlockGcrypt();
@@ -282,10 +282,10 @@
size = RSA_ENC_LEN;
lockGcrypt();
rc = gcry_mpi_scan(&n,
- GCRYMPI_FMT_USG,
- &publicKey->key[0],
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ &publicKey->key[0],
+ size,
+ &size);
if (rc) {
LOG_GCRY(NULL, LOG_ERROR, "gcry_mpi_scan", rc);
unlockGcrypt();
@@ -293,10 +293,10 @@
}
size = RSA_KEY_LEN - RSA_ENC_LEN;
rc = gcry_mpi_scan(&e,
- GCRYMPI_FMT_USG,
- &publicKey->key[RSA_ENC_LEN],
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ &publicKey->key[RSA_ENC_LEN],
+ size,
+ &size);
if (rc) {
LOG_GCRY(NULL, LOG_ERROR, "gcry_mpi_scan", rc);
gcry_mpi_release(n);
@@ -304,10 +304,10 @@
return NULL;
}
rc = gcry_sexp_build(&result,
- &erroff,
- "(public-key(rsa(n %m)(e %m)))",
- n,
- e);
+ &erroff,
+ "(public-key(rsa(n %m)(e %m)))",
+ n,
+ e);
gcry_mpi_release(n);
gcry_mpi_release(e);
if (rc) {
@@ -348,39 +348,39 @@
memset(pkv, 0, sizeof(gcry_mpi_t) * 6);
rc = key_from_sexp(pkv,
- hostkey->sexp,
- "private-key",
- "nedpqu");
+ hostkey->sexp,
+ "private-key",
+ "nedpqu");
if (rc)
rc = key_from_sexp(pkv,
- hostkey->sexp,
- "rsa",
- "nedpqu");
+ hostkey->sexp,
+ "rsa",
+ "nedpqu");
if (rc)
rc = key_from_sexp(pkv,
- hostkey->sexp,
- "private-key",
- "nedpq");
+ hostkey->sexp,
+ "private-key",
+ "nedpq");
if (rc)
rc = key_from_sexp(pkv,
- hostkey->sexp,
- "rsa",
- "nedpq");
+ hostkey->sexp,
+ "rsa",
+ "nedpq");
if (rc)
rc = key_from_sexp(pkv,
- hostkey->sexp,
- "private-key",
- "ned");
+ hostkey->sexp,
+ "private-key",
+ "ned");
if (rc)
rc = key_from_sexp(pkv,
- hostkey->sexp,
- "rsa",
- "ned");
+ hostkey->sexp,
+ "rsa",
+ "ned");
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "key_from_sexp",
- rc);
+ LOG_ERROR,
+ "key_from_sexp",
+ rc);
unlockGcrypt();
return NULL;
}
@@ -388,23 +388,23 @@
for (i=0;i<6;i++) {
if (pkv[i] != NULL) {
rc = gcry_mpi_aprint(GCRYMPI_FMT_USG,
- (unsigned char**) &pbu[i],
- &sizes[i],
- pkv[i]);
+ (unsigned char**) &pbu[i],
+ &sizes[i],
+ pkv[i]);
size += sizes[i];
if (rc) {
- LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_aprint",
- rc);
- while (i>0)
- if (pbu[i] != NULL)
- free(pbu[--i]);
- for (i=0;i<6;i++)
- if (pkv[i] != NULL)
- gcry_mpi_release(pkv[i]);
- unlockGcrypt();
- return NULL;
+ LOG_GCRY(NULL,
+ LOG_ERROR,
+ "gcry_mpi_aprint",
+ rc);
+ while (i>0)
+ if (pbu[i] != NULL)
+ free(pbu[--i]);
+ for (i=0;i<6;i++)
+ if (pkv[i] != NULL)
+ gcry_mpi_release(pkv[i]);
+ unlockGcrypt();
+ return NULL;
}
} else {
pbu[i] = NULL;
@@ -417,35 +417,35 @@
i = 0;
retval->sizen = htons(sizes[0]);
memcpy(&((char*)(&retval[1]))[i],
- pbu[0],
- sizes[0]);
+ pbu[0],
+ sizes[0]);
i += sizes[0];
retval->sizee = htons(sizes[1]);
memcpy(&((char*)(&retval[1]))[i],
- pbu[1],
- sizes[1]);
+ pbu[1],
+ sizes[1]);
i += sizes[1];
retval->sized = htons(sizes[2]);
memcpy(&((char*)(&retval[1]))[i],
- pbu[2],
- sizes[2]);
+ pbu[2],
+ sizes[2]);
i += sizes[2];
/* swap p and q! */
retval->sizep = htons(sizes[4]);
memcpy(&((char*)(&retval[1]))[i],
- pbu[4],
- sizes[4]);
+ pbu[4],
+ sizes[4]);
i += sizes[4];
retval->sizeq = htons(sizes[3]);
memcpy(&((char*)(&retval[1]))[i],
- pbu[3],
- sizes[3]);
+ pbu[3],
+ sizes[3]);
i += sizes[3];
retval->sizedmp1 = htons(0);
retval->sizedmq1 = htons(0);
memcpy(&((char*)(&retval[1]))[i],
- pbu[5],
- sizes[5]);
+ pbu[5],
+ sizes[5]);
for (i=0;i<6;i++) {
if (pkv[i] != NULL)
gcry_mpi_release(pkv[i]);
@@ -473,47 +473,47 @@
size = ntohs(encoding->sizen);
lockGcrypt();
rc = gcry_mpi_scan(&n,
- GCRYMPI_FMT_USG,
- &((const unsigned char*)(&encoding[1]))[pos],
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ &((const unsigned char*)(&encoding[1]))[pos],
+ size,
+ &size);
pos += ntohs(encoding->sizen);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_scan",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_scan",
+ rc);
unlockGcrypt();
return NULL;
}
size = ntohs(encoding->sizee);
rc = gcry_mpi_scan(&e,
- GCRYMPI_FMT_USG,
- &((const unsigned char*)(&encoding[1]))[pos],
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ &((const unsigned char*)(&encoding[1]))[pos],
+ size,
+ &size);
pos += ntohs(encoding->sizee);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_scan",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_scan",
+ rc);
gcry_mpi_release(n);
unlockGcrypt();
return NULL;
}
size = ntohs(encoding->sized);
rc = gcry_mpi_scan(&d,
- GCRYMPI_FMT_USG,
- &((const unsigned char*)(&encoding[1]))[pos],
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ &((const unsigned char*)(&encoding[1]))[pos],
+ size,
+ &size);
pos += ntohs(encoding->sized);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_scan",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_scan",
+ rc);
gcry_mpi_release(n);
gcry_mpi_release(e);
unlockGcrypt();
@@ -523,16 +523,16 @@
size = ntohs(encoding->sizep);
if (size > 0) {
rc = gcry_mpi_scan(&q,
- GCRYMPI_FMT_USG,
- &((const unsigned char*)(&encoding[1]))[pos],
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ &((const unsigned char*)(&encoding[1]))[pos],
+ size,
+ &size);
pos += ntohs(encoding->sizep);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_scan",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_scan",
+ rc);
gcry_mpi_release(n);
gcry_mpi_release(e);
gcry_mpi_release(d);
@@ -544,21 +544,21 @@
size = ntohs(encoding->sizeq);
if (size > 0) {
rc = gcry_mpi_scan(&p,
- GCRYMPI_FMT_USG,
- &((const unsigned char*)(&encoding[1]))[pos],
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ &((const unsigned char*)(&encoding[1]))[pos],
+ size,
+ &size);
pos += ntohs(encoding->sizeq);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_scan",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_scan",
+ rc);
gcry_mpi_release(n);
gcry_mpi_release(e);
gcry_mpi_release(d);
if (q != NULL)
- gcry_mpi_release(q);
+ gcry_mpi_release(q);
unlockGcrypt();
return NULL;
}
@@ -569,22 +569,22 @@
size = ntohs(encoding->len) - sizeof(PrivateKeyEncoded) - pos;
if (size > 0) {
rc = gcry_mpi_scan(&u,
- GCRYMPI_FMT_USG,
- &((const unsigned char*)(&encoding[1]))[pos],
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ &((const unsigned char*)(&encoding[1]))[pos],
+ size,
+ &size);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_scan",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_scan",
+ rc);
gcry_mpi_release(n);
gcry_mpi_release(e);
gcry_mpi_release(d);
if (p != NULL)
- gcry_mpi_release(p);
+ gcry_mpi_release(p);
if (q != NULL)
- gcry_mpi_release(q);
+ gcry_mpi_release(q);
unlockGcrypt();
return NULL;
}
@@ -595,21 +595,21 @@
(q != NULL) &&
(u != NULL) ) {
rc = gcry_sexp_build(&res,
- &size, /* erroff */
- "(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)(u
%m)))",
- n, e, d, p, q, u);
+ &size, /* erroff */
+ "(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)(u %m)))",
+ n, e, d, p, q, u);
} else {
if ( (p != NULL) &&
- (q != NULL) ) {
+ (q != NULL) ) {
rc = gcry_sexp_build(&res,
- &size, /* erroff */
- "(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)))",
- n, e, d, p, q);
+ &size, /* erroff */
+ "(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)))",
+ n, e, d, p, q);
} else {
rc = gcry_sexp_build(&res,
- &size, /* erroff */
- "(private-key(rsa(n %m)(e %m)(d %m)))",
- n, e, d);
+ &size, /* erroff */
+ "(private-key(rsa(n %m)(e %m)(d %m)))",
+ n, e, d);
}
}
gcry_mpi_release(n);
@@ -624,13 +624,13 @@
if (rc)
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_sexp_build", rc);
+ LOG_ERROR,
+ "gcry_sexp_build", rc);
#if EXTRA_CHECKS
if (gcry_pk_testkey(res)) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_pk_testkey", rc);
+ LOG_ERROR,
+ "gcry_pk_testkey", rc);
unlockGcrypt();
return NULL;
}
@@ -652,9 +652,9 @@
* @returns SYSERR on error, OK if ok
*/
int encryptPrivateKey(const void * block,
- unsigned short size,
- const PublicKey * publicKey,
- RSAEncryptedData * target) {
+ unsigned short size,
+ const PublicKey * publicKey,
+ RSAEncryptedData * target) {
gcry_sexp_t result;
gcry_sexp_t data;
struct PrivateKey * pubkey;
@@ -669,28 +669,28 @@
isize = size;
lockGcrypt();
rc = gcry_mpi_scan(&val,
- GCRYMPI_FMT_USG,
- block,
- isize,
- &isize);
+ GCRYMPI_FMT_USG,
+ block,
+ isize,
+ &isize);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_scan", rc);
+ LOG_ERROR,
+ "gcry_mpi_scan", rc);
freePrivateKey(pubkey);
unlockGcrypt();
return SYSERR;
}
rc = gcry_sexp_build(&data,
- &erroff,
- "(data (flags pkcs1)(value %m))",
- val);
+ &erroff,
+ "(data (flags pkcs1)(value %m))",
+ val);
gcry_mpi_release(val);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_sexp_build",
- rc); /* more info in erroff */
+ LOG_ERROR,
+ "gcry_sexp_build",
+ rc); /* more info in erroff */
freePrivateKey(pubkey);
unlockGcrypt();
return SYSERR;
@@ -699,9 +699,9 @@
rc = gcry_pk_encrypt(&result, data, pubkey->sexp);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_pk_encrypt",
- rc);
+ LOG_ERROR,
+ "gcry_pk_encrypt",
+ rc);
gcry_sexp_release(data);
freePrivateKey(pubkey);
unlockGcrypt();
@@ -711,36 +711,36 @@
freePrivateKey(pubkey);
rc = key_from_sexp(&rval,
- result,
- "rsa",
- "a");
+ result,
+ "rsa",
+ "a");
gcry_sexp_release(result);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "key_from_sexp",
- rc);
+ LOG_ERROR,
+ "key_from_sexp",
+ rc);
unlockGcrypt();
return SYSERR;
}
isize = sizeof(RSAEncryptedData);
rc = gcry_mpi_print(GCRYMPI_FMT_USG,
- (unsigned char*)target,
- isize,
- &isize,
- rval);
+ (unsigned char*)target,
+ isize,
+ &isize,
+ rval);
gcry_mpi_release(rval);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_print",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_print",
+ rc);
unlockGcrypt();
return SYSERR;
}
adjust(&target->encoding[0],
- isize,
- sizeof(RSAEncryptedData));
+ isize,
+ sizeof(RSAEncryptedData));
unlockGcrypt();
return OK;
}
@@ -756,9 +756,9 @@
* @returns the size of the decrypted block, -1 on error
*/
int decryptPrivateKey(const struct PrivateKey * hostkey,
- const RSAEncryptedData * block,
- void * result,
- unsigned short max) {
+ const RSAEncryptedData * block,
+ void * result,
+ unsigned short max) {
gcry_sexp_t resultsexp;
gcry_sexp_t data;
size_t erroff;
@@ -773,49 +773,49 @@
rc = gcry_pk_testkey(hostkey->sexp);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_pk_testkey",
- rc);
+ LOG_ERROR,
+ "gcry_pk_testkey",
+ rc);
unlockGcrypt();
return -1;
}
#endif
size = sizeof(RSAEncryptedData);
rc = gcry_mpi_scan(&val,
- GCRYMPI_FMT_USG,
- &block->encoding[0],
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ &block->encoding[0],
+ size,
+ &size);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_scan",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_scan",
+ rc);
unlockGcrypt();
return SYSERR;
}
rc = gcry_sexp_build(&data,
- &erroff,
- "(enc-val(flags)(rsa(a %m)))",
- val);
+ &erroff,
+ "(enc-val(flags)(rsa(a %m)))",
+ val);
gcry_mpi_release(val);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_sexp_build",
- rc); /* more info in erroff */
+ LOG_ERROR,
+ "gcry_sexp_build",
+ rc); /* more info in erroff */
unlockGcrypt();
return SYSERR;
}
rc = gcry_pk_decrypt(&resultsexp,
- data,
- hostkey->sexp);
+ data,
+ hostkey->sexp);
gcry_sexp_release(data);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_pk_decrypt",
- rc);
+ LOG_ERROR,
+ "gcry_pk_decrypt",
+ rc);
unlockGcrypt();
return SYSERR;
}
@@ -825,25 +825,25 @@
gcry_sexp_release(resultsexp);
if (val == NULL) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_sexp_nth_mpi",
- rc);
+ LOG_ERROR,
+ "gcry_sexp_nth_mpi",
+ rc);
unlockGcrypt();
return SYSERR;
}
tmp = MALLOC(max + HOSTKEY_LEN/8);
size = max+HOSTKEY_LEN/8;
rc = gcry_mpi_print(GCRYMPI_FMT_USG,
- tmp,
- size,
- &size,
- val);
+ tmp,
+ size,
+ &size,
+ val);
gcry_mpi_release(val);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_print",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_print",
+ rc);
FREE(tmp);
unlockGcrypt();
return SYSERR;
@@ -853,8 +853,8 @@
endp += (size - max);
size = max;
memcpy(result,
- endp,
- size);
+ endp,
+ size);
FREE(tmp);
unlockGcrypt();
return size;
@@ -870,9 +870,9 @@
* @return SYSERR on error, OK on success
*/
int sign(const struct PrivateKey * hostkey,
- unsigned short size,
- const void * block,
- Signature * sig) {
+ unsigned short size,
+ const void * block,
+ Signature * sig) {
gcry_sexp_t result;
gcry_sexp_t data;
size_t ssize;
@@ -887,22 +887,22 @@
bufSize = strlen(FORMATSTRING) + 1;
buff = MALLOC(bufSize);
memcpy(buff,
- FORMATSTRING,
- bufSize);
+ FORMATSTRING,
+ bufSize);
memcpy(&buff[bufSize -
strlen("0123456789012345678901234567890123456789012345678901234567890123))") -
1],
- &hc,
- sizeof(HashCode512));
+ &hc,
+ sizeof(HashCode512));
lockGcrypt();
rc = gcry_sexp_new(&data,
- buff,
- bufSize,
- 0);
+ buff,
+ bufSize,
+ 0);
FREE(buff);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_sexp_new",
- rc);
+ LOG_ERROR,
+ "gcry_sexp_new",
+ rc);
unlockGcrypt();
return SYSERR;
}
@@ -910,43 +910,43 @@
gcry_sexp_release(data);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_pk_sign",
- rc);
+ LOG_ERROR,
+ "gcry_pk_sign",
+ rc);
unlockGcrypt();
return SYSERR;
}
rc = key_from_sexp(&rval,
- result,
- "rsa",
- "s");
+ result,
+ "rsa",
+ "s");
gcry_sexp_release(result);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "key_from_sexp",
- rc);
+ LOG_ERROR,
+ "key_from_sexp",
+ rc);
unlockGcrypt();
return SYSERR;
}
ssize = sizeof(Signature);
rc = gcry_mpi_print(GCRYMPI_FMT_USG,
- (unsigned char*)sig,
- ssize,
- &ssize,
- rval);
+ (unsigned char*)sig,
+ ssize,
+ &ssize,
+ rval);
gcry_mpi_release(rval);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_print",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_print",
+ rc);
unlockGcrypt();
return SYSERR;
}
adjust(&sig->sig[0],
- ssize,
- sizeof(Signature));
+ ssize,
+ sizeof(Signature));
unlockGcrypt();
return OK;
}
@@ -961,9 +961,9 @@
* @returns OK if ok, SYSERR if invalid
*/
int verifySig(const void * block,
- unsigned short len,
- const Signature * sig,
- const PublicKey * publicKey) {
+ unsigned short len,
+ const Signature * sig,
+ const PublicKey * publicKey) {
gcry_sexp_t data;
gcry_sexp_t sigdata;
size_t size;
@@ -978,28 +978,28 @@
size = sizeof(Signature);
lockGcrypt();
rc = gcry_mpi_scan(&val,
- GCRYMPI_FMT_USG,
- (const unsigned char*)sig,
- size,
- &size);
+ GCRYMPI_FMT_USG,
+ (const unsigned char*)sig,
+ size,
+ &size);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_mpi_scan",
- rc);
+ LOG_ERROR,
+ "gcry_mpi_scan",
+ rc);
unlockGcrypt();
return SYSERR;
}
rc = gcry_sexp_build(&sigdata,
- &erroff,
- "(sig-val(rsa(s %m)))",
- val);
+ &erroff,
+ "(sig-val(rsa(s %m)))",
+ val);
gcry_mpi_release(val);
if (rc) {
LOG_GCRY(NULL,
- LOG_ERROR,
- "gcry_sexp_build",
- rc);
+ LOG_ERROR,
+ "gcry_sexp_build",
+ rc);
unlockGcrypt();
return SYSERR;
}
@@ -1007,16 +1007,16 @@
bufSize = strlen(FORMATSTRING) + 1;
buff = MALLOC(bufSize);
memcpy(buff,
- FORMATSTRING,
- bufSize);
+ FORMATSTRING,
+ bufSize);
memcpy(&buff[strlen(FORMATSTRING) -
-
strlen("0123456789012345678901234567890123456789012345678901234567890123))")],
- &hc,
- sizeof(HashCode512));
+
strlen("0123456789012345678901234567890123456789012345678901234567890123))")],
+ &hc,
+ sizeof(HashCode512));
rc = gcry_sexp_new(&data,
- buff,
- bufSize,
- 0);
+ buff,
+ bufSize,
+ 0);
FREE(buff);
hostkey = public2PrivateKey(publicKey);
if (hostkey == NULL) {
@@ -1025,17 +1025,17 @@
return SYSERR;
}
rc = gcry_pk_verify(sigdata,
- data,
- hostkey->sexp);
+ data,
+ hostkey->sexp);
freePrivateKey(hostkey);
gcry_sexp_release(data);
gcry_sexp_release(sigdata);
if (rc) {
GE_LOG(NULL,
- GE_WARNING | GE_USER | GE_BULK | GE_DEVELOPER,
- _("RSA signature verification failed at %s:%d: %s\n"),
- __FILE__, __LINE__,
- gcry_strerror(rc));
+ GE_WARNING | GE_USER | GE_BULK | GE_DEVELOPER,
+ _("RSA signature verification failed at %s:%d: %s\n"),
+ __FILE__, __LINE__,
+ gcry_strerror(rc));
unlockGcrypt();
return SYSERR;
} else {
Modified: GNUnet/src/util/crypto/hostkeytest.c
===================================================================
--- GNUnet/src/util/crypto/hostkeytest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/crypto/hostkeytest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -52,38 +52,38 @@
for (i=0;i<ITER;i++) {
fprintf(stderr, ".");
if (SYSERR == encryptPrivateKey(TESTSTRING,
- strlen(TESTSTRING)+1,
- &pkey,
- &target)) {
+ strlen(TESTSTRING)+1,
+ &pkey,
+ &target)) {
fprintf(stderr,
- "encryptPrivateKey returned SYSERR\n");
+ "encryptPrivateKey returned SYSERR\n");
ok++;
continue;
}
if (-1 == decryptPrivateKey(hostkey,
- &target,
- result,
- strlen(TESTSTRING)+1)) {
+ &target,
+ result,
+ strlen(TESTSTRING)+1)) {
fprintf(stderr,
- "decryptPrivateKey returned SYSERR\n");
+ "decryptPrivateKey returned SYSERR\n");
ok++;
continue;
}
if (strncmp(TESTSTRING, result,
- strlen(TESTSTRING)) != 0) {
+ strlen(TESTSTRING)) != 0) {
printf("%s != %.*s - testEncryptDecrypt failed!\n",
- TESTSTRING,
- MAX_TESTVAL,
- result);
+ TESTSTRING,
+ MAX_TESTVAL,
+ result);
ok++;
continue;
}
}
printf("%d RSA encrypt/decrypt operations %ds (%d failures)\n",
- ITER,
- (int) (TIME(NULL)-start),
- ok);
+ ITER,
+ (int) (TIME(NULL)-start),
+ ok);
freePrivateKey(hostkey);
if (ok == 0)
return OK;
@@ -109,19 +109,19 @@
for (i=0;i<ITER;i++) {
fprintf(stderr, ".");
if (SYSERR == encryptPrivateKey(TESTSTRING,
- strlen(TESTSTRING)+1,
- &pkey,
- &target)) {
+ strlen(TESTSTRING)+1,
+ &pkey,
+ &target)) {
fprintf(stderr,
- "encryptPrivateKey returned SYSERR\n");
+ "encryptPrivateKey returned SYSERR\n");
ok++;
continue;
}
}
printf("%d RSA encrypt operations %llu ms (%d failures)\n",
- ITER,
- get_time() - start,
- ok);
+ ITER,
+ get_time() - start,
+ ok);
freePrivateKey(hostkey);
if (ok != 0)
return SYSERR;
@@ -149,35 +149,35 @@
fprintf(stderr, ".");
makeSessionkey(&insk);
if (SYSERR == encryptPrivateKey(&insk,
- sizeof(SESSIONKEY),
- &pkey,
- &target)) {
+ sizeof(SESSIONKEY),
+ &pkey,
+ &target)) {
fprintf(stderr,
- "encryptPrivateKey returned SYSERR\n");
+ "encryptPrivateKey returned SYSERR\n");
ok++;
continue;
}
if (-1 == decryptPrivateKey(hostkey,
- &target,
- &outsk,
- sizeof(SESSIONKEY))) {
+ &target,
+ &outsk,
+ sizeof(SESSIONKEY))) {
fprintf(stderr,
- "decryptPrivateKey returned SYSERR\n");
+ "decryptPrivateKey returned SYSERR\n");
ok++;
continue;
}
if (0 != memcmp(&insk,
- &outsk,
- sizeof(SESSIONKEY))) {
+ &outsk,
+ sizeof(SESSIONKEY))) {
printf("testEncryptDecryptSK failed!\n");
ok++;
continue;
}
}
printf("%d RSA encrypt/decrypt SK operations %ds (%d failures)\n",
- ITER,
- (int) (TIME(NULL)-start),
- ok);
+ ITER,
+ (int) (TIME(NULL)-start),
+ ok);
freePrivateKey(hostkey);
if (ok != 0)
return SYSERR;
@@ -199,26 +199,26 @@
for (i=0;i<ITER;i++) {
fprintf(stderr, ".");
if (SYSERR == sign(hostkey,
- strlen(TESTSTRING),
- TESTSTRING,
- &sig)) {
+ strlen(TESTSTRING),
+ TESTSTRING,
+ &sig)) {
fprintf(stderr,
- "sign returned SYSERR\n");
+ "sign returned SYSERR\n");
ok = SYSERR;
continue;
}
if (SYSERR == verifySig(TESTSTRING,
- strlen(TESTSTRING),
- &sig,
- &pkey)) {
+ strlen(TESTSTRING),
+ &sig,
+ &pkey)) {
printf("testSignVerify failed!\n");
ok = SYSERR;
continue;
}
}
printf("%d RSA sign/verify operations %ds\n",
- ITER,
- (int) (TIME(NULL)-start));
+ ITER,
+ (int) (TIME(NULL)-start));
freePrivateKey(hostkey);
return ok;
}
@@ -239,18 +239,18 @@
for (i=0;i<ITER;i++) {
fprintf(stderr, ".");
if (SYSERR == sign(hostkey,
- strlen(TESTSTRING),
- TESTSTRING,
- &sig)) {
+ strlen(TESTSTRING),
+ TESTSTRING,
+ &sig)) {
fprintf(stderr,
- "sign returned SYSERR\n");
+ "sign returned SYSERR\n");
ok = SYSERR;
continue;
}
}
printf("%d RSA sign operations %llu ms\n",
- ITER,
- get_time() - start);
+ ITER,
+ get_time() - start);
freePrivateKey(hostkey);
return ok;
}
@@ -274,11 +274,11 @@
fprintf(stderr, ".");
getPublicKey(hostkey, &pkey);
if (SYSERR == encryptPrivateKey(TESTSTRING,
- strlen(TESTSTRING)+1,
- &pkey,
- &target)) {
+ strlen(TESTSTRING)+1,
+ &pkey,
+ &target)) {
fprintf(stderr,
- "encryptPrivateKey returned SYSERR\n");
+ "encryptPrivateKey returned SYSERR\n");
ok = SYSERR;
continue;
}
@@ -286,35 +286,35 @@
freePrivateKey(hostkey);
if (encoding == NULL) {
fprintf(stderr,
- "encodePrivateKey returned NULL\n");
+ "encodePrivateKey returned NULL\n");
ok = SYSERR;
continue;
}
hostkey = decodePrivateKey(encoding);
FREE(encoding);
if (SYSERR == decryptPrivateKey(hostkey,
- &target,
- result,
- strlen(TESTSTRING)+1)) {
+ &target,
+ result,
+ strlen(TESTSTRING)+1)) {
fprintf(stderr,
- "decryptPrivateKey returned SYSERR\n");
+ "decryptPrivateKey returned SYSERR\n");
ok = SYSERR;
continue;
}
if (strncmp(TESTSTRING, result,
- strlen(TESTSTRING)) != 0) {
+ strlen(TESTSTRING)) != 0) {
printf("%s != %.*s - testEncryptDecrypt failed!\n",
- TESTSTRING,
- (int) strlen(TESTSTRING),
- result);
+ TESTSTRING,
+ (int) strlen(TESTSTRING),
+ result);
ok = SYSERR;
continue;
}
}
freePrivateKey(hostkey);
printf("%d RSA encrypt/encode/decode/decrypt operations %ds\n",
- ITER,
- (int) (TIME(NULL)-start));
+ ITER,
+ (int) (TIME(NULL)-start));
return ok;
}
@@ -338,7 +338,7 @@
if (failureCount != 0) {
printf("\n\n%d TESTS FAILED!\n\n",
- failureCount);
+ failureCount);
return -1;
}
return 0;
Modified: GNUnet/src/util/crypto/kblockkey.c
===================================================================
--- GNUnet/src/util/crypto/kblockkey.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/crypto/kblockkey.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -38,12 +38,12 @@
#include <gmp.h>
typedef struct {
- mpz_t n; /* public modulus */
- mpz_t e; /* public exponent */
- mpz_t d; /* exponent */
- mpz_t p; /* prime p. */
- mpz_t q; /* prime q. */
- mpz_t u; /* inverse of p mod q. */
+ mpz_t n; /* public modulus */
+ mpz_t e; /* public exponent */
+ mpz_t d; /* exponent */
+ mpz_t p; /* prime p. */
+ mpz_t q; /* prime q. */
+ mpz_t u; /* inverse of p mod q. */
} KBlock_secret_key;
/* Note: 2 is not included because it can be tested more easily by
@@ -155,7 +155,7 @@
* Set bit N of A. and clear all bits above
*/
static void set_highbit(mpz_t a,
- unsigned int n) {
+ unsigned int n) {
unsigned int nbits;
nbits = get_nbits(a);
@@ -165,8 +165,8 @@
}
static void mpz_randomize(mpz_t n,
- unsigned int nbits,
- HashCode512 * rnd) {
+ unsigned int nbits,
+ HashCode512 * rnd) {
HashCode512 * tmp;
int cnt;
int i;
@@ -177,12 +177,12 @@
tmp[0] = *rnd;
for (i=0;i<cnt-1;i++) {
hash(&tmp[i],
- sizeof(HashCode512),
- &tmp[i+1]);
+ sizeof(HashCode512),
+ &tmp[i+1]);
}
*rnd = tmp[cnt-1];
mpz_import(n, cnt * sizeof(HashCode512) / sizeof(unsigned int),
- 1, sizeof(unsigned int), 1, 0, tmp);
+ 1, sizeof(unsigned int), 1, 0, tmp);
FREE(tmp);
i = get_nbits(n);
while (i > nbits)
@@ -193,8 +193,8 @@
* Return true if n is probably a prime
*/
static int is_prime (mpz_t n,
- int steps,
- HashCode512 * hc) {
+ int steps,
+ HashCode512 * hc) {
mpz_t x;
mpz_t y;
mpz_t z;
@@ -225,25 +225,25 @@
mpz_randomize( x, nbits, hc );
/* Make sure that the number is smaller than the prime and
- keep the randomness of the high bit. */
+ keep the randomness of the high bit. */
if (mpz_tstbit(x, nbits-2) ) {
- set_highbit(x, nbits-2); /* Clear all higher bits. */
+ set_highbit(x, nbits-2); /* Clear all higher bits. */
} else {
- set_highbit(x, nbits-2 );
- mpz_clrbit( x, nbits-2 );
+ set_highbit(x, nbits-2 );
+ mpz_clrbit( x, nbits-2 );
}
GE_ASSERT(NULL,
- mpz_cmp( x, nminus1 ) < 0 && mpz_cmp_ui( x, 1 ) > 0 );
+ mpz_cmp( x, nminus1 ) < 0 && mpz_cmp_ui( x, 1 ) > 0 );
}
mpz_powm ( y, x, q, n);
if ( mpz_cmp_ui(y, 1) && mpz_cmp( y, nminus1 ) ) {
for ( j=1; j < k && mpz_cmp( y, nminus1 ); j++ ) {
- mpz_powm(y, y, a2, n);
- if( !mpz_cmp_ui( y, 1 ) )
- goto leave; /* Not a prime. */
+ mpz_powm(y, y, a2, n);
+ if( !mpz_cmp_ui( y, 1 ) )
+ goto leave; /* Not a prime. */
}
if (mpz_cmp( y, nminus1 ) )
- goto leave; /* Not a prime. */
+ goto leave; /* Not a prime. */
}
}
rc = 1; /* May be a prime. */
@@ -260,8 +260,8 @@
}
static void gen_prime(mpz_t ptest,
- unsigned int nbits,
- HashCode512 * hc) {
+ unsigned int nbits,
+ HashCode512 * hc) {
mpz_t prime, pminus1, val_2, val_3, result;
int i;
unsigned x, step;
@@ -298,31 +298,31 @@
for (step=0; step < 20000; step += 2 ) {
/* Check against all the small primes we have in mods. */
for (i=0; (x = small_prime_numbers[i]); i++ ) {
- while ( mods[i] + step >= x )
- mods[i] -= x;
- if ( !(mods[i] + step) )
- break;
+ while ( mods[i] + step >= x )
+ mods[i] -= x;
+ if ( !(mods[i] + step) )
+ break;
}
if (x)
- continue; /* Found a multiple of an already known prime. */
-
+ continue; /* Found a multiple of an already known prime. */
+
mpz_add_ui( ptest, prime, step );
if (! mpz_tstbit( ptest, nbits-2 ))
- break;
+ break;
/* Do a fast Fermat test now. */
mpz_sub_ui( pminus1, ptest, 1);
mpz_powm( result, val_2, pminus1, ptest );
- if ( ( !mpz_cmp_ui( result, 1 ) ) &&
- (is_prime(ptest, 5, hc) ) ) {
- /* Got it. */
- mpz_clear(val_2);
- mpz_clear(val_3);
- mpz_clear(result);
- mpz_clear(pminus1);
- mpz_clear(prime);
- FREE(mods);
- return;
+ if ( ( !mpz_cmp_ui( result, 1 ) ) &&
+ (is_prime(ptest, 5, hc) ) ) {
+ /* Got it. */
+ mpz_clear(val_2);
+ mpz_clear(val_3);
+ mpz_clear(result);
+ mpz_clear(pminus1);
+ mpz_clear(prime);
+ FREE(mods);
+ return;
}
}
}
@@ -333,8 +333,8 @@
* Return: 1 if this 1, 0 in all other cases
*/
static int test_gcd(mpz_t g,
- mpz_t xa,
- mpz_t xb) {
+ mpz_t xa,
+ mpz_t xb) {
mpz_t a, b;
mpz_init_set(a, xa);
@@ -360,8 +360,8 @@
* @param hc the HC to use for PRNG (modified!)
*/
static void generate_kblock_key(KBlock_secret_key *sk,
- unsigned int nbits,
- HashCode512 * hc) {
+ unsigned int nbits,
+ HashCode512 * hc) {
mpz_t t1, t2;
mpz_t phi; /* helper: (p-1)(q-1) */
mpz_t g;
@@ -392,7 +392,7 @@
gen_prime(sk->q, nbits/2, hc);
if (mpz_cmp (sk->p, sk->q) > 0 ) /* p shall be smaller than q (for calc
of u)*/
- mpz_swap(sk->p, sk->q);
+ mpz_swap(sk->p, sk->q);
/* calculate the modulus */
mpz_mul(sk->n, sk->p, sk->q );
} while (get_nbits(sk->n) != nbits);
@@ -410,7 +410,7 @@
/* calculate the secret key d = e^1 mod phi */
} while ( (0 == mpz_invert(sk->d, sk->e, f )) ||
- (0 == mpz_invert(sk->u, sk->p, sk->q )) );
+ (0 == mpz_invert(sk->u, sk->p, sk->q )) );
mpz_clear(t1);
mpz_clear(t2);
@@ -436,16 +436,16 @@
hx = *hc;
generate_kblock_key(&sk,
- 1024, /* at least 10x as fast than 2048 bits
- -- we simply cannot afford 2048 bits
- even on modern hardware, and especially
- not since clearly a dictionary attack
- will still be much cheaper
- than breaking a 1024 bit RSA key.
- If an adversary can spend the time to
- break a 1024 bit RSA key just to forge
- a signature -- SO BE IT. [ CG, 6/2005 ] */
- &hx);
+ 1024, /* at least 10x as fast than 2048 bits
+ -- we simply cannot afford 2048 bits
+ even on modern hardware, and especially
+ not since clearly a dictionary attack
+ will still be much cheaper
+ than breaking a 1024 bit RSA key.
+ If an adversary can spend the time to
+ break a 1024 bit RSA key just to forge
+ a signature -- SO BE IT. [ CG, 6/2005 ] */
+ &hx);
pkv[0] = &sk.n;
pkv[1] = &sk.e;
pkv[2] = &sk.d;
@@ -455,12 +455,12 @@
size = sizeof(PrivateKeyEncoded);
for (i=0;i<6;i++) {
pbu[i] = mpz_export(NULL,
- &sizes[i],
- 1, /* most significant word first */
- 1, /* unit is bytes */
- 1, /* big endian */
- 0, /* nails */
- *pkv[i]);
+ &sizes[i],
+ 1, /* most significant word first */
+ 1, /* unit is bytes */
+ 1, /* big endian */
+ 0, /* nails */
+ *pkv[i]);
size += sizes[i];
}
GE_ASSERT(NULL, size < 65536);
@@ -469,35 +469,35 @@
i = 0;
retval->sizen = htons(sizes[0]);
memcpy(&((char*)&retval[1])[i],
- pbu[0],
- sizes[0]);
+ pbu[0],
+ sizes[0]);
i += sizes[0];
retval->sizee = htons(sizes[1]);
memcpy(&((char*)&retval[1])[i],
- pbu[1],
- sizes[1]);
+ pbu[1],
+ sizes[1]);
i += sizes[1];
retval->sized = htons(sizes[2]);
memcpy(&((char*)&retval[1])[i],
- pbu[2],
- sizes[2]);
+ pbu[2],
+ sizes[2]);
i += sizes[2];
/* swap p and q! */
retval->sizep = htons(sizes[4]);
memcpy(&((char*)&retval[1])[i],
- pbu[4],
- sizes[4]);
+ pbu[4],
+ sizes[4]);
i += sizes[4];
retval->sizeq = htons(sizes[3]);
memcpy(&((char*)&retval[1])[i],
- pbu[3],
- sizes[3]);
+ pbu[3],
+ sizes[3]);
i += sizes[3];
retval->sizedmp1 = htons(0);
retval->sizedmq1 = htons(0);
memcpy(&((char*)&retval[1])[i],
- pbu[5],
- sizes[5]);
+ pbu[5],
+ sizes[5]);
for (i=0;i<6;i++) {
mpz_clear(*pkv[i]);
free(pbu[i]);
@@ -526,7 +526,7 @@
MUTEX_LOCK(lock);
for (i=0;i<cacheSize;i++) {
if (equalsHashCode512(hc,
- &cache[i]->hc)) {
+ &cache[i]->hc)) {
ret = decodePrivateKey(cache[i]->pke);
MUTEX_UNLOCK(lock);
return ret;
Modified: GNUnet/src/util/crypto/kblockkey_test.c
===================================================================
--- GNUnet/src/util/crypto/kblockkey_test.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/crypto/kblockkey_test.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -42,8 +42,8 @@
int i;
fprintf(stderr,
- "Testing KBlock key uniqueness (%s) ",
- word);
+ "Testing KBlock key uniqueness (%s) ",
+ word);
hash(word, strlen(word), &in);
hostkey = makeKblockKey(&in);
if (hostkey == NULL) {
@@ -67,7 +67,7 @@
getPublicKey(hostkey, &pkey1);
freePrivateKey(hostkey);
if (0 != memcmp(&pkey, &pkey1,
- sizeof(PublicKey))) {
+ sizeof(PublicKey))) {
GE_BREAK(NULL, 0);
fprintf(stderr, " ERROR\n");
return SYSERR;
@@ -94,37 +94,37 @@
for (i=0;i<ITER;i++) {
fprintf(stderr, ".");
if (SYSERR == encryptPrivateKey(TESTSTRING,
- strlen(TESTSTRING)+1,
- &pkey,
- &target)) {
+ strlen(TESTSTRING)+1,
+ &pkey,
+ &target)) {
fprintf(stderr,
- "encryptPrivateKey returned SYSERR\n");
+ "encryptPrivateKey returned SYSERR\n");
ok++;
continue;
}
if (-1 == decryptPrivateKey(hostkey,
- &target,
- result,
- strlen(TESTSTRING)+1)) {
+ &target,
+ result,
+ strlen(TESTSTRING)+1)) {
fprintf(stderr,
- "decryptPrivateKey returned SYSERR\n");
+ "decryptPrivateKey returned SYSERR\n");
ok++;
continue;
}
if (strncmp(TESTSTRING, result,
- strlen(TESTSTRING)) != 0) {
+ strlen(TESTSTRING)) != 0) {
printf("%s != %.*s - testEncryptDecrypt failed!\n",
- TESTSTRING,
- MAX_TESTVAL,
- result);
+ TESTSTRING,
+ MAX_TESTVAL,
+ result);
ok++;
continue;
}
}
printf("%d RSA encrypt/decrypt operations %ds (%d failures)\n",
- ITER,
- (int) (TIME(NULL)-start),
- ok);
+ ITER,
+ (int) (TIME(NULL)-start),
+ ok);
if (ok == 0)
return OK;
else
@@ -144,25 +144,25 @@
for (i=0;i<ITER;i++) {
fprintf(stderr, ".");
if (SYSERR == sign(hostkey,
- strlen(TESTSTRING),
- TESTSTRING, &sig)) {
+ strlen(TESTSTRING),
+ TESTSTRING, &sig)) {
fprintf(stderr,
- "sign returned SYSERR\n");
+ "sign returned SYSERR\n");
ok = SYSERR;
continue;
}
if (SYSERR == verifySig(TESTSTRING,
- strlen(TESTSTRING),
- &sig,
- &pkey)) {
+ strlen(TESTSTRING),
+ &sig,
+ &pkey)) {
printf("testSignVerify failed!\n");
ok = SYSERR;
continue;
}
}
printf("%d RSA sign/verify operations %ds\n",
- ITER,
- (int) (TIME(NULL)-start));
+ ITER,
+ (int) (TIME(NULL)-start));
return ok;
}
@@ -183,47 +183,47 @@
fprintf(stderr, ".");
getPublicKey(hostkey, &pkey);
if (SYSERR == encryptPrivateKey(TESTSTRING,
- strlen(TESTSTRING)+1,
- &pkey,
- &target)) {
+ strlen(TESTSTRING)+1,
+ &pkey,
+ &target)) {
fprintf(stderr,
- "encryptPrivateKey returned SYSERR\n");
+ "encryptPrivateKey returned SYSERR\n");
ok = SYSERR;
continue;
}
encoding = encodePrivateKey(hostkey);
if (encoding == NULL) {
fprintf(stderr,
- "encodePrivateKey returned NULL\n");
+ "encodePrivateKey returned NULL\n");
ok = SYSERR;
continue;
}
hostkey2 = decodePrivateKey(encoding);
FREE(encoding);
if (SYSERR == decryptPrivateKey(hostkey2,
- &target,
- result,
- strlen(TESTSTRING)+1)) {
+ &target,
+ result,
+ strlen(TESTSTRING)+1)) {
fprintf(stderr,
- "decryptPrivateKey returned SYSERR\n");
+ "decryptPrivateKey returned SYSERR\n");
ok = SYSERR;
freePrivateKey(hostkey2);
continue;
}
freePrivateKey(hostkey2);
if (strncmp(TESTSTRING, result,
- strlen(TESTSTRING)) != 0) {
+ strlen(TESTSTRING)) != 0) {
printf("%s != %.*s - testEncryptDecrypt failed!\n",
- TESTSTRING,
- (int) strlen(TESTSTRING),
- result);
+ TESTSTRING,
+ (int) strlen(TESTSTRING),
+ result);
ok = SYSERR;
continue;
}
}
printf("%d RSA encrypt/encode/decode/decrypt operations %ds\n",
- ITER,
- (int) (TIME(NULL)-start));
+ ITER,
+ (int) (TIME(NULL)-start));
return ok;
}
@@ -253,7 +253,7 @@
if (failureCount != 0) {
printf("\n\n%d TESTS FAILED!\n\n",
- failureCount);
+ failureCount);
return -1;
}
return 0;
Modified: GNUnet/src/util/crypto/locking_gcrypt.c
===================================================================
--- GNUnet/src/util/crypto/locking_gcrypt.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/crypto/locking_gcrypt.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -56,9 +56,9 @@
}
static void dummy_logger(void * arg,
- int level,
- const char * format,
- va_list args) {
+ int level,
+ const char * format,
+ va_list args) {
/* do nothing -- ignore libgcyrpt errors */
}
@@ -71,8 +71,8 @@
gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
if (! gcry_check_version(GCRYPT_VERSION)) {
fprintf(stderr,
- _("libgcrypt has not the expected version (version %s is
required).\n"),
- GCRYPT_VERSION);
+ _("libgcrypt has not the expected version (version %s is required).\n"),
+ GCRYPT_VERSION);
abort();
}
srand((unsigned int)time(NULL));
Modified: GNUnet/src/util/crypto/random.c
===================================================================
--- GNUnet/src/util/crypto/random.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/crypto/random.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -47,11 +47,11 @@
gcry_fast_random_poll();
#endif
ret = rand(); /* in case gcry_randomize fails,
- we at least get a pseudo-
- random number this way */
+ we at least get a pseudo-
+ random number this way */
gcry_randomize((unsigned char*)&ret,
- sizeof(unsigned int),
- GCRY_STRONG_RANDOM);
+ sizeof(unsigned int),
+ GCRY_STRONG_RANDOM);
unlockGcrypt();
return ret % i;
}
@@ -93,8 +93,8 @@
GE_ASSERT(NULL, u > 0);
lockGcrypt();
gcry_randomize((unsigned char *) &ret,
- sizeof(unsigned long long),
- GCRY_STRONG_RANDOM);
+ sizeof(unsigned long long),
+ GCRY_STRONG_RANDOM);
unlockGcrypt();
return ret % u;
}
Modified: GNUnet/src/util/crypto/symcipher_gcrypt.c
===================================================================
--- GNUnet/src/util/crypto/symcipher_gcrypt.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/crypto/symcipher_gcrypt.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -59,8 +59,8 @@
void makeSessionkey(SESSIONKEY * key) {
lockGcrypt();
gcry_randomize(&key->key[0],
- SESSIONKEY_LEN,
- GCRY_STRONG_RANDOM);
+ SESSIONKEY_LEN,
+ GCRY_STRONG_RANDOM);
unlockGcrypt();
key->crc32 = htonl(crc32N(key, SESSIONKEY_LEN));
}
@@ -77,10 +77,10 @@
* @returns the size of the encrypted block, -1 for errors
*/
int encryptBlock(const void * block,
- unsigned short len,
- const SESSIONKEY * sessionkey,
- const INITVECTOR * iv,
- void * result) {
+ unsigned short len,
+ const SESSIONKEY * sessionkey,
+ const INITVECTOR * iv,
+ void * result) {
gcry_cipher_hd_t handle;
int rc;
@@ -91,53 +91,53 @@
}
lockGcrypt();
rc = gcry_cipher_open(&handle,
- GCRY_CIPHER_AES256,
- GCRY_CIPHER_MODE_CFB,
- 0);
+ GCRY_CIPHER_AES256,
+ GCRY_CIPHER_MODE_CFB,
+ 0);
if (rc) {
LOG_GCRY(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- "gcry_cipher_open",
- rc);
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ "gcry_cipher_open",
+ rc);
unlockGcrypt();
return -1;
}
rc = gcry_cipher_setkey(handle,
- sessionkey,
- SESSIONKEY_LEN);
+ sessionkey,
+ SESSIONKEY_LEN);
if (rc && ((char)rc != GPG_ERR_WEAK_KEY)) {
LOG_GCRY(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- "gcry_cipher_setkey",
- rc);
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ "gcry_cipher_setkey",
+ rc);
gcry_cipher_close(handle);
unlockGcrypt();
return -1;
}
rc = gcry_cipher_setiv(handle,
- iv,
- sizeof(INITVECTOR));
+ iv,
+ sizeof(INITVECTOR));
if (rc && ((char)rc != GPG_ERR_WEAK_KEY)) {
LOG_GCRY(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- "gcry_cipher_setiv",
- rc);
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ "gcry_cipher_setiv",
+ rc);
gcry_cipher_close(handle);
unlockGcrypt();
return -1;
}
rc = gcry_cipher_encrypt(handle,
- result,
- len,
- block,
- len);
+ result,
+ len,
+ block,
+ len);
if (rc) {
LOG_GCRY(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- "gcry_cipher_encrypt",
- rc);
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ "gcry_cipher_encrypt",
+ rc);
gcry_cipher_close(handle);
unlockGcrypt();
return -1;
@@ -158,10 +158,10 @@
* @return -1 on failure, size of decrypted block on success
*/
int decryptBlock(const SESSIONKEY * sessionkey,
- const void * block,
- unsigned short size,
- const INITVECTOR * iv,
- void * result) {
+ const void * block,
+ unsigned short size,
+ const INITVECTOR * iv,
+ void * result) {
gcry_cipher_hd_t handle;
int rc;
@@ -172,53 +172,53 @@
}
lockGcrypt();
rc = gcry_cipher_open(&handle,
- GCRY_CIPHER_AES256,
- GCRY_CIPHER_MODE_CFB,
- 0);
+ GCRY_CIPHER_AES256,
+ GCRY_CIPHER_MODE_CFB,
+ 0);
if (rc) {
LOG_GCRY(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- "gcry_cipher_open",
- rc);
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ "gcry_cipher_open",
+ rc);
unlockGcrypt();
return -1;
}
rc = gcry_cipher_setkey(handle,
- sessionkey,
- SESSIONKEY_LEN);
+ sessionkey,
+ SESSIONKEY_LEN);
if (rc && ((char)rc != GPG_ERR_WEAK_KEY)) {
LOG_GCRY(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- "gcry_cipher_setkey",
- rc);
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ "gcry_cipher_setkey",
+ rc);
gcry_cipher_close(handle);
unlockGcrypt();
return -1;
}
rc = gcry_cipher_setiv(handle,
- iv,
- sizeof(INITVECTOR));
+ iv,
+ sizeof(INITVECTOR));
if (rc && ((char)rc != GPG_ERR_WEAK_KEY)) {
LOG_GCRY(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- "gcry_cipher_setiv",
- rc);
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ "gcry_cipher_setiv",
+ rc);
gcry_cipher_close(handle);
unlockGcrypt();
return -1;
}
rc = gcry_cipher_decrypt(handle,
- result,
- size,
- block,
- size);
+ result,
+ size,
+ block,
+ size);
if (rc) {
LOG_GCRY(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- "gcry_cipher_decrypt",
- rc);
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ "gcry_cipher_decrypt",
+ rc);
gcry_cipher_close(handle);
unlockGcrypt();
return -1;
Modified: GNUnet/src/util/crypto/symciphertest.c
===================================================================
--- GNUnet/src/util/crypto/symciphertest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/crypto/symciphertest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -39,29 +39,29 @@
makeSessionkey(&key);
size = encryptBlock(TESTSTRING,
- strlen(TESTSTRING)+1,
- &key,
- (const INITVECTOR*) INITVALUE,
- result);
+ strlen(TESTSTRING)+1,
+ &key,
+ (const INITVECTOR*) INITVALUE,
+ result);
if (size == -1) {
printf("symciphertest failed: encryptBlock returned %d\n",
- size);
+ size);
return 1;
}
size = decryptBlock(&key,
- result,
- size,
- (const INITVECTOR*) INITVALUE,
- res);
+ result,
+ size,
+ (const INITVECTOR*) INITVALUE,
+ res);
if (strlen(TESTSTRING)+1
!= size) {
printf("symciphertest failed: decryptBlock returned %d\n",
- size);
+ size);
return 1;
}
if (0 != strcmp(res,TESTSTRING)) {
printf("symciphertest failed: %s != %s\n",
- res, TESTSTRING);
+ res, TESTSTRING);
return 1;
} else
return 0;
@@ -85,8 +85,8 @@
if (ntohl(key.crc32) != (unsigned int) 38125195LL) {
printf("Static key has different CRC: %u - %u\n",
- ntohl(key.crc32),
- key.crc32);
+ ntohl(key.crc32),
+ key.crc32);
ret = 1;
goto error;
@@ -94,18 +94,18 @@
if (SESSIONKEY_LEN !=
encryptBlock(plain,
- SESSIONKEY_LEN,
- &key,
- (const INITVECTOR*) "testtesttesttest",
- result)) {
+ SESSIONKEY_LEN,
+ &key,
+ (const INITVECTOR*) "testtesttesttest",
+ result)) {
printf("Wrong return value from encrypt block.\n");
ret = 1;
goto error;
}
if (memcmp(encrresult,
- result,
- SESSIONKEY_LEN) != 0) {
+ result,
+ SESSIONKEY_LEN) != 0) {
printf("Encrypted result wrong.\n");
ret = 1;
goto error;
@@ -115,10 +115,10 @@
if (SESSIONKEY_LEN !=
decryptBlock(&key,
- result,
- SESSIONKEY_LEN,
- (const INITVECTOR*) "testtesttesttest",
- res)) {
+ result,
+ SESSIONKEY_LEN,
+ (const INITVECTOR*) "testtesttesttest",
+ res)) {
printf("Wrong return value from decrypt block.\n");
ret = 1;
goto error;
Modified: GNUnet/src/util/crypto/weakkeytest.c
===================================================================
--- GNUnet/src/util/crypto/weakkeytest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/crypto/weakkeytest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -39,7 +39,7 @@
int i;
for (i = 0; i < SESSIONKEY_LEN; i++) {
printf("%x ",
- (int)(key->key[i]));
+ (int)(key->key[i]));
}
}
@@ -87,7 +87,7 @@
weak_key.key[31]= (char)(0xaa);
/* memset(&weak_key, 0, 32); */
weak_key.crc32 = htonl(crc32N(&weak_key,
- SESSIONKEY_LEN));
+ SESSIONKEY_LEN));
size = encryptBlock(WEAK_KEY_TESTSTRING,
strlen(WEAK_KEY_TESTSTRING)+1,
@@ -111,7 +111,7 @@
return 1;
}
if (0 != strcmp(res,
- WEAK_KEY_TESTSTRING)) {
+ WEAK_KEY_TESTSTRING)) {
GE_BREAK(NULL, 0);
return 1;
} else
@@ -135,21 +135,21 @@
makeSessionkey(&sessionkey);
rc = gcry_cipher_open(&handle,
- GCRY_CIPHER_AES256,
- GCRY_CIPHER_MODE_CFB,
- 0);
+ GCRY_CIPHER_AES256,
+ GCRY_CIPHER_MODE_CFB,
+ 0);
if (rc) {
printf("testweakkey: gcry_cipher_open failed on trial %d. %s\n",
- number_of_runs,
- gcry_strerror(rc));
+ number_of_runs,
+ gcry_strerror(rc));
rc = 0;
continue;
}
rc = gcry_cipher_setkey(handle,
- &sessionkey,
- SESSIONKEY_LEN);
+ &sessionkey,
+ SESSIONKEY_LEN);
if ((char)rc == GPG_ERR_WEAK_KEY) {
printf("\nWeak key (in hex): ");
@@ -163,7 +163,7 @@
}
gcry_cipher_close(handle);
-
+
}
return number_of_weak_keys;
@@ -177,12 +177,12 @@
if (weak_keys == 0) {
printf("\nNo weak keys found in %d runs.\n",
- MAX_WEAK_KEY_TRIALS);
+ MAX_WEAK_KEY_TRIALS);
}
else {
printf("\n%d weak keys found in %d runs.\n",
- weak_keys,
- MAX_WEAK_KEY_TRIALS);
+ weak_keys,
+ MAX_WEAK_KEY_TRIALS);
}
}
Modified: GNUnet/src/util/disk/storage.c
===================================================================
--- GNUnet/src/util/disk/storage.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/disk/storage.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -46,9 +46,9 @@
#include <sys/statvfs.h>
#else
#ifdef MINGW
-#define _IFMT 0170000 /* type of file */
-#define _IFLNK 0120000 /* symbolic link */
-#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
+#define _IFMT 0170000 /* type of file */
+#define _IFLNK 0120000 /* symbolic link */
+#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
#else
#error PORT-ME: need to port statfs (how much space is left on the drive?)
#endif
@@ -72,8 +72,8 @@
} GetFileSizeData;
static int getSizeRec(const char * filename,
- const char * dirname,
- void * ptr) {
+ const char * dirname,
+ void * ptr) {
GetFileSizeData * gfsd = ptr;
#ifdef HAVE_STAT64
struct stat64 buf;
@@ -89,7 +89,7 @@
if (strlen(dirname) > 0) {
strcpy(fn, dirname);
if (dirname[strlen(dirname)-1] != DIR_SEPARATOR)
- strcat(fn, DIR_SEPARATOR_STR); /* add tailing / if needed */
+ strcat(fn, DIR_SEPARATOR_STR); /* add tailing / if needed */
}
/* Windows paths don't start with / */
#ifndef MINGW
@@ -107,18 +107,18 @@
#ifdef HAVE_STAT64
if (0 != STAT64(fn, &buf)) {
GE_LOG_STRERROR_FILE(gfsd->ectx,
- GE_WARNING | GE_USER | GE_REQUEST,
- "stat64",
- fn);
+ GE_WARNING | GE_USER | GE_REQUEST,
+ "stat64",
+ fn);
FREE(fn);
return SYSERR;
}
#else
if (0 != STAT(fn, &buf)) {
GE_LOG_STRERROR_FILE(gfsd->ectx,
- GE_WARNING | GE_USER | GE_REQUEST,
- "stat",
- fn);
+ GE_WARNING | GE_USER | GE_REQUEST,
+ "stat",
+ fn);
FREE(fn);
return SYSERR;
}
@@ -129,12 +129,12 @@
if ( (S_ISDIR(buf.st_mode)) &&
(0 == ACCESS(fn, X_OK)) &&
( (!S_ISLNK(buf.st_mode)) ||
- (gfsd->include_sym_links == YES) ) ) {
+ (gfsd->include_sym_links == YES) ) ) {
if (SYSERR ==
- disk_directory_scan(gfsd->ectx,
- fn,
- &getSizeRec,
- gfsd)) {
+ disk_directory_scan(gfsd->ectx,
+ fn,
+ &getSizeRec,
+ gfsd)) {
FREE(fn);
return SYSERR;
}
@@ -150,9 +150,9 @@
* @return SYSERR on error, OK on success
*/
int disk_file_size(struct GE_Context * ectx,
- const char * filename,
- unsigned long long * size,
- int includeSymLinks) {
+ const char * filename,
+ unsigned long long * size,
+ int includeSymLinks) {
GetFileSizeData gfsd;
int ret;
@@ -173,15 +173,15 @@
* @return -1 on errors, otherwise the number of free blocks
*/
long disk_get_blocks_available(struct GE_Context * ectx,
- const char * part) {
+ const char * part) {
#ifdef SOLARIS
struct statvfs buf;
if (0 != statvfs(part, &buf)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- "statfs",
- part);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ "statfs",
+ part);
return -1;
}
return buf.f_bavail;
@@ -193,16 +193,16 @@
memcpy(szDrive, part, 3);
szDrive[3] = 0;
if (!GetDiskFreeSpace(szDrive,
- &dwDummy,
- &dwDummy,
- &dwBlocks,
- &dwDummy)) {
+ &dwDummy,
+ &dwDummy,
+ &dwBlocks,
+ &dwDummy)) {
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- _("`%s' failed for drive `%s': %u\n"),
- "GetDiskFreeSpace",
- szDrive,
- GetLastError());
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ _("`%s' failed for drive `%s': %u\n"),
+ "GetDiskFreeSpace",
+ szDrive,
+ GetLastError());
return -1;
}
@@ -211,9 +211,9 @@
struct statfs s;
if (0 != statfs(part, &s)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- "statfs",
- part);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ "statfs",
+ part);
return -1;
}
return s.f_bavail;
@@ -227,7 +227,7 @@
* does not exist
*/
int disk_directory_test(struct GE_Context * ectx,
- const char * fil) {
+ const char * fil) {
struct stat filestat;
int ret;
@@ -235,9 +235,9 @@
if (ret != 0) {
if (errno != ENOENT) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
- "stat",
- fil);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
+ "stat",
+ fil);
return SYSERR;
}
return NO;
@@ -246,9 +246,9 @@
return NO;
if (ACCESS(fil, R_OK | X_OK) < 0 ) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
- "access",
- fil);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
+ "access",
+ fil);
return SYSERR;
}
return YES;
@@ -261,13 +261,13 @@
* else (will print an error message in that case, too).
*/
int disk_file_test(struct GE_Context * ectx,
- const char * fil) {
+ const char * fil) {
struct stat filestat;
int ret;
char * rdir;
rdir = string_expandFileName(ectx,
- fil);
+ fil);
if (rdir == NULL)
return SYSERR;
@@ -275,9 +275,9 @@
if (ret != 0) {
if (errno != ENOENT) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
- "stat",
- rdir);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
+ "stat",
+ rdir);
FREE(rdir);
return SYSERR;
}
@@ -290,9 +290,9 @@
}
if (ACCESS(rdir, R_OK) < 0 ) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
- "access",
- rdir);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
+ "access",
+ rdir);
FREE(rdir);
return SYSERR;
}
@@ -306,14 +306,14 @@
* @returns OK on success, SYSERR on failure
*/
int disk_directory_create(struct GE_Context * ectx,
- const char * dir) {
+ const char * dir) {
char * rdir;
int len;
int pos;
int ret = OK;
rdir = string_expandFileName(ectx,
- dir);
+ dir);
if (rdir == NULL)
return SYSERR;
@@ -337,32 +337,32 @@
#endif
while (pos <= len) {
if ( (rdir[pos] == DIR_SEPARATOR) ||
- (pos == len) ) {
+ (pos == len) ) {
rdir[pos] = '\0';
ret = disk_directory_test(ectx, rdir);
if (ret == SYSERR) {
- FREE(rdir);
- return SYSERR;
+ FREE(rdir);
+ return SYSERR;
}
if (ret == NO) {
#ifndef MINGW
- ret = mkdir(rdir,
- S_IRUSR | S_IWUSR |
- S_IXUSR | S_IRGRP |
- S_IXGRP | S_IROTH |
- S_IXOTH); /* 755 */
+ ret = mkdir(rdir,
+ S_IRUSR | S_IWUSR |
+ S_IXUSR | S_IRGRP |
+ S_IXGRP | S_IROTH |
+ S_IXOTH); /* 755 */
#else
- ret = mkdir(rdir);
+ ret = mkdir(rdir);
#endif
- if ( (ret != 0) &&
- (errno != EEXIST) ) {
- GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "mkdir",
- rdir);
- FREE(rdir);
- return SYSERR;
- }
+ if ( (ret != 0) &&
+ (errno != EEXIST) ) {
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_ERROR | GE_USER | GE_BULK,
+ "mkdir",
+ rdir);
+ FREE(rdir);
+ return SYSERR;
+ }
}
rdir[pos] = DIR_SEPARATOR;
}
@@ -381,18 +381,18 @@
* @returns OK on success, SYSERR on failure
*/
int disk_directory_create_for_file(struct GE_Context * ectx,
- const char * dir) {
+ const char * dir) {
char * rdir;
int len;
int ret;
rdir = string_expandFileName(ectx,
- dir);
+ dir);
if (rdir == NULL)
return SYSERR;
len = strlen(rdir);
while ( (len > 0) &&
- (rdir[len] != DIR_SEPARATOR) )
+ (rdir[len] != DIR_SEPARATOR) )
len--;
rdir[len] = '\0';
ret = disk_directory_create(ectx, rdir);
@@ -409,9 +409,9 @@
* @return the number of bytes read on success, -1 on failure
*/
int disk_file_read(struct GE_Context * ectx,
- const char * fileName,
- int len,
- void * result) {
+ const char * fileName,
+ int len,
+ void * result) {
/* open file, must exist, open read only */
int handle;
int size;
@@ -422,9 +422,9 @@
return 0;
GE_ASSERT(ectx, result != NULL);
handle = disk_file_open(ectx,
- fileName,
- O_RDONLY,
- S_IRUSR);
+ fileName,
+ O_RDONLY,
+ S_IRUSR);
if (handle < 0)
return -1;
size = READ(handle, result, len);
@@ -455,10 +455,10 @@
* @return OK on success, SYSERR on error
*/
int disk_file_write(struct GE_Context * ectx,
- const char * fileName,
- const void * buffer,
- unsigned int n,
- const char * mode) {
+ const char * fileName,
+ const void * buffer,
+ unsigned int n,
+ const char * mode) {
int handle;
char * fn;
@@ -467,32 +467,32 @@
GE_ASSERT(ectx, fileName != NULL);
fn = string_expandFileName(ectx, fileName);
handle = disk_file_open(ectx,
- fn,
- O_CREAT | O_WRONLY,
- S_IRUSR | S_IWUSR);
+ fn,
+ O_CREAT | O_WRONLY,
+ S_IRUSR | S_IWUSR);
if (handle == -1) {
FREE(fn);
return SYSERR;
}
GE_ASSERT(ectx,
- (n == 0) || (buffer != NULL));
+ (n == 0) || (buffer != NULL));
/* write the buffer take length from the beginning */
if (n != WRITE(handle, buffer, n)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_IMMEDIATE,
- "write",
- fn);
+ GE_WARNING | GE_USER | GE_IMMEDIATE,
+ "write",
+ fn);
disk_file_close(ectx, fn, handle);
FREE(fn);
return SYSERR;
}
disk_file_close(ectx, fn, handle);
if (0 != CHMOD(fn,
- atoo(mode))) {
+ atoo(mode))) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "chmod",
- fn);
+ GE_WARNING | GE_USER | GE_BULK,
+ "chmod",
+ fn);
}
FREE(fn);
return OK;
@@ -509,9 +509,9 @@
* ieration aborted by callback returning SYSERR
*/
int disk_directory_scan(struct GE_Context * ectx,
- const char * dirName,
- DirectoryEntryCallback callback,
- void * data) {
+ const char * dirName,
+ DirectoryEntryCallback callback,
+ void * data) {
DIR * dinfo;
struct dirent *finfo;
struct stat istat;
@@ -520,39 +520,39 @@
GE_ASSERT(ectx, dirName != NULL);
if (0 != STAT(dirName, &istat)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "stat",
- dirName);
+ GE_WARNING | GE_USER | GE_BULK,
+ "stat",
+ dirName);
return SYSERR;
}
if (!S_ISDIR(istat.st_mode)) {
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Expected `%s' to be a directory!\n"),
- dirName);
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Expected `%s' to be a directory!\n"),
+ dirName);
return SYSERR;
}
errno = 0;
dinfo = OPENDIR(dirName);
if ( (errno == EACCES) || (dinfo == NULL)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "opendir",
- dirName);
+ GE_WARNING | GE_USER | GE_BULK,
+ "opendir",
+ dirName);
return SYSERR;
}
while ((finfo = readdir(dinfo)) != NULL) {
if ( (0 == strcmp(finfo->d_name, ".")) ||
- (0 == strcmp(finfo->d_name, "..")) )
+ (0 == strcmp(finfo->d_name, "..")) )
continue;
if (callback != NULL) {
if (OK != callback(finfo->d_name,
- dirName,
- data)) {
- closedir(dinfo);
- return SYSERR;
+ dirName,
+ data)) {
+ closedir(dinfo);
+ return SYSERR;
}
- }
+ }
count++;
}
closedir(dinfo);
@@ -563,8 +563,8 @@
* Callback for disk_directory_remove
*/
static int rmHelper(const char * fil,
- const char * dir,
- void * ctx) {
+ const char * dir,
+ void * ctx) {
struct GE_Context * ectx = ctx;
char * fn;
size_t n;
@@ -572,12 +572,12 @@
n = strlen(dir) + strlen(fil) + 2;
fn = MALLOC(n);
SNPRINTF(fn,
- n,
- "%s/%s",
- dir,
- fil);
+ n,
+ "%s/%s",
+ dir,
+ fil);
if (SYSERR == disk_directory_remove(ectx,
- fn)) {
+ fn)) {
FREE(fn);
return SYSERR;
}
@@ -594,7 +594,7 @@
* @return OK on success, SYSERR on error
*/
int disk_directory_remove(struct GE_Context * ectx,
- const char * fileName) {
+ const char * fileName) {
struct stat istat;
if (0 != STAT(fileName, &istat))
@@ -603,44 +603,44 @@
return OK;
if ( (errno != EISDIR) &&
/* EISDIR is not sufficient in all cases, e.g.
- sticky /tmp directory may result in EPERM on BSD.
- So we also explicitly check "isDirectory" */
+ sticky /tmp directory may result in EPERM on BSD.
+ So we also explicitly check "isDirectory" */
(YES != disk_directory_test(ectx, fileName)) ) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- "rmdir",
- fileName);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ "rmdir",
+ fileName);
return SYSERR;
}
if (SYSERR == disk_directory_scan(ectx,
- fileName,
- &rmHelper,
- ectx))
+ fileName,
+ &rmHelper,
+ ectx))
return SYSERR;
if (0 != RMDIR(fileName)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- "rmdir",
- fileName);
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ "rmdir",
+ fileName);
return SYSERR;
}
return OK;
}
void disk_file_close(struct GE_Context * ectx,
- const char * filename,
- int fd) {
+ const char * filename,
+ int fd) {
if (0 != CLOSE(fd))
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "close",
- filename);
+ GE_WARNING | GE_USER | GE_BULK,
+ "close",
+ filename);
}
int disk_file_open(struct GE_Context * ectx,
- const char * filename,
- int oflag,
- ...) {
+ const char * filename,
+ int oflag,
+ ...) {
char * fn;
int mode;
int ret;
@@ -649,13 +649,13 @@
long lRet;
if ((lRet = plibc_conv_to_win_path(filename,
- szFile)) != ERROR_SUCCESS) {
+ szFile)) != ERROR_SUCCESS) {
errno = ENOENT;
SetLastError(lRet);
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_DEVELOPER | GE_ADMIN |
GE_BULK,
- "plibc_conv_to_win_path",
- filename);
+ GE_WARNING | GE_USER | GE_DEVELOPER | GE_ADMIN | GE_BULK,
+ "plibc_conv_to_win_path",
+ filename);
return -1;
}
fn = STRDUP(szFile);
@@ -677,9 +677,9 @@
ret = open(fn, oflag, mode);
if (ret == -1)
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "open",
- fn);
+ GE_WARNING | GE_USER | GE_BULK,
+ "open",
+ fn);
FREE(fn);
return ret;
}
@@ -691,8 +691,8 @@
* @return OK on success, SYSERR on error
*/
int disk_file_copy(struct GE_Context * ectx,
- const char * src,
- const char * dst) {
+ const char * src,
+ const char * dst) {
char * buf;
unsigned long long pos;
unsigned long long size;
@@ -701,24 +701,24 @@
int out;
if (OK != disk_file_size(ectx,
- src,
- &size,
- YES))
+ src,
+ &size,
+ YES))
return SYSERR;
pos = 0;
in = disk_file_open(ectx,
- src,
- O_RDONLY | O_LARGEFILE);
+ src,
+ O_RDONLY | O_LARGEFILE);
if (in == -1)
return SYSERR;
out = disk_file_open(ectx,
- dst,
- O_LARGEFILE | O_WRONLY | O_CREAT | O_EXCL,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ dst,
+ O_LARGEFILE | O_WRONLY | O_CREAT | O_EXCL,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (out == -1) {
disk_file_close(ectx,
- src,
- in);
+ src,
+ in);
return SYSERR;
}
buf = MALLOC(COPY_BLK_SIZE);
Modified: GNUnet/src/util/disk/storagetest.c
===================================================================
--- GNUnet/src/util/disk/storagetest.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/disk/storagetest.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -33,22 +33,22 @@
char tmp[100];
disk_file_write(NULL,
- ".testfile",
- TESTSTRING,
- strlen(TESTSTRING),
- "644");
+ ".testfile",
+ TESTSTRING,
+ strlen(TESTSTRING),
+ "644");
tmp[disk_file_read(NULL,
- ".testfile",
- 100,
- tmp)] = '\0';
+ ".testfile",
+ 100,
+ tmp)] = '\0';
if (0 != memcmp(tmp,
- TESTSTRING,
- strlen(TESTSTRING)+1)) {
+ TESTSTRING,
+ strlen(TESTSTRING)+1)) {
fprintf(stderr,
- "Error in testReadWrite: *%s* != *%s* for file %s\n",
- tmp,
- TESTSTRING,
- ".testfile");
+ "Error in testReadWrite: *%s* != *%s* for file %s\n",
+ tmp,
+ TESTSTRING,
+ ".testfile");
return 1;
}
UNLINK(".testfile");
Modified: GNUnet/src/util/error/error.c
===================================================================
--- GNUnet/src/util/error/error.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/error/error.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -49,17 +49,17 @@
* @param mask the filter mask
*/
int GE_applies(GE_KIND have,
- GE_KIND mask) {
+ GE_KIND mask) {
GE_KIND both = mask & have;
return ( (both & GE_EVENTKIND) &&
- (both & GE_USERKIND) &&
- (both & GE_ROUTEKIND) );
+ (both & GE_USERKIND) &&
+ (both & GE_ROUTEKIND) );
}
void GE_LOG(struct GE_Context * ctx,
- GE_KIND kind,
- const char * message,
- ...) {
+ GE_KIND kind,
+ const char * message,
+ ...) {
va_list va;
char date[64];
time_t timetmp;
@@ -75,7 +75,7 @@
return;
if ( (ctx == NULL) &&
( ((kind & (GE_IMMEDIATE | GE_BULK)) == 0) ||
- ((kind & (GE_FATAL | GE_ERROR | GE_WARNING)) == 0) ) )
+ ((kind & (GE_FATAL | GE_ERROR | GE_WARNING)) == 0) ) )
return;
va_start(va, message);
@@ -91,19 +91,19 @@
memset(date, 0, 64);
tmptr = localtime(&timetmp);
strftime(date,
- 64,
- "%b %d %H:%M:%S",
- tmptr);
+ 64,
+ "%b %d %H:%M:%S",
+ tmptr);
if (ctx != NULL)
ctx->handler(ctx->cls,
- kind,
- date,
- buf);
+ kind,
+ date,
+ buf);
else
fprintf(stderr,
- "%s %s",
- date,
- buf);
+ "%s %s",
+ date,
+ buf);
free(buf);
}
@@ -119,7 +119,7 @@
/* Console open? */
if (GetStdHandle(STD_ERROR_HANDLE) != NULL) {
fprintf(stderr,
- _("\nPress any key to continue\n"));
+ _("\nPress any key to continue\n"));
getch();
}
#endif
@@ -137,9 +137,9 @@
*/
struct GE_Context *
GE_create_context_callback(GE_KIND mask,
- GE_LogHandler handler,
- void * ctx,
- GE_CtxFree liberator,
+ GE_LogHandler handler,
+ void * ctx,
+ GE_CtxFree liberator,
GE_Confirm confirm) {
GE_Context * ret;
@@ -173,11 +173,11 @@
* @param have the kind of event
*/
int GE_isLogged(GE_Context * ctx,
- GE_KIND kind) {
+ GE_KIND kind) {
if (ctx == NULL)
return YES;
return GE_applies(kind,
- ctx->mask);
+ ctx->mask);
}
/**
@@ -187,40 +187,40 @@
*/
GE_KIND GE_getKIND(const char * log) {
if (0 == strcasecmp(log,
- _("DEBUG")))
+ _("DEBUG")))
return GE_DEBUG;
if (0 == strcasecmp(log,
- _("STATUS")))
+ _("STATUS")))
return GE_STATUS;
if (0 == strcasecmp(log,
- _("WARNING")))
+ _("WARNING")))
return GE_WARNING;
if (0 == strcasecmp(log,
- _("ERROR")))
+ _("ERROR")))
return GE_ERROR;
if (0 == strcasecmp(log,
- _("FATAL")))
+ _("FATAL")))
return GE_FATAL;
if (0 == strcasecmp(log,
- _("USER")))
+ _("USER")))
return GE_USER;
if (0 == strcasecmp(log,
- _("ADMIN")))
+ _("ADMIN")))
return GE_ADMIN;
if (0 == strcasecmp(log,
- _("DEVELOPER")))
+ _("DEVELOPER")))
return GE_DEVELOPER;
if (0 == strcasecmp(log,
- _("REQUEST")))
+ _("REQUEST")))
return GE_REQUEST;
if (0 == strcasecmp(log,
- _("BULK")))
+ _("BULK")))
return GE_BULK;
if (0 == strcasecmp(log,
- _("IMMEDIATE")))
+ _("IMMEDIATE")))
return GE_IMMEDIATE;
if (0 == strcasecmp(log,
- _("ALL")))
+ _("ALL")))
return GE_ALL;
return GE_INVALID;
@@ -264,9 +264,9 @@
} CPair;
static void multiplexer(void * ctx,
- GE_KIND kind,
- const char * date,
- const char * msg) {
+ GE_KIND kind,
+ const char * date,
+ const char * msg) {
CPair * pair = ctx;
if (GE_applies(kind, pair->c1->mask))
@@ -299,7 +299,7 @@
*/
struct GE_Context *
GE_create_context_multiplexer(struct GE_Context * ctx1,
- struct GE_Context * ctx2) {
+ struct GE_Context * ctx2) {
CPair * cls;
GE_Context * ret;
Modified: GNUnet/src/util/getopt/getopt.c
===================================================================
--- GNUnet/src/util/getopt/getopt.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/getopt/getopt.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -4,7 +4,7 @@
before changing it!
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97
- Free Software Foundation, Inc.
+ Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to address@hidden
@@ -61,9 +61,9 @@
When compiling libc, the _ macro is predefined. */
# ifdef HAVE_LIBINTL_H
# include <libintl.h>
-# define _(msgid) gettext (msgid)
+# define _(msgid) gettext (msgid)
# else
-# define _(msgid) (msgid)
+# define _(msgid) (msgid)
# endif
#endif
@@ -73,9 +73,9 @@
zero.
The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
@@ -198,13 +198,13 @@
/* Value of POSIXLY_CORRECT environment variable. */
static char *posixly_correct;
-#ifdef __GNU_LIBRARY__
+#ifdef __GNU_LIBRARY__
/* We want to avoid inclusion of string.h with non-GNU libraries
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
in GCC. */
#include <string.h>
-#define my_index strchr
+#define my_index strchr
#else
/* Avoid depending on library functions or files
@@ -220,7 +220,7 @@
while (*str)
{
if (*str == chr)
- return (char *) str;
+ return (char *) str;
str++;
}
return 0;
@@ -279,15 +279,15 @@
text_set_element (__libc_subinit, store_args_and_env);
# define SWAP_FLAGS(ch1, ch2) \
- if (nonoption_flags_len > 0) \
- { \
- char __tmp = __getopt_nonoption_flags[ch1]; \
- __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
- __getopt_nonoption_flags[ch2] = __tmp; \
+ if (nonoption_flags_len > 0) \
+ { \
+ char __tmp = __getopt_nonoption_flags[ch1]; \
+ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
+ __getopt_nonoption_flags[ch2] = __tmp; \
}
-#else /* !_LIBC */
+#else /* !_LIBC */
# define SWAP_FLAGS(ch1, ch2)
-#endif /* _LIBC */
+#endif /* _LIBC */
/* Exchange two adjacent subsequences of ARGV.
One subsequence is elements [first_nonopt,last_nonopt)
@@ -323,57 +323,57 @@
if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
{
/* We must extend the array. The user plays games with us and
- presents new arguments. */
+ presents new arguments. */
char *new_str = malloc (top + 1);
if (new_str == NULL)
- nonoption_flags_len = nonoption_flags_max_len = 0;
+ nonoption_flags_len = nonoption_flags_max_len = 0;
else
- {
- memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len);
- memset (&new_str[nonoption_flags_max_len], '\0',
- top + 1 - nonoption_flags_max_len);
- nonoption_flags_max_len = top + 1;
- __getopt_nonoption_flags = new_str;
- }
+ {
+ memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len);
+ memset (&new_str[nonoption_flags_max_len], '\0',
+ top + 1 - nonoption_flags_max_len);
+ nonoption_flags_max_len = top + 1;
+ __getopt_nonoption_flags = new_str;
+ }
}
#endif
while (top > middle && middle > bottom)
{
if (top - middle > middle - bottom)
- {
- /* Bottom segment is the short one. */
- int len = middle - bottom;
- register int i;
+ {
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ register int i;
- /* Swap it with the top part of the top segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[top - (middle - bottom) + i];
- argv[top - (middle - bottom) + i] = tem;
- SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
- }
- /* Exclude the moved bottom segment from further swapping. */
- top -= len;
- }
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ }
else
- {
- /* Top segment is the short one. */
- int len = top - middle;
- register int i;
+ {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ register int i;
- /* Swap it with the bottom part of the bottom segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[middle + i];
- argv[middle + i] = tem;
- SWAP_FLAGS (bottom + i, middle + i);
- }
- /* Exclude the moved top segment from further swapping. */
- bottom += len;
- }
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ SWAP_FLAGS (bottom + i, middle + i);
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
+ }
}
/* Update records for the slots the non-options now occupy. */
@@ -425,28 +425,28 @@
&& argc == original_argc && argv == original_argv)
{
if (nonoption_flags_max_len == 0)
- {
- if (__getopt_nonoption_flags == NULL
- || __getopt_nonoption_flags[0] == '\0')
- nonoption_flags_max_len = -1;
- else
- {
- const char *orig_str = __getopt_nonoption_flags;
- int len = nonoption_flags_max_len = strlen (orig_str);
- if (nonoption_flags_max_len < argc)
- nonoption_flags_max_len = argc;
- __getopt_nonoption_flags =
- (char *) malloc (nonoption_flags_max_len);
- if (__getopt_nonoption_flags == NULL)
- nonoption_flags_max_len = -1;
- else
- {
- memcpy (__getopt_nonoption_flags, orig_str, len);
- memset (&__getopt_nonoption_flags[len], '\0',
- nonoption_flags_max_len - len);
- }
- }
- }
+ {
+ if (__getopt_nonoption_flags == NULL
+ || __getopt_nonoption_flags[0] == '\0')
+ nonoption_flags_max_len = -1;
+ else
+ {
+ const char *orig_str = __getopt_nonoption_flags;
+ int len = nonoption_flags_max_len = strlen (orig_str);
+ if (nonoption_flags_max_len < argc)
+ nonoption_flags_max_len = argc;
+ __getopt_nonoption_flags =
+ (char *) malloc (nonoption_flags_max_len);
+ if (__getopt_nonoption_flags == NULL)
+ nonoption_flags_max_len = -1;
+ else
+ {
+ memcpy (__getopt_nonoption_flags, orig_str, len);
+ memset (&__getopt_nonoption_flags[len], '\0',
+ nonoption_flags_max_len - len);
+ }
+ }
+ }
nonoption_flags_len = nonoption_flags_max_len;
}
else
@@ -526,7 +526,7 @@
if (GNoptind == 0 || !__getopt_initialized)
{
if (GNoptind == 0)
- GNoptind = 1; /* Don't scan ARGV[0], the program name. */
+ GNoptind = 1; /* Don't scan ARGV[0], the program name. */
optstring = _getopt_initialize (argc, argv, optstring);
__getopt_initialized = 1;
}
@@ -536,9 +536,9 @@
from the shell indicating it is not an option. The later information
is only used when the used in the GNU libc. */
#ifdef _LIBC
-#define NONOPTION_P (argv[GNoptind][0] != '-' || argv[GNoptind][1] == '\0'
\
- || (GNoptind < nonoption_flags_len \
- && __getopt_nonoption_flags[GNoptind] == '1'))
+#define NONOPTION_P (argv[GNoptind][0] != '-' || argv[GNoptind][1] == '\0'
\
+ || (GNoptind < nonoption_flags_len \
+ && __getopt_nonoption_flags[GNoptind] == '1'))
#else
#define NONOPTION_P (argv[GNoptind][0] != '-' || argv[GNoptind][1] == '\0')
#endif
@@ -548,76 +548,76 @@
/* Advance to the next ARGV-element. */
/* Give FIRST_NONOPT & LAST_NONOPT rational values if GNoptind has been
- moved back by the user (who may also have changed the arguments). */
+ moved back by the user (who may also have changed the arguments). */
if (last_nonopt > GNoptind)
- last_nonopt = GNoptind;
+ last_nonopt = GNoptind;
if (first_nonopt > GNoptind)
- first_nonopt = GNoptind;
+ first_nonopt = GNoptind;
if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
+ {
+ /* If we have just processed some options following some non-options,
+ exchange them so that the options come first. */
- if (first_nonopt != last_nonopt && last_nonopt != GNoptind)
- exchange ((char **) argv);
- else if (last_nonopt != GNoptind)
- first_nonopt = GNoptind;
+ if (first_nonopt != last_nonopt && last_nonopt != GNoptind)
+ exchange ((char **) argv);
+ else if (last_nonopt != GNoptind)
+ first_nonopt = GNoptind;
- /* Skip any additional non-options
- and extend the range of non-options previously skipped. */
+ /* Skip any additional non-options
+ and extend the range of non-options previously skipped. */
- while (GNoptind < argc && NONOPTION_P)
- GNoptind++;
- last_nonopt = GNoptind;
- }
+ while (GNoptind < argc && NONOPTION_P)
+ GNoptind++;
+ last_nonopt = GNoptind;
+ }
/* The special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
+ Skip it like a null option,
+ then exchange with previous non-options as if it were an option,
+ then skip everything else like a non-option. */
if (GNoptind != argc && !strcmp (argv[GNoptind], "--"))
- {
- GNoptind++;
+ {
+ GNoptind++;
- if (first_nonopt != last_nonopt && last_nonopt != GNoptind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = GNoptind;
- last_nonopt = argc;
+ if (first_nonopt != last_nonopt && last_nonopt != GNoptind)
+ exchange ((char **) argv);
+ else if (first_nonopt == last_nonopt)
+ first_nonopt = GNoptind;
+ last_nonopt = argc;
- GNoptind = argc;
- }
+ GNoptind = argc;
+ }
/* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
+ and back over any non-options that we skipped and permuted. */
if (GNoptind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- GNoptind = first_nonopt;
- return -1;
- }
+ {
+ /* Set the next-arg-index to point at the non-options
+ that we previously skipped, so the caller will digest them. */
+ if (first_nonopt != last_nonopt)
+ GNoptind = first_nonopt;
+ return -1;
+ }
/* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
+ either stop the scan or describe it to the caller and pass it by. */
if (NONOPTION_P)
- {
- if (ordering == REQUIRE_ORDER)
- return -1;
- GNoptarg = argv[GNoptind++];
- return 1;
- }
+ {
+ if (ordering == REQUIRE_ORDER)
+ return -1;
+ GNoptarg = argv[GNoptind++];
+ return 1;
+ }
/* We have found another option-ARGV-element.
- Skip the initial punctuation. */
+ Skip the initial punctuation. */
nextchar = (argv[GNoptind] + 1
- + (longopts != NULL && argv[GNoptind][1] == '-'));
+ + (longopts != NULL && argv[GNoptind][1] == '-'));
}
/* Decode the current option-ARGV-element. */
@@ -637,7 +637,7 @@
if (longopts != NULL
&& (argv[GNoptind][1] == '-'
- || (long_only && (argv[GNoptind][2] || !my_index (optstring,
argv[GNoptind][1])))))
+ || (long_only && (argv[GNoptind][2] || !my_index (optstring,
argv[GNoptind][1])))))
{
char *nameend;
const struct GNoption *p;
@@ -648,124 +648,124 @@
int option_index;
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
- /* Do nothing. */ ;
+ /* Do nothing. */ ;
/* Test all long options for either exact match
- or abbreviated matches. */
+ or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp (p->name, nextchar, nameend - nextchar))
- {
- if ((unsigned int) (nameend - nextchar)
- == (unsigned int) strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
+ if (!strncmp (p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend - nextchar)
+ == (unsigned int) strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
if (ambig && !exact)
- {
- if (GNopterr)
- fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
- argv[0], argv[GNoptind]);
- nextchar += strlen (nextchar);
- GNoptind++;
- GNoptopt = 0;
- return '?';
- }
+ {
+ if (GNopterr)
+ fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[GNoptind]);
+ nextchar += strlen (nextchar);
+ GNoptind++;
+ GNoptopt = 0;
+ return '?';
+ }
if (pfound != NULL)
- {
- option_index = indfound;
- GNoptind++;
- if (*nameend)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- GNoptarg = nameend + 1;
- else
- {
- if (GNopterr) {
- if (argv[GNoptind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- _("%s: option `--%s' does not allow an
argument\n"),
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- _("%s: option `%c%s' does not allow an
argument\n"),
- argv[0], argv[GNoptind - 1][0], pfound->name);
- }
- nextchar += strlen (nextchar);
+ {
+ option_index = indfound;
+ GNoptind++;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ GNoptarg = nameend + 1;
+ else
+ {
+ if (GNopterr) {
+ if (argv[GNoptind - 1][1] == '-')
+ /* --option */
+ fprintf (stderr,
+ _("%s: option `--%s' does not allow an argument\n"),
+ argv[0], pfound->name);
+ else
+ /* +option or -option */
+ fprintf (stderr,
+ _("%s: option `%c%s' does not allow an argument\n"),
+ argv[0], argv[GNoptind - 1][0], pfound->name);
+ }
+ nextchar += strlen (nextchar);
- GNoptopt = pfound->val;
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (GNoptind < argc) {
- GNoptarg = argv[GNoptind++];
- } else
- {
- if (GNopterr) {
- fprintf (stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[GNoptind - 1]);
- }
- nextchar += strlen (nextchar);
- GNoptopt = pfound->val;
- return (optstring[0] == ':') ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
+ GNoptopt = pfound->val;
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (GNoptind < argc) {
+ GNoptarg = argv[GNoptind++];
+ } else
+ {
+ if (GNopterr) {
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[GNoptind - 1]);
+ }
+ nextchar += strlen (nextchar);
+ GNoptopt = pfound->val;
+ return (optstring[0] == ':') ? ':' : '?';
+ }
+ }
+ nextchar += strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
/* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
+ or the option starts with '--' or is not a valid short
+ option, then it's an error.
+ Otherwise interpret it as a short option. */
if (!long_only || argv[GNoptind][1] == '-'
- || my_index (optstring, *nextchar) == NULL)
- {
- if (GNopterr)
- {
- if (argv[GNoptind][1] == '-')
- /* --option */
- fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
- argv[0], argv[GNoptind][0], nextchar);
- }
- nextchar = (char *) "";
- GNoptind++;
- GNoptopt = 0;
- return '?';
- }
+ || my_index (optstring, *nextchar) == NULL)
+ {
+ if (GNopterr)
+ {
+ if (argv[GNoptind][1] == '-')
+ /* --option */
+ fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
+ argv[0], nextchar);
+ else
+ /* +option or -option */
+ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[GNoptind][0], nextchar);
+ }
+ nextchar = (char *) "";
+ GNoptind++;
+ GNoptopt = 0;
+ return '?';
+ }
}
/* Look at and handle the next short option-character. */
@@ -780,188 +780,188 @@
if (temp == NULL || c == ':')
{
- if (GNopterr)
- {
- if (posixly_correct)
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, _("%s: illegal option -- %c\n"),
- argv[0], c);
- else
- fprintf (stderr, _("%s: invalid option -- %c\n"),
- argv[0], c);
- }
- GNoptopt = c;
- return '?';
+ if (GNopterr)
+ {
+ if (posixly_correct)
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, _("%s: illegal option -- %c\n"),
+ argv[0], c);
+ else
+ fprintf (stderr, _("%s: invalid option -- %c\n"),
+ argv[0], c);
+ }
+ GNoptopt = c;
+ return '?';
}
/* Convenience. Treat POSIX -W foo same as long option --foo */
if (temp[0] == 'W' && temp[1] == ';')
{
- char *nameend;
- const struct GNoption *p;
- const struct GNoption *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound = 0;
- int option_index;
+ char *nameend;
+ const struct GNoption *p;
+ const struct GNoption *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = 0;
+ int option_index;
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- GNoptarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- GNoptind++;
- }
- else if (GNoptind == argc)
- {
- if (GNopterr)
- {
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, _("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- GNoptopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- return c;
- }
- else
- /* We already incremented `GNoptind' once;
- increment it again when taking next ARGV-elt as argument. */
- GNoptarg = argv[GNoptind++];
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ GNoptarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ GNoptind++;
+ }
+ else if (GNoptind == argc)
+ {
+ if (GNopterr)
+ {
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ GNoptopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ return c;
+ }
+ else
+ /* We already incremented `GNoptind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ GNoptarg = argv[GNoptind++];
- /* GNoptarg is now the argument, see if it's in the
- table of longopts. */
+ /* GNoptarg is now the argument, see if it's in the
+ table of longopts. */
- for (nextchar = nameend = GNoptarg; *nameend && *nameend != '=';
nameend++)
- /* Do nothing. */ ;
+ for (nextchar = nameend = GNoptarg; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */ ;
- /* Test all long options for either exact match
- or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp (p->name, nextchar, nameend - nextchar))
- {
- if ((unsigned int) (nameend - nextchar) == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
- if (ambig && !exact)
- {
- if (GNopterr)
- fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
- argv[0], argv[GNoptind]);
- nextchar += strlen (nextchar);
- GNoptind++;
- return '?';
- }
- if (pfound != NULL)
- {
- option_index = indfound;
- if (*nameend)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- GNoptarg = nameend + 1;
- else
- {
- if (GNopterr)
- fprintf (stderr, _("\
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend - nextchar) == strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+ if (ambig && !exact)
+ {
+ if (GNopterr)
+ fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[GNoptind]);
+ nextchar += strlen (nextchar);
+ GNoptind++;
+ return '?';
+ }
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ GNoptarg = nameend + 1;
+ else
+ {
+ if (GNopterr)
+ fprintf (stderr, _("\
%s: option `-W %s' does not allow an argument\n"),
- argv[0], pfound->name);
+ argv[0], pfound->name);
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (GNoptind < argc)
- GNoptarg = argv[GNoptind++];
- else
- {
- if (GNopterr)
- fprintf (stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[GNoptind - 1]);
- nextchar += strlen (nextchar);
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- nextchar = NULL;
- return 'W'; /* Let the application handle it. */
+ nextchar += strlen (nextchar);
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (GNoptind < argc)
+ GNoptarg = argv[GNoptind++];
+ else
+ {
+ if (GNopterr)
+ fprintf (stderr,
+ _("%s: option `%s' requires an argument\n"),
+ argv[0], argv[GNoptind - 1]);
+ nextchar += strlen (nextchar);
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ nextchar += strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+ nextchar = NULL;
+ return 'W'; /* Let the application handle it. */
}
if (temp[1] == ':')
{
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- GNoptarg = nextchar;
- GNoptind++;
- }
- else
- GNoptarg = NULL;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- GNoptarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- GNoptind++;
- }
- else if (GNoptind == argc)
- {
- if (GNopterr)
- {
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr,
- _("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- GNoptopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- }
- else
- /* We already incremented `GNoptind' once;
- increment it again when taking next ARGV-elt as argument. */
- GNoptarg = argv[GNoptind++];
- nextchar = NULL;
- }
+ if (temp[2] == ':')
+ {
+ /* This is an option that accepts an argument optionally. */
+ if (*nextchar != '\0')
+ {
+ GNoptarg = nextchar;
+ GNoptind++;
+ }
+ else
+ GNoptarg = NULL;
+ nextchar = NULL;
+ }
+ else
+ {
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ GNoptarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ GNoptind++;
+ }
+ else if (GNoptind == argc)
+ {
+ if (GNopterr)
+ {
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr,
+ _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ GNoptopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ }
+ else
+ /* We already incremented `GNoptind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ GNoptarg = argv[GNoptind++];
+ nextchar = NULL;
+ }
}
return c;
}
@@ -969,16 +969,16 @@
static int
GNgetopt_long(int argc,
- char * const * argv,
- const char * options,
- const struct GNoption * long_options,
- int * opt_index) {
+ char * const * argv,
+ const char * options,
+ const struct GNoption * long_options,
+ int * opt_index) {
return GN_getopt_internal(argc,
- argv,
- options,
- long_options,
- opt_index,
- 0);
+ argv,
+ options,
+ long_options,
+ opt_index,
+ 0);
}
/* ******************** now the GNUnet specific modifications...
********************* */
@@ -996,11 +996,11 @@
* argument, or -1 on error
*/
int gnunet_parse_options(const char * binaryOptions,
- struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const CommandLineOption * allOptions,
- unsigned int argc,
- char * const * argv) {
+ struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const CommandLineOption * allOptions,
+ unsigned int argc,
+ char * const * argv) {
struct GNoption * long_options;
CommandLineProcessorContext clpc;
int count;
@@ -1043,10 +1043,10 @@
while (cont == OK) {
int option_index = 0;
c = GNgetopt_long(argc,
- argv,
- shorts,
- long_options,
- &option_index);
+ argv,
+ shorts,
+ long_options,
+ &option_index);
if (c == SYSERR)
break; /* No more flags to process */
@@ -1054,17 +1054,17 @@
for (i=0;i<count;i++) {
clpc.currentArgument = GNoptind - 1;
if ((char)c == allOptions[i].shortName) {
- cont = allOptions[i].processor(&clpc,
- allOptions[i].scls,
- allOptions[i].name,
- GNoptarg);
- break;
+ cont = allOptions[i].processor(&clpc,
+ allOptions[i].scls,
+ allOptions[i].name,
+ GNoptarg);
+ break;
}
}
if (i == count) {
GE_LOG(ectx,
- GE_INFO | GE_USER | GE_IMMEDIATE,
- _("Use --help to get a list of options.\n"));
+ GE_INFO | GE_USER | GE_IMMEDIATE,
+ _("Use --help to get a list of options.\n"));
cont = SYSERR;
}
}
Modified: GNUnet/src/util/getopt/printhelp.c
===================================================================
--- GNUnet/src/util/getopt/printhelp.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/getopt/printhelp.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -31,9 +31,9 @@
#define BORDER 29
int gnunet_getopt_format_help(CommandLineProcessorContext * ctx,
- void * scls,
- const char * option,
- const char * value) {
+ void * scls,
+ const char * option,
+ const char * value) {
const char * about = scls;
int slen;
int i;
@@ -43,10 +43,10 @@
char * scp;
const char * trans;
const struct CommandLineOption * opt;
-
+
printf("%s\n%s\n",
- ctx->binaryOptions,
- gettext(about));
+ ctx->binaryOptions,
+ gettext(about));
printf(_("Arguments mandatory for long options are also mandatory for short
options.\n"));
slen = 0;
i = 0;
@@ -56,13 +56,13 @@
printf(" ");
else
printf(" -%c, ",
- opt[i].shortName);
+ opt[i].shortName);
printf("--%s",
- opt[i].name);
+ opt[i].name);
slen = 8 + strlen(opt[i].name);
if (opt[i].argumentHelp != NULL) {
printf("=%s",
- opt[i].argumentHelp);
+ opt[i].argumentHelp);
slen += 1+strlen(opt[i].argumentHelp);
}
if (slen > BORDER) {
@@ -79,32 +79,32 @@
OUTER:
while (ml - p > 78 - slen) {
for (j=p+78-slen;j>p;j--) {
- if (isspace(trans[j])) {
- scp = MALLOC(j-p+1);
- memcpy(scp,
- &trans[p],
- j-p);
- scp[j-p] = '\0';
- printf("%s\n%*s",
- scp,
- BORDER+2,
- "");
- FREE(scp);
- p = j+1;
- slen = BORDER+2;
- goto OUTER;
- }
+ if (isspace(trans[j])) {
+ scp = MALLOC(j-p+1);
+ memcpy(scp,
+ &trans[p],
+ j-p);
+ scp[j-p] = '\0';
+ printf("%s\n%*s",
+ scp,
+ BORDER+2,
+ "");
+ FREE(scp);
+ p = j+1;
+ slen = BORDER+2;
+ goto OUTER;
+ }
}
/* could not find space to break line */
scp = MALLOC(78 - slen + 1);
memcpy(scp,
- &trans[p],
- 78 - slen);
+ &trans[p],
+ 78 - slen);
scp[78 - slen] = '\0';
printf("%s\n%*s",
- scp,
- BORDER+2,
- "");
+ scp,
+ BORDER+2,
+ "");
FREE(scp);
slen = BORDER+2;
p = p + 78 - slen;
@@ -112,7 +112,7 @@
/* print rest */
if (p < ml)
printf("%s\n",
- &trans[p]);
+ &trans[p]);
if (strlen(trans) == 0)
printf("\n");
i++;
Modified: GNUnet/src/util/getopt/printversion.c
===================================================================
--- GNUnet/src/util/getopt/printversion.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/getopt/printversion.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -29,14 +29,14 @@
#include "platform.h"
int gnunet_getopt_print_version(CommandLineProcessorContext * ctx,
- void * scls,
- const char * option,
- const char * value) {
+ void * scls,
+ const char * option,
+ const char * value) {
const char * version = scls;
printf("%s v%s\n",
- ctx->binaryName,
- version);
+ ctx->binaryName,
+ version);
return SYSERR;
}
Modified: GNUnet/src/util/getopt/setoption.c
===================================================================
--- GNUnet/src/util/getopt/setoption.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/getopt/setoption.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -31,9 +31,9 @@
int gnunet_getopt_configure_set_option(CommandLineProcessorContext * ctx,
- void * scls,
- const char * cmdLineOption,
- const char * value) {
+ void * scls,
+ const char * cmdLineOption,
+ const char * value) {
char * section = STRDUP(scls);
struct GC_Configuration * cfg = ctx->cfg;
char * option;
@@ -41,25 +41,25 @@
option = strstr(section, ":");
GE_ASSERT(ctx->ectx,
- option != NULL);
+ option != NULL);
option[0] = '\0';
option++;
if (value == NULL)
value = "YES";
ret = GC_set_configuration_value_string(cfg,
- ctx->ectx,
- section,
- option,
- value);
+ ctx->ectx,
+ section,
+ option,
+ value);
if (ret != 0) {
GE_LOG(ctx->ectx,
- GE_USER | GE_BULK | GE_ERROR,
- _("Setting option `%s' in section `%s' to `%s' when processing
command line option `%s' was denied.\n"),
- option,
- section,
- value,
- cmdLineOption);
+ GE_USER | GE_BULK | GE_ERROR,
+ _("Setting option `%s' in section `%s' to `%s' when processing command
line option `%s' was denied.\n"),
+ option,
+ section,
+ value,
+ cmdLineOption);
FREE(section);
return SYSERR;
}
@@ -68,9 +68,9 @@
}
int gnunet_getopt_configure_increment_value(CommandLineProcessorContext * ctx,
- void * scls,
- const char * cmdLineOption,
- const char * value) {
+ void * scls,
+ const char * cmdLineOption,
+ const char * value) {
char * section = STRDUP(scls);
struct GC_Configuration * cfg = ctx->cfg;
char * option;
@@ -79,25 +79,25 @@
option = strstr(section, ":");
GE_ASSERT(ctx->ectx,
- option != NULL);
+ option != NULL);
option[0] = '\0';
option++;
ret = GC_get_configuration_value_number(cfg,
- section,
- option,
- 0,
- (unsigned long long) -1L,
- 0,
- &old);
+ section,
+ option,
+ 0,
+ (unsigned long long) -1L,
+ 0,
+ &old);
if (ret == SYSERR) {
FREE(section);
return SYSERR;
}
ret = GC_set_configuration_value_number(cfg,
- ctx->ectx,
- section,
- option,
- old+1);
+ ctx->ectx,
+ section,
+ option,
+ old+1);
FREE(section);
if (ret == 0)
ret = OK;
@@ -107,18 +107,18 @@
}
int gnunet_getopt_configure_set_one(CommandLineProcessorContext * ctx,
- void * scls,
- const char * option,
- const char * value) {
+ void * scls,
+ const char * option,
+ const char * value) {
int * val = scls;
*val = 1;
return OK;
}
int gnunet_getopt_configure_set_string(CommandLineProcessorContext * ctx,
- void * scls,
- const char * option,
- const char * value) {
+ void * scls,
+ const char * option,
+ const char * value) {
char ** val = scls;
GE_ASSERT(NULL, value != NULL);
@@ -127,31 +127,31 @@
}
int gnunet_getopt_configure_set_ulong(CommandLineProcessorContext * ctx,
- void * scls,
- const char * option,
- const char * value) {
+ void * scls,
+ const char * option,
+ const char * value) {
unsigned long long * val = scls;
if (1 != SSCANF(value, "%llu", val)) {
GE_LOG(ctx->ectx,
- GE_ERROR | GE_IMMEDIATE | GE_USER,
- _("You must pass a number to the `%s' option.\n"),
- "-X");
+ GE_ERROR | GE_IMMEDIATE | GE_USER,
+ _("You must pass a number to the `%s' option.\n"),
+ "-X");
return SYSERR;
}
return OK;
}
int gnunet_getopt_configure_set_uint(CommandLineProcessorContext * ctx,
- void * scls,
- const char * option,
- const char * value) {
+ void * scls,
+ const char * option,
+ const char * value) {
unsigned int * val = scls;
if (1 != SSCANF(value, "%u", val)) {
GE_LOG(ctx->ectx,
- GE_ERROR | GE_IMMEDIATE | GE_USER,
- _("You must pass a number to the `%s' option.\n"),
- "-X");
+ GE_ERROR | GE_IMMEDIATE | GE_USER,
+ _("You must pass a number to the `%s' option.\n"),
+ "-X");
return SYSERR;
}
return OK;
Modified: GNUnet/src/util/loggers/file.c
===================================================================
--- GNUnet/src/util/loggers/file.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/loggers/file.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -118,8 +118,8 @@
*/
static int
removeOldLog(const char * fil,
- const char * dir,
- void * ptr) {
+ const char * dir,
+ void * ptr) {
const FileContext * ctx = ptr;
struct tm t;
char * fullname;
@@ -139,8 +139,8 @@
strcat(fullname, DIR_SEPARATOR_STR);
strcat(fullname, fil);
if (0 != strncmp(def,
- fullname,
- strlen(def))) {
+ fullname,
+ strlen(def))) {
FREE(fullname);
return OK;
}
@@ -168,7 +168,7 @@
*/
static char *
getLogFileName(struct GE_Context * fctx,
- const char * name) {
+ const char * name) {
time_t curtime;
struct tm lcltime;
char * datefmt;
@@ -186,10 +186,10 @@
#endif
/* Format current date for filename*/
GE_ASSERT(fctx,
- 0 != strftime(date,
- 80,
- datefmt,
- &lcltime));
+ 0 != strftime(date,
+ 80,
+ datefmt,
+ &lcltime));
FREE(datefmt);
/* Remove special chars */
@@ -198,18 +198,18 @@
size = strlen(name) + 82;
ret = MALLOC(size);
SNPRINTF(ret,
- size,
- "%s-%s",
- name,
- date);
+ size,
+ "%s-%s",
+ name,
+ date);
return ret;
}
static void
filelogger(void * cls,
- GE_KIND kind,
- const char * date,
- const char * msg) {
+ GE_KIND kind,
+ const char * date,
+ const char * msg) {
FileContext * fctx = cls;
char * name;
int ret;
@@ -218,30 +218,30 @@
MUTEX_LOCK(fctx->lock);
if (fctx->logrotate) {
name = getLogFileName(fctx->ectx,
- fctx->basename);
+ fctx->basename);
if ( (fctx->first_start == YES) ||
- (0 != strcmp(name,
- fctx->filename)) ) {
+ (0 != strcmp(name,
+ fctx->filename)) ) {
fctx->first_start = NO;
fclose(fctx->handle);
fctx->handle = FOPEN(name, "a+");
if (fctx->handle == NULL) {
- fctx->handle = stderr;
- fprintf(stderr,
- _("Failed to open log-file `%s': %s\n"),
- name,
- STRERROR(errno));
+ fctx->handle = stderr;
+ fprintf(stderr,
+ _("Failed to open log-file `%s': %s\n"),
+ name,
+ STRERROR(errno));
}
FREE(fctx->filename);
fctx->filename = name;
dirname = STRDUP(name);
while ( (strlen(dirname) > 0) &&
- (dirname[strlen(dirname)-1] != DIR_SEPARATOR) )
- dirname[strlen(dirname)-1] = '\0';
+ (dirname[strlen(dirname)-1] != DIR_SEPARATOR) )
+ dirname[strlen(dirname)-1] = '\0';
disk_directory_scan(fctx->ectx,
- dirname,
- &removeOldLog,
- fctx);
+ dirname,
+ &removeOldLog,
+ fctx);
FREE(dirname);
} else {
FREE(name);
@@ -259,20 +259,20 @@
if (fctx->logdate) {
ret = fprintf(fctx->handle,
- "%s %s: %s",
- date,
- GE_kindToString(kind & GE_EVENTKIND),
- msg);
+ "%s %s: %s",
+ date,
+ GE_kindToString(kind & GE_EVENTKIND),
+ msg);
} else {
ret = fprintf(fctx->handle,
- "%s: %s",
- GE_kindToString(kind & GE_EVENTKIND),
- msg);
+ "%s: %s",
+ GE_kindToString(kind & GE_EVENTKIND),
+ msg);
}
if (ret < 0)
GE_LOG_STRERROR(fctx->ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK,
- "fclose");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK,
+ "fclose");
fflush(fctx->handle);
MUTEX_UNLOCK(fctx->lock);
@@ -289,11 +289,11 @@
(fctx->handle != stdout) &&
(0 != fclose(fctx->handle)) )
GE_LOG_STRERROR(fctx->ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK,
- "fclose");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK,
+ "fclose");
FREE(fctx);
}
-
+
/**
* Create a logger that writes events to a file.
*
@@ -305,10 +305,10 @@
*/
struct GE_Context *
GE_create_context_logfile(struct GE_Context * ectx,
- GE_KIND mask,
- const char * filename,
- int logDate,
- int logrotate) {
+ GE_KIND mask,
+ const char * filename,
+ int logDate,
+ int logrotate) {
FileContext * fctx;
FILE * fd;
char * name;
@@ -317,16 +317,16 @@
TIME(&start);
if (logrotate != 0) {
name = getLogFileName(NULL,
- filename);
+ filename);
} else {
name = STRDUP(filename);
}
fd = FOPEN(name, "a+");
if (fd == NULL) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK,
- "fopen",
- name);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE | GE_BULK,
+ "fopen",
+ name);
FREE(name);
return NULL; /* ERROR! */
}
@@ -341,10 +341,10 @@
fctx->logstart = start;
fctx->lock = MUTEX_CREATE(YES);
return GE_create_context_callback(mask,
- &filelogger,
- fctx,
- &fileclose,
- NULL);
+ &filelogger,
+ fctx,
+ &fileclose,
+ NULL);
}
@@ -355,7 +355,7 @@
*/
struct GE_Context *
GE_create_context_stderr(int logDate,
- GE_KIND mask) {
+ GE_KIND mask) {
FileContext * fctx;
fctx = MALLOC(sizeof(FileContext));
@@ -369,10 +369,10 @@
fctx->first_start = NO;
fctx->lock = MUTEX_CREATE(YES);
return GE_create_context_callback(mask,
- &filelogger,
- fctx,
- &fileclose,
- NULL);
+ &filelogger,
+ fctx,
+ &fileclose,
+ NULL);
}
@@ -383,7 +383,7 @@
*/
struct GE_Context *
GE_create_context_stdout(int logDate,
- GE_KIND mask) {
+ GE_KIND mask) {
FileContext * fctx;
fctx = MALLOC(sizeof(FileContext));
@@ -397,9 +397,9 @@
fctx->logstart = 0;
fctx->lock = MUTEX_CREATE(YES);
return GE_create_context_callback(mask,
- &filelogger,
- fctx,
- &fileclose,
- NULL);
+ &filelogger,
+ fctx,
+ &fileclose,
+ NULL);
}
Modified: GNUnet/src/util/loggers/memory.c
===================================================================
--- GNUnet/src/util/loggers/memory.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/loggers/memory.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -45,26 +45,26 @@
static void
memorylogger(void * cls,
- GE_KIND kind,
- const char * date,
- const char * msg) {
+ GE_KIND kind,
+ const char * date,
+ const char * msg) {
GE_Memory * ctx = cls;
unsigned int max;
MUTEX_LOCK(ctx->lock);
if (ctx->pos == ctx->size) {
if ( (ctx->maxSize != 0) &&
- (ctx->size == ctx->maxSize) ) {
+ (ctx->size == ctx->maxSize) ) {
MUTEX_UNLOCK(ctx->lock);
return;
}
max = ctx->pos * 2 + 16;
if ( (ctx->maxSize == 0) &&
- (max > ctx->maxSize) )
+ (max > ctx->maxSize) )
max = ctx->maxSize;
GROW(ctx->messages,
- ctx->size,
- max);
+ ctx->size,
+ max);
}
ctx->messages[ctx->pos].date = STRDUP(date);
if (ctx->pos == ctx->maxSize-1) {
@@ -84,12 +84,12 @@
*/
struct GE_Context *
GE_create_context_memory(GE_KIND mask,
- struct GE_Memory * memory) {
+ struct GE_Memory * memory) {
return GE_create_context_callback(mask,
- &memorylogger,
- memory,
- NULL,
- NULL);
+ &memorylogger,
+ memory,
+ NULL,
+ NULL);
}
/**
@@ -121,7 +121,7 @@
*/
const char *
GE_memory_get(struct GE_Memory * memory,
- unsigned int index) {
+ unsigned int index) {
if (index > memory->pos || memory->messages == NULL)
return NULL;
return memory->messages[index].msg;
@@ -132,16 +132,16 @@
* Also clears the memory.
*/
void GE_memory_poll(struct GE_Memory * memory,
- GE_LogHandler handler,
- void * ctx) {
+ GE_LogHandler handler,
+ void * ctx) {
int i;
MUTEX_LOCK(memory->lock);
for (i=0;i<memory->pos;i++) {
handler(ctx,
- memory->messages[i].mask,
- memory->messages[i].date,
- memory->messages[i].msg);
+ memory->messages[i].mask,
+ memory->messages[i].date,
+ memory->messages[i].msg);
FREE(memory->messages[i].date);
FREE(memory->messages[i].msg);
}
Modified: GNUnet/src/util/loggers/smtp.c
===================================================================
--- GNUnet/src/util/loggers/smtp.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/loggers/smtp.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -36,12 +36,12 @@
*/
struct GE_Context *
GE_create_context_email(struct GE_Context * ectx,
- GE_MASK mask,
- const char * address,
- const char * server,
- unsigned short port,
- int logDate,
- unsigned int bulkSize) {
+ GE_MASK mask,
+ const char * address,
+ const char * server,
+ unsigned short port,
+ int logDate,
+ unsigned int bulkSize) {
return NULL;
}
Modified: GNUnet/src/util/network/dns.c
===================================================================
--- GNUnet/src/util/network/dns.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/network/dns.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -64,29 +64,29 @@
if (cache->posted == NO) {
ret = adns_submit_reverse(a_state,
- cache->sa,
- adns_r_ptr,
+ cache->sa,
+ adns_r_ptr,
#ifdef adns_qf_none
- adns_qf_none,
+ adns_qf_none,
#else
- 0,
-#endif
- cache,
- &cache->query);
+ 0,
+#endif
+ cache,
+ &cache->query);
if (adns_s_ok == ret)
cache->posted = YES;
}
adns_processany(a_state);
answer = NULL;
reti = adns_check(a_state,
- &cache->query,
- &answer,
- (void**)&rec);
+ &cache->query,
+ &answer,
+ (void**)&rec);
if (reti == 0) {
if (answer != NULL) {
if ( (answer->rrs.str != NULL) &&
- (*(answer->rrs.str) != NULL) )
- cache->addr = STRDUP(*(answer->rrs.str));
+ (*(answer->rrs.str) != NULL) )
+ cache->addr = STRDUP(*(answer->rrs.str));
free(answer);
}
cache->posted = NO;
@@ -96,11 +96,11 @@
char hostname[256];
if (0 == getnameinfo(cache->sa,
- cache->salen,
- hostname,
- 255,
- NULL, 0,
- 0))
+ cache->salen,
+ hostname,
+ 255,
+ NULL, 0,
+ 0))
cache->addr = STRDUP(hostname);
#else
#if HAVE_GETHOSTBYADDR
@@ -109,13 +109,13 @@
switch (cache->sa->sa_family) {
case AF_INET:
ent = gethostbyaddr(&((struct sockaddr_in*) cache->sa)->sin_addr,
- sizeof(IPaddr),
- AF_INET);
+ sizeof(IPaddr),
+ AF_INET);
break;
case AF_INET6:
ent = gethostbyaddr(&((struct sockaddr_in6*) cache->sa)->sin6_addr,
- sizeof(IPaddr6),
- AF_INET6);
+ sizeof(IPaddr6),
+ AF_INET6);
break;
default:
ent = NULL;
@@ -129,7 +129,7 @@
static struct IPCache *
resolve(const struct sockaddr * sa,
- unsigned int salen) {
+ unsigned int salen) {
struct IPCache * ret;
ret = MALLOC(sizeof(struct IPCache));
@@ -140,8 +140,8 @@
ret->salen = salen;
ret->sa = salen == 0 ? NULL : MALLOC(salen);
memcpy(ret->sa,
- sa,
- salen);
+ sa,
+ salen);
ret->last_request = get_time();
ret->last_refresh = get_time();
ret->addr = NULL;
@@ -151,7 +151,7 @@
}
static char * no_resolve(const struct sockaddr * sa,
- unsigned int salen) {
+ unsigned int salen) {
char * ret;
char inet6[INET6_ADDRSTRLEN];
@@ -163,17 +163,17 @@
return NULL;
ret = STRDUP("255.255.255.255");
SNPRINTF(ret,
- strlen("255.255.255.255")+1,
- "%u.%u.%u.%u",
- PRIP(ntohl(*(int*)&((struct sockaddr_in*)sa)->sin_addr)));
+ strlen("255.255.255.255")+1,
+ "%u.%u.%u.%u",
+ PRIP(ntohl(*(int*)&((struct sockaddr_in*)sa)->sin_addr)));
break;
case AF_INET6:
if (salen != sizeof(struct sockaddr_in6))
return NULL;
inet_ntop(AF_INET6,
- &((struct sockaddr_in6*) sa)->sin6_addr,
- inet6,
- INET6_ADDRSTRLEN);
+ &((struct sockaddr_in6*) sa)->sin6_addr,
+ inet6,
+ INET6_ADDRSTRLEN);
ret = STRDUP(inet6);
break;
default:
@@ -192,8 +192,8 @@
* @param sa should be of type "struct sockaddr*"
*/
char * network_get_ip_as_string(const void * sav,
- unsigned int salen,
- int do_resolve) {
+ unsigned int salen,
+ int do_resolve) {
const struct sockaddr * sa = sav;
char * ret;
struct IPCache * cache;
@@ -207,29 +207,29 @@
cache = head;
prev = NULL;
while ( (cache != NULL) &&
- ( (cache->salen != salen) ||
- (0 != memcmp(cache->sa,
- sa,
- salen) ) ) ) {
+ ( (cache->salen != salen) ||
+ (0 != memcmp(cache->sa,
+ sa,
+ salen) ) ) ) {
if (cache->last_request + 60 * cronMINUTES < now) {
#if HAVE_ADNS
if (cache->posted == YES) {
- adns_cancel(cache->query);
- cache->posted = NO;
+ adns_cancel(cache->query);
+ cache->posted = NO;
}
#endif
if (prev != NULL) {
- prev->next = cache->next;
- FREENONNULL(cache->addr);
- FREE(cache->sa);
- FREE(cache);
- cache = prev->next;
+ prev->next = cache->next;
+ FREENONNULL(cache->addr);
+ FREE(cache->sa);
+ FREE(cache);
+ cache = prev->next;
} else {
- head = cache->next;
- FREENONNULL(cache->addr);
- FREE(cache->sa);
- FREE(cache);
- cache = head;
+ head = cache->next;
+ FREENONNULL(cache->addr);
+ FREE(cache->sa);
+ FREE(cache);
+ cache = head;
}
continue;
}
@@ -268,8 +268,8 @@
lock = MUTEX_CREATE(YES);
#if HAVE_ADNS
adns_init(&a_state,
- adns_if_noerrprint,
- NULL);
+ adns_if_noerrprint,
+ NULL);
#endif
}
@@ -280,8 +280,8 @@
pos = head->next;
#if HAVE_ADNS
if (head->posted == YES) {
- adns_cancel(head->query);
- head->posted = NO;
+ adns_cancel(head->query);
+ head->posted = NO;
}
#endif
FREENONNULL(head->addr);
Modified: GNUnet/src/util/network/io.c
===================================================================
--- GNUnet/src/util/network/io.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/network/io.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -67,7 +67,7 @@
* @return OK on success, SYSERR on error
*/
int get_host_by_name(struct GE_Context * ectx,
- const char * hostname,
+ const char * hostname,
IPaddr * ip) {
struct hostent * he;
@@ -76,10 +76,10 @@
he = GETHOSTBYNAME(hostname);
if (he == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- _("Could not find IP of host `%s': %s\n"),
- hostname,
- hstrerror(h_errno));
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("Could not find IP of host `%s': %s\n"),
+ hostname,
+ hstrerror(h_errno));
MUTEX_UNLOCK(lock);
return SYSERR;
}
@@ -99,8 +99,8 @@
struct SocketHandle *
socket_create(struct GE_Context * ectx,
- struct LoadMonitor * mon,
- int osSocket) {
+ struct LoadMonitor * mon,
+ int osSocket) {
SocketHandle * ret;
ret = MALLOC(sizeof(SocketHandle));
@@ -114,7 +114,7 @@
void socket_close(struct SocketHandle * s) {
GE_ASSERT(NULL, s != NULL);
if ( (0 != SHUTDOWN(s->handle,
- SHUT_RDWR)) &&
+ SHUT_RDWR)) &&
#ifdef OSX
(errno != EINVAL) && /* OS X returns these instead of ENOTCONN */
(errno != EHOSTDOWN) &&
@@ -122,12 +122,12 @@
#endif
(errno != ENOTCONN) )
GE_LOG_STRERROR(s->ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "shutdown");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "shutdown");
if (0 != CLOSE(s->handle))
GE_LOG_STRERROR(s->ectx,
- GE_WARNING | GE_USER | GE_DEVELOPER | GE_BULK,
- "close");
+ GE_WARNING | GE_USER | GE_DEVELOPER | GE_BULK,
+ "close");
s->handle = -1;
s->checksum = 1;
}
@@ -136,7 +136,7 @@
GE_ASSERT(NULL, s != NULL);
if (s->handle != -1) {
if ( (0 != SHUTDOWN(s->handle,
- SHUT_RDWR)) &&
+ SHUT_RDWR)) &&
#ifdef OSX
(errno != EINVAL) && /* OS X returns these instead of ENOTCONN */
(errno != EHOSTDOWN) &&
@@ -144,12 +144,12 @@
#endif
(errno != ENOTCONN) )
GE_LOG_STRERROR(s->ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "shutdown");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "shutdown");
if (0 != CLOSE(s->handle))
GE_LOG_STRERROR(s->ectx,
- GE_WARNING | GE_USER | GE_DEVELOPER | GE_BULK,
- "close");
+ GE_WARNING | GE_USER | GE_DEVELOPER | GE_BULK,
+ "close");
}
FREE(s);
}
@@ -159,7 +159,7 @@
static int socket_set_nosigpipe(struct SocketHandle * s,
int dontSigPipe) {
return setsockopt(s->handle,
- SOL_SOCKET, SO_NOSIGPIPE,
+ SOL_SOCKET, SO_NOSIGPIPE,
(void *)&dontSigPipe,
sizeof(dontSigPipe));
}
@@ -167,13 +167,13 @@
/* TODO: log errors! */
int socket_set_blocking(struct SocketHandle * s,
- int doBlock) {
+ int doBlock) {
#if MINGW
u_long mode;
mode = !doBlock;
if (ioctlsocket(s->handle,
- FIONBIO, &mode) == SOCKET_ERROR) {
+ FIONBIO, &mode) == SOCKET_ERROR) {
SetErrnoFromWinsockError(WSAGetLastError());
return -1;
@@ -189,8 +189,8 @@
else
flags |= O_NONBLOCK;
return fcntl(s->handle,
- F_SETFL,
- flags);
+ F_SETFL,
+ flags);
#endif
}
@@ -198,24 +198,24 @@
{
#ifndef MINGW
return (fcntl(s->handle,
- F_GETFL) & O_NONBLOCK) ? NO : YES;
+ F_GETFL) & O_NONBLOCK) ? NO : YES;
#else
return __win_IsHandleMarkedAsBlocking(s->handle);
#endif
}
int socket_recv(struct SocketHandle * s,
- NC_KIND nc,
- void * buf,
- size_t max,
- size_t * read) {
+ NC_KIND nc,
+ void * buf,
+ size_t max,
+ size_t * read) {
int flags;
size_t pos;
size_t ret;
GE_ASSERT(NULL, s->checksum == - s->handle);
socket_set_blocking(s,
- 0 != (nc & NC_Blocking));
+ 0 != (nc & NC_Blocking));
flags = 0;
#ifdef CYGWIN
if (0 == (nc & NC_IgnoreInt))
@@ -240,30 +240,30 @@
GE_ASSERT(NULL, s->checksum == - s->handle);
GE_ASSERT(NULL, max > pos);
ret = (size_t) RECV(s->handle,
- &((char*)buf)[pos],
- max - pos,
- flags);
+ &((char*)buf)[pos],
+ max - pos,
+ flags);
GE_ASSERT(NULL, s->checksum == - s->handle);
if ( (ret == (size_t) -1) &&
- (errno == EINTR) &&
- (0 != (nc & NC_IgnoreInt)) )
+ (errno == EINTR) &&
+ (0 != (nc & NC_IgnoreInt)) )
continue;
if ( (ret == (size_t) -1) ||
- (ret > max - pos) ) {
+ (ret > max - pos) ) {
if (errno == EINTR) {
- *read = pos;
- return YES;
+ *read = pos;
+ return YES;
}
if (errno == EWOULDBLOCK) {
- if (0 != (nc & NC_Blocking))
- continue;
- *read = pos;
- return (pos == 0) ? NO : YES;
+ if (0 != (nc & NC_Blocking))
+ continue;
+ *read = pos;
+ return (pos == 0) ? NO : YES;
}
#if DEBUG_IO
GE_LOG_STRERROR(s->ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "recv");
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "recv");
#endif
*read = pos;
return SYSERR;
@@ -275,29 +275,29 @@
}
if (s->mon != NULL)
os_network_monitor_notify_transmission(s->mon,
- Download,
- ret);
+ Download,
+ ret);
GE_ASSERT(NULL, pos + ret >= pos);
pos += ret;
} while ( (pos < max) &&
- (0 != (nc & NC_Blocking)) );
+ (0 != (nc & NC_Blocking)) );
*read = pos;
return YES;
}
int socket_recv_from(struct SocketHandle * s,
- NC_KIND nc,
- void * buf,
- size_t max,
- size_t * read,
- char * from,
- unsigned int * fromlen) {
+ NC_KIND nc,
+ void * buf,
+ size_t max,
+ size_t * read,
+ char * from,
+ unsigned int * fromlen) {
int flags;
size_t pos;
size_t ret;
socket_set_blocking(s,
- 0 != (nc & NC_Blocking));
+ 0 != (nc & NC_Blocking));
flags = 0;
#ifdef CYGWIN
if (0 == (nc & NC_IgnoreInt))
@@ -320,31 +320,31 @@
pos = 0;
do {
ret = (size_t) RECVFROM(s->handle,
- &((char*)buf)[pos],
- max - pos,
- flags,
- (struct sockaddr*) from,
- fromlen);
+ &((char*)buf)[pos],
+ max - pos,
+ flags,
+ (struct sockaddr*) from,
+ fromlen);
if ( (ret == (size_t) -1) &&
- (errno == EINTR) &&
- (0 != (nc & NC_IgnoreInt)) )
+ (errno == EINTR) &&
+ (0 != (nc & NC_IgnoreInt)) )
continue;
if ( (ret == (size_t) -1) ||
- (ret > max - pos) ) {
+ (ret > max - pos) ) {
if (errno == EINTR) {
- *read = pos;
- return YES;
+ *read = pos;
+ return YES;
}
if (errno == EWOULDBLOCK) {
- if (0 != (nc & NC_Blocking))
- continue;
- *read = pos;
- return (pos == 0) ? NO : YES;
+ if (0 != (nc & NC_Blocking))
+ continue;
+ *read = pos;
+ return (pos == 0) ? NO : YES;
}
#if DEBUG_IO
GE_LOG_STRERROR(s->ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "recvfrom");
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "recvfrom");
#endif
*read = pos;
return SYSERR;
@@ -356,26 +356,26 @@
}
if (s->mon != NULL)
os_network_monitor_notify_transmission(s->mon,
- Download,
- ret);
+ Download,
+ ret);
pos += ret;
} while ( (pos < max) &&
- (0 != (nc & NC_Blocking)) );
+ (0 != (nc & NC_Blocking)) );
*read = pos;
return YES;
}
int socket_send(struct SocketHandle * s,
- NC_KIND nc,
- const void * buf,
- size_t max,
- size_t * sent) {
+ NC_KIND nc,
+ const void * buf,
+ size_t max,
+ size_t * sent) {
int flags;
size_t pos;
size_t ret;
socket_set_blocking(s,
- 0 != (nc & NC_Blocking));
+ 0 != (nc & NC_Blocking));
flags = 0;
#if SOMEBSD || SOLARIS
if (0 == (nc & NC_Blocking))
@@ -399,29 +399,29 @@
pos = 0;
do {
ret = (size_t) SEND(s->handle,
- &((char*)buf)[pos],
- max - pos,
- flags);
+ &((char*)buf)[pos],
+ max - pos,
+ flags);
if ( (ret == (size_t) -1) &&
- (errno == EINTR) &&
- (0 != (nc & NC_IgnoreInt)) )
+ (errno == EINTR) &&
+ (0 != (nc & NC_IgnoreInt)) )
continue;
if ( (ret == (size_t) -1) ||
- (ret > max - pos) ) {
+ (ret > max - pos) ) {
if (errno == EINTR) {
- *sent = pos;
- return YES;
+ *sent = pos;
+ return YES;
}
if (errno == EWOULDBLOCK) {
- if (0 != (nc & NC_Blocking))
- continue;
- *sent = pos;
- return (pos == 0) ? NO : YES;
+ if (0 != (nc & NC_Blocking))
+ continue;
+ *sent = pos;
+ return (pos == 0) ? NO : YES;
}
#if DEBUG_IO
GE_LOG_STRERROR(s->ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "send");
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "send");
#endif
*sent = pos;
return SYSERR;
@@ -433,28 +433,28 @@
}
if (s->mon != NULL)
os_network_monitor_notify_transmission(s->mon,
- Upload,
- ret);
+ Upload,
+ ret);
pos += ret;
} while ( (pos < max) &&
- (0 != (nc & NC_Blocking)) );
+ (0 != (nc & NC_Blocking)) );
*sent = pos;
return YES;
}
int socket_send_to(struct SocketHandle * s,
- NC_KIND nc,
- const void * buf,
- size_t max,
- size_t * sent,
- const char * dst,
- unsigned int dstlen) {
+ NC_KIND nc,
+ const void * buf,
+ size_t max,
+ size_t * sent,
+ const char * dst,
+ unsigned int dstlen) {
int flags;
size_t pos;
size_t ret;
socket_set_blocking(s,
- 0 != (nc & NC_Blocking));
+ 0 != (nc & NC_Blocking));
flags = 0;
#if SOMEBSD || SOLARIS
if (0 == (nc & NC_Blocking))
@@ -478,31 +478,31 @@
pos = 0;
do {
ret = (size_t) SENDTO(s->handle,
- &((char*)buf)[pos],
- max - pos,
- flags,
- (const struct sockaddr*) dst,
- dstlen);
+ &((char*)buf)[pos],
+ max - pos,
+ flags,
+ (const struct sockaddr*) dst,
+ dstlen);
if ( (ret == (size_t) -1) &&
- (errno == EINTR) &&
- (0 != (nc & NC_IgnoreInt)) )
+ (errno == EINTR) &&
+ (0 != (nc & NC_IgnoreInt)) )
continue;
if ( (ret == (size_t) -1) ||
- (ret > max - pos) ) {
+ (ret > max - pos) ) {
if (errno == EINTR) {
- *sent = pos;
- return YES;
+ *sent = pos;
+ return YES;
}
if (errno == EWOULDBLOCK) {
- if (0 != (nc & NC_Blocking))
- continue;
- *sent = pos;
- return (pos == 0) ? NO : YES;
+ if (0 != (nc & NC_Blocking))
+ continue;
+ *sent = pos;
+ return (pos == 0) ? NO : YES;
}
#if DEBUG_IO
GE_LOG_STRERROR(s->ectx,
- GE_DEBUG | GE_USER | GE_REQUEST,
- "sendto");
+ GE_DEBUG | GE_USER | GE_REQUEST,
+ "sendto");
#endif
*sent = pos;
return SYSERR;
@@ -514,11 +514,11 @@
}
if (s->mon != NULL)
os_network_monitor_notify_transmission(s->mon,
- Upload,
- ret);
+ Upload,
+ ret);
pos += ret;
} while ( (pos < max) &&
- (0 != (nc & NC_Blocking)) );
+ (0 != (nc & NC_Blocking)) );
*sent = pos;
return YES;
}
@@ -531,12 +531,12 @@
#ifndef MINGW
struct stat buf;
return -1 != fstat(s->handle,
- &buf);
+ &buf);
#else
long l;
return ioctlsocket(s->handle,
- FIONREAD,
- &l) != SOCKET_ERROR;
+ FIONREAD,
+ &l) != SOCKET_ERROR;
#endif
}
Modified: GNUnet/src/util/network/ip.c
===================================================================
--- GNUnet/src/util/network/ip.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/network/ip.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -50,39 +50,39 @@
* @return SYSERR on failure, OK on success
*/
static int getAddressFromHostname(struct GE_Context * ectx,
- IPaddr * identity) {
+ IPaddr * identity) {
char hostname[MAX_HOSTNAME];
int ret;
if (0 != gethostname(hostname, MAX_HOSTNAME)) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "gethostname");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "gethostname");
return SYSERR;
}
ret = get_host_by_name(ectx,
- hostname,
- identity);
+ hostname,
+ identity);
return ret;
}
#if HAVE_GETIFADDRS && HAVE_FREEIFADDRS
static int getAddressFromGetIfAddrs(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- IPaddr * identity) {
+ struct GE_Context * ectx,
+ IPaddr * identity) {
char * interfaces;
struct ifaddrs *ifa_first;
if (-1 == GC_get_configuration_value_string(cfg,
- "NETWORK",
- "INTERFACE",
- "eth0",
- &interfaces)) {
+ "NETWORK",
+ "INTERFACE",
+ "eth0",
+ &interfaces)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("No interface specified in section `%s' under `%s'!\n"),
- "NETWORK",
- "INTERFACE");
+ GE_ERROR | GE_BULK | GE_USER,
+ _("No interface specified in section `%s' under `%s'!\n"),
+ "NETWORK",
+ "INTERFACE");
return SYSERR; /* that won't work! */
}
@@ -109,10 +109,10 @@
freeifaddrs(ifa_first);
}
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Could not obtain IP for interface `%s' using `%s'.\n"),
- interfaces,
- "getifaddrs");
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Could not obtain IP for interface `%s' using `%s'.\n"),
+ interfaces,
+ "getifaddrs");
FREE(interfaces);
return SYSERR;
}
@@ -122,8 +122,8 @@
#if LINUX || SOMEBSD || MINGW
#define MAX_INTERFACES 16
static int getAddressFromIOCTL(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- IPaddr * identity) {
+ struct GE_Context * ectx,
+ IPaddr * identity) {
char * interfaces;
#ifndef MINGW
struct ifreq ifr[MAX_INTERFACES];
@@ -135,15 +135,15 @@
int i;
if (-1 == GC_get_configuration_value_string(cfg,
- "NETWORK",
- "INTERFACE",
- "eth0",
- &interfaces)) {
+ "NETWORK",
+ "INTERFACE",
+ "eth0",
+ &interfaces)) {
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- _("No interface specified in section `%s' under `%s'!\n"),
- "NETWORK",
- "INTERFACE");
+ GE_ERROR | GE_BULK | GE_USER,
+ _("No interface specified in section `%s' under `%s'!\n"),
+ "NETWORK",
+ "INTERFACE");
return SYSERR; /* that won't work! */
}
#ifndef MINGW
@@ -151,26 +151,26 @@
if (sockfd == -1) {
FREE(interfaces);
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "socket");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "socket");
return SYSERR;
}
memset(&ifc,
- 0,
- sizeof(struct ifconf));
+ 0,
+ sizeof(struct ifconf));
ifc.ifc_len = sizeof(ifr);
ifc.ifc_buf = (char*)𝔦
if (ioctl(sockfd,
- SIOCGIFCONF,
- &ifc) == -1) {
+ SIOCGIFCONF,
+ &ifc) == -1) {
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
- "ioctl");
+ GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+ "ioctl");
if (0 != CLOSE(sockfd))
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "close");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "close");
FREE(interfaces);
return SYSERR;
}
@@ -185,24 +185,24 @@
if (!(ifr[i].ifr_flags & IFF_UP))
continue;
if (strcmp((char*) interfaces,
- (char*) ifr[i].ifr_name) != 0)
+ (char*) ifr[i].ifr_name) != 0)
continue;
memcpy(identity,
- &(((struct sockaddr_in *)&ifr[i].ifr_addr)->sin_addr),
- sizeof(struct in_addr));
+ &(((struct sockaddr_in *)&ifr[i].ifr_addr)->sin_addr),
+ sizeof(struct in_addr));
if (0 != CLOSE(sockfd))
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "close");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "close");
FREE(interfaces);
return OK;
}
GE_LOG(ectx,
- GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
- _("Could not find interface `%s' using `%s', "
- "trying to find another interface.\n"),
- interfaces,
- "ioctl");
+ GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
+ _("Could not find interface `%s' using `%s', "
+ "trying to find another interface.\n"),
+ interfaces,
+ "ioctl");
/* if no such interface exists, take any interface but loopback */
for (i=0;i<ifCount;i++){
if (ioctl(sockfd, SIOCGIFADDR, &ifr[i]) != 0)
@@ -212,28 +212,28 @@
if (!(ifr[i].ifr_flags & IFF_UP))
continue;
if (strncmp("lo",
- (char*) ifr[i].ifr_name, 2) == 0)
+ (char*) ifr[i].ifr_name, 2) == 0)
continue;
memcpy(identity,
- &(((struct sockaddr_in *)&ifr[i].ifr_addr)->sin_addr),
- sizeof(struct in_addr));
+ &(((struct sockaddr_in *)&ifr[i].ifr_addr)->sin_addr),
+ sizeof(struct in_addr));
if (0 != CLOSE(sockfd))
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "close");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "close");
FREE(interfaces);
return OK;
}
if (0 != CLOSE(sockfd))
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "close");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "close");
GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Could not obtain IP for interface `%s' using `%s'.\n"),
- interfaces,
- "ioctl");
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Could not obtain IP for interface `%s' using `%s'.\n"),
+ interfaces,
+ "ioctl");
FREE(interfaces);
return SYSERR;
#else /* MinGW */
@@ -264,7 +264,7 @@
if (memcmp(bPhysAddr, &l, sizeof(l)) == 0) {
for(i = 0; i < pAddrTable->dwNumEntries; i++) {
if (pAddrTable->table[i].dwIndex
- == pTable->table[dwIfIdx].dwIndex) {
+ == pTable->table[dwIfIdx].dwIndex) {
iAddrCount++;
dwIP = pAddrTable->table[i].dwAddr;
}
@@ -275,9 +275,9 @@
if (! iAddrCount)
{
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Could not find an IP address for "
- "interface `%s'.\n"),
- interfaces);
+ _("Could not find an IP address for "
+ "interface `%s'.\n"),
+ interfaces);
GlobalFree(pTable);
GlobalFree(pAddrTable);
@@ -285,11 +285,11 @@
}
else if (iAddrCount > 1)
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("There is more than one IP address specified"
- " for interface `%s'.\nGNUnet will "
- "use %u.%u.%u.%u.\n"),
- interfaces,
- PRIP(ntohl(dwIP)));
+ _("There is more than one IP address specified"
+ " for interface `%s'.\nGNUnet will "
+ "use %u.%u.%u.%u.\n"),
+ interfaces,
+ PRIP(ntohl(dwIP)));
identity->addr = dwIP;
@@ -306,10 +306,10 @@
pHost = GETHOSTBYNAME("www.example.com");
if (! pHost) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Could not resolve `%s' to "
- "determine our IP address: %s\n"),
- "www.example.com",
- STRERROR(errno));
+ _("Could not resolve `%s' to "
+ "determine our IP address: %s\n"),
+ "www.example.com",
+ STRERROR(errno));
return SYSERR;
}
@@ -318,19 +318,19 @@
theHost.sin_addr.S_un.S_addr
= *((unsigned long *) pHost->h_addr_list[0]);
if (CONNECT(s,
- (SOCKADDR *) &theHost,
- sizeof(theHost)) == SOCKET_ERROR && errno != EWOULDBLOCK) {
+ (SOCKADDR *) &theHost,
+ sizeof(theHost)) == SOCKET_ERROR && errno != EWOULDBLOCK) {
GE_LOG_STRERROR(ectx, GE_ERROR | GE_BULK | GE_USER,
- "connect");
+ "connect");
return SYSERR;
}
i = sizeof(theHost);
if (GETSOCKNAME(s,
- (SOCKADDR *) &theHost,
- &i) == SOCKET_ERROR) {
+ (SOCKADDR *) &theHost,
+ &i) == SOCKET_ERROR) {
GE_LOG_STRERROR(ectx, GE_ERROR | GE_BULK | GE_USER,
- "getsockname");
+ "getsockname");
return SYSERR;
}
closesocket(s);
@@ -352,8 +352,8 @@
* @return NULL on error, IP as string otherwise
*/
char * network_get_local_ip(struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- IPaddr * addr) {
+ struct GE_Context * ectx,
+ IPaddr * addr) {
IPaddr address;
char * ipString;
int retval;
@@ -361,44 +361,44 @@
retval = SYSERR;
if (GC_have_configuration_value(cfg,
- "NETWORK",
- "IP")) {
+ "NETWORK",
+ "IP")) {
ipString = NULL;
GC_get_configuration_value_string(cfg,
- "NETWORK",
- "IP",
- "",
- &ipString);
+ "NETWORK",
+ "IP",
+ "",
+ &ipString);
if (strlen(ipString) > 0) {
retval = get_host_by_name(ectx,
- ipString,
- &address);
+ ipString,
+ &address);
}
FREE(ipString);
}
#if LINUX || SOMEBSD || MINGW
if (retval == SYSERR)
if (OK == getAddressFromIOCTL(cfg,
- ectx,
- &address))
+ ectx,
+ &address))
retval = OK;
#endif
#if HAVE_GETIFADDRS && HAVE_FREEIFADDRS
if (retval == SYSERR)
if (OK == getAddressFromGetIfAddrs(cfg,
ectx,
- &address))
+ &address))
retval = OK;
#endif
if (retval == SYSERR)
retval = getAddressFromHostname(ectx,
- &address);
+ &address);
if (retval == SYSERR)
return NULL;
SNPRINTF(buf,
- 64,
- "%u.%u.%u.%u",
- PRIP(ntohl(*(int*)&address)));
+ 64,
+ "%u.%u.%u.%u",
+ PRIP(ntohl(*(int*)&address)));
if (addr != NULL)
*addr = address;
return STRDUP(buf);
Modified: GNUnet/src/util/network/ipcheck.c
===================================================================
--- GNUnet/src/util/network/ipcheck.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/network/ipcheck.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -58,7 +58,7 @@
* @return the converted list, NULL if the synatx is flawed
*/
CIDRNetwork * parse_ipv4_network_specification(struct GE_Context * ectx,
- const char * routeList) {
+ const char * routeList) {
unsigned int count;
unsigned int i;
unsigned int j;
@@ -81,96 +81,96 @@
result = MALLOC(sizeof(CIDRNetwork) * (count+1));
/* add termination */
memset(result,
- 0,
- sizeof(CIDRNetwork)*(count+1));
+ 0,
+ sizeof(CIDRNetwork)*(count+1));
i=0;
pos = 0;
while (i < count) {
cnt = sscanf(&routeList[pos],
- "%u.%u.%u.%u/%u.%u.%u.%u;",
- &temps[0],
- &temps[1],
- &temps[2],
- &temps[3],
- &temps[4],
- &temps[5],
- &temps[6],
- &temps[7]);
+ "%u.%u.%u.%u/%u.%u.%u.%u;",
+ &temps[0],
+ &temps[1],
+ &temps[2],
+ &temps[3],
+ &temps[4],
+ &temps[5],
+ &temps[6],
+ &temps[7]);
if (cnt == 8) {
for (j=0;j<8;j++)
- if (temps[j] > 0xFF) {
- GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Invalid format for IP: `%s'\n"),
- &routeList[pos]);
- FREE(result);
- return NULL;
- }
+ if (temps[j] > 0xFF) {
+ GE_LOG(ectx,
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Invalid format for IP: `%s'\n"),
+ &routeList[pos]);
+ FREE(result);
+ return NULL;
+ }
result[i].network.addr
- = htonl((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) +
temps[3]);
+ = htonl((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + temps[3]);
result[i].netmask.addr
- = htonl((temps[4] << 24) + (temps[5] << 16) + (temps[6] << 8) +
temps[7]);
+ = htonl((temps[4] << 24) + (temps[5] << 16) + (temps[6] << 8) + temps[7]);
while (routeList[pos] != ';')
- pos++;
+ pos++;
pos++;
i++;
continue;
}
/* try second notation */
cnt = sscanf(&routeList[pos],
- "%u.%u.%u.%u/%u;",
- &temps[0],
- &temps[1],
- &temps[2],
- &temps[3],
- &slash);
+ "%u.%u.%u.%u/%u;",
+ &temps[0],
+ &temps[1],
+ &temps[2],
+ &temps[3],
+ &slash);
if (cnt == 5) {
for (j=0;j<4;j++)
- if (temps[j] > 0xFF) {
- GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Invalid format for IP: `%s'\n"),
- &routeList[pos]);
- FREE(result);
- return NULL;
- }
+ if (temps[j] > 0xFF) {
+ GE_LOG(ectx,
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Invalid format for IP: `%s'\n"),
+ &routeList[pos]);
+ FREE(result);
+ return NULL;
+ }
result[i].network.addr
- = htonl((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) +
temps[3]);
+ = htonl((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + temps[3]);
if ( (slash <= 32) && (slash > 0) ) {
- result[i].netmask.addr = 0;
- while (slash > 0) {
- result[i].netmask.addr
- = (result[i].netmask.addr >> 1) + 0x80000000;
- slash--;
- }
- result[i].netmask.addr
- = htonl(result[i].netmask.addr);
- while (routeList[pos] != ';')
- pos++;
- pos++;
- i++;
- continue;
+ result[i].netmask.addr = 0;
+ while (slash > 0) {
+ result[i].netmask.addr
+ = (result[i].netmask.addr >> 1) + 0x80000000;
+ slash--;
+ }
+ result[i].netmask.addr
+ = htonl(result[i].netmask.addr);
+ while (routeList[pos] != ';')
+ pos++;
+ pos++;
+ i++;
+ continue;
} else {
- GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Invalid network notation ('/%d' is not legal in IPv4 CIDR)."),
- slash);
- FREE(result);
- return NULL; /* error */
+ GE_LOG(ectx,
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Invalid network notation ('/%d' is not legal in IPv4 CIDR)."),
+ slash);
+ FREE(result);
+ return NULL; /* error */
}
}
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Invalid format for IP: `%s'\n"),
- &routeList[pos]);
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Invalid format for IP: `%s'\n"),
+ &routeList[pos]);
FREE(result);
return NULL; /* error */
}
if (pos < strlen(routeList)) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Invalid format for IP: `%s'\n"),
- &routeList[pos]);
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Invalid format for IP: `%s'\n"),
+ &routeList[pos]);
FREE(result);
return NULL; /* oops */
}
@@ -190,7 +190,7 @@
* @return the converted list, NULL if the synatx is flawed
*/
CIDR6Network * parse_ipv6_network_specification(struct GE_Context * ectx,
- const char * routeListX) {
+ const char * routeListX) {
unsigned int count;
unsigned int i;
unsigned int len;
@@ -213,17 +213,17 @@
count++;
if (routeList[len-1] != ';') {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Invalid network notation (does not end with ';': `%s')\n"),
- routeList);
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Invalid network notation (does not end with ';': `%s')\n"),
+ routeList);
FREE(routeList);
return NULL;
}
result = MALLOC(sizeof(CIDR6Network) * (count+1));
memset(result,
- 0,
- sizeof(CIDR6Network) * (count+1));
+ 0,
+ sizeof(CIDR6Network) * (count+1));
i=0;
pos = 0;
while (i < count) {
@@ -232,39 +232,39 @@
pos++;
slash = pos;
while ( (slash >= start) &&
- (routeList[slash] != '/') )
+ (routeList[slash] != '/') )
slash--;
if (slash < start) {
memset(&result[i].netmask,
- 0xFF,
- sizeof(IP6addr));
+ 0xFF,
+ sizeof(IP6addr));
slash = pos;
} else {
routeList[pos] = '\0';
ret = inet_pton(AF_INET6,
- &routeList[slash+1],
- &result[i].netmask);
+ &routeList[slash+1],
+ &result[i].netmask);
if (ret <= 0) {
- GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Wrong format `%s' for netmask: %s\n"),
- &routeList[slash+1],
- STRERROR(errno));
- FREE(result);
- FREE(routeList);
- return NULL;
+ GE_LOG(ectx,
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Wrong format `%s' for netmask: %s\n"),
+ &routeList[slash+1],
+ STRERROR(errno));
+ FREE(result);
+ FREE(routeList);
+ return NULL;
}
}
routeList[slash] = '\0';
ret = inet_pton(AF_INET6,
- &routeList[start],
- &result[i].network);
+ &routeList[start],
+ &result[i].network);
if (ret <= 0) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- _("Wrong format `%s' for network: %s\n"),
- &routeList[slash+1],
- STRERROR(errno));
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ _("Wrong format `%s' for network: %s\n"),
+ &routeList[slash+1],
+ STRERROR(errno));
FREE(result);
FREE(routeList);
return NULL;
@@ -284,7 +284,7 @@
* @return NO if the IP is not in the list, YES if it it is
*/
int check_ipv4_listed(const CIDRNetwork * list,
- IPaddr ip) {
+ IPaddr ip) {
int i;
IPaddr add;
@@ -294,9 +294,9 @@
return NO;
while ( (list[i].network.addr != 0) ||
- (list[i].netmask.addr != 0) ) {
+ (list[i].netmask.addr != 0) ) {
if ( (add.addr & list[i].netmask.addr) ==
- (list[i].network.addr & list[i].netmask.addr) )
+ (list[i].network.addr & list[i].netmask.addr) )
return YES;
i++;
}
@@ -311,7 +311,7 @@
* @return NO if the IP is not in the list, YES if it it is
*/
int check_ipv6_listed(const CIDR6Network * list,
- IP6addr ip) {
+ IP6addr ip) {
unsigned int i;
unsigned int j;
struct in6_addr zero;
@@ -322,10 +322,10 @@
memset(&zero, 0, sizeof(struct in6_addr));
while ( (memcmp(&zero, &list[i].network, sizeof(struct in6_addr)) != 0) ||
- (memcmp(&zero, &list[i].netmask, sizeof(struct in6_addr)) != 0) ) {
+ (memcmp(&zero, &list[i].netmask, sizeof(struct in6_addr)) != 0) ) {
for (j=0;j<sizeof(struct in6_addr)/sizeof(int);j++)
if ( ((((int*)&ip)[j] & ((int*)&list[i].netmask)[j])) !=
- (((int*)&list[i].network)[j] & ((int*)&list[i].netmask)[j]) ) {
+ (((int*)&list[i].network)[j] & ((int*)&list[i].netmask)[j]) ) {
i++;
continue;
}
Modified: GNUnet/src/util/network/select.c
===================================================================
--- GNUnet/src/util/network/select.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/network/select.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -166,10 +166,10 @@
} SelectHandle;
static void add_to_select_set(struct SocketHandle * s,
- fd_set * set,
- int * max) {
+ fd_set * set,
+ int * max) {
FD_SET(s->handle,
- set);
+ set);
if (*max < s->handle)
*max = s->handle;
}
@@ -184,17 +184,17 @@
#if DEBUG_SELECT
GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Signaling select %p.\n",
- sh);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Signaling select %p.\n",
+ sh);
#endif
ret = WRITE(sh->signal_pipe[1],
- &i,
- sizeof(char));
+ &i,
+ sizeof(char));
if (ret != sizeof(char))
GE_LOG_STRERROR(sh->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "write");
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "write");
}
/**
@@ -206,7 +206,7 @@
* already held by the caller.
*/
static void destroySession(SelectHandle * sh,
- Session * s) {
+ Session * s) {
int i;
if (s->locked == 1) {
@@ -218,28 +218,28 @@
s->locked = 2;
#if DEBUG_SELECT
GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Destroying session %p of select %p with %u in read and %u in write
buffer.\n",
- s,
- sh,
- s->rsize,
- s->wsize);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Destroying session %p of select %p with %u in read and %u in write
buffer.\n",
+ s,
+ sh,
+ s->rsize,
+ s->wsize);
#endif
#if 0
if ( (s->pos > 0) ||
(s->wapos > s->wspos) )
fprintf(stderr,
- "Destroying session %p of select %p with loss of %u in read and %u
in write buffer.\n",
- s,
- sh,
- s->pos,
- s->wapos - s->wspos);
+ "Destroying session %p of select %p with loss of %u in read and %u in
write buffer.\n",
+ s,
+ sh,
+ s->pos,
+ s->wapos - s->wspos);
#endif
MUTEX_UNLOCK(sh->lock);
sh->ch(sh->ch_cls,
- sh,
- s->sock,
- s->sock_ctx);
+ sh,
+ s->sock,
+ s->sock_ctx);
MUTEX_LOCK(sh->lock);
socket_destroy(s->sock);
sh->socket_quota++;
@@ -259,8 +259,8 @@
FREE(s);
if (sh->sessionCount * 2 < sh->sessionArrayLength)
GROW(sh->sessions,
- sh->sessionArrayLength,
- sh->sessionCount);
+ sh->sessionArrayLength,
+ sh->sessionCount);
}
/**
@@ -272,7 +272,7 @@
* @return OK for success, SYSERR if session was destroyed
*/
static int readAndProcess(SelectHandle * sh,
- Session * session) {
+ Session * session) {
const MESSAGE_HEADER * pack;
int ret;
size_t recvd;
@@ -281,23 +281,23 @@
if (session->rsize == session->pos) {
/* read buffer too small, grow */
GROW(session->rbuff,
- session->rsize,
- session->rsize + 1024);
+ session->rsize,
+ session->rsize + 1024);
}
ret = socket_recv(session->sock,
- NC_Nonblocking | NC_IgnoreInt,
- &session->rbuff[session->pos],
- session->rsize - session->pos,
- &recvd);
+ NC_Nonblocking | NC_IgnoreInt,
+ &session->rbuff[session->pos],
+ session->rsize - session->pos,
+ &recvd);
#if DEBUG_SELECT
GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Receiving from session %p of select %p return %d-%u (%s).\n",
- sh,
- session,
- ret,
- recvd,
- STRERROR(errno));
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Receiving from session %p of select %p return %d-%u (%s).\n",
+ sh,
+ session,
+ ret,
+ recvd,
+ STRERROR(errno));
#endif
if (ret != OK) {
destroySession(sh, session);
@@ -305,21 +305,21 @@
}
session->pos += recvd;
while ( (sh->shutdown == NO) &&
- (session->pos >= sizeof(MESSAGE_HEADER)) ) {
+ (session->pos >= sizeof(MESSAGE_HEADER)) ) {
pack = (const MESSAGE_HEADER*) &session->rbuff[0];
len = ntohs(pack->size);
/* check minimum size */
if (len < sizeof(MESSAGE_HEADER)) {
GE_LOG(sh->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Received malformed message (too small) from connection.
Closing.\n"));
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Received malformed message (too small) from connection.
Closing.\n"));
destroySession(sh, session);
return SYSERR;
}
if (len > session->rsize) /* if message larger than read buffer, grow! */
GROW(session->rbuff,
- session->rsize,
- len);
+ session->rsize,
+ len);
/* do we have the entire message? */
if (session->pos < len)
@@ -328,13 +328,13 @@
session->locked = 1;
MUTEX_UNLOCK(sh->lock);
if (OK != sh->mh(sh->mh_cls,
- sh,
- session->sock,
- session->sock_ctx,
- pack)) {
+ sh,
+ session->sock,
+ session->sock_ctx,
+ pack)) {
MUTEX_LOCK(sh->lock);
if (session->locked == 1)
- session->locked = 0;
+ session->locked = 0;
destroySession(sh, session);
return SYSERR;
}
@@ -348,8 +348,8 @@
session->locked = 0;
/* shrink buffer adequately */
memmove(&session->rbuff[0],
- &session->rbuff[len],
- session->pos - len);
+ &session->rbuff[len],
+ session->pos - len);
session->pos -= len;
}
session->lastUse = get_time();
@@ -365,63 +365,63 @@
* @return OK for success, SYSERR if session was destroyed
*/
static int writeAndProcess(SelectHandle * sh,
- Session * session) {
+ Session * session) {
SocketHandle * sock;
int ret;
size_t size;
#if DEBUG_SELECT
GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Write and process called for session %p of select %p status %d.\n",
- sh,
- session,
- sh->shutdown);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Write and process called for session %p of select %p status %d.\n",
+ sh,
+ session,
+ sh->shutdown);
#endif
sock = session->sock;
while (sh->shutdown == NO) {
ret = socket_send(sock,
- NC_Nonblocking,
- &session->wbuff[session->wspos],
- session->wapos - session->wspos,
- &size);
+ NC_Nonblocking,
+ &session->wbuff[session->wspos],
+ session->wapos - session->wspos,
+ &size);
#if DEBUG_SELECT
GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Sending %d bytes from session %p of select %p return %d.\n",
- session->wapos - session->wspos,
- sh,
- session,
- ret);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Sending %d bytes from session %p of select %p return %d.\n",
+ session->wapos - session->wspos,
+ sh,
+ session,
+ ret);
#endif
if (ret == SYSERR) {
GE_LOG_STRERROR(sh->ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
- "send");
+ GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
+ "send");
destroySession(sh, session);
return SYSERR;
}
if (ret == OK) {
if (size == 0) {
- /* send only returns 0 on error (happens if
- other side closed connection), so close
- the session */
- destroySession(sh, session);
- return SYSERR;
+ /* send only returns 0 on error (happens if
+ other side closed connection), so close
+ the session */
+ destroySession(sh, session);
+ return SYSERR;
}
session->wspos += size;
if (session->wspos == session->wapos) {
- /* free compaction! */
- session->wspos = 0;
- session->wapos = 0;
- if (session->wsize > sh->memory_quota) {
- /* if we went over quota before because of
- force, use this opportunity to shrink
- back to size! */
- GROW(session->wbuff,
- session->wsize,
- sh->memory_quota);
- }
+ /* free compaction! */
+ session->wspos = 0;
+ session->wapos = 0;
+ if (session->wsize > sh->memory_quota) {
+ /* if we went over quota before because of
+ force, use this opportunity to shrink
+ back to size! */
+ GROW(session->wbuff,
+ session->wsize,
+ sh->memory_quota);
+ }
}
break;
}
@@ -452,7 +452,7 @@
int s;
void * sctx;
SocketHandle * sock;
- Session * session;
+ Session * session;
size_t size;
int old_errno;
@@ -464,25 +464,25 @@
FD_ZERO(&writeSet);
if (sh->signal_pipe[0] != -1) {
if (-1 == FSTAT(sh->signal_pipe[0], &buf)) {
- GE_LOG_STRERROR(sh->ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "fstat");
- sh->signal_pipe[0] = -1; /* prevent us from error'ing all the time */
+ GE_LOG_STRERROR(sh->ectx,
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "fstat");
+ sh->signal_pipe[0] = -1; /* prevent us from error'ing all the time */
} else {
- FD_SET(sh->signal_pipe[0],
- &readSet);
+ FD_SET(sh->signal_pipe[0],
+ &readSet);
}
}
max = sh->signal_pipe[0];
if (sh->listen_sock != NULL) {
if (! socket_test_valid(sh->listen_sock)) {
- socket_destroy(sh->listen_sock);
- GE_LOG(sh->ectx,
- GE_USER | GE_ERROR | GE_BULK,
- _("select listen socket not valid!\n"));
- sh->listen_sock = NULL; /* prevent us from error'ing all the time */
+ socket_destroy(sh->listen_sock);
+ GE_LOG(sh->ectx,
+ GE_USER | GE_ERROR | GE_BULK,
+ _("select listen socket not valid!\n"));
+ sh->listen_sock = NULL; /* prevent us from error'ing all the time */
} else {
- add_to_select_set(sh->listen_sock, &readSet, &max);
+ add_to_select_set(sh->listen_sock, &readSet, &max);
}
}
for (i=0;i<sh->sessionCount;i++) {
@@ -491,296 +491,296 @@
if (! socket_test_valid(sock)) {
#if DEBUG_SELECT
- GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Select %p destroys invalid client handle %p\n",
- sh,
- session);
+ GE_LOG(sh->ectx,
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Select %p destroys invalid client handle %p\n",
+ sh,
+ session);
#endif
- destroySession(sh, session);
+ destroySession(sh, session);
} else {
- add_to_select_set(sock, &readSet, &max);
- add_to_select_set(sock, &errorSet, &max);
- GE_ASSERT(NULL, session->wapos >= session->wspos);
- if (session->wapos > session->wspos)
- add_to_select_set(sock, &writeSet, &max); /* do we have a pending
write request? */
+ add_to_select_set(sock, &readSet, &max);
+ add_to_select_set(sock, &errorSet, &max);
+ GE_ASSERT(NULL, session->wapos >= session->wspos);
+ if (session->wapos > session->wspos)
+ add_to_select_set(sock, &writeSet, &max); /* do we have a pending write
request? */
}
}
MUTEX_UNLOCK(sh->lock);
ret = SELECT(max+1,
- &readSet,
- &writeSet,
- &errorSet,
- NULL);
+ &readSet,
+ &writeSet,
+ &errorSet,
+ NULL);
old_errno = errno;
MUTEX_LOCK(sh->lock);
if ( (ret == -1) &&
- ( (old_errno == EAGAIN) || (old_errno == EINTR) ) )
+ ( (old_errno == EAGAIN) || (old_errno == EINTR) ) )
continue;
if (ret == -1) {
errno = old_errno;
if (errno == EBADF) {
- GE_LOG_STRERROR(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "select");
+ GE_LOG_STRERROR(sh->ectx,
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "select");
} else {
- GE_DIE_STRERROR(sh->ectx,
- GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
- "select");
+ GE_DIE_STRERROR(sh->ectx,
+ GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
+ "select");
}
continue;
}
if (sh->is_udp == NO) {
if ( (sh->listen_sock != NULL) &&
- (FD_ISSET(sh->listen_sock->handle, &readSet)) ) {
- lenOfIncomingAddr = sh->max_addr_len;
- memset(clientAddr,
- 0,
- lenOfIncomingAddr);
- /* make sure this is non-blocking */
- socket_set_blocking(sh->listen_sock,
- NO);
- s = ACCEPT(sh->listen_sock->handle,
- (struct sockaddr *) clientAddr,
- &lenOfIncomingAddr);
- if (s == -1) {
- GE_LOG_STRERROR(sh->ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "accept");
- GE_LOG(sh->ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "Select %s failed to accept!\n",
- sh->description);
- if ( (errno == EAGAIN) || (errno == EWOULDBLOCK))
- continue; /* not good, but not fatal either */
- break;
- }
- if (sh->socket_quota <= 0) {
- SHUTDOWN(s, SHUT_WR);
- CLOSE(s);
- s = -1;
- continue;
- }
- sh->socket_quota--;
+ (FD_ISSET(sh->listen_sock->handle, &readSet)) ) {
+ lenOfIncomingAddr = sh->max_addr_len;
+ memset(clientAddr,
+ 0,
+ lenOfIncomingAddr);
+ /* make sure this is non-blocking */
+ socket_set_blocking(sh->listen_sock,
+ NO);
+ s = ACCEPT(sh->listen_sock->handle,
+ (struct sockaddr *) clientAddr,
+ &lenOfIncomingAddr);
+ if (s == -1) {
+ GE_LOG_STRERROR(sh->ectx,
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "accept");
+ GE_LOG(sh->ectx,
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "Select %s failed to accept!\n",
+ sh->description);
+ if ( (errno == EAGAIN) || (errno == EWOULDBLOCK))
+ continue; /* not good, but not fatal either */
+ break;
+ }
+ if (sh->socket_quota <= 0) {
+ SHUTDOWN(s, SHUT_WR);
+ CLOSE(s);
+ s = -1;
+ continue;
+ }
+ sh->socket_quota--;
#if DEBUG_SELECT
- GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Select %p is accepting connection: %d\n",
- sh,
- s);
+ GE_LOG(sh->ectx,
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Select %p is accepting connection: %d\n",
+ sh,
+ s);
#endif
- sock = socket_create(sh->ectx,
- sh->load_monitor,
- s);
- MUTEX_UNLOCK(sh->lock);
- sctx = sh->ah(sh->ah_cls,
- sh,
- sock,
- clientAddr,
- lenOfIncomingAddr);
- MUTEX_LOCK(sh->lock);
+ sock = socket_create(sh->ectx,
+ sh->load_monitor,
+ s);
+ MUTEX_UNLOCK(sh->lock);
+ sctx = sh->ah(sh->ah_cls,
+ sh,
+ sock,
+ clientAddr,
+ lenOfIncomingAddr);
+ MUTEX_LOCK(sh->lock);
#if DEBUG_SELECT
- GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Select %p is accepting connection: %p\n",
- sh,
- sctx);
+ GE_LOG(sh->ectx,
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Select %p is accepting connection: %p\n",
+ sh,
+ sctx);
#endif
- if (sctx == NULL) {
- socket_destroy(sock);
- sh->socket_quota++;
- } else {
- session = MALLOC(sizeof(Session));
- memset(session,
- 0,
- sizeof(Session));
- session->sock = sock;
- session->sock_ctx = sctx;
- session->lastUse = get_time();
- if (sh->sessionArrayLength == sh->sessionCount)
- GROW(sh->sessions,
- sh->sessionArrayLength,
- sh->sessionArrayLength + 4);
- sh->sessions[sh->sessionCount++] = session;
- }
+ if (sctx == NULL) {
+ socket_destroy(sock);
+ sh->socket_quota++;
+ } else {
+ session = MALLOC(sizeof(Session));
+ memset(session,
+ 0,
+ sizeof(Session));
+ session->sock = sock;
+ session->sock_ctx = sctx;
+ session->lastUse = get_time();
+ if (sh->sessionArrayLength == sh->sessionCount)
+ GROW(sh->sessions,
+ sh->sessionArrayLength,
+ sh->sessionArrayLength + 4);
+ sh->sessions[sh->sessionCount++] = session;
+ }
}
} else { /* is_udp == YES */
if ( (sh->listen_sock != NULL) &&
- (FD_ISSET(sh->listen_sock->handle, &readSet)) ) {
- int pending;
- int udp_sock;
- int error;
- socklen_t optlen;
-
- udp_sock = sh->listen_sock->handle;
- lenOfIncomingAddr = sh->max_addr_len;
- memset(clientAddr,
- 0,
- lenOfIncomingAddr);
- pending = 0;
- optlen = sizeof(pending);
+ (FD_ISSET(sh->listen_sock->handle, &readSet)) ) {
+ int pending;
+ int udp_sock;
+ int error;
+ socklen_t optlen;
+
+ udp_sock = sh->listen_sock->handle;
+ lenOfIncomingAddr = sh->max_addr_len;
+ memset(clientAddr,
+ 0,
+ lenOfIncomingAddr);
+ pending = 0;
+ optlen = sizeof(pending);
#ifdef OSX
- error = GETSOCKOPT(udp_sock,
- SOL_SOCKET,
- SO_NREAD,
- &pending,
- &optlen);
+ error = GETSOCKOPT(udp_sock,
+ SOL_SOCKET,
+ SO_NREAD,
+ &pending,
+ &optlen);
#elif MINGW
- error = ioctlsocket(udp_sock,
- FIONREAD,
- &pending);
+ error = ioctlsocket(udp_sock,
+ FIONREAD,
+ &pending);
#else
- error = ioctl(udp_sock,
- FIONREAD,
- &pending);
+ error = ioctl(udp_sock,
+ FIONREAD,
+ &pending);
#endif
- if ( (error != 0) ||
- (optlen != sizeof(pending)) ) {
- GE_LOG_STRERROR(sh->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- "ioctl");
- pending = 65535; /* max */
- }
+ if ( (error != 0) ||
+ (optlen != sizeof(pending)) ) {
+ GE_LOG_STRERROR(sh->ectx,
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "ioctl");
+ pending = 65535; /* max */
+ }
#if DEBUG_SELECT
- GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Select %p is preparing to receive %u bytes from UDP\n",
- sh,
- pending);
+ GE_LOG(sh->ectx,
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Select %p is preparing to receive %u bytes from UDP\n",
+ sh,
+ pending);
#endif
- GE_ASSERT(sh->ectx,
- pending >= 0);
- if (pending >= 65536)
- pending = 65536;
- if (pending == 0) {
- /* maybe empty UDP packet was sent (see report on bug-gnunet,
- 5/11/6; read 0 bytes from UDP just to kill potential empty packet!
*/
- socket_recv_from(sh->listen_sock,
- NC_Nonblocking,
- NULL,
- 0,
- &size,
- clientAddr,
- &lenOfIncomingAddr);
- } else {
- char * msg;
+ GE_ASSERT(sh->ectx,
+ pending >= 0);
+ if (pending >= 65536)
+ pending = 65536;
+ if (pending == 0) {
+ /* maybe empty UDP packet was sent (see report on bug-gnunet,
+ 5/11/6; read 0 bytes from UDP just to kill potential empty packet! */
+ socket_recv_from(sh->listen_sock,
+ NC_Nonblocking,
+ NULL,
+ 0,
+ &size,
+ clientAddr,
+ &lenOfIncomingAddr);
+ } else {
+ char * msg;
- msg = MALLOC(pending);
- size = 0;
- if (YES != socket_recv_from(sh->listen_sock,
- NC_Nonblocking,
- msg,
- pending,
- &size,
- clientAddr,
- &lenOfIncomingAddr)) {
+ msg = MALLOC(pending);
+ size = 0;
+ if (YES != socket_recv_from(sh->listen_sock,
+ NC_Nonblocking,
+ msg,
+ pending,
+ &size,
+ clientAddr,
+ &lenOfIncomingAddr)) {
#if DEBUG_SELECT
- GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Error in select %p -- failed to receive %u bytes\n",
- sh,
- pending);
+ GE_LOG(sh->ectx,
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Error in select %p -- failed to receive %u bytes\n",
+ sh,
+ pending);
#endif
- socket_close(sh->listen_sock);
- } else {
- /* validate msg format! */
- const MESSAGE_HEADER * hdr;
-
- /* if size < pending, set pending to size */
- if (size < pending)
- pending = size;
- hdr = (const MESSAGE_HEADER*) msg;
- if ( (size == pending) &&
- (size >= sizeof(MESSAGE_HEADER)) &&
- (ntohs(hdr->size) == size) ) {
- void * sctx;
-
- MUTEX_UNLOCK(sh->lock);
- sctx = sh->ah(sh->ah_cls,
- sh,
- NULL,
- clientAddr,
- lenOfIncomingAddr);
- MUTEX_LOCK(sh->lock);
- if (sctx != NULL) {
+ socket_close(sh->listen_sock);
+ } else {
+ /* validate msg format! */
+ const MESSAGE_HEADER * hdr;
+
+ /* if size < pending, set pending to size */
+ if (size < pending)
+ pending = size;
+ hdr = (const MESSAGE_HEADER*) msg;
+ if ( (size == pending) &&
+ (size >= sizeof(MESSAGE_HEADER)) &&
+ (ntohs(hdr->size) == size) ) {
+ void * sctx;
+
+ MUTEX_UNLOCK(sh->lock);
+ sctx = sh->ah(sh->ah_cls,
+ sh,
+ NULL,
+ clientAddr,
+ lenOfIncomingAddr);
+ MUTEX_LOCK(sh->lock);
+ if (sctx != NULL) {
#if DEBUG_SELECT
- GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Select %p is passing %u bytes from UDP to handler\n",
- sh,
- size);
+ GE_LOG(sh->ectx,
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Select %p is passing %u bytes from UDP to handler\n",
+ sh,
+ size);
#endif
- sh->mh(sh->mh_cls,
- sh,
- NULL,
- sctx,
- hdr);
- sh->ch(sh->ch_cls,
- sh,
- NULL,
- sctx);
- } else {
+ sh->mh(sh->mh_cls,
+ sh,
+ NULL,
+ sctx,
+ hdr);
+ sh->ch(sh->ch_cls,
+ sh,
+ NULL,
+ sctx);
+ } else {
#if DEBUG_SELECT
- GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Error in select %p -- connection refused\n",
- sh);
+ GE_LOG(sh->ectx,
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Error in select %p -- connection refused\n",
+ sh);
#endif
- }
- } else {
+ }
+ } else {
#if DEBUG_SELECT
- GE_BREAK(sh->ectx, size == pending);
- GE_BREAK(sh->ectx, size >= sizeof(MESSAGE_HEADER));
- GE_BREAK(sh->ectx, (size >= sizeof(MESSAGE_HEADER)) &&
(ntohs(hdr->size) == size));
+ GE_BREAK(sh->ectx, size == pending);
+ GE_BREAK(sh->ectx, size >= sizeof(MESSAGE_HEADER));
+ GE_BREAK(sh->ectx, (size >= sizeof(MESSAGE_HEADER)) &&
(ntohs(hdr->size) == size));
#endif
- }
- }
- FREE(msg);
- }
}
+ }
+ FREE(msg);
+ }
+ }
} /* end UDP processing */
if (FD_ISSET(sh->signal_pipe[0], &readSet)) {
/* allow reading multiple signals in one go in case we get many
- in one shot... */
+ in one shot... */
#define MAXSIG_BUF 128
char buf[MAXSIG_BUF];
/* just a signal to refresh sets, eat and continue */
if (0 >= READ(sh->signal_pipe[0],
- &buf[0],
- MAXSIG_BUF)) {
- GE_LOG_STRERROR(sh->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "read");
+ &buf[0],
+ MAXSIG_BUF)) {
+ GE_LOG_STRERROR(sh->ectx,
+ GE_WARNING | GE_USER | GE_BULK,
+ "read");
}
}
for (i=0;i<sh->sessionCount;i++) {
session = sh->sessions[i];
sock = session->sock;
if ( (FD_ISSET(sock->handle, &readSet)) &&
- (SYSERR == readAndProcess(sh,
- session)) ) {
- i--;
- continue;
+ (SYSERR == readAndProcess(sh,
+ session)) ) {
+ i--;
+ continue;
}
if ( (FD_ISSET(sock->handle, &writeSet)) &&
- (SYSERR == writeAndProcess(sh,
- session)) ) {
- i--;
- continue;
+ (SYSERR == writeAndProcess(sh,
+ session)) ) {
+ i--;
+ continue;
}
if (FD_ISSET(sock->handle, &errorSet)) {
- destroySession(sh,
- session);
- i--;
- continue;
+ destroySession(sh,
+ session);
+ i--;
+ continue;
}
if ( ( (sh->timeout != 0) &&
- (get_time() > session->lastUse + sh->timeout) ) ||
- ( (session->timeout != 0) &&
- (get_time() > session->lastUse + session->timeout) ) ) {
- destroySession(sh, session);
- i--;
- continue;
+ (get_time() > session->lastUse + sh->timeout) ) ||
+ ( (session->timeout != 0) &&
+ (get_time() > session->lastUse + session->timeout) ) ) {
+ destroySession(sh, session);
+ i--;
+ continue;
}
}
}
@@ -791,7 +791,7 @@
}
static int makePipeNonblocking(struct GE_Context * ectx,
- int handle) {
+ int handle) {
#if MINGW
DWORD mode;
@@ -804,11 +804,11 @@
int flags = fcntl(handle, F_GETFL);
flags |= O_NONBLOCK;
if (-1 == fcntl(handle,
- F_SETFL,
- flags)) {
+ F_SETFL,
+ flags)) {
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "fcntl");
+ GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "fcntl");
return SYSERR;
}
#endif
@@ -830,28 +830,28 @@
*/
SelectHandle *
select_create(const char * description,
- int is_udp,
- struct GE_Context * ectx,
- struct LoadMonitor * mon,
- int sock,
- unsigned int max_addr_len,
- cron_t timeout,
- SelectMessageHandler mh,
- void * mh_cls,
- SelectAcceptHandler ah,
- void * ah_cls,
- SelectCloseHandler ch,
- void * ch_cls,
- unsigned int memory_quota,
- int socket_quota) {
+ int is_udp,
+ struct GE_Context * ectx,
+ struct LoadMonitor * mon,
+ int sock,
+ unsigned int max_addr_len,
+ cron_t timeout,
+ SelectMessageHandler mh,
+ void * mh_cls,
+ SelectAcceptHandler ah,
+ void * ah_cls,
+ SelectCloseHandler ch,
+ void * ch_cls,
+ unsigned int memory_quota,
+ int socket_quota) {
SelectHandle * sh;
if ( (is_udp == NO) &&
(sock != -1) &&
(0 != LISTEN(sock, 5)) ) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- "listen");
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ "listen");
return NULL;
}
GE_ASSERT(ectx, description != NULL);
@@ -861,18 +861,18 @@
sh->description = description;
if (0 != PIPE(sh->signal_pipe)) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_USER | GE_IMMEDIATE,
- "pipe");
+ GE_ERROR | GE_USER | GE_IMMEDIATE,
+ "pipe");
FREE(sh);
return NULL;
}
if (OK != makePipeNonblocking(sh->ectx,
- sh->signal_pipe[0])) {
+ sh->signal_pipe[0])) {
if ( (0 != CLOSE(sh->signal_pipe[0])) ||
- (0 != CLOSE(sh->signal_pipe[1])) )
+ (0 != CLOSE(sh->signal_pipe[1])) )
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_IMMEDIATE | GE_ADMIN,
- "close");
+ GE_ERROR | GE_IMMEDIATE | GE_ADMIN,
+ "close");
FREE(sh);
return NULL;
}
@@ -893,24 +893,24 @@
sh->lock = MUTEX_CREATE(YES);
if (sock != -1)
sh->listen_sock = socket_create(ectx,
- mon,
- sock);
+ mon,
+ sock);
else
sh->listen_sock = NULL;
sh->thread = PTHREAD_CREATE(&selectThread,
- sh,
- 256 * 1024);
+ sh,
+ 256 * 1024);
if (sh->thread == NULL) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_IMMEDIATE | GE_ADMIN,
- "pthread_create");
+ GE_ERROR | GE_IMMEDIATE | GE_ADMIN,
+ "pthread_create");
if (sh->listen_sock != NULL)
socket_destroy(sh->listen_sock);
if ( (0 != CLOSE(sh->signal_pipe[0])) ||
- (0 != CLOSE(sh->signal_pipe[1])) )
+ (0 != CLOSE(sh->signal_pipe[1])) )
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_IMMEDIATE | GE_ADMIN,
- "close");
+ GE_ERROR | GE_IMMEDIATE | GE_ADMIN,
+ "close");
MUTEX_DESTROY(sh->lock);
FREE(sh);
return NULL;
@@ -927,9 +927,9 @@
#if DEBUG_SELECT
GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Destroying select %p\n",
- sh);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Destroying select %p\n",
+ sh);
#endif
sh->shutdown = YES;
signalSelect(sh);
@@ -946,12 +946,12 @@
MUTEX_DESTROY(sh->lock);
if (0 != CLOSE(sh->signal_pipe[1]))
GE_LOG_STRERROR(sh->ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "close");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "close");
if (0 != CLOSE(sh->signal_pipe[0]))
GE_LOG_STRERROR(sh->ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "close");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "close");
if (sh->listen_sock != NULL)
socket_destroy(sh->listen_sock);
FREE(sh);
@@ -969,10 +969,10 @@
* SYSERR if the sock does not belong with this select
*/
int select_write(struct SelectHandle * sh,
- struct SocketHandle * sock,
- const MESSAGE_HEADER * msg,
- int mayBlock,
- int force) {
+ struct SocketHandle * sock,
+ const MESSAGE_HEADER * msg,
+ int mayBlock,
+ int force) {
Session * session;
int i;
unsigned short len;
@@ -982,11 +982,11 @@
#if DEBUG_SELECT
GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Adding message of size %u to %p of select %p\n",
- ntohs(msg->size),
- sock,
- sh);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Adding message of size %u to %p of select %p\n",
+ ntohs(msg->size),
+ sock,
+ sh);
#endif
session = NULL;
len = ntohs(msg->size);
@@ -1014,27 +1014,27 @@
if (session->wapos - session->wspos + len <= session->wsize) {
/* can compact buffer to get space */
memmove(session->wbuff,
- &session->wbuff[session->wspos],
- session->wapos - session->wspos);
+ &session->wbuff[session->wspos],
+ session->wapos - session->wspos);
session->wapos -= session->wspos;
session->wspos = 0;
} else {
/* need to grow buffer */
newBufferSize = session->wsize;
if (session->wsize == 0)
- newBufferSize = 4092;
+ newBufferSize = 4092;
while (newBufferSize < len + session->wapos - session->wspos)
- newBufferSize *= 2;
+ newBufferSize *= 2;
if ( (sh->memory_quota > 0) &&
- (newBufferSize > sh->memory_quota) &&
- (force == NO) )
- newBufferSize = sh->memory_quota;
+ (newBufferSize > sh->memory_quota) &&
+ (force == NO) )
+ newBufferSize = sh->memory_quota;
GE_ASSERT(NULL,
- newBufferSize >= len + session->wapos - session->wspos);
+ newBufferSize >= len + session->wapos - session->wspos);
newBuffer = MALLOC(newBufferSize);
memcpy(newBuffer,
- &session->wbuff[session->wspos],
- session->wapos - session->wspos);
+ &session->wbuff[session->wspos],
+ session->wapos - session->wspos);
FREENONNULL(session->wbuff);
session->wbuff = newBuffer;
session->wsize = newBufferSize;
@@ -1043,10 +1043,10 @@
}
}
GE_ASSERT(NULL,
- session->wapos + len <= session->wsize);
+ session->wapos + len <= session->wsize);
memcpy(&session->wbuff[session->wapos],
- msg,
- len);
+ msg,
+ len);
session->wapos += len;
MUTEX_UNLOCK(sh->lock);
if (fresh_write)
@@ -1058,10 +1058,10 @@
/**
*/
int select_update_closure(struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * old_sock_ctx,
- void * new_sock_ctx) {
- Session * session;
+ struct SocketHandle * sock,
+ void * old_sock_ctx,
+ void * new_sock_ctx) {
+ Session * session;
int i;
session = NULL;
@@ -1076,7 +1076,7 @@
return SYSERR;
}
GE_ASSERT(NULL,
- session->sock_ctx == old_sock_ctx);
+ session->sock_ctx == old_sock_ctx);
session->sock_ctx = new_sock_ctx;
MUTEX_UNLOCK(sh->lock);
return OK;
@@ -1087,16 +1087,16 @@
* sockets managed by the select.
*/
int select_connect(struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * sock_ctx) {
- Session * session;
+ struct SocketHandle * sock,
+ void * sock_ctx) {
+ Session * session;
#if DEBUG_SELECT
GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Adding connection %p to selector %p\n",
- sock,
- sh);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Adding connection %p to selector %p\n",
+ sock,
+ sh);
#endif
session = MALLOC(sizeof(Session));
memset(session, 0, sizeof(Session));
@@ -1106,8 +1106,8 @@
MUTEX_LOCK(sh->lock);
if (sh->sessionArrayLength == sh->sessionCount)
GROW(sh->sessions,
- sh->sessionArrayLength,
- sh->sessionArrayLength + 4);
+ sh->sessionArrayLength,
+ sh->sessionArrayLength + 4);
sh->sessions[sh->sessionCount++] = session;
sh->socket_quota--;
MUTEX_UNLOCK(sh->lock);
@@ -1116,7 +1116,7 @@
}
static Session * findSession(struct SelectHandle * sh,
- struct SocketHandle * sock) {
+ struct SocketHandle * sock) {
int i;
for (i=0;i<sh->sessionCount;i++)
@@ -1130,19 +1130,19 @@
* set of sockets managed by select.
*/
int select_disconnect(struct SelectHandle * sh,
- struct SocketHandle * sock) {
+ struct SocketHandle * sock) {
Session * session;
#if DEBUG_SELECT
GE_LOG(sh->ectx,
- GE_DEBUG | GE_DEVELOPER | GE_BULK,
- "Removing connection %p from selector %p\n",
- sock,
- sh);
+ GE_DEBUG | GE_DEVELOPER | GE_BULK,
+ "Removing connection %p from selector %p\n",
+ sock,
+ sh);
#endif
MUTEX_LOCK(sh->lock);
session = findSession(sh,
- sock);
+ sock);
if (session == NULL) {
MUTEX_UNLOCK(sh->lock);
return SYSERR;
@@ -1159,13 +1159,13 @@
* this select.
*/
int select_change_timeout(struct SelectHandle * sh,
- struct SocketHandle * sock,
- cron_t timeout) {
+ struct SocketHandle * sock,
+ cron_t timeout) {
Session * session;
MUTEX_LOCK(sh->lock);
session = findSession(sh,
- sock);
+ sock);
if (session == NULL) {
MUTEX_UNLOCK(sh->lock);
return SYSERR;
@@ -1189,21 +1189,21 @@
* SYSERR if the sock does not belong with this select
*/
int select_would_try(struct SelectHandle * sh,
- struct SocketHandle * sock,
- unsigned int size,
- int mayBlock,
- int force) {
+ struct SocketHandle * sock,
+ unsigned int size,
+ int mayBlock,
+ int force) {
Session * session;
MUTEX_LOCK(sh->lock);
session = findSession(sh,
- sock);
+ sock);
if (session == NULL) {
MUTEX_UNLOCK(sh->lock);
return SYSERR;
}
GE_ASSERT(NULL,
- session->wapos >= session->wspos);
+ session->wapos >= session->wspos);
if ( (sh->memory_quota > 0) &&
(session->wapos - session->wspos + size > sh->memory_quota) &&
(force == NO) ) {
Modified: GNUnet/src/util/network/selecttest.c
===================================================================
--- GNUnet/src/util/network/selecttest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/network/selecttest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -78,10 +78,10 @@
* socket should be closed
*/
static int test_smh(void * mh_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * sock_ctx,
- const MESSAGE_HEADER * msg) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ void * sock_ctx,
+ const MESSAGE_HEADER * msg) {
static int sleeper;
char * expect;
unsigned short size;
@@ -90,22 +90,22 @@
throughput += size;
expect = MALLOC(size);
memset(expect,
- (size - sizeof(MESSAGE_HEADER)) % 251,
- size);
+ (size - sizeof(MESSAGE_HEADER)) % 251,
+ size);
if (0 != memcmp(&msg[1],
- expect,
- size - sizeof(MESSAGE_HEADER)) ) {
+ expect,
+ size - sizeof(MESSAGE_HEADER)) ) {
fprintf(stderr,
- "Message of size %u corrupt!\n",
- size);
+ "Message of size %u corrupt!\n",
+ size);
FREE(expect);
return OK;
}
FREE(expect);
while (msg->type != htons(recvPos)) {
fprintf(stderr,
- "Message %u lost!\n",
- recvPos);
+ "Message %u lost!\n",
+ recvPos);
recvPos++;
}
recvPos++;
@@ -132,10 +132,10 @@
* for the new connection
*/
static void * test_sah(void * ah_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- const void * addr,
- unsigned int addr_len) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ const void * addr,
+ unsigned int addr_len) {
static int ret_addr;
GE_BREAK(NULL, in == NULL);
@@ -148,9 +148,9 @@
* Free the associated context.
*/
static void test_sch(void * ch_cls,
- struct SelectHandle * sh,
- struct SocketHandle * sock,
- void * sock_ctx) {
+ struct SelectHandle * sh,
+ struct SocketHandle * sock,
+ void * sock_ctx) {
if (sock == in)
in = NULL;
else if (sock == out)
@@ -173,8 +173,8 @@
cron_t start;
listen_sock = SOCKET(PF_INET,
- SOCK_STREAM,
- 6); /* 6: TCP */
+ SOCK_STREAM,
+ 6); /* 6: TCP */
if (listen_sock == -1) {
GE_BREAK(NULL, 0);
return 1;
@@ -183,53 +183,53 @@
/* only try a single packet to establish connection,
if that does not work, abort instantly */
setsockopt(listen_sock,
- IPPROTO_TCP,
- TCP_SYNCNT,
- &zero,
- sizeof(zero));
+ IPPROTO_TCP,
+ TCP_SYNCNT,
+ &zero,
+ sizeof(zero));
#endif
memset((char *) &serverAddr,
- 0,
- sizeof(serverAddr));
+ 0,
+ sizeof(serverAddr));
serverAddr.sin_family = AF_INET;
serverAddr.sin_addr.s_addr = htonl(INADDR_ANY);
serverAddr.sin_port = htons(PORT);
if (BIND(listen_sock,
- (struct sockaddr *) &serverAddr,
- sizeof(serverAddr)) < 0) {
+ (struct sockaddr *) &serverAddr,
+ sizeof(serverAddr)) < 0) {
CLOSE(listen_sock);
return 1;
}
LISTEN(listen_sock, 5);
sh = select_create("Select Tester",
- NO, /* tcp */
- NULL, /* ectx */
- NULL, /* no load monitoring */
- listen_sock,
- sizeof(IPaddr),
- 15 * cronSECONDS, /* inactive timeout */
- test_smh,
- NULL,
- test_sah,
- NULL,
- test_sch,
- NULL,
- 128 * 1024); /* memory quota */
+ NO, /* tcp */
+ NULL, /* ectx */
+ NULL, /* no load monitoring */
+ listen_sock,
+ sizeof(IPaddr),
+ 15 * cronSECONDS, /* inactive timeout */
+ test_smh,
+ NULL,
+ test_sah,
+ NULL,
+ test_sch,
+ NULL,
+ 128 * 1024); /* memory quota */
write_sock = SOCKET(PF_INET,
- SOCK_STREAM,
- 6);
+ SOCK_STREAM,
+ 6);
memset((char *) &serverAddr,
- 0,
- sizeof(serverAddr));
+ 0,
+ sizeof(serverAddr));
serverAddr.sin_family = AF_INET;
serverAddr.sin_addr.s_addr = htonl(INADDR_ANY);
serverAddr.sin_port = htons(PORT);
i = CONNECT(write_sock,
- (struct sockaddr*)&serverAddr,
- sizeof(serverAddr));
+ (struct sockaddr*)&serverAddr,
+ sizeof(serverAddr));
if ( (i < 0) &&
(errno != EINPROGRESS) && (errno != EWOULDBLOCK) ) {
CLOSE(write_sock);
@@ -237,8 +237,8 @@
return 1;
}
out = socket_create(NULL,
- NULL,
- write_sock);
+ NULL,
+ write_sock);
if (-1 == socket_set_blocking(out, NO)) {
socket_destroy(out);
select_destroy(sh);
@@ -248,27 +248,27 @@
m = MALLOC(65536);
h = (MESSAGE_HEADER*) m;
select_connect(sh,
- out,
- NULL);
+ out,
+ NULL);
start = get_time();
for (i=0;i<ITER;i++) {
if (GNUNET_SHUTDOWN_TEST() == YES)
break;
if (select_would_try(sh,
- out,
- (i % 60000) + sizeof(MESSAGE_HEADER),
- NO,
- NO)) {
+ out,
+ (i % 60000) + sizeof(MESSAGE_HEADER),
+ NO,
+ NO)) {
h->size = htons((i % 60000) + sizeof(MESSAGE_HEADER));
h->type = htons(msg++);
memset(&m[sizeof(MESSAGE_HEADER)],
- (i % 60000) % 251,
- i % 60000);
+ (i % 60000) % 251,
+ i % 60000);
select_write(sh,
- out,
- h,
- NO,
- NO);
+ out,
+ h,
+ NO,
+ NO);
} else {
#if DO_YIELD
pthread_yield();
@@ -287,10 +287,10 @@
select_destroy(sh);
FREE(m);
fprintf(stderr,
- "\nTransmitted %u test messages - received %u (performance: %llu
kbps)\n",
- msg,
- recvPos,
- (throughput / 1024) * cronSECONDS / (get_time() - start));
+ "\nTransmitted %u test messages - received %u (performance: %llu kbps)\n",
+ msg,
+ recvPos,
+ (throughput / 1024) * cronSECONDS / (get_time() - start));
#if DO_SLEEP
if (msg - recvPos > 30)
return 1;
@@ -299,13 +299,13 @@
}
int main(int argc,
- char * argv[]){
+ char * argv[]){
int ret;
ret = check();
if (ret != 0)
fprintf(stderr,
- "ERROR %d.\n",
- ret);
+ "ERROR %d.\n",
+ ret);
return ret;
}
Modified: GNUnet/src/util/network_client/daemon.c
===================================================================
--- GNUnet/src/util/network_client/daemon.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/network_client/daemon.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -31,7 +31,7 @@
#include "gnunet_util_threads.h"
int connection_test_running(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
struct ClientServerConnection * sock;
MESSAGE_HEADER csHdr;
int ret;
@@ -44,12 +44,12 @@
csHdr.type
= htons(CS_PROTO_traffic_COUNT);
if (SYSERR == connection_write(sock,
- &csHdr)) {
+ &csHdr)) {
connection_destroy(sock);
return SYSERR;
}
if (SYSERR == connection_read_result(sock,
- &ret)) {
+ &ret)) {
connection_destroy(sock);
return SYSERR;
}
@@ -66,12 +66,12 @@
csHdr.type
= htons(CS_PROTO_SHUTDOWN_REQUEST);
if (SYSERR == connection_write(sock,
- &csHdr)) {
+ &csHdr)) {
connection_close_temporarily(sock);
return SYSERR;
}
if (SYSERR == connection_read_result(sock,
- &ret)) {
+ &ret)) {
connection_close_temporarily(sock);
return SYSERR;
}
@@ -86,15 +86,15 @@
* @return OK if gnunetd is now running
*/
int connection_wait_for_running(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- cron_t timeout) {
+ struct GC_Configuration * cfg,
+ cron_t timeout) {
cron_t min;
int ret;
timeout += get_time();
while (GNUNET_SHUTDOWN_TEST() == 0) {
ret = connection_test_running(ectx,
- cfg);
+ cfg);
if (ret == OK)
return OK;
if (timeout < get_time())
Modified: GNUnet/src/util/network_client/tcpio.c
===================================================================
--- GNUnet/src/util/network_client/tcpio.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/network_client/tcpio.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -78,20 +78,20 @@
* @return 0 on error
*/
static unsigned short getGNUnetPort(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * res;
char * pos;
unsigned int port;
res = NULL;
if (-1 == GC_get_configuration_value_string(cfg,
- "NETWORK",
- "HOST",
- "localhost:2087",
- &res)) {
+ "NETWORK",
+ "HOST",
+ "localhost:2087",
+ &res)) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("Could not find valid value for HOST in section NETWORK."));
+ GE_ERROR | GE_USER | GE_BULK,
+ _("Could not find valid value for HOST in section NETWORK."));
return 2087;
}
pos = strstr(res, ":");
@@ -102,9 +102,9 @@
pos++;
if (1 != SSCANF(pos, "%u", &port)) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("Syntax error in configuration entry HOST in section NETWORK:
`%s'"),
- pos);
+ GE_ERROR | GE_USER | GE_BULK,
+ _("Syntax error in configuration entry HOST in section NETWORK: `%s'"),
+ pos);
FREE(res);
return 2087;
}
@@ -120,19 +120,19 @@
*/
static char *
getGNUnetdHost(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * res;
char * pos;
res = NULL;
if (-1 == GC_get_configuration_value_string(cfg,
- "NETWORK",
- "HOST",
- "localhost:2087",
- &res)) {
+ "NETWORK",
+ "HOST",
+ "localhost:2087",
+ &res)) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("Could not find valid value for HOST in section NETWORK."));
+ GE_ERROR | GE_USER | GE_BULK,
+ _("Could not find valid value for HOST in section NETWORK."));
return NULL;
}
pos = strstr(res, ":");
@@ -143,7 +143,7 @@
struct ClientServerConnection *
client_connection_create(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
ClientServerConnection * result;
result = MALLOC(sizeof(ClientServerConnection));
@@ -223,16 +223,16 @@
if (sock->dead == YES)
return SYSERR;
port = getGNUnetPort(sock->ectx,
- sock->cfg);
+ sock->cfg);
if (port == 0)
return SYSERR;
host = getGNUnetdHost(sock->ectx,
- sock->cfg);
+ sock->cfg);
if (host == NULL)
return SYSERR;
if (SYSERR == get_host_by_name(sock->ectx,
- host,
- &ip)) {
+ host,
+ &ip)) {
FREE(host);
return SYSERR;
}
@@ -250,37 +250,37 @@
osock = SOCKET(PF_INET, SOCK_STREAM, 6); /* 6: TCP */
if (osock == -1) {
GE_LOG_STRERROR(sock->ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "socket");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "socket");
FREE(host);
MUTEX_UNLOCK(sock->destroylock);
return SYSERR;
}
sock->sock = socket_create(sock->ectx,
- NULL,
- osock);
+ NULL,
+ osock);
socket_set_blocking(sock->sock, NO);
memset(&soaddr,
- 0,
- sizeof(soaddr));
+ 0,
+ sizeof(soaddr));
soaddr.sin_family = AF_INET;
GE_ASSERT(sock->ectx,
- sizeof(struct in_addr) == sizeof(IPaddr));
+ sizeof(struct in_addr) == sizeof(IPaddr));
memcpy(&soaddr.sin_addr,
- &ip,
- sizeof(struct in_addr));
+ &ip,
+ sizeof(struct in_addr));
soaddr.sin_port = htons(port);
ret = CONNECT(osock,
- (struct sockaddr*)&soaddr,
- sizeof(soaddr));
+ (struct sockaddr*)&soaddr,
+ sizeof(soaddr));
if ( (ret != 0) &&
(errno != EINPROGRESS) && (errno != EWOULDBLOCK)) {
GE_LOG(sock->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Cannot connect to %s:%u: %s\n"),
- host,
- port,
- STRERROR(errno));
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Cannot connect to %s:%u: %s\n"),
+ host,
+ port,
+ STRERROR(errno));
socket_destroy(sock->sock);
sock->sock = NULL;
FREE(host);
@@ -301,15 +301,15 @@
timeout.tv_usec = 0;
errno = 0;
ret = SELECT(osock + 1,
- &rset,
- &wset,
- &eset,
- &timeout);
+ &rset,
+ &wset,
+ &eset,
+ &timeout);
if (ret == -1) {
if (errno != EINTR)
GE_LOG_STRERROR(sock->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "select");
+ GE_WARNING | GE_USER | GE_BULK,
+ "select");
socket_destroy(sock->sock);
sock->sock = NULL;
FREE(host);
@@ -317,12 +317,12 @@
return SYSERR;
}
if (FD_ISSET(osock,
- &eset)) {
+ &eset)) {
GE_LOG(sock->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Error connecting to %s:%u\n"),
- host,
- port);
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Error connecting to %s:%u\n"),
+ host,
+ port);
socket_destroy(sock->sock);
sock->sock = NULL;
FREE(host);
@@ -330,13 +330,13 @@
return SYSERR;
}
if (! FD_ISSET(osock,
- &wset)) {
+ &wset)) {
GE_LOG(sock->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- _("Failed to connect to %s:%u in %ds\n"),
- host,
- port,
- WAIT_SECONDS);
+ GE_WARNING | GE_USER | GE_BULK,
+ _("Failed to connect to %s:%u in %ds\n"),
+ host,
+ port,
+ WAIT_SECONDS);
socket_destroy(sock->sock);
sock->sock = NULL;
FREE(host);
@@ -358,7 +358,7 @@
* @return OK if the write was sucessful, otherwise SYSERR.
*/
int connection_write(struct ClientServerConnection * sock,
- const MESSAGE_HEADER * buffer) {
+ const MESSAGE_HEADER * buffer) {
size_t size;
size_t sent;
int res;
@@ -374,10 +374,10 @@
GE_ASSERT(NULL, sock->sock != NULL);
size = ntohs(buffer->size);
res = socket_send(sock->sock,
- NC_Complete,
- buffer,
- size,
- &sent);
+ NC_Complete,
+ buffer,
+ size,
+ &sent);
if ( (res != YES) ||
(sent != size) ) {
MUTEX_UNLOCK(sock->writelock);
@@ -389,7 +389,7 @@
}
int connection_read(struct ClientServerConnection * sock,
- MESSAGE_HEADER ** buffer) {
+ MESSAGE_HEADER ** buffer) {
int res;
size_t pos;
char * buf;
@@ -409,11 +409,11 @@
pos = 0;
res = 0;
if ( (OK != socket_recv(sock->sock,
- NC_Complete,
- &size,
- sizeof(unsigned short),
- &pos)) ||
- (pos != sizeof(unsigned short)) ) {
+ NC_Complete,
+ &size,
+ sizeof(unsigned short),
+ &pos)) ||
+ (pos != sizeof(unsigned short)) ) {
MUTEX_UNLOCK(sock->readlock);
connection_close_temporarily(sock);
return SYSERR;
@@ -428,11 +428,11 @@
buf = MALLOC(size);
if ( (OK != socket_recv(sock->sock,
- NC_Complete,
- &buf[pos],
- size - pos,
- &pos)) ||
- (pos + sizeof(unsigned short) != size) ) {
+ NC_Complete,
+ &buf[pos],
+ size - pos,
+ &pos)) ||
+ (pos + sizeof(unsigned short) != size) ) {
FREE(buf);
MUTEX_UNLOCK(sock->readlock);
connection_close_temporarily(sock);
@@ -440,9 +440,9 @@
}
#if DEBUG_TCPIO
GE_LOG(sock->ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "Successfully received %d bytes from TCP socket.\n",
- size);
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Successfully received %d bytes from TCP socket.\n",
+ size);
#endif
*buffer = (MESSAGE_HEADER*) buf;
(*buffer)->size = htons(size);
@@ -459,10 +459,10 @@
}
size = ntohs(rem->header.size) - sizeof(RETURN_ERROR_MESSAGE);
GE_LOG(sock->ectx,
- ntohl(rem->kind),
- "%.*s",
- (int) size,
- &rem[1]);
+ ntohl(rem->kind),
+ "%.*s",
+ (int) size,
+ &rem[1]);
FREE(rem);
} /* while (1) */
MUTEX_UNLOCK(sock->readlock);
@@ -478,19 +478,19 @@
* successfully
*/
int connection_read_result(struct ClientServerConnection * sock,
- int * ret) {
+ int * ret) {
RETURN_VALUE_MESSAGE * rv;
rv = NULL;
if (SYSERR == connection_read(sock,
- (MESSAGE_HEADER **) &rv))
+ (MESSAGE_HEADER **) &rv))
return SYSERR;
if ( (ntohs(rv->header.size) != sizeof(RETURN_VALUE_MESSAGE)) ||
(ntohs(rv->header.type) != CS_PROTO_RETURN_VALUE) ) {
GE_LOG(sock->ectx,
- GE_WARNING | GE_DEVELOPER | GE_BULK,
- _("`%s' failed, reply invalid!\n"),
- __FUNCTION__);
+ GE_WARNING | GE_DEVELOPER | GE_BULK,
+ _("`%s' failed, reply invalid!\n"),
+ __FUNCTION__);
FREE(rv);
return SYSERR;
}
@@ -508,7 +508,7 @@
* send successfully
*/
int connection_write_result(struct ClientServerConnection * sock,
- int ret) {
+ int ret) {
RETURN_VALUE_MESSAGE rv;
rv.header.size
@@ -518,7 +518,7 @@
rv.return_value
= htonl(ret);
return connection_write(sock,
- &rv.header);
+ &rv.header);
}
/* end of tcpio.c */
Modified: GNUnet/src/util/network_client/tcpiotest.c
===================================================================
--- GNUnet/src/util/network_client/tcpiotest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/network_client/tcpiotest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -44,37 +44,37 @@
listenerFD = SOCKET(PF_INET, SOCK_STREAM, 0);
if (listenerFD < 0) {
GE_LOG_STRERROR(NULL,
- GE_BULK | GE_ERROR | GE_USER,
- "socket");
+ GE_BULK | GE_ERROR | GE_USER,
+ "socket");
return -1;
}
/* fill in the inet address structure */
memset((char *) &serverAddr,
- 0,
- sizeof(serverAddr));
+ 0,
+ sizeof(serverAddr));
serverAddr.sin_family = AF_INET;
serverAddr.sin_addr.s_addr=htonl(INADDR_ANY);
serverAddr.sin_port=htons(listenerPort);
if ( SETSOCKOPT(listenerFD,
- SOL_SOCKET,
- SO_REUSEADDR,
- &on, sizeof(on)) < 0 ) {
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ &on, sizeof(on)) < 0 ) {
GE_LOG_STRERROR(NULL,
- GE_BULK | GE_ERROR | GE_USER,
- "setsockopt");
+ GE_BULK | GE_ERROR | GE_USER,
+ "setsockopt");
CLOSE(listenerFD);
return -1;
}
/* bind the socket */
if (BIND (listenerFD,
- (struct sockaddr *) &serverAddr,
- sizeof(serverAddr)) < 0) {
+ (struct sockaddr *) &serverAddr,
+ sizeof(serverAddr)) < 0) {
GE_LOG_STRERROR(NULL,
- GE_BULK | GE_ERROR | GE_USER,
- "bind");
+ GE_BULK | GE_ERROR | GE_USER,
+ "bind");
CLOSE(listenerFD);
return -1;
}
@@ -82,8 +82,8 @@
/* start listening for new connections */
if (0 != LISTEN(listenerFD, 5)) {
GE_LOG_STRERROR(NULL,
- GE_BULK | GE_ERROR | GE_USER,
- "listen");
+ GE_BULK | GE_ERROR | GE_USER,
+ "listen");
CLOSE(listenerFD);
return -1;
}
@@ -99,12 +99,12 @@
while (incomingFD < 0) {
lenOfIncomingAddr = sizeof(clientAddr);
incomingFD = ACCEPT(serverSocket,
- (struct sockaddr *)&clientAddr,
- &lenOfIncomingAddr);
+ (struct sockaddr *)&clientAddr,
+ &lenOfIncomingAddr);
if (incomingFD < 0) {
GE_LOG_STRERROR(NULL,
- GE_BULK | GE_ERROR | GE_USER,
- "accept");
+ GE_BULK | GE_ERROR | GE_USER,
+ "accept");
continue;
}
}
@@ -112,7 +112,7 @@
}
static int testTransmission(struct ClientServerConnection * a,
- struct SocketHandle * b) {
+ struct SocketHandle * b) {
MESSAGE_HEADER * hdr;
MESSAGE_HEADER * buf;
int i;
@@ -136,13 +136,13 @@
while (pos < i + sizeof(MESSAGE_HEADER)) {
rd = 0;
if (SYSERR == socket_recv(b,
- NC_Nonblocking,
- &buf[pos],
- 2048 - pos,
- &rd)) {
- FREE(hdr);
- FREE(buf);
- return 2;
+ NC_Nonblocking,
+ &buf[pos],
+ 2048 - pos,
+ &rd)) {
+ FREE(hdr);
+ FREE(buf);
+ return 2;
}
pos += rd;
}
@@ -172,7 +172,7 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
- "check.conf")) {
+ "check.conf")) {
GC_free(cfg);
return -1;
}
@@ -180,7 +180,7 @@
if (serverSocket == -1)
return 1;
clientSocket = client_connection_create(NULL,
- cfg);
+ cfg);
ret = 0;
for (i=0;i<2;i++) {
if (OK != connection_ensure_connected(clientSocket)) {
@@ -201,8 +201,8 @@
CLOSE(serverSocket);
if (ret > 0)
fprintf(stderr,
- "Error %d\n",
- ret);
+ "Error %d\n",
+ ret);
GC_free(cfg);
return ret;
}
Modified: GNUnet/src/util/os/console.c
===================================================================
--- GNUnet/src/util/os/console.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/console.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -40,10 +40,10 @@
char * pif;
if (0 != GC_get_configuration_value_filename(cfg,
- "GNUNETD",
- "PIDFILE",
- VAR_DAEMON_DIRECTORY
"/gnunetd/pid",
- &pif))
+ "GNUNETD",
+ "PIDFILE",
+ VAR_DAEMON_DIRECTORY "/gnunetd/pid",
+ &pif))
return NULL;
return pif;
}
@@ -55,8 +55,8 @@
* @return OK on success, SYSERR on error
*/
int os_write_pid_file(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- unsigned int pid) {
+ struct GC_Configuration * cfg,
+ unsigned int pid) {
FILE * pidfd;
char * pif;
char * user;
@@ -67,14 +67,14 @@
if (pif == NULL)
return OK; /* no PID file */
GC_get_configuration_value_string(cfg,
- "GNUNETD",
- "USER",
- "",
- &user);
+ "GNUNETD",
+ "USER",
+ "",
+ &user);
rdir = STRDUP(pif);
len = strlen(rdir);
while ( (len > 0) &&
- (rdir[len] != DIR_SEPARATOR) )
+ (rdir[len] != DIR_SEPARATOR) )
len--;
rdir[len] = '\0';
if (0 != ACCESS(rdir, F_OK)) {
@@ -83,14 +83,14 @@
disk_directory_create(ectx, rdir);
if (strlen(user))
os_change_owner(ectx,
- rdir,
- user);
+ rdir,
+ user);
}
if (0 != ACCESS(rdir, W_OK | X_OK)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "access",
- rdir);
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "access",
+ rdir);
FREE(rdir);
FREE(user);
return SYSERR;
@@ -99,46 +99,46 @@
pidfd = FOPEN(pif, "w");
if (pidfd == NULL) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "fopen",
- pif);
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "fopen",
+ pif);
FREE(pif);
FREE(user);
return SYSERR;
}
if (0 > FPRINTF(pidfd,
- "%u",
- pid))
+ "%u",
+ pid))
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "fprintf",
- pif);
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "fprintf",
+ pif);
if (0 != fclose(pidfd))
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "fclose",
- pif);
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "fclose",
+ pif);
if (strlen(user))
os_change_owner(ectx,
- pif,
- user);
+ pif,
+ user);
FREE(user);
FREE(pif);
return OK;
}
int os_delete_pid_file(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
char * pif = getPIDFile(cfg);
if (pif == NULL)
return OK; /* no PID file */
if (YES == disk_file_test(ectx,
- pif)) {
+ pif)) {
if (0 != UNLINK(pif)) {
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "unlink",
- pif);
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "unlink",
+ pif);
FREE(pif);
return SYSERR;
}
@@ -156,16 +156,16 @@
* to complete the detachment protocol (handshake)
*/
int os_terminal_detach(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- int * filedes) {
+ struct GC_Configuration * cfg,
+ int * filedes) {
pid_t pid;
int nullfd;
/* Don't hold the wrong FS mounted */
if (CHDIR("/") < 0) {
GE_LOG_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "chdir");
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "chdir");
return SYSERR;
}
@@ -174,8 +174,8 @@
pid = fork();
if (pid < 0) {
GE_LOG_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "fork");
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "fork");
return SYSERR;
}
if (pid) { /* Parent */
@@ -184,20 +184,20 @@
if (0 != CLOSE(filedes[1]))
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "close");
+ GE_WARNING | GE_USER | GE_BULK,
+ "close");
ok = SYSERR;
while (0 < READ(filedes[0],
- &c,
- sizeof(char))) {
+ &c,
+ sizeof(char))) {
if (c == '.')
- ok = OK;
+ ok = OK;
}
fflush(stdout);
if (ok == OK) {
os_write_pid_file(ectx,
- cfg,
- pid);
+ cfg,
+ pid);
exit(0);
} else {
exit(1); /* child reported error */
@@ -205,16 +205,16 @@
}
if (0 != CLOSE(filedes[0]))
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "close");
+ GE_WARNING | GE_USER | GE_BULK,
+ "close");
nullfd = disk_file_open(ectx,
- "/dev/null",
- O_RDWR | O_APPEND);
+ "/dev/null",
+ O_RDWR | O_APPEND);
if (nullfd < 0) {
GE_LOG_STRERROR_FILE(ectx,
- GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "fork",
- "/dev/null");
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "fork",
+ "/dev/null");
return SYSERR;
}
/* child - close fds linking to invoking terminal, but
@@ -225,15 +225,15 @@
dup2(nullfd,1) < 0 ||
dup2(nullfd,2) < 0) {
GE_LOG_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "dup2");
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "dup2");
return SYSERR;
}
pid = setsid(); /* Detach from controlling terminal */
if (pid == -1)
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "setsid");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "setsid");
#else
FreeConsole();
#endif
@@ -241,20 +241,20 @@
}
void os_terminal_detach_complete(struct GE_Context * ectx,
- int * filedes,
- int success) {
+ int * filedes,
+ int success) {
#ifndef MINGW
char c = '.';
if (! success)
c = '!';
WRITE(filedes[1],
- &c,
- sizeof(char)); /* signal success */
+ &c,
+ sizeof(char)); /* signal success */
if (0 != CLOSE(filedes[1]))
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "close");
+ GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "close");
#endif
}
Modified: GNUnet/src/util/os/cpustatus.c
===================================================================
--- GNUnet/src/util/os/cpustatus.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/cpustatus.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -90,7 +90,7 @@
int i,j;
kret = host_processor_info(mach_host_self(),
- PROCESSOR_CPU_LOAD_INFO,
+ PROCESSOR_CPU_LOAD_INFO,
&cpu_count,
(processor_info_array_t *)&cpu_load,
&cpu_msg_count);
@@ -140,53 +140,53 @@
fflush(proc_stat);
if (NULL == fgets(line, 256, proc_stat)) {
GE_LOG_STRERROR_FILE(NULL,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "fgets",
- "/proc/stat");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "fgets",
+ "/proc/stat");
fclose(proc_stat);
proc_stat = NULL; /* don't try again */
} else {
iowait_read = 0;
ret = sscanf(line, "%*s %llu %llu %llu %llu %llu",
- &user_read,
- &system_read,
- &nice_read,
- &idle_read,
- &iowait_read);
+ &user_read,
+ &system_read,
+ &nice_read,
+ &idle_read,
+ &iowait_read);
if (ret < 4) {
- GE_LOG_STRERROR_FILE(NULL,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "fgets-sscanf",
- "/proc/stat");
- fclose(proc_stat);
- proc_stat = NULL; /* don't try again */
- have_last_cpu = NO;
+ GE_LOG_STRERROR_FILE(NULL,
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "fgets-sscanf",
+ "/proc/stat");
+ fclose(proc_stat);
+ proc_stat = NULL; /* don't try again */
+ have_last_cpu = NO;
} else {
- /* Store the current usage*/
- user = user_read - last_cpu_results[0];
- system = system_read - last_cpu_results[1];
- nice = nice_read - last_cpu_results[2];
- idle = idle_read - last_cpu_results[3];
- iowait = iowait_read - last_cpu_results[4];
- /* Calculate the % usage */
- usage_time = user + system + nice;
- total_time = usage_time + idle + iowait;
- if ( (total_time > 0) &&
- (have_last_cpu == YES) ) {
- currentCPULoad = (int) (100L * usage_time / total_time);
- if (ret > 4)
- currentIOLoad = (int) (100L * iowait / total_time);
- else
- currentIOLoad = -1; /* 2.4 kernel */
- }
- /* Store the values for the next calculation*/
- last_cpu_results[0] = user_read;
- last_cpu_results[1] = system_read;
- last_cpu_results[2] = nice_read;
- last_cpu_results[3] = idle_read;
- last_cpu_results[4] = iowait_read;
- have_last_cpu = YES;
- return OK;
+ /* Store the current usage*/
+ user = user_read - last_cpu_results[0];
+ system = system_read - last_cpu_results[1];
+ nice = nice_read - last_cpu_results[2];
+ idle = idle_read - last_cpu_results[3];
+ iowait = iowait_read - last_cpu_results[4];
+ /* Calculate the % usage */
+ usage_time = user + system + nice;
+ total_time = usage_time + idle + iowait;
+ if ( (total_time > 0) &&
+ (have_last_cpu == YES) ) {
+ currentCPULoad = (int) (100L * usage_time / total_time);
+ if (ret > 4)
+ currentIOLoad = (int) (100L * iowait / total_time);
+ else
+ currentIOLoad = -1; /* 2.4 kernel */
+ }
+ /* Store the values for the next calculation*/
+ last_cpu_results[0] = user_read;
+ last_cpu_results[1] = system_read;
+ last_cpu_results[2] = nice_read;
+ last_cpu_results[3] = idle_read;
+ last_cpu_results[4] = iowait_read;
+ have_last_cpu = YES;
+ return OK;
}
}
}
@@ -280,7 +280,7 @@
static long long last_idlecount;
static long long last_totalcount;
static int kstat_once; /* if open fails, don't keep
- trying */
+ trying */
kstat_ctl_t * kc;
kstat_t * khelper;
long long idlecount;
@@ -293,50 +293,50 @@
kc = kstat_open();
if (kc == NULL) {
GE_LOG_STRERROR(NULL,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "kstat_open");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "kstat_open");
goto ABORT_KSTAT;
}
idlecount = 0;
totalcount = 0;
for (khelper = kc->kc_chain;
- khelper != NULL;
- khelper = khelper->ks_next) {
+ khelper != NULL;
+ khelper = khelper->ks_next) {
cpu_stat_t stats;
if (0 != strncmp(khelper->ks_name,
- "cpu_stat",
- strlen("cpu_stat")) )
- continue;
+ "cpu_stat",
+ strlen("cpu_stat")) )
+ continue;
if (khelper->ks_data_size > sizeof(cpu_stat_t))
- continue; /* better save then sorry! */
+ continue; /* better save then sorry! */
if (-1 != kstat_read(kc, khelper, &stats)) {
- idlecount
- += stats.cpu_sysinfo.cpu[CPU_IDLE];
- totalcount
- += stats.cpu_sysinfo.cpu[CPU_IDLE] +
- stats.cpu_sysinfo.cpu[CPU_USER] +
- stats.cpu_sysinfo.cpu[CPU_KERNEL] +
- stats.cpu_sysinfo.cpu[CPU_WAIT];
+ idlecount
+ += stats.cpu_sysinfo.cpu[CPU_IDLE];
+ totalcount
+ += stats.cpu_sysinfo.cpu[CPU_IDLE] +
+ stats.cpu_sysinfo.cpu[CPU_USER] +
+ stats.cpu_sysinfo.cpu[CPU_KERNEL] +
+ stats.cpu_sysinfo.cpu[CPU_WAIT];
}
}
if (0 != kstat_close(kc))
GE_LOG_STRERROR(NULL,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "kstat_close");
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "kstat_close");
if ( (idlecount == 0) &&
- (totalcount == 0) )
+ (totalcount == 0) )
goto ABORT_KSTAT; /* no stats found => abort */
deltaidle = idlecount - last_idlecount;
deltatotal = totalcount - last_totalcount;
if ( (deltatotal > 0) &&
- (last_totalcount > 0) ) {
+ (last_totalcount > 0) ) {
currentCPULoad = (unsigned int) (100.0 * deltaidle / deltatotal);
if (currentCPULoad > 100)
- currentCPULoad = 100; /* odd */
+ currentCPULoad = 100; /* odd */
if (currentCPULoad < 0)
- currentCPULoad = 0; /* odd */
+ currentCPULoad = 0; /* odd */
currentCPULoad = 100 - currentCPULoad; /* computed idle-load before! */
} else
currentCPULoad = -1;
@@ -360,12 +360,12 @@
double loadavg;
if (1 != getloadavg(&loadavg, 1)) {
/* only warn once, if there is a problem with
- getloadavg, we're going to hit it frequently... */
+ getloadavg, we're going to hit it frequently... */
if (warnOnce == 0) {
- warnOnce = 1;
- GE_LOG_STRERROR(NULL,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "getloadavg");
+ warnOnce = 1;
+ GE_LOG_STRERROR(NULL,
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "getloadavg");
}
return SYSERR;
} else {
@@ -392,9 +392,9 @@
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION theInfo;
if (GNNtQuerySystemInformation(SystemProcessorPerformanceInformation,
- &theInfo,
- sizeof(theInfo),
- NULL) == NO_ERROR) {
+ &theInfo,
+ sizeof(theInfo),
+ NULL) == NO_ERROR) {
/* PORT-ME MINGW: Multi-processor? */
dKernel = Li2Double(theInfo.KernelTime);
dIdle = Li2Double(theInfo.IdleTime);
@@ -404,7 +404,7 @@
dDiffUser = dUser - dLastUser;
if ( ( (dDiffKernel + dDiffUser) > 0) &&
- (dLastIdle + dLastKernel + dLastUser > 0) )
+ (dLastIdle + dLastKernel + dLastUser > 0) )
currentCPULoad = 100.0 - (dDiffIdle / (dDiffKernel + dDiffUser)) *
100.0;
else
currentCPULoad = -1; /* don't know (yet) */
@@ -417,13 +417,13 @@
return OK;
} else {
/* only warn once, if there is a problem with
- NtQuery..., we're going to hit it frequently... */
+ NtQuery..., we're going to hit it frequently... */
static int once;
if (once == 0) {
- once = 1;
- GE_LOG(NULL,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- _("Cannot query the CPU usage (Windows NT).\n"));
+ once = 1;
+ GE_LOG(NULL,
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ _("Cannot query the CPU usage (Windows NT).\n"));
}
return SYSERR;
}
@@ -433,67 +433,67 @@
/* Start query */
if (RegOpenKeyEx(HKEY_DYN_DATA,
- "PerfStats\\StartSrv",
- 0,
- KEY_ALL_ACCESS,
+ "PerfStats\\StartSrv",
+ 0,
+ KEY_ALL_ACCESS,
&hKey) != ERROR_SUCCESS) {
/* only warn once */
static int once = 0;
if (once == 0) {
- once = 1;
- GE_LOG(NULL,
- GE_USER | GE_ADMIN | GE_ERROR | GE_BULK,
- _("Cannot query the CPU usage (Win 9x)\n"));
+ once = 1;
+ GE_LOG(NULL,
+ GE_USER | GE_ADMIN | GE_ERROR | GE_BULK,
+ _("Cannot query the CPU usage (Win 9x)\n"));
}
}
RegOpenKeyEx(HKEY_DYN_DATA,
- "PerfStats\\StartStat",
- 0,
- KEY_ALL_ACCESS,
- &hKey);
+ "PerfStats\\StartStat",
+ 0,
+ KEY_ALL_ACCESS,
+ &hKey);
dwDataSize = sizeof(dwDummy);
RegQueryValueEx(hKey,
- "KERNEL\\CPUUsage",
- NULL,
- &dwType,
- (LPBYTE) &dwDummy,
+ "KERNEL\\CPUUsage",
+ NULL,
+ &dwType,
+ (LPBYTE) &dwDummy,
&dwDataSize);
RegCloseKey(hKey);
/* Get CPU usage */
RegOpenKeyEx(HKEY_DYN_DATA,
- "PerfStats\\StatData",
- 0,
- KEY_ALL_ACCESS,
+ "PerfStats\\StatData",
+ 0,
+ KEY_ALL_ACCESS,
&hKey);
dwDataSize = sizeof(currentCPULoad);
RegQueryValueEx(hKey,
- "KERNEL\\CPUUsage",
- NULL,
- &dwType,
+ "KERNEL\\CPUUsage",
+ NULL,
+ &dwType,
(LPBYTE) ¤tCPULoad,
- &dwDataSize);
+ &dwDataSize);
RegCloseKey(hKey);
currentIOLoad = -1; /* FIXME-MINGW! */
/* Stop query */
RegOpenKeyEx(HKEY_DYN_DATA,
- "PerfStats\\StopStat",
- 0,
- KEY_ALL_ACCESS,
+ "PerfStats\\StopStat",
+ 0,
+ KEY_ALL_ACCESS,
&hKey);
RegOpenKeyEx(HKEY_DYN_DATA,
- "PerfStats\\StopSrv",
- 0,
- KEY_ALL_ACCESS,
+ "PerfStats\\StopSrv",
+ 0,
+ KEY_ALL_ACCESS,
&hKey);
dwDataSize = sizeof(dwDummy);
RegQueryValueEx(hKey,
- "KERNEL\\CPUUsage",
- NULL,
- &dwType,
- (LPBYTE)&dwDummy,
+ "KERNEL\\CPUUsage",
+ NULL,
+ &dwType,
+ (LPBYTE)&dwDummy,
&dwDataSize);
RegCloseKey(hKey);
@@ -514,7 +514,7 @@
* that lock has already been obtained.
*/
static void updateAgedLoad(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
static cron_t lastCall;
cron_t now;
@@ -531,22 +531,22 @@
agedCPULoad = -1;
} else {
if (agedCPULoad == -1) {
- agedCPULoad = currentCPULoad;
+ agedCPULoad = currentCPULoad;
} else {
- /* for CPU, we don't do the 'fast increase' since CPU is much
- more jitterish to begin with */
- agedCPULoad = (agedCPULoad * 31 + currentCPULoad) / 32;
+ /* for CPU, we don't do the 'fast increase' since CPU is much
+ more jitterish to begin with */
+ agedCPULoad = (agedCPULoad * 31 + currentCPULoad) / 32;
}
}
if (currentIOLoad == -1) {
agedIOLoad = -1;
} else {
if (agedIOLoad == -1) {
- agedIOLoad = currentIOLoad;
+ agedIOLoad = currentIOLoad;
} else {
- /* for IO, we don't do the 'fast increase' since IO is much
- more jitterish to begin with */
- agedIOLoad = (agedIOLoad * 31 + currentIOLoad) / 32;
+ /* for IO, we don't do the 'fast increase' since IO is much
+ more jitterish to begin with */
+ agedIOLoad = (agedIOLoad * 31 + currentIOLoad) / 32;
}
}
}
@@ -558,7 +558,7 @@
* (100 is equivalent to full load)
*/
int os_cpu_get_load(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
unsigned long long maxCPULoad;
int ret;
@@ -569,12 +569,12 @@
if (ret == -1)
return -1;
if (-1 == GC_get_configuration_value_number(cfg,
- "LOAD",
- "MAXCPULOAD",
- 0,
- 10000, /* more than 1 CPU
possible */
- 100,
- &maxCPULoad))
+ "LOAD",
+ "MAXCPULOAD",
+ 0,
+ 10000, /* more than 1 CPU possible */
+ 100,
+ &maxCPULoad))
return SYSERR;
return (100 * ret) / maxCPULoad;
}
@@ -586,7 +586,7 @@
* (100 is equivalent to full load)
*/
int os_disk_get_load(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
unsigned long long maxIOLoad;
int ret;
@@ -597,12 +597,12 @@
if (ret == -1)
return -1;
if (-1 == GC_get_configuration_value_number(cfg,
- "LOAD",
- "MAXIOLOAD",
- 0,
- 10000, /* more than 1 CPU
possible */
- 100,
- &maxIOLoad))
+ "LOAD",
+ "MAXIOLOAD",
+ 0,
+ 10000, /* more than 1 CPU possible */
+ 100,
+ &maxIOLoad))
return SYSERR;
return (100 * ret) / maxIOLoad;
}
@@ -618,9 +618,9 @@
proc_stat = fopen("/proc/stat", "r");
if (NULL == proc_stat)
GE_LOG_STRERROR_FILE(NULL,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "fopen",
- "/proc/stat");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "fopen",
+ "/proc/stat");
#elif OSX
initMachCpuStats();
#elif MINGW
Modified: GNUnet/src/util/os/daemon.c
===================================================================
--- GNUnet/src/util/os/daemon.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/daemon.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -37,8 +37,8 @@
* daemonized sucessfully, -1 on error
*/
static pid_t launchWithExec(struct GE_Context * ectx,
- const char * cfgFile,
- int daemonize) {
+ const char * cfgFile,
+ int daemonize) {
pid_t pid;
#ifndef MINGW
@@ -72,31 +72,31 @@
args[1] = "-c";
args[2] = cfgFile;
if (NO == daemonize) {
- args[3] = "-d";
- args[4] = NULL;
+ args[3] = "-d";
+ args[4] = NULL;
} else
- args[3] = NULL;
+ args[3] = NULL;
} else {
if (NO == daemonize) {
- args[1] = "-d";
- args[2] = NULL;
+ args[1] = "-d";
+ args[2] = NULL;
} else
- args[1] = NULL;
+ args[1] = NULL;
}
errno = 0;
#ifndef MINGW
nice(10); /* return value is not well-defined */
if (errno != 0)
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "nice");
+ GE_WARNING | GE_USER | GE_BULK,
+ "nice");
if (path != NULL)
i = execv(path,
- (char**) args);
+ (char**) args);
else
i = execvp("gnunetd",
- (char**) args);
+ (char**) args);
#else
if (path != NULL)
pid = i = spawnv(_P_NOWAIT, path, (const char *const *) args);
@@ -106,9 +106,9 @@
FREENONNULL(path);
if (i == -1)
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "exec",
- path == NULL ? "gnunetd" : path);
+ GE_ERROR | GE_USER | GE_BULK,
+ "exec",
+ path == NULL ? "gnunetd" : path);
#ifndef MINGW
_exit(-1);
#endif
@@ -121,12 +121,12 @@
ret = waitpid(pid, &status, 0);
if (ret == -1) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "waitpid");
+ GE_ERROR | GE_USER | GE_BULK,
+ "waitpid");
return SYSERR;
}
if ( (WIFEXITED(status) &&
- (0 != WEXITSTATUS(status)) ) ) {
+ (0 != WEXITSTATUS(status)) ) ) {
return SYSERR;
}
#ifdef WCOREDUMP
@@ -135,7 +135,7 @@
}
#endif
if (WIFSIGNALED(status) ||
- WTERMSIG(status) ) {
+ WTERMSIG(status) ) {
return SYSERR;
}
return 0;
@@ -153,17 +153,17 @@
* daemonized sucessfully, -1 on error
*/
int os_daemon_start(struct GE_Context * ectx,
- struct GC_Configuration * cfg,
- const char * cfgFile,
- int daemonize) {
+ struct GC_Configuration * cfg,
+ const char * cfgFile,
+ int daemonize) {
#if LINUX || OSX || SOLARIS || SOMEBSD || MINGW
return launchWithExec(ectx,
- cfgFile,
- daemonize);
+ cfgFile,
+ daemonize);
#else
/* any system out there that does not support THIS!? */
if (-1 == system("gnunetd")) /* we may not have nice,
- so let's be minimalistic here. */
+ so let's be minimalistic here. */
return -1;
return 0;
#endif
@@ -208,7 +208,7 @@
* some error
*/
int os_daemon_stop(struct GE_Context * ectx,
- int pid) {
+ int pid) {
pid_t p;
int status;
@@ -216,8 +216,8 @@
p = pid;
if (p != WAITPID(p, &status, 0)) {
GE_LOG_STRERROR(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "waitpid");
+ GE_ERROR | GE_USER | GE_BULK,
+ "waitpid");
return SYSERR;
}
if (WEXITSTATUS(status) == 0)
Modified: GNUnet/src/util/os/daemontest.c
===================================================================
--- GNUnet/src/util/os/daemontest.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/daemontest.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -30,35 +30,35 @@
#include "platform.h"
int main(int argc,
- const char *argv[]) {
+ const char *argv[]) {
int daemon;
struct GE_Context * ectx;
struct GC_Configuration * cfg;
ectx = GE_create_context_stderr(NO,
- GE_WARNING | GE_ERROR | GE_FATAL |
- GE_USER | GE_ADMIN | GE_DEVELOPER |
- GE_IMMEDIATE | GE_BULK);
+ GE_WARNING | GE_ERROR | GE_FATAL |
+ GE_USER | GE_ADMIN | GE_DEVELOPER |
+ GE_IMMEDIATE | GE_BULK);
GE_setDefaultContext(ectx);
cfg = GC_create_C_impl();
GE_ASSERT(ectx, cfg != NULL);
os_init(ectx);
daemon = os_daemon_start(ectx,
- cfg,
- "check.conf",
- NO);
+ cfg,
+ "check.conf",
+ NO);
if (daemon <= 0) {
fprintf(stderr,
- "Failed to start daemon.\n");
+ "Failed to start daemon.\n");
GC_free(cfg);
GE_free_context(ectx);
return 1;
}
if (OK != connection_wait_for_running(ectx,
- cfg,
- 30 * cronSECONDS)) {
+ cfg,
+ 30 * cronSECONDS)) {
fprintf(stderr,
- "Failed to confirm daemon running (after 30s).\n");
+ "Failed to confirm daemon running (after 30s).\n");
/* try killing anyway, just to be sure */
os_daemon_stop(ectx, daemon);
GC_free(cfg);
@@ -67,7 +67,7 @@
}
if (OK != os_daemon_stop(ectx, daemon)) {
fprintf(stderr,
- "Failed to stop daemon.\n");
+ "Failed to stop daemon.\n");
GC_free(cfg);
GE_free_context(ectx);
return 1;
Modified: GNUnet/src/util/os/dso.c
===================================================================
--- GNUnet/src/util/os/dso.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/dso.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -53,8 +53,8 @@
err = lt_dlinit();
if (err > 0) {
fprintf(stderr,
- _("Initialization of plugin mechanism failed: %s!\n"),
- lt_dlerror());
+ _("Initialization of plugin mechanism failed: %s!\n"),
+ lt_dlerror());
return;
}
opath = lt_dlgetsearchpath();
@@ -93,24 +93,24 @@
struct PluginHandle *
os_plugin_load(struct GE_Context * ectx,
- const char * libprefix,
- const char * dsoname) {
+ const char * libprefix,
+ const char * dsoname) {
void * libhandle;
char * libname;
Plugin * plug;
libname = MALLOC(strlen(dsoname) +
- strlen(libprefix) + 1);
+ strlen(libprefix) + 1);
strcpy(libname, libprefix);
strcat(libname, dsoname);
libhandle = lt_dlopenext(libname);
if (libhandle == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- _("`%s' failed for library `%s' with error: %s\n"),
- "lt_dlopenext",
- libname,
- lt_dlerror());
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("`%s' failed for library `%s' with error: %s\n"),
+ "lt_dlopenext",
+ libname,
+ lt_dlerror());
FREE(libname);
return NULL;
}
@@ -132,13 +132,13 @@
void *
os_plugin_resolve_function(struct PluginHandle * plug,
- const char * methodprefix,
- int logError) {
+ const char * methodprefix,
+ int logError) {
char * initName;
void * mptr;
initName = MALLOC(strlen(plug->dsoname) +
- strlen(methodprefix) + 2);
+ strlen(methodprefix) + 2);
strcpy(initName, "_");
strcat(initName, methodprefix);
strcat(initName, plug->dsoname);
@@ -148,13 +148,13 @@
if ( (mptr == NULL) &&
(logError) )
GE_LOG(plug->ectx,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
- _("`%s' failed to resolve method '%s' with error: %s\n"),
- "lt_dlsym",
- &initName[1],
- lt_dlerror());
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
+ _("`%s' failed to resolve method '%s' with error: %s\n"),
+ "lt_dlsym",
+ &initName[1],
+ lt_dlerror());
FREE(initName);
return mptr;
}
-/* end of dso.c */
+/* end of dso.c */
Modified: GNUnet/src/util/os/installpath.c
===================================================================
--- GNUnet/src/util/os/installpath.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/installpath.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -53,22 +53,22 @@
size_t size;
SNPRINTF(fn,
- 64,
- "/proc/%u/exe",
- getpid());
+ 64,
+ "/proc/%u/exe",
+ getpid());
lnk = MALLOC(1024);
size = readlink(fn, lnk, 1023);
if ( (size == 0) || (size >= 1024) ) {
GE_LOG_STRERROR_FILE(NULL,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "readlink",
- fn);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "readlink",
+ fn);
FREE(lnk);
return NULL;
}
lnk[size] = '\0';
while ( (lnk[size] != '/') &&
- (size > 0) )
+ (size > 0) )
size--;
if ( (size < 4) ||
(lnk[size-4] != '/') ) {
@@ -93,8 +93,8 @@
GetModuleFileName(NULL, path, 4096);
idx = path + strlen(path);
while ( (idx > path) &&
- (*idx != '\\') &&
- (*idx != '/') )
+ (*idx != '\\') &&
+ (*idx != '/') )
idx--;
*idx = '\0';
return path;
@@ -235,9 +235,9 @@
}
tmp = MALLOC(strlen(execpath)+strlen(dirname)+1);
sprintf(tmp,
- "%s%s",
- execpath,
- dirname);
+ "%s%s",
+ execpath,
+ dirname);
FREE(execpath);
return tmp;
}
Modified: GNUnet/src/util/os/osconfig.c
===================================================================
--- GNUnet/src/util/os/osconfig.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/osconfig.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -292,11 +292,11 @@
/* Unix */
if ((ACCESS("/usr/sbin/update-rc.d",
- X_OK) != 0)) {
+ X_OK) != 0)) {
GE_LOG_STRERROR_FILE(ectx,
GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
"access",
- "/usr/sbin/update-rc.d");
+ "/usr/sbin/update-rc.d");
return SYSERR;
}
@@ -307,7 +307,7 @@
GE_LOG_STRERROR_FILE(ectx,
GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
"access",
- application);
+ application);
}
if (STAT("/etc/init.d/gnunetd", &buf) == -1) {
/* create init file */
@@ -316,7 +316,7 @@
GE_LOG_STRERROR_FILE(ectx,
GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
"fopen",
- "/etc/init.d/gnunetd");
+ "/etc/init.d/gnunetd");
return 2;
}
@@ -329,38 +329,38 @@
"PIDFILE=/var/run/gnunetd/gnunetd.pid\n"
"\n"
"case \"$1\" in\n"
- " start)\n"
- " echo -n \"Starting GNUnet: \"\n"
- " %s\n && echo ok || echo failed\n"
- " ;;\n"
- " stop)\n"
- " echo -n \"Stopping GNUnet: \"\n"
- " kill `cat $PIDFILE`\n && echo ok || echo
failed\n"
- " ;;\n"
- " reload)\n"
- " echo -n \"Reloading GNUnet: \"\n"
- " kill -HUP `cat $PIDFILE`\n && echo ok || echo
failed\n"
- " ;;\n"
- " restart|force-reload)\n"
- " echo \"Restarting GNUnet: gnunetd...\"\n"
- " $0 stop\n"
- " sleep 1\n"
- " $0 start\n"
- " ;;\n"
- " *)\n"
- " echo \"Usage: /etc/init.d/gnunetd
{start|stop|reload|restart|force-reload}\" >&2\n"
- " exit 1\n"
- " ;;\n"
+ " start)\n"
+ " echo -n \"Starting GNUnet: \"\n"
+ " %s\n && echo ok || echo failed\n"
+ " ;;\n"
+ " stop)\n"
+ " echo -n \"Stopping GNUnet: \"\n"
+ " kill `cat $PIDFILE`\n && echo ok || echo failed\n"
+ " ;;\n"
+ " reload)\n"
+ " echo -n \"Reloading GNUnet: \"\n"
+ " kill -HUP `cat $PIDFILE`\n && echo ok || echo failed\n"
+ " ;;\n"
+ " restart|force-reload)\n"
+ " echo \"Restarting GNUnet: gnunetd...\"\n"
+ " $0 stop\n"
+ " sleep 1\n"
+ " $0 start\n"
+ " ;;\n"
+ " *)\n"
+ " echo \"Usage: /etc/init.d/gnunetd
{start|stop|reload|restart|force-reload}\" >&2\n"
+ " exit 1\n"
+ " ;;\n"
"\n" "esac\n" "exit 0\n",
- "gnunet-setup",
- application);
+ "gnunet-setup",
+ application);
fclose(f);
if (0 != CHMOD("/etc/init.d/gnunetd",
- S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
GE_LOG_STRERROR_FILE(ectx,
GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
"chmod",
- "/etc/init.d/gnunetd");
+ "/etc/init.d/gnunetd");
return SYSERR;
}
}
@@ -368,29 +368,29 @@
errno = 0;
ret = system("/usr/sbin/update-rc.d gnunetd defaults");
if (ret != 0) {
- if (errno != 0) {
- GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "system",
- "/usr/sbin/update-rc.d");
- } else {
- GE_LOG(ectx,
- GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- _("Command `%s' failed with error code %u\n"),
- "/usr/sbin/update-rc.d gnunetd defaults",
- WEXITSTATUS(ret));
- }
- return SYSERR;
+ if (errno != 0) {
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "system",
+ "/usr/sbin/update-rc.d");
+ } else {
+ GE_LOG(ectx,
+ GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("Command `%s' failed with error code %u\n"),
+ "/usr/sbin/update-rc.d gnunetd defaults",
+ WEXITSTATUS(ret));
+ }
+ return SYSERR;
}
}
return YES;
} else { /* REMOVE autostart */
if ( (UNLINK("/etc/init.d/gnunetd") == -1) &&
- (errno != ENOENT)) {
+ (errno != ENOENT)) {
GE_LOG_STRERROR_FILE(ectx,
GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
"unlink",
- "/etc/init.d/gnunetd");
+ "/etc/init.d/gnunetd");
return SYSERR;
}
errno = 0;
@@ -398,7 +398,7 @@
GE_LOG_STRERROR_FILE(ectx,
GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
"system",
- "/usr/sbin/update-rc.d");
+ "/usr/sbin/update-rc.d");
return SYSERR;
}
return YES;
Modified: GNUnet/src/util/os/priority.c
===================================================================
--- GNUnet/src/util/os/priority.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/priority.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -32,11 +32,11 @@
* Set our process priority
*/
int os_set_process_priority(struct GE_Context * ectx,
- const char * str) {
+ const char * str) {
int prio = 0;
GE_ASSERT(ectx,
- str != NULL);
+ str != NULL);
/* We support four levels (NORMAL, ABOVE NORMAL, BELOW NORMAL, HIGH and IDLE)
* and the usual numeric nice() increments */
if (strcmp(str, "NORMAL") == 0)
@@ -71,12 +71,12 @@
#endif
else {
if (1 != sscanf(str,
- "%d",
- &prio)) {
+ "%d",
+ &prio)) {
GE_LOG(ectx,
- GE_USER | GE_BULK | GE_ERROR,
- _("Invalid process priority `%s'\n"),
- str);
+ GE_USER | GE_BULK | GE_ERROR,
+ _("Invalid process priority `%s'\n"),
+ str);
return SYSERR;
}
@@ -103,8 +103,8 @@
nice(prio);
if (errno != 0) {
GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "nice");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "nice");
return SYSERR;
}
#endif
Modified: GNUnet/src/util/os/semaphore.c
===================================================================
--- GNUnet/src/util/os/semaphore.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/semaphore.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -113,43 +113,43 @@
#if SOMEBSD
static void FLOCK(int fd,
- int operation) {
+ int operation) {
int ret;
ret = -1;
while (ret == -1) {
ret = flock(fd,
- operation);
+ operation);
if (ret == -1) {
if (errno != EINTR) {
- GE_LOG_STRERROR(NULL,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "flock");
- return;
+ GE_LOG_STRERROR(NULL,
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "flock");
+ return;
}
}
}
fsync(fd);
}
static int LSEEK(int fd,
- off_t pos,
- int mode) {
+ off_t pos,
+ int mode) {
int ret;
ret = lseek(fd,
- pos,
- mode);
+ pos,
+ mode);
if (ret == -1)
GE_LOG_STRERROR(NULL,
- GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
- "lseek");
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "lseek");
return ret;
}
#endif
struct IPC_SEMAPHORE *
IPC_SEMAPHORE_CREATE(struct GE_Context * ectx,
- const char * basename,
- const unsigned int initialValue) {
+ const char * basename,
+ const unsigned int initialValue) {
/* Could older FreeBSD use this too since this code can shorten the IPC name
*/
#if SOLARIS || OSX || FREEBSD5
char * noslashBasename;
@@ -162,14 +162,14 @@
for (i=strlen(noslashBasename);i>0;i--)
if (noslashBasename[i] == '/')
noslashBasename[i] = '.'; /* first character MUST be /, but Solaris
- forbids it afterwards */
+ forbids it afterwards */
noslashBasename[0] = '/';
ret->internal = sem_open(noslashBasename,
- O_CREAT,
- S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, /* 660 */
- initialValue);
+ O_CREAT,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, /* 660 */
+ initialValue);
while ( (ret->internal == (void *) SEM_FAILED)
- && (errno == ENAMETOOLONG) ) {
+ && (errno == ENAMETOOLONG) ) {
char * halfBasename;
if (strlen(noslashBasename) < 4)
@@ -178,15 +178,15 @@
halfBasename = noslashBasename+strlen(noslashBasename)/2; /* cut in half */
halfBasename[0] = '/';
ret->internal = sem_open(halfBasename,
- O_CREAT,
- S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, /* 660 */
- initialValue);
+ O_CREAT,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, /* 660 */
+ initialValue);
}
if (ret->internal == (void *) SEM_FAILED)
GE_DIE_STRERROR_FILE(ectx,
- GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
- "sem_open",
- noslashBasename);
+ GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
+ "sem_open",
+ noslashBasename);
FREE(noslashBasename);
return ret;
#elif WINDOWS
@@ -215,12 +215,12 @@
}
if (! ret->internal) {
GE_LOG(ectx,
- GE_FATAL | GE_USER | GE_DEVELOPER | GE_BULK,
- _("Can't create semaphore: %i"),
- dwErr);
+ GE_FATAL | GE_USER | GE_DEVELOPER | GE_BULK,
+ _("Can't create semaphore: %i"),
+ dwErr);
GE_DIE_STRERROR_FILE(ectx,
- GE_FATAL | GE_USER | GE_DEVELOPER | GE_BULK,
- "OpenSemaphore", noslashBasename);
+ GE_FATAL | GE_USER | GE_DEVELOPER | GE_BULK,
+ "OpenSemaphore", noslashBasename);
}
FREE(noslashBasename);
return ret;
@@ -242,9 +242,9 @@
fp = FOPEN(ebasename, "a+");
if (NULL == fp) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "fopen",
- ebasename);
+ GE_ERROR | GE_USER | GE_BULK,
+ "fopen",
+ ebasename);
FREE(ret);
FREE(ebasename);
return NULL;
@@ -255,55 +255,55 @@
again:
ret->internal = semget(key,
- 3,
- IPC_CREAT|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
+ 3,
+ IPC_CREAT|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
if (ret->internal == -1)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "semget");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "semget");
if (semop(ret->internal, &op_lock[0], 2) < 0) {
if (errno == EINVAL)
goto again;
else
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "semop");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "semop");
}
/* get process count */
if ( (pcount = semctl(ret->internal,
- 1,
- GETVAL,
- 0)) < 0)
+ 1,
+ GETVAL,
+ 0)) < 0)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "semctl");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "semctl");
if (pcount==0) {
semctl_arg.val = initialValue;
if (semctl(ret->internal,
- 0,
- SETVAL,
- semctl_arg) < 0)
+ 0,
+ SETVAL,
+ semctl_arg) < 0)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "semtcl");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "semtcl");
semctl_arg.val = PROCCOUNT;
if (semctl(ret->internal,
- 1,
- SETVAL,
- semctl_arg) < 0)
+ 1,
+ SETVAL,
+ semctl_arg) < 0)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "semtcl");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "semtcl");
}
if (semop(ret->internal,
- &op_endcreate[0],
- 2) < 0)
+ &op_endcreate[0],
+ 2) < 0)
GE_DIE_STRERROR(ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "semop");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "semop");
ret->filename = ebasename;
return ret;
#elif SOMEBSD
@@ -319,28 +319,28 @@
fd = -1;
while (fd == -1) {
fd = disk_file_open(ectx,
- basename,
- O_CREAT|O_RDWR|O_EXCL,
- S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP /* 660 */);
+ basename,
+ O_CREAT|O_RDWR|O_EXCL,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP /* 660 */);
if ( (fd == -1) &&
- (errno == EEXIST) ) {
+ (errno == EEXIST) ) {
/* try without creation */
fd = disk_file_open(ectx,
- basename,
- O_RDWR,
- S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP /* 660 */);
+ basename,
+ O_RDWR,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP /* 660 */);
/* possibly the file was deleted in the meantime,
- then try again with O_CREAT! */
+ then try again with O_CREAT! */
if ( (fd == -1) &&
- (errno != ENOENT) )
- break;
+ (errno != ENOENT) )
+ break;
}
}
if (fd == -1) {
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "open",
- ret->filename);
+ GE_ERROR | GE_USER | GE_BULK,
+ "open",
+ ret->filename);
MUTEX_DESTROY(&ret->internalLock);
FREE(ret->filename);
FREE(ret);
@@ -348,37 +348,37 @@
}
FLOCK(fd, LOCK_EX);
if (sizeof(int) != READ(fd,
- &cnt,
- sizeof(int))) {
+ &cnt,
+ sizeof(int))) {
cnt = htonl(initialValue);
LSEEK(fd,
- 0,
- SEEK_SET);
+ 0,
+ SEEK_SET);
if (sizeof(int) != WRITE(fd,
- &cnt,
- sizeof(int)))
+ &cnt,
+ sizeof(int)))
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- "write",
- basename);
+ GE_ERROR | GE_USER | GE_BULK,
+ "write",
+ basename);
}
LSEEK(fd,
- sizeof(int),
- SEEK_SET);
+ sizeof(int),
+ SEEK_SET);
if (sizeof(int) != READ(fd,
- &cnt,
- sizeof(int)))
+ &cnt,
+ sizeof(int)))
cnt = htonl(1);
else
cnt = htonl(ntohl(cnt)+1);
LSEEK(fd, sizeof(int), SEEK_SET);
if (sizeof(int) != WRITE(fd,
- &cnt,
- sizeof(int)))
+ &cnt,
+ sizeof(int)))
GE_LOG_STRERROR_FILE(ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "write",
- basename);
+ GE_WARNING | GE_USER | GE_BULK,
+ "write",
+ basename);
FLOCK(fd, LOCK_UN);
ret->fd = fd;
ret->initialValue = initialValue;
@@ -399,21 +399,21 @@
#if SOLARIS || OSX || FREEBSD5
if (0 != sem_post(sem->internal))
GE_LOG_STRERROR(sem->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "sem_post");
+ GE_WARNING | GE_USER | GE_BULK,
+ "sem_post");
#elif WINDOWS
if (!ReleaseSemaphore(sem->internal, 1, NULL))
GE_LOG(sem->ectx, GE_WARNING | GE_USER | GE_BULK,
- "ReleaseSemaphore signaled error: %i\n",
- GetLastError());
+ "ReleaseSemaphore signaled error: %i\n",
+ GetLastError());
#elif LINUX
{
struct sembuf sops = {0,1,SEM_UNDO};
if (0 != semop(sem->internal,&sops,1))
GE_LOG_STRERROR(sem->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "semop");
+ GE_WARNING | GE_USER | GE_BULK,
+ "semop");
}
#elif SOMEBSD
{
@@ -421,35 +421,35 @@
MUTEX_LOCK(&sem->internalLock);
FLOCK(sem->fd,
- LOCK_EX);
+ LOCK_EX);
LSEEK(sem->fd,
- 0,
- SEEK_SET);
+ 0,
+ SEEK_SET);
if (sizeof(int) != READ(sem->fd,
- &cnt,
- sizeof(int))) {
+ &cnt,
+ sizeof(int))) {
GE_LOG_STRERROR_FILE(sem->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "read",
- sem->filename);
+ GE_WARNING | GE_USER | GE_BULK,
+ "read",
+ sem->filename);
FLOCK(sem->fd,
- LOCK_UN);
+ LOCK_UN);
MUTEX_UNLOCK(&sem->internalLock);
return;
}
cnt = htonl(ntohl(cnt)+1);
LSEEK(sem->fd,
- 0,
- SEEK_SET);
+ 0,
+ SEEK_SET);
if (sizeof(int) != WRITE(sem->fd,
- &cnt,
- sizeof(int)))
+ &cnt,
+ sizeof(int)))
GE_LOG_STRERROR_FILE(sem->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "write",
- sem->filename);
+ GE_WARNING | GE_USER | GE_BULK,
+ "write",
+ sem->filename);
FLOCK(sem->fd,
- LOCK_UN);
+ LOCK_UN);
MUTEX_UNLOCK(&sem->internalLock);
}
#endif
@@ -457,39 +457,39 @@
/* FIXME: add support for mayBlock! */
int IPC_SEMAPHORE_DOWN(struct IPC_SEMAPHORE * sem,
- int mayBlock) {
+ int mayBlock) {
if (sem == NULL) /* error on creation, optimistic execution; good luck */
return OK;
#if OSX || SOLARIS || FREEBSD5
while (0 != sem_wait(sem->internal)) {
if ( (errno == EINTR) ||
- (errno == EAGAIN) )
+ (errno == EAGAIN) )
continue;
GE_DIE_STRERROR(sem->ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "sem_wait");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "sem_wait");
}
return OK;
#elif WINDOWS
if (WaitForSingleObject(sem->internal,
- INFINITE) == WAIT_FAILED)
+ INFINITE) == WAIT_FAILED)
GE_LOG_STRERROR(sem->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "WaitForSingleObject");
+ GE_WARNING | GE_USER | GE_BULK,
+ "WaitForSingleObject");
return OK;
#elif LINUX
{
struct sembuf sops = {0,-1,SEM_UNDO};
while (0 != semop(sem->internal,
- &sops,
- 1)) {
+ &sops,
+ 1)) {
if ( (errno == EINTR) ||
- (errno == EAGAIN) )
- continue;
+ (errno == EAGAIN) )
+ continue;
GE_DIE_STRERROR(sem->ectx,
- GE_FATAL | GE_USER | GE_IMMEDIATE,
- "semop");
+ GE_FATAL | GE_USER | GE_IMMEDIATE,
+ "semop");
}
return OK;
}
@@ -499,45 +499,45 @@
MUTEX_LOCK(&sem->internalLock);
FLOCK(sem->fd,
- LOCK_EX);
+ LOCK_EX);
cnt = ntohl(0);
while (htonl(cnt) == 0) {
LSEEK(sem->fd,
- 0,
- SEEK_SET);
+ 0,
+ SEEK_SET);
if (sizeof(int) != READ(sem->fd,
- &cnt,
- sizeof(int))) {
- GE_LOG_STRERROR_FILE(sem->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "read",
- sem->filename);
- FLOCK(sem->fd,
- LOCK_UN);
- MUTEX_UNLOCK(&sem->internalLock);
- return SYSERR;
+ &cnt,
+ sizeof(int))) {
+ GE_LOG_STRERROR_FILE(sem->ectx,
+ GE_WARNING | GE_USER | GE_BULK,
+ "read",
+ sem->filename);
+ FLOCK(sem->fd,
+ LOCK_UN);
+ MUTEX_UNLOCK(&sem->internalLock);
+ return SYSERR;
}
if (htonl(cnt) == 0) {
- /* busy wait! */
- FLOCK(sem->fd,
- LOCK_UN);
- PTHREAD_SLEEP(50 * cronMILLIS);
- FLOCK(sem->fd,
- LOCK_EX);
+ /* busy wait! */
+ FLOCK(sem->fd,
+ LOCK_UN);
+ PTHREAD_SLEEP(50 * cronMILLIS);
+ FLOCK(sem->fd,
+ LOCK_EX);
}
}
cnt = htonl(ntohl(cnt)-1);
LSEEK(sem->fd, 0, SEEK_SET);
if (sizeof(int) != WRITE(sem->fd,
- &cnt,
- sizeof(int)))
+ &cnt,
+ sizeof(int)))
GE_LOG_STRERROR_FILE(sem->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "write",
- sem->filename);
+ GE_WARNING | GE_USER | GE_BULK,
+ "write",
+ sem->filename);
FLOCK(sem->fd,
- LOCK_UN);
+ LOCK_UN);
MUTEX_UNLOCK(&sem->internalLock);
}
return OK;
@@ -552,44 +552,44 @@
#if SOLARIS || OSX || FREEBSD5
if (0 != sem_close(sem->internal))
GE_LOG_STRERROR(sem->ectx,
- GE_USER | GE_WARNING | GE_BULK,
- "sem_close");
+ GE_USER | GE_WARNING | GE_BULK,
+ "sem_close");
#elif WINDOWS
if (!CloseHandle(sem->internal))
GE_LOG(sem->ectx,
- GE_USER | GE_WARNING | GE_BULK,
- "CloseHandle signaled error: %i\n",
- GetLastError());
+ GE_USER | GE_WARNING | GE_BULK,
+ "CloseHandle signaled error: %i\n",
+ GetLastError());
#elif LINUX
{
int pcount;
if (semop(sem->internal, &op_close[0], 3) < 0)
GE_LOG_STRERROR(sem->ectx,
- GE_USER | GE_WARNING | GE_BULK,
- "semop");
+ GE_USER | GE_WARNING | GE_BULK,
+ "semop");
if ( (pcount = semctl(sem->internal, 1, GETVAL, 0)) < 0)
GE_LOG_STRERROR(sem->ectx,
- GE_USER | GE_WARNING | GE_BULK,
- "semctl");
+ GE_USER | GE_WARNING | GE_BULK,
+ "semctl");
if (pcount > PROCCOUNT) {
GE_BREAK(sem->ectx, 0);
} else if (pcount == PROCCOUNT) {
if (0 != semctl(sem->internal,
- 0,
- IPC_RMID,
- 0))
- GE_LOG_STRERROR(sem->ectx,
- GE_USER | GE_WARNING | GE_BULK,
- "semctl");
+ 0,
+ IPC_RMID,
+ 0))
+ GE_LOG_STRERROR(sem->ectx,
+ GE_USER | GE_WARNING | GE_BULK,
+ "semctl");
UNLINK(sem->filename);
} else {
if (semop(sem->internal,
- &op_unlock[0],
- 1) < 0)
- GE_LOG_STRERROR(sem->ectx,
- GE_USER | GE_WARNING | GE_BULK,
- "semop");
+ &op_unlock[0],
+ 1) < 0)
+ GE_LOG_STRERROR(sem->ectx,
+ GE_USER | GE_WARNING | GE_BULK,
+ "semop");
}
FREE(sem->filename);
}
@@ -604,19 +604,19 @@
cnt = htonl(ntohl(cnt)-1);
LSEEK(sem->fd, sizeof(int), SEEK_SET);
if (sizeof(int) != WRITE(sem->fd, &cnt, sizeof(int)))
- GE_LOG_STRERROR(sem->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "write");
+ GE_LOG_STRERROR(sem->ectx,
+ GE_WARNING | GE_USER | GE_BULK,
+ "write");
if (ntohl(cnt) == 0)
- UNLINK(sem->filename);
+ UNLINK(sem->filename);
} else
GE_LOG_STRERROR(sem->ectx,
- GE_WARNING | GE_USER | GE_BULK,
- "read");
+ GE_WARNING | GE_USER | GE_BULK,
+ "read");
FLOCK(sem->fd, LOCK_UN);
disk_file_close(sem->ectx,
- sem->filename,
- sem->fd);
+ sem->filename,
+ sem->fd);
FREE(sem->filename);
}
#else
Modified: GNUnet/src/util/os/semaphoretest.c
===================================================================
--- GNUnet/src/util/os/semaphoretest.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/semaphoretest.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -49,64 +49,64 @@
sw = me;
ipc = IPC_SEMAPHORE_CREATE(ectx,
- "/tmp/gnunet_ipc_semtest",
- 0);
+ "/tmp/gnunet_ipc_semtest",
+ 0);
for (cnt=0;cnt<3;cnt++) {
if (sw == 0) {
for (i=0;i<6;i++) {
- IPC_SEMAPHORE_DOWN(ipc,
- YES);
- fd = FOPEN("/tmp/gnunet_ipc_xchange",
- "a+");
- if (fd == NULL) {
- printf("Could not open testfile for reading: %s\n",
- STRERROR(errno));
- ret = 1;
- goto END;
- }
- fseek(fd, 4*i, SEEK_SET);
- si = GN_FREAD(&j, 4, 1, fd);
- if (si != 1) {
- printf("Could not read from testfile: %d - %s at %s:%d\n",
- si,
- STRERROR(errno),
- __FILE__,
- __LINE__);
- ret = 1;
- goto END;
- }
- fclose(fd);
- if (j != i+cnt) {
- printf("IPC test failed at cnt=%d i=%d j=%d %s:%u\n",
- cnt, i, j, __FILE__, __LINE__);
- ret = 1;
- goto END;
- } else
- fprintf(stderr, ".");
+ IPC_SEMAPHORE_DOWN(ipc,
+ YES);
+ fd = FOPEN("/tmp/gnunet_ipc_xchange",
+ "a+");
+ if (fd == NULL) {
+ printf("Could not open testfile for reading: %s\n",
+ STRERROR(errno));
+ ret = 1;
+ goto END;
+ }
+ fseek(fd, 4*i, SEEK_SET);
+ si = GN_FREAD(&j, 4, 1, fd);
+ if (si != 1) {
+ printf("Could not read from testfile: %d - %s at %s:%d\n",
+ si,
+ STRERROR(errno),
+ __FILE__,
+ __LINE__);
+ ret = 1;
+ goto END;
+ }
+ fclose(fd);
+ if (j != i+cnt) {
+ printf("IPC test failed at cnt=%d i=%d j=%d %s:%u\n",
+ cnt, i, j, __FILE__, __LINE__);
+ ret = 1;
+ goto END;
+ } else
+ fprintf(stderr, ".");
}
REMOVE("/tmp/gnunet_ipc_xchange");
sw = 1;
} else {
for (i=0;i<6;i++) {
- PTHREAD_SLEEP(50 + i*50);
- fd = FOPEN("/tmp/gnunet_ipc_xchange",
- "a+");
- if (fd == NULL) {
- printf("Could not open testfile for writing: %s\n",
- STRERROR(errno));
- ret = 1;
- goto END;
- }
- fseek(fd, 4*i, SEEK_SET);
- j=cnt+i;
- if (1 != GN_FWRITE(&j, 4, 1, fd)) {
- printf("Could not write to testfile: %s\n",
- STRERROR(errno));
- ret = 1;
- goto END;
- }
- fclose(fd);
- IPC_SEMAPHORE_UP(ipc);
+ PTHREAD_SLEEP(50 + i*50);
+ fd = FOPEN("/tmp/gnunet_ipc_xchange",
+ "a+");
+ if (fd == NULL) {
+ printf("Could not open testfile for writing: %s\n",
+ STRERROR(errno));
+ ret = 1;
+ goto END;
+ }
+ fseek(fd, 4*i, SEEK_SET);
+ j=cnt+i;
+ if (1 != GN_FWRITE(&j, 4, 1, fd)) {
+ printf("Could not write to testfile: %s\n",
+ STRERROR(errno));
+ ret = 1;
+ goto END;
+ }
+ fclose(fd);
+ IPC_SEMAPHORE_UP(ipc);
}
fprintf(stderr, ".");
sleep(1); /* give reader ample time to finish */
@@ -120,13 +120,13 @@
exit(ret);
} else {
GE_LOG(ectx,
- GE_DEBUG | GE_REQUEST | GE_USER,
- "waiting for other process to exit.\n");
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "waiting for other process to exit.\n");
if (-1 == waitpid(me, &j, 0))
GE_LOG(ectx,
- GE_ERROR | GE_BULK | GE_USER,
- "waitpid failed: %s\n",
- STRERROR(errno));
+ GE_ERROR | GE_BULK | GE_USER,
+ "waitpid failed: %s\n",
+ STRERROR(errno));
if ((! WIFEXITED(j)) || WEXITSTATUS(j) == 1)
ret = 1; /* error in child */
}
@@ -137,9 +137,9 @@
int ret = 0;
ectx = GE_create_context_stderr(NO,
- GE_WARNING | GE_ERROR | GE_FATAL |
- GE_USER | GE_ADMIN | GE_DEVELOPER |
- GE_IMMEDIATE | GE_BULK);
+ GE_WARNING | GE_ERROR | GE_FATAL |
+ GE_USER | GE_ADMIN | GE_DEVELOPER |
+ GE_IMMEDIATE | GE_BULK);
GE_setDefaultContext(ectx);
os_init(ectx);
ret += testIPCSemaphore();
Modified: GNUnet/src/util/os/statuscalls.c
===================================================================
--- GNUnet/src/util/os/statuscalls.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/statuscalls.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -140,8 +140,8 @@
} LoadMonitor;
void os_network_monitor_notify_transmission(struct LoadMonitor * monitor,
- NetworkDirection dir,
- unsigned long long delta) {
+ NetworkDirection dir,
+ unsigned long long delta) {
MUTEX_LOCK(monitor->statusMutex);
if (dir == Download)
monitor->globalTrafficBetweenProc.last_in += delta;
@@ -167,32 +167,32 @@
/* Parse the line matching the interface ('eth0') */
while (! feof(monitor->proc_net_dev) ) {
if (NULL == fgets(line,
- MAX_PROC_LINE,
- monitor->proc_net_dev))
- break;
+ MAX_PROC_LINE,
+ monitor->proc_net_dev))
+ break;
for (i=0;i<monitor->ifcsSize;i++) {
- ifc = &monitor->ifcs[i];
- if (NULL != strstr(line, ifc->name) ) {
- data = strchr(line, ':');
- if (data == NULL)
- continue;
- data++;
- if (2 != SSCANF(data,
- "%llu %*s %*s %*s %*s %*s %*s %*s %llu",
- &rxnew,
- &txnew)) {
- GE_LOG(monitor->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- _("Failed to parse interface data from `%s'.\n"),
- PROC_NET_DEV);
- continue;
- }
- ifc->last_in = rxnew;
- ifc->last_out = txnew;
- monitor->globalTrafficBetweenProc.last_in = 0;
- monitor->globalTrafficBetweenProc.last_out = 0;
- break;
- }
+ ifc = &monitor->ifcs[i];
+ if (NULL != strstr(line, ifc->name) ) {
+ data = strchr(line, ':');
+ if (data == NULL)
+ continue;
+ data++;
+ if (2 != SSCANF(data,
+ "%llu %*s %*s %*s %*s %*s %*s %*s %llu",
+ &rxnew,
+ &txnew)) {
+ GE_LOG(monitor->ectx,
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("Failed to parse interface data from `%s'.\n"),
+ PROC_NET_DEV);
+ continue;
+ }
+ ifc->last_in = rxnew;
+ ifc->last_out = txnew;
+ monitor->globalTrafficBetweenProc.last_in = 0;
+ monitor->globalTrafficBetweenProc.last_out = 0;
+ break;
+ }
}
}
}
@@ -272,20 +272,20 @@
for (dwIfIdx=0; dwIfIdx < pTable->dwNumEntries; dwIfIdx++) {
l = _atoi64(ifc->name);
memset(bPhysAddr,
- 0,
- MAXLEN_PHYSADDR);
+ 0,
+ MAXLEN_PHYSADDR);
memcpy(bPhysAddr,
- pTable->table[dwIfIdx].bPhysAddr,
- pTable->table[dwIfIdx].dwPhysAddrLen);
+ pTable->table[dwIfIdx].bPhysAddr,
+ pTable->table[dwIfIdx].dwPhysAddrLen);
if (0 == memcmp(bPhysAddr,
- &l,
- sizeof(unsigned long long))) {
- ifc->last_in
- = pTable->table[dwIfIdx].dwInOctets;
- ifc->last_out
- = pTable->table[dwIfIdx].dwOutOctets;
- monitor->globalTrafficBetweenProc.last_in = 0;
- monitor->globalTrafficBetweenProc.last_out = 0;
+ &l,
+ sizeof(unsigned long long))) {
+ ifc->last_in
+ = pTable->table[dwIfIdx].dwInOctets;
+ ifc->last_out
+ = pTable->table[dwIfIdx].dwOutOctets;
+ monitor->globalTrafficBetweenProc.last_in = 0;
+ monitor->globalTrafficBetweenProc.last_out = 0;
break;
}
}
@@ -295,34 +295,34 @@
if ( ( command = popen("netstat -e", "rt") ) == NULL ) {
GE_LOG_STRERROR_FILE(monitor->ectx,
GE_ERROR | GE_ADMIN | GE_BULK,
- "popen",
- "netstat -e");
+ "popen",
+ "netstat -e");
return;
}
ifc = &monitor->ifcs[0];
while (!feof(command)) {
if (NULL == fgets(line,
- MAX_PROC_LINE,
- command))
- break;
+ MAX_PROC_LINE,
+ command))
+ break;
/* PORT-ME: any way to do this per-ifc? */
if (iLine == 1) {
if (2 == sscanf("%*s%i%i",
- &rxnew,
- &txnew)) {
- ifc->last_in
- = rxnew;
- ifc->last_out
- = txnew;
- monitor->globalTrafficBetweenProc.last_in = 0;
- monitor->globalTrafficBetweenProc.last_out = 0;
- break;
- } else {
- GE_LOG(monitor->ectx,
- GE_ERROR | GE_ADMIN | GE_BULK,
- _("Failed to parse interface data from `%s'.\n"),
- PROC_NET_DEV);
- }
+ &rxnew,
+ &txnew)) {
+ ifc->last_in
+ = rxnew;
+ ifc->last_out
+ = txnew;
+ monitor->globalTrafficBetweenProc.last_in = 0;
+ monitor->globalTrafficBetweenProc.last_out = 0;
+ break;
+ } else {
+ GE_LOG(monitor->ectx,
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("Failed to parse interface data from `%s'.\n"),
+ PROC_NET_DEV);
+ }
}
iLine++;
}
@@ -337,10 +337,10 @@
* Re-read the configuration for statuscalls.
*/
static int resetStatusCalls(void * cls,
- struct GC_Configuration * cfg,
- struct GE_Context * ectx,
- const char * sect,
- const char * op) {
+ struct GC_Configuration * cfg,
+ struct GE_Context * ectx,
+ const char * sect,
+ const char * op) {
struct LoadMonitor * monitor = cls;
char * interfaces;
int i;
@@ -348,32 +348,32 @@
int basic;
basic = GC_get_configuration_value_yesno(cfg,
- "LOAD",
- "BASICLIMITING",
- YES);
+ "LOAD",
+ "BASICLIMITING",
+ YES);
if (basic == SYSERR)
return SYSERR;
if (-1 == GC_get_configuration_value_string(cfg,
- "LOAD",
- "INTERFACES",
- "eth0",
- &interfaces))
+ "LOAD",
+ "INTERFACES",
+ "eth0",
+ &interfaces))
return SYSERR;
if (interfaces == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("No network interfaces defined in configuration section `%s' under
`%s'!\n"),
- "LOAD",
- "INTERFACES");
+ GE_ERROR | GE_USER | GE_BULK,
+ _("No network interfaces defined in configuration section `%s' under
`%s'!\n"),
+ "LOAD",
+ "INTERFACES");
return SYSERR;
}
if (strlen(interfaces) == 0) {
FREE(interfaces);
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_BULK,
- _("No network interfaces defined in configuration section `%s' under
`%s'!\n"),
- "LOAD",
- "INTERFACES");
+ GE_ERROR | GE_USER | GE_BULK,
+ _("No network interfaces defined in configuration section `%s' under
`%s'!\n"),
+ "LOAD",
+ "INTERFACES");
return SYSERR;
}
MUTEX_LOCK(monitor->statusMutex);
@@ -408,19 +408,19 @@
FREE(interfaces);
monitor->useBasicMethod = basic;
GC_get_configuration_value_number(cfg,
- "LOAD",
- "MAXNETDOWNBPSTOTAL",
- 0,
- (unsigned long long)-1,
- 50000,
- &monitor->download_info.max);
+ "LOAD",
+ "MAXNETDOWNBPSTOTAL",
+ 0,
+ (unsigned long long)-1,
+ 50000,
+ &monitor->download_info.max);
GC_get_configuration_value_number(cfg,
- "LOAD",
- "MAXNETUPBPSTOTAL",
- 0,
- (unsigned long long)-1,
- 50000,
- &monitor->upload_info.max);
+ "LOAD",
+ "MAXNETUPBPSTOTAL",
+ 0,
+ (unsigned long long)-1,
+ 50000,
+ &monitor->upload_info.max);
monitor->last_ifc_update = get_time();
updateInterfaceTraffic(monitor);
MUTEX_UNLOCK(monitor->statusMutex);
@@ -434,7 +434,7 @@
* @return the maximum bandwidth in bytes per second, -1 for no limit
*/
unsigned long long os_network_monitor_get_limit(struct LoadMonitor * monitor,
- NetworkDirection dir) {
+ NetworkDirection dir) {
if (monitor == NULL)
return -1;
if (dir == Upload)
@@ -452,7 +452,7 @@
* (100 is equivalent to full load)
*/
int os_network_monitor_get_load(struct LoadMonitor * monitor,
- NetworkDirection dir) {
+ NetworkDirection dir) {
DirectionInfo * di;
cron_t now;
unsigned long long maxExpect;
@@ -530,27 +530,27 @@
struct LoadMonitor *
os_network_monitor_create(struct GE_Context * ectx,
- struct GC_Configuration * cfg) {
+ struct GC_Configuration * cfg) {
struct LoadMonitor * monitor;
monitor = MALLOC(sizeof(struct LoadMonitor));
memset(monitor,
- 0,
- sizeof(struct LoadMonitor));
+ 0,
+ sizeof(struct LoadMonitor));
monitor->ectx = ectx;
monitor->cfg = cfg;
#ifdef LINUX
monitor->proc_net_dev = fopen(PROC_NET_DEV, "r");
if (NULL == monitor->proc_net_dev)
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
- "fopen",
- PROC_NET_DEV);
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "fopen",
+ PROC_NET_DEV);
#endif
monitor->statusMutex = MUTEX_CREATE(NO);
if (-1 == GC_attach_change_listener(cfg,
- &resetStatusCalls,
- monitor)) {
+ &resetStatusCalls,
+ monitor)) {
os_network_monitor_destroy(monitor);
return NULL;
}
@@ -561,8 +561,8 @@
int i;
GC_detach_change_listener(monitor->cfg,
- &resetStatusCalls,
- monitor);
+ &resetStatusCalls,
+ monitor);
#ifdef LINUX
if (monitor->proc_net_dev != NULL)
fclose(monitor->proc_net_dev);
Modified: GNUnet/src/util/os/statuscallstest.c
===================================================================
--- GNUnet/src/util/os/statuscallstest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/os/statuscallstest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -34,9 +34,9 @@
struct GC_Configuration * cfg;
ectx = GE_create_context_stderr(NO,
- GE_WARNING | GE_ERROR | GE_FATAL |
- GE_USER | GE_ADMIN | GE_DEVELOPER |
- GE_IMMEDIATE | GE_BULK);
+ GE_WARNING | GE_ERROR | GE_FATAL |
+ GE_USER | GE_ADMIN | GE_DEVELOPER |
+ GE_IMMEDIATE | GE_BULK);
GE_setDefaultContext(ectx);
cfg = GC_create_C_impl();
GE_ASSERT(ectx, cfg != NULL);
@@ -48,15 +48,15 @@
PTHREAD_SLEEP(1);
start = get_time();
ret = os_cpu_get_load(ectx,
- cfg);
+ cfg);
while (start + 60 * cronSECONDS > get_time())
sqrt(245.2523); /* do some processing to drive load up */
if (ret > os_cpu_get_load(ectx,
- cfg)) {
+ cfg)) {
printf("busy loop decreased CPU load: %d < %d.\n",
- ret,
- os_cpu_get_load(ectx,
- cfg));
+ ret,
+ os_cpu_get_load(ectx,
+ cfg));
ret = 1;
} else {
ret = 0;
Modified: GNUnet/src/util/os/user.c
===================================================================
--- GNUnet/src/util/os/user.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/os/user.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -29,9 +29,9 @@
#include "platform.h"
int os_modify_user(int testCapability,
- int doAdd,
- const char *group_name,
- const char *user_name) {
+ int doAdd,
+ const char *group_name,
+ const char *user_name) {
int haveGroup;
if (testCapability) {
@@ -45,22 +45,22 @@
return SYSERR;
if (doAdd == YES) {
if ( ( (ACCESS("/usr/sbin/adduser", X_OK) == 0) ||
- (ACCESS("/usr/sbin/useradd", X_OK) == 0) ) &&
- ( (ACCESS("/usr/sbin/addgroup", X_OK) == 0) ||
- (ACCESS("/usr/sbin/groupadd", X_OK) == 0) ) )
- return OK;
+ (ACCESS("/usr/sbin/useradd", X_OK) == 0) ) &&
+ ( (ACCESS("/usr/sbin/addgroup", X_OK) == 0) ||
+ (ACCESS("/usr/sbin/groupadd", X_OK) == 0) ) )
+ return OK;
return SYSERR;
} else if (doAdd == NO) {
if ( (ACCESS("/usr/sbin/deluser", X_OK) == 0) ||
- (ACCESS("/usr/sbin/userdel", X_OK) == 0) )
- return OK;
+ (ACCESS("/usr/sbin/userdel", X_OK) == 0) )
+ return OK;
return SYSERR;
} else if (doAdd == SYSERR) {
if ( ( (ACCESS("/usr/sbin/dleuser", X_OK) == 0) ||
- (ACCESS("/usr/sbin/userdel", X_OK) == 0) ) &&
- ( (ACCESS("/usr/sbin/delgroup", X_OK) == 0) ||
- (ACCESS("/usr/sbin/groupdel", X_OK) == 0) ) )
- return OK;
+ (ACCESS("/usr/sbin/userdel", X_OK) == 0) ) &&
+ ( (ACCESS("/usr/sbin/delgroup", X_OK) == 0) ||
+ (ACCESS("/usr/sbin/groupdel", X_OK) == 0) ) )
+ return OK;
return SYSERR;
}
#endif
@@ -73,30 +73,30 @@
#ifdef WINDOWS
if (IsWinNT())
return CreateServiceAccount(user_name,
- "GNUnet service account");
+ "GNUnet service account");
#else
if (ACCESS("/usr/sbin/adduser",
- X_OK) == 0) {
+ X_OK) == 0) {
/* Debian */
/* TODO: FreeBSD?
http://www.freebsd.org/cgi/man.cgi?query=adduser&sektion=8 */
char * cmd;
- haveGroup = group_name && strlen(group_name) > 0;
+ haveGroup = group_name && strlen(group_name) > 0;
cmd = MALLOC(256 + (haveGroup ? strlen(group_name) : 0) +
strlen(user_name));
if (haveGroup) {
sprintf(cmd,
- "/usr/sbin/addgroup --quiet --system %s",
- group_name);
+ "/usr/sbin/addgroup --quiet --system %s",
+ group_name);
system(cmd);
}
sprintf(cmd,
- "/usr/sbin/adduser --quiet --system %s %s "
- "--no-create-home %s",
- haveGroup ? "--ingroup" : "",
- haveGroup ? group_name : "",
- user_name);
+ "/usr/sbin/adduser --quiet --system %s %s "
+ "--no-create-home %s",
+ haveGroup ? "--ingroup" : "",
+ haveGroup ? group_name : "",
+ user_name);
system(cmd);
FREE(cmd);
return OK;
@@ -114,7 +114,7 @@
* @brief Change user ID
*/
int os_change_user(struct GE_Context * ectx,
- const char * user) {
+ const char * user) {
#ifndef MINGW
struct passwd * pws;
@@ -122,10 +122,10 @@
pws = getpwnam(user);
if (pws == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- _("Cannot obtain information about user `%s': %s\n"),
- user,
- errno == 0 ? _("No such user") : STRERROR(errno));
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("Cannot obtain information about user `%s': %s\n"),
+ user,
+ errno == 0 ? _("No such user") : STRERROR(errno));
return SYSERR;
}
if ( (0 != setgid(pws->pw_gid)) ||
@@ -135,12 +135,12 @@
#endif
(0 != setuid(pws->pw_uid)) || (0 != seteuid(pws->pw_uid))) {
if ( (0 != setregid(pws->pw_gid, pws->pw_gid)) ||
- (0 != setreuid(pws->pw_uid, pws->pw_uid)) ) {
+ (0 != setreuid(pws->pw_uid, pws->pw_uid)) ) {
GE_LOG(ectx,
- GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- _("Cannot change user/group to `%s': %s\n"),
- user,
- STRERROR(errno));
+ GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("Cannot change user/group to `%s': %s\n"),
+ user,
+ STRERROR(errno));
return SYSERR;
}
}
@@ -155,27 +155,27 @@
* @brief Change owner of a file
*/
int os_change_owner(struct GE_Context * ectx,
- const char * filename,
- const char * user) {
+ const char * filename,
+ const char * user) {
#ifndef MINGW
struct passwd * pws;
pws = getpwnam(user);
if (pws == NULL) {
GE_LOG(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- _("Cannot obtain information about user `%s': %s\n"),
- user,
- STRERROR(errno));
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ _("Cannot obtain information about user `%s': %s\n"),
+ user,
+ STRERROR(errno));
return SYSERR;
}
if (0 != chown(filename,
- pws->pw_uid,
- pws->pw_gid))
+ pws->pw_uid,
+ pws->pw_gid))
GE_LOG_STRERROR_FILE(ectx,
- GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
- "chown",
- filename);
+ GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+ "chown",
+ filename);
#endif
return OK;
}
Modified: GNUnet/src/util/string/string.c
===================================================================
--- GNUnet/src/util/string/string.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/string/string.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -62,8 +62,8 @@
* out the result like strncpy() does.
*/
size_t strlcpy(char * dest,
- const char * src,
- size_t size) {
+ const char * src,
+ size_t size) {
size_t ret;
GE_ASSERT(NULL, dest != NULL);
@@ -89,8 +89,8 @@
* @param count The size of the destination buffer.
*/
size_t strlcat(char * dest,
- const char * src,
- size_t count) {
+ const char * src,
+ size_t count) {
size_t dsize;
size_t len;
size_t res;
@@ -128,21 +128,21 @@
delta = delta / 60;
unit = _(/* time unit */ "m");
if (delta > 5 * 60) {
- delta = delta / 60;
- unit = _(/* time unit */ "h");
- if (delta > 5 * 24) {
- delta = delta / 24;
- unit = _(/* time unit */ " days");
- }
- }
- }
+ delta = delta / 60;
+ unit = _(/* time unit */ "h");
+ if (delta > 5 * 24) {
+ delta = delta / 24;
+ unit = _(/* time unit */ " days");
}
+ }
+ }
+ }
ret = MALLOC(32);
SNPRINTF(ret,
- 32,
- "%llu%s",
- delta,
- unit);
+ 32,
+ "%llu%s",
+ delta,
+ unit);
return ret;
}
@@ -160,21 +160,21 @@
size = size / 1024;
unit = _(/* size unit */ "MiB");
if (size > 5 * 1024) {
- size = size / 1024;
- unit = _(/* size unit */ "GiB");
- if (size > 5 * 1024) {
- size = size / 1024;
- unit = _(/* size unit */ "TiB");
- }
- }
- }
+ size = size / 1024;
+ unit = _(/* size unit */ "GiB");
+ if (size > 5 * 1024) {
+ size = size / 1024;
+ unit = _(/* size unit */ "TiB");
}
+ }
+ }
+ }
ret = MALLOC(32);
SNPRINTF(ret,
- 32,
- "%llu%s",
- size,
- unit);
+ 32,
+ "%llu%s",
+ size,
+ unit);
return ret;
}
@@ -190,9 +190,9 @@
* string is returned.
*/
char * string_convertToUtf8(struct GE_Context * ectx,
- const char * input,
- size_t len,
- const char * charset) {
+ const char * input,
+ size_t len,
+ const char * charset) {
char * ret;
#if ENABLE_NLS && HAVE_ICONV
size_t tmpSize;
@@ -204,8 +204,8 @@
cd = iconv_open("UTF-8", charset);
if (cd == (iconv_t) -1) {
GE_LOG_STRERROR(ectx,
- GE_USER | GE_ADMIN | GE_WARNING | GE_BULK,
- "iconv_open");
+ GE_USER | GE_ADMIN | GE_WARNING | GE_BULK,
+ "iconv_open");
ret = MALLOC(len+1);
memcpy(ret, input, len);
ret[len] = '\0';
@@ -216,13 +216,13 @@
itmp = tmp;
finSize = tmpSize;
if (iconv(cd,
- (char**) &input,
- &len,
- &itmp,
- &finSize) == (size_t)-1) {
+ (char**) &input,
+ &len,
+ &itmp,
+ &finSize) == (size_t)-1) {
GE_LOG_STRERROR(ectx,
- GE_USER | GE_WARNING | GE_BULK,
- "iconv");
+ GE_USER | GE_WARNING | GE_BULK,
+ "iconv");
iconv_close(cd);
FREE(tmp);
ret = MALLOC(len+1);
@@ -232,14 +232,14 @@
}
ret = MALLOC(tmpSize - finSize + 1);
memcpy(ret,
- tmp,
- tmpSize - finSize);
+ tmp,
+ tmpSize - finSize);
ret[tmpSize - finSize] = '\0';
FREE(tmp);
if (0 != iconv_close(cd))
GE_LOG_STRERROR(ectx,
- GE_ADMIN | GE_WARNING | GE_REQUEST,
- "iconv_close");
+ GE_ADMIN | GE_WARNING | GE_REQUEST,
+ "iconv_close");
return ret;
#else
ret = MALLOC(len+1);
@@ -260,7 +260,7 @@
* NULL is returned on error
*/
char * string_expandFileName(struct GE_Context * ectx,
- const char * fil) {
+ const char * fil) {
char * buffer;
#ifndef MINGW
size_t len;
@@ -283,8 +283,8 @@
fm = getenv("HOME");
if (fm == NULL) {
GE_LOG(ectx,
- GE_USER | GE_ADMIN | GE_WARNING | GE_IMMEDIATE,
- _("Failed to expand `$HOME': environment variable `HOME' not
set"));
+ GE_USER | GE_ADMIN | GE_WARNING | GE_IMMEDIATE,
+ _("Failed to expand `$HOME': environment variable `HOME' not set"));
return NULL;
}
fm = STRDUP(fm);
@@ -293,7 +293,7 @@
/* skip over dir seperator to be consistent */
if (fil_ptr[0] == DIR_SEPARATOR)
- fil_ptr++;
+ fil_ptr++;
} else {
/* relative path */
fil_ptr = fil;
@@ -302,25 +302,25 @@
while (1) {
buffer = MALLOC(len);
if (getcwd(buffer, len) != NULL) {
- fm = buffer;
- break;
+ fm = buffer;
+ break;
}
if ( (errno == ERANGE) &&
- (len < 1024 * 1024 * 4) ) {
- len *= 2;
- FREE(buffer);
- continue;
+ (len < 1024 * 1024 * 4) ) {
+ len *= 2;
+ FREE(buffer);
+ continue;
}
FREE(buffer);
break;
}
if (fm == NULL) {
GE_LOG_STRERROR(ectx,
- GE_USER | GE_WARNING | GE_IMMEDIATE,
- "getcwd");
+ GE_USER | GE_WARNING | GE_IMMEDIATE,
+ "getcwd");
buffer = getenv("PWD"); /* alternative */
if (buffer != NULL)
- fm = STRDUP(buffer);
+ fm = STRDUP(buffer);
}
if (fm == NULL)
fm = STRDUP("./"); /* give up */
@@ -328,7 +328,7 @@
n = strlen(fm) + 1 + strlen(fil_ptr) + 1;
buffer = MALLOC(n);
SNPRINTF(buffer, n,
- "%s/%s", fm, fil_ptr);
+ "%s/%s", fm, fil_ptr);
FREE(fm);
return buffer;
#else
@@ -337,8 +337,8 @@
if ((lRet = plibc_conv_to_win_path(fil, fn)) != ERROR_SUCCESS) {
SetErrnoFromWinError(lRet);
GE_LOG_STRERROR(ectx,
- GE_USER | GE_WARNING | GE_IMMEDIATE,
- "plibc_conv_to_win_path");
+ GE_USER | GE_WARNING | GE_IMMEDIATE,
+ "plibc_conv_to_win_path");
return NULL;
}
/* is the path relative? */
@@ -349,14 +349,14 @@
if (lRet + strlen(fn) + 1 > (MAX_PATH + 1)) {
SetErrnoFromWinError(ERROR_BUFFER_OVERFLOW);
GE_LOG_STRERROR(ectx,
- GE_USER | GE_WARNING | GE_IMMEDIATE,
- "GetCurrentDirectory");
+ GE_USER | GE_WARNING | GE_IMMEDIATE,
+ "GetCurrentDirectory");
return NULL;
}
buffer = MALLOC(MAX_PATH + 1);
SNPRINTF(buffer,
- MAX_PATH+1,
- "%s\\%s", szCurDir, fn);
+ MAX_PATH+1,
+ "%s\\%s", szCurDir, fn);
FREE(fn);
fn = buffer;
}
Modified: GNUnet/src/util/string/xmalloc.c
===================================================================
--- GNUnet/src/util/string/xmalloc.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/string/xmalloc.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -45,44 +45,44 @@
* @return pointer to size bytes of memory
*/
void * xmalloc_(size_t size,
- const char * filename,
- int linenumber,
- const char * function) {
+ const char * filename,
+ int linenumber,
+ const char * function) {
/* As a security precaution, we generally do not allow very large
allocations using the default 'MALLOC' macro */
GE_ASSERT_FLF(NULL,
- size <= MAX_MALLOC_CHECKED,
- filename,
- linenumber,
- function);
+ size <= MAX_MALLOC_CHECKED,
+ filename,
+ linenumber,
+ function);
return xmalloc_unchecked_(size,
- filename,
- linenumber,
- function);
+ filename,
+ linenumber,
+ function);
}
void * xmalloc_unchecked_(size_t size,
- const char * filename,
- int linenumber,
- const char * function) {
+ const char * filename,
+ int linenumber,
+ const char * function) {
void * result;
GE_ASSERT_FLF(NULL,
- size < INT_MAX,
- filename,
- linenumber,
- function);
+ size < INT_MAX,
+ filename,
+ linenumber,
+ function);
result = malloc(size);
if (result == NULL)
GE_DIE_STRERROR_FLF(NULL,
- GE_IMMEDIATE | GE_USER | GE_DEVELOPER | GE_FATAL,
- "malloc",
- filename,
- linenumber,
- function);
+ GE_IMMEDIATE | GE_USER | GE_DEVELOPER | GE_FATAL,
+ "malloc",
+ filename,
+ linenumber,
+ function);
memset(result,
- 0,
- size); /* client code should not rely on this, though... */
+ 0,
+ size); /* client code should not rely on this, though... */
return result;
}
@@ -99,19 +99,19 @@
* @return pointer to size bytes of memory
*/
void * xrealloc_(void * ptr,
- const size_t n,
- const char * filename,
- int linenumber,
- const char * function) {
+ const size_t n,
+ const char * filename,
+ int linenumber,
+ const char * function) {
ptr = realloc(ptr, n);
if (!ptr)
GE_DIE_STRERROR_FLF(NULL,
- GE_IMMEDIATE | GE_USER | GE_DEVELOPER | GE_FATAL,
- "realloc",
- filename,
- linenumber,
- function);
+ GE_IMMEDIATE | GE_USER | GE_DEVELOPER | GE_FATAL,
+ "realloc",
+ filename,
+ linenumber,
+ function);
return ptr;
}
@@ -124,14 +124,14 @@
* @param linenumber where in the code was the call to GROW
*/
void xfree_(void * ptr,
- const char * filename,
- int linenumber,
- const char * function) {
+ const char * filename,
+ int linenumber,
+ const char * function) {
GE_ASSERT_FLF(NULL,
- ptr != NULL,
- filename,
- linenumber,
- function);
+ ptr != NULL,
+ filename,
+ linenumber,
+ function);
free(ptr);
}
@@ -144,23 +144,23 @@
* @return strdup(str)
*/
char * xstrdup_(const char * str,
- const char * filename,
- int linenumber,
- const char * function) {
+ const char * filename,
+ int linenumber,
+ const char * function) {
char * res;
GE_ASSERT_FLF(NULL,
- str != NULL,
- filename,
- linenumber,
- function);
+ str != NULL,
+ filename,
+ linenumber,
+ function);
res = (char*)xmalloc_(strlen(str)+1,
- filename,
- linenumber,
- function);
+ filename,
+ linenumber,
+ function);
memcpy(res,
- str,
- strlen(str)+1);
+ str,
+ strlen(str)+1);
return res;
}
@@ -174,25 +174,25 @@
* @return strdup(str)
*/
char * xstrndup_(const char * str,
- const size_t n,
- const char * filename,
- int linenumber,
- const char * function) {
+ const size_t n,
+ const char * filename,
+ int linenumber,
+ const char * function) {
char * res;
size_t min;
GE_ASSERT_FLF(NULL,
- str != NULL,
- filename,
- linenumber,
- function);
+ str != NULL,
+ filename,
+ linenumber,
+ function);
min = 0;
while ( (min < n) && (str[min] != '\0'))
min++;
res = (char*)xmalloc_(min+1,
- filename,
- linenumber,
- function);
+ filename,
+ linenumber,
+ function);
memcpy(res, str, min);
res[min] = '\0';
return res;
@@ -212,42 +212,42 @@
* @param linenumber where in the code was the call to GROW
*/
void xgrow_(void ** old,
- size_t elementSize,
- unsigned int * oldCount,
- unsigned int newCount,
- const char * filename,
- int linenumber,
- const char * function) {
+ size_t elementSize,
+ unsigned int * oldCount,
+ unsigned int newCount,
+ const char * filename,
+ int linenumber,
+ const char * function) {
void * tmp;
size_t size;
GE_ASSERT_FLF(NULL,
- INT_MAX / elementSize > newCount,
- filename,
- linenumber,
- function);
+ INT_MAX / elementSize > newCount,
+ filename,
+ linenumber,
+ function);
size = newCount * elementSize;
if (size == 0) {
tmp = NULL;
} else {
tmp = xmalloc_(size,
- filename,
- linenumber,
- function);
+ filename,
+ linenumber,
+ function);
GE_ASSERT(NULL, tmp != NULL);
memset(tmp, 0, size); /* client code should not rely on this, though... */
if (*oldCount > newCount)
*oldCount = newCount; /* shrink is also allowed! */
memcpy(tmp,
- *old,
- elementSize * (*oldCount));
+ *old,
+ elementSize * (*oldCount));
}
if (*old != NULL) {
xfree_(*old,
- filename,
- linenumber,
- function);
+ filename,
+ linenumber,
+ function);
}
*old = tmp;
*oldCount = newCount;
Modified: GNUnet/src/util/string/xmalloctest.c
===================================================================
--- GNUnet/src/util/string/xmalloctest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/string/xmalloctest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -45,7 +45,7 @@
for (i=MAX_TESTVAL-1;i>=1;i--) {
for (j=i-1;j>=0;j--)
if (ptrs[i][j] != (char) --k)
- return 1;
+ return 1;
FREE(ptrs[i]);
}
@@ -107,13 +107,13 @@
}
int main(int argc,
- char * argv[]){
+ char * argv[]){
int ret;
ret = check();
if (ret != 0)
fprintf(stderr,
- "ERROR %d.\n",
- ret);
+ "ERROR %d.\n",
+ ret);
return ret;
}
Modified: GNUnet/src/util/threads/mutex.c
===================================================================
--- GNUnet/src/util/threads/mutex.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/threads/mutex.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -58,7 +58,7 @@
*/
#ifndef _MSC_VER
extern int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr,
- int kind);
+ int kind);
#endif
@@ -81,40 +81,40 @@
if (isRecursive) {
#if LINUX
GE_ASSERT(NULL,
- 0 == pthread_mutexattr_setkind_np
- (&attr,
- PTHREAD_MUTEX_RECURSIVE_NP));
+ 0 == pthread_mutexattr_setkind_np
+ (&attr,
+ PTHREAD_MUTEX_RECURSIVE_NP));
#elif SOMEBSD || FREEBSD || FREEBSD5
GE_ASSERT(NULL,
- 0 == pthread_mutexattr_setkind_np
- (&attr,
- PTHREAD_MUTEX_RECURSIVE));
+ 0 == pthread_mutexattr_setkind_np
+ (&attr,
+ PTHREAD_MUTEX_RECURSIVE));
#elif SOLARIS || OSX || WINDOWS
GE_ASSERT(NULL,
- 0 == pthread_mutexattr_settype
- (&attr,
- PTHREAD_MUTEX_RECURSIVE));
+ 0 == pthread_mutexattr_settype
+ (&attr,
+ PTHREAD_MUTEX_RECURSIVE));
#endif
} else {
#if LINUX
GE_ASSERT(NULL,
- 0 == pthread_mutexattr_setkind_np
- (&attr,
- PTHREAD_MUTEX_ERRORCHECK_NP));
+ 0 == pthread_mutexattr_setkind_np
+ (&attr,
+ PTHREAD_MUTEX_ERRORCHECK_NP));
#else
GE_ASSERT(NULL,
- 0 == pthread_mutexattr_settype
- (&attr,
- PTHREAD_MUTEX_ERRORCHECK));
+ 0 == pthread_mutexattr_settype
+ (&attr,
+ PTHREAD_MUTEX_ERRORCHECK));
#endif
}
mut = MALLOC(sizeof(Mutex));
memset(mut,
- 0,
- sizeof(Mutex));
+ 0,
+ sizeof(Mutex));
GE_ASSERT(NULL,
- 0 == pthread_mutex_init(&mut->pt,
- &attr));
+ 0 == pthread_mutex_init(&mut->pt,
+ &attr));
return mut;
}
@@ -128,8 +128,8 @@
}
void MUTEX_LOCK_FL(Mutex * mutex,
- const char * file,
- unsigned int line) {
+ const char * file,
+ unsigned int line) {
int ret;
cron_t start;
cron_t end;
@@ -141,23 +141,23 @@
if ( (end - start > REALTIME_LIMIT) &&
(REALTIME_LIMIT != 0) ) {
GE_LOG(NULL,
- GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
- _("Real-time delay violation (%llu ms) at %s:%u\n"),
- end - start,
- file,
- line);
+ GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
+ _("Real-time delay violation (%llu ms) at %s:%u\n"),
+ end - start,
+ file,
+ line);
}
if (ret != 0) {
if (ret == EINVAL)
GE_LOG(NULL,
- GE_FATAL | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
- _("Invalid argument for `%s'.\n"),
- "pthread_mutex_lock");
+ GE_FATAL | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
+ _("Invalid argument for `%s'.\n"),
+ "pthread_mutex_lock");
if (ret == EDEADLK)
GE_LOG(NULL,
- GE_FATAL | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
- _("Deadlock due to `%s'.\n"),
- "pthread_mutex_lock");
+ GE_FATAL | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
+ _("Deadlock due to `%s'.\n"),
+ "pthread_mutex_lock");
GE_ASSERT(NULL, 0);
}
if (mutex->locked_depth++ == 0) {
@@ -175,13 +175,13 @@
if (0 == --mutex->locked_depth) {
now = get_time();
if ( (now - mutex->locked_time > REALTIME_LIMIT) &&
- (REALTIME_LIMIT != 0) )
+ (REALTIME_LIMIT != 0) )
GE_LOG(NULL,
- GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
- _("Lock aquired for too long (%llu ms) at %s:%u\n"),
- now - mutex->locked_time,
- mutex->locked_file,
- mutex->locked_line);
+ GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
+ _("Lock aquired for too long (%llu ms) at %s:%u\n"),
+ now - mutex->locked_time,
+ mutex->locked_file,
+ mutex->locked_line);
mutex->locked_file = NULL;
mutex->locked_line = 0;
mutex->locked_time = 0;
@@ -190,14 +190,14 @@
if (ret != 0) {
if (ret == EINVAL)
GE_LOG(NULL,
- GE_FATAL | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
- _("Invalid argument for `%s'.\n"),
- "pthread_mutex_lock");
+ GE_FATAL | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
+ _("Invalid argument for `%s'.\n"),
+ "pthread_mutex_lock");
if (ret == EPERM)
GE_LOG(NULL,
- GE_FATAL | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
- _("Permission denied for `%s'.\n"),
- "pthread_mutex_unlock");
+ GE_FATAL | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
+ _("Permission denied for `%s'.\n"),
+ "pthread_mutex_unlock");
GE_ASSERT(NULL, 0);
}
}
Modified: GNUnet/src/util/threads/pthread.c
===================================================================
--- GNUnet/src/util/threads/pthread.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/threads/pthread.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -96,8 +96,8 @@
* @return see pthread_create
*/
PThread * PTHREAD_CREATE(PThreadMain main,
- void * arg,
- unsigned int stackSize) {
+ void * arg,
+ unsigned int stackSize) {
PThread * handle;
#ifndef LINUX
pthread_attr_t stack_size_custom_attr;
@@ -111,16 +111,16 @@
#ifndef LINUX
pthread_attr_init(&stack_size_custom_attr);
pthread_attr_setstacksize(&stack_size_custom_attr,
- stackSize);
+ stackSize);
#endif
ret = pthread_create(&handle->pt,
#ifndef LINUX
- &stack_size_custom_attr,
+ &stack_size_custom_attr,
#else
- NULL,
+ NULL,
#endif
- main,
- arg);
+ main,
+ arg);
if (ret != 0) {
FREE(handle);
return NULL;
@@ -129,28 +129,28 @@
}
void PTHREAD_JOIN_FL(PThread * handle,
- void ** ret,
- const char * file,
- unsigned int line) {
+ void ** ret,
+ const char * file,
+ unsigned int line) {
cron_t start;
cron_t end;
int k;
GE_ASSERT(NULL,
- handle != NULL);
+ handle != NULL);
GE_ASSERT(NULL,
- NO == PTHREAD_TEST_SELF(handle));
+ NO == PTHREAD_TEST_SELF(handle));
start = get_time();
k = pthread_join(handle->pt, ret);
end = get_time();
if ( (end - start > REALTIME_LIMIT) &&
(REALTIME_LIMIT != 0) ) {
GE_LOG(NULL,
- GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
- _("Real-time delay violation (%llu ms) at %s:%u\n"),
- end - start,
- file,
- line);
+ GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
+ _("Real-time delay violation (%llu ms) at %s:%u\n"),
+ end - start,
+ file,
+ line);
}
FREE(handle);
switch (k) {
@@ -158,33 +158,33 @@
return;
case ESRCH:
GE_LOG(NULL,
- GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
- _("`%s' failed with error code %s: %s\n"),
- "pthread_join",
- "ESRCH",
- STRERROR(errno));
+ GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
+ _("`%s' failed with error code %s: %s\n"),
+ "pthread_join",
+ "ESRCH",
+ STRERROR(errno));
break;
case EINVAL:
GE_LOG(NULL,
- GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
- _("`%s' failed with error code %s: %s\n"),
- "pthread_join",
- "EINVAL",
- STRERROR(errno));
+ GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
+ _("`%s' failed with error code %s: %s\n"),
+ "pthread_join",
+ "EINVAL",
+ STRERROR(errno));
case EDEADLK:
GE_LOG(NULL,
- GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
- _("`%s' failed with error code %s: %s\n"),
- "pthread_join",
- "EDEADLK",
- STRERROR(errno));
+ GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
+ _("`%s' failed with error code %s: %s\n"),
+ "pthread_join",
+ "EDEADLK",
+ STRERROR(errno));
default:
GE_LOG(NULL,
- GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
- _("`%s' failed with error code %d: %s\n"),
- "pthread_join",
- k,
- STRERROR(errno));
+ GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
+ _("`%s' failed with error code %d: %s\n"),
+ "pthread_join",
+ k,
+ STRERROR(errno));
}
GE_ASSERT(NULL, 0);
}
@@ -227,8 +227,8 @@
if ( (0 != nanosleep(&req, &rem)) &&
(errno != EINTR) )
GE_LOG_STRERROR(NULL,
- GE_WARNING | GE_USER | GE_BULK,
- "nanosleep");
+ GE_WARNING | GE_USER | GE_BULK,
+ "nanosleep");
#elif WINDOWS
SleepEx(delay, TRUE);
@@ -243,8 +243,8 @@
if ( (ret == -1) &&
(errno != EINTR) )
GE_LOG_STRERROR(NULL,
- GE_WARNING | GE_USER | GE_BULK,
- "select");
+ GE_WARNING | GE_USER | GE_BULK,
+ "select");
#endif
}
@@ -256,8 +256,8 @@
return;
#ifdef WINDOWS
ret = QueueUserAPC((PAPCFUNC) __PTHREAD_SIGNALED,
- pthread_getw32threadhandle_np(handle->pt),
- 0) != 0 ? 0 : EINVAL;
+ pthread_getw32threadhandle_np(handle->pt),
+ 0) != 0 ? 0 : EINVAL;
#else
ret = pthread_kill(handle->pt, SIGALRM);
#endif
@@ -266,22 +266,22 @@
break; /* ok */
case EINVAL:
GE_LOG(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- _("`%s' failed with error code %s: %s\n"),
- "pthread_kill",
- "EINVAL",
- STRERROR(ret));
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ _("`%s' failed with error code %s: %s\n"),
+ "pthread_kill",
+ "EINVAL",
+ STRERROR(ret));
break;
case ESRCH:
/* ignore, thread might have already exited by chance */
break;
default:
GE_LOG(NULL,
- GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
- _("`%s' failed with error code %d: %s\n"),
- "pthread_kill",
- ret,
- STRERROR(ret));
+ GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
+ _("`%s' failed with error code %d: %s\n"),
+ "pthread_kill",
+ ret,
+ STRERROR(ret));
break;
}
}
@@ -304,10 +304,10 @@
sig.sa_handler = &sigalrmHandler;
if (0 != sigaction(SIGALRM, &sig, &old))
GE_LOG_STRERROR(NULL,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "sigaction");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "sigaction");
#else
- InitWinEnv(NULL);
+ InitWinEnv(NULL);
#endif
}
@@ -315,10 +315,10 @@
#ifndef MINGW
if (0 != sigaction(SIGALRM, &old, &sig))
GE_LOG_STRERROR(NULL,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "sigaction");
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "sigaction");
#else
- ShutdownWinEnv();
+ ShutdownWinEnv();
#endif
}
Modified: GNUnet/src/util/threads/semaphore.c
===================================================================
--- GNUnet/src/util/threads/semaphore.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/threads/semaphore.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -81,7 +81,7 @@
*/
#ifndef _MSC_VER
extern int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr,
- int kind);
+ int kind);
#endif
/**
@@ -99,32 +99,32 @@
pthread_mutexattr_init(&attr);
#if LINUX
GE_ASSERT(NULL,
- 0 == pthread_mutexattr_setkind_np
- (&attr,
- PTHREAD_MUTEX_ERRORCHECK_NP));
+ 0 == pthread_mutexattr_setkind_np
+ (&attr,
+ PTHREAD_MUTEX_ERRORCHECK_NP));
#else
GE_ASSERT(NULL,
- 0 == pthread_mutexattr_settype
- (&attr,
- PTHREAD_MUTEX_ERRORCHECK));
+ 0 == pthread_mutexattr_settype
+ (&attr,
+ PTHREAD_MUTEX_ERRORCHECK));
#endif
s = MALLOC(sizeof(Semaphore));
s->v = value;
GE_ASSERT(NULL,
- 0 == pthread_mutex_init(&s->mutex,
- &attr));
+ 0 == pthread_mutex_init(&s->mutex,
+ &attr));
GE_ASSERT(NULL,
- 0 == pthread_cond_init(&s->cond,
- NULL));
+ 0 == pthread_cond_init(&s->cond,
+ NULL));
return s;
}
void SEMAPHORE_DESTROY(Semaphore * s) {
GE_ASSERT(NULL, s != NULL);
GE_ASSERT(NULL,
- 0 == pthread_cond_destroy(&s->cond));
+ 0 == pthread_cond_destroy(&s->cond));
GE_ASSERT(NULL,
- 0 == pthread_mutex_destroy(&s->mutex));
+ 0 == pthread_mutex_destroy(&s->mutex));
FREE(s);
}
@@ -133,20 +133,20 @@
GE_ASSERT(NULL, s != NULL);
GE_ASSERT(NULL,
- 0 == pthread_mutex_lock(&s->mutex));
+ 0 == pthread_mutex_lock(&s->mutex));
ret = ++(s->v);
GE_ASSERT(NULL,
- 0 == pthread_cond_signal(&s->cond));
+ 0 == pthread_cond_signal(&s->cond));
GE_ASSERT(NULL,
- 0 == pthread_mutex_unlock(&s->mutex));
+ 0 == pthread_mutex_unlock(&s->mutex));
return ret;
}
int SEMAPHORE_DOWN_FL(Semaphore * s,
- int mayblock,
- int longwait,
- const char * file,
- unsigned int line) {
+ int mayblock,
+ int longwait,
+ const char * file,
+ unsigned int line) {
int ret;
cron_t start;
cron_t end;
@@ -154,27 +154,27 @@
GE_ASSERT(NULL, s != NULL);
start = get_time();
GE_ASSERT(NULL,
- 0 == pthread_mutex_lock(&s->mutex));
+ 0 == pthread_mutex_lock(&s->mutex));
while ( (s->v <= 0) && mayblock)
GE_ASSERT(NULL,
- 0 == pthread_cond_wait(&s->cond,
- &s->mutex));
+ 0 == pthread_cond_wait(&s->cond,
+ &s->mutex));
if (s->v > 0)
ret = --(s->v);
else
ret = SYSERR;
GE_ASSERT(NULL,
- 0 == pthread_mutex_unlock(&s->mutex));
+ 0 == pthread_mutex_unlock(&s->mutex));
end = get_time();
if ( (longwait == NO) &&
(end - start > REALTIME_LIMIT) &&
(REALTIME_LIMIT != 0) ) {
GE_LOG(NULL,
- GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
- _("Real-time delay violation (%llu ms) at %s:%u\n"),
- end - start,
- file,
- line);
+ GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
+ _("Real-time delay violation (%llu ms) at %s:%u\n"),
+ end - start,
+ file,
+ line);
}
return ret;
}
Modified: GNUnet/src/util/threads/semaphoretest.c
===================================================================
--- GNUnet/src/util/threads/semaphoretest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/threads/semaphoretest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -63,8 +63,8 @@
sv = -1; tv = 0;
lock = MUTEX_CREATE(NO);
pt = PTHREAD_CREATE(&lockIt,
- NULL,
- 1024);
+ NULL,
+ 1024);
while (tv != 2) {
sv = 1;
PTHREAD_SLEEP(50 * cronMILLIS); /* busy waiting may not always work */
@@ -72,8 +72,8 @@
PTHREAD_JOIN(pt, &unused);
MUTEX_DESTROY(lock);
pt = PTHREAD_CREATE(&bigStack,
- NULL,
- 1024*100 + 25000); /* fails by segfault */
+ NULL,
+ 1024*100 + 25000); /* fails by segfault */
PTHREAD_JOIN(pt, &unused);
return 0;
}
@@ -87,13 +87,13 @@
sv = 1;
tv = 0;
pt = PTHREAD_CREATE(&lockIt,
- NULL,
- 1024);
+ NULL,
+ 1024);
while (sv == 1)
PTHREAD_SLEEP(50 * cronMILLIS); /* busy waiting may not always work */
MUTEX_LOCK(lock);
sv = 5; /* release lockIt from while sv==0 loop,
- blocks it on lock */
+ blocks it on lock */
if (sv != 5) {
MUTEX_UNLOCK(lock);
@@ -101,7 +101,7 @@
PTHREAD_SLEEP(50 * cronMILLIS); /* busy waiting may not always work */
MUTEX_DESTROY(lock);
printf("MUTEX test failed at %s:%u\n",
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
return 1; /* error */
} else {
MUTEX_UNLOCK(lock);
@@ -133,8 +133,8 @@
if (SEMAPHORE_DOWN(sem, NO) != SYSERR) {
SEMAPHORE_DESTROY(sem);
printf("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u\n"
- "Testcase deadlocked.\n",
- __FILE__, __LINE__);
+ "Testcase deadlocked.\n",
+ __FILE__, __LINE__);
return NULL; /* will halt testcase! */
}
for (i=0;i<42;i++)
@@ -153,7 +153,7 @@
if (SEMAPHORE_DOWN(sem, NO) != SYSERR) {
SEMAPHORE_DESTROY(sem);
printf("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u\n",
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
return 1;
}
for (i=0;i<42;i++)
@@ -162,18 +162,18 @@
if (SYSERR == SEMAPHORE_DOWN(sem, NO)) {
SEMAPHORE_DESTROY(sem);
printf("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u iteration %d\n",
- __FILE__, __LINE__, i);
+ __FILE__, __LINE__, i);
return 1;
}
if (SEMAPHORE_DOWN(sem, NO) != SYSERR) {
SEMAPHORE_DESTROY(sem);
printf("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u\n",
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
return 1;
}
pt = PTHREAD_CREATE(&semUpDown,
- NULL,
- 1024);
+ NULL,
+ 1024);
for (i=0;i<42;i++)
SEMAPHORE_UP(sem);
PTHREAD_JOIN(pt, &unused);
@@ -182,14 +182,14 @@
if (SEMAPHORE_DOWN(sem, NO) != SYSERR) {
SEMAPHORE_DESTROY(sem);
printf("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u\n",
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
return 1;
}
return 0;
}
int main(int argc,
- char * argv[]){
+ char * argv[]){
int ret = 0;
ret += testPTHREAD_CREATE();
Modified: GNUnet/src/util/threads/shutdowntest.c
===================================================================
--- GNUnet/src/util/threads/shutdowntest.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/threads/shutdowntest.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -37,7 +37,7 @@
}
int main(int argc,
- char * argv[]){
+ char * argv[]){
int ret;
ret = check();
Modified: GNUnet/src/util/threads/shutdowntest2.c
===================================================================
--- GNUnet/src/util/threads/shutdowntest2.c 2007-07-05 19:56:14 UTC (rev
5248)
+++ GNUnet/src/util/threads/shutdowntest2.c 2007-07-05 21:12:30 UTC (rev
5249)
@@ -41,7 +41,7 @@
}
int main(int argc,
- char * argv[]){
+ char * argv[]){
int ret;
ret = check();
Modified: GNUnet/src/util/threads/signal.c
===================================================================
--- GNUnet/src/util/threads/signal.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/threads/signal.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -38,7 +38,7 @@
} SignalHandlerContext;
struct SignalHandlerContext * signal_handler_install(int signal,
- SignalHandler handler) {
+ SignalHandler handler) {
struct SignalHandlerContext * ret;
struct sigaction sig;
@@ -58,8 +58,8 @@
}
void signal_handler_uninstall(int signal,
- SignalHandler handler,
- struct SignalHandlerContext * ctx) {
+ SignalHandler handler,
+ struct SignalHandlerContext * ctx) {
struct sigaction sig;
GE_ASSERT(NULL, (ctx->sig == signal) && (ctx->method == handler));
Modified: GNUnet/src/util/threads/time.c
===================================================================
--- GNUnet/src/util/threads/time.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/threads/time.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -36,7 +36,7 @@
struct timeval tv;
#ifndef WINDOWS
struct timezone tz; /* man page says it's obsolete, but
- I'd rather not pass a NULL pointer */
+ I'd rather not pass a NULL pointer */
gettimeofday(&tv, &tz);
#else
Modified: GNUnet/src/util/threads/timertest.c
===================================================================
--- GNUnet/src/util/threads/timertest.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/threads/timertest.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -60,9 +60,9 @@
now = get_time();
#if VERBOSE
fprintf(stderr,
- "%4llu ms requested, got: %4llu ms\n",
- i * cronMILLIS,
- (now - last));
+ "%4llu ms requested, got: %4llu ms\n",
+ i * cronMILLIS,
+ (now - last));
#endif
if (last + cronMILLIS * i < now)
cumDelta += (now - (last+cronMILLIS*i));
@@ -70,25 +70,25 @@
cumDelta += ((last+cronMILLIS*i) - now);
}
FPRINTF(stdout,
- "Sleep precision: %llu ms. ",
- cumDelta / cronMILLIS / (MAXV/INCR));
+ "Sleep precision: %llu ms. ",
+ cumDelta / cronMILLIS / (MAXV/INCR));
if (cumDelta <= 10 * cronMILLIS * MAXV / INCR)
fprintf(stdout,
- "Timer precision is excellent.\n");
+ "Timer precision is excellent.\n");
else if (cumDelta <= 50 * cronMILLIS * MAXV / INCR) /* 50 ms average
deviation */
fprintf(stdout,
- "Timer precision is good.\n");
+ "Timer precision is good.\n");
else if (cumDelta > 250 * cronMILLIS * MAXV / INCR)
fprintf(stdout,
- "Timer precision is awful.\n");
+ "Timer precision is awful.\n");
else
fprintf(stdout,
- "Timer precision is acceptable.\n");
+ "Timer precision is acceptable.\n");
return 0;
}
int main(int argc,
- char * argv[]){
+ char * argv[]){
int ret;
ret = check();
Modified: GNUnet/src/util/win/win.cc
===================================================================
--- GNUnet/src/util/win/win.cc 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/win/win.cc 2007-07-05 21:12:30 UTC (rev 5249)
@@ -94,7 +94,7 @@
GlobalFree(*pAddrTable);
*pAddrTable = (MIB_IPADDRTABLE *) GlobalAlloc(GPTR, dwSize);
}
- GNGetIpAddrTable(*pAddrTable, &dwSize, 0);
+ GNGetIpAddrTable(*pAddrTable, &dwSize, 0);
}
}
}
@@ -129,9 +129,9 @@
char szEntry[1001];
DWORD dwIP = 0;
int iItm;
- PIP_ADAPTER_INFO pAdapterInfo;
- PIP_ADAPTER_INFO pAdapter = NULL;
- DWORD dwRetVal = 0;
+ PIP_ADAPTER_INFO pAdapterInfo;
+ PIP_ADAPTER_INFO pAdapter = NULL;
+ DWORD dwRetVal = 0;
/* Get IP-Address */
int i;
@@ -147,44 +147,44 @@
if (dwIP)
{
BYTE bPhysAddr[MAXLEN_PHYSADDR];
- char *pszIfName = NULL;
+ char *pszIfName = NULL;
- /* Get friendly interface name */
- pAdapterInfo = (IP_ADAPTER_INFO *)
malloc(sizeof(IP_ADAPTER_INFO));
- ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO);
-
- /* Make an initial call to GetAdaptersInfo to
get
- the necessary size into the ulOutBufLen
variable */
- if (GGetAdaptersInfo(pAdapterInfo,
&ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
- free(pAdapterInfo);
- pAdapterInfo = (IP_ADAPTER_INFO *) malloc
(ulOutBufLen);
- }
-
- if ((dwRetVal = GGetAdaptersInfo( pAdapterInfo,
&ulOutBufLen)) == NO_ERROR) {
- pAdapter = pAdapterInfo;
- while (pAdapter) {
- if (pTable->table[dwIfIdx].dwIndex ==
pAdapter->Index)
- {
- char szKey[251];
- long lLen = 250;
-
- sprintf(szKey,
"SYSTEM\\CurrentControlSet\\Control\\Network\\"
-
"{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection",
- pAdapter->AdapterName);
- pszIfName = (char *)
malloc(251);
- if
(QueryRegistry(HKEY_LOCAL_MACHINE, szKey, "Name", pszIfName,
- &lLen) != ERROR_SUCCESS)
- {
- free(pszIfName);
- pszIfName = NULL;
- }
- }
- pAdapter = pAdapter->Next;
- }
- }
- free(pAdapterInfo);
+ /* Get friendly interface name */
+ pAdapterInfo = (IP_ADAPTER_INFO *)
malloc(sizeof(IP_ADAPTER_INFO));
+ ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO);
+
+ /* Make an initial call to GetAdaptersInfo to get
+ the necessary size into the ulOutBufLen variable */
+ if (GGetAdaptersInfo(pAdapterInfo, &ulOutBufLen) ==
ERROR_BUFFER_OVERFLOW) {
+ free(pAdapterInfo);
+ pAdapterInfo = (IP_ADAPTER_INFO *) malloc
(ulOutBufLen);
+ }
+
+ if ((dwRetVal = GGetAdaptersInfo( pAdapterInfo,
&ulOutBufLen)) == NO_ERROR) {
+ pAdapter = pAdapterInfo;
+ while (pAdapter) {
+ if (pTable->table[dwIfIdx].dwIndex ==
pAdapter->Index)
+ {
+ char szKey[251];
+ long lLen = 250;
+
+ sprintf(szKey,
"SYSTEM\\CurrentControlSet\\Control\\Network\\"
+
"{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection",
+ pAdapter->AdapterName);
+ pszIfName = (char *) malloc(251);
+ if (QueryRegistry(HKEY_LOCAL_MACHINE,
szKey, "Name", pszIfName,
+ &lLen) != ERROR_SUCCESS)
+ {
+ free(pszIfName);
+ pszIfName = NULL;
+ }
+ }
+ pAdapter = pAdapter->Next;
+ }
+ }
+ free(pAdapterInfo);
- /* Set entry */
+ /* Set entry */
memset(bPhysAddr, 0, MAXLEN_PHYSADDR);
memcpy(bPhysAddr,
pTable->table[dwIfIdx].bPhysAddr,
@@ -197,7 +197,7 @@
szEntry[1000] = 0;
if (pszIfName)
- free(pszIfName);
+ free(pszIfName);
callback(szEntry, pAddrTable->table[dwIfIdx].dwIndex == dwExternalNIC,
cls);
}
@@ -232,18 +232,18 @@
if (! hManager)
return 2;
- if (username)
- {
- user = (char *) malloc(strlen(username) + 3);
- sprintf(user, ".\\%s", username);
- }
+ if (username)
+ {
+ user = (char *) malloc(strlen(username) + 3);
+ sprintf(user, ".\\%s", username);
+ }
hService = GNCreateService(hManager, "GNUnet", "GNUnet", 0,
SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, szEXE,
NULL, NULL, NULL, user, username);
if (user)
- free(user);
+ free(user);
if (! hService)
return 3;
@@ -273,19 +273,19 @@
return 2;
if (! (hService = GNOpenService(hManager, "GNUnet", DELETE)))
- if (GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST)
- return 3;
- else
- goto closeSCM;
+ if (GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST)
+ return 3;
+ else
+ goto closeSCM;
if (! GNDeleteService(hService))
- if (GetLastError() != ERROR_SERVICE_MARKED_FOR_DELETE)
- return 4;
+ if (GetLastError() != ERROR_SERVICE_MARKED_FOR_DELETE)
+ return 4;
closeSCM:
GNCloseServiceHandle(hService);
- return 0;
+ return 0;
}
/**
@@ -353,63 +353,63 @@
BOOL _GetAccountSid(LPTSTR SystemName, LPTSTR AccountName, PSID * Sid)
{
LPTSTR ReferencedDomain = NULL;
- DWORD cbSid = 128;
/* initial allocation attempt */
- DWORD cchReferencedDomain = 16; /* initial allocation size */
+ DWORD cbSid = 128; /*
initial allocation attempt */
+ DWORD cchReferencedDomain = 16; /* initial allocation size */
SID_NAME_USE peUse;
- BOOL bSuccess = FALSE; /*
assume this function will fail */
+ BOOL bSuccess = FALSE; /* assume this
function will fail */
/* initial memory allocations */
- if ((*Sid = HeapAlloc (GetProcessHeap (), 0, cbSid)) == NULL)
- return FALSE;
+ if ((*Sid = HeapAlloc (GetProcessHeap (), 0, cbSid)) == NULL)
+ return FALSE;
- if ((ReferencedDomain = (LPTSTR) HeapAlloc (GetProcessHeap (),
- 0,
- cchReferencedDomain *
- sizeof (TCHAR))) == NULL)
- return FALSE;
+ if ((ReferencedDomain = (LPTSTR) HeapAlloc (GetProcessHeap (),
+ 0,
+ cchReferencedDomain *
+ sizeof (TCHAR))) == NULL)
+ return FALSE;
/* Obtain the SID of the specified account on the specified system. */
- while (!GNLookupAccountName(SystemName, /* machine to lookup
account on */
- AccountName,
/* account to lookup */
- *Sid,
/* SID
of interest */
- &cbSid,
/* size of SID
*/
- ReferencedDomain,
/* domain account was found on */
- &cchReferencedDomain, &peUse))
- {
- if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
- {
- /* reallocate memory */
- if ((*Sid = HeapReAlloc (GetProcessHeap (), 0,
*Sid, cbSid)) == NULL)
- return FALSE;
+ while (!GNLookupAccountName(SystemName, /* machine to lookup account on
*/
+ AccountName,
/* account to lookup */
+ *Sid,
/* SID of
interest */
+ &cbSid,
/* size of SID */
+ ReferencedDomain,
/* domain account was found on */
+ &cchReferencedDomain, &peUse))
+ {
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ /* reallocate memory */
+ if ((*Sid = HeapReAlloc (GetProcessHeap (), 0, *Sid,
cbSid)) == NULL)
+ return FALSE;
- if ((ReferencedDomain = (LPTSTR) HeapReAlloc
(GetProcessHeap (),
- 0,
- ReferencedDomain,
- cchReferencedDomain
- * sizeof (TCHAR))) ==
NULL)
- return FALSE;
+ if ((ReferencedDomain = (LPTSTR) HeapReAlloc
(GetProcessHeap (),
+ 0,
+ ReferencedDomain,
+ cchReferencedDomain
+ * sizeof (TCHAR))) == NULL)
+ return FALSE;
}
- else
- goto end;
+ else
+ goto end;
}
/* Indicate success. */
- bSuccess = TRUE;
+ bSuccess = TRUE;
end:
- /* Cleanup and indicate failure, if appropriate. */
- HeapFree (GetProcessHeap (), 0, ReferencedDomain);
+ /* Cleanup and indicate failure, if appropriate. */
+ HeapFree (GetProcessHeap (), 0, ReferencedDomain);
- if (!bSuccess)
- {
- if (*Sid != NULL)
+ if (!bSuccess)
+ {
+ if (*Sid != NULL)
{
- HeapFree (GetProcessHeap (), 0, *Sid);
- *Sid = NULL;
+ HeapFree (GetProcessHeap (), 0, *Sid);
+ *Sid = NULL;
}
}
- return bSuccess;
+ return bSuccess;
}
/**
@@ -418,9 +418,9 @@
* @date 12-Jul-95
*/
NTSTATUS _SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle,/* open policy handle
*/
- PSID AccountSid,
/* SID to grant privilege to */
- LPWSTR PrivilegeName, /* privilege to
grant (Unicode) */
- BOOL bEnable
/* enable or disable */
+ PSID AccountSid, /* SID
to grant privilege to */
+ LPWSTR PrivilegeName, /* privilege to grant
(Unicode) */
+ BOOL bEnable
/* enable or disable */
)
{
LSA_UNICODE_STRING PrivilegeString;
@@ -431,21 +431,21 @@
/* grant or revoke the privilege, accordingly */
if(bEnable)
{
- NTSTATUS i;
-
- i = GNLsaAddAccountRights(PolicyHandle,
/* open policy handle */
- AccountSid,
/* target SID */
+ NTSTATUS i;
+
+ i = GNLsaAddAccountRights(PolicyHandle, /* open
policy handle */
+ AccountSid, /*
target SID */
&PrivilegeString, /* privileges */
- 1
/* privilege count */
+ 1
/* privilege count */
);
}
else
{
- return GNLsaRemoveAccountRights(PolicyHandle,
/* open policy handle */
- AccountSid,
/* target SID */
- FALSE,
/* do not disable all rights */
- &PrivilegeString, /*
privileges */
- 1
/* privilege count */
+ return GNLsaRemoveAccountRights(PolicyHandle, /* open
policy handle */
+ AccountSid, /*
target SID */
+ FALSE,
/* do not disable all rights */
+ &PrivilegeString, /* privileges */
+ 1
/* privilege count */
);
}
}
@@ -458,50 +458,50 @@
*/
int CreateServiceAccount(char *pszName, char *pszDesc)
{
- USER_INFO_1 ui;
- USER_INFO_1008 ui2;
- NET_API_STATUS nStatus;
- wchar_t wszName[MAX_NAME_LENGTH], wszDesc[MAX_NAME_LENGTH];
- DWORD dwErr;
- LSA_HANDLE hPolicy;
- PSID pSID;
-
- if (! GNNetUserAdd)
- return 1;
- mbstowcs(wszName, pszName, strlen(pszName) + 1);
- mbstowcs(wszDesc, pszDesc, strlen(pszDesc) + 1);
-
- memset(&ui, 0, sizeof(ui));
- ui.usri1_name = wszName;
- ui.usri1_password = wszName; /* account is locked anyway */
- ui.usri1_priv = USER_PRIV_USER;
- ui.usri1_comment = wszDesc;
- ui.usri1_flags = UF_SCRIPT;
+ USER_INFO_1 ui;
+ USER_INFO_1008 ui2;
+ NET_API_STATUS nStatus;
+ wchar_t wszName[MAX_NAME_LENGTH], wszDesc[MAX_NAME_LENGTH];
+ DWORD dwErr;
+ LSA_HANDLE hPolicy;
+ PSID pSID;
+
+ if (! GNNetUserAdd)
+ return 1;
+ mbstowcs(wszName, pszName, strlen(pszName) + 1);
+ mbstowcs(wszDesc, pszDesc, strlen(pszDesc) + 1);
+
+ memset(&ui, 0, sizeof(ui));
+ ui.usri1_name = wszName;
+ ui.usri1_password = wszName; /* account is locked anyway */
+ ui.usri1_priv = USER_PRIV_USER;
+ ui.usri1_comment = wszDesc;
+ ui.usri1_flags = UF_SCRIPT;
- nStatus = GNNetUserAdd(NULL, 1, (LPBYTE)&ui, NULL);
-
- if (nStatus != NERR_Success && nStatus != NERR_UserExists)
- return 2;
-
+ nStatus = GNNetUserAdd(NULL, 1, (LPBYTE)&ui, NULL);
+
+ if (nStatus != NERR_Success && nStatus != NERR_UserExists)
+ return 2;
+
ui2.usri1008_flags = UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD;
GNNetUserSetInfo(NULL, wszName, 1008, (LPBYTE)&ui2, NULL);
-
- if (_OpenPolicy(NULL, POLICY_ALL_ACCESS, &hPolicy) !=
-
STATUS_SUCCESS)
- return 3;
-
- _GetAccountSid(NULL, pszName, &pSID);
-
- if (_SetPrivilegeOnAccount(hPolicy, pSID, L"SeServiceLogonRight", TRUE)
!= STATUS_SUCCESS)
- return 4;
-
- _SetPrivilegeOnAccount(hPolicy, pSID, L"SeDenyInteractiveLogonRight",
TRUE);
- _SetPrivilegeOnAccount(hPolicy, pSID, L"SeDenyBatchLogonRight", TRUE);
- _SetPrivilegeOnAccount(hPolicy, pSID, L"SeDenyNetworkLogonRight", TRUE);
-
- GNLsaClose(hPolicy);
-
- return 0;
+
+ if (_OpenPolicy(NULL, POLICY_ALL_ACCESS, &hPolicy) !=
+
STATUS_SUCCESS)
+ return 3;
+
+ _GetAccountSid(NULL, pszName, &pSID);
+
+ if (_SetPrivilegeOnAccount(hPolicy, pSID, L"SeServiceLogonRight", TRUE) !=
STATUS_SUCCESS)
+ return 4;
+
+ _SetPrivilegeOnAccount(hPolicy, pSID, L"SeDenyInteractiveLogonRight", TRUE);
+ _SetPrivilegeOnAccount(hPolicy, pSID, L"SeDenyBatchLogonRight", TRUE);
+ _SetPrivilegeOnAccount(hPolicy, pSID, L"SeDenyNetworkLogonRight", TRUE);
+
+ GNLsaClose(hPolicy);
+
+ return 0;
}
/**
@@ -515,285 +515,285 @@
BOOL AddPathAccessRights(char *lpszFileName, char *lpszAccountName,
DWORD dwAccessMask)
{
- /* SID variables. */
- SID_NAME_USE snuType;
- TCHAR * szDomain = NULL;
- DWORD cbDomain = 0;
- LPVOID pUserSID = NULL;
- DWORD cbUserSID = 0;
-
- /* File SD variables. */
- PSECURITY_DESCRIPTOR pFileSD = NULL;
- DWORD cbFileSD = 0;
-
- /* New SD variables. */
- SECURITY_DESCRIPTOR newSD;
-
- /* ACL variables. */
- PACL pACL = NULL;
- BOOL fDaclPresent;
- BOOL fDaclDefaulted;
- ACL_SIZE_INFORMATION AclInfo;
-
- /* New ACL variables. */
- PACL pNewACL = NULL;
- DWORD cbNewACL = 0;
-
- /* Temporary ACE. */
- LPVOID pTempAce = NULL;
- UINT CurrentAceIndex = 0;
-
- UINT newAceIndex = 0;
-
- /* Assume function will fail. */
- BOOL fResult = FALSE;
- BOOL fAPISuccess;
-
- SECURITY_INFORMATION secInfo = DACL_SECURITY_INFORMATION;
-
- /**
- * STEP 1: Get SID of the account name specified.
- */
- fAPISuccess = GNLookupAccountName(NULL, lpszAccountName,
- pUserSID, &cbUserSID, szDomain, &cbDomain, &snuType);
-
- /* API should have failed with insufficient buffer. */
- if (fAPISuccess)
- goto end;
- else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
- goto end;
- }
-
- pUserSID = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbUserSID);
- if (!pUserSID) {
- goto end;
- }
-
- szDomain = (TCHAR *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
cbDomain * sizeof(TCHAR));
- if (!szDomain) {
- goto end;
- }
-
- fAPISuccess = GNLookupAccountName(NULL, lpszAccountName,
- pUserSID, &cbUserSID, szDomain, &cbDomain, &snuType);
- if (!fAPISuccess) {
- goto end;
- }
-
- /**
- * STEP 2: Get security descriptor (SD) of the file specified.
- */
- fAPISuccess = GNGetFileSecurity(lpszFileName,
- secInfo, pFileSD, 0, &cbFileSD);
-
- /* API should have failed with insufficient buffer. */
- if (fAPISuccess)
- goto end;
- else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
- goto end;
- }
-
- pFileSD = (PSECURITY_DESCRIPTOR) HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
- cbFileSD);
- if (!pFileSD) {
- goto end;
- }
-
- fAPISuccess = GNGetFileSecurity(lpszFileName,
- secInfo, pFileSD, cbFileSD, &cbFileSD);
- if (!fAPISuccess) {
- goto end;
- }
-
- /**
- * STEP 3: Initialize new SD.
- */
- if (!GNInitializeSecurityDescriptor(&newSD,
- SECURITY_DESCRIPTOR_REVISION)) {
- goto end;
- }
-
- /**
- * STEP 4: Get DACL from the old SD.
- */
- if (!GNGetSecurityDescriptorDacl(pFileSD, &fDaclPresent, &pACL,
- &fDaclDefaulted)) {
- goto end;
- }
-
- /**
- * STEP 5: Get size information for DACL.
- */
- AclInfo.AceCount = 0; // Assume NULL DACL.
- AclInfo.AclBytesFree = 0;
- AclInfo.AclBytesInUse = sizeof(ACL);
-
- if (pACL == NULL)
- fDaclPresent = FALSE;
-
- /* If not NULL DACL, gather size information from DACL. */
- if (fDaclPresent) {
-
- if (!GNGetAclInformation(pACL, &AclInfo,
- sizeof(ACL_SIZE_INFORMATION), AclSizeInformation)) {
- goto end;
- }
- }
-
- /**
- * STEP 6: Compute size needed for the new ACL.
- */
- cbNewACL = AclInfo.AclBytesInUse + sizeof(ACCESS_ALLOWED_ACE)
- + GetLengthSid(pUserSID) - sizeof(DWORD);
-
- /**
- * STEP 7: Allocate memory for new ACL.
- */
- pNewACL = (PACL) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
cbNewACL);
- if (!pNewACL) {
- goto end;
- }
-
- /**
- * STEP 8: Initialize the new ACL.
- */
- if (!GNInitializeAcl(pNewACL, cbNewACL, ACL_REVISION2)) {
- goto end;
- }
-
- /**
- * STEP 9 If DACL is present, copy all the ACEs from the old DACL
- * to the new DACL.
- *
- * The following code assumes that the old DACL is
- * already in Windows 2000 preferred order. To conform
- * to the new Windows 2000 preferred order, first we will
- * copy all non-inherited ACEs from the old DACL to the
- * new DACL, irrespective of the ACE type.
- */
-
- newAceIndex = 0;
-
- if (fDaclPresent && AclInfo.AceCount) {
-
- for (CurrentAceIndex = 0;
- CurrentAceIndex < AclInfo.AceCount;
- CurrentAceIndex++) {
-
- /**
- * TEP 10: Get an ACE.
- */
- if (!GNGetAce(pACL, CurrentAceIndex, &pTempAce)) {
- goto end;
- }
-
- /**
- * STEP 11: Check if it is a non-inherited ACE.
- * If it is an inherited ACE, break from the loop so
- * that the new access allowed non-inherited ACE can
- * be added in the correct position, immediately after
- * all non-inherited ACEs.
- */
- if (((ACCESS_ALLOWED_ACE *)pTempAce)->Header.AceFlags
- & INHERITED_ACE)
- break;
-
- /**
- * STEP 12: Skip adding the ACE, if the SID matches
- * with the account specified, as we are going to
- * add an access allowed ACE with a different access
- * mask.
- */
- if (GNEqualSid(pUserSID,
- &(((ACCESS_ALLOWED_ACE *)pTempAce)->SidStart)))
- continue;
-
- /**
- * STEP 13: Add the ACE to the new ACL.
- */
- if (!GNAddAce(pNewACL, ACL_REVISION, MAXDWORD, pTempAce,
- ((PACE_HEADER) pTempAce)->AceSize)) {
- goto end;
- }
-
- newAceIndex++;
- }
- }
-
- /**
- * STEP 14: Add the access-allowed ACE to the new DACL.
- * The new ACE added here will be in the correct position,
- * immediately after all existing non-inherited ACEs.
- */
- if (!GNAddAccessAllowedAce(pNewACL, ACL_REVISION2, dwAccessMask,
- pUserSID)) {
- goto end;
- }
+ /* SID variables. */
+ SID_NAME_USE snuType;
+ TCHAR * szDomain = NULL;
+ DWORD cbDomain = 0;
+ LPVOID pUserSID = NULL;
+ DWORD cbUserSID = 0;
+
+ /* File SD variables. */
+ PSECURITY_DESCRIPTOR pFileSD = NULL;
+ DWORD cbFileSD = 0;
+
+ /* New SD variables. */
+ SECURITY_DESCRIPTOR newSD;
+
+ /* ACL variables. */
+ PACL pACL = NULL;
+ BOOL fDaclPresent;
+ BOOL fDaclDefaulted;
+ ACL_SIZE_INFORMATION AclInfo;
+
+ /* New ACL variables. */
+ PACL pNewACL = NULL;
+ DWORD cbNewACL = 0;
+
+ /* Temporary ACE. */
+ LPVOID pTempAce = NULL;
+ UINT CurrentAceIndex = 0;
+
+ UINT newAceIndex = 0;
+
+ /* Assume function will fail. */
+ BOOL fResult = FALSE;
+ BOOL fAPISuccess;
+
+ SECURITY_INFORMATION secInfo = DACL_SECURITY_INFORMATION;
+
+ /**
+ * STEP 1: Get SID of the account name specified.
+ */
+ fAPISuccess = GNLookupAccountName(NULL, lpszAccountName,
+ pUserSID, &cbUserSID, szDomain, &cbDomain, &snuType);
+
+ /* API should have failed with insufficient buffer. */
+ if (fAPISuccess)
+ goto end;
+ else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ goto end;
+ }
+
+ pUserSID = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbUserSID);
+ if (!pUserSID) {
+ goto end;
+ }
+
+ szDomain = (TCHAR *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbDomain
* sizeof(TCHAR));
+ if (!szDomain) {
+ goto end;
+ }
+
+ fAPISuccess = GNLookupAccountName(NULL, lpszAccountName,
+ pUserSID, &cbUserSID, szDomain, &cbDomain, &snuType);
+ if (!fAPISuccess) {
+ goto end;
+ }
+
+ /**
+ * STEP 2: Get security descriptor (SD) of the file specified.
+ */
+ fAPISuccess = GNGetFileSecurity(lpszFileName,
+ secInfo, pFileSD, 0, &cbFileSD);
+
+ /* API should have failed with insufficient buffer. */
+ if (fAPISuccess)
+ goto end;
+ else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ goto end;
+ }
+
+ pFileSD = (PSECURITY_DESCRIPTOR) HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
+ cbFileSD);
+ if (!pFileSD) {
+ goto end;
+ }
+
+ fAPISuccess = GNGetFileSecurity(lpszFileName,
+ secInfo, pFileSD, cbFileSD, &cbFileSD);
+ if (!fAPISuccess) {
+ goto end;
+ }
+
+ /**
+ * STEP 3: Initialize new SD.
+ */
+ if (!GNInitializeSecurityDescriptor(&newSD,
+ SECURITY_DESCRIPTOR_REVISION)) {
+ goto end;
+ }
+
+ /**
+ * STEP 4: Get DACL from the old SD.
+ */
+ if (!GNGetSecurityDescriptorDacl(pFileSD, &fDaclPresent, &pACL,
+ &fDaclDefaulted)) {
+ goto end;
+ }
+
+ /**
+ * STEP 5: Get size information for DACL.
+ */
+ AclInfo.AceCount = 0; // Assume NULL DACL.
+ AclInfo.AclBytesFree = 0;
+ AclInfo.AclBytesInUse = sizeof(ACL);
+
+ if (pACL == NULL)
+ fDaclPresent = FALSE;
+
+ /* If not NULL DACL, gather size information from DACL. */
+ if (fDaclPresent) {
+
+ if (!GNGetAclInformation(pACL, &AclInfo,
+ sizeof(ACL_SIZE_INFORMATION), AclSizeInformation)) {
+ goto end;
+ }
+ }
+
+ /**
+ * STEP 6: Compute size needed for the new ACL.
+ */
+ cbNewACL = AclInfo.AclBytesInUse + sizeof(ACCESS_ALLOWED_ACE)
+ + GetLengthSid(pUserSID) - sizeof(DWORD);
+
+ /**
+ * STEP 7: Allocate memory for new ACL.
+ */
+ pNewACL = (PACL) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbNewACL);
+ if (!pNewACL) {
+ goto end;
+ }
+
+ /**
+ * STEP 8: Initialize the new ACL.
+ */
+ if (!GNInitializeAcl(pNewACL, cbNewACL, ACL_REVISION2)) {
+ goto end;
+ }
+
+ /**
+ * STEP 9 If DACL is present, copy all the ACEs from the old DACL
+ * to the new DACL.
+ *
+ * The following code assumes that the old DACL is
+ * already in Windows 2000 preferred order. To conform
+ * to the new Windows 2000 preferred order, first we will
+ * copy all non-inherited ACEs from the old DACL to the
+ * new DACL, irrespective of the ACE type.
+ */
+
+ newAceIndex = 0;
+
+ if (fDaclPresent && AclInfo.AceCount) {
+
+ for (CurrentAceIndex = 0;
+ CurrentAceIndex < AclInfo.AceCount;
+ CurrentAceIndex++) {
+
+ /**
+ * TEP 10: Get an ACE.
+ */
+ if (!GNGetAce(pACL, CurrentAceIndex, &pTempAce)) {
+ goto end;
+ }
+
+ /**
+ * STEP 11: Check if it is a non-inherited ACE.
+ * If it is an inherited ACE, break from the loop so
+ * that the new access allowed non-inherited ACE can
+ * be added in the correct position, immediately after
+ * all non-inherited ACEs.
+ */
+ if (((ACCESS_ALLOWED_ACE *)pTempAce)->Header.AceFlags
+ & INHERITED_ACE)
+ break;
+
+ /**
+ * STEP 12: Skip adding the ACE, if the SID matches
+ * with the account specified, as we are going to
+ * add an access allowed ACE with a different access
+ * mask.
+ */
+ if (GNEqualSid(pUserSID,
+ &(((ACCESS_ALLOWED_ACE *)pTempAce)->SidStart)))
+ continue;
+
+ /**
+ * STEP 13: Add the ACE to the new ACL.
+ */
+ if (!GNAddAce(pNewACL, ACL_REVISION, MAXDWORD, pTempAce,
+ ((PACE_HEADER) pTempAce)->AceSize)) {
+ goto end;
+ }
+
+ newAceIndex++;
+ }
+ }
+
+ /**
+ * STEP 14: Add the access-allowed ACE to the new DACL.
+ * The new ACE added here will be in the correct position,
+ * immediately after all existing non-inherited ACEs.
+ */
+ if (!GNAddAccessAllowedAce(pNewACL, ACL_REVISION2, dwAccessMask,
+ pUserSID)) {
+ goto end;
+ }
- /**
- * STEP 14.5: Make new ACE inheritable
- */
+ /**
+ * STEP 14.5: Make new ACE inheritable
+ */
if (!GetAce(pNewACL, newAceIndex, &pTempAce))
- goto end;
+ goto end;
((ACCESS_ALLOWED_ACE *)pTempAce)->Header.AceFlags |=
- (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE);
-
- /**
- * STEP 15: To conform to the new Windows 2000 preferred order,
- * we will now copy the rest of inherited ACEs from the
- * old DACL to the new DACL.
- */
- if (fDaclPresent && AclInfo.AceCount) {
-
- for (;
- CurrentAceIndex < AclInfo.AceCount;
- CurrentAceIndex++) {
-
- /**
- * STEP 16: Get an ACE.
- */
- if (!GNGetAce(pACL, CurrentAceIndex, &pTempAce)) {
- goto end;
- }
-
- /**
- * STEP 17: Add the ACE to the new ACL.
- */
- if (!GNAddAce(pNewACL, ACL_REVISION, MAXDWORD, pTempAce,
- ((PACE_HEADER) pTempAce)->AceSize)) {
- goto end;
- }
- }
- }
+ (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE);
+
+ /**
+ * STEP 15: To conform to the new Windows 2000 preferred order,
+ * we will now copy the rest of inherited ACEs from the
+ * old DACL to the new DACL.
+ */
+ if (fDaclPresent && AclInfo.AceCount) {
+
+ for (;
+ CurrentAceIndex < AclInfo.AceCount;
+ CurrentAceIndex++) {
+
+ /**
+ * STEP 16: Get an ACE.
+ */
+ if (!GNGetAce(pACL, CurrentAceIndex, &pTempAce)) {
+ goto end;
+ }
+
+ /**
+ * STEP 17: Add the ACE to the new ACL.
+ */
+ if (!GNAddAce(pNewACL, ACL_REVISION, MAXDWORD, pTempAce,
+ ((PACE_HEADER) pTempAce)->AceSize)) {
+ goto end;
+ }
+ }
+ }
- /**
- * STEP 18: Set permissions
- */
+ /**
+ * STEP 18: Set permissions
+ */
if (GNSetNamedSecurityInfo(lpszFileName, SE_FILE_OBJECT,
- DACL_SECURITY_INFORMATION, NULL, NULL, pNewACL, NULL) != ERROR_SUCCESS)
{
- goto end;
+ DACL_SECURITY_INFORMATION, NULL, NULL, pNewACL, NULL) != ERROR_SUCCESS) {
+ goto end;
}
-
- fResult = TRUE;
-
+
+ fResult = TRUE;
+
end:
-
- /**
- * STEP 19: Free allocated memory
- */
- if (pUserSID)
- HeapFree(GetProcessHeap(), 0, pUserSID);
-
- if (szDomain)
- HeapFree(GetProcessHeap(), 0, szDomain);
-
- if (pFileSD)
- HeapFree(GetProcessHeap(), 0, pFileSD);
-
- if (pNewACL)
- HeapFree(GetProcessHeap(), 0, pNewACL);
-
- return fResult;
+
+ /**
+ * STEP 19: Free allocated memory
+ */
+ if (pUserSID)
+ HeapFree(GetProcessHeap(), 0, pUserSID);
+
+ if (szDomain)
+ HeapFree(GetProcessHeap(), 0, szDomain);
+
+ if (pFileSD)
+ HeapFree(GetProcessHeap(), 0, pFileSD);
+
+ if (pNewACL)
+ HeapFree(GetProcessHeap(), 0, pNewACL);
+
+ return fResult;
}
char *winErrorStr(const char *prefix, int dwErr)
Modified: GNUnet/src/util/win/winproc.c
===================================================================
--- GNUnet/src/util/win/winproc.c 2007-07-05 19:56:14 UTC (rev 5248)
+++ GNUnet/src/util/win/winproc.c 2007-07-05 21:12:30 UTC (rev 5249)
@@ -86,14 +86,14 @@
*/
int InitWinEnv(struct GE_Context *ectx)
{
- int ret, init;
+ int ret, init;
if (ectx)
pEctx = ectx;
-
+
init = plibc_initialized();
plibc_set_panic_proc(plibc_panic);
- ret = plibc_init("GNU", PACKAGE);
+ ret = plibc_init("GNU", PACKAGE);
/* don't load other DLLs twice */
if (init)
@@ -123,7 +123,7 @@
GNGetBestInterface = (TGetBestInterface) GetProcAddress(hIphlpapi,
"GetBestInterface");
GGetAdaptersInfo = (TGetAdaptersInfo) GetProcAddress(hIphlpapi,
- "GetAdaptersInfo");
+ "GetAdaptersInfo");
}
else
{
@@ -157,37 +157,37 @@
GNOpenService = (TOpenService)
GetProcAddress(hAdvapi, "OpenServiceA");
- GNLsaOpenPolicy = (TLsaOpenPolicy)
- GetProcAddress(hAdvapi, "LsaOpenPolicy");
- GNLsaAddAccountRights = (TLsaAddAccountRights)
- GetProcAddress(hAdvapi, "LsaAddAccountRights");
- GNLsaRemoveAccountRights = (TLsaRemoveAccountRights)
- GetProcAddress(hAdvapi, "LsaRemoveAccountRights");
- GNLsaClose = (TLsaClose)
- GetProcAddress(hAdvapi, "LsaClose");
- GNLookupAccountName = (TLookupAccountName)
- GetProcAddress(hAdvapi, "LookupAccountNameA");
+ GNLsaOpenPolicy = (TLsaOpenPolicy)
+ GetProcAddress(hAdvapi, "LsaOpenPolicy");
+ GNLsaAddAccountRights = (TLsaAddAccountRights)
+ GetProcAddress(hAdvapi, "LsaAddAccountRights");
+ GNLsaRemoveAccountRights = (TLsaRemoveAccountRights)
+ GetProcAddress(hAdvapi, "LsaRemoveAccountRights");
+ GNLsaClose = (TLsaClose)
+ GetProcAddress(hAdvapi, "LsaClose");
+ GNLookupAccountName = (TLookupAccountName)
+ GetProcAddress(hAdvapi, "LookupAccountNameA");
- GNGetFileSecurity = (TGetFileSecurity)
- GetProcAddress(hAdvapi, "GetFileSecurityA");
- GNInitializeSecurityDescriptor = (TInitializeSecurityDescriptor)
- GetProcAddress(hAdvapi, "InitializeSecurityDescriptor");
- GNGetSecurityDescriptorDacl = (TGetSecurityDescriptorDacl)
- GetProcAddress(hAdvapi, "GetSecurityDescriptorDacl");
- GNGetAclInformation = (TGetAclInformation)
- GetProcAddress(hAdvapi, "GetAclInformation");
- GNInitializeAcl = (TInitializeAcl)
- GetProcAddress(hAdvapi, "InitializeAcl");
- GNGetAce = (TGetAce)
- GetProcAddress(hAdvapi, "GetAce");
- GNEqualSid = (TEqualSid)
- GetProcAddress(hAdvapi, "EqualSid");
- GNAddAce = (TAddAce)
- GetProcAddress(hAdvapi, "AddAce");
- GNAddAccessAllowedAce = (TAddAccessAllowedAce)
- GetProcAddress(hAdvapi, "AddAccessAllowedAce");
- GNSetNamedSecurityInfo = (TSetNamedSecurityInfo)
- GetProcAddress(hAdvapi, "SetNamedSecurityInfoA");
+ GNGetFileSecurity = (TGetFileSecurity)
+ GetProcAddress(hAdvapi, "GetFileSecurityA");
+ GNInitializeSecurityDescriptor = (TInitializeSecurityDescriptor)
+ GetProcAddress(hAdvapi, "InitializeSecurityDescriptor");
+ GNGetSecurityDescriptorDacl = (TGetSecurityDescriptorDacl)
+ GetProcAddress(hAdvapi, "GetSecurityDescriptorDacl");
+ GNGetAclInformation = (TGetAclInformation)
+ GetProcAddress(hAdvapi, "GetAclInformation");
+ GNInitializeAcl = (TInitializeAcl)
+ GetProcAddress(hAdvapi, "InitializeAcl");
+ GNGetAce = (TGetAce)
+ GetProcAddress(hAdvapi, "GetAce");
+ GNEqualSid = (TEqualSid)
+ GetProcAddress(hAdvapi, "EqualSid");
+ GNAddAce = (TAddAce)
+ GetProcAddress(hAdvapi, "AddAce");
+ GNAddAccessAllowedAce = (TAddAccessAllowedAce)
+ GetProcAddress(hAdvapi, "AddAccessAllowedAce");
+ GNSetNamedSecurityInfo = (TSetNamedSecurityInfo)
+ GetProcAddress(hAdvapi, "SetNamedSecurityInfoA");
}
else
{
@@ -201,37 +201,37 @@
GNControlService = NULL;
GNOpenService = NULL;
- GNLsaOpenPolicy = NULL;
- GNLsaAddAccountRights = NULL;
- GNLsaRemoveAccountRights = NULL;
- GNLsaClose = NULL;
- GNLookupAccountName = NULL;
+ GNLsaOpenPolicy = NULL;
+ GNLsaAddAccountRights = NULL;
+ GNLsaRemoveAccountRights = NULL;
+ GNLsaClose = NULL;
+ GNLookupAccountName = NULL;
- GNGetFileSecurity = NULL;
- GNInitializeSecurityDescriptor = NULL;
- GNGetSecurityDescriptorDacl = NULL;
- GNGetAclInformation = NULL;
- GNInitializeAcl = NULL;
- GNGetAce = NULL;
- GNEqualSid = NULL;
- GNAddAce = NULL;
- GNAddAccessAllowedAce = NULL;
- GNSetNamedSecurityInfo = NULL;
+ GNGetFileSecurity = NULL;
+ GNInitializeSecurityDescriptor = NULL;
+ GNGetSecurityDescriptorDacl = NULL;
+ GNGetAclInformation = NULL;
+ GNInitializeAcl = NULL;
+ GNGetAce = NULL;
+ GNEqualSid = NULL;
+ GNAddAce = NULL;
+ GNAddAccessAllowedAce = NULL;
+ GNSetNamedSecurityInfo = NULL;
}
/* Account function */
hNetapi = LoadLibrary("netapi32.dll");
if (hNetapi)
{
- GNNetUserAdd = (TNetUserAdd)
- GetProcAddress(hNetapi, "NetUserAdd");
- GNNetUserSetInfo = (TNetUserSetInfo)
- GetProcAddress(hNetapi, "NetUserSetInfo");
+ GNNetUserAdd = (TNetUserAdd)
+ GetProcAddress(hNetapi, "NetUserAdd");
+ GNNetUserSetInfo = (TNetUserSetInfo)
+ GetProcAddress(hNetapi, "NetUserSetInfo");
}
else
{
- GNNetUserAdd = NULL;
- GNNetUserSetInfo = NULL;
+ GNNetUserAdd = NULL;
+ GNNetUserSetInfo = NULL;
}
return ret;
@@ -242,7 +242,7 @@
*/
void ShutdownWinEnv()
{
- plibc_shutdown();
+ plibc_shutdown();
FreeLibrary(hNTDLL);
FreeLibrary(hIphlpapi);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5249 - in GNUnet/src: applications/advertising applications/bootstrap_http applications/chat applications/datastore applications/dht/module applications/dht/tools applications/dstore applications/fragmentation applications/fs applications/fs/collection applications/fs/ecrs applications/fs/fsui applications/fs/lib applications/fs/module applications/fs/namespace applications/fs/tools applications/fs/uritrack applications/gap applications/getoption applications/identity applications/kvstore_sqlite applications/pingpong applications/rpc applications/session applications/sqstore_mysql applications/sqstore_mysql_embedded applications/sqstore_sqlite applications/state applications/stats applications/tbench applications/template applications/testbed applications/testing applications/topology_default applications/topology_f2f applications/tracekit applications/traffic applications/transport applications/vpn server setup setup/gtk setup/lib setup/ncurses setup/text transports transports/upnp util/boot util/config util/config_impl util/containers util/cron util/crypto util/disk util/error util/getopt util/loggers util/network util/network_client util/os util/string util/threads util/win,
gnunet <=