gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r5742 - in GNUnet: . libltdl src/applications/advertising s


From: gnunet
Subject: [GNUnet-SVN] r5742 - in GNUnet: . libltdl src/applications/advertising src/applications/bootstrap_http src/applications/chat src/applications/datastore src/applications/dht/module src/applications/dht/tools src/applications/dstore src/applications/fragmentation src/applications/fs src/applications/fs/collection src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/lib src/applications/fs/module src/applications/fs/namespace src/applications/fs/tools src/applications/fs/uritrack src/applications/gap src/applications/getoption src/applications/identity src/applications/kvstore_sqlite src/applications/pingpong src/applications/rpc src/applications/session src/applications/sqstore_mysql src/applications/sqstore_sqlite src/applications/state src/applications/stats src/applications/tbench src/applications/template src/applications/testbed src/applications/testing src/applications/topology_default src/applications/topology_f2f src/applications/tracekit src/applications/traffic src/applications/transport src/applications/vpn src/include src/server src/setup src/setup/gtk src/setup/lib src/setup/ncurses src/setup/text src/transports src/transports/upnp src/util src/util/boot src/util/config src/util/config_impl src/util/containers src/util/cron src/util/crypto src/util/disk src/util/error src/util/getopt src/util/loggers src/util/network src/util/network_client src/util/os src/util/string src/util/threads src/util/win
Date: Fri, 23 Nov 2007 04:51:59 -0700 (MST)

Author: grothoff
Date: 2007-11-23 04:51:54 -0700 (Fri, 23 Nov 2007)
New Revision: 5742

Added:
   GNUnet/src/util/config/configtest.c
   GNUnet/src/util/config/testconfig.conf
Removed:
   GNUnet/src/include/gnunet_util_config_impl.h
   GNUnet/src/util/containers/hashtable.c
   GNUnet/src/util/containers/hashtabletest.c
Modified:
   GNUnet/ChangeLog
   GNUnet/libltdl/ltdl.c
   GNUnet/libltdl/ltdl.h
   GNUnet/src/applications/advertising/Makefile.am
   GNUnet/src/applications/advertising/advertising.c
   GNUnet/src/applications/advertising/advertising_test.c
   GNUnet/src/applications/advertising/bootstrap.c
   GNUnet/src/applications/bootstrap_http/Makefile.am
   GNUnet/src/applications/bootstrap_http/http.c
   GNUnet/src/applications/bootstrap_http/httptest.c
   GNUnet/src/applications/chat/Makefile.am
   GNUnet/src/applications/chat/chat.c
   GNUnet/src/applications/chat/chat.h
   GNUnet/src/applications/chat/clientapi.c
   GNUnet/src/applications/chat/gnunet-chat.c
   GNUnet/src/applications/datastore/Makefile.am
   GNUnet/src/applications/datastore/datastore.c
   GNUnet/src/applications/datastore/filter.c
   GNUnet/src/applications/datastore/filter.h
   GNUnet/src/applications/datastore/prefetch.c
   GNUnet/src/applications/datastore/prefetch.h
   GNUnet/src/applications/dht/module/Makefile.am
   GNUnet/src/applications/dht/module/cs.c
   GNUnet/src/applications/dht/module/dstore.c
   GNUnet/src/applications/dht/module/dstore.h
   GNUnet/src/applications/dht/module/routing.c
   GNUnet/src/applications/dht/module/routing.h
   GNUnet/src/applications/dht/module/service.c
   GNUnet/src/applications/dht/module/table.c
   GNUnet/src/applications/dht/module/table.h
   GNUnet/src/applications/dht/tools/Makefile.am
   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/Makefile.am
   GNUnet/src/applications/dstore/dstore.c
   GNUnet/src/applications/dstore/dstore_test.c
   GNUnet/src/applications/fragmentation/Makefile.am
   GNUnet/src/applications/fragmentation/fragmentation.c
   GNUnet/src/applications/fragmentation/fragmentationtest.c
   GNUnet/src/applications/fs/Makefile.am
   GNUnet/src/applications/fs/collection/Makefile.am
   GNUnet/src/applications/fs/collection/collection.c
   GNUnet/src/applications/fs/collection/collectiontest.c
   GNUnet/src/applications/fs/ecrs/Makefile.am
   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/downloadtest.c
   GNUnet/src/applications/fs/ecrs/ecrs.c
   GNUnet/src/applications/fs/ecrs/ecrs.h
   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/tree.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/Makefile.am
   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/fsui.h
   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/Makefile.am
   GNUnet/src/applications/fs/lib/fslib.c
   GNUnet/src/applications/fs/lib/fslibtest.c
   GNUnet/src/applications/fs/module/Makefile.am
   GNUnet/src/applications/fs/module/anonymity.c
   GNUnet/src/applications/fs/module/anonymity.h
   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/migration.h
   GNUnet/src/applications/fs/module/ondemand.c
   GNUnet/src/applications/fs/module/ondemand.h
   GNUnet/src/applications/fs/module/querymanager.c
   GNUnet/src/applications/fs/module/querymanager.h
   GNUnet/src/applications/fs/namespace/Makefile.am
   GNUnet/src/applications/fs/namespace/namespace_info.c
   GNUnet/src/applications/fs/namespace/namespace_infotest.c
   GNUnet/src/applications/fs/tools/Makefile.am
   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/Makefile.am
   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/Makefile.am
   GNUnet/src/applications/gap/gap.c
   GNUnet/src/applications/gap/gap.h
   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/gap/pid_table.h
   GNUnet/src/applications/getoption/Makefile.am
   GNUnet/src/applications/getoption/clientapi.c
   GNUnet/src/applications/getoption/getoption.c
   GNUnet/src/applications/getoption/getoption.h
   GNUnet/src/applications/identity/Makefile.am
   GNUnet/src/applications/identity/clientapi.c
   GNUnet/src/applications/identity/hostkey.c
   GNUnet/src/applications/identity/hostkey.h
   GNUnet/src/applications/identity/identity.c
   GNUnet/src/applications/identity/identity.h
   GNUnet/src/applications/identity/identitytest.c
   GNUnet/src/applications/kvstore_sqlite/Makefile.am
   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/Makefile.am
   GNUnet/src/applications/rpc/parameters.c
   GNUnet/src/applications/rpc/parameterstest.c
   GNUnet/src/applications/rpc/rpc.c
   GNUnet/src/applications/session/Makefile.am
   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/Makefile.am
   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_sqlite/Makefile.am
   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/Makefile.am
   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/stats/statistics.h
   GNUnet/src/applications/tbench/Makefile.am
   GNUnet/src/applications/tbench/gnunet-tbench.c
   GNUnet/src/applications/tbench/tbench.c
   GNUnet/src/applications/tbench/tbench.h
   GNUnet/src/applications/tbench/tbenchtest.c
   GNUnet/src/applications/template/Makefile.am
   GNUnet/src/applications/template/gnunet-template.c
   GNUnet/src/applications/template/template.c
   GNUnet/src/applications/testbed/commands.c
   GNUnet/src/applications/testbed/commands.h
   GNUnet/src/applications/testbed/gnunet-testbed.c
   GNUnet/src/applications/testbed/socket.c
   GNUnet/src/applications/testbed/testbed.c
   GNUnet/src/applications/testbed/testbed.h
   GNUnet/src/applications/testing/Makefile.am
   GNUnet/src/applications/testing/testing.c
   GNUnet/src/applications/testing/testingtest.c
   GNUnet/src/applications/topology_default/Makefile.am
   GNUnet/src/applications/topology_default/topology.c
   GNUnet/src/applications/topology_f2f/Makefile.am
   GNUnet/src/applications/topology_f2f/topology.c
   GNUnet/src/applications/tracekit/Makefile.am
   GNUnet/src/applications/tracekit/gnunet-tracekit.c
   GNUnet/src/applications/tracekit/tracekit.c
   GNUnet/src/applications/tracekit/tracekit.h
   GNUnet/src/applications/traffic/Makefile.am
   GNUnet/src/applications/traffic/clientapi.c
   GNUnet/src/applications/traffic/traffic.c
   GNUnet/src/applications/traffic/traffic.h
   GNUnet/src/applications/transport/Makefile.am
   GNUnet/src/applications/transport/check.c
   GNUnet/src/applications/transport/transport.c
   GNUnet/src/applications/vpn/Makefile.am
   GNUnet/src/applications/vpn/gnunet-vpn.c
   GNUnet/src/applications/vpn/vpn.c
   GNUnet/src/include/Makefile.am
   GNUnet/src/include/core.h
   GNUnet/src/include/dht.h
   GNUnet/src/include/ecrs_core.h
   GNUnet/src/include/fs.h
   GNUnet/src/include/gettext.h
   GNUnet/src/include/gnunet_blockstore.h
   GNUnet/src/include/gnunet_bootstrap_service.h
   GNUnet/src/include/gnunet_chat_lib.h
   GNUnet/src/include/gnunet_collection_lib.h
   GNUnet/src/include/gnunet_core.h
   GNUnet/src/include/gnunet_datastore_service.h
   GNUnet/src/include/gnunet_dht_lib.h
   GNUnet/src/include/gnunet_dht_service.h
   GNUnet/src/include/gnunet_dstore_service.h
   GNUnet/src/include/gnunet_ecrs_lib.h
   GNUnet/src/include/gnunet_fragmentation_service.h
   GNUnet/src/include/gnunet_fs_lib.h
   GNUnet/src/include/gnunet_fsui_lib.h
   GNUnet/src/include/gnunet_gap_service.h
   GNUnet/src/include/gnunet_getoption_lib.h
   GNUnet/src/include/gnunet_identity_lib.h
   GNUnet/src/include/gnunet_identity_service.h
   GNUnet/src/include/gnunet_kvstore_service.h
   GNUnet/src/include/gnunet_namespace_lib.h
   GNUnet/src/include/gnunet_peerinfo_lib.h
   GNUnet/src/include/gnunet_pingpong_service.h
   GNUnet/src/include/gnunet_protocols.h
   GNUnet/src/include/gnunet_rpc_service.h
   GNUnet/src/include/gnunet_session_service.h
   GNUnet/src/include/gnunet_sqstore_service.h
   GNUnet/src/include/gnunet_state_service.h
   GNUnet/src/include/gnunet_stats_lib.h
   GNUnet/src/include/gnunet_testing_lib.h
   GNUnet/src/include/gnunet_topology_service.h
   GNUnet/src/include/gnunet_traffic_lib.h
   GNUnet/src/include/gnunet_traffic_service.h
   GNUnet/src/include/gnunet_transport.h
   GNUnet/src/include/gnunet_transport_service.h
   GNUnet/src/include/gnunet_upnp_service.h
   GNUnet/src/include/gnunet_uritrack_lib.h
   GNUnet/src/include/gnunet_util.h
   GNUnet/src/include/gnunet_util_boot.h
   GNUnet/src/include/gnunet_util_common.h
   GNUnet/src/include/gnunet_util_config.h
   GNUnet/src/include/gnunet_util_containers.h
   GNUnet/src/include/gnunet_util_core.h
   GNUnet/src/include/gnunet_util_cron.h
   GNUnet/src/include/gnunet_util_crypto.h
   GNUnet/src/include/gnunet_util_disk.h
   GNUnet/src/include/gnunet_util_error.h
   GNUnet/src/include/gnunet_util_error_loggers.h
   GNUnet/src/include/gnunet_util_getopt.h
   GNUnet/src/include/gnunet_util_network.h
   GNUnet/src/include/gnunet_util_network_client.h
   GNUnet/src/include/gnunet_util_os.h
   GNUnet/src/include/gnunet_util_string.h
   GNUnet/src/include/gnunet_util_threads.h
   GNUnet/src/include/platform.h
   GNUnet/src/include/plibc.h
   GNUnet/src/server/Makefile.am
   GNUnet/src/server/connection.c
   GNUnet/src/server/connection.h
   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/handler.h
   GNUnet/src/server/startup.c
   GNUnet/src/server/tcpserver.c
   GNUnet/src/server/tcpserver.h
   GNUnet/src/server/version.c
   GNUnet/src/server/version.h
   GNUnet/src/setup/Makefile.am
   GNUnet/src/setup/gnunet-setup.c
   GNUnet/src/setup/gnunet-win-tool.c
   GNUnet/src/setup/gtk/gconf.c
   GNUnet/src/setup/gtk/gconf.h
   GNUnet/src/setup/gtk/glade_support.c
   GNUnet/src/setup/gtk/glade_support.h
   GNUnet/src/setup/gtk/ngconf.c
   GNUnet/src/setup/gtk/wizard_gtk.c
   GNUnet/src/setup/gtk/wizard_gtk.h
   GNUnet/src/setup/lib/Makefile.am
   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/mconf.h
   GNUnet/src/setup/ncurses/wizard_curs.c
   GNUnet/src/setup/ncurses/wizard_curs.h
   GNUnet/src/setup/text/conf.c
   GNUnet/src/setup/text/conf.h
   GNUnet/src/transports/Makefile.am
   GNUnet/src/transports/http.c
   GNUnet/src/transports/ip.c
   GNUnet/src/transports/ip.h
   GNUnet/src/transports/ip6.c
   GNUnet/src/transports/ip6.h
   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/test.c
   GNUnet/src/transports/test_repeat.c
   GNUnet/src/transports/udp.c
   GNUnet/src/transports/udp6.c
   GNUnet/src/transports/udp_helper.c
   GNUnet/src/transports/upnp/Makefile.am
   GNUnet/src/transports/upnp/init.c
   GNUnet/src/transports/upnp/ip.c
   GNUnet/src/transports/upnp/upnp.c
   GNUnet/src/transports/upnp/upnp.h
   GNUnet/src/transports/upnp/upnptest.c
   GNUnet/src/transports/upnp/util.c
   GNUnet/src/transports/upnp/xmlnode.c
   GNUnet/src/util/Makefile.am
   GNUnet/src/util/README
   GNUnet/src/util/boot/Makefile.am
   GNUnet/src/util/boot/startup.c
   GNUnet/src/util/config/Makefile.am
   GNUnet/src/util/config/config.c
   GNUnet/src/util/config_impl/Makefile.am
   GNUnet/src/util/config_impl/configtest.c
   GNUnet/src/util/config_impl/impl.c
   GNUnet/src/util/containers/Makefile.am
   GNUnet/src/util/containers/bloomfilter.c
   GNUnet/src/util/containers/bloomtest.c
   GNUnet/src/util/containers/hashtest.c
   GNUnet/src/util/containers/vector.c
   GNUnet/src/util/containers/vectortest.c
   GNUnet/src/util/cron/Makefile.am
   GNUnet/src/util/cron/cron.c
   GNUnet/src/util/cron/crontest.c
   GNUnet/src/util/cron/timertest.c
   GNUnet/src/util/crypto/Makefile.am
   GNUnet/src/util/crypto/crc32.c
   GNUnet/src/util/crypto/crctest.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/Makefile.am
   GNUnet/src/util/loggers/file.c
   GNUnet/src/util/loggers/memory.c
   GNUnet/src/util/network/dns.c
   GNUnet/src/util/network/endian.c
   GNUnet/src/util/network/io.c
   GNUnet/src/util/network/ip.c
   GNUnet/src/util/network/ipcheck.c
   GNUnet/src/util/network/ipchecktest.c
   GNUnet/src/util/network/network.h
   GNUnet/src/util/network/select.c
   GNUnet/src/util/network/selecttest.c
   GNUnet/src/util/network_client/Makefile.am
   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/Makefile.am
   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/init.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/time.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/shutdown.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
Log:
the big alpha

Modified: GNUnet/ChangeLog
===================================================================
--- GNUnet/ChangeLog    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/ChangeLog    2007-11-23 11:51:54 UTC (rev 5742)
@@ -1,3 +1,8 @@
+Thu Nov 22 20:49:16 MST 2007
+       United all libgnunetutil_*.so libraries into one big
+       libgnunetutil.so library (eliminates issues for binary
+       packagers and reduces file size by about 20%).
+
 Sat Sep 29 16:48:24 MDT 2007
        Improved MySQL sqstore module performance.
        Releasing GNUnet 0.7.2c.

Modified: GNUnet/libltdl/ltdl.c
===================================================================
--- GNUnet/libltdl/ltdl.c       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/libltdl/ltdl.c       2007-11-23 11:51:54 UTC (rev 5742)
@@ -42,7 +42,7 @@
 #if HAVE_STDLIB_H
 #  include <stdlib.h>
 #else
-#  if HAVE_MALLOC_H
+#  if HAVE_GNUNET_malloc_H
 #    include <malloc.h>
 #  endif
 #endif
@@ -128,7 +128,7 @@
 
 #include "ltdl.h"
 
-#if WITH_DMALLOC
+#if WITH_DGNUNET_malloc
 #  include <dmalloc.h>
 #endif
 
@@ -228,25 +228,25 @@
 
 /* The following macros reduce the amount of typing needed to cast
    assigned memory.  */
-#if WITH_DMALLOC
+#if WITH_DGNUNET_malloc
 
-#define LT_DLMALLOC(tp, n)     ((tp *) xmalloc ((n) * sizeof(tp)))
-#define LT_DLREALLOC(tp, p, n) ((tp *) xrealloc ((p), (n) * sizeof(tp)))
-#define LT_DLFREE(p)                                           \
+#define LT_DLGNUNET_malloc(tp, n)      ((tp *) xmalloc ((n) * sizeof(tp)))
+#define LT_DLGNUNET_realloc(tp, p, n)  ((tp *) xrealloc ((p), (n) * 
sizeof(tp)))
+#define LT_DLGNUNET_free(p)                                            \
        LT_STMT_START { if (p) (p) = (xfree (p), (lt_ptr) 0); } LT_STMT_END
 
-#define LT_EMALLOC(tp, n)      ((tp *) xmalloc ((n) * sizeof(tp)))
-#define LT_EREALLOC(tp, p, n)  ((tp *) xrealloc ((p), (n) * sizeof(tp)))
+#define LT_EGNUNET_malloc(tp, n)       ((tp *) xmalloc ((n) * sizeof(tp)))
+#define LT_EGNUNET_realloc(tp, p, n)   ((tp *) xrealloc ((p), (n) * 
sizeof(tp)))
 
 #else
 
-#define LT_DLMALLOC(tp, n)     ((tp *) lt_dlmalloc ((n) * sizeof(tp)))
-#define LT_DLREALLOC(tp, p, n) ((tp *) lt_dlrealloc ((p), (n) * sizeof(tp)))
-#define LT_DLFREE(p)                                           \
+#define LT_DLGNUNET_malloc(tp, n)      ((tp *) lt_dlmalloc ((n) * sizeof(tp)))
+#define LT_DLGNUNET_realloc(tp, p, n)  ((tp *) lt_dlrealloc ((p), (n) * 
sizeof(tp)))
+#define LT_DLGNUNET_free(p)                                            \
        LT_STMT_START { if (p) (p) = (lt_dlfree (p), (lt_ptr) 0); } LT_STMT_END
 
-#define LT_EMALLOC(tp, n)      ((tp *) lt_emalloc ((n) * sizeof(tp)))
-#define LT_EREALLOC(tp, p, n)  ((tp *) lt_erealloc ((p), (n) * sizeof(tp)))
+#define LT_EGNUNET_malloc(tp, n)       ((tp *) lt_emalloc ((n) * sizeof(tp)))
+#define LT_EGNUNET_realloc(tp, p, n)   ((tp *) lt_erealloc ((p), (n) * 
sizeof(tp)))
 
 #endif
 
@@ -270,7 +270,7 @@
 
   if (str)
     {
-      tmp = LT_DLMALLOC (char, 1 + strlen (str));
+      tmp = LT_DLGNUNET_malloc (char, 1 + strlen (str));
       if (tmp)
         {
           strcpy (tmp, str);
@@ -463,7 +463,7 @@
   (void) strncpy (file_specification, path, LT_FILENAME_MAX - 6);
   file_specification[LT_FILENAME_MAX - 6] = LT_EOS_CHAR;
   (void) strcat (file_specification, "\\");
-  entry = LT_DLMALLOC (DIR, sizeof (DIR));
+  entry = LT_DLGNUNET_malloc (DIR, sizeof (DIR));
   if (entry != (DIR *) 0)
     {
       entry->firsttime = TRUE;
@@ -477,7 +477,7 @@
         FindFirstFile (file_specification, &entry->Win32FindData);
       if (entry->hSearch == INVALID_HANDLE_VALUE)
         {
-          LT_DLFREE (entry);
+          LT_DLGNUNET_free (entry);
           return (DIR *) 0;
         }
     }
@@ -567,7 +567,7 @@
 #endif
 
 
-#if ! HAVE_ARGZ_APPEND
+#if ! HAVE_ARGZ_GNUNET_array_append
 #  define argz_append rpl_argz_append
 
 static error_t argz_append LT_PARAMS ((char **pargz, size_t * pargz_len,
@@ -593,7 +593,7 @@
 
   /* Ensure there is enough room to append BUF_LEN.  */
   argz_len = *pargz_len + buf_len;
-  argz = LT_DLREALLOC (char, *pargz, argz_len);
+  argz = LT_DLGNUNET_realloc (char, *pargz, argz_len);
   if (!argz)
     return ENOMEM;
 
@@ -606,7 +606,7 @@
 
   return 0;
 }
-#endif /* !HAVE_ARGZ_APPEND */
+#endif /* !HAVE_ARGZ_GNUNET_array_append */
 
 
 #if ! HAVE_ARGZ_CREATE_SEP
@@ -637,7 +637,7 @@
       const char *p;
       char *q;
 
-      argz = LT_DLMALLOC (char, argz_len);
+      argz = LT_DLGNUNET_malloc (char, argz_len);
       if (!argz)
         return ENOMEM;
 
@@ -661,7 +661,7 @@
 
   /* If ARGZ_LEN has shrunk to nothing, release ARGZ's memory.  */
   if (!argz_len)
-    LT_DLFREE (argz);
+    LT_DLGNUNET_free (argz);
 
   /* Assign new values.  */
   *pargz = argz;
@@ -704,7 +704,7 @@
     size_t entry_len = 1 + LT_STRLEN (entry);
     size_t argz_len = *pargz_len + entry_len;
     size_t offset = before - *pargz;
-    char *argz = LT_DLREALLOC (char, *pargz, argz_len);
+    char *argz = LT_DLGNUNET_realloc (char, *pargz, argz_len);
 
     if (!argz)
       return ENOMEM;
@@ -879,7 +879,7 @@
 
 
 
-/* --- MUTEX LOCKING --- */
+/* --- GNUNET_Mutex LOCKING --- */
 
 
 /* Macros to make it easier to run the lock functions only if they have
@@ -887,10 +887,10 @@
    ensure that the stored error message from the last error is not
    accidentally erased if the current function doesn't generate an
    error of its own.  */
-#define LT_DLMUTEX_LOCK()                      LT_STMT_START { \
+#define LT_DLGNUNET_mutex_lock()                       LT_STMT_START { \
        if (lt_dlmutex_lock_func) (*lt_dlmutex_lock_func)();    \
                                                } LT_STMT_END
-#define LT_DLMUTEX_UNLOCK()                    LT_STMT_START { \
+#define LT_DLGNUNET_mutex_unlock()                     LT_STMT_START { \
        if (lt_dlmutex_unlock_func) (*lt_dlmutex_unlock_func)();\
                                                } LT_STMT_END
 #define LT_DLMUTEX_SETERROR(errormsg)          LT_STMT_START { \
@@ -926,7 +926,7 @@
   int errors = 0;
 
   /* Lock using the old lock() callback, if any.  */
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   if ((lock && unlock && seterror && geterror)
       || !(lock || unlock || seterror || geterror))
@@ -970,10 +970,10 @@
 
   assert (diagnostic);
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   errindex = errorcount - LT_ERROR_MAX;
-  temp = LT_EREALLOC (const char *, user_error_strings, 1 + errindex);
+  temp = LT_EGNUNET_realloc (const char *, user_error_strings, 1 + errindex);
   if (temp)
     {
       user_error_strings = temp;
@@ -981,7 +981,7 @@
       result = errorcount++;
     }
 
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return result;
 }
@@ -992,7 +992,7 @@
 {
   int errors = 0;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   if (errindex >= errorcount || errindex < 0)
     {
@@ -1011,7 +1011,7 @@
       LT_DLMUTEX_SETERROR (user_error_strings[errindex - LT_ERROR_MAX]);
     }
 
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return errors;
 }
@@ -1335,7 +1335,7 @@
     {
       /* Append a `.' to stop Windows from adding an
          implicit `.dll' extension. */
-      searchname = LT_EMALLOC (char, 2 + LT_STRLEN (filename));
+      searchname = LT_EGNUNET_malloc (char, 2 + LT_STRLEN (filename));
       if (searchname)
         sprintf (searchname, "%s.", filename);
     }
@@ -1363,7 +1363,7 @@
     SetErrorMode (errormode);
   }
 
-  LT_DLFREE (searchname);
+  LT_DLGNUNET_free (searchname);
 
   /* libltdl expects this function to fail if it is unable
      to physically load the library.  Sadly, LoadLibrary
@@ -1373,7 +1373,7 @@
      We check whether LoadLibrary is returning a handle to
      an already loaded module, and simulate failure if we
      find one. */
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   cur = handles;
   while (cur)
     {
@@ -1390,7 +1390,7 @@
 
       cur = cur->next;
     }
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   if (cur || !module)
     {
@@ -1543,7 +1543,7 @@
   if (dld_link (filename) != 0)
     {
       LT_DLMUTEX_SETERROR (LT_DLSTRERROR (CANNOT_OPEN));
-      LT_DLFREE (module);
+      LT_DLGNUNET_free (module);
       module = 0;
     }
 
@@ -1564,7 +1564,7 @@
     }
   else
     {
-      LT_DLFREE (module);
+      LT_DLGNUNET_free (module);
     }
 
   return errors;
@@ -2003,7 +2003,7 @@
 {
   int errors = 0;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   preloaded_symbols = 0;
   if (default_preloaded_symbols)
@@ -2011,7 +2011,7 @@
       errors = lt_dlpreload (default_preloaded_symbols);
     }
 
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return errors;
 }
@@ -2021,7 +2021,7 @@
 {
   lt_dlsymlists_t *lists;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   lists = preloaded_symbols;
   while (lists)
@@ -2029,11 +2029,11 @@
       lt_dlsymlists_t *tmp = lists;
 
       lists = lists->next;
-      LT_DLFREE (tmp);
+      LT_DLGNUNET_free (tmp);
     }
   preloaded_symbols = 0;
 
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return 0;
 }
@@ -2054,7 +2054,7 @@
   lt_dlsymlists_t *lists;
   int errors = 0;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   lists = preloaded_symbols;
   while (lists)
@@ -2066,7 +2066,7 @@
       lists = lists->next;
     }
 
-  tmp = LT_EMALLOC (lt_dlsymlists_t, 1);
+  tmp = LT_EGNUNET_malloc (lt_dlsymlists_t, 1);
   if (tmp)
     {
       memset (tmp, 0, sizeof (lt_dlsymlists_t));
@@ -2080,7 +2080,7 @@
     }
 
 done:
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
   return errors;
 }
 
@@ -2092,7 +2092,7 @@
   lt_dlsymlists_t *lists;
   lt_module module = (lt_module) 0;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   lists = preloaded_symbols;
 
   if (!lists)
@@ -2130,7 +2130,7 @@
   LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FILE_NOT_FOUND));
 
 done:
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
   return module;
 }
 
@@ -2246,7 +2246,7 @@
 {
   int errors = 0;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   /* Initialize only at first call. */
   if (++initialized == 1)
@@ -2287,7 +2287,7 @@
         }
     }
 
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return errors;
 }
@@ -2306,12 +2306,12 @@
     {
       presym_free_symlists ();
 
-      LT_DLMUTEX_LOCK ();
+      LT_DLGNUNET_mutex_lock ();
       if (default_preloaded_symbols)
         {
           errors = lt_dlpreload (default_preloaded_symbols);
         }
-      LT_DLMUTEX_UNLOCK ();
+      LT_DLGNUNET_mutex_unlock ();
     }
 
   return errors;
@@ -2321,9 +2321,9 @@
 lt_dlpreload_default (preloaded)
      const lt_dlsymlist *preloaded;
 {
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   default_preloaded_symbols = preloaded;
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
   return 0;
 }
 
@@ -2334,7 +2334,7 @@
   lt_dlloader *loader;
   int errors = 0;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   loader = loaders;
 
   if (!initialized)
@@ -2395,7 +2395,7 @@
     }
 
 done:
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
   return errors;
 }
 
@@ -2410,7 +2410,7 @@
   int errors = 0;
 
   LT_DLMUTEX_GETERROR (saved_error);
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   cur = handles;
   loader = loaders;
@@ -2482,7 +2482,7 @@
 
   if (!loader)
     {
-      LT_DLFREE (cur->info.filename);
+      LT_DLGNUNET_free (cur->info.filename);
       ++errors;
       goto done;
     }
@@ -2491,7 +2491,7 @@
   LT_DLMUTEX_SETERROR (saved_error);
 
 done:
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return errors;
 }
@@ -2524,7 +2524,7 @@
 
   /* Allocate memory, and combine DIRNAME and MODULENAME into it.
      The PREFIX (if any) is handled below.  */
-  filename = LT_EMALLOC (char, dirname_len + 1 + filename_len + 1);
+  filename = LT_EGNUNET_malloc (char, dirname_len + 1 + filename_len + 1);
   if (!filename)
     return 1;
 
@@ -2543,7 +2543,7 @@
       ++error;
     }
 
-  LT_DLFREE (filename);
+  LT_DLGNUNET_free (filename);
   return error;
 }
 
@@ -2605,7 +2605,7 @@
   assert (path && *path);
   assert (pcanonical);
 
-  canonical = LT_EMALLOC (char, 1 + LT_STRLEN (path));
+  canonical = LT_EGNUNET_malloc (char, 1 + LT_STRLEN (path));
   if (!canonical)
     return 1;
 
@@ -2708,7 +2708,7 @@
   char *filename = 0;
   char *canonical = 0;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   if (!search_path || !*search_path)
     {
@@ -2730,9 +2730,9 @@
 
         if (lendir + 1 + lenbase >= filenamesize)
           {
-            LT_DLFREE (filename);
+            LT_DLGNUNET_free (filename);
             filenamesize = lendir + 1 + lenbase + 1;    /* "/d" + '/' + "f" + 
'\0' */
-            filename = LT_EMALLOC (char, filenamesize);
+            filename = LT_EGNUNET_malloc (char, filenamesize);
             if (!filename)
               goto cleanup;
           }
@@ -2755,11 +2755,11 @@
   }
 
 cleanup:
-  LT_DLFREE (argz);
-  LT_DLFREE (canonical);
-  LT_DLFREE (filename);
+  LT_DLGNUNET_free (argz);
+  LT_DLGNUNET_free (canonical);
+  LT_DLGNUNET_free (filename);
 
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return result;
 }
@@ -2788,7 +2788,7 @@
       if (dirend > filename)
         *dirend = LT_EOS_CHAR;
 
-      LT_DLFREE (*pdir);
+      LT_DLGNUNET_free (*pdir);
       *pdir = lt_estrdup (filename);
       is_done = (*pdir == 0) ? -1 : 1;
     }
@@ -2870,7 +2870,7 @@
     }
   ++errors;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   if (user_search_path)
     {
       save_search_path = lt_estrdup (user_search_path);
@@ -2919,7 +2919,7 @@
       goto cleanup;
     }
 
-  names = LT_EMALLOC (char *, depcount * sizeof (char *));
+  names = LT_EGNUNET_malloc (char *, depcount * sizeof (char *));
   if (!names)
     goto cleanup;
 
@@ -2948,7 +2948,7 @@
               if (strncmp (p, "-l", 2) == 0)
                 {
                   size_t name_len = 3 + /* "lib" */ LT_STRLEN (p + 2);
-                  name = LT_EMALLOC (char, 1 + name_len);
+                  name = LT_EGNUNET_malloc (char, 1 + name_len);
                   if (name)
                     sprintf (name, "lib%s", p + 2);
                 }
@@ -2974,7 +2974,8 @@
     {
       int j = 0;
 
-      handle->deplibs = (lt_dlhandle *) LT_EMALLOC (lt_dlhandle *, depcount);
+      handle->deplibs =
+        (lt_dlhandle *) LT_EGNUNET_malloc (lt_dlhandle *, depcount);
       if (!handle->deplibs)
         goto cleanup;
 
@@ -2994,18 +2995,18 @@
 cleanup_names:
   for (i = 0; i < depcount; ++i)
     {
-      LT_DLFREE (names[i]);
+      LT_DLGNUNET_free (names[i]);
     }
 
 cleanup:
-  LT_DLFREE (names);
+  LT_DLGNUNET_free (names);
   /* restore the old search path */
   if (user_search_path)
     {
-      LT_DLFREE (user_search_path);
+      LT_DLGNUNET_free (user_search_path);
       user_search_path = save_search_path;
     }
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
 #endif
 
@@ -3044,14 +3045,14 @@
   size_t len = LT_STRLEN (str);
   char *tmp;
 
-  LT_DLFREE (*dest);
+  LT_DLGNUNET_free (*dest);
 
   if (!end)
     return 1;
 
   if (len > 3 && str[0] == '\'')
     {
-      tmp = LT_EMALLOC (char, end - str);
+      tmp = LT_EGNUNET_malloc (char, end - str);
       if (!tmp)
         return 1;
 
@@ -3074,10 +3075,10 @@
      char *libdir;
      char *deplibs;
 {
-  LT_DLFREE (dlname);
-  LT_DLFREE (oldname);
-  LT_DLFREE (libdir);
-  LT_DLFREE (deplibs);
+  LT_DLGNUNET_free (dlname);
+  LT_DLGNUNET_free (oldname);
+  LT_DLGNUNET_free (libdir);
+  LT_DLGNUNET_free (deplibs);
 
   return 0;
 }
@@ -3104,7 +3105,8 @@
   /* dlopen self? */
   if (!filename)
     {
-      *phandle = (lt_dlhandle) LT_EMALLOC (struct lt_dlhandle_struct, 1);
+      *phandle =
+        (lt_dlhandle) LT_EGNUNET_malloc (struct lt_dlhandle_struct, 1);
       if (*phandle == 0)
         return 1;
 
@@ -3116,7 +3118,7 @@
 
       if (tryall_dlopen (&newhandle, 0) != 0)
         {
-          LT_DLFREE (*phandle);
+          LT_DLGNUNET_free (*phandle);
           return 1;
         }
 
@@ -3140,7 +3142,7 @@
     {
       size_t dirlen = (1 + base_name) - canonical;
 
-      dir = LT_EMALLOC (char, 1 + dirlen);
+      dir = LT_EGNUNET_malloc (char, 1 + dirlen);
       if (!dir)
         {
           ++errors;
@@ -3176,7 +3178,7 @@
       int installed = 1;
 
       /* extract the module name from the file name */
-      name = LT_EMALLOC (char, ext - base_name + 1);
+      name = LT_EGNUNET_malloc (char, ext - base_name + 1);
       if (!name)
         {
           ++errors;
@@ -3208,11 +3210,11 @@
         {
           const char *search_path;
 
-          LT_DLMUTEX_LOCK ();
+          LT_DLGNUNET_mutex_lock ();
           search_path = user_search_path;
           if (search_path)
             file = find_file (user_search_path, base_name, &dir);
-          LT_DLMUTEX_UNLOCK ();
+          LT_DLGNUNET_mutex_unlock ();
 
           if (!file)
             {
@@ -3251,7 +3253,7 @@
         }
 
       line_len = LT_FILENAME_MAX;
-      line = LT_EMALLOC (char, line_len);
+      line = LT_EGNUNET_malloc (char, line_len);
       if (!line)
         {
           fclose (file);
@@ -3271,7 +3273,7 @@
              that is longer than the initial buffer size.  */
           while ((line[LT_STRLEN (line) - 1] != '\n') && (!feof (file)))
             {
-              line = LT_DLREALLOC (char, line, line_len * 2);
+              line = LT_DLGNUNET_realloc (char, line, line_len * 2);
               if (!fgets (&line[line_len - 1], (int) line_len + 1, file))
                 {
                   break;
@@ -3346,17 +3348,18 @@
         }
 
       fclose (file);
-      LT_DLFREE (line);
+      LT_DLGNUNET_free (line);
 
       /* allocate the handle */
-      *phandle = (lt_dlhandle) LT_EMALLOC (struct lt_dlhandle_struct, 1);
+      *phandle =
+        (lt_dlhandle) LT_EGNUNET_malloc (struct lt_dlhandle_struct, 1);
       if (*phandle == 0)
         ++errors;
 
       if (errors)
         {
           free_vars (dlname, old_name, libdir, deplibs);
-          LT_DLFREE (*phandle);
+          LT_DLGNUNET_free (*phandle);
           goto cleanup;
         }
 
@@ -3382,7 +3385,7 @@
       free_vars (dlname, old_name, libdir, deplibs);
       if (errors)
         {
-          LT_DLFREE (*phandle);
+          LT_DLGNUNET_free (*phandle);
           goto cleanup;
         }
 
@@ -3394,7 +3397,8 @@
   else
     {
       /* not a libtool module */
-      *phandle = (lt_dlhandle) LT_EMALLOC (struct lt_dlhandle_struct, 1);
+      *phandle =
+        (lt_dlhandle) LT_EGNUNET_malloc (struct lt_dlhandle_struct, 1);
       if (*phandle == 0)
         {
           ++errors;
@@ -3428,7 +3432,7 @@
 
       if (!newhandle)
         {
-          LT_DLFREE (*phandle);
+          LT_DLGNUNET_free (*phandle);
           ++errors;
           goto cleanup;
         }
@@ -3442,18 +3446,18 @@
       (*phandle)->info.ref_count = 1;
       LT_DLMEM_REASSIGN ((*phandle)->info.name, name);
 
-      LT_DLMUTEX_LOCK ();
+      LT_DLGNUNET_mutex_lock ();
       (*phandle)->next = handles;
       handles = *phandle;
-      LT_DLMUTEX_UNLOCK ();
+      LT_DLGNUNET_mutex_unlock ();
     }
 
   LT_DLMUTEX_SETERROR (saved_error);
 
 cleanup:
-  LT_DLFREE (dir);
-  LT_DLFREE (name);
-  LT_DLFREE (canonical);
+  LT_DLGNUNET_free (dir);
+  LT_DLGNUNET_free (name);
+  LT_DLGNUNET_free (canonical);
 
   return errors;
 }
@@ -3522,7 +3526,7 @@
     }
 
   /* First try appending ARCHIVE_EXT.  */
-  tmp = LT_EMALLOC (char, len + LT_STRLEN (archive_ext) + 1);
+  tmp = LT_EGNUNET_malloc (char, len + LT_STRLEN (archive_ext) + 1);
   if (!tmp)
     return 0;
 
@@ -3537,7 +3541,7 @@
      in the module search path.  */
   if (handle || ((errors > 0) && !file_not_found ()))
     {
-      LT_DLFREE (tmp);
+      LT_DLGNUNET_free (tmp);
       return handle;
     }
 
@@ -3545,8 +3549,8 @@
   /* Try appending SHLIB_EXT.   */
   if (LT_STRLEN (shlib_ext) > LT_STRLEN (archive_ext))
     {
-      LT_DLFREE (tmp);
-      tmp = LT_EMALLOC (char, len + LT_STRLEN (shlib_ext) + 1);
+      LT_DLGNUNET_free (tmp);
+      tmp = LT_EGNUNET_malloc (char, len + LT_STRLEN (shlib_ext) + 1);
       if (!tmp)
         return 0;
 
@@ -3564,7 +3568,7 @@
      with the current error message.  */
   if (handle || ((errors > 0) && !file_not_found ()))
     {
-      LT_DLFREE (tmp);
+      LT_DLGNUNET_free (tmp);
       return handle;
     }
 #endif
@@ -3572,7 +3576,7 @@
   /* Still here?  Then we really did fail to locate any of the file
      names we tried.  */
   LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FILE_NOT_FOUND));
-  LT_DLFREE (tmp);
+  LT_DLGNUNET_free (tmp);
   return 0;
 }
 
@@ -3682,7 +3686,7 @@
   /* Prepend the directory name.  */
   end_offset = end - dp->d_name;
   buf_len = dir_len + 1 + end_offset;
-  buf = LT_EMALLOC (char, 1 + buf_len);
+  buf = LT_EGNUNET_malloc (char, 1 + buf_len);
   if (!buf)
     return ++errors;
 
@@ -3697,7 +3701,7 @@
   if (lt_argz_insertinorder (pargz, pargz_len, buf) != 0)
     ++errors;
 
-  LT_DLFREE (buf);
+  LT_DLGNUNET_free (buf);
 
   return errors;
 }
@@ -3766,7 +3770,7 @@
   }
 
 cleanup:
-  LT_DLFREE (argz);
+  LT_DLGNUNET_free (argz);
 
   return is_done;
 }
@@ -3830,7 +3834,7 @@
   lt_dlhandle cur, last;
   int errors = 0;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   /* check whether the handle is valid */
   last = cur = handles;
@@ -3870,11 +3874,11 @@
       errors += unload_deplibs (handle);
 
       /* It is up to the callers to free the data itself.  */
-      LT_DLFREE (handle->caller_data);
+      LT_DLGNUNET_free (handle->caller_data);
 
-      LT_DLFREE (handle->info.filename);
-      LT_DLFREE (handle->info.name);
-      LT_DLFREE (handle);
+      LT_DLGNUNET_free (handle->info.filename);
+      LT_DLGNUNET_free (handle->info.name);
+      LT_DLGNUNET_free (handle);
 
       goto done;
     }
@@ -3886,7 +3890,7 @@
     }
 
 done:
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return errors;
 }
@@ -3923,7 +3927,7 @@
     }
   else
     {
-      sym = LT_EMALLOC (char, lensym + LT_SYMBOL_OVERHEAD + 1);
+      sym = LT_EGNUNET_malloc (char, lensym + LT_SYMBOL_OVERHEAD + 1);
       if (!sym)
         {
           LT_DLMUTEX_SETERROR (LT_DLSTRERROR (BUFFER_OVERFLOW));
@@ -3958,7 +3962,7 @@
         {
           if (sym != lsym)
             {
-              LT_DLFREE (sym);
+              LT_DLGNUNET_free (sym);
             }
           return address;
         }
@@ -3979,7 +3983,7 @@
   address = handle->loader->find_sym (data, handle->module, sym);
   if (sym != lsym)
     {
-      LT_DLFREE (sym);
+      LT_DLGNUNET_free (sym);
     }
 
   return address;
@@ -4062,8 +4066,8 @@
   LT_DLMEM_REASSIGN (*ppath, argz);
 
 cleanup:
-  LT_DLFREE (canonical);
-  LT_DLFREE (argz);
+  LT_DLGNUNET_free (canonical);
+  LT_DLGNUNET_free (argz);
 
   return errors;
 }
@@ -4076,10 +4080,10 @@
 
   if (search_dir && *search_dir)
     {
-      LT_DLMUTEX_LOCK ();
+      LT_DLGNUNET_mutex_lock ();
       if (lt_dlpath_insertdir (&user_search_path, 0, search_dir) != 0)
         ++errors;
-      LT_DLMUTEX_UNLOCK ();
+      LT_DLGNUNET_mutex_unlock ();
     }
 
   return errors;
@@ -4094,26 +4098,26 @@
 
   if (before)
     {
-      LT_DLMUTEX_LOCK ();
+      LT_DLGNUNET_mutex_lock ();
       if ((before < user_search_path)
           || (before >= user_search_path + LT_STRLEN (user_search_path)))
         {
-          LT_DLMUTEX_UNLOCK ();
+          LT_DLGNUNET_mutex_unlock ();
           LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INVALID_POSITION));
           return 1;
         }
-      LT_DLMUTEX_UNLOCK ();
+      LT_DLGNUNET_mutex_unlock ();
     }
 
   if (search_dir && *search_dir)
     {
-      LT_DLMUTEX_LOCK ();
+      LT_DLGNUNET_mutex_lock ();
       if (lt_dlpath_insertdir (&user_search_path,
                                (char *) before, search_dir) != 0)
         {
           ++errors;
         }
-      LT_DLMUTEX_UNLOCK ();
+      LT_DLGNUNET_mutex_unlock ();
     }
 
   return errors;
@@ -4125,19 +4129,19 @@
 {
   int errors = 0;
 
-  LT_DLMUTEX_LOCK ();
-  LT_DLFREE (user_search_path);
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_lock ();
+  LT_DLGNUNET_free (user_search_path);
+  LT_DLGNUNET_mutex_unlock ();
 
   if (!search_path || !LT_STRLEN (search_path))
     {
       return errors;
     }
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   if (canonicalize_path (search_path, &user_search_path) != 0)
     ++errors;
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return errors;
 }
@@ -4147,9 +4151,9 @@
 {
   const char *saved_path;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   saved_path = user_search_path;
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return saved_path;
 }
@@ -4219,7 +4223,7 @@
   int errors = 0;
   lt_dlhandle cur;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   cur = handles;
   while (cur)
@@ -4234,7 +4238,7 @@
         }
     }
 
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return errors;
 }
@@ -4245,9 +4249,9 @@
   static lt_dlcaller_id last_caller_id = 0;
   int result;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   result = ++last_caller_id;
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return result;
 }
@@ -4264,7 +4268,7 @@
 
   /* This needs to be locked so that the caller data can be updated
      simultaneously by different threads.  */
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   if (handle->caller_data)
     while (handle->caller_data[n_elements].key)
@@ -4284,7 +4288,8 @@
   if (i == n_elements)
     {
       lt_caller_data *temp
-        = LT_DLREALLOC (lt_caller_data, handle->caller_data, 2 + n_elements);
+        = LT_DLGNUNET_realloc (lt_caller_data, handle->caller_data,
+                               2 + n_elements);
 
       if (!temp)
         {
@@ -4302,7 +4307,7 @@
   handle->caller_data[i].data = data;
 
 done:
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return stale;
 }
@@ -4316,7 +4321,7 @@
 
   /* This needs to be locked so that the caller data isn't updated by
      another thread part way through this function.  */
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   /* Locate the index of the element with a matching KEY.  */
   {
@@ -4331,7 +4336,7 @@
       }
   }
 
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return result;
 }
@@ -4359,7 +4364,7 @@
     }
 
   /* Create a new dlloader node with copies of the user callbacks.  */
-  node = LT_EMALLOC (lt_dlloader, 1);
+  node = LT_EGNUNET_malloc (lt_dlloader, 1);
   if (!node)
     return 1;
 
@@ -4372,7 +4377,7 @@
   node->find_sym = dlloader->find_sym;
   node->dlloader_data = dlloader->dlloader_data;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   if (!loaders)
     {
       /* If there are no loaders, NODE becomes the list! */
@@ -4416,7 +4421,7 @@
         }
     }
 
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return errors;
 }
@@ -4435,7 +4440,7 @@
       return 1;
     }
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
 
   /* Fail if there are any open modules which use this loader. */
   for (handle = handles; handle; handle = handle->next)
@@ -4474,10 +4479,10 @@
       errors = place->dlloader_exit (place->dlloader_data);
     }
 
-  LT_DLFREE (place);
+  LT_DLGNUNET_free (place);
 
 done:
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return errors;
 }
@@ -4488,9 +4493,9 @@
 {
   lt_dlloader *next;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   next = place ? place->next : loaders;
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return next;
 }
@@ -4503,9 +4508,9 @@
 
   if (place)
     {
-      LT_DLMUTEX_LOCK ();
+      LT_DLGNUNET_mutex_lock ();
       name = place ? place->loader_name : 0;
-      LT_DLMUTEX_UNLOCK ();
+      LT_DLGNUNET_mutex_unlock ();
     }
   else
     {
@@ -4523,9 +4528,9 @@
 
   if (place)
     {
-      LT_DLMUTEX_LOCK ();
+      LT_DLGNUNET_mutex_lock ();
       data = place ? &(place->dlloader_data) : 0;
-      LT_DLMUTEX_UNLOCK ();
+      LT_DLGNUNET_mutex_unlock ();
     }
   else
     {
@@ -4541,7 +4546,7 @@
 {
   lt_dlloader *place = 0;
 
-  LT_DLMUTEX_LOCK ();
+  LT_DLGNUNET_mutex_lock ();
   for (place = loaders; place; place = place->next)
     {
       if (strcmp (place->loader_name, loader_name) == 0)
@@ -4549,7 +4554,7 @@
           break;
         }
     }
-  LT_DLMUTEX_UNLOCK ();
+  LT_DLGNUNET_mutex_unlock ();
 
   return place;
 }

Modified: GNUnet/libltdl/ltdl.h
===================================================================
--- GNUnet/libltdl/ltdl.h       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/libltdl/ltdl.h       2007-11-23 11:51:54 UTC (rev 5742)
@@ -161,7 +161,7 @@
 
 
 
-/* --- MUTEX LOCKING --- */
+/* --- GNUNET_Mutex LOCKING --- */
 
 
 typedef void lt_dlmutex_lock LT_PARAMS ((void));

Modified: GNUnet/src/applications/advertising/Makefile.am
===================================================================
--- GNUnet/src/applications/advertising/Makefile.am     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/advertising/Makefile.am     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -10,9 +10,7 @@
   bootstrap.c \
   bootstrap.h
 libgnunetmodule_advertising_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la
+ $(top_builddir)/src/util/libgnunetutil.la 
 libgnunetmodule_advertising_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 
@@ -32,27 +30,21 @@
   advertising_test.c 
 advertisingtest_tcp_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 advertisingtest_udp_SOURCES = \
   advertising_test.c 
 advertisingtest_udp_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 advertisingtest_http_SOURCES = \
   advertising_test.c 
 advertisingtest_http_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 

Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c   2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/advertising/advertising.c   2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -44,13 +44,13 @@
 /**
  * Send our hello to a random connected host on a regular basis.
  */
-#define HELLO_BROADCAST_FREQUENCY (2 * cronMINUTES)
+#define HELLO_BROADCAST_FREQUENCY (2 * GNUNET_CRON_MINUTES)
 
 /**
  * From time to time, forward one hello from one peer to
  * a random other peer.
  */
-#define HELLO_FORWARD_FREQUENCY (45 * cronSECONDS)
+#define HELLO_FORWARD_FREQUENCY (45 * GNUNET_CRON_SECONDS)
 
 /**
  * Meanings of the bits in activeCronJobs (ACJ).
@@ -60,7 +60,7 @@
 #define ACJ_FORWARD 2
 #define ACJ_ALL (ACJ_ANNOUNCE | ACJ_FORWARD)
 
-#define DEBUG_ADVERTISING NO
+#define DEBUG_ADVERTISING GNUNET_NO
 
 static CoreAPIForApplication *coreAPI;
 
@@ -107,7 +107,7 @@
  */
 static int activeCronJobs = ACJ_NONE;
 
-static cron_t lasthelloMsg = 0;
+static GNUNET_CronTime lasthelloMsg = 0;
 
 static double
 getConnectPriority ()
@@ -132,12 +132,12 @@
 static void
 callAddHost (void *cls)
 {
-  P2P_hello_MESSAGE *hello = cls;
+  GNUNET_MessageHello *hello = cls;
 
   if (stats != NULL)
     stats->change (stat_hello_verified, 1);
   identity->addHost (hello);
-  FREE (hello);
+  GNUNET_free (hello);
 }
 
 /**
@@ -145,84 +145,86 @@
  * ping-pong) and store identity if ok.
  *
  * @param message the hello message
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
-receivedhello (const PeerIdentity * sender, const MESSAGE_HEADER * message)
+receivedhello (const GNUNET_PeerIdentity * sender,
+               const GNUNET_MessageHeader * message)
 {
   TSession *tsession;
-  P2P_hello_MESSAGE *copy;
-  PeerIdentity foreignId;
-  const P2P_hello_MESSAGE *msg;
-  MESSAGE_HEADER *ping;
+  GNUNET_MessageHello *copy;
+  GNUNET_PeerIdentity foreignId;
+  const GNUNET_MessageHello *msg;
+  GNUNET_MessageHeader *ping;
   char *buffer;
   int helloEnd;
   int mtu;
   int res;
-  cron_t now;
-  EncName enc;
+  GNUNET_CronTime now;
+  GNUNET_EncName enc;
 
   /* first verify that it is actually a valid hello */
-  msg = (const P2P_hello_MESSAGE *) message;
-  if ((ntohs (msg->header.size) < sizeof (P2P_hello_MESSAGE)) ||
-      (ntohs (msg->header.size) != P2P_hello_MESSAGE_size (msg)))
+  msg = (const GNUNET_MessageHello *) message;
+  if ((ntohs (msg->header.size) < sizeof (GNUNET_MessageHello)) ||
+      (ntohs (msg->header.size) != GNUNET_sizeof_hello (msg)))
     {
       GE_BREAK_OP (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   identity->getPeerIdentity (&msg->publicKey, &foreignId);
-  if (!equalsHashCode512 (&msg->senderIdentity.hashPubKey,
-                          &foreignId.hashPubKey))
+  if (0 != memcmp (&msg->senderIdentity.hashPubKey,
+                   &foreignId.hashPubKey, sizeof (GNUNET_HashCode)))
     {
       GE_BREAK_OP (ectx, 0);
-      return SYSERR;            /* public key and host hash do not match */
+      return GNUNET_SYSERR;     /* public key and host GNUNET_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))
+  if (GNUNET_SYSERR == GNUNET_RSA_verify (&msg->senderIdentity,
+                                          GNUNET_sizeof_hello (msg)
+                                          - sizeof (GNUNET_RSA_Signature)
+                                          - sizeof (GNUNET_RSA_PublicKey)
+                                          - sizeof (GNUNET_MessageHeader),
+                                          &msg->signature, &msg->publicKey))
     {
       IF_GELOG (ectx,
                 GE_WARNING | GE_BULK | GE_USER,
-                hash2enc (&msg->senderIdentity.hashPubKey, &enc));
+                GNUNET_hash_to_enc (&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_BREAK_OP (ectx, 0);
-      return SYSERR;            /* message invalid */
+      return GNUNET_SYSERR;     /* message invalid */
     }
-  if ((TIME_T) ntohl (msg->expirationTime) > TIME (NULL) + MAX_HELLO_EXPIRES)
+  if ((GNUNET_Int32Time) ntohl (msg->expirationTime) >
+      GNUNET_get_time_int32 (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_BREAK_OP (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if (SYSERR == transport->verifyhello (msg))
+  if (GNUNET_SYSERR == transport->verifyhello (msg))
     {
 #if DEBUG_ADVERTISING
       IF_GELOG (ectx,
                 GE_INFO | GE_BULK | GE_USER,
-                hash2enc (&msg->senderIdentity.hashPubKey, &enc));
+                GNUNET_hash_to_enc (&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));
 #endif
-      return OK;                /* not good, but do process rest of message */
+      return GNUNET_OK;         /* not good, but do process rest of message */
     }
   if (stats != NULL)
     stats->change (stat_hello_in, 1);
 #if DEBUG_ADVERTISING
   IF_GELOG (ectx,
             GE_INFO | GE_REQUEST | GE_USER,
-            hash2enc (&msg->senderIdentity.hashPubKey, &enc));
+            GNUNET_hash_to_enc (&msg->senderIdentity.hashPubKey, &enc));
   GE_LOG (ectx,
           GE_INFO | GE_REQUEST | GE_USER,
           "HELLO advertisement from `%s' for protocol %d received.\n",
@@ -238,26 +240,27 @@
          check can not be done securely (since we
          have to accept hellos in plaintext).  Thus
          we take NAT advertisements at face value
-         (which is OK since we never attempt to
+         (which is GNUNET_OK since we never attempt to
          connect to a NAT). */
       identity->addHost (msg);
       if (stats != NULL)
         stats->change (stat_hello_nat_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,
+                GNUNET_hash_to_enc (&msg->senderIdentity.hashPubKey, &enc));
       GE_LOG (ectx,
-             GE_INFO | GE_REQUEST | GE_USER,
-             "HELLO advertisement from `%s' for NAT, no verification 
required.\n",
-             &enc);
+              GE_INFO | GE_REQUEST | GE_USER,
+              "HELLO advertisement from `%s' for NAT, no verification 
required.\n",
+              &enc);
 #endif
-      return OK;
+      return GNUNET_OK;
     }
 
   /* 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);
+  copy =
+    identity->identity2Hello (&foreignId, ntohs (msg->protocol), GNUNET_NO);
   if (NULL != copy)
     {
       if ((ntohs (copy->senderAddressSize) ==
@@ -274,17 +277,17 @@
           identity->addHost (msg);
           if (stats != NULL)
             stats->change (stat_hello_update, 1);
-          FREE (copy);
+          GNUNET_free (copy);
 #if DEBUG_ADVERTISING
-         IF_GELOG (ectx,
-                   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 updates old 
advertisement, no verification required.\n",
-                 &enc, ntohs (msg->protocol));
+          IF_GELOG (ectx,
+                    GE_INFO | GE_REQUEST | GE_USER,
+                    GNUNET_hash_to_enc (&msg->senderIdentity.hashPubKey,
+                                        &enc));
+          GE_LOG (ectx, GE_INFO | GE_REQUEST | GE_USER,
+                  "HELLO advertisement from `%s' for protocol %d updates old 
advertisement, no verification required.\n",
+                  &enc, ntohs (msg->protocol));
 #endif
-          return OK;
+          return GNUNET_OK;
         }
 #if DEBUG_ADVERTISING
       GE_LOG (ectx,
@@ -292,12 +295,13 @@
               "HELLO advertisement differs from prior knowledge,"
               " requireing ping-pong confirmation.\n");
 #endif
-      FREE (copy);
+      GNUNET_free (copy);
     }
 
-  if (YES == GC_get_configuration_value_yesno (coreAPI->cfg,
-                                               "GNUNETD",
-                                               "PRIVATE-NETWORK", NO))
+  if (GNUNET_YES == GC_get_configuration_value_yesno (coreAPI->cfg,
+                                                      "GNUNETD",
+                                                      "PRIVATE-NETWORK",
+                                                      GNUNET_NO))
     {
       /* the option 'PRIVATE-NETWORK' can be used
          to limit the connections of this peer to
@@ -318,7 +322,7 @@
               GE_INFO | GE_BULK | GE_USER,
               "Private network, discarding unknown advertisements\n");
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   /* Ok, must play PING-PONG. Add the hello to the temporary
@@ -326,12 +330,12 @@
      time in order to play PING-PONG */
   identity->addHostTemporarily (msg);
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   if ((sender != NULL) &&
-      ((now - lasthelloMsg) / cronSECONDS) *
-      (os_network_monitor_get_limit (coreAPI->load_monitor,
-                                     Download))
-      < P2P_hello_MESSAGE_size (msg) * 10)
+      ((now - lasthelloMsg) / GNUNET_CRON_SECONDS) *
+      (GNUNET_network_monitor_get_limit (coreAPI->load_monitor,
+                                         GNUNET_ND_DOWNLOAD))
+      < GNUNET_sizeof_hello (msg) * 10)
     {
       /* do not use more than about 10% of the
          available bandwidth to VERIFY hellos (by sending
@@ -346,35 +350,34 @@
       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));
+              (unsigned int) ((now - lasthelloMsg) / GNUNET_CRON_SECONDS),
+              (unsigned int) GNUNET_network_monitor_get_limit (coreAPI->
+                                                               load_monitor,
+                                                               
GNUNET_ND_DOWNLOAD),
+              (unsigned int) GNUNET_sizeof_hello (msg));
 #endif
       if (stats != NULL)
         stats->change (stat_hello_discard, 1);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   lasthelloMsg = now;
 
 
   /* Establish session as advertised in the hello */
-  tsession = transport->connect (msg, __FILE__, NO);
+  tsession = transport->connect (msg, __FILE__, GNUNET_NO);
   if (tsession == NULL)
     {
       if (stats != NULL)
         stats->change (stat_hello_no_transport, 1);
 #if DEBUG_ADVERTISING
       IF_GELOG (ectx,
-               GE_INFO | GE_REQUEST | GE_USER,
-               hash2enc (&msg->senderIdentity.hashPubKey, &enc));
+                GE_INFO | GE_REQUEST | GE_USER,
+                GNUNET_hash_to_enc (&msg->senderIdentity.hashPubKey, &enc));
       GE_LOG (ectx,
-             GE_INFO | GE_REQUEST | GE_USER,
-             "Failed to connect to `%s'.  Verification failed.\n",
-             &enc);
+              GE_INFO | GE_REQUEST | GE_USER,
+              "Failed to connect to `%s'.  Verification failed.\n", &enc);
 #endif
-      return SYSERR;            /* could not connect */
+      return GNUNET_SYSERR;     /* could not connect */
     }
 
   /* build message to send, ping must contain return-information,
@@ -389,22 +392,22 @@
       GE_ASSERT (ectx, mtu > P2P_MESSAGE_OVERHEAD);
       mtu -= P2P_MESSAGE_OVERHEAD;
     }
-  copy = MALLOC (P2P_hello_MESSAGE_size (msg));
-  memcpy (copy, msg, P2P_hello_MESSAGE_size (msg));
+  copy = GNUNET_malloc (GNUNET_sizeof_hello (msg));
+  memcpy (copy, msg, GNUNET_sizeof_hello (msg));
   ping = pingpong->pingUser (&msg->senderIdentity,
-                             &callAddHost, copy, YES, rand ());
+                             &callAddHost, copy, GNUNET_YES, rand ());
   if (ping == NULL)
     {
-      res = SYSERR;
+      res = GNUNET_SYSERR;
       GE_LOG (ectx,
               GE_INFO | GE_REQUEST | GE_USER,
               _("Could not send HELLO+PING, ping buffer full.\n"));
       transport->disconnect (tsession, __FILE__);
       if (stats != NULL)
         stats->change (stat_hello_ping_busy, 1);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  buffer = MALLOC (mtu);
+  buffer = GNUNET_malloc (mtu);
   if (mtu > ntohs (ping->size))
     {
       helloEnd = transport->getAdvertisedhellos (mtu - ntohs (ping->size),
@@ -421,114 +424,116 @@
               GE_WARNING | GE_BULK | GE_USER,
               _
               ("Failed to create an advertisement for this peer. Will not send 
PING.\n"));
-      FREE (buffer);
+      GNUNET_free (buffer);
       if (stats != NULL)
         stats->change (stat_hello_noselfad, 1);
       transport->disconnect (tsession, __FILE__);
 #if DEBUG_ADVERTISING
       IF_GELOG (ectx,
-               GE_INFO | GE_REQUEST | GE_USER,
-               hash2enc (&msg->senderIdentity.hashPubKey, &enc));
+                GE_INFO | GE_REQUEST | GE_USER,
+                GNUNET_hash_to_enc (&msg->senderIdentity.hashPubKey, &enc));
       GE_LOG (ectx,
-             GE_INFO | GE_REQUEST | GE_USER,
-             "Failed to connect advertisement for myself.  Verification 
failed.\n",
-             &enc);
+              GE_INFO | GE_REQUEST | GE_USER,
+              "Failed to connect advertisement for myself.  Verification 
failed.\n",
+              &enc);
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  res = OK;
+  res = GNUNET_OK;
   memcpy (&buffer[helloEnd], ping, ntohs (ping->size));
   helloEnd += ntohs (ping->size);
-  FREE (ping);
+  GNUNET_free (ping);
 
   /* ok, finally we can send! */
-  if ((res == OK) &&
-      (SYSERR == coreAPI->sendPlaintext (tsession, buffer, helloEnd)))
+  if ((res == GNUNET_OK) &&
+      (GNUNET_SYSERR == coreAPI->sendPlaintext (tsession, buffer, helloEnd)))
     {
 
       if (stats != NULL)
         stats->change (stat_hello_send_error, 1);
 #if DEBUG_ADVERTISING
       IF_GELOG (ectx,
-               GE_INFO | GE_REQUEST | GE_USER,
-               hash2enc (&msg->senderIdentity.hashPubKey, &enc));
+                GE_INFO | GE_REQUEST | GE_USER,
+                GNUNET_hash_to_enc (&msg->senderIdentity.hashPubKey, &enc));
       GE_LOG (ectx,
-             GE_INFO | GE_REQUEST | GE_USER,
-             "Failed to transmit advertisement for myself.  Verification 
failed.\n",
-             &enc);
+              GE_INFO | GE_REQUEST | GE_USER,
+              "Failed to transmit advertisement for myself.  Verification 
failed.\n",
+              &enc);
 #endif
-      res = SYSERR;
+      res = GNUNET_SYSERR;
     }
-  if (res == OK)
+  if (res == GNUNET_OK)
     {
       if (stats != NULL)
         stats->change (stat_plaintextPingSent, 1);
     }
-  FREE (buffer);
-  if (SYSERR == transport->disconnect (tsession, __FILE__))
-    res = SYSERR;
+  GNUNET_free (buffer);
+  if (GNUNET_SYSERR == transport->disconnect (tsession, __FILE__))
+    res = GNUNET_SYSERR;
   return res;
 }
 
 typedef struct
 {
   /* the hello message */
-  P2P_hello_MESSAGE *m;
+  GNUNET_MessageHello *m;
   /* send the hello in 1 out of n cases */
   int n;
 } SendData;
 
 static int
-broadcastHelper (const PeerIdentity * hi,
+broadcastHelper (const GNUNET_PeerIdentity * hi,
                  const unsigned short proto, int confirmed, void *cls)
 {
   SendData *sd = cls;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   TSession *tsession;
   int prio;
 #if DEBUG_ADVERTISING
-  EncName other;
+  GNUNET_EncName other;
 #endif
 
-  if (confirmed == NO)
-    return OK;
+  if (confirmed == GNUNET_NO)
+    return GNUNET_OK;
   if (proto == NAT_PROTOCOL_NUMBER)
     {
       sd->n--;
-      return OK;                /* don't advertise NAT addresses via broadcast 
*/
+      return GNUNET_OK;         /* don't advertise NAT addresses via broadcast 
*/
     }
-  if ((sd->n != 0) && (weak_randomi (sd->n) != 0))
-    return OK;
+  if ((sd->n != 0)
+      && (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, sd->n) != 0))
+    return GNUNET_OK;
 #if DEBUG_ADVERTISING
   IF_GELOG (ectx,
             GE_DEBUG | GE_REQUEST | GE_USER,
-            hash2enc (&hi->hashPubKey, &other));
+            GNUNET_hash_to_enc (&hi->hashPubKey, &other));
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Entering `%s' with target `%s'.\n", __FUNCTION__, &other);
 #endif
-  if (0 == memcmp (hi, coreAPI->myIdentity, sizeof (PeerIdentity)))
-    return OK;                  /* never advertise to myself... */
+  if (0 == memcmp (hi, coreAPI->myIdentity, sizeof (GNUNET_PeerIdentity)))
+    return GNUNET_OK;           /* never advertise to myself... */
   prio = (int) getConnectPriority ();
   if (prio >= EXTREME_PRIORITY)
     prio = EXTREME_PRIORITY / 4;
-  if (OK == coreAPI->queryPeerStatus (hi, NULL, NULL))
+  if (GNUNET_OK == coreAPI->queryPeerStatus (hi, NULL, NULL))
     {
       coreAPI->unicast (hi, &sd->m->header, prio, HELLO_BROADCAST_FREQUENCY);
       if (stats != NULL)
         stats->change (stat_hello_out, 1);
-      return OK;
+      return GNUNET_OK;
     }
   /* with even lower probability (with n peers
      trying to contact with a probability of 1/n^2,
      we get a probability of 1/n for this, which
      is what we want: fewer attempts to contact fresh
      peers as the network grows): */
-  if ((sd->n != 0) && (weak_randomi (sd->n) != 0))
-    return OK;
+  if ((sd->n != 0)
+      && (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, sd->n) != 0))
+    return GNUNET_OK;
 
   /* establish short-lived connection, send, tear down */
-  hello = identity->identity2Hello (hi, proto, NO);
+  hello = identity->identity2Hello (hi, proto, GNUNET_NO);
   if (NULL == hello)
     {
 #if DEBUG_ADVERTISING
@@ -536,10 +541,10 @@
               "Exit from `%s' (error: `%s' failed).\n",
               __FUNCTION__, "identity2Hello");
 #endif
-      return OK;
+      return GNUNET_OK;
     }
-  tsession = transport->connect (hello, __FILE__, YES);
-  FREE (hello);
+  tsession = transport->connect (hello, __FILE__, GNUNET_YES);
+  GNUNET_free (hello);
   if (tsession == NULL)
     {
 #if DEBUG_ADVERTISING
@@ -548,19 +553,19 @@
               "Exit from `%s' (%s error).\n",
               __FUNCTION__, "transportConnect");
 #endif
-      return OK;                /* could not connect */
+      return GNUNET_OK;         /* could not connect */
     }
   if (stats != NULL)
     stats->change (stat_hello_out, 1);
   coreAPI->sendPlaintext (tsession,
                           (char *) &sd->m->header,
-                          P2P_hello_MESSAGE_size (sd->m));
+                          GNUNET_sizeof_hello (sd->m));
   transport->disconnect (tsession, __FILE__);
 #if DEBUG_ADVERTISING
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER, "Exit from %s.\n", __FUNCTION__);
 #endif
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -572,13 +577,15 @@
 {
   const int *prob = cls;
   SendData sd;
-  cron_t now;
+  GNUNET_CronTime now;
 
-  if (os_network_monitor_get_load (coreAPI->load_monitor, Upload) > 100)
+  if (GNUNET_network_monitor_get_load
+      (coreAPI->load_monitor, GNUNET_ND_UPLOAD) > 100)
     return;                     /* network load too high... */
-  if (((*prob) != 0) && (0 != weak_randomi (*prob)))
+  if (((*prob) != 0)
+      && (0 != GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, *prob)))
     return;                     /* ignore */
-  now = get_time ();
+  now = GNUNET_get_time ();
   sd.n = identity->forEachHost (now, NULL, NULL);       /* just count */
   sd.m = transport->createhello (tapi->protocolNumber);
   if (sd.m == NULL)
@@ -597,11 +604,11 @@
                 GE_WARNING | GE_BULK | GE_USER,
                 _("Announcing ourselves pointless: "
                   "no other peers are known to us so far.\n"));
-      FREE (sd.m);
+      GNUNET_free (sd.m);
       return;                   /* no point in trying... */
     }
   identity->forEachHost (now, &broadcastHelper, &sd);
-  FREE (sd.m);
+  GNUNET_free (sd.m);
 }
 
 /**
@@ -613,9 +620,10 @@
 {
   unsigned int i;
 
-  if (os_network_monitor_get_load (coreAPI->load_monitor, Upload) > 100)
+  if (GNUNET_network_monitor_get_load
+      (coreAPI->load_monitor, GNUNET_ND_UPLOAD) > 100)
     return;                     /* network load too high... */
-  if (os_cpu_get_load (coreAPI->ectx, coreAPI->cfg) > 100)
+  if (GNUNET_cpu_get_load (coreAPI->ectx, coreAPI->cfg) > 100)
     return;                     /* CPU load too high... */
   i = transport->forEach (NULL, NULL);
   if (i > 0)
@@ -624,20 +632,23 @@
 
 typedef struct
 {
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
   int prob;
 } FCC;
 
 static void
-forwardCallback (const PeerIdentity * peer, void *cls)
+forwardCallback (const GNUNET_PeerIdentity * peer, void *cls)
 {
   FCC *fcc = cls;
-  if (os_network_monitor_get_load (coreAPI->load_monitor, Upload) > 100)
+  if (GNUNET_network_monitor_get_load
+      (coreAPI->load_monitor, GNUNET_ND_UPLOAD) > 100)
     return;                     /* network load too high... */
-  if ((fcc->prob != 0) && (weak_randomi (fcc->prob) != 0))
+  if ((fcc->prob != 0)
+      && (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, fcc->prob) != 0))
     return;                     /* only forward with a certain chance */
-  if (equalsHashCode512 (&peer->hashPubKey,
-                         &fcc->msg->senderIdentity.hashPubKey))
+  if (0 == memcmp (&peer->hashPubKey,
+                   &fcc->msg->senderIdentity.hashPubKey,
+                   sizeof (GNUNET_HashCode)))
     return;                     /* do not bounce the hello of a peer back
                                    to the same peer! */
   if (stats != NULL)
@@ -650,48 +661,49 @@
  * Forward hellos from all known hosts to all connected hosts.
  */
 static int
-forwardhelloHelper (const PeerIdentity * peer,
+forwardhelloHelper (const GNUNET_PeerIdentity * peer,
                     unsigned short protocol, int confirmed, void *data)
 {
   int *probability = data;
-  P2P_hello_MESSAGE *hello;
-  TIME_T now;
+  GNUNET_MessageHello *hello;
+  GNUNET_Int32Time now;
   int count;
   FCC fcc;
 
-  if (os_network_monitor_get_load (coreAPI->load_monitor, Upload) > 100)
-    return SYSERR;              /* network load too high... */
-  if (confirmed == NO)
-    return OK;
+  if (GNUNET_network_monitor_get_load
+      (coreAPI->load_monitor, GNUNET_ND_UPLOAD) > 100)
+    return GNUNET_SYSERR;       /* network load too high... */
+  if (confirmed == GNUNET_NO)
+    return GNUNET_OK;
   if (protocol == NAT_PROTOCOL_NUMBER)
-    return OK;                  /* don't forward NAT addresses */
-  hello = identity->identity2Hello (peer, protocol, NO);
+    return GNUNET_OK;           /* don't forward NAT addresses */
+  hello = identity->identity2Hello (peer, protocol, GNUNET_NO);
   if (NULL == hello)
-    return OK;                  /* this should not happen */
+    return GNUNET_OK;           /* this should not happen */
   /* do not forward expired hellos */
-  TIME (&now);
-  if ((TIME_T) ntohl (hello->expirationTime) < now)
+  GNUNET_get_time_int32 (&now);
+  if ((GNUNET_Int32Time) ntohl (hello->expirationTime) < now)
     {
 #if DEBUG_ADVERTISING
-      EncName enc;
+      GNUNET_EncName enc;
       /* remove hellos that expired */
       IF_GELOG (ectx,
                 GE_INFO | GE_REQUEST | GE_USER,
-                hash2enc (&peer->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&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));
 #endif
       identity->delHostFromKnown (peer, protocol);
-      FREE (hello);
+      GNUNET_free (hello);
       (*probability)--;
-      return OK;
+      return GNUNET_OK;
     }
-  if (weak_randomi ((*probability) + 1) != 0)
+  if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, (*probability) + 1) != 0)
     {
-      FREE (hello);
-      return OK;                /* only forward with a certain chance,
+      GNUNET_free (hello);
+      return GNUNET_OK;         /* only forward with a certain chance,
                                    (on average: 1 peer per run!) */
     }
   count = coreAPI->forAllConnectedNodes (NULL, NULL);
@@ -701,8 +713,8 @@
       fcc.prob = count;
       coreAPI->forAllConnectedNodes (&forwardCallback, &fcc);
     }
-  FREE (hello);
-  return OK;
+  GNUNET_free (hello);
+  return GNUNET_OK;
 }
 
 /**
@@ -715,9 +727,10 @@
 {
   int count;
 
-  if (os_cpu_get_load (coreAPI->ectx, coreAPI->cfg) > 100)
+  if (GNUNET_cpu_get_load (coreAPI->ectx, coreAPI->cfg) > 100)
     return;                     /* CPU load too high... */
-  if (os_network_monitor_get_load (coreAPI->load_monitor, Upload) > 100)
+  if (GNUNET_network_monitor_get_load
+      (coreAPI->load_monitor, GNUNET_ND_UPLOAD) > 100)
     return;                     /* network load too high... */
   count = identity->forEachHost (0, NULL, NULL);
   if (count > 0)
@@ -729,27 +742,28 @@
  * Type for a hello send via an encrypted channel.
  */
 static int
-ehelloHandler (const PeerIdentity * sender, const MESSAGE_HEADER * message)
+ehelloHandler (const GNUNET_PeerIdentity * sender,
+               const GNUNET_MessageHeader * message)
 {
-  if (OK == receivedhello (sender, message))
+  if (GNUNET_OK == receivedhello (sender, 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 ());
     }
-  return OK;                    /* even if we had errors processing the hello, 
keep going */
+  return GNUNET_OK;             /* even if we had errors processing the hello, 
keep going */
 }
 
 /**
  * Type for a hello send in plaintext.
  */
 static int
-phelloHandler (const PeerIdentity * sender,
-               const MESSAGE_HEADER * message, TSession * session)
+phelloHandler (const GNUNET_PeerIdentity * sender,
+               const GNUNET_MessageHeader * message, TSession * session)
 {
   receivedhello (sender, message);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -767,44 +781,49 @@
     return 0;
   if (ACJ_ANNOUNCE == (activeCronJobs & ACJ_ANNOUNCE))
     {
-      if (YES == GC_get_configuration_value_yesno (cfg,
-                                                   "NETWORK",
-                                                   "DISABLE-ADVERTISEMENTS",
-                                                   NO))
-        cron_del_job (coreAPI->cron,
-                      &broadcasthello, HELLO_BROADCAST_FREQUENCY, NULL);
+      if (GNUNET_YES == GC_get_configuration_value_yesno (cfg,
+                                                          "NETWORK",
+                                                          
"DISABLE-ADVERTISEMENTS",
+                                                          GNUNET_NO))
+        GNUNET_cron_del_job (coreAPI->cron,
+                             &broadcasthello, HELLO_BROADCAST_FREQUENCY,
+                             NULL);
       activeCronJobs -= ACJ_ANNOUNCE;
     }
   else
     {
-      if (YES != GC_get_configuration_value_yesno (cfg,
-                                                   "NETWORK",
-                                                   "DISABLE-ADVERTISEMENTS",
-                                                   NO))
-        cron_add_job (coreAPI->cron,
-                      &broadcasthello,
-                      15 * cronSECONDS, HELLO_BROADCAST_FREQUENCY, NULL);
+      if (GNUNET_YES != GC_get_configuration_value_yesno (cfg,
+                                                          "NETWORK",
+                                                          
"DISABLE-ADVERTISEMENTS",
+                                                          GNUNET_NO))
+        GNUNET_cron_add_job (coreAPI->cron,
+                             &broadcasthello,
+                             15 * GNUNET_CRON_SECONDS,
+                             HELLO_BROADCAST_FREQUENCY, NULL);
       activeCronJobs += ACJ_ANNOUNCE;
     }
   if (ACJ_FORWARD == (activeCronJobs & ACJ_FORWARD))
     {
-      if (YES != GC_get_configuration_value_yesno (cfg,
-                                                   "NETWORK",
-                                                   "HELLOEXCHANGE", YES))
+      if (GNUNET_YES != GC_get_configuration_value_yesno (cfg,
+                                                          "NETWORK",
+                                                          "HELLOEXCHANGE",
+                                                          GNUNET_YES))
         {
-          cron_del_job (coreAPI->cron, &forwardhello, HELLO_FORWARD_FREQUENCY, 
NULL);   /* seven minutes: exchange */
+          GNUNET_cron_del_job (coreAPI->cron, &forwardhello, 
HELLO_FORWARD_FREQUENCY, NULL);    /* seven minutes: exchange */
         }
       activeCronJobs -= ACJ_FORWARD;
     }
   else
     {
-      if (YES == GC_get_configuration_value_yesno (cfg,
-                                                   "NETWORK",
-                                                   "HELLOEXCHANGE", YES))
+      if (GNUNET_YES == GC_get_configuration_value_yesno (cfg,
+                                                          "NETWORK",
+                                                          "HELLOEXCHANGE",
+                                                          GNUNET_YES))
         {
-          cron_add_job (coreAPI->cron,
-                        &forwardhello,
-                        15 * cronSECONDS, HELLO_FORWARD_FREQUENCY, NULL);
+          GNUNET_cron_add_job (coreAPI->cron,
+                               &forwardhello,
+                               15 * GNUNET_CRON_SECONDS,
+                               HELLO_FORWARD_FREQUENCY, NULL);
         }
       activeCronJobs += ACJ_FORWARD;
     }
@@ -823,7 +842,7 @@
   if (identity == NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   transport = capi->requestService ("transport");
   if (transport == NULL)
@@ -831,7 +850,7 @@
       GE_BREAK (ectx, 0);
       capi->releaseService (identity);
       identity = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   pingpong = capi->requestService ("pingpong");
   if (pingpong == NULL)
@@ -841,7 +860,7 @@
       identity = NULL;
       capi->releaseService (transport);
       transport = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   topology = capi->requestService ("topology");
   if (topology == NULL)
@@ -853,7 +872,7 @@
       transport = NULL;
       capi->releaseService (pingpong);
       pingpong = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   stats = capi->requestService ("stats");
   if (stats != NULL)
@@ -916,7 +935,7 @@
                                                      _
                                                      ("ensures that this peer 
is known by other"
                                                       " peers and discovers 
other peers")));
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -930,13 +949,13 @@
                              &configurationUpdateCallback, NULL);
   if (ACJ_ANNOUNCE == (activeCronJobs & ACJ_ANNOUNCE))
     {
-      cron_del_job (coreAPI->cron,
-                    &broadcasthello, HELLO_BROADCAST_FREQUENCY, NULL);
+      GNUNET_cron_del_job (coreAPI->cron,
+                           &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 */
+      GNUNET_cron_del_job (coreAPI->cron, &forwardhello, 
HELLO_FORWARD_FREQUENCY, NULL);        /* seven minutes: exchange */
       activeCronJobs -= ACJ_FORWARD;
     }
   coreAPI->unregisterHandler (p2p_PROTO_hello, &ehelloHandler);

Modified: GNUnet/src/applications/advertising/advertising_test.c
===================================================================
--- GNUnet/src/applications/advertising/advertising_test.c      2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/advertising/advertising_test.c      2007-11-23 
11:51:54 UTC (rev 5742)
@@ -49,9 +49,9 @@
   if (0 == strcmp (_("# of connected peers"), name))
     {
       *num = value;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -61,11 +61,11 @@
 int
 main (int argc, const char **argv)
 {
-  struct DaemonContext *peers;
+  struct GNUNET_TESTING_DaemonContext *peers;
   int ret = 0;
   struct GE_Context *ectx;
   struct GC_Configuration *cfg;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   int i;
   int k;
   int have;
@@ -74,14 +74,14 @@
   int min;
 
   ectx = NULL;
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
   peers =
-    gnunet_testing_start_daemons (strstr (argv[0], "_") + 1,
+    GNUNET_TESTING_start_daemons (strstr (argv[0], "_") + 1,
                                   "advertising stats",
                                   "/tmp/gnunet-advertising-test", 12087, 10,
                                   NUM_PEERS);
@@ -93,11 +93,12 @@
   /* do circular connect */
   for (i = 0; i < NUM_PEERS; i++)
     {
-      if (OK != gnunet_testing_connect_daemons (12087 + 10 * i,
-                                                12087 +
-                                                10 * ((i + 1) % NUM_PEERS)))
+      if (GNUNET_OK != GNUNET_TESTING_connect_daemons (12087 + 10 * i,
+                                                       12087 +
+                                                       10 * ((i + 1) %
+                                                             NUM_PEERS)))
         {
-          gnunet_testing_stop_daemons (peers);
+          GNUNET_TESTING_stop_daemons (peers);
           fprintf (stderr,
                    "Failed to connect peers %d and %d!\n",
                    i, (i + 1) % NUM_PEERS);
@@ -105,23 +106,23 @@
           return -1;
         }
     }
-  PTHREAD_SLEEP (15 * cronSECONDS);
+  GNUNET_thread_sleep (15 * GNUNET_CRON_SECONDS);
 
   /* check loops */
   for (k = 0; k < NUM_ROUNDS; k++)
     {
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
       found = 0;
       min = NUM_PEERS;
       for (i = 0; i < NUM_PEERS; i++)
         {
-          SNPRINTF (buf, 128, "localhost:%u", 2087 + i * 10);
+          GNUNET_snprintf (buf, 128, "localhost:%u", 2087 + i * 10);
           GC_set_configuration_value_string (cfg,
                                              ectx, "NETWORK", "HOST", buf);
-          sock = client_connection_create (NULL, cfg);
+          sock = GNUNET_client_connection_create (NULL, cfg);
           STATS_getStatistics (NULL, sock, &countConnections, &have);
-          connection_destroy (sock);
+          GNUNET_client_connection_destroy (sock);
           found += have;
           if (have < min)
             min = have;
@@ -130,9 +131,9 @@
                "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! */
+        GNUNET_thread_sleep (45 * GNUNET_CRON_SECONDS); /* one hello-forward 
round is 45s! */
     }
-  gnunet_testing_stop_daemons (peers);
+  GNUNET_TESTING_stop_daemons (peers);
   GC_free (cfg);
   return ret;
 }

Modified: GNUnet/src/applications/advertising/bootstrap.c
===================================================================
--- GNUnet/src/applications/advertising/bootstrap.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/advertising/bootstrap.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -31,7 +31,7 @@
 #include "gnunet_bootstrap_service.h"
 #include "gnunet_state_service.h"
 
-#define DEBUG_BOOTSTRAP NO
+#define DEBUG_BOOTSTRAP GNUNET_NO
 
 #define hello_HELPER_TABLE_START_SIZE 64
 
@@ -41,11 +41,11 @@
 
 static State_ServiceAPI *state;
 
-static struct PTHREAD *pt;
+static struct GNUNET_ThreadHandle *pt;
 
 typedef struct
 {
-  P2P_hello_MESSAGE **hellos;
+  GNUNET_MessageHello **hellos;
   unsigned int hellosCount;
   unsigned int hellosLen;
   int do_shutdown;
@@ -65,7 +65,7 @@
 {
   int rndidx;
   int i;
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
 
   if (NULL == hcq)
     {
@@ -75,59 +75,66 @@
   while ((!hcq->do_shutdown) && (hcq->hellosCount > 0))
     {
       /* select hellos in random order */
-      rndidx = weak_randomi (hcq->hellosCount);
+      rndidx =
+        GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, hcq->hellosCount);
 #if DEBUG_BOOTSTRAP
       GE_LOG (coreAPI->ectx,
               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];
+      msg = (GNUNET_MessageHello *) hcq->hellos[rndidx];
       hcq->hellos[rndidx] = hcq->hellos[hcq->hellosCount - 1];
-      GROW (hcq->hellos, hcq->hellosCount, hcq->hellosCount - 1);
+      GNUNET_array_grow (hcq->hellos, hcq->hellosCount, hcq->hellosCount - 1);
 
       coreAPI->injectMessage (NULL,
                               (const char *) msg,
-                              ntohs (msg->header.size), NO, NULL);
-      FREE (msg);
+                              ntohs (msg->header.size), GNUNET_NO, NULL);
+      GNUNET_free (msg);
       if ((hcq->hellosCount > 0) && (!hlc.do_shutdown))
         {
           /* wait a bit */
           unsigned int load;
           int nload;
-          load = os_cpu_get_load (coreAPI->ectx, coreAPI->cfg);
+          load = GNUNET_cpu_get_load (coreAPI->ectx, coreAPI->cfg);
           if (load == (unsigned int) -1)
             load = 50;
-          nload = os_network_monitor_get_load (coreAPI->load_monitor, Upload);
+          nload =
+            GNUNET_network_monitor_get_load (coreAPI->load_monitor,
+                                             GNUNET_ND_UPLOAD);
           if (nload > load)
             load = nload;
-          nload = os_network_monitor_get_load (coreAPI->load_monitor,
-                                               Download);
+          nload = GNUNET_network_monitor_get_load (coreAPI->load_monitor,
+                                                   GNUNET_ND_DOWNLOAD);
           if (nload > load)
             load = nload;
           if (load > 100)
             load = 100;
 
-          PTHREAD_SLEEP (50 + weak_randomi ((load + 1) * (load + 1)));
+          GNUNET_thread_sleep (50 +
+                               GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                                                  (load + 1) * (load + 1)));
         }
     }
   for (i = 0; i < hcq->hellosCount; i++)
-    FREE (hcq->hellos[i]);
-  GROW (hcq->hellos, hcq->hellosCount, 0);
+    GNUNET_free (hcq->hellos[i]);
+  GNUNET_array_grow (hcq->hellos, hcq->hellosCount, 0);
 }
 
 static void
-downloadHostlistCallback (const P2P_hello_MESSAGE * hello, void *c)
+downloadHostlistCallback (const GNUNET_MessageHello * hello, void *c)
 {
   HelloListClosure *cls = c;
   if (cls->hellosCount >= cls->hellosLen)
     {
-      GROW (cls->hellos,
-            cls->hellosLen, cls->hellosLen + hello_HELPER_TABLE_START_SIZE);
+      GNUNET_array_grow (cls->hellos,
+                         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));
+  cls->hellos[cls->hellosCount++] =
+    GNUNET_malloc (ntohs (hello->header.size));
+  memcpy (cls->hellos[cls->hellosCount - 1], hello,
+          ntohs (hello->header.size));
 }
 
 #define BOOTSTRAP_INFO "bootstrap-info"
@@ -135,21 +142,22 @@
 static int
 needBootstrap ()
 {
-  static cron_t lastTest;
-  static cron_t delta;
-  cron_t now;
+  static GNUNET_CronTime lastTest;
+  static GNUNET_CronTime delta;
+  GNUNET_CronTime now;
   char *data;
 
-  now = get_time ();
-  if (coreAPI->forAllConnectedNodes (NULL, NULL) >= MIN_CONNECTION_TARGET)
+  now = GNUNET_get_time ();
+  if (coreAPI->forAllConnectedNodes (NULL, NULL) >=
+      GNUNET_MIN_CONNECTION_TARGET)
     {
       /* still change delta and lastTest; even
          if the peer _briefly_ drops below MCT
          connections, we don't want it to immediately
          go for the hostlist... */
-      delta = 5 * cronMINUTES;
+      delta = 5 * GNUNET_CRON_MINUTES;
       lastTest = now;
-      return NO;
+      return GNUNET_NO;
     }
   if (lastTest == 0)
     {
@@ -158,14 +166,14 @@
         {
           /* but not first on this machine */
           lastTest = now;
-          delta = 2 * cronMINUTES;      /* wait 2 minutes */
-          FREE (data);
+          delta = 2 * GNUNET_CRON_MINUTES;      /* wait 2 minutes */
+          GNUNET_free (data);
         }
       else
         {
           /* first on this machine, too! */
           state->write (coreAPI->ectx, BOOTSTRAP_INFO, 1, "X");
-          delta = 60 * cronSECONDS;
+          delta = 60 * GNUNET_CRON_SECONDS;
         }
     }
   if (now - lastTest > delta)
@@ -176,25 +184,25 @@
          we know (identity).
          Sure, in the end it goes to the topology, so
          probably that API should be extended here... */
-      return YES;
+      return GNUNET_YES;
     }
   /* wait a bit longer */
-  return NO;
+  return GNUNET_NO;
 }
 
 static void *
 processThread (void *unused)
 {
   hlc.hellos = NULL;
-  while (NO == hlc.do_shutdown)
+  while (GNUNET_NO == hlc.do_shutdown)
     {
-      while (NO == hlc.do_shutdown)
+      while (GNUNET_NO == hlc.do_shutdown)
         {
-          PTHREAD_SLEEP (2 * cronSECONDS);
+          GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
           if (needBootstrap ())
             break;
         }
-      if (YES == hlc.do_shutdown)
+      if (GNUNET_YES == hlc.do_shutdown)
         break;
 #if DEBUG_BOOTSTRAP
       GE_LOG (coreAPI->ectx, GE_DEBUG | GE_REQUEST | GE_USER,
@@ -204,7 +212,7 @@
       hlc.hellosCount = 0;
       bootstrap->bootstrap (&downloadHostlistCallback,
                             &hlc, &testTerminate, &hlc);
-      GROW (hlc.hellos, hlc.hellosLen, hlc.hellosCount);
+      GNUNET_array_grow (hlc.hellos, hlc.hellosLen, hlc.hellosCount);
       processhellos (&hlc);
     }
   return NULL;
@@ -222,8 +230,8 @@
   GE_ASSERT (capi->ectx, state != NULL);
   bootstrap = capi->requestService ("bootstrap");
   GE_ASSERT (capi->ectx, bootstrap != NULL);
-  hlc.do_shutdown = NO;
-  pt = PTHREAD_CREATE (&processThread, NULL, 64 * 1024);
+  hlc.do_shutdown = GNUNET_NO;
+  pt = GNUNET_thread_create (&processThread, NULL, 64 * 1024);
   GE_ASSERT (capi->ectx, pt != NULL);
 }
 
@@ -235,9 +243,9 @@
 {
   void *unused;
 
-  hlc.do_shutdown = YES;
-  PTHREAD_STOP_SLEEP (pt);
-  PTHREAD_JOIN (pt, &unused);
+  hlc.do_shutdown = GNUNET_YES;
+  GNUNET_thread_stop_sleep (pt);
+  GNUNET_thread_join (pt, &unused);
   pt = NULL;
   coreAPI->releaseService (bootstrap);
   bootstrap = NULL;

Modified: GNUnet/src/applications/bootstrap_http/Makefile.am
===================================================================
--- GNUnet/src/applications/bootstrap_http/Makefile.am  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/bootstrap_http/Makefile.am  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -8,8 +8,7 @@
 libgnunetmodule_bootstrap_la_SOURCES = \
   http.c 
 libgnunetmodule_bootstrap_la_LIBADD = @LIBCURL@ \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 libgnunetmodule_bootstrap_la_LDFLAGS = \
   -export-dynamic -avoid-version -module 
 libgnunetmodule_bootstrap_la_CPPFLAGS = \
@@ -24,6 +23,5 @@
 httptest_SOURCES = \
   httptest.c 
 httptest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 

Modified: GNUnet/src/applications/bootstrap_http/http.c
===================================================================
--- GNUnet/src/applications/bootstrap_http/http.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/bootstrap_http/http.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -66,12 +66,12 @@
 } BootstrapContext;
 
 #ifndef MINGW
-#define USE_MULTI YES
+#define USE_MULTI GNUNET_YES
 #else
   /* FIXME: plibc needs to know about handle types in SELECT(),
      figure out whether curl only returns sockets from
      curl_multi_fdset() */
-#define USE_MULTI NO
+#define USE_MULTI GNUNET_NO
 #endif
 
 /**
@@ -83,7 +83,7 @@
   BootstrapContext *bctx = ctx;
   size_t osize;
   unsigned int total;
-  const P2P_hello_MESSAGE *hello;
+  const GNUNET_MessageHello *hello;
   unsigned int hs;
 
   bctx->total += size * nmemb;
@@ -91,18 +91,18 @@
     return 0;                   /* ok, no data */
   osize = bctx->bsize;
   total = size * nmemb + osize;
-  GROW (bctx->buf, bctx->bsize, total);
+  GNUNET_array_grow (bctx->buf, bctx->bsize, total);
   memcpy (&bctx->buf[osize], ptr, size * nmemb);
-  while ((bctx->bsize >= sizeof (P2P_hello_MESSAGE)) &&
+  while ((bctx->bsize >= sizeof (GNUNET_MessageHello)) &&
          (bctx->termTest (bctx->targ)))
     {
-      hello = (const P2P_hello_MESSAGE *) &bctx->buf[0];
+      hello = (const GNUNET_MessageHello *) &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) != GNUNET_sizeof_hello (hello)) ||
+          (GNUNET_sizeof_hello (hello) >= GNUNET_MAX_BUFFER_SIZE))
         {
           GE_LOG (ectx,
                   GE_WARNING | GE_USER | GE_IMMEDIATE,
@@ -114,7 +114,7 @@
         stats->change (stat_hellodownloaded, 1);
       bctx->callback (hello, bctx->arg);
       memmove (&bctx->buf[0], &bctx->buf[hs], bctx->bsize - hs);
-      GROW (bctx->buf, bctx->bsize, bctx->bsize - hs);
+      GNUNET_array_grow (bctx->buf, bctx->bsize, bctx->bsize - hs);
     }
   return size * nmemb;
 }
@@ -175,7 +175,7 @@
               GE_WARNING | GE_BULK | GE_USER,
               _
               ("No hostlist URL specified in configuration, will not 
bootstrap.\n"));
-      FREE (url);
+      GNUNET_free (url);
       curl_easy_cleanup (curl);
       return;
     }
@@ -193,11 +193,11 @@
     }
   if (urls == 0)
     {
-      FREE (url);
+      GNUNET_free (url);
       curl_easy_cleanup (curl);
       return;
     }
-  urls = weak_randomi (urls) + 1;
+  urls = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, urls) + 1;
   pos = strlen (url) - 1;
   while (pos > 0)
     {
@@ -256,7 +256,8 @@
               __FILE__, __LINE__, curl_multi_strerror (mret));
       goto cleanup;
     }
-  while ((YES == termTest (targ)) && (GNUNET_SHUTDOWN_TEST () == NO))
+  while ((GNUNET_YES == termTest (targ))
+         && (GNUNET_shutdown_test () == GNUNET_NO))
     {
       max = 0;
       FD_ZERO (&rs);
@@ -278,7 +279,7 @@
       tv.tv_sec = 0;
       tv.tv_usec = 1000;
       SELECT (max + 1, &rs, &ws, &es, &tv);
-      if (YES != termTest (targ))
+      if (GNUNET_YES != termTest (targ))
         break;
       do
         {
@@ -312,7 +313,8 @@
               break;
             }
         }
-      while ((mret == CURLM_CALL_MULTI_PERFORM) && (YES == termTest (targ)));
+      while ((mret == CURLM_CALL_MULTI_PERFORM)
+             && (GNUNET_YES == termTest (targ)));
       if ((mret != CURLM_OK) && (mret != CURLM_CALL_MULTI_PERFORM))
         {
           GE_LOG (ectx,
@@ -357,8 +359,8 @@
   GE_LOG (ectx,
           GE_INFO | GE_BULK | GE_USER,
           _("Downloaded %llu bytes from `%s'.\n"), bctx.total, url);
-  FREE (url);
-  FREE (proxy);
+  GNUNET_free (url);
+  GNUNET_free (proxy);
   curl_global_cleanup ();
   return;
 cleanup:
@@ -372,8 +374,8 @@
   if (multi != NULL)
     curl_multi_cleanup (multi);
 #endif
-  FREE (url);
-  FREE (proxy);
+  GNUNET_free (url);
+  GNUNET_free (proxy);
   curl_global_cleanup ();
 }
 

Modified: GNUnet/src/applications/bootstrap_http/httptest.c
===================================================================
--- GNUnet/src/applications/bootstrap_http/httptest.c   2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/bootstrap_http/httptest.c   2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -45,14 +45,14 @@
 static int
 rsx (void *s)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 static unsigned int count;
 
 
 static void
-hello (const P2P_hello_MESSAGE * m, void *arg)
+hello (const GNUNET_MessageHello * m, void *arg)
 {
   count++;
 }
@@ -60,9 +60,9 @@
 static int
 terminate (void *arg)
 {
-  if (GNUNET_SHUTDOWN_TEST () == YES)
-    return NO;
-  return YES;                   /* todo: add timeout? */
+  if (GNUNET_shutdown_test () == GNUNET_YES)
+    return GNUNET_NO;
+  return GNUNET_YES;            /* todo: add timeout? */
 }
 
 static void *
@@ -79,15 +79,15 @@
 {
   static CoreAPIForApplication capi;
   struct GC_Configuration *cfg;
-  struct PluginHandle *plugin;
+  struct GNUNET_PluginHandle *plugin;
   Bootstrap_ServiceAPI *boot;
-  struct PTHREAD *p;
+  struct GNUNET_ThreadHandle *p;
   void *unused;
   ServiceInitMethod init;
   ServiceDoneMethod done;
 
   count = 0;
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   GC_set_configuration_value_string (cfg,
                                      NULL,
                                      "GNUNETD",
@@ -97,14 +97,16 @@
   capi.cfg = cfg;
   capi.requestService = &rs;
   capi.releaseService = &rsx;
-  plugin = os_plugin_load (NULL, "libgnunetmodule_", "bootstrap");
-  init = os_plugin_resolve_function (plugin, "provide_module_", YES);
+  plugin = GNUNET_plugin_load (NULL, "libgnunetmodule_", "bootstrap");
+  init =
+    GNUNET_plugin_resolve_function (plugin, "provide_module_", GNUNET_YES);
   boot = init (&capi);
-  p = PTHREAD_CREATE (&pt, boot, 1024 * 64);
-  PTHREAD_JOIN (p, &unused);
-  done = os_plugin_resolve_function (plugin, "release_module_", YES);
+  p = GNUNET_thread_create (&pt, boot, 1024 * 64);
+  GNUNET_thread_join (p, &unused);
+  done =
+    GNUNET_plugin_resolve_function (plugin, "release_module_", GNUNET_YES);
   done ();
-  os_plugin_unload (plugin);
+  GNUNET_plugin_unload (plugin);
   GC_free (cfg);
   if (count == 0)
     return 1;

Modified: GNUnet/src/applications/chat/Makefile.am
===================================================================
--- GNUnet/src/applications/chat/Makefile.am    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/chat/Makefile.am    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -15,8 +15,6 @@
   gnunet-chat.c 
 gnunet_chat_LDADD = \
   $(top_builddir)/src/applications/chat/libgnunetchat.so \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
 libgnunetchat_api_la_SOURCES = \
@@ -31,5 +29,4 @@
 libgnunetmodule_chat_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 libgnunetmodule_chat_la_LIBADD = \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
+  $(top_builddir)/src/util/libgnunetutil.la 

Modified: GNUnet/src/applications/chat/chat.c
===================================================================
--- GNUnet/src/applications/chat/chat.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/chat/chat.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -37,33 +37,33 @@
 
 static ClientHandle clients[MAX_CLIENTS];
 static int clientCount;
-static HashCode512 lastMsgs[MAX_LAST_MESSAGES];
+static GNUNET_HashCode lastMsgs[MAX_LAST_MESSAGES];
 static int ringIndex;
 static Mutex chatMutex;
 
 static void
-markSeen (HashCode512 * hc)
+markSeen (GNUNET_HashCode * hc)
 {
   if (++ringIndex >= MAX_LAST_MESSAGES)
     ringIndex = 0;
-  memcpy (&lastMsgs[ringIndex], hc, sizeof (HashCode512));
+  memcpy (&lastMsgs[ringIndex], hc, sizeof (GNUNET_HashCode));
 }
 
 typedef struct
 {
-  const MESSAGE_HEADER *message;
+  const GNUNET_MessageHeader *message;
   unsigned int prio;
   unsigned int delay;
 } BCC;
 
 static void
-bccHelper (const PeerIdentity * peer, BCC * bcc)
+bccHelper (const GNUNET_PeerIdentity * peer, BCC * bcc)
 {
   coreAPI->unicast (peer, bcc->message, bcc->prio, bcc->delay);
 }
 
 static void
-broadcastToConnected (const MESSAGE_HEADER * message,
+broadcastToConnected (const GNUNET_MessageHeader * message,
                       unsigned int prio, unsigned int delay)
 {
   BCC bcc;
@@ -74,29 +74,30 @@
 }
 
 static int
-handleChatMSG (const PeerIdentity * sender, const MESSAGE_HEADER * message)
+handleChatMSG (const GNUNET_PeerIdentity * sender,
+               const GNUNET_MessageHeader * message)
 {
   int i;
   int j;
   CS_chat_MESSAGE *cmsg;
   P2P_chat_MESSAGE *pmsg;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 
   if (ntohs (message->size) != sizeof (P2P_chat_MESSAGE))
     {
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("Message received from peer is invalid.\n"));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   pmsg = (P2P_chat_MESSAGE *) message;
   cmsg = (CS_chat_MESSAGE *) message;
 
   /* check if we have seen this message already */
-  hash (pmsg, sizeof (P2P_chat_MESSAGE), &hc);
+  GNUNET_hash (pmsg, sizeof (P2P_chat_MESSAGE), &hc);
   j = -1;
-  MUTEX_LOCK (&chatMutex);
+  GNUNET_mutex_lock (&chatMutex);
   for (i = 0; i < MAX_LAST_MESSAGES; i++)
-    if (equalsHashCode512 (&hc, &lastMsgs[i]))
+    if (0 == memcmp (&hc, &lastMsgs[i], sizeof (GNUNET_HashCode)))
       j = i;
   if (j == -1)
     {
@@ -116,8 +117,8 @@
          &pmsg->message[0]);
        */
     }
-  MUTEX_UNLOCK (&chatMutex);
-  return OK;
+  GNUNET_mutex_unlock (&chatMutex);
+  return GNUNET_OK;
 }
 
 static int
@@ -127,18 +128,18 @@
   int j;
   CS_chat_MESSAGE *cmsg;
   P2P_chat_MESSAGE *pmsg;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 
   if (ntohs (message->size) != sizeof (CS_chat_MESSAGE))
     {
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("Message received from client is invalid\n"));
-      return SYSERR;            /* invalid message */
+      return GNUNET_SYSERR;     /* invalid message */
     }
   pmsg = (P2P_chat_MESSAGE *) message;
   cmsg = (CS_chat_MESSAGE *) message;
-  hash (pmsg, sizeof (P2P_chat_MESSAGE), &hc);
-  MUTEX_LOCK (&chatMutex);
+  GNUNET_hash (pmsg, sizeof (P2P_chat_MESSAGE), &hc);
+  GNUNET_mutex_lock (&chatMutex);
   markSeen (&hc);
 
   /* forward to all other TCP chat clients */
@@ -164,15 +165,15 @@
   /* forward to all other nodes in the network */
   pmsg->header.type = htons (P2P_PROTO_chat_MSG);
   broadcastToConnected (&pmsg->header, 5, 1);
-  MUTEX_UNLOCK (&chatMutex);
-  return OK;
+  GNUNET_mutex_unlock (&chatMutex);
+  return GNUNET_OK;
 }
 
 static void
 chatClientExitHandler (ClientHandle client)
 {
   int i;
-  MUTEX_LOCK (&chatMutex);
+  GNUNET_mutex_lock (&chatMutex);
   for (i = 0; i < clientCount; i++)
     if (clients[i] == client)
       {
@@ -181,34 +182,36 @@
         clients[i] = clients[--clientCount];
         break;
       }
-  MUTEX_UNLOCK (&chatMutex);
+  GNUNET_mutex_unlock (&chatMutex);
 }
 
 /**
  * Initialize the AFS module. This method name must match
  * the library name (libgnunet_XXX => initialize_XXX).
- * @return SYSERR on errors
+ * @return GNUNET_SYSERR on errors
  */
 int
 initialize_module_chat (CoreAPIForApplication * capi)
 {
-  int ok = OK;
+  int ok = GNUNET_OK;
 
   GE_ASSERT (ectx, sizeof (P2P_chat_MESSAGE) == sizeof (CS_chat_MESSAGE));
-  MUTEX_CREATE (&chatMutex);
+  GNUNET_mutex_create (&chatMutex);
   clientCount = 0;
   coreAPI = capi;
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           _("`%s' registering handlers %d and %d\n"),
           "chat", P2P_PROTO_chat_MSG, CS_PROTO_chat_MSG);
 
-  if (SYSERR == capi->registerHandler (P2P_PROTO_chat_MSG, &handleChatMSG))
-    ok = SYSERR;
-  if (SYSERR == capi->registerClientExitHandler (&chatClientExitHandler))
-    ok = SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_chat_MSG,
-                                             &csHandleChatRequest))
-    ok = SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (P2P_PROTO_chat_MSG, &handleChatMSG))
+    ok = GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientExitHandler (&chatClientExitHandler))
+    ok = GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerClientHandler (CS_PROTO_chat_MSG,
+                                                    &csHandleChatRequest))
+    ok = GNUNET_SYSERR;
 
   GE_ASSERT (capi->ectx,
              0 == GC_set_configuration_value_string (capi->cfg,
@@ -226,7 +229,7 @@
   coreAPI->unregisterHandler (P2P_PROTO_chat_MSG, &handleChatMSG);
   coreAPI->unregisterClientExitHandler (&chatClientExitHandler);
   coreAPI->unregisterClientHandler (CS_PROTO_chat_MSG, &csHandleChatRequest);
-  MUTEX_DESTROY (&chatMutex);
+  GNUNET_mutex_destroy (&chatMutex);
   coreAPI = NULL;
 }
 

Modified: GNUnet/src/applications/chat/chat.h
===================================================================
--- GNUnet/src/applications/chat/chat.h 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/chat/chat.h 2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
 
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   char nick[CHAT_NICK_LENGTH];
   char message[CHAT_MSG_LENGTH];
 } P2P_chat_MESSAGE;

Modified: GNUnet/src/applications/chat/clientapi.c
===================================================================
--- GNUnet/src/applications/chat/clientapi.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/chat/clientapi.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -35,9 +35,9 @@
  */
 struct GNUNET_CHAT_Room
 {
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
 
-  struct PTHREAD *listen_thread;
+  struct GNUNET_ThreadHandle *listen_thread;
 
   struct GE_Context *ectx;
 
@@ -45,13 +45,13 @@
 
   char *nickname;
 
-  const PublicKey *my_public_key;
+  const GNUNET_RSA_PublicKey *my_public_key;
 
-  const struct PrivateKey *my_private_key;
+  const struct GNUNET_RSA_PrivateKey *my_private_key;
 
   char *memberInfo;
 
-  GNUNET_CHAT_Message_Callback callback;
+  GNUNET_CHAT_MessageCallback callback;
 
   void *callback_cls;
 
@@ -66,34 +66,34 @@
 
 /**
  * List all of the (publically visible) chat rooms.
- * @return number of rooms on success, SYSERR if iterator aborted
+ * @return number of rooms on success, GNUNET_SYSERR if iterator aborted
  */
 int
 GNUNET_CHAT_list_rooms (struct GE_Context *ectx,
                         struct GC_Configuration *cfg,
-                        GNUNET_CHAT_Room_Iterator it, void *cls)
+                        GNUNET_CHAT_RoomIterator it, void *cls)
 {
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
- * Join a chat room.  
+ * Join a chat room.
  *
  * @param nickname the nick you want to use
  * @param memberInfo public information about you
  * @param callback which function to call if a message has
  *        been received?
  * @param cls argument to callback
- * @return NULL on error 
+ * @return NULL on error
  */
 struct GNUNET_CHAT_Room *
 GNUNET_CHAT_join_room (struct GE_Context *ectx,
                        struct GC_Configuration *cfg,
                        const char *nickname,
-                       const PublicKey * me,
-                       const struct PrivateKey *key,
+                       const GNUNET_RSA_PublicKey * me,
+                       const struct GNUNET_RSA_PrivateKey *key,
                        const char *memberInfo,
-                       GNUNET_CHAT_Message_Callback callback, void *cls)
+                       GNUNET_CHAT_MessageCallback callback, void *cls)
 {
   // connect
 
@@ -120,28 +120,28 @@
  * Send a message.
  *
  * @param receiver use NULL to send to everyone in the room
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
 GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room,
                           const char *message,
-                          GNUNET_CHAT_Message_Confirmation callback,
+                          GNUNET_CHAT_MessageConfirmation callback,
                           void *cls,
                           GNUNET_CHAT_MSG_OPTIONS options,
-                          const PublicKey * receiver)
+                          const GNUNET_RSA_PublicKey * receiver)
 {
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
  * List all of the (known) chat members.
- * @return number of rooms on success, SYSERR if iterator aborted
+ * @return number of rooms on success, GNUNET_SYSERR if iterator aborted
  */
 int
 GNUNET_CHAT_list_members (struct GNUNET_CHAT_Room *room,
-                          GNUNET_CHAT_Member_Iterator it, void *cls)
+                          GNUNET_CHAT_MemberIterator it, void *cls)
 {
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 

Modified: GNUnet/src/applications/chat/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/gnunet-chat.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/chat/gnunet-chat.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -41,19 +41,19 @@
 /**
  * All gnunet-chat command line options
  */
-static struct CommandLineOption gnunetchatOptions[] = {
+static struct GNUNET_CommandLineOption gnunetchatOptions[] = {
   COMMAND_LINE_OPTION_HELP (gettext_noop ("Join a chat on GNUnet.")),   /* -h 
*/
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'n', "nick", "NAME",
    gettext_noop ("set the nickname to use (requred)"),
-   1, &gnunet_getopt_configure_set_string, &nickname},
+   1, &GNUNET_getopt_configure_set_string, &nickname},
   {'r', "room", "NAME",
    gettext_noop ("set the chat room to join (requred)"),
-   1, &gnunet_getopt_configure_set_string, &roomname},
+   1, &GNUNET_getopt_configure_set_string, &roomname},
   COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 /**
@@ -68,18 +68,18 @@
  *        the user is merely asked if engaging in the exchange is ok
  * @param room in which room was the message received?
  * @param options options for the message
- * @return OK to accept the message now, NO to 
- *         accept (but user is away), SYSERR to signal denied delivery
+ * @return GNUNET_OK to accept the message now, GNUNET_NO to
+ *         accept (but user is away), GNUNET_SYSERR to signal denied delivery
  */
 static int
 receive_callback (void *cls,
                   struct GNUNET_CHAT_Room *room,
                   const char *senderNick,
                   const char *message,
-                  cron_t timestamp, GNUNET_CHAT_MSG_OPTIONS options)
+                  GNUNET_CronTime timestamp, GNUNET_CHAT_MSG_OPTIONS options)
 {
   fprintf (stdout, "%s: %s\n", senderNick, message);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -90,23 +90,23 @@
  * @param message the message (maybe NULL)
  * @param room in which room was the message received?
  * @param options what were the options of the message
- * @param response what was the receivers response (OK, NO, SYSERR).
+ * @param response what was the receivers response (GNUNET_OK, GNUNET_NO, 
GNUNET_SYSERR).
  * @param receipt signature confirming delivery (maybe NULL, only
  *        if confirmation was requested)
- * @return OK to continue, SYSERR to refuse processing further
+ * @return GNUNET_OK to continue, GNUNET_SYSERR to refuse processing further
  *         confirmations from anyone for this message
  */
 static int
 confirmation_callback (void *cls,
                        struct GNUNET_CHAT_Room *room,
                        const char *receiverNick,
-                       const PublicKey * receiverKey,
+                       const GNUNET_RSA_PublicKey * receiverKey,
                        const char *message,
-                       cron_t timestamp,
+                       GNUNET_CronTime timestamp,
                        GNUNET_CHAT_MSG_OPTIONS options,
-                       int response, const Signature * receipt)
+                       int response, const GNUNET_RSA_Signature * receipt)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -120,14 +120,15 @@
 main (int argc, char **argv)
 {
   struct GNUNET_CHAT_Room *room;
-  PublicKey *my_pub;
-  struct PrivateKey *my_priv;
+  GNUNET_RSA_PublicKey *my_pub;
+  struct GNUNET_RSA_PrivateKey *my_priv;
   char message[1024];
 
-  if (SYSERR == GNUNET_init (argc,
-                             argv,
-                             "gnunet-chat [OPTIONS]",
-                             &cfgFilename, gnunetchatOptions, &ectx, &cfg))
+  if (GNUNET_SYSERR == GNUNET_init (argc,
+                                    argv,
+                                    "gnunet-chat [OPTIONS]",
+                                    &cfgFilename, gnunetchatOptions, &ectx,
+                                    &cfg))
     return 1;                   /* parse error, --help, etc. */
   if (nickname == NULL)
     {
@@ -151,11 +152,12 @@
       memset (message, 0, 1024);
       if (NULL == fgets (message, 1023, stdin))
         break;
-      if (OK != GNUNET_CHAT_send_message (room,
-                                          message,
-                                          &confirmation_callback,
-                                          NULL,
-                                          GNUNET_CHAT_MSG_OPTION_NONE, NULL))
+      if (GNUNET_OK != GNUNET_CHAT_send_message (room,
+                                                 message,
+                                                 &confirmation_callback,
+                                                 NULL,
+                                                 GNUNET_CHAT_MSG_OPTION_NONE,
+                                                 NULL))
         {
           fprintf (stderr, _("Failed to send message.\n"));
         }

Modified: GNUnet/src/applications/datastore/Makefile.am
===================================================================
--- GNUnet/src/applications/datastore/Makefile.am       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/datastore/Makefile.am       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -12,8 +12,5 @@
 libgnunetmodule_datastore_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 libgnunetmodule_datastore_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/containers/libgnunetutil_containers.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 

Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/datastore/datastore.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -38,7 +38,7 @@
 #include "filter.h"
 #include "prefetch.h"
 
-#define DEBUG_DATASTORE NO
+#define DEBUG_DATASTORE GNUNET_NO
 
 /**
  * SQ-store handle
@@ -65,7 +65,7 @@
  */
 static unsigned long long quota;
 
-static struct CronManager *cron;
+static struct GNUNET_CronManager *cron;
 
 static Stats_ServiceAPI *stats;
 
@@ -76,21 +76,23 @@
 /**
  * Time at which the database was created (used for
  * content aging).
- */ 
-static TIME_T db_creation_time;
+ */
+static GNUNET_Int32Time db_creation_time;
 
 /**
  * Require 1/100th of quota to be 'free' space.
  */
-#define MIN_FREE (quota / 100)
+#define MIN_GNUNET_free (quota / 100)
 
 /**
  * One month of database uptime corresponds to one
  * priority point.
  */
-static int comp_priority() {
-  TIME_T now;
-  TIME(&now);
+static int
+comp_priority ()
+{
+  GNUNET_Int32Time now;
+  GNUNET_get_time_int32 (&now);
   if (db_creation_time < now)
     return 0;
   return (db_creation_time - now) / 60 / 60 / 24 / 30;
@@ -103,7 +105,7 @@
 }
 
 static int
-get (const HashCode512 * query,
+get (const GNUNET_HashCode * query,
      unsigned int type, Datum_Iterator iter, void *closure)
 {
   int ret;
@@ -111,12 +113,12 @@
   if (!testAvailable (query))
     {
 #if DEBUG_DATASTORE
-      EncName enc;
+      GNUNET_EncName enc;
 
       IF_GELOG (coreAPI->ectx,
-                GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (query, &enc));
-      GE_LOG (coreAPI->ectx,
-              GE_DEBUG | GE_REQUEST | GE_USER,
+                GE_DEBUG | GE_REQUEST | GE_USER, GNUNET_hash_to_enc (query,
+                                                                     &enc));
+      GE_LOG (coreAPI->ectx, GE_DEBUG | GE_REQUEST | GE_USER,
               "Datastore availability pre-test failed for `%s'.\n", &enc);
 #endif
       if (stats != NULL)
@@ -131,38 +133,38 @@
 
 
 static int
-deleteCB (const HashCode512 * key,
+deleteCB (const GNUNET_HashCode * key,
           const Datastore_Value * value, void *closure,
           unsigned long long uid)
 {
   const Datastore_Value *have = closure;
   if (have == NULL)
-    return NO;
+    return GNUNET_NO;
   if ((value->size == have->size) &&
       (0 == memcmp (&have[1],
                     &value[1],
                     ntohl (value->size) - sizeof (Datastore_Value))))
-    return NO;
-  return OK;
+    return GNUNET_NO;
+  return GNUNET_OK;
 }
 
 /**
  * Explicitly remove some content from the database.
  */
 static int
-del (const HashCode512 * query, const Datastore_Value * value)
+del (const GNUNET_HashCode * query, const Datastore_Value * value)
 {
   int ok;
-  EncName enc;
+  GNUNET_EncName enc;
 
   if (!testAvailable (query))
     {
       IF_GELOG (coreAPI->ectx,
-                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, GNUNET_hash_to_enc (query,
+                                                                    &enc));
+      GE_LOG (coreAPI->ectx, GE_WARNING | GE_BULK | GE_USER,
+              _("Availability test failed for `%s' at %s:%d.\n"), &enc,
+              __FILE__, __LINE__);
       return 0;
     }
   ok = sq->get (query, ntohl (value->type), &deleteCB, (void *) value);
@@ -178,45 +180,45 @@
  * Store an item in the datastore.  If the item is
  * already present, a second copy is created.
  *
- * @return YES on success, NO if the datastore is
+ * @return GNUNET_YES on success, GNUNET_NO if the datastore is
  *   full and the priority of the item is not high enough
- *   to justify removing something else, SYSERR on
+ *   to justify removing something else, GNUNET_SYSERR on
  *   other serious error (i.e. IO permission denied)
  */
 static int
-put (const HashCode512 * key, const Datastore_Value * value)
+put (const GNUNET_HashCode * key, const Datastore_Value * value)
 {
   int ok;
-  Datastore_Value * nvalue;
+  Datastore_Value *nvalue;
 
   /* check if we have enough space / priority */
-  if (ntohll (value->expirationTime) < get_time ())
+  if (GNUNET_ntohll (value->expirationTime) < GNUNET_get_time ())
     {
       GE_LOG (coreAPI->ectx,
               GE_INFO | GE_REQUEST | GE_USER,
               "Received content for put already expired!\n");
-      return NO;
+      return GNUNET_NO;
     }
   if ((available < ntohl (value->size)) &&
-      (minPriority > ntohl (value->prio) + comp_priority()))
+      (minPriority > ntohl (value->prio) + comp_priority ()))
     {
       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);
-      return NO;                /* new content has such a low priority that
+      return GNUNET_NO;         /* new content has such a low priority that
                                    we should not even bother! */
     }
   if (ntohl (value->prio) < minPriority)
     minPriority = ntohl (value->prio);
   /* construct new value with comp'ed priority */
-  nvalue = MALLOC(ntohl(value->size));
-  memcpy(nvalue, value, ntohl(value->size));
-  nvalue->prio = htonl(comp_priority() + ntohl(value->prio));
+  nvalue = GNUNET_malloc (ntohl (value->size));
+  memcpy (nvalue, value, ntohl (value->size));
+  nvalue->prio = htonl (comp_priority () + ntohl (value->prio));
   /* add the content */
   ok = sq->put (key, nvalue);
-  FREE(nvalue);
-  if (ok == YES)
+  GNUNET_free (nvalue);
+  if (ok == GNUNET_YES)
     {
       makeAvailable (key);
       available -= ntohl (value->size);
@@ -233,7 +235,7 @@
 } CE;
 
 static int
-checkExists (const HashCode512 * key,
+checkExists (const GNUNET_HashCode * key,
              const Datastore_Value * value, void *cls, unsigned long long uid)
 {
   CE *ce = cls;
@@ -242,11 +244,11 @@
       (0 != memcmp (&value[1],
                     &ce->value[1],
                     ntohl (value->size) - sizeof (Datastore_Value))))
-    return OK;                  /* found another value, but different content! 
*/
+    return GNUNET_OK;           /* found another value, but different content! 
*/
   ce->uid = uid;
-  ce->expiration = ntohll (value->expirationTime);
-  ce->exists = YES;
-  return SYSERR;                /* abort iteration! */
+  ce->expiration = GNUNET_ntohll (value->expirationTime);
+  ce->exists = GNUNET_YES;
+  return GNUNET_SYSERR;         /* abort iteration! */
 }
 
 /**
@@ -254,21 +256,21 @@
  * the priorities are summed up and the higher expiration time and
  * lower anonymity level is used.
  *
- * @return YES on success, NO if the datastore is
+ * @return GNUNET_YES on success, GNUNET_NO if the datastore is
  *   full and the priority of the item is not high enough
- *   to justify removing something else, SYSERR on
+ *   to justify removing something else, GNUNET_SYSERR on
  *   other serious error (i.e. IO permission denied)
  */
 static int
-putUpdate (const HashCode512 * key, const Datastore_Value * value)
+putUpdate (const GNUNET_HashCode * key, const Datastore_Value * value)
 {
   CE cls;
   int ok;
   int comp_prio;
-  Datastore_Value * nvalue;
+  Datastore_Value *nvalue;
 
   /* check if it already exists... */
-  cls.exists = NO;
+  cls.exists = GNUNET_NO;
   cls.value = value;
   sq->get (key, ntohl (value->type), &checkExists, &cls);
   if (ntohl (value->type) == D_BLOCK)
@@ -277,37 +279,38 @@
   if (cls.exists)
     {
       if ((ntohl (value->prio) == 0) &&
-          (ntohll (value->expirationTime) <= cls.expiration))
+          (GNUNET_ntohll (value->expirationTime) <= cls.expiration))
         {
-          return OK;
+          return GNUNET_OK;
         }
       /* update prio */
       sq->update (cls.uid,
-                  ntohl (value->prio), ntohll (value->expirationTime));
-      return OK;
+                  ntohl (value->prio), GNUNET_ntohll (value->expirationTime));
+      return GNUNET_OK;
     }
-  comp_prio = comp_priority();
+  comp_prio = comp_priority ();
 #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) + 
comp_prio);
+          available, ntohl (value->size), minPriority,
+          ntohl (value->prio) + comp_prio);
 #endif
   /* check if we have enough space / priority */
   if ((available < ntohl (value->size)) &&
       (minPriority > ntohl (value->prio) + comp_prio))
-    return NO;                  /* new content has such a low priority that
+    return GNUNET_NO;           /* new content has such a low priority that
                                    we should not even bother! */
   if (ntohl (value->prio) + comp_prio < minPriority)
     minPriority = ntohl (value->prio) + comp_prio;
   /* construct new value with comp'ed priority */
-  nvalue = MALLOC(ntohl(value->size));
-  memcpy(nvalue, value, ntohl(value->size));
-  nvalue->prio = htonl(comp_priority() + ntohl(value->prio));
+  nvalue = GNUNET_malloc (ntohl (value->size));
+  memcpy (nvalue, value, ntohl (value->size));
+  nvalue->prio = htonl (comp_priority () + ntohl (value->prio));
   /* add the content */
   ok = sq->put (key, nvalue);
-  FREE(nvalue);
- if (ok == YES)
+  GNUNET_free (nvalue);
+  if (ok == GNUNET_YES)
     {
       makeAvailable (key);
       available -= ntohl (value->size);
@@ -317,32 +320,32 @@
 
 /**
  * @return *closure if we are below quota,
- *         SYSERR if we have deleted all of the expired content
- *         OK if we deleted expired content and are above quota
+ *         GNUNET_SYSERR if we have deleted all of the expired content
+ *         GNUNET_OK if we deleted expired content and are above quota
  */
 static int
-freeSpaceExpired (const HashCode512 * key,
+freeSpaceExpired (const GNUNET_HashCode * key,
                   const Datastore_Value * value, void *closure,
                   unsigned long long uid)
 {
-  if ((available > 0) && (available >= MIN_FREE))
-    return SYSERR;
-  if (get_time () < ntohll (value->expirationTime))
-    return SYSERR;              /* not expired */
+  if ((available > 0) && (available >= MIN_GNUNET_free))
+    return GNUNET_SYSERR;
+  if (GNUNET_get_time () < GNUNET_ntohll (value->expirationTime))
+    return GNUNET_SYSERR;       /* not expired */
   available += ntohl (value->size);
-  return NO;
+  return GNUNET_NO;
 }
 
 static int
-freeSpaceLow (const HashCode512 * key,
+freeSpaceLow (const GNUNET_HashCode * key,
               const Datastore_Value * value, void *closure,
               unsigned long long uid)
 {
-  if ((available > 0) && (available >= MIN_FREE))
-    return SYSERR;
+  if ((available > 0) && (available >= MIN_GNUNET_free))
+    return GNUNET_SYSERR;
   minPriority = ntohl (value->prio);
   available += ntohl (value->size);
-  return NO;
+  return GNUNET_NO;
 }
 
 /**
@@ -355,11 +358,11 @@
 cronMaintenance (void *unused)
 {
   available = quota - sq->getSize ();
-  if ((available < 0) || (available < MIN_FREE))
+  if ((available < 0) || (available < MIN_GNUNET_free))
     {
       sq->iterateExpirationTime (ANY_BLOCK, &freeSpaceExpired, NULL);
-      if ((available < 0) || (available < MIN_FREE))        
-          sq->iterateLowPriority (ANY_BLOCK, &freeSpaceLow, NULL);        
+      if ((available < 0) || (available < MIN_GNUNET_free))
+        sq->iterateLowPriority (ANY_BLOCK, &freeSpaceLow, NULL);
     }
   else
     {
@@ -378,7 +381,7 @@
   unsigned long long sqot;
   State_ServiceAPI *state;
   struct stat sbuf;
-  char * fsdir;
+  char *fsdir;
 
   if (-1 == GC_get_configuration_value_number (capi->cfg,
                                                "FS",
@@ -406,7 +409,7 @@
   state = capi->requestService ("state");
   if (state != NULL)
     {
-      sqot = htonll (lquota);
+      sqot = GNUNET_htonll (lquota);
       state->write (capi->ectx,
                     "FS-LAST-QUOTA", sizeof (unsigned long long), &sqot);
       capi->releaseService (state);
@@ -430,7 +433,7 @@
     }
   coreAPI = capi;
   initPrefetch (capi->ectx, capi->cfg, sq);
-  if (OK != initFilters (capi->ectx, capi->cfg))
+  if (GNUNET_OK != initFilters (capi->ectx, capi->cfg))
     {
       GE_BREAK (capi->ectx, 0);
       donePrefetch ();
@@ -443,22 +446,23 @@
       return NULL;
     }
   fsdir = NULL;
-  GC_get_configuration_value_filename(capi->cfg,
-                                     "FS",
-                                     "DIR",
-                                     VAR_DAEMON_DIRECTORY "/data/fs/",
-                                     &fsdir);
+  GC_get_configuration_value_filename (capi->cfg,
+                                       "FS",
+                                       "DIR",
+                                       VAR_DAEMON_DIRECTORY "/data/fs/",
+                                       &fsdir);
   /* just in case dir does not exist ... */
-  disk_directory_create(NULL, fsdir);
-  if (0 == STAT(fsdir, &sbuf))
+  GNUNET_disk_directory_create (NULL, fsdir);
+  if (0 == STAT (fsdir, &sbuf))
     db_creation_time = sbuf.st_ctime;
-  FREE(fsdir);
+  GNUNET_free (fsdir);
 
   available = quota - sq->getSize ();
   cron = cron_create (capi->ectx);
-  cron_add_job (cron,
-                &cronMaintenance, 10 * cronSECONDS, 10 * cronSECONDS, NULL);
-  cron_start (cron);
+  GNUNET_cron_add_job (cron,
+                       &cronMaintenance, 10 * GNUNET_CRON_SECONDS,
+                       10 * GNUNET_CRON_SECONDS, NULL);
+  GNUNET_cron_start (cron);
   api.getSize = &getSize;
   api.put = &put;
   api.fast_get = &testAvailable;
@@ -476,9 +480,10 @@
 void
 release_module_datastore ()
 {
-  cron_stop (cron);
-  cron_del_job (cron, &cronMaintenance, 10 * cronSECONDS, NULL);
-  cron_destroy (cron);
+  GNUNET_cron_stop (cron);
+  GNUNET_cron_del_job (cron, &cronMaintenance, 10 * GNUNET_CRON_SECONDS,
+                       NULL);
+  GNUNET_cron_destroy (cron);
   cron = NULL;
   donePrefetch ();
   doneFilters ();
@@ -497,12 +502,12 @@
  * bloomfilter.
  */
 static int
-filterAddAll (const HashCode512 * key,
+filterAddAll (const GNUNET_HashCode * key,
               const Datastore_Value * value, void *closure,
               unsigned long long uid)
 {
   makeAvailable (key);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -531,13 +536,13 @@
       (sizeof (unsigned long long) == state->read (uapi->ectx,
                                                    "FS-LAST-QUOTA",
                                                    (void **) &lq)) &&
-      (ntohll (*lq) == quota))
+      (GNUNET_ntohll (*lq) == quota))
     {
       uapi->releaseService (state);
-      FREE (lq);
+      GNUNET_free (lq);
       return;                   /* no change */
     }
-  FREENONNULL (lq);
+  GNUNET_free_non_null (lq);
   /* ok, need to convert! */
   deleteFilter (uapi->ectx, uapi->cfg);
   initFilters (uapi->ectx, uapi->cfg);
@@ -558,7 +563,7 @@
   doneFilters ();
   if (state != NULL)
     {
-      lastQuota = htonll (quota);
+      lastQuota = GNUNET_htonll (quota);
       state->write (uapi->ectx,
                     "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-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/datastore/filter.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -33,7 +33,7 @@
 /**
  * Filter.
  */
-static struct Bloomfilter *filter;
+static struct GNUNET_BloomFilter *filter;
 
 static char *
 getFilterName (struct GE_Context *ectx, struct GC_Configuration *cfg)
@@ -48,15 +48,15 @@
                                                  VAR_DAEMON_DIRECTORY "/fs",
                                                  &fn))
     return NULL;
-  if (OK != disk_directory_create (ectx, fn))
+  if (GNUNET_OK != GNUNET_disk_directory_create (ectx, fn))
     {
-      FREE (fn);
+      GNUNET_free (fn);
       return NULL;
     }
-  bf = MALLOC (strlen (fn) + strlen ("/bloomfilter") + 1);
+  bf = GNUNET_malloc (strlen (fn) + strlen ("/bloomfilter") + 1);
   strcpy (bf, fn);
   strcat (bf, "/bloomfilter");
-  FREE (fn);
+  GNUNET_free (fn);
   return bf;
 }
 
@@ -73,24 +73,24 @@
                                                0,
                                                ((unsigned long long) -1) /
                                                1024 / 1024, 1024, &quota))
-    return SYSERR;
+    return GNUNET_SYSERR;
   quota *= 1024;
   bf_size = quota / 32;         /* 8 bit per entry, 1 bit per 32 kb in DB */
   bf = getFilterName (ectx, cfg);
   if (bf == NULL)
-    return SYSERR;
-  filter = loadBloomfilter (ectx, bf, bf_size, 5);      /* approx. 3% false 
positives at max use */
-  FREE (bf);
+    return GNUNET_SYSERR;
+  filter = GNUNET_bloomfilter_load (ectx, bf, bf_size, 5);      /* approx. 3% 
false positives at max use */
+  GNUNET_free (bf);
   if (filter == NULL)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 void
 doneFilters ()
 {
   if (filter != NULL)
-    freeBloomfilter (filter);
+    GNUNET_bloomfilter_free (filter);
 }
 
 void
@@ -101,25 +101,25 @@
   GE_ASSERT (ectx, filter == NULL);
   fn = getFilterName (ectx, cfg);
   UNLINK (fn);
-  FREE (fn);
+  GNUNET_free (fn);
 }
 
 void
-makeAvailable (const HashCode512 * key)
+makeAvailable (const GNUNET_HashCode * key)
 {
-  addToBloomfilter (filter, key);
+  GNUNET_bloomfilter_add (filter, key);
 }
 
 void
-makeUnavailable (const HashCode512 * key)
+makeUnavailable (const GNUNET_HashCode * key)
 {
-  delFromBloomfilter (filter, key);
+  GNUNET_bloomfilter_remove (filter, key);
 }
 
 int
-testAvailable (const HashCode512 * key)
+testAvailable (const GNUNET_HashCode * key)
 {
-  return testBloomfilter (filter, key);
+  return GNUNET_bloomfilter_test (filter, key);
 }
 
 /* end of filter.c */

Modified: GNUnet/src/applications/datastore/filter.h
===================================================================
--- GNUnet/src/applications/datastore/filter.h  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/datastore/filter.h  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -34,10 +34,10 @@
 
 void deleteFilter (struct GE_Context *ectx, struct GC_Configuration *cfg);
 
-void makeAvailable (const HashCode512 * key);
+void makeAvailable (const GNUNET_HashCode * key);
 
-void makeUnavailable (const HashCode512 * key);
+void makeUnavailable (const GNUNET_HashCode * key);
 
-int testAvailable (const HashCode512 * key);
+int testAvailable (const GNUNET_HashCode * key);
 
 #endif

Modified: GNUnet/src/applications/datastore/prefetch.c
===================================================================
--- GNUnet/src/applications/datastore/prefetch.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/datastore/prefetch.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -29,9 +29,9 @@
 #include "prefetch.h"
 #include "gnunet_protocols.h"
 
-#define DEBUG_PREFETCH NO
+#define DEBUG_PREFETCH GNUNET_NO
 
-static HashCode512 rkey;
+static GNUNET_HashCode rkey;
 
 static Datastore_Value *rvalue;
 
@@ -44,19 +44,19 @@
  * Semaphore on which the RCB acquire thread waits
  * if the RCB buffer is full.
  */
-static struct SEMAPHORE *acquireMoreSignal;
+static struct GNUNET_Semaphore *acquireMoreSignal;
 
 /**
- * Set to YES to shutdown the module.
+ * Set to GNUNET_YES to shutdown the module.
  */
 static int doneSignal;
 
 /**
  * Lock for the RCB buffer.
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
-static struct PTHREAD *gather_thread;
+static struct GNUNET_ThreadHandle *gather_thread;
 
 static struct GE_Context *ectx;
 
@@ -64,23 +64,23 @@
 
 
 static int
-acquire (const HashCode512 * key,
+acquire (const GNUNET_HashCode * key,
          const Datastore_Value * value, void *closure, unsigned long long uid)
 {
   if (doneSignal)
-    return SYSERR;
-  SEMAPHORE_DOWN (acquireMoreSignal, YES);
+    return GNUNET_SYSERR;
+  GNUNET_semaphore_down (acquireMoreSignal, GNUNET_YES);
   if (doneSignal)
-    return SYSERR;
-  MUTEX_LOCK (lock);
+    return GNUNET_SYSERR;
+  GNUNET_mutex_lock (lock);
   GE_ASSERT (NULL, rvalue == NULL);
   rkey = *key;
-  rvalue = MALLOC (ntohl (value->size));
+  rvalue = GNUNET_malloc (ntohl (value->size));
   memcpy (rvalue, value, ntohl (value->size));
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   if (doneSignal)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 /**
@@ -90,18 +90,18 @@
 rcbAcquire (void *unused)
 {
   int load;
-  while (doneSignal == NO)
+  while (doneSignal == GNUNET_NO)
     {
       sq->iterateMigrationOrder (&acquire, NULL);
       /* sleep here - otherwise we may start looping immediately
          if there is no content in the DB! */
-      load = os_cpu_get_load (ectx, cfg);
+      load = GNUNET_cpu_get_load (ectx, cfg);
       if (load < 10)
         load = 10;              /* never sleep less than 500 ms */
       if (load > 100)
         load = 100;             /* never sleep longer than 5 seconds */
-      if (doneSignal == NO)
-        PTHREAD_SLEEP (50 * cronMILLIS * load);
+      if (doneSignal == GNUNET_NO)
+        GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS * load);
     }
   return NULL;
 }
@@ -110,23 +110,23 @@
  * Select content for active migration.  Takes the best match from the
  * randomContentBuffer (if the RCB is non-empty) and returns it.
  *
- * @return SYSERR if the RCB is empty
+ * @return GNUNET_SYSERR if the RCB is empty
  */
 int
-getRandom (HashCode512 * key, Datastore_Value ** value)
+getRandom (GNUNET_HashCode * key, Datastore_Value ** value)
 {
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if (rvalue == NULL)
     {
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   *value = rvalue;
   *key = rkey;
   rvalue = NULL;
-  MUTEX_UNLOCK (lock);
-  SEMAPHORE_UP (acquireMoreSignal);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  GNUNET_semaphore_up (acquireMoreSignal);
+  return GNUNET_OK;
 }
 
 void
@@ -136,10 +136,10 @@
   ectx = e;
   cfg = c;
   sq = s;
-  acquireMoreSignal = SEMAPHORE_CREATE (1);
-  doneSignal = NO;
-  lock = MUTEX_CREATE (NO);
-  gather_thread = PTHREAD_CREATE (&rcbAcquire, NULL, 64 * 1024);
+  acquireMoreSignal = GNUNET_semaphore_create (1);
+  doneSignal = GNUNET_NO;
+  lock = GNUNET_mutex_create (GNUNET_NO);
+  gather_thread = GNUNET_thread_create (&rcbAcquire, NULL, 64 * 1024);
   if (gather_thread == NULL)
     GE_LOG_STRERROR (ectx,
                      GE_ERROR | GE_ADMIN | GE_USER | GE_IMMEDIATE,
@@ -151,16 +151,16 @@
 {
   void *unused;
 
-  doneSignal = YES;
+  doneSignal = GNUNET_YES;
   if (gather_thread != NULL)
-    PTHREAD_STOP_SLEEP (gather_thread);
-  SEMAPHORE_UP (acquireMoreSignal);
+    GNUNET_thread_stop_sleep (gather_thread);
+  GNUNET_semaphore_up (acquireMoreSignal);
   if (gather_thread != NULL)
-    PTHREAD_JOIN (gather_thread, &unused);
-  SEMAPHORE_DESTROY (acquireMoreSignal);
-  FREENONNULL (rvalue);
+    GNUNET_thread_join (gather_thread, &unused);
+  GNUNET_semaphore_destroy (acquireMoreSignal);
+  GNUNET_free_non_null (rvalue);
   rvalue = NULL;
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
   sq = NULL;
   cfg = NULL;

Modified: GNUnet/src/applications/datastore/prefetch.h
===================================================================
--- GNUnet/src/applications/datastore/prefetch.h        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/datastore/prefetch.h        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -45,9 +45,9 @@
  * @param value set to an approximate match
  * @param type if a particular type is desired, 0
  *        for any type.
- * @return OK if a value was found, SYSERR if not
+ * @return GNUNET_OK if a value was found, GNUNET_SYSERR if not
  */
-int getRandom (HashCode512 * key, Datastore_Value ** value);
+int getRandom (GNUNET_HashCode * key, Datastore_Value ** value);
 
 
 /* end of prefetch.h */

Modified: GNUnet/src/applications/dht/module/Makefile.am
===================================================================
--- GNUnet/src/applications/dht/module/Makefile.am      2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/dht/module/Makefile.am      2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -13,10 +13,7 @@
   table.c table.h 
 
 libgnunetmodule_dht_la_LIBADD = -lm \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/containers/libgnunetutil_containers.la \
  $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
  $(top_builddir)/src/applications/rpc/libgnunetrpc_util.la
 libgnunetmodule_dht_la_LDFLAGS = \
   -export-dynamic -avoid-version -module

Modified: GNUnet/src/applications/dht/module/cs.c
===================================================================
--- GNUnet/src/applications/dht/module/cs.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/dht/module/cs.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -33,7 +33,7 @@
 #include "dht.h"
 #include "gnunet_dht_service.h"
 
-#define DEBUG_CS NO
+#define DEBUG_CS GNUNET_NO
 
 /**
  * Global core API.
@@ -61,13 +61,13 @@
 /**
  * Lock.
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * CS handler for inserting <key,value>-pair into DHT-table.
  */
 static int
-csPut (struct ClientHandle *client, const MESSAGE_HEADER * message)
+csPut (struct ClientHandle *client, const GNUNET_MessageHeader * message)
 {
   const CS_dht_request_put_MESSAGE *req;
   unsigned int size;
@@ -75,24 +75,25 @@
   if (ntohs (message->size) < sizeof (CS_dht_request_put_MESSAGE))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   req = (const CS_dht_request_put_MESSAGE *) message;
   size = ntohs (req->header.size) - sizeof (CS_dht_request_put_MESSAGE);
-  GE_ASSERT (NULL, size < MAX_BUFFER_SIZE);
+  GE_ASSERT (NULL, size < GNUNET_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]);
 #endif
-  dhtAPI->put (&req->key, ntohl (req->type), size, ntohll (req->expire) + 
get_time (),  /* convert to absolute time */
+  dhtAPI->put (&req->key, ntohl (req->type), size, GNUNET_ntohll (req->expire) 
+ GNUNET_get_time (),    /* convert to absolute time */
                (const char *) &req[1]);
-  return OK;
+  return GNUNET_OK;
 }
 
 int
-get_result (const HashCode512 * key, const DataContainer * value, void *cls)
+get_result (const GNUNET_HashCode * key, const DataContainer * value,
+            void *cls)
 {
   DHT_CLIENT_GET_RECORD *record = cls;
   CS_dht_request_put_MESSAGE *msg;
@@ -102,12 +103,12 @@
   n =
     sizeof (CS_dht_request_put_MESSAGE) + ntohl (value->size) -
     sizeof (DataContainer);
-  if (n > MAX_BUFFER_SIZE)
+  if (n > GNUNET_MAX_BUFFER_SIZE)
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  msg = MALLOC (n);
+  msg = GNUNET_malloc (n);
   msg->header.size = htons (n);
   msg->header.type = htons (CS_PROTO_dht_REQUEST_PUT);
   msg->expire = 0;              /* unknown */
@@ -121,7 +122,8 @@
           __FILE__,
           __LINE__, ntohl (value->size) - sizeof (DataContainer), &value[1]);
 #endif
-  if (OK != coreAPI->sendToClient (record->client, &msg->header, YES))
+  if (GNUNET_OK !=
+      coreAPI->sendToClient (record->client, &msg->header, GNUNET_YES))
     {
       GE_LOG (coreAPI->ectx,
               GE_ERROR | GE_IMMEDIATE | GE_USER,
@@ -129,8 +131,8 @@
               "sendToClient");
       coreAPI->terminateClientConnection (record->client);
     }
-  FREE (msg);
-  return OK;
+  GNUNET_free (msg);
+  return GNUNET_OK;
 }
 
 static void
@@ -140,21 +142,21 @@
   int i;
   int found;
 
-  found = NO;
-  MUTEX_LOCK (lock);
+  found = GNUNET_NO;
+  GNUNET_mutex_lock (lock);
   for (i = getRecordsSize - 1; i >= 0; i--)
     if (getRecords[i] == record)
       {
         getRecords[i] = getRecords[getRecordsSize - 1];
-        GROW (getRecords, getRecordsSize, getRecordsSize - 1);
-        found = YES;
+        GNUNET_array_grow (getRecords, getRecordsSize, getRecordsSize - 1);
+        found = GNUNET_YES;
         break;
       }
-  MUTEX_UNLOCK (lock);
-  if (found == YES)
+  GNUNET_mutex_unlock (lock);
+  if (found == GNUNET_YES)
     {
       dhtAPI->get_stop (record->get_record);
-      FREE (record);
+      GNUNET_free (record);
     }
 }
 
@@ -162,7 +164,7 @@
  * CS handler for inserting <key,value>-pair into DHT-table.
  */
 static int
-csGet (struct ClientHandle *client, const MESSAGE_HEADER * message)
+csGet (struct ClientHandle *client, const GNUNET_MessageHeader * message)
 {
   const CS_dht_request_get_MESSAGE *get;
   DHT_CLIENT_GET_RECORD *cpc;
@@ -170,7 +172,7 @@
   if (ntohs (message->size) != sizeof (CS_dht_request_get_MESSAGE))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #if DEBUG_CS
   GE_LOG (coreAPI->ectx,
@@ -178,16 +180,16 @@
           "`%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 = GNUNET_malloc (sizeof (DHT_CLIENT_GET_RECORD));
   cpc->client = client;
   cpc->get_record = dhtAPI->get_start (ntohl (get->type),
                                        &get->key,
-                                       ntohll (get->timeout),
+                                       GNUNET_ntohll (get->timeout),
                                        &get_result, cpc, &get_timeout, cpc);
-  MUTEX_LOCK (lock);
-  APPEND (getRecords, getRecordsSize, cpc);
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_lock (lock);
+  GNUNET_array_append (getRecords, getRecordsSize, cpc);
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -200,7 +202,7 @@
   int i;
   struct DHT_GET_RECORD *gr;
   DHT_CLIENT_GET_RECORD *cgr;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < getRecordsSize; i++)
     {
       cgr = getRecords[i];
@@ -208,15 +210,15 @@
         {
           gr = cgr->get_record;
           getRecords[i] = getRecords[getRecordsSize - 1];
-          GROW (getRecords, getRecordsSize, getRecordsSize - 1);
-          MUTEX_UNLOCK (lock);
+          GNUNET_array_grow (getRecords, getRecordsSize, getRecordsSize - 1);
+          GNUNET_mutex_unlock (lock);
           dhtAPI->get_stop (gr);
-          FREE (cgr);
-          MUTEX_LOCK (lock);
+          GNUNET_free (cgr);
+          GNUNET_mutex_lock (lock);
           i--;
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 int
@@ -226,22 +228,22 @@
 
   dhtAPI = capi->requestService ("dht");
   if (dhtAPI == NULL)
-    return SYSERR;
+    return GNUNET_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);
-  status = OK;
-  lock = MUTEX_CREATE (NO);
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_dht_REQUEST_PUT,
-                                             &csPut))
-    status = SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_dht_REQUEST_GET,
-                                             &csGet))
-    status = SYSERR;
-  if (SYSERR == capi->registerClientExitHandler (&csClientExit))
-    status = SYSERR;
+  status = GNUNET_OK;
+  lock = GNUNET_mutex_create (GNUNET_NO);
+  if (GNUNET_SYSERR == capi->registerClientHandler (CS_PROTO_dht_REQUEST_PUT,
+                                                    &csPut))
+    status = GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerClientHandler (CS_PROTO_dht_REQUEST_GET,
+                                                    &csGet))
+    status = GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerClientExitHandler (&csClientExit))
+    status = GNUNET_SYSERR;
   GE_ASSERT (capi->ectx,
              0 == GC_set_configuration_value_string (capi->cfg,
                                                      capi->ectx,
@@ -260,23 +262,23 @@
 {
   int status;
 
-  status = OK;
+  status = GNUNET_OK;
   GE_LOG (coreAPI->ectx, GE_DEBUG | GE_REQUEST | GE_USER, "DHT: shutdown\n");
-  if (OK != coreAPI->unregisterClientHandler (CS_PROTO_dht_REQUEST_PUT,
-                                              &csPut))
-    status = SYSERR;
-  if (OK != coreAPI->unregisterClientHandler (CS_PROTO_dht_REQUEST_GET,
-                                              &csGet))
-    status = SYSERR;
-  if (OK != coreAPI->unregisterClientExitHandler (&csClientExit))
-    status = SYSERR;
+  if (GNUNET_OK != coreAPI->unregisterClientHandler (CS_PROTO_dht_REQUEST_PUT,
+                                                     &csPut))
+    status = GNUNET_SYSERR;
+  if (GNUNET_OK != coreAPI->unregisterClientHandler (CS_PROTO_dht_REQUEST_GET,
+                                                     &csGet))
+    status = GNUNET_SYSERR;
+  if (GNUNET_OK != coreAPI->unregisterClientExitHandler (&csClientExit))
+    status = GNUNET_SYSERR;
 
   while (getRecordsSize > 0)
     get_timeout (getRecords[0]);
   coreAPI->releaseService (dhtAPI);
   dhtAPI = NULL;
   coreAPI = NULL;
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   return status;
 }
 

Modified: GNUnet/src/applications/dht/module/dstore.c
===================================================================
--- GNUnet/src/applications/dht/module/dstore.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/dht/module/dstore.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -28,7 +28,7 @@
 #include "dstore.h"
 #include "gnunet_blockstore.h"
 
-#define DEBUG_DSTORE NO
+#define DEBUG_DSTORE GNUNET_NO
 
 static Dstore_ServiceAPI *dstore;
 
@@ -39,7 +39,7 @@
  * @return total number of results found
  */
 int
-dht_store_get (const HashCode512 * key,
+dht_store_get (const GNUNET_HashCode * key,
                unsigned int type, ResultHandler handler, void *cls)
 {
   return dstore->get (key, type, handler, cls);
@@ -50,16 +50,17 @@
  */
 void
 dht_store_put (unsigned int type,
-               const HashCode512 * key,
-               cron_t discard_time, unsigned int size, const char *data)
+               const GNUNET_HashCode * key,
+               GNUNET_CronTime discard_time, unsigned int size,
+               const char *data)
 {
-  if (discard_time < get_time ())
+  if (discard_time < GNUNET_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 ());
+              discard_time, GNUNET_get_time ());
 #endif
       return;
     }
@@ -70,7 +71,7 @@
  * Initialize dstore DHT component.
  *
  * @param capi the core API
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int
 init_dht_store (size_t max_size, CoreAPIForApplication * capi)
@@ -78,14 +79,14 @@
   coreAPI = capi;
   dstore = coreAPI->requestService ("dstore");
   if (dstore == NULL)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 /**
  * Shutdown dstore DHT component.
  *
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int
 done_dht_store ()
@@ -93,7 +94,7 @@
   coreAPI->releaseService (dstore);
   coreAPI = NULL;
   dstore = NULL;
-  return OK;
+  return GNUNET_OK;
 }
 
 /* end of dstore.c */

Modified: GNUnet/src/applications/dht/module/dstore.h
===================================================================
--- GNUnet/src/applications/dht/module/dstore.h 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/dht/module/dstore.h 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -34,28 +34,29 @@
  * Lookup in the local datastore.
  * @return total number of results found
  */
-int dht_store_get (const HashCode512 * key,
+int dht_store_get (const GNUNET_HashCode * key,
                    unsigned int type, ResultHandler handler, void *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 GNUNET_HashCode * key,
+                    GNUNET_CronTime discard_time, unsigned int size,
+                    const char *data);
 
 /**
  * Initialize dstore DHT component.
  *
  * @param capi the core API
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int init_dht_store (size_t max_size, CoreAPIForApplication * capi);
 
 /**
  * Shutdown dstore DHT component.
  *
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int done_dht_store (void);
 

Modified: GNUnet/src/applications/dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dht/module/routing.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/dht/module/routing.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -37,7 +37,7 @@
 #include "gnunet_protocols.h"
 #include "gnunet_stats_service.h"
 
-#define DEBUG_ROUTING NO
+#define DEBUG_ROUTING GNUNET_NO
 
 /**
  * @brief record used for sending response back
@@ -54,7 +54,7 @@
    * Source of the request.  Replies should be forwarded to
    * this peer.
    */
-  PeerIdentity source;
+  GNUNET_PeerIdentity source;
 
   /**
    * If local peer is NOT interested in results, this callback
@@ -72,7 +72,7 @@
 typedef struct
 {
 
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Type of the requested content (NBO)
@@ -85,14 +85,14 @@
   unsigned int prio;
 
   /**
-   * Relative time to live in cronMILLIS (NBO)
+   * Relative time to live in GNUNET_CRON_MILLISECONDS (NBO)
    */
   int ttl;
 
   /**
    * Search key.
    */
-  HashCode512 key;
+  GNUNET_HashCode key;
 
 } DHT_GET_MESSAGE;
 
@@ -104,7 +104,7 @@
 typedef struct
 {
 
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Type of the content (NBO)
@@ -114,12 +114,12 @@
   /**
    * When to discard the content (relative time, NBO)
    */
-  cron_t timeout;
+  GNUNET_CronTime timeout;
 
   /**
    * Key for the content.
    */
-  HashCode512 key;
+  GNUNET_HashCode key;
 
 } DHT_PUT_MESSAGE;
 
@@ -131,7 +131,7 @@
 typedef struct
 {
 
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Type of the content (NBO)
@@ -141,7 +141,7 @@
   /**
    * Key for the content.
    */
-  HashCode512 key;
+  GNUNET_HashCode key;
 
 } DHT_RESULT_MESSAGE;
 
@@ -154,7 +154,7 @@
   /**
    * When do we stop forwarding this request?
    */
-  cron_t expires;
+  GNUNET_CronTime expires;
 
   /**
    * Information about where to send the results back to.
@@ -170,7 +170,7 @@
    * Hashcodes of the results that we have send back
    * so far.
    */
-  HashCode512 *results;
+  GNUNET_HashCode *results;
 
   /**
    * Number of entries in results.
@@ -183,7 +183,7 @@
  * Note that this also caps the frequency of how
  * often peers will re-issue requests.
  */
-#define MAX_TTL (5 * cronMINUTES)
+#define MAX_TTL (5 * GNUNET_CRON_MINUTES)
 
 /**
  * Linked list of active records.
@@ -200,7 +200,7 @@
  */
 static Stats_ServiceAPI *stats;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static CoreAPIForApplication *coreAPI;
 
@@ -219,7 +219,7 @@
  * where to send it next.
  */
 static void
-routeResult (const HashCode512 * key,
+routeResult (const GNUNET_HashCode * key,
              unsigned int type,
              unsigned int size, const char *data, void *cls)
 {
@@ -227,7 +227,7 @@
   int i;
   int j;
   int found;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
   DHT_RESULT_MESSAGE *result;
   unsigned int routed;
   unsigned int tracked;
@@ -239,17 +239,17 @@
     }
   else
     {
-      result = MALLOC (sizeof (DHT_RESULT_MESSAGE) + size);
+      result = GNUNET_malloc (sizeof (DHT_RESULT_MESSAGE) + size);
       result->header.size = htons (sizeof (DHT_RESULT_MESSAGE) + size);
       result->header.type = htons (P2P_PROTO_DHT_RESULT);
       result->type = htonl (type);
       result->key = *key;
       memcpy (&result[1], data, size);
     }
-  hash (data, size, &hc);
+  GNUNET_hash (data, size, &hc);
   routed = 0;
   tracked = 0;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < rt_size; i++)
     {
       q = records[i];
@@ -257,25 +257,25 @@
         continue;
       tracked++;
       if ((ntohl (q->get->type) != type) ||
-          (0 != memcmp (key, &q->get->key, sizeof (HashCode512))))
+          (0 != memcmp (key, &q->get->key, sizeof (GNUNET_HashCode))))
         continue;
-      found = NO;
+      found = GNUNET_NO;
       for (j = 0; j < q->result_count; j++)
-        if (0 == memcmp (&hc, &q->results[j], sizeof (HashCode512)))
+        if (0 == memcmp (&hc, &q->results[j], sizeof (GNUNET_HashCode)))
           {
-            found = YES;
+            found = GNUNET_YES;
             break;
           }
-      if (found == YES)
+      if (found == GNUNET_YES)
         continue;
-      GROW (q->results, q->result_count, q->result_count + 1);
+      GNUNET_array_grow (q->results, 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 (GNUNET_PeerIdentity)))
             {
 #if DEBUG_ROUTING
               GE_LOG (coreAPI->ectx,
@@ -283,7 +283,7 @@
                       "Routing result to other peer\n");
 #endif
               coreAPI->unicast (&pos->source, &result->header, 0,       /* 
FIXME: priority */
-                                5 * cronSECONDS);       /* FIXME */
+                                5 * GNUNET_CRON_SECONDS);       /* FIXME */
               if (stats != NULL)
                 stats->change (stat_replies_routed, 1);
             }
@@ -301,7 +301,7 @@
           pos = pos->next;
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 #if DEBUG_ROUTING
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
@@ -309,30 +309,30 @@
           routed, tracked);
 #endif
   if (cls == NULL)
-    FREE (result);
+    GNUNET_free (result);
 }
 
 /**
- * @return OK if route was added, SYSERR if not
+ * @return GNUNET_OK if route was added, GNUNET_SYSERR if not
  */
 static int
-addRoute (const PeerIdentity * sender,
+addRoute (const GNUNET_PeerIdentity * sender,
           ResultHandler handler, void *cls, const DHT_GET_MESSAGE * get)
 {
   DHTQueryRecord *q;
   unsigned int i;
   unsigned int rt_pos;
-  cron_t expire;
-  cron_t now;
+  GNUNET_CronTime expire;
+  GNUNET_CronTime now;
   int ttl;
   struct DHT_Source_Route *pos;
 
   ttl = ntohl (get->ttl);
   if (ttl > MAX_TTL)
     ttl = 0;                    /* implausibly high */
-  now = get_time ();
+  now = GNUNET_get_time ();
   expire = now + ttl;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   rt_pos = rt_size;
   for (i = 0; i < rt_size; i++)
     {
@@ -340,7 +340,7 @@
           (records[i] != NULL) &&
           (0 == memcmp (&records[i]->get->key,
                         &get->key,
-                        sizeof (HashCode512))) &&
+                        sizeof (GNUNET_HashCode))) &&
           (records[i]->get->type == get->type) &&
           (records[i]->expires > now - MAX_TTL))
         {
@@ -348,8 +348,8 @@
              active (possibly from other initiator) */
           /* FIXME: support sending replies back to
              multiple peers!? */
-          MUTEX_UNLOCK (lock);
-          return SYSERR;
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_SYSERR;
         }
       if (records[i] == NULL)
         {
@@ -365,30 +365,30 @@
   if (rt_pos == rt_size)
     {
       /* do not route, expiration time too high */
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   if (records[rt_pos] == NULL)
     {
-      records[rt_pos] = MALLOC (sizeof (DHTQueryRecord));
+      records[rt_pos] = GNUNET_malloc (sizeof (DHTQueryRecord));
       records[rt_pos]->get = NULL;
     }
   if (records[rt_pos]->get != NULL)
     {
-      FREE (records[rt_pos]->get);
+      GNUNET_free (records[rt_pos]->get);
       while (records[rt_pos]->sources != NULL)
         {
           pos = records[rt_pos]->sources;
           records[rt_pos]->sources = pos->next;
-          FREE (pos);
+          GNUNET_free (pos);
         }
     }
   q = records[rt_pos];
   memset (q, 0, sizeof (DHTQueryRecord));
   q->expires = now + ttl;
-  q->get = MALLOC (ntohs (get->header.size));
+  q->get = GNUNET_malloc (ntohs (get->header.size));
   memcpy (q->get, get, ntohs (get->header.size));
-  pos = MALLOC (sizeof (DHT_Source_Route));
+  pos = GNUNET_malloc (sizeof (DHT_Source_Route));
   pos->next = q->sources;
   q->sources = pos;
   if (sender != NULL)
@@ -403,10 +403,10 @@
           "Tracking request in slot %u\n", rt_pos);
 #endif
   rt_pos = (rt_pos + 1) % rt_size;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   if (stats != NULL)
     stats->change (stat_requests_routed, 1);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -420,34 +420,35 @@
  * Handle GET message.
  */
 static int
-handleGet (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+handleGet (const GNUNET_PeerIdentity * sender,
+           const GNUNET_MessageHeader * msg)
 {
-  PeerIdentity next[GET_TRIES];
+  GNUNET_PeerIdentity next[GET_TRIES];
   const DHT_GET_MESSAGE *get;
   DHT_GET_MESSAGE aget;
   int total;
   int ttl;
   int i;
 #if DEBUG_ROUTING
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   if (ntohs (msg->size) != sizeof (DHT_GET_MESSAGE))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   get = (const DHT_GET_MESSAGE *) msg;
 #if DEBUG_ROUTING
-  hash2enc (&get->key, &enc);
+  GNUNET_hash_to_enc (&get->key, &enc);
   GE_LOG (coreAPI->ectx,
           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)))
-    return OK;                  /* could not route */
+  if ((sender != NULL) && (GNUNET_OK != addRoute (sender, NULL, NULL, get)))
+    return GNUNET_OK;           /* could not route */
   total = dht_store_get (&get->key, ntohl (get->type), &routeResult, NULL);
   if ((total > GET_TRIES) && (sender != NULL))
     {
@@ -457,16 +458,16 @@
               "Found %d results locally, will not route GET any further\n",
               total);
 #endif
-      return OK;
+      return GNUNET_OK;
     }
   total = 0;
   for (i = 0; i < GET_TRIES; i++)
     {
-      if (OK != select_dht_peer (&next[i], &get->key, &next[0], i))
+      if (GNUNET_OK != select_dht_peer (&next[i], &get->key, &next[0], i))
         break;
-      if (-1 == hashCodeCompareDistance (&next[i].hashPubKey,
-                                         &coreAPI->myIdentity->hashPubKey,
-                                         &get->key))
+      if (-1 == GNUNET_hash_xorcmp (&next[i].hashPubKey,
+                                    &coreAPI->myIdentity->hashPubKey,
+                                    &get->key))
         {
           if (total == 0)
             {
@@ -474,15 +475,15 @@
               ttl = ntohl (get->ttl);
               if (ttl > MAX_TTL)
                 ttl = MAX_TTL;
-              ttl -= 5 * cronSECONDS;
+              ttl -= 5 * GNUNET_CRON_SECONDS;
               aget.ttl = htonl (ttl);
               total = 1;
             }
           coreAPI->unicast (&next[i], msg, 0,   /* FIXME: priority */
-                            5 * cronSECONDS);   /* FIXME */
+                            5 * GNUNET_CRON_SECONDS);   /* FIXME */
         }
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -497,27 +498,28 @@
  * Handle PUT message.
  */
 static int
-handlePut (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+handlePut (const GNUNET_PeerIdentity * sender,
+           const GNUNET_MessageHeader * msg)
 {
-  PeerIdentity next[PUT_TRIES];
+  GNUNET_PeerIdentity next[PUT_TRIES];
   const DHT_PUT_MESSAGE *put;
-  cron_t now;
+  GNUNET_CronTime now;
   int store;
   int i;
 #if DEBUG_ROUTING
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   if (ntohs (msg->size) < sizeof (DHT_PUT_MESSAGE))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (stats != NULL)
     stats->change (stat_put_requests_received, 1);
   put = (const DHT_PUT_MESSAGE *) msg;
 #if DEBUG_ROUTING
-  hash2enc (&put->key, &enc);
+  GNUNET_hash_to_enc (&put->key, &enc);
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
           "Received DHT PUT for key `%s'.\n", &enc);
@@ -525,32 +527,33 @@
   store = 0;
   for (i = 0; i < PUT_TRIES; i++)
     {
-      if (OK != select_dht_peer (&next[i], &put->key, &next[0], i))
+      if (GNUNET_OK != select_dht_peer (&next[i], &put->key, &next[0], i))
         {
           store = 1;
           break;
         }
-      if (1 == hashCodeCompareDistance (&next[i].hashPubKey,
-                                        &coreAPI->myIdentity->hashPubKey,
-                                        &put->key))
+      if (1 == GNUNET_hash_xorcmp (&next[i].hashPubKey,
+                                   &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 */
+                          5 * GNUNET_CRON_SECONDS);     /* FIXME */
     }
   if (store != 0)
     {
-      now = get_time ();
+      now = GNUNET_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));
+              &put[1], GNUNET_ntohll (put->timeout) + now,
+              GNUNET_ntohll (put->timeout));
 #endif
       dht_store_put (ntohl (put->type),
                      &put->key,
-                     ntohll (MAKE_UNALIGNED (put->timeout)) + now,
+                     GNUNET_ntohll (MAKE_UNALIGNED (put->timeout)) + now,
                      ntohs (put->header.size) - sizeof (DHT_PUT_MESSAGE),
                      (const char *) &put[1]);
     }
@@ -563,30 +566,31 @@
               ntohs (put->header.size) - sizeof (DHT_PUT_MESSAGE), &put[1]);
 #endif
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Handle RESULT message.
  */
 static int
-handleResult (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+handleResult (const GNUNET_PeerIdentity * sender,
+              const GNUNET_MessageHeader * msg)
 {
   const DHT_RESULT_MESSAGE *result;
 #if DEBUG_ROUTING
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   if (ntohs (msg->size) < sizeof (DHT_RESULT_MESSAGE))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (stats != NULL)
     stats->change (stat_results_received, 1);
   result = (const DHT_RESULT_MESSAGE *) msg;
 #if DEBUG_ROUTING
-  hash2enc (&result->key, &enc);
+  GNUNET_hash_to_enc (&result->key, &enc);
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
           "Received DHT RESULT for key `%s'.\n", &enc);
@@ -595,14 +599,14 @@
                ntohl (result->type),
                ntohs (result->header.size) - sizeof (DHT_RESULT_MESSAGE),
                (const char *) &result[1], (void *) msg);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Start a DHT get operation.
  */
 void
-dht_get_start (const HashCode512 * key,
+dht_get_start (const GNUNET_HashCode * key,
                unsigned int type, ResultHandler handler, void *cls)
 {
   DHT_GET_MESSAGE get;
@@ -613,7 +617,7 @@
   get.prio = htonl (0);         /* FIXME */
   get.ttl = htonl (MAX_TTL);    /* FIXME? */
   get.key = *key;
-  if (OK == addRoute (NULL, handler, cls, &get))
+  if (GNUNET_OK == addRoute (NULL, handler, cls, &get))
     handleGet (NULL, &get.header);
 }
 
@@ -622,7 +626,7 @@
  * the given iterator).
  */
 void
-dht_get_stop (const HashCode512 * key,
+dht_get_stop (const GNUNET_HashCode * key,
               unsigned int type, ResultHandler handler, void *cls)
 {
   int i;
@@ -630,8 +634,8 @@
   struct DHT_Source_Route *prev;
   int done;
 
-  done = NO;
-  MUTEX_LOCK (lock);
+  done = GNUNET_NO;
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < rt_size; i++)
     {
       if (records[i] == NULL)
@@ -643,14 +647,14 @@
           if ((pos->receiver == handler) &&
               (pos->receiver_closure == cls) &&
               (0 == memcmp (key,
-                            &records[i]->get->key, sizeof (HashCode512))))
+                            &records[i]->get->key, sizeof (GNUNET_HashCode))))
             {
               if (prev == NULL)
                 records[i]->sources = pos->next;
               else
                 prev->next = pos->next;
-              FREE (pos);
-              done = YES;
+              GNUNET_free (pos);
+              done = GNUNET_YES;
               break;
             }
           prev = pos;
@@ -658,14 +662,14 @@
         }
       if (records[i]->sources == NULL)
         {
-          FREE (records[i]->get);
-          FREE (records[i]);
+          GNUNET_free (records[i]->get);
+          GNUNET_free (records[i]);
           records[i] = NULL;
         }
-      if (done == YES)
+      if (done == GNUNET_YES)
         break;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 /**
@@ -678,21 +682,21 @@
  * @param expirationTime absolute expiration time
  */
 void
-dht_put (const HashCode512 * key,
+dht_put (const GNUNET_HashCode * key,
          unsigned int type,
-         unsigned int size, cron_t expirationTime, const char *data)
+         unsigned int size, GNUNET_CronTime expirationTime, const char *data)
 {
   DHT_PUT_MESSAGE *put;
 
-  put = MALLOC (sizeof (DHT_PUT_MESSAGE) + size);
+  put = GNUNET_malloc (sizeof (DHT_PUT_MESSAGE) + size);
   put->header.size = htons (sizeof (DHT_PUT_MESSAGE) + size);
   put->header.type = htons (P2P_PROTO_DHT_PUT);
   put->key = *key;
   put->type = htonl (type);
-  put->timeout = htonll (expirationTime - get_time ()); /* convert to relative 
time */
+  put->timeout = GNUNET_htonll (expirationTime - GNUNET_get_time ());   /* 
convert to relative time */
   memcpy (&put[1], data, size);
   handlePut (NULL, &put->header);
-  FREE (put);
+  GNUNET_free (put);
 }
 
 /**
@@ -704,7 +708,7 @@
  * @return number of bytes added at position
  */
 static unsigned int
-extra_get_callback (const PeerIdentity * receiver,
+extra_get_callback (const GNUNET_PeerIdentity * receiver,
                     void *position, unsigned int padding)
 {
   return 0;
@@ -714,7 +718,7 @@
  * Initialize routing DHT component.
  *
  * @param capi the core API
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int
 init_dht_routing (CoreAPIForApplication * capi)
@@ -727,8 +731,8 @@
                                      "DHT",
                                      "TABLESIZE",
                                      128, 1024 * 1024, 1024, &rts);
-  GROW (records, rt_size, rts);
-  lock = MUTEX_CREATE (NO);
+  GNUNET_array_grow (records, rt_size, rts);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   stats = capi->requestService ("stats");
   if (stats != NULL)
     {
@@ -752,13 +756,13 @@
   coreAPI->registerHandler (P2P_PROTO_DHT_RESULT, &handleResult);
   coreAPI->registerSendCallback (sizeof (DHT_GET_MESSAGE),
                                  &extra_get_callback);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Shutdown routing DHT component.
  *
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int
 done_dht_routing ()
@@ -775,17 +779,17 @@
       coreAPI->releaseService (stats);
       stats = NULL;
     }
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   for (i = 0; i < rt_size; i++)
     {
       if (records[i] != NULL)
         {
-          FREE (records[i]->get);
-          FREE (records[i]);
+          GNUNET_free (records[i]->get);
+          GNUNET_free (records[i]);
         }
     }
-  GROW (records, rt_size, 0);
-  return OK;
+  GNUNET_array_grow (records, rt_size, 0);
+  return GNUNET_OK;
 }
 
 /* end of routing.c */

Modified: GNUnet/src/applications/dht/module/routing.h
===================================================================
--- GNUnet/src/applications/dht/module/routing.h        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/dht/module/routing.h        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -35,14 +35,14 @@
 /**
  * Start a DHT get operation.
  */
-void dht_get_start (const HashCode512 * key,
+void dht_get_start (const GNUNET_HashCode * key,
                     unsigned int type, ResultHandler handler, void *cls);
 
 /**
  * Stop a DHT get operation (prevents calls to
  * the given iterator).
  */
-void dht_get_stop (const HashCode512 * key,
+void dht_get_stop (const GNUNET_HashCode * key,
                    unsigned int type, ResultHandler handler, void *cls);
 
 /**
@@ -54,22 +54,23 @@
  *
  * @param expirationTime absolute expiration time
  */
-void dht_put (const HashCode512 * key,
+void dht_put (const GNUNET_HashCode * key,
               unsigned int type,
-              unsigned int size, cron_t expirationTime, const char *data);
+              unsigned int size, GNUNET_CronTime expirationTime,
+              const char *data);
 
 /**
  * Initialize routing DHT component.
  *
  * @param capi the core API
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int init_dht_routing (CoreAPIForApplication * capi);
 
 /**
  * Shutdown routing DHT component.
  *
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int done_dht_routing (void);
 

Modified: GNUnet/src/applications/dht/module/service.c
===================================================================
--- GNUnet/src/applications/dht/module/service.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/dht/module/service.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -36,14 +36,14 @@
  */
 static CoreAPIForApplication *coreAPI;
 
-static struct CronManager *cron;
+static struct GNUNET_CronManager *cron;
 
 typedef struct DHT_GET_RECORD
 {
   /**
    * Key that we are looking for.
    */
-  HashCode512 key;
+  GNUNET_HashCode key;
 
   /**
    * Function to call for each result.
@@ -73,18 +73,18 @@
 } DHT_GET_RECORD;
 
 static void
-client_result_converter (const HashCode512 * key,
+client_result_converter (const GNUNET_HashCode * key,
                          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 = GNUNET_malloc (sizeof (DataContainer) + size);
   dc->size = ntohl (sizeof (DataContainer) + size);
   memcpy (&dc[1], data, size);
   get->callback (key, dc, get->cls);
-  FREE (dc);
+  GNUNET_free (dc);
 }
 
 /**
@@ -118,22 +118,22 @@
  */
 static struct DHT_GET_RECORD *
 dht_get_async_start (unsigned int type,
-                     const HashCode512 * key,
-                     cron_t timeout,
+                     const GNUNET_HashCode * key,
+                     GNUNET_CronTime timeout,
                      DataProcessor callback,
                      void *cls,
                      DHT_OP_Complete callbackComplete, void *closure)
 {
   struct DHT_GET_RECORD *ret;
 
-  ret = MALLOC (sizeof (DHT_GET_RECORD));
+  ret = GNUNET_malloc (sizeof (DHT_GET_RECORD));
   ret->key = *key;
   ret->callback = callback;
   ret->cls = cls;
   ret->callbackComplete = callbackComplete;
   ret->closure = closure;
   ret->type = type;
-  cron_add_job (cron, &timeout_callback, timeout, 0, ret);
+  GNUNET_cron_add_job (cron, &timeout_callback, timeout, 0, ret);
   dht_get_start (key, type, &client_result_converter, ret);
   return ret;
 }
@@ -144,12 +144,12 @@
 static int
 dht_get_async_stop (struct DHT_GET_RECORD *record)
 {
-  cron_suspend (cron, YES);
-  cron_del_job (cron, &timeout_callback, 0, record);
-  cron_resume_jobs (cron, YES);
+  GNUNET_cron_suspend_jobs (cron, GNUNET_YES);
+  GNUNET_cron_del_job (cron, &timeout_callback, 0, record);
+  GNUNET_cron_resume_jobs (cron, GNUNET_YES);
   dht_get_stop (&record->key, record->type, &client_result_converter, record);
-  FREE (record);
-  return OK;
+  GNUNET_free (record);
+  return GNUNET_OK;
 }
 
 /**
@@ -165,19 +165,19 @@
   static DHT_ServiceAPI api;
 
   cron = cron_create (capi->ectx);
-  cron_start (cron);
-  if (OK != init_dht_store (1024 * 1024, capi))
+  GNUNET_cron_start (cron);
+  if (GNUNET_OK != init_dht_store (1024 * 1024, capi))
     {
       GE_BREAK (capi->ectx, 0);
       return NULL;
     }
-  if (OK != init_dht_table (capi))
+  if (GNUNET_OK != init_dht_table (capi))
     {
       GE_BREAK (capi->ectx, 0);
       done_dht_store ();
       return NULL;
     }
-  if (OK != init_dht_routing (capi))
+  if (GNUNET_OK != init_dht_routing (capi))
     {
       GE_BREAK (capi->ectx, 0);
       done_dht_table ();
@@ -197,12 +197,12 @@
 int
 release_module_dht ()
 {
-  cron_stop (cron);
+  GNUNET_cron_stop (cron);
   done_dht_routing ();
   done_dht_table ();
   done_dht_store ();
-  cron_destroy (cron);
-  return OK;
+  GNUNET_cron_destroy (cron);
+  return GNUNET_OK;
 }
 
 /* end of service.c */

Modified: GNUnet/src/applications/dht/module/table.c
===================================================================
--- GNUnet/src/applications/dht/module/table.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/dht/module/table.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -57,7 +57,7 @@
  * How often should the cron job for maintaining the DHT
  * run?
  */
-#define MAINTAIN_FREQUENCY 1500 * cronMILLIS
+#define MAINTAIN_FREQUENCY 1500 * GNUNET_CRON_MILLISECONDS
 
 /**
  * What is the chance (1 in XXX) that we send DISCOVERY messages
@@ -91,17 +91,17 @@
   /**
    * What was the last time we received a message from this peer?
    */
-  cron_t lastActivity;
+  GNUNET_CronTime lastActivity;
 
   /**
    * What was the last time we send a PING to this peer?
    */
-  cron_t lastTimePingSend;
+  GNUNET_CronTime lastTimePingSend;
 
   /**
    * What is the average latency for replies received?
    */
-  cron_t expected_latency;
+  GNUNET_CronTime expected_latency;
 
   /**
    * Number of responses received
@@ -116,7 +116,7 @@
   /**
    * What is the identity of the peer?
    */
-  PeerIdentity id;
+  GNUNET_PeerIdentity id;
 
 } PeerInfo;
 
@@ -170,7 +170,7 @@
 /**
  * Mutex to synchronize access to tables.
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * Identity service.
@@ -203,7 +203,7 @@
 typedef struct
 {
 
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   unsigned int space_available;
 
@@ -217,38 +217,38 @@
 typedef struct
 {
 
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   unsigned int reserved;
 
-  PeerIdentity peer;
+  GNUNET_PeerIdentity peer;
 
 } P2P_DHT_ASK_HELLO;
 
 /**
- * Get the index of the lowest bit of the two hash codes that
+ * Get the index of the lowest bit of the two GNUNET_hash codes that
  * differs.
  */
 static unsigned int
-get_bit_distance (const HashCode512 * h1, const HashCode512 * h2)
+get_bit_distance (const GNUNET_HashCode * h1, const GNUNET_HashCode * h2)
 {
   unsigned int i;
   int diff;
 
-  for (i = 0; i < sizeof (HashCode512) * 8; i++)
+  for (i = 0; i < sizeof (GNUNET_HashCode) * 8; i++)
     {
-      diff = getHashCodeBit (h1, i) - getHashCodeBit (h2, i);
+      diff = GNUNET_hash_get_bit (h1, i) - GNUNET_hash_get_bit (h2, i);
       if (diff != 0)
         return i;
     }
-  return sizeof (HashCode512) * 8;
+  return sizeof (GNUNET_HashCode) * 8;
 }
 
 /**
  * @return NULL if peer is the current host
  */
 static PeerBucket *
-findBucketFor (const PeerIdentity * peer)
+findBucketFor (const GNUNET_PeerIdentity * peer)
 {
   unsigned int index;
   int i;
@@ -268,14 +268,15 @@
  * in our DHT routing table.
  */
 static PeerInfo *
-findPeerEntryInBucket (PeerBucket * bucket, const PeerIdentity * peer)
+findPeerEntryInBucket (PeerBucket * bucket, const GNUNET_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)))
+    if (0 ==
+        memcmp (peer, &bucket->peers[i]->id, sizeof (GNUNET_PeerIdentity)))
       return bucket->peers[i];
   return NULL;
 }
@@ -285,14 +286,14 @@
  * in our DHT routing table.
  */
 static PeerInfo *
-findPeerEntry (const PeerIdentity * peer)
+findPeerEntry (const GNUNET_PeerIdentity * peer)
 {
   return findPeerEntryInBucket (findBucketFor (peer), peer);
 }
 
 /**
  * Return a number that is the larger the closer the
- * "have" hash code is to the "target".  The basic
+ * "have" GNUNET_hash code is to the "target".  The basic
  * idea is that if "have" would be in the n-th lowest
  * bucket of "target", the returned value should be
  * 2^n.  However, the largest number we can return
@@ -301,14 +302,15 @@
  * @return inverse distance metric, non-zero.
  */
 static unsigned int
-inverse_distance (const HashCode512 * target, const HashCode512 * have)
+inverse_distance (const GNUNET_HashCode * target,
+                  const GNUNET_HashCode * have)
 {
   unsigned int bucket;
   double d;
 
   bucket = get_bit_distance (target, have);
   d = bucket * 32;
-  d = exp2 (d / (sizeof (HashCode512) * 8));
+  d = exp2 (d / (sizeof (GNUNET_HashCode) * 8));
   if (d > ((unsigned int) -1))
     return -1;
   return (unsigned int) d;
@@ -324,12 +326,13 @@
  * exponentially declining probability (this function is also used for
  * populating the target's routing table).
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-select_dht_peer (PeerIdentity * set,
-                 const HashCode512 * target,
-                 const PeerIdentity * blocked, unsigned int blocked_size)
+select_dht_peer (GNUNET_PeerIdentity * set,
+                 const GNUNET_HashCode * target,
+                 const GNUNET_PeerIdentity * blocked,
+                 unsigned int blocked_size)
 {
   unsigned long long total_distance;
   unsigned long long selected;
@@ -341,7 +344,7 @@
   PeerBucket *bucket;
   PeerInfo *pi;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if (stats != NULL)
     stats->change (stat_dht_route_looks, 1);
   total_distance = 0;
@@ -351,56 +354,58 @@
       for (ec = 0; ec < bucket->peers_size; ec++)
         {
           pi = bucket->peers[ec];
-          match = NO;
+          match = GNUNET_NO;
           for (i = 0; i < blocked_size; i++)
             {
-              if (0 == memcmp (&pi->id, &blocked[i], sizeof (PeerIdentity)))
+              if (0 ==
+                  memcmp (&pi->id, &blocked[i], sizeof (GNUNET_PeerIdentity)))
                 {
-                  match = YES;
+                  match = GNUNET_YES;
                   break;
                 }
             }
-          if (match == YES)
+          if (match == GNUNET_YES)
             continue;
           total_distance += inverse_distance (target, &pi->id.hashPubKey);
         }
     }
   if (total_distance == 0)
     {
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
-  selected = weak_randomi64 (total_distance);
+  selected = GNUNET_random_u64 (GNUNET_RANDOM_QUALITY_WEAK, total_distance);
   for (bc = 0; bc < bucketCount; bc++)
     {
       bucket = &buckets[bc];
       for (ec = 0; ec < bucket->peers_size; ec++)
         {
           pi = bucket->peers[ec];
-          match = NO;
+          match = GNUNET_NO;
           for (i = 0; i < blocked_size; i++)
             {
-              if (0 == memcmp (&pi->id, &blocked[i], sizeof (PeerIdentity)))
+              if (0 ==
+                  memcmp (&pi->id, &blocked[i], sizeof (GNUNET_PeerIdentity)))
                 {
-                  match = YES;
+                  match = GNUNET_YES;
                   break;
                 }
             }
-          if (match == YES)
+          if (match == GNUNET_YES)
             continue;
           distance = inverse_distance (target, &pi->id.hashPubKey);
           if (distance > selected)
             {
               *set = pi->id;
-              MUTEX_UNLOCK (lock);
-              return OK;
+              GNUNET_mutex_unlock (lock);
+              return GNUNET_OK;
             }
           selected -= distance;
         }
     }
   GE_BREAK (NULL, 0);
-  MUTEX_UNLOCK (lock);
-  return SYSERR;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -409,12 +414,12 @@
  * @param cls NULL or pre-build discovery message
  */
 static void
-broadcast_dht_discovery (const PeerIdentity * other, void *cls)
+broadcast_dht_discovery (const GNUNET_PeerIdentity * other, void *cls)
 {
   P2P_DHT_Discovery *disco = cls;
   unsigned int pc;
   unsigned int i;
-  PeerIdentity *pos;
+  GNUNET_PeerIdentity *pos;
 
   if (stats != NULL)
     stats->change (stat_dht_advertisements, 1);
@@ -431,10 +436,12 @@
     pc = MAINTAIN_ADV_CAP;
   if (pc == 0)
     pc = 1;
-  disco = MALLOC (pc * sizeof (PeerIdentity) + sizeof (P2P_DHT_Discovery));
+  disco =
+    GNUNET_malloc (pc * sizeof (GNUNET_PeerIdentity) +
+                   sizeof (P2P_DHT_Discovery));
   disco->header.type = htons (P2P_PROTO_DHT_DISCOVERY);
   disco->space_available = -1;  /* FIXME */
-  pos = (PeerIdentity *) & disco[1];
+  pos = (GNUNET_PeerIdentity *) & disco[1];
   i = 0;
   if (total_peers == 0)
     {
@@ -445,22 +452,22 @@
     }
   while (i < pc)
     {
-      if (OK != select_dht_peer (&pos[i], &other->hashPubKey, pos, i))
+      if (GNUNET_OK != select_dht_peer (&pos[i], &other->hashPubKey, pos, i))
         pc--;
       else
         i++;
     }
   disco->header.size =
-    htons (pc * sizeof (PeerIdentity) + sizeof (P2P_DHT_Discovery));
+    htons (pc * sizeof (GNUNET_PeerIdentity) + sizeof (P2P_DHT_Discovery));
   coreAPI->unicast (other, &disco->header, 0,
                     MAINTAIN_FREQUENCY * MAINTAIN_CHANCE / 2);
-  FREE (disco);
+  GNUNET_free (disco);
 }
 
 static void
-broadcast_dht_discovery_prob (const PeerIdentity * other, void *cls)
+broadcast_dht_discovery_prob (const GNUNET_PeerIdentity * other, void *cls)
 {
-  if (weak_randomi (MAINTAIN_CHANCE) != 0)
+  if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, MAINTAIN_CHANCE) != 0)
     return;
   broadcast_dht_discovery (other, cls);
 }
@@ -493,17 +500,17 @@
 static void
 pongNotify (void *cls)
 {
-  PeerIdentity *peer = cls;
+  GNUNET_PeerIdentity *peer = cls;
   PeerInfo *pi;
 
   pi = findPeerEntry (peer);
   if (pi != NULL)
     {
-      pi->lastActivity = get_time ();
+      pi->lastActivity = GNUNET_get_time ();
       pi->expected_latency = pi->lastActivity - pi->lastTimePingSend;
       pi->response_count++;
     }
-  FREE (peer);
+  GNUNET_free (peer);
 }
 
 /**
@@ -513,13 +520,13 @@
 static void
 pingPeer (PeerInfo * pi)
 {
-  PeerIdentity *p;
+  GNUNET_PeerIdentity *p;
 
-  p = MALLOC (sizeof (PeerIdentity));
+  p = GNUNET_malloc (sizeof (GNUNET_PeerIdentity));
   *p = pi->id;
-  if (OK == pingpong->ping (p, &pongNotify, p, NO, rand ()))
+  if (GNUNET_OK == pingpong->ping (p, &pongNotify, p, GNUNET_NO, rand ()))
     {
-      pi->lastTimePingSend = get_time ();
+      pi->lastTimePingSend = GNUNET_get_time ();
       pi->request_count++;
     }
 }
@@ -528,21 +535,21 @@
  * Check if pi is still up and running.  May also try
  * to confirm that the peer is still live.
  *
- * @return YES if the peer should be removed from the DHT table
+ * @return GNUNET_YES if the peer should be removed from the DHT table
  */
 static int
 checkExpired (PeerInfo * pi)
 {
-  cron_t now;
+  GNUNET_CronTime now;
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   if (pi->lastActivity >= now)
-    return NO;
+    return GNUNET_NO;
   if (now - pi->lastActivity > MAINTAIN_PEER_TIMEOUT)
-    return YES;
+    return GNUNET_YES;
   if (now - pi->lastActivity > MAINTAIN_PEER_TIMEOUT / 2)
     pingPeer (pi);
-  return NO;
+  return GNUNET_NO;
 }
 
 /**
@@ -557,14 +564,15 @@
   for (i = 0; i < bucket->peers_size; i++)
     {
       peer = bucket->peers[i];
-      if (checkExpired (peer) == YES)
+      if (checkExpired (peer) == GNUNET_YES)
         {
           total_peers--;
           if (stats != NULL)
             stats->change (stat_dht_total_peers, -1);
-          FREE (peer);
+          GNUNET_free (peer);
           bucket->peers[i] = bucket->peers[bucket->peers_size - 1];
-          GROW (bucket->peers, bucket->peers_size, bucket->peers_size - 1);
+          GNUNET_array_grow (bucket->peers, bucket->peers_size,
+                             bucket->peers_size - 1);
         }
     }
 }
@@ -573,12 +581,13 @@
  * Consider adding the given peer to the DHT.
  */
 static void
-considerPeer (const PeerIdentity * sender, const PeerIdentity * peer)
+considerPeer (const GNUNET_PeerIdentity * sender,
+              const GNUNET_PeerIdentity * peer)
 {
   PeerInfo *pi;
   PeerBucket *bucket;
   P2P_DHT_ASK_HELLO ask;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
 
   bucket = findBucketFor (peer);
   if (bucket == NULL)
@@ -590,7 +599,7 @@
   if (NULL != findPeerEntryInBucket (bucket, peer))
     return;                     /* already have this peer in buckets */
   /* do we know how to contact this peer? */
-  hello = identity->identity2Hello (peer, ANY_PROTOCOL_NUMBER, NO);
+  hello = identity->identity2Hello (peer, ANY_PROTOCOL_NUMBER, GNUNET_NO);
   if (hello == NULL)
     {
       /* if identity not known, ask sender for HELLO of other peer */
@@ -599,23 +608,24 @@
       ask.reserved = 0;
       ask.peer = *peer;
       coreAPI->unicast (sender, &ask.header, 0, /* FIXME: priority */
-                        5 * cronSECONDS);
+                        5 * GNUNET_CRON_SECONDS);
       return;
     }
-  FREE (hello);
+  GNUNET_free (hello);
   /* check if connected, if not, send discovery */
-  if (OK != coreAPI->queryPeerStatus (peer, NULL, NULL))
+  if (GNUNET_OK != coreAPI->queryPeerStatus (peer, NULL, NULL))
     {
       /* not yet connected; connect sending DISCOVERY */
       broadcast_dht_discovery (peer, NULL);
       return;
     }
   /* we are connected (in core), add to bucket */
-  pi = MALLOC (sizeof (PeerInfo));
+  pi = GNUNET_malloc (sizeof (PeerInfo));
   memset (pi, 0, sizeof (PeerInfo));
   pi->id = *peer;
   pingPeer (pi);
-  GROW (bucket->peers, bucket->peers_size, bucket->peers_size + 1);
+  GNUNET_array_grow (bucket->peers, bucket->peers_size,
+                     bucket->peers_size + 1);
   bucket->peers[bucket->peers_size - 1] = pi;
   total_peers++;
   if (stats != NULL)
@@ -626,25 +636,27 @@
  * Handle discovery message.
  */
 static int
-handleDiscovery (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+handleDiscovery (const GNUNET_PeerIdentity * sender,
+                 const GNUNET_MessageHeader * msg)
 {
   unsigned int pc;
   unsigned int i;
   const P2P_DHT_Discovery *disco;
-  const PeerIdentity *peers;
+  const GNUNET_PeerIdentity *peers;
 
   pc =
-    (ntohs (msg->size) - sizeof (P2P_DHT_Discovery)) / sizeof (PeerIdentity);
+    (ntohs (msg->size) -
+     sizeof (P2P_DHT_Discovery)) / sizeof (GNUNET_PeerIdentity);
   if (pc > MAINTAIN_ADV_CAP * 8)
     {
       GE_BREAK (coreAPI->ectx, 0);
-      return SYSERR;            /* far too big */
+      return GNUNET_SYSERR;     /* far too big */
     }
   if (ntohs (msg->size) !=
-      sizeof (P2P_DHT_Discovery) + pc * sizeof (PeerIdentity))
+      sizeof (P2P_DHT_Discovery) + pc * sizeof (GNUNET_PeerIdentity))
     {
       GE_BREAK (coreAPI->ectx, 0);
-      return SYSERR;            /* malformed */
+      return GNUNET_SYSERR;     /* malformed */
     }
   disco = (const P2P_DHT_Discovery *) msg;
   if (stats != NULL)
@@ -654,42 +666,44 @@
       /* if peer has 0 connections, be sure to send discovery back */
       broadcast_dht_discovery (sender, NULL);
     }
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   considerPeer (sender, sender);
-  peers = (const PeerIdentity *) &disco[1];
+  peers = (const GNUNET_PeerIdentity *) &disco[1];
   for (i = 0; i < pc; i++)
     considerPeer (sender, &peers[i]);
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
  * Handle ask hello message.
  */
 static int
-handleAskHello (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+handleAskHello (const GNUNET_PeerIdentity * sender,
+                const GNUNET_MessageHeader * msg)
 {
   const P2P_DHT_ASK_HELLO *ask;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
 
   if (ntohs (msg->size) != sizeof (P2P_DHT_ASK_HELLO))
-    return SYSERR;
+    return GNUNET_SYSERR;
   ask = (const P2P_DHT_ASK_HELLO *) msg;
   if (NULL == findBucketFor (&ask->peer))
-    return OK;
-  hello = identity->identity2Hello (&ask->peer, ANY_PROTOCOL_NUMBER, NO);
+    return GNUNET_OK;
+  hello =
+    identity->identity2Hello (&ask->peer, ANY_PROTOCOL_NUMBER, GNUNET_NO);
   if (hello == NULL)
-    return OK;
-  coreAPI->unicast (sender, &hello->header, 0, 5 * cronSECONDS);
-  FREE (hello);
-  return OK;
+    return GNUNET_OK;
+  coreAPI->unicast (sender, &hello->header, 0, 5 * GNUNET_CRON_SECONDS);
+  GNUNET_free (hello);
+  return GNUNET_OK;
 }
 
 /**
  * Initialize table DHT component.
  *
  * @param capi the core API
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int
 init_dht_table (CoreAPIForApplication * capi)
@@ -702,7 +716,7 @@
   i = coreAPI->getSlotCount () / MAINTAIN_BUCKET_SIZE / 2;
   if (i < 4)
     i = 4;
-  GROW (buckets, bucketCount, i);
+  GNUNET_array_grow (buckets, bucketCount, i);
   for (i = 0; i < bucketCount; i++)
     {
       buckets[i].bstart = 512 * i / bucketCount;
@@ -727,16 +741,16 @@
   GE_ASSERT (coreAPI->ectx, pingpong != NULL);
   capi->registerHandler (P2P_PROTO_DHT_DISCOVERY, &handleDiscovery);
   capi->registerHandler (P2P_PROTO_DHT_ASK_HELLO, &handleAskHello);
-  cron_add_job (coreAPI->cron,
-                &maintain_dht_job,
-                MAINTAIN_FREQUENCY, MAINTAIN_FREQUENCY, NULL);
-  return OK;
+  GNUNET_cron_add_job (coreAPI->cron,
+                       &maintain_dht_job,
+                       MAINTAIN_FREQUENCY, MAINTAIN_FREQUENCY, NULL);
+  return GNUNET_OK;
 }
 
 /**
  * Shutdown table DHT component.
  *
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int
 done_dht_table ()
@@ -746,7 +760,8 @@
 
   coreAPI->unregisterHandler (P2P_PROTO_DHT_DISCOVERY, &handleDiscovery);
   coreAPI->unregisterHandler (P2P_PROTO_DHT_ASK_HELLO, &handleAskHello);
-  cron_del_job (coreAPI->cron, &maintain_dht_job, MAINTAIN_FREQUENCY, NULL);
+  GNUNET_cron_del_job (coreAPI->cron, &maintain_dht_job, MAINTAIN_FREQUENCY,
+                       NULL);
   if (stats != NULL)
     {
       coreAPI->releaseService (stats);
@@ -759,12 +774,12 @@
   for (i = 0; i < bucketCount; i++)
     {
       for (j = 0; j < buckets[i].peers_size; j++)
-        FREE (buckets[i].peers[j]);
-      GROW (buckets[i].peers, buckets[i].peers_size, 0);
+        GNUNET_free (buckets[i].peers[j]);
+      GNUNET_array_grow (buckets[i].peers, buckets[i].peers_size, 0);
     }
-  GROW (buckets, bucketCount, 0);
+  GNUNET_array_grow (buckets, bucketCount, 0);
   lock = NULL;
-  return OK;
+  return GNUNET_OK;
 }
 
 /* end of table.c */

Modified: GNUnet/src/applications/dht/module/table.h
===================================================================
--- GNUnet/src/applications/dht/module/table.h  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/dht/module/table.h  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -40,24 +40,25 @@
  * exponentially declining probability (this function is also used for
  * populating the target's routing table).
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int select_dht_peer (PeerIdentity * set,
-                     const HashCode512 * target,
-                     const PeerIdentity * blocked, unsigned int blocked_size);
+int select_dht_peer (GNUNET_PeerIdentity * set,
+                     const GNUNET_HashCode * target,
+                     const GNUNET_PeerIdentity * blocked,
+                     unsigned int blocked_size);
 
 /**
  * Initialize table DHT component.
  *
  * @param capi the core API
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int init_dht_table (CoreAPIForApplication * capi);
 
 /**
  * Shutdown table DHT component.
  *
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int done_dht_table (void);
 

Modified: GNUnet/src/applications/dht/tools/Makefile.am
===================================================================
--- GNUnet/src/applications/dht/tools/Makefile.am       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/dht/tools/Makefile.am       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -9,16 +9,12 @@
 libgnunetdht_api_la_SOURCES = \
   dht_api.c 
 libgnunetdht_api_la_LIBADD = \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
 gnunet_dht_query_SOURCES = \
   dht-query.c
 gnunet_dht_query_LDADD =  \
   $(top_builddir)/src/applications/dht/tools/libgnunetdht_api.la \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
 
@@ -36,8 +32,6 @@
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
   $(top_builddir)/src/applications/dht/tools/libgnunetdht_api.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 dhttest_SOURCES = \
@@ -46,8 +40,6 @@
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
   $(top_builddir)/src/applications/dht/tools/libgnunetdht_api.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 EXTRA_DIST = \

Modified: GNUnet/src/applications/dht/tools/dht-query.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-query.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/dht/tools/dht-query.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -28,18 +28,15 @@
 #include "gnunet_directories.h"
 #include "gnunet_protocols.h"
 #include "gnunet_util.h"
-#include "gnunet_util_crypto.h"
 #include "gnunet_dht_lib.h"
-#include "gnunet_util_boot.h"
-#include "gnunet_util_network_client.h"
 
-#define DEBUG_DHT_QUERY NO
+#define DEBUG_DHT_QUERY GNUNET_NO
 
 /**
  * How long should a "GET" run (or how long should
  * content last on the network).
  */
-static cron_t timeout;
+static GNUNET_CronTime timeout;
 
 static struct GE_Context *ectx;
 
@@ -50,22 +47,22 @@
 /**
  * All gnunet-dht-query command line options
  */
-static struct CommandLineOption gnunetqueryOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Query (get KEY, put KEY VALUE) DHT 
table.")),        /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+static struct GNUNET_CommandLineOption gnunetqueryOptions[] = {
+       GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Query (get KEY, put KEY 
VALUE) DHT table.")),        /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'T', "timeout", "TIME",
    gettext_noop
    ("allow TIME ms to process a GET command or expire PUT content after ms 
TIME"),
-   1, &gnunet_getopt_configure_set_ulong, &timeout},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+   1, &GNUNET_getopt_configure_set_ulong, &timeout},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 static int
-printCallback (const HashCode512 * hash,
+printCallback (const GNUNET_HashCode * hash,
                const DataContainer * data, void *cls)
 {
   char *key = cls;
@@ -74,23 +71,23 @@
           key,
           (int) (ntohl (data->size) - sizeof (DataContainer)),
           (char *) &data[1]);
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
-do_get (struct ClientServerConnection *sock, const char *key)
+do_get (struct GNUNET_ClientServerConnection *sock, const char *key)
 {
   int ret;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 
-  hash (key, strlen (key), &hc);
+  GNUNET_hash (key, strlen (key), &hc);
 #if DEBUG_DHT_QUERY
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Issuing '%s(%s)' command.\n", "get", key);
 #endif
   if (timeout == 0)
-    timeout = 30 * cronSECONDS;
+    timeout = 30 * GNUNET_CRON_SECONDS;
   ret = DHT_LIB_get (cfg,
                      ectx,
                      DHT_STRING2STRING_BLOCK,
@@ -100,14 +97,14 @@
 }
 
 static void
-do_put (struct ClientServerConnection *sock,
+do_put (struct GNUNET_ClientServerConnection *sock,
         const char *key, const char *value)
 {
   DataContainer *dc;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 
-  hash (key, strlen (key), &hc);
-  dc = MALLOC (sizeof (DataContainer) + strlen (value));
+  GNUNET_hash (key, strlen (key), &hc);
+  dc = GNUNET_malloc (sizeof (DataContainer) + strlen (value));
   dc->size = htonl (strlen (value) + sizeof (DataContainer));
   memcpy (&dc[1], value, strlen (value));
 #if DEBUG_DHT_QUERY
@@ -116,9 +113,9 @@
           _("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))
+    timeout = 30 * GNUNET_CRON_MINUTES;
+  if (GNUNET_OK == DHT_LIB_put (cfg, ectx, &hc, DHT_STRING2STRING_BLOCK, 
timeout + GNUNET_get_time (),  /* convert to absolute time */
+                                dc))
     {
       printf (_("'%s(%s,%s)' succeeded\n"), "put", key, value);
     }
@@ -126,14 +123,14 @@
     {
       printf (_("'%s(%s,%s)' failed.\n"), "put", key, value);
     }
-  FREE (dc);
+  GNUNET_free (dc);
 }
 
 int
 main (int argc, char *const *argv)
 {
   int i;
-  struct ClientServerConnection *handle;
+  struct GNUNET_ClientServerConnection *handle;
 
   i = GNUNET_init (argc,
                    argv,
@@ -145,7 +142,7 @@
       return -1;
     }
 
-  handle = client_connection_create (ectx, cfg);
+  handle = GNUNET_client_connection_create (ectx, cfg);
   if (handle == NULL)
     {
       fprintf (stderr, _("Failed to connect to gnunetd.\n"));
@@ -192,7 +189,7 @@
       fprintf (stderr, _("Unsupported command `%s'.  Aborting.\n"), argv[i]);
       break;
     }
-  connection_destroy (handle);
+  GNUNET_client_connection_destroy (handle);
   GNUNET_fini (ectx, cfg);
   return 0;
 }

Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -30,7 +30,7 @@
 #include "gnunet_dht_lib.h"
 #include "gnunet_util_network_client.h"
 
-#define DEBUG_DHT_API NO
+#define DEBUG_DHT_API GNUNET_NO
 
 /**
  * Data exchanged between main thread and GET thread.
@@ -41,7 +41,7 @@
   /**
    * Connection with gnunetd.
    */
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
 
   /**
    * Callback to call for each result.
@@ -60,7 +60,7 @@
    * connection or the processor callback requesting
    * it).
    */
-  struct PTHREAD *parent;
+  struct GNUNET_ThreadHandle *parent;
 
   /**
    * Are we done (for whichever reason)?
@@ -78,23 +78,23 @@
 poll_thread (void *cls)
 {
   GetInfo *info = cls;
-  MESSAGE_HEADER *reply;
+  GNUNET_MessageHeader *reply;
   CS_dht_request_put_MESSAGE *put;
   DataContainer *cont;
   unsigned short size;
 
-  while (info->aborted == NO)
+  while (info->aborted == GNUNET_NO)
     {
-      if (connection_test_open (info->sock) == 0)
+      if (GNUNET_client_connection_test_connected (info->sock) == 0)
         break;
       reply = NULL;
-      if (OK != connection_read (info->sock, &reply))
+      if (GNUNET_OK != GNUNET_client_connection_read (info->sock, &reply))
         break;
       if ((sizeof (CS_dht_request_put_MESSAGE) > ntohs (reply->size)) ||
           (CS_PROTO_dht_REQUEST_PUT != ntohs (reply->type)))
         {
           GE_BREAK (NULL, 0);
-          info->total = SYSERR;
+          info->total = GNUNET_SYSERR;
           break;                /*  invalid reply */
         }
 
@@ -106,13 +106,13 @@
       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)))
-        info->aborted = YES;
+          (GNUNET_OK != info->processor (&put->key, cont, info->closure)))
+        info->aborted = GNUNET_YES;
       info->total++;
-      FREE (reply);
+      GNUNET_free (reply);
     }
-  info->aborted = YES;
-  PTHREAD_STOP_SLEEP (info->parent);
+  info->aborted = GNUNET_YES;
+  GNUNET_thread_stop_sleep (info->parent);
   return NULL;
 }
 
@@ -134,59 +134,60 @@
  *        automatically time-out
  * @param maxResults maximum number of results to obtain, size of the results 
array
  * @param results where to store the results (on success)
- * @return number of results on success, SYSERR on error (i.e. timeout)
+ * @return number of results on success, GNUNET_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)
+             const GNUNET_HashCode * key,
+             GNUNET_CronTime timeout, DataProcessor processor, void *closure)
 {
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   CS_dht_request_get_MESSAGE req;
-  struct PTHREAD *thread;
-  cron_t start;
-  cron_t now;
-  cron_t delta;
+  struct GNUNET_ThreadHandle *thread;
+  GNUNET_CronTime start;
+  GNUNET_CronTime now;
+  GNUNET_CronTime delta;
   GetInfo info;
   void *unused;
 
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   req.header.size = htons (sizeof (CS_dht_request_get_MESSAGE));
   req.header.type = htons (CS_PROTO_dht_REQUEST_GET);
   req.type = htonl (type);
-  req.timeout = htonll (timeout);
+  req.timeout = GNUNET_htonll (timeout);
   req.key = *key;
-  if (OK != connection_write (sock, &req.header))
+  if (GNUNET_OK != GNUNET_client_connection_write (sock, &req.header))
     {
-      connection_destroy (sock);
-      return SYSERR;
+      GNUNET_client_connection_destroy (sock);
+      return GNUNET_SYSERR;
     }
   info.sock = sock;
   info.processor = processor;
   info.closure = closure;
-  info.parent = PTHREAD_GET_SELF ();
-  info.aborted = NO;
+  info.parent = GNUNET_thread_get_self ();
+  info.aborted = GNUNET_NO;
   info.total = 0;
-  thread = PTHREAD_CREATE (&poll_thread, &info, 1024 * 8);
-  start = get_time ();
-  while ((start + timeout > (now = get_time ())) &&
-         (GNUNET_SHUTDOWN_TEST () == NO) && (info.aborted == NO))
+  thread = GNUNET_thread_create (&poll_thread, &info, 1024 * 8);
+  start = GNUNET_get_time ();
+  while ((start + timeout > (now = GNUNET_get_time ())) &&
+         (GNUNET_shutdown_test () == GNUNET_NO)
+         && (info.aborted == GNUNET_NO))
     {
       delta = (start + timeout) - now;
-      if (delta > 100 * cronMILLIS)
-        delta = 100 * cronMILLIS;       /* in case we miss SIGINT
-                                           on CTRL-C */
-      PTHREAD_SLEEP (delta);
+      if (delta > 100 * GNUNET_CRON_MILLISECONDS)
+        delta = 100 * GNUNET_CRON_MILLISECONDS; /* in case we miss SIGINT
+                                                   on CTRL-C */
+      GNUNET_thread_sleep (delta);
     }
-  info.aborted = YES;
-  connection_close_forever (sock);
-  PTHREAD_JOIN (thread, &unused);
-  PTHREAD_REL_SELF (info.parent);
-  connection_destroy (sock);
+  info.aborted = GNUNET_YES;
+  GNUNET_client_connection_close_forever (sock);
+  GNUNET_thread_join (thread, &unused);
+  GNUNET_thread_release_self (info.parent);
+  GNUNET_client_connection_destroy (sock);
   return info.total;
 }
 
@@ -198,24 +199,25 @@
  * @param key the key to store
  * @param expire how long until the content should expire (absolute time)
  * @param value what to store
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_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)
+             const GNUNET_HashCode * key,
+             unsigned int type, GNUNET_CronTime expire,
+             const DataContainer * value)
 {
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   CS_dht_request_put_MESSAGE *req;
   int ret;
-  cron_t now;
+  GNUNET_CronTime now;
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   if (expire < now)
     {
       GE_BREAK (ectx, 0);       /* content already expired!? */
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #if DEBUG_DHT_API
   GE_LOG (ectx,
@@ -223,23 +225,23 @@
           "DHT_LIB_put called with value '%.*s'\n",
           ntohl (value->size), &value[1]);
 #endif
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   GE_ASSERT (NULL, ntohl (value->size) >= sizeof (DataContainer));
-  req = MALLOC (sizeof (CS_dht_request_put_MESSAGE) +
-                ntohl (value->size) - sizeof (DataContainer));
+  req = GNUNET_malloc (sizeof (CS_dht_request_put_MESSAGE) +
+                       ntohl (value->size) - sizeof (DataContainer));
   req->header.size
     = htons (sizeof (CS_dht_request_put_MESSAGE) +
              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 */
+  req->expire = GNUNET_htonll (expire - now);   /* convert to relative time */
   memcpy (&req[1], &value[1], ntohl (value->size) - sizeof (DataContainer));
-  ret = connection_write (sock, &req->header);
-  connection_destroy (sock);
-  FREE (req);
+  ret = GNUNET_client_connection_write (sock, &req->header);
+  GNUNET_client_connection_destroy (sock);
+  GNUNET_free (req);
   return ret;
 }
 

Modified: GNUnet/src/applications/dht/tools/dhttest.c
===================================================================
--- GNUnet/src/applications/dht/tools/dhttest.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/dht/tools/dhttest.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -45,9 +45,9 @@
   if ((value > 0) && (0 == strcmp (_("# dht connections"), name)))
     {
       ok = 1;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 #define CHECK(a) do { if (!(a)) { ret = 1; GE_BREAK(ectx, 0); goto FAILURE; } 
} while(0)
@@ -59,13 +59,13 @@
 int
 main (int argc, const char **argv)
 {
-  struct DaemonContext *peers;
+  struct GNUNET_TESTING_DaemonContext *peers;
   int ret = 0;
-  HashCode512 key;
+  GNUNET_HashCode key;
   DataContainer *value;
   struct GE_Context *ectx;
   struct GC_Configuration *cfg;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   int left;
   int i;
   int j;
@@ -74,13 +74,13 @@
   char buf[128];
 
   ectx = NULL;
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
-  peers = gnunet_testing_start_daemons ("tcp",
+  peers = GNUNET_TESTING_start_daemons ("tcp",
                                         "advertising dht stats",
                                         "/tmp/gnunet-dht-test",
                                         2087, 10, NUM_PEERS);
@@ -93,10 +93,10 @@
     {
       for (j = 0; j < i; j++)
         {
-          if (OK != gnunet_testing_connect_daemons (2087 + 10 * i,
-                                                    2087 + 10 * j))
+          if (GNUNET_OK != GNUNET_TESTING_connect_daemons (2087 + 10 * i,
+                                                           2087 + 10 * j))
             {
-              gnunet_testing_stop_daemons (peers);
+              GNUNET_TESTING_stop_daemons (peers);
               fprintf (stderr, "Failed to connect the peers!\n");
               GC_free (cfg);
               return -1;
@@ -105,9 +105,9 @@
     }
 
   /* wait for some DHT's to find each other! */
-  sock = client_connection_create (NULL, cfg);
+  sock = GNUNET_client_connection_create (NULL, cfg);
   left = 30;                    /* how many iterations should we wait? */
-  while (OK == STATS_getStatistics (NULL, sock, &waitForConnect, NULL))
+  while (GNUNET_OK == STATS_getStatistics (NULL, sock, &waitForConnect, NULL))
     {
       printf ("Waiting for peers to DHT-connect (%u iterations left)...\n",
               left);
@@ -116,10 +116,10 @@
       if (left == 0)
         break;
     }
-  connection_destroy (sock);
+  GNUNET_client_connection_destroy (sock);
   if (ok == 0)
     {
-      gnunet_testing_stop_daemons (peers);
+      GNUNET_TESTING_stop_daemons (peers);
       fprintf (stderr, "Peers' DHTs failed to DHT-connect!\n");
       GC_free (cfg);
       return -1;
@@ -128,19 +128,19 @@
   /* put loop */
   for (i = 0; i < NUM_PEERS; i++)
     {
-      SNPRINTF (buf, 128, "localhost:%u", 2087 + i * 10);
+      GNUNET_snprintf (buf, 128, "localhost:%u", 2087 + i * 10);
       GC_set_configuration_value_string (cfg, ectx, "NETWORK", "HOST", buf);
-      hash (buf, 4, &key);
-      value = MALLOC (8);
+      GNUNET_hash (buf, 4, &key);
+      value = GNUNET_malloc (8);
       value->size = ntohl (8);
       memset (&value[1], '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));
+      CHECK (GNUNET_OK == DHT_LIB_put (cfg,
+                                       ectx,
+                                       &key,
+                                       DHT_STRING2STRING_BLOCK,
+                                       GNUNET_get_time () +
+                                       15 * GNUNET_CRON_MINUTES * NUM_ROUNDS *
+                                       NUM_PEERS * NUM_PEERS, value));
     }
 
   /* get loops */
@@ -149,19 +149,19 @@
       found = 0;
       for (i = 0; i < NUM_PEERS; i++)
         {
-          SNPRINTF (buf, 128, "localhost:%u", 2087 + i * 10);
+          GNUNET_snprintf (buf, 128, "localhost:%u", 2087 + i * 10);
           GC_set_configuration_value_string (cfg,
                                              ectx, "NETWORK", "HOST", buf);
           for (j = 0; j < NUM_PEERS; j++)
             {
-              SNPRINTF (buf, 128, "localhost:%u", 2087 + j * 10);
-              hash (buf, 4, &key);
+              GNUNET_snprintf (buf, 128, "localhost:%u", 2087 + j * 10);
+              GNUNET_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,
+                                   (NUM_ROUNDS - k) * GNUNET_CRON_SECONDS,
                                    NULL, NULL))
                 {
                   fprintf (stderr, " - found!\n");
@@ -177,7 +177,7 @@
                found, NUM_PEERS * NUM_PEERS, k);
     }
 FAILURE:
-  gnunet_testing_stop_daemons (peers);
+  GNUNET_TESTING_stop_daemons (peers);
   GC_free (cfg);
   return ret;
 }

Modified: GNUnet/src/applications/dht/tools/dhttest2.c
===================================================================
--- GNUnet/src/applications/dht/tools/dhttest2.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/dht/tools/dhttest2.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -45,9 +45,9 @@
   if ((value > 0) && (0 == strcmp (_("# dht connections"), name)))
     {
       ok = 1;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 #define CHECK(a) do { if (!(a)) { ret = 1; GE_BREAK(ectx, 0); goto FAILURE; } 
} while(0)
@@ -60,25 +60,25 @@
 main (int argc, const char **argv)
 {
 #if START_PEERS
-  struct DaemonContext *peers;
+  struct GNUNET_TESTING_DaemonContext *peers;
 #endif
   int ret = 0;
-  HashCode512 key;
+  GNUNET_HashCode key;
   DataContainer *value;
   struct GE_Context *ectx;
   struct GC_Configuration *cfg;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   int left;
 
   ectx = NULL;
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_PEERS
-  peers = gnunet_testing_start_daemons ("tcp",
+  peers = GNUNET_TESTING_start_daemons ("tcp",
                                         "advertising dht stats",
                                         "/tmp/gnunet-dht-test",
                                         2087, 10000, 2);
@@ -88,18 +88,18 @@
       return -1;
     }
 #endif
-  if (OK != gnunet_testing_connect_daemons (2087, 12087))
+  if (GNUNET_OK != GNUNET_TESTING_connect_daemons (2087, 12087))
     {
-      gnunet_testing_stop_daemons (peers);
+      GNUNET_TESTING_stop_daemons (peers);
       fprintf (stderr, "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);
+  sock = GNUNET_client_connection_create (NULL, cfg);
   left = 30;                    /* how many iterations should we wait? */
-  while (OK == STATS_getStatistics (NULL, sock, &waitForConnect, NULL))
+  while (GNUNET_OK == STATS_getStatistics (NULL, sock, &waitForConnect, NULL))
     {
       printf ("Waiting for peers to DHT-connect (%u iterations left)...\n",
               left);
@@ -108,10 +108,10 @@
       if (left == 0)
         break;
     }
-  connection_destroy (sock);
+  GNUNET_client_connection_destroy (sock);
   if (ok == 0)
     {
-      gnunet_testing_stop_daemons (peers);
+      GNUNET_TESTING_stop_daemons (peers);
       fprintf (stderr, "Peers' DHTs failed to DHT-connect!\n");
       GC_free (cfg);
       return -1;
@@ -123,9 +123,9 @@
                                      "NETWORK", "HOST", "localhost:12087");
   /* verify that peer2 also sees the other DHT! */
   ok = 0;
-  sock = client_connection_create (NULL, cfg);
+  sock = GNUNET_client_connection_create (NULL, cfg);
   left = 30;                    /* how many iterations should we wait? */
-  while (OK == STATS_getStatistics (NULL, sock, &waitForConnect, NULL))
+  while (GNUNET_OK == STATS_getStatistics (NULL, sock, &waitForConnect, NULL))
     {
       printf ("Waiting for peers to DHT-connect (%u iterations left)...\n",
               left);
@@ -134,10 +134,10 @@
       if (left == 0)
         break;
     }
-  connection_destroy (sock);
+  GNUNET_client_connection_destroy (sock);
   if (ok == 0)
     {
-      gnunet_testing_stop_daemons (peers);
+      GNUNET_TESTING_stop_daemons (peers);
       fprintf (stderr, "Peers' DHTs failed to DHT-connect!\n");
       GC_free (cfg);
       return -1;
@@ -150,47 +150,49 @@
                                      "NETWORK", "HOST", "localhost:2087");
 
   /* actual test code */
-  hash ("key2", 4, &key);
-  value = MALLOC (8);
+  GNUNET_hash ("key2", 4, &key);
+  value = GNUNET_malloc (8);
   value->size = ntohl (8);
   memset (&value[1], 'A', 4);
   printf ("Peer1 stores key2\n");
-  CHECK (OK == DHT_LIB_put (cfg,
-                            ectx,
-                            &key,
-                            DHT_STRING2STRING_BLOCK,
-                            get_time () + 5 * cronMINUTES, value));
+  CHECK (GNUNET_OK == DHT_LIB_put (cfg,
+                                   ectx,
+                                   &key,
+                                   DHT_STRING2STRING_BLOCK,
+                                   GNUNET_get_time () +
+                                   5 * GNUNET_CRON_MINUTES, value));
   printf ("Peer1 gets key2\n");
   CHECK (1 == DHT_LIB_get (cfg,
                            ectx,
                            DHT_STRING2STRING_BLOCK,
-                           &key, 2 * cronSECONDS, NULL, NULL));
+                           &key, 2 * GNUNET_CRON_SECONDS, NULL, NULL));
   /* switch to peer2 */
   GC_set_configuration_value_string (cfg,
                                      ectx,
                                      "NETWORK", "HOST", "localhost:12087");
-  hash ("key", 3, &key);
-  value = MALLOC (8);
+  GNUNET_hash ("key", 3, &key);
+  value = GNUNET_malloc (8);
   value->size = ntohl (8);
   memset (&value[1], 'B', 4);
   printf ("Peer2 stores key.\n");
-  CHECK (OK == DHT_LIB_put (cfg,
-                            ectx,
-                            &key,
-                            DHT_STRING2STRING_BLOCK,
-                            get_time () + 5 * cronMINUTES, value));
+  CHECK (GNUNET_OK == DHT_LIB_put (cfg,
+                                   ectx,
+                                   &key,
+                                   DHT_STRING2STRING_BLOCK,
+                                   GNUNET_get_time () +
+                                   5 * GNUNET_CRON_MINUTES, value));
   printf ("Peer2 gets key.\n");
   CHECK (1 == DHT_LIB_get (cfg,
                            ectx,
                            DHT_STRING2STRING_BLOCK,
-                           &key, 2 * cronSECONDS, NULL, NULL));
+                           &key, 2 * GNUNET_CRON_SECONDS, NULL, NULL));
 
-  hash ("key2", 4, &key);
+  GNUNET_hash ("key2", 4, &key);
   printf ("Peer2 gets key2.\n");
   CHECK (1 == DHT_LIB_get (cfg,
                            ectx,
                            DHT_STRING2STRING_BLOCK,
-                           &key, 30 * cronSECONDS, NULL, NULL));
+                           &key, 30 * GNUNET_CRON_SECONDS, NULL, NULL));
   /* switch to peer1 */
   GC_set_configuration_value_string (cfg,
                                      ectx,
@@ -199,12 +201,12 @@
   CHECK (1 == DHT_LIB_get (cfg,
                            ectx,
                            DHT_STRING2STRING_BLOCK,
-                           &key, 30 * cronSECONDS, NULL, NULL));
+                           &key, 30 * GNUNET_CRON_SECONDS, NULL, NULL));
   /* end of actual test code */
 
 FAILURE:
 #if START_PEERS
-  gnunet_testing_stop_daemons (peers);
+  GNUNET_TESTING_stop_daemons (peers);
 #endif
   GC_free (cfg);
   return ret;

Modified: GNUnet/src/applications/dstore/Makefile.am
===================================================================
--- GNUnet/src/applications/dstore/Makefile.am  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/dstore/Makefile.am  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -22,7 +22,6 @@
   $(SQLITE_LDFLAGS)
 libgnunetmodule_dstore_la_LIBADD = \
  $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/containers/libgnunetutil_containers.la \
  -lsqlite3
 
 EXTRA_DIST = check.conf
@@ -31,5 +30,4 @@
  dstore_test.c 
 dstore_test_LDADD = \
  $(top_builddir)/src/server/libgnunetcore.la  \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
  $(top_builddir)/src/util/libgnunetutil.la  

Modified: GNUnet/src/applications/dstore/dstore.c
===================================================================
--- GNUnet/src/applications/dstore/dstore.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/dstore/dstore.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -34,7 +34,7 @@
 #include "gnunet_stats_service.h"
 #include <sqlite3.h>
 
-#define DEBUG_DSTORE NO
+#define DEBUG_DSTORE GNUNET_NO
 
 /**
  * Maximum size for an individual item.
@@ -58,7 +58,7 @@
 
 static CoreAPIForApplication *coreAPI;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * Statistics service.
@@ -70,9 +70,9 @@
 /**
  * Estimate of the per-entry overhead (including indices).
  */
-#define OVERHEAD ((4+4+8+8*2+sizeof(HashCode512)*2+32))
+#define OVERHEAD ((4+4+8+8*2+sizeof(GNUNET_HashCode)*2+32))
 
-struct Bloomfilter *bloom;
+struct GNUNET_BloomFilter *bloom;
 
 static char *bloom_name;
 
@@ -129,51 +129,51 @@
   if (fn != NULL)
     {
       UNLINK (fn);
-      FREE (fn);
+      GNUNET_free (fn);
     }
   tmpl = "/tmp/dstoreXXXXXX";
 
 #ifdef MINGW
-  fn = (char *) MALLOC (MAX_PATH + 1);
+  fn = (char *) GNUNET_malloc (MAX_PATH + 1);
   plibc_conv_to_win_path (tmpl, fn);
 #else
-  fn = STRDUP (tmpl);
+  fn = GNUNET_strdup (tmpl);
 #endif
   fd = mkstemp (fn);
   if (fd == -1)
     {
       GE_BREAK (NULL, 0);
-      FREE (fn);
+      GNUNET_free (fn);
       fn = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   CLOSE (fd);
   if (SQLITE_OK != sqlite3_open (fn, &dbh))
-    return SYSERR;
+    return GNUNET_SYSERR;
   db_init (dbh);
   sqlite3_close (dbh);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Check that we are within quota.
- * @return OK if we are.
+ * @return GNUNET_OK if we are.
  */
 static int
 checkQuota (sqlite3 * dbh)
 {
-  HashCode512 dkey;
+  GNUNET_HashCode dkey;
   unsigned int dsize;
   unsigned int dtype;
-  cron_t dputtime;
-  cron_t dexpire;
+  GNUNET_CronTime dputtime;
+  GNUNET_CronTime dexpire;
   char *dcontent;
   sqlite3_stmt *stmt;
   sqlite3_stmt *dstmt;
   int err;
 
   if (payload * 10 <= quota * 9)
-    return OK;                  /* we seem to be about 10% off */
+    return GNUNET_OK;           /* we seem to be about 10% off */
 #if DEBUG_DSTORE
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
@@ -199,9 +199,9 @@
         sqlite3_finalize (dstmt);
       if (stmt != NULL)
         sqlite3_finalize (stmt);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  dcontent = MALLOC (MAX_CONTENT_SIZE);
+  dcontent = GNUNET_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))
@@ -210,9 +210,10 @@
       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));
+      GE_BREAK (NULL,
+                sqlite3_column_bytes (stmt, 4) == sizeof (GNUNET_HashCode));
       GE_BREAK (NULL, dsize == sqlite3_column_bytes (stmt, 5));
-      memcpy (&dkey, sqlite3_column_blob (stmt, 4), sizeof (HashCode512));
+      memcpy (&dkey, sqlite3_column_blob (stmt, 4), sizeof (GNUNET_HashCode));
       if (dsize >= MAX_CONTENT_SIZE)
         {
           GE_BREAK (NULL, 0);
@@ -225,7 +226,8 @@
       sqlite3_bind_int64 (dstmt, 3, dputtime);
       sqlite3_bind_int64 (dstmt, 4, dexpire);
       sqlite3_bind_blob (dstmt,
-                         5, &dkey, sizeof (HashCode512), SQLITE_TRANSIENT);
+                         5, &dkey, sizeof (GNUNET_HashCode),
+                         SQLITE_TRANSIENT);
       sqlite3_bind_blob (dstmt, 6, dcontent, dsize, SQLITE_TRANSIENT);
       if ((err = sqlite3_step (dstmt)) != SQLITE_DONE)
         {
@@ -253,7 +255,7 @@
               _("`%s' failed at %s:%d with error: %s\n"),
               "sqlite3_step", __FILE__, __LINE__, sqlite3_errmsg (dbh));
     }
-  FREE (dcontent);
+  GNUNET_free (dcontent);
   sqlite3_finalize (dstmt);
   sqlite3_finalize (stmt);
   if (payload * 10 > quota * 9)
@@ -263,33 +265,33 @@
               GE_ERROR | GE_BULK | GE_DEVELOPER,
               "Failed to delete content to drop below quota (bug?).\n",
               payload, quota);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Store an item in the datastore.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
-d_put (const HashCode512 * key,
+d_put (const GNUNET_HashCode * key,
        unsigned int type,
-       cron_t discard_time, unsigned int size, const char *data)
+       GNUNET_CronTime discard_time, unsigned int size, const char *data)
 {
   sqlite3 *dbh;
   sqlite3_stmt *stmt;
   int ret;
 
   if (size > MAX_CONTENT_SIZE)
-    return SYSERR;
-  MUTEX_LOCK (lock);
+    return GNUNET_SYSERR;
+  GNUNET_mutex_lock (lock);
   if ((fn == NULL) || (SQLITE_OK != sqlite3_open (fn, &dbh)))
     {
       db_reset (dbh);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
 #if DEBUG_DSTORE
   GE_LOG (coreAPI->ectx,
@@ -308,13 +310,13 @@
               _("`%s' failed at %s:%d with error: %s\n"),
               "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (dbh));
       sqlite3_close (dbh);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
-  if ((SQLITE_OK != sqlite3_bind_int64 (stmt, 1, get_time ())) ||
+  if ((SQLITE_OK != sqlite3_bind_int64 (stmt, 1, GNUNET_get_time ())) ||
       (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, discard_time)) ||
       (SQLITE_OK !=
-       sqlite3_bind_blob (stmt, 3, key, sizeof (HashCode512),
+       sqlite3_bind_blob (stmt, 3, key, sizeof (GNUNET_HashCode),
                           SQLITE_TRANSIENT))
       || (SQLITE_OK != sqlite3_bind_int (stmt, 4, type))
       || (SQLITE_OK != sqlite3_bind_int (stmt, 5, size))
@@ -327,8 +329,8 @@
               "sqlite3_bind_xxx", __FILE__, __LINE__, sqlite3_errmsg (dbh));
       sqlite3_finalize (stmt);
       sqlite3_close (dbh);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   if (SQLITE_DONE != sqlite3_step (stmt))
     {
@@ -338,25 +340,25 @@
               "sqlite3_step", __FILE__, __LINE__, sqlite3_errmsg (dbh));
       sqlite3_finalize (stmt);
       sqlite3_close (dbh);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   ret = sqlite3_changes (dbh);
   sqlite3_finalize (stmt);
   if (ret > 0)
     {
       sqlite3_close (dbh);
-      MUTEX_UNLOCK (lock);
-      return OK;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_OK;
     }
   if (bloom != NULL)
-    addToBloomfilter (bloom, key);
+    GNUNET_bloomfilter_add (bloom, key);
 
-  if (OK != checkQuota (dbh))
+  if (GNUNET_OK != checkQuota (dbh))
     {
       sqlite3_close (dbh);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   if (sq_prepare (dbh,
                   "INSERT INTO ds071 "
@@ -368,15 +370,15 @@
               _("`%s' failed at %s:%d with error: %s\n"),
               "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (dbh));
       sqlite3_close (dbh);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   if ((SQLITE_OK == sqlite3_bind_int (stmt, 1, size)) &&
       (SQLITE_OK == sqlite3_bind_int (stmt, 2, type)) &&
-      (SQLITE_OK == sqlite3_bind_int64 (stmt, 3, get_time ())) &&
+      (SQLITE_OK == sqlite3_bind_int64 (stmt, 3, GNUNET_get_time ())) &&
       (SQLITE_OK == sqlite3_bind_int64 (stmt, 4, discard_time)) &&
       (SQLITE_OK ==
-       sqlite3_bind_blob (stmt, 5, key, sizeof (HashCode512),
+       sqlite3_bind_blob (stmt, 5, key, sizeof (GNUNET_HashCode),
                           SQLITE_TRANSIENT))
       && (SQLITE_OK ==
           sqlite3_bind_blob (stmt, 6, data, size, SQLITE_TRANSIENT)))
@@ -406,10 +408,10 @@
 #endif
   checkQuota (dbh);
   sqlite3_close (dbh);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   if (stats != NULL)
     stats->set (stat_dstore_size, payload);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -419,37 +421,37 @@
  * @param key
  * @param type entries of which type are relevant?
  * @param iter maybe NULL (to just count)
- * @return the number of results, SYSERR if the
+ * @return the number of results, GNUNET_SYSERR if the
  *   iter is non-NULL and aborted the iteration
  */
 static int
-d_get (const HashCode512 * key,
+d_get (const GNUNET_HashCode * key,
        unsigned int type, ResultHandler handler, void *closure)
 {
   sqlite3 *dbh;
   sqlite3_stmt *stmt;
-  cron_t now;
+  GNUNET_CronTime now;
   unsigned int size;
   const char *dat;
   unsigned int cnt;
 
-  MUTEX_LOCK (lock);
-  if ((bloom != NULL) && (NO == testBloomfilter (bloom, key)))
+  GNUNET_mutex_lock (lock);
+  if ((bloom != NULL) && (GNUNET_NO == GNUNET_bloomfilter_test (bloom, key)))
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return 0;
     }
   if ((fn == NULL) || (SQLITE_OK != sqlite3_open (fn, &dbh)))
     {
       db_reset (dbh);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
 #if DEBUG_DSTORE
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_DEVELOPER, "dstore processes get\n");
 #endif
-  now = get_time ();
+  now = GNUNET_get_time ();
   if (sq_prepare (dbh,
                   "SELECT size, value FROM ds071 WHERE key=? AND type=? AND 
expire >= ?",
                   &stmt) != SQLITE_OK)
@@ -459,10 +461,11 @@
               _("`%s' failed at %s:%d with error: %s\n"),
               "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (dbh));
       sqlite3_close (dbh);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
-  sqlite3_bind_blob (stmt, 1, key, sizeof (HashCode512), SQLITE_TRANSIENT);
+  sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode),
+                     SQLITE_TRANSIENT);
   sqlite3_bind_int (stmt, 2, type);
   sqlite3_bind_int (stmt, 3, now);
   cnt = 0;
@@ -480,7 +483,7 @@
     }
   sqlite3_finalize (stmt);
   sqlite3_close (dbh);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return cnt;
 }
 
@@ -495,12 +498,12 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           "SQLite Dstore: initializing database\n");
 #endif
-  if (OK != db_reset ())
+  if (GNUNET_OK != db_reset ())
     {
       GE_BREAK (capi->ectx, 0);
       return NULL;
     }
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
 
 
   coreAPI = capi;
@@ -512,12 +515,12 @@
     quota = 1;
   quota *= 1024 * 1024;
 
-  bloom_name = STRDUP ("/tmp/dbloomXXXXXX");
+  bloom_name = GNUNET_strdup ("/tmp/dbloomXXXXXX");
   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 = GNUNET_bloomfilter_load (coreAPI->ectx, bloom_name, quota / 
(OVERHEAD + 1024),    /* 8 bit per entry in DB, expect 1k entries */
+                                       5);
       CLOSE (fd);
     }
   stats = capi->requestService ("stats");
@@ -533,15 +536,15 @@
 release_module_dstore ()
 {
   UNLINK (fn);
-  FREE (fn);
+  GNUNET_free (fn);
   fn = NULL;
   if (bloom != NULL)
     {
-      freeBloomfilter (bloom);
+      GNUNET_bloomfilter_free (bloom);
       bloom = NULL;
     }
   UNLINK (bloom_name);
-  FREE (bloom_name);
+  GNUNET_free (bloom_name);
   bloom_name = NULL;
   if (stats != NULL)
     {
@@ -553,7 +556,7 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           "SQLite Dstore: database shutdown\n");
 #endif
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   coreAPI = NULL;
 }
 

Modified: GNUnet/src/applications/dstore/dstore_test.c
===================================================================
--- GNUnet/src/applications/dstore/dstore_test.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/dstore/dstore_test.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -36,10 +36,10 @@
 static int error;
 
 static void
-checkIt (const HashCode512 * key,
+checkIt (const GNUNET_HashCode * key,
          unsigned int type, unsigned int size, const char *data, void *cls)
 {
-  if (size != sizeof (HashCode512))
+  if (size != sizeof (GNUNET_HashCode))
     {
       printf ("ERROR: Invalid size\n");
       error = 2;
@@ -57,31 +57,32 @@
 static int
 test (Dstore_ServiceAPI * api)
 {
-  HashCode512 k;
-  HashCode512 n;
-  cron_t exp;
+  GNUNET_HashCode k;
+  GNUNET_HashCode n;
+  GNUNET_CronTime exp;
   unsigned int i;
 
-  exp = get_time () + 5 * cronMINUTES;
-  memset (&k, 0, sizeof (HashCode512));
+  exp = GNUNET_get_time () + 5 * GNUNET_CRON_MINUTES;
+  memset (&k, 0, sizeof (GNUNET_HashCode));
   for (i = 0; i < 100; i++)
     {
-      hash (&k, sizeof (HashCode512), &n);
-      ASSERT (OK == api->put (&k,
-                              i % 2,
-                              exp, sizeof (HashCode512), (const char *) &n));
+      GNUNET_hash (&k, sizeof (GNUNET_HashCode), &n);
+      ASSERT (GNUNET_OK == api->put (&k,
+                                     i % 2,
+                                     exp, sizeof (GNUNET_HashCode),
+                                     (const char *) &n));
       k = n;
     }
-  memset (&k, 0, sizeof (HashCode512));
+  memset (&k, 0, sizeof (GNUNET_HashCode));
   for (i = 0; i < 100; i++)
     {
-      hash (&k, sizeof (HashCode512), &n);
+      GNUNET_hash (&k, sizeof (GNUNET_HashCode), &n);
       ASSERT (1 == api->get (&k, i % 2, &checkIt, &n));
       k = n;
     }
-  return OK;
+  return GNUNET_OK;
 FAILURE:
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 #define TEST_DB "/tmp/GNUnet_dstore_test/"
@@ -92,9 +93,9 @@
   Dstore_ServiceAPI *api;
   int ok;
   struct GC_Configuration *cfg;
-  struct CronManager *cron;
+  struct GNUNET_CronManager *cron;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
@@ -109,9 +110,9 @@
       releaseService (api);
     }
   else
-    ok = SYSERR;
+    ok = GNUNET_SYSERR;
   doneCore ();
-  if (ok == SYSERR)
+  if (ok == GNUNET_SYSERR)
     return 1;
   return error;
 }

Modified: GNUnet/src/applications/fragmentation/Makefile.am
===================================================================
--- GNUnet/src/applications/fragmentation/Makefile.am   2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fragmentation/Makefile.am   2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -8,9 +8,7 @@
 libgnunetmodule_fragmentation_la_SOURCES = \
   fragmentation.c 
 libgnunetmodule_fragmentation_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la  \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la 
+ $(top_builddir)/src/util/libgnunetutil.la  
 libgnunetmodule_fragmentation_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 
@@ -29,7 +27,5 @@
 fragmentationtest_SOURCES = \
  fragmentationtest.c 
 fragmentationtest_LDADD = \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 

Modified: GNUnet/src/applications/fragmentation/fragmentation.c
===================================================================
--- GNUnet/src/applications/fragmentation/fragmentation.c       2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/fragmentation/fragmentation.c       2007-11-23 
11:51:54 UTC (rev 5742)
@@ -43,7 +43,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Fragment identity.
@@ -63,7 +63,7 @@
 } P2P_fragmentation_MESSAGE;
 
 /**
- * How many buckets does the fragment hash table
+ * How many buckets does the fragment GNUNET_hash table
  * have?
  */
 #define DEFRAG_BUCKET_COUNT 16
@@ -72,7 +72,7 @@
  * After how long do fragments time out?
  */
 #ifndef DEFRAGMENTATION_TIMEOUT
-#define DEFRAGMENTATION_TIMEOUT (3 * cronMINUTES)
+#define DEFRAGMENTATION_TIMEOUT (3 * GNUNET_CRON_MINUTES)
 #endif
 
 /**
@@ -85,15 +85,15 @@
 } FL;
 
 /**
- * Entry in the hash table of fragments.
+ * Entry in the GNUNET_hash table of fragments.
  */
 typedef struct FC
 {
   struct FC *next;
   FL *head;
-  PeerIdentity sender;
+  GNUNET_PeerIdentity sender;
   int id;
-  cron_t ttl;
+  GNUNET_CronTime ttl;
 } FC;
 
 #define FRAGSIZE(fl) 
((ntohs(fl->frag->header.size)-sizeof(P2P_fragmentation_MESSAGE)))
@@ -116,7 +116,7 @@
 /**
  * Lock for the defragmentation cache.
  */
-static struct MUTEX *defragCacheLock;
+static struct GNUNET_Mutex *defragCacheLock;
 
 static void
 freeFL (FL * fl, int c)
@@ -126,8 +126,8 @@
       FL *link = fl->link;
       if (stats != NULL)
         stats->change (stat_discarded, c);
-      FREE (fl->frag);
-      FREE (fl);
+      GNUNET_free (fl->frag);
+      GNUNET_free (fl);
       fl = link;
     }
 }
@@ -150,19 +150,19 @@
   FC *next;
   FC *last;
 
-  MUTEX_LOCK (defragCacheLock);
+  GNUNET_mutex_lock (defragCacheLock);
   for (i = 0; i < DEFRAG_BUCKET_COUNT; i++)
     {
       last = NULL;
       smf = defragmentationCache[i];
       while (smf != NULL)
         {
-          if (smf->ttl < get_time ())
+          if (smf->ttl < GNUNET_get_time ())
             {
               /* free linked list of fragments */
               freeFL (smf->head, 1);
               next = smf->next;
-              FREE (smf);
+              GNUNET_free (smf);
               if (last == NULL)
                 defragmentationCache[i] = next;
               else
@@ -176,7 +176,7 @@
             }
         }                       /* while smf != NULL */
     }                           /* for all buckets */
-  MUTEX_UNLOCK (defragCacheLock);
+  GNUNET_mutex_unlock (defragCacheLock);
 }
 
 /**
@@ -185,7 +185,7 @@
  * itself (but sets the TTL to 0 to have the cron free it
  * in the next iteration).
  *
- * @param pep the entry in the hash table
+ * @param pep the entry in the GNUNET_hash table
  */
 static void
 checkComplete (FC * pep)
@@ -216,7 +216,7 @@
   if (off < len)
     return;                     /* some fragment is still missing */
 
-  msg = MALLOC (len);
+  msg = GNUNET_malloc (len);
   pos = pep->head;
   while (pos != NULL)
     {
@@ -229,8 +229,8 @@
   printf ("Finished defragmentation!\n");
 #endif
   /* handle message! */
-  coreAPI->injectMessage (&pep->sender, msg, len, YES, NULL);
-  FREE (msg);
+  coreAPI->injectMessage (&pep->sender, msg, len, GNUNET_YES, NULL);
+  GNUNET_free (msg);
 CLEANUP:
   /* free fragment buffers */
   freeFL (pep->head, 0);
@@ -240,7 +240,7 @@
 
 /**
  * See if the new fragment is a part of this entry and join them if
- * yes.  Return SYSERR if the fragments do not match.  Return OK if
+ * yes.  Return GNUNET_SYSERR if the fragments do not match.  Return GNUNET_OK 
if
  * the fragments do match and the fragment has been processed.  The
  * defragCacheLock is already acquired by the caller whenever this
  * method is called.<p>
@@ -251,7 +251,7 @@
  */
 static int
 tryJoin (FC * entry,
-         const PeerIdentity * sender,
+         const GNUNET_PeerIdentity * sender,
          const P2P_fragmentation_MESSAGE * packet)
 {
   /* frame before ours; may end in the middle of
@@ -270,10 +270,10 @@
   unsigned short end;
 
   GE_ASSERT (NULL, entry != NULL);
-  if (0 != memcmp (sender, &entry->sender, sizeof (PeerIdentity)))
-    return SYSERR;              /* wrong fragment list, try another! */
+  if (0 != memcmp (sender, &entry->sender, sizeof (GNUNET_PeerIdentity)))
+    return GNUNET_SYSERR;       /* wrong fragment list, try another! */
   if (ntohl (packet->id) != entry->id)
-    return SYSERR;              /* wrong fragment list, try another! */
+    return GNUNET_SYSERR;       /* wrong fragment list, try another! */
 #if 0
   printf ("Received fragment %u from %u to %u\n",
           ntohl (packet->id),
@@ -283,7 +283,7 @@
 #endif
   pos = entry->head;
   if ((pos != NULL) && (packet->len != pos->frag->len))
-    return SYSERR;              /* wrong fragment size */
+    return GNUNET_SYSERR;       /* wrong fragment size */
 
   before = NULL;
   /* find the before-frame */
@@ -302,7 +302,7 @@
       GE_LOG (NULL,
               GE_DEVELOPER | GE_DEBUG | GE_BULK,
               "Received invalid fragment at %s:%d\n", __FILE__, __LINE__);
-      return SYSERR;            /* yuck! integer overflow! */
+      return GNUNET_SYSERR;     /* yuck! integer overflow! */
     }
 
   if (before != NULL)
@@ -319,7 +319,7 @@
          fragment */
       if (stats != NULL)
         stats->change (stat_defragmented, 1);
-      return OK;                /* drop, there is a packet that spans our 
range! */
+      return GNUNET_OK;         /* drop, there is a packet that spans our 
range! */
     }
 
   if ((before != NULL) &&
@@ -332,12 +332,12 @@
          or even overlap; thus we can drop this redundant piece */
       if (stats != NULL)
         stats->change (stat_defragmented, 1);
-      return OK;
+      return GNUNET_OK;
     }
 
   /* allocate pep */
-  pep = MALLOC (sizeof (FC));
-  pep->frag = MALLOC (ntohs (packet->header.size));
+  pep = GNUNET_malloc (sizeof (FC));
+  pep->frag = GNUNET_malloc (ntohs (packet->header.size));
   memcpy (pep->frag, packet, ntohs (packet->header.size));
   pep->link = NULL;
 
@@ -348,8 +348,8 @@
       while (pos != after)
         {
           tmp = pos->link;
-          FREE (pos->frag);
-          FREE (pos);
+          GNUNET_free (pos->frag);
+          GNUNET_free (pos);
           pos = tmp;
         }
       entry->head = pep;
@@ -373,17 +373,17 @@
   while (pos != after)
     {
       tmp = pos->link;
-      FREE (pos->frag);
-      FREE (pos);
+      GNUNET_free (pos->frag);
+      GNUNET_free (pos);
       pos = tmp;
     }
   before->link = pep;
   pep->link = after;
 
 FINISH:
-  entry->ttl = get_time () + DEFRAGMENTATION_TIMEOUT;
+  entry->ttl = GNUNET_get_time () + DEFRAGMENTATION_TIMEOUT;
   checkComplete (entry);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -391,28 +391,30 @@
  * defragmentation is complete.
  *
  * @param frag the packet to defragment
- * @return SYSERR if the fragment is invalid
+ * @return GNUNET_SYSERR if the fragment is invalid
  */
 static int
-processFragment (const PeerIdentity * sender, const MESSAGE_HEADER * frag)
+processFragment (const GNUNET_PeerIdentity * sender,
+                 const GNUNET_MessageHeader * frag)
 {
   unsigned int hash;
   FC *smf;
 
   if (ntohs (frag->size) < sizeof (P2P_fragmentation_MESSAGE))
-    return SYSERR;
+    return GNUNET_SYSERR;
 
-  MUTEX_LOCK (defragCacheLock);
+  GNUNET_mutex_lock (defragCacheLock);
   hash = sender->hashPubKey.bits[0] % DEFRAG_BUCKET_COUNT;
   smf = defragmentationCache[hash];
   while (smf != NULL)
     {
-      if (OK == tryJoin (smf, sender, (P2P_fragmentation_MESSAGE *) frag))
+      if (GNUNET_OK ==
+          tryJoin (smf, sender, (P2P_fragmentation_MESSAGE *) frag))
         {
-          MUTEX_UNLOCK (defragCacheLock);
-          return OK;
+          GNUNET_mutex_unlock (defragCacheLock);
+          return GNUNET_OK;
         }
-      if (0 == memcmp (sender, &smf->sender, sizeof (PeerIdentity)))
+      if (0 == memcmp (sender, &smf->sender, sizeof (GNUNET_PeerIdentity)))
         {
           freeFL (smf->head, 1);
           break;
@@ -421,31 +423,31 @@
     }
   if (smf == NULL)
     {
-      smf = MALLOC (sizeof (FC));
+      smf = GNUNET_malloc (sizeof (FC));
       smf->next = defragmentationCache[hash];
       defragmentationCache[hash] = smf;
-      smf->ttl = get_time () + DEFRAGMENTATION_TIMEOUT;
+      smf->ttl = GNUNET_get_time () + DEFRAGMENTATION_TIMEOUT;
       smf->sender = *sender;
     }
   smf->id = ntohl (((P2P_fragmentation_MESSAGE *) frag)->id);
-  smf->head = MALLOC (sizeof (FL));
+  smf->head = GNUNET_malloc (sizeof (FL));
   smf->head->link = NULL;
-  smf->head->frag = MALLOC (ntohs (frag->size));
+  smf->head->frag = GNUNET_malloc (ntohs (frag->size));
   memcpy (smf->head->frag, frag, ntohs (frag->size));
 
-  MUTEX_UNLOCK (defragCacheLock);
-  return OK;
+  GNUNET_mutex_unlock (defragCacheLock);
+  return GNUNET_OK;
 }
 
 typedef struct
 {
-  PeerIdentity sender;
+  GNUNET_PeerIdentity sender;
   /* maximums size of each fragment */
   unsigned short mtu;
   /** how long is this message part expected to be? */
   unsigned short len;
   /** when did we intend to transmit? */
-  cron_t transmissionTime;
+  GNUNET_CronTime transmissionTime;
 } FragmentBMC;
 
 /**
@@ -473,12 +475,12 @@
 
   if ((len < ctx->mtu) || (buf == NULL))
     {
-      FREE (ctx);
-      return SYSERR;
+      GNUNET_free (ctx);
+      return GNUNET_SYSERR;
     }
   if (stats != NULL)
     stats->change (stat_fragmented, 1);
-  id = (idGen++) + weak_randomi (512);
+  id = (idGen++) + GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 512);
   /* write first fragment to buf */
   frag = (P2P_fragmentation_MESSAGE *) buf;
   frag->header.size = htons (len);
@@ -490,7 +492,7 @@
 
   /* create remaining fragments, add to queue! */
   pos = len - sizeof (P2P_fragmentation_MESSAGE);
-  frag = MALLOC (ctx->mtu);
+  frag = GNUNET_malloc (ctx->mtu);
   while (pos < ctx->len)
     {
       mlen = sizeof (P2P_fragmentation_MESSAGE) + ctx->len - pos;
@@ -508,13 +510,13 @@
       coreAPI->unicast (&ctx->sender,
                         &frag->header,
                         EXTREME_PRIORITY,
-                        ctx->transmissionTime - get_time ());
+                        ctx->transmissionTime - GNUNET_get_time ());
       pos += mlen - sizeof (P2P_fragmentation_MESSAGE);
     }
   GE_ASSERT (NULL, pos == ctx->len);
-  FREE (frag);
-  FREE (ctx);
-  return OK;
+  GNUNET_free (frag);
+  GNUNET_free (ctx);
+  return GNUNET_OK;
 }
 
 /**
@@ -524,7 +526,7 @@
  * the other fragments (with very high priority).
  */
 void
-fragment (const PeerIdentity * peer,
+fragment (const GNUNET_PeerIdentity * peer,
           unsigned int mtu,
           unsigned int prio,
           unsigned int targetTime,
@@ -535,7 +537,7 @@
 
   GE_ASSERT (NULL, len > mtu);
   GE_ASSERT (NULL, mtu > sizeof (P2P_fragmentation_MESSAGE));
-  fbmc = MALLOC (sizeof (FragmentBMC) + len);
+  fbmc = GNUNET_malloc (sizeof (FragmentBMC) + len);
   fbmc->mtu = mtu;
   fbmc->sender = *peer;
   fbmc->transmissionTime = targetTime;
@@ -543,13 +545,13 @@
   if (bmc == NULL)
     {
       memcpy (&fbmc[1], bmcClosure, len);
-      FREE (bmcClosure);
+      GNUNET_free (bmcClosure);
     }
   else
     {
-      if (SYSERR == bmc (&fbmc[1], bmcClosure, len))
+      if (GNUNET_SYSERR == bmc (&fbmc[1], bmcClosure, len))
         {
-          FREE (fbmc);
+          GNUNET_free (fbmc);
           return;
         }
     }
@@ -579,14 +581,14 @@
     }
   for (i = 0; i < DEFRAG_BUCKET_COUNT; i++)
     defragmentationCache[i] = NULL;
-  defragCacheLock = MUTEX_CREATE (NO);
-  cron_add_job (coreAPI->cron,
-                &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);
+  defragCacheLock = GNUNET_mutex_create (GNUNET_NO);
+  GNUNET_cron_add_job (coreAPI->cron,
+                       &defragmentationPurgeCron,
+                       60 * GNUNET_CRON_SECONDS, 60 * GNUNET_CRON_SECONDS,
+                       NULL);
+  GE_LOG (capi->ectx, GE_INFO | GE_USER | GE_REQUEST,
+          _("`%s' registering handler %d\n"), "fragmentation",
+          P2P_PROTO_fragment);
   capi->registerHandler (P2P_PROTO_fragment, &processFragment);
 
   ret.fragment = &fragment;
@@ -602,8 +604,9 @@
   int i;
 
   coreAPI->unregisterHandler (P2P_PROTO_fragment, &processFragment);
-  cron_del_job (coreAPI->cron,
-                &defragmentationPurgeCron, 60 * cronSECONDS, NULL);
+  GNUNET_cron_del_job (coreAPI->cron,
+                       &defragmentationPurgeCron, 60 * GNUNET_CRON_SECONDS,
+                       NULL);
   for (i = 0; i < DEFRAG_BUCKET_COUNT; i++)
     {
       FC *pos = defragmentationCache[i];
@@ -611,7 +614,7 @@
         {
           FC *next = pos->next;
           freeFL (pos->head, 1);
-          FREE (pos);
+          GNUNET_free (pos);
           pos = next;
         }
     }
@@ -620,7 +623,7 @@
       coreAPI->releaseService (stats);
       stats = NULL;
     }
-  MUTEX_DESTROY (defragCacheLock);
+  GNUNET_mutex_destroy (defragCacheLock);
   defragCacheLock = NULL;
   coreAPI = NULL;
 }

Modified: GNUnet/src/applications/fragmentation/fragmentationtest.c
===================================================================
--- GNUnet/src/applications/fragmentation/fragmentationtest.c   2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/fragmentation/fragmentationtest.c   2007-11-23 
11:51:54 UTC (rev 5742)
@@ -33,12 +33,12 @@
  * - holes in sequence
  * - other overlaps
  * - timeouts
- * - multiple entries in hash-list
- * - id collisions in hash-list
+ * - multiple entries in GNUNET_hash-list
+ * - id collisions in GNUNET_hash-list
  */
 
 /* -- to speed up the testcases -- */
-#define DEFRAGMENTATION_TIMEOUT (1 * cronSECONDS)
+#define DEFRAGMENTATION_TIMEOUT (1 * GNUNET_CRON_SECONDS)
 
 #include "platform.h"
 #include "gnunet_util.h"
@@ -46,7 +46,7 @@
 
 #include "fragmentation.c"
 
-static PeerIdentity mySender;
+static GNUNET_PeerIdentity mySender;
 static char *myMsg;
 static unsigned short myMsgLen;
 
@@ -55,11 +55,12 @@
 static char resultBuffer[65536];
 
 static void
-handleHelper (const PeerIdentity * sender,
+handleHelper (const GNUNET_PeerIdentity * sender,
               const char *msg,
               const unsigned int len, int wasEncrypted, TSession * ts)
 {
-  GE_ASSERT (NULL, 0 == memcmp (sender, &mySender, sizeof (PeerIdentity)));
+  GE_ASSERT (NULL,
+             0 == memcmp (sender, &mySender, sizeof (GNUNET_PeerIdentity)));
   myMsg = resultBuffer;
   memcpy (resultBuffer, msg, len);
   myMsgLen = len;
@@ -71,7 +72,7 @@
 static void
 makeTimeout ()
 {
-  PTHREAD_SLEEP (DEFRAGMENTATION_TIMEOUT * 2);
+  GNUNET_thread_sleep (DEFRAGMENTATION_TIMEOUT * 2);
   defragmentationPurgeCron (NULL);
 }
 
@@ -85,7 +86,7 @@
  * @param length of the data portion
  * @param id the identity of the fragment
  */
-static MESSAGE_HEADER *
+static GNUNET_MessageHeader *
 makeFragment (unsigned short start,
               unsigned short size, unsigned short tot, int id)
 {
@@ -128,7 +129,7 @@
 static void
 testSimpleFragment ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
 
   pep = makeFragment (0, 16, 32, 42);
   processFragment (&mySender, pep);
@@ -141,7 +142,7 @@
 static void
 testSimpleFragmentTimeout ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
 
   pep = makeFragment (0, 16, 32, 42);
   processFragment (&mySender, pep);
@@ -158,7 +159,7 @@
 static void
 testSimpleFragmentReverse ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
 
   pep = makeFragment (16, 16, 32, 42);
   processFragment (&mySender, pep);
@@ -171,7 +172,7 @@
 static void
 testManyFragments ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
   int i;
 
   for (i = 0; i < 50; i++)
@@ -188,7 +189,7 @@
 static void
 testManyFragmentsMegaLarge ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
   int i;
 
   for (i = 0; i < 4000; i++)
@@ -205,7 +206,7 @@
 static void
 testLastFragmentEarly ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
   int i;
 
   for (i = 0; i < 5; i++)
@@ -227,7 +228,7 @@
 static void
 testManyInterleavedFragments ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
   int i;
 
   for (i = 0; i < 50; i++)
@@ -250,7 +251,7 @@
 static void
 testManyInterleavedOverlappingFragments ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
   int i;
 
   for (i = 0; i < 50; i++)
@@ -273,7 +274,7 @@
 static void
 testManyOverlappingFragments ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
   int i;
 
   for (i = 0; i < 50; i++)
@@ -290,7 +291,7 @@
 static void
 testManyOverlappingFragmentsTimeout ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
   int i;
 
   for (i = 0; i < 50; i++)
@@ -314,7 +315,7 @@
 static void
 testManyFragmentsMultiId ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
   int i;
   int id;
 
@@ -340,7 +341,7 @@
 static void
 testManyFragmentsMultiIdCollisions ()
 {
-  MESSAGE_HEADER *pep;
+  GNUNET_MessageHeader *pep;
   int i;
   int id;
 
@@ -368,13 +369,13 @@
 static int
 registerp2pHandler (const unsigned short type, MessagePartHandler callback)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
 unregisterp2pHandler (const unsigned short type, MessagePartHandler callback)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -425,6 +426,6 @@
   fprintf (stderr, ".");
   release_module_fragmentation ();
   fprintf (stderr, "\n");
-  cron_destroy (capi.cron);
+  GNUNET_cron_destroy (capi.cron);
   return 0;                     /* testcase passed */
 }

Modified: GNUnet/src/applications/fs/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/Makefile.am      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/Makefile.am      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -20,7 +20,5 @@
 ecrs_core_test_SOURCES = \
   ecrs_core_test.c 
 ecrs_core_test_LDADD = \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
   $(top_builddir)/src/applications/fs/libecrs_core.la 
 

Modified: GNUnet/src/applications/fs/collection/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/collection/Makefile.am   2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/collection/Makefile.am   2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -8,7 +8,6 @@
 libgnunetcollection_la_LIBADD = \
  $(top_builddir)/src/applications/fs/namespace/libgnunetnamespace.la \
  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 check_PROGRAMS = \
@@ -19,8 +18,6 @@
 collectiontest_SOURCES = \
   collectiontest.c 
 collectiontest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/collection/libgnunetcollection.la 
 
 EXTRA_DIST = \

Modified: GNUnet/src/applications/fs/collection/collection.c
===================================================================
--- GNUnet/src/applications/fs/collection/collection.c  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/collection/collection.c  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -49,7 +49,7 @@
 /**
  * How long does a collection advertisement live?
  */
-#define COLLECTION_ADV_LIFETIME (12 * cronMONTHS)
+#define COLLECTION_ADV_LIFETIME (12 * GNUNET_CRON_MONTHS)
 
 /**
  * @brief information about a collection
@@ -60,22 +60,22 @@
   /**
    * What is the last ID for the publication?
    */
-  HashCode512 lastId;
+  GNUNET_HashCode lastId;
 
   /**
    * What is the next ID for the publication?
    */
-  HashCode512 nextId;
+  GNUNET_HashCode nextId;
 
   /**
    * What is the update interval? (NBO!)
    */
-  TIME_T updateInterval;
+  GNUNET_Int32Time updateInterval;
 
   /**
    * What is the update interval? (NBO!)
    */
-  TIME_T lastPublication;
+  GNUNET_Int32Time lastPublication;
 
   /**
    * Anonymity level for the collection. (NBO)
@@ -124,7 +124,7 @@
 
 static CollectionInfo *collectionData;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static struct GE_Context *ectx;
 
@@ -140,12 +140,12 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &fnBase);
-  fn = MALLOC (strlen (fnBase) + strlen (COLLECTION) + 4);
+  fn = GNUNET_malloc (strlen (fnBase) + strlen (COLLECTION) + 4);
   strcpy (fn, fnBase);
-  disk_directory_create (ectx, fn);
+  GNUNET_disk_directory_create (ectx, fn);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, COLLECTION);
-  FREE (fnBase);
+  GNUNET_free (fnBase);
   return fn;
 }
 
@@ -168,17 +168,17 @@
 
   cfg = c;
   ectx = e;
-  lock = MUTEX_CREATE (YES);
+  lock = GNUNET_mutex_create (GNUNET_YES);
   fn = getCollectionFileName ();
-  if (!disk_file_test (ectx, fn))
+  if (!GNUNET_disk_file_test (ectx, fn))
     {
-      FREE (fn);
+      GNUNET_free (fn);
       return;
     }
   /* read collection data */
-  if (OK != disk_file_size (ectx, fn, &size, YES))
+  if (GNUNET_OK != GNUNET_disk_file_size (ectx, fn, &size, GNUNET_YES))
     {
-      FREE (fn);
+      GNUNET_free (fn);
       return;
     }
   if ((size > 0x7FFFFFFF) ||
@@ -186,7 +186,7 @@
     {
       GE_BREAK (ectx, 0);
       UNLINK (fn);
-      FREE (fn);
+      GNUNET_free (fn);
       return;
     }
   fd = OPEN (fn, O_RDONLY | O_LARGEFILE);
@@ -194,7 +194,7 @@
     {
       GE_BREAK (ectx, 0);
       UNLINK (fn);
-      FREE (fn);
+      GNUNET_free (fn);
       return;
     }
   rsize = (size_t) size;
@@ -205,10 +205,10 @@
                             GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                             "mmap", fn);
       CLOSE (fd);
-      FREE (fn);
+      GNUNET_free (fn);
       return;
     }
-  collectionData = MALLOC (sizeof (CollectionInfo));
+  collectionData = GNUNET_malloc (sizeof (CollectionInfo));
   memcpy (&collectionData->data, buf, sizeof (CollectionData));
   pos = &buf[sizeof (CollectionData)];
   rsize -= sizeof (CollectionData);
@@ -218,7 +218,7 @@
       GE_BREAK (ectx, 0);
       len = 1024 * 1024 * 4;
     }
-  GROW (collectionData->files, collectionData->file_count, len);
+  GNUNET_array_grow (collectionData->files, collectionData->file_count, len);
   pos += sizeof (int);
   collectionData->changed = ntohl (*(int *) pos);
   pos += sizeof (int);
@@ -230,7 +230,7 @@
       GE_BREAK (ectx, 0);
       len = 1024;
     }
-  collectionData->name = MALLOC (len + 1);
+  collectionData->name = GNUNET_malloc (len + 1);
   pos += sizeof (int);
   rsize -= 4 * sizeof (int);
   if (len > rsize)
@@ -272,14 +272,14 @@
           GE_BREAK (ectx, 0);
           len = 1024 * 16;
         }
-      tmp = MALLOC (len + 1);
+      tmp = GNUNET_malloc (len + 1);
       tmp[len] = '\0';
       memcpy (tmp, pos, len);
       pos += len;
       rsize -= len;
       collectionData->files[i].uri = ECRS_stringToUri (ectx, tmp);
       GE_ASSERT (ectx, collectionData->files[i].uri != NULL);
-      FREE (tmp);
+      GNUNET_free (tmp);
       collectionData->files[i].meta
         = ECRS_deserializeMetaData (ectx, pos, mlen);
       GE_ASSERT (ectx, collectionData->files[i].meta != NULL);
@@ -289,7 +289,7 @@
   GE_ASSERT (ectx, rsize == 0);
   MUNMAP (buf, (size_t) size);
   CLOSE (fd);
-  FREE (fn);
+  GNUNET_free (fn);
   /* kill invalid entries (meta or uri == NULL) */
   for (i = 0; i < collectionData->file_count; i++)
     {
@@ -302,8 +302,9 @@
         ECRS_freeMetaData (collectionData->files[i].meta);
       collectionData->files[i]
         = collectionData->files[collectionData->file_count - 1];
-      GROW (collectionData->files,
-            collectionData->file_count, collectionData->file_count - 1);
+      GNUNET_array_grow (collectionData->files,
+                         collectionData->file_count,
+                         collectionData->file_count - 1);
     }
 }
 
@@ -330,13 +331,14 @@
     return;
 
   /* write collection data */
-  mlen = ECRS_sizeofMetaData (collectionData->meta, NO);
-  buf = MALLOC (mlen);
+  mlen = ECRS_sizeofMetaData (collectionData->meta, GNUNET_NO);
+  buf = GNUNET_malloc (mlen);
   if (mlen != ECRS_serializeMetaData (ectx,
-                                      collectionData->meta, buf, mlen, NO))
+                                      collectionData->meta, buf, mlen,
+                                      GNUNET_NO))
     {
       GE_BREAK (ectx, 0);
-      FREE (buf);
+      GNUNET_free (buf);
       return;
     }
 
@@ -348,8 +350,8 @@
       GE_LOG_STRERROR_FILE (ectx,
                             GE_USER | GE_ADMIN | GE_ERROR | GE_BULK,
                             "open", fn);
-      FREE (fn);
-      FREE (buf);
+      GNUNET_free (fn);
+      GNUNET_free (buf);
       return;
     }
   GE_BREAK (ectx, collectionData->file_count <= 1024 * 1024 * 4);
@@ -361,17 +363,17 @@
   WRITEINT (fd, strlen (collectionData->name));
   WRITE (fd, collectionData->name, strlen (collectionData->name));
   WRITE (fd, buf, mlen);
-  FREE (buf);
+  GNUNET_free (buf);
   for (i = 0; i < collectionData->file_count; i++)
     {
-      mlen = ECRS_sizeofMetaData (collectionData->files[i].meta, NO);
-      buf = MALLOC (mlen);
+      mlen = ECRS_sizeofMetaData (collectionData->files[i].meta, GNUNET_NO);
+      buf = GNUNET_malloc (mlen);
       if (mlen != ECRS_serializeMetaData (ectx,
                                           collectionData->files[i].meta,
-                                          buf, mlen, NO))
+                                          buf, mlen, GNUNET_NO))
         {
           GE_BREAK (ectx, 0);
-          FREE (buf);
+          GNUNET_free (buf);
           break;
         }
       tmp = ECRS_uriToString (collectionData->files[i].uri);
@@ -379,12 +381,12 @@
       WRITEINT (fd, mlen);
       GE_BREAK (ectx, strlen (tmp) < 16 * 1024);
       WRITE (fd, tmp, strlen (tmp));
-      FREE (tmp);
+      GNUNET_free (tmp);
       WRITE (fd, buf, mlen);
-      FREE (buf);
+      GNUNET_free (buf);
     }
   CLOSE (fd);
-  FREE (fn);
+  GNUNET_free (fn);
 }
 
 /**
@@ -395,7 +397,7 @@
 {
   writeCO ();
   CO_stopCollection ();
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
   ectx = NULL;
   cfg = NULL;
@@ -414,65 +416,66 @@
 int
 CO_startCollection (unsigned int anonymityLevel,
                     unsigned int prio,
-                    TIME_T updateInterval,
+                    GNUNET_Int32Time updateInterval,
                     const char *name, const struct ECRS_MetaData *meta)
 {
   struct ECRS_URI *advertisement;
   struct ECRS_URI *rootURI;
-  HashCode512 nextId;
-  TIME_T now;
+  GNUNET_HashCode nextId;
+  GNUNET_Int32Time now;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   CO_stopCollection ();         /* cancel old collection */
   GE_ASSERT (ectx, name != NULL);
   advertisement = ECRS_parseCharKeywordURI (ectx, COLLECTION);
   GE_ASSERT (ectx, advertisement != NULL);
-  TIME (&now);
-  makeRandomId (&nextId);
+  GNUNET_get_time_int32 (&now);
+  GNUNET_create_random_hash (&nextId);
   rootURI = ECRS_createNamespace (ectx,
                                   cfg,
                                   name,
                                   meta,
                                   anonymityLevel,
                                   prio,
-                                  get_time () + COLLECTION_ADV_LIFETIME,
-                                  advertisement, &nextId);
+                                  GNUNET_get_time () +
+                                  COLLECTION_ADV_LIFETIME, advertisement,
+                                  &nextId);
   if (rootURI == NULL)
     {
       ECRS_freeUri (advertisement);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   ECRS_freeUri (advertisement);
   ECRS_freeUri (rootURI);
-  collectionData = MALLOC (sizeof (CollectionInfo));
+  collectionData = GNUNET_malloc (sizeof (CollectionInfo));
   memset (collectionData, 0, sizeof (CollectionInfo));
-  makeRandomId (&collectionData->data.lastId);
+  GNUNET_create_random_hash (&collectionData->data.lastId);
   collectionData->data.nextId = nextId;
   collectionData->data.updateInterval = htonl (updateInterval);
   collectionData->data.anonymityLevel = htonl (anonymityLevel);
   collectionData->data.priority = htonl (prio);
   collectionData->meta = ECRS_dupMetaData (meta);
-  collectionData->name = STRDUP (name);
-  MUTEX_UNLOCK (lock);
-  return OK;
+  collectionData->name = GNUNET_strdup (name);
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
  * Stop collection.
  *
- * @return OK on success, SYSERR if no collection is active
+ * @return GNUNET_OK on success, GNUNET_SYSERR if no collection is active
  */
 int
 CO_stopCollection ()
 {
   unsigned int i;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if (collectionData == NULL)
     {
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   ECRS_deleteNamespace (ectx, cfg, collectionData->name);
   ECRS_freeMetaData (collectionData->meta);
@@ -481,12 +484,12 @@
       ECRS_freeMetaData (collectionData->files[i].meta);
       ECRS_freeUri (collectionData->files[i].uri);
     }
-  GROW (collectionData->files, collectionData->file_count, 0);
-  FREE (collectionData->name);
-  FREE (collectionData);
+  GNUNET_array_grow (collectionData->files, collectionData->file_count, 0);
+  GNUNET_free (collectionData->name);
+  GNUNET_free (collectionData);
   collectionData = NULL;
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -499,19 +502,19 @@
 {
   char *name;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if (collectionData == NULL)
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return NULL;
     }
-  name = STRDUP (collectionData->name);
-  MUTEX_UNLOCK (lock);
+  name = GNUNET_strdup (collectionData->name);
+  GNUNET_mutex_unlock (lock);
   return name;
 }
 
 /**
- * Upload an update of the current collection information to the
+ * GNUNET_ND_UPLOAD an update of the current collection information to the
  * network now.  The function has no effect if the collection has not
  * changed since the last publication.  If we are currently not
  * collecting, this function does nothing.
@@ -530,8 +533,8 @@
 void
 CO_publishCollectionNow ()
 {
-  HashCode512 delta;
-  TIME_T now;
+  GNUNET_HashCode delta;
+  GNUNET_Int32Time now;
   struct ECRS_URI *uri;
   struct ECRS_URI *directoryURI;
   unsigned long long dirLen;
@@ -539,83 +542,85 @@
   int fd;
   char *dirData;
 
-  MUTEX_LOCK (lock);
-  if ((collectionData == NULL) || (collectionData->changed == NO))
+  GNUNET_mutex_lock (lock);
+  if ((collectionData == NULL) || (collectionData->changed == GNUNET_NO))
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return;
     }
-  TIME (&now);
+  GNUNET_get_time_int32 (&now);
   if ((ntohl (collectionData->data.updateInterval) != ECRS_SBLOCK_UPDATE_NONE)
       && (ntohl (collectionData->data.updateInterval) !=
           ECRS_SBLOCK_UPDATE_SPORADIC)
       && (ntohl (collectionData->data.lastPublication) +
           ntohl (collectionData->data.updateInterval) < now))
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return;
     }
   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);
+      GNUNET_hash_difference (&collectionData->data.nextId,
+                              &collectionData->data.lastId, &delta);
       collectionData->data.lastId = collectionData->data.nextId;
-      addHashCodes (&collectionData->data.nextId,
-                    &delta, &collectionData->data.nextId);
+      GNUNET_hash_sum (&collectionData->data.nextId,
+                       &delta, &collectionData->data.nextId);
     }
   else
     {
       collectionData->data.lastId = collectionData->data.nextId;
-      makeRandomId (&collectionData->data.nextId);
+      GNUNET_create_random_hash (&collectionData->data.nextId);
     }
-  tmpName = STRDUP ("/tmp/gnunet-collectionXXXXXX");
+  tmpName = GNUNET_strdup ("/tmp/gnunet-collectionXXXXXX");
   fd = mkstemp (tmpName);
   if (fd == -1)
     {
       GE_LOG_STRERROR (ectx, GE_ERROR | GE_ADMIN | GE_BULK, "mkstemp");
-      FREE (tmpName);
-      MUTEX_UNLOCK (lock);
+      GNUNET_free (tmpName);
+      GNUNET_mutex_unlock (lock);
       return;
     }
   dirData = NULL;
   GE_ASSERT (ectx,
-             OK == ECRS_createDirectory (ectx,
-                                         &dirData,
-                                         &dirLen,
-                                         collectionData->file_count,
-                                         collectionData->files,
-                                         collectionData->meta));
+             GNUNET_OK == ECRS_createDirectory (ectx,
+                                                &dirData,
+                                                &dirLen,
+                                                collectionData->file_count,
+                                                collectionData->files,
+                                                collectionData->meta));
   if (-1 == WRITE (fd, dirData, dirLen))
     {
       GE_LOG_STRERROR (ectx, GE_ERROR | GE_ADMIN | GE_BULK, "write");
-      FREE (tmpName);
-      FREE (dirData);
-      MUTEX_UNLOCK (lock);
+      GNUNET_free (tmpName);
+      GNUNET_free (dirData);
+      GNUNET_mutex_unlock (lock);
       return;
     }
-  FREE (dirData);
+  GNUNET_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))
+  if (GNUNET_OK != ECRS_uploadFile (ectx, cfg, tmpName, GNUNET_NO,      /* 
indexing */
+                                    ntohl (collectionData->data.
+                                           anonymityLevel),
+                                    ntohl (collectionData->data.priority),
+                                    GNUNET_get_time () +
+                                    COLLECTION_ADV_LIFETIME, NULL, NULL, NULL,
+                                    NULL, &directoryURI))
     {
       UNLINK (tmpName);
-      FREE (tmpName);
-      MUTEX_UNLOCK (lock);
+      GNUNET_free (tmpName);
+      GNUNET_mutex_unlock (lock);
       return;
     }
   UNLINK (tmpName);
-  FREE (tmpName);
+  GNUNET_free (tmpName);
   uri = ECRS_addToNamespace (ectx,
                              cfg,
                              collectionData->name,
                              ntohl (collectionData->data.anonymityLevel),
                              ntohl (collectionData->data.priority),
-                             get_time () + COLLECTION_ADV_LIFETIME,
+                             GNUNET_get_time () + COLLECTION_ADV_LIFETIME,
                              now,
                              ntohl (collectionData->data.updateInterval),
                              &collectionData->data.lastId,
@@ -624,10 +629,10 @@
   if (uri != NULL)
     {
       collectionData->data.lastPublication = htonl (now);
-      collectionData->changed = NO;
+      collectionData->changed = GNUNET_NO;
       ECRS_freeUri (uri);
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 /**
@@ -659,27 +664,27 @@
       GE_BREAK (ectx, 0);
       return;
     }
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if (collectionData == NULL)
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return;
     }
   for (i = 0; i < collectionData->file_count; i++)
     {
       if (ECRS_equalsUri (fi->uri, collectionData->files[i].uri))
         {
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           return;
         }
     }
   fc.uri = ECRS_dupUri (fi->uri);
   fc.meta = ECRS_dupMetaData (fi->meta);
-  APPEND (collectionData->files, collectionData->file_count, fc);
-  collectionData->changed = YES;
+  GNUNET_array_append (collectionData->files, collectionData->file_count, fc);
+  collectionData->changed = GNUNET_YES;
   if (ntohl (collectionData->data.updateInterval) == ECRS_SBLOCK_UPDATE_NONE)
     CO_publishCollectionNow ();
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 /* end of collection.c */

Modified: GNUnet/src/applications/fs/collection/collectiontest.c
===================================================================
--- GNUnet/src/applications/fs/collection/collectiontest.c      2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/fs/collection/collectiontest.c      2007-11-23 
11:51:54 UTC (rev 5742)
@@ -30,7 +30,7 @@
 #include "gnunet_util_config_impl.h"
 #include "gnunet_util_network_client.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
 #define START_DAEMON 1
 
@@ -42,12 +42,12 @@
   pid_t daemon;
 #endif
   int ok;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   struct ECRS_MetaData *meta;
   ECRS_FileInfo fi;
   char *have;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
@@ -56,15 +56,17 @@
   sock = NULL;
   meta = NULL;
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 300 * cronSECONDS));
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         300 * GNUNET_CRON_SECONDS));
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
 #endif
-  ok = YES;
+  ok = GNUNET_YES;
   meta = ECRS_createMetaData ();
   ECRS_addToMetaData (meta, EXTRACTOR_MIMETYPE, "test/foo");
-  sock = client_connection_create (NULL, cfg);
+  sock = GNUNET_client_connection_create (NULL, cfg);
   CHECK (sock != NULL);
   CO_init (NULL, cfg);
 
@@ -72,12 +74,12 @@
   CO_stopCollection ();
   ECRS_deleteNamespace (NULL, cfg, "test-collection");
   CHECK (NULL == CO_getCollection ());
-  CHECK (OK == CO_startCollection (1, 100, 60,  /* 60s */
-                                   "test-collection", meta));
+  CHECK (GNUNET_OK == CO_startCollection (1, 100, 60,   /* 60s */
+                                          "test-collection", meta));
   have = CO_getCollection ();
   CHECK (NULL != have);
   CHECK (0 == strcmp (have, "test-collection"));
-  FREE (have);
+  GNUNET_free (have);
   fi.meta = meta;
   fi.uri =
     ECRS_stringToUri (NULL,
@@ -89,7 +91,7 @@
   have = CO_getCollection ();
   CHECK (NULL != have);
   CHECK (0 == strcmp (have, "test-collection"));
-  FREE (have);
+  GNUNET_free (have);
   CO_publishCollectionNow ();
   CO_stopCollection ();
   ECRS_deleteNamespace (NULL, cfg, "test-collection");
@@ -100,15 +102,15 @@
   if (sock != NULL)
     {
       CO_done ();
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
     }
   if (meta != NULL)
     ECRS_freeMetaData (meta);
 #if START_DAEMON
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of collectiontest.c */

Modified: GNUnet/src/applications/fs/ecrs/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/ecrs/Makefile.am 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/Makefile.am 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -25,8 +25,6 @@
  $(top_builddir)/src/applications/fs/libecrs_core.la \
  $(top_builddir)/src/applications/fs/lib/libgnunetfs.la \
  $(top_builddir)/src/applications/getoption/libgnunetgetoption_api.la \
- $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 
@@ -51,14 +49,11 @@
 uritest_SOURCES = \
   uritest.c 
 uritest_LDADD = \
-  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la 
+  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 namespacetest_SOURCES = \
   namespacetest.c 
 namespacetest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 metatest_SOURCES = \
@@ -75,29 +70,21 @@
 ecrstest_SOURCES = \
   ecrstest.c
 ecrstest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 downloadtest_SOURCES = \
   downloadtest.c
 downloadtest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 searchtest_SOURCES = \
   searchtest.c
 searchtest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 directorytest_SOURCES = \
   directorytest.c
 directorytest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la 
 
 EXTRA_DIST = \

Modified: GNUnet/src/applications/fs/ecrs/bincoder.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/bincoder.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/bincoder.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -66,7 +66,7 @@
   len = size * 8 / 6;
   if (((size * 8) % 6) != 0)
     len++;
-  ret = MALLOC (len + 1);
+  ret = GNUNET_malloc (len + 1);
   ret[len] = '\0';
   len = 0;
   bits = 0;

Modified: GNUnet/src/applications/fs/ecrs/bincodertest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/bincodertest.c      2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/ecrs/bincodertest.c      2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -37,7 +37,7 @@
   char dec[256];
   int ret;
 
-  orig = MALLOC (i);
+  orig = GNUNET_malloc (i);
   memset (orig, i, i);
   enc = bin2enc (orig, i);
   ret = enc2bin (enc, dec, i);
@@ -46,8 +46,8 @@
       printf ("Failed in iteration %d\n", i);
       ret = -1;
     }
-  FREE (enc);
-  FREE (orig);
+  GNUNET_free (enc);
+  GNUNET_free (orig);
   return ret != -1 ? 0 : 1;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/directory.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directory.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/directory.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -40,13 +40,13 @@
  *
  * Note that this function maybe called on parts of directories.
  * Thus parser errors should not be reported _at all_ (with BREAK).
- * Of course, returning SYSERR maybe appropriate.  Still, if some
+ * Of course, returning GNUNET_SYSERR maybe appropriate.  Still, if some
  * entries can be recovered despite these parsing errors, the
  * function should try to do this.
  *
  * @param data pointer to the beginning of the directory
  * @param len number of bytes in data
- * @return number of entries on success, SYSERR if the
+ * @return number of entries on success, GNUNET_SYSERR if the
  *         directory is malformed
  */
 int
@@ -72,14 +72,14 @@
       memcpy (&mdSize, &data[8], sizeof (unsigned int));
       mdSize = ntohl (mdSize);
       if (mdSize > len - 8 - sizeof (unsigned int))
-        return SYSERR;          /* invalid size */
+        return GNUNET_SYSERR;   /* invalid size */
       *md = ECRS_deserializeMetaData (ectx,
                                       &data[8 + sizeof (unsigned int)],
                                       mdSize);
       if (*md == NULL)
         {
           GE_BREAK (ectx, 0);
-          return SYSERR;        /* malformed ! */
+          return GNUNET_SYSERR; /* malformed ! */
         }
       pos = 8 + sizeof (unsigned int) + mdSize;
     }
@@ -107,7 +107,7 @@
       while ((epos < len) && (data[epos] != '\0'))
         epos++;
       if (epos >= len)
-        return SYSERR;          /* malformed - or partial download */
+        return GNUNET_SYSERR;   /* malformed - or partial download */
 
       fi.uri = ECRS_stringToUri (ectx, &data[pos]);
       pos = epos + 1;
@@ -120,7 +120,7 @@
         {
           ECRS_freeUri (fi.uri);
           GE_BREAK (ectx, 0);
-          return SYSERR;        /* illegal in directory! */
+          return GNUNET_SYSERR; /* illegal in directory! */
         }
 
       memcpy (&mdSize, &data[pos], sizeof (unsigned int));
@@ -130,7 +130,7 @@
       if (pos + mdSize > len)
         {
           ECRS_freeUri (fi.uri);
-          return SYSERR;        /* malformed - or partial download */
+          return GNUNET_SYSERR; /* malformed - or partial download */
         }
 
       fi.meta = ECRS_deserializeMetaData (ectx, &data[pos], mdSize);
@@ -138,12 +138,12 @@
         {
           ECRS_freeUri (fi.uri);
           GE_BREAK (ectx, 0);
-          return SYSERR;        /* malformed ! */
+          return GNUNET_SYSERR; /* malformed ! */
         }
       pos += mdSize;
       count++;
       if (spcb != NULL)
-        spcb (&fi, NULL, NO, spcbClosure);
+        spcb (&fi, NULL, GNUNET_NO, spcbClosure);
       ECRS_freeMetaData (fi.meta);
       ECRS_freeUri (fi.uri);
     }
@@ -256,7 +256,7 @@
  *        respective values at same offset in in uris)
  * @param meta meta-data for the directory.  The meta entry
  *        is extended with the mime-type for a GNUnet directory.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
 ECRS_createDirectory (struct GE_Context *ectx,
@@ -280,14 +280,14 @@
       if (ECRS_isKeywordUri (fis[i].uri))
         {
           GE_BREAK (ectx, 0);
-          return SYSERR;        /* illegal in directory! */
+          return GNUNET_SYSERR; /* illegal in directory! */
         }
     }
-  ucs = MALLOC (sizeof (char *) * count);
+  ucs = GNUNET_malloc (sizeof (char *) * count);
   size = 8 + sizeof (unsigned int);
   size += ECRS_sizeofMetaData (meta, ECRS_SERIALIZE_FULL);
-  sizes = MALLOC (count * sizeof (unsigned long long));
-  perm = MALLOC (count * sizeof (int));
+  sizes = GNUNET_malloc (count * sizeof (unsigned long long));
+  perm = GNUNET_malloc (count * sizeof (int));
   for (i = 0; i < count; i++)
     {
       perm[i] = i;
@@ -297,12 +297,12 @@
       if (psize == -1)
         {
           GE_BREAK (ectx, 0);
-          FREE (sizes);
-          FREE (perm);
+          GNUNET_free (sizes);
+          GNUNET_free (perm);
           while (i >= 0)
-            FREE (ucs[i--]);
-          FREE (ucs);
-          return SYSERR;
+            GNUNET_free (ucs[i--]);
+          GNUNET_free (ucs);
+          return GNUNET_SYSERR;
         }
       sizes[i] = psize + sizeof (unsigned int) + strlen (ucs[i]) + 1;
     }
@@ -317,7 +317,7 @@
       size = do_align (psize, size);
     }
   *len = size;
-  *data = MALLOC (size);
+  *data = GNUNET_malloc (size);
   memset (*data, 0, size);
 
   pos = 8;
@@ -328,7 +328,7 @@
                                 &(*data)[pos + sizeof (unsigned int)],
                                 size - pos - sizeof (unsigned int),
                                 ECRS_SERIALIZE_FULL);
-  GE_ASSERT (ectx, ret != SYSERR);
+  GE_ASSERT (ectx, ret != GNUNET_SYSERR);
   ret = htonl (ret);
   memcpy (&(*data)[pos], &ret, sizeof (unsigned int));
   pos += ntohl (ret) + sizeof (unsigned int);
@@ -342,23 +342,23 @@
       pos -= sizes[i];          /* go back to beginning */
       memcpy (&(*data)[pos], ucs[i], strlen (ucs[i]) + 1);
       pos += strlen (ucs[i]) + 1;
-      FREE (ucs[i]);
+      GNUNET_free (ucs[i]);
       ret = ECRS_serializeMetaData (ectx,
                                     fis[i].meta,
                                     &(*data)[pos + sizeof (unsigned int)],
                                     size - pos - sizeof (unsigned int),
                                     ECRS_SERIALIZE_FULL);
-      GE_ASSERT (ectx, ret != SYSERR);
+      GE_ASSERT (ectx, ret != GNUNET_SYSERR);
       ret = htonl (ret);
       memcpy (&(*data)[pos], &ret, sizeof (unsigned int));
       pos += ntohl (ret) + sizeof (unsigned int);
     }
-  FREE (sizes);
-  FREE (perm);
-  FREE (ucs);
+  GNUNET_free (sizes);
+  GNUNET_free (perm);
+  GNUNET_free (ucs);
   GE_ASSERT (ectx, pos == size);
 
-  return OK;
+  return GNUNET_OK;
 }
 
 /* end of directory.c */

Modified: GNUnet/src/applications/fs/ecrs/directorytest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directorytest.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/ecrs/directorytest.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -41,7 +41,7 @@
 
 static int
 processor (const ECRS_FileInfo * fi,
-           const HashCode512 * key, int isRoot, void *cls)
+           const GNUNET_HashCode * key, int isRoot, void *cls)
 {
   struct PCLS *p = cls;
   int i;
@@ -53,11 +53,11 @@
           ECRS_equalsUri (p->fi[i].uri, fi->uri))
         {
           p->pos++;
-          return OK;
+          return GNUNET_OK;
         }
     }
   fprintf (stderr, "Error at %s:%d\n", __FILE__, __LINE__);
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 static int
@@ -76,21 +76,21 @@
   int ret = 0;
 
   cls.max = i;
-  fis = MALLOC (sizeof (ECRS_FileInfo) * i);
+  fis = GNUNET_malloc (sizeof (ECRS_FileInfo) * i);
   for (p = 0; p < i; p++)
     {
       fis[p].meta = ECRS_createMetaData ();
       for (q = 0; q <= p; q++)
         {
-          SNPRINTF (txt, 128, "%u -- %u\n", p, q);
+          GNUNET_snprintf (txt, 128, "%u -- %u\n", p, q);
           ECRS_addToMetaData (fis[p].meta,
                               q % EXTRACTOR_getHighestKeywordTypeNumber (),
                               txt);
         }
-      SNPRINTF (uri,
-                512,
-                
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
-                p);
+      GNUNET_snprintf (uri,
+                       512,
+                       
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
+                       p);
       fis[p].uri = ECRS_stringToUri (NULL, uri);
       if (fis[p].uri == NULL)
         {
@@ -100,14 +100,14 @@
               ECRS_freeMetaData (fis[p].meta);
               ECRS_freeUri (fis[p].uri);
             }
-          FREE (fis);
+          GNUNET_free (fis);
           ABORT ();             /* error in testcase */
         }
     }
   meta = ECRS_createMetaData ();
   ECRS_addToMetaData (meta, EXTRACTOR_TITLE, "A title");
   ECRS_addToMetaData (meta, EXTRACTOR_AUTHOR, "An author");
-  if (OK != ECRS_createDirectory (NULL, &data, &dlen, i, fis, meta))
+  if (GNUNET_OK != ECRS_createDirectory (NULL, &data, &dlen, i, fis, meta))
     {
       ECRS_freeMetaData (meta);
       for (p = 0; p < i; p++)
@@ -115,7 +115,7 @@
           ECRS_freeMetaData (fis[p].meta);
           ECRS_freeUri (fis[p].uri);
         }
-      FREE (fis);
+      GNUNET_free (fis);
       ABORT ();
     }
   cls.pos = 0;
@@ -132,7 +132,7 @@
       goto END;
     }
 END:
-  FREE (data);
+  GNUNET_free (data);
   ECRS_freeMetaData (meta);
   ECRS_freeMetaData (meta2);
   for (p = 0; p < i; p++)
@@ -140,7 +140,7 @@
       ECRS_freeMetaData (fis[p].meta);
       ECRS_freeUri (fis[p].uri);
     }
-  FREE (fis);
+  GNUNET_free (fis);
   return ret;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/download.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -19,7 +19,7 @@
 */
 /**
  * @file applications/fs/ecrs/download.c
- * @brief Download helper methods (which do the real work).
+ * @brief GNUNET_ND_DOWNLOAD helper methods (which do the real work).
  * @author Christian Grothoff
  */
 
@@ -32,7 +32,7 @@
 #include "ecrs.h"
 #include "tree.h"
 
-#define DEBUG_DOWNLOAD NO
+#define DEBUG_DOWNLOAD GNUNET_NO
 
 /**
  * Highest TTL allowed? (equivalent of 25-50 HOPS distance!)
@@ -72,7 +72,7 @@
   /**
    * A lock for synchronizing access.
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   /**
    * The file handles for each level in the tree.
@@ -98,8 +98,8 @@
  * itself.
  *
  * @param this reference to the IOContext
- * @param unlinkTreeFiles if YES, the non-level 0 files
- *     are unlinked (removed), set to NO if the download
+ * @param unlinkTreeFiles if GNUNET_YES, the non-level 0 files
+ *     are unlinked (removed), set to GNUNET_NO if the download
  *     is not complete and may be resumed later.
  */
 static void
@@ -116,12 +116,12 @@
           this->handles[i] = -1;
         }
     }
-  MUTEX_DESTROY (this->lock);
-  if (YES == unlinkTreeFiles)
+  GNUNET_mutex_destroy (this->lock);
+  if (GNUNET_YES == unlinkTreeFiles)
     {
       for (i = 1; i <= this->treedepth; i++)
         {
-          fn = MALLOC (strlen (this->filename) + 3);
+          fn = GNUNET_malloc (strlen (this->filename) + 3);
           strcpy (fn, this->filename);
           strcat (fn, ".A");
           fn[strlen (fn) - 1] += i;
@@ -130,11 +130,11 @@
                     GE_WARNING | GE_BULK | GE_USER,
                     _("Could not unlink temporary file `%s': %s\n"),
                     fn, STRERROR (errno));
-          FREE (fn);
+          GNUNET_free (fn);
         }
     }
-  FREE (this->filename);
-  FREE (this->handles);
+  GNUNET_free (this->filename);
+  GNUNET_free (this->handles);
 }
 
 /**
@@ -144,7 +144,7 @@
  * @param no_temporaries disallow creation of temp files
  * @param filesize the size of the file
  * @param filename the name of the level-0 file
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 static int
 createIOContext (struct GE_Context *ectx,
@@ -159,9 +159,9 @@
   this->ectx = ectx;
   GE_ASSERT (ectx, filename != NULL);
   this->treedepth = computeDepth (filesize);
-  this->lock = MUTEX_CREATE (NO);
-  this->handles = MALLOC (sizeof (int) * (this->treedepth + 1));
-  this->filename = STRDUP (filename);
+  this->lock = GNUNET_mutex_create (GNUNET_NO);
+  this->handles = GNUNET_malloc (sizeof (int) * (this->treedepth + 1));
+  this->filename = GNUNET_strdup (filename);
 
   if ((0 == STAT (filename, &st)) && ((size_t) st.st_size > filesize))
     {
@@ -171,7 +171,7 @@
           GE_LOG_STRERROR_FILE (ectx,
                                 GE_ERROR | GE_ADMIN | GE_BULK,
                                 "truncate", filename);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
   for (i = 0; i <= this->treedepth; i++)
@@ -179,29 +179,29 @@
 
   for (i = 0; i <= this->treedepth; i++)
     {
-      if ((i == 0) || (no_temporaries != YES))
+      if ((i == 0) || (no_temporaries != GNUNET_YES))
         {
-          fn = MALLOC (strlen (filename) + 3);
+          fn = GNUNET_malloc (strlen (filename) + 3);
           strcpy (fn, filename);
           if (i > 0)
             {
               strcat (fn, ".A");
               fn[strlen (fn) - 1] += i;
             }
-          this->handles[i] = disk_file_open (ectx,
-                                             fn,
-                                             O_CREAT | O_RDWR,
-                                             S_IRUSR | S_IWUSR);
+          this->handles[i] = GNUNET_disk_file_open (ectx,
+                                                    fn,
+                                                    O_CREAT | O_RDWR,
+                                                    S_IRUSR | S_IWUSR);
           if (this->handles[i] < 0)
             {
-              freeIOC (this, YES);
-              FREE (fn);
-              return SYSERR;
+              freeIOC (this, GNUNET_YES);
+              GNUNET_free (fn);
+              return GNUNET_SYSERR;
             }
-          FREE (fn);
+          GNUNET_free (fn);
         }
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -212,7 +212,7 @@
  * @param pos position where to read or write
  * @param buf where to read from or write to
  * @param len how many bytes to read or write
- * @return number of bytes read, SYSERR on error
+ * @return number of bytes read, GNUNET_SYSERR on error
  */
 int
 readFromIOC (IOContext * this,
@@ -221,15 +221,15 @@
 {
   int ret;
 
-  MUTEX_LOCK (this->lock);
+  GNUNET_mutex_lock (this->lock);
   if (this->handles[level] == -1)
     {
-      MUTEX_UNLOCK (this->lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (this->lock);
+      return GNUNET_SYSERR;
     }
   LSEEK (this->handles[level], pos, SEEK_SET);
   ret = READ (this->handles[level], buf, len);
-  MUTEX_UNLOCK (this->lock);
+  GNUNET_mutex_unlock (this->lock);
 #if DEBUG_DOWNLOAD
   GE_LOG (this->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -247,7 +247,7 @@
  * @param pos position where to  write
  * @param buf where to write to
  * @param len how many bytes to write
- * @return number of bytes written, SYSERR on error
+ * @return number of bytes written, GNUNET_SYSERR on error
  */
 int
 writeToIOC (IOContext * this,
@@ -256,10 +256,10 @@
 {
   int ret;
 
-  MUTEX_LOCK (this->lock);
+  GNUNET_mutex_lock (this->lock);
   if ((this->handles[level] == -1) && (level > 0))
     {
-      MUTEX_UNLOCK (this->lock);
+      GNUNET_mutex_unlock (this->lock);
       return len;               /* lie -- no temps allowed... */
     }
   LSEEK (this->handles[level], pos, SEEK_SET);
@@ -271,7 +271,7 @@
               _("Write(%d, %p, %d) failed: %s\n"),
               this->handles[level], buf, len, STRERROR (errno));
     }
-  MUTEX_UNLOCK (this->lock);
+  GNUNET_mutex_unlock (this->lock);
 #if DEBUG_DOWNLOAD
   GE_LOG (this->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -341,14 +341,14 @@
   /**
    * Last time the query was send.
    */
-  cron_t lasttime;
+  GNUNET_CronTime lasttime;
 
   /**
    * Timeout used for the last search (ttl in request is
    * = lastTimeout - lasttime modulo corrections in gap
    * with respect to priority cap).
    */
-  cron_t lastTimeout;
+  GNUNET_CronTime lastTimeout;
 
   /**
    * How long have we been actively trying this one?
@@ -376,7 +376,7 @@
   /**
    * Mutex for synchronizing access to this struct
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   /**
    * Current list of all pending requests
@@ -385,13 +385,13 @@
 
   struct FS_SEARCH_CONTEXT *sctx;
 
-  struct PTHREAD *requestThread;
+  struct GNUNET_ThreadHandle *requestThread;
 
   struct GE_Context *ectx;
 
   struct GC_Configuration *cfg;
 
-  PeerIdentity target;
+  GNUNET_PeerIdentity target;
 
   /**
    * Number of pending requests (highest used index)
@@ -422,7 +422,7 @@
   /**
    * What was the last time we updated ssthresh?
    */
-  TIME_T lastDET;
+  GNUNET_Int32Time lastDET;
 
   /**
    * Abort?  Flag that can be set at any time
@@ -456,27 +456,27 @@
 {
   RequestManager *rm;
 
-  rm = MALLOC (sizeof (RequestManager));
-  rm->shutdown = NO;
-  rm->lock = MUTEX_CREATE (YES);
+  rm = GNUNET_malloc (sizeof (RequestManager));
+  rm->shutdown = GNUNET_NO;
+  rm->lock = GNUNET_mutex_create (GNUNET_YES);
   rm->sctx = FS_SEARCH_makeContext (ectx, cfg, rm->lock);
   if (rm->sctx == NULL)
     {
-      MUTEX_DESTROY (rm->lock);
-      FREE (rm);
+      GNUNET_mutex_destroy (rm->lock);
+      GNUNET_free (rm);
       return NULL;
     }
   rm->ectx = ectx;
   rm->cfg = cfg;
-  rm->requestThread = PTHREAD_GET_SELF ();
-  rm->abortFlag = NO;
+  rm->requestThread = GNUNET_thread_get_self ();
+  rm->abortFlag = GNUNET_NO;
   rm->lastDET = 0;
   rm->requestListIndex = 0;
   rm->requestListSize = 0;
   rm->requestList = NULL;
-  rm->have_target = NO;
-  GROW (rm->requestList, rm->requestListSize, 256);
-  rm->initialTTL = 5 * cronSECONDS;
+  rm->have_target = GNUNET_NO;
+  GNUNET_array_grow (rm->requestList, rm->requestListSize, 256);
+  rm->initialTTL = 5 * GNUNET_CRON_SECONDS;
   /* RFC 2001 suggests to use 1 segment size initially;
      Given 1500 octets per message in GNUnet, we would
      have 2-3 queries of maximum size (552); but since
@@ -510,26 +510,26 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           "destroying request manager %p\n", rm);
 #endif
-  MUTEX_LOCK (rm->lock);
+  GNUNET_mutex_lock (rm->lock);
   /* cannot hold lock during shutdown since
      fslib may have to aquire it; but we can
      flag that we are in the shutdown process
      and start to ignore fslib events! */
-  rm->shutdown = YES;
-  MUTEX_UNLOCK (rm->lock);
+  rm->shutdown = GNUNET_YES;
+  GNUNET_mutex_unlock (rm->lock);
   for (i = 0; i < rm->requestListIndex; i++)
     {
       if (rm->requestList[i]->searchHandle != NULL)
         FS_stop_search (rm->sctx, rm->requestList[i]->searchHandle);
-      FREE (rm->requestList[i]->node);
-      FREE (rm->requestList[i]);
+      GNUNET_free (rm->requestList[i]->node);
+      GNUNET_free (rm->requestList[i]);
     }
-  GROW (rm->requestList, rm->requestListSize, 0);
+  GNUNET_array_grow (rm->requestList, rm->requestListSize, 0);
   FS_SEARCH_destroyContext (rm->sctx);
   rm->sctx = NULL;
-  MUTEX_DESTROY (rm->lock);
-  PTHREAD_REL_SELF (rm->requestThread);
-  FREE (rm);
+  GNUNET_mutex_destroy (rm->lock);
+  GNUNET_thread_release_self (rm->requestThread);
+  GNUNET_free (rm);
 }
 
 /**
@@ -541,8 +541,8 @@
 {
   int i;
 
-  MUTEX_LOCK (rm->lock);
-  if (rm->shutdown == NO)
+  GNUNET_mutex_lock (rm->lock);
+  if (rm->shutdown == GNUNET_NO)
     {
       for (i = 0; i < rm->requestListIndex; i++)
         {
@@ -551,7 +551,7 @@
           entry->lasttime += (entry->lasttime + entry->lastTimeout) / 2;
         }
     }
-  MUTEX_UNLOCK (rm->lock);
+  GNUNET_mutex_unlock (rm->lock);
 }
 
 /**
@@ -565,38 +565,39 @@
 {
   RequestEntry *entry;
 #if DEBUG_DOWNLOAD
-  EncName enc;
+  GNUNET_EncName enc;
 
   IF_GELOG (rm->ectx,
             GE_DEBUG | GE_REQUEST | GE_USER,
-            hash2enc (&node->chk.query, &enc));
+            GNUNET_hash_to_enc (&node->chk.query, &enc));
   GE_LOG (rm->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Queuing request (query: %s)\n", &enc);
 #endif
 
   GE_ASSERT (rm->ectx, node != NULL);
-  entry = MALLOC (sizeof (RequestEntry));
+  entry = GNUNET_malloc (sizeof (RequestEntry));
   entry->node = node;
   entry->lasttime = 0;          /* never sent */
   entry->lastTimeout = 0;
   entry->tries = 0;             /* not tried so far */
   entry->lastPriority = 0;
   entry->searchHandle = NULL;
-  MUTEX_LOCK (rm->lock);
-  if (rm->shutdown == NO)
+  GNUNET_mutex_lock (rm->lock);
+  if (rm->shutdown == GNUNET_NO)
     {
       GE_ASSERT (rm->ectx, rm->requestListSize > 0);
       if (rm->requestListSize == rm->requestListIndex)
-        GROW (rm->requestList, rm->requestListSize, rm->requestListSize * 2);
+        GNUNET_array_grow (rm->requestList, rm->requestListSize,
+                           rm->requestListSize * 2);
       rm->requestList[rm->requestListIndex++] = entry;
     }
   else
     {
       GE_BREAK (rm->ectx, 0);
-      FREE (entry);
+      GNUNET_free (entry);
     }
-  MUTEX_UNLOCK (rm->lock);
+  GNUNET_mutex_unlock (rm->lock);
 }
 
 
@@ -612,8 +613,8 @@
   int i;
   RequestEntry *re;
 
-  MUTEX_LOCK (rm->lock);
-  if (rm->shutdown == NO)
+  GNUNET_mutex_lock (rm->lock);
+  if (rm->shutdown == GNUNET_NO)
     {
       for (i = 0; i < rm->requestListIndex; i++)
         {
@@ -622,15 +623,15 @@
             {
               rm->requestList[i] = rm->requestList[--rm->requestListIndex];
               rm->requestList[rm->requestListIndex] = NULL;
-              MUTEX_UNLOCK (rm->lock);
+              GNUNET_mutex_unlock (rm->lock);
               if (NULL != re->searchHandle)
                 FS_stop_search (rm->sctx, re->searchHandle);
-              FREE (re);
+              GNUNET_free (re);
               return;
             }
         }
     }
-  MUTEX_UNLOCK (rm->lock);
+  GNUNET_mutex_unlock (rm->lock);
   GE_BREAK (rm->ectx, 0);       /* uh uh - at least a memory leak... */
 }
 
@@ -647,8 +648,8 @@
   unsigned long long completed;
   unsigned long long offset;
   unsigned long long length;
-  cron_t startTime;
-  cron_t TTL_DECREMENT;
+  GNUNET_CronTime startTime;
+  GNUNET_CronTime TTL_DECREMENT;
   RequestManager *rm;
   IOContext *ioc;
   ECRS_DownloadProgressCallback dpcb;
@@ -717,16 +718,16 @@
   /* locking? */
   if (node->level == 0)
     {
-      cron_t eta;
+      GNUNET_CronTime eta;
 
       node->ctx->completed += size;
-      eta = get_time ();
+      eta = GNUNET_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);
+          eta = (GNUNET_CronTime) (node->ctx->startTime +
+                                   (((double) (eta - node->ctx->startTime) /
+                                     (double) node->ctx->completed)) *
+                                   (double) node->ctx->length);
         }
       if (node->ctx->dpcb != NULL)
         {
@@ -737,10 +738,10 @@
         }
     }
   rm = node->ctx->rm;
-  MUTEX_LOCK (rm->lock);
-  if (rm->shutdown == YES)
+  GNUNET_mutex_lock (rm->lock);
+  if (rm->shutdown == GNUNET_YES)
     {
-      MUTEX_UNLOCK (rm->lock);
+      GNUNET_mutex_unlock (rm->lock);
       return;
     }
 
@@ -754,17 +755,17 @@
   if (pos == -1)
     {
       /* GE_BREAK(ectx, 0); *//* should never happen */
-      MUTEX_UNLOCK (rm->lock);
+      GNUNET_mutex_unlock (rm->lock);
       return;
     }
   entry = rm->requestList[pos];
 
-  if ((entry->lasttime < get_time ()) && (entry->lasttime != 0))
+  if ((entry->lasttime < GNUNET_get_time ()) && (entry->lasttime != 0))
     {
       unsigned int weight = 15;
       unsigned int ettl = entry->lastTimeout - entry->lasttime;
       if ((ettl > 4 * rm->initialTTL) &&
-          ((get_time () - entry->lasttime) < rm->initialTTL))
+          ((GNUNET_get_time () - entry->lasttime) < rm->initialTTL))
         {
           weight = 127;
           /* eTTL is MUCH bigger than what we currently expect AND the time
@@ -782,9 +783,9 @@
     }
   if (entry->tries > 1)
     {
-      TIME_T nowTT;
+      GNUNET_Int32Time nowTT;
 
-      TIME (&nowTT);
+      GNUNET_get_time_int32 (&nowTT);
       if ((nowTT - rm->initialTTL) > rm->lastDET)
         {
           /* only consider congestion control every
@@ -798,12 +799,12 @@
           rm->lastDET = nowTT;
         }
     }
-  MUTEX_UNLOCK (rm->lock);
+  GNUNET_mutex_unlock (rm->lock);
 }
 
 
 /**
- * Download children of this IBlock.
+ * GNUNET_ND_DOWNLOAD children of this IBlock.
  *
  * @param rm the node that should downloaded
  */
@@ -822,7 +823,7 @@
  * progress.
  *
  * @param node that is checked for presence
- * @return YES if present, NO if not.
+ * @return GNUNET_YES if present, GNUNET_NO if not.
  */
 static int
 checkPresent (NodeClosure * node)
@@ -831,7 +832,7 @@
   int ret;
   char *data;
   unsigned int size;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 
   size = getNodeSize (node);
 
@@ -841,39 +842,39 @@
   if ((node->level == 0) &&
       ((node->offset + size < node->ctx->offset) ||
        (node->offset >= node->ctx->offset + node->ctx->length)))
-    return YES;
+    return GNUNET_YES;
 
-  data = MALLOC (size);
+  data = GNUNET_malloc (size);
   res = readFromIOC (node->ctx->ioc, node->level, node->offset, data, size);
   if (res == size)
     {
-      hash (data, size, &hc);
-      if (equalsHashCode512 (&hc, &node->chk.key))
+      GNUNET_hash (data, size, &hc);
+      if (0 == memcmp (&hc, &node->chk.key, sizeof (GNUNET_HashCode)))
         {
           updateProgress (node, data, size);
           if (node->level > 0)
             iblock_download_children (node, data, size);
 
-          ret = YES;
+          ret = GNUNET_YES;
         }
       else
-        ret = NO;
+        ret = GNUNET_NO;
     }
   else
-    ret = NO;
-  FREE (data);
+    ret = GNUNET_NO;
+  GNUNET_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");
+          node->offset, node->level, ret == GNUNET_YES ? "YES" : "NO");
 #endif
 
   return ret;
 }
 
 /**
- * Download children of this IBlock.
+ * GNUNET_ND_DOWNLOAD children of this IBlock.
  *
  * @param this the node that should downloaded
  */
@@ -908,7 +909,7 @@
   chks = (CHK *) data;
   for (i = 0; i < childcount; i++)
     {
-      child = MALLOC (sizeof (NodeClosure));
+      child = GNUNET_malloc (sizeof (NodeClosure));
       child->ctx = node->ctx;
       child->chk = chks[i];
       child->offset = baseOffset + i * levelSize;
@@ -916,10 +917,10 @@
       child->level = node->level - 1;
       GE_ASSERT (ectx, (child->level != 0) ||
                  ((child->offset % DBLOCK_SIZE) == 0));
-      if (NO == checkPresent (child))
+      if (GNUNET_NO == checkPresent (child))
         addRequest (node->ctx->rm, child);
       else
-        FREE (child);           /* done already! */
+        GNUNET_free (child);    /* done already! */
     }
 }
 
@@ -931,19 +932,20 @@
  * @param hashcode represents the key concatenated with the initial
  *        value used in the alg
  * @param result where to store the result (encrypted block)
- * @returns OK on success, SYSERR on error
+ * @returns GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 decryptContent (const char *data,
-                unsigned int size, const HashCode512 * hashcode, char *result)
+                unsigned int size, const GNUNET_HashCode * hashcode,
+                char *result)
 {
-  INITVECTOR iv;
-  SESSIONKEY skey;
+  GNUNET_AES_InitializationVector iv;
+  GNUNET_AES_SessionKey skey;
 
   GE_ASSERT (NULL, (data != NULL) && (hashcode != NULL) && (result != NULL));
-  /* get key and init value from the hash code */
-  hashToKey (hashcode, &skey, &iv);
-  return decryptBlock (&skey, data, size, &iv, result);
+  /* get key and init value from the GNUNET_hash code */
+  GNUNET_hash_to_AES_key (hashcode, &skey, &iv);
+  return GNUNET_AES_decrypt (&skey, data, size, &iv, result);
 }
 
 
@@ -958,59 +960,60 @@
  *        this function!
  * @param query the query for which reply is the answer
  * @param reply the reply
- * @return OK if the reply was valid, SYSERR on error
+ * @return GNUNET_OK if the reply was valid, GNUNET_SYSERR on error
  */
 static int
-nodeReceive (const HashCode512 * query,
+nodeReceive (const GNUNET_HashCode * query,
              const Datastore_Value * reply, void *cls, unsigned long long uid)
 {
   NodeClosure *node = cls;
   struct GE_Context *ectx = node->ctx->rm->ectx;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
   unsigned int size;
   int i;
   char *data;
 #if DEBUG_DOWNLOAD
-  EncName enc;
+  GNUNET_EncName enc;
 
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (query, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (query, &enc));
+  GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "Receiving reply to query `%s'\n", &enc);
 #endif
-  GE_ASSERT (ectx, equalsHashCode512 (query, &node->chk.query));
+  GE_ASSERT (ectx,
+             0 == memcmp (query, &node->chk.query, sizeof (GNUNET_HashCode)));
   size = ntohl (reply->size) - sizeof (Datastore_Value);
   if ((size <= sizeof (DBlock)) ||
       (size - sizeof (DBlock) != getNodeSize (node)))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;            /* invalid size! */
+      return GNUNET_SYSERR;     /* invalid size! */
     }
   size -= sizeof (DBlock);
-  data = MALLOC (size);
-  if (SYSERR == decryptContent ((char *) &((DBlock *) & reply[1])[1],
-                                size, &node->chk.key, data))
+  data = GNUNET_malloc (size);
+  if (GNUNET_SYSERR == decryptContent ((char *) &((DBlock *) & reply[1])[1],
+                                       size, &node->chk.key, data))
     GE_ASSERT (ectx, 0);
-  hash (data, size, &hc);
-  if (!equalsHashCode512 (&hc, &node->chk.key))
+  GNUNET_hash (data, size, &hc);
+  if (0 != memcmp (&hc, &node->chk.key, sizeof (GNUNET_HashCode)))
     {
       delRequest (node->ctx->rm, node);
-      FREE (data);
+      GNUNET_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"));
-      node->ctx->rm->abortFlag = YES;
-      return SYSERR;
+      node->ctx->rm->abortFlag = GNUNET_YES;
+      return GNUNET_SYSERR;
     }
   if (size != writeToIOC (node->ctx->ioc,
                           node->level, node->offset, data, size))
     {
       GE_LOG_STRERROR (ectx,
                        GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "WRITE");
-      node->ctx->rm->abortFlag = YES;
-      return SYSERR;
+      node->ctx->rm->abortFlag = GNUNET_YES;
+      return GNUNET_SYSERR;
     }
   updateProgress (node, data, size);
   if (node->level > 0)
@@ -1030,10 +1033,10 @@
         }
     }
   GE_ASSERT (node->ctx->rm->ectx, node->ctx->rm->requestThread != NULL);
-  PTHREAD_STOP_SLEEP (node->ctx->rm->requestThread);
-  FREE (data);
-  FREE (node);
-  return OK;
+  GNUNET_thread_stop_sleep (node->ctx->rm->requestThread);
+  GNUNET_free (data);
+  GNUNET_free (node);
+  return GNUNET_OK;
 }
 
 
@@ -1048,35 +1051,37 @@
 issueRequest (RequestManager * rm, int requestIndex)
 {
   static unsigned int lastmpriority;
-  static cron_t lastmpritime;
+  static GNUNET_CronTime lastmpritime;
   RequestEntry *entry;
-  cron_t now;
+  GNUNET_CronTime now;
   unsigned int priority;
   unsigned int mpriority;
-  cron_t timeout;
+  GNUNET_CronTime timeout;
   unsigned int ttl;
   int TTL_DECREMENT;
 #if DEBUG_DOWNLOAD
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   entry = rm->requestList[requestIndex];
 
   /* compute priority */
-  if (lastmpritime + 10 * cronSECONDS < now)
+  if (lastmpritime + 10 * GNUNET_CRON_SECONDS < now)
     {
       /* only update avg. priority at most every
          10 seconds */
-      struct ClientServerConnection *sock;
+      struct GNUNET_ClientServerConnection *sock;
 
-      sock = client_connection_create (rm->ectx, rm->cfg);
+      sock = GNUNET_client_connection_create (rm->ectx, rm->cfg);
       lastmpriority = FS_getAveragePriority (sock);
       lastmpritime = now;
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
     }
   mpriority = lastmpriority;
-  priority = entry->lastPriority + weak_randomi (1 + entry->tries);
+  priority =
+    entry->lastPriority + GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                                             1 + entry->tries);
   if (priority > mpriority)
     {
       /* mpriority is (2 * (current average priority + 2)) and
@@ -1084,10 +1089,12 @@
          calculated tpriority is above it, we reduce tpriority
          to random value between the average (mpriority/2) but
          bounded by mpriority */
-      priority = 1 + mpriority / 2 + (weak_randomi (2 + mpriority / 2));
+      priority =
+        1 + mpriority / 2 +
+        (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 2 + mpriority / 2));
     }
   if (priority > 0x0FFFFFF)
-    priority = weak_randomi (0xFFFFFF); /* bound! */
+    priority = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 0xFFFFFF);       
 /* bound! */
 
   /* compute TTL */
 
@@ -1104,7 +1111,9 @@
       ttl = entry->lastTimeout - entry->lasttime;
       if (ttl > MAX_TTL)
         {
-          ttl = MAX_TTL + weak_randomi (2 * TTL_DECREMENT);
+          ttl =
+            MAX_TTL + GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                                         2 * TTL_DECREMENT);
         }
       else if (ttl > rm->initialTTL)
         {
@@ -1119,13 +1128,15 @@
           rd = TTL_DECREMENT / rd;
           if (rd == 0)
             rd = 1;
-          ttl += weak_randomi (50 * cronMILLIS + rd);
+          ttl +=
+            GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                               50 * GNUNET_CRON_MILLISECONDS + rd);
           /* rd == TTL_DECREMENT / (con->ttl / rm->initialTTL) + saveguards
              50ms: minimum increment */
         }
       else
         {
-          ttl += weak_randomi (ttl + 2 * TTL_DECREMENT);        /* exponential 
backoff with random factor */
+          ttl += GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, ttl + 2 * 
TTL_DECREMENT);       /* exponential backoff with random factor */
         }
       if (ttl > (priority + 8) * TTL_DECREMENT)
         ttl = (priority + 8) * TTL_DECREMENT;   /* see adjustTTL in gap */
@@ -1135,7 +1146,7 @@
 #if DEBUG_DOWNLOAD
   IF_GELOG (ectx,
             GE_DEBUG | GE_REQUEST | GE_USER,
-            hash2enc (&entry->node->chk.query, &enc));
+            GNUNET_hash_to_enc (&entry->node->chk.query, &enc));
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Starting FS search for %s:%llu:%u `%s'\n",
@@ -1147,7 +1158,7 @@
     FS_stop_search (rm->sctx, entry->searchHandle);
   entry->searchHandle
     = FS_start_search (rm->sctx,
-                       rm->have_target == NO ? NULL : &rm->target,
+                       rm->have_target == GNUNET_NO ? NULL : &rm->target,
                        D_BLOCK,
                        1,
                        &entry->node->chk.query,
@@ -1158,7 +1169,8 @@
       entry->lastPriority = priority;
       entry->lastTimeout = timeout;
       entry->lasttime = now + 2 * TTL_DECREMENT;
-      if (weak_randomi (1 + entry->tries) > 1)
+      if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 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
@@ -1167,17 +1179,18 @@
              http://www.industrialethernetuniversity.com/courses/101_4.htm
            */
           entry->lasttime +=
-            weak_randomi (TTL_DECREMENT * (1 + entry->tries));
+            GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                               TTL_DECREMENT * (1 + entry->tries));
         }
       entry->tries++;
     }
   /* warn if number of attempts goes too high */
   if ((0 == (entry->tries % MAX_TRIES)) && (entry->tries > 0))
     {
-      EncName enc;
+      GNUNET_EncName enc;
       IF_GELOG (rm->ectx,
                 GE_WARNING | GE_BULK | GE_USER,
-                hash2enc (&entry->node->chk.key, &enc));
+                GNUNET_hash_to_enc (&entry->node->chk.key, &enc));
       GE_LOG (rm->ectx,
               GE_WARNING | GE_BULK | GE_USER,
               _
@@ -1191,24 +1204,24 @@
  * (min ttl until next job is ready) and re-schedule itself
  * accordingly!
  */
-static cron_t
+static GNUNET_CronTime
 processRequests (RequestManager * rm)
 {
-  cron_t minSleep;
-  cron_t now;
-  cron_t delta;
+  GNUNET_CronTime minSleep;
+  GNUNET_CronTime now;
+  GNUNET_CronTime delta;
   int i;
   unsigned int pending;
-  int *perm;
+  unsigned int *perm;
   unsigned int TTL_DECREMENT;
 
-  MUTEX_LOCK (rm->lock);
-  if ((rm->shutdown == YES) || (rm->requestListIndex == 0))
+  GNUNET_mutex_lock (rm->lock);
+  if ((rm->shutdown == GNUNET_YES) || (rm->requestListIndex == 0))
     {
-      MUTEX_UNLOCK (rm->lock);
+      GNUNET_mutex_unlock (rm->lock);
       return 0;
     }
-  now = get_time ();
+  now = GNUNET_get_time ();
   pending = 0;
   TTL_DECREMENT = 0;
   if (rm->requestListIndex > 0)
@@ -1227,8 +1240,8 @@
         }
     }
 
-  minSleep = 5000 * cronMILLIS; /* max-sleep! */
-  perm = permute (WEAK, rm->requestListIndex);
+  minSleep = 5000 * GNUNET_CRON_MILLISECONDS;   /* max-sleep! */
+  perm = GNUNET_permute (GNUNET_RANDOM_QUALITY_WEAK, rm->requestListIndex);
   for (i = 0; i < rm->requestListIndex; i++)
     {
       int j = perm[i];
@@ -1242,7 +1255,9 @@
           if ((pOCWCubed <= 0) ||
               (pOCWCubed * rm->requestListIndex <= 0) /* see #642 */  ||
               /* avoid no-start: override congestionWindow occasionally... */
-              (0 == weak_randomi (rm->requestListIndex * pOCWCubed)))
+              (0 ==
+               GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                                  rm->requestListIndex * pOCWCubed)))
             {
               issueRequest (rm, j);
               delta = (rm->requestList[j]->lastTimeout - now) + TTL_DECREMENT;
@@ -1260,10 +1275,10 @@
       if (delta < minSleep)
         minSleep = delta;
     }
-  FREE (perm);
-  if (minSleep < cronMILLIS * 100)
-    minSleep = cronMILLIS * 100;        /* maximum resolution: 100ms */
-  MUTEX_UNLOCK (rm->lock);
+  GNUNET_free (perm);
+  if (minSleep < GNUNET_CRON_MILLISECONDS * 100)
+    minSleep = GNUNET_CRON_MILLISECONDS * 100;  /* maximum resolution: 100ms */
+  GNUNET_mutex_unlock (rm->lock);
   return minSleep;
 }
 
@@ -1272,7 +1287,7 @@
 /* ***************** main method **************** */
 
 /**
- * Download a file.
+ * GNUNET_ND_DOWNLOAD a file.
  *
  * @param uri the URI of the file (determines what to download)
  * @param filename where to store the file
@@ -1293,12 +1308,13 @@
                                    0,
                                    ECRS_fileSize (uri),
                                    anonymityLevel,
-                                   NO, dpcb, dpcbClosure, tt, ttClosure);
+                                   GNUNET_NO, dpcb, dpcbClosure, tt,
+                                   ttClosure);
 }
 
 
 /**
- * Download parts of a file.  Note that this will store
+ * GNUNET_ND_DOWNLOAD parts of a file.  Note that this will store
  * the blocks at the respective offset in the given file.
  * Also, the download is still using the blocking of the
  * underlying ECRS encoding.  As a result, the download
@@ -1312,7 +1328,7 @@
  *
  * @param uri the URI of the file (determines what to download)
  * @param filename where to store the file
- * @param no_temporaries set to YES to disallow generation of temporary files
+ * @param no_temporaries set to GNUNET_YES to disallow generation of temporary 
files
  * @param start starting offset
  * @param length length of the download (starting at offset)
  */
@@ -1335,7 +1351,7 @@
   CommonCtx ctx;
   NodeClosure *top;
   FileIdentifier fid;
-  cron_t minSleep;
+  GNUNET_CronTime minSleep;
   char *realFN;
   char *path;
   char *pos;
@@ -1350,16 +1366,17 @@
   if ((filename[strlen (filename) - 1] == '/') ||
       (filename[strlen (filename) - 1] == '\\'))
     {
-      realFN = MALLOC (strlen (filename) + strlen (GNUNET_DIRECTORY_EXT));
+      realFN =
+        GNUNET_malloc (strlen (filename) + strlen (GNUNET_DIRECTORY_EXT));
       strcpy (realFN, filename);
       realFN[strlen (filename) - 1] = '\0';
       strcat (realFN, GNUNET_DIRECTORY_EXT);
     }
   else
     {
-      realFN = STRDUP (filename);
+      realFN = GNUNET_strdup (filename);
     }
-  path = MALLOC (strlen (realFN) * strlen (GNUNET_DIRECTORY_EXT) + 1);
+  path = GNUNET_malloc (strlen (realFN) * strlen (GNUNET_DIRECTORY_EXT) + 1);
   strcpy (path, realFN);
   pos = path;
   while (*pos != '\0')
@@ -1383,96 +1400,98 @@
         }
       pos++;
     }
-  FREE (realFN);
+  GNUNET_free (realFN);
   realFN = path;
 
-  if (SYSERR == disk_directory_create_for_file (ectx, realFN))
+  if (GNUNET_SYSERR == GNUNET_disk_directory_create_for_file (ectx, realFN))
     {
-      FREE (realFN);
-      return SYSERR;
+      GNUNET_free (realFN);
+      return GNUNET_SYSERR;
     }
   if (0 == ECRS_fileSize (uri))
     {
-      ret = disk_file_open (ectx,
-                            realFN,
-                            O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
-      FREE (realFN);
+      ret = GNUNET_disk_file_open (ectx,
+                                   realFN,
+                                   O_CREAT | O_WRONLY | O_TRUNC,
+                                   S_IRUSR | S_IWUSR);
+      GNUNET_free (realFN);
       if (ret == -1)
-        return SYSERR;
+        return GNUNET_SYSERR;
       CLOSE (ret);
-      dpcb (0, 0, get_time (), 0, NULL, 0, dpcbClosure);
-      return OK;
+      dpcb (0, 0, GNUNET_get_time (), 0, NULL, 0, dpcbClosure);
+      return GNUNET_OK;
     }
   fid = uri->data.fi;
 
   if ((!ECRS_isFileUri (uri)) && (!ECRS_isLocationUri (uri)))
     {
       GE_BREAK (ectx, 0);
-      FREE (realFN);
-      return SYSERR;
+      GNUNET_free (realFN);
+      return GNUNET_SYSERR;
     }
 
-  if (OK != createIOContext (ectx,
-                             &ioc,
-                             no_temporaries,
-                             ntohll (fid.file_length), realFN))
+  if (GNUNET_OK != createIOContext (ectx,
+                                    &ioc,
+                                    no_temporaries,
+                                    GNUNET_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);
 #endif
-      FREE (realFN);
-      return SYSERR;
+      GNUNET_free (realFN);
+      return GNUNET_SYSERR;
     }
   rm = createRequestManager (ectx, cfg);
   if (rm == NULL)
     {
-      freeIOC (&ioc, YES);
-      FREE (realFN);
-      return SYSERR;
+      freeIOC (&ioc, GNUNET_YES);
+      GNUNET_free (realFN);
+      return GNUNET_SYSERR;
     }
   if (ECRS_isLocationUri (uri))
     {
-      hash (&uri->data.loc.peer, sizeof (PublicKey), &rm->target.hashPubKey);
-      rm->have_target = YES;
+      GNUNET_hash (&uri->data.loc.peer, sizeof (GNUNET_RSA_PublicKey),
+                   &rm->target.hashPubKey);
+      rm->have_target = GNUNET_YES;
     }
 
-  ctx.startTime = get_time ();
+  ctx.startTime = GNUNET_get_time ();
   ctx.anonymityLevel = anonymityLevel;
   ctx.offset = offset;
   ctx.length = length;
-  ctx.TTL_DECREMENT = 5 * cronSECONDS;  /* HACK! */
+  ctx.TTL_DECREMENT = 5 * GNUNET_CRON_SECONDS;  /* HACK! */
   ctx.rm = rm;
   ctx.ioc = &ioc;
   ctx.dpcb = dpcb;
   ctx.dpcbClosure = dpcbClosure;
-  ctx.total = ntohll (fid.file_length);
+  ctx.total = GNUNET_ntohll (fid.file_length);
   ctx.completed = 0;
-  top = MALLOC (sizeof (NodeClosure));
+  top = GNUNET_malloc (sizeof (NodeClosure));
   top->ctx = &ctx;
   top->chk = fid.chk;
   top->offset = 0;
   top->level = computeDepth (ctx.total);
-  if (NO == checkPresent (top))
+  if (GNUNET_NO == checkPresent (top))
     addRequest (rm, top);
   else
-    FREE (top);
-  while ((OK == tt (ttClosure)) &&
-         (rm->abortFlag == NO) && (rm->requestListIndex != 0))
+    GNUNET_free (top);
+  while ((GNUNET_OK == tt (ttClosure)) &&
+         (rm->abortFlag == GNUNET_NO) && (rm->requestListIndex != 0))
     {
       minSleep = processRequests (rm);
-      if ((OK == tt (ttClosure)) &&
-          (rm->abortFlag == NO) && (rm->requestListIndex != 0))
-        PTHREAD_SLEEP (minSleep);
+      if ((GNUNET_OK == tt (ttClosure)) &&
+          (rm->abortFlag == GNUNET_NO) && (rm->requestListIndex != 0))
+        GNUNET_thread_sleep (minSleep);
     }
 
   if ((rm->requestListIndex == 0) &&
       ((ctx.completed == ctx.total) ||
        ((ctx.total != ctx.length) &&
-        (ctx.completed >= ctx.length))) && (rm->abortFlag == NO))
+        (ctx.completed >= ctx.length))) && (rm->abortFlag == GNUNET_NO))
     {
-      ret = OK;
+      ret = GNUNET_OK;
     }
   else
     {
@@ -1483,16 +1502,16 @@
               rm->requestListIndex,
               ctx.completed, ctx.total, rm->abortFlag, tt (ttClosure));
 #endif
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
   destroyRequestManager (rm);
-  if (ret == OK)
+  if (ret == GNUNET_OK)
     {
-      freeIOC (&ioc, YES);
+      freeIOC (&ioc, GNUNET_YES);
     }
-  else if (tt (ttClosure) == SYSERR)
+  else if (tt (ttClosure) == GNUNET_SYSERR)
     {
-      freeIOC (&ioc, YES);
+      freeIOC (&ioc, GNUNET_YES);
       if (0 != UNLINK (realFN))
         {
           GE_LOG_STRERROR_FILE (ectx,
@@ -1504,7 +1523,7 @@
           char *rdir;
           int len;
 
-          rdir = STRDUP (realFN);
+          rdir = GNUNET_strdup (realFN);
           len = strlen (rdir);
           do
             {
@@ -1513,20 +1532,21 @@
               rdir[len] = '\0';
             }
           while ((len > 0) && (0 == rmdir (rdir)));
-          FREE (rdir);
+          GNUNET_free (rdir);
         }
     }
   else
     {
-      freeIOC (&ioc, NO);       /* aborted */
+      freeIOC (&ioc, GNUNET_NO);        /* aborted */
     }
 #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");
+          __FUNCTION__, filename,
+          ret == GNUNET_OK ? "SUCCESS" : "INCOMPLETE");
 #endif
-  FREE (realFN);
+  GNUNET_free (realFN);
   return ret;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/downloadtest.c      2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/ecrs/downloadtest.c      2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -31,7 +31,7 @@
 #include "gnunet_util_network_client.h"
 #include "tree.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
 /**
  * Must be a multiple of 16k.
@@ -41,13 +41,13 @@
 static int
 testTerminate (void *unused)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 static void progress_check
   (unsigned long long totalBytes,
    unsigned long long completedBytes,
-   cron_t eta,
+   GNUNET_CronTime eta,
    unsigned long long lastBlockOffset,
    const char *lastBlock, unsigned int lastBlockSize, void *closure)
 {
@@ -65,11 +65,11 @@
 {
   char *fn;
 
-  fn = MALLOC (strlen ("/tmp/gnunet-ecrstest/ECRSTEST") + 14);
-  SNPRINTF (fn,
-            strlen ("/tmp/gnunet-ecrstest/ECRSTEST") + 14,
-            "/tmp/gnunet-ecrstest/ECRSTEST%u", i);
-  disk_directory_create_for_file (NULL, fn);
+  fn = GNUNET_malloc (strlen ("/tmp/gnunet-ecrstest/ECRSTEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen ("/tmp/gnunet-ecrstest/ECRSTEST") + 14,
+                   "/tmp/gnunet-ecrstest/ECRSTEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -84,22 +84,24 @@
   int i;
 
   name = makeName (size);
-  fd = disk_file_open (NULL, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
-  buf = MALLOC (size);
+  fd =
+    GNUNET_disk_file_open (NULL, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
+  buf = GNUNET_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)]);
+  for (i = 0; i < (int) (size - 42 - sizeof (GNUNET_HashCode));
+       i += sizeof (GNUNET_HashCode))
+    GNUNET_hash (&buf[i], 42,
+                 (GNUNET_HashCode *) & buf[i + sizeof (GNUNET_HashCode)]);
   WRITE (fd, buf, size);
-  FREE (buf);
+  GNUNET_free (buf);
   CLOSE (fd);
-  ret = ECRS_uploadFile (NULL, cfg, name, YES,  /* index */
+  ret = ECRS_uploadFile (NULL, cfg, name, GNUNET_YES,   /* index */
                          0,     /* anon */
                          0,     /* prio */
-                         get_time () + 10 * cronMINUTES,        /* expire */
+                         GNUNET_get_time () + 10 * GNUNET_CRON_MINUTES, /* 
expire */
                          NULL,  /* progress */
                          NULL, &testTerminate, NULL, &uri);
-  FREE (name);
+  GNUNET_free (name);
   return uri;
 }
 
@@ -119,41 +121,42 @@
   GE_LOG (NULL,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Starting download of `%s'\n", tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   tmpName = makeName (0);
-  ret = SYSERR;
+  ret = GNUNET_SYSERR;
   for (j = SIZE - 16 * 1024; j >= 0; j -= 16 * 1024)
     {
-      if (OK == ECRS_downloadPartialFile (NULL,
-                                          cfg,
-                                          uri,
-                                          tmpName,
-                                          j,
-                                          16 * 1024,
-                                          0,
-                                          NO,
-                                          &progress_check,
-                                          NULL, &testTerminate, NULL))
+      if (GNUNET_OK == ECRS_downloadPartialFile (NULL,
+                                                 cfg,
+                                                 uri,
+                                                 tmpName,
+                                                 j,
+                                                 16 * 1024,
+                                                 0,
+                                                 GNUNET_NO,
+                                                 &progress_check,
+                                                 NULL, &testTerminate, NULL))
         {
-          fd = disk_file_open (NULL, tmpName, O_RDONLY);
-          buf = MALLOC (size);
-          in = MALLOC (size);
+          fd = GNUNET_disk_file_open (NULL, tmpName, O_RDONLY);
+          buf = GNUNET_malloc (size);
+          in = GNUNET_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)]);
+          for (i = 0; i < (int) (size - 42 - sizeof (GNUNET_HashCode));
+               i += sizeof (GNUNET_HashCode))
+            GNUNET_hash (&buf[i], 42,
+                         (GNUNET_HashCode *) & buf[i +
+                                                   sizeof (GNUNET_HashCode)]);
           if (size != READ (fd, in, size))
-            ret = SYSERR;
+            ret = GNUNET_SYSERR;
           else if (0 == memcmp (&buf[j], &in[j], 16 * 1024))
-            ret = OK;
-          FREE (buf);
-          FREE (in);
+            ret = GNUNET_OK;
+          GNUNET_free (buf);
+          GNUNET_free (in);
           CLOSE (fd);
         }
     }
   UNLINK (tmpName);
-  FREE (tmpName);
+  GNUNET_free (tmpName);
   return ret;
 }
 
@@ -167,8 +170,8 @@
   name = makeName (size);
   ret = ECRS_unindexFile (NULL, cfg, name, NULL, NULL, &testTerminate, NULL);
   if (0 != UNLINK (name))
-    ret = SYSERR;
-  FREE (name);
+    ret = GNUNET_SYSERR;
+  GNUNET_free (name);
   return ret;
 }
 
@@ -177,40 +180,42 @@
 {
   pid_t daemon;
   int ok;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   struct ECRS_URI *uri;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
   sock = NULL;
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  ok = YES;
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
-  sock = client_connection_create (NULL, cfg);
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  ok = GNUNET_YES;
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
+  sock = GNUNET_client_connection_create (NULL, cfg);
   CHECK (sock != NULL);
 
   /* ACTUAL TEST CODE */
   uri = uploadFile (SIZE);
   CHECK (NULL != uri);
-  CHECK (OK == downloadFile (SIZE, uri));
+  CHECK (GNUNET_OK == downloadFile (SIZE, uri));
   ECRS_freeUri (uri);
-  CHECK (OK == unindexFile (SIZE));
+  CHECK (GNUNET_OK == unindexFile (SIZE));
   fprintf (stderr, " Ok.\n");
 
 
   /* END OF TEST CODE */
 FAILURE:
   if (sock != NULL)
-    connection_destroy (sock);
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+    GNUNET_client_connection_destroy (sock);
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
   GC_free (cfg);
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of ecrstest.c */

Modified: GNUnet/src/applications/fs/ecrs/ecrs.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrs.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/ecrs.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -30,31 +30,31 @@
 #include "ecrs.h"
 
 void
-ECRS_encryptInPlace (const HashCode512 * hc, void *data, unsigned int len)
+ECRS_encryptInPlace (const GNUNET_HashCode * hc, void *data, unsigned int len)
 {
   char *tmp;
-  SESSIONKEY skey;
-  INITVECTOR iv;
+  GNUNET_AES_SessionKey skey;
+  GNUNET_AES_InitializationVector iv;
 
-  hashToKey (hc, &skey, &iv);
-  tmp = MALLOC (len);
-  GE_ASSERT (NULL, len == encryptBlock (data, len, &skey, &iv, tmp));
+  GNUNET_hash_to_AES_key (hc, &skey, &iv);
+  tmp = GNUNET_malloc (len);
+  GE_ASSERT (NULL, len == GNUNET_AES_encrypt (data, len, &skey, &iv, tmp));
   memcpy (data, tmp, len);
-  FREE (tmp);
+  GNUNET_free (tmp);
 }
 
 void
-ECRS_decryptInPlace (const HashCode512 * hc, void *data, unsigned int len)
+ECRS_decryptInPlace (const GNUNET_HashCode * hc, void *data, unsigned int len)
 {
   char *tmp;
-  SESSIONKEY skey;
-  INITVECTOR iv;
+  GNUNET_AES_SessionKey skey;
+  GNUNET_AES_InitializationVector iv;
 
-  hashToKey (hc, &skey, &iv);
-  tmp = MALLOC (len);
-  GE_ASSERT (NULL, len == decryptBlock (&skey, data, len, &iv, tmp));
+  GNUNET_hash_to_AES_key (hc, &skey, &iv);
+  tmp = GNUNET_malloc (len);
+  GE_ASSERT (NULL, len == GNUNET_AES_decrypt (&skey, data, len, &iv, tmp));
   memcpy (data, tmp, len);
-  FREE (tmp);
+  GNUNET_free (tmp);
 }
 
 /* end of ecrs.c */

Modified: GNUnet/src/applications/fs/ecrs/ecrs.h
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrs.h      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/ecrs.h      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -55,20 +55,20 @@
   /**
    * Identity of the peer sharing the file.
    */
-  PublicKey peer;
+  GNUNET_RSA_PublicKey peer;
 
   /**
    * Time when the HELLO *and* this location URI
    * expire (they expire together!).
    */
-  TIME_T expirationTime;
+  GNUNET_Int32Time expirationTime;
 
   /**
    * RSA signature over the FileIdentifier,
-   * hash of the peer and expiration time.
+   * GNUNET_hash of the peer and expiration time.
    * (everything until proto).
    */
-  Signature contentSignature;
+  GNUNET_RSA_Signature contentSignature;
 
 } Location;
 
@@ -87,8 +87,8 @@
     } ksk;
     struct
     {
-      HashCode512 namespace;
-      HashCode512 identifier;
+      GNUNET_HashCode namespace;
+      GNUNET_HashCode identifier;
     } sks;
     FileIdentifier fi;
     Location loc;
@@ -111,10 +111,10 @@
 } MetaData;
 
 
-void ECRS_encryptInPlace (const HashCode512 * hc,
+void ECRS_encryptInPlace (const GNUNET_HashCode * hc,
                           void *data, unsigned int len);
 
-void ECRS_decryptInPlace (const HashCode512 * hc,
+void ECRS_decryptInPlace (const GNUNET_HashCode * hc,
                           void *data, unsigned int len);
 
 

Modified: GNUnet/src/applications/fs/ecrs/ecrstest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrstest.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/ecrstest.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,12 +31,12 @@
 #include "gnunet_util_network_client.h"
 #include "tree.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
 static int
 testTerminate (void *unused)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 static struct GC_Configuration *cfg;
@@ -46,11 +46,11 @@
 {
   char *fn;
 
-  fn = MALLOC (strlen ("/tmp/gnunet-ecrstest/ECRSTEST") + 14);
-  SNPRINTF (fn,
-            strlen ("/tmp/gnunet-ecrstest/ECRSTEST") + 14,
-            "/tmp/gnunet-ecrstest/ECRSTEST%u", i);
-  disk_directory_create_for_file (NULL, fn);
+  fn = GNUNET_malloc (strlen ("/tmp/gnunet-ecrstest/ECRSTEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen ("/tmp/gnunet-ecrstest/ECRSTEST") + 14,
+                   "/tmp/gnunet-ecrstest/ECRSTEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -65,22 +65,24 @@
   int i;
 
   name = makeName (size);
-  fd = disk_file_open (NULL, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
-  buf = MALLOC (size);
+  fd =
+    GNUNET_disk_file_open (NULL, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
+  buf = GNUNET_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)]);
+  for (i = 0; i < (int) (size - 42 - sizeof (GNUNET_HashCode));
+       i += sizeof (GNUNET_HashCode))
+    GNUNET_hash (&buf[i], 42,
+                 (GNUNET_HashCode *) & buf[i + sizeof (GNUNET_HashCode)]);
   WRITE (fd, buf, size);
-  FREE (buf);
+  GNUNET_free (buf);
   CLOSE (fd);
-  ret = ECRS_uploadFile (NULL, cfg, name, YES,  /* index */
+  ret = ECRS_uploadFile (NULL, cfg, name, GNUNET_YES,   /* index */
                          0,     /* anon */
                          0,     /* prio */
-                         get_time () + 10 * cronMINUTES,        /* expire */
+                         GNUNET_get_time () + 10 * GNUNET_CRON_MINUTES, /* 
expire */
                          NULL,  /* progress */
                          NULL, &testTerminate, NULL, &uri);
-  if (ret != SYSERR)
+  if (ret != GNUNET_SYSERR)
     {
       struct ECRS_MetaData *meta;
       struct ECRS_URI *key;
@@ -91,12 +93,12 @@
 
       meta = ECRS_createMetaData ();
       key = ECRS_keywordsToUri (keywords);
-      ret = ECRS_addToKeyspace (NULL, cfg, key, 0, 0, get_time () + 10 * 
cronMINUTES,   /* expire */
+      ret = ECRS_addToKeyspace (NULL, cfg, key, 0, 0, GNUNET_get_time () + 10 
* GNUNET_CRON_MINUTES,    /* expire */
                                 uri, meta);
       ECRS_freeMetaData (meta);
       ECRS_freeUri (uri);
-      FREE (name);
-      if (ret == OK)
+      GNUNET_free (name);
+      if (ret == GNUNET_OK)
         {
           return key;
         }
@@ -108,14 +110,14 @@
     }
   else
     {
-      FREE (name);
+      GNUNET_free (name);
       return NULL;
     }
 }
 
 static int
 searchCB (const ECRS_FileInfo * fi,
-          const HashCode512 * key, int isRoot, void *closure)
+          const GNUNET_HashCode * key, int isRoot, void *closure)
 {
   struct ECRS_URI **my = closure;
   char *tmp;
@@ -123,15 +125,15 @@
   tmp = ECRS_uriToString (fi->uri);
   GE_LOG (NULL,
           GE_DEBUG | GE_REQUEST | GE_USER, "Search found URI `%s'\n", tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   GE_ASSERT (NULL, NULL == *my);
   *my = ECRS_dupUri (fi->uri);
-  return SYSERR;                /* abort search */
+  return GNUNET_SYSERR;         /* abort search */
 }
 
 /**
  * @param *uri In: keyword URI, out: file URI
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 static int
 searchFile (struct ECRS_URI **uri)
@@ -144,14 +146,14 @@
                      cfg,
                      *uri,
                      0,
-                     15 * cronSECONDS,
+                     15 * GNUNET_CRON_SECONDS,
                      &searchCB, &myURI, &testTerminate, NULL);
   ECRS_freeUri (*uri);
   *uri = myURI;
-  if ((ret != SYSERR) && (myURI != NULL))
-    return OK;
+  if ((ret != GNUNET_SYSERR) && (myURI != NULL))
+    return GNUNET_OK;
   else
-    return SYSERR;
+    return GNUNET_SYSERR;
 }
 
 static int
@@ -169,32 +171,34 @@
   GE_LOG (NULL,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Starting download of `%s'\n", tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   tmpName = makeName (0);
-  ret = SYSERR;
-  if (OK == ECRS_downloadFile (NULL,
-                               cfg,
-                               uri,
-                               tmpName, 0, NULL, NULL, &testTerminate, NULL))
+  ret = GNUNET_SYSERR;
+  if (GNUNET_OK == ECRS_downloadFile (NULL,
+                                      cfg,
+                                      uri,
+                                      tmpName, 0, NULL, NULL, &testTerminate,
+                                      NULL))
     {
 
-      fd = disk_file_open (NULL, tmpName, O_RDONLY);
-      buf = MALLOC (size);
-      in = MALLOC (size);
+      fd = GNUNET_disk_file_open (NULL, tmpName, O_RDONLY);
+      buf = GNUNET_malloc (size);
+      in = GNUNET_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)]);
+      for (i = 0; i < (int) (size - 42 - sizeof (GNUNET_HashCode));
+           i += sizeof (GNUNET_HashCode))
+        GNUNET_hash (&buf[i], 42,
+                     (GNUNET_HashCode *) & buf[i + sizeof (GNUNET_HashCode)]);
       if (size != READ (fd, in, size))
-        ret = SYSERR;
+        ret = GNUNET_SYSERR;
       else if (0 == memcmp (buf, in, size))
-        ret = OK;
-      FREE (buf);
-      FREE (in);
+        ret = GNUNET_OK;
+      GNUNET_free (buf);
+      GNUNET_free (in);
       CLOSE (fd);
     }
   UNLINK (tmpName);
-  FREE (tmpName);
+  GNUNET_free (tmpName);
   return ret;
 }
 
@@ -208,8 +212,8 @@
   name = makeName (size);
   ret = ECRS_unindexFile (NULL, cfg, name, NULL, NULL, &testTerminate, NULL);
   if (0 != UNLINK (name))
-    ret = SYSERR;
-  FREE (name);
+    ret = GNUNET_SYSERR;
+  GNUNET_free (name);
   return ret;
 }
 
@@ -233,23 +237,25 @@
   };
   pid_t daemon;
   int ok;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   struct ECRS_URI *uri;
   int i;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
   sock = NULL;
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  ok = YES;
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
-  sock = client_connection_create (NULL, cfg);
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  ok = GNUNET_YES;
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
+  sock = GNUNET_client_connection_create (NULL, cfg);
   CHECK (sock != NULL);
 
   /* ACTUAL TEST CODE */
@@ -259,10 +265,10 @@
       fprintf (stderr, "Testing filesize %u", filesizes[i]);
       uri = uploadFile (filesizes[i]);
       CHECK (NULL != uri);
-      CHECK (OK == searchFile (&uri));
-      CHECK (OK == downloadFile (filesizes[i], uri));
+      CHECK (GNUNET_OK == searchFile (&uri));
+      CHECK (GNUNET_OK == downloadFile (filesizes[i], uri));
       ECRS_freeUri (uri);
-      CHECK (OK == unindexFile (filesizes[i]));
+      CHECK (GNUNET_OK == unindexFile (filesizes[i]));
       fprintf (stderr, " Ok.\n");
       i++;
     }
@@ -270,10 +276,10 @@
   /* END OF TEST CODE */
 FAILURE:
   if (sock != NULL)
-    connection_destroy (sock);
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+    GNUNET_client_connection_destroy (sock);
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
   GC_free (cfg);
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of ecrstest.c */

Modified: GNUnet/src/applications/fs/ecrs/helper.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/helper.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/helper.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -51,7 +51,7 @@
       GE_BREAK (ectx, 0);
       return NULL;
     }
-  searchString = STRDUP (input);
+  searchString = GNUNET_strdup (input);
   num_Words = 0;
   for (inWord = 0, c = searchString; *c != '\0'; ++c)
     {
@@ -68,13 +68,13 @@
 
   if (num_Words == 0)
     {
-      FREENONNULL (searchString);
+      GNUNET_free_non_null (searchString);
       GE_LOG (ectx,
               GE_ERROR | GE_IMMEDIATE | GE_USER,
               _("No keywords specified!\n"));
       return NULL;
     }
-  keywords = MALLOC (num_Words * sizeof (char *));
+  keywords = GNUNET_malloc (num_Words * sizeof (char *));
   num_Words = 0;
   for (inWord = 0, c = searchString; *c != '\0'; ++c)
     {
@@ -91,8 +91,8 @@
         }
     }
   uri = ECRS_parseArgvKeywordURI (ectx, num_Words, (const char **) keywords);
-  FREE (keywords);
-  FREE (searchString);
+  GNUNET_free (keywords);
+  GNUNET_free (searchString);
   return uri;
 }
 
@@ -116,7 +116,7 @@
 
   uriString = NULL;
   uriSize = 0;
-  GROW (uriString, uriSize, 4096);
+  GNUNET_array_grow (uriString, uriSize, 4096);
   strcpy (uriString, ECRS_URI_PREFIX);
   strcat (uriString, ECRS_SEARCH_INFIX);
   uriLen = 1 + strlen (ECRS_URI_PREFIX) + strlen (ECRS_SEARCH_INFIX);
@@ -125,7 +125,8 @@
   for (i = 0; i < num_keywords; i++)
     {
       if (uriSize < uriLen + strlen (_("AND")) + 1 + strlen (keywords[i]))
-        GROW (uriString, uriSize, uriSize + 4096 + strlen (keywords[i]));
+        GNUNET_array_grow (uriString, uriSize,
+                           uriSize + 4096 + strlen (keywords[i]));
       if ((i > 0) && (0 == strcmp (keywords[i], _("AND"))))
         {
           strcat (uriString, "+");
@@ -145,7 +146,7 @@
         }
     }
   uri = ECRS_stringToUri (ectx, uriString);
-  GROW (uriString, uriSize, 0);
+  GNUNET_array_grow (uriString, uriSize, 0);
   return uri;
 }
 
@@ -169,7 +170,7 @@
 
   uriString = NULL;
   uriSize = 0;
-  GROW (uriString, uriSize, 4096);
+  GNUNET_array_grow (uriString, uriSize, 4096);
   strcpy (uriString, ECRS_URI_PREFIX);
   strcat (uriString, ECRS_SEARCH_INFIX);
   uriLen = 1 + strlen (ECRS_URI_PREFIX) + strlen (ECRS_SEARCH_INFIX);
@@ -178,7 +179,8 @@
   for (i = 0; i < num_keywords; i++)
     {
       if (uriSize < uriLen + 1 + strlen (keywords[i]))
-        GROW (uriString, uriSize, uriSize + 4096 + strlen (keywords[i]));
+        GNUNET_array_grow (uriString, uriSize,
+                           uriSize + 4096 + strlen (keywords[i]));
       if (i > 0)
         {
           strcat (uriString, "+");
@@ -188,7 +190,7 @@
       uriLen += strlen (keywords[i]);
     }
   uri = ECRS_stringToUri (ectx, uriString);
-  GROW (uriString, uriSize, 0);
+  GNUNET_array_grow (uriString, uriSize, 0);
   return uri;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/indexinfo.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/indexinfo.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/indexinfo.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,27 +32,27 @@
 /**
  * Test if a file is indexed.
  *
- * @return YES if the file is indexed, NO if not, SYSERR on errors
+ * @return GNUNET_YES if the file is indexed, GNUNET_NO if not, GNUNET_SYSERR 
on errors
  *  (i.e. filename could not be accessed and thus we have problems
  *  checking; also possible that the file was modified after indexing;
- *  in either case, if SYSERR is returned the user should probably
+ *  in either case, if GNUNET_SYSERR is returned the user should probably
  *  be notified that 'something is wrong')
  */
 int
 ECRS_isFileIndexed (struct GE_Context *ectx,
                     struct GC_Configuration *cfg, const char *filename)
 {
-  HashCode512 hc;
-  struct ClientServerConnection *sock;
+  GNUNET_HashCode hc;
+  struct GNUNET_ClientServerConnection *sock;
   int ret;
 
-  if (SYSERR == getFileHash (ectx, filename, &hc))
-    return SYSERR;
-  sock = client_connection_create (ectx, cfg);
+  if (GNUNET_SYSERR == GNUNET_hash_file (ectx, filename, &hc))
+    return GNUNET_SYSERR;
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   ret = FS_testIndexed (sock, &hc);
-  connection_destroy (sock);
+  GNUNET_client_connection_destroy (sock);
   return ret;
 }
 
@@ -73,12 +73,12 @@
   unsigned int size;
   int ret;
 
-  fullName = MALLOC (strlen (dir) + strlen (fn) + 4);
+  fullName = GNUNET_malloc (strlen (dir) + strlen (fn) + 4);
   strcpy (fullName, dir);
   strcat (fullName, DIR_SEPARATOR_STR);
   strcat (fullName, fn);
   size = 256;
-  lnkName = MALLOC (size);
+  lnkName = GNUNET_malloc (size);
   while (1)
     {
       ret = READLINK (fullName, lnkName, size - 1);
@@ -88,11 +88,11 @@
             {
               if (size * 2 < size)
                 {
-                  FREE (lnkName);
-                  FREE (fullName);
-                  return OK;    /* error */
+                  GNUNET_free (lnkName);
+                  GNUNET_free (fullName);
+                  return GNUNET_OK;     /* error */
                 }
-              GROW (lnkName, size, size * 2);
+              GNUNET_array_grow (lnkName, size, size * 2);
               continue;
             }
           if (errno != EINVAL)
@@ -101,9 +101,9 @@
                                     GE_WARNING | GE_BULK | GE_ADMIN | GE_USER,
                                     "readlink", fullName);
             }
-          FREE (lnkName);
-          FREE (fullName);
-          return OK;            /* error */
+          GNUNET_free (lnkName);
+          GNUNET_free (fullName);
+          return GNUNET_OK;     /* error */
         }
       else
         {
@@ -112,16 +112,16 @@
         }
     }
   cls->cnt++;
-  if (OK != cls->iterator (lnkName, cls->closure))
+  if (GNUNET_OK != cls->iterator (lnkName, cls->closure))
     {
-      cls->cnt = SYSERR;
-      FREE (fullName);
-      FREE (lnkName);
-      return SYSERR;
+      cls->cnt = GNUNET_SYSERR;
+      GNUNET_free (fullName);
+      GNUNET_free (lnkName);
+      return GNUNET_SYSERR;
     }
-  FREE (fullName);
-  FREE (lnkName);
-  return OK;
+  GNUNET_free (fullName);
+  GNUNET_free (lnkName);
+  return GNUNET_OK;
 }
 
 /**
@@ -134,7 +134,7 @@
  * names will have been lost.  In that case, the iterator
  * will NOT iterate over these files.
  *
- * @return number of files indexed, SYSERR if iterator aborted
+ * @return number of files indexed, GNUNET_SYSERR if iterator aborted
  */
 int
 ECRS_iterateIndexedFiles (struct GE_Context *ectx,
@@ -143,26 +143,26 @@
 {
   char *tmp;
   char *indexDirectory;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   struct iiC cls;
 
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
     return 0;
-  tmp = getConfigurationOptionValue (sock, "FS", "INDEX-DIRECTORY");
-  connection_destroy (sock);
+  tmp = GNUNET_get_daemon_configuration_value (sock, "FS", "INDEX-DIRECTORY");
+  GNUNET_client_connection_destroy (sock);
   if (tmp == NULL)
     {
       return 0;
     }
-  indexDirectory = string_expandFileName (ectx, tmp);
-  FREE (tmp);
+  indexDirectory = GNUNET_expand_file_name (ectx, tmp);
+  GNUNET_free (tmp);
   cls.ectx = ectx;
   cls.iterator = iterator;
   cls.closure = closure;
   cls.cnt = 0;
-  disk_directory_scan (ectx, indexDirectory, &iiHelper, &cls);
-  FREE (indexDirectory);
+  GNUNET_disk_directory_scan (ectx, indexDirectory, &iiHelper, &cls);
+  GNUNET_free (indexDirectory);
   return cls.cnt;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,7 +32,7 @@
 #include "gnunet_protocols.h"
 #include "ecrs.h"
 
-#define DEBUG_KEYSPACE NO
+#define DEBUG_KEYSPACE GNUNET_NO
 
 /**
  * What is the maximum size that we allow for a kblock
@@ -49,28 +49,29 @@
  * queries.  Verifies, decrypts and passes valid
  * replies to the callback.
  *
- * @return SYSERR if the entry is malformed
+ * @return GNUNET_SYSERR if the entry is malformed
  */
 static int
 verifyKBlock (struct GE_Context *ectx,
-              const HashCode512 * key, Datastore_Value * value)
+              const GNUNET_HashCode * key, Datastore_Value * value)
 {
   unsigned int type;
   ECRS_FileInfo fi;
   unsigned int size;
-  HashCode512 query;
+  GNUNET_HashCode query;
   KBlock *kb;
   const char *dstURI;
   int j;
 
   type = ntohl (value->type);
   size = ntohl (value->size) - sizeof (Datastore_Value);
-  if (OK != getQueryFor (size, (DBlock *) & value[1], YES, &query))
-    return SYSERR;
+  if (GNUNET_OK !=
+      getQueryFor (size, (DBlock *) & value[1], GNUNET_YES, &query))
+    return GNUNET_SYSERR;
   GE_ASSERT (ectx, type == K_BLOCK);
 
   if (size < sizeof (KBlock))
-    return SYSERR;
+    return GNUNET_SYSERR;
   kb = (KBlock *) & value[1];
   ECRS_decryptInPlace (key, &kb[1], size - sizeof (KBlock));
   j = sizeof (KBlock);
@@ -79,7 +80,7 @@
   if (j == size)
     {
       GE_BREAK (NULL, 0);       /* kblock malformed */
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   dstURI = (const char *) &kb[1];
   j++;
@@ -88,18 +89,18 @@
   if (fi.meta == NULL)
     {
       GE_BREAK (ectx, 0);       /* kblock malformed */
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   fi.uri = ECRS_stringToUri (ectx, dstURI);
   if (fi.uri == NULL)
     {
       GE_BREAK (ectx, 0);       /* kblock malformed */
       ECRS_freeMetaData (fi.meta);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ECRS_freeUri (fi.uri);
   ECRS_freeMetaData (fi.meta);
-  return OK;
+  return GNUNET_OK;
 }
 
 #endif
@@ -120,35 +121,35 @@
                     const struct ECRS_URI *uri,
                     unsigned int anonymityLevel,
                     unsigned int priority,
-                    cron_t expirationTime,
+                    GNUNET_CronTime expirationTime,
                     const struct ECRS_URI *dst,
                     const struct ECRS_MetaData *md)
 {
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   Datastore_Value *value;
   int ret;
   unsigned int size;
   unsigned int mdsize;
-  struct PrivateKey *pk;
+  struct GNUNET_RSA_PrivateKey *pk;
   char *dstURI;
   KBlock *kb;
   char **keywords;
   unsigned int keywordCount;
   int i;
 #if DEBUG_KEYSPACE
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 #if EXTRA_CHECKS
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 #endif
-  HashCode512 key;
+  GNUNET_HashCode key;
   char *cpy;                    /* copy of the encrypted portion */
   struct ECRS_URI *xuri;
 
   if (!ECRS_isKeywordUri (uri))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   mdsize = ECRS_sizeofMetaData (md, ECRS_SERIALIZE_PART);
   dstURI = ECRS_uriToString (dst);
@@ -156,7 +157,7 @@
   if (size > MAX_KBLOCK_SIZE)
     {
       size = MAX_KBLOCK_SIZE;
-      value = MALLOC (sizeof (Datastore_Value) + size);
+      value = GNUNET_malloc (sizeof (Datastore_Value) + size);
       kb = (KBlock *) & value[1];
       kb->type = htonl (K_BLOCK);
       memcpy (&kb[1], dstURI, strlen (dstURI) + 1);
@@ -169,14 +170,14 @@
       if (mdsize == -1)
         {
           GE_BREAK (ectx, 0);
-          FREE (dstURI);
-          return SYSERR;
+          GNUNET_free (dstURI);
+          return GNUNET_SYSERR;
         }
       size = sizeof (KBlock) + strlen (dstURI) + 1 + mdsize;
     }
   else
     {
-      value = MALLOC (sizeof (Datastore_Value) + size);
+      value = GNUNET_malloc (sizeof (Datastore_Value) + size);
       kb = (KBlock *) & value[1];
       kb->type = htonl (K_BLOCK);
       memcpy (&kb[1], dstURI, strlen (dstURI) + 1);
@@ -192,53 +193,56 @@
   value->type = htonl (K_BLOCK);
   value->prio = htonl (priority);
   value->anonymityLevel = htonl (anonymityLevel);
-  value->expirationTime = htonll (expirationTime);
-  sock = client_connection_create (ectx, cfg);
-  ret = OK;
+  value->expirationTime = GNUNET_htonll (expirationTime);
+  sock = GNUNET_client_connection_create (ectx, cfg);
+  ret = GNUNET_OK;
 
   if (GC_get_configuration_value_yesno (cfg,
                                         "FS",
-                                        "DISABLE-CREATION-TIME", NO) == YES)
+                                        "DISABLE-CREATION-TIME",
+                                        GNUNET_NO) == GNUNET_YES)
     xuri = ECRS_dupUri (uri);
   else
     xuri = ECRS_dateExpandKeywordUri (uri);
   keywords = xuri->data.ksk.keywords;
   keywordCount = xuri->data.ksk.keywordCount;
-  cpy = MALLOC (mdsize + strlen (dstURI) + 1);
+  cpy = GNUNET_malloc (mdsize + strlen (dstURI) + 1);
   memcpy (cpy, &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);
+      GNUNET_hash (keywords[i], strlen (keywords[i]), &key);
 #if DEBUG_KEYSPACE
-      IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (&key, &enc));
-      GE_LOG (ectx,
-              GE_DEBUG | GE_REQUEST | GE_USER,
+      IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+                GNUNET_hash_to_enc (&key, &enc));
+      GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
               "Encrypting KBlock with key %s.\n", &enc);
 #endif
       ECRS_encryptInPlace (&key, &kb[1], mdsize + strlen (dstURI) + 1);
-      pk = makeKblockKey (&key);
-      getPublicKey (pk, &kb->keyspace);
+      pk = GNUNET_RSA_create_key_from_hash (&key);
+      GNUNET_RSA_get_public_key (pk, &kb->keyspace);
       GE_ASSERT (ectx,
-                 OK == sign (pk,
-                             mdsize + strlen (dstURI) + 1,
-                             &kb[1], &kb->signature));
+                 GNUNET_OK == GNUNET_RSA_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));
+      GE_ASSERT (ectx,
+                 GNUNET_OK == getQueryFor (size, (DBlock *) kb, GNUNET_YES,
+                                           &hc));
 #endif
-      freePrivateKey (pk);
-      if (OK != FS_insert (sock, value))
-        ret = SYSERR;
+      GNUNET_RSA_free_key (pk);
+      if (GNUNET_OK != FS_insert (sock, value))
+        ret = GNUNET_SYSERR;
 #if EXTRA_CHECKS
-      GE_ASSERT (ectx, OK == verifyKBlock (ectx, &key, value))
+      GE_ASSERT (ectx, GNUNET_OK == verifyKBlock (ectx, &key, value))
 #endif
     }
   ECRS_freeUri (xuri);
-  FREE (cpy);
-  FREE (dstURI);
-  connection_destroy (sock);
-  FREE (value);
+  GNUNET_free (cpy);
+  GNUNET_free (dstURI);
+  GNUNET_client_connection_destroy (sock);
+  GNUNET_free (value);
   return ret;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/meta.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/meta.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/meta.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -38,7 +38,7 @@
 ECRS_createMetaData ()
 {
   MetaData *ret;
-  ret = MALLOC (sizeof (MetaData));
+  ret = GNUNET_malloc (sizeof (MetaData));
   ret->items = NULL;
   ret->itemCount = 0;
   return ret;
@@ -52,9 +52,9 @@
 {
   int i;
   for (i = 0; i < md->itemCount; i++)
-    FREE (md->items[i].data);
-  GROW (md->items, md->itemCount, 0);
-  FREE (md);
+    GNUNET_free (md->items[i].data);
+  GNUNET_array_grow (md->items, md->itemCount, 0);
+  GNUNET_free (md);
 }
 
 /**
@@ -65,18 +65,18 @@
 ECRS_addPublicationDateToMetaData (MetaData * md)
 {
   char *dat;
-  TIME_T t;
+  GNUNET_Int32Time t;
 
-  TIME (&t);
+  GNUNET_get_time_int32 (&t);
   ECRS_delFromMetaData (md, EXTRACTOR_PUBLICATION_DATE, NULL);
-  dat = GN_CTIME (&t);
+  dat = GNUNET_int32_time_to_string (&t);
   ECRS_addToMetaData (md, EXTRACTOR_PUBLICATION_DATE, dat);
-  FREE (dat);
+  GNUNET_free (dat);
 }
 
 /**
  * Extend metadata.
- * @return OK on success, SYSERR if this entry already exists
+ * @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists
  */
 int
 ECRS_addToMetaData (MetaData * md,
@@ -89,39 +89,39 @@
     {
       if ((md->items[idx].type == type) &&
           (0 == strcmp (md->items[idx].data, data)))
-        return SYSERR;
+        return GNUNET_SYSERR;
     }
   idx = md->itemCount;
-  GROW (md->items, md->itemCount, md->itemCount + 1);
+  GNUNET_array_grow (md->items, md->itemCount, md->itemCount + 1);
   md->items[idx].type = type;
-  md->items[idx].data = STRDUP (data);
-  return OK;
+  md->items[idx].data = GNUNET_strdup (data);
+  return GNUNET_OK;
 }
 
 /**
  * Remove an item.
- * @return OK on success, SYSERR if the item does not exist in md
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md
  */
 int
 ECRS_delFromMetaData (MetaData * md,
                       EXTRACTOR_KeywordType type, const char *data)
 {
   int idx;
-  int ret = SYSERR;
+  int ret = GNUNET_SYSERR;
   for (idx = 0; idx < md->itemCount; idx++)
     {
       if ((md->items[idx].type == type) &&
           ((data == NULL) || (0 == strcmp (md->items[idx].data, data))))
         {
-          FREE (md->items[idx].data);
+          GNUNET_free (md->items[idx].data);
           md->items[idx] = md->items[md->itemCount - 1];
-          GROW (md->items, md->itemCount, md->itemCount - 1);
+          GNUNET_array_grow (md->items, md->itemCount, md->itemCount - 1);
           if (data == NULL)
             {
-              ret = OK;
+              ret = GNUNET_OK;
               continue;
             }
-          return OK;
+          return GNUNET_OK;
         }
     }
   return ret;
@@ -145,9 +145,9 @@
       if (md->items[i].type != EXTRACTOR_THUMBNAIL_DATA)
         {
           if ((iterator != NULL) &&
-              (OK != iterator (md->items[i].type,
-                               md->items[i].data, closure)))
-            return SYSERR;
+              (GNUNET_OK != iterator (md->items[i].type,
+                                      md->items[i].data, closure)))
+            return GNUNET_SYSERR;
         }
       else
         sub++;
@@ -167,7 +167,7 @@
 
   for (i = md->itemCount - 1; i >= 0; i--)
     if (type == md->items[i].type)
-      return STRDUP (md->items[i].data);
+      return GNUNET_strdup (md->items[i].data);
   return NULL;
 }
 
@@ -264,12 +264,12 @@
     return 0;
   if (strlen (encoded) == 0)
     {
-      FREE (encoded);
+      GNUNET_free (encoded);
       return 0;                 /* invalid */
     }
   *thumb = NULL;
   ret = decodeThumbnail (encoded, thumb, &size);
-  FREE (encoded);
+  GNUNET_free (encoded);
   if (ret == 0)
     return size;
   else
@@ -296,7 +296,7 @@
 /**
  * Extract meta-data from a file.
  *
- * @return SYSERR on error, otherwise the number
+ * @return GNUNET_SYSERR on error, otherwise the number
  *   of meta-data items obtained
  */
 int
@@ -310,7 +310,7 @@
   int ret;
 
   if (filename == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (extractors == NULL)
     return 0;
   head = EXTRACTOR_getKeywords (extractors, filename);
@@ -320,7 +320,8 @@
   ret = 0;
   while (pos != NULL)
     {
-      if (OK == ECRS_addToMetaData (md, pos->keywordType, pos->keyword))
+      if (GNUNET_OK ==
+          ECRS_addToMetaData (md, pos->keywordType, pos->keyword))
         ret++;
       pos = pos->next;
     }
@@ -341,18 +342,18 @@
   /* documentation says 100.1% oldSize + 12 bytes, but we
      should be able to overshoot by more to be safe */
 #endif
-  tmp = MALLOC (dlen);
+  tmp = GNUNET_malloc (dlen);
   if (Z_OK == compress2 ((Bytef *) tmp,
                          &dlen, (const Bytef *) data, oldSize, 9))
     {
       if (dlen < oldSize)
         {
           memcpy (data, tmp, dlen);
-          FREE (tmp);
+          GNUNET_free (tmp);
           return dlen;
         }
     }
-  FREE (tmp);
+  GNUNET_free (tmp);
   return oldSize;
 }
 
@@ -371,7 +372,7 @@
   uLongf olen;
 
   olen = outputSize;
-  output = MALLOC (olen);
+  output = GNUNET_malloc (olen);
   if (Z_OK == uncompress ((Bytef *) output,
                           &olen, (const Bytef *) input, inputSize))
     {
@@ -379,7 +380,7 @@
     }
   else
     {
-      FREE (output);
+      GNUNET_free (output);
       return NULL;
     }
 }
@@ -428,9 +429,9 @@
  * @param size maximum number of bytes available
  * @param part is it ok to just write SOME of the
  *        meta-data to match the size constraint,
- *        possibly discarding some data? YES/NO.
+ *        possibly discarding some data? GNUNET_YES/GNUNET_NO.
  * @return number of bytes written on success,
- *         SYSERR on error (typically: not enough
+ *         GNUNET_SYSERR on error (typically: not enough
  *         space)
  */
 int
@@ -446,7 +447,7 @@
   unsigned int ic;
 
   if (max < sizeof (MetaDataHeader))
-    return SYSERR;              /* far too small */
+    return GNUNET_SYSERR;       /* far too small */
   ic = md->itemCount;
   hdr = NULL;
   while (1)
@@ -457,7 +458,7 @@
         size += 1 + strlen (md->items[i].data);
       while (size % 8 != 0)
         size++;
-      hdr = MALLOC (size);
+      hdr = GNUNET_malloc (size);
       hdr->version = htonl (0);
       hdr->entries = htonl (ic);
       for (i = 0; i < ic; i++)
@@ -489,12 +490,12 @@
         }
       if (size <= max)
         break;
-      FREE (hdr);
+      GNUNET_free (hdr);
       hdr = NULL;
 
       if ((part & ECRS_SERIALIZE_PART) == 0)
         {
-          return SYSERR;        /* does not fit! */
+          return GNUNET_SYSERR; /* does not fit! */
         }
       /* partial serialization ok, try again with less meta-data */
       if (size > 2 * max)
@@ -504,7 +505,7 @@
     }
   GE_ASSERT (ectx, size <= max);
   memcpy (target, hdr, size);
-  FREE (hdr);
+  GNUNET_free (hdr);
   /* extra check: deserialize! */
 #if EXTRA_CHECKS
   {
@@ -539,7 +540,7 @@
     size += 1 + strlen (md->items[i].data);
   while (size % 8 != 0)
     size++;
-  hdr = MALLOC (size);
+  hdr = GNUNET_malloc (size);
   hdr->version = htonl (0);
   hdr->entries = htonl (md->itemCount);
   for (i = 0; i < ic; i++)
@@ -563,7 +564,7 @@
   if (pos < size - sizeof (MetaDataHeader))
     size = pos + sizeof (MetaDataHeader);
 
-  FREE (hdr);
+  GNUNET_free (hdr);
 
   return size;
 }
@@ -637,7 +638,7 @@
     }
 
   md = ECRS_createMetaData ();
-  GROW (md->items, md->itemCount, ic);
+  GNUNET_array_grow (md->items, md->itemCount, ic);
   i = 0;
   pos = sizeof (unsigned int) * ic;
   while ((pos < dataSize) && (i < ic))
@@ -645,7 +646,7 @@
       len = strlen (&data[pos]) + 1;
       md->items[i].type = (EXTRACTOR_KeywordType)
         ntohl (MAKE_UNALIGNED (((unsigned int *) data)[i]));
-      md->items[i].data = STRDUP (&data[pos]);
+      md->items[i].data = GNUNET_strdup (&data[pos]);
       pos += len;
       i++;
     }
@@ -655,11 +656,11 @@
       goto FAILURE;
     }
   if (compressed)
-    FREE (data);
+    GNUNET_free (data);
   return md;
 FAILURE:
   if (compressed)
-    FREE (data);
+    GNUNET_free (data);
   return NULL;                  /* size too small */
 }
 
@@ -677,12 +678,12 @@
       if (md->items[i].type == EXTRACTOR_MIMETYPE)
         {
           if (0 == strcmp (md->items[i].data, GNUNET_DIRECTORY_MIME))
-            return YES;
+            return GNUNET_YES;
           else
-            return NO;
+            return GNUNET_NO;
         }
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 static char *mimeMap[][2] = {
@@ -770,7 +771,7 @@
   char *ret;
   struct stat filestat;
 
-  path = STRDUP (filename);
+  path = GNUNET_strdup (filename);
   i = strlen (path);
   while ((i > 0) && (path[i] != DIR_SEPARATOR))
     i--;
@@ -820,13 +821,13 @@
              (filename[i] != '.') && (filename[i] != DIR_SEPARATOR))
         i--;
       if (filename[i] == '.')
-        mime = STRDUP (&filename[i]);
+        mime = GNUNET_strdup (&filename[i]);
     }
   if (mime == NULL)
     {
       renameTo =
-        MALLOC (strlen (path) + strlen (key) + strlen (DIR_SEPARATOR_STR) +
-                20);
+        GNUNET_malloc (strlen (path) + strlen (key) +
+                       strlen (DIR_SEPARATOR_STR) + 20);
       strcpy (renameTo, path);
       if (path[strlen (path) - 1] != DIR_SEPARATOR)
         strcat (renameTo, DIR_SEPARATOR_STR);
@@ -835,8 +836,8 @@
   else
     {
       renameTo =
-        MALLOC (strlen (path) + strlen (key) + strlen (mime) +
-                strlen (DIR_SEPARATOR_STR) + 20);
+        GNUNET_malloc (strlen (path) + strlen (key) + strlen (mime) +
+                       strlen (DIR_SEPARATOR_STR) + 20);
       strcpy (renameTo, path);
       if (path[strlen (path) - 1] != DIR_SEPARATOR)
         strcat (renameTo, DIR_SEPARATOR_STR);
@@ -862,7 +863,7 @@
           j = 0;
           do
             {
-              SNPRINTF (&renameTo[i], 19, ".%u", j++);
+              GNUNET_snprintf (&renameTo[i], 19, ".%u", j++);
               if (j > 100000)
                 break;
             }
@@ -876,7 +877,7 @@
                     _("Renaming of file `%s' to `%s' failed: %s\n"),
                     filename, renameTo, STRERROR (errno));
           else
-            ret = STRDUP (renameTo);
+            ret = GNUNET_strdup (renameTo);
         }
       else
         {
@@ -885,8 +886,8 @@
                   filename, renameTo);
         }
     }
-  FREE (path);
-  FREE (renameTo);
+  GNUNET_free (path);
+  GNUNET_free (renameTo);
   EXTRACTOR_freeKeywords (list);
   EXTRACTOR_removeAll (l);
   return ret;
@@ -904,18 +905,18 @@
   int found;
 
   if (md1->itemCount != md2->itemCount)
-    return NO;
+    return GNUNET_NO;
   for (i = 0; i < md1->itemCount; i++)
     {
-      found = NO;
+      found = GNUNET_NO;
       for (j = 0; j < md2->itemCount; j++)
         if ((md1->items[i].type == md2->items[j].type) &&
             (0 == strcmp (md1->items[i].data, md2->items[j].data)))
-          found = YES;
-      if (found == NO)
-        return NO;
+          found = GNUNET_YES;
+      if (found == GNUNET_NO)
+        return GNUNET_NO;
     }
-  return YES;
+  return GNUNET_YES;
 }
 
 

Modified: GNUnet/src/applications/fs/ecrs/metatest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/metatest.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/metatest.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -41,68 +41,68 @@
   unsigned int size;
 
   m = ECRS_createMetaData ();
-  if (OK != ECRS_addToMetaData (m, EXTRACTOR_TITLE, "TestTitle"))
+  if (GNUNET_OK != ECRS_addToMetaData (m, EXTRACTOR_TITLE, "TestTitle"))
     ABORT (m);
-  if (OK != ECRS_addToMetaData (m, EXTRACTOR_AUTHOR, "TestTitle"))
+  if (GNUNET_OK != ECRS_addToMetaData (m, EXTRACTOR_AUTHOR, "TestTitle"))
     ABORT (m);
-  if (OK == ECRS_addToMetaData (m, EXTRACTOR_TITLE, "TestTitle"))       /* 
dup! */
+  if (GNUNET_OK == ECRS_addToMetaData (m, EXTRACTOR_TITLE, "TestTitle"))       
 /* dup! */
     ABORT (m);
-  if (OK == ECRS_addToMetaData (m, EXTRACTOR_AUTHOR, "TestTitle"))      /* 
dup! */
+  if (GNUNET_OK == ECRS_addToMetaData (m, EXTRACTOR_AUTHOR, "TestTitle"))      
 /* dup! */
     ABORT (m);
   if (2 != ECRS_getMetaData (m, NULL, NULL))
     ABORT (m);
-  if (OK != ECRS_delFromMetaData (m, EXTRACTOR_AUTHOR, "TestTitle"))
+  if (GNUNET_OK != ECRS_delFromMetaData (m, EXTRACTOR_AUTHOR, "TestTitle"))
     ABORT (m);
-  if (OK == ECRS_delFromMetaData (m, EXTRACTOR_AUTHOR, "TestTitle"))    /* 
already gone */
+  if (GNUNET_OK == ECRS_delFromMetaData (m, EXTRACTOR_AUTHOR, "TestTitle"))    
 /* already gone */
     ABORT (m);
   if (1 != ECRS_getMetaData (m, NULL, NULL))
     ABORT (m);
-  if (OK != ECRS_delFromMetaData (m, EXTRACTOR_TITLE, "TestTitle"))
+  if (GNUNET_OK != ECRS_delFromMetaData (m, EXTRACTOR_TITLE, "TestTitle"))
     ABORT (m);
-  if (OK == ECRS_delFromMetaData (m, EXTRACTOR_TITLE, "TestTitle"))     /* 
already gone */
+  if (GNUNET_OK == ECRS_delFromMetaData (m, EXTRACTOR_TITLE, "TestTitle"))     
 /* already gone */
     ABORT (m);
   if (0 != ECRS_getMetaData (m, NULL, NULL))
     ABORT (m);
-  val = MALLOC (256);
+  val = GNUNET_malloc (256);
   for (j = 0; j < i; j++)
     {
-      SNPRINTF (val, 256, "%s.%d",
-                "A teststring that should compress well.", j);
-      if (OK != ECRS_addToMetaData (m, EXTRACTOR_UNKNOWN, val))
+      GNUNET_snprintf (val, 256, "%s.%d",
+                       "A teststring that should compress well.", j);
+      if (GNUNET_OK != ECRS_addToMetaData (m, EXTRACTOR_UNKNOWN, val))
         {
-          FREE (val);
+          GNUNET_free (val);
           ABORT (m);
         }
     }
-  FREE (val);
+  GNUNET_free (val);
   if (i != ECRS_getMetaData (m, NULL, NULL))
     ABORT (m);
 
   size = ECRS_sizeofMetaData (m, ECRS_SERIALIZE_FULL);
-  val = MALLOC (size);
+  val = GNUNET_malloc (size);
   if (size != ECRS_serializeMetaData (NULL,
                                       m, val, size, ECRS_SERIALIZE_FULL))
     {
-      FREE (val);
+      GNUNET_free (val);
       ABORT (m);
     }
   ECRS_freeMetaData (m);
   m = ECRS_deserializeMetaData (NULL, val, size);
-  FREE (val);
+  GNUNET_free (val);
   if (m == NULL)
     ABORT (m);
-  val = MALLOC (256);
+  val = GNUNET_malloc (256);
   for (j = 0; j < i; j++)
     {
-      SNPRINTF (val, 256, "%s.%d",
-                "A teststring that should compress well.", j);
-      if (OK != ECRS_delFromMetaData (m, EXTRACTOR_UNKNOWN, val))
+      GNUNET_snprintf (val, 256, "%s.%d",
+                       "A teststring that should compress well.", j);
+      if (GNUNET_OK != ECRS_delFromMetaData (m, EXTRACTOR_UNKNOWN, val))
         {
-          FREE (val);
+          GNUNET_free (val);
           ABORT (m);
         }
     }
-  FREE (val);
+  GNUNET_free (val);
   if (0 != ECRS_getMetaData (m, NULL, NULL))
     {
       ABORT (m);
@@ -123,21 +123,21 @@
   meta = ECRS_createMetaData ();
   for (q = 0; q <= i; q++)
     {
-      SNPRINTF (txt, 128, "%u -- %u\n", i, q);
+      GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
       ECRS_addToMetaData (meta,
                           q % EXTRACTOR_getHighestKeywordTypeNumber (), txt);
     }
   size = ECRS_sizeofMetaData (meta, ECRS_SERIALIZE_FULL);
-  data = MALLOC (size * 4);
+  data = GNUNET_malloc (size * 4);
   if (size != ECRS_serializeMetaData (NULL,
                                       meta,
                                       data, size * 4, ECRS_SERIALIZE_FULL))
     {
-      FREE (data);
+      GNUNET_free (data);
       ABORT (meta);
     }
   ECRS_freeMetaData (meta);
-  FREE (data);
+  GNUNET_free (data);
   return 0;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/metatest2.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/metatest2.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/metatest2.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -40,28 +40,28 @@
   unsigned int size;
 
   m = ECRS_createMetaData ();
-  if (OK != ECRS_addToMetaData (m, EXTRACTOR_UNKNOWN, "link"))
+  if (GNUNET_OK != ECRS_addToMetaData (m, EXTRACTOR_UNKNOWN, "link"))
     {
       ECRS_freeMetaData (m);
       ABORT ();
     }
-  if (OK != ECRS_addToMetaData (m, EXTRACTOR_FILENAME, "lib-link.m4"))
+  if (GNUNET_OK != ECRS_addToMetaData (m, EXTRACTOR_FILENAME, "lib-link.m4"))
     {
       ECRS_freeMetaData (m);
       ABORT ();
     }
   size = ECRS_sizeofMetaData (m, ECRS_SERIALIZE_FULL);
-  val = MALLOC (size);
+  val = GNUNET_malloc (size);
   if (size != ECRS_serializeMetaData (NULL,
                                       m, val, size, ECRS_SERIALIZE_FULL))
     {
       ECRS_freeMetaData (m);
-      FREE (val);
+      GNUNET_free (val);
       ABORT ();
     }
   ECRS_freeMetaData (m);
   m = ECRS_deserializeMetaData (NULL, val, size);
-  FREE (val);
+  GNUNET_free (val);
   if (m == NULL)
     ABORT ();
   ECRS_freeMetaData (m);

Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -48,15 +48,15 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &fileName);
-  gnHome = string_expandFileName (ectx, fileName);
-  FREE (fileName);
+  gnHome = GNUNET_expand_file_name (ectx, fileName);
+  GNUNET_free (fileName);
   fileName =
-    MALLOC (strlen (gnHome) + strlen (PSEUDODIR) + strlen (name) + 2);
+    GNUNET_malloc (strlen (gnHome) + strlen (PSEUDODIR) + strlen (name) + 2);
   strcpy (fileName, gnHome);
-  FREE (gnHome);
+  GNUNET_free (gnHome);
   strcat (fileName, DIR_SEPARATOR_STR);
   strcat (fileName, PSEUDODIR);
-  disk_directory_create (ectx, fileName);
+  GNUNET_disk_directory_create (ectx, fileName);
   strcat (fileName, name);
   return fileName;
 }
@@ -64,7 +64,7 @@
 /**
  * Delete a local namespace.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
 ECRS_deleteNamespace (struct GE_Context *ectx,
@@ -73,21 +73,21 @@
   char *fileName;
 
   fileName = getPseudonymFileName (ectx, cfg, name);
-  if (YES != disk_file_test (ectx, fileName))
+  if (GNUNET_YES != GNUNET_disk_file_test (ectx, fileName))
     {
-      FREE (fileName);
-      return SYSERR;            /* no such namespace */
+      GNUNET_free (fileName);
+      return GNUNET_SYSERR;     /* no such namespace */
     }
   if (0 != UNLINK (fileName))
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_USER | GE_BULK,
                             "unlink", fileName);
-      FREE (fileName);
-      return SYSERR;
+      GNUNET_free (fileName);
+      return GNUNET_SYSERR;
     }
-  FREE (fileName);
-  return OK;
+  GNUNET_free (fileName);
+  return GNUNET_OK;
 }
 
 /**
@@ -108,7 +108,7 @@
  * @param rootURI set to the URI of the namespace, NULL if
  *        no advertisement was created
  *
- * @return OK on success, SYSERR on error (namespace already exists)
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error (namespace already 
exists)
  */
 struct ECRS_URI *
 ECRS_createNamespace (struct GE_Context *ectx,
@@ -117,23 +117,23 @@
                       const struct ECRS_MetaData *meta,
                       unsigned int anonymityLevel,
                       unsigned int priority,
-                      cron_t expiration,
+                      GNUNET_CronTime expiration,
                       const struct ECRS_URI *advertisementURI,
-                      const HashCode512 * rootEntry)
+                      const GNUNET_HashCode * rootEntry)
 {
   struct ECRS_URI *rootURI;
   char *fileName;
-  struct PrivateKey *hk;
-  PrivateKeyEncoded *hke;
+  struct GNUNET_RSA_PrivateKey *hk;
+  GNUNET_RSA_PrivateKeyEncoded *hke;
   char *dst;
   unsigned short len;
-  HashCode512 hc;
-  struct ClientServerConnection *sock;
+  GNUNET_HashCode hc;
+  struct GNUNET_ClientServerConnection *sock;
   Datastore_Value *value;
   Datastore_Value *knvalue;
   unsigned int size;
   unsigned int mdsize;
-  struct PrivateKey *pk;
+  struct GNUNET_RSA_PrivateKey *pk;
   NBlock *nb;
   KNBlock *knb;
   char **keywords;
@@ -147,22 +147,22 @@
       return NULL;
     }
   fileName = getPseudonymFileName (ectx, cfg, name);
-  if (YES == disk_file_test (ectx, fileName))
+  if (GNUNET_YES == GNUNET_disk_file_test (ectx, fileName))
     {
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("Cannot create pseudonym `%s', file `%s' exists.\n"),
               name, fileName);
-      FREE (fileName);
+      GNUNET_free (fileName);
       return NULL;
     }
-  hk = makePrivateKey ();
-  hke = encodePrivateKey (hk);
+  hk = GNUNET_RSA_create_key ();
+  hke = GNUNET_RSA_encode_key (hk);
   len = ntohs (hke->len);
   dst = (char *) hke;
-  disk_file_write (ectx, fileName, dst, len, "600");
-  FREE (fileName);
-  FREE (dst);
+  GNUNET_disk_file_write (ectx, fileName, dst, len, "600");
+  GNUNET_free (fileName);
+  GNUNET_free (dst);
 
   /* create advertisements */
 
@@ -171,7 +171,7 @@
   if (size > MAX_NBLOCK_SIZE)
     {
       size = MAX_NBLOCK_SIZE;
-      value = MALLOC (sizeof (Datastore_Value) + size);
+      value = GNUNET_malloc (sizeof (Datastore_Value) + size);
       nb = (NBlock *) & value[1];
       nb->type = htonl (N_BLOCK);
       mdsize = size - sizeof (NBlock);
@@ -183,14 +183,14 @@
         {
           GE_BREAK (ectx, 0);
           ECRS_deleteNamespace (ectx, cfg, name);
-          freePrivateKey (hk);
+          GNUNET_RSA_free_key (hk);
           return NULL;
         }
       size = sizeof (NBlock) + mdsize;
     }
   else
     {
-      value = MALLOC (sizeof (Datastore_Value) + size);
+      value = GNUNET_malloc (sizeof (Datastore_Value) + size);
       nb = (NBlock *) & value[1];
       nb->type = htonl (N_BLOCK);
       ECRS_serializeMetaData (ectx,
@@ -201,14 +201,14 @@
   value->type = htonl (N_BLOCK);
   value->prio = htonl (priority);
   value->anonymityLevel = htonl (anonymityLevel);
-  value->expirationTime = htonll (expiration);
-  sock = client_connection_create (ectx, cfg);
+  value->expirationTime = GNUNET_htonll (expiration);
+  sock = GNUNET_client_connection_create (ectx, cfg);
 
   /* publish NBlock */
-  memset (&nb->identifier, 0, sizeof (HashCode512));
-  getPublicKey (hk, &nb->subspace);
-  hash (&nb->subspace, sizeof (PublicKey), &nb->namespace);
-  rootURI = MALLOC (sizeof (URI));
+  memset (&nb->identifier, 0, sizeof (GNUNET_HashCode));
+  GNUNET_RSA_get_public_key (hk, &nb->subspace);
+  GNUNET_hash (&nb->subspace, sizeof (GNUNET_RSA_PublicKey), &nb->namespace);
+  rootURI = GNUNET_malloc (sizeof (URI));
   rootURI->type = sks;
   rootURI->data.sks.namespace = nb->namespace;
   rootURI->data.sks.identifier = *rootEntry;
@@ -216,16 +216,17 @@
   nb->rootEntry = *rootEntry;
 
   GE_ASSERT (ectx,
-             OK == sign (hk,
-                         mdsize + 3 * sizeof (HashCode512),
-                         &nb->identifier, &nb->signature));
-  if (OK != FS_insert (sock, value))
+             GNUNET_OK == GNUNET_RSA_sign (hk,
+                                           mdsize +
+                                           3 * sizeof (GNUNET_HashCode),
+                                           &nb->identifier, &nb->signature));
+  if (GNUNET_OK != FS_insert (sock, value))
     {
       GE_BREAK (ectx, 0);
-      FREE (rootURI);
-      FREE (value);
-      connection_destroy (sock);
-      freePrivateKey (hk);
+      GNUNET_free (rootURI);
+      GNUNET_free (value);
+      GNUNET_client_connection_destroy (sock);
+      GNUNET_RSA_free_key (hk);
       ECRS_deleteNamespace (ectx, cfg, name);
       return NULL;
     }
@@ -233,7 +234,7 @@
 
   /* publish KNBlocks */
   size += sizeof (KNBlock) - sizeof (NBlock);
-  knvalue = MALLOC (sizeof (Datastore_Value) + size);
+  knvalue = GNUNET_malloc (sizeof (Datastore_Value) + size);
   *knvalue = *value;
   knvalue->type = htonl (KN_BLOCK);
   knvalue->size = htonl (sizeof (Datastore_Value) + size);
@@ -245,14 +246,14 @@
     {
       keywords = advertisementURI->data.ksk.keywords;
       keywordCount = advertisementURI->data.ksk.keywordCount;
-      cpy = MALLOC (size - sizeof (KBlock) - sizeof (unsigned int));
+      cpy = GNUNET_malloc (size - sizeof (KBlock) - sizeof (unsigned int));
       memcpy (cpy,
               &knb->nblock, size - sizeof (KBlock) - sizeof (unsigned int));
       for (i = 0; i < keywordCount; i++)
         {
-          hash (keywords[i], strlen (keywords[i]), &hc);
-          pk = makeKblockKey (&hc);
-          getPublicKey (pk, &knb->kblock.keyspace);
+          GNUNET_hash (keywords[i], strlen (keywords[i]), &hc);
+          pk = GNUNET_RSA_create_key_from_hash (&hc);
+          GNUNET_RSA_get_public_key (pk, &knb->kblock.keyspace);
           GE_ASSERT (ectx, size - sizeof (KBlock) - sizeof (unsigned int)
                      == sizeof (NBlock) + mdsize);
           ECRS_encryptInPlace (&hc,
@@ -261,33 +262,34 @@
                                sizeof (unsigned int));
 
           GE_ASSERT (ectx,
-                     OK == sign (pk,
-                                 sizeof (NBlock) + mdsize,
-                                 &knb->nblock, &knb->kblock.signature));
+                     GNUNET_OK == GNUNET_RSA_sign (pk,
+                                                   sizeof (NBlock) + mdsize,
+                                                   &knb->nblock,
+                                                   &knb->kblock.signature));
           /* extra check: verify sig */
-          freePrivateKey (pk);
-          if (OK != FS_insert (sock, knvalue))
+          GNUNET_RSA_free_key (pk);
+          if (GNUNET_OK != FS_insert (sock, knvalue))
             {
               GE_BREAK (ectx, 0);
-              FREE (rootURI);
+              GNUNET_free (rootURI);
               ECRS_deleteNamespace (ectx, cfg, name);
-              FREE (cpy);
-              FREE (knvalue);
-              FREE (value);
-              connection_destroy (sock);
-              freePrivateKey (hk);
+              GNUNET_free (cpy);
+              GNUNET_free (knvalue);
+              GNUNET_free (value);
+              GNUNET_client_connection_destroy (sock);
+              GNUNET_RSA_free_key (hk);
               return NULL;
             }
           /* restore nblock to avoid re-encryption! */
           memcpy (&knb->nblock,
                   cpy, size - sizeof (KBlock) - sizeof (unsigned int));
         }
-      FREE (cpy);
+      GNUNET_free (cpy);
     }
-  FREE (knvalue);
-  FREE (value);
-  connection_destroy (sock);
-  freePrivateKey (hk);
+  GNUNET_free (knvalue);
+  GNUNET_free (value);
+  GNUNET_client_connection_destroy (sock);
+  GNUNET_RSA_free_key (hk);
 
   return rootURI;
 }
@@ -297,58 +299,59 @@
  * Check if the given namespace exists (locally).
  * @param hc if non-null, also check that this is the
  *   hc of the public key
- * @return OK if the namespace exists, SYSERR if not
+ * @return GNUNET_OK if the namespace exists, GNUNET_SYSERR if not
  */
 int
 ECRS_testNamespaceExists (struct GE_Context *ectx,
                           struct GC_Configuration *cfg,
-                          const char *name, const HashCode512 * hc)
+                          const char *name, const GNUNET_HashCode * hc)
 {
-  struct PrivateKey *hk;
+  struct GNUNET_RSA_PrivateKey *hk;
   char *fileName;
-  PrivateKeyEncoded *hke;
+  GNUNET_RSA_PrivateKeyEncoded *hke;
   char *dst;
   unsigned long long len;
-  HashCode512 namespace;
-  PublicKey pk;
+  GNUNET_HashCode namespace;
+  GNUNET_RSA_PublicKey pk;
 
   /* FIRST: read and decrypt pseudonym! */
   fileName = getPseudonymFileName (ectx, cfg, name);
-  if (OK != disk_file_size (ectx, fileName, &len, YES))
+  if (GNUNET_OK != GNUNET_disk_file_size (ectx, fileName, &len, GNUNET_YES))
     {
-      FREE (fileName);
-      return SYSERR;
+      GNUNET_free (fileName);
+      return GNUNET_SYSERR;
     }
   if (len < 2)
     {
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _("File `%s' does not contain a pseudonym.\n"), fileName);
-      FREE (fileName);
-      return SYSERR;
+      GNUNET_free (fileName);
+      return GNUNET_SYSERR;
     }
-  dst = MALLOC (len);
-  len = disk_file_read (ectx, fileName, len, dst);
-  FREE (fileName);
-  hke = (PrivateKeyEncoded *) dst;
+  dst = GNUNET_malloc (len);
+  len = GNUNET_disk_file_read (ectx, fileName, len, dst);
+  GNUNET_free (fileName);
+  hke = (GNUNET_RSA_PrivateKeyEncoded *) dst;
   if (ntohs (hke->len) != len)
     {
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("Format of pseudonym `%s' is invalid.\n"), name);
-      FREE (hke);
-      return SYSERR;
+      GNUNET_free (hke);
+      return GNUNET_SYSERR;
     }
-  hk = decodePrivateKey (hke);
-  FREE (hke);
+  hk = GNUNET_RSA_decode_key (hke);
+  GNUNET_free (hke);
   if (hk == NULL)
-    return SYSERR;
-  getPublicKey (hk, &pk);
-  freePrivateKey (hk);
-  hash (&pk, sizeof (PublicKey), &namespace);
-  if ((hc == NULL) || (equalsHashCode512 (hc, &namespace)))
-    return OK;
+    return GNUNET_SYSERR;
+  GNUNET_RSA_get_public_key (hk, &pk);
+  GNUNET_RSA_free_key (hk);
+  GNUNET_hash (&pk, sizeof (GNUNET_RSA_PublicKey), &namespace);
+  if ((hc == NULL)
+      || (0 == memcmp (hc, &namespace, sizeof (GNUNET_HashCode))))
+    return GNUNET_OK;
   else
-    return SYSERR;
+    return GNUNET_SYSERR;
 }
 
 /**
@@ -366,58 +369,58 @@
                      const char *name,
                      unsigned int anonymityLevel,
                      unsigned int priority,
-                     cron_t expiration,
-                     TIME_T creationTime,
-                     TIME_T updateInterval,
-                     const HashCode512 * thisId,
-                     const HashCode512 * nextId,
+                     GNUNET_CronTime expiration,
+                     GNUNET_Int32Time creationTime,
+                     GNUNET_Int32Time updateInterval,
+                     const GNUNET_HashCode * thisId,
+                     const GNUNET_HashCode * nextId,
                      const struct ECRS_URI *dstU,
                      const struct ECRS_MetaData *md)
 {
   struct ECRS_URI *uri;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   Datastore_Value *value;
   unsigned int size;
   unsigned int mdsize;
-  struct PrivateKey *hk;
+  struct GNUNET_RSA_PrivateKey *hk;
   SBlock *sb;
-  HashCode512 namespace;
+  GNUNET_HashCode namespace;
   char *dstURI;
   char *destPos;
   char *fileName;
-  PrivateKeyEncoded *hke;
+  GNUNET_RSA_PrivateKeyEncoded *hke;
   char *dst;
   unsigned long long len;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
   int ret;
 
   /* FIRST: read pseudonym! */
   fileName = getPseudonymFileName (ectx, cfg, name);
-  if (OK != disk_file_size (ectx, fileName, &len, YES))
+  if (GNUNET_OK != GNUNET_disk_file_size (ectx, fileName, &len, GNUNET_YES))
     {
-      FREE (fileName);
+      GNUNET_free (fileName);
       return NULL;
     }
   if (len < 2)
     {
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _("File `%s' does not contain a pseudonym.\n"), fileName);
-      FREE (fileName);
+      GNUNET_free (fileName);
       return NULL;
     }
-  dst = MALLOC (len);
-  len = disk_file_read (ectx, fileName, len, dst);
-  FREE (fileName);
-  hke = (PrivateKeyEncoded *) dst;
+  dst = GNUNET_malloc (len);
+  len = GNUNET_disk_file_read (ectx, fileName, len, dst);
+  GNUNET_free (fileName);
+  hke = (GNUNET_RSA_PrivateKeyEncoded *) dst;
   if (ntohs (hke->len) != len)
     {
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _("Format of pseudonym `%s' is invalid.\n"), name);
-      FREE (hke);
+      GNUNET_free (hke);
       return NULL;
     }
-  hk = decodePrivateKey (hke);
-  FREE (hke);
+  hk = GNUNET_RSA_decode_key (hke);
+  GNUNET_free (hke);
   if (hk == NULL)
     return NULL;
 
@@ -428,7 +431,7 @@
   if (size > MAX_SBLOCK_SIZE)
     {
       size = MAX_SBLOCK_SIZE;
-      value = MALLOC (sizeof (Datastore_Value) + size);
+      value = GNUNET_malloc (sizeof (Datastore_Value) + size);
       sb = (SBlock *) & value[1];
       sb->type = htonl (S_BLOCK);
       destPos = (char *) &sb[1];
@@ -441,15 +444,15 @@
       if (mdsize == -1)
         {
           GE_BREAK (ectx, 0);
-          FREE (dstURI);
-          freePrivateKey (hk);
+          GNUNET_free (dstURI);
+          GNUNET_RSA_free_key (hk);
           return NULL;
         }
       size = sizeof (SBlock) + mdsize + strlen (dstURI) + 1;
     }
   else
     {
-      value = MALLOC (sizeof (Datastore_Value) + size);
+      value = GNUNET_malloc (sizeof (Datastore_Value) + size);
       sb = (SBlock *) & value[1];
       sb->type = htonl (S_BLOCK);
       destPos = (char *) &sb[1];
@@ -463,20 +466,20 @@
   value->type = htonl (S_BLOCK);
   value->prio = htonl (priority);
   value->anonymityLevel = htonl (anonymityLevel);
-  value->expirationTime = htonll (expiration);
+  value->expirationTime = GNUNET_htonll (expiration);
 
   /* update SBlock specific data */
   sb->creationTime = htonl (creationTime);
   sb->updateInterval = htonl (updateInterval);
   sb->nextIdentifier = *nextId;
 
-  deltaId (thisId, nextId, &sb->identifierIncrement);
-  hash (thisId, sizeof (HashCode512), &hc);
-  getPublicKey (hk, &sb->subspace);
-  hash (&sb->subspace, sizeof (PublicKey), &namespace);
-  xorHashCodes (&hc, &namespace, &sb->identifier);      /* sb->identifier = 
primary key in query! */
+  GNUNET_hash_difference (thisId, nextId, &sb->identifierIncrement);
+  GNUNET_hash (thisId, sizeof (GNUNET_HashCode), &hc);
+  GNUNET_RSA_get_public_key (hk, &sb->subspace);
+  GNUNET_hash (&sb->subspace, sizeof (GNUNET_RSA_PublicKey), &namespace);
+  GNUNET_hash_xor (&hc, &namespace, &sb->identifier);   /* sb->identifier = 
primary key in query! */
 
-  uri = MALLOC (sizeof (URI));
+  uri = GNUNET_malloc (sizeof (URI));
   uri->type = sks;
   uri->data.sks.namespace = namespace;
   uri->data.sks.identifier = *thisId;
@@ -485,28 +488,29 @@
                        &sb->creationTime,
                        size
                        - sizeof (unsigned int)
-                       - sizeof (Signature)
-                       - sizeof (PublicKey) - sizeof (HashCode512));
-  /* FINALLY: sign & publish SBlock */
+                       - sizeof (GNUNET_RSA_Signature)
+                       - sizeof (GNUNET_RSA_PublicKey) -
+                       sizeof (GNUNET_HashCode));
+  /* FINALLY: GNUNET_RSA_sign & publish SBlock */
   GE_ASSERT (ectx,
-             OK == sign (hk,
-                         size
-                         - sizeof (Signature)
-                         - sizeof (PublicKey)
-                         - sizeof (unsigned int),
-                         &sb->identifier, &sb->signature));
-  freePrivateKey (hk);
+             GNUNET_OK == GNUNET_RSA_sign (hk,
+                                           size
+                                           - sizeof (GNUNET_RSA_Signature)
+                                           - sizeof (GNUNET_RSA_PublicKey)
+                                           - sizeof (unsigned int),
+                                           &sb->identifier, &sb->signature));
+  GNUNET_RSA_free_key (hk);
 
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   ret = FS_insert (sock, value);
-  if (ret != OK)
+  if (ret != GNUNET_OK)
     {
-      FREE (uri);
+      GNUNET_free (uri);
       uri = NULL;
     }
-  connection_destroy (sock);
-  FREE (value);
-  FREE (dstURI);
+  GNUNET_client_connection_destroy (sock);
+  GNUNET_free (value);
+  GNUNET_free (dstURI);
 
   return uri;
 }
@@ -524,72 +528,73 @@
 processFile_ (const char *name, const char *dirName, void *cls)
 {
   struct lNCLS *c = cls;
-  struct PrivateKey *hk;
+  struct GNUNET_RSA_PrivateKey *hk;
   char *fileName;
-  PrivateKeyEncoded *hke;
+  GNUNET_RSA_PrivateKeyEncoded *hke;
   char *dst;
   unsigned long long len;
-  HashCode512 namespace;
-  PublicKey pk;
+  GNUNET_HashCode namespace;
+  GNUNET_RSA_PublicKey pk;
 
   fileName = getPseudonymFileName (c->ectx, c->cfg, name);
-  if (OK != disk_file_size (c->ectx, fileName, &len, YES))
+  if (GNUNET_OK !=
+      GNUNET_disk_file_size (c->ectx, fileName, &len, GNUNET_YES))
     {
-      FREE (fileName);
-      return OK;
+      GNUNET_free (fileName);
+      return GNUNET_OK;
     }
   if (len < 2)
     {
       GE_LOG (c->ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("File `%s' does not contain a pseudonym.\n"), fileName);
-      FREE (fileName);
-      return OK;
+      GNUNET_free (fileName);
+      return GNUNET_OK;
     }
-  dst = MALLOC (len);
-  len = disk_file_read (c->ectx, fileName, len, dst);
-  hke = (PrivateKeyEncoded *) dst;
+  dst = GNUNET_malloc (len);
+  len = GNUNET_disk_file_read (c->ectx, fileName, len, dst);
+  hke = (GNUNET_RSA_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);
-      FREE (hke);
-      FREE (fileName);
-      return OK;
+      GNUNET_free (hke);
+      GNUNET_free (fileName);
+      return GNUNET_OK;
     }
-  hk = decodePrivateKey (hke);
-  FREE (hke);
+  hk = GNUNET_RSA_decode_key (hke);
+  GNUNET_free (hke);
   if (hk == NULL)
     {
       GE_LOG (c->ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("Format of file `%s' is invalid.\n"), fileName);
-      FREE (fileName);
+      GNUNET_free (fileName);
       GE_BREAK (c->ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  FREE (fileName);
-  getPublicKey (hk, &pk);
-  freePrivateKey (hk);
-  hash (&pk, sizeof (PublicKey), &namespace);
+  GNUNET_free (fileName);
+  GNUNET_RSA_get_public_key (hk, &pk);
+  GNUNET_RSA_free_key (hk);
+  GNUNET_hash (&pk, sizeof (GNUNET_RSA_PublicKey), &namespace);
   if (NULL != c->cb)
     {
-      if (OK == c->cb (&namespace, name, c->cls))
+      if (GNUNET_OK == c->cb (&namespace, name, c->cls))
         c->cnt++;
       else
-        c->cnt = SYSERR;
+        c->cnt = GNUNET_SYSERR;
     }
   else
     c->cnt++;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Build a list of all available namespaces
  *
  * @param list where to store the names (is allocated, caller frees)
- * @return SYSERR on error, otherwise the number of pseudonyms in list
+ * @return GNUNET_SYSERR on error, otherwise the number of pseudonyms in list
  */
 int
 ECRS_listNamespaces (struct GE_Context *ectx,
@@ -605,8 +610,8 @@
   myCLS.ectx = ectx;
   myCLS.cfg = cfg;
   dirName = getPseudonymFileName (ectx, cfg, "");
-  disk_directory_scan (ectx, dirName, &processFile_, &myCLS);
-  FREE (dirName);
+  GNUNET_disk_directory_scan (ectx, dirName, &processFile_, &myCLS);
+  GNUNET_free (dirName);
   return myCLS.cnt;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/namespacetest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespacetest.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/ecrs/namespacetest.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -42,7 +42,7 @@
 
 static int
 spcb (const ECRS_FileInfo * fi,
-      const HashCode512 * key, int isRoot, void *closure)
+      const GNUNET_HashCode * key, int isRoot, void *closure)
 {
   struct ECRS_URI *want = closure;
 
@@ -52,15 +52,15 @@
     fprintf (stderr,
              "Namespace search returned unexpected result: \nHAVE: %s\nWANT: 
%s...\n",
              ECRS_uriToString (fi->uri), ECRS_uriToString (want));
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
 testNamespace ()
 {
-  HashCode512 root;
-  HashCode512 thisId;
-  HashCode512 nextId;
+  GNUNET_HashCode root;
+  GNUNET_HashCode thisId;
+  GNUNET_HashCode nextId;
   struct ECRS_URI *adv;
   struct ECRS_URI *uri;
   struct ECRS_URI *advURI;
@@ -75,31 +75,33 @@
   ECRS_deleteNamespace (NULL, cfg, CHECKNAME);  /* make sure old one is 
deleted */
   meta = ECRS_createMetaData ();
   adv = ECRS_keywordsToUri (keys);
-  hash ("root", 4, &root);
+  GNUNET_hash ("root", 4, &root);
   rootURI =
     ECRS_createNamespace (NULL,
                           cfg,
                           CHECKNAME,
                           meta,
-                          0, 0, get_time () + 15 * cronMINUTES, adv, &root);
+                          0, 0, GNUNET_get_time () + 15 * GNUNET_CRON_MINUTES,
+                          adv, &root);
   CHECK (NULL != rootURI);
-  hash ("this", 4, &thisId);
-  hash ("next", 4, &nextId);
+  GNUNET_hash ("this", 4, &thisId);
+  GNUNET_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,
+                                5 * GNUNET_CRON_MINUTES + GNUNET_get_time (),
+                                GNUNET_get_time_int32 (NULL) + 300,
                                 0, &thisId, &nextId, uri, meta);
   CHECK (NULL != advURI);
   fprintf (stderr, "Starting namespace search...\n");
-  CHECK (OK == ECRS_search (NULL,
-                            cfg,
-                            advURI,
-                            1, 60 * cronSECONDS, &spcb, uri, NULL, NULL));
+  CHECK (GNUNET_OK == ECRS_search (NULL,
+                                   cfg,
+                                   advURI,
+                                   1, 60 * GNUNET_CRON_SECONDS, &spcb, uri,
+                                   NULL, NULL));
   fprintf (stderr, "Completed namespace search...\n");
-  CHECK (OK == ECRS_deleteNamespace (NULL, cfg, CHECKNAME));
-  CHECK (SYSERR == ECRS_deleteNamespace (NULL, cfg, CHECKNAME));
+  CHECK (GNUNET_OK == ECRS_deleteNamespace (NULL, cfg, CHECKNAME));
+  CHECK (GNUNET_SYSERR == ECRS_deleteNamespace (NULL, cfg, CHECKNAME));
   ECRS_freeMetaData (meta);
   ECRS_freeUri (rootURI);
   ECRS_freeUri (advURI);
@@ -113,24 +115,25 @@
   pid_t daemon;
   int failureCount = 0;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  if (OK != connection_wait_for_running (NULL, cfg, 60 * cronSECONDS))
+  if (GNUNET_OK !=
+      GNUNET_wait_for_daemon_running (NULL, cfg, 60 * GNUNET_CRON_SECONDS))
     {
       failureCount++;
     }
   else
     {
-      PTHREAD_SLEEP (5 * cronSECONDS);
+      GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);
       failureCount += testNamespace ();
     }
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 
   return (failureCount == 0) ? 0 : 1;
 }

Modified: GNUnet/src/applications/fs/ecrs/parser.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/parser.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/parser.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,16 +32,16 @@
  * @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)
+gnunet_getopt_configure_set_keywords (GNUNET_CommandLineProcessorContext *
+                                      ctx, void *scls, const char *option,
+                                      const char *value)
 {
   struct ECRS_URI **uri = scls;
   struct ECRS_URI *u = *uri;
 
   if (u == NULL)
     {
-      u = MALLOC (sizeof (struct ECRS_URI));
+      u = GNUNET_malloc (sizeof (struct ECRS_URI));
       *uri = u;
       u->type = ksk;
       u->data.ksk.keywordCount = 0;
@@ -51,10 +51,10 @@
     {
       GE_ASSERT (NULL, u->type == ksk);
     }
-  GROW (u->data.ksk.keywords,
-        u->data.ksk.keywordCount, u->data.ksk.keywordCount + 1);
-  u->data.ksk.keywords[u->data.ksk.keywordCount - 1] = STRDUP (value);
-  return OK;
+  GNUNET_array_grow (u->data.ksk.keywords,
+                     u->data.ksk.keywordCount, u->data.ksk.keywordCount + 1);
+  u->data.ksk.keywords[u->data.ksk.keywordCount - 1] = GNUNET_strdup (value);
+  return GNUNET_OK;
 }
 
 
@@ -62,9 +62,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)
+gnunet_getopt_configure_set_metadata (GNUNET_CommandLineProcessorContext *
+                                      ctx, void *scls, const char *option,
+                                      const char *value)
 {
   struct ECRS_MetaData **mm = scls;
   EXTRACTOR_KeywordType type;
@@ -80,11 +80,11 @@
       *mm = meta;
     }
 
-  tmp = string_convertToUtf8 (NULL, value, strlen (value),
+  tmp = GNUNET_convert_string_to_utf8 (NULL, value, strlen (value),
 #if ENABLE_NLS
-                              nl_langinfo (CODESET)
+                                       nl_langinfo (CODESET)
 #else
-                              "utf-8"
+                                       "utf-8"
 #endif
     );
   type = EXTRACTOR_getHighestKeywordTypeNumber ();
@@ -98,7 +98,7 @@
           (0 == strncmp (typename, tmp, strlen (typename))))
         {
           ECRS_addToMetaData (meta, type, &tmp[strlen (typename) + 1]);
-          FREE (tmp);
+          GNUNET_free (tmp);
           tmp = NULL;
           break;
         }
@@ -107,7 +107,7 @@
           (0 == strncmp (typename_i18n, tmp, strlen (typename_i18n))))
         {
           ECRS_addToMetaData (meta, type, &tmp[strlen (typename_i18n) + 1]);
-          FREE (tmp);
+          GNUNET_free (tmp);
           tmp = NULL;
           break;
         }
@@ -115,10 +115,10 @@
   if (tmp != NULL)
     {
       ECRS_addToMetaData (meta, EXTRACTOR_UNKNOWN, tmp);
-      FREE (tmp);
+      GNUNET_free (tmp);
       printf (_
               ("Unknown metadata type in metadata option `%s'.  Using metadata 
type `unknown' instead.\n"),
               value);
     }
-  return OK;
+  return GNUNET_OK;
 }

Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/search.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,7 +31,7 @@
 #include "ecrs_core.h"
 #include "ecrs.h"
 
-#define DEBUG_SEARCH NO
+#define DEBUG_SEARCH GNUNET_NO
 
 typedef struct
 {
@@ -44,24 +44,24 @@
   /**
    * The keys (for the search).
    */
-  HashCode512 *keys;
+  GNUNET_HashCode *keys;
 
   /**
    * When does this query time-out (we may want
    * to refresh it at that point).
    */
-  cron_t timeout;
+  GNUNET_CronTime timeout;
 
   /**
    * What was the last time we transmitted
    * this query?
    */
-  cron_t lastTransmission;
+  GNUNET_CronTime lastTransmission;
 
   /**
    * The key (for decryption)
    */
-  HashCode512 decryptKey;
+  GNUNET_HashCode decryptKey;
 
   /**
    * With which priority does the query run?
@@ -88,12 +88,12 @@
   /**
    * Time when the cron-job was first started.
    */
-  cron_t start;
+  GNUNET_CronTime start;
 
   /**
    * What is the global timeout?
    */
-  cron_t timeout;
+  GNUNET_CronTime timeout;
 
   /**
    * Search context
@@ -109,7 +109,7 @@
 
   void *spcbClosure;
 
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   struct GE_Context *ectx;
 
@@ -130,25 +130,25 @@
 static void
 addPS (unsigned int type,
        unsigned int keyCount,
-       const HashCode512 * keys,
-       const HashCode512 * dkey, SendQueriesContext * sqc)
+       const GNUNET_HashCode * keys,
+       const GNUNET_HashCode * dkey, SendQueriesContext * sqc)
 {
   PendingSearch *ps;
 
-  ps = MALLOC (sizeof (PendingSearch));
+  ps = GNUNET_malloc (sizeof (PendingSearch));
   ps->timeout = 0;
   ps->lastTransmission = 0;
-  ps->priority = 5 + weak_randomi (20);
+  ps->priority = 5 + GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 20);
   ps->type = type;
   ps->keyCount = keyCount;
-  ps->keys = MALLOC (sizeof (HashCode512) * keyCount);
-  memcpy (ps->keys, keys, sizeof (HashCode512) * keyCount);
+  ps->keys = GNUNET_malloc (sizeof (GNUNET_HashCode) * keyCount);
+  memcpy (ps->keys, keys, sizeof (GNUNET_HashCode) * keyCount);
   ps->decryptKey = *dkey;
   ps->handle = NULL;
-  MUTEX_LOCK (sqc->lock);
-  GROW (sqc->queries, sqc->queryCount, sqc->queryCount + 1);
+  GNUNET_mutex_lock (sqc->lock);
+  GNUNET_array_grow (sqc->queries, sqc->queryCount, sqc->queryCount + 1);
   sqc->queries[sqc->queryCount - 1] = ps;
-  MUTEX_UNLOCK (sqc->lock);
+  GNUNET_mutex_unlock (sqc->lock);
 }
 
 /**
@@ -169,11 +169,12 @@
       break;
     case sks:
       {
-        HashCode512 keys[2];
-        HashCode512 hk;         /* hk = hash(identifier) */
+        GNUNET_HashCode keys[2];
+        GNUNET_HashCode hk;     /* hk = GNUNET_hash(identifier) */
 
-        hash (&uri->data.sks.identifier, sizeof (HashCode512), &hk);
-        xorHashCodes (&hk, &uri->data.sks.namespace, &keys[0]); /* compute 
routing key r = H(identifier) ^ namespace */
+        GNUNET_hash (&uri->data.sks.identifier, sizeof (GNUNET_HashCode),
+                     &hk);
+        GNUNET_hash_xor (&hk, &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);
@@ -181,10 +182,10 @@
       }
     case ksk:
       {
-        HashCode512 hc;
-        HashCode512 query;
-        struct PrivateKey *pk;
-        PublicKey pub;
+        GNUNET_HashCode hc;
+        GNUNET_HashCode query;
+        struct GNUNET_RSA_PrivateKey *pk;
+        GNUNET_RSA_PublicKey pub;
         int i;
 
 #if DEBUG_SEARCH
@@ -194,14 +195,14 @@
 #endif
         for (i = 0; i < uri->data.ksk.keywordCount; i++)
           {
-            hash (uri->data.ksk.keywords[i],
-                  strlen (uri->data.ksk.keywords[i]), &hc);
-            pk = makeKblockKey (&hc);
-            getPublicKey (pk, &pub);
-            hash (&pub, sizeof (PublicKey), &query);
+            GNUNET_hash (uri->data.ksk.keywords[i],
+                         strlen (uri->data.ksk.keywords[i]), &hc);
+            pk = GNUNET_RSA_create_key_from_hash (&hc);
+            GNUNET_RSA_get_public_key (pk, &pub);
+            GNUNET_hash (&pub, sizeof (GNUNET_RSA_PublicKey), &query);
             addPS (ANY_BLOCK,   /* K_BLOCK, N_BLOCK or KN_BLOCK ok */
                    1, &query, &hc, sqc);
-            freePrivateKey (pk);
+            GNUNET_RSA_free_key (pk);
           }
 #if DEBUG_SEARCH
         GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, "Queries ready.\n");
@@ -231,39 +232,40 @@
  * @param c the resulting current ID (set)
  */
 static int
-computeIdAtTime (const SBlock * sb, TIME_T now, HashCode512 * c)
+computeIdAtTime (const SBlock * sb, GNUNET_Int32Time now, GNUNET_HashCode * c)
 {
-  TIME_T pos;
-  HashCode512 tmp;
+  GNUNET_Int32Time pos;
+  GNUNET_HashCode tmp;
   unsigned int iter;
 
   if (ntohl (sb->updateInterval) == SBLOCK_UPDATE_SPORADIC)
     {
-      memcpy (c, &sb->nextIdentifier, sizeof (HashCode512));
-      return OK;
+      memcpy (c, &sb->nextIdentifier, sizeof (GNUNET_HashCode));
+      return GNUNET_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);
-      return OK;
+      GNUNET_hash_difference (&sb->identifierIncrement, &sb->nextIdentifier,
+                              c);
+      return GNUNET_OK;
     }
   GE_ASSERT (NULL, ntohl (sb->updateInterval) != 0);
   pos = ntohl (sb->creationTime);
-  deltaId (&sb->identifierIncrement, &sb->nextIdentifier, c);
+  GNUNET_hash_difference (&sb->identifierIncrement, &sb->nextIdentifier, c);
 
   iter =
     (now - (pos + ntohl (sb->updateInterval))) / ntohl (sb->updateInterval);
   if (iter > 0xFFFF)
     /* too many iterators, signal error! */
-    return SYSERR;
+    return GNUNET_SYSERR;
   while (pos + ntohl (sb->updateInterval) < now)
     {
       pos += ntohl (sb->updateInterval);
-      addHashCodes (c, &sb->identifierIncrement, &tmp);
+      GNUNET_hash_sum (c, &sb->identifierIncrement, &tmp);
       *c = tmp;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -273,7 +275,7 @@
  */
 static int
 processNBlock (const NBlock * nb,
-               const HashCode512 * key,
+               const GNUNET_HashCode * key,
                unsigned int size, SendQueriesContext * sqc)
 {
   struct GE_Context *ectx = sqc->ectx;
@@ -287,7 +289,7 @@
   if (fi.meta == NULL)
     {
       GE_BREAK (ectx, 0);       /* nblock malformed */
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   fi.uri = &uri;
   uri.type = sks;
@@ -295,12 +297,12 @@
   uri.data.sks.identifier = nb->rootEntry;
   if (sqc->spcb != NULL)
     {
-      ret = sqc->spcb (&fi, key, YES, sqc->spcbClosure);
-      if (ret == SYSERR)
-        sqc->aborted = YES;
+      ret = sqc->spcb (&fi, key, GNUNET_YES, sqc->spcbClosure);
+      if (ret == GNUNET_SYSERR)
+        sqc->aborted = GNUNET_YES;
     }
   else
-    ret = OK;
+    ret = GNUNET_OK;
   ECRS_freeMetaData (fi.meta);
   return ret;
 }
@@ -310,10 +312,10 @@
  * queries.  Verifies, decrypts and passes valid
  * replies to the callback.
  *
- * @return SYSERR if the entry is malformed
+ * @return GNUNET_SYSERR if the entry is malformed
  */
 static int
-receiveReplies (const HashCode512 * key,
+receiveReplies (const GNUNET_HashCode * key,
                 const Datastore_Value * value, SendQueriesContext * sqc)
 {
   struct GE_Context *ectx = sqc->ectx;
@@ -323,7 +325,7 @@
   unsigned int size;
   PendingSearch *ps;
   int ret;
-  HashCode512 query;
+  GNUNET_HashCode query;
 
   type = ntohl (value->type);
   size = ntohl (value->size) - sizeof (Datastore_Value);
@@ -332,19 +334,20 @@
           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))
-    return SYSERR;
+  if (GNUNET_OK !=
+      getQueryFor (size, (const DBlock *) &value[1], GNUNET_YES, &query))
+    return GNUNET_SYSERR;
   for (i = 0; i < sqc->queryCount; i++)
     {
       ps = sqc->queries[i];
-      if (equalsHashCode512 (&query,
-                             &ps->keys[0]) &&
+      if ((0 == memcmp (&query,
+                        &ps->keys[0], sizeof (GNUNET_HashCode))) &&
           ((ps->type == type) ||
            (ps->type == ANY_BLOCK)) &&
-          (YES == isDatumApplicable (type,
-                                     size,
-                                     (const DBlock *) &value[1],
-                                     &query, ps->keyCount, ps->keys)))
+          (GNUNET_YES == isDatumApplicable (type,
+                                            size,
+                                            (const DBlock *) &value[1],
+                                            &query, ps->keyCount, ps->keys)))
         {
           switch (type)
             {
@@ -353,17 +356,17 @@
                 KBlock *kb;
                 const char *dstURI;
 #if DEBUG_SEARCH
-                EncName enc;
+                GNUNET_EncName enc;
 #endif
                 int j;
 
                 if (size < sizeof (KBlock))
-                  return SYSERR;
-                kb = MALLOC (size);
+                  return GNUNET_SYSERR;
+                kb = GNUNET_malloc (size);
                 memcpy (kb, &value[1], size);
 #if DEBUG_SEARCH
                 IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-                          hash2enc (&ps->decryptKey, &enc));
+                          GNUNET_hash_to_enc (&ps->decryptKey, &enc));
                 GE_LOG (ectx,
                         GE_DEBUG | GE_REQUEST | GE_USER,
                         "Decrypting KBlock with key %s.\n", &enc);
@@ -376,8 +379,8 @@
                 if (j == size)
                   {
                     GE_BREAK (ectx, 0); /* kblock malformed */
-                    FREE (kb);
-                    return SYSERR;
+                    GNUNET_free (kb);
+                    return GNUNET_SYSERR;
                   }
                 dstURI = (const char *) &kb[1];
                 j++;
@@ -387,29 +390,30 @@
                 if (fi.meta == NULL)
                   {
                     GE_BREAK (ectx, 0); /* kblock malformed */
-                    FREE (kb);
-                    return SYSERR;
+                    GNUNET_free (kb);
+                    return GNUNET_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;
+                    GNUNET_free (kb);
+                    return GNUNET_SYSERR;
                   }
                 if (sqc->spcb != NULL)
                   {
                     ret = sqc->spcb (&fi,
-                                     &ps->decryptKey, NO, sqc->spcbClosure);
-                    if (ret == SYSERR)
-                      sqc->aborted = YES;
+                                     &ps->decryptKey, GNUNET_NO,
+                                     sqc->spcbClosure);
+                    if (ret == GNUNET_SYSERR)
+                      sqc->aborted = GNUNET_YES;
                   }
                 else
-                  ret = OK;
+                  ret = GNUNET_OK;
                 ECRS_freeUri (fi.uri);
                 ECRS_freeMetaData (fi.meta);
-                FREE (kb);
+                GNUNET_free (kb);
                 return ret;
               }
             case N_BLOCK:
@@ -417,7 +421,7 @@
                 const NBlock *nb;
 
                 if (size < sizeof (NBlock))
-                  return SYSERR;
+                  return GNUNET_SYSERR;
                 nb = (const NBlock *) &value[1];
                 return processNBlock (nb, NULL, size, sqc);
               }
@@ -427,8 +431,8 @@
                 int ret;
 
                 if (size < sizeof (KNBlock))
-                  return SYSERR;
-                kb = MALLOC (size);
+                  return GNUNET_SYSERR;
+                kb = GNUNET_malloc (size);
                 memcpy (kb, &value[1], size);
                 ECRS_decryptInPlace (&ps->decryptKey,
                                      &kb->nblock,
@@ -438,7 +442,7 @@
                   processNBlock (&kb->nblock, &ps->decryptKey,
                                  size - sizeof (KNBlock) + sizeof (NBlock),
                                  sqc);
-                FREE (kb);
+                GNUNET_free (kb);
                 return ret;
               }
             case S_BLOCK:
@@ -446,21 +450,21 @@
                 SBlock *sb;
                 const char *dstURI;
                 int j;
-                TIME_T now;
-                HashCode512 updateId;
+                GNUNET_Int32Time now;
+                GNUNET_HashCode updateId;
                 URI updateURI;
 
                 if (size < sizeof (SBlock))
-                  return SYSERR;
-                sb = MALLOC (size);
+                  return GNUNET_SYSERR;
+                sb = GNUNET_malloc (size);
                 memcpy (sb, &value[1], size);
                 ECRS_decryptInPlace (&ps->decryptKey,
                                      &sb->creationTime,
                                      size
                                      - sizeof (unsigned int)
-                                     - sizeof (Signature)
-                                     - sizeof (PublicKey)
-                                     - sizeof (HashCode512));
+                                     - sizeof (GNUNET_RSA_Signature)
+                                     - sizeof (GNUNET_RSA_PublicKey)
+                                     - sizeof (GNUNET_HashCode));
                 j = 0;
                 dstURI = (const char *) &sb[1];
                 while ((j < size - sizeof (SBlock)) && (dstURI[j] != '\0'))
@@ -468,8 +472,8 @@
                 if (j == size - sizeof (SBlock))
                   {
                     GE_BREAK (ectx, 0); /* sblock malformed */
-                    FREE (sb);
-                    return SYSERR;
+                    GNUNET_free (sb);
+                    return GNUNET_SYSERR;
                   }
                 j++;
                 /* j == strlen(dstURI) + 1 */
@@ -480,53 +484,55 @@
                 if (fi.meta == NULL)
                   {
                     GE_BREAK (ectx, 0); /* sblock malformed */
-                    FREE (sb);
-                    return SYSERR;
+                    GNUNET_free (sb);
+                    return GNUNET_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;
+                    GNUNET_free (sb);
+                    return GNUNET_SYSERR;
                   }
                 if (sqc->spcb != NULL)
                   {
-                    ret = sqc->spcb (&fi, NULL, NO, sqc->spcbClosure);
-                    if (ret == SYSERR)
-                      sqc->aborted = YES;
+                    ret = sqc->spcb (&fi, NULL, GNUNET_NO, sqc->spcbClosure);
+                    if (ret == GNUNET_SYSERR)
+                      sqc->aborted = GNUNET_YES;
                   }
                 else
-                  ret = OK;
+                  ret = GNUNET_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))
+                GNUNET_get_time_int32 (&now);
+                if (GNUNET_OK != computeIdAtTime (sb, now, &updateId))
                   {
-                    FREE (sb);
-                    return SYSERR;
+                    GNUNET_free (sb);
+                    return GNUNET_SYSERR;
                   }
-                if (equalsHashCode512 (&updateId, &ps->decryptKey))
+                if (0 ==
+                    memcmp (&updateId, &ps->decryptKey,
+                            sizeof (GNUNET_HashCode)))
                   {
-                    FREE (sb);
+                    GNUNET_free (sb);
                     return ret; /* have latest version */
                   }
                 if (ps->keyCount != 2)
                   {
                     GE_BREAK (ectx, 0);
-                    FREE (sb);
-                    return SYSERR;
+                    GNUNET_free (sb);
+                    return GNUNET_SYSERR;
                   }
 
                 updateURI.type = sks;
                 updateURI.data.sks.namespace = ps->keys[1];
                 updateURI.data.sks.identifier = updateId;
                 addQueryForURI (&updateURI, sqc);
-                FREE (sb);
+                GNUNET_free (sb);
                 return ret;
               }
             default:
@@ -535,7 +541,7 @@
             }                   /* end switch */
         }                       /* for all matches */
     }                           /* for all pending queries */
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -551,20 +557,20 @@
              struct GC_Configuration *cfg,
              const struct ECRS_URI *uri,
              unsigned int anonymityLevel,
-             cron_t timeout,
+             GNUNET_CronTime timeout,
              ECRS_SearchProgressCallback spcb,
              void *spcbClosure, ECRS_TestTerminate tt, void *ttClosure)
 {
   SendQueriesContext ctx;
   PendingSearch *ps;
   int i;
-  cron_t now;
-  cron_t remTime;
-  cron_t new_ttl;
+  GNUNET_CronTime now;
+  GNUNET_CronTime remTime;
+  GNUNET_CronTime new_ttl;
   unsigned int new_priority;
 
-  ctx.start = get_time ();
-  now = get_time ();
+  ctx.start = GNUNET_get_time ();
+  now = GNUNET_get_time ();
   timeout += now;
   ctx.ectx = ectx;
   ctx.cfg = cfg;
@@ -573,18 +579,18 @@
   ctx.queries = NULL;
   ctx.spcb = spcb;
   ctx.spcbClosure = spcbClosure;
-  ctx.aborted = NO;
-  ctx.lock = MUTEX_CREATE (YES);
+  ctx.aborted = GNUNET_NO;
+  ctx.lock = GNUNET_mutex_create (GNUNET_YES);
   ctx.sctx = FS_SEARCH_makeContext (ectx, cfg, ctx.lock);
   addQueryForURI (uri, &ctx);
   while (((NULL == tt) ||
-          (OK == tt (ttClosure))) &&
-         (NO == GNUNET_SHUTDOWN_TEST ()) &&
-         (timeout > now) && (ctx.aborted == NO))
+          (GNUNET_OK == tt (ttClosure))) &&
+         (GNUNET_NO == GNUNET_shutdown_test ()) &&
+         (timeout > now) && (ctx.aborted == GNUNET_NO))
     {
       remTime = timeout - now;
 
-      MUTEX_LOCK (ctx.lock);
+      GNUNET_mutex_lock (ctx.lock);
       for (i = 0; i < ctx.queryCount; i++)
         {
           ps = ctx.queries[i];
@@ -594,25 +600,33 @@
             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 = new_ttl + weak_randomi (5 * cronSECONDS + 2 * new_ttl);
+          if (new_ttl < 4 * 5 * GNUNET_CRON_SECONDS)
+            new_ttl =
+              4 * 5 * GNUNET_CRON_SECONDS +
+              GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                                 5 * GNUNET_CRON_SECONDS);
+          new_ttl =
+            new_ttl + GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                                         5 * GNUNET_CRON_SECONDS +
+                                         2 * new_ttl);
           if (new_ttl > 0xFFFFFF)
-            new_ttl = weak_randomi (0xFFFFFF);  /* if we get to large, reduce! 
*/
+            new_ttl = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 
0xFFFFFF); /* if we get to large, reduce! */
           if (remTime < new_ttl)
             new_ttl = remTime;
           ps->timeout = new_ttl + now;
           new_priority = ps->priority;
-          new_priority = new_priority + weak_randomi (4 + 2 * new_priority);
+          new_priority =
+            new_priority + GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                                              4 + 2 * new_priority);
           if (new_priority > 0xFFFFFF)
-            new_priority = weak_randomi (0xFFFFFF);     /* if we get to large, 
reduce! */
+            new_priority = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 
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);
+                  (ps->timeout - now) / GNUNET_CRON_SECONDS, ps->priority);
 #endif
           ps->handle
             = FS_start_search (ctx.sctx,
@@ -625,24 +639,25 @@
                                ps->timeout,
                                (Datum_Iterator) & receiveReplies, &ctx);
         }
-      MUTEX_UNLOCK (ctx.lock);
+      GNUNET_mutex_unlock (ctx.lock);
       if (((NULL != tt) &&
-           (OK != tt (ttClosure))) || (timeout <= now) || (ctx.aborted != NO))
+           (GNUNET_OK != tt (ttClosure))) || (timeout <= now)
+          || (ctx.aborted != GNUNET_NO))
         break;
-      PTHREAD_SLEEP (100 * cronMILLIS);
-      now = get_time ();
+      GNUNET_thread_sleep (100 * GNUNET_CRON_MILLISECONDS);
+      now = GNUNET_get_time ();
     }
   for (i = 0; i < ctx.queryCount; i++)
     {
       if (ctx.queries[i]->handle != NULL)
         FS_stop_search (ctx.sctx, ctx.queries[i]->handle);
-      FREE (ctx.queries[i]->keys);
-      FREE (ctx.queries[i]);
+      GNUNET_free (ctx.queries[i]->keys);
+      GNUNET_free (ctx.queries[i]);
     }
-  GROW (ctx.queries, ctx.queryCount, 0);
+  GNUNET_array_grow (ctx.queries, ctx.queryCount, 0);
   FS_SEARCH_destroyContext (ctx.sctx);
-  MUTEX_DESTROY (ctx.lock);
-  return OK;
+  GNUNET_mutex_destroy (ctx.lock);
+  return GNUNET_OK;
 }
 
 

Modified: GNUnet/src/applications/fs/ecrs/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/searchtest.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/ecrs/searchtest.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -31,19 +31,19 @@
 #include "gnunet_util_network_client.h"
 #include "tree.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
 static int
 testTerminate (void *unused)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 static struct GC_Configuration *cfg;
 
 static int
 searchCB (const ECRS_FileInfo * fi,
-          const HashCode512 * key, int isRoot, void *closure)
+          const GNUNET_HashCode * key, int isRoot, void *closure)
 {
   int *cnt = closure;
 #if 1
@@ -51,17 +51,17 @@
 
   st = ECRS_uriToString (fi->uri);
   printf ("Got result `%s'\n", st);
-  FREE (st);
+  GNUNET_free (st);
 #endif
   (*cnt)--;
   if (0 == *cnt)
-    return SYSERR;              /* abort search */
-  return OK;
+    return GNUNET_SYSERR;       /* abort search */
+  return GNUNET_OK;
 }
 
 /**
  * @param *uri In: keyword URI
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 searchFile (const struct ECRS_URI *uri, int resultCount)
@@ -70,11 +70,11 @@
                cfg,
                uri,
                0,
-               60 * 15 * cronSECONDS,
+               60 * 15 * GNUNET_CRON_SECONDS,
                &searchCB, &resultCount, &testTerminate, NULL);
   if (resultCount > 0)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 int
@@ -82,26 +82,28 @@
 {
   pid_t daemon;
   int ok;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   struct ECRS_URI *uri;
   struct ECRS_MetaData *meta;
   struct ECRS_URI *key;
   const char *keywords[6];
 
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
   sock = NULL;
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  ok = YES;
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
-  sock = client_connection_create (NULL, cfg);
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  ok = GNUNET_YES;
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
+  sock = GNUNET_client_connection_create (NULL, cfg);
   CHECK (sock != NULL);
   /* ACTUAL TEST CODE */
   /* first, simple insertion => one result */
@@ -115,9 +117,9 @@
   keywords[1] = NULL;
 
   key = ECRS_keywordsToUri (keywords);
-  CHECK (OK == ECRS_addToKeyspace (NULL, cfg, key, 0, 0, get_time () + 10 * 
cronMINUTES,        /* expire */
-                                   uri, meta));
-  CHECK (OK == searchFile (key, 1));
+  CHECK (GNUNET_OK == ECRS_addToKeyspace (NULL, cfg, key, 0, 0, 
GNUNET_get_time () + 10 * GNUNET_CRON_MINUTES,  /* expire */
+                                          uri, meta));
+  CHECK (GNUNET_OK == searchFile (key, 1));
   ECRS_freeUri (key);
   ECRS_freeUri (uri);
 
@@ -131,9 +133,9 @@
   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));
-  CHECK (OK == searchFile (key, 2));
+  CHECK (GNUNET_OK == ECRS_addToKeyspace (NULL, cfg, key, 0, 0, 
GNUNET_get_time () + 10 * GNUNET_CRON_MINUTES,  /* expire */
+                                          uri, meta));
+  CHECK (GNUNET_OK == searchFile (key, 2));
   ECRS_freeUri (key);
   ECRS_freeUri (uri);
   ECRS_freeMetaData (meta);
@@ -144,15 +146,15 @@
 #endif
   keywords[1] = NULL;
   key = ECRS_keywordsToUri (keywords);
-  CHECK (OK == searchFile (key, 2));
+  CHECK (GNUNET_OK == searchFile (key, 2));
   ECRS_freeUri (key);
 
   /* END OF TEST CODE */
 FAILURE:
   if (sock != NULL)
-    connection_destroy (sock);
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
-  return (ok == YES) ? 0 : 1;
+    GNUNET_client_connection_destroy (sock);
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of searchtest.c */

Modified: GNUnet/src/applications/fs/ecrs/tree.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/tree.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/tree.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -33,8 +33,8 @@
   unsigned int treeDepth;
   unsigned long long fl;
 
-  GE_ASSERT (NULL, DBLOCK_SIZE < MAX_BUFFER_SIZE);
-  GE_ASSERT (NULL, IBLOCK_SIZE < MAX_BUFFER_SIZE);
+  GE_ASSERT (NULL, DBLOCK_SIZE < GNUNET_MAX_BUFFER_SIZE);
+  GE_ASSERT (NULL, IBLOCK_SIZE < GNUNET_MAX_BUFFER_SIZE);
   treeDepth = 0;
   fl = DBLOCK_SIZE;
   while (fl < flen)

Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/unindex.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -39,7 +39,7 @@
 #include "fs.h"
 #include "tree.h"
 
-#define STRICT_CHECKS NO
+#define STRICT_CHECKS GNUNET_NO
 
 /**
  * Append the given key and query to the iblock[level].
@@ -53,7 +53,7 @@
  * FS_delete as argument!).
  */
 static int
-pushBlock (struct ClientServerConnection *sock,
+pushBlock (struct GNUNET_ClientServerConnection *sock,
            const CHK * chk, unsigned int level, Datastore_Value ** iblocks)
 {
   unsigned int size;
@@ -69,30 +69,30 @@
     {
       fileBlockGetKey (db, size, &ichk.key);
       fileBlockGetQuery (db, size, &ichk.query);
-      if (OK != pushBlock (sock, &ichk, level + 1, iblocks))
+      if (GNUNET_OK != pushBlock (sock, &ichk, level + 1, iblocks))
         {
           GE_BREAK (NULL, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       fileBlockEncode (db, size, &ichk.query, &value);
 #if STRICT_CHECKS
-      if (SYSERR == FS_delete (sock, value))
+      if (GNUNET_SYSERR == FS_delete (sock, value))
         {
-          FREE (value);
+          GNUNET_free (value);
           GE_BREAK (NULL, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
 #else
       FS_delete (sock, value);
 #endif
-      FREE (value);
+      GNUNET_free (value);
       size = sizeof (DBlock);
     }
   /* append CHK */
   memcpy (&((char *) db)[size], chk, sizeof (CHK));
   iblocks[level]->size = htonl (size +
                                 sizeof (CHK) + sizeof (Datastore_Value));
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -105,38 +105,38 @@
 static int
 undoSymlinking (struct GE_Context *ectx,
                 const char *fn,
-                const HashCode512 * fileId,
-                struct ClientServerConnection *sock)
+                const GNUNET_HashCode * fileId,
+                struct GNUNET_ClientServerConnection *sock)
 {
-  EncName enc;
+  GNUNET_EncName enc;
   char *serverDir;
   char *serverFN;
   struct stat buf;
 
 #ifndef S_ISLNK
   if (1)
-    return OK;                  /* symlinks do not exist? */
+    return GNUNET_OK;           /* symlinks do not exist? */
 #endif
   if (0 != LSTAT (fn, &buf))
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_BULK | GE_USER | GE_ADMIN,
                             "stat", fn);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #ifdef S_ISLNK
   if (!S_ISLNK (buf.st_mode))
-    return OK;
+    return GNUNET_OK;
 #endif
-  serverDir = getConfigurationOptionValue (sock, "FS", "INDEX-DIRECTORY");
+  serverDir = GNUNET_get_daemon_configuration_value (sock, "FS", 
"INDEX-DIRECTORY");
   if (serverDir == NULL)
-    return OK;
-  serverFN = MALLOC (strlen (serverDir) + 2 + sizeof (EncName));
+    return GNUNET_OK;
+  serverFN = GNUNET_malloc (strlen (serverDir) + 2 + sizeof (GNUNET_EncName));
   strcpy (serverFN, serverDir);
-  FREE (serverDir);
+  GNUNET_free (serverDir);
   if (serverFN[strlen (serverFN) - 1] != DIR_SEPARATOR)
     strcat (serverFN, DIR_SEPARATOR_STR);
-  hash2enc (fileId, &enc);
+  GNUNET_hash_to_enc (fileId, &enc);
   strcat (serverFN, (char *) &enc);
 
   if (0 != UNLINK (serverFN))
@@ -144,11 +144,11 @@
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_BULK | GE_USER | GE_ADMIN,
                             "unlink", serverFN);
-      FREE (serverFN);
-      return SYSERR;
+      GNUNET_free (serverFN);
+      return GNUNET_SYSERR;
     }
-  FREE (serverFN);
-  return OK;
+  GNUNET_free (serverFN);
+  return GNUNET_OK;
 }
 
 
@@ -156,7 +156,7 @@
 /**
  * Unindex a file.
  *
- * @return SYSERR if the unindexing failed (i.e. not indexed)
+ * @return GNUNET_SYSERR if the unindexing failed (i.e. not indexed)
  */
 int
 ECRS_unindexFile (struct GE_Context *ectx,
@@ -175,70 +175,73 @@
   Datastore_Value *dblock;
   DBlock *db;
   Datastore_Value *value;
-  struct ClientServerConnection *sock;
-  HashCode512 fileId;
+  struct GNUNET_ClientServerConnection *sock;
+  GNUNET_HashCode fileId;
   CHK chk;
-  cron_t eta;
-  cron_t start;
-  cron_t now;
+  GNUNET_CronTime eta;
+  GNUNET_CronTime start;
+  GNUNET_CronTime now;
   int wasIndexed;
 
-  start = get_time ();
-  if (YES != disk_file_test (ectx, filename))
+  start = GNUNET_get_time ();
+  if (GNUNET_YES != GNUNET_disk_file_test (ectx, filename))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if (OK != disk_file_size (ectx, filename, &filesize, YES))
-    return SYSERR;
-  sock = client_connection_create (ectx, cfg);
+  if (GNUNET_OK !=
+      GNUNET_disk_file_size (ectx, filename, &filesize, GNUNET_YES))
+    return GNUNET_SYSERR;
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   eta = 0;
   if (upcb != NULL)
     upcb (filesize, 0, eta, upcbClosure);
-  if (SYSERR == getFileHash (ectx, filename, &fileId))
+  if (GNUNET_SYSERR == GNUNET_hash_file (ectx, filename, &fileId))
     {
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  now = get_time ();
+  now = GNUNET_get_time ();
   eta = now + 2 * (now - start);
-  /* very rough estimate: hash reads once through the file,
+  /* very rough estimate: GNUNET_hash reads once through the file,
      we'll do that once more and write it.  But of course
      the second read may be cached, and we have the encryption,
      so a factor of two is really, really just a rough estimate */
   start = now;
   /* reset the counter since the formula later does not
-     take the time for getFileHash into account */
+     take the time for GNUNET_hash_file into account */
   treedepth = computeDepth (filesize);
 
   /* Test if file is indexed! */
   wasIndexed = FS_testIndexed (sock, &fileId);
 
-  fd = disk_file_open (ectx, filename, O_RDONLY | O_LARGEFILE);
+  fd = GNUNET_disk_file_open (ectx, filename, O_RDONLY | O_LARGEFILE);
   if (fd == -1)
-    return SYSERR;
-  dblock = MALLOC (sizeof (Datastore_Value) + DBLOCK_SIZE + sizeof (DBlock));
+    return GNUNET_SYSERR;
+  dblock =
+    GNUNET_malloc (sizeof (Datastore_Value) + DBLOCK_SIZE + sizeof (DBlock));
   dblock->size =
     htonl (sizeof (Datastore_Value) + DBLOCK_SIZE + sizeof (DBlock));
   dblock->anonymityLevel = htonl (0);
   dblock->prio = htonl (0);
   dblock->type = htonl (D_BLOCK);
-  dblock->expirationTime = htonll (0);
+  dblock->expirationTime = GNUNET_htonll (0);
   db = (DBlock *) & dblock[1];
   db->type = htonl (D_BLOCK);
-  iblocks = MALLOC (sizeof (Datastore_Value *) * (treedepth + 1));
+  iblocks = GNUNET_malloc (sizeof (Datastore_Value *) * (treedepth + 1));
   for (i = 0; i <= treedepth; i++)
     {
       iblocks[i] =
-        MALLOC (sizeof (Datastore_Value) + IBLOCK_SIZE + sizeof (DBlock));
+        GNUNET_malloc (sizeof (Datastore_Value) + IBLOCK_SIZE +
+                       sizeof (DBlock));
       iblocks[i]->size = htonl (sizeof (Datastore_Value) + sizeof (DBlock));
       iblocks[i]->anonymityLevel = htonl (0);
       iblocks[i]->prio = htonl (0);
       iblocks[i]->type = htonl (D_BLOCK);
-      iblocks[i]->expirationTime = htonll (0);
+      iblocks[i]->expirationTime = GNUNET_htonll (0);
       ((DBlock *) & iblocks[i][1])->type = htonl (D_BLOCK);
     }
 
@@ -248,7 +251,7 @@
       if (upcb != NULL)
         upcb (filesize, pos, eta, upcbClosure);
       if (tt != NULL)
-        if (OK != tt (ttClosure))
+        if (GNUNET_OK != tt (ttClosure))
           goto FAILURE;
       size = DBLOCK_SIZE;
       if (size > filesize - pos)
@@ -266,32 +269,32 @@
           goto FAILURE;
         }
       if (tt != NULL)
-        if (OK != tt (ttClosure))
+        if (GNUNET_OK != tt (ttClosure))
           goto FAILURE;
       fileBlockGetKey (db, size + sizeof (DBlock), &chk.key);
       fileBlockGetQuery (db, size + sizeof (DBlock), &chk.query);
-      if (OK != pushBlock (sock, &chk, 0,       /* dblocks are on level 0 */
-                           iblocks))
+      if (GNUNET_OK != pushBlock (sock, &chk, 0,        /* dblocks are on 
level 0 */
+                                  iblocks))
         {
           GE_BREAK (ectx, 0);
           goto FAILURE;
         }
       if (!wasIndexed)
         {
-          if (OK == fileBlockEncode (db, size, &chk.query, &value))
+          if (GNUNET_OK == fileBlockEncode (db, size, &chk.query, &value))
             {
               *value = *dblock; /* copy options! */
 #if STRICT_CHECKS
-              if (OK != FS_delete (sock, value))
+              if (GNUNET_OK != FS_delete (sock, value))
                 {
-                  FREE (value);
+                  GNUNET_free (value);
                   GE_BREAK (ectx, 0);
                   goto FAILURE;
                 }
 #else
               FS_delete (sock, value);
 #endif
-              FREE (value);
+              GNUNET_free (value);
             }
           else
             {
@@ -299,13 +302,13 @@
             }
         }
       pos += size;
-      now = get_time ();
-      eta = (cron_t) (start +
-                      (((double) (now - start) / (double) pos))
-                      * (double) filesize);
+      now = GNUNET_get_time ();
+      eta = (GNUNET_CronTime) (start +
+                               (((double) (now - start) / (double) pos))
+                               * (double) filesize);
     }
   if (tt != NULL)
-    if (OK != tt (ttClosure))
+    if (GNUNET_OK != tt (ttClosure))
       goto FAILURE;
   for (i = 0; i < treedepth; i++)
     {
@@ -313,32 +316,32 @@
       db = (DBlock *) & iblocks[i][1];
       fileBlockGetKey (db, size, &chk.key);
       fileBlockGetQuery (db, size, &chk.query);
-      if (OK != pushBlock (sock, &chk, i + 1, iblocks))
+      if (GNUNET_OK != pushBlock (sock, &chk, i + 1, iblocks))
         {
           GE_BREAK (ectx, 0);
           goto FAILURE;
         }
       fileBlockEncode (db, size, &chk.query, &value);
 #if STRICT_CHECKS
-      if (OK != FS_delete (sock, value))
+      if (GNUNET_OK != FS_delete (sock, value))
         {
-          FREE (value);
+          GNUNET_free (value);
           GE_BREAK (ectx, 0);
           goto FAILURE;
         }
 #else
       FS_delete (sock, value);
 #endif
-      FREE (value);
-      FREE (iblocks[i]);
+      GNUNET_free (value);
+      GNUNET_free (iblocks[i]);
       iblocks[i] = NULL;
     }
 
   if (wasIndexed)
     {
-      if (OK == undoSymlinking (ectx, filename, &fileId, sock))
+      if (GNUNET_OK == undoSymlinking (ectx, filename, &fileId, sock))
         {
-          if (OK != FS_unindex (sock, DBLOCK_SIZE, &fileId))
+          if (GNUNET_OK != FS_unindex (sock, DBLOCK_SIZE, &fileId))
             {
               GE_BREAK (ectx, 0);
               goto FAILURE;
@@ -350,21 +353,21 @@
           goto FAILURE;
         }
     }
-  FREE (iblocks[treedepth]);
+  GNUNET_free (iblocks[treedepth]);
   /* free resources */
-  FREE (iblocks);
-  FREE (dblock);
+  GNUNET_free (iblocks);
+  GNUNET_free (dblock);
   CLOSE (fd);
-  connection_destroy (sock);
-  return OK;
+  GNUNET_client_connection_destroy (sock);
+  return GNUNET_OK;
 FAILURE:
   for (i = 0; i <= treedepth; i++)
-    FREENONNULL (iblocks[i]);
-  FREE (iblocks);
-  FREE (dblock);
+    GNUNET_free_non_null (iblocks[i]);
+  GNUNET_free (iblocks);
+  GNUNET_free (dblock);
   CLOSE (fd);
-  connection_destroy (sock);
-  return SYSERR;
+  GNUNET_client_connection_destroy (sock);
+  return GNUNET_SYSERR;
 }
 
 /* end of unindex.c */

Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/upload.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -38,7 +38,7 @@
 #include "uri.h"
 #include "tree.h"
 
-#define DEBUG_UPLOAD NO
+#define DEBUG_UPLOAD GNUNET_NO
 
 /**
  * Append the given key and query to the iblock[level].  If
@@ -47,11 +47,11 @@
  * enough.
  */
 static int
-pushBlock (struct ClientServerConnection *sock,
+pushBlock (struct GNUNET_ClientServerConnection *sock,
            const CHK * chk,
            unsigned int level,
            Datastore_Value ** iblocks,
-           unsigned int prio, cron_t expirationTime)
+           unsigned int prio, GNUNET_CronTime expirationTime)
 {
   unsigned int size;
   unsigned int present;
@@ -59,7 +59,7 @@
   DBlock *db;
   CHK ichk;
 #if DEBUG_UPLOAD
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   size = ntohl (iblocks[level]->size);
@@ -72,32 +72,33 @@
     {
       fileBlockGetKey (db, size, &ichk.key);
       fileBlockGetQuery (db, size, &ichk.query);
-      if (OK != pushBlock (sock,
-                           &ichk, level + 1, iblocks, prio, expirationTime))
-        return SYSERR;
+      if (GNUNET_OK != pushBlock (sock,
+                                  &ichk, level + 1, iblocks, prio,
+                                  expirationTime))
+        return GNUNET_SYSERR;
       fileBlockEncode (db, size, &ichk.query, &value);
       if (value == NULL)
         {
           GE_BREAK (NULL, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       value->prio = htonl (prio);
-      value->expirationTime = htonll (expirationTime);
-      if (OK != FS_insert (sock, value))
+      value->expirationTime = GNUNET_htonll (expirationTime);
+      if (GNUNET_OK != FS_insert (sock, value))
         {
-          FREE (value);
-          return SYSERR;
+          GNUNET_free (value);
+          return GNUNET_SYSERR;
         }
-      FREE (value);
+      GNUNET_free (value);
       size = sizeof (DBlock);   /* type */
     }
   /* append CHK */
   memcpy (&((char *) db)[size], chk, sizeof (CHK));
   size += sizeof (CHK) + sizeof (Datastore_Value);
-  GE_ASSERT (NULL, size < MAX_BUFFER_SIZE);
+  GE_ASSERT (NULL, size < GNUNET_MAX_BUFFER_SIZE);
   iblocks[level]->size = htonl (size);
 
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -106,9 +107,9 @@
  * @param priority what is the priority for OUR node to
  *   keep this file available?  Use 0 for maximum anonymity and
  *   minimum reliability...
- * @param doIndex YES for index, NO for insertion
+ * @param doIndex GNUNET_YES for index, GNUNET_NO for insertion
  * @param uri set to the URI of the uploaded file
- * @return SYSERR if the upload failed (i.e. not enough space
+ * @return GNUNET_SYSERR if the upload failed (i.e. not enough space
  *  or gnunetd not running)
  */
 int
@@ -118,7 +119,7 @@
                  int doIndex,
                  unsigned int anonymityLevel,
                  unsigned int priority,
-                 cron_t expirationTime,
+                 GNUNET_CronTime expirationTime,
                  ECRS_UploadProgressCallback upcb,
                  void *upcbClosure,
                  ECRS_TestTerminate tt,
@@ -134,117 +135,120 @@
   Datastore_Value *dblock;
   DBlock *db;
   Datastore_Value *value;
-  struct ClientServerConnection *sock;
-  HashCode512 fileId;
+  struct GNUNET_ClientServerConnection *sock;
+  GNUNET_HashCode fileId;
   CHK mchk;
-  cron_t eta;
-  cron_t start;
-  cron_t now;
+  GNUNET_CronTime eta;
+  GNUNET_CronTime start;
+  GNUNET_CronTime now;
   FileIdentifier fid;
 #if DEBUG_UPLOAD
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   GE_ASSERT (ectx, cfg != NULL);
-  start = get_time ();
+  start = GNUNET_get_time ();
   memset (&mchk, 0, sizeof (CHK));
-  if (YES != disk_file_test (ectx, filename))
+  if (GNUNET_YES != GNUNET_disk_file_test (ectx, filename))
     {
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("`%s' is not a file.\n"), filename);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if (OK != disk_file_size (ectx, filename, &filesize, YES))
+  if (GNUNET_OK !=
+      GNUNET_disk_file_size (ectx, filename, &filesize, GNUNET_YES))
     {
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("Cannot get size of file `%s'"), filename);
 
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
     {
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("Failed to connect to gnunetd."));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   eta = 0;
   if (upcb != NULL)
     upcb (filesize, 0, eta, upcbClosure);
   if (doIndex)
     {
-      if (SYSERR == getFileHash (ectx, filename, &fileId))
+      if (GNUNET_SYSERR == GNUNET_hash_file (ectx, filename, &fileId))
         {
           GE_LOG (ectx,
                   GE_ERROR | GE_BULK | GE_USER,
                   _("Cannot hash `%s'.\n"), filename);
-          connection_destroy (sock);
-          return SYSERR;
+          GNUNET_client_connection_destroy (sock);
+          return GNUNET_SYSERR;
         }
-      now = get_time ();
+      now = GNUNET_get_time ();
       eta = now + 2 * (now - start);
-      /* very rough estimate: hash reads once through the file,
+      /* very rough estimate: GNUNET_hash reads once through the file,
          we'll do that once more and write it.  But of course
          the second read may be cached, and we have the encryption,
          so a factor of two is really, really just a rough estimate */
       start = now;
       /* reset the counter since the formula later does not
-         take the time for getFileHash into account */
+         take the time for GNUNET_hash_file into account */
 
       switch (FS_initIndex (sock, &fileId, filename))
         {
-        case SYSERR:
+        case GNUNET_SYSERR:
           GE_LOG (ectx,
                   GE_ERROR | GE_BULK | GE_USER,
                   _("Initialization for indexing file `%s' failed.\n"),
                   filename);
-          connection_destroy (sock);
-          return SYSERR;
-        case NO:
+          GNUNET_client_connection_destroy (sock);
+          return GNUNET_SYSERR;
+        case GNUNET_NO:
           GE_LOG (ectx,
                   GE_ERROR | GE_BULK | GE_USER,
                   _("Indexing file `%s' failed. Trying to insert file...\n"),
                   filename);
-          doIndex = YES;
+          doIndex = GNUNET_YES;
           break;
         default:
           break;
         }
     }
   treedepth = computeDepth (filesize);
-  fd = disk_file_open (ectx, filename, O_RDONLY | O_LARGEFILE);
+  fd = GNUNET_disk_file_open (ectx, filename, O_RDONLY | O_LARGEFILE);
   if (fd == -1)
     {
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("Cannot open file `%s': `%s'"), filename, STRERROR (errno));
 
-      connection_destroy (sock);
-      return SYSERR;
+      GNUNET_client_connection_destroy (sock);
+      return GNUNET_SYSERR;
     }
 
-  dblock = MALLOC (sizeof (Datastore_Value) + DBLOCK_SIZE + sizeof (DBlock));
+  dblock =
+    GNUNET_malloc (sizeof (Datastore_Value) + DBLOCK_SIZE + sizeof (DBlock));
   dblock->size =
     htonl (sizeof (Datastore_Value) + DBLOCK_SIZE + sizeof (DBlock));
   dblock->anonymityLevel = htonl (anonymityLevel);
   dblock->prio = htonl (priority);
   dblock->type = htonl (D_BLOCK);
-  dblock->expirationTime = htonll (expirationTime);
+  dblock->expirationTime = GNUNET_htonll (expirationTime);
   db = (DBlock *) & dblock[1];
   db->type = htonl (D_BLOCK);
-  iblocks = MALLOC (sizeof (Datastore_Value *) * (treedepth + 1));
+  iblocks = GNUNET_malloc (sizeof (Datastore_Value *) * (treedepth + 1));
   for (i = 0; i <= treedepth; i++)
     {
       iblocks[i] =
-        MALLOC (sizeof (Datastore_Value) + IBLOCK_SIZE + sizeof (DBlock));
+        GNUNET_malloc (sizeof (Datastore_Value) + IBLOCK_SIZE +
+                       sizeof (DBlock));
       iblocks[i]->size = htonl (sizeof (Datastore_Value) + sizeof (DBlock));
       iblocks[i]->anonymityLevel = htonl (anonymityLevel);
       iblocks[i]->prio = htonl (priority);
       iblocks[i]->type = htonl (D_BLOCK);
-      iblocks[i]->expirationTime = htonll (expirationTime);
+      iblocks[i]->expirationTime = GNUNET_htonll (expirationTime);
       ((DBlock *) & iblocks[i][1])->type = htonl (D_BLOCK);
     }
 
@@ -254,7 +258,7 @@
       if (upcb != NULL)
         upcb (filesize, pos, eta, upcbClosure);
       if (tt != NULL)
-        if (OK != tt (ttClosure))
+        if (GNUNET_OK != tt (ttClosure))
           goto FAILURE;
       size = DBLOCK_SIZE;
       if (size > filesize - pos)
@@ -264,7 +268,7 @@
         }
       GE_ASSERT (ectx,
                  sizeof (Datastore_Value) + size + sizeof (DBlock) <
-                 MAX_BUFFER_SIZE);
+                 GNUNET_MAX_BUFFER_SIZE);
       dblock->size =
         htonl (sizeof (Datastore_Value) + size + sizeof (DBlock));
       if (size != READ (fd, &db[1], size))
@@ -275,21 +279,21 @@
           goto FAILURE;
         }
       if (tt != NULL)
-        if (OK != tt (ttClosure))
+        if (GNUNET_OK != tt (ttClosure))
           goto FAILURE;
       fileBlockGetKey (db, size + sizeof (DBlock), &mchk.key);
       fileBlockGetQuery (db, size + sizeof (DBlock), &mchk.query);
 #if DEBUG_UPLOAD
       IF_GELOG (ectx,
                 GE_DEBUG | GE_REQUEST | GE_USER,
-                hash2enc (&mchk.query, &enc));
+                GNUNET_hash_to_enc (&mchk.query, &enc));
       GE_LOG (ectx,
               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))
+          if (GNUNET_SYSERR == FS_index (sock, &fileId, dblock, pos))
             {
               GE_LOG (ectx,
                       GE_ERROR | GE_BULK | GE_USER,
@@ -300,7 +304,7 @@
       else
         {
           value = NULL;
-          if (OK !=
+          if (GNUNET_OK !=
               fileBlockEncode (db,
                                size + sizeof (DBlock), &mchk.query, &value))
             {
@@ -310,28 +314,28 @@
           GE_ASSERT (ectx, value != NULL);
           *value = *dblock;     /* copy options! */
 
-          if (SYSERR == FS_insert (sock, value))
+          if (GNUNET_SYSERR == FS_insert (sock, value))
             {
               GE_BREAK (ectx, 0);
-              FREE (value);
+              GNUNET_free (value);
               goto FAILURE;
             }
-          FREE (value);
+          GNUNET_free (value);
         }
       pos += size;
-      now = get_time ();
+      now = GNUNET_get_time ();
       if (pos > 0)
         {
-          eta = (cron_t) (start +
-                          (((double) (now - start) / (double) pos))
-                          * (double) filesize);
+          eta = (GNUNET_CronTime) (start +
+                                   (((double) (now - start) / (double) pos))
+                                   * (double) filesize);
         }
-      if (OK != pushBlock (sock, &mchk, 0,      /* dblocks are on level 0 */
-                           iblocks, priority, expirationTime))
+      if (GNUNET_OK != pushBlock (sock, &mchk, 0,       /* dblocks are on 
level 0 */
+                                  iblocks, priority, expirationTime))
         goto FAILURE;
     }
   if (tt != NULL)
-    if (OK != tt (ttClosure))
+    if (GNUNET_OK != tt (ttClosure))
       goto FAILURE;
 #if DEBUG_UPLOAD
   GE_LOG (ectx,
@@ -341,7 +345,7 @@
   for (i = 0; i < treedepth; i++)
     {
       size = ntohl (iblocks[i]->size) - sizeof (Datastore_Value);
-      GE_ASSERT (ectx, size < MAX_BUFFER_SIZE);
+      GE_ASSERT (ectx, size < GNUNET_MAX_BUFFER_SIZE);
       if (size == sizeof (DBlock))
         {
 #if DEBUG_UPLOAD
@@ -361,13 +365,14 @@
 #if DEBUG_UPLOAD
       IF_GELOG (ectx,
                 GE_DEBUG | GE_REQUEST | GE_USER,
-                hash2enc (&mchk.query, &enc));
+                GNUNET_hash_to_enc (&mchk.query, &enc));
       GE_LOG (ectx,
               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))
+      if (GNUNET_OK != pushBlock (sock,
+                                  &mchk, i + 1, iblocks, priority,
+                                  expirationTime))
         {
           GE_BREAK (ectx, 0);
           goto FAILURE;
@@ -378,50 +383,51 @@
           GE_BREAK (ectx, 0);
           goto FAILURE;
         }
-      value->expirationTime = htonll (expirationTime);
+      value->expirationTime = GNUNET_htonll (expirationTime);
       value->prio = htonl (priority);
-      if (SYSERR == FS_insert (sock, value))
+      if (GNUNET_SYSERR == FS_insert (sock, value))
         {
           GE_BREAK (ectx, 0);
-          FREE (value);
+          GNUNET_free (value);
           goto FAILURE;
         }
-      FREE (value);
-      FREE (iblocks[i]);
+      GNUNET_free (value);
+      GNUNET_free (iblocks[i]);
       iblocks[i] = NULL;
     }
 #if DEBUG_UPLOAD
   IF_GELOG (ectx,
-            GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (&mchk.query, &enc));
+            GE_DEBUG | GE_REQUEST | GE_USER, GNUNET_hash_to_enc (&mchk.query,
+                                                                 &enc));
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "Query for top block is %s\n", &enc);
 #endif
   /* build URI */
-  fid.file_length = htonll (filesize);
+  fid.file_length = GNUNET_htonll (filesize);
   db = (DBlock *) & iblocks[treedepth][1];
 
   fid.chk = *(CHK *) & (db[1]);
-  *uri = MALLOC (sizeof (URI));
+  *uri = GNUNET_malloc (sizeof (URI));
   (*uri)->type = chk;
   (*uri)->data.fi = fid;
 
   /* free resources */
-  FREENONNULL (iblocks[treedepth]);
-  FREE (iblocks);
-  FREE (dblock);
+  GNUNET_free_non_null (iblocks[treedepth]);
+  GNUNET_free (iblocks);
+  GNUNET_free (dblock);
   if (upcb != NULL)
     upcb (filesize, filesize, eta, upcbClosure);
   CLOSE (fd);
-  connection_destroy (sock);
-  return OK;
+  GNUNET_client_connection_destroy (sock);
+  return GNUNET_OK;
 FAILURE:
   for (i = 0; i <= treedepth; i++)
-    FREENONNULL (iblocks[i]);
-  FREE (iblocks);
-  FREE (dblock);
+    GNUNET_free_non_null (iblocks[i]);
+  GNUNET_free (iblocks);
+  GNUNET_free (dblock);
   CLOSE (fd);
-  connection_destroy (sock);
-  return SYSERR;
+  GNUNET_client_connection_destroy (sock);
+  return GNUNET_SYSERR;
 }
 
 /* end of upload.c */

Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/uri.c       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -76,7 +76,7 @@
  * </li></ul>
  *
  * The encoding for hexadecimal values is defined in the hashing.c
- * module (EncName) in the gnunet-util library and discussed there.
+ * module (GNUNET_EncName) in the gnunet-util library and discussed there.
  * <p>
  */
 
@@ -100,7 +100,7 @@
     keywordCount + strlen (ECRS_URI_PREFIX) + strlen (ECRS_SEARCH_INFIX) + 1;
   for (i = 0; i < keywordCount; i++)
     n += strlen (keywords[i]);
-  ret = MALLOC (n);
+  ret = GNUNET_malloc (n);
   strcpy (ret, ECRS_URI_PREFIX);
   strcat (ret, ECRS_SEARCH_INFIX);
   for (i = 0; i < keywordCount; i++)
@@ -116,23 +116,24 @@
  * Generate a subspace URI.
  */
 static char *
-createSubspaceURI (const HashCode512 * namespace,
-                   const HashCode512 * identifier)
+createSubspaceURI (const GNUNET_HashCode * namespace,
+                   const GNUNET_HashCode * identifier)
 {
   size_t n;
   char *ret;
-  EncName ns;
-  EncName id;
+  GNUNET_EncName ns;
+  GNUNET_EncName id;
 
   n =
-    sizeof (EncName) * 2 + strlen (ECRS_URI_PREFIX) +
+    sizeof (GNUNET_EncName) * 2 + strlen (ECRS_URI_PREFIX) +
     strlen (ECRS_SUBSPACE_INFIX) + 1;
-  ret = MALLOC (n);
-  hash2enc (namespace, &ns);
-  hash2enc (identifier, &id);
-  SNPRINTF (ret, n,
-            "%s%s%s/%s",
-            ECRS_URI_PREFIX, ECRS_SUBSPACE_INFIX, (char *) &ns, (char *) &id);
+  ret = GNUNET_malloc (n);
+  GNUNET_hash_to_enc (namespace, &ns);
+  GNUNET_hash_to_enc (identifier, &id);
+  GNUNET_snprintf (ret, n,
+                   "%s%s%s/%s",
+                   ECRS_URI_PREFIX, ECRS_SUBSPACE_INFIX, (char *) &ns,
+                   (char *) &id);
   return ret;
 }
 
@@ -143,23 +144,24 @@
 createFileURI (const FileIdentifier * fi)
 {
   char *ret;
-  EncName keyhash;
-  EncName queryhash;
+  GNUNET_EncName keyhash;
+  GNUNET_EncName queryhash;
   size_t n;
 
-  hash2enc (&fi->chk.key, &keyhash);
-  hash2enc (&fi->chk.query, &queryhash);
+  GNUNET_hash_to_enc (&fi->chk.key, &keyhash);
+  GNUNET_hash_to_enc (&fi->chk.query, &queryhash);
 
   n =
-    strlen (ECRS_URI_PREFIX) + 2 * sizeof (EncName) + 8 + 16 + 32 +
+    strlen (ECRS_URI_PREFIX) + 2 * sizeof (GNUNET_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));
+  ret = GNUNET_malloc (n);
+  GNUNET_snprintf (ret,
+                   n,
+                   "%s%s%s.%s.%llu",
+                   ECRS_URI_PREFIX,
+                   ECRS_FILE_INFIX,
+                   (char *) &keyhash, (char *) &queryhash,
+                   GNUNET_ntohll (fi->file_length));
   return ret;
 }
 
@@ -173,28 +175,28 @@
 {
   size_t n;
   char *ret;
-  EncName keyhash;
-  EncName queryhash;
+  GNUNET_EncName keyhash;
+  GNUNET_EncName queryhash;
   char *peerId;
   char *peerSig;
 
-  hash2enc (&loc->fi.chk.key, &keyhash);
-  hash2enc (&loc->fi.chk.query, &queryhash);
+  GNUNET_hash_to_enc (&loc->fi.chk.key, &keyhash);
+  GNUNET_hash_to_enc (&loc->fi.chk.query, &queryhash);
   n = 2148;
-  peerId = bin2enc (&loc->peer, sizeof (PublicKey));
-  peerSig = bin2enc (&loc->contentSignature, 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);
-  FREE (peerSig);
-  FREE (peerId);
+  peerId = bin2enc (&loc->peer, sizeof (GNUNET_RSA_PublicKey));
+  peerSig = bin2enc (&loc->contentSignature, sizeof (GNUNET_RSA_Signature));
+  ret = GNUNET_malloc (n);
+  GNUNET_snprintf (ret,
+                   n,
+                   "%s%s%s.%s.%llu.%s.%s.%u",
+                   ECRS_URI_PREFIX,
+                   ECRS_LOCATION_INFIX,
+                   (char *) &keyhash,
+                   (char *) &queryhash,
+                   GNUNET_ntohll (loc->fi.file_length),
+                   peerId, peerSig, loc->expirationTime);
+  GNUNET_free (peerSig);
+  GNUNET_free (peerId);
   return ret;
 }
 
@@ -232,7 +234,7 @@
  *
  * @param uri an uri string
  * @param keyword will be set to an array with the keywords
- * @return SYSERR if this is not a search URI, otherwise
+ * @return GNUNET_SYSERR if this is not a search URI, otherwise
  *  the number of keywords placed in the array
  */
 static int
@@ -251,9 +253,9 @@
   pos = strlen (ECRS_URI_PREFIX);
 
   if (0 != strncmp (uri, ECRS_URI_PREFIX, pos))
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (0 != strncmp (&uri[pos], ECRS_SEARCH_INFIX, strlen (ECRS_SEARCH_INFIX)))
-    return SYSERR;
+    return GNUNET_SYSERR;
   pos += strlen (ECRS_SEARCH_INFIX);
   if (slen == pos)
     {
@@ -262,7 +264,7 @@
       return 0;
     }
   if ((uri[slen - 1] == '+') || (uri[pos] == '+'))
-    return SYSERR;              /* no keywords / malformed */
+    return GNUNET_SYSERR;       /* no keywords / malformed */
 
   ret = 1;
   for (i = pos; i < slen; i++)
@@ -271,23 +273,23 @@
         {
           ret++;
           if (uri[i - 1] == '+')
-            return SYSERR;      /* "++" not allowed */
+            return GNUNET_SYSERR;       /* "++" not allowed */
         }
     }
   iret = ret;
-  dup = STRDUP (uri);
-  (*keywords) = MALLOC (ret * sizeof (char *));
+  dup = GNUNET_strdup (uri);
+  (*keywords) = GNUNET_malloc (ret * sizeof (char *));
   for (i = slen - 1; i >= pos; i--)
     {
       if (dup[i] == '+')
         {
-          (*keywords)[--ret] = STRDUP (&dup[i + 1]);
+          (*keywords)[--ret] = GNUNET_strdup (&dup[i + 1]);
           dup[i] = '\0';
         }
     }
-  (*keywords)[--ret] = STRDUP (&dup[pos]);
+  (*keywords)[--ret] = GNUNET_strdup (&dup[pos]);
   GE_ASSERT (ectx, ret == 0);
-  FREE (dup);
+  GNUNET_free (dup);
   return iret;
 }
 
@@ -297,12 +299,12 @@
  * @param uri an uri string
  * @param namespace set to the namespace ID
  * @param identifier set to the ID in the namespace
- * @return OK on success, SYSERR if this is not a namespace URI
+ * @return GNUNET_OK on success, GNUNET_SYSERR if this is not a namespace URI
  */
 static int
 parseSubspaceURI (struct GE_Context *ectx,
                   const char *uri,
-                  HashCode512 * namespace, HashCode512 * identifier)
+                  GNUNET_HashCode * namespace, GNUNET_HashCode * identifier)
 {
   unsigned int pos;
   size_t slen;
@@ -314,33 +316,34 @@
   pos = strlen (ECRS_URI_PREFIX);
 
   if (0 != strncmp (uri, ECRS_URI_PREFIX, pos))
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (0 != strncmp (&uri[pos],
                     ECRS_SUBSPACE_INFIX, strlen (ECRS_SUBSPACE_INFIX)))
-    return SYSERR;
+    return GNUNET_SYSERR;
   pos += strlen (ECRS_SUBSPACE_INFIX);
-  if ((slen < pos + sizeof (EncName) + 1) ||
-      (!((uri[pos + sizeof (EncName) - 1] == '/') ||
-         (uri[pos + sizeof (EncName) - 1] == '\\'))))
-    return SYSERR;
+  if ((slen < pos + sizeof (GNUNET_EncName) + 1) ||
+      (!((uri[pos + sizeof (GNUNET_EncName) - 1] == '/') ||
+         (uri[pos + sizeof (GNUNET_EncName) - 1] == '\\'))))
+    return GNUNET_SYSERR;
 
-  up = STRDUP (uri);
-  up[pos + sizeof (EncName) - 1] = '\0';
-  if ((OK != enc2hash (&up[pos], namespace)))
+  up = GNUNET_strdup (uri);
+  up[pos + sizeof (GNUNET_EncName) - 1] = '\0';
+  if ((GNUNET_OK != GNUNET_enc_to_hash (&up[pos], namespace)))
     {
-      FREE (up);
-      return SYSERR;
+      GNUNET_free (up);
+      return GNUNET_SYSERR;
     }
-  if ((slen != pos + 2 * sizeof (EncName) - 1) ||
-      (OK != enc2hash (&up[pos + sizeof (EncName)], identifier)))
+  if ((slen != pos + 2 * sizeof (GNUNET_EncName) - 1) ||
+      (GNUNET_OK !=
+       GNUNET_enc_to_hash (&up[pos + sizeof (GNUNET_EncName)], identifier)))
     {
       if (up[slen - 1] == '\\')
         up[--slen] = '\0';
-      hash (&up[pos + sizeof (EncName)],
-            slen - (pos + sizeof (EncName)), identifier);
+      GNUNET_hash (&up[pos + sizeof (GNUNET_EncName)],
+                   slen - (pos + sizeof (GNUNET_EncName)), identifier);
     }
-  FREE (up);
-  return OK;
+  GNUNET_free (up);
+  return GNUNET_OK;
 }
 
 /**
@@ -348,7 +351,7 @@
  *
  * @param uri an uri string
  * @param fi the file identifier
- * @return OK on success, SYSERR if this is not a file URI
+ * @return GNUNET_OK on success, GNUNET_SYSERR if this is not a file URI
  */
 static int
 parseFileURI (struct GE_Context *ectx, const char *uri, FileIdentifier * fi)
@@ -363,31 +366,31 @@
   pos = strlen (ECRS_URI_PREFIX);
 
   if (0 != strncmp (uri, ECRS_URI_PREFIX, pos))
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (0 != strncmp (&uri[pos], ECRS_FILE_INFIX, strlen (ECRS_FILE_INFIX)))
-    return SYSERR;
+    return GNUNET_SYSERR;
   pos += strlen (ECRS_FILE_INFIX);
-  if ((slen < pos + 2 * sizeof (EncName) + 1) ||
-      (uri[pos + sizeof (EncName) - 1] != '.') ||
-      (uri[pos + sizeof (EncName) * 2 - 1] != '.'))
-    return SYSERR;
+  if ((slen < pos + 2 * sizeof (GNUNET_EncName) + 1) ||
+      (uri[pos + sizeof (GNUNET_EncName) - 1] != '.') ||
+      (uri[pos + sizeof (GNUNET_EncName) * 2 - 1] != '.'))
+    return GNUNET_SYSERR;
 
-  dup = STRDUP (uri);
-  dup[pos + sizeof (EncName) - 1] = '\0';
-  dup[pos + sizeof (EncName) * 2 - 1] = '\0';
-  if ((OK != enc2hash (&dup[pos],
-                       &fi->chk.key)) ||
-      (OK != enc2hash (&dup[pos + sizeof (EncName)],
-                       &fi->chk.query)) ||
-      (1 != SSCANF (&dup[pos + sizeof (EncName) * 2],
+  dup = GNUNET_strdup (uri);
+  dup[pos + sizeof (GNUNET_EncName) - 1] = '\0';
+  dup[pos + sizeof (GNUNET_EncName) * 2 - 1] = '\0';
+  if ((GNUNET_OK != GNUNET_enc_to_hash (&dup[pos],
+                                        &fi->chk.key)) ||
+      (GNUNET_OK != GNUNET_enc_to_hash (&dup[pos + sizeof (GNUNET_EncName)],
+                                        &fi->chk.query)) ||
+      (1 != SSCANF (&dup[pos + sizeof (GNUNET_EncName) * 2],
                     "%llu", &fi->file_length)))
     {
-      FREE (dup);
-      return SYSERR;
+      GNUNET_free (dup);
+      return GNUNET_SYSERR;
     }
-  FREE (dup);
-  fi->file_length = htonll (fi->file_length);
-  return OK;
+  GNUNET_free (dup);
+  fi->file_length = GNUNET_htonll (fi->file_length);
+  return GNUNET_OK;
 }
 
 /**
@@ -396,7 +399,7 @@
  *
  * @param uri an uri string
  * @param loc where to store the location
- * @return OK on success, SYSERR if this is not a file URI
+ * @return GNUNET_OK on success, GNUNET_SYSERR if this is not a file URI
  */
 static int
 parseLocationURI (struct GE_Context *ectx, const char *uri, Location * loc)
@@ -415,40 +418,42 @@
   pos = strlen (ECRS_URI_PREFIX);
 
   if (0 != strncmp (uri, ECRS_URI_PREFIX, pos))
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (0 != strncmp (&uri[pos],
                     ECRS_LOCATION_INFIX, strlen (ECRS_LOCATION_INFIX)))
-    return SYSERR;
+    return GNUNET_SYSERR;
   pos += strlen (ECRS_LOCATION_INFIX);
-  if ((slen < pos + 2 * sizeof (EncName) + 1) ||
-      (uri[pos + sizeof (EncName) - 1] != '.') ||
-      (uri[pos + sizeof (EncName) * 2 - 1] != '.'))
-    return SYSERR;
+  if ((slen < pos + 2 * sizeof (GNUNET_EncName) + 1) ||
+      (uri[pos + sizeof (GNUNET_EncName) - 1] != '.') ||
+      (uri[pos + sizeof (GNUNET_EncName) * 2 - 1] != '.'))
+    return GNUNET_SYSERR;
 
-  dup = STRDUP (uri);
-  dup[pos + sizeof (EncName) - 1] = '\0';
-  dup[pos + sizeof (EncName) * 2 - 1] = '\0';
-  npos = pos + sizeof (EncName) * 2;
+  dup = GNUNET_strdup (uri);
+  dup[pos + sizeof (GNUNET_EncName) - 1] = '\0';
+  dup[pos + sizeof (GNUNET_EncName) * 2 - 1] = '\0';
+  npos = pos + sizeof (GNUNET_EncName) * 2;
   while ((uri[npos] != '\0') && (uri[npos] != '.'))
     npos++;
   if (dup[npos] == '\0')
     goto ERR;
   dup[npos++] = '\0';
-  if ((OK != enc2hash (&dup[pos],
-                       &loc->fi.chk.key)) ||
-      (OK != enc2hash (&dup[pos + sizeof (EncName)],
-                       &loc->fi.chk.query)) ||
-      (1 != SSCANF (&dup[pos + sizeof (EncName) * 2],
+  if ((GNUNET_OK != GNUNET_enc_to_hash (&dup[pos],
+                                        &loc->fi.chk.key)) ||
+      (GNUNET_OK != GNUNET_enc_to_hash (&dup[pos + sizeof (GNUNET_EncName)],
+                                        &loc->fi.chk.query)) ||
+      (1 != SSCANF (&dup[pos + sizeof (GNUNET_EncName) * 2],
                     "%llu", &loc->fi.file_length)))
     goto ERR;
-  loc->fi.file_length = htonll (loc->fi.file_length);
-  ret = enc2bin (&dup[npos], &loc->peer, sizeof (PublicKey));
+  loc->fi.file_length = GNUNET_htonll (loc->fi.file_length);
+  ret = enc2bin (&dup[npos], &loc->peer, sizeof (GNUNET_RSA_PublicKey));
   if (ret == -1)
     goto ERR;
   npos += ret;
   if (dup[npos++] != '.')
     goto ERR;
-  ret = enc2bin (&dup[npos], &loc->contentSignature, sizeof (Signature));
+  ret =
+    enc2bin (&dup[npos], &loc->contentSignature,
+             sizeof (GNUNET_RSA_Signature));
   if (ret == -1)
     goto ERR;
   npos += ret;
@@ -457,17 +462,18 @@
   if (1 != SSCANF (&dup[npos], "%u", &loc->expirationTime))
     goto ERR;
   /* Finally: verify sigs! */
-  if (OK != verifySig (&loc->fi,
-                       sizeof (FileIdentifier) +
-                       sizeof (PeerIdentity) +
-                       sizeof (TIME_T), &loc->contentSignature, &loc->peer))
+  if (GNUNET_OK != GNUNET_RSA_verify (&loc->fi,
+                                      sizeof (FileIdentifier) +
+                                      sizeof (GNUNET_PeerIdentity) +
+                                      sizeof (GNUNET_Int32Time),
+                                      &loc->contentSignature, &loc->peer))
     goto ERR;
-  FREE (dup);
-  return OK;
+  GNUNET_free (dup);
+  return GNUNET_OK;
 ERR:
-  FREE (dup);
-  FREENONNULL (addr);
-  return SYSERR;
+  GNUNET_free (dup);
+  GNUNET_free_non_null (addr);
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -479,21 +485,21 @@
   URI *ret;
   int len;
 
-  ret = MALLOC (sizeof (URI));
-  if (OK == parseFileURI (ectx, uri, &ret->data.fi))
+  ret = GNUNET_malloc (sizeof (URI));
+  if (GNUNET_OK == parseFileURI (ectx, uri, &ret->data.fi))
     {
       ret->type = chk;
       return ret;
     }
-  if (OK == parseSubspaceURI (ectx,
-                              uri,
-                              &ret->data.sks.namespace,
-                              &ret->data.sks.identifier))
+  if (GNUNET_OK == parseSubspaceURI (ectx,
+                                     uri,
+                                     &ret->data.sks.namespace,
+                                     &ret->data.sks.identifier))
     {
       ret->type = sks;
       return ret;
     }
-  if (OK == parseLocationURI (ectx, uri, &ret->data.loc))
+  if (GNUNET_OK == parseLocationURI (ectx, uri, &ret->data.loc))
     {
       ret->type = loc;
       return ret;
@@ -501,7 +507,7 @@
   len = parseKeywordURI (ectx, uri, &ret->data.ksk.keywords);
   if (len < 0)
     {
-      FREE (ret);
+      GNUNET_free (ret);
       return NULL;
     }
   ret->type = ksk;
@@ -522,8 +528,9 @@
     {
     case ksk:
       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);
+        GNUNET_free (uri->data.ksk.keywords[i]);
+      GNUNET_array_grow (uri->data.ksk.keywords, uri->data.ksk.keywordCount,
+                         0);
       break;
     case loc:
       break;
@@ -531,7 +538,7 @@
       /* do nothing */
       break;
     }
-  FREE (uri);
+  GNUNET_free (uri);
 }
 
 /**
@@ -546,16 +553,16 @@
 /**
  * Get the (globally unique) name for the given namespace.
  *
- * @return the name (hash) of the namespace, caller
+ * @return the name (GNUNET_hash) of the namespace, caller
  *  must free it.
  */
 char *
-ECRS_getNamespaceName (const HashCode512 * id)
+ECRS_getNamespaceName (const GNUNET_HashCode * id)
 {
   char *ret;
 
-  ret = MALLOC (sizeof (EncName));
-  hash2enc (id, (EncName *) ret);
+  ret = GNUNET_malloc (sizeof (GNUNET_EncName));
+  GNUNET_hash_to_enc (id, (GNUNET_EncName *) ret);
   return ret;
 }
 
@@ -563,35 +570,35 @@
  * Get the (globally unique) ID of the namespace
  * from the given namespace URI.
  *
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int
-ECRS_getNamespaceId (const struct ECRS_URI *uri, HashCode512 * id)
+ECRS_getNamespaceId (const struct ECRS_URI *uri, GNUNET_HashCode * id)
 {
   if (!ECRS_isNamespaceUri (uri))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   *id = uri->data.sks.namespace;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Get the content ID of an SKS URI.
  *
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 int
-ECRS_getSKSContentHash (const struct ECRS_URI *uri, HashCode512 * id)
+ECRS_getSKSContentHash (const struct ECRS_URI *uri, GNUNET_HashCode * id)
 {
   if (!ECRS_isNamespaceUri (uri))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   *id = uri->data.sks.identifier;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -643,7 +650,7 @@
     {
       for (i = 0; i < uri->data.ksk.keywordCount; i++)
         if (iterator != NULL)
-          if (OK != iterator (uri->data.ksk.keywords[i], cls))
+          if (GNUNET_OK != iterator (uri->data.ksk.keywords[i], cls))
             return i;
       return i;
     }
@@ -679,9 +686,9 @@
   switch (uri->type)
     {
     case chk:
-      return ntohll (uri->data.fi.file_length);
+      return GNUNET_ntohll (uri->data.fi.file_length);
     case loc:
-      return ntohll (uri->data.loc.fi.file_length);
+      return GNUNET_ntohll (uri->data.loc.fi.file_length);
     default:
       GE_ASSERT (NULL, 0);
     }
@@ -698,7 +705,7 @@
   struct ECRS_URI *ret;
   int i;
 
-  ret = MALLOC (sizeof (URI));
+  ret = GNUNET_malloc (sizeof (URI));
   memcpy (ret, uri, sizeof (URI));
   switch (ret->type)
     {
@@ -706,9 +713,10 @@
       if (ret->data.ksk.keywordCount > 0)
         {
           ret->data.ksk.keywords
-            = MALLOC (ret->data.ksk.keywordCount * sizeof (char *));
+            = GNUNET_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] =
+              GNUNET_strdup (uri->data.ksk.keywords[i]);
         }
       break;
     case loc:
@@ -743,19 +751,20 @@
   t = *gmtime (&now);
 #endif
 
-  ret = MALLOC (sizeof (URI));
+  ret = GNUNET_malloc (sizeof (URI));
   ret->type = ksk;
   keywordCount = uri->data.ksk.keywordCount;
   ret->data.ksk.keywordCount = 2 * keywordCount;
   if (keywordCount > 0)
     {
-      ret->data.ksk.keywords = MALLOC (sizeof (char *) * keywordCount * 2);
+      ret->data.ksk.keywords =
+        GNUNET_malloc (sizeof (char *) * keywordCount * 2);
       for (i = 0; i < keywordCount; i++)
         {
           key = uri->data.ksk.keywords[i];
           GE_ASSERT (NULL, key != NULL);
-          ret->data.ksk.keywords[2 * i] = STRDUP (key);
-          kd = MALLOC (strlen (key) + 13);
+          ret->data.ksk.keywords[2 * i] = GNUNET_strdup (key);
+          kd = GNUNET_malloc (strlen (key) + 13);
           memset (kd, 0, strlen (key) + 13);
           strcpy (kd, key);
           strftime (&kd[strlen (key)], 13, "-%Y-%m-%d", &t);
@@ -785,7 +794,7 @@
 
   if (md == NULL)
     return NULL;
-  ret = MALLOC (sizeof (URI));
+  ret = GNUNET_malloc (sizeof (URI));
   ret->type = ksk;
   ret->data.ksk.keywordCount = 0;
   ret->data.ksk.keywords = NULL;
@@ -808,8 +817,8 @@
             }
         }
     }
-  GROW (ret->data.ksk.keywords,
-        ret->data.ksk.keywordCount, md->itemCount - havePreview);
+  GNUNET_array_grow (ret->data.ksk.keywords,
+                     ret->data.ksk.keywordCount, md->itemCount - havePreview);
   for (i = md->itemCount - 1; i >= 0; i--)
     {
       if (md->items[i].type == EXTRACTOR_THUMBNAIL_DATA)
@@ -832,7 +841,7 @@
             {
               GE_ASSERT (NULL, md->items[i].data != NULL);
               ret->data.ksk.keywords[i - havePreview]
-                = STRDUP (md->items[i].data);
+                = GNUNET_strdup (md->items[i].data);
             }
         }
     }
@@ -854,13 +863,14 @@
   while (keyword[count] != NULL)
     count++;
 
-  ret = MALLOC (sizeof (URI));
+  ret = GNUNET_malloc (sizeof (URI));
   ret->type = ksk;
   ret->data.ksk.keywordCount = 0;
   ret->data.ksk.keywords = NULL;
-  GROW (ret->data.ksk.keywords, ret->data.ksk.keywordCount, count);
+  GNUNET_array_grow (ret->data.ksk.keywords, ret->data.ksk.keywordCount,
+                     count);
   for (i = 0; i < count; i++)
-    ret->data.ksk.keywords[i] = STRDUP (keyword[i]);
+    ret->data.ksk.keywords[i] = GNUNET_strdup (keyword[i]);
   return ret;
 }
 
@@ -879,66 +889,69 @@
   GE_ASSERT (NULL, uri1 != NULL);
   GE_ASSERT (NULL, uri2 != NULL);
   if (uri1->type != uri2->type)
-    return NO;
+    return GNUNET_NO;
   switch (uri1->type)
     {
     case chk:
       if (0 == memcmp (&uri1->data.fi,
                        &uri2->data.fi, sizeof (FileIdentifier)))
-        return YES;
-      return NO;
+        return GNUNET_YES;
+      return GNUNET_NO;
     case sks:
-      if (equalsHashCode512 (&uri1->data.sks.namespace,
-                             &uri2->data.sks.namespace) &&
-          equalsHashCode512 (&uri1->data.sks.identifier,
-                             &uri2->data.sks.identifier))
+      if ((0 == memcmp (&uri1->data.sks.namespace,
+                        &uri2->data.sks.namespace,
+                        sizeof (GNUNET_HashCode))) &&
+          (0 == memcmp (&uri1->data.sks.identifier,
+                        &uri2->data.sks.identifier,
+                        sizeof (GNUNET_HashCode))))
 
-        return YES;
-      return NO;
+        return GNUNET_YES;
+      return GNUNET_NO;
     case ksk:
       if (uri1->data.ksk.keywordCount != uri2->data.ksk.keywordCount)
-        return NO;
+        return GNUNET_NO;
       for (i = 0; i < uri1->data.ksk.keywordCount; i++)
         {
-          ret = NO;
+          ret = GNUNET_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;
+                  ret = GNUNET_YES;
                   break;
                 }
             }
-          if (ret == NO)
-            return NO;
+          if (ret == GNUNET_NO)
+            return GNUNET_NO;
         }
-      return YES;
+      return GNUNET_YES;
     case loc:
       if (memcmp (&uri1->data.loc,
                   &uri2->data.loc,
                   sizeof (FileIdentifier) +
-                  sizeof (PublicKey) +
-                  sizeof (TIME_T) +
+                  sizeof (GNUNET_RSA_PublicKey) +
+                  sizeof (GNUNET_Int32Time) +
                   sizeof (unsigned short) + sizeof (unsigned short)) != 0)
-        return NO;
-      return YES;
+        return GNUNET_NO;
+      return GNUNET_YES;
     default:
-      return NO;
+      return GNUNET_NO;
     }
 }
 
 /**
  * Obtain the identity of the peer offering the data
- * @return -1 if this is not a location URI, otherwise OK
+ * @return -1 if this is not a location URI, otherwise GNUNET_OK
  */
 int
-ECRS_getPeerFromUri (const struct ECRS_URI *uri, PeerIdentity * peer)
+ECRS_getPeerFromUri (const struct ECRS_URI *uri, GNUNET_PeerIdentity * peer)
 {
   if (uri->type != loc)
     return -1;
-  hash (&uri->data.loc.peer, sizeof (PublicKey), &peer->hashPubKey);
-  return OK;
+  GNUNET_hash (&uri->data.loc.peer, sizeof (GNUNET_RSA_PublicKey),
+               &peer->hashPubKey);
+  return GNUNET_OK;
 }
 
 /**
@@ -953,7 +966,7 @@
 
   if (uri->type != loc)
     return NULL;
-  ret = MALLOC (sizeof (struct ECRS_URI));
+  ret = GNUNET_malloc (sizeof (struct ECRS_URI));
   ret->type = chk;
   ret->data.fi = uri->data.loc.fi;
   return ret;
@@ -974,8 +987,8 @@
  */
 struct ECRS_URI *
 ECRS_uriFromLocation (const struct ECRS_URI *baseUri,
-                      const PublicKey * sender,
-                      TIME_T expirationTime,
+                      const GNUNET_RSA_PublicKey * sender,
+                      GNUNET_Int32Time expirationTime,
                       ECRS_SignFunction signer, void *signer_cls)
 {
   struct ECRS_URI *uri;
@@ -983,15 +996,15 @@
   if (baseUri->type != chk)
     return NULL;
 
-  uri = MALLOC (sizeof (struct ECRS_URI));
+  uri = GNUNET_malloc (sizeof (struct ECRS_URI));
   uri->type = loc;
   uri->data.loc.fi = baseUri->data.fi;
   uri->data.loc.peer = *sender;
   uri->data.loc.expirationTime = expirationTime;
   signer (signer_cls,
           sizeof (FileIdentifier) +
-          sizeof (PeerIdentity) +
-          sizeof (TIME_T),
+          sizeof (GNUNET_PeerIdentity) +
+          sizeof (GNUNET_Int32Time),
           &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-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs/uritest.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -59,11 +59,11 @@
   uri = ECRS_uriToString (ret);
   if (0 != strcmp (uri, "gnunet://ecrs/ksk/foo+bar"))
     {
-      FREE (uri);
+      GNUNET_free (uri);
       ECRS_freeUri (ret);
       ABORT ();
     }
-  FREE (uri);
+  GNUNET_free (uri);
   ECRS_freeUri (ret);
   return 0;
 }
@@ -74,18 +74,19 @@
   struct ECRS_URI *uri;
   char *uric;
   struct ECRS_URI *uri2;
-  PublicKey pk;
-  struct PrivateKey *hk;
+  GNUNET_RSA_PublicKey pk;
+  struct GNUNET_RSA_PrivateKey *hk;
   struct ECRS_URI *baseURI;
 
   baseURI =
     ECRS_stringToUri (NULL,
                       
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42");
-  hk = makePrivateKey ();
-  getPublicKey (hk, &pk);
+  hk = GNUNET_RSA_create_key ();
+  GNUNET_RSA_get_public_key (hk, &pk);
   uri = ECRS_uriFromLocation (baseURI,
-                              &pk, 43, (ECRS_SignFunction) & sign, hk);
-  freePrivateKey (hk);
+                              &pk, 43, (ECRS_SignFunction) & GNUNET_RSA_sign,
+                              hk);
+  GNUNET_RSA_free_key (hk);
   if (uri == NULL)
     {
       GE_BREAK (NULL, 0);
@@ -116,14 +117,14 @@
   printf ("URI: `%s'\n", uric);
 #endif
   uri2 = ECRS_stringToUri (NULL, uric);
-  FREE (uric);
+  GNUNET_free (uric);
   if (uri2 == NULL)
     {
       GE_BREAK (NULL, 0);
       ECRS_freeUri (uri);
       return 1;
     }
-  if (YES != ECRS_equalsUri (uri, uri2))
+  if (GNUNET_YES != ECRS_equalsUri (uri, uri2))
     {
       GE_BREAK (NULL, 0);
       ECRS_freeUri (uri);
@@ -172,10 +173,10 @@
                    
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/TOJB1NAAUVJKJAGQHRHS22N9I8VM32C0ESN4EFS836IT950E1MP7LGC5V2GE3LFO9U4BP23VQPTH8DPIOC2CONT9LM76ULVL00KAHVO"))
     {
       ECRS_freeUri (ret);
-      FREE (uri);
+      GNUNET_free (uri);
       ABORT ();
     }
-  FREE (uri);
+  GNUNET_free (uri);
   ECRS_freeUri (ret);
   return 0;
 }
@@ -213,7 +214,7 @@
       ECRS_freeUri (ret);
       ABORT ();
     }
-  if (ntohll (ret->data.fi.file_length) != 42)
+  if (GNUNET_ntohll (ret->data.fi.file_length) != 42)
     {
       ECRS_freeUri (ret);
       ABORT ();
@@ -223,11 +224,11 @@
   if (0 != strcmp (uri,
                    
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42"))
     {
-      FREE (uri);
+      GNUNET_free (uri);
       ECRS_freeUri (ret);
       ABORT ();
     }
-  FREE (uri);
+  GNUNET_free (uri);
   ECRS_freeUri (ret);
   return 0;
 }

Modified: GNUnet/src/applications/fs/ecrs_core.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs_core.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -40,46 +40,47 @@
  *        the anonymityLevel is to be set to 0
  *        (caller should have checked before calling
  *        this method).
- * @return OK on success, SYSERR if data does not
+ * @return GNUNET_OK on success, GNUNET_SYSERR if data does not
  *  match the query
  */
 int
 fileBlockEncode (const DBlock * data,
                  unsigned int len,
-                 const HashCode512 * query, Datastore_Value ** value)
+                 const GNUNET_HashCode * query, Datastore_Value ** value)
 {
-  HashCode512 hc;
-  SESSIONKEY skey;
-  INITVECTOR iv;                /* initial value */
+  GNUNET_HashCode hc;
+  GNUNET_AES_SessionKey skey;
+  GNUNET_AES_InitializationVector iv;   /* initial value */
   Datastore_Value *val;
   DBlock *db;
 
   GE_ASSERT (NULL, len >= sizeof (DBlock));
   GE_ASSERT (NULL, (data != NULL) && (query != NULL));
-  hash (&data[1], len - sizeof (DBlock), &hc);
-  hashToKey (&hc, &skey, &iv);
-  val = MALLOC (sizeof (Datastore_Value) + len);
+  GNUNET_hash (&data[1], len - sizeof (DBlock), &hc);
+  GNUNET_hash_to_AES_key (&hc, &skey, &iv);
+  val = GNUNET_malloc (sizeof (Datastore_Value) + len);
   val->size = htonl (sizeof (Datastore_Value) + len);
   val->type = htonl (D_BLOCK);
   val->prio = htonl (0);
   val->anonymityLevel = htonl (0);
-  val->expirationTime = htonll (0);
+  val->expirationTime = GNUNET_htonll (0);
   db = (DBlock *) & val[1];
   db->type = htonl (D_BLOCK);
-  GE_ASSERT (NULL, len - sizeof (DBlock) < MAX_BUFFER_SIZE);
+  GE_ASSERT (NULL, len - sizeof (DBlock) < GNUNET_MAX_BUFFER_SIZE);
   GE_ASSERT (NULL,
              len - sizeof (DBlock)
-             == encryptBlock (&data[1],
-                              len - sizeof (DBlock), &skey, &iv, &db[1]));
-  hash (&db[1], len - sizeof (DBlock), &hc);
-  if (!equalsHashCode512 (query, &hc))
+             == GNUNET_AES_encrypt (&data[1],
+                                    len - sizeof (DBlock), &skey, &iv,
+                                    &db[1]));
+  GNUNET_hash (&db[1], len - sizeof (DBlock), &hc);
+  if (0 != memcmp (query, &hc, sizeof (GNUNET_HashCode)))
     {
-      FREE (val);
+      GNUNET_free (val);
       *value = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   *value = val;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -87,10 +88,10 @@
  * a certain block of data.
  */
 void
-fileBlockGetKey (const DBlock * data, unsigned int len, HashCode512 * key)
+fileBlockGetKey (const DBlock * data, unsigned int len, GNUNET_HashCode * key)
 {
   GE_ASSERT (NULL, len >= sizeof (DBlock));
-  hash (&data[1], len - sizeof (DBlock), key);
+  GNUNET_hash (&data[1], len - sizeof (DBlock), key);
 }
 
 /**
@@ -100,24 +101,25 @@
  * @param db the block in plaintext
  */
 void
-fileBlockGetQuery (const DBlock * db, unsigned int len, HashCode512 * query)
+fileBlockGetQuery (const DBlock * db, unsigned int len,
+                   GNUNET_HashCode * query)
 {
   char *tmp;
   const char *data;
-  HashCode512 hc;
-  SESSIONKEY skey;
-  INITVECTOR iv;
+  GNUNET_HashCode hc;
+  GNUNET_AES_SessionKey skey;
+  GNUNET_AES_InitializationVector iv;
 
   GE_ASSERT (NULL, len >= sizeof (DBlock));
   data = (const char *) &db[1];
   len -= sizeof (DBlock);
-  GE_ASSERT (NULL, len < MAX_BUFFER_SIZE);
-  hash (data, len, &hc);
-  hashToKey (&hc, &skey, &iv);
-  tmp = MALLOC (len);
-  GE_ASSERT (NULL, len == encryptBlock (data, len, &skey, &iv, tmp));
-  hash (tmp, len, query);
-  FREE (tmp);
+  GE_ASSERT (NULL, len < GNUNET_MAX_BUFFER_SIZE);
+  GNUNET_hash (data, len, &hc);
+  GNUNET_hash_to_AES_key (&hc, &skey, &iv);
+  tmp = GNUNET_malloc (len);
+  GE_ASSERT (NULL, len == GNUNET_AES_encrypt (data, len, &skey, &iv, tmp));
+  GNUNET_hash (tmp, len, query);
+  GNUNET_free (tmp);
 }
 
 unsigned int
@@ -137,12 +139,12 @@
  *
  * @param data the content (encoded)
  * @param query set to the query for the content
- * @return SYSERR if the content is invalid or
+ * @return GNUNET_SYSERR if the content is invalid or
  *   the content type is not known
  */
 int
 getQueryFor (unsigned int size,
-             const DBlock * data, int verify, HashCode512 * query)
+             const DBlock * data, int verify, GNUNET_HashCode * query)
 {
   unsigned int type;
 
@@ -150,36 +152,36 @@
   if (type == ANY_BLOCK)
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   switch (type)
     {
     case D_BLOCK:
-      /* CHK: hash of content == query */
-      hash (&data[1], size - sizeof (DBlock), query);
-      return OK;
+      /* CHK: GNUNET_hash of content == query */
+      GNUNET_hash (&data[1], size - sizeof (DBlock), query);
+      return GNUNET_OK;
     case S_BLOCK:
       {
         const SBlock *sb;
         if (size < sizeof (SBlock))
           {
             GE_BREAK (NULL, 0);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         sb = (const SBlock *) data;
-        if ((verify == YES) &&
-            (OK != verifySig (&sb->identifier,
-                              size
-                              - sizeof (Signature)
-                              - sizeof (PublicKey)
-                              - sizeof (unsigned int),
-                              &sb->signature, &sb->subspace)))
+        if ((verify == GNUNET_YES) &&
+            (GNUNET_OK != GNUNET_RSA_verify (&sb->identifier,
+                                             size
+                                             - sizeof (GNUNET_RSA_Signature)
+                                             - sizeof (GNUNET_RSA_PublicKey)
+                                             - sizeof (unsigned int),
+                                             &sb->signature, &sb->subspace)))
           {
             GE_BREAK (NULL, 0);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         *query = sb->identifier;
-        return OK;
+        return GNUNET_OK;
       }
     case K_BLOCK:
       {
@@ -187,19 +189,20 @@
         if (size < sizeof (KBlock))
           {
             GE_BREAK (NULL, 0);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         kb = (const KBlock *) data;
-        if ((verify == YES) &&
-            ((OK != verifySig (&kb[1],
-                               size - sizeof (KBlock),
-                               &kb->signature, &kb->keyspace))))
+        if ((verify == GNUNET_YES) &&
+            ((GNUNET_OK != GNUNET_RSA_verify (&kb[1],
+                                              size - sizeof (KBlock),
+                                              &kb->signature,
+                                              &kb->keyspace))))
           {
             GE_BREAK (NULL, 0);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
-        hash (&kb->keyspace, sizeof (PublicKey), query);
-        return OK;
+        GNUNET_hash (&kb->keyspace, sizeof (GNUNET_RSA_PublicKey), query);
+        return GNUNET_OK;
       }
     case N_BLOCK:
       {
@@ -207,22 +210,22 @@
         if (size < sizeof (NBlock))
           {
             GE_BREAK (NULL, 0);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         nb = (const NBlock *) data;
-        if ((verify == YES) &&
-            (OK != verifySig (&nb->identifier,
-                              size
-                              - sizeof (Signature)
-                              - sizeof (PublicKey)
-                              - sizeof (unsigned int),
-                              &nb->signature, &nb->subspace)))
+        if ((verify == GNUNET_YES) &&
+            (GNUNET_OK != GNUNET_RSA_verify (&nb->identifier,
+                                             size
+                                             - sizeof (GNUNET_RSA_Signature)
+                                             - sizeof (GNUNET_RSA_PublicKey)
+                                             - sizeof (unsigned int),
+                                             &nb->signature, &nb->subspace)))
           {
             GE_BREAK (NULL, 0);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         *query = nb->namespace; /* XOR with all zeros makes no difference... */
-        return OK;
+        return GNUNET_OK;
       }
     case KN_BLOCK:
       {
@@ -230,31 +233,33 @@
         if (size < sizeof (KNBlock))
           {
             GE_BREAK (NULL, 0);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         kb = (const KNBlock *) data;
-        if ((verify == YES) &&
-            ((OK != verifySig (&kb->nblock,
-                               size
-                               - sizeof (KBlock)
-                               - sizeof (unsigned int),
-                               &kb->kblock.signature, &kb->kblock.keyspace))))
+        if ((verify == GNUNET_YES) &&
+            ((GNUNET_OK != GNUNET_RSA_verify (&kb->nblock,
+                                              size
+                                              - sizeof (KBlock)
+                                              - sizeof (unsigned int),
+                                              &kb->kblock.signature,
+                                              &kb->kblock.keyspace))))
           {
             GE_BREAK (NULL, 0);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
-        hash (&kb->kblock.keyspace, sizeof (PublicKey), query);
-        return OK;
+        GNUNET_hash (&kb->kblock.keyspace, sizeof (GNUNET_RSA_PublicKey),
+                     query);
+        return GNUNET_OK;
       }
     case ONDEMAND_BLOCK:
       {
         GE_BREAK (NULL, 0);     /* should never be used here! */
-        return SYSERR;
+        return GNUNET_SYSERR;
       }
     default:
       {
         GE_BREAK (NULL, 0);     /* unknown block type */
-        return SYSERR;
+        return GNUNET_SYSERR;
       }
     }                           /* end switch */
 }
@@ -271,60 +276,62 @@
  * @param keyCount the number of keys in the query,
  *        use 0 to match only primary key
  * @param keys the keys of the query
- * @return YES if this data matches the query, otherwise
- *         NO; SYSERR if the keyCount does not match the
+ * @return GNUNET_YES if this data matches the query, otherwise
+ *         GNUNET_NO; GNUNET_SYSERR if the keyCount does not match the
  *         query type
  */
 int
 isDatumApplicable (unsigned int type,
                    unsigned int size,
                    const DBlock * data,
-                   const HashCode512 * hc,
-                   unsigned int keyCount, const HashCode512 * keys)
+                   const GNUNET_HashCode * hc,
+                   unsigned int keyCount, const GNUNET_HashCode * keys)
 {
-  HashCode512 h;
+  GNUNET_HashCode h;
 
   if (type != getTypeOfBlock (size, data))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;            /* type mismatch */
+      return GNUNET_SYSERR;     /* type mismatch */
     }
-  if (!equalsHashCode512 (hc, &keys[0]))
+  if (0 != memcmp (hc, &keys[0], sizeof (GNUNET_HashCode)))
     {
       GE_BREAK (NULL, 0);       /* mismatch between primary queries,
                                    we should not even see those here. */
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (keyCount == 0)
-    return YES;                 /* request was to match only primary key */
+    return GNUNET_YES;          /* request was to match only primary key */
   switch (type)
     {
     case S_BLOCK:
       if (keyCount != 2)
-        return SYSERR;          /* no match */
-      hash (&((const SBlock *) data)->subspace, sizeof (PublicKey), &h);
-      if (equalsHashCode512 (&keys[1], &h))
-        return OK;
-      return SYSERR;
+        return GNUNET_SYSERR;   /* no match */
+      GNUNET_hash (&((const SBlock *) data)->subspace,
+                   sizeof (GNUNET_RSA_PublicKey), &h);
+      if (0 == memcmp (&keys[1], &h, sizeof (GNUNET_HashCode)))
+        return GNUNET_OK;
+      return GNUNET_SYSERR;
     case N_BLOCK:
       if (keyCount != 2)
-        return SYSERR;          /* no match */
-      hash (&((const NBlock *) data)->subspace, sizeof (PublicKey), &h);
-      if (!equalsHashCode512 (&keys[1], &h))
-        return SYSERR;
-      return OK;
+        return GNUNET_SYSERR;   /* no match */
+      GNUNET_hash (&((const NBlock *) data)->subspace,
+                   sizeof (GNUNET_RSA_PublicKey), &h);
+      if (0 != memcmp (&keys[1], &h, sizeof (GNUNET_HashCode)))
+        return GNUNET_SYSERR;
+      return GNUNET_OK;
     case D_BLOCK:
     case K_BLOCK:
     case KN_BLOCK:
       if (keyCount != 1)
         GE_BREAK (NULL, 0);     /* keyCount should be 1 */
-      return OK;                /* if query matches, everything matches! */
+      return GNUNET_OK;         /* if query matches, everything matches! */
     case ANY_BLOCK:
       GE_BREAK (NULL, 0);       /* block type should be known */
-      return SYSERR;
+      return GNUNET_SYSERR;
     default:
       GE_BREAK (NULL, 0);       /* unknown block type */
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 }
 

Modified: GNUnet/src/applications/fs/ecrs_core_test.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core_test.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/ecrs_core_test.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -28,30 +28,31 @@
 #include "ecrs_core.h"
 #include "gnunet_protocols.h"
 
-#define CHECK(a,b) { if (! (a)) { fprintf(stderr, "Error at %s:%d\n", 
__FILE__, __LINE__); FREENONNULL(b); return 1; } }
+#define CHECK(a,b) { if (! (a)) { fprintf(stderr, "Error at %s:%d\n", 
__FILE__, __LINE__); GNUNET_free_non_null(b); return 1; } }
 
 static int
 testEC ()
 {
   DBlock *data;
   Datastore_Value *value;
-  HashCode512 query;
-  HashCode512 key;
+  GNUNET_HashCode query;
+  GNUNET_HashCode key;
   unsigned int len;
 
   len = sizeof (DBlock) + 42;
-  data = MALLOC (len);
+  data = GNUNET_malloc (len);
   memset (&data[1], rand (), len - sizeof (DBlock));
   data->type = htonl (D_BLOCK);
   CHECK (D_BLOCK == getTypeOfBlock (len, data), data);
   fileBlockGetKey (data, len, &key);
   fileBlockGetQuery (data, len, &query);
-  CHECK (OK == fileBlockEncode (data, len, &query, &value), data);
+  CHECK (GNUNET_OK == fileBlockEncode (data, len, &query, &value), data);
   memcpy (data, &value[1], len);
-  FREE (value);
-  CHECK (YES == isDatumApplicable (D_BLOCK,
-                                   len, data, &query, 1, &query), data);
-  FREE (data);
+  GNUNET_free (value);
+  CHECK (GNUNET_YES == isDatumApplicable (D_BLOCK,
+                                          len, data, &query, 1, &query),
+         data);
+  GNUNET_free (data);
   return 0;
 }
 

Modified: GNUnet/src/applications/fs/fsui/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/fsui/Makefile.am 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/Makefile.am 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -19,9 +19,6 @@
  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
  $(top_builddir)/src/applications/fs/namespace/libgnunetnamespace.la \
  $(top_builddir)/src/applications/fs/uritrack/libgnuneturitrack.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 EXTRA_DIST = \
@@ -31,10 +28,8 @@
 fsui_loader_SOURCES = \
  fsui-loader.c 
 fsui_loader_LDADD = \
- $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
  $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 check_PROGRAMS = \
@@ -52,8 +47,6 @@
 fsuitest_SOURCES = \
   fsuitest.c 
 fsuitest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/util/libgnunetutil.la 
@@ -61,8 +54,6 @@
 fsuitest2_SOURCES = \
   fsuitest2.c 
 fsuitest2_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/util/libgnunetutil.la 
@@ -70,8 +61,6 @@
 searchtest_SOURCES = \
   searchtest.c 
 searchtest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/util/libgnunetutil.la 
@@ -79,8 +68,6 @@
 downloadtest_SOURCES = \
   downloadtest.c 
 downloadtest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/util/libgnunetutil.la 
@@ -88,8 +75,6 @@
 serializetest_SOURCES = \
   serializetest.c 
 serializetest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/util/libgnunetutil.la 
@@ -97,8 +82,6 @@
 serializetest2_SOURCES = \
   serializetest2.c 
 serializetest2_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/util/libgnunetutil.la 
@@ -106,8 +89,6 @@
 serializetest3_SOURCES = \
   serializetest3.c 
 serializetest3_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/util/libgnunetutil.la 
@@ -116,8 +97,6 @@
 serializetest4_SOURCES = \
   serializetest4.c 
 serializetest4_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/util/libgnunetutil.la 

Modified: GNUnet/src/applications/fs/fsui/deserialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/deserialize.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/fsui/deserialize.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -38,12 +38,12 @@
   int big;
 
   if (sizeof (int) != READ (fd, &big, sizeof (int)))
-    return SYSERR;
+    return GNUNET_SYSERR;
   *val = ntohl (big);
-  return OK;
+  return GNUNET_OK;
 }
 
-#define READINT(a) if (OK != read_int(fd, (int*) &a)) return SYSERR;
+#define READINT(a) if (GNUNET_OK != read_int(fd, (int*) &a)) return 
GNUNET_SYSERR;
 
 static int
 read_long (int fd, long long *val)
@@ -51,12 +51,12 @@
   long long big;
 
   if (sizeof (long long) != READ (fd, &big, sizeof (long long)))
-    return SYSERR;
-  *val = ntohll (big);
-  return OK;
+    return GNUNET_SYSERR;
+  *val = GNUNET_ntohll (big);
+  return GNUNET_OK;
 }
 
-#define READLONG(a) if (OK != read_long(fd, (long long*) &a)) return SYSERR;
+#define READLONG(a) if (GNUNET_OK != read_long(fd, (long long*) &a)) return 
GNUNET_SYSERR;
 
 static struct ECRS_URI *
 read_uri (struct GE_Context *ectx, int fd)
@@ -65,22 +65,22 @@
   struct ECRS_URI *ret;
   unsigned int size;
 
-  if (OK != read_int (fd, (int *) &size))
+  if (GNUNET_OK != read_int (fd, (int *) &size))
     return NULL;
-  buf = MALLOC (size + 1);
+  buf = GNUNET_malloc (size + 1);
   buf[size] = '\0';
   if (size != READ (fd, buf, size))
     {
-      FREE (buf);
+      GNUNET_free (buf);
       return NULL;
     }
   ret = ECRS_stringToUri (ectx, buf);
   GE_BREAK (ectx, ret != NULL);
-  FREE (buf);
+  GNUNET_free (buf);
   return ret;
 }
 
-#define READURI(u) if (NULL == (u = read_uri(ectx, fd))) return SYSERR;
+#define READURI(u) if (NULL == (u = read_uri(ectx, fd))) return GNUNET_SYSERR;
 
 static char *
 read_string (int fd, unsigned int maxLen)
@@ -88,21 +88,21 @@
   char *buf;
   unsigned int big;
 
-  if (OK != read_int (fd, (int *) &big))
+  if (GNUNET_OK != read_int (fd, (int *) &big))
     return NULL;
   if (big > maxLen)
     return NULL;
-  buf = MALLOC (big + 1);
+  buf = GNUNET_malloc (big + 1);
   buf[big] = '\0';
   if (big != READ (fd, buf, big))
     {
-      FREE (buf);
+      GNUNET_free (buf);
       return NULL;
     }
   return buf;
 }
 
-#define READSTRING(c, max) if (NULL == (c = read_string(fd, max))) return 
SYSERR;
+#define READSTRING(c, max) if (NULL == (c = read_string(fd, max))) return 
GNUNET_SYSERR;
 
 static void
 fixState (FSUI_State * state)
@@ -136,7 +136,7 @@
 /**
  * Read file info from file.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static struct ECRS_MetaData *
 read_meta (struct GE_Context *ectx, int fd)
@@ -145,7 +145,7 @@
   char *buf;
   struct ECRS_MetaData *meta;
 
-  if (read_int (fd, (int *) &size) != OK)
+  if (read_int (fd, (int *) &size) != GNUNET_OK)
     {
       GE_BREAK (ectx, 0);
       return NULL;
@@ -155,28 +155,28 @@
       GE_BREAK (ectx, 0);
       return NULL;
     }
-  buf = MALLOC (size);
+  buf = GNUNET_malloc (size);
   if (size != READ (fd, buf, size))
     {
-      FREE (buf);
+      GNUNET_free (buf);
       GE_BREAK (ectx, 0);
       return NULL;
     }
   meta = ECRS_deserializeMetaData (ectx, buf, size);
   if (meta == NULL)
     {
-      FREE (buf);
+      GNUNET_free (buf);
       GE_BREAK (ectx, 0);
       return NULL;
     }
-  FREE (buf);
+  GNUNET_free (buf);
   return meta;
 }
 
 /**
  * Read file info from file.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 readFileInfo (struct GE_Context *ectx, int fd, ECRS_FileInfo * fi)
@@ -185,7 +185,7 @@
   if (fi->meta == NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   fi->uri = NULL;
 
@@ -195,9 +195,9 @@
       ECRS_freeMetaData (fi->meta);
       fi->meta = NULL;
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -221,59 +221,61 @@
   int soff;
 
   GE_ASSERT (ectx, ctx != NULL);
-  if ((OK != read_int (fd, (int *) &big)) || (big == 0))
+  if ((GNUNET_OK != read_int (fd, (int *) &big)) || (big == 0))
     return NULL;
-  ret = MALLOC (sizeof (FSUI_DownloadList));
+  ret = GNUNET_malloc (sizeof (FSUI_DownloadList));
   memset (ret, 0, sizeof (FSUI_DownloadList));
   ret->ctx = ctx;
-  if ((OK != read_int (fd, (int *) &soff)) ||
-      (OK != read_int (fd, (int *) &ret->state)) ||
-      (OK != read_int (fd, (int *) &ret->is_recursive)) ||
-      (OK != read_int (fd, (int *) &ret->is_directory)) ||
-      (OK != read_int (fd, (int *) &ret->anonymityLevel)) ||
-      (OK != read_int (fd, (int *) &ret->completedDownloadsCount)) ||
-      (OK != read_long (fd, (long long *) &ret->total)) ||
-      (OK != read_long (fd, (long long *) &ret->completed)) ||
-      (OK != read_long (fd, (long long *) &ret->runTime)) ||
-      (OK != read_int (fd, (int *) &big)) || (big > 1024 * 1024))
+  if ((GNUNET_OK != read_int (fd, (int *) &soff)) ||
+      (GNUNET_OK != read_int (fd, (int *) &ret->state)) ||
+      (GNUNET_OK != read_int (fd, (int *) &ret->is_recursive)) ||
+      (GNUNET_OK != read_int (fd, (int *) &ret->is_directory)) ||
+      (GNUNET_OK != read_int (fd, (int *) &ret->anonymityLevel)) ||
+      (GNUNET_OK != read_int (fd, (int *) &ret->completedDownloadsCount)) ||
+      (GNUNET_OK != read_long (fd, (long long *) &ret->total)) ||
+      (GNUNET_OK != read_long (fd, (long long *) &ret->completed)) ||
+      (GNUNET_OK != read_long (fd, (long long *) &ret->runTime)) ||
+      (GNUNET_OK != read_int (fd, (int *) &big)) || (big > 1024 * 1024))
     {
       GE_BREAK (NULL, 0);
-      FREE (ret);
+      GNUNET_free (ret);
       return NULL;
     }
   fixState (&ret->state);
-  ret->filename = MALLOC (big + 1);
+  ret->filename = GNUNET_malloc (big + 1);
   ret->filename[big] = '\0';
   if (big != READ (fd, ret->filename, big))
     {
       GE_BREAK (ectx, 0);
-      FREE (ret->filename);
-      FREE (ret);
+      GNUNET_free (ret->filename);
+      GNUNET_free (ret);
       return NULL;
     }
-  if (OK != readFileInfo (ectx, fd, &ret->fi))
+  if (GNUNET_OK != readFileInfo (ectx, fd, &ret->fi))
     {
       GE_BREAK (NULL, 0);
-      FREE (ret->filename);
-      FREE (ret);
+      GNUNET_free (ret->filename);
+      GNUNET_free (ret);
       return NULL;
     }
   if (ret->completedDownloadsCount > 0)
     ret->completedDownloads
-      = MALLOC (sizeof (struct ECRS_URI *) * ret->completedDownloadsCount);
-  ok = YES;
+      =
+      GNUNET_malloc (sizeof (struct ECRS_URI *) *
+                     ret->completedDownloadsCount);
+  ok = GNUNET_YES;
   for (i = 0; i < ret->completedDownloadsCount; i++)
     {
       ret->completedDownloads[i] = read_uri (ectx, fd);
       if (ret->completedDownloads[i] == NULL)
         {
           GE_BREAK (NULL, 0);
-          ok = NO;
+          ok = GNUNET_NO;
         }
     }
-  if (NO == ok)
+  if (GNUNET_NO == ok)
     {
-      FREE (ret->filename);
+      GNUNET_free (ret->filename);
       ECRS_freeUri (ret->fi.uri);
       ECRS_freeMetaData (ret->fi.meta);
       for (i = 0; i < ret->completedDownloadsCount; i++)
@@ -281,8 +283,8 @@
           if (ret->completedDownloads[i] != NULL)
             ECRS_freeUri (ret->completedDownloads[i]);
         }
-      FREE (ret->completedDownloads);
-      FREE (ret);
+      GNUNET_free (ret->completedDownloads);
+      GNUNET_free (ret);
       GE_BREAK (NULL, 0);
       return NULL;
     }
@@ -306,8 +308,9 @@
       ret->search = pos;
       if (pos != NULL)
         {
-          GROW (pos->my_downloads,
-                pos->my_downloads_size, pos->my_downloads_size + 1);
+          GNUNET_array_grow (pos->my_downloads,
+                             pos->my_downloads_size,
+                             pos->my_downloads_size + 1);
           pos->my_downloads[pos->my_downloads_size - 1] = ret;
         }
     }
@@ -330,14 +333,14 @@
   if (8 != READ (fd, magic, 8))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (0 != memcmp (magic, "FSUI01\n\0", 8))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
@@ -350,23 +353,23 @@
   if (big == 0)
     {
       ctx->collectionData = NULL;
-      return OK;
+      return GNUNET_OK;
     }
   if ((big > 16 * 1024 * 1024) || (big < sizeof (unsigned int)))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  ctx->collectionData = MALLOC (big);
+  ctx->collectionData = GNUNET_malloc (big);
   if (big - sizeof (unsigned int) !=
       READ (fd, &ctx->collectionData[1], big - sizeof (unsigned int)))
     {
-      FREE (ctx->collectionData);
+      GNUNET_free (ctx->collectionData);
       ctx->collectionData = NULL;
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
@@ -378,23 +381,24 @@
   int i;
   ResultPending *rp;
   char *buf;
-  cron_t stime;
+  GNUNET_CronTime stime;
 
   while (1)
     {
       READINT (big);
       if (big == 0)
-        return OK;
-      list = MALLOC (sizeof (FSUI_SearchList));
+        return GNUNET_OK;
+      list = GNUNET_malloc (sizeof (FSUI_SearchList));
       memset (list, 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))
+      if ((GNUNET_OK != read_int (fd, (int *) &list->state)) ||
+          (GNUNET_OK != read_int (fd, (int *) &list->maxResults)) ||
+          (GNUNET_OK != read_long (fd, (long long *) &list->timeout)) ||
+          (GNUNET_OK != read_long (fd, (long long *) &list->start_time)) ||
+          (GNUNET_OK != read_long (fd, (long long *) &stime)) ||
+          (GNUNET_OK != read_int (fd, (int *) &list->anonymityLevel)) ||
+          (GNUNET_OK != read_int (fd, (int *) &list->sizeResultsReceived)) ||
+          (GNUNET_OK !=
+           read_int (fd, (int *) &list->sizeUnmatchedResultsReceived))
           || (list->sizeResultsReceived > 1024 * 1024)
           || (list->sizeUnmatchedResultsReceived > 1024 * 1024))
         {
@@ -402,9 +406,9 @@
           break;
         }
       fixState (&list->state);
-      if (stime > get_time ())
-        stime = get_time ();
-      list->start_time += get_time () - stime;
+      if (stime > GNUNET_get_time ())
+        stime = GNUNET_get_time ();
+      list->start_time += GNUNET_get_time () - stime;
       buf = read_string (fd, 1024 * 1024);
       if (buf == NULL)
         {
@@ -412,7 +416,7 @@
           break;
         }
       list->uri = ECRS_stringToUri (NULL, buf);
-      FREE (buf);
+      GNUNET_free (buf);
       if (list->uri == NULL)
         {
           GE_BREAK (NULL, 0);
@@ -427,22 +431,25 @@
       if (list->sizeResultsReceived > 0)
         {
           list->resultsReceived
-            = MALLOC (list->sizeResultsReceived * sizeof (ECRS_FileInfo));
-          memset (list->resultsReceived,
-                  0, list->sizeResultsReceived * sizeof (ECRS_FileInfo));
+            =
+            GNUNET_malloc (list->sizeResultsReceived *
+                           sizeof (ECRS_FileInfo));
+          memset (list->resultsReceived, 0,
+                  list->sizeResultsReceived * sizeof (ECRS_FileInfo));
         }
       if (list->sizeUnmatchedResultsReceived > 0)
         {
           list->unmatchedResultsReceived
-            = MALLOC (list->sizeUnmatchedResultsReceived *
-                      sizeof (ResultPending));
+            = GNUNET_malloc (list->sizeUnmatchedResultsReceived *
+                             sizeof (ResultPending));
           memset (list->unmatchedResultsReceived,
                   0,
                   list->sizeUnmatchedResultsReceived *
                   sizeof (ResultPending));
         }
       for (i = 0; i < list->sizeResultsReceived; i++)
-        if (OK != readFileInfo (ctx->ectx, fd, &list->resultsReceived[i]))
+        if (GNUNET_OK !=
+            readFileInfo (ctx->ectx, fd, &list->resultsReceived[i]))
           {
             GE_BREAK (NULL, 0);
             goto ERR;
@@ -450,12 +457,12 @@
       for (i = 0; i < list->sizeUnmatchedResultsReceived; i++)
         {
           rp = &list->unmatchedResultsReceived[i];
-          if (OK != readFileInfo (ctx->ectx, fd, &rp->fi))
+          if (GNUNET_OK != readFileInfo (ctx->ectx, fd, &rp->fi))
             {
               GE_BREAK (NULL, 0);
               goto ERR;
             }
-          if (OK != read_int (fd, (int *) &rp->matchingKeyCount))
+          if (GNUNET_OK != read_int (fd, (int *) &rp->matchingKeyCount))
             {
               GE_BREAK (NULL, 0);
               goto ERR;
@@ -469,12 +476,12 @@
           if (rp->matchingKeyCount > 0)
             {
               rp->matchingKeys
-                = MALLOC (sizeof (HashCode512) * rp->matchingKeyCount);
-              if (sizeof (HashCode512) *
-                  rp->matchingKeyCount !=
-                  READ (fd,
-                        rp->matchingKeys,
-                        sizeof (HashCode512) * rp->matchingKeyCount))
+                =
+                GNUNET_malloc (sizeof (GNUNET_HashCode) *
+                               rp->matchingKeyCount);
+              if (sizeof (GNUNET_HashCode) * rp->matchingKeyCount !=
+                  READ (fd, rp->matchingKeys,
+                        sizeof (GNUNET_HashCode) * rp->matchingKeyCount))
                 {
                   GE_BREAK (NULL, 0);
                   goto ERR;
@@ -508,7 +515,7 @@
           if (list->resultsReceived[i].meta != NULL)
             ECRS_freeMetaData (list->resultsReceived[i].meta);
         }
-      GROW (list->resultsReceived, list->sizeResultsReceived, 0);
+      GNUNET_array_grow (list->resultsReceived, list->sizeResultsReceived, 0);
     }
   if (list->unmatchedResultsReceived != NULL)
     {
@@ -520,14 +527,14 @@
             ECRS_freeUri (rp->fi.uri);
           if (rp->fi.meta != NULL)
             ECRS_freeMetaData (rp->fi.meta);
-          FREENONNULL (rp->matchingKeys);
+          GNUNET_free_non_null (rp->matchingKeys);
         }
-      GROW (list->resultsReceived, list->sizeResultsReceived, 0);
+      GNUNET_array_grow (list->resultsReceived, list->sizeResultsReceived, 0);
     }
   if (list->uri != NULL)
     ECRS_freeUri (list->uri);
-  FREE (list);
-  return SYSERR;
+  GNUNET_free (list);
+  return GNUNET_SYSERR;
 }
 
 static int
@@ -536,7 +543,7 @@
   memset (&ctx->activeDownloads, 0, sizeof (FSUI_DownloadList));
   ctx->activeDownloads.child
     = readDownloadList (ctx->ectx, fd, ctx, &ctx->activeDownloads);
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
@@ -557,17 +564,17 @@
     {
       READINT (big);
       if (big == 0)
-        return OK;
+        return GNUNET_OK;
       if ((big < 1) || (big > 15))
         {
           GE_BREAK (NULL, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       READINT (bag);
       if (bag != 0x34D1F023)
         {
           GE_BREAK (NULL, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       memset (&l, 0, sizeof (FSUI_UploadList));
       READINT (l.state);
@@ -577,11 +584,11 @@
       READLONG (l.completed);
       READLONG (l.total);
       READLONG (stime);
-      if (stime < get_time ())
-        stime = get_time ();
+      if (stime < GNUNET_get_time ())
+        stime = GNUNET_get_time ();
       READLONG (l.start_time);
       if (l.start_time != 0)
-        l.start_time = (get_time () - stime) + l.start_time;
+        l.start_time = (GNUNET_get_time () - stime) + l.start_time;
       l.uri = NULL;
       if ((big & 2) == 2)
         READURI (l.uri);
@@ -621,25 +628,25 @@
           GE_BREAK (NULL, 0);
           break;
         }
-      list = MALLOC (sizeof (struct FSUI_UploadList));
+      list = GNUNET_malloc (sizeof (struct FSUI_UploadList));
       memcpy (list, &l, sizeof (struct FSUI_UploadList));
       list->shared = shared;
       list->parent = parent;
-      if (OK != readUploadList (ctx, list, fd, shared, NO))
+      if (GNUNET_OK != readUploadList (ctx, list, fd, shared, GNUNET_NO))
         {
           if (l.uri != NULL)
             ECRS_freeUri (l.uri);
-          FREE (l.filename);
-          FREE (list);
+          GNUNET_free (l.filename);
+          GNUNET_free (list);
           GE_BREAK (NULL, 0);
           break;
         }
       list->next = parent->child;
       parent->child = list;
-      if (top == YES)
-        return OK;
+      if (top == GNUNET_YES)
+        return GNUNET_OK;
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 
@@ -656,7 +663,7 @@
     {
       READINT (big);
       if (big == 0)
-        return OK;
+        return GNUNET_OK;
       if ((big < 1) && (big > 7))
         {
           GE_BREAK (NULL, 0);
@@ -666,7 +673,7 @@
       if (bag != 0x44D1F024)
         {
           GE_BREAK (NULL, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       memset (&sshared, 0, sizeof (FSUI_UploadShared));
       READINT (sshared.doIndex);
@@ -681,15 +688,16 @@
           sshared.global_keywords = read_uri (ctx->ectx, fd);
           if (sshared.global_keywords == NULL)
             {
-              FREENONNULL (sshared.extractor_config);
+              GNUNET_free_non_null (sshared.extractor_config);
               GE_BREAK (NULL, 0);
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
         }
-      shared = MALLOC (sizeof (FSUI_UploadShared));
+      shared = GNUNET_malloc (sizeof (FSUI_UploadShared));
       memcpy (shared, &sshared, sizeof (FSUI_UploadShared));
       shared->ctx = ctx;
-      if (OK != readUploadList (ctx, &ctx->activeUploads, fd, shared, YES))
+      if (GNUNET_OK !=
+          readUploadList (ctx, &ctx->activeUploads, fd, shared, GNUNET_YES))
         {
           GE_BREAK (NULL, 0);
 #if 0
@@ -699,13 +707,13 @@
              find and cleanup those first,
              or at least detect their presence
              and not free */
-          FREE (shared->extractor_config);
-          FREE (shared);
+          GNUNET_free (shared->extractor_config);
+          GNUNET_free (shared);
 #endif
           break;
         }
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 static int
@@ -719,17 +727,17 @@
     {
       READINT (big);
       if (big != 1)
-        return OK;
+        return GNUNET_OK;
       READINT (big);            /* state */
       READSTRING (name, 1024 * 1024);
-      ul = MALLOC (sizeof (struct FSUI_UnindexList));
+      ul = GNUNET_malloc (sizeof (struct FSUI_UnindexList));
       ul->state = big;
       ul->filename = name;
       ul->next = ctx->unindexOperations;
       ul->ctx = ctx;
       ctx->unindexOperations = ul;
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 
@@ -741,15 +749,16 @@
   fd = -1;
   if (0 != ACCESS (ctx->name, R_OK))
     return;
-  fd = disk_file_open (ctx->ectx, ctx->name, O_RDONLY);
+  fd = GNUNET_disk_file_open (ctx->ectx, ctx->name, O_RDONLY);
   if (fd == -1)
     return;
 
-  if ((OK != checkMagic (fd)) ||
-      (OK != readCollection (fd, ctx)) ||
-      (OK != readSearches (fd, ctx)) ||
-      (OK != readDownloads (fd, ctx)) ||
-      (OK != readUnindex (fd, ctx)) || (OK != readUploads (fd, ctx)))
+  if ((GNUNET_OK != checkMagic (fd)) ||
+      (GNUNET_OK != readCollection (fd, ctx)) ||
+      (GNUNET_OK != readSearches (fd, ctx)) ||
+      (GNUNET_OK != readDownloads (fd, ctx)) ||
+      (GNUNET_OK != readUnindex (fd, ctx))
+      || (GNUNET_OK != readUploads (fd, ctx)))
     {
       GE_BREAK (ctx->ectx, 0);
       GE_LOG (ctx->ectx,

Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/download.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,7 +32,7 @@
 #include "gnunet_fsui_lib.h"
 #include "fsui.h"
 
-#define DEBUG_DTM NO
+#define DEBUG_DTM GNUNET_NO
 
 /**
  * Mark the given URI as found in a directory
@@ -40,16 +40,16 @@
  */
 static int
 listURIfoundDirectory (const ECRS_FileInfo * fi,
-                       const HashCode512 * key, int isRoot, void *prnt)
+                       const GNUNET_HashCode * key, int isRoot, void *prnt)
 {
   FSUI_DownloadList *dl = prnt;
 
-  if (isRoot == YES)
-    return OK;                  /* namespace ad, ignore */
+  if (isRoot == GNUNET_YES)
+    return GNUNET_OK;           /* namespace ad, ignore */
   URITRACK_addState (dl->ctx->ectx,
                      dl->ctx->cfg, fi->uri, URITRACK_DIRECTORY_FOUND);
 
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -72,7 +72,7 @@
  */
 static int
 triggerRecursiveDownload (const ECRS_FileInfo * fi,
-                          const HashCode512 * key, int isRoot, void *prnt)
+                          const GNUNET_HashCode * key, int isRoot, void *prnt)
 {
   FSUI_DownloadList *parent = prnt;
   struct GE_Context *ectx;
@@ -83,18 +83,18 @@
   char *dotdot;
 
   ectx = parent->ctx->ectx;
-  if (isRoot == YES)
-    return OK;                  /* namespace ad, ignore */
+  if (isRoot == GNUNET_YES)
+    return GNUNET_OK;           /* namespace ad, ignore */
 
   URITRACK_trackURI (ectx, parent->ctx->cfg, fi);
   for (i = 0; i < parent->completedDownloadsCount; i++)
     if (ECRS_equalsUri (parent->completedDownloads[i], fi->uri))
-      return OK;                /* already complete! */
+      return GNUNET_OK;         /* already complete! */
   pos = parent->child;
   while (pos != NULL)
     {
       if (ECRS_equalsUri (pos->fi.uri, fi->uri))
-        return OK;              /* already downloading */
+        return GNUNET_OK;       /* already downloading */
       pos = pos->next;
     }
   filename = ECRS_getFromMetaData (fi->meta, EXTRACTOR_FILENAME);
@@ -105,15 +105,17 @@
                  strlen (tmp) >=
                  strlen (ECRS_URI_PREFIX) + strlen (ECRS_FILE_INFIX));
       filename =
-        STRDUP (&tmp[strlen (ECRS_URI_PREFIX) + strlen (ECRS_FILE_INFIX)]);
-      FREE (tmp);
+        GNUNET_strdup (&tmp
+                       [strlen (ECRS_URI_PREFIX) + strlen (ECRS_FILE_INFIX)]);
+      GNUNET_free (tmp);
     }
-  fullName = MALLOC (strlen (parent->filename) + 2 + strlen (filename));
+  fullName =
+    GNUNET_malloc (strlen (parent->filename) + 2 + strlen (filename));
   strcpy (fullName, parent->filename);
   strcat (fullName, filename);
   while (NULL != (dotdot = strstr (fullName, "..")))
     dotdot[0] = dotdot[1] = '_';
-  FREE (filename);
+  GNUNET_free (filename);
 #if DEBUG_DTM
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -121,9 +123,10 @@
 #endif
   startDownload (parent->ctx,
                  parent->anonymityLevel,
-                 YES, fi->uri, fi->meta, fullName, parent->search, parent);
-  FREE (fullName);
-  return OK;
+                 GNUNET_YES, fi->uri, fi->meta, fullName, parent->search,
+                 parent);
+  GNUNET_free (fullName);
+  return GNUNET_OK;
 }
 
 /**
@@ -132,7 +135,7 @@
 static void
 downloadProgressCallback (unsigned long long totalBytes,
                           unsigned long long completedBytes,
-                          cron_t eta,
+                          GNUNET_CronTime eta,
                           unsigned long long lastBlockOffset,
                           const char *lastBlock,
                           unsigned int lastBlockSize, void *cls)
@@ -140,8 +143,8 @@
   FSUI_DownloadList *dl = cls;
   FSUI_Event event;
   struct ECRS_MetaData *md;
-  cron_t now;
-  cron_t run_time;
+  GNUNET_CronTime now;
+  GNUNET_CronTime run_time;
 
   GE_ASSERT (dl->ctx->ectx, dl->total == totalBytes);
   dl->completed = completedBytes;
@@ -157,7 +160,7 @@
   event.data.DownloadProgress.completed = dl->completed;
   event.data.DownloadProgress.total = dl->total;
   event.data.DownloadProgress.last_offset = lastBlockOffset;
-  now = get_time ();
+  now = GNUNET_get_time ();
   run_time = now - dl->startTime;
   if ((dl->total == 0) || (dl->completed == 0))
     {
@@ -165,9 +168,10 @@
     }
   else
     {
-      eta = (cron_t) (dl->startTime +
-                      (((double) (run_time) / (double) dl->completed))
-                      * (double) dl->total);
+      eta = (GNUNET_CronTime) (dl->startTime +
+                               (((double) (run_time) /
+                                 (double) dl->completed)) *
+                               (double) dl->total);
       if (eta < now)
         eta = now;
     }
@@ -177,17 +181,17 @@
   event.data.DownloadProgress.last_block = lastBlock;
   event.data.DownloadProgress.last_size = lastBlockSize;
   dl->ctx->ecb (dl->ctx->ecbClosure, &event);
-  if ((lastBlockOffset == 0) && (dl->is_directory == SYSERR))
+  if ((lastBlockOffset == 0) && (dl->is_directory == GNUNET_SYSERR))
     {
       /* check if this is a directory */
       if ((lastBlockSize > strlen (GNUNET_DIRECTORY_MAGIC)) &&
           (0 == strncmp (GNUNET_DIRECTORY_MAGIC,
                          lastBlock, strlen (GNUNET_DIRECTORY_MAGIC))))
-        dl->is_directory = YES;
+        dl->is_directory = GNUNET_YES;
       else
-        dl->is_directory = NO;
+        dl->is_directory = GNUNET_NO;
     }
-  if (dl->is_directory == YES)
+  if (dl->is_directory == GNUNET_YES)
     {
       md = NULL;
       ECRS_listDirectory (dl->ctx->ectx,
@@ -196,14 +200,14 @@
       if (md != NULL)
         ECRS_freeMetaData (md);
     }
-  if ((dl->is_recursive == YES) && (dl->is_directory == YES))
+  if ((dl->is_recursive == GNUNET_YES) && (dl->is_directory == GNUNET_YES))
     {
       md = NULL;
-      MUTEX_LOCK (dl->ctx->lock);
+      GNUNET_mutex_lock (dl->ctx->lock);
       ECRS_listDirectory (dl->ctx->ectx,
                           lastBlock,
                           lastBlockSize, &md, &triggerRecursiveDownload, dl);
-      MUTEX_UNLOCK (dl->ctx->lock);
+      GNUNET_mutex_unlock (dl->ctx->lock);
       if (md != NULL)
         ECRS_freeMetaData (md);
     }
@@ -218,10 +222,10 @@
   FSUI_DownloadList *dl = cls;
 
   if ((dl->state == FSUI_ERROR) || (dl->state == FSUI_ABORTED))
-    return SYSERR;              /* aborted - delete! */
+    return GNUNET_SYSERR;       /* aborted - delete! */
   if (dl->state != FSUI_ACTIVE)
-    return NO;                  /* suspended */
-  return OK;
+    return GNUNET_NO;           /* suspended */
+  return GNUNET_OK;
 }
 
 /**
@@ -237,7 +241,7 @@
   struct GE_Memory *mem;
   struct GE_Context *ee;
 
-  dl->startTime = get_time () - dl->runTime;
+  dl->startTime = GNUNET_get_time () - dl->runTime;
   ectx = dl->ctx->ectx;
 #if DEBUG_DTM
   GE_LOG (ectx,
@@ -254,7 +258,7 @@
     ECRS_downloadFile (ee, dl->ctx->cfg, dl->fi.uri, dl->filename,
                        dl->anonymityLevel, &downloadProgressCallback, dl,
                        &testTerminate, dl);
-  if (ret == OK)
+  if (ret == GNUNET_OK)
     {
       dl->state = FSUI_COMPLETED;
       event.type = FSUI_download_completed;
@@ -319,8 +323,8 @@
     }
 
 
-  if ((ret == OK) &&
-      (dl->is_directory == YES) && (ECRS_fileSize (dl->fi.uri) > 0))
+  if ((ret == GNUNET_OK) &&
+      (dl->is_directory == GNUNET_YES) && (ECRS_fileSize (dl->fi.uri) > 0))
     {
       char *dirBlock;
       int fd;
@@ -329,7 +333,9 @@
       struct ECRS_MetaData *md;
 
       totalBytes = ECRS_fileSize (dl->fi.uri);
-      fn = MALLOC (strlen (dl->filename) + strlen (GNUNET_DIRECTORY_EXT) + 1);
+      fn =
+        GNUNET_malloc (strlen (dl->filename) + strlen (GNUNET_DIRECTORY_EXT) +
+                       1);
       strcpy (fn, dl->filename);
       fd = strlen (fn) - 1;
       if (fn[fd] == '/' || fn[fd] == '\\')
@@ -337,7 +343,7 @@
           fn[fd] = '\0';
           strcat (fn, GNUNET_DIRECTORY_EXT);
         }
-      fd = disk_file_open (ectx, fn, O_LARGEFILE | O_RDONLY);
+      fd = GNUNET_disk_file_open (ectx, fn, O_LARGEFILE | O_RDONLY);
       if (fd != -1)
         {
           dirBlock = MMAP (NULL, totalBytes, PROT_READ, MAP_SHARED, fd, 0);
@@ -361,27 +367,27 @@
                 {
                   /* load directory, start downloads */
                   md = NULL;
-                  MUTEX_LOCK (dl->ctx->lock);
+                  GNUNET_mutex_lock (dl->ctx->lock);
                   ECRS_listDirectory (dl->ctx->ectx,
                                       dirBlock,
                                       totalBytes,
                                       &md, &triggerRecursiveDownload, dl);
-                  MUTEX_UNLOCK (dl->ctx->lock);
+                  GNUNET_mutex_unlock (dl->ctx->lock);
                   ECRS_freeMetaData (md);
                   MUNMAP (dirBlock, totalBytes);
                 }
             }
           CLOSE (fd);
         }
-      FREE (fn);
+      GNUNET_free (fn);
     }
 #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");
+          dl->filename, ret == GNUNET_OK ? "COMPLETED" : "ABORTED");
 #endif
-  dl->runTime = get_time () - dl->startTime;
+  dl->runTime = GNUNET_get_time () - dl->startTime;
   GE_free_context (ee);
   GE_memory_free (mem);
   return NULL;
@@ -409,7 +415,7 @@
       GE_BREAK (NULL, 0);       /* wrong type of URI! */
       return NULL;
     }
-  dl = MALLOC (sizeof (FSUI_DownloadList));
+  dl = GNUNET_malloc (sizeof (FSUI_DownloadList));
   memset (dl, 0, sizeof (FSUI_DownloadList));
   dl->startTime = 0;            /* not run at all so far! */
   dl->runTime = 0;              /* not run at all so far! */
@@ -417,10 +423,10 @@
   dl->is_recursive = is_recursive;
   dl->parent = parent;
   dl->search = psearch;
-  dl->is_directory = SYSERR;    /* don't know */
+  dl->is_directory = GNUNET_SYSERR;     /* don't know */
   dl->anonymityLevel = anonymityLevel;
   dl->ctx = ctx;
-  dl->filename = STRDUP (filename);
+  dl->filename = GNUNET_strdup (filename);
   dl->fi.uri = ECRS_dupUri (uri);
   dl->fi.meta = ECRS_dupMetaData (meta);
   dl->total = ECRS_fileSize (uri);
@@ -447,8 +453,9 @@
   parent->child = dl;
   if (psearch != NULL)
     {
-      GROW (psearch->my_downloads,
-            psearch->my_downloads_size, psearch->my_downloads_size + 1);
+      GNUNET_array_grow (psearch->my_downloads,
+                         psearch->my_downloads_size,
+                         psearch->my_downloads_size + 1);
       psearch->my_downloads[psearch->my_downloads_size - 1] = dl;
     }
   return dl;
@@ -457,7 +464,7 @@
 /**
  * Start to download a file.
  *
- * @return OK on success, SYSERR if the target file is
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the target file is
  *  already used for another download at the moment (or
  *  if the disk does not have enough space).
  */
@@ -473,13 +480,13 @@
 {
   struct FSUI_DownloadList *ret;
 
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   if (pdownload == NULL)
     pdownload = &ctx->activeDownloads;
   ret = startDownload (ctx,
                        anonymityLevel,
                        doRecursive, uri, meta, filename, psearch, pdownload);
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_mutex_unlock (ctx->lock);
   return ret;
 }
 
@@ -488,7 +495,7 @@
  * size and active downloads.  Call only while holding FSUI lock (or
  * during start/stop).  Called from cron job in fsui.c.
  *
- * @return YES if change done that may require re-trying
+ * @return GNUNET_YES if change done that may require re-trying
  */
 int
 FSUI_updateDownloadThread (FSUI_DownloadList * list)
@@ -499,7 +506,7 @@
   int ret;
 
   if (list == NULL)
-    return NO;
+    return GNUNET_NO;
   ectx = list->ctx->ectx;
 
 #if DEBUG_DTM
@@ -509,7 +516,7 @@
           list->filename,
           list->ctx->activeDownloadThreads, list->ctx->threadPoolSize);
 #endif
-  ret = NO;
+  ret = GNUNET_NO;
   /* should this one be started? */
   if ((list->ctx->threadPoolSize
        > list->ctx->activeDownloadThreads) &&
@@ -523,7 +530,7 @@
               list->filename);
 #endif
       list->state = FSUI_ACTIVE;
-      list->handle = PTHREAD_CREATE (&downloadThread, list, 128 * 1024);
+      list->handle = GNUNET_thread_create (&downloadThread, list, 128 * 1024);
       if (list->handle != NULL)
         {
           list->ctx->activeDownloadThreads++;
@@ -550,12 +557,12 @@
 #endif
       list->state = FSUI_SUSPENDING;
       GE_ASSERT (ectx, list->handle != NULL);
-      PTHREAD_STOP_SLEEP (list->handle);
-      PTHREAD_JOIN (list->handle, &unused);
+      GNUNET_thread_stop_sleep (list->handle);
+      GNUNET_thread_join (list->handle, &unused);
       list->handle = NULL;
       list->ctx->activeDownloadThreads--;
       list->state = FSUI_PENDING;
-      ret = YES;
+      ret = GNUNET_YES;
     }
 
   /* has this one "died naturally"? */
@@ -568,19 +575,19 @@
               "Download thread manager collects inactive download of file 
`%s'\n",
               list->filename);
 #endif
-      PTHREAD_STOP_SLEEP (list->handle);
-      PTHREAD_JOIN (list->handle, &unused);
+      GNUNET_thread_stop_sleep (list->handle);
+      GNUNET_thread_join (list->handle, &unused);
       list->handle = NULL;
       list->ctx->activeDownloadThreads--;
       list->state++;            /* adds _JOINED */
-      ret = YES;
+      ret = GNUNET_YES;
     }
 
   dpos = list->child;
   while (dpos != NULL)
     {
-      if (YES == FSUI_updateDownloadThread (dpos))
-        ret = YES;
+      if (GNUNET_YES == FSUI_updateDownloadThread (dpos))
+        ret = GNUNET_YES;
       dpos = dpos->next;
     }
   return ret;
@@ -590,8 +597,8 @@
 /**
  * Abort a download (and all child-downloads).
  *
- * @return SYSERR if no such download is pending,
- *         NO if the download has already finished
+ * @return GNUNET_SYSERR if no such download is pending,
+ *         GNUNET_NO if the download has already finished
  */
 int
 FSUI_abortDownload (struct FSUI_Context *ctx, struct FSUI_DownloadList *dl)
@@ -606,24 +613,24 @@
       c = c->next;
     }
   if ((dl->state != FSUI_ACTIVE) && (dl->state != FSUI_PENDING))
-    return NO;
+    return GNUNET_NO;
   if (dl->state == FSUI_ACTIVE)
     {
       dl->state = FSUI_ABORTED;
-      PTHREAD_STOP_SLEEP (dl->handle);
+      GNUNET_thread_stop_sleep (dl->handle);
     }
   else
     {
       dl->state = FSUI_ABORTED_JOINED;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Stops a download (and all downloads that are
  * child downloads of this download).
  *
- * @return SYSERR if no such download is pending
+ * @return GNUNET_SYSERR if no such download is pending
  */
 int
 FSUI_stopDownload (struct FSUI_Context *ctx, struct FSUI_DownloadList *dl)
@@ -636,34 +643,34 @@
   GE_ASSERT (ctx->ectx, dl != NULL);
   while (dl->child != NULL)
     FSUI_stopDownload (ctx, dl->child);
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   prev =
     (dl->parent != NULL) ? dl->parent->child : ctx->activeDownloads.child;
   while ((prev != dl) && (prev != NULL) && (prev->next != dl))
     prev = prev->next;
   if (prev == NULL)
     {
-      MUTEX_UNLOCK (ctx->lock);
+      GNUNET_mutex_unlock (ctx->lock);
       GE_LOG (ctx->ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "FSUI_stopDownload failed to locate download.\n");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (prev == dl)
     dl->parent->child = dl->next;       /* first child of parent */
   else
     prev->next = dl->next;      /* not first child */
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_mutex_unlock (ctx->lock);
   if ((dl->state == FSUI_ACTIVE) ||
       (dl->state == FSUI_COMPLETED) ||
       (dl->state == FSUI_ABORTED) || (dl->state == FSUI_ERROR))
     {
       GE_ASSERT (ctx->ectx, dl->handle != NULL);
-      PTHREAD_STOP_SLEEP (dl->handle);
-      PTHREAD_JOIN (dl->handle, &unused);
-      MUTEX_LOCK (ctx->lock);
+      GNUNET_thread_stop_sleep (dl->handle);
+      GNUNET_thread_join (dl->handle, &unused);
+      GNUNET_mutex_lock (ctx->lock);
       dl->ctx->activeDownloadThreads--;
-      MUTEX_UNLOCK (ctx->lock);
+      GNUNET_mutex_unlock (ctx->lock);
       dl->handle = NULL;
       if (dl->state == FSUI_ACTIVE)
         dl->state = FSUI_PENDING;
@@ -692,20 +699,20 @@
             {
               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);
+              GNUNET_array_grow (dl->search->my_downloads,
+                                 dl->search->my_downloads_size,
+                                 dl->search->my_downloads_size - 1);
             }
         }
     }
   for (i = dl->completedDownloadsCount - 1; i >= 0; i--)
     ECRS_freeUri (dl->completedDownloads[i]);
-  GROW (dl->completedDownloads, dl->completedDownloadsCount, 0);
+  GNUNET_array_grow (dl->completedDownloads, dl->completedDownloadsCount, 0);
   ECRS_freeUri (dl->fi.uri);
   ECRS_freeMetaData (dl->fi.meta);
-  FREE (dl->filename);
-  FREE (dl);
-  return OK;
+  GNUNET_free (dl->filename);
+  GNUNET_free (dl);
+  return GNUNET_OK;
 }
 
 

Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c      2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c      2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -31,9 +31,9 @@
 #include "gnunet_util_network_client.h"
 #include "gnunet_util_crypto.h"
 
-#define DEBUG_VERBOSE NO
+#define DEBUG_VERBOSE GNUNET_NO
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(ectx, 0); goto FAILURE; }
 
 static volatile int suspendRestart = 0;
 
@@ -44,11 +44,11 @@
 {
   char *fn;
 
-  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);
-  disk_directory_create_for_file (NULL, fn);
+  fn = GNUNET_malloc (strlen ("/tmp/gnunet-fsui-downloadtest/FSUITEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen ("/tmp/gnunet-fsui-downloadtest/FSUITEST") + 14,
+                   "/tmp/gnunet-fsui-downloadtest/FSUITEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -115,10 +115,10 @@
 #if DEBUG_VERBOSE
           printf ("Download started: %s.\n", u);
 #endif
-          FREE (u);
+          GNUNET_free (u);
           download = FSUI_startDownload (ctx,
                                          0,
-                                         NO,
+                                         GNUNET_NO,
                                          event->data.SearchResult.fi.uri,
                                          event->data.SearchResult.fi.meta,
                                          fn, NULL, NULL);
@@ -127,7 +127,7 @@
               GE_BREAK (ectx, 0);
               return NULL;
             }
-          FREE (fn);
+          GNUNET_free (fn);
           suspendRestart = 4;
         }
       break;
@@ -237,42 +237,42 @@
   struct FSUI_UnindexList *unindex = NULL;
   struct FSUI_UploadList *upload = NULL;
 
-  ok = YES;
-  cfg = GC_create_C_impl ();
+  ok = GNUNET_YES;
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
   /* ACTUAL TEST CODE */
 #endif
   ctx = FSUI_start (NULL,
-                    cfg, "fsuidownloadtest", 32, YES, &eventCallback, NULL);
+                    cfg, "fsuidownloadtest", 32, GNUNET_YES, &eventCallback,
+                    NULL);
   CHECK (ctx != NULL);
   fn = makeName (42);
-  buf = MALLOC (FILESIZE);
+  buf = GNUNET_malloc (FILESIZE);
   for (i = 0; i < FILESIZE; i++)
-    buf[i] = weak_randomi (256);
-  disk_file_write (ectx, fn, buf, FILESIZE, "600");
-  FREE (buf);
+    buf[i] = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 256);
+  GNUNET_disk_file_write (ectx, fn, buf, FILESIZE, "600");
+  GNUNET_free (buf);
   meta = ECRS_createMetaData ();
   kuri = ECRS_parseListKeywordURI (ectx, 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);
+                             (DirectoryScanCallback) &
+                             GNUNET_disk_directory_scan, NULL, 0, 0,
+                             GNUNET_YES, GNUNET_NO, GNUNET_NO,
+                             GNUNET_get_time () + 5 * GNUNET_CRON_HOURS, meta,
+                             kuri, kuri);
   CHECK (upload != NULL);
   ECRS_freeUri (kuri);
   kuri = NULL;
@@ -282,23 +282,25 @@
     {
       prog++;
       CHECK (prog < 5000);
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   FSUI_stopUpload (ctx, upload);
-  SNPRINTF (keyword, 40, "%s %s %s", keywords[0], _("AND"), keywords[1]);
+  GNUNET_snprintf (keyword, 40, "%s %s %s", keywords[0], _("AND"),
+                   keywords[1]);
   uri = ECRS_parseCharKeywordURI (ectx, keyword);
   waitForEvent = FSUI_download_completed;
-  search = FSUI_startSearch (ctx, 0, 10000, 240 * cronSECONDS, uri);
+  search = FSUI_startSearch (ctx, 0, 10000, 240 * GNUNET_CRON_SECONDS, uri);
   CHECK (search != NULL);
   prog = 0;
   while (search != NULL)
     {
       prog++;
       CHECK (prog < 10000);
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if ((suspendRestart > 0) && (weak_randomi (4) == 0))
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if ((suspendRestart > 0)
+          && (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 4) == 0))
         {
 #if 1
 #if DEBUG_VERBOSE
@@ -311,14 +313,14 @@
           ctx = FSUI_start (NULL,
                             cfg,
                             "fsuidownloadtest",
-                            32, YES, &eventCallback, NULL);
+                            32, GNUNET_YES, &eventCallback, NULL);
 #if DEBUG_VERBOSE
           printf ("Resumed...\n");
 #endif
 #endif
           suspendRestart--;
         }
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   CHECK (search == NULL);
@@ -331,9 +333,9 @@
     {
       prog++;
       CHECK (prog < 5000);
-      PTHREAD_SLEEP (50 * cronMILLIS);
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
       CHECK (lastEvent != FSUI_unindex_error);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   CHECK (lastEvent == FSUI_unindex_completed);
@@ -350,7 +352,7 @@
   if (fn != NULL)
     {
       UNLINK (fn);
-      FREE (fn);
+      GNUNET_free (fn);
     }
   if (uri != NULL)
     ECRS_freeUri (uri);
@@ -359,15 +361,15 @@
   fn = makeName (43);
   /* TODO: verify file 'fn(42)' == file 'fn(43)' */
   UNLINK (fn);
-  FREE (fn);
+  GNUNET_free (fn);
   if (upURI != NULL)
     ECRS_freeUri (upURI);
 
 #if START_DAEMON
-  GE_BREAK (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_BREAK (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of downloadtest.c */

Modified: GNUnet/src/applications/fs/fsui/fsui-loader.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui-loader.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/fsui/fsui-loader.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -26,7 +26,7 @@
 
 #include "platform.h"
 #include "gnunet_fsui_lib.h"
-#include "gnunet_util_config_impl.h"
+#include "gnunet_util.h"
 
 static void *
 eventCallback (void *cls, const FSUI_Event * event)
@@ -60,14 +60,14 @@
   struct FSUI_Context *ctx;
   struct GC_Configuration *cfg;
 
-  os_init (NULL);
-  cfg = GC_create_C_impl ();
+  GNUNET_os_init (NULL);
+  cfg = GC_create ();
   if (argc != 2)
     {
       fprintf (stderr, "Call with name of FSUI resource file!\n");
       return -1;
     }
-  ctx = FSUI_start (NULL, cfg, argv[1], 16, YES, &eventCallback, NULL);
+  ctx = FSUI_start (NULL, cfg, argv[1], 16, GNUNET_YES, &eventCallback, NULL);
   if (ctx != NULL)
     FSUI_stop (ctx);
   else

Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/fsui.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -29,11 +29,11 @@
 #include "gnunet_directories.h"
 #include "fsui.h"
 
-#define DEBUG_PERSISTENCE NO
+#define DEBUG_PERSISTENCE GNUNET_NO
 
 /* ***************** CRON code ***************** */
 
-#define FSUI_UDT_FREQUENCY (2 * cronSECONDS)
+#define FSUI_UDT_FREQUENCY (2 * GNUNET_CRON_SECONDS)
 
 /**
  * Cron job for download load management.
@@ -44,7 +44,7 @@
   FSUI_Context *ctx = c;
   FSUI_DownloadList *dpos;
 
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   dpos = ctx->activeDownloads.child;
 #if DEBUG_PERSISTENCE
   if (dpos != NULL)
@@ -57,7 +57,7 @@
       FSUI_updateDownloadThread (dpos);
       dpos = dpos->next;
     }
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_mutex_unlock (ctx->lock);
 }
 
 /* ******************* START code *********************** */
@@ -66,8 +66,8 @@
 signalDownloadResume (struct FSUI_DownloadList *ret, FSUI_Context * ctx)
 {
   FSUI_Event event;
-  cron_t now;
-  cron_t eta;
+  GNUNET_CronTime now;
+  GNUNET_CronTime eta;
 
   while (ret != NULL)
     {
@@ -83,16 +83,17 @@
       event.data.DownloadResumed.completed = ret->completed;
       event.data.DownloadResumed.total = ret->total;
       event.data.DownloadResumed.state = ret->state;
-      now = get_time ();
+      now = GNUNET_get_time ();
       if ((ret->total == 0) || (ret->completed == 0))
         {
           eta = now;
         }
       else
         {
-          eta = (cron_t) (now - ret->runTime +
-                          (((double) (ret->runTime) /
-                            (double) ret->completed)) * (double) ret->total);
+          eta = (GNUNET_CronTime) (now - ret->runTime +
+                                   (((double) (ret->runTime) /
+                                     (double) ret->completed)) *
+                                   (double) ret->total);
           if (eta < now)
             eta = now;
         }
@@ -112,8 +113,8 @@
 signalUploadResume (struct FSUI_UploadList *ret, FSUI_Context * ctx)
 {
   FSUI_Event event;
-  cron_t now;
-  cron_t eta;
+  GNUNET_CronTime now;
+  GNUNET_CronTime eta;
 
   while (ret != NULL)
     {
@@ -126,16 +127,17 @@
       event.data.UploadResumed.total = ret->total;
       event.data.UploadResumed.uri = ret->uri;
       event.data.UploadResumed.state = ret->state;
-      now = get_time ();
+      now = GNUNET_get_time ();
       if ((ret->total == 0) || (ret->completed == 0))
         {
           eta = now;
         }
       else
         {
-          eta = (cron_t) (ret->start_time +
-                          (((double) (now - ret->start_time) /
-                            (double) ret->completed)) * (double) ret->total);
+          eta = (GNUNET_CronTime) (ret->start_time +
+                                   (((double) (now - ret->start_time) /
+                                     (double) ret->completed)) *
+                                   (double) ret->total);
           if (eta < now)
             eta = now;
         }
@@ -161,8 +163,8 @@
     {
       if (ret->state == FSUI_ACTIVE)
         {
-          ret->shared->handle = PTHREAD_CREATE (&FSUI_uploadThread,
-                                                ret, 128 * 1024);
+          ret->shared->handle = GNUNET_thread_create (&FSUI_uploadThread,
+                                                      ret, 128 * 1024);
           if (ret->shared->handle == NULL)
             GE_DIE_STRERROR (ctx->ectx,
                              GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
@@ -196,7 +198,7 @@
   unsigned long long size;
 
   GE_ASSERT (ectx, cfg != NULL);
-  ret = MALLOC (sizeof (FSUI_Context));
+  ret = GNUNET_malloc (sizeof (FSUI_Context));
   memset (ret, 0, sizeof (FSUI_Context));
   ret->activeDownloads.state = FSUI_PENDING;    /* !? */
   ret->activeDownloads.ctx = ret;
@@ -212,10 +214,10 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &gh);
-  disk_directory_create (ectx, gh);
-  fn = MALLOC (strlen (gh) + strlen (name) + 2 + 5);
+  GNUNET_disk_directory_create (ectx, gh);
+  fn = GNUNET_malloc (strlen (gh) + strlen (name) + 2 + 5);
   strcpy (fn, gh);
-  FREE (gh);
+  GNUNET_free (gh);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, name);
   ret->name = fn;
@@ -223,13 +225,13 @@
   /* 1) read state  in */
   if (doResume)
     {
-      ret->ipc = IPC_SEMAPHORE_CREATE (ectx, fn, 1);
+      ret->ipc = GNUNET_IPC_semaphore_create (ectx, fn, 1);
 #if DEBUG_PERSISTENCE
       GE_LOG (ectx,
               GE_INFO | GE_REQUEST | GE_USER,
               "Getting IPC lock for FSUI (%s).\n", fn);
 #endif
-      IPC_SEMAPHORE_DOWN (ret->ipc, YES);
+      GNUNET_IPC_semaphore_down (ret->ipc, GNUNET_YES);
 #if DEBUG_PERSISTENCE
       GE_LOG (ectx, GE_INFO | GE_REQUEST | GE_USER, "Aquired IPC lock.\n");
 #endif
@@ -240,7 +242,7 @@
     {
       ret->ipc = NULL;
     }
-  ret->lock = MUTEX_CREATE (YES);
+  ret->lock = GNUNET_mutex_create (GNUNET_YES);
 
   /* 2) do resume events */
   /* 2a) signal download restarts */
@@ -266,7 +268,8 @@
   xlist = ret->unindexOperations;
   while (xlist != NULL)
     {
-      if (OK != disk_file_size (ectx, xlist->filename, &size, YES))
+      if (GNUNET_OK !=
+          GNUNET_disk_file_size (ectx, xlist->filename, &size, GNUNET_YES))
         size = 0;
       event.type = FSUI_unindex_resumed;
       event.data.UnindexResumed.uc.pos = xlist;
@@ -274,7 +277,7 @@
       event.data.UnindexResumed.completed =
         (xlist->state == FSUI_COMPLETED_JOINED) ? size : 0;
       event.data.UnindexResumed.total = size;
-      event.data.UnindexResumed.eta = get_time ();
+      event.data.UnindexResumed.eta = GNUNET_get_time ();
       event.data.UnindexResumed.filename = xlist->filename;
       event.data.UnindexResumed.state = xlist->state;
       xlist->cctx = cb (closure, &event);
@@ -284,9 +287,9 @@
   /* 3) restart processing */
   ret->cron = cron_create (ectx);
   /* 3a) resume downloads */
-  cron_add_job (ret->cron,
-                &updateDownloadThreads, 0, FSUI_UDT_FREQUENCY, ret);
-  cron_start (ret->cron);
+  GNUNET_cron_add_job (ret->cron,
+                       &updateDownloadThreads, 0, FSUI_UDT_FREQUENCY, ret);
+  GNUNET_cron_start (ret->cron);
   /* 3b) resume uploads */
   doResumeUploads (ret->activeUploads.child, ret);
   /* 3c) resume unindexing */
@@ -296,8 +299,8 @@
       if (xlist->state == FSUI_PENDING)
         {
           xlist->state = FSUI_ACTIVE;
-          xlist->handle = PTHREAD_CREATE (&FSUI_unindexThread,
-                                          xlist, 32 * 1024);
+          xlist->handle = GNUNET_thread_create (&FSUI_unindexThread,
+                                                xlist, 32 * 1024);
           if (xlist->handle == NULL)
             GE_DIE_STRERROR (ectx,
                              GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
@@ -312,7 +315,8 @@
       if (list->state == FSUI_PENDING)
         {
           list->state = FSUI_ACTIVE;
-          list->handle = PTHREAD_CREATE (&FSUI_searchThread, list, 32 * 1024);
+          list->handle =
+            GNUNET_thread_create (&FSUI_searchThread, list, 32 * 1024);
           if (list->handle == NULL)
             GE_DIE_STRERROR (ectx,
                              GE_FATAL | GE_ADMIN | GE_IMMEDIATE,
@@ -386,12 +390,13 @@
       freeDownloadList (list->child);
       ECRS_freeUri (list->fi.uri);
       ECRS_freeMetaData (list->fi.meta);
-      FREE (list->filename);
+      GNUNET_free (list->filename);
       for (i = 0; i < list->completedDownloadsCount; i++)
         ECRS_freeUri (list->completedDownloads[i]);
-      GROW (list->completedDownloads, list->completedDownloadsCount, 0);
+      GNUNET_array_grow (list->completedDownloads,
+                         list->completedDownloadsCount, 0);
       next = list->next;
-      FREE (list);
+      GNUNET_free (list);
       list = next;
     }
 }
@@ -409,7 +414,7 @@
     {
       freeUploadList (ctx, list->child);
       next = list->next;
-      FREE (list->filename);
+      GNUNET_free (list->filename);
       if (list->meta != NULL)
         ECRS_freeMetaData (list->meta);
       if (list->keywords != NULL)
@@ -422,10 +427,10 @@
           EXTRACTOR_removeAll (shared->extractors);
           if (shared->global_keywords != NULL)
             ECRS_freeUri (shared->global_keywords);
-          FREENONNULL (shared->extractor_config);
-          FREE (shared);
+          GNUNET_free_non_null (shared->extractor_config);
+          GNUNET_free (shared);
         }
-      FREE (list);
+      GNUNET_free (list);
       list = next;
     }
 }
@@ -453,9 +458,10 @@
             "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);
-  cron_destroy (ctx->cron);
+  GNUNET_cron_stop (ctx->cron);
+  GNUNET_cron_del_job (ctx->cron, &updateDownloadThreads, FSUI_UDT_FREQUENCY,
+                       ctx);
+  GNUNET_cron_destroy (ctx->cron);
 
   /* 1a) stop downloading */
   ctx->threadPoolSize = 0;
@@ -475,8 +481,8 @@
         {
           if (spos->state == FSUI_ACTIVE)
             spos->state = FSUI_PENDING;
-          PTHREAD_STOP_SLEEP (spos->handle);
-          PTHREAD_JOIN (spos->handle, &unused);
+          GNUNET_thread_stop_sleep (spos->handle);
+          GNUNET_thread_join (spos->handle, &unused);
           if (spos->state != FSUI_PENDING)
             spos->state++;      /* _JOINED */
         }
@@ -492,8 +498,8 @@
         {
           if (xpos->state == FSUI_ACTIVE)
             xpos->state = FSUI_PENDING;
-          PTHREAD_STOP_SLEEP (xpos->handle);
-          PTHREAD_JOIN (xpos->handle, &unused);
+          GNUNET_thread_stop_sleep (xpos->handle);
+          GNUNET_thread_join (xpos->handle, &unused);
           if (xpos->state != FSUI_PENDING)
             xpos->state++;      /* _JOINED */
         }
@@ -511,8 +517,8 @@
              of rest of tree! */
           if (upos->state == FSUI_ACTIVE)
             upos->state = FSUI_PENDING;
-          PTHREAD_STOP_SLEEP (upos->shared->handle);
-          PTHREAD_JOIN (upos->shared->handle, &unused);
+          GNUNET_thread_stop_sleep (upos->shared->handle);
+          GNUNET_thread_join (upos->shared->handle, &unused);
           if (upos->state != FSUI_PENDING)
             upos->state++;      /* _JOINED */
         }
@@ -563,27 +569,27 @@
           ECRS_freeMetaData (fi->meta);
           ECRS_freeUri (fi->uri);
         }
-      GROW (spos->resultsReceived, spos->sizeResultsReceived, 0);
+      GNUNET_array_grow (spos->resultsReceived, spos->sizeResultsReceived, 0);
       for (i = spos->sizeUnmatchedResultsReceived - 1; i >= 0; i--)
         {
           ResultPending *rp;
 
           rp = &spos->unmatchedResultsReceived[i];
-          GROW (rp->matchingKeys, rp->matchingKeyCount, 0);
+          GNUNET_array_grow (rp->matchingKeys, rp->matchingKeyCount, 0);
           ECRS_freeMetaData (rp->fi.meta);
           ECRS_freeUri (rp->fi.uri);
         }
-      GROW (spos->unmatchedResultsReceived,
-            spos->sizeUnmatchedResultsReceived, 0);
-      FREE (spos);
+      GNUNET_array_grow (spos->unmatchedResultsReceived,
+                         spos->sizeUnmatchedResultsReceived, 0);
+      GNUNET_free (spos);
     }
   /* 4b) free unindex memory */
   while (ctx->unindexOperations != NULL)
     {
       xpos = ctx->unindexOperations;
       ctx->unindexOperations = xpos->next;
-      FREE (xpos->filename);
-      FREE (xpos);
+      GNUNET_free (xpos->filename);
+      GNUNET_free (xpos);
     }
   /* 4c) free upload memory */
   freeUploadList (ctx, ctx->activeUploads.child);
@@ -593,15 +599,15 @@
   /* 5) finish FSUI Context */
   if (ctx->ipc != NULL)
     {
-      IPC_SEMAPHORE_UP (ctx->ipc);
-      IPC_SEMAPHORE_DESTROY (ctx->ipc);
+      GNUNET_IPC_semaphore_up (ctx->ipc);
+      GNUNET_IPC_semaphore_destroy (ctx->ipc);
     }
-  MUTEX_DESTROY (ctx->lock);
-  FREE (ctx->name);
+  GNUNET_mutex_destroy (ctx->lock);
+  GNUNET_free (ctx->name);
   if (ctx->ipc != NULL)
     GE_LOG (ectx,
             GE_DEBUG | GE_REQUEST | GE_USER, "FSUI shutdown complete.\n");
-  FREE (ctx);
+  GNUNET_free (ctx);
 }
 
 

Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/fsui.h      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -40,7 +40,7 @@
   /**
    * What are these keys?
    */
-  HashCode512 *matchingKeys;
+  GNUNET_HashCode *matchingKeys;
 
   /**
    * What info do we have about this result?
@@ -48,7 +48,7 @@
   ECRS_FileInfo fi;
 
   /**
-   * For how many keys (hash of keyword) did we
+   * For how many keys (GNUNET_hash of keyword) did we
    * get this result?
    */
   unsigned int matchingKeyCount;
@@ -64,12 +64,12 @@
   /**
    * Desired timeout (relative) for this search
    */
-  cron_t timeout;
+  GNUNET_CronTime timeout;
 
   /**
    * start time of the search
    */
-  cron_t start_time;
+  GNUNET_CronTime start_time;
 
   /**
    * Searches are kept in a simple linked list.
@@ -84,7 +84,7 @@
   /**
    * Handle to the thread which performs the search.
    */
-  struct PTHREAD *handle;
+  struct GNUNET_ThreadHandle *handle;
 
   /**
    * Which URI are we searching?
@@ -206,7 +206,7 @@
   /**
    * Currently assigned thread (if any).
    */
-  struct PTHREAD *handle;
+  struct GNUNET_ThreadHandle *handle;
 
   /**
    * FIs of completed sub-downloads.
@@ -220,7 +220,7 @@
    * While the download thread is running, this is the
    * absolute start time assuming the thread ran continuously.
    */
-  cron_t startTime;
+  GNUNET_CronTime startTime;
 
   /**
    * While the download thread is suspended, this is the
@@ -228,24 +228,24 @@
    * While the download thread is running, startTime should
    * be used instead (since runTime maybe outdated).
    */
-  cron_t runTime;
+  GNUNET_CronTime runTime;
 
   /**
-   * Is this a recursive download? (YES/NO)
+   * Is this a recursive download? (GNUNET_YES/GNUNET_NO)
    */
   int is_recursive;
 
   /**
-   * Is this file a directory?  Set to YES either if the first block
+   * Is this file a directory?  Set to GNUNET_YES either if the first block
    * contains the correct directory MAGIC, or if the mime-type in the
-   * meta-data was saying that the file is a directory.  Set to SYSERR
+   * meta-data was saying that the file is a directory.  Set to GNUNET_SYSERR
    * initially if no mime-type is specified and we have not yet seen
-   * the first block.  Set to NO if a different mime-type was given or
+   * the first block.  Set to GNUNET_NO if a different mime-type was given or
    * if the first block did not have the correct MAGIC.<p>
    *
-   * As long as is_directory is SYSERR we _defer_ processing the other
+   * As long as is_directory is GNUNET_SYSERR we _defer_ processing the other
    * blocks of the file that we may receive.  After we established
-   * that this is a directory (and if is_recursive is YES), we try to
+   * that this is a directory (and if is_recursive is GNUNET_YES), we try to
    * decode the directory eagerly and start the other downloads in
    * parallel.  Once the directory is complete, we make sure that
    * really all files have been started and wait for their completion.
@@ -275,11 +275,11 @@
 typedef struct FSUI_UnindexList
 {
 
-  cron_t start_time;
+  GNUNET_CronTime start_time;
 
   struct FSUI_UnindexList *next;
 
-  struct PTHREAD *handle;
+  struct GNUNET_ThreadHandle *handle;
 
   char *filename;
 
@@ -298,7 +298,7 @@
 typedef struct FSUI_UploadShared
 {
 
-  cron_t expiration;
+  GNUNET_CronTime expiration;
 
   DirectoryScanCallback dsc;
 
@@ -308,7 +308,7 @@
 
   struct FSUI_Context *ctx;
 
-  struct PTHREAD *handle;
+  struct GNUNET_ThreadHandle *handle;
 
   /**
    * Keywords to be used for all uploads.
@@ -337,7 +337,7 @@
 
   unsigned long long total;
 
-  cron_t start_time;
+  GNUNET_CronTime start_time;
 
   struct FSUI_UploadShared *shared;
 
@@ -391,7 +391,7 @@
    * between different processes of the same name
    * that all use resume.
    */
-  struct IPC_SEMAPHORE *ipc;
+  struct GNUNET_IPC_Semaphore *ipc;
 
   /**
    * Name of the tool using FSUI (used for resume).
@@ -401,9 +401,9 @@
   /**
    * Lock to synchronize access to the FSUI Context.
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
-  struct CronManager *cron;
+  struct GNUNET_CronManager *cron;
 
   /**
    * Callback for notifying the client about events.
@@ -459,7 +459,7 @@
  * size and active downloads.  Call only while holding FSUI lock (or
  * during start/stop).
  *
- * @return YES if change done that may require re-trying
+ * @return GNUNET_YES if change done that may require re-trying
  */
 int FSUI_updateDownloadThread (FSUI_DownloadList * list);
 

Modified: GNUnet/src/applications/fs/fsui/fsuitest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsuitest.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/fsuitest.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -30,20 +30,20 @@
 #include "gnunet_util_config_impl.h"
 #include "gnunet_util_network_client.h"
 
-#define DEBUG_VERBOSE NO
+#define DEBUG_VERBOSE GNUNET_NO
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
 static char *
 makeName (unsigned int i)
 {
   char *fn;
 
-  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);
-  disk_directory_create_for_file (NULL, fn);
+  fn =
+    GNUNET_malloc (strlen ("/tmp/gnunet-fsui-serializetest/FSUITEST") + 14);
+  GNUNET_snprintf (fn, strlen ("/tmp/gnunet-fsui-test/FSUITEST") + 14,
+                   "/tmp/gnunet-fsui-test/FSUITEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -73,11 +73,11 @@
       fn = makeName (43);
       download = FSUI_startDownload (ctx,
                                      0,
-                                     NO,
+                                     GNUNET_NO,
                                      event->data.SearchResult.fi.uri,
                                      event->data.SearchResult.fi.meta,
                                      fn, NULL, NULL);
-      FREE (fn);
+      GNUNET_free (fn);
       break;
     case FSUI_upload_completed:
 #if DEBUG_VERBOSE
@@ -126,37 +126,40 @@
   struct FSUI_SearchList *search;
   struct FSUI_UnindexList *unindex;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 60 * cronSECONDS));
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         60 * GNUNET_CRON_SECONDS));
 #endif
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
-  ok = YES;
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
+  ok = GNUNET_YES;
 
   /* ACTUAL TEST CODE */
   ctx = FSUI_start (NULL, cfg, "fsuitest", 32,  /* thread pool size */
-                    NO,         /* no resume */
+                    GNUNET_NO,  /* no resume */
                     &eventCallback, NULL);
   CHECK (ctx != NULL);
   filename = makeName (42);
-  disk_file_write (NULL,
-                   filename,
-                   "foo bar test!", strlen ("foo bar test!"), "600");
+  GNUNET_disk_file_write (NULL,
+                          filename,
+                          "foo bar test!", strlen ("foo bar test!"), "600");
   meta = ECRS_createMetaData ();
   kuri = ECRS_parseListKeywordURI (NULL, 2, (const char **) keywords);
-  upload = FSUI_startUpload (ctx, filename, (DirectoryScanCallback) & 
disk_directory_scan, NULL, 0,     /* anonymity */
+  upload = FSUI_startUpload (ctx, filename, (DirectoryScanCallback) & 
GNUNET_disk_directory_scan, NULL, 0,      /* anonymity */
                              0, /* priority */
-                             YES,
-                             NO,
-                             NO,
-                             get_time () + 5 * cronHOURS, meta, kuri, kuri);
+                             GNUNET_YES,
+                             GNUNET_NO,
+                             GNUNET_NO,
+                             GNUNET_get_time () + 5 * GNUNET_CRON_HOURS, meta,
+                             kuri, kuri);
   CHECK (upload != NULL);
   ECRS_freeUri (kuri);
   ECRS_freeMetaData (meta);
@@ -164,13 +167,15 @@
   while (lastEvent != FSUI_upload_completed)
     {
       prog++;
-      CHECK (prog < 10000) PTHREAD_SLEEP (50 * cronMILLIS);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      CHECK (prog <
+             10000) GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
-  SNPRINTF (keyword, 40, "%s %s %s", keywords[0], _("AND"), keywords[1]);
+  GNUNET_snprintf (keyword, 40, "%s %s %s", keywords[0], _("AND"),
+                   keywords[1]);
   uri = ECRS_parseCharKeywordURI (NULL, keyword);
-  search = FSUI_startSearch (ctx, 0, 100, 240 * cronSECONDS, uri);
+  search = FSUI_startSearch (ctx, 0, 100, 240 * GNUNET_CRON_SECONDS, uri);
   ECRS_freeUri (uri);
   CHECK (search != NULL);
   prog = 0;
@@ -178,8 +183,8 @@
     {
       prog++;
       CHECK (prog < 10000);
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   FSUI_abortSearch (ctx, search);
@@ -190,8 +195,8 @@
     {
       prog++;
       CHECK (prog < 10000);
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   if (lastEvent != FSUI_unindex_completed)
@@ -206,19 +211,19 @@
   if (filename != NULL)
     {
       UNLINK (filename);
-      FREE (filename);
+      GNUNET_free (filename);
     }
   filename = makeName (43);
   /* TODO: verify file 'filename(42)' == file 'filename(43)' */
   UNLINK (filename);
-  FREE (filename);
+  GNUNET_free (filename);
 
 #if START_DAEMON
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
 
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of fsuitest.c */

Modified: GNUnet/src/applications/fs/fsui/fsuitest2.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsuitest2.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/fsuitest2.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -30,7 +30,7 @@
 #include "gnunet_util_config_impl.h"
 #include "gnunet_util_network_client.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
 
 static struct FSUI_Context *ctx;
@@ -52,36 +52,39 @@
   int ok;
   struct GC_Configuration *cfg;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 60 * cronSECONDS));
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         60 * GNUNET_CRON_SECONDS));
 #endif
-  ok = YES;
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
+  ok = GNUNET_YES;
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
 
   /* ACTUAL TEST CODE */
-  ctx = FSUI_start (NULL, cfg, "fsuitest2", 32, YES,    /* do resume! */
+  ctx = FSUI_start (NULL, cfg, "fsuitest2", 32, GNUNET_YES,     /* do resume! 
*/
                     &eventCallback, NULL);
   CHECK (ctx != NULL);
   FSUI_stop (ctx);
-  ctx = FSUI_start (NULL, cfg, "fsuitest2", 32, YES, &eventCallback, NULL);
+  ctx =
+    FSUI_start (NULL, cfg, "fsuitest2", 32, GNUNET_YES, &eventCallback, NULL);
   CHECK (ctx != NULL);
 FAILURE:
   if (ctx != NULL)
     FSUI_stop (ctx);
 #if START_DAEMON
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
 
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of fsuitest2.c */

Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/search.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -35,7 +35,7 @@
 #include "gnunet_namespace_lib.h"
 #include "fsui.h"
 
-#define DEBUG_SEARCH NO
+#define DEBUG_SEARCH GNUNET_NO
 
 /**
  * Pass the result to the client and note it as shown.
@@ -45,8 +45,8 @@
 {
   FSUI_Event event;
 
-  GROW (pos->resultsReceived,
-        pos->sizeResultsReceived, pos->sizeResultsReceived + 1);
+  GNUNET_array_grow (pos->resultsReceived,
+                     pos->sizeResultsReceived, pos->sizeResultsReceived + 1);
   pos->resultsReceived[pos->sizeResultsReceived - 1].uri
     = ECRS_dupUri (fi->uri);
   pos->resultsReceived[pos->sizeResultsReceived - 1].meta
@@ -68,7 +68,7 @@
  */
 static int
 spcb (const ECRS_FileInfo * fi,
-      const HashCode512 * key, int isRoot, void *cls)
+      const GNUNET_HashCode * key, int isRoot, void *cls)
 {
   FSUI_SearchList *pos = cls;
   unsigned int i;
@@ -83,7 +83,7 @@
     {
       NS_setNamespaceRoot (ectx, pos->ctx->cfg, fi->uri);
       NS_addNamespaceInfo (ectx, pos->ctx->cfg, fi->uri, fi->meta);
-      return OK;
+      return GNUNET_OK;
     }
   for (i = 0; i < pos->sizeResultsReceived; i++)
     if (ECRS_equalsUri (fi->uri, pos->resultsReceived[i].uri))
@@ -93,7 +93,7 @@
                 GE_DEBUG | GE_REQUEST | GE_USER,
                 "Received search result that I have seen before.\n");
 #endif
-        return OK;              /* seen before */
+        return GNUNET_OK;       /* seen before */
       }
   if (pos->numberOfURIKeys > 1)
     {
@@ -105,7 +105,7 @@
                   GE_DEBUG | GE_REQUEST | GE_USER,
                   "Received search result without key to decrypt.\n");
 #endif
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       for (i = 0; i < pos->sizeUnmatchedResultsReceived; i++)
         {
@@ -114,14 +114,15 @@
             {
               for (j = 0; j < rp->matchingKeyCount; j++)
                 if (0 == memcmp (key,
-                                 &rp->matchingKeys[j], sizeof (HashCode512)))
+                                 &rp->matchingKeys[j],
+                                 sizeof (GNUNET_HashCode)))
                   {
 #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");
 #endif
-                    return OK;
+                    return GNUNET_OK;
                   }
               if (rp->matchingKeyCount + 1 == pos->numberOfURIKeys)
                 {
@@ -130,7 +131,8 @@
                           GE_DEBUG | GE_REQUEST | GE_USER,
                           "Received search result (showing client)!\n");
 #endif
-                  GROW (rp->matchingKeys, rp->matchingKeyCount, 0);
+                  GNUNET_array_grow (rp->matchingKeys, rp->matchingKeyCount,
+                                     0);
                   processResult (&rp->fi, pos);
                   ECRS_freeUri (rp->fi.uri);
                   ECRS_freeMetaData (rp->fi.meta);
@@ -139,15 +141,16 @@
                     pos->unmatchedResultsReceived[pos->
                                                   sizeUnmatchedResultsReceived
                                                   - 1];
-                  GROW (pos->unmatchedResultsReceived,
-                        pos->sizeUnmatchedResultsReceived,
-                        pos->sizeUnmatchedResultsReceived - 1);
-                  return OK;
+                  GNUNET_array_grow (pos->unmatchedResultsReceived,
+                                     pos->sizeUnmatchedResultsReceived,
+                                     pos->sizeUnmatchedResultsReceived - 1);
+                  return GNUNET_OK;
                 }
               else
                 {
-                  GROW (rp->matchingKeys,
-                        rp->matchingKeyCount, rp->matchingKeyCount + 1);
+                  GNUNET_array_grow (rp->matchingKeys,
+                                     rp->matchingKeyCount,
+                                     rp->matchingKeyCount + 1);
                   rp->matchingKeys[rp->matchingKeyCount - 1] = *key;
 #if DEBUG_SEARCH
                   GE_LOG (ectx,
@@ -155,20 +158,20 @@
                           "Received search result (waiting for more %u keys 
before showing client).\n",
                           pos->numberOfURIKeys - rp->matchingKeyCount);
 #endif
-                  return OK;
+                  return GNUNET_OK;
                 }
             }
         }
-      GROW (pos->unmatchedResultsReceived,
-            pos->sizeUnmatchedResultsReceived,
-            pos->sizeUnmatchedResultsReceived + 1);
+      GNUNET_array_grow (pos->unmatchedResultsReceived,
+                         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);
+      GNUNET_array_grow (rp->matchingKeys, rp->matchingKeyCount, 1);
       rp->matchingKeys[0] = *key;
 #if DEBUG_SEARCH
       GE_LOG (ectx,
@@ -176,7 +179,7 @@
               "Received search result (waiting for %u more keys before showing 
client).\n",
               pos->numberOfURIKeys - rp->matchingKeyCount);
 #endif
-      return OK;
+      return GNUNET_OK;
     }
   else
     {
@@ -187,7 +190,7 @@
 #endif
       processResult (fi, pos);
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
@@ -196,8 +199,8 @@
   FSUI_SearchList *pos = cls;
   if ((pos->state == FSUI_ACTIVE) &&
       (pos->maxResults > pos->sizeResultsReceived))
-    return OK;
-  return SYSERR;
+    return GNUNET_OK;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -221,7 +224,7 @@
                      pos->uri,
                      pos->anonymityLevel,
                      pos->timeout, &spcb, pos, &testTerminate, pos);
-  if (ret != OK)
+  if (ret != GNUNET_OK)
     {
       const char *error;
 
@@ -286,14 +289,14 @@
 FSUI_startSearch (struct FSUI_Context *ctx,
                   unsigned int anonymityLevel,
                   unsigned int maxResults,
-                  cron_t timeout, const struct ECRS_URI *uri)
+                  GNUNET_CronTime timeout, const struct ECRS_URI *uri)
 {
   FSUI_SearchList *pos;
   struct GE_Context *ectx;
 
   ectx = ctx->ectx;
-  MUTEX_LOCK (ctx->lock);
-  pos = MALLOC (sizeof (FSUI_SearchList));
+  GNUNET_mutex_lock (ctx->lock);
+  pos = GNUNET_malloc (sizeof (FSUI_SearchList));
   pos->maxResults = maxResults;
   pos->state = FSUI_ACTIVE;
   pos->uri = ECRS_dupUri (uri);
@@ -304,22 +307,23 @@
   pos->unmatchedResultsReceived = 0;
   pos->anonymityLevel = anonymityLevel;
   pos->ctx = ctx;
-  pos->start_time = get_time ();
+  pos->start_time = GNUNET_get_time ();
   pos->timeout = timeout;
-  pos->handle = PTHREAD_CREATE (&FSUI_searchThreadSignal, pos, 32 * 1024);
+  pos->handle =
+    GNUNET_thread_create (&FSUI_searchThreadSignal, pos, 32 * 1024);
   if (pos->handle == NULL)
     {
       GE_LOG_STRERROR (ectx,
                        GE_ERROR | GE_IMMEDIATE | GE_USER | GE_ADMIN,
                        "PTHREAD_CREATE");
       ECRS_freeUri (pos->uri);
-      FREE (pos);
-      MUTEX_UNLOCK (ctx->lock);
+      GNUNET_free (pos);
+      GNUNET_mutex_unlock (ctx->lock);
       return NULL;
     }
   pos->next = ctx->activeSearches;
   ctx->activeSearches = pos;
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_mutex_unlock (ctx->lock);
   return pos;
 }
 
@@ -332,13 +336,13 @@
   if (sl->state == FSUI_PENDING)
     {
       sl->state = FSUI_ABORTED_JOINED;
-      return OK;
+      return GNUNET_OK;
     }
   if (sl->state != FSUI_ACTIVE)
-    return SYSERR;
+    return GNUNET_SYSERR;
   sl->state = FSUI_ABORTED;
-  PTHREAD_STOP_SLEEP (sl->handle);
-  return OK;
+  GNUNET_thread_stop_sleep (sl->handle);
+  return GNUNET_OK;
 }
 
 /**
@@ -353,7 +357,7 @@
   void *unused;
   int i;
 
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   prev = NULL;
   pos = ctx->activeSearches;
   while ((pos != sl) && (pos != NULL))
@@ -363,8 +367,8 @@
     }
   if (pos == NULL)
     {
-      MUTEX_UNLOCK (ctx->lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (ctx->lock);
+      return GNUNET_SYSERR;
     }
   if (prev == NULL)
     ctx->activeSearches = pos->next;
@@ -372,15 +376,15 @@
     prev->next = pos->next;
   for (i = 0; i < sl->my_downloads_size; i++)
     sl->my_downloads[i]->search = NULL;
-  GROW (sl->my_downloads, sl->my_downloads_size, 0);
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_array_grow (sl->my_downloads, sl->my_downloads_size, 0);
+  GNUNET_mutex_unlock (ctx->lock);
   pos->next = NULL;
   if ((pos->state == FSUI_ACTIVE) ||
       (pos->state == FSUI_COMPLETED) ||
       (pos->state == FSUI_ABORTED) || (pos->state == FSUI_ERROR))
     {
       GE_ASSERT (ctx->ectx, pos->handle != NULL);
-      PTHREAD_JOIN (pos->handle, &unused);
+      GNUNET_thread_join (pos->handle, &unused);
       pos->handle = NULL;
       if (pos->state == FSUI_ACTIVE)
         pos->state = FSUI_PENDING;
@@ -403,17 +407,19 @@
       ECRS_freeUri (pos->resultsReceived[i].uri);
       ECRS_freeMetaData (pos->resultsReceived[i].meta);
     }
-  GROW (pos->resultsReceived, pos->sizeResultsReceived, 0);
+  GNUNET_array_grow (pos->resultsReceived, pos->sizeResultsReceived, 0);
   for (i = 0; i < pos->sizeUnmatchedResultsReceived; i++)
     {
       ECRS_freeUri (pos->unmatchedResultsReceived[i].fi.uri);
       ECRS_freeMetaData (pos->unmatchedResultsReceived[i].fi.meta);
-      GROW (pos->unmatchedResultsReceived[i].matchingKeys,
-            pos->unmatchedResultsReceived[i].matchingKeyCount, 0);
+      GNUNET_array_grow (pos->unmatchedResultsReceived[i].matchingKeys,
+                         pos->unmatchedResultsReceived[i].matchingKeyCount,
+                         0);
     }
-  GROW (pos->unmatchedResultsReceived, pos->sizeUnmatchedResultsReceived, 0);
-  FREE (pos);
-  return OK;
+  GNUNET_array_grow (pos->unmatchedResultsReceived,
+                     pos->sizeUnmatchedResultsReceived, 0);
+  GNUNET_free (pos);
+  return GNUNET_OK;
 }
 
 /* end of search.c */

Modified: GNUnet/src/applications/fs/fsui/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/searchtest.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/fsui/searchtest.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -30,18 +30,18 @@
 #include "gnunet_util_config_impl.h"
 #include "gnunet_util_network_client.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
 static char *
 makeName (unsigned int i)
 {
   char *fn;
 
-  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);
-  disk_directory_create_for_file (NULL, fn);
+  fn = GNUNET_malloc (strlen ("/tmp/gnunet-fsui-searchtest/FSUITEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen ("/tmp/gnunet-fsui-searchtest/FSUITEST") + 14,
+                   "/tmp/gnunet-fsui-searchtest/FSUITEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -53,7 +53,7 @@
 
 static struct FSUI_Context *ctx;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static volatile enum FSUI_EventType waitForEvent;
 
@@ -62,7 +62,7 @@
 {
   static char unused;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   switch (event->type)
     {
     case FSUI_search_resumed:
@@ -74,7 +74,7 @@
     case FSUI_download_resumed:
     case FSUI_upload_resumed:
     case FSUI_unindex_resumed:
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return &unused;
     case FSUI_search_result:
       printf ("Received search result\n");
@@ -103,7 +103,7 @@
     }
   if (lastEvent != waitForEvent)
     lastEvent = event->type;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return NULL;
 }
 
@@ -132,51 +132,59 @@
   struct FSUI_DownloadList *download;
   struct ECRS_URI *luri;
 
-  ok = YES;
-  cfg = GC_create_C_impl ();
+  ok = GNUNET_YES;
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
   /* ACTUAL TEST CODE */
 #endif
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   ctx = FSUI_start (NULL,
-                    cfg, "fsuisearchtest", 32, YES, &eventCallback, NULL);
+                    cfg, "fsuisearchtest", 32, GNUNET_YES, &eventCallback,
+                    NULL);
   CHECK (ctx != NULL);
-  SNPRINTF (keyword, 40, "%s %s %s", keywords[0], _("AND"), keywords[1]);
+  GNUNET_snprintf (keyword, 40, "%s %s %s", keywords[0], _("AND"),
+                   keywords[1]);
   luri = ECRS_parseCharKeywordURI (NULL, keyword);
-  search = FSUI_startSearch (ctx, 0, 100, 240 * cronSECONDS, luri);
+  search = FSUI_startSearch (ctx, 0, 100, 240 * GNUNET_CRON_SECONDS, 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, GNUNET_YES, &eventCallback,
+                    NULL);
   fn = makeName (42);
-  disk_file_write (NULL,
-                   fn, "foo bar test!", strlen ("foo bar test!"), "600");
+  GNUNET_disk_file_write (NULL,
+                          fn, "foo bar test!", strlen ("foo bar test!"),
+                          "600");
   meta = ECRS_createMetaData ();
   kuri = ECRS_parseListKeywordURI (NULL, 2, (const char **) keywords);
   waitForEvent = FSUI_upload_completed;
   upload =
     FSUI_startUpload (ctx,
                       fn,
-                      (DirectoryScanCallback) & disk_directory_scan,
+                      (DirectoryScanCallback) & GNUNET_disk_directory_scan,
                       NULL,
                       0,
                       0,
-                      YES,
-                      NO, NO, get_time () + 5 * cronHOURS, meta, kuri, kuri);
+                      GNUNET_YES,
+                      GNUNET_NO, GNUNET_NO,
+                      GNUNET_get_time () + 5 * GNUNET_CRON_HOURS, meta, kuri,
+                      kuri);
   CHECK (NULL != upload);
-  FREE (fn);
+  GNUNET_free (fn);
   fn = NULL;
   ECRS_freeUri (kuri);
   ECRS_freeMetaData (meta);
@@ -190,8 +198,9 @@
                    "Upload failed to complete -- last event: %u\n",
                    lastEvent);
         }
-      CHECK (prog < 10000) PTHREAD_SLEEP (50 * cronMILLIS);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      CHECK (prog <
+             10000) GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   FSUI_stopUpload (ctx, upload);
@@ -199,7 +208,8 @@
   while (uri == NULL)
     {
       prog++;
-      CHECK (prog < 10000) PTHREAD_SLEEP (50 * cronMILLIS);
+      CHECK (prog <
+             10000) GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
     }
   FSUI_abortSearch (ctx, search);
   FSUI_stopSearch (ctx, search);
@@ -207,9 +217,10 @@
   fn = makeName (43);
   meta = ECRS_createMetaData ();
   waitForEvent = FSUI_download_completed;
-  download = FSUI_startDownload (ctx, 0, NO, uri, meta, fn, NULL, NULL);
+  download =
+    FSUI_startDownload (ctx, 0, GNUNET_NO, uri, meta, fn, NULL, NULL);
   ECRS_freeMetaData (meta);
-  FREE (fn);
+  GNUNET_free (fn);
   fn = NULL;
   ECRS_freeUri (uri);
 
@@ -218,15 +229,15 @@
     {
       prog++;
       CHECK (prog < 10000);
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   FSUI_stopDownload (ctx, download);
   fn = makeName (42);
   waitForEvent = FSUI_unindex_completed;
   unindex = FSUI_startUnindex (ctx, fn);
-  FREE (fn);
+  GNUNET_free (fn);
   fn = NULL;
   CHECK (NULL != unindex);
   prog = 0;
@@ -234,8 +245,8 @@
     {
       prog++;
       CHECK (prog < 10000);
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   FSUI_stopUnindex (ctx, unindex);
@@ -245,21 +256,21 @@
   if (ctx != NULL)
     FSUI_stop (ctx);
   if (lock != NULL)
-    MUTEX_DESTROY (lock);
-  FREENONNULL (fn);
+    GNUNET_mutex_destroy (lock);
+  GNUNET_free_non_null (fn);
   /* TODO: verify file 'fn(42)' == file 'fn(43)' */
   fn = makeName (42);
   UNLINK (fn);
-  FREE (fn);
+  GNUNET_free (fn);
   fn = makeName (43);
   UNLINK (fn);
-  FREE (fn);
+  GNUNET_free (fn);
 
 #if START_DAEMON
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of searchtest.c */

Modified: GNUnet/src/applications/fs/fsui/serialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serialize.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/serialize.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,7 +43,7 @@
 WRITELONG (int fd, long long val)
 {
   long long big;
-  big = htonll (val);
+  big = GNUNET_htonll (val);
   WRITE (fd, &big, sizeof (long long));
 }
 
@@ -57,7 +57,7 @@
   size = strlen (buf);
   WRITEINT (fd, size);
   WRITE (fd, buf, size);
-  FREE (buf);
+  GNUNET_free (buf);
 }
 
 static void
@@ -80,7 +80,7 @@
                               ECRS_SERIALIZE_NO_COMPRESS);
   if (size > 1024 * 1024)
     size = 1024 * 1024;
-  buf = MALLOC (size);
+  buf = GNUNET_malloc (size);
   ECRS_serializeMetaData (ectx,
                           meta,
                           buf,
@@ -88,7 +88,7 @@
                           ECRS_SERIALIZE_PART | ECRS_SERIALIZE_NO_COMPRESS);
   WRITEINT (fd, size);
   WRITE (fd, buf, size);
-  FREE (buf);
+  GNUNET_free (buf);
 }
 
 
@@ -156,7 +156,7 @@
   WRITEINT (fd, list->completedDownloadsCount);
   WRITELONG (fd, list->total);
   WRITELONG (fd, list->completed);
-  WRITELONG (fd, get_time () - list->startTime);
+  WRITELONG (fd, GNUNET_get_time () - list->startTime);
 
   WRITESTRING (fd, list->filename);
   writeFileInfo (ectx, fd, &list->fi);
@@ -203,7 +203,7 @@
       WRITEINT (fd, spos->maxResults);
       WRITELONG (fd, spos->timeout);
       WRITELONG (fd, spos->start_time);
-      WRITELONG (fd, get_time ());
+      WRITELONG (fd, GNUNET_get_time ());
       WRITEINT (fd, spos->anonymityLevel);
       WRITEINT (fd, spos->sizeResultsReceived);
       WRITEINT (fd, spos->sizeUnmatchedResultsReceived);
@@ -225,7 +225,7 @@
           WRITEINT (fd, rp->matchingKeyCount);
           WRITE (fd,
                  rp->matchingKeys,
-                 sizeof (HashCode512) * rp->matchingKeyCount);
+                 sizeof (GNUNET_HashCode) * rp->matchingKeyCount);
         }
       spos = spos->next;
     }
@@ -271,7 +271,7 @@
       WRITEINT (fd, upos->state);
       WRITELONG (fd, upos->completed);
       WRITELONG (fd, upos->total);
-      WRITELONG (fd, get_time ());
+      WRITELONG (fd, GNUNET_get_time ());
       WRITELONG (fd, upos->start_time);
       if (upos->uri != NULL)
         writeURI (fd, upos->uri);
@@ -280,8 +280,8 @@
       if (upos->meta != NULL)
         writeMetaData (ctx->ectx, fd, upos->meta);
       WRITESTRING (fd, upos->filename);
-      writeUploadList (fd, ctx, upos->child, NO);
-      if (top == YES)
+      writeUploadList (fd, ctx, upos->child, GNUNET_NO);
+      if (top == GNUNET_YES)
         break;
       upos = upos->next;
     }
@@ -313,7 +313,7 @@
         WRITESTRING (fd, shared->extractor_config);
       if (shared->global_keywords != NULL)
         writeURI (fd, shared->global_keywords);
-      writeUploadList (fd, ctx, upos, YES);
+      writeUploadList (fd, ctx, upos, GNUNET_YES);
       upos = upos->next;
     }
   WRITEINT (fd, 0);
@@ -324,9 +324,10 @@
 {
   int fd;
 
-  fd = disk_file_open (ctx->ectx,
-                       ctx->name,
-                       O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
+  fd = GNUNET_disk_file_open (ctx->ectx,
+                              ctx->name,
+                              O_CREAT | O_TRUNC | O_WRONLY,
+                              S_IRUSR | S_IWUSR);
   if (fd == -1)
     return;
   WRITE (fd, "FSUI01\n\0", 8);  /* magic */

Modified: GNUnet/src/applications/fs/fsui/serializetest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/fsui/serializetest.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -31,9 +31,9 @@
 #include "gnunet_util_network_client.h"
 #include "gnunet_util_crypto.h"
 
-#define DEBUG_VERBOSE NO
+#define DEBUG_VERBOSE GNUNET_NO
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(ectx, 0); goto FAILURE; }
 
 static volatile int suspendRestart = 0;
 
@@ -44,11 +44,12 @@
 {
   char *fn;
 
-  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);
-  disk_directory_create_for_file (NULL, fn);
+  fn =
+    GNUNET_malloc (strlen ("/tmp/gnunet-fsui-serializetest/FSUITEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen ("/tmp/gnunet-fsui-serializetest/FSUITEST") + 14,
+                   "/tmp/gnunet-fsui-serializetest/FSUITEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -166,42 +167,42 @@
   struct ECRS_URI *kuri = NULL;
   struct GC_Configuration *cfg;
 
-  ok = YES;
-  cfg = GC_create_C_impl ();
+  ok = GNUNET_YES;
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
   /* ACTUAL TEST CODE */
 #endif
   ctx = FSUI_start (NULL,
-                    cfg, "fsuiserializetest", 32, YES, &eventCallback, NULL);
+                    cfg, "fsuiserializetest", 32, GNUNET_YES, &eventCallback,
+                    NULL);
   CHECK (ctx != NULL);
   fn = makeName (42);
-  buf = MALLOC (FILESIZE);
+  buf = GNUNET_malloc (FILESIZE);
   for (i = 0; i < FILESIZE; i++)
-    buf[i] = weak_randomi (256);
-  disk_file_write (ectx, fn, buf, FILESIZE, "600");
-  FREE (buf);
+    buf[i] = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 256);
+  GNUNET_disk_file_write (ectx, fn, buf, FILESIZE, "600");
+  GNUNET_free (buf);
   meta = ECRS_createMetaData ();
   kuri = ECRS_parseListKeywordURI (ectx, 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);
+                             (DirectoryScanCallback) &
+                             GNUNET_disk_directory_scan, NULL, 0, 0,
+                             GNUNET_YES, GNUNET_NO, GNUNET_NO,
+                             GNUNET_get_time () + 5 * GNUNET_CRON_HOURS, meta,
+                             kuri, kuri);
   CHECK (upload != NULL);
   ECRS_freeUri (kuri);
   kuri = NULL;
@@ -210,7 +211,8 @@
   suspendRestart = 4;
   while (lastEvent != FSUI_upload_completed)
     {
-      if ((suspendRestart > 0) && (weak_randomi (4) == 0))
+      if ((suspendRestart > 0)
+          && (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 4) == 0))
         {
 #if 1
 #if DEBUG_VERBOSE
@@ -221,7 +223,7 @@
           ctx = FSUI_start (NULL,
                             cfg,
                             "fsuiserializetest",
-                            32, YES, &eventCallback, NULL);
+                            32, GNUNET_YES, &eventCallback, NULL);
 #if DEBUG_VERBOSE
           printf ("Resumed...\n");
 #endif
@@ -230,8 +232,8 @@
         }
       prog++;
       CHECK (prog < 5000);
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   FSUI_stopUpload (ctx, upload);
@@ -242,7 +244,8 @@
   suspendRestart = 4;
   while (lastEvent != FSUI_unindex_completed)
     {
-      if ((suspendRestart > 0) && (weak_randomi (4) == 0))
+      if ((suspendRestart > 0)
+          && (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 4) == 0))
         {
 #if 1
 #if DEBUG_VERBOSE
@@ -253,7 +256,7 @@
           ctx = FSUI_start (NULL,
                             cfg,
                             "fsuiserializetest",
-                            32, YES, &eventCallback, NULL);
+                            32, GNUNET_YES, &eventCallback, NULL);
 #if DEBUG_VERBOSE
           printf ("Resumed...\n");
 #endif
@@ -262,9 +265,9 @@
         }
       prog++;
       CHECK (prog < 5000);
-      PTHREAD_SLEEP (50 * cronMILLIS);
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
       CHECK (lastEvent != FSUI_unindex_error);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   CHECK (lastEvent == FSUI_unindex_completed);
@@ -279,22 +282,22 @@
   if (fn != NULL)
     {
       UNLINK (fn);
-      FREE (fn);
+      GNUNET_free (fn);
     }
   if (kuri != NULL)
     ECRS_freeUri (kuri);
   fn = makeName (43);
   /* TODO: verify file 'fn(42)' == file 'fn(43)' */
   UNLINK (fn);
-  FREE (fn);
+  GNUNET_free (fn);
   if (upURI != NULL)
     ECRS_freeUri (upURI);
 
 #if START_DAEMON
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of downloadtest.c */

Modified: GNUnet/src/applications/fs/fsui/serializetest2.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest2.c    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/fsui/serializetest2.c    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -32,11 +32,11 @@
 #include "gnunet_util_network_client.h"
 #include "gnunet_util_crypto.h"
 
-#define DEBUG_VERBOSE NO
+#define DEBUG_VERBOSE GNUNET_NO
 
 #define UPLOAD_PREFIX "/tmp/gnunet-fsui-searializetest2"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(ectx, 0); goto FAILURE; }
 
 static struct GE_Context *ectx;
 
@@ -45,11 +45,11 @@
 {
   char *fn;
 
-  fn = MALLOC (strlen (UPLOAD_PREFIX "/FSUITEST") + 14);
-  SNPRINTF (fn,
-            strlen (UPLOAD_PREFIX "/FSUITEST") + 14,
-            UPLOAD_PREFIX "/FSUITEST%u", i);
-  disk_directory_create_for_file (NULL, fn);
+  fn = GNUNET_malloc (strlen (UPLOAD_PREFIX "/FSUITEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen (UPLOAD_PREFIX "/FSUITEST") + 14,
+                   UPLOAD_PREFIX "/FSUITEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -345,58 +345,59 @@
   int suspendRestart = 0;
 
 
-  ok = YES;
-  cfg = GC_create_C_impl ();
+  ok = GNUNET_YES;
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
   /* ACTUAL TEST CODE */
 #endif
   ctx = FSUI_start (NULL,
-                    cfg, "serializetest2", 32, YES, &eventCallback, NULL);
+                    cfg, "serializetest2", 32, GNUNET_YES, &eventCallback,
+                    NULL);
   CHECK (ctx != NULL);
   for (j = 4; j < 256; j += 4)
     {
       fn = makeName (j);
-      buf = MALLOC (FILESIZE * j);
+      buf = GNUNET_malloc (FILESIZE * j);
       for (i = 0; i < FILESIZE; i++)
-        buf[i] = weak_randomi (256);
-      disk_file_write (ectx, fn, buf, FILESIZE, "600");
-      FREE (buf);
-      FREE (fn);
+        buf[i] = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 256);
+      GNUNET_disk_file_write (ectx, fn, buf, FILESIZE, "600");
+      GNUNET_free (buf);
+      GNUNET_free (fn);
     }
   meta = ECRS_createMetaData ();
   kuri = ECRS_parseListKeywordURI (ectx, 2, (const char **) keywords);
   ECRS_addToMetaData (meta, 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);
+                             (DirectoryScanCallback) &
+                             GNUNET_disk_directory_scan, NULL, 0, 0,
+                             GNUNET_YES, GNUNET_NO, GNUNET_NO,
+                             GNUNET_get_time () + 5 * GNUNET_CRON_HOURS, 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]);
+  GNUNET_snprintf (keyword, 40, "%s %s %s", keywords[0], _("AND"),
+                   keywords[1]);
   uri = ECRS_parseCharKeywordURI (ectx, keyword);
-  search = FSUI_startSearch (ctx, 0, 100, 240 * cronSECONDS, uri);
+  search = FSUI_startSearch (ctx, 0, 100, 240 * GNUNET_CRON_SECONDS, uri);
   CHECK (search != NULL);
   download = FSUI_startDownload (ctx,
                                  0,
-                                 YES,
+                                 GNUNET_YES,
                                  upURI,
                                  meta,
                                  UPLOAD_PREFIX "-download", search, NULL);
@@ -406,8 +407,9 @@
   while (prog < 1000)
     {
       prog++;
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if ((suspendRestart > 0) && (weak_randomi (100) == 0))
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if ((suspendRestart > 0)
+          && (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100) == 0))
         {
 #if 1
 #if DEBUG_VERBOSE
@@ -419,7 +421,8 @@
           CHECK (download == NULL);
           ctx = FSUI_start (NULL,
                             cfg,
-                            "serializetest2", 32, YES, &eventCallback, NULL);
+                            "serializetest2", 32, GNUNET_YES, &eventCallback,
+                            NULL);
 #if DEBUG_VERBOSE
           printf ("Resumed...\n");
 #endif
@@ -429,13 +432,13 @@
       if ((search != NULL) && (suspendRestart >= 5))
         {
           no_check = 1;
-          PTHREAD_SLEEP (50 * cronMILLIS);
+          GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
           FSUI_abortSearch (ctx, search);
           FSUI_stopSearch (ctx, search);
           search = NULL;
           no_check = 0;
         }
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   FSUI_stopDownload (ctx, download);
@@ -445,7 +448,7 @@
       unindex = FSUI_startUnindex (ctx, fn);
       FSUI_stopUnindex (ctx, unindex);
       UNLINK (fn);
-      FREE (fn);
+      GNUNET_free (fn);
     }
   /* END OF TEST CODE */
 FAILURE:
@@ -459,12 +462,12 @@
     ECRS_freeUri (upURI);
 
 #if START_DAEMON
-  GE_BREAK (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_BREAK (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
   if (have_error)
-    ok = NO;
-  return (ok == YES) ? 0 : 1;
+    ok = GNUNET_NO;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of serializetest2.c */

Modified: GNUnet/src/applications/fs/fsui/serializetest3.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest3.c    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/fsui/serializetest3.c    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -31,11 +31,11 @@
 #include "gnunet_util_network_client.h"
 #include "gnunet_util_crypto.h"
 
-#define DEBUG_VERBOSE NO
+#define DEBUG_VERBOSE GNUNET_NO
 
 #define UPLOAD_PREFIX "/tmp/gnunet-fsui-searializetest3"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(ectx, 0); goto FAILURE; }
 
 static struct GE_Context *ectx;
 
@@ -143,34 +143,39 @@
   int suspendRestart = 0;
 
 
-  ok = YES;
-  cfg = GC_create_C_impl ();
+  ok = GNUNET_YES;
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
   /* ACTUAL TEST CODE */
 #endif
   ctx = FSUI_start (NULL,
-                    cfg, "serializetest3", 32, YES, &eventCallback, NULL);
+                    cfg, "serializetest3", 32, GNUNET_YES, &eventCallback,
+                    NULL);
   CHECK (ctx != NULL);
-  SNPRINTF (keyword, 40, "%s %s %s", keywords[0], _("AND"), keywords[1]);
+  GNUNET_snprintf (keyword, 40, "%s %s %s", keywords[0], _("AND"),
+                   keywords[1]);
   uri = ECRS_parseCharKeywordURI (ectx, keyword);
-  search = FSUI_startSearch (ctx, 0, 100, 240 * cronSECONDS, uri);
+  search = FSUI_startSearch (ctx, 0, 100, 240 * GNUNET_CRON_SECONDS, uri);
   CHECK (search != NULL);
   prog = 0;
   suspendRestart = 10;
   while (prog < 1000)
     {
       prog++;
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if ((suspendRestart > 0) && (weak_randomi (100) == 0))
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if ((suspendRestart > 0)
+          && (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100) == 0))
         {
 #if 1
 #if DEBUG_VERBOSE
@@ -181,14 +186,15 @@
           CHECK (search == NULL);
           ctx = FSUI_start (NULL,
                             cfg,
-                            "serializetest3", 32, YES, &eventCallback, NULL);
+                            "serializetest3", 32, GNUNET_YES, &eventCallback,
+                            NULL);
 #if DEBUG_VERBOSE
           printf ("Resumed...\n");
 #endif
 #endif
           suspendRestart--;
         }
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   FSUI_abortSearch (ctx, search);
@@ -202,12 +208,12 @@
     ECRS_freeUri (uri);
 
 #if START_DAEMON
-  GE_BREAK (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_BREAK (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
   if (have_error)
-    ok = NO;
-  return (ok == YES) ? 0 : 1;
+    ok = GNUNET_NO;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of serializetest3.c */

Modified: GNUnet/src/applications/fs/fsui/serializetest4.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serializetest4.c    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/fsui/serializetest4.c    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -32,11 +32,11 @@
 #include "gnunet_util_network_client.h"
 #include "gnunet_util_crypto.h"
 
-#define DEBUG_VERBOSE NO
+#define DEBUG_VERBOSE GNUNET_NO
 
 #define UPLOAD_PREFIX "/tmp/gnunet-fsui-searializetest4"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(ectx, 0); goto FAILURE; }
 
 static struct GE_Context *ectx;
 
@@ -45,11 +45,11 @@
 {
   char *fn;
 
-  fn = MALLOC (strlen (UPLOAD_PREFIX "/FSUITEST") + 14);
-  SNPRINTF (fn,
-            strlen (UPLOAD_PREFIX "/FSUITEST") + 14,
-            UPLOAD_PREFIX "/FSUITEST%u", i);
-  disk_directory_create_for_file (NULL, fn);
+  fn = GNUNET_malloc (strlen (UPLOAD_PREFIX "/FSUITEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen (UPLOAD_PREFIX "/FSUITEST") + 14,
+                   UPLOAD_PREFIX "/FSUITEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -313,55 +313,56 @@
   int suspendRestart = 0;
 
 
-  ok = YES;
-  cfg = GC_create_C_impl ();
+  ok = GNUNET_YES;
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
   /* ACTUAL TEST CODE */
 #endif
   ctx = FSUI_start (NULL,
-                    cfg, "serializetest4", 32, YES, &eventCallback, NULL);
+                    cfg, "serializetest4", 32, GNUNET_YES, &eventCallback,
+                    NULL);
   CHECK (ctx != NULL);
   for (j = 4; j < 16; j += 4)
     {
       fn = makeName (j);
-      buf = MALLOC (FILESIZE * j);
+      buf = GNUNET_malloc (FILESIZE * j);
       for (i = 0; i < FILESIZE; i++)
-        buf[i] = weak_randomi (256);
-      disk_file_write (ectx, fn, buf, FILESIZE, "600");
-      FREE (buf);
-      FREE (fn);
+        buf[i] = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 256);
+      GNUNET_disk_file_write (ectx, fn, buf, FILESIZE, "600");
+      GNUNET_free (buf);
+      GNUNET_free (fn);
     }
   meta = ECRS_createMetaData ();
   kuri = ECRS_parseListKeywordURI (ectx, 2, (const char **) keywords);
   ECRS_addToMetaData (meta, 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);
+                             (DirectoryScanCallback) &
+                             GNUNET_disk_directory_scan, NULL, 0, 0,
+                             GNUNET_YES, GNUNET_NO, GNUNET_NO,
+                             GNUNET_get_time () + 5 * GNUNET_CRON_HOURS, 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]);
+  GNUNET_snprintf (keyword, 40, "%s %s %s", keywords[0], _("AND"),
+                   keywords[1]);
   uri = ECRS_parseCharKeywordURI (ectx, keyword);
   download = FSUI_startDownload (ctx,
                                  0,
-                                 YES,
+                                 GNUNET_YES,
                                  upURI,
                                  meta, UPLOAD_PREFIX "-download", NULL, NULL);
   ECRS_freeMetaData (meta);
@@ -370,8 +371,9 @@
   while (prog < 1000)
     {
       prog++;
-      PTHREAD_SLEEP (50 * cronMILLIS);
-      if ((suspendRestart > 0) && (weak_randomi (100) == 0))
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if ((suspendRestart > 0)
+          && (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100) == 0))
         {
 #if 1
 #if DEBUG_VERBOSE
@@ -382,14 +384,15 @@
           CHECK (download == NULL);
           ctx = FSUI_start (NULL,
                             cfg,
-                            "serializetest4", 32, YES, &eventCallback, NULL);
+                            "serializetest4", 32, GNUNET_YES, &eventCallback,
+                            NULL);
 #if DEBUG_VERBOSE
           printf ("Resumed...\n");
 #endif
 #endif
           suspendRestart--;
         }
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   FSUI_stopDownload (ctx, download);
@@ -399,7 +402,7 @@
       unindex = FSUI_startUnindex (ctx, fn);
       FSUI_stopUnindex (ctx, unindex);
       UNLINK (fn);
-      FREE (fn);
+      GNUNET_free (fn);
     }
   /* END OF TEST CODE */
 FAILURE:
@@ -413,12 +416,12 @@
     ECRS_freeUri (upURI);
 
 #if START_DAEMON
-  GE_BREAK (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_BREAK (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
   if (have_error)
-    ok = NO;
-  return (ok == YES) ? 0 : 1;
+    ok = GNUNET_NO;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of serializetest4.c */

Modified: GNUnet/src/applications/fs/fsui/unindex.c
===================================================================
--- GNUnet/src/applications/fs/fsui/unindex.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/unindex.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -37,7 +37,8 @@
  */
 static void
 progressCallback (unsigned long long totalBytes,
-                  unsigned long long completedBytes, cron_t eta, void *cls)
+                  unsigned long long completedBytes, GNUNET_CronTime eta,
+                  void *cls)
 {
   FSUI_UnindexList *utc = cls;
   FSUI_Event event;
@@ -57,8 +58,8 @@
 {
   FSUI_UnindexList *utc = cls;
   if (utc->state != FSUI_ACTIVE)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 /**
@@ -74,7 +75,9 @@
   struct GE_Memory *mem;
   struct GE_Context *ee;
 
-  if (OK != disk_file_size (utc->ctx->ectx, utc->filename, &size, YES))
+  if (GNUNET_OK !=
+      GNUNET_disk_file_size (utc->ctx->ectx, utc->filename, &size,
+                             GNUNET_YES))
     {
       GE_BREAK (utc->ctx->ectx, 0);
       size = 0;
@@ -86,7 +89,7 @@
   ret =
     ECRS_unindexFile (ee, utc->ctx->cfg, utc->filename, &progressCallback,
                       utc, &tt, utc);
-  if (ret == OK)
+  if (ret == GNUNET_OK)
     {
       utc->state = FSUI_COMPLETED;
       event.type = FSUI_unindex_completed;
@@ -142,7 +145,9 @@
   FSUI_Event event;
   unsigned long long size;
 
-  if (OK != disk_file_size (utc->ctx->ectx, utc->filename, &size, YES))
+  if (GNUNET_OK !=
+      GNUNET_disk_file_size (utc->ctx->ectx, utc->filename, &size,
+                             GNUNET_YES))
     {
       GE_BREAK (utc->ctx->ectx, 0);
       size = 0;
@@ -162,8 +167,8 @@
  * automatically the unindexed file in the global keyword space under
  * the given keywords.
  *
- * @return OK on success (at least we started with it),
- *  SYSERR if the file does not exist or gnunetd is not
+ * @return GNUNET_OK on success (at least we started with it),
+ *  GNUNET_SYSERR if the file does not exist or gnunetd is not
  *  running
  */
 struct FSUI_UnindexList *
@@ -171,35 +176,36 @@
 {
   FSUI_UnindexList *utc;
 
-  if (YES == disk_directory_test (ctx->ectx, filename))
+  if (GNUNET_YES == GNUNET_disk_directory_test (ctx->ectx, filename))
     {
       GE_BREAK (ctx->ectx, 0);
       return NULL;
     }
-  if (YES != disk_file_test (ctx->ectx, filename))
+  if (GNUNET_YES != GNUNET_disk_file_test (ctx->ectx, filename))
     {
       GE_BREAK (ctx->ectx, 0);
       return NULL;
     }
-  utc = MALLOC (sizeof (FSUI_UnindexList));
+  utc = GNUNET_malloc (sizeof (FSUI_UnindexList));
   utc->ctx = ctx;
-  utc->filename = STRDUP (filename);
-  utc->start_time = get_time ();
+  utc->filename = GNUNET_strdup (filename);
+  utc->start_time = GNUNET_get_time ();
   utc->state = FSUI_ACTIVE;
-  utc->handle = PTHREAD_CREATE (&FSUI_unindexThreadEvent, utc, 32 * 1024);
+  utc->handle =
+    GNUNET_thread_create (&FSUI_unindexThreadEvent, utc, 32 * 1024);
   if (utc->handle == NULL)
     {
       GE_LOG_STRERROR (ctx->ectx,
                        GE_ERROR | GE_ADMIN | GE_USER | GE_IMMEDIATE,
                        "PTHREAD_CREATE");
-      FREE (utc->filename);
-      FREE (utc);
+      GNUNET_free (utc->filename);
+      GNUNET_free (utc);
       return NULL;
     }
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   utc->next = ctx->unindexOperations;
   ctx->unindexOperations = utc;
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_mutex_unlock (ctx->lock);
   return utc;
 }
 
@@ -207,30 +213,30 @@
 /**
  * Abort a deletion operation.
  *
- * @return SYSERR if no such unindex is pending
+ * @return GNUNET_SYSERR if no such unindex is pending
  */
 int
 FSUI_abortUnindex (struct FSUI_Context *ctx, struct FSUI_UnindexList *ul)
 {
   if ((ul->state != FSUI_ACTIVE) && (ul->state != FSUI_PENDING))
-    return NO;
+    return GNUNET_NO;
   if (ul->state == FSUI_ACTIVE)
     {
       ul->state = FSUI_ABORTED;
-      PTHREAD_STOP_SLEEP (ul->handle);
+      GNUNET_thread_stop_sleep (ul->handle);
     }
   else
     {
       ul->state = FSUI_ABORTED_JOINED;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 
 /**
  * Stop a deletion operation.
  *
- * @return SYSERR if no such unindex is pending
+ * @return GNUNET_SYSERR if no such unindex is pending
  */
 int
 FSUI_stopUnindex (struct FSUI_Context *ctx, struct FSUI_UnindexList *dl)
@@ -244,23 +250,23 @@
   if (dl == NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #if 0
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER, "FSUI_stopUnindex called.\n");
 #endif
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   prev = ctx->unindexOperations;
   while ((prev != dl) && (prev != NULL) && (prev->next != dl))
     prev = prev->next;
   if (prev == NULL)
     {
-      MUTEX_UNLOCK (ctx->lock);
+      GNUNET_mutex_unlock (ctx->lock);
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "FSUI_stopUnindex failed to locate deletion operation.\n");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (prev == dl)
     {
@@ -270,13 +276,13 @@
     {
       prev->next = dl->next;
     }
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_mutex_unlock (ctx->lock);
   if ((dl->state == FSUI_ACTIVE) ||
       (dl->state == FSUI_COMPLETED) ||
       (dl->state == FSUI_ABORTED) || (dl->state == FSUI_ERROR))
     {
       GE_ASSERT (ctx->ectx, dl->handle != NULL);
-      PTHREAD_JOIN (dl->handle, &unused);
+      GNUNET_thread_join (dl->handle, &unused);
       dl->handle = NULL;
       if (dl->state == FSUI_ACTIVE)
         dl->state = FSUI_PENDING;
@@ -291,9 +297,9 @@
   event.data.UnindexStopped.uc.pos = dl;
   event.data.UnindexStopped.uc.cctx = dl->cctx;
   dl->ctx->ecb (dl->ctx->ecbClosure, &event);
-  FREE (dl->filename);
-  FREE (dl);
-  return OK;
+  GNUNET_free (dl->filename);
+  GNUNET_free (dl);
+  return GNUNET_OK;
 }
 
 /* end of unindex.c */

Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/fsui/upload.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -35,56 +35,63 @@
 #include "fsui.h"
 #include <extractor.h>
 
-#define DEBUG_UPLOAD NO
+#define DEBUG_UPLOAD GNUNET_NO
 
 /**
  * Transform an ECRS progress callback into an FSUI event.
- * 
+ *
  * @param direct is this a direct ECRS trigger, or a recursive
  *        call from a child signaling progress to the parent?
  */
 static void
 progressCallbackR (unsigned long long totalBytes,
-                  unsigned long long completedBytes, cron_t eta, void *ptr,
-                  int direct,
-                  int add,
-                  int unaccounted)
+                   unsigned long long completedBytes, GNUNET_CronTime eta,
+                   void *ptr, int direct, int add, int unaccounted)
 {
   FSUI_UploadList *utc = ptr;
   FSUI_Event event;
   unsigned long long subtotal;
   FSUI_UploadList *pos;
-  cron_t xeta;
-  cron_t now;
+  GNUNET_CronTime xeta;
+  GNUNET_CronTime now;
 
   event.type = FSUI_upload_progress;
   event.data.UploadProgress.uc.pos = utc;
   event.data.UploadProgress.uc.cctx = utc->cctx;
   event.data.UploadProgress.uc.ppos = utc->parent;
   event.data.UploadProgress.uc.pcctx = utc->parent->cctx;
-  if (YES == ECRS_isDirectory(utc->meta)) {
-    if (direct == YES)
-      unaccounted = YES;
-    if ( (direct == YES) && (totalBytes == completedBytes) ) 
-      add = YES;
-    if (add == NO) {
-      event.data.UploadProgress.completed = completedBytes + utc->completed;
-      event.data.UploadProgress.total = utc->total + ((unaccounted == NO) ? 0 
: totalBytes);
-      if (totalBytes == completedBytes) 
-       utc->completed += completedBytes;
-    } else {
-      GE_ASSERT(NULL, totalBytes == completedBytes);
-      event.data.UploadProgress.completed = completedBytes + utc->completed;
-      event.data.UploadProgress.total = totalBytes + utc->total;
-      utc->total += completedBytes;
-      utc->completed += completedBytes;
+  if (GNUNET_YES == ECRS_isDirectory (utc->meta))
+    {
+      if (direct == GNUNET_YES)
+        unaccounted = GNUNET_YES;
+      if ((direct == GNUNET_YES) && (totalBytes == completedBytes))
+        add = GNUNET_YES;
+      if (add == GNUNET_NO)
+        {
+          event.data.UploadProgress.completed =
+            completedBytes + utc->completed;
+          event.data.UploadProgress.total =
+            utc->total + ((unaccounted == GNUNET_NO) ? 0 : totalBytes);
+          if (totalBytes == completedBytes)
+            utc->completed += completedBytes;
+        }
+      else
+        {
+          GE_ASSERT (NULL, totalBytes == completedBytes);
+          event.data.UploadProgress.completed =
+            completedBytes + utc->completed;
+          event.data.UploadProgress.total = totalBytes + utc->total;
+          utc->total += completedBytes;
+          utc->completed += completedBytes;
+        }
     }
-  } else {
-    /* simple file upload */
-    event.data.UploadProgress.completed = completedBytes;
-    event.data.UploadProgress.total = totalBytes;
-    utc->completed = completedBytes;
-  }
+  else
+    {
+      /* simple file upload */
+      event.data.UploadProgress.completed = completedBytes;
+      event.data.UploadProgress.total = totalBytes;
+      utc->completed = completedBytes;
+    }
   event.data.UploadProgress.eta = eta;
   event.data.UploadProgress.filename = utc->filename;
   utc->shared->ctx->ecb (utc->shared->ctx->ecbClosure, &event);
@@ -97,17 +104,17 @@
           subtotal += pos->completed;
           pos = pos->next;
         }
-      now = get_time ();
+      now = GNUNET_get_time ();
       xeta = now;
       if (subtotal > 0)
         {
-          xeta = (cron_t) (utc->parent->start_time +
-                           (((double) (now - utc->parent->start_time) /
-                             (double) subtotal)) *
-                           (double) utc->parent->total);
+          xeta = (GNUNET_CronTime) (utc->parent->start_time +
+                                    (((double) (now - utc->parent->start_time)
+                                      / (double) subtotal)) *
+                                    (double) utc->parent->total);
         }
       progressCallbackR (totalBytes, completedBytes, xeta, utc->parent,
-                        NO, add, unaccounted);
+                         GNUNET_NO, add, unaccounted);
     }
 }
 
@@ -116,9 +123,11 @@
  */
 static void
 progressCallback (unsigned long long totalBytes,
-                  unsigned long long completedBytes, cron_t eta, void *ptr) 
+                  unsigned long long completedBytes, GNUNET_CronTime eta,
+                  void *ptr)
 {
-  progressCallbackR(totalBytes, completedBytes, eta, ptr, YES, NO, NO);
+  progressCallbackR (totalBytes, completedBytes, eta, ptr, GNUNET_YES,
+                     GNUNET_NO, GNUNET_NO);
 }
 
 static int
@@ -126,8 +135,8 @@
 {
   FSUI_UploadList *utc = cls;
   if (utc->state != FSUI_ACTIVE)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 /**
@@ -162,7 +171,7 @@
         count++;
       pos = pos->next;
     }
-  GROW (fis, size, count);
+  GNUNET_array_grow (fis, size, count);
   count = 0;
   pos = children;
   while (pos != NULL)
@@ -181,10 +190,10 @@
     GE_create_context_memory (GE_USER | GE_ADMIN | GE_ERROR | GE_WARNING |
                               GE_FATAL | GE_BULK | GE_IMMEDIATE, mem);
   ret = ECRS_createDirectory (ee, &data, &len, size, fis, meta);
-  GROW (fis, size, 0);
-  if (ret != OK)
+  GNUNET_array_grow (fis, size, 0);
+  if (ret != GNUNET_OK)
     {
-      *error = STRDUP (GE_memory_get (mem, 0));
+      *error = GNUNET_strdup (GE_memory_get (mem, 0));
       GE_free_context (ee);
       GE_memory_free (mem);
       return NULL;
@@ -197,16 +206,16 @@
       pos = pos->next;
     }
   GE_memory_reset (mem);
-  tempName = STRDUP ("/tmp/gnunet-upload-dir.XXXXXX");
+  tempName = GNUNET_strdup ("/tmp/gnunet-upload-dir.XXXXXX");
   handle = mkstemp (tempName);
   if (handle == -1)
     {
       GE_LOG_STRERROR_FILE (ee,
                             GE_ERROR | GE_USER | GE_BULK,
                             "mkstemp", tempName);
-      FREE (tempName);
-      FREE (data);
-      *error = STRDUP (GE_memory_get (mem, 0));
+      GNUNET_free (tempName);
+      GNUNET_free (data);
+      *error = GNUNET_strdup (GE_memory_get (mem, 0));
       GE_free_context (ee);
       GE_memory_free (mem);
       return NULL;
@@ -215,16 +224,16 @@
     {
       GE_LOG_STRERROR_FILE (ee,
                             GE_ERROR | GE_USER | GE_BULK, "write", tempName);
-      *error = STRDUP (GE_memory_get (mem, 0));
+      *error = GNUNET_strdup (GE_memory_get (mem, 0));
       GE_free_context (ee);
       GE_memory_free (mem);
-      FREE (data);
+      GNUNET_free (data);
       return NULL;
     }
   GE_free_context (ee);
   GE_memory_free (mem);
   CLOSE (handle);
-  FREE (data);
+  GNUNET_free (data);
   return tempName;
 }
 
@@ -303,7 +312,7 @@
     }
   if (utc->state != FSUI_ACTIVE)
     return NULL;                /* aborted or suspended */
-  if (YES == disk_directory_test (ectx, utc->filename))
+  if (GNUNET_YES == GNUNET_disk_directory_test (ectx, utc->filename))
     {
       error = NULL;
       filename = createDirectoryHelper (ectx,
@@ -312,29 +321,31 @@
       if (filename == NULL)
         {
           if (error == NULL)
-            error = STRDUP (_("Failed to create temporary directory."));
+            error =
+              GNUNET_strdup (_("Failed to create temporary directory."));
           signalError (utc, error);
-          FREE (error);
+          GNUNET_free (error);
           return NULL;
         }
     }
   else
     {
-      filename = STRDUP (utc->filename);
+      filename = GNUNET_strdup (utc->filename);
     }
-  utc->start_time = get_time ();
+  utc->start_time = GNUNET_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);
   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);
-  if (ret != OK)
+                     utc->shared->doIndex == GNUNET_YES ? (utc->child ==
+                                                           NULL ? GNUNET_YES :
+                                                           GNUNET_NO) :
+                     GNUNET_NO, utc->shared->anonymityLevel,
+                     utc->shared->priority, utc->shared->expiration,
+                     &progressCallback, utc, &testTerminate, utc, &utc->uri);
+  if (ret != GNUNET_OK)
     {
       if (utc->state == FSUI_ACTIVE)
         {
@@ -359,7 +370,7 @@
         }
       if (utc->child != NULL)
         UNLINK (filename);
-      FREE (filename);
+      GNUNET_free (filename);
       GE_free_context (ee);
       GE_memory_free (mem);
       return NULL;
@@ -368,7 +379,8 @@
   if (utc->child == NULL)
     ECRS_extractMetaData (utc->shared->ctx->ectx,
                           utc->meta, utc->filename, utc->shared->extractors);
-  while (OK == ECRS_delFromMetaData (utc->meta, EXTRACTOR_FILENAME, NULL));
+  while (GNUNET_OK ==
+         ECRS_delFromMetaData (utc->meta, EXTRACTOR_FILENAME, NULL));
   /* only publish the last part of the path
      -- we do not want to publish $HOME or similar
      trivially deanonymizing information */
@@ -377,38 +389,39 @@
     tpos--;
   while ((tpos > 0) && (utc->filename[tpos] != DIR_SEPARATOR))
     tpos--;
-  pfn = MALLOC (strlen (&utc->filename[tpos + 1]) + 2);
+  pfn = GNUNET_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)))
     strcat (pfn, DIR_SEPARATOR_STR);
   ECRS_addToMetaData (utc->meta, EXTRACTOR_FILENAME, pfn);
-  FREE (pfn);
-  if ((utc->shared->anonymityLevel == 0) && (utc->shared->doIndex == YES))
+  GNUNET_free (pfn);
+  if ((utc->shared->anonymityLevel == 0)
+      && (utc->shared->doIndex == GNUNET_YES))
     {
       /* generate location URI for non-anonymous download */
-      struct ClientServerConnection *sock;
-      P2P_hello_MESSAGE *hello;
+      struct GNUNET_ClientServerConnection *sock;
+      GNUNET_MessageHello *hello;
 
-      sock = client_connection_create (utc->shared->ctx->ectx,
-                                       utc->shared->ctx->cfg);
+      sock = GNUNET_client_connection_create (utc->shared->ctx->ectx,
+                                              utc->shared->ctx->cfg);
 
-      if (OK == gnunet_identity_get_self (sock, &hello))
+      if (GNUNET_OK == GNUNET_IDENTITY_get_self (sock, &hello))
         {
           loc = ECRS_uriFromLocation (utc->uri,
                                       &hello->publicKey,
                                       ntohl (hello->expirationTime),
                                       (ECRS_SignFunction) &
-                                      gnunet_identity_sign_function, sock);
+                                      GNUNET_IDENTITY_sign_function, sock);
 
-          FREE (hello);
+          GNUNET_free (hello);
         }
       else
         {
           /* may happen if no transports are available... */
           loc = ECRS_dupUri (utc->uri);
         }
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
     }
   else
     {
@@ -430,7 +443,7 @@
                         utc->shared->anonymityLevel,
                         utc->shared->priority,
                         utc->shared->expiration, loc, utc->meta);
-  if (utc->shared->individualKeywords == YES)
+  if (utc->shared->individualKeywords == GNUNET_YES)
     {
       uri = ECRS_metaDataToUri (utc->meta);
       ECRS_addToKeyspace (ectx,
@@ -443,7 +456,8 @@
     }
   ECRS_freeUri (loc);
   loc = NULL;
-  while (OK == ECRS_delFromMetaData (utc->meta, EXTRACTOR_SPLIT, NULL));
+  while (GNUNET_OK ==
+         ECRS_delFromMetaData (utc->meta, EXTRACTOR_SPLIT, NULL));
   fi.meta = utc->meta;
   fi.uri = utc->uri;
   URITRACK_trackURI (ectx, utc->shared->ctx->cfg, &fi);
@@ -451,7 +465,7 @@
                      utc->shared->ctx->cfg,
                      utc->uri,
                      utc->shared->doIndex ==
-                     YES ? URITRACK_INDEXED : URITRACK_INSERTED);
+                     GNUNET_YES ? URITRACK_INDEXED : URITRACK_INSERTED);
   event.type = FSUI_upload_completed;
   event.data.UploadCompleted.uc.pos = utc;
   event.data.UploadCompleted.uc.cctx = utc->cctx;
@@ -463,7 +477,7 @@
   utc->shared->ctx->ecb (utc->shared->ctx->ecbClosure, &event);
   if (utc->child != NULL)
     UNLINK (filename);
-  FREE (filename);
+  GNUNET_free (filename);
   GE_free_context (ee);
   GE_memory_free (mem);
   return NULL;
@@ -495,8 +509,8 @@
   ctx = ul->shared->ctx;
   while (ul->child != NULL)
     freeUploadList (ul->child);
-  MUTEX_LOCK (ctx->lock);
-  FREE (ul->filename);
+  GNUNET_mutex_lock (ctx->lock);
+  GNUNET_free (ul->filename);
   if (ul->keywords != NULL)
     ECRS_freeUri (ul->keywords);
   if (ul->uri != NULL)
@@ -508,7 +522,7 @@
   if (next == NULL)
     {
       GE_BREAK (NULL, 0);
-      MUTEX_UNLOCK (ctx->lock);
+      GNUNET_mutex_unlock (ctx->lock);
       return;
     }
   if (next == ul)
@@ -523,14 +537,14 @@
           if (next == NULL)
             {
               GE_BREAK (NULL, 0);
-              MUTEX_UNLOCK (ctx->lock);
+              GNUNET_mutex_unlock (ctx->lock);
               return;
             }
         }
       next->next = ul->next;
     }
-  FREE (ul);
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_free (ul);
+  GNUNET_mutex_unlock (ctx->lock);
 }
 
 static struct FSUI_UploadList *addUploads (struct FSUI_UploadShared *shared,
@@ -547,18 +561,18 @@
   struct FSUI_UploadList *child;
   struct ECRS_MetaData *md;
 
-  filename = MALLOC (strlen (dirName) + strlen (name) + 2);
+  filename = GNUNET_malloc (strlen (dirName) + strlen (name) + 2);
   strcpy (filename, dirName);
   strcat (filename, DIR_SEPARATOR_STR);
   strcat (filename, name);
   md = ECRS_createMetaData ();
   child = addUploads (parent->shared, filename, NULL, md, parent);
-  FREE (filename);
+  GNUNET_free (filename);
   ECRS_freeMetaData (md);
   if (child == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   parent->total += child->total;
-  return OK;
+  return GNUNET_OK;
 }
 
 static struct FSUI_UploadList *
@@ -569,10 +583,10 @@
 {
   FSUI_UploadList *utc;
 
-  utc = MALLOC (sizeof (FSUI_UploadList));
+  utc = GNUNET_malloc (sizeof (FSUI_UploadList));
   utc->completed = 0;
   utc->total = 0;               /* to be set later */
-  utc->start_time = get_time ();
+  utc->start_time = GNUNET_get_time ();
   utc->shared = shared;
   utc->next = NULL;
   utc->child = NULL;
@@ -580,26 +594,27 @@
   utc->uri = NULL;
   utc->cctx = NULL;             /* to be set later */
   utc->state = FSUI_ACTIVE;
-  if (YES == disk_file_test (shared->ctx->ectx, filename))
+  if (GNUNET_YES == GNUNET_disk_file_test (shared->ctx->ectx, filename))
     {
       /* add this file */
-      if (OK != disk_file_size (shared->ctx->ectx,
-                                filename, &utc->total, YES))
+      if (GNUNET_OK != GNUNET_disk_file_size (shared->ctx->ectx,
+                                              filename, &utc->total,
+                                              GNUNET_YES))
         {
-          FREE (utc);
+          GNUNET_free (utc);
           return NULL;
         }
       utc->meta = ECRS_dupMetaData (md);
     }
   else
     {
-      if (SYSERR == shared->dsc (shared->dscClosure,
-                                 filename, &addChildUpload, utc))
+      if (GNUNET_SYSERR == shared->dsc (shared->dscClosure,
+                                        filename, &addChildUpload, utc))
         {
           /* error scanning upload directory */
           while (utc->child != NULL)
             freeUploadList (utc->child);
-          FREE (utc);
+          GNUNET_free (utc);
           return NULL;
         }
       utc->meta = ECRS_dupMetaData (md);
@@ -610,13 +625,13 @@
     utc->keywords = ECRS_dupUri (keywords);
   else
     utc->keywords = NULL;
-  utc->filename = STRDUP (filename);
+  utc->filename = GNUNET_strdup (filename);
 
   /* finally, link with parent */
-  MUTEX_LOCK (shared->ctx->lock);
+  GNUNET_mutex_lock (shared->ctx->lock);
   utc->next = parent->child;
   parent->child = utc;
-  MUTEX_UNLOCK (shared->ctx->lock);
+  GNUNET_mutex_unlock (shared->ctx->lock);
   return utc;
 }
 
@@ -646,8 +661,8 @@
   if (shared->global_keywords != NULL)
     ECRS_freeUri (shared->global_keywords);
   EXTRACTOR_removeAll (shared->extractors);
-  FREENONNULL (shared->extractor_config);
-  FREE (shared);
+  GNUNET_free_non_null (shared->extractor_config);
+  GNUNET_free (shared);
 }
 
 /**
@@ -656,8 +671,8 @@
  * automatically the uploaded file in the global keyword space under
  * the given keywords.
  *
- * @return OK on success (at least we started with it),
- *  SYSERR if the file does not exist or gnunetd is not
+ * @return GNUNET_OK on success (at least we started with it),
+ *  GNUNET_SYSERR if the file does not exist or gnunetd is not
  *  running
  */
 struct FSUI_UploadList *
@@ -670,7 +685,7 @@
                   int doIndex,
                   int doExtract,
                   int individualKeywords,
-                  cron_t expiration,
+                  GNUNET_CronTime expiration,
                   const struct ECRS_MetaData *md,
                   const struct ECRS_URI *globalURI,
                   const struct ECRS_URI *keyUri)
@@ -696,7 +711,7 @@
             }
         }
     }
-  shared = MALLOC (sizeof (FSUI_UploadShared));
+  shared = GNUNET_malloc (sizeof (FSUI_UploadShared));
   shared->dsc = dsc;
   shared->dscClosure = dscClosure;
   shared->extractors = extractors;
@@ -717,7 +732,8 @@
       freeShared (shared);
       return NULL;
     }
-  shared->handle = PTHREAD_CREATE (&FSUI_uploadThreadEvent, ul, 128 * 1024);
+  shared->handle =
+    GNUNET_thread_create (&FSUI_uploadThreadEvent, ul, 128 * 1024);
   if (shared->handle == NULL)
     {
       GE_LOG_STRERROR (ctx->ectx,
@@ -737,7 +753,7 @@
  * the top-level upload will continue without the
  * subtree selected using this abort command.
  *
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 int
 FSUI_abortUpload (struct FSUI_Context *ctx, struct FSUI_UploadList *ul)
@@ -746,7 +762,7 @@
 
   GE_ASSERT (ctx->ectx, ul != NULL);
   if ((ul->state != FSUI_ACTIVE) && (ul->state != FSUI_PENDING))
-    return NO;
+    return GNUNET_NO;
   if (ul->state == FSUI_ACTIVE)
     {
       ul->state = FSUI_ABORTED;
@@ -756,7 +772,7 @@
           FSUI_abortUpload (ctx, c);
           c = c->next;
         }
-      PTHREAD_STOP_SLEEP (ul->shared->handle);
+      GNUNET_thread_stop_sleep (ul->shared->handle);
     }
   else
     {
@@ -768,14 +784,14 @@
           c = c->next;
         }
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Stop an upload.  Only to be called for the top-level
  * upload.
  *
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 int
 FSUI_stopUpload (struct FSUI_Context *ctx, struct FSUI_UploadList *ul)
@@ -790,7 +806,7 @@
       (ul->state == FSUI_ABORTED) || (ul->state == FSUI_ERROR))
     {
       GE_ASSERT (ctx->ectx, ul->shared->handle != NULL);
-      PTHREAD_JOIN (ul->shared->handle, &unused);
+      GNUNET_thread_join (ul->shared->handle, &unused);
       ul->shared->handle = NULL;
       if (ul->state == FSUI_ACTIVE)
         ul->state = FSUI_PENDING;
@@ -805,7 +821,7 @@
   shared = ul->shared;
   freeUploadList (ul);
   freeShared (shared);
-  return OK;
+  return GNUNET_OK;
 }
 
 /* end of upload.c */

Modified: GNUnet/src/applications/fs/lib/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/lib/Makefile.am  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/lib/Makefile.am  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -7,8 +7,6 @@
   fslib.c 
 libgnunetfs_la_LIBADD = \
  $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
  $(top_builddir)/src/applications/fs/libecrs_core.la
 
 
@@ -21,8 +19,6 @@
   fslibtest.c
 fslibtest_LDADD = \
   $(top_builddir)/src/applications/fs/lib/libgnunetfs.la \
-  $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 EXTRA_DIST = \

Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/lib/fslib.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -30,7 +30,7 @@
 #include "fs.h"
 #include "ecrs_core.h"
 
-#define DEBUG_FSLIB NO
+#define DEBUG_FSLIB GNUNET_NO
 
 typedef struct FS_SEARCH_HANDLE
 {
@@ -43,9 +43,9 @@
 {
   struct GC_Configuration *cfg;
   struct GE_Context *ectx;
-  struct ClientServerConnection *sock;
-  struct PTHREAD *thread;
-  struct MUTEX *lock;
+  struct GNUNET_ClientServerConnection *sock;
+  struct GNUNET_ThreadHandle *thread;
+  struct GNUNET_Mutex *lock;
   SEARCH_HANDLE **handles;
   unsigned int handleCount;
   unsigned int handleSize;
@@ -66,26 +66,26 @@
 processReplies (void *cls)
 {
   SEARCH_CONTEXT *ctx = cls;
-  MESSAGE_HEADER *hdr;
+  GNUNET_MessageHeader *hdr;
   int i;
   int matched;
   const CS_fs_reply_content_MESSAGE *rep;
-  HashCode512 query;
+  GNUNET_HashCode query;
   unsigned int size;
-  cron_t delay;
+  GNUNET_CronTime delay;
 
-  delay = 100 * cronMILLIS;
-  while (ctx->abort == NO)
+  delay = 100 * GNUNET_CRON_MILLISECONDS;
+  while (ctx->abort == GNUNET_NO)
     {
       hdr = NULL;
-      if (OK == connection_read (ctx->sock, &hdr))
+      if (GNUNET_OK == GNUNET_client_connection_read (ctx->sock, &hdr))
         {
 #if DEBUG_FSLIB
           GE_LOG (ctx->ectx,
                   GE_DEBUG | GE_REQUEST | GE_USER,
                   "FSLIB: received message from gnunetd\n");
 #endif
-          delay = 100 * cronMILLIS;
+          delay = 100 * GNUNET_CRON_MILLISECONDS;
           /* verify hdr, if reply, process, otherwise
              signal protocol problem; if ok, find
              matching callback, call on value */
@@ -93,30 +93,32 @@
               (ntohs (hdr->type) != CS_PROTO_gap_RESULT))
             {
               GE_BREAK (ctx->ectx, 0);
-              FREE (hdr);
+              GNUNET_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))
+          if (GNUNET_OK != getQueryFor (size, (DBlock *) & rep[1], GNUNET_NO,  
 /* gnunetd will have checked already */
+                                        &query))
             {
               GE_BREAK (ctx->ectx, 0);
-              FREE (hdr);
+              GNUNET_free (hdr);
               continue;
             }
           matched = 0;
-          MUTEX_LOCK (ctx->lock);
+          GNUNET_mutex_lock (ctx->lock);
           for (i = ctx->handleCount - 1; i >= 0; i--)
             {
-              if (equalsHashCode512 (&query, &ctx->handles[i]->req->query[0]))
+              if (0 ==
+                  memcmp (&query, &ctx->handles[i]->req->query[0],
+                          sizeof (GNUNET_HashCode)))
                 {
                   Datastore_Value *value;
 
                   matched++;
                   if (ctx->handles[i]->callback != NULL)
                     {
-                      value = MALLOC (sizeof (Datastore_Value) + size);
+                      value = GNUNET_malloc (sizeof (Datastore_Value) + size);
                       value->size = htonl (size + sizeof (Datastore_Value));
                       value->type = htonl (getTypeOfBlock (size,
                                                            (DBlock *) &
@@ -125,19 +127,21 @@
                       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, 0))
+                      if (GNUNET_SYSERR == ctx->handles[i]->callback (&query,
+                                                                      value,
+                                                                      ctx->
+                                                                      handles
+                                                                      [i]->
+                                                                      closure,
+                                                                      0))
                         {
                           ctx->handles[i]->callback = NULL;
                         }
-                      FREE (value);
+                      GNUNET_free (value);
                     }
                 }
             }
-          MUTEX_UNLOCK (ctx->lock);
+          GNUNET_mutex_unlock (ctx->lock);
 #if DEBUG_FSLIB
           if (matched == 0)
             GE_LOG (ctx->ectx,
@@ -153,39 +157,40 @@
                   "FSLIB: error communicating with gnunetd; sleeping for 
%ums\n",
                   delay);
 #endif
-          if (ctx->abort == NO)
-            PTHREAD_SLEEP (delay);
+          if (ctx->abort == GNUNET_NO)
+            GNUNET_thread_sleep (delay);
           delay *= 2;
-          if (delay > 5 * cronSECONDS)
-            delay = 5 * cronSECONDS;
+          if (delay > 5 * GNUNET_CRON_SECONDS)
+            delay = 5 * GNUNET_CRON_SECONDS;
         }
-      FREENONNULL (hdr);
+      GNUNET_free_non_null (hdr);
     }
   return NULL;
 }
 
 SEARCH_CONTEXT *
 FS_SEARCH_makeContext (struct GE_Context * ectx,
-                       struct GC_Configuration * cfg, struct MUTEX * lock)
+                       struct GC_Configuration * cfg,
+                       struct GNUNET_Mutex * lock)
 {
   SEARCH_CONTEXT *ret;
 
   GE_ASSERT (ectx, lock != NULL);
-  ret = MALLOC (sizeof (SEARCH_CONTEXT));
+  ret = GNUNET_malloc (sizeof (SEARCH_CONTEXT));
   ret->ectx = ectx;
   ret->cfg = cfg;
   ret->lock = lock;
-  ret->sock = client_connection_create (ectx, cfg);
+  ret->sock = GNUNET_client_connection_create (ectx, cfg);
   if (ret->sock == NULL)
     {
-      FREE (ret);
+      GNUNET_free (ret);
       return NULL;
     }
   ret->handles = NULL;
   ret->handleCount = 0;
   ret->handleSize = 0;
-  ret->abort = NO;
-  ret->thread = PTHREAD_CREATE (&processReplies, ret, 128 * 1024);
+  ret->abort = GNUNET_NO;
+  ret->thread = GNUNET_thread_create (&processReplies, ret, 128 * 1024);
   if (ret->thread == NULL)
     GE_DIE_STRERROR (ectx, GE_FATAL | GE_ADMIN | GE_BULK, "PTHREAD_CREATE");
   return ret;
@@ -196,17 +201,17 @@
 {
   void *unused;
 
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   GE_ASSERT (ctx->ectx, 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);
+  ctx->abort = GNUNET_YES;
+  GNUNET_client_connection_close_forever (ctx->sock);
+  GNUNET_mutex_unlock (ctx->lock);
+  GNUNET_thread_stop_sleep (ctx->thread);
+  GNUNET_thread_join (ctx->thread, &unused);
   ctx->lock = NULL;
-  connection_destroy (ctx->sock);
-  GROW (ctx->handles, ctx->handleSize, 0);
-  FREE (ctx);
+  GNUNET_client_connection_destroy (ctx->sock);
+  GNUNET_array_grow (ctx->handles, ctx->handleSize, 0);
+  GNUNET_free (ctx);
 }
 
 /**
@@ -221,60 +226,62 @@
  */
 SEARCH_HANDLE *
 FS_start_search (SEARCH_CONTEXT * ctx,
-                 const PeerIdentity * target,
+                 const GNUNET_PeerIdentity * target,
                  unsigned int type,
                  unsigned int keyCount,
-                 const HashCode512 * keys,
+                 const GNUNET_HashCode * keys,
                  unsigned int anonymityLevel,
                  unsigned int prio,
-                 cron_t timeout, Datum_Iterator callback, void *closure)
+                 GNUNET_CronTime timeout, Datum_Iterator callback,
+                 void *closure)
 {
   SEARCH_HANDLE *ret;
   CS_fs_request_search_MESSAGE *req;
 #if DEBUG_FSLIB
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
-  ret = MALLOC (sizeof (SEARCH_HANDLE));
+  ret = GNUNET_malloc (sizeof (SEARCH_HANDLE));
 #if DEBUG_FSLIB
   GE_LOG (ctx->ectx,
           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));
+    GNUNET_malloc (sizeof (CS_fs_request_search_MESSAGE) +
+                   (keyCount - 1) * sizeof (GNUNET_HashCode));
   req->header.size =
     htons (sizeof (CS_fs_request_search_MESSAGE) +
-           (keyCount - 1) * sizeof (HashCode512));
+           (keyCount - 1) * sizeof (GNUNET_HashCode));
   req->header.type = htons (CS_PROTO_gap_QUERY_START);
   req->prio = htonl (prio);
   req->anonymityLevel = htonl (anonymityLevel);
-  req->expiration = htonll (timeout);
+  req->expiration = GNUNET_htonll (timeout);
   req->type = htonl (type);
   if (target != NULL)
     req->target = *target;
   else
-    memset (&req->target, 0, sizeof (PeerIdentity));
-  memcpy (&req->query[0], keys, keyCount * sizeof (HashCode512));
+    memset (&req->target, 0, sizeof (GNUNET_PeerIdentity));
+  memcpy (&req->query[0], keys, keyCount * sizeof (GNUNET_HashCode));
   ret->req = req;
   ret->callback = callback;
   ret->closure = closure;
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   if (ctx->handleCount == ctx->handleSize)
     {
-      GROW (ctx->handles, ctx->handleSize, ctx->handleSize * 2 + 4);
+      GNUNET_array_grow (ctx->handles, ctx->handleSize,
+                         ctx->handleSize * 2 + 4);
     }
   ctx->handles[ctx->handleCount++] = ret;
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_mutex_unlock (ctx->lock);
 #if DEBUG_FSLIB
   IF_GELOG (ctx->ectx,
-            GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (&req->query[0], &enc));
-  GE_LOG (ctx->ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+            GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (&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);
 #endif
   GE_ASSERT (NULL, ctx->sock != NULL);
-  if (OK != connection_write (ctx->sock, &req->header))
+  if (GNUNET_OK != GNUNET_client_connection_write (ctx->sock, &req->header))
     {
       FS_stop_search (ctx, ret);
       return NULL;
@@ -302,27 +309,28 @@
 #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))
+  if (GNUNET_OK !=
+      GNUNET_client_connection_write (ctx->sock, &handle->req->header))
     {
       GE_LOG (ctx->ectx,
               GE_WARNING | GE_REQUEST | GE_DEVELOPER,
               "FSLIB: failed to request stop search with gnunetd\n");
     }
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   for (i = ctx->handleCount - 1; i >= 0; i--)
     if (ctx->handles[i] == handle)
       {
         ctx->handles[i] = ctx->handles[--ctx->handleCount];
         break;
       }
-  MUTEX_UNLOCK (ctx->lock);
-  FREE (handle->req);
+  GNUNET_mutex_unlock (ctx->lock);
+  GNUNET_free (handle->req);
 #if DEBUG_FSLIB
   GE_LOG (ctx->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "FSLIB: search stopped (%p)\n", handle);
 #endif
-  FREE (handle);
+  GNUNET_free (handle);
 }
 
 /**
@@ -330,16 +338,16 @@
  * in the routing table like?  Returns -1 on error.
  */
 int
-FS_getAveragePriority (struct ClientServerConnection *sock)
+FS_getAveragePriority (struct GNUNET_ClientServerConnection *sock)
 {
-  MESSAGE_HEADER req;
+  GNUNET_MessageHeader req;
   int ret;
 
-  req.size = htons (sizeof (MESSAGE_HEADER));
+  req.size = htons (sizeof (GNUNET_MessageHeader));
   req.type = htons (CS_PROTO_gap_GET_AVG_PRIORITY);
-  if (OK != connection_write (sock, &req))
+  if (GNUNET_OK != GNUNET_client_connection_write (sock, &req))
     return -1;
-  if (OK != connection_read_result (sock, &ret))
+  if (GNUNET_OK != GNUNET_client_connection_read_result (sock, &ret))
     return -1;
   return ret;
 }
@@ -348,10 +356,11 @@
  * Insert a block.
  *
  * @param block the block (properly encoded and all)
- * @return OK on success, SYSERR on error, NO on transient error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error, GNUNET_NO on 
transient error
  */
 int
-FS_insert (struct ClientServerConnection *sock, const Datastore_Value * block)
+FS_insert (struct GNUNET_ClientServerConnection *sock,
+           const Datastore_Value * block)
 {
   int ret;
   CS_fs_request_insert_MESSAGE *ri;
@@ -361,10 +370,10 @@
   if (ntohl (block->size) <= sizeof (Datastore_Value))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   size = ntohl (block->size) - sizeof (Datastore_Value);
-  ri = MALLOC (sizeof (CS_fs_request_insert_MESSAGE) + size);
+  ri = GNUNET_malloc (sizeof (CS_fs_request_insert_MESSAGE) + size);
   ri->header.size = htons (sizeof (CS_fs_request_insert_MESSAGE) + size);
   ri->header.type = htons (CS_PROTO_gap_INSERT);
   ri->prio = block->prio;
@@ -374,20 +383,20 @@
   retry = AUTO_RETRY;
   do
     {
-      if (OK != connection_write (sock, &ri->header))
+      if (GNUNET_OK != GNUNET_client_connection_write (sock, &ri->header))
         {
-          FREE (ri);
-          return SYSERR;
+          GNUNET_free (ri);
+          return GNUNET_SYSERR;
         }
-      if (OK != connection_read_result (sock, &ret))
+      if (GNUNET_OK != GNUNET_client_connection_read_result (sock, &ret))
         {
           GE_BREAK (NULL, 0);
-          FREE (ri);
-          return SYSERR;
+          GNUNET_free (ri);
+          return GNUNET_SYSERR;
         }
     }
-  while ((ret == NO) && (retry-- > 0));
-  FREE (ri);
+  while ((ret == GNUNET_NO) && (retry-- > 0));
+  GNUNET_free (ri);
   return ret;
 }
 
@@ -395,8 +404,8 @@
  * Initialize to index a file
  */
 int
-FS_initIndex (struct ClientServerConnection *sock,
-              const HashCode512 * fileHc, const char *fn)
+FS_initIndex (struct GNUNET_ClientServerConnection *sock,
+              const GNUNET_HashCode * fileHc, const char *fn)
 {
   int ret;
   CS_fs_request_init_index_MESSAGE *ri;
@@ -407,7 +416,7 @@
   fnSize = (fnSize + 7) & (~7); /* align */
   size = sizeof (CS_fs_request_init_index_MESSAGE) + fnSize;
   GE_ASSERT (NULL, size < 65536);
-  ri = MALLOC (size);
+  ri = GNUNET_malloc (size);
   memset (ri, 0, size);
   ri->header.size = htons (size);
   ri->header.type = htons (CS_PROTO_gap_INIT_INDEX);
@@ -420,33 +429,33 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Sending index initialization request to gnunetd\n");
 #endif
-  if (OK != connection_write (sock, &ri->header))
+  if (GNUNET_OK != GNUNET_client_connection_write (sock, &ri->header))
     {
-      FREE (ri);
-      return SYSERR;
+      GNUNET_free (ri);
+      return GNUNET_SYSERR;
     }
-  FREE (ri);
+  GNUNET_free (ri);
 #if DEBUG_FSLIB
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Waiting for confirmation of index initialization request by 
gnunetd\n");
 #endif
-  if (OK != connection_read_result (sock, &ret))
-    return SYSERR;
+  if (GNUNET_OK != GNUNET_client_connection_read_result (sock, &ret))
+    return GNUNET_SYSERR;
   return ret;
 }
 
 /**
  * Index a block.
  *
- * @param fileHc the hash of the entire file
+ * @param fileHc the GNUNET_hash of the entire file
  * @param block the data from the file (in plaintext)
  * @param offset the offset of the block into the file
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-FS_index (struct ClientServerConnection *sock,
-          const HashCode512 * fileHc,
+FS_index (struct GNUNET_ClientServerConnection *sock,
+          const GNUNET_HashCode * fileHc,
           const Datastore_Value * block, unsigned long long offset)
 {
   int ret;
@@ -455,14 +464,14 @@
   int retry;
 
   size = ntohl (block->size) - sizeof (Datastore_Value);
-  ri = MALLOC (sizeof (CS_fs_request_index_MESSAGE) + size);
+  ri = GNUNET_malloc (sizeof (CS_fs_request_index_MESSAGE) + size);
   ri->header.size = htons (sizeof (CS_fs_request_index_MESSAGE) + size);
   ri->header.type = htons (CS_PROTO_gap_INDEX);
   ri->prio = block->prio;
   ri->expiration = block->expirationTime;
   ri->anonymityLevel = block->anonymityLevel;
   ri->fileId = *fileHc;
-  ri->fileOffset = htonll (offset);
+  ri->fileOffset = GNUNET_htonll (offset);
   memcpy (&ri[1], &block[1], size);
 #if DEBUG_FSLIB
   GE_LOG (ectx,
@@ -472,24 +481,24 @@
   retry = AUTO_RETRY;
   do
     {
-      if (OK != connection_write (sock, &ri->header))
+      if (GNUNET_OK != GNUNET_client_connection_write (sock, &ri->header))
         {
-          FREE (ri);
-          return SYSERR;
+          GNUNET_free (ri);
+          return GNUNET_SYSERR;
         }
 #if DEBUG_FSLIB
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "Waiting for confirmation of index request by gnunetd\n");
 #endif
-      if (OK != connection_read_result (sock, &ret))
+      if (GNUNET_OK != GNUNET_client_connection_read_result (sock, &ret))
         {
-          FREE (ri);
-          return SYSERR;
+          GNUNET_free (ri);
+          return GNUNET_SYSERR;
         }
     }
-  while ((ret == NO) && (retry-- > 0));
-  FREE (ri);
+  while ((ret == GNUNET_NO) && (retry-- > 0));
+  GNUNET_free (ri);
   return ret;
 }
 
@@ -499,10 +508,11 @@
  *
  * @param block the block (properly encoded and all)
  * @return number of items deleted on success,
- *    SYSERR on error
+ *    GNUNET_SYSERR on error
  */
 int
-FS_delete (struct ClientServerConnection *sock, const Datastore_Value * block)
+FS_delete (struct GNUNET_ClientServerConnection *sock,
+           const Datastore_Value * block)
 {
   int ret;
   CS_fs_request_delete_MESSAGE *rd;
@@ -510,40 +520,40 @@
   int retry;
 
   size = ntohl (block->size) - sizeof (Datastore_Value);
-  rd = MALLOC (sizeof (CS_fs_request_delete_MESSAGE) + size);
+  rd = GNUNET_malloc (sizeof (CS_fs_request_delete_MESSAGE) + size);
   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);
   retry = AUTO_RETRY;
   do
     {
-      if (OK != connection_write (sock, &rd->header))
+      if (GNUNET_OK != GNUNET_client_connection_write (sock, &rd->header))
         {
-          FREE (rd);
+          GNUNET_free (rd);
           GE_BREAK (NULL, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      if (OK != connection_read_result (sock, &ret))
+      if (GNUNET_OK != GNUNET_client_connection_read_result (sock, &ret))
         {
           GE_BREAK (NULL, 0);
-          FREE (rd);
-          return SYSERR;
+          GNUNET_free (rd);
+          return GNUNET_SYSERR;
         }
     }
-  while ((ret == NO) && (retry-- > 0));
-  FREE (rd);
+  while ((ret == GNUNET_NO) && (retry-- > 0));
+  GNUNET_free (rd);
   return ret;
 }
 
 /**
  * Unindex a file.
  *
- * @param hc the hash of the entire file
- * @return OK on success, SYSERR on error
+ * @param hc the GNUNET_hash of the entire file
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-FS_unindex (struct ClientServerConnection *sock,
-            unsigned int blocksize, const HashCode512 * hc)
+FS_unindex (struct GNUNET_ClientServerConnection *sock,
+            unsigned int blocksize, const GNUNET_HashCode * hc)
 {
   int ret;
   CS_fs_request_unindex_MESSAGE ru;
@@ -552,21 +562,22 @@
   ru.header.type = htons (CS_PROTO_gap_UNINDEX);
   ru.blocksize = htonl (blocksize);
   ru.fileId = *hc;
-  if (OK != connection_write (sock, &ru.header))
-    return SYSERR;
-  if (OK != connection_read_result (sock, &ret))
-    return SYSERR;
+  if (GNUNET_OK != GNUNET_client_connection_write (sock, &ru.header))
+    return GNUNET_SYSERR;
+  if (GNUNET_OK != GNUNET_client_connection_read_result (sock, &ret))
+    return GNUNET_SYSERR;
   return ret;
 }
 
 /**
- * Test if a file of the given hash is indexed.
+ * Test if a file of the given GNUNET_hash is indexed.
  *
- * @param hc the hash of the entire file
- * @return YES if so, NO if not, SYSERR on error
+ * @param hc the GNUNET_hash of the entire file
+ * @return GNUNET_YES if so, GNUNET_NO if not, GNUNET_SYSERR on error
  */
 int
-FS_testIndexed (struct ClientServerConnection *sock, const HashCode512 * hc)
+FS_testIndexed (struct GNUNET_ClientServerConnection *sock,
+                const GNUNET_HashCode * hc)
 {
   RequestTestindex ri;
   int ret;
@@ -575,10 +586,10 @@
   ri.header.type = htons (CS_PROTO_gap_TESTINDEX);
   ri.reserved = htonl (0);
   ri.fileId = *hc;
-  if (OK != connection_write (sock, &ri.header))
-    return SYSERR;
-  if (OK != connection_read_result (sock, &ret))
-    return SYSERR;
+  if (GNUNET_OK != GNUNET_client_connection_write (sock, &ri.header))
+    return GNUNET_SYSERR;
+  if (GNUNET_OK != GNUNET_client_connection_read_result (sock, &ret))
+    return GNUNET_SYSERR;
   return ret;
 }
 

Modified: GNUnet/src/applications/fs/lib/fslibtest.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslibtest.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/lib/fslibtest.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,13 +32,13 @@
 #include "gnunet_protocols.h"
 #include "ecrs_core.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
-static struct CronManager *cron;
+static struct GNUNET_CronManager *cron;
 
-static cron_t now;
+static GNUNET_CronTime now;
 
-static struct PTHREAD *mainThread;
+static struct GNUNET_ThreadHandle *mainThread;
 
 static Datastore_Value *
 makeBlock (int i)
@@ -46,12 +46,12 @@
   Datastore_Value *block;
   DBlock *db;
 
-  block = MALLOC (sizeof (Datastore_Value) + sizeof (DBlock) + i);
+  block = GNUNET_malloc (sizeof (Datastore_Value) + sizeof (DBlock) + i);
   block->size = htonl (sizeof (Datastore_Value) + sizeof (DBlock) + i);
   block->type = htonl (D_BLOCK);
   block->prio = htonl (0);
   block->anonymityLevel = htonl (0);
-  block->expirationTime = htonll (now + 1 * cronHOURS);
+  block->expirationTime = GNUNET_htonll (now + 1 * GNUNET_CRON_HOURS);
   db = (DBlock *) & block[1];
   db->type = htonl (D_BLOCK);
   memset (&db[1], i + (i / 253), i);
@@ -59,33 +59,34 @@
 }
 
 static Datastore_Value *
-makeKBlock (unsigned int i, const HashCode512 * key, HashCode512 * query)
+makeKBlock (unsigned int i, const GNUNET_HashCode * key,
+            GNUNET_HashCode * query)
 {
   Datastore_Value *block;
   KBlock *db;
-  struct PrivateKey *kkey;
+  struct GNUNET_RSA_PrivateKey *kkey;
 
-  block = MALLOC (sizeof (Datastore_Value) + sizeof (KBlock) + i);
+  block = GNUNET_malloc (sizeof (Datastore_Value) + sizeof (KBlock) + i);
   block->size = htonl (sizeof (Datastore_Value) + sizeof (KBlock) + i);
   block->type = htonl (K_BLOCK);
   block->prio = htonl (0);
   block->anonymityLevel = htonl (0);
-  block->expirationTime = htonll (now + 1 * cronHOURS);
+  block->expirationTime = GNUNET_htonll (now + 1 * GNUNET_CRON_HOURS);
   db = (KBlock *) & block[1];
   db->type = htonl (K_BLOCK);
   memset (&db[1], i + (i / 253), i);
-  kkey = makeKblockKey (key);
-  sign (kkey, i, &db[1], &db->signature);
-  getPublicKey (kkey, &db->keyspace);
-  hash (&db->keyspace, sizeof (PublicKey), query);
-  freePrivateKey (kkey);
+  kkey = GNUNET_RSA_create_key_from_hash (key);
+  GNUNET_RSA_sign (kkey, i, &db[1], &db->signature);
+  GNUNET_RSA_get_public_key (kkey, &db->keyspace);
+  GNUNET_hash (&db->keyspace, sizeof (GNUNET_RSA_PublicKey), query);
+  GNUNET_RSA_free_key (kkey);
   return block;
 }
 
 
 typedef struct
 {
-  struct SEMAPHORE *sem;
+  struct GNUNET_Semaphore *sem;
   int found;
   int i;
 } TSC;
@@ -93,8 +94,8 @@
 static void
 abortSem (void *cls)
 {
-  struct SEMAPHORE *sem = cls;
-  SEMAPHORE_UP (sem);
+  struct GNUNET_Semaphore *sem = cls;
+  GNUNET_semaphore_up (sem);
 }
 
 /**
@@ -102,23 +103,23 @@
  * a counter.
  */
 static int
-countCallback (const HashCode512 * key,
+countCallback (const GNUNET_HashCode * key,
                const Datastore_Value * value, void *cls)
 {
   int *cnt = cls;
   (*cnt)--;
   fprintf (stderr, "*");
   if (*cnt <= 0)
-    PTHREAD_STOP_SLEEP (mainThread);
-  return OK;
+    GNUNET_thread_stop_sleep (mainThread);
+  return GNUNET_OK;
 }
 
 
 static int
-searchResultCB (const HashCode512 * key,
+searchResultCB (const GNUNET_HashCode * key,
                 const Datastore_Value * value, TSC * cls)
 {
-  HashCode512 ekey;
+  GNUNET_HashCode ekey;
   Datastore_Value *blk;
   Datastore_Value *eblk;
   int ret;
@@ -126,29 +127,29 @@
   blk = makeBlock (cls->i);
   fileBlockGetQuery ((DBlock *) & blk[1],
                      ntohl (blk->size) - sizeof (Datastore_Value), &ekey);
-  GE_ASSERT (NULL, OK ==
+  GE_ASSERT (NULL, GNUNET_OK ==
              fileBlockEncode ((DBlock *) & blk[1],
                               ntohl (blk->size) - sizeof (Datastore_Value),
                               &ekey, &eblk));
-  if ((equalsHashCode512 (&ekey,
-                          key)) &&
+  if ((0 == memcmp (&ekey,
+                    key, sizeof (GNUNET_HashCode))) &&
       (value->size == blk->size) &&
       (0 == memcmp (&value[1],
                     &eblk[1],
                     ntohl (value->size) - sizeof (Datastore_Value))))
     {
-      cls->found = YES;
-      SEMAPHORE_UP (cls->sem);
-      ret = SYSERR;
+      cls->found = GNUNET_YES;
+      GNUNET_semaphore_up (cls->sem);
+      ret = GNUNET_SYSERR;
     }
   else
     {
       GE_BREAK (NULL, 0);
       printf ("Received unexpected result.\n");
-      ret = OK;
+      ret = GNUNET_OK;
     }
-  FREE (eblk);
-  FREE (blk);
+  GNUNET_free (eblk);
+  GNUNET_free (blk);
   return ret;
 }
 
@@ -156,8 +157,8 @@
 trySearch (struct FS_SEARCH_CONTEXT *ctx, int i)
 {
   struct FS_SEARCH_HANDLE *handle;
-  cron_t now;
-  HashCode512 query;
+  GNUNET_CronTime now;
+  GNUNET_HashCode query;
   TSC closure;
   Datastore_Value *dv;
   DBlock *db;
@@ -165,11 +166,11 @@
   dv = makeBlock (i);
   db = (DBlock *) & dv[1];
   fileBlockGetQuery (db, ntohl (dv->size) - sizeof (Datastore_Value), &query);
-  FREE (dv);
-  closure.found = NO;
+  GNUNET_free (dv);
+  closure.found = GNUNET_NO;
   closure.i = i;
-  closure.sem = SEMAPHORE_CREATE (0);
-  now = get_time ();
+  closure.sem = GNUNET_semaphore_create (0);
+  now = GNUNET_get_time ();
   handle = FS_start_search (ctx,
                             NULL,
                             D_BLOCK,
@@ -177,15 +178,16 @@
                             &query,
                             0,
                             0,
-                            now + 30 * cronSECONDS,
+                            now + 30 * GNUNET_CRON_SECONDS,
                             (Datum_Iterator) & searchResultCB, &closure);
-  cron_add_job (cron, &abortSem, 30 * cronSECONDS, 0, closure.sem);
-  SEMAPHORE_DOWN (closure.sem, YES);
+  GNUNET_cron_add_job (cron, &abortSem, 30 * GNUNET_CRON_SECONDS, 0,
+                       closure.sem);
+  GNUNET_semaphore_down (closure.sem, GNUNET_YES);
   FS_stop_search (ctx, handle);
-  cron_suspend (cron, NO);
-  cron_del_job (cron, &abortSem, 0, closure.sem);
-  cron_resume_jobs (cron, NO);
-  SEMAPHORE_DESTROY (closure.sem);
+  GNUNET_cron_suspend_jobs (cron, GNUNET_NO);
+  GNUNET_cron_del_job (cron, &abortSem, 0, closure.sem);
+  GNUNET_cron_resume_jobs (cron, GNUNET_NO);
+  GNUNET_semaphore_destroy (closure.sem);
   return closure.found;
 }
 
@@ -200,36 +202,38 @@
   int ok;
   struct FS_SEARCH_CONTEXT *ctx = NULL;
   struct FS_SEARCH_HANDLE *hnd;
-  struct MUTEX *lock;
-  struct ClientServerConnection *sock;
+  struct GNUNET_Mutex *lock;
+  struct GNUNET_ClientServerConnection *sock;
   Datastore_Value *block;
   Datastore_Value *eblock;
-  HashCode512 hc;
-  HashCode512 query;
+  GNUNET_HashCode hc;
+  GNUNET_HashCode query;
   int i;
   char *tmpName;
   int fd;
   struct GC_Configuration *cfg;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
-  now = get_time ();
+  now = GNUNET_get_time ();
   cron = cron_create (NULL);
 #if START_DAEMON
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
 #endif
-  ok = YES;
-  cron_start (cron);
-  lock = MUTEX_CREATE (NO);
+  ok = GNUNET_YES;
+  GNUNET_cron_start (cron);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   GE_ASSERT (NULL,
-             OK == connection_wait_for_running (NULL, cfg, 60 * cronSECONDS));
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
-  sock = client_connection_create (NULL, cfg);
+             GNUNET_OK == GNUNET_wait_for_daemon_running (NULL, cfg,
+                                                          60 *
+                                                          
GNUNET_CRON_SECONDS));
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
+  sock = GNUNET_client_connection_create (NULL, cfg);
   CHECK (sock != NULL);
   ctx = FS_SEARCH_makeContext (NULL, cfg, lock);
   CHECK (ctx != NULL);
@@ -242,86 +246,87 @@
       fileBlockGetQuery ((DBlock *) & block[1],
                          ntohl (block->size) - sizeof (Datastore_Value),
                          &query);
-      CHECK (OK == fileBlockEncode ((DBlock *) & block[1],
-                                    ntohl (block->size) -
-                                    sizeof (Datastore_Value), &query,
-                                    &eblock));
+      CHECK (GNUNET_OK == fileBlockEncode ((DBlock *) & block[1],
+                                           ntohl (block->size) -
+                                           sizeof (Datastore_Value), &query,
+                                           &eblock));
       eblock->expirationTime = block->expirationTime;
       eblock->prio = block->prio;
-      CHECK (OK == FS_insert (sock, eblock));
-      CHECK (OK == trySearch (ctx, i));
-      CHECK (SYSERR != FS_delete (sock, eblock));
-      FREE (eblock);
-      hash (&((DBlock *) & block[1])[1],
-            ntohl (block->size) - sizeof (Datastore_Value) - sizeof (DBlock),
-            &hc);
+      CHECK (GNUNET_OK == FS_insert (sock, eblock));
+      CHECK (GNUNET_OK == trySearch (ctx, i));
+      CHECK (GNUNET_SYSERR != FS_delete (sock, eblock));
+      GNUNET_free (eblock);
+      GNUNET_hash (&((DBlock *) & block[1])[1],
+                   ntohl (block->size) - sizeof (Datastore_Value) -
+                   sizeof (DBlock), &hc);
       /* indexing without symlink */
-      CHECK (OK == FS_index (sock, &hc, block, 0));
-      CHECK (OK == trySearch (ctx, i));
-      CHECK (OK == FS_unindex (sock, MAX_BUFFER_SIZE, &hc));
+      CHECK (GNUNET_OK == FS_index (sock, &hc, block, 0));
+      CHECK (GNUNET_OK == trySearch (ctx, i));
+      CHECK (GNUNET_OK == FS_unindex (sock, GNUNET_MAX_BUFFER_SIZE, &hc));
       /* indexing with symlink */
-      tmpName = STRDUP ("/tmp/symlinkTestXXXXXX");
+      tmpName = GNUNET_strdup ("/tmp/symlinkTestXXXXXX");
       CHECK (-1 != (fd = mkstemp (tmpName)));
       CHECK (-1 != WRITE (fd,
                           &((DBlock *) & block[1])[1],
                           ntohl (block->size) - sizeof (Datastore_Value) -
                           sizeof (DBlock)));
       CLOSE (fd);
-      CHECK (FS_initIndex (sock, &hc, tmpName) == YES);
-      CHECK (OK == FS_index (sock, &hc, block, 0));
-      CHECK (OK == trySearch (ctx, i));
-      CHECK (OK == FS_unindex (sock, MAX_BUFFER_SIZE, &hc));
+      CHECK (FS_initIndex (sock, &hc, tmpName) == GNUNET_YES);
+      CHECK (GNUNET_OK == FS_index (sock, &hc, block, 0));
+      CHECK (GNUNET_OK == trySearch (ctx, i));
+      CHECK (GNUNET_OK == FS_unindex (sock, GNUNET_MAX_BUFFER_SIZE, &hc));
       UNLINK (tmpName);
-      FREE (tmpName);
-      FREE (block);
+      GNUNET_free (tmpName);
+      GNUNET_free (block);
     }
   fprintf (stderr, "\n");
-  for (i = 32; i < MAX_BUFFER_SIZE; i *= 2)
+  for (i = 32; i < GNUNET_MAX_BUFFER_SIZE; i *= 2)
     {
       fprintf (stderr, ".");
       block = makeBlock (i);
       fileBlockGetQuery ((DBlock *) & block[1],
                          ntohl (block->size) - sizeof (Datastore_Value),
                          &query);
-      CHECK (OK == fileBlockEncode ((DBlock *) & block[1],
-                                    ntohl (block->size) -
-                                    sizeof (Datastore_Value), &query,
-                                    &eblock));
+      CHECK (GNUNET_OK == fileBlockEncode ((DBlock *) & block[1],
+                                           ntohl (block->size) -
+                                           sizeof (Datastore_Value), &query,
+                                           &eblock));
       eblock->expirationTime = block->expirationTime;
       eblock->prio = block->prio;
-      CHECK (OK == FS_insert (sock, eblock));
-      CHECK (OK == trySearch (ctx, i));
+      CHECK (GNUNET_OK == FS_insert (sock, eblock));
+      CHECK (GNUNET_OK == trySearch (ctx, i));
       CHECK (1 == FS_delete (sock, eblock));
-      FREE (eblock);
-      hash (&((DBlock *) & block[1])[1],
-            ntohl (block->size) - sizeof (Datastore_Value) - sizeof (DBlock),
-            &hc);
-      CHECK (OK == FS_index (sock, &hc, block, 0));
-      CHECK (OK == trySearch (ctx, i));
-      CHECK (OK == FS_unindex (sock, MAX_BUFFER_SIZE, &hc));
-      FREE (block);
+      GNUNET_free (eblock);
+      GNUNET_hash (&((DBlock *) & block[1])[1],
+                   ntohl (block->size) - sizeof (Datastore_Value) -
+                   sizeof (DBlock), &hc);
+      CHECK (GNUNET_OK == FS_index (sock, &hc, block, 0));
+      CHECK (GNUNET_OK == trySearch (ctx, i));
+      CHECK (GNUNET_OK == FS_unindex (sock, GNUNET_MAX_BUFFER_SIZE, &hc));
+      GNUNET_free (block);
     }
   fprintf (stderr, "\n");
 
   /* multiple search results test */
-  makeRandomId (&hc);
+  GNUNET_create_random_hash (&hc);
   block = makeKBlock (40, &hc, &query);
-  CHECK (OK == FS_insert (sock, block));
-  FREE (block);
+  CHECK (GNUNET_OK == FS_insert (sock, block));
+  GNUNET_free (block);
   block = makeKBlock (60, &hc, &query);
-  CHECK (OK == FS_insert (sock, block));
-  FREE (block);
+  CHECK (GNUNET_OK == FS_insert (sock, block));
+  GNUNET_free (block);
   i = 2;
-  mainThread = PTHREAD_GET_SELF ();
+  mainThread = GNUNET_thread_get_self ();
   hnd = FS_start_search (ctx,
                          NULL,
                          ANY_BLOCK,
                          1,
-                         &query, 0, 0, 10 * cronSECONDS, &countCallback, &i);
+                         &query, 0, 0, 10 * GNUNET_CRON_SECONDS,
+                         &countCallback, &i);
   CHECK (hnd != NULL);
-  PTHREAD_SLEEP (10 * cronSECONDS);
+  GNUNET_thread_sleep (10 * GNUNET_CRON_SECONDS);
   FS_stop_search (ctx, hnd);
-  PTHREAD_REL_SELF (mainThread);
+  GNUNET_thread_release_self (mainThread);
   CHECK (i <= 0);
 
 
@@ -334,15 +339,15 @@
   if (ctx != NULL)
     FS_SEARCH_destroyContext (ctx);
   if (sock != NULL)
-    connection_destroy (sock);
-  MUTEX_DESTROY (lock);
-  cron_stop (cron);
-  cron_destroy (cron);
+    GNUNET_client_connection_destroy (sock);
+  GNUNET_mutex_destroy (lock);
+  GNUNET_cron_stop (cron);
+  GNUNET_cron_destroy (cron);
 #if START_DAEMON
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
 #endif
   GC_free (cfg);
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of fslibtest.c */

Modified: GNUnet/src/applications/fs/module/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/module/Makefile.am       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/Makefile.am       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -17,7 +17,5 @@
   -export-dynamic -avoid-version -module
 libgnunetmodule_fs_la_LIBADD = \
  $(top_builddir)/src/applications/fs/libecrs_core.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 

Modified: GNUnet/src/applications/fs/module/anonymity.c
===================================================================
--- GNUnet/src/applications/fs/module/anonymity.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/anonymity.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -40,7 +40,7 @@
  * simple, we do the anonymity-level check for
  * outgoing content right here.
  *
- * @return OK if cover traffic is sufficient
+ * @return GNUNET_OK if cover traffic is sufficient
  */
 int
 checkCoverTraffic (struct GE_Context *ectx,
@@ -52,18 +52,19 @@
   unsigned int timevect;
 
   if (level == 0)
-    return OK;
+    return GNUNET_OK;
   level--;
   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))
+    return GNUNET_SYSERR;
+  if (GNUNET_OK != traffic->get (5 * GNUNET_CRON_SECONDS / TRAFFIC_TIME_UNIT,  
 /* TTL_DECREMENT/TTU */
+                                 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"));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (level > 1000)
     {
@@ -73,7 +74,7 @@
                   GE_DEBUG | GE_REQUEST | GE_USER,
                   "Not enough cover traffic to satisfy anonymity requirements 
(%u, %u peers). "
                   "Result dropped.\n", level, peers);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (count < level % 1000)
         {
@@ -81,7 +82,7 @@
                   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 GNUNET_SYSERR;
         }
     }
   else
@@ -92,10 +93,10 @@
                   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 GNUNET_SYSERR;
         }
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /* end of anonymity.c */

Modified: GNUnet/src/applications/fs/module/anonymity.h
===================================================================
--- GNUnet/src/applications/fs/module/anonymity.h       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/anonymity.h       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -41,7 +41,7 @@
  * simple, we do the anonymity-level check for
  * outgoing content right here.
  *
- * @return OK if cover traffic is sufficient
+ * @return GNUNET_OK if cover traffic is sufficient
  */
 int checkCoverTraffic (struct GE_Context *ectx,
                        Traffic_ServiceAPI * traffic, unsigned int level);

Modified: GNUnet/src/applications/fs/module/dht_push.c
===================================================================
--- GNUnet/src/applications/fs/module/dht_push.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/dht_push.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -38,7 +38,7 @@
  * some of the processing cost which would otherwise go
  * to waste).
  */
-#define NO_PUSH NO
+#define NO_PUSH GNUNET_NO
 
 /**
  * DHT service.  Set to NULL to terminate
@@ -59,7 +59,7 @@
 /**
  * Thread that does the pushing.
  */
-static struct PTHREAD *thread;
+static struct GNUNET_ThreadHandle *thread;
 
 /**
  * Total number of entries with anonymity 0.
@@ -74,33 +74,33 @@
 
 
 static int
-push_callback (const HashCode512 * key,
+push_callback (const GNUNET_HashCode * key,
                const Datastore_Value * value, void *closure,
                unsigned long long uid)
 {
-  cron_t delay;
+  GNUNET_CronTime delay;
 
   if (dht == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   /* try pushing out everything every 6h,
      but do not push more often than every 5s */
-  delay = 6 * cronHOURS / total;
-  if (delay < 5 * cronSECONDS)
-    delay = 5 * cronSECONDS;
-  if (delay > 60 * cronSECONDS)
-    delay = 60 * cronSECONDS;
-  PTHREAD_SLEEP (delay);
+  delay = 6 * GNUNET_CRON_HOURS / total;
+  if (delay < 5 * GNUNET_CRON_SECONDS)
+    delay = 5 * GNUNET_CRON_SECONDS;
+  if (delay > 60 * GNUNET_CRON_SECONDS)
+    delay = 60 * GNUNET_CRON_SECONDS;
+  GNUNET_thread_sleep (delay);
   if (dht == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   dht->put (key,
             ntohl (value->type),
             ntohl (value->size) - sizeof (Datastore_Value),
-            ntohll (value->expirationTime), (const char *) &value[1]);
+            GNUNET_ntohll (value->expirationTime), (const char *) &value[1]);
   if (stats != NULL)
     stats->change (stat_push_count, 1);
   if (dht == NULL)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 static void *
@@ -112,7 +112,7 @@
         total = 1;
       total = sqstore->iterateNonAnonymous (0, &push_callback, NULL);
       if ((dht != NULL) && (total == 0))
-        PTHREAD_SLEEP (15 * cronMINUTES);
+        GNUNET_thread_sleep (15 * GNUNET_CRON_MINUTES);
     }
   return NULL;
 }
@@ -138,7 +138,7 @@
       = stats->create (gettext_noop ("# blocks pushed into DHT"));
   if (!NO_PUSH)
     {
-      thread = PTHREAD_CREATE (&push_thread, NULL, 1024 * 128);
+      thread = GNUNET_thread_create (&push_thread, NULL, 1024 * 128);
     }
 }
 
@@ -152,8 +152,8 @@
   dht = NULL;
   if (thread != NULL)
     {
-      PTHREAD_STOP_SLEEP (thread);
-      PTHREAD_JOIN (thread, &unused);
+      GNUNET_thread_stop_sleep (thread);
+      GNUNET_thread_join (thread, &unused);
     }
   coreAPI->releaseService (sqstore);
   if (stats != NULL)

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/fs/module/fs.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,7 +43,7 @@
 #include "querymanager.h"
 #include "fs.h"
 
-#define DEBUG_FS NO
+#define DEBUG_FS GNUNET_NO
 
 typedef struct
 {
@@ -55,7 +55,7 @@
 {
   unsigned int keyCount;
   unsigned int type;
-  HashCode512 *queries;
+  GNUNET_HashCode *queries;
   struct LG_Job *next;
 } LG_Job;
 
@@ -93,13 +93,13 @@
 
 static int stat_valid_replies_received;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static int migration;
 
-static struct SEMAPHORE *ltgSignal;
+static struct GNUNET_Semaphore *ltgSignal;
 
-static struct PTHREAD *localGetProcessor;
+static struct GNUNET_ThreadHandle *localGetProcessor;
 
 static LG_Job *lg_jobs;
 
@@ -111,8 +111,8 @@
   Datastore_Value *dv;
   const GapWrapper *gw;
   unsigned int size;
-  cron_t et;
-  cron_t now;
+  GNUNET_CronTime et;
+  GNUNET_CronTime now;
 
   if (ntohl (value->size) < sizeof (GapWrapper))
     {
@@ -121,14 +121,14 @@
     }
   gw = (const GapWrapper *) value;
   size = ntohl (gw->dc.size) - sizeof (GapWrapper) + sizeof (Datastore_Value);
-  dv = MALLOC (size);
+  dv = GNUNET_malloc (size);
   dv->size = htonl (size);
   dv->type = htonl (getTypeOfBlock (size - sizeof (Datastore_Value),
                                     (DBlock *) & gw[1]));
   dv->prio = htonl (prio);
   dv->anonymityLevel = htonl (0);
-  et = ntohll (gw->timeout);
-  now = get_time ();
+  et = GNUNET_ntohll (gw->timeout);
+  now = GNUNET_get_time ();
   /* bound ET to MAX_MIGRATION_EXP from now */
   if (et > now)
     {
@@ -136,7 +136,7 @@
       et = et % MAX_MIGRATION_EXP;
       et += now;
     }
-  dv->expirationTime = htonll (et);
+  dv->expirationTime = GNUNET_htonll (et);
   memcpy (&dv[1], &gw[1], size - sizeof (Datastore_Value));
   return dv;
 }
@@ -148,50 +148,53 @@
  * @param value the value to store
  * @param prio how much does our routing code value
  *        this datum?
- * @return OK if the value could be stored,
- *         NO if the value verifies but is not stored,
- *         SYSERR if the value is malformed
+ * @return GNUNET_OK if the value could be stored,
+ *         GNUNET_NO if the value verifies but is not stored,
+ *         GNUNET_SYSERR if the value is malformed
  */
 static int
 gapPut (void *closure,
-        const HashCode512 * query,
+        const GNUNET_HashCode * query,
         const DataContainer * value, unsigned int prio)
 {
   Datastore_Value *dv;
   const GapWrapper *gw;
   unsigned int size;
   int ret;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 #if DEBUG_FS
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   gw = (const GapWrapper *) value;
   size = ntohl (gw->dc.size) - sizeof (GapWrapper);
-  if ((OK != getQueryFor (size,
-                          (const DBlock *) &gw[1],
-                          YES, &hc)) || (!equalsHashCode512 (&hc, query)))
+  if ((GNUNET_OK != getQueryFor (size,
+                                 (const DBlock *) &gw[1],
+                                 GNUNET_YES, &hc))
+      || (0 != memcmp (&hc, query, sizeof (GNUNET_HashCode))))
     {
       GE_BREAK_OP (ectx, 0);    /* value failed verification! */
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   dv = gapWrapperToDatastoreValue (value, prio);
   if (dv == NULL)
     {
       GE_BREAK_OP (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if (YES != isDatumApplicable (ntohl (dv->type),
-                                ntohl (dv->size) - sizeof (Datastore_Value),
-                                (const DBlock *) &dv[1], &hc, 0, query))
+  if (GNUNET_YES != isDatumApplicable (ntohl (dv->type),
+                                       ntohl (dv->size) -
+                                       sizeof (Datastore_Value),
+                                       (const DBlock *) &dv[1], &hc, 0,
+                                       query))
     {
       GE_BREAK (ectx, 0);
-      FREE (dv);
-      return SYSERR;
+      GNUNET_free (dv);
+      return GNUNET_SYSERR;
     }
   if (stats != NULL)
     stats->change (stat_valid_replies_received, 1);
-  if (ntohll (dv->expirationTime) < get_time ())
+  if (GNUNET_ntohll (dv->expirationTime) < GNUNET_get_time ())
     {
       /* do not do anything with expired data
          _except_ if it is pure content that one
@@ -202,56 +205,57 @@
       else if (stats != NULL)
         stats->change (stat_expired_replies_dropped, 1);
 
-      FREE (dv);
-      return NO;
+      GNUNET_free (dv);
+      return GNUNET_NO;
     }
   processResponse (query, dv);
 
 
 #if DEBUG_FS
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (query, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (query, &enc));
+  GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "FS received GAP-PUT request (query: `%s')\n", &enc);
 #endif
   if (migration)
     ret = datastore->putUpdate (query, dv);
   else
-    ret = OK;
-  FREE (dv);
-  if (ret == SYSERR)
-    ret = NO;                   /* error in put != content invalid! */
+    ret = GNUNET_OK;
+  GNUNET_free (dv);
+  if (ret == GNUNET_SYSERR)
+    ret = GNUNET_NO;            /* error in put != content invalid! */
   return ret;
 }
 
 static int
-get_result_callback (const HashCode512 * query,
+get_result_callback (const GNUNET_HashCode * query,
                      const DataContainer * value, void *ctx)
 {
   DHT_GET_CLS *cls = ctx;
   const GapWrapper *gw;
   unsigned int size;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 #if DEBUG_FS
-  EncName enc;
+  GNUNET_EncName enc;
 
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (query, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (query, &enc));
+  GE_LOG (ectx, 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)) || (!equalsHashCode512 (&hc, query)))
+  if ((GNUNET_OK != getQueryFor (size,
+                                 (const DBlock *) &gw[1],
+                                 GNUNET_YES, &hc))
+      || (0 != memcmp (&hc, query, sizeof (GNUNET_HashCode))))
     {
       GE_BREAK (NULL, 0);
-      return OK;
+      return GNUNET_OK;
     }
 
   gapPut (NULL, query, value, cls->prio);
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
@@ -259,61 +263,61 @@
 {
   DHT_GET_CLS *cls = ctx;
   dht->get_stop (cls->rec);
-  FREE (cls);
+  GNUNET_free (cls);
 }
 
 /**
  * Stop processing a query.
  *
- * @return SYSERR if the TCP connection should be closed, otherwise OK
+ * @return GNUNET_SYSERR if the TCP connection should be closed, otherwise 
GNUNET_OK
  */
 static int
 csHandleRequestQueryStop (struct ClientHandle *sock,
-                          const MESSAGE_HEADER * req)
+                          const GNUNET_MessageHeader * req)
 {
   const CS_fs_request_search_MESSAGE *rs;
 #if DEBUG_FS
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   if (ntohs (req->size) < sizeof (CS_fs_request_search_MESSAGE))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   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_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+            GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (&rs->query[0], &enc));
+  GE_LOG (ectx, 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]);
+                 sizeof (GNUNET_HashCode), &rs->query[0]);
   untrackQuery (&rs->query[0], sock);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Process a request to insert content from the client.
  *
- * @return SYSERR if the TCP connection should be closed, otherwise OK
+ * @return GNUNET_SYSERR if the TCP connection should be closed, otherwise 
GNUNET_OK
  */
 static int
 csHandleCS_fs_request_insert_MESSAGE (struct ClientHandle *sock,
-                                      const MESSAGE_HEADER * req)
+                                      const GNUNET_MessageHeader * req)
 {
   const CS_fs_request_insert_MESSAGE *ri;
   Datastore_Value *datum;
   struct GE_Context *cectx;
-  HashCode512 query;
+  GNUNET_HashCode query;
   int ret;
   unsigned int type;
 #if DEBUG_FS
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   cectx =
@@ -324,79 +328,81 @@
       GE_BREAK (ectx, 0);
       GE_BREAK (cectx, 0);
       GE_free_context (cectx);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ri = (const CS_fs_request_insert_MESSAGE *) req;
-  datum = MALLOC (sizeof (Datastore_Value) +
-                  ntohs (req->size) - sizeof (CS_fs_request_insert_MESSAGE));
-  datum->size = htonl (sizeof (Datastore_Value) +
-                       ntohs (req->size) -
-                       sizeof (CS_fs_request_insert_MESSAGE));
+  datum = GNUNET_malloc (sizeof (Datastore_Value) +
+                         ntohs (req->size) -
+                         sizeof (CS_fs_request_insert_MESSAGE));
+  datum->size =
+    htonl (sizeof (Datastore_Value) + ntohs (req->size) -
+           sizeof (CS_fs_request_insert_MESSAGE));
   datum->expirationTime = ri->expiration;
   datum->prio = ri->prio;
   datum->anonymityLevel = ri->anonymityLevel;
-  if (OK !=
+  if (GNUNET_OK !=
       getQueryFor (ntohs (ri->header.size) -
                    sizeof (CS_fs_request_insert_MESSAGE),
-                   (const DBlock *) &ri[1], YES, &query))
+                   (const DBlock *) &ri[1], GNUNET_YES, &query))
     {
       GE_BREAK (ectx, 0);
       GE_BREAK (cectx, 0);
-      FREE (datum);
+      GNUNET_free (datum);
       GE_free_context (cectx);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   type =
     getTypeOfBlock (ntohs (ri->header.size) -
                     sizeof (CS_fs_request_insert_MESSAGE),
                     (const DBlock *) &ri[1]);
 #if DEBUG_FS
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (&query, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (&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));
 #endif
   datum->type = htonl (type);
   memcpy (&datum[1],
           &ri[1], ntohs (req->size) - sizeof (CS_fs_request_insert_MESSAGE));
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if ((type != D_BLOCK) || (0 == datastore->get (&query, type, NULL, NULL)))
     ret = datastore->put (&query, datum);
   else
-    ret = OK;
-  MUTEX_UNLOCK (lock);
+    ret = GNUNET_OK;
+  GNUNET_mutex_unlock (lock);
   if ((ntohl (ri->anonymityLevel) == 0) && (dht != NULL))
     {
       GapWrapper *gw;
       unsigned int size;
-      cron_t now;
-      cron_t et;
-      HashCode512 hc;
+      GNUNET_CronTime now;
+      GNUNET_CronTime et;
+      GNUNET_HashCode hc;
 
       size = sizeof (GapWrapper) +
         ntohs (ri->header.size) - sizeof (CS_fs_request_insert_MESSAGE);
-      gw = MALLOC (size);
+      gw = GNUNET_malloc (size);
       gw->reserved = 0;
       gw->dc.size = htonl (size);
-      et = ntohll (ri->expiration);
+      et = GNUNET_ntohll (ri->expiration);
       /* expiration time normalization and randomization */
-      now = get_time ();
+      now = GNUNET_get_time ();
       if (et > now)
         {
           et -= now;
           et = et % MAX_MIGRATION_EXP;
           if (et > 0)
-            et = weak_randomi (et);
+            et = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, et);
           et = et + now;
         }
-      gw->timeout = htonll (et);
+      gw->timeout = GNUNET_htonll (et);
       memcpy (&gw[1], &ri[1], size - sizeof (GapWrapper));
       /* sanity check */
-      if ((OK != getQueryFor (size - sizeof (GapWrapper),
-                              (const DBlock *) &gw[1],
-                              YES,
-                              &hc)) || (!equalsHashCode512 (&hc, &query)))
+      if ((GNUNET_OK != getQueryFor (size - sizeof (GapWrapper),
+                                     (const DBlock *) &gw[1],
+                                     GNUNET_YES,
+                                     &hc))
+          || (0 != memcmp (&hc, &query, sizeof (GNUNET_HashCode))))
         {
           GE_BREAK (NULL, 0);
         }
@@ -404,9 +410,9 @@
         {
           dht->put (&query, type, size, et, (const char *) gw);
         }
-      FREE (gw);
+      GNUNET_free (gw);
     }
-  FREE (datum);
+  GNUNET_free (datum);
   GE_free_context (cectx);
   return coreAPI->sendValueToClient (sock, ret);
 }
@@ -416,7 +422,7 @@
  */
 static int
 csHandleCS_fs_request_init_index_MESSAGE (struct ClientHandle *sock,
-                                          const MESSAGE_HEADER * req)
+                                          const GNUNET_MessageHeader * req)
 {
   int ret;
   char *fn;
@@ -432,7 +438,7 @@
       GE_BREAK (ectx, 0);
       GE_BREAK (cectx, 0);
       GE_free_context (cectx);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   ri = (CS_fs_request_init_index_MESSAGE *) req;
@@ -443,20 +449,20 @@
     {
       GE_BREAK (cectx, 0);
       GE_free_context (cectx);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #endif
-  fn = MALLOC (fnLen + 1);
+  fn = GNUNET_malloc (fnLen + 1);
   strncpy (fn, (char *) &ri[1], fnLen + 1);
   fn[fnLen] = 0;
   ret = ONDEMAND_initIndex (cectx, &ri->fileId, fn);
 
-  FREE (fn);
+  GNUNET_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");
+          ret == GNUNET_OK ? "success" : "failure");
 #endif
   GE_free_context (cectx);
   return coreAPI->sendValueToClient (sock, ret);
@@ -465,11 +471,11 @@
 /**
  * Process a request to index content from the client.
  *
- * @return SYSERR if the TCP connection should be closed, otherwise OK
+ * @return GNUNET_SYSERR if the TCP connection should be closed, otherwise 
GNUNET_OK
  */
 static int
 csHandleCS_fs_request_index_MESSAGE (struct ClientHandle *sock,
-                                     const MESSAGE_HEADER * req)
+                                     const GNUNET_MessageHeader * req)
 {
   int ret;
   const CS_fs_request_index_MESSAGE *ri;
@@ -483,14 +489,14 @@
       GE_BREAK (ectx, 0);
       GE_BREAK (cectx, 0);
       GE_free_context (cectx);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ri = (const CS_fs_request_index_MESSAGE *) req;
   ret = ONDEMAND_index (cectx,
                         datastore,
                         ntohl (ri->prio),
-                        ntohll (ri->expiration),
-                        ntohll (ri->fileOffset),
+                        GNUNET_ntohll (ri->expiration),
+                        GNUNET_ntohll (ri->fileOffset),
                         ntohl (ri->anonymityLevel),
                         &ri->fileId,
                         ntohs (ri->header.size) -
@@ -500,7 +506,7 @@
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Sending confirmation (%s) of index request to client\n",
-          ret == OK ? "success" : "failure");
+          ret == GNUNET_OK ? "success" : "failure");
 #endif
   GE_free_context (cectx);
   return coreAPI->sendValueToClient (sock, ret);
@@ -513,7 +519,7 @@
  * continue.
  */
 static int
-completeValue (const HashCode512 * key,
+completeValue (const GNUNET_HashCode * key,
                const Datastore_Value * value, void *closure,
                unsigned long long uid)
 {
@@ -530,7 +536,7 @@
               "`%s' found value that does not match (%u, %u).\n",
               __FUNCTION__, ntohl (comp->size), ntohl (value->size));
 #endif
-      return OK;
+      return GNUNET_OK;
     }
   *comp = *value;               /* make copy! */
 #if DEBUG_FS
@@ -538,25 +544,25 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           "`%s' found value that matches.\n", __FUNCTION__);
 #endif
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
  * Process a query to delete content.
  *
- * @return SYSERR if the TCP connection should be closed, otherwise OK
+ * @return GNUNET_SYSERR if the TCP connection should be closed, otherwise 
GNUNET_OK
  */
 static int
 csHandleCS_fs_request_delete_MESSAGE (struct ClientHandle *sock,
-                                      const MESSAGE_HEADER * req)
+                                      const GNUNET_MessageHeader * req)
 {
   int ret;
   const CS_fs_request_delete_MESSAGE *rd;
   Datastore_Value *value;
-  HashCode512 query;
+  GNUNET_HashCode query;
   unsigned int type;
 #if DEBUG_FS
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
   struct GE_Context *cectx;
 
@@ -568,14 +574,15 @@
       GE_BREAK (ectx, 0);
       GE_BREAK (cectx, 0);
       GE_free_context (cectx);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   rd = (const CS_fs_request_delete_MESSAGE *) req;
-  value = MALLOC (sizeof (Datastore_Value) +
-                  ntohs (req->size) - sizeof (CS_fs_request_delete_MESSAGE));
-  value->size = ntohl (sizeof (Datastore_Value) +
-                       ntohs (req->size) -
-                       sizeof (CS_fs_request_delete_MESSAGE));
+  value = GNUNET_malloc (sizeof (Datastore_Value) +
+                         ntohs (req->size) -
+                         sizeof (CS_fs_request_delete_MESSAGE));
+  value->size =
+    ntohl (sizeof (Datastore_Value) + ntohs (req->size) -
+           sizeof (CS_fs_request_delete_MESSAGE));
   type =
     getTypeOfBlock (ntohs (rd->header.size) -
                     sizeof (CS_fs_request_delete_MESSAGE),
@@ -583,35 +590,35 @@
   value->type = htonl (type);
   memcpy (&value[1],
           &rd[1], ntohs (req->size) - sizeof (CS_fs_request_delete_MESSAGE));
-  if (OK !=
+  if (GNUNET_OK !=
       getQueryFor (ntohs (rd->header.size) -
                    sizeof (CS_fs_request_delete_MESSAGE),
-                   (const DBlock *) &rd[1], NO, &query))
+                   (const DBlock *) &rd[1], GNUNET_NO, &query))
     {
-      FREE (value);
+      GNUNET_free (value);
       GE_BREAK (ectx, 0);
       GE_BREAK (cectx, 0);
       GE_free_context (cectx);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #if DEBUG_FS
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (&query, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (&query, &enc));
+  GE_LOG (ectx, 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! */
+  GNUNET_mutex_lock (lock);
+  if (GNUNET_SYSERR == datastore->get (&query, type, &completeValue, value))   
 /* aborted == found! */
     ret = datastore->del (&query, value);
   else                          /* not found */
-    ret = SYSERR;
-  MUTEX_UNLOCK (lock);
-  FREE (value);
+    ret = GNUNET_SYSERR;
+  GNUNET_mutex_unlock (lock);
+  GNUNET_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");
+          ret != GNUNET_SYSERR ? "success" : "failure");
 #endif
   GE_free_context (cectx);
   return coreAPI->sendValueToClient (sock, ret);
@@ -622,7 +629,7 @@
  */
 static int
 csHandleCS_fs_request_unindex_MESSAGE (struct ClientHandle *sock,
-                                       const MESSAGE_HEADER * req)
+                                       const GNUNET_MessageHeader * req)
 {
   int ret;
   const CS_fs_request_unindex_MESSAGE *ru;
@@ -636,7 +643,7 @@
       GE_BREAK (ectx, 0);
       GE_BREAK (cectx, 0);
       GE_free_context (cectx);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ru = (const CS_fs_request_unindex_MESSAGE *) req;
 #if DEBUG_FS
@@ -655,7 +662,7 @@
  */
 static int
 csHandleCS_fs_request_test_index_MESSAGEed (struct ClientHandle *sock,
-                                            const MESSAGE_HEADER * req)
+                                            const GNUNET_MessageHeader * req)
 {
   int ret;
   const RequestTestindex *ru;
@@ -663,7 +670,7 @@
   if (ntohs (req->size) != sizeof (RequestTestindex))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ru = (const RequestTestindex *) req;
 #if DEBUG_FS
@@ -681,7 +688,7 @@
  */
 static int
 csHandleRequestGetAvgPriority (struct ClientHandle *sock,
-                               const MESSAGE_HEADER * req)
+                               const GNUNET_MessageHeader * req)
 {
 #if DEBUG_FS
   GE_LOG (ectx,
@@ -699,7 +706,7 @@
   DataProcessor resultCallback;
   void *resCallbackClosure;
   unsigned int keyCount;
-  const HashCode512 *keys;
+  const GNUNET_HashCode *keys;
   int count;
 } GGC;
 
@@ -709,7 +716,7 @@
  * gap routing protocol.
  */
 static int
-gapGetConverter (const HashCode512 * key,
+gapGetConverter (const GNUNET_HashCode * key,
                  const Datastore_Value * invalue, void *cls,
                  unsigned long long uid)
 {
@@ -717,34 +724,34 @@
   GapWrapper *gw;
   int ret;
   unsigned int size;
-  cron_t et;
-  cron_t now;
+  GNUNET_CronTime et;
+  GNUNET_CronTime now;
   const Datastore_Value *value;
   Datastore_Value *xvalue;
   unsigned int level;
-  EncName enc;
+  GNUNET_EncName enc;
 #if EXTRA_CHECKS
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 #endif
 
 #if DEBUG_FS
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (key, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (key, &enc));
+  GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "Converting reply for query `%s' for gap.\n", &enc);
 #endif
-  et = ntohll (invalue->expirationTime);
-  now = get_time ();
+  et = GNUNET_ntohll (invalue->expirationTime);
+  now = GNUNET_get_time ();
   if ((et <= now) && (ntohl (invalue->type) != D_BLOCK))
     {
       /* content expired and not just data -- drop! */
-      return OK;
+      return GNUNET_OK;
     }
 
   if (ntohl (invalue->type) == ONDEMAND_BLOCK)
     {
-      if (OK != ONDEMAND_getIndexed (datastore, invalue, key, &xvalue))
-        return SYSERR;
+      if (GNUNET_OK != ONDEMAND_getIndexed (datastore, invalue, key, &xvalue))
+        return GNUNET_SYSERR;
       value = xvalue;
     }
   else
@@ -753,57 +760,58 @@
       value = invalue;
     }
 #if EXTRA_CHECKS
-  if ((OK != getQueryFor (ntohl (value->size) - sizeof (Datastore_Value),
-                          (const DBlock *) &value[1],
-                          YES, &hc)) || (!equalsHashCode512 (&hc, key)))
+  if ((GNUNET_OK !=
+       getQueryFor (ntohl (value->size) - sizeof (Datastore_Value),
+                    (const DBlock *) &value[1], GNUNET_YES, &hc))
+      || (!equalsGNUNET_HashCode (&hc, key)))
     {
       GE_BREAK (ectx, 0);       /* value failed verification! */
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #endif
   ret = isDatumApplicable (ntohl (value->type),
                            ntohl (value->size) - sizeof (Datastore_Value),
                            (const DBlock *) &value[1],
                            key, ggc->keyCount, ggc->keys);
-  if (ret == SYSERR)
+  if (ret == GNUNET_SYSERR)
     {
-      IF_GELOG (ectx, GE_WARNING | GE_BULK | GE_USER, hash2enc (key, &enc));
-      GE_LOG (ectx,
-              GE_WARNING | GE_BULK | GE_USER,
+      IF_GELOG (ectx, GE_WARNING | GE_BULK | GE_USER,
+                GNUNET_hash_to_enc (key, &enc));
+      GE_LOG (ectx, 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 */
+      GNUNET_free_non_null (xvalue);
+      return GNUNET_SYSERR;     /* no query will ever match */
     }
-  if (ret == NO)
+  if (ret == GNUNET_NO)
     {
-      IF_GELOG (ectx, GE_WARNING | GE_BULK | GE_USER, hash2enc (key, &enc));
-      GE_LOG (ectx,
-              GE_WARNING | GE_BULK | GE_USER,
+      IF_GELOG (ectx, GE_WARNING | GE_BULK | GE_USER,
+                GNUNET_hash_to_enc (key, &enc));
+      GE_LOG (ectx, 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;
+      GNUNET_free_non_null (xvalue);
+      return GNUNET_OK;         /* Additional filtering based on type;
                                    i.e., namespace request and namespace
                                    in reply does not match namespace in query 
*/
     }
   size = sizeof (GapWrapper) + ntohl (value->size) - sizeof (Datastore_Value);
 
   level = ntohl (value->anonymityLevel);
-  if (OK != checkCoverTraffic (ectx, traffic, level))
+  if (GNUNET_OK != checkCoverTraffic (ectx, 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_LOG (ectx,
-              GE_WARNING | GE_BULK | GE_USER,
+      GNUNET_free_non_null (xvalue);
+      IF_GELOG (ectx, GE_WARNING | GE_BULK | GE_USER,
+                GNUNET_hash_to_enc (key, &enc));
+      GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               "Converting reply for query `%s' for gap failed (insufficient 
cover traffic).\n",
               &enc);
-      return OK;
+      return GNUNET_OK;
     }
-  gw = MALLOC (size);
+  gw = GNUNET_malloc (size);
   gw->dc.size = htonl (size);
   /* expiration time normalization and randomization */
   if (et > now)
@@ -811,19 +819,19 @@
       et -= now;
       et = et % MAX_MIGRATION_EXP;
       if (et > 0)
-        et = weak_randomi (et);
+        et = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, et);
       et = et + now;
     }
-  gw->timeout = htonll (et);
+  gw->timeout = GNUNET_htonll (et);
   memcpy (&gw[1], &value[1], size - sizeof (GapWrapper));
 
   if (ggc->resultCallback != NULL)
     ret = ggc->resultCallback (key, &gw->dc, ggc->resCallbackClosure);
   else
-    ret = OK;
+    ret = GNUNET_OK;
   ggc->count++;
-  FREE (gw);
-  FREENONNULL (xvalue);
+  GNUNET_free (gw);
+  GNUNET_free_non_null (xvalue);
   return ret;
 }
 
@@ -833,24 +841,24 @@
  * @param key the value to lookup
  * @param resultCallback function to call for each result that was found
  * @param resCallbackClosure extra argument to resultCallback
- * @return number of results, SYSERR on error
+ * @return number of results, GNUNET_SYSERR on error
  */
 static int
 gapGet (void *closure,
         unsigned int type,
         unsigned int prio,
         unsigned int keyCount,
-        const HashCode512 * keys,
+        const GNUNET_HashCode * keys,
         DataProcessor resultCallback, void *resCallbackClosure)
 {
   int ret;
   GGC myClosure;
 #if DEBUG_FS
-  EncName enc;
+  GNUNET_EncName enc;
 
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (&keys[0], &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (&keys[0], &enc));
+  GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "GAP requests content for `%s' of type %u\n", &enc, type);
 #endif
   myClosure.count = 0;
@@ -858,15 +866,15 @@
   myClosure.keys = keys;
   myClosure.resultCallback = resultCallback;
   myClosure.resCallbackClosure = resCallbackClosure;
-  ret = OK;
+  ret = GNUNET_OK;
   if (type == D_BLOCK)
     {
       ret = datastore->get (&keys[0],
                             ONDEMAND_BLOCK, &gapGetConverter, &myClosure);
     }
-  if (ret != SYSERR)
+  if (ret != GNUNET_SYSERR)
     ret = datastore->get (&keys[0], type, &gapGetConverter, &myClosure);
-  if (ret != SYSERR)
+  if (ret != GNUNET_SYSERR)
     ret = myClosure.count;      /* return number of actual
                                    results (unfiltered) that
                                    were found */
@@ -878,13 +886,14 @@
  *
  * @param key the key of the item
  * @param value the value to remove, NULL for all values of the key
- * @return OK if the value could be removed, SYSERR if not (i.e. not present)
+ * @return GNUNET_OK if the value could be removed, GNUNET_SYSERR if not (i.e. 
not present)
  */
 static int
-gapDel (void *closure, const HashCode512 * key, const DataContainer * value)
+gapDel (void *closure, const GNUNET_HashCode * key,
+        const DataContainer * value)
 {
   GE_BREAK (ectx, 0);           /* gap does not use 'del'! */
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -892,17 +901,17 @@
  *
  * @param processor function to call on each item
  * @param cls argument to processor
- * @return number of results, SYSERR on error
+ * @return number of results, GNUNET_SYSERR on error
  */
 static int
 gapIterate (void *closure, DataProcessor processor, void *cls)
 {
   GE_BREAK (ectx, 0);           /* gap does not use 'iterate' */
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 static int
-replyHashFunction (const DataContainer * content, HashCode512 * id)
+replyHashFunction (const DataContainer * content, GNUNET_HashCode * id)
 {
   const GapWrapper *gw;
   unsigned int size;
@@ -911,20 +920,20 @@
   if (size < sizeof (GapWrapper))
     {
       GE_BREAK (ectx, 0);
-      memset (id, 0, sizeof (HashCode512));
-      return SYSERR;
+      memset (id, 0, sizeof (GNUNET_HashCode));
+      return GNUNET_SYSERR;
     }
   gw = (const GapWrapper *) content;
-  hash (&gw[1], size - sizeof (GapWrapper), id);
-  return OK;
+  GNUNET_hash (&gw[1], size - sizeof (GapWrapper), id);
+  return GNUNET_OK;
 }
 
 static int
 uniqueReplyIdentifier (const DataContainer * content,
                        unsigned int type,
-                       int verify, const HashCode512 * primaryKey)
+                       int verify, const GNUNET_HashCode * primaryKey)
 {
-  HashCode512 q;
+  GNUNET_HashCode q;
   unsigned int t;
   const GapWrapper *gw;
   unsigned int size;
@@ -933,15 +942,15 @@
   if (size < sizeof (GapWrapper))
     {
       GE_BREAK (ectx, 0);
-      return NO;
+      return GNUNET_NO;
     }
   gw = (const GapWrapper *) content;
-  if ((OK == getQueryFor (size - sizeof (GapWrapper),
-                          (const DBlock *) &gw[1],
-                          verify,
-                          &q)) &&
-      (equalsHashCode512 (&q,
-                          primaryKey)) &&
+  if ((GNUNET_OK == getQueryFor (size - sizeof (GapWrapper),
+                                 (const DBlock *) &gw[1],
+                                 verify,
+                                 &q)) &&
+      (0 == memcmp (&q,
+                    primaryKey, sizeof (GNUNET_HashCode))) &&
       ((type == ANY_BLOCK) ||
        (type == (t = getTypeOfBlock (size - sizeof (GapWrapper),
                                      (const DBlock *) &gw[1])))))
@@ -949,27 +958,27 @@
       switch (type)
         {
         case D_BLOCK:
-          return YES;
+          return GNUNET_YES;
         default:
-          return NO;
+          return GNUNET_NO;
         }
     }
   else
-    return NO;
+    return GNUNET_NO;
 }
 
 static int
-fastPathProcessor (const HashCode512 * query,
+fastPathProcessor (const GNUNET_HashCode * query,
                    const DataContainer * value, void *cls)
 {
   Datastore_Value *dv;
 
   dv = gapWrapperToDatastoreValue (value, 0);
   if (dv == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   processResponse (query, dv);
-  FREE (dv);
-  return OK;
+  GNUNET_free (dv);
+  return GNUNET_OK;
 }
 
 /**
@@ -978,7 +987,7 @@
  * as true or false.
  */
 static int
-fastPathProcessorFirst (const HashCode512 * query,
+fastPathProcessorFirst (const GNUNET_HashCode * query,
                         const DataContainer * value, void *cls)
 {
   int *done = cls;
@@ -986,12 +995,13 @@
 
   dv = gapWrapperToDatastoreValue (value, 0);
   if (dv == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   processResponse (query, dv);
-  if (YES == uniqueReplyIdentifier (value, ntohl (dv->type), NO, query))
-    *done = YES;
-  FREE (dv);
-  return SYSERR;
+  if (GNUNET_YES ==
+      uniqueReplyIdentifier (value, ntohl (dv->type), GNUNET_NO, query))
+    *done = GNUNET_YES;
+  GNUNET_free (dv);
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -1004,57 +1014,57 @@
   LG_Job *job;
   while (1)
     {
-      SEMAPHORE_DOWN (ltgSignal, YES);
-      MUTEX_LOCK (lock);
+      GNUNET_semaphore_down (ltgSignal, GNUNET_YES);
+      GNUNET_mutex_lock (lock);
       if (lg_jobs == NULL)
         {
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           break;
         }
       job = lg_jobs;
       lg_jobs = job->next;
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       gapGet (NULL,
               job->type,
               EXTREME_PRIORITY,
               job->keyCount, job->queries, &fastPathProcessor, NULL);
-      FREE (job->queries);
-      FREE (job);
+      GNUNET_free (job->queries);
+      GNUNET_free (job);
     }
   return NULL;
 }
 
 static void
 queueLG_Job (unsigned int type,
-             unsigned int keyCount, const HashCode512 * queries)
+             unsigned int keyCount, const GNUNET_HashCode * queries)
 {
   LG_Job *job;
 
-  job = MALLOC (sizeof (LG_Job));
+  job = GNUNET_malloc (sizeof (LG_Job));
   job->keyCount = keyCount;
-  job->queries = MALLOC (sizeof (HashCode512) * keyCount);
-  memcpy (job->queries, queries, sizeof (HashCode512) * keyCount);
-  MUTEX_LOCK (lock);
+  job->queries = GNUNET_malloc (sizeof (GNUNET_HashCode) * keyCount);
+  memcpy (job->queries, queries, sizeof (GNUNET_HashCode) * keyCount);
+  GNUNET_mutex_lock (lock);
   job->next = lg_jobs;
   lg_jobs = job;
-  MUTEX_UNLOCK (lock);
-  SEMAPHORE_UP (ltgSignal);
+  GNUNET_mutex_unlock (lock);
+  GNUNET_semaphore_up (ltgSignal);
 }
 
 /**
  * Process a query from the client. Forwards to the network.
  *
- * @return SYSERR if the TCP connection should be closed, otherwise OK
+ * @return GNUNET_SYSERR if the TCP connection should be closed, otherwise 
GNUNET_OK
  */
 static int
 csHandleRequestQueryStart (struct ClientHandle *sock,
-                           const MESSAGE_HEADER * req)
+                           const GNUNET_MessageHeader * req)
 {
-  static PeerIdentity all_zeros;
+  static GNUNET_PeerIdentity all_zeros;
   const CS_fs_request_search_MESSAGE *rs;
   unsigned int keyCount;
 #if DEBUG_FS
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
   unsigned int type;
   int done;
@@ -1063,72 +1073,72 @@
   if (ntohs (req->size) < sizeof (CS_fs_request_search_MESSAGE))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   rs = (const CS_fs_request_search_MESSAGE *) req;
-  if (memcmp (&all_zeros, &rs->target, sizeof (PeerIdentity)) == 0)
-    have_target = NO;
+  if (memcmp (&all_zeros, &rs->target, sizeof (GNUNET_PeerIdentity)) == 0)
+    have_target = GNUNET_NO;
   else
-    have_target = YES;
+    have_target = GNUNET_YES;
 #if DEBUG_FS
   IF_GELOG (ectx,
-            GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (&rs->query[0], &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+            GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (&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 (),
+          &enc, GNUNET_ntohll (rs->expiration) - GNUNET_get_time (),
           ntohl (rs->prio), ntohl (rs->anonymityLevel));
 #endif
   type = ntohl (rs->type);
   trackQuery (&rs->query[0], type, sock);
   keyCount =
     1 + (ntohs (req->size) -
-         sizeof (CS_fs_request_search_MESSAGE)) / sizeof (HashCode512);
+         sizeof (CS_fs_request_search_MESSAGE)) / sizeof (GNUNET_HashCode);
 
   /* try a "fast path" avoiding gap/dht if unique reply is locally available */
-  done = NO;
+  done = GNUNET_NO;
   gapGet (NULL,
           type,
           EXTREME_PRIORITY,
           keyCount, &rs->query[0], &fastPathProcessorFirst, &done);
-  if (done == YES)
+  if (done == GNUNET_YES)
     {
 #if DEBUG_FS
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "FS successfully took GAP shortcut for `%s'.\n", &enc);
 #endif
-      return OK;
+      return GNUNET_OK;
     }
 
   /* run gapGet asynchronously (since it may take a while due to lots of IO) */
   queueLG_Job (type, keyCount, &rs->query[0]);
-  gap->get_start (have_target == NO ? NULL : &rs->target,
+  gap->get_start (have_target == GNUNET_NO ? NULL : &rs->target,
                   type,
                   ntohl (rs->anonymityLevel),
                   keyCount,
-                  &rs->query[0], ntohll (rs->expiration), ntohl (rs->prio));
-  if ((ntohl (rs->anonymityLevel) == 0) &&
-      (have_target == NO) && (dht != NULL))
+                  &rs->query[0], GNUNET_ntohll (rs->expiration),
+                  ntohl (rs->prio));
+  if ((ntohl (rs->anonymityLevel) == 0) && (have_target == GNUNET_NO)
+      && (dht != NULL))
     {
       DHT_GET_CLS *cls;
 
-      cls = MALLOC (sizeof (DHT_GET_CLS));
+      cls = GNUNET_malloc (sizeof (DHT_GET_CLS));
       cls->prio = ntohl (rs->prio);
       cls->rec = dht->get_start (type,
                                  &rs->query[0],
-                                 ntohll (rs->expiration),
+                                 GNUNET_ntohll (rs->expiration),
                                  &get_result_callback,
                                  cls, &get_complete_callback, cls);
       if (cls->rec == NULL)
-        FREE (cls);             /* should never happen... */
+        GNUNET_free (cls);      /* should never happen... */
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
-fastGet (const HashCode512 * key)
+fastGet (const GNUNET_HashCode * key)
 {
   return datastore->fast_get (key);
 }
@@ -1137,7 +1147,7 @@
  * Initialize the FS module. This method name must match
  * the library name (libgnunet_XXX => initialize_XXX).
  *
- * @return SYSERR on errors
+ * @return GNUNET_SYSERR on errors
  */
 int
 initialize_module_fs (CoreAPIForApplication * capi)
@@ -1154,9 +1164,10 @@
   GE_ASSERT (ectx, sizeof (NBlock) == 716);
   GE_ASSERT (ectx, sizeof (KNBlock) == 1244);
   migration = GC_get_configuration_value_yesno (capi->cfg,
-                                                "FS", "ACTIVEMIGRATION", YES);
-  if (migration == SYSERR)
-    return SYSERR;
+                                                "FS", "ACTIVEMIGRATION",
+                                                GNUNET_YES);
+  if (migration == GNUNET_SYSERR)
+    return GNUNET_SYSERR;
   if (GC_get_configuration_value_number (capi->cfg,
                                          "FS",
                                          "QUOTA",
@@ -1169,13 +1180,13 @@
               _
               ("You must specify a postive number for `%s' in the 
configuration in section `%s'.\n"),
               "QUOTA", "FS");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   datastore = capi->requestService ("datastore");
   if (datastore == NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   traffic = capi->requestService ("traffic");
   stats = capi->requestService ("stats");
@@ -1194,18 +1205,18 @@
       if (stats != NULL)
         capi->releaseService (stats);
       capi->releaseService (traffic);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   dht = capi->requestService ("dht");
   if (dht != NULL)
     init_dht_push (capi, dht);
-  ltgSignal = SEMAPHORE_CREATE (0);
-  localGetProcessor = PTHREAD_CREATE (&localGetter, NULL, 128 * 1024);
+  ltgSignal = GNUNET_semaphore_create (0);
+  localGetProcessor = GNUNET_thread_create (&localGetter, NULL, 128 * 1024);
   if (localGetProcessor == NULL)
     GE_DIE_STRERROR (ectx, GE_ADMIN | GE_FATAL | GE_BULK, "pthread_create");
   coreAPI = capi;
   ONDEMAND_init (capi);
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   dsGap.closure = NULL;
   dsGap.get = &gapGet;
   dsGap.put = &gapPut;
@@ -1229,31 +1240,38 @@
           CS_PROTO_gap_GET_AVG_PRIORITY, CS_PROTO_gap_INIT_INDEX);
 
   GE_ASSERT (ectx,
-             SYSERR != capi->registerClientHandler (CS_PROTO_gap_QUERY_START,
-                                                    
&csHandleRequestQueryStart));
+             GNUNET_SYSERR !=
+             capi->registerClientHandler (CS_PROTO_gap_QUERY_START,
+                                          &csHandleRequestQueryStart));
   GE_ASSERT (ectx,
-             SYSERR != capi->registerClientHandler (CS_PROTO_gap_QUERY_STOP,
-                                                    
&csHandleRequestQueryStop));
+             GNUNET_SYSERR !=
+             capi->registerClientHandler (CS_PROTO_gap_QUERY_STOP,
+                                          &csHandleRequestQueryStop));
   GE_ASSERT (ectx,
-             SYSERR != capi->registerClientHandler (CS_PROTO_gap_INSERT,
-                                                    
&csHandleCS_fs_request_insert_MESSAGE));
+             GNUNET_SYSERR !=
+             capi->registerClientHandler (CS_PROTO_gap_INSERT,
+                                          
&csHandleCS_fs_request_insert_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR != capi->registerClientHandler (CS_PROTO_gap_INDEX,
-                                                    
&csHandleCS_fs_request_index_MESSAGE));
+             GNUNET_SYSERR != capi->registerClientHandler (CS_PROTO_gap_INDEX,
+                                                           
&csHandleCS_fs_request_index_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR != capi->registerClientHandler (CS_PROTO_gap_INIT_INDEX,
-                                                    
&csHandleCS_fs_request_init_index_MESSAGE));
+             GNUNET_SYSERR !=
+             capi->registerClientHandler (CS_PROTO_gap_INIT_INDEX,
+                                          
&csHandleCS_fs_request_init_index_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR != capi->registerClientHandler (CS_PROTO_gap_DELETE,
-                                                    
&csHandleCS_fs_request_delete_MESSAGE));
+             GNUNET_SYSERR !=
+             capi->registerClientHandler (CS_PROTO_gap_DELETE,
+                                          
&csHandleCS_fs_request_delete_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR != capi->registerClientHandler (CS_PROTO_gap_UNINDEX,
-                                                    
&csHandleCS_fs_request_unindex_MESSAGE));
+             GNUNET_SYSERR !=
+             capi->registerClientHandler (CS_PROTO_gap_UNINDEX,
+                                          
&csHandleCS_fs_request_unindex_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR != capi->registerClientHandler (CS_PROTO_gap_TESTINDEX,
-                                                    
&csHandleCS_fs_request_test_index_MESSAGEed));
+             GNUNET_SYSERR !=
+             capi->registerClientHandler (CS_PROTO_gap_TESTINDEX,
+                                          
&csHandleCS_fs_request_test_index_MESSAGEed));
   GE_ASSERT (ectx,
-             SYSERR !=
+             GNUNET_SYSERR !=
              capi->registerClientHandler (CS_PROTO_gap_GET_AVG_PRIORITY,
                                           &csHandleRequestGetAvgPriority));
   initMigration (capi, datastore, gap, dht, traffic);
@@ -1264,7 +1282,7 @@
                                                      "fs",
                                                      gettext_noop
                                                      ("enables (anonymous) 
file-sharing")));
-  return OK;
+  return GNUNET_OK;
 }
 
 void
@@ -1276,47 +1294,51 @@
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, "fs shutdown\n");
   doneMigration ();
   GE_ASSERT (ectx,
-             SYSERR !=
+             GNUNET_SYSERR !=
              coreAPI->unregisterClientHandler (CS_PROTO_gap_QUERY_START,
                                                &csHandleRequestQueryStart));
   GE_ASSERT (ectx,
-             SYSERR !=
+             GNUNET_SYSERR !=
              coreAPI->unregisterClientHandler (CS_PROTO_gap_QUERY_STOP,
                                                &csHandleRequestQueryStop));
   GE_ASSERT (ectx,
-             SYSERR != coreAPI->unregisterClientHandler (CS_PROTO_gap_INSERT,
-                                                         
&csHandleCS_fs_request_insert_MESSAGE));
+             GNUNET_SYSERR !=
+             coreAPI->unregisterClientHandler (CS_PROTO_gap_INSERT,
+                                               
&csHandleCS_fs_request_insert_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR != coreAPI->unregisterClientHandler (CS_PROTO_gap_INDEX,
-                                                         
&csHandleCS_fs_request_index_MESSAGE));
+             GNUNET_SYSERR !=
+             coreAPI->unregisterClientHandler (CS_PROTO_gap_INDEX,
+                                               
&csHandleCS_fs_request_index_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR !=
+             GNUNET_SYSERR !=
              coreAPI->unregisterClientHandler (CS_PROTO_gap_INIT_INDEX,
                                                
&csHandleCS_fs_request_init_index_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR != coreAPI->unregisterClientHandler (CS_PROTO_gap_DELETE,
-                                                         
&csHandleCS_fs_request_delete_MESSAGE));
+             GNUNET_SYSERR !=
+             coreAPI->unregisterClientHandler (CS_PROTO_gap_DELETE,
+                                               
&csHandleCS_fs_request_delete_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR != coreAPI->unregisterClientHandler (CS_PROTO_gap_UNINDEX,
-                                                         
&csHandleCS_fs_request_unindex_MESSAGE));
+             GNUNET_SYSERR !=
+             coreAPI->unregisterClientHandler (CS_PROTO_gap_UNINDEX,
+                                               
&csHandleCS_fs_request_unindex_MESSAGE));
   GE_ASSERT (ectx,
-             SYSERR !=
+             GNUNET_SYSERR !=
              coreAPI->unregisterClientHandler (CS_PROTO_gap_TESTINDEX,
                                                
&csHandleCS_fs_request_test_index_MESSAGEed));
   GE_ASSERT (ectx,
-             SYSERR !=
+             GNUNET_SYSERR !=
              coreAPI->unregisterClientHandler (CS_PROTO_gap_GET_AVG_PRIORITY,
                                                
&csHandleRequestGetAvgPriority));
   doneQueryManager ();
   while (lg_jobs != NULL)
     {
       job = lg_jobs->next;
-      FREE (lg_jobs->queries);
-      FREE (lg_jobs);
+      GNUNET_free (lg_jobs->queries);
+      GNUNET_free (lg_jobs);
       lg_jobs = job;
     }
-  SEMAPHORE_UP (ltgSignal);     /* lg_jobs == NULL => thread will terminate */
-  PTHREAD_JOIN (localGetProcessor, &unused);
+  GNUNET_semaphore_up (ltgSignal);      /* lg_jobs == NULL => thread will 
terminate */
+  GNUNET_thread_join (localGetProcessor, &unused);
   coreAPI->releaseService (datastore);
   datastore = NULL;
   if (stats != NULL)
@@ -1338,10 +1360,10 @@
       traffic = NULL;
     }
   coreAPI = NULL;
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
   ONDEMAND_done ();
-  SEMAPHORE_DESTROY (ltgSignal);
+  GNUNET_semaphore_destroy (ltgSignal);
   ltgSignal = NULL;
 }
 

Modified: GNUnet/src/applications/fs/module/migration.c
===================================================================
--- GNUnet/src/applications/fs/module/migration.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/migration.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -33,7 +33,7 @@
 #include "gnunet_protocols.h"
 #include "ondemand.h"
 
-#define DEBUG_MIGRATION NO
+#define DEBUG_MIGRATION GNUNET_NO
 
 /**
  * To how many peers may we migrate the same piece of content during
@@ -56,7 +56,7 @@
 /**
  * How often do we poll the datastore for content (at most).
  */
-#define MAX_POLL_FREQUENCY (250 * cronMILLIS)
+#define MAX_POLL_FREQUENCY (250 * GNUNET_CRON_MILLISECONDS)
 
 /**
  * Datastore service.
@@ -94,12 +94,12 @@
 /**
  * Lock used to access content.
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 struct MigrationRecord
 {
   Datastore_Value *value;
-  HashCode512 key;
+  GNUNET_HashCode key;
   unsigned int receiverIndices[MAX_RECEIVERS];
   unsigned int sentCount;
 };
@@ -111,7 +111,7 @@
 /**
  * Callback method for pushing content into the network.
  * The method chooses either a "recently" deleted block
- * or content that has a hash close to the receiver ID
+ * or content that has a GNUNET_hash close to the receiver ID
  * (randomized to guarantee diversity, unpredictability
  * etc.).<p>
  *
@@ -124,15 +124,15 @@
  *   that buffer (must be a positive number).
  */
 static unsigned int
-activeMigrationCallback (const PeerIdentity * receiver,
+activeMigrationCallback (const GNUNET_PeerIdentity * receiver,
                          void *position, unsigned int padding)
 {
-  static cron_t discard_time;
+  static GNUNET_CronTime discard_time;
   unsigned int ret;
   GapWrapper *gw;
   unsigned int size;
-  cron_t et;
-  cron_t now;
+  GNUNET_CronTime et;
+  GNUNET_CronTime now;
   unsigned int anonymity;
   Datastore_Value *enc;
   Datastore_Value *value;
@@ -147,8 +147,8 @@
   unsigned int minDist;
 
   index = coreAPI->computeIndex (receiver);
-  MUTEX_LOCK (lock);
-  now = get_time ();
+  GNUNET_mutex_lock (lock);
+  now = GNUNET_get_time ();
   entry = -1;
   discard_entry = -1;
   discard_match = -1;
@@ -160,7 +160,8 @@
           if (discard_time >= now - MAX_POLL_FREQUENCY)
             continue;
           discard_time = now;
-          if (OK != datastore->getRandom (&content[i].key, &content[i].value))
+          if (GNUNET_OK !=
+              datastore->getRandom (&content[i].key, &content[i].value))
             {
               content[i].value = NULL;  /* just to be sure... */
               continue;
@@ -188,7 +189,8 @@
         }
       if (match == 0)
         {
-          dist = distanceHashCode512 (&content[i].key, &receiver->hashPubKey);
+          dist =
+            GNUNET_hash_distance_u32 (&content[i].key, &receiver->hashPubKey);
           if (dist <= minDist)
             {
               entry = i;
@@ -210,11 +212,11 @@
       (discard_time < now - MAX_POLL_FREQUENCY))
     {
       discard_time = now;
-      FREENONNULL (content[discard_entry].value);
+      GNUNET_free_non_null (content[discard_entry].value);
       content[discard_entry].value = NULL;
       content[discard_entry].sentCount = 0;
-      if (OK != datastore->getRandom (&content[discard_entry].key,
-                                      &content[discard_entry].value))
+      if (GNUNET_OK != datastore->getRandom (&content[discard_entry].key,
+                                             &content[discard_entry].value))
         {
           content[discard_entry].value = NULL;  /* just to be sure... */
           discard_entry = -1;
@@ -234,14 +236,14 @@
               GE_DEBUG | GE_REQUEST | GE_USER,
               "Migration: no content available for migration.\n");
 #endif
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return 0;
     }
   value = content[entry].value;
   if (value == NULL)
     {
       GE_ASSERT (NULL, 0);
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return 0;
     }
   size = sizeof (GapWrapper) + ntohl (value->size) - sizeof (Datastore_Value);
@@ -253,7 +255,7 @@
               "Migration: available content too big (%u > %u) for 
migration.\n",
               size, padding);
 #endif
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return 0;
     }
 #if DEBUG_MIGRATION
@@ -265,11 +267,11 @@
   if (ntohl (value->type) == ONDEMAND_BLOCK)
     {
       if (ONDEMAND_getIndexed (datastore,
-                               value, &content[entry].key, &enc) != OK)
+                               value, &content[entry].key, &enc) != GNUNET_OK)
         {
-          FREENONNULL (value);
+          GNUNET_free_non_null (value);
           content[entry].value = NULL;
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
 #if DEBUG_MIGRATION
           GE_LOG (ectx,
                   GE_DEBUG | GE_REQUEST | GE_USER,
@@ -280,14 +282,14 @@
       if (stats != NULL)
         stats->change (stat_on_demand_migration_attempts, 1);
       content[entry].value = enc;
-      FREE (value);
+      GNUNET_free (value);
       value = enc;
     }
 
   size = sizeof (GapWrapper) + ntohl (value->size) - sizeof (Datastore_Value);
   if (size > padding)
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
 #if DEBUG_MIGRATION
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
@@ -296,7 +298,7 @@
 #endif
       return 0;
     }
-  et = ntohll (value->expirationTime);
+  et = GNUNET_ntohll (value->expirationTime);
   if (et > now)
     {
       et -= now;
@@ -310,14 +312,14 @@
       value->anonymityLevel = htonl (1);
       anonymity = 1;
     }
-  if (OK == checkCoverTraffic (ectx, traffic, anonymity))
+  if (GNUNET_OK == checkCoverTraffic (ectx, traffic, anonymity))
     {
-      gw = MALLOC (size);
+      gw = GNUNET_malloc (size);
       gw->dc.size = htonl (size);
-      gw->timeout = htonll (et);
+      gw->timeout = GNUNET_htonll (et);
       memcpy (&gw[1], &value[1], size - sizeof (GapWrapper));
       ret = gap->tryMigrate (&gw->dc, &content[entry].key, position, padding);
-      FREE (gw);
+      GNUNET_free (gw);
 #if DEBUG_MIGRATION
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
@@ -327,7 +329,7 @@
         {
           if (content[entry].sentCount == MAX_RECEIVERS)
             {
-              FREE (content[entry].value);
+              GNUNET_free (content[entry].value);
               content[entry].value = NULL;
               content[entry].sentCount = 0;
             }
@@ -346,7 +348,7 @@
 #endif
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   if ((ret > 0) && (stats != NULL))
     stats->change (stat_migration_count, 1);
   GE_BREAK (NULL, ret <= padding);
@@ -359,7 +361,7 @@
                GAP_ServiceAPI * g, DHT_ServiceAPI * d, Traffic_ServiceAPI * t)
 {
   ectx = capi->ectx;
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   coreAPI = capi;
   datastore = ds;
   gap = g;
@@ -399,10 +401,10 @@
   traffic = NULL;
   for (i = 0; i < MAX_RECORDS; i++)
     {
-      FREENONNULL (content[i].value);
+      GNUNET_free_non_null (content[i].value);
       content[i].value = NULL;
     }
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
 }
 

Modified: GNUnet/src/applications/fs/module/migration.h
===================================================================
--- GNUnet/src/applications/fs/module/migration.h       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/migration.h       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -60,7 +60,7 @@
  *
  * Now, for local content eventually modulo will rebound to the MAX
  * (whereas for migrated content it will hit 0 and disappear).  But
- * that is OK: the adversary cannot distinguish the modulo wraparound
+ * that is GNUNET_OK: the adversary cannot distinguish the modulo wraparound
  * from content migration (refresh with higher lifetime) which could
  * plausibly happen from the original node (and in fact would happen
  * around the same time!).  This design also achieves the design goal
@@ -76,7 +76,7 @@
  * expiration to give the user some indication about availability.
  *
  */
-#define MAX_MIGRATION_EXP (1L * cronMONTHS)
+#define MAX_MIGRATION_EXP (1L * GNUNET_CRON_MONTHS)
 
 /**
  * Initialize the migration module.

Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/ondemand.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -31,9 +31,9 @@
 #include "ondemand.h"
 #include "gnunet_state_service.h"
 
-#define DEBUG_ONDEMAND NO
+#define DEBUG_ONDEMAND GNUNET_NO
 
-#define TRACK_INDEXED_FILES NO
+#define TRACK_INDEXED_FILES GNUNET_NO
 
 #define TRACKFILE "indexed_requests.txt"
 
@@ -59,11 +59,11 @@
   unsigned int blockSize;
 
   /**
-   * What is the hash of the file that contains
+   * What is the GNUNET_hash of the file that contains
    * this block?  Used to determine the name
    * of the file in the on-demand datastore.
    */
-  HashCode512 fileId;
+  GNUNET_HashCode fileId;
 
 } OnDemandBlock;
 
@@ -76,13 +76,13 @@
 static State_ServiceAPI *state;
 
 static char *
-getOnDemandFile (const HashCode512 * fileId)
+getOnDemandFile (const GNUNET_HashCode * fileId)
 {
-  EncName enc;
+  GNUNET_EncName enc;
   char *fn;
 
-  hash2enc (fileId, &enc);
-  fn = MALLOC (strlen (index_directory) + sizeof (EncName) + 1);
+  GNUNET_hash_to_enc (fileId, &enc);
+  fn = GNUNET_malloc (strlen (index_directory) + sizeof (GNUNET_EncName) + 1);
   strcpy (fn, index_directory);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, (char *) &enc);
@@ -96,7 +96,7 @@
  * by aborting the iteration.
  */
 static int
-checkPresent (const HashCode512 * key,
+checkPresent (const GNUNET_HashCode * key,
               const Datastore_Value * value, void *closure,
               unsigned long long uid)
 {
@@ -106,42 +106,43 @@
       (0 != memcmp (&value[1],
                     &comp[1],
                     ntohl (value->size) - sizeof (Datastore_Value))))
-    return OK;
-  return SYSERR;
+    return GNUNET_OK;
+  return GNUNET_SYSERR;
 }
 
 /**
  * Creates a symlink to the given file in the shared directory
  *
  * @param fn the file that was indexed
- * @param fileId the file's hash code
- * @return SYSERR on error, NO if symlinking failed,
- *         YES on success
+ * @param fileId the file's GNUNET_hash code
+ * @return GNUNET_SYSERR on error, GNUNET_NO if symlinking failed,
+ *         GNUNET_YES on success
  */
 int
 ONDEMAND_initIndex (struct GE_Context *cectx,
-                    const HashCode512 * fileId, const char *fn)
+                    const GNUNET_HashCode * fileId, const char *fn)
 {
-  EncName enc;
+  GNUNET_EncName enc;
   char *serverFN;
   char unavail_key[256];
-  HashCode512 linkId;
+  GNUNET_HashCode linkId;
 
-  if ((SYSERR == getFileHash (cectx,
-                              fn,
-                              &linkId)) ||
-      (!equalsHashCode512 (&linkId, fileId)))
+  if ((GNUNET_SYSERR == GNUNET_hash_file (cectx,
+                                          fn,
+                                          &linkId)) ||
+      (0 != memcmp (&linkId, fileId, sizeof (GNUNET_HashCode))))
     {
-      return NO;
+      return GNUNET_NO;
     }
 
-  serverFN = MALLOC (strlen (index_directory) + 2 + sizeof (EncName));
+  serverFN =
+    GNUNET_malloc (strlen (index_directory) + 2 + sizeof (GNUNET_EncName));
   strcpy (serverFN, index_directory);
   strcat (serverFN, DIR_SEPARATOR_STR);
-  hash2enc (fileId, &enc);
+  GNUNET_hash_to_enc (fileId, &enc);
   strcat (serverFN, (char *) &enc);
   UNLINK (serverFN);
-  disk_directory_create_for_file (cectx, serverFN);
+  GNUNET_disk_directory_create_for_file (cectx, serverFN);
   if (0 != SYMLINK (fn, serverFN))
     {
       GE_LOG_STRERROR_FILE (cectx,
@@ -150,39 +151,39 @@
       GE_LOG_STRERROR_FILE (cectx,
                             GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                             "symlink", serverFN);
-      FREE (serverFN);
-      return NO;
+      GNUNET_free (serverFN);
+      return GNUNET_NO;
     }
-  SNPRINTF (unavail_key, 256, "FIRST_UNAVAILABLE-%s", (char *) &enc);
+  GNUNET_snprintf (unavail_key, 256, "FIRST_UNAVAILABLE-%s", (char *) &enc);
   state->unlink (ectx, unavail_key);
-  FREE (serverFN);
-  return YES;
+  GNUNET_free (serverFN);
+  return GNUNET_YES;
 }
 
 /**
  * Writes the given content to the file at the specified offset
  * and stores an OnDemandBlock into the datastore.
  *
- * @return NO if already present, YES on success,
- *  SYSERR on other error (i.e. datastore full)
+ * @return GNUNET_NO if already present, GNUNET_YES on success,
+ *  GNUNET_SYSERR on other error (i.e. datastore full)
  */
 int
 ONDEMAND_index (struct GE_Context *cectx,
                 Datastore_ServiceAPI * datastore,
                 unsigned int prio,
-                cron_t expiration,
+                GNUNET_CronTime expiration,
                 unsigned long long fileOffset,
                 unsigned int anonymityLevel,
-                const HashCode512 * fileId,
+                const GNUNET_HashCode * fileId,
                 unsigned int size, const DBlock * content)
 {
   int ret;
   OnDemandBlock odb;
-  HashCode512 key;
+  GNUNET_HashCode key;
   struct stat sbuf;
   char *fn;
 #if DEBUG_ONDEMAND
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
 
@@ -190,7 +191,7 @@
     {
       GE_BREAK (cectx, 0);
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   fn = getOnDemandFile (fileId);
@@ -208,41 +209,41 @@
               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 */
+      fd = GNUNET_disk_file_open (cectx, fn, O_LARGEFILE | O_CREAT | O_WRONLY, 
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);  /* 644 */
       if (fd == -1)
         {
-          FREE (fn);
-          return SYSERR;
+          GNUNET_free (fn);
+          return GNUNET_SYSERR;
         }
       LSEEK (fd, fileOffset, SEEK_SET);
       ret = WRITE (fd, &content[1], size - sizeof (DBlock));
       if (ret == size - sizeof (DBlock))
         {
-          ret = OK;
+          ret = GNUNET_OK;
         }
       else
         {
           GE_LOG_STRERROR_FILE (cectx,
                                 GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                                 "write", fn);
-          ret = SYSERR;
+          ret = GNUNET_SYSERR;
         }
       CLOSE (fd);
-      if (ret == SYSERR)
+      if (ret == GNUNET_SYSERR)
         {
-          FREE (fn);
+          GNUNET_free (fn);
           return ret;
         }
     }
-  FREE (fn);
+  GNUNET_free (fn);
 
   odb.header.size = htonl (sizeof (OnDemandBlock));
   odb.header.type = htonl (ONDEMAND_BLOCK);
   odb.header.prio = htonl (prio);
   odb.header.anonymityLevel = htonl (anonymityLevel);
-  odb.header.expirationTime = htonll (expiration);
+  odb.header.expirationTime = GNUNET_htonll (expiration);
   odb.type = htonl (ONDEMAND_BLOCK);
-  odb.fileOffset = htonll (fileOffset);
+  odb.fileOffset = GNUNET_htonll (fileOffset);
   odb.blockSize = htonl (size - sizeof (DBlock));
   odb.fileId = *fileId;
   /* compute the primary key */
@@ -250,22 +251,22 @@
 #if EXTRA_CHECKS
   {
     Datastore_Value *dsvalue;
-    if (OK != fileBlockEncode (content, size, &key, &dsvalue))
+    if (GNUNET_OK != fileBlockEncode (content, size, &key, &dsvalue))
       {
         GE_BREAK (cectx, 0);
         GE_BREAK (ectx, 0);
       }
     else
       {
-        FREE (dsvalue);
+        GNUNET_free (dsvalue);
       }
   }
 #endif
 
 #if DEBUG_ONDEMAND
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (&key, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (&key, &enc));
+  GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "Storing on-demand content for query `%s'\n", &enc);
 #endif
 
@@ -276,7 +277,7 @@
     }
   else
     {
-      ret = NO;                 /* already present! */
+      ret = GNUNET_NO;          /* already present! */
     }
   return ret;
 }
@@ -285,7 +286,7 @@
 {
   Datastore_ServiceAPI *datastore;
   Datastore_Value *dbv;
-  HashCode512 query;
+  GNUNET_HashCode query;
 };
 
 static void
@@ -293,8 +294,8 @@
 {
   struct adJ *job = cls;
   job->datastore->del (&job->query, job->dbv);
-  FREE (job->dbv);
-  FREE (job);
+  GNUNET_free (job->dbv);
+  GNUNET_free (job);
 }
 
 /**
@@ -304,27 +305,27 @@
  */
 static void
 asyncDelete (Datastore_ServiceAPI * datastore,
-             const Datastore_Value * dbv, const HashCode512 * query)
+             const Datastore_Value * dbv, const GNUNET_HashCode * query)
 {
   struct adJ *job;
 #if DEBUG_ONDEMAND
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
-  job = MALLOC (sizeof (struct adJ));
+  job = GNUNET_malloc (sizeof (struct adJ));
   job->datastore = datastore;
   job->query = *query;
-  job->dbv = MALLOC (ntohl (dbv->size));
+  job->dbv = GNUNET_malloc (ntohl (dbv->size));
   memcpy (job->dbv, dbv, ntohl (dbv->size));
 #if DEBUG_ONDEMAND
-  hash2enc (query, &enc);
+  GNUNET_hash_to_enc (query, &enc);
   GE_LOG (ectx,
           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);
+  GNUNET_cron_add_job (coreAPI->cron, &asyncDelJob, 0, 0, job);
 }
 
 /**
@@ -334,12 +335,12 @@
  * encoding fails because the file is no longer there,
  * this function also removes the OD-Entry
  *
- * @return OK on success, SYSERR if there was an error
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there was an error
  */
 int
 ONDEMAND_getIndexed (Datastore_ServiceAPI * datastore,
                      const Datastore_Value * dbv,
-                     const HashCode512 * query, Datastore_Value ** enc)
+                     const GNUNET_HashCode * query, Datastore_Value ** enc)
 {
   char *fn;
   char *iobuf;
@@ -352,17 +353,18 @@
   if (ntohl (dbv->size) != sizeof (OnDemandBlock))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   odb = (OnDemandBlock *) dbv;
   fn = getOnDemandFile (&odb->fileId);
-  if ((YES != disk_file_test (ectx,
-                              fn)) ||
-      (-1 == (fileHandle = disk_file_open (ectx,
-                                           fn, O_LARGEFILE | O_RDONLY, 0))))
+  if ((GNUNET_YES != GNUNET_disk_file_test (ectx,
+                                            fn)) ||
+      (-1 == (fileHandle = GNUNET_disk_file_open (ectx,
+                                                  fn, O_LARGEFILE | O_RDONLY,
+                                                  0))))
     {
       char unavail_key[256];
-      EncName enc;
+      GNUNET_EncName enc;
       unsigned long long *first_unavail;
       struct stat linkStat;
 
@@ -378,37 +380,39 @@
       else
         {
           /* For how long has the file been unavailable? */
-          hash2enc (&odb->fileId, &enc);
-          SNPRINTF (unavail_key, 256, "FIRST_UNVAILABLE-%s", (char *) &enc);
-          if (state->read (ectx,
-                           unavail_key,
-                           (void *) &first_unavail) != sizeof (cron_t))
+          GNUNET_hash_to_enc (&odb->fileId, &enc);
+          GNUNET_snprintf (unavail_key, 256, "FIRST_UNVAILABLE-%s",
+                           (char *) &enc);
+          if (state->read (ectx, unavail_key, (void *) &first_unavail) !=
+              sizeof (GNUNET_CronTime))
             {
-              unsigned long long now = htonll (get_time ());
+              unsigned long long now = GNUNET_htonll (GNUNET_get_time ());
               state->write (ectx,
-                            unavail_key, sizeof (cron_t), (void *) &now);
+                            unavail_key, sizeof (GNUNET_CronTime),
+                            (void *) &now);
             }
           else
             {
               /* Delete it after 3 days */
-              if (ntohll (*first_unavail) - get_time () > 3 * cronDAYS)
+              if (GNUNET_ntohll (*first_unavail) - GNUNET_get_time () >
+                  3 * GNUNET_CRON_DAYS)
                 {
                   unsigned int len;
                   char *ofn;
                   int ret;
 
                   len = 256;
-                  ofn = MALLOC (len);
+                  ofn = GNUNET_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;
+                        GNUNET_array_grow (ofn, len, 0);
+                        GNUNET_free (fn);
+                        return GNUNET_SYSERR;
                       }
-                  GROW (ofn, len, len * 2);
+                  GNUNET_array_grow (ofn, len, len * 2);
 
                   if (ret != -1)
                     {
@@ -420,7 +424,7 @@
                                " deleting them as the index now contains 
invalid references!\n"),
                               ofn);
                     }
-                  FREE (ofn);
+                  GNUNET_free (ofn);
                   asyncDelete (datastore, dbv, query);
                   state->unlink (ectx, unavail_key);
                   UNLINK (fn);
@@ -428,8 +432,8 @@
             }
         }
 
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
 
 #if TRACK_INDEXED_FILES
@@ -445,29 +449,32 @@
                             " 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);
+    scratch = GNUNET_malloc (n);
+    GNUNET_snprintf (scratch, n, "%s/%s", afsDir, TRACKFILE);
     fp = FOPEN (scratch, "a");
     FPRINTF (fp,
              "%u %llu\n",
-             ntohs (ce->fileNameIndex), (unsigned long long) TIME (NULL));
+             ntohs (ce->fileNameIndex),
+             (unsigned long long) GNUNET_get_time_int32 (NULL));
     fclose (fp);
-    FREE (scratch);
-    FREE (afsDir);
+    GNUNET_free (scratch);
+    GNUNET_free (afsDir);
   }
 #endif
-  if (ntohll (odb->fileOffset) != LSEEK (fileHandle,
-                                         ntohll (odb->fileOffset), SEEK_SET))
+  if (GNUNET_ntohll (odb->fileOffset) != LSEEK (fileHandle,
+                                                GNUNET_ntohll (odb->
+                                                               fileOffset),
+                                                SEEK_SET))
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
                             "lseek", fn);
-      FREE (fn);
+      GNUNET_free (fn);
       CLOSE (fileHandle);
       asyncDelete (datastore, dbv, query);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  db = MALLOC (sizeof (DBlock) + ntohl (odb->blockSize));
+  db = GNUNET_malloc (sizeof (DBlock) + ntohl (odb->blockSize));
   db->type = htonl (D_BLOCK);
   iobuf = (char *) &db[1];
   blen = READ (fileHandle, iobuf, ntohl (odb->blockSize));
@@ -476,52 +483,52 @@
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
                             "read", fn);
-      FREE (fn);
-      FREE (db);
+      GNUNET_free (fn);
+      GNUNET_free (db);
       CLOSE (fileHandle);
       asyncDelete (datastore, dbv, query);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   CLOSE (fileHandle);
   ret = fileBlockEncode (db,
                          ntohl (odb->blockSize) + sizeof (DBlock),
                          query, enc);
-  FREE (db);
-  FREE (fn);
-  if (ret == SYSERR)
+  GNUNET_free (db);
+  GNUNET_free (fn);
+  if (ret == GNUNET_SYSERR)
     {
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_USER,
               _("Indexed content changed (does not match its hash).\n"));
       asyncDelete (datastore, dbv, query);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   (*enc)->anonymityLevel = dbv->anonymityLevel;
   (*enc)->expirationTime = dbv->expirationTime;
   (*enc)->prio = dbv->prio;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Test if the file with the given ID is
  * indexed.
- * @return YES if so, NO if not.
+ * @return GNUNET_YES if so, GNUNET_NO if not.
  */
 int
 ONDEMAND_testindexed (Datastore_ServiceAPI * datastore,
-                      const HashCode512 * fileId)
+                      const GNUNET_HashCode * fileId)
 {
   char *fn;
   int fd;
 
   fn = getOnDemandFile (fileId);
-  fd = disk_file_open (ectx, fn, O_RDONLY);
-  FREE (fn);
+  fd = GNUNET_disk_file_open (ectx, fn, O_RDONLY);
+  GNUNET_free (fn);
   if (fd == -1)
-    return NO;
+    return GNUNET_NO;
   CLOSE (fd);
-  return YES;
+  return GNUNET_YES;
 }
 
 
@@ -532,7 +539,7 @@
  * continue.
  */
 static int
-completeValue (const HashCode512 * key,
+completeValue (const GNUNET_HashCode * key,
                const Datastore_Value * value, void *closure,
                unsigned long long uid)
 {
@@ -549,7 +556,7 @@
               "`%s' found value that does not match (%u, %u).\n",
               __FUNCTION__, ntohl (comp->size), ntohl (value->size));
 #endif
-      return OK;
+      return GNUNET_OK;
     }
   *comp = *value;               /* make copy! */
 #if DEBUG_ONDEMAND
@@ -557,7 +564,7 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           "`%s' found value that matches.\n", __FUNCTION__);
 #endif
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -573,18 +580,18 @@
 int
 ONDEMAND_unindex (struct GE_Context *cectx,
                   Datastore_ServiceAPI * datastore,
-                  unsigned int blocksize, const HashCode512 * fileId)
+                  unsigned int blocksize, const GNUNET_HashCode * fileId)
 {
   char *fn;
   int fd;
   int ret;
   OnDemandBlock odb;
-  HashCode512 key;
+  GNUNET_HashCode key;
   unsigned long long pos;
   unsigned long long size;
   unsigned long long delta;
   DBlock *block;
-  EncName enc;
+  GNUNET_EncName enc;
   char unavail_key[256];
 
   fn = getOnDemandFile (fileId);
@@ -593,19 +600,19 @@
           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 */
+  fd = GNUNET_disk_file_open (cectx, fn, O_RDONLY | O_LARGEFILE, S_IRUSR | 
S_IWUSR | S_IRGRP | S_IROTH);        /* 644 */
   if (fd == -1)
     {
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
   pos = 0;
-  if (OK != disk_file_size (cectx, fn, &size, YES))
+  if (GNUNET_OK != GNUNET_disk_file_size (cectx, fn, &size, GNUNET_YES))
     {
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
-  block = MALLOC (sizeof (DBlock) + blocksize);
+  block = GNUNET_malloc (sizeof (DBlock) + blocksize);
   block->type = htonl (D_BLOCK);
   while (pos < size)
     {
@@ -618,9 +625,9 @@
                                 GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                                 "read", fn);
           CLOSE (fd);
-          FREE (fn);
-          FREE (block);
-          return SYSERR;
+          GNUNET_free (fn);
+          GNUNET_free (block);
+          return GNUNET_SYSERR;
         }
       odb.header.size = htonl (sizeof (OnDemandBlock));
       odb.header.type = htonl (ONDEMAND_BLOCK);
@@ -628,36 +635,36 @@
       odb.header.anonymityLevel = 0;
       odb.header.expirationTime = 0;
       odb.type = htonl (ONDEMAND_BLOCK);
-      odb.fileOffset = htonll (pos);
+      odb.fileOffset = GNUNET_htonll (pos);
       odb.blockSize = htonl (delta);
       odb.fileId = *fileId;
       /* compute the primary key */
       fileBlockGetQuery (block, delta + sizeof (DBlock), &key);
-      if (SYSERR == datastore->get (&key, ONDEMAND_BLOCK, &completeValue, 
&odb.header)) /* aborted == found! */
+      if (GNUNET_SYSERR == datastore->get (&key, ONDEMAND_BLOCK, 
&completeValue, &odb.header))  /* aborted == found! */
         ret = datastore->del (&key, &odb.header);
       else                      /* not found */
-        ret = SYSERR;
-      if (ret == SYSERR)
+        ret = GNUNET_SYSERR;
+      if (ret == GNUNET_SYSERR)
         {
           IF_GELOG (cectx,
-                    GE_WARNING | GE_BULK | GE_USER, hash2enc (&key, &enc));
-          GE_LOG (ectx,
-                  GE_WARNING | GE_BULK | GE_USER,
+                    GE_WARNING | GE_BULK | GE_USER, GNUNET_hash_to_enc (&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);
         }
       pos += delta;
     }
-  FREE (block);
+  GNUNET_free (block);
   CLOSE (fd);
   UNLINK (fn);
   /* Remove information about unavailability */
-  hash2enc (fileId, &enc);
-  SNPRINTF (unavail_key, 256, "FIRST_UNAVAILABLE-%s", (char *) &enc);
+  GNUNET_hash_to_enc (fileId, &enc);
+  GNUNET_snprintf (unavail_key, 256, "FIRST_UNAVAILABLE-%s", (char *) &enc);
   state->unlink (ectx, unavail_key);
-  FREE (fn);
-  return OK;
+  GNUNET_free (fn);
+  return GNUNET_OK;
 }
 
 int
@@ -670,7 +677,7 @@
   if (state == NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ectx = capi->ectx;
   GC_get_configuration_value_filename (capi->cfg,
@@ -678,15 +685,15 @@
                                        "GNUNETD_HOME",
                                        VAR_DAEMON_DIRECTORY, &tmp);
   GE_ASSERT (ectx, NULL != tmp);
-  tmp = REALLOC (tmp, strlen (tmp) + strlen ("/data/shared/") + 1);
+  tmp = GNUNET_realloc (tmp, strlen (tmp) + strlen ("/data/shared/") + 1);
   strcat (tmp, "/data/shared/");
   GC_get_configuration_value_filename (capi->cfg,
                                        "FS",
                                        "INDEX-DIRECTORY",
                                        tmp, &index_directory);
-  FREE (tmp);
-  disk_directory_create (ectx, index_directory);        /* just in case */
-  return OK;
+  GNUNET_free (tmp);
+  GNUNET_disk_directory_create (ectx, index_directory); /* just in case */
+  return GNUNET_OK;
 }
 
 int
@@ -694,8 +701,8 @@
 {
   coreAPI->releaseService (state);
   state = NULL;
-  FREE (index_directory);
-  return OK;
+  GNUNET_free (index_directory);
+  return GNUNET_OK;
 }
 
 /* end of ondemand.c */

Modified: GNUnet/src/applications/fs/module/ondemand.h
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.h        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/ondemand.h        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -35,23 +35,23 @@
 
 /**
  * Creates a symlink to the given file in the shared directory
- * @return SYSERR on error, NO if symlinking failed,
- *         YES on success
+ * @return GNUNET_SYSERR on error, GNUNET_NO if symlinking failed,
+ *         GNUNET_YES on success
  */
 int ONDEMAND_initIndex (struct GE_Context *cectx,
-                        const HashCode512 * fileId, const char *fn);
+                        const GNUNET_HashCode * fileId, const char *fn);
 
 /**
- * @return NO if already present, YES on success,
- *  SYSERR on other error (i.e. datastore full)
+ * @return GNUNET_NO if already present, GNUNET_YES on success,
+ *  GNUNET_SYSERR on other error (i.e. datastore full)
  */
 int ONDEMAND_index (struct GE_Context *cectx,
                     Datastore_ServiceAPI * datastore,
                     unsigned int prio,
-                    cron_t expiration,
+                    GNUNET_CronTime expiration,
                     unsigned long long fileOffset,
                     unsigned int anonymityLevel,
-                    const HashCode512 * fileId,
+                    const GNUNET_HashCode * fileId,
                     unsigned int size, const DBlock * content);
 
 /**
@@ -60,11 +60,12 @@
  * the resulting DSV in enc.  If the on-demand
  * encoding fails because the file is no longer there,
  * this function also removes the OD-Entry
- * @return OK on success, SYSERR if there was an error
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there was an error
  */
 int ONDEMAND_getIndexed (Datastore_ServiceAPI * datastore,
                          const Datastore_Value * odb,
-                         const HashCode512 * query, Datastore_Value ** enc);
+                         const GNUNET_HashCode * query,
+                         Datastore_Value ** enc);
 
 /**
  * Unindex the file with the given ID.  Removes the file from the
@@ -78,15 +79,15 @@
  */
 int ONDEMAND_unindex (struct GE_Context *cectx,
                       Datastore_ServiceAPI * datastore,
-                      unsigned int blocksize, const HashCode512 * fileId);
+                      unsigned int blocksize, const GNUNET_HashCode * fileId);
 
 /**
  * Test if the file with the given ID is
  * indexed.
- * @return YES if so, NO if not.
+ * @return GNUNET_YES if so, GNUNET_NO if not.
  */
 int ONDEMAND_testindexed (Datastore_ServiceAPI * datastore,
-                          const HashCode512 * fileId);
+                          const GNUNET_HashCode * fileId);
 
 int ONDEMAND_init (CoreAPIForApplication * capi);
 

Modified: GNUnet/src/applications/fs/module/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/module/querymanager.c    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/querymanager.c    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -32,11 +32,11 @@
 #include "querymanager.h"
 
 
-#define DEBUG_QUERYMANAGER NO
+#define DEBUG_QUERYMANAGER GNUNET_NO
 
 typedef struct
 {
-  HashCode512 query;
+  GNUNET_HashCode query;
   unsigned int type;
   struct ClientHandle *client;
 } TrackRecord;
@@ -63,7 +63,7 @@
 /**
  * Mutex for all query manager structures.
  */
-static struct MUTEX *queryManagerLock;
+static struct GNUNET_Mutex *queryManagerLock;
 
 static CoreAPIForApplication *coreAPI;
 
@@ -73,24 +73,24 @@
 removeEntry (unsigned int off)
 {
   GE_ASSERT (ectx, off < trackerCount);
-  FREE (trackers[off]);
+  GNUNET_free (trackers[off]);
   if (stats != NULL)
     stats->change (stat_queries_tracked, -1);
   trackers[off] = trackers[--trackerCount];
   trackers[trackerCount] = NULL;
   if ((trackerSize > 64) && (trackerSize > 2 * trackerCount))
-    GROW (trackers, trackerSize, trackerSize / 2);
+    GNUNET_array_grow (trackers, trackerSize, trackerSize / 2);
 }
 
 static void
 ceh (struct ClientHandle *client)
 {
   int i;
-  MUTEX_LOCK (queryManagerLock);
+  GNUNET_mutex_lock (queryManagerLock);
   for (i = trackerCount - 1; i >= 0; i--)
     if (trackers[i]->client == client)
       removeEntry (i);
-  MUTEX_UNLOCK (queryManagerLock);
+  GNUNET_mutex_unlock (queryManagerLock);
 }
 
 /**
@@ -101,21 +101,21 @@
  * @param client where did the query come from?
  */
 void
-trackQuery (const HashCode512 * query,
+trackQuery (const GNUNET_HashCode * query,
             unsigned int type, struct ClientHandle *client)
 {
   GE_ASSERT (ectx, client != NULL);
-  MUTEX_LOCK (queryManagerLock);
+  GNUNET_mutex_lock (queryManagerLock);
   if (trackerSize == trackerCount)
-    GROW (trackers, trackerSize, trackerSize * 2);
-  trackers[trackerCount] = MALLOC (sizeof (TrackRecord));
+    GNUNET_array_grow (trackers, trackerSize, trackerSize * 2);
+  trackers[trackerCount] = GNUNET_malloc (sizeof (TrackRecord));
   trackers[trackerCount]->query = *query;
   trackers[trackerCount]->type = type;
   trackers[trackerCount]->client = client;
   trackerCount++;
   if (stats != NULL)
     stats->change (stat_queries_tracked, 1);
-  MUTEX_UNLOCK (queryManagerLock);
+  GNUNET_mutex_unlock (queryManagerLock);
 }
 
 /**
@@ -125,20 +125,20 @@
  * @param client where did the query come from?
  */
 void
-untrackQuery (const HashCode512 * query, struct ClientHandle *client)
+untrackQuery (const GNUNET_HashCode * query, struct ClientHandle *client)
 {
   int i;
 
-  MUTEX_LOCK (queryManagerLock);
+  GNUNET_mutex_lock (queryManagerLock);
   for (i = trackerCount - 1; i >= 0; i--)
     if ((trackers[i]->client == client) &&
-        (equalsHashCode512 (&trackers[i]->query, query)))
+        (0 == memcmp (&trackers[i]->query, query, sizeof (GNUNET_HashCode))))
       {
         removeEntry (i);
-        MUTEX_UNLOCK (queryManagerLock);
+        GNUNET_mutex_unlock (queryManagerLock);
         return;
       }
-  MUTEX_UNLOCK (queryManagerLock);
+  GNUNET_mutex_unlock (queryManagerLock);
 }
 
 /**
@@ -148,35 +148,36 @@
  * @param value the response
  */
 void
-processResponse (const HashCode512 * key, const Datastore_Value * value)
+processResponse (const GNUNET_HashCode * key, const Datastore_Value * value)
 {
   int i;
   CS_fs_reply_content_MESSAGE *rc;
   unsigned int matchCount;
 #if DEBUG_QUERYMANAGER
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   GE_ASSERT (ectx, ntohl (value->size) > sizeof (Datastore_Value));
-  if ((ntohll (value->expirationTime) < get_time ()) &&
+  if ((GNUNET_ntohll (value->expirationTime) < GNUNET_get_time ()) &&
       (ntohl (value->type) != D_BLOCK))
     return;                     /* ignore expired, non-data responses! */
 
   matchCount = 0;
 #if DEBUG_QUERYMANAGER
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (key, &enc));
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (key, &enc));
 #endif
-  MUTEX_LOCK (queryManagerLock);
+  GNUNET_mutex_lock (queryManagerLock);
   for (i = trackerCount - 1; i >= 0; i--)
     {
-      if ((equalsHashCode512 (&trackers[i]->query,
-                              key)) &&
+      if ((0 == memcmp (&trackers[i]->query,
+                        key, sizeof (GNUNET_HashCode))) &&
           ((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));
+          rc = GNUNET_malloc (sizeof (CS_fs_reply_content_MESSAGE) +
+                              ntohl (value->size) - sizeof (Datastore_Value));
           rc->header.size = htons (sizeof (CS_fs_reply_content_MESSAGE) +
                                    ntohl (value->size) -
                                    sizeof (Datastore_Value));
@@ -193,8 +194,8 @@
 #endif
           if (stats != NULL)
             stats->change (stat_replies_transmitted, 1);
-          coreAPI->sendToClient (trackers[i]->client, &rc->header, NO);
-          FREE (rc);
+          coreAPI->sendToClient (trackers[i]->client, &rc->header, GNUNET_NO);
+          GNUNET_free (rc);
         }
     }
 #if DEBUG_QUERYMANAGER && 0
@@ -205,7 +206,7 @@
               "Reply `%s' did not match any request.\n", &enc);
     }
 #endif
-  MUTEX_UNLOCK (queryManagerLock);
+  GNUNET_mutex_unlock (queryManagerLock);
 }
 
 /**
@@ -217,8 +218,8 @@
   coreAPI = capi;
   ectx = capi->ectx;
   capi->registerClientExitHandler (&ceh);
-  GROW (trackers, trackerSize, 64);
-  queryManagerLock = MUTEX_CREATE (NO);
+  GNUNET_array_grow (trackers, trackerSize, 64);
+  queryManagerLock = GNUNET_mutex_create (GNUNET_NO);
   stats = capi->requestService ("stats");
   if (stats != NULL)
     {
@@ -229,7 +230,7 @@
       stat_replies_transmitted =
         stats->create (gettext_noop ("# FS replies passed to clients"));
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 void
@@ -238,9 +239,9 @@
   int i;
 
   for (i = trackerCount - 1; i >= 0; i--)
-    FREE (trackers[i]);
+    GNUNET_free (trackers[i]);
 
-  GROW (trackers, trackerSize, 0);
+  GNUNET_array_grow (trackers, trackerSize, 0);
   trackerCount = 0;
   if (stats != NULL)
     {
@@ -250,7 +251,7 @@
     }
 
   coreAPI->unregisterClientExitHandler (&ceh);
-  MUTEX_DESTROY (queryManagerLock);
+  GNUNET_mutex_destroy (queryManagerLock);
   coreAPI = NULL;
   ectx = NULL;
 }

Modified: GNUnet/src/applications/fs/module/querymanager.h
===================================================================
--- GNUnet/src/applications/fs/module/querymanager.h    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/module/querymanager.h    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -45,7 +45,7 @@
  * @param msg the query
  * @param client where did the query come from?
  */
-void trackQuery (const HashCode512 * query,
+void trackQuery (const GNUNET_HashCode * query,
                  unsigned int type, struct ClientHandle *client);
 
 /**
@@ -54,7 +54,8 @@
  * @param msg the query
  * @param client where did the query come from?
  */
-void untrackQuery (const HashCode512 * query, struct ClientHandle *client);
+void untrackQuery (const GNUNET_HashCode * query,
+                   struct ClientHandle *client);
 
 /**
  * We received a reply from 'responder'.
@@ -62,6 +63,7 @@
  *
  * @param value the response
  */
-void processResponse (const HashCode512 * key, const Datastore_Value * value);
+void processResponse (const GNUNET_HashCode * key,
+                      const Datastore_Value * value);
 
 #endif

Modified: GNUnet/src/applications/fs/namespace/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/namespace/Makefile.am    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/namespace/Makefile.am    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -7,7 +7,6 @@
   namespace_info.c 
 libgnunetnamespace_la_LIBADD = \
  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 check_PROGRAMS = \
@@ -22,8 +21,6 @@
 namespace_infotest_LDADD = \
   $(top_builddir)/src/applications/fs/namespace/libgnunetnamespace.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 

Modified: GNUnet/src/applications/fs/namespace/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/namespace/namespace_info.c       2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/fs/namespace/namespace_info.c       2007-11-23 
11:51:54 UTC (rev 5742)
@@ -45,26 +45,26 @@
 
 static struct DiscoveryCallback *head;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * Internal notification about new tracked URI.
  */
 static void
 internal_notify (const char *name,
-                 const HashCode512 * id,
+                 const GNUNET_HashCode * id,
                  const struct ECRS_MetaData *md, int rating)
 {
   struct DiscoveryCallback *pos;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   pos = head;
   while (pos != NULL)
     {
       pos->callback (pos->closure, name, id, md, rating);
       pos = pos->next;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 static void
@@ -84,28 +84,28 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &fnBase);
-  fn = MALLOC (strlen (fnBase) +
-               strlen (NS_DIR) + strlen (namespaceName) + 6);
+  fn = GNUNET_malloc (strlen (fnBase) +
+                      strlen (NS_DIR) + strlen (namespaceName) + 6);
   strcpy (fn, fnBase);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, NS_DIR);
-  disk_directory_create (ectx, fn);
+  GNUNET_disk_directory_create (ectx, fn);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, namespaceName);
-  FREE (fnBase);
+  GNUNET_free (fnBase);
 
   size = ECRS_sizeofMetaData (meta, ECRS_SERIALIZE_FULL);
   tag = size + sizeof (int);
-  buf = MALLOC (tag);
+  buf = GNUNET_malloc (tag);
   ((int *) buf)[0] = htonl (ranking);   /* ranking */
   GE_ASSERT (ectx,
              size == ECRS_serializeMetaData (ectx,
                                              meta,
                                              &buf[sizeof (int)],
                                              size, ECRS_SERIALIZE_FULL));
-  disk_file_write (ectx, fn, buf, tag, "660");
-  FREE (fn);
-  FREE (buf);
+  GNUNET_disk_file_write (ectx, fn, buf, tag, "660");
+  GNUNET_free (fn);
+  GNUNET_free (buf);
 }
 
 static int
@@ -125,42 +125,42 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &fnBase);
-  fn = MALLOC (strlen (fnBase) +
-               strlen (NS_DIR) + strlen (namespaceName) + 6);
+  fn = GNUNET_malloc (strlen (fnBase) +
+                      strlen (NS_DIR) + strlen (namespaceName) + 6);
   strcpy (fn, fnBase);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, NS_DIR);
-  disk_directory_create (ectx, fn);
+  GNUNET_disk_directory_create (ectx, fn);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, namespaceName);
-  FREE (fnBase);
+  GNUNET_free (fnBase);
 
-  if ((OK != disk_file_test (ectx,
-                             fn) ||
-       (OK != disk_file_size (ectx, fn, &len, YES))))
+  if ((GNUNET_OK != GNUNET_disk_file_test (ectx,
+                                           fn) ||
+       (GNUNET_OK != GNUNET_disk_file_size (ectx, fn, &len, GNUNET_YES))))
     {
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
   if (len <= sizeof (int))
     {
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
   if (len > 16 * 1024 * 1024)
     {
       /* too big, must be invalid! remove! */
       GE_BREAK (ectx, 0);
       UNLINK (fn);
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
-  buf = MALLOC (len);
-  if (len != disk_file_read (ectx, fn, len, buf))
+  buf = GNUNET_malloc (len);
+  if (len != GNUNET_disk_file_read (ectx, fn, len, buf))
     {
-      FREE (buf);
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (buf);
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
 
   size = len - sizeof (int);
@@ -171,13 +171,13 @@
       /* invalid data! remove! */
       GE_BREAK (ectx, 0);
       UNLINK (fn);
-      FREE (buf);
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (buf);
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
-  FREE (fn);
-  FREE (buf);
-  return OK;
+  GNUNET_free (fn);
+  GNUNET_free (buf);
+  return GNUNET_OK;
 }
 
 
@@ -194,11 +194,11 @@
                     struct GC_Configuration *cfg,
                     unsigned int anonymityLevel,
                     unsigned int insertPriority,
-                    cron_t insertExpiration,
+                    GNUNET_CronTime insertExpiration,
                     const char *namespaceName,
                     const struct ECRS_MetaData *meta,
                     const struct ECRS_URI *advertisementURI,
-                    const HashCode512 * rootEntry)
+                    const GNUNET_HashCode * rootEntry)
 {
   struct ECRS_URI *ret;
 
@@ -212,7 +212,7 @@
   /* store binding of namespaceName to 'meta' in state DB! */
   if (ret != NULL)
     {
-      HashCode512 id;
+      GNUNET_HashCode id;
       char *name;
 
       NS_setNamespaceRoot (ectx, cfg, ret);
@@ -220,7 +220,7 @@
       name = ECRS_getNamespaceName (&id);
       writeNamespaceInfo (ectx, cfg, name, meta, 0);
       internal_notify (namespaceName, &id, meta, 0);
-      FREE (name);
+      GNUNET_free (name);
     }
   return ret;
 }
@@ -229,7 +229,7 @@
 /**
  * Delete a local namespace.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
 NS_deleteNamespace (struct GE_Context *ectx,
@@ -244,16 +244,16 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &tmp);
-  fn = MALLOC (strlen (tmp) + strlen (NS_UPDATE_DIR) +
-               strlen (namespaceName) + 20);
+  fn = GNUNET_malloc (strlen (tmp) + strlen (NS_UPDATE_DIR) +
+                      strlen (namespaceName) + 20);
   strcpy (fn, tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, NS_UPDATE_DIR);
   strcat (fn, namespaceName);
   strcat (fn, DIR_SEPARATOR_STR);
-  disk_directory_remove (ectx, fn);
-  FREE (fn);
+  GNUNET_disk_directory_remove (ectx, fn);
+  GNUNET_free (fn);
   return ret;
 }
 
@@ -277,7 +277,7 @@
   int ranking;
 
   ret = readNamespaceInfo (ectx, cfg, ns, &meta, &ranking);
-  if (ret == SYSERR)
+  if (ret == GNUNET_SYSERR)
     {
       ranking = 0;
       meta = ECRS_createMetaData ();
@@ -297,7 +297,7 @@
 } LNClosure;
 
 static int
-localListNamespaceHelper (const HashCode512 * nsid,
+localListNamespaceHelper (const GNUNET_HashCode * nsid,
                           const char *name, void *cls)
 {
   LNClosure *c = cls;
@@ -315,7 +315,7 @@
       ret = c->iterator (c->closure, name, nsid, meta, rating);
     }
   else
-    ret = OK;
+    ret = GNUNET_OK;
   ECRS_freeMetaData (meta);
   return ret;
 }
@@ -327,20 +327,20 @@
   int ret;
   struct ECRS_MetaData *meta;
   int rating;
-  HashCode512 id;
+  GNUNET_HashCode id;
 
-  if (OK != enc2hash (fn, &id))
-    return OK;                  /* invalid name */
-  if (OK != readNamespaceInfo (c->ectx, c->cfg, fn, &meta, &rating))
-    return OK;                  /* ignore entry */
+  if (GNUNET_OK != GNUNET_enc_to_hash (fn, &id))
+    return GNUNET_OK;           /* invalid name */
+  if (GNUNET_OK != readNamespaceInfo (c->ectx, c->cfg, fn, &meta, &rating))
+    return GNUNET_OK;           /* ignore entry */
   if (c->iterator != NULL)
     {
       ret = c->iterator (c->closure, fn, &id, meta, rating);
     }
   else
-    ret = OK;
+    ret = GNUNET_OK;
   ECRS_freeMetaData (meta);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -369,14 +369,14 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &fnBase);
-  fn = MALLOC (strlen (fnBase) + strlen (NS_DIR) + 4);
+  fn = GNUNET_malloc (strlen (fnBase) + strlen (NS_DIR) + 4);
   strcpy (fn, fnBase);
-  FREE (fnBase);
+  GNUNET_free (fnBase);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, NS_DIR);
-  disk_directory_create (ectx, fn);
-  ret2 = disk_directory_scan (ectx, fn, &listNamespaceHelper, &cls);
-  FREE (fn);
+  GNUNET_disk_directory_create (ectx, fn);
+  ret2 = GNUNET_disk_directory_scan (ectx, fn, &listNamespaceHelper, &cls);
+  GNUNET_free (fn);
   if (ret2 == -1)
     return ret2;
   return ret1 + ret2;
@@ -390,7 +390,7 @@
 static char *
 getUpdateDataFilename (struct GE_Context *ectx,
                        struct GC_Configuration *cfg,
-                       const char *nsname, const HashCode512 * lastId)
+                       const char *nsname, const GNUNET_HashCode * lastId)
 {
   char *tmp;
   char *ret;
@@ -399,20 +399,20 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &tmp);
-  ret = MALLOC (strlen (tmp) + strlen (NS_UPDATE_DIR) +
-                strlen (nsname) + sizeof (EncName) + 20);
+  ret = GNUNET_malloc (strlen (tmp) + strlen (NS_UPDATE_DIR) +
+                       strlen (nsname) + sizeof (GNUNET_EncName) + 20);
   strcpy (ret, tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   strcat (ret, DIR_SEPARATOR_STR);
   strcat (ret, NS_UPDATE_DIR);
   strcat (ret, nsname);
   strcat (ret, DIR_SEPARATOR_STR);
-  disk_directory_create (ectx, ret);
+  GNUNET_disk_directory_create (ectx, ret);
   if (lastId != NULL)
     {
-      EncName enc;
+      GNUNET_EncName enc;
 
-      hash2enc (lastId, &enc);
+      GNUNET_hash_to_enc (lastId, &enc);
       strcat (ret, (char *) &enc);
     }
   return ret;
@@ -420,10 +420,10 @@
 
 struct UpdateData
 {
-  TIME_T updateInterval;
-  TIME_T lastPubTime;
-  HashCode512 nextId;
-  HashCode512 thisId;
+  GNUNET_Int32Time updateInterval;
+  GNUNET_Int32Time lastPubTime;
+  GNUNET_HashCode nextId;
+  GNUNET_HashCode thisId;
 };
 
 /**
@@ -431,16 +431,17 @@
  * published in the given namespace under 'lastId'.
  *
  * @param fi maybe NULL
- * @return OK if update data was found, SYSERR if not.
+ * @return GNUNET_OK if update data was found, GNUNET_SYSERR if not.
  */
 static int
 readUpdateData (struct GE_Context *ectx,
                 struct GC_Configuration *cfg,
                 const char *nsname,
-                const HashCode512 * lastId,
-                HashCode512 * nextId,
+                const GNUNET_HashCode * lastId,
+                GNUNET_HashCode * nextId,
                 ECRS_FileInfo * fi,
-                TIME_T * updateInterval, TIME_T * lastPubTime)
+                GNUNET_Int32Time * updateInterval,
+                GNUNET_Int32Time * lastPubTime)
 {
   char *fn;
   struct UpdateData *buf;
@@ -449,30 +450,30 @@
   size_t pos;
 
   fn = getUpdateDataFilename (ectx, cfg, nsname, lastId);
-  if (OK != disk_file_size (ectx, fn, &size, YES))
+  if (GNUNET_OK != GNUNET_disk_file_size (ectx, fn, &size, GNUNET_YES))
     {
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
   if ((size == 0) ||
       (size <= sizeof (struct UpdateData)) || (size > 1024 * 1024 * 16))
     {
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
 
-  buf = MALLOC (size);
-  if (size != disk_file_read (ectx, fn, size, buf))
+  buf = GNUNET_malloc (size);
+  if (size != GNUNET_disk_file_read (ectx, fn, size, buf))
     {
-      FREE (buf);
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (buf);
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
-  FREE (fn);
-  if (!equalsHashCode512 (lastId, &buf->thisId))
+  GNUNET_free (fn);
+  if (0 != memcmp (lastId, &buf->thisId, sizeof (GNUNET_HashCode)))
     {
-      FREE (buf);
-      return SYSERR;
+      GNUNET_free (buf);
+      return GNUNET_SYSERR;
     }
   uri = (char *) &buf[1];
   size -= sizeof (struct UpdateData);
@@ -483,27 +484,27 @@
   size -= pos;
   if (size == 0)
     {
-      FREE (buf);
+      GNUNET_free (buf);
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (fi != NULL)
     {
       fi->meta = ECRS_deserializeMetaData (ectx, &uri[pos], size);
       if (fi->meta == NULL)
         {
-          FREE (buf);
+          GNUNET_free (buf);
           GE_BREAK (ectx, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       fi->uri = ECRS_stringToUri (ectx, uri);
       if (fi->uri == NULL)
         {
           ECRS_freeMetaData (fi->meta);
           fi->meta = NULL;
-          FREE (buf);
+          GNUNET_free (buf);
           GE_BREAK (ectx, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
   if (updateInterval != NULL)
@@ -512,8 +513,8 @@
     *lastPubTime = ntohl (buf->lastPubTime);
   if (nextId != NULL)
     *nextId = buf->nextId;
-  FREE (buf);
-  return OK;
+  GNUNET_free (buf);
+  return GNUNET_OK;
 }
 
 /**
@@ -523,10 +524,11 @@
 writeUpdateData (struct GE_Context *ectx,
                  struct GC_Configuration *cfg,
                  const char *nsname,
-                 const HashCode512 * thisId,
-                 const HashCode512 * nextId,
+                 const GNUNET_HashCode * thisId,
+                 const GNUNET_HashCode * nextId,
                  const ECRS_FileInfo * fi,
-                 const TIME_T updateInterval, const TIME_T lastPubTime)
+                 const GNUNET_Int32Time updateInterval,
+                 const GNUNET_Int32Time lastPubTime)
 {
   char *fn;
   char *uri;
@@ -537,7 +539,7 @@
   uri = ECRS_uriToString (fi->uri);
   metaSize = ECRS_sizeofMetaData (fi->meta, ECRS_SERIALIZE_FULL);
   size = sizeof (struct UpdateData) + metaSize + strlen (uri) + 1;
-  buf = MALLOC (size);
+  buf = GNUNET_malloc (size);
   buf->nextId = *nextId;
   buf->thisId = *thisId;
   buf->updateInterval = htonl (updateInterval);
@@ -549,12 +551,12 @@
                                      fi->meta,
                                      &((char *) &buf[1])[strlen (uri) + 1],
                                      metaSize, ECRS_SERIALIZE_FULL));
-  FREE (uri);
+  GNUNET_free (uri);
   fn = getUpdateDataFilename (ectx, cfg, nsname, thisId);
-  disk_file_write (ectx, fn, buf, size, "400"); /* no editing, just deletion */
-  FREE (fn);
-  FREE (buf);
-  return OK;
+  GNUNET_disk_file_write (ectx, fn, buf, size, "400");  /* no editing, just 
deletion */
+  GNUNET_free (fn);
+  GNUNET_free (buf);
+  return GNUNET_OK;
 }
 
 
@@ -562,39 +564,40 @@
  * Compute the next ID for peridodically updated content.
  * @param updateInterval MUST be a peridic interval (not NONE or SPORADIC)
  * @param thisId MUST be known to NAMESPACE
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_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)
+                  const GNUNET_HashCode * lastId,
+                  const GNUNET_HashCode * thisId,
+                  GNUNET_Int32Time updateInterval, GNUNET_HashCode * nextId)
 {
-  HashCode512 delta;
-  cron_t now;
-  TIME_T tnow;
-  TIME_T lastTime;
-  TIME_T ui;
+  GNUNET_HashCode delta;
+  GNUNET_CronTime now;
+  GNUNET_Int32Time tnow;
+  GNUNET_Int32Time lastTime;
+  GNUNET_Int32Time ui;
 
   if ((updateInterval == ECRS_SBLOCK_UPDATE_SPORADIC) ||
       (updateInterval == ECRS_SBLOCK_UPDATE_NONE))
-    return SYSERR;
+    return GNUNET_SYSERR;
 
-  if (OK != readUpdateData (ectx,
-                            cfg, name, lastId, NULL, NULL, &ui, &lastTime))
-    return SYSERR;
-  deltaId (lastId, thisId, &delta);
-  now = get_time ();
-  TIME (&tnow);
+  if (GNUNET_OK != readUpdateData (ectx,
+                                   cfg, name, lastId, NULL, NULL, &ui,
+                                   &lastTime))
+    return GNUNET_SYSERR;
+  GNUNET_hash_difference (lastId, thisId, &delta);
+  now = GNUNET_get_time ();
+  GNUNET_get_time_int32 (&tnow);
   *nextId = *thisId;
   while (lastTime < tnow + updateInterval / 2)
     {
       lastTime += updateInterval;
-      addHashCodes (nextId, &delta, nextId);
+      GNUNET_hash_sum (nextId, &delta, nextId);
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -617,20 +620,20 @@
                    struct GC_Configuration *cfg,
                    unsigned int anonymityLevel,
                    unsigned int insertPriority,
-                   cron_t insertExpiration,
+                   GNUNET_CronTime insertExpiration,
                    const char *name,
-                   TIME_T updateInterval,
-                   const HashCode512 * lastId,
-                   const HashCode512 * thisId,
-                   const HashCode512 * nextId,
+                   GNUNET_Int32Time updateInterval,
+                   const GNUNET_HashCode * lastId,
+                   const GNUNET_HashCode * thisId,
+                   const GNUNET_HashCode * nextId,
                    const struct ECRS_URI *dst, const struct ECRS_MetaData *md)
 {
-  TIME_T creationTime;
-  HashCode512 nid;
-  HashCode512 tid;
-  TIME_T now;
-  TIME_T lastTime;
-  TIME_T lastInterval;
+  GNUNET_Int32Time creationTime;
+  GNUNET_HashCode nid;
+  GNUNET_HashCode tid;
+  GNUNET_Int32Time now;
+  GNUNET_Int32Time lastTime;
+  GNUNET_Int32Time lastInterval;
   ECRS_FileInfo fi;
   char *old;
   struct ECRS_URI *uri;
@@ -638,15 +641,16 @@
   /* computation of IDs of update(s).  Not as terrible as
      it looks, just enumerating all of the possible cases
      of periodic/sporadic updates and how IDs are computed. */
-  creationTime = TIME (&now);
+  creationTime = GNUNET_get_time_int32 (&now);
   if (updateInterval != ECRS_SBLOCK_UPDATE_NONE)
     {
       if ((lastId != NULL) &&
-          (OK == readUpdateData (ectx,
-                                 cfg,
-                                 name,
-                                 lastId,
-                                 &tid, NULL, &lastInterval, &lastTime)))
+          (GNUNET_OK == readUpdateData (ectx,
+                                        cfg,
+                                        name,
+                                        lastId,
+                                        &tid, NULL, &lastInterval,
+                                        &lastTime)))
         {
           if (lastInterval != updateInterval)
             {
@@ -659,17 +663,17 @@
 
           if (updateInterval != ECRS_SBLOCK_UPDATE_SPORADIC)
             {
-              HashCode512 delta;
+              GNUNET_HashCode delta;
 
-              deltaId (lastId, &tid, &delta);
+              GNUNET_hash_difference (lastId, &tid, &delta);
 
               creationTime = lastTime + updateInterval;
               while (creationTime < now - updateInterval)
                 {
                   creationTime += updateInterval;
-                  addHashCodes (&tid, &delta, &tid);
+                  GNUNET_hash_sum (&tid, &delta, &tid);
                 }
-              if (creationTime > get_time () + 7 * cronDAYS)
+              if (creationTime > GNUNET_get_time () + 7 * GNUNET_CRON_DAYS)
                 {
                   GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
                           _("Publishing update for periodically updated "
@@ -677,7 +681,7 @@
                 }
               if (thisId != NULL)
                 tid = *thisId;  /* allow override! */
-              addHashCodes (&tid, &delta, &nid);
+              GNUNET_hash_sum (&tid, &delta, &nid);
               if (nextId != NULL)
                 nid = *nextId;  /* again, allow override */
             }
@@ -690,7 +694,7 @@
                 tid = *thisId;  /* allow user override */
               if (nextId == NULL)
                 {
-                  makeRandomId (&nid);
+                  GNUNET_create_random_hash (&nid);
                 }
               else
                 {
@@ -704,7 +708,7 @@
             {
               /* no previous block found and nextId not specified;
                  pick random nid */
-              makeRandomId (&nid);
+              GNUNET_create_random_hash (&nid);
             }
           else
             {
@@ -716,7 +720,7 @@
             }
           else
             {
-              makeRandomId (&tid);
+              GNUNET_create_random_hash (&tid);
             }
         }
     }
@@ -728,7 +732,7 @@
         }
       else
         {
-          makeRandomId (&tid);
+          GNUNET_create_random_hash (&tid);
           nid = tid;
         }
     }
@@ -752,7 +756,7 @@
         {
           old = getUpdateDataFilename (ectx, cfg, name, lastId);
           UNLINK (old);
-          FREE (old);
+          GNUNET_free (old);
         }
     }
   return uri;
@@ -773,27 +777,28 @@
 {
   struct lNCC *cls = ptr;
   ECRS_FileInfo fi;
-  HashCode512 lastId;
-  HashCode512 nextId;
-  TIME_T pubFreq;
-  TIME_T lastTime;
-  TIME_T nextTime;
-  TIME_T now;
+  GNUNET_HashCode lastId;
+  GNUNET_HashCode nextId;
+  GNUNET_Int32Time pubFreq;
+  GNUNET_Int32Time lastTime;
+  GNUNET_Int32Time nextTime;
+  GNUNET_Int32Time now;
 
-  if (OK != enc2hash (fil, &lastId))
+  if (GNUNET_OK != GNUNET_enc_to_hash (fil, &lastId))
     {
       GE_BREAK (cls->ectx, 0);
-      return OK;
+      return GNUNET_OK;
     }
   fi.uri = NULL;
   fi.meta = NULL;
-  if (OK != readUpdateData (cls->ectx,
-                            cls->cfg,
-                            cls->name,
-                            &lastId, &nextId, &fi, &pubFreq, &lastTime))
+  if (GNUNET_OK != readUpdateData (cls->ectx,
+                                   cls->cfg,
+                                   cls->name,
+                                   &lastId, &nextId, &fi, &pubFreq,
+                                   &lastTime))
     {
       GE_BREAK (cls->ectx, 0);
-      return OK;
+      return GNUNET_OK;
     }
   cls->cnt++;
   if (pubFreq == ECRS_SBLOCK_UPDATE_SPORADIC)
@@ -802,24 +807,24 @@
     }
   else
     {
-      TIME (&now);
+      GNUNET_get_time_int32 (&now);
       nextTime = lastTime;
       if ((nextTime + pubFreq < now) && (nextTime + pubFreq > nextTime))
         nextTime += pubFreq * ((now - nextTime) / pubFreq);
     }
   if (cls->it != NULL)
     {
-      if (OK != cls->it (cls->closure,
-                         &fi, &lastId, &nextId, pubFreq, nextTime))
+      if (GNUNET_OK != cls->it (cls->closure,
+                                &fi, &lastId, &nextId, pubFreq, nextTime))
         {
           ECRS_freeUri (fi.uri);
           ECRS_freeMetaData (fi.meta);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
   ECRS_freeUri (fi.uri);
   ECRS_freeMetaData (fi.meta);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -841,13 +846,14 @@
   cls.ectx = ectx;
   cls.cfg = cfg;
   dirName = getUpdateDataFilename (ectx, cfg, name, NULL);
-  disk_directory_create (ectx, dirName);
-  if (SYSERR == disk_directory_scan (ectx, dirName, &lNCHelper, &cls))
+  GNUNET_disk_directory_create (ectx, dirName);
+  if (GNUNET_SYSERR ==
+      GNUNET_disk_directory_scan (ectx, dirName, &lNCHelper, &cls))
     {
-      FREE (dirName);
-      return SYSERR;
+      GNUNET_free (dirName);
+      return GNUNET_SYSERR;
     }
-  FREE (dirName);
+  GNUNET_free (dirName);
   return cls.cnt;
 }
 
@@ -856,7 +862,7 @@
 {
   struct ECRS_MetaData *meta = cls;
   ECRS_addToMetaData (meta, type, data);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -875,7 +881,7 @@
   char *name;
   int ranking;
   struct ECRS_MetaData *old;
-  HashCode512 id;
+  GNUNET_HashCode id;
 
   if (!ECRS_isNamespaceUri (uri))
     {
@@ -890,7 +896,7 @@
       return;
     }
   ranking = 0;
-  if (OK == readNamespaceInfo (ectx, cfg, name, &old, &ranking))
+  if (GNUNET_OK == readNamespaceInfo (ectx, cfg, name, &old, &ranking))
     {
       ECRS_getMetaData (meta, &mergeMeta, old);
       writeNamespaceInfo (ectx, cfg, name, old, ranking);
@@ -901,18 +907,18 @@
       writeNamespaceInfo (ectx, cfg, name, meta, ranking);
     }
   internal_notify (name, &id, meta, ranking);
-  FREE (name);
+  GNUNET_free (name);
 }
 
 
 /**
  * Get the root of the namespace (if we have one).
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int
 NS_getNamespaceRoot (struct GE_Context *ectx,
                      struct GC_Configuration *cfg,
-                     const char *ns, HashCode512 * root)
+                     const char *ns, GNUNET_HashCode * root)
 {
   char *fn;
   char *fnBase;
@@ -922,20 +928,20 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &fnBase);
-  fn = MALLOC (strlen (fnBase) + strlen (NS_ROOTS) + strlen (ns) + 6);
+  fn = GNUNET_malloc (strlen (fnBase) + strlen (NS_ROOTS) + strlen (ns) + 6);
   strcpy (fn, fnBase);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, NS_ROOTS);
-  disk_directory_create (ectx, fn);
+  GNUNET_disk_directory_create (ectx, fn);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, ns);
-  FREE (fnBase);
-  if (sizeof (HashCode512)
-      == disk_file_read (ectx, fn, sizeof (HashCode512), root))
-    ret = OK;
+  GNUNET_free (fnBase);
+  if (sizeof (GNUNET_HashCode)
+      == GNUNET_disk_file_read (ectx, fn, sizeof (GNUNET_HashCode), root))
+    ret = GNUNET_OK;
   else
-    ret = SYSERR;
-  FREE (fn);
+    ret = GNUNET_SYSERR;
+  GNUNET_free (fn);
   return ret;
 }
 
@@ -945,10 +951,10 @@
 {
   char *fn;
   char *fnBase;
-  HashCode512 ns;
+  GNUNET_HashCode ns;
   char *name;
 
-  if (OK != ECRS_getNamespaceId (uri, &ns))
+  if (GNUNET_OK != ECRS_getNamespaceId (uri, &ns))
     {
       GE_BREAK (ectx, 0);
       return;
@@ -958,20 +964,21 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &fnBase);
-  fn = MALLOC (strlen (fnBase) + strlen (NS_ROOTS) + strlen (name) + 6);
+  fn =
+    GNUNET_malloc (strlen (fnBase) + strlen (NS_ROOTS) + strlen (name) + 6);
   strcpy (fn, fnBase);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, NS_ROOTS);
-  disk_directory_create (ectx, fn);
+  GNUNET_disk_directory_create (ectx, fn);
   strcat (fn, DIR_SEPARATOR_STR);
   strcat (fn, name);
-  FREE (name);
-  FREE (fnBase);
-  if (OK == ECRS_getSKSContentHash (uri, &ns))
+  GNUNET_free (name);
+  GNUNET_free (fnBase);
+  if (GNUNET_OK == ECRS_getSKSContentHash (uri, &ns))
     {
-      disk_file_write (ectx, fn, &ns, sizeof (HashCode512), "644");
+      GNUNET_disk_file_write (ectx, fn, &ns, sizeof (GNUNET_HashCode), "644");
     }
-  FREE (fn);
+  GNUNET_free (fn);
 }
 
 /**
@@ -985,15 +992,15 @@
 {
   struct DiscoveryCallback *list;
 
-  list = MALLOC (sizeof (struct DiscoveryCallback));
+  list = GNUNET_malloc (sizeof (struct DiscoveryCallback));
   list->callback = iterator;
   list->closure = closure;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   list->next = head;
   head = list;
   NS_listNamespaces (ectx, cfg, iterator, closure);
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -1006,7 +1013,7 @@
   struct DiscoveryCallback *pos;
 
   prev = NULL;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   pos = head;
   while ((pos != NULL) &&
          ((pos->callback != iterator) || (pos->closure != closure)))
@@ -1016,27 +1023,27 @@
     }
   if (pos == NULL)
     {
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   if (prev == NULL)
     head = pos->next;
   else
     prev->next = pos->next;
-  FREE (pos);
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_free (pos);
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 
 void __attribute__ ((constructor)) gnunet_namespace_ltdl_init ()
 {
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
 }
 
 void __attribute__ ((destructor)) gnunet_namespace_ltdl_fini ()
 {
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
 }
 

Modified: GNUnet/src/applications/fs/namespace/namespace_infotest.c
===================================================================
--- GNUnet/src/applications/fs/namespace/namespace_infotest.c   2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/fs/namespace/namespace_infotest.c   2007-11-23 
11:51:54 UTC (rev 5742)
@@ -33,7 +33,7 @@
 #include "gnunet_util_crypto.h"
 #include "gnunet_util_network_client.h"
 
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GE_BREAK(ectx, 0); goto FAILURE; }
 
 static struct GE_Context *ectx;
 
@@ -45,35 +45,37 @@
   struct ECRS_URI *uri = NULL;
   struct ECRS_URI *euri = NULL;
   struct ECRS_MetaData *meta = NULL;
-  HashCode512 root;
+  GNUNET_HashCode root;
   int old;
   int newVal;
   struct GC_Configuration *cfg;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
-  daemon = os_daemon_start (NULL, cfg, "peer.conf", NO);
+  daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GE_ASSERT (NULL, daemon > 0);
-  CHECK (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS));
-  ok = YES;
+  CHECK (GNUNET_OK ==
+         GNUNET_wait_for_daemon_running (NULL, cfg,
+                                         30 * GNUNET_CRON_SECONDS));
+  ok = GNUNET_YES;
   NS_deleteNamespace (ectx, cfg, "test");
-  PTHREAD_SLEEP (5 * cronSECONDS);      /* give apps time to start */
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);        /* give apps time to 
start */
 
   /* ACTUAL TEST CODE */
   old = NS_listNamespaces (ectx, cfg, NULL, NULL);
 
   meta = ECRS_createMetaData ();
   ECRS_addToMetaData (meta, 0, "test");
-  makeRandomId (&root);
+  GNUNET_create_random_hash (&root);
   uri = NS_createNamespace (ectx,
                             cfg,
                             1,
                             1,
-                            get_time () + 10 * cronMINUTES,
+                            GNUNET_get_time () + 10 * GNUNET_CRON_MINUTES,
                             "test", meta, NULL, &root);
   CHECK (uri != NULL);
   newVal = NS_listNamespaces (ectx, cfg, NULL, NULL);
@@ -83,12 +85,12 @@
                             cfg,
                             1,
                             1,
-                            get_time () + 10 * cronMINUTES,
+                            GNUNET_get_time () + 10 * GNUNET_CRON_MINUTES,
                             "test", 42, NULL, &root, NULL, uri, meta);
   CHECK (euri != NULL);
   newVal = NS_listNamespaceContent (ectx, cfg, "test", NULL, NULL);
   CHECK (old < newVal);
-  CHECK (OK == NS_deleteNamespace (ectx, cfg, "test"));
+  CHECK (GNUNET_OK == NS_deleteNamespace (ectx, cfg, "test"));
   /* END OF TEST CODE */
 FAILURE:
   if (uri != NULL)
@@ -99,9 +101,9 @@
     ECRS_freeMetaData (meta);
   ECRS_deleteNamespace (ectx, cfg, "test");
 
-  GE_ASSERT (NULL, OK == os_daemon_stop (NULL, daemon));
+  GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
   GC_free (cfg);
-  return (ok == YES) ? 0 : 1;
+  return (ok == GNUNET_YES) ? 0 : 1;
 }
 
 /* end of namespace_infotest.c */

Modified: GNUnet/src/applications/fs/tools/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/tools/Makefile.am        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/tools/Makefile.am        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -4,7 +4,6 @@
   $(top_builddir)/src/applications/fs/uritrack/libgnuneturitrack.la \
   $(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
 bin_PROGRAMS = \
@@ -28,7 +27,6 @@
 gnunet_directory_LDADD = \
   $(top_builddir)/src/applications/fs/uritrack/libgnuneturitrack.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
 
@@ -39,7 +37,6 @@
   $(top_builddir)/src/applications/fs/uritrack/libgnuneturitrack.la \
   $(top_builddir)/src/applications/fs/collection/libgnunetcollection.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
 gnunet_search_SOURCES = \

Modified: GNUnet/src/applications/fs/tools/gnunet-directory.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-directory.c 2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/tools/gnunet-directory.c 2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -30,7 +30,7 @@
 #include "gnunet_directories.h"
 #include "gnunet_ecrs_lib.h"
 #include "gnunet_uritrack_lib.h"
-#include "gnunet_util_boot.h"
+#include "gnunet_util.h"
 
 static char *cfgFilename = DEFAULT_CLIENT_CONFIG_FILE;
 
@@ -48,7 +48,7 @@
   printf ("\t%20s: %s\n",
           dgettext ("libextractor",
                     EXTRACTOR_getKeywordTypeAsString (type)), data);
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
@@ -59,15 +59,15 @@
 
 static int
 printNode (const ECRS_FileInfo * fi,
-           const HashCode512 * key, int isRoot, void *unused)
+           const GNUNET_HashCode * key, int isRoot, void *unused)
 {
   char *string;
 
   string = ECRS_uriToString (fi->uri);
   printf ("%s:\n", string);
-  FREE (string);
+  GNUNET_free (string);
   printMeta (fi->meta);
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
@@ -80,16 +80,17 @@
   char *name;
   int fd;
 
-  name = string_expandFileName (ectx, filename);
+  name = GNUNET_expand_file_name (ectx, filename);
   printf (_("==> Directory `%s':\n"), name);
-  if ((OK != disk_file_size (ectx, name, &len, YES)) || (len == 0))
+  if ((GNUNET_OK != GNUNET_disk_file_size (ectx, name, &len, GNUNET_YES))
+      || (len == 0))
     {
       printf (_("=\tError reading directory.\n"));
-      FREE (name);
+      GNUNET_free (name);
       return;
     }
   md = NULL;
-  fd = disk_file_open (ectx, name, O_LARGEFILE | O_RDONLY);
+  fd = GNUNET_disk_file_open (ectx, name, O_LARGEFILE | O_RDONLY);
   if (fd == -1)
     {
       ret = -1;
@@ -120,29 +121,29 @@
       ECRS_freeMetaData (md);
     }
   printf ("\n");
-  FREE (name);
+  GNUNET_free (name);
 }
 
 /**
  * All gnunet-directory command line options
  */
-static struct CommandLineOption gnunetdirectoryOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Perform directory related 
operations.")),    /* -h */
+static struct GNUNET_CommandLineOption gnunetdirectoryOptions[] = {
+       GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+       GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Perform directory 
related operations.")),    /* -h */
   {'k', "kill", NULL,
    gettext_noop
    ("remove all entries from the directory database and stop tracking URIs"),
-   0, &gnunet_getopt_configure_set_one, &do_kill},
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+   0, &GNUNET_getopt_configure_set_one, &do_kill},
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'l', "list", NULL,
    gettext_noop ("list entries from the directory database"),
-   0, &gnunet_getopt_configure_set_one, &do_list},
+   0, &GNUNET_getopt_configure_set_one, &do_list},
   {'t', "track", NULL,
    gettext_noop ("start tracking entries for the directory database"),
-   0, &gnunet_getopt_configure_set_one, &do_track},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+   0, &GNUNET_getopt_configure_set_one, &do_track},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 int
@@ -162,14 +163,14 @@
     }
   if (do_list)
     printf (_("Listed %d matching entries.\n"),
-            URITRACK_listURIs (ectx, cfg, YES, &printNode, NULL));
+            URITRACK_listURIs (ectx, cfg, GNUNET_YES, &printNode, NULL));
   if (do_kill)
     {
-      URITRACK_trackURIS (ectx, cfg, NO);
+      URITRACK_trackURIS (ectx, cfg, GNUNET_NO);
       URITRACK_clearTrackedURIS (ectx, cfg);
     }
   if (do_track)
-    URITRACK_trackURIS (ectx, cfg, YES);
+    URITRACK_trackURIS (ectx, cfg, GNUNET_YES);
 
   while (i < argc)
     printDirectory (argv[i++]);

Modified: GNUnet/src/applications/fs/tools/gnunet-download.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-download.c  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -27,7 +27,7 @@
 #include "platform.h"
 #include "gnunet_directories.h"
 #include "gnunet_fsui_lib.h"
-#include "gnunet_util_boot.h"
+#include "gnunet_util.h"
 
 static struct GE_Context *ectx;
 
@@ -47,7 +47,7 @@
 
 static unsigned int parallelism = 32;
 
-static cron_t start_time;
+static GNUNET_CronTime start_time;
 
 static struct FSUI_DownloadList *dl;
 
@@ -59,36 +59,36 @@
 
 static unsigned int downloads_size;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * All gnunet-download command line options
  */
-static struct CommandLineOption gnunetdownloadOptions[] = {
+static struct GNUNET_CommandLineOption gnunetdownloadOptions[] = {
   {'a', "anonymity", "LEVEL",
    gettext_noop ("set the desired LEVEL of sender-anonymity"),
-   1, &gnunet_getopt_configure_set_uint, &anonymity},
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+   1, &GNUNET_getopt_configure_set_uint, &anonymity},
+   GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
   {'d', "directory", NULL,
    gettext_noop
    ("download a GNUnet directory that has already been downloaded.  Requires 
that a filename of an existing file is specified instead of the URI.  The 
download will only download the top-level files in the directory unless the 
`-R' option is also specified."),
-   0, &gnunet_getopt_configure_set_one, &do_directory},
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Download files from GNUnet.")),     
 /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+   0, &GNUNET_getopt_configure_set_one, &do_directory},
+   GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Download files from 
GNUnet.")),      /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'o', "output", "FILENAME",
    gettext_noop ("write the file to FILENAME"),
-   1, &gnunet_getopt_configure_set_string, &filename},
+   1, &GNUNET_getopt_configure_set_string, &filename},
   {'p', "parallelism", "DOWNLOADS",
    gettext_noop
    ("set the maximum number of parallel downloads that are allowed"),
-   1, &gnunet_getopt_configure_set_uint, &parallelism},
+   1, &GNUNET_getopt_configure_set_uint, &parallelism},
   {'R', "recursive", NULL,
    gettext_noop ("download a GNUnet directory recursively"),
-   0, &gnunet_getopt_configure_set_one, &do_recursive},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+   0, &GNUNET_getopt_configure_set_one, &do_recursive},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 /**
@@ -99,7 +99,7 @@
 static void *
 progressModel (void *unused, const FSUI_Event * event)
 {
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   switch (event->type)
     {
     case FSUI_download_progress:
@@ -111,8 +111,8 @@
                   event->data.DownloadProgress.completed,
                   event->data.DownloadProgress.total,
                   (event->data.DownloadProgress.completed / 1024.0) /
-                  (((double) (get_time () - (start_time - 1)))
-                   / (double) cronSECONDS));
+                  (((double) (GNUNET_get_time () - (start_time - 1)))
+                   / (double) GNUNET_CRON_SECONDS));
         }
       break;
     case FSUI_download_aborted:
@@ -121,45 +121,46 @@
           /* top-download aborted */
           printf (_("Download aborted.\n"));
           errorCode = 2;
-          GNUNET_SHUTDOWN_INITIATE ();
+          GNUNET_shutdown_initiate ();
         }
       break;
     case FSUI_download_error:
       printf (_("Error downloading: %s\n"),
               event->data.DownloadError.message);
       errorCode = 3;
-      GNUNET_SHUTDOWN_INITIATE ();
+      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));
+              (((double) (GNUNET_get_time () - (start_time - 1)))
+               / (double) GNUNET_CRON_SECONDS));
       downloads_running--;
       if (downloads_running == 0)
         {
           errorCode = 0;
-          GNUNET_SHUTDOWN_INITIATE ();
+          GNUNET_shutdown_initiate ();
         }
       break;
     case FSUI_download_started:
       downloads_running++;
-      APPEND (downloads, downloads_size, event->data.DownloadStarted.dc.pos);
+      GNUNET_array_append (downloads, downloads_size,
+                           event->data.DownloadStarted.dc.pos);
     case FSUI_download_stopped:
       break;
     default:
       GE_BREAK (ectx, 0);
       break;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return NULL;
 }
 
 static int
 directoryIterator (const ECRS_FileInfo * fi,
-                   const HashCode512 * key, int isRoot, void *cls)
+                   const GNUNET_HashCode * key, int isRoot, void *cls)
 {
   struct FSUI_Context *ctx = cls;
   struct ECRS_MetaData *meta;
@@ -175,20 +176,20 @@
                                  EXTRACTOR_CREATOR,
                                  EXTRACTOR_PRODUCER, EXTRACTOR_UNKNOWN, -1);
   if (f == NULL)
-    f = STRDUP (_("no name given"));
-  fn = MALLOC (strlen (filename) + strlen (f) + 4);
+    f = GNUNET_strdup (_("no name given"));
+  fn = GNUNET_malloc (strlen (filename) + strlen (f) + 4);
   strcpy (fn, filename);
   strcat (fn, "/");
   strcat (fn, f);
   if (verbose > 1)
     printf (_("Starting download `%s'\n"), f);
-  FREE (f);
+  GNUNET_free (f);
   meta = ECRS_createMetaData ();
   FSUI_startDownload (ctx,
                       anonymity, do_recursive, fi->uri, meta, fn, NULL, NULL);
   ECRS_freeMetaData (meta);
-  FREE (fn);
-  return OK;
+  GNUNET_free (fn);
+  return GNUNET_OK;
 }
 
 
@@ -245,50 +246,51 @@
         }
     }
 
-  try_rename = NO;
+  try_rename = GNUNET_NO;
   if (filename == NULL)
     {
       if (do_directory)
         {
           if (NULL != strstr (argv[i], GNUNET_DIRECTORY_EXT))
             {
-              filename = STRDUP (argv[i]);
+              filename = GNUNET_strdup (argv[i]);
               strstr (filename, GNUNET_DIRECTORY_EXT)[0] = '\0';
             }
           else
             {
               filename =
-                MALLOC (strlen (argv[i]) + strlen (GNUNET_DIRECTORY_EXT) + 2);
+                GNUNET_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;
+          try_rename = GNUNET_NO;
         }
       else
         {
           GE_ASSERT (ectx,
                      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)]);
+          filename = GNUNET_expand_file_name (ectx,
+                                              &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);
-          try_rename = YES;
+          try_rename = GNUNET_YES;
         }
     }
-  ok = NO;
-  lock = MUTEX_CREATE (NO);
+  ok = GNUNET_NO;
+  lock = GNUNET_mutex_create (GNUNET_NO);
   ctx = FSUI_start (ectx,
                     cfg,
                     "gnunet-download",
                     parallelism == 0 ? 1 : parallelism,
-                    NO, &progressModel, NULL);
-  start_time = get_time ();
+                    GNUNET_NO, &progressModel, NULL);
+  start_time = GNUNET_get_time ();
   errorCode = 1;
   if (do_directory)
     {
@@ -299,16 +301,16 @@
       char *efn;
 
       fd = -1;
-      efn = string_expandFileName (ectx, argv[i]);
+      efn = GNUNET_expand_file_name (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))) ||
+          (-1 == (fd = GNUNET_disk_file_open (ectx,
+                                              efn,
+                                              O_LARGEFILE | O_RDONLY))) ||
           (MAP_FAILED == (data = MMAP (NULL,
                                        sbuf.st_size,
                                        PROT_READ, MAP_SHARED, fd, 0))))
@@ -319,8 +321,8 @@
                   GE_ERROR | GE_IMMEDIATE | GE_USER,
                   _("Could not access gnunet-directory file `%s'\n"), efn);
           FSUI_stop (ctx);
-          MUTEX_DESTROY (lock);
-          FREE (efn);
+          GNUNET_mutex_destroy (lock);
+          GNUNET_free (efn);
           goto quit;
         }
       meta = ECRS_createMetaData ();
@@ -331,7 +333,7 @@
       ECRS_freeMetaData (meta);
       MUNMAP (data, sbuf.st_size);
       CLOSE (fd);
-      FREE (efn);
+      GNUNET_free (efn);
       if (verbose > 0)
         {
           if (count > 0)
@@ -351,11 +353,11 @@
       if (dl == NULL)
         {
           FSUI_stop (ctx);
-          MUTEX_DESTROY (lock);
+          GNUNET_mutex_destroy (lock);
           goto quit;
         }
     }
-  GNUNET_SHUTDOWN_WAITFOR ();
+  GNUNET_shutdown_wait_for ();
   if (errorCode == 1)
     {
       for (i = 0; i < downloads_size; i++)
@@ -363,11 +365,11 @@
     }
   for (i = 0; i < downloads_size; i++)
     FSUI_stopDownload (ctx, downloads[i]);
-  GROW (downloads, downloads_size, 0);
+  GNUNET_array_grow (downloads, downloads_size, 0);
   FSUI_stop (ctx);
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
 
-  if ((errorCode == 0) && (dl != NULL) && (try_rename == YES))
+  if ((errorCode == 0) && (dl != NULL) && (try_rename == GNUNET_YES))
     {
       char *newname = ECRS_suggestFilename (ectx,
                                             filename);
@@ -375,10 +377,10 @@
       if (newname != NULL)
         {
           fprintf (stdout, _("File stored as `%s'.\n"), newname);
-          FREE (newname);
+          GNUNET_free (newname);
         }
     }
-  FREE (filename);
+  GNUNET_free (filename);
   if (uri != NULL)
     ECRS_freeUri (uri);
 quit:

Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -31,8 +31,7 @@
 #include "gnunet_directories.h"
 #include "gnunet_fsui_lib.h"
 #include "gnunet_namespace_lib.h"
-#include "gnunet_util_boot.h"
-#include "gnunet_util_crypto.h"
+#include "gnunet_util.h"
 
 /* hmm. Man says time.h, but that doesn't yield the
    prototype.  Strange... */
@@ -48,7 +47,7 @@
 
 static struct FSUI_UploadList *ul;
 
-static cron_t start_time;
+static GNUNET_CronTime start_time;
 
 /* ************ config options ******** */
 
@@ -91,10 +90,10 @@
 static int do_disable_creation_time;
 
 static void
-convertId (const char *s, HashCode512 * id)
+convertId (const char *s, GNUNET_HashCode * id)
 {
-  if ((s != NULL) && (enc2hash (s, id) == SYSERR))
-    hash (s, strlen (s), id);
+  if ((s != NULL) && (GNUNET_enc_to_hash (s, id) == GNUNET_SYSERR))
+    GNUNET_hash (s, strlen (s), id);
 }
 
 /**
@@ -104,9 +103,9 @@
 static void
 postProcess (const struct ECRS_URI *uri)
 {
-  HashCode512 prevId;
-  HashCode512 thisId;
-  HashCode512 nextId;
+  GNUNET_HashCode prevId;
+  GNUNET_HashCode thisId;
+  GNUNET_HashCode nextId;
   struct ECRS_URI *nsuri;
   char *us;
 
@@ -119,9 +118,9 @@
                              cfg,
                              anonymity,
                              priority,
-                             get_time () + 2 * cronYEARS,
+                             GNUNET_get_time () + 2 * GNUNET_CRON_YEARS,
                              pseudonym,
-                             (TIME_T) interval,
+                             (GNUNET_Int32Time) interval,
                              prev_id == NULL ? NULL : &prevId,
                              this_id == NULL ? NULL : &thisId,
                              next_id == NULL ? NULL : &nextId, uri, meta);
@@ -130,14 +129,14 @@
       us = ECRS_uriToString (nsuri);
       ECRS_freeUri (nsuri);
       printf (_("Created entry `%s' in namespace `%s'\n"), us, pseudonym);
-      FREE (us);
+      GNUNET_free (us);
     }
   else
     {
       printf (_("Failed to add entry to namespace `%s' (does it exist?)\n"),
               pseudonym);
     }
-  FREE (pseudonym);
+  GNUNET_free (pseudonym);
   pseudonym = NULL;
 }
 
@@ -149,7 +148,7 @@
   struct stat buf;
   EXTRACTOR_KeywordList *list;
 
-  fullName = MALLOC (strlen (dir) + strlen (fn) + 2);
+  fullName = GNUNET_malloc (strlen (dir) + strlen (fn) + 2);
   strcpy (fullName, dir);
   if (dir[strlen (dir) - 1] != DIR_SEPARATOR)
     strcat (fullName, DIR_SEPARATOR_STR);
@@ -157,8 +156,8 @@
   printf (_("Keywords for file `%s':\n"), fullName);
   if (0 != STAT (fullName, &buf))
     {
-      FREE (fullName);
-      return OK;
+      GNUNET_free (fullName);
+      return GNUNET_OK;
     }
   if (S_ISDIR (buf.st_mode))
     {
@@ -166,7 +165,7 @@
       printf ("%s - %s\n",
               dgettext ("libextractor", "mimetype"),
               "application/gnunet-directory");
-      disk_directory_scan (NULL, fullName, &listKeywords, cls);
+      GNUNET_disk_directory_scan (NULL, fullName, &listKeywords, cls);
     }
   else
     {
@@ -177,8 +176,8 @@
       EXTRACTOR_printKeywords (stdout, list);
       EXTRACTOR_freeKeywords (list);
     }
-  FREE (fullName);
-  return OK;
+  GNUNET_free (fullName);
+  return GNUNET_OK;
 }
 
 
@@ -198,56 +197,56 @@
       if (*verboselevel)
         {
           char *ret;
-          cron_t now;
+          GNUNET_CronTime now;
 
-          now = get_time ();
+          now = GNUNET_get_time ();
           delta = event->data.UploadProgress.eta - now;
           if (event->data.UploadProgress.eta < now)
             delta = 0;
-          ret = string_get_fancy_time_interval (delta);
+          ret = GNUNET_get_time_interval_as_fancy_string (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);
-          FREE (ret);
+          GNUNET_free (ret);
         }
       break;
     case FSUI_upload_completed:
       if (*verboselevel)
         {
-          delta = get_time () - start_time;
+          delta = GNUNET_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 / GNUNET_CRON_SECONDS,
                   (delta == 0)
                   ? (double) (-1.0)
                   : (double) (event->data.UploadCompleted.total
-                              / 1024.0 * cronSECONDS / delta));
+                              / 1024.0 * GNUNET_CRON_SECONDS / delta));
         }
       fstring = ECRS_uriToString (event->data.UploadCompleted.uri);
       printf (_("File `%s' has URI: %s\n"),
               event->data.UploadCompleted.filename, fstring);
-      FREE (fstring);
+      GNUNET_free (fstring);
       if (ul == event->data.UploadCompleted.uc.pos)
         {
           postProcess (event->data.UploadCompleted.uri);
           errorCode = 0;
-          GNUNET_SHUTDOWN_INITIATE ();
+          GNUNET_shutdown_initiate ();
         }
       break;
     case FSUI_upload_aborted:
       printf (_("\nUpload aborted.\n"));
       errorCode = 2;
-      GNUNET_SHUTDOWN_INITIATE ();
+      GNUNET_shutdown_initiate ();
       break;
     case FSUI_upload_error:
       printf (_("\nError uploading file: %s"),
               event->data.UploadError.message);
       errorCode = 3;
-      GNUNET_SHUTDOWN_INITIATE ();
+      GNUNET_shutdown_initiate ();
       break;
     case FSUI_upload_started:
     case FSUI_upload_stopped:
@@ -263,33 +262,33 @@
 /**
  * All gnunet-insert command line options
  */
-static struct CommandLineOption gnunetinsertOptions[] = {
+static struct GNUNET_CommandLineOption gnunetinsertOptions[] = {
   {'a', "anonymity", "LEVEL",
    gettext_noop ("set the desired LEVEL of sender-anonymity"),
-   1, &gnunet_getopt_configure_set_uint, &anonymity},
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+   1, &GNUNET_getopt_configure_set_uint, &anonymity},
+   GNUNET_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"),
-   0, &gnunet_getopt_configure_set_one, &do_copy},
+   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"),
-   0, &gnunet_getopt_configure_set_one, &do_disable_creation_time},
+   0, &GNUNET_getopt_configure_set_one, &do_disable_creation_time},
   {'D', "disable-direct", NULL,
    gettext_noop
    ("do not use libextractor to add additional references to directory entries 
and/or the published file"),
-   0, &gnunet_getopt_configure_set_one, &do_no_direct_references},
+   0, &GNUNET_getopt_configure_set_one, &do_no_direct_references},
   {'e', "extract", NULL,
    gettext_noop
    ("print list of extracted keywords that would be used, but do not perform 
upload"),
-   0, &gnunet_getopt_configure_set_one, &extract_only},
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Make files available to GNUnet for 
sharing.")),      /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
+   0, &GNUNET_getopt_configure_set_one, &extract_only},
+   GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Make files available to 
GNUnet for sharing.")),      /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
   {'i', "interval", "SECONDS",
    gettext_noop ("set interval for availability of updates to SECONDS"
                  " (for namespace insertions only)"),
-   1, &gnunet_getopt_configure_set_uint, &interval},
+   1, &GNUNET_getopt_configure_set_uint, &interval},
   {'k', "key", "KEYWORD",
    gettext_noop
    ("add an additional keyword for the top-level file or directory"
@@ -299,45 +298,45 @@
    gettext_noop ("add an additional keyword for all files and directories"
                  " (this option can be specified multiple times)"),
    1, &gnunet_getopt_configure_set_keywords, &gloKeywords},
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'m', "meta", "TYPE:VALUE",
    gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
    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)"),
-   0, &gnunet_getopt_configure_set_one, &do_insert},
+   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)"),
-   1, &gnunet_getopt_configure_set_string, &next_id},
+   1, &GNUNET_getopt_configure_set_string, &next_id},
   {'p', "priority", "PRIORITY",
    gettext_noop ("specify the priority of the content"),
-   1, &gnunet_getopt_configure_set_uint, &priority},
+   1, &GNUNET_getopt_configure_set_uint, &priority},
   {'P', "pseudonym", "NAME",
    gettext_noop
    ("publish the files under the pseudonym NAME (place file into namespace)"),
-   1, &gnunet_getopt_configure_set_string, &pseudonym},
+   1, &GNUNET_getopt_configure_set_string, &pseudonym},
   {'S', "sporadic", NULL,
    gettext_noop ("specifies this as an aperiodic but updated publication"
                  " (for namespace insertions only)"),
-   0, &gnunet_getopt_configure_set_one, &is_sporadic},
+   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)"),
-   1, &gnunet_getopt_configure_set_string, &this_id},
+   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},
+   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)"),
-   1, &gnunet_getopt_configure_set_string, &prev_id},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+   1, &GNUNET_getopt_configure_set_string, &prev_id},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 /**
@@ -386,8 +385,8 @@
       GC_get_configuration_value_string (cfg, "FS", "EXTRACTORS", "", &ex);
       if (strlen (ex) > 0)
         l = EXTRACTOR_loadConfigLibraries (l, ex);
-      FREE (ex);
-      dirname = string_expandFileName (ectx, filename);
+      GNUNET_free (ex);
+      dirname = GNUNET_expand_file_name (ectx, filename);
       GE_ASSERT (ectx, dirname != NULL);
       while ((strlen (dirname) > 0) &&
              (dirname[strlen (dirname) - 1] == DIR_SEPARATOR))
@@ -398,7 +397,7 @@
       GE_ASSERT (ectx, fname != dirname);
       fname[-1] = '\0';
       listKeywords (fname, dirname, l);
-      FREE (dirname);
+      GNUNET_free (dirname);
       EXTRACTOR_removeAll (l);
       ECRS_freeMetaData (meta);
 
@@ -413,7 +412,7 @@
   /* check arguments */
   if (pseudonym != NULL)
     {
-      if (OK != ECRS_testNamespaceExists (ectx, cfg, pseudonym, NULL))
+      if (GNUNET_OK != ECRS_testNamespaceExists (ectx, cfg, pseudonym, NULL))
         {
           printf (_("Could not access namespace `%s' (does not exist?).\n"),
                   pseudonym);
@@ -485,34 +484,34 @@
     }
 
   /* fundamental init */
-  ctx = FSUI_start (ectx, cfg, "gnunet-insert", NO, 32, /* make configurable */
+  ctx = FSUI_start (ectx, cfg, "gnunet-insert", GNUNET_NO, 32,  /* make 
configurable */
                     &printstatus, &verbose);
 
   /* first insert all of the top-level files or directories */
-  tmp = string_expandFileName (ectx, filename);
+  tmp = GNUNET_expand_file_name (ectx, filename);
   if (!do_disable_creation_time)
     ECRS_addPublicationDateToMetaData (meta);
-  start_time = get_time ();
+  start_time = GNUNET_get_time ();
   errorCode = 1;
   ul = FSUI_startUpload (ctx,
                          tmp,
-                         (DirectoryScanCallback) & disk_directory_scan,
+                         (DirectoryScanCallback) & GNUNET_disk_directory_scan,
                          ectx,
                          anonymity,
                          priority,
                          !do_insert,
-                         YES,
+                         GNUNET_YES,
                          !do_no_direct_references,
-                         start_time + 2 * cronYEARS,
+                         start_time + 2 * GNUNET_CRON_YEARS,
                          meta, gloKeywords, topKeywords);
   if (gloKeywords != NULL)
     ECRS_freeUri (gloKeywords);
   if (topKeywords != NULL)
     ECRS_freeUri (topKeywords);
-  FREE (tmp);
+  GNUNET_free (tmp);
   if (ul != NULL)
     {
-      GNUNET_SHUTDOWN_WAITFOR ();
+      GNUNET_shutdown_wait_for ();
       if (errorCode == 1)
         FSUI_abortUpload (ctx, ul);
       FSUI_stopUpload (ctx, ul);

Modified: GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -28,8 +28,7 @@
 #include "gnunet_directories.h"
 #include "gnunet_collection_lib.h"
 #include "gnunet_namespace_lib.h"
-#include "gnunet_util_boot.h"
-#include "gnunet_util_crypto.h"
+#include "gnunet_util.h"
 
 static struct GE_Context *ectx;
 
@@ -55,7 +54,7 @@
 
 static unsigned int priority;
 
-static cron_t expiration = 2 * cronYEARS;
+static GNUNET_CronTime expiration = 2 * GNUNET_CRON_YEARS;
 
 static char *cfgFilename = DEFAULT_CLIENT_CONFIG_FILE;
 
@@ -66,25 +65,25 @@
 /**
  * All gnunet-pseudonym command line options
  */
-static struct CommandLineOption gnunetpseudonymOptions[] = {
+static struct GNUNET_CommandLineOption gnunetpseudonymOptions[] = {
   {'a', "anonymity", "LEVEL",
    gettext_noop ("set the desired LEVEL of sender-anonymity"),
-   1, &gnunet_getopt_configure_set_uint, &anonymity},
+   1, &GNUNET_getopt_configure_set_uint, &anonymity},
   {'A', "automate", NULL,
    gettext_noop ("automate creation of a namespace by starting a collection"),
-   0, &gnunet_getopt_configure_set_one, &start_collection},
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+   0, &GNUNET_getopt_configure_set_one, &start_collection},
+   GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
   {'C', "create", "NICKNAME",
    gettext_noop ("create a new pseudonym under the given NICKNAME"),
-   1, &gnunet_getopt_configure_set_string, &create_name},
+   1, &GNUNET_getopt_configure_set_string, &create_name},
   {'D', "delete", "NICKNAME",
    gettext_noop ("delete the pseudonym with the given NICKNAME"),
-   1, &gnunet_getopt_configure_set_string, &delete_name},
+   1, &GNUNET_getopt_configure_set_string, &delete_name},
   {'E', "end", NULL,
    gettext_noop ("end automated building of a namespace (ends collection)"),
-   0, &gnunet_getopt_configure_set_one, &stop_collection},
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Create new pseudonyms, delete 
pseudonyms or list existing pseudonyms.")),    /* -h */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+   0, &GNUNET_getopt_configure_set_one, &stop_collection},
+   GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Create new pseudonyms, 
delete pseudonyms or list existing pseudonyms.")),    /* -h */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'k', "keyword", "KEYWORD",
    gettext_noop
    ("use the given keyword to advertise the namespace (use when creating a new 
pseudonym)"),
@@ -95,20 +94,20 @@
   {'n', "no-advertisement", NULL,
    gettext_noop
    ("do not generate an advertisement for this namespace (use when creating a 
new pseudonym)"),
-   0, &gnunet_getopt_configure_set_one, &no_advertisement},
+   0, &GNUNET_getopt_configure_set_one, &no_advertisement},
   {'q', "quiet", NULL,
    gettext_noop ("do not list the pseudonyms from the pseudonym database"),
-   0, &gnunet_getopt_configure_set_one, &be_quiet},
+   0, &GNUNET_getopt_configure_set_one, &be_quiet},
   {'R', "root", "IDENTIFIER",
    gettext_noop
    ("specify IDENTIFIER to be the address of the entrypoint to content in the 
namespace (use when creating a new pseudonym)"),
-   1, &gnunet_getopt_configure_set_string, &root_name},
+   1, &GNUNET_getopt_configure_set_string, &root_name},
   {'s', "set-rating", "ID:VALUE",
    gettext_noop ("set the rating of a namespace"),
-   0, &gnunet_getopt_configure_set_string, &set_rating},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+   0, &GNUNET_getopt_configure_set_string, &set_rating},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 static int
@@ -117,7 +116,7 @@
   printf ("\t%20s: %s\n",
           dgettext ("libextractor",
                     EXTRACTOR_getKeywordTypeAsString (type)), data);
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
@@ -129,13 +128,13 @@
 static int
 namespacePrinter (void *unused,
                   const char *namespaceName,
-                  const HashCode512 * id,
+                  const GNUNET_HashCode * id,
                   const struct ECRS_MetaData *md, int rating)
 {
-  EncName enc;
+  GNUNET_EncName enc;
   int cpos;
 
-  hash2enc (id, &enc);
+  GNUNET_hash_to_enc (id, &enc);
   if (0 == strcmp (namespaceName, (char *) &enc))
     printf (_("Namespace `%s' has rating %d.\n"), namespaceName, rating);
   else
@@ -172,7 +171,7 @@
         }
     }
   printf ("\n");
-  return OK;
+  return GNUNET_OK;
 }
 
 int
@@ -181,7 +180,7 @@
   int cnt;
   int success;
   int i;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 
   meta = ECRS_createMetaData ();
   i = GNUNET_init (argc,
@@ -200,7 +199,7 @@
   /* stop collections */
   if (stop_collection && (!start_collection))
     {
-      if (OK == CO_stopCollection ())
+      if (GNUNET_OK == CO_stopCollection ())
         printf (_("Collection stopped.\n"));
       else
         printf (_("Failed to stop collection (not active?).\n"));
@@ -209,7 +208,7 @@
   /* delete pseudonyms */
   if (delete_name != NULL)
     {
-      if (OK == NS_deleteNamespace (ectx, cfg, delete_name))
+      if (GNUNET_OK == NS_deleteNamespace (ectx, cfg, delete_name))
         {
           printf (_("Pseudonym `%s' deleted.\n"), delete_name);
         }
@@ -219,7 +218,7 @@
           printf (_("Error deleting pseudonym `%s' (does not exist?).\n"),
                   delete_name);
         }
-      FREE (delete_name);
+      GNUNET_free (delete_name);
     }
 
   /* create collections / namespace */
@@ -228,8 +227,8 @@
       if (start_collection)
         {
           ECRS_addToMetaData (meta, EXTRACTOR_OWNER, create_name);
-          if (OK == CO_startCollection (anonymity, priority, 
ECRS_SBLOCK_UPDATE_SPORADIC,       /* FIXME: allow other update policies */
-                                        create_name, meta))
+          if (GNUNET_OK == CO_startCollection (anonymity, priority, 
ECRS_SBLOCK_UPDATE_SPORADIC,        /* FIXME: allow other update policies */
+                                               create_name, meta))
             {
               printf (_("Started collection `%s'.\n"), create_name);
             }
@@ -243,18 +242,18 @@
         }
       else
         {                       /* no collection */
-          HashCode512 rootEntry;
+          GNUNET_HashCode rootEntry;
           struct ECRS_URI *rootURI;
           char *root;
 
           if (root_name == NULL)
             {
-              memset (&rootEntry, 0, sizeof (HashCode512));
+              memset (&rootEntry, 0, sizeof (GNUNET_HashCode));
             }
           else
             {
-              if (SYSERR == enc2hash (root_name, &hc))
-                hash (root_name, strlen (root_name), &hc);
+              if (GNUNET_SYSERR == GNUNET_enc_to_hash (root_name, &hc))
+                GNUNET_hash (root_name, strlen (root_name), &hc);
             }
           if (no_advertisement)
             {
@@ -271,7 +270,7 @@
                                         cfg,
                                         anonymity,
                                         priority,
-                                        expiration + get_time (),
+                                        expiration + GNUNET_get_time (),
                                         create_name,
                                         meta, advertisement, &rootEntry);
           if (rootURI == NULL)
@@ -285,13 +284,13 @@
               root = ECRS_uriToString (rootURI);
               printf (_("Namespace `%s' created (root: %s).\n"),
                       create_name, root);
-              FREE (root);
+              GNUNET_free (root);
               ECRS_freeUri (rootURI);
             }
           if (NULL != advertisement)
             ECRS_freeUri (advertisement);
         }
-      FREE (create_name);
+      GNUNET_free (create_name);
       create_name = NULL;
     }
   else

Modified: GNUnet/src/applications/fs/tools/gnunet-search.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-search.c    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/tools/gnunet-search.c    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -27,8 +27,7 @@
 #include "platform.h"
 #include "gnunet_directories.h"
 #include "gnunet_fsui_lib.h"
-#include "gnunet_util_cron.h"
-#include "gnunet_util_boot.h"
+#include "gnunet_util.h"
 
 
 static struct GE_Context *ectx;
@@ -58,7 +57,7 @@
   printf ("\t%20s: %s\n",
           dgettext ("libextractor",
                     EXTRACTOR_getKeywordTypeAsString (type)), data);
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
@@ -80,19 +79,19 @@
     {
     case FSUI_search_error:
       errorCode = 3;
-      GNUNET_SHUTDOWN_INITIATE ();
+      GNUNET_shutdown_initiate ();
       break;
     case FSUI_search_aborted:
       errorCode = 4;
-      GNUNET_SHUTDOWN_INITIATE ();
+      GNUNET_shutdown_initiate ();
       break;
     case FSUI_search_completed:
       errorCode = 0;
-      GNUNET_SHUTDOWN_INITIATE ();
+      GNUNET_shutdown_initiate ();
       break;
     case FSUI_search_result:
       /* retain URIs for possible directory dump later */
-      GROW (fis, fiCount, fiCount + 1);
+      GNUNET_array_grow (fis, fiCount, fiCount + 1);
       fis[fiCount - 1].uri = ECRS_dupUri (event->data.SearchResult.fi.uri);
       fis[fiCount - 1].meta
         = ECRS_dupMetaData (event->data.SearchResult.fi.meta);
@@ -114,8 +113,8 @@
         printf ("gnunet-download %s\n", uri);
       printMeta (event->data.SearchResult.fi.meta);
       printf ("\n");
-      FREENONNULL (filename);
-      FREE (uri);
+      GNUNET_free_non_null (filename);
+      GNUNET_free (uri);
       break;
     case FSUI_search_started:
     case FSUI_search_stopped:
@@ -130,26 +129,26 @@
 /**
  * All gnunet-search command line options
  */
-static struct CommandLineOption gnunetsearchOptions[] = {
+static struct GNUNET_CommandLineOption gnunetsearchOptions[] = {
   {'a', "anonymity", "LEVEL",
    gettext_noop ("set the desired LEVEL of sender-anonymity"),
-   1, &gnunet_getopt_configure_set_uint, &anonymity},
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Search GNUnet for files.")), /* -h 
*/
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+   1, &GNUNET_getopt_configure_set_uint, &anonymity},
+   GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+   GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Search GNUnet for 
files.")), /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'m', "max", "LIMIT",
    gettext_noop ("exit after receiving LIMIT results"),
-   1, &gnunet_getopt_configure_set_uint, &max_results},
+   1, &GNUNET_getopt_configure_set_uint, &max_results},
   {'o', "output", "FILENAME",
    gettext_noop ("write encountered (decrypted) search results to FILENAME"),
-   1, &gnunet_getopt_configure_set_string, &output_filename},
+   1, &GNUNET_getopt_configure_set_string, &output_filename},
   {'t', "timeout", "DELAY",
    gettext_noop ("wait DELAY seconds for search results before aborting"),
-   1, &gnunet_getopt_configure_set_uint, &delay},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+   1, &GNUNET_getopt_configure_set_uint, &delay},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 /**
@@ -171,7 +170,7 @@
                    argv,
                    "gnunet-search [OPTIONS] [KEYWORDS]",
                    &cfgFilename, gnunetsearchOptions, &ectx, &cfg);
-  if (i == SYSERR)
+  if (i == GNUNET_SYSERR)
     {
       GNUNET_fini (ectx, cfg);
       return -1;
@@ -186,16 +185,19 @@
     }
   if (max_results == 0)
     max_results = (unsigned int) -1;    /* infty */
-  ctx = FSUI_start (ectx, cfg, "gnunet-search", 4, NO, &eventCallback, NULL);
+  ctx =
+    FSUI_start (ectx, cfg, "gnunet-search", 4, GNUNET_NO, &eventCallback,
+                NULL);
   if (ctx == NULL)
     {
       ECRS_freeUri (uri);
       GNUNET_fini (ectx, cfg);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   errorCode = 1;
   s = FSUI_startSearch (ctx,
-                        anonymity, max_results, delay * cronSECONDS, uri);
+                        anonymity, max_results, delay * GNUNET_CRON_SECONDS,
+                        uri);
   ECRS_freeUri (uri);
   if (s == NULL)
     {
@@ -203,7 +205,7 @@
       FSUI_stop (ctx);
       goto quit;
     }
-  GNUNET_SHUTDOWN_WAITFOR ();
+  GNUNET_shutdown_wait_for ();
   if (errorCode == 1)
     FSUI_abortSearch (ctx, s);
   FSUI_stopSearch (ctx, s);
@@ -218,21 +220,22 @@
 
       meta = ECRS_createMetaData ();
       /* ?: anything here to put into meta? */
-      if (OK == ECRS_createDirectory (ectx, &data, &n, fiCount, fis, meta))
+      if (GNUNET_OK ==
+          ECRS_createDirectory (ectx, &data, &n, fiCount, fis, meta))
         {
-          outfile = string_expandFileName (ectx, output_filename);
-          disk_file_write (ectx, outfile, data, n, "600");
-          FREE (outfile);
-          FREE (data);
+          outfile = GNUNET_expand_file_name (ectx, output_filename);
+          GNUNET_disk_file_write (ectx, outfile, data, n, "600");
+          GNUNET_free (outfile);
+          GNUNET_free (data);
         }
-      FREE (output_filename);
+      GNUNET_free (output_filename);
     }
   for (i = 0; i < fiCount; i++)
     {
       ECRS_freeUri (fis[i].uri);
       ECRS_freeMetaData (fis[i].meta);
     }
-  GROW (fis, fiCount, 0);
+  GNUNET_array_grow (fis, fiCount, 0);
 quit:
   GNUNET_fini (ectx, cfg);
   return errorCode;

Modified: GNUnet/src/applications/fs/tools/gnunet-unindex.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-unindex.c   2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/tools/gnunet-unindex.c   2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -30,13 +30,13 @@
 #include "platform.h"
 #include "gnunet_directories.h"
 #include "gnunet_fsui_lib.h"
-#include "gnunet_util_boot.h"
+#include "gnunet_util.h"
 
 static struct GE_Context *ectx;
 
 static struct GC_Configuration *cfg;
 
-static cron_t start_time;
+static GNUNET_CronTime start_time;
 
 static int errorCode;
 
@@ -56,36 +56,39 @@
     case FSUI_unindex_progress:
       if (*verboselevel)
         {
-          delta = event->data.UnindexProgress.eta - get_time ();
+          delta = event->data.UnindexProgress.eta - GNUNET_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.total,
+                  delta / GNUNET_CRON_SECONDS);
           printf ("\r");
         }
       break;
     case FSUI_unindex_completed:
       if (*verboselevel)
         {
-          delta = get_time () - start_time;
+          delta = GNUNET_get_time () - start_time;
           PRINTF (_
                   ("\nUnindexing of `%s' complete, %llu bytes took %llu 
seconds (%8.3f KiB/s).\n"),
                   event->data.UnindexCompleted.filename,
-                  event->data.UnindexCompleted.total, delta / cronSECONDS,
+                  event->data.UnindexCompleted.total,
+                  delta / GNUNET_CRON_SECONDS,
                   (delta ==
                    0) ? (double) (-1.0) : (double) (event->data.
                                                     UnindexCompleted.total /
-                                                    1024.0 * cronSECONDS /
+                                                    1024.0 *
+                                                    GNUNET_CRON_SECONDS /
                                                     delta));
         }
       errorCode = 0;
-      GNUNET_SHUTDOWN_INITIATE ();
+      GNUNET_shutdown_initiate ();
       break;
     case FSUI_unindex_error:
       printf (_("\nError unindexing file: %s\n"),
               event->data.UnindexError.message);
       errorCode = 3;
-      GNUNET_SHUTDOWN_INITIATE ();
+      GNUNET_shutdown_initiate ();
       break;
     case FSUI_unindex_started:
     case FSUI_unindex_stopped:
@@ -100,14 +103,14 @@
 /**
  * All gnunet-unindex command line options
  */
-static struct CommandLineOption gnunetunindexOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Unindex files.")),   /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+static struct GNUNET_CommandLineOption gnunetunindexOptions[] = {
+       GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Unindex files.")),   /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
+  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 /**
@@ -148,10 +151,11 @@
                                      "VERBOSE", 0, 9999, 0, &verbose);
   /* fundamental init */
   ctx = FSUI_start (ectx,
-                    cfg, "gnunet-unindex", 2, NO, &printstatus, &verbose);
+                    cfg, "gnunet-unindex", 2, GNUNET_NO, &printstatus,
+                    &verbose);
   errorCode = 1;
-  start_time = get_time ();
-  filename = string_expandFileName (ectx, argv[i]);
+  start_time = GNUNET_get_time ();
+  filename = GNUNET_expand_file_name (ectx, argv[i]);
   ul = FSUI_startUnindex (ctx, filename);
   if (ul == NULL)
     {
@@ -160,12 +164,12 @@
     }
   else
     {
-      GNUNET_SHUTDOWN_WAITFOR ();
+      GNUNET_shutdown_wait_for ();
       if (errorCode == 1)
         FSUI_abortUnindex (ctx, ul);
       FSUI_stopUnindex (ctx, ul);
     }
-  FREE (filename);
+  GNUNET_free (filename);
   FSUI_stop (ctx);
   GNUNET_fini (ectx, cfg);
   return errorCode;

Modified: GNUnet/src/applications/fs/uritrack/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/uritrack/Makefile.am     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/uritrack/Makefile.am     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -8,7 +8,6 @@
   uri_info.c \
   callbacks.c callbacks.h
 libgnuneturitrack_la_LIBADD = \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
  $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
@@ -21,7 +20,6 @@
 tracktest_SOURCES = \
   tracktest.c 
 tracktest_LDADD = \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
   $(top_builddir)/src/applications/fs/uritrack/libgnuneturitrack.la 
 
 EXTRA_DIST = \

Modified: GNUnet/src/applications/fs/uritrack/callbacks.c
===================================================================
--- GNUnet/src/applications/fs/uritrack/callbacks.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/uritrack/callbacks.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -42,12 +42,12 @@
 
   void *closure;
 
-  struct PTHREAD *init;
+  struct GNUNET_ThreadHandle *init;
 
   int abort_init;
 } Callback;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static Callback **callbacks;
 
@@ -55,21 +55,21 @@
 
 static int
 init_iterator (const ECRS_FileInfo * fi,
-               const HashCode512 * key, int isRoot, void *closure)
+               const GNUNET_HashCode * key, int isRoot, void *closure)
 {
   Callback *c = closure;
 
   c->iterator (fi, key, isRoot, c->closure);
   if (c->abort_init)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 static void *
 init_thread (void *arg)
 {
   Callback *c = arg;
-  URITRACK_listURIs (c->ectx, c->cfg, YES, &init_iterator, arg);
+  URITRACK_listURIs (c->ectx, c->cfg, GNUNET_YES, &init_iterator, arg);
   return NULL;
 }
 
@@ -87,18 +87,18 @@
 {
   Callback *c;
 
-  c = MALLOC (sizeof (Callback));
+  c = GNUNET_malloc (sizeof (Callback));
   c->ectx = ectx;
   c->cfg = cfg;
   c->iterator = iterator;
   c->closure = closure;
-  c->abort_init = NO;
-  c->init = PTHREAD_CREATE (&init_thread, c, 16 * 1024);
-  MUTEX_LOCK (lock);
-  GROW (callbacks, callbacks_size, callbacks_size + 1);
+  c->abort_init = GNUNET_NO;
+  c->init = GNUNET_thread_create (&init_thread, c, 16 * 1024);
+  GNUNET_mutex_lock (lock);
+  GNUNET_array_grow (callbacks, callbacks_size, callbacks_size + 1);
   callbacks[callbacks_size - 1] = c;
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -112,23 +112,23 @@
   void *unused;
   Callback *c;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < callbacks_size; i++)
     {
       c = callbacks[i];
       if ((c->iterator == iterator) && (c->closure == closure))
         {
-          c->abort_init = YES;
-          PTHREAD_JOIN (c->init, &unused);
+          c->abort_init = GNUNET_YES;
+          GNUNET_thread_join (c->init, &unused);
           callbacks[i] = callbacks[callbacks_size - 1];
-          GROW (callbacks, callbacks_size, callbacks_size - 1);
-          FREE (c);
-          MUTEX_UNLOCK (lock);
-          return OK;
+          GNUNET_array_grow (callbacks, callbacks_size, callbacks_size - 1);
+          GNUNET_free (c);
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_OK;
         }
     }
-  MUTEX_UNLOCK (lock);
-  return SYSERR;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -139,20 +139,20 @@
 {
   int i;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < callbacks_size; i++)
-    callbacks[i]->iterator (fi, NULL, NO, callbacks[i]->closure);
-  MUTEX_UNLOCK (lock);
+    callbacks[i]->iterator (fi, NULL, GNUNET_NO, callbacks[i]->closure);
+  GNUNET_mutex_unlock (lock);
 }
 
 void __attribute__ ((constructor)) gnunet_uritrack_ltdl_init ()
 {
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
 }
 
 void __attribute__ ((destructor)) gnunet_uritrack_ltdl_fini ()
 {
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
 }
 

Modified: GNUnet/src/applications/fs/uritrack/file_info.c
===================================================================
--- GNUnet/src/applications/fs/uritrack/file_info.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/uritrack/file_info.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -33,17 +33,17 @@
 #include "platform.h"
 #include "callbacks.h"
 
-#define DEBUG_FILE_INFO NO
+#define DEBUG_FILE_INFO GNUNET_NO
 
 #define STATE_NAME DIR_SEPARATOR_STR "data" DIR_SEPARATOR_STR "fs_uridb"
 #define TRACK_OPTION "fs_uridb_status"
 
-static struct IPC_SEMAPHORE *
+static struct GNUNET_IPC_Semaphore *
 createIPC (struct GE_Context *ectx, struct GC_Configuration *cfg)
 {
   char *basename;
   char *ipcName;
-  struct IPC_SEMAPHORE *sem;
+  struct GNUNET_IPC_Semaphore *sem;
   size_t n;
 
   GC_get_configuration_value_filename (cfg,
@@ -51,11 +51,11 @@
                                        "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);
+  ipcName = GNUNET_malloc (n);
+  GNUNET_snprintf (ipcName, n, "%s/directory_ipc_lock", basename);
+  GNUNET_free (basename);
+  sem = GNUNET_IPC_semaphore_create (ectx, ipcName, 1);
+  GNUNET_free (ipcName);
   return sem;
 }
 
@@ -69,12 +69,12 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &pfx);
-  nw = MALLOC (strlen (pfx) + strlen (STATE_NAME) + 2);
+  nw = GNUNET_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);
+  GNUNET_free (pfx);
+  GNUNET_disk_directory_create_for_file (ectx, nw);
   return nw;
 }
 
@@ -88,19 +88,19 @@
                                        "GNUNET",
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &pfx);
-  nw = MALLOC (strlen (pfx) + strlen (TRACK_OPTION) + 2);
+  nw = GNUNET_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);
+  GNUNET_free (pfx);
+  GNUNET_disk_directory_create_for_file (ectx, nw);
   return nw;
 }
 
 /**
  * Get the URITRACK URI tracking status.
  *
- * @return YES of tracking is enabled, NO if not
+ * @return GNUNET_YES of tracking is enabled, GNUNET_NO if not
  */
 int
 URITRACK_trackStatus (struct GE_Context *ectx, struct GC_Configuration *cfg)
@@ -109,28 +109,29 @@
   char *tn;
 
   tn = getToggleName (ectx, cfg);
-  if (YES != disk_file_test (ectx, tn))
+  if (GNUNET_YES != GNUNET_disk_file_test (ectx, tn))
     {
-      FREE (tn);
-      return NO;                /* default: off */
+      GNUNET_free (tn);
+      return GNUNET_NO;         /* default: off */
     }
-  if ((sizeof (int) != disk_file_read (ectx,
-                                       tn,
-                                       sizeof (int),
-                                       &status)) || (ntohl (status) != YES))
+  if ((sizeof (int) != GNUNET_disk_file_read (ectx,
+                                              tn,
+                                              sizeof (int),
+                                              &status))
+      || (ntohl (status) != GNUNET_YES))
     {
-      FREE (tn);
+      GNUNET_free (tn);
 #if DEBUG_FILE_INFO
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               _("Collecting file identifiers disabled.\n"));
 #endif
-      return NO;
+      return GNUNET_NO;
     }
   else
     {
-      FREE (tn);
-      return YES;
+      GNUNET_free (tn);
+      return GNUNET_YES;
     }
 }
 
@@ -142,15 +143,15 @@
 
 static int
 checkPresent (const ECRS_FileInfo * fi,
-              const HashCode512 * key, int isRoot, void *closure)
+              const GNUNET_HashCode * key, int isRoot, void *closure)
 {
   struct CheckPresentClosure *cpc = closure;
   if (ECRS_equalsUri (fi->uri, cpc->fi->uri))
     {
       cpc->present = 1;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -160,7 +161,7 @@
 URITRACK_trackURI (struct GE_Context *ectx,
                    struct GC_Configuration *cfg, const ECRS_FileInfo * fi)
 {
-  struct IPC_SEMAPHORE *sem;
+  struct GNUNET_IPC_Semaphore *sem;
   char *data;
   unsigned int size;
   char *suri;
@@ -168,17 +169,17 @@
   char *fn;
   struct CheckPresentClosure cpc;
 
-  if (NO == URITRACK_trackStatus (ectx, cfg))
+  if (GNUNET_NO == URITRACK_trackStatus (ectx, cfg))
     return;
   cpc.present = 0;
   cpc.fi = fi;
-  URITRACK_listURIs (ectx, cfg, NO, &checkPresent, &cpc);
+  URITRACK_listURIs (ectx, cfg, GNUNET_NO, &checkPresent, &cpc);
   if (cpc.present == 1)
     return;
   size = ECRS_sizeofMetaData (fi->meta,
                               ECRS_SERIALIZE_FULL |
                               ECRS_SERIALIZE_NO_COMPRESS);
-  data = MALLOC (size);
+  data = GNUNET_malloc (size);
   GE_ASSERT (ectx,
              size == ECRS_serializeMetaData (ectx,
                                              fi->meta,
@@ -189,12 +190,12 @@
   size = htonl (size);
   suri = ECRS_uriToString (fi->uri);
   sem = createIPC (ectx, cfg);
-  IPC_SEMAPHORE_DOWN (sem, YES);
+  GNUNET_IPC_semaphore_down (sem, GNUNET_YES);
   fn = getUriDbName (ectx, cfg);
-  fh = disk_file_open (ectx,
-                       fn,
-                       O_WRONLY | O_APPEND | O_CREAT | O_LARGEFILE,
-                       S_IRUSR | S_IWUSR);
+  fh = GNUNET_disk_file_open (ectx,
+                              fn,
+                              O_WRONLY | O_APPEND | O_CREAT |
+                              O_LARGEFILE, S_IRUSR | S_IWUSR);
   if (fh != -1)
     {
       WRITE (fh, suri, strlen (suri) + 1);
@@ -202,11 +203,11 @@
       WRITE (fh, data, ntohl (size));
       CLOSE (fh);
     }
-  FREE (fn);
-  IPC_SEMAPHORE_UP (sem);
-  IPC_SEMAPHORE_DESTROY (sem);
-  FREE (data);
-  FREE (suri);
+  GNUNET_free (fn);
+  GNUNET_IPC_semaphore_up (sem);
+  GNUNET_IPC_semaphore_destroy (sem);
+  GNUNET_free (data);
+  GNUNET_free (suri);
   URITRACK_internal_notify (fi);
 }
 
@@ -218,28 +219,28 @@
 URITRACK_clearTrackedURIS (struct GE_Context *ectx,
                            struct GC_Configuration *cfg)
 {
-  struct IPC_SEMAPHORE *sem;
+  struct GNUNET_IPC_Semaphore *sem;
   char *fn;
 
   sem = createIPC (ectx, cfg);
-  IPC_SEMAPHORE_DOWN (sem, YES);
+  GNUNET_IPC_semaphore_down (sem, GNUNET_YES);
   fn = getUriDbName (ectx, cfg);
-  if (YES == disk_file_test (ectx, fn))
+  if (GNUNET_YES == GNUNET_disk_file_test (ectx, fn))
     {
       if (0 != UNLINK (fn))
         GE_LOG_STRERROR_FILE (ectx,
                               GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                               "unlink", fn);
     }
-  FREE (fn);
-  IPC_SEMAPHORE_UP (sem);
-  IPC_SEMAPHORE_DESTROY (sem);
+  GNUNET_free (fn);
+  GNUNET_IPC_semaphore_up (sem);
+  GNUNET_IPC_semaphore_destroy (sem);
 }
 
 /**
  * Toggle tracking URIs.
  *
- * @param onOff YES to enable tracking, NO to disable
+ * @param onOff GNUNET_YES to enable tracking, GNUNET_NO to disable
  *  disabling tracking
  */
 void
@@ -250,8 +251,8 @@
   char *tn;
 
   tn = getToggleName (ectx, cfg);
-  disk_file_write (ectx, tn, &o, sizeof (int), "600");
-  FREE (tn);
+  GNUNET_disk_file_write (ectx, tn, &o, sizeof (int), "600");
+  GNUNET_free (tn);
 }
 
 /**
@@ -260,8 +261,8 @@
  *
  * @param iterator function to call on each entry, may be NULL
  * @param closure extra argument to the callback
- * @param need_metadata YES if metadata should be
- *        provided, NO if metadata is not needed (faster)
+ * @param need_metadata GNUNET_YES if metadata should be
+ *        provided, GNUNET_NO if metadata is not needed (faster)
  * @return number of entries found
  */
 int
@@ -270,7 +271,7 @@
                    int need_metadata,
                    ECRS_SearchProgressCallback iterator, void *closure)
 {
-  struct IPC_SEMAPHORE *sem;
+  struct GNUNET_IPC_Semaphore *sem;
   int rval;
   char *result;
   off_t ret;
@@ -284,24 +285,24 @@
 
   fn = getUriDbName (ectx, cfg);
   sem = createIPC (ectx, cfg);
-  IPC_SEMAPHORE_DOWN (sem, YES);
+  GNUNET_IPC_semaphore_down (sem, GNUNET_YES);
   if ((0 != STAT (fn, &buf)) || (buf.st_size == 0))
     {
-      IPC_SEMAPHORE_UP (sem);
-      IPC_SEMAPHORE_DESTROY (sem);
-      FREE (fn);
+      GNUNET_IPC_semaphore_up (sem);
+      GNUNET_IPC_semaphore_destroy (sem);
+      GNUNET_free (fn);
       return 0;                 /* no URI db */
     }
-  fd = disk_file_open (ectx, fn, O_LARGEFILE | O_RDONLY);
+  fd = GNUNET_disk_file_open (ectx, fn, O_LARGEFILE | O_RDONLY);
   if (fd == -1)
     {
-      IPC_SEMAPHORE_UP (sem);
-      IPC_SEMAPHORE_DESTROY (sem);
+      GNUNET_IPC_semaphore_up (sem);
+      GNUNET_IPC_semaphore_destroy (sem);
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                             "open", fn);
-      FREE (fn);
-      return SYSERR;            /* error opening URI db */
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;     /* error opening URI db */
     }
   result = MMAP (NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0);
   if (result == MAP_FAILED)
@@ -310,10 +311,10 @@
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                             "mmap", fn);
-      FREE (fn);
-      IPC_SEMAPHORE_UP (sem);
-      IPC_SEMAPHORE_DESTROY (sem);
-      return SYSERR;
+      GNUNET_free (fn);
+      GNUNET_IPC_semaphore_up (sem);
+      GNUNET_IPC_semaphore_destroy (sem);
+      return GNUNET_SYSERR;
     }
   ret = buf.st_size;
   pos = 0;
@@ -344,7 +345,7 @@
           ECRS_freeUri (fi.uri);
           goto FORMATERROR;
         }
-      if (need_metadata == YES)
+      if (need_metadata == GNUNET_YES)
         {
           fi.meta = ECRS_deserializeMetaData (ectx, &result[spos], msize);
           if (fi.meta == NULL)
@@ -361,7 +362,7 @@
       pos = spos + msize;
       if (iterator != NULL)
         {
-          if (OK != iterator (&fi, NULL, NO, closure))
+          if (GNUNET_OK != iterator (&fi, NULL, GNUNET_NO, closure))
             {
               if (fi.meta != NULL)
                 ECRS_freeMetaData (fi.meta);
@@ -371,10 +372,10 @@
                                       GE_ERROR | GE_ADMIN | GE_BULK,
                                       "munmap", fn);
               CLOSE (fd);
-              FREE (fn);
-              IPC_SEMAPHORE_UP (sem);
-              IPC_SEMAPHORE_DESTROY (sem);
-              return SYSERR;    /* iteration aborted */
+              GNUNET_free (fn);
+              GNUNET_IPC_semaphore_up (sem);
+              GNUNET_IPC_semaphore_destroy (sem);
+              return GNUNET_SYSERR;     /* iteration aborted */
             }
         }
       rval++;
@@ -385,9 +386,9 @@
   if (0 != MUNMAP (result, buf.st_size))
     GE_LOG_STRERROR_FILE (ectx, GE_ERROR | GE_ADMIN | GE_BULK, "munmap", fn);
   CLOSE (fd);
-  FREE (fn);
-  IPC_SEMAPHORE_UP (sem);
-  IPC_SEMAPHORE_DESTROY (sem);
+  GNUNET_free (fn);
+  GNUNET_IPC_semaphore_up (sem);
+  GNUNET_IPC_semaphore_destroy (sem);
   return rval;
 FORMATERROR:
   GE_LOG (ectx,
@@ -396,11 +397,11 @@
   if (0 != MUNMAP (result, buf.st_size))
     GE_LOG_STRERROR_FILE (ectx, GE_ERROR | GE_ADMIN | GE_BULK, "munmap", fn);
   CLOSE (fd);
-  FREE (fn);
-  IPC_SEMAPHORE_UP (sem);
-  IPC_SEMAPHORE_DESTROY (sem);
+  GNUNET_free (fn);
+  GNUNET_IPC_semaphore_up (sem);
+  GNUNET_IPC_semaphore_destroy (sem);
   URITRACK_clearTrackedURIS (ectx, cfg);
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 

Modified: GNUnet/src/applications/fs/uritrack/tracktest.c
===================================================================
--- GNUnet/src/applications/fs/uritrack/tracktest.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/uritrack/tracktest.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -42,7 +42,7 @@
 
 static int
 notified (const ECRS_FileInfo * fi,
-          const HashCode512 * key, int isRoot, void *cls)
+          const GNUNET_HashCode * key, int isRoot, void *cls)
 {
   if ((fi1.meta != NULL) &&
       (fi1.uri != NULL) &&
@@ -50,7 +50,7 @@
                             fi1.meta)) && (ECRS_equalsUri (fi->uri, fi1.uri)))
     {
       notifications++;
-      return OK;
+      return GNUNET_OK;
     }
   if ((fi2.meta != NULL) &&
       (fi2.uri != NULL) &&
@@ -58,14 +58,14 @@
                             fi2.meta)) && (ECRS_equalsUri (fi->uri, fi2.uri)))
     {
       notifications++;
-      return OK;
+      return GNUNET_OK;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
 processor (const ECRS_FileInfo * fi,
-           const HashCode512 * key, int isRoot, void *cls)
+           const GNUNET_HashCode * key, int isRoot, void *cls)
 {
   if ((fi1.meta != NULL) &&
       (fi1.uri != NULL) &&
@@ -76,7 +76,7 @@
       fi1.uri = NULL;
       ECRS_freeMetaData (fi1.meta);
       fi1.meta = NULL;
-      return OK;
+      return GNUNET_OK;
     }
   if ((fi2.meta != NULL) &&
       (fi2.uri != NULL) &&
@@ -87,9 +87,9 @@
       fi2.uri = NULL;
       ECRS_freeMetaData (fi2.meta);
       fi2.meta = NULL;
-      return OK;
+      return GNUNET_OK;
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 static int
@@ -112,23 +112,23 @@
 
   URITRACK_clearTrackedURIS (NULL, cfg);
   URITRACK_registerTrackCallback (NULL, cfg, &notified, NULL);
-  URITRACK_trackURIS (NULL, cfg, NO);
+  URITRACK_trackURIS (NULL, cfg, GNUNET_NO);
   URITRACK_clearTrackedURIS (NULL, cfg);
   /* test non-tracking */
   URITRACK_trackURI (NULL, cfg, &fi1);
-  CHECK (0 == URITRACK_listURIs (NULL, cfg, NO, NULL, NULL));
-  CHECK (NO == URITRACK_trackStatus (NULL, cfg));
+  CHECK (0 == URITRACK_listURIs (NULL, cfg, GNUNET_NO, NULL, NULL));
+  CHECK (GNUNET_NO == URITRACK_trackStatus (NULL, cfg));
   URITRACK_clearTrackedURIS (NULL, cfg);
-  URITRACK_trackURIS (NULL, cfg, YES);
+  URITRACK_trackURIS (NULL, cfg, GNUNET_YES);
   URITRACK_clearTrackedURIS (NULL, cfg);
-  CHECK (0 == URITRACK_listURIs (NULL, cfg, NO, NULL, NULL));
-  CHECK (YES == URITRACK_trackStatus (NULL, cfg));
+  CHECK (0 == URITRACK_listURIs (NULL, cfg, GNUNET_NO, NULL, NULL));
+  CHECK (GNUNET_YES == URITRACK_trackStatus (NULL, cfg));
   URITRACK_trackURI (NULL, cfg, &fi1);
-  CHECK (1 == URITRACK_listURIs (NULL, cfg, NO, NULL, NULL));
+  CHECK (1 == URITRACK_listURIs (NULL, cfg, GNUNET_NO, NULL, NULL));
   URITRACK_trackURI (NULL, cfg, &fi2);
-  CHECK (2 == URITRACK_listURIs (NULL, cfg, YES, &processor, NULL));
-  URITRACK_trackURIS (NULL, cfg, NO);
-  CHECK (NO == URITRACK_trackStatus (NULL, cfg));
+  CHECK (2 == URITRACK_listURIs (NULL, cfg, GNUNET_YES, &processor, NULL));
+  URITRACK_trackURIS (NULL, cfg, GNUNET_NO);
+  CHECK (GNUNET_NO == URITRACK_trackStatus (NULL, cfg));
   URITRACK_clearTrackedURIS (NULL, cfg);
   CHECK (notifications == 2);
   URITRACK_unregisterTrackCallback (&notified, NULL);
@@ -140,7 +140,7 @@
 {
   int failureCount = 0;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);

Modified: GNUnet/src/applications/fs/uritrack/uri_info.c
===================================================================
--- GNUnet/src/applications/fs/uritrack/uri_info.c      2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/fs/uritrack/uri_info.c      2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -45,9 +45,9 @@
                                        "GNUNET_HOME",
                                        GNUNET_HOME_DIRECTORY, &basename);
   n = strlen (basename) + 512;
-  ipcName = MALLOC (n);
-  SNPRINTF (ipcName, n, "%s/uri_info.db", basename);
-  FREE (basename);
+  ipcName = GNUNET_malloc (n);
+  GNUNET_snprintf (ipcName, n, "%s/uri_info.db", basename);
+  GNUNET_free (basename);
   return ipcName;
 }
 
@@ -71,7 +71,7 @@
  * information that we give back maybe inaccurate (returning
  * URITRACK_FRESH if the URI did not fit into our bounded-size map,
  * even if the URI is not fresh anymore; also, if the URI has a
- * hash-collision in the map, there is a 1:256 chance that we will
+ * GNUNET_hash-collision in the map, there is a 1:256 chance that we will
  * return information from the wrong URI without detecting it).
  */
 enum URITRACK_STATE
@@ -86,14 +86,14 @@
   off_t o;
 
   s = ECRS_uriToString (uri);
-  crc = crc32N (s, strlen (s));
-  FREE (s);
+  crc = GNUNET_crc32_n (s, strlen (s));
+  GNUNET_free (s);
   s = getDBName (cfg);
-  if (NO == disk_file_test (ectx, s))
+  if (GNUNET_NO == GNUNET_disk_file_test (ectx, s))
     return URITRACK_FRESH;
   size = getDBSize (cfg);
-  fd = disk_file_open (ectx, s, O_RDONLY);
-  FREE (s);
+  fd = GNUNET_disk_file_open (ectx, s, O_RDONLY);
+  GNUNET_free (s);
   if (fd == -1)
     return URITRACK_FRESH;
   o = 2 * (crc % size);
@@ -132,14 +132,14 @@
   off_t o;
 
   s = ECRS_uriToString (uri);
-  crc = crc32N (s, strlen (s));
-  FREE (s);
+  crc = GNUNET_crc32_n (s, strlen (s));
+  GNUNET_free (s);
   s = getDBName (cfg);
   size = getDBSize (cfg);
-  fd = disk_file_open (ectx, s, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+  fd = GNUNET_disk_file_open (ectx, s, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
   if (fd == -1)
     {
-      FREE (s);
+      GNUNET_free (s);
       return;
     }
   o = 2 * (crc % size);
@@ -149,7 +149,7 @@
                             GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
                             "lseek", s);
       CLOSE (fd);
-      FREE (s);
+      GNUNET_free (s);
       return;
     }
   if (2 != read (fd, io, 2))
@@ -169,15 +169,15 @@
                             GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
                             "lseek", s);
       CLOSE (fd);
-      FREE (s);
+      GNUNET_free (s);
       return;
     }
   if (2 != write (fd, io, 2))
     GE_LOG_STRERROR_FILE (ectx,
                           GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
                           "write", s);
-  disk_file_close (ectx, s, fd);
-  FREE (s);
+  GNUNET_disk_file_close (ectx, s, fd);
+  GNUNET_free (s);
 }
 
 /* end of uri_info.c */

Modified: GNUnet/src/applications/gap/Makefile.am
===================================================================
--- GNUnet/src/applications/gap/Makefile.am     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/gap/Makefile.am     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -3,9 +3,7 @@
 plugindir = $(libdir)/GNUnet
 
 LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 plugin_LTLIBRARIES = \
   libgnunetmodule_gap.la
@@ -31,9 +29,6 @@
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 
@@ -43,9 +38,6 @@
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 
@@ -56,9 +48,6 @@
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la  \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la  \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 

Modified: GNUnet/src/applications/gap/gap.c
===================================================================
--- GNUnet/src/applications/gap/gap.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/gap/gap.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -40,7 +40,7 @@
 /**
  * Only for debugging / system analysis!
  */
-#define DO_HISTOGRAM NO
+#define DO_HISTOGRAM GNUNET_NO
 
 /* ********************** GLOBALS ******************** */
 
@@ -48,7 +48,7 @@
  * Avoiding concurrent lookups for the same ITE: lock to grant
  * access to peers to perform a lookup that matches this ITE entry.
  */
-static struct MUTEX *lookup_exclusion;
+static struct GNUNET_Mutex *lookup_exclusion;
 
 /**
  * GNUnet core.
@@ -155,7 +155,7 @@
 /**
  * Mutex for all gap structures.
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * Linked list tracking reply statistics.  Synchronize access using
@@ -214,10 +214,11 @@
  * @return binary encoding: QUERY_XXXX constants
  */
 static QUERY_POLICY
-evaluateQuery (const PeerIdentity * sender, unsigned int *priority)
+evaluateQuery (const GNUNET_PeerIdentity * sender, unsigned int *priority)
 {
-  unsigned int netLoad = os_network_monitor_get_load (coreAPI->load_monitor,
-                                                      Upload);
+  unsigned int netLoad =
+    GNUNET_network_monitor_get_load (coreAPI->load_monitor,
+                                     GNUNET_ND_UPLOAD);
 
   if ((netLoad == (unsigned int) -1) || (netLoad < GAP_IDLE_LOAD_THRESHOLD))
     {
@@ -240,7 +241,7 @@
  * Map the id to an index into the bitmap array.
  */
 static unsigned int
-getIndex (const PeerIdentity * peer)
+getIndex (const GNUNET_PeerIdentity * peer)
 {
   return ((unsigned int *) peer)[0] % (8 * BITMAP_SIZE);
 }
@@ -274,20 +275,20 @@
   ResponseList *rpos;
   ResponseList *rprev;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   prev = NULL;
   pos = rtdList;
   while (pos != NULL)
     {
       /* after 10 minutes, always discard everything */
-      if (pos->lastReplyReceived < TIME (NULL) - 600)
+      if (pos->lastReplyReceived < GNUNET_get_time_int32 (NULL) - 600)
         {
           while (pos->responseList != NULL)
             {
               rpos = pos->responseList;
               pos->responseList = rpos->next;
               change_pid_rc (rpos->responder, -1);
-              FREE (rpos);
+              GNUNET_free (rpos);
             }
         }
       /* otherwise, age reply counts */
@@ -305,7 +306,7 @@
               else
                 rprev->next = rpos->next;
               change_pid_rc (rpos->responder, -1);
-              FREE (rpos);
+              GNUNET_free (rpos);
               if (rprev == NULL)
                 rpos = pos->responseList;
               else
@@ -324,7 +325,7 @@
           else
             prev->next = pos->next;
           change_pid_rc (pos->queryOrigin, -1);
-          FREE (pos);
+          GNUNET_free (pos);
           if (prev == NULL)
             pos = rtdList;
           else
@@ -334,7 +335,7 @@
       prev = pos;
       pos = pos->next;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 /**
@@ -354,7 +355,7 @@
 
   if (responder == 0)
     return;                     /* we don't track local responses */
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   pos = rtdList;
   prev = NULL;
   while (pos != NULL)
@@ -366,7 +367,7 @@
     }
   if (pos == NULL)
     {
-      pos = MALLOC (sizeof (ReplyTrackData));
+      pos = GNUNET_malloc (sizeof (ReplyTrackData));
       pos->next = NULL;
       pos->responseList = NULL;
       pos->queryOrigin = origin;
@@ -376,7 +377,7 @@
       else
         prev->next = pos;
     }
-  TIME (&pos->lastReplyReceived);
+  GNUNET_get_time_int32 (&pos->lastReplyReceived);
   rpos = pos->responseList;
   rprev = NULL;
   while (rpos != NULL)
@@ -386,13 +387,13 @@
           rpos->responseCount++;
           if (stats != NULL)
             stats->change (stat_response_count, 1);
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           return;
         }
       rprev = rpos;
       rpos = rpos->next;
     }
-  rpos = MALLOC (sizeof (ResponseList));
+  rpos = GNUNET_malloc (sizeof (ResponseList));
   rpos->responseCount = 1;
   if (stats != NULL)
     stats->change (stat_response_count, 1);
@@ -403,7 +404,7 @@
     pos->responseList = rpos;
   else
     rprev->next = rpos;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 /**
@@ -424,19 +425,19 @@
  *   that buffer (must be a positive number).
  */
 static unsigned int
-fillInQuery (const PeerIdentity * receiver,
+fillInQuery (const GNUNET_PeerIdentity * receiver,
              void *position, unsigned int padding)
 {
   static unsigned int pos = 0;
   unsigned int start;
   unsigned int delta;
-  cron_t now;
+  GNUNET_CronTime now;
   QueryRecord *qr;
   PID_INDEX receiverId;
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   receiverId = intern_pid (receiver);
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   start = pos;
   delta = 0;
   while (padding - delta > sizeof (P2P_gap_query_MESSAGE))
@@ -445,9 +446,10 @@
       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 != memcmp (&receiver->hashPubKey,
+                        &qr->msg->returnTo.hashPubKey,
+                        sizeof (GNUNET_HashCode)))
+          && (padding - delta >= ntohs (qr->msg->header.size)))
         {
           setBit (&queries[pos], getIndex (receiver));
           memcpy (&((char *) position)[delta],
@@ -461,7 +463,7 @@
       if (pos == start)
         break;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   change_pid_rc (receiverId, -1);
   return delta;
 }
@@ -471,7 +473,7 @@
  * on each connected node by the core.
  */
 static void
-hotpathSelectionCode (const PeerIdentity * peer, void *cls)
+hotpathSelectionCode (const GNUNET_PeerIdentity * peer, void *cls)
 {
   QueryRecord *qr = cls;
   ReplyTrackData *pos;
@@ -481,8 +483,8 @@
   PID_INDEX id;
   unsigned int idx;
 #if DEBUG_GAP
-  EncName enc;
-  EncName enc2;
+  GNUNET_EncName enc;
+  GNUNET_EncName enc2;
 #endif
 
   id = intern_pid (peer);
@@ -513,18 +515,18 @@
             ranking = 0x7FFFFFF;
         }
     }
-  distance = distanceHashCode512 (&qr->msg->queries[0], &peer->hashPubKey) >> 
10;       /* change to value in [0:63] */
+  distance = GNUNET_hash_distance_u32 (&qr->msg->queries[0], 
&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 */
-  ranking += weak_randomi (0xFFFF);     /* 2 "response equivalents" random 
chance for everyone */
+  ranking += GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 1 + 0xFFFF * 10 / 
(1 + distance));  /* 0 to 20 "response equivalents" for proximity */
+  ranking += GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 0xFFFF);    /* 2 
"response equivalents" random chance for everyone */
   if (id == qr->noTarget)
     ranking = 0;                /* no chance for blocked peers */
   idx = getIndex (peer);
 #if DEBUG_GAP
-  hash2enc (&qr->msg->queries[0], &enc);
+  GNUNET_hash_to_enc (&qr->msg->queries[0], &enc);
   ((char *) &enc)[6] = '\0';
-  hash2enc (&peer->hashPubKey, &enc2);
+  GNUNET_hash_to_enc (&peer->hashPubKey, &enc2);
   ((char *) &enc2)[6] = '\0';
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -547,11 +549,11 @@
 loadTooHigh ()
 {
   return ((hardCPULimit > 0) &&
-          (os_cpu_get_load (ectx,
-                            coreAPI->cfg) >= hardCPULimit)) ||
+          (GNUNET_cpu_get_load (ectx,
+                                coreAPI->cfg) >= hardCPULimit)) ||
     ((hardUpLimit > 0) &&
-     (os_network_monitor_get_load (coreAPI->load_monitor,
-                                   Upload) >= hardUpLimit));
+     (GNUNET_network_monitor_get_load (coreAPI->load_monitor,
+                                       GNUNET_ND_UPLOAD) >= hardUpLimit));
 }
 
 /**
@@ -559,16 +561,18 @@
  * nodes.
  */
 static void
-sendToSelected (const PeerIdentity * peer, void *cls)
+sendToSelected (const GNUNET_PeerIdentity * peer, void *cls)
 {
   const QueryRecord *qr = cls;
   PID_INDEX id;
 #if DEBUG_GAP
-  EncName encq;
-  EncName encp;
+  GNUNET_EncName encq;
+  GNUNET_EncName encp;
 #endif
 
-  if (equalsHashCode512 (&peer->hashPubKey, &qr->msg->returnTo.hashPubKey))
+  if (0 ==
+      memcmp (&peer->hashPubKey, &qr->msg->returnTo.hashPubKey,
+              sizeof (GNUNET_HashCode)))
     return;                     /* never send back to source */
 
   /* Load above hard limit? */
@@ -587,8 +591,8 @@
 #if DEBUG_GAP
       IF_GELOG (ectx,
                 GE_DEBUG | GE_REQUEST | GE_USER,
-                hash2enc (&peer->hashPubKey, &encp);
-                hash2enc (&qr->msg->queries[0], &encq));
+                GNUNET_hash_to_enc (&peer->hashPubKey, &encp);
+                GNUNET_hash_to_enc (&qr->msg->queries[0], &encq));
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "Sending query `%s' to `%s'\n", &encq, &encp);
@@ -609,17 +613,18 @@
  */
 static void
 forwardQuery (const P2P_gap_query_MESSAGE * msg,
-              const PeerIdentity * target, const PeerIdentity * excludePeer)
+              const GNUNET_PeerIdentity * target,
+              const GNUNET_PeerIdentity * excludePeer)
 {
-  cron_t now;
+  GNUNET_CronTime now;
   QueryRecord *qr;
   QueryRecord dummy;
-  cron_t oldestTime;
-  cron_t expirationTime;
+  GNUNET_CronTime oldestTime;
+  GNUNET_CronTime expirationTime;
   int oldestIndex;
   int i;
   int j;
-  int noclear = NO;
+  int noclear = GNUNET_NO;
   unsigned long long rankingSum;
   unsigned long long sel;
   unsigned long long pos;
@@ -630,8 +635,8 @@
       /* connect to target host -- if known */
       coreAPI->unicast (target, NULL, ntohl (msg->priority), 0);
     }
-  now = get_time ();
-  MUTEX_LOCK (lock);
+  now = GNUNET_get_time ();
+  GNUNET_mutex_lock (lock);
 
   oldestIndex = -1;
   expirationTime = now + ntohl (msg->ttl);
@@ -650,13 +655,13 @@
                         &msg->queries[0],
                         ntohs (msg->header.size)
                         - sizeof (P2P_gap_query_MESSAGE)
-                        + sizeof (HashCode512))))
+                        + sizeof (GNUNET_HashCode))))
         {
           /* We have exactly this query pending already.
              Replace existing query! */
           oldestIndex = i;
           if ((queries[i].expires > now - 4 * TTL_DECREMENT) && /* not long 
expired */
-              (weak_randomi (4) != 0))
+              (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 4) != 0))
             {
               /* do not clear the bitmap describing which peers we have
                  forwarded the query to already; but do this only with high
@@ -676,7 +681,7 @@
                  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 = GNUNET_YES;
             }
           break;                /* this is it, do not scan for other
                                    'oldest' entries */
@@ -690,14 +695,14 @@
   else
     {
       qr = &queries[oldestIndex];
-      FREENONNULL (qr->msg);
+      GNUNET_free_non_null (qr->msg);
       qr->msg = NULL;
     }
   qr->expires = expirationTime;
   qr->transmissionCount = 0;
-  qr->msg = MALLOC (ntohs (msg->header.size));
+  qr->msg = GNUNET_malloc (ntohs (msg->header.size));
   memcpy (qr->msg, msg, ntohs (msg->header.size));
-  if (noclear == NO)
+  if (noclear == GNUNET_NO)
     memset (&qr->bitmap[0], 0, BITMAP_SIZE);
 
   if (qr->noTarget != 0)
@@ -707,7 +712,7 @@
   else
     qr->noTarget = intern_pid (coreAPI->myIdentity);
   qr->totalDistance = 0;
-  qr->rankings = MALLOC (sizeof (int) * 8 * BITMAP_SIZE);
+  qr->rankings = GNUNET_malloc (sizeof (int) * 8 * BITMAP_SIZE);
   qr->activeConnections
     = coreAPI->forAllConnectedNodes (&hotpathSelectionCode, qr);
   /* actual selection, proportional to rankings
@@ -722,7 +727,7 @@
         {
           if (rankingSum == 0)
             break;
-          sel = weak_randomi64 (rankingSum);
+          sel = GNUNET_random_u64 (GNUNET_RANDOM_QUALITY_WEAK, rankingSum);
           pos = 0;
           for (j = 0; j < 8 * BITMAP_SIZE; j++)
             {
@@ -738,7 +743,7 @@
             }
         }
     }
-  FREE (qr->rankings);
+  GNUNET_free (qr->rankings);
   qr->rankings = NULL;
   if (target != NULL)
     {
@@ -751,9 +756,9 @@
   if (qr == &dummy)
     {
       change_pid_rc (dummy.noTarget, -1);
-      FREE (dummy.msg);
+      GNUNET_free (dummy.msg);
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 /**
@@ -761,28 +766,29 @@
  * we have learned the answer).
  */
 static int
-dequeueQuery (const HashCode512 * query)
+dequeueQuery (const GNUNET_HashCode * query)
 {
   int i;
   int ret;
   QueryRecord *qr;
 
-  ret = SYSERR;
-  MUTEX_LOCK (lock);
+  ret = GNUNET_SYSERR;
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < QUERY_RECORD_COUNT; i++)
     {
       qr = &queries[i];
       if (qr->msg != NULL)
         {
-          if (equalsHashCode512 (query, &qr->msg->queries[0]))
+          if (0 ==
+              memcmp (query, &qr->msg->queries[0], sizeof (GNUNET_HashCode)))
             {
               qr->expires = 0;  /* expire NOW! */
-              ret = OK;
+              ret = GNUNET_OK;
               break;
             }
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return ret;
 }
 
@@ -792,7 +798,7 @@
  * Compute the hashtable index of a host id.
  */
 static unsigned int
-computeRoutingIndex (const HashCode512 * query)
+computeRoutingIndex (const GNUNET_HashCode * query)
 {
   unsigned int res
     = (((unsigned int *) query)[0] ^
@@ -819,8 +825,8 @@
  * @param hostId the peer from where the content came,
  *     NULL for the local peer
  */
-static int useContent (const PeerIdentity * hostId,
-                       const MESSAGE_HEADER * pmsg);
+static int useContent (const GNUNET_PeerIdentity * hostId,
+                       const GNUNET_MessageHeader * pmsg);
 
 /**
  * Call useContent "later" and then free the pmsg.
@@ -828,9 +834,9 @@
 static void
 useContentLater (void *data)
 {
-  MESSAGE_HEADER *pmsg = data;
+  GNUNET_MessageHeader *pmsg = data;
   useContent (NULL, pmsg);
-  FREE (pmsg);
+  GNUNET_free (pmsg);
 }
 
 /**
@@ -847,75 +853,77 @@
  *  the type ID).
  */
 static int
-queueReply (const PeerIdentity * sender,
-            const HashCode512 * primaryKey, const DataContainer * data)
+queueReply (const GNUNET_PeerIdentity * sender,
+            const GNUNET_HashCode * primaryKey, const DataContainer * data)
 {
   P2P_gap_reply_MESSAGE *pmsg;
   IndirectionTableEntry *ite;
   unsigned int size;
 #if DEBUG_GAP
-  EncName enc;
+  GNUNET_EncName enc;
 
   IF_GELOG (ectx,
-            GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (primaryKey, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+            GE_DEBUG | GE_REQUEST | GE_USER, GNUNET_hash_to_enc (primaryKey,
+                                                                 &enc));
+  GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "Gap queues reply to query `%s' for later use.\n", &enc);
 #endif
 
 #if EXTRA_CHECKS
   /* verify data is valid */
-  uri (data, ANY_BLOCK, YES, primaryKey);
+  uri (data, ANY_BLOCK, GNUNET_YES, primaryKey);
 #endif
 
   ite = &ROUTING_indTable_[computeRoutingIndex (primaryKey)];
-  if (!equalsHashCode512 (&ite->primaryKey, primaryKey))
+  if (0 != memcmp (&ite->primaryKey, primaryKey, sizeof (GNUNET_HashCode)))
     {
 #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");
 #endif
-      return NO;                /* we don't care for the reply (anymore) */
+      return GNUNET_NO;         /* we don't care for the reply (anymore) */
     }
-  if (YES == ite->successful_local_lookup_in_delay_loop)
+  if (GNUNET_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");
 #endif
-      return NO;                /* wow, really bad concurrent DB lookup and 
processing for
+      return GNUNET_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... */
     }
   size =
     sizeof (P2P_gap_reply_MESSAGE) + ntohl (data->size) -
     sizeof (DataContainer);
-  if (size >= MAX_BUFFER_SIZE)
+  if (size >= GNUNET_MAX_BUFFER_SIZE)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  ite->successful_local_lookup_in_delay_loop = YES;
-  pmsg = MALLOC (size);
+  ite->successful_local_lookup_in_delay_loop = GNUNET_YES;
+  pmsg = GNUNET_malloc (size);
   pmsg->header.size = htons (size);
   pmsg->header.type = htons (P2P_PROTO_gap_RESULT);
   pmsg->primaryKey = *primaryKey;
   memcpy (&pmsg[1], &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);
-  return YES;
+  GNUNET_cron_add_job (coreAPI->cron,
+                       &useContentLater,
+                       GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                                          TTL_DECREMENT), 0, pmsg);
+  return GNUNET_YES;
 }
 
 static void
-addReward (const HashCode512 * query, unsigned int prio)
+addReward (const GNUNET_HashCode * query, unsigned int prio)
 {
   if (prio == 0)
     return;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   rewards[rewardPos].query = *query;
   if (stats != NULL)
     stats->change (stat_pending_rewards, prio - rewards[rewardPos].prio);
@@ -923,20 +931,20 @@
   rewardPos++;
   if (rewardPos == rewardSize)
     rewardPos = 0;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 static unsigned int
-claimReward (const HashCode512 * query)
+claimReward (const GNUNET_HashCode * query)
 {
   int i;
   unsigned int ret;
 
   ret = 0;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < rewardSize; i++)
     {
-      if (equalsHashCode512 (query, &rewards[i].query))
+      if (0 == memcmp (query, &rewards[i].query, sizeof (GNUNET_HashCode)))
         {
           ret += rewards[i].prio;
           if (stats != NULL)
@@ -944,7 +952,7 @@
           rewards[i].prio = 0;
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return ret;
 }
 
@@ -953,7 +961,7 @@
 {
   if (stats != NULL)
     stats->change (stat_memory_seen, -ite->seenIndex);
-  GROW (ite->seen, ite->seenIndex, 0);
+  GNUNET_array_grow (ite->seen, ite->seenIndex, 0);
 }
 
 static void
@@ -962,7 +970,7 @@
   decrement_pid_rcs (ite->destination, ite->hostsWaiting);
   if (stats != NULL)
     stats->change (stat_memory_destinations, -ite->hostsWaiting);
-  GROW (ite->destination, ite->hostsWaiting, 0);
+  GNUNET_array_grow (ite->destination, ite->hostsWaiting, 0);
 }
 
 /**
@@ -975,47 +983,47 @@
  * @param ttl how long to keep the new entry, relative ttl
  * @param priority how important is the new entry
  * @param sender for which node is the entry
- * @return OK if sender was added, SYSERR if existed already
+ * @return GNUNET_OK if sender was added, GNUNET_SYSERR if existed already
  *            in the queue
  */
 static int
 addToSlot (int mode,
            IndirectionTableEntry * ite,
-           const HashCode512 * query,
+           const GNUNET_HashCode * query,
            int ttl, unsigned int priority, PID_INDEX sender)
 {
   unsigned int i;
-  cron_t now;
+  GNUNET_CronTime now;
 #if DEBUG__GAP
-  EncName enc;
+  GNUNET_EncName enc;
 
-  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, hash2enc (query, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
+            GNUNET_hash_to_enc (query, &enc));
+  GE_LOG (ectx, 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 ();
+  now = GNUNET_get_time ();
   if ((stats != NULL) && (ite->ttl == 0))
     stats->change (stat_routing_slots_used, 1);
 
   if (mode == ITE_REPLACE)
     {
       resetSeen (ite);
-      ite->seenReplyWasUnique = NO;
-      if (equalsHashCode512 (query, &ite->primaryKey))
+      ite->seenReplyWasUnique = GNUNET_NO;
+      if (0 == memcmp (query, &ite->primaryKey, sizeof (GNUNET_HashCode)))
         {
           ite->ttl = now + ttl;
           ite->priority += priority;
           for (i = 0; i < ite->hostsWaiting; i++)
             if (ite->destination[i] == sender)
-              return SYSERR;
+              return GNUNET_SYSERR;
           if (ite->hostsWaiting >= MAX_HOSTS_WAITING)
             resetDestinations (ite);
         }
       else
         {
-          ite->successful_local_lookup_in_delay_loop = NO;
+          ite->successful_local_lookup_in_delay_loop = GNUNET_NO;
           /* different request, flush pending queues */
           dequeueQuery (&ite->primaryKey);
           ite->primaryKey = *query;
@@ -1025,33 +1033,36 @@
         }
     }
   else
-    {                           /* GROW mode */
-      GE_ASSERT (ectx, equalsHashCode512 (query, &ite->primaryKey));
+    {                           /* GNUNET_array_grow mode */
+      GE_ASSERT (ectx,
+                 0 == memcmp (query, &ite->primaryKey,
+                              sizeof (GNUNET_HashCode)));
       /* 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 GNUNET_SYSERR; /* already there! */
     }
   if (stats != NULL)
     stats->change (stat_memory_destinations, 1);
-  GROW (ite->destination, ite->hostsWaiting, ite->hostsWaiting + 1);
+  GNUNET_array_grow (ite->destination, ite->hostsWaiting,
+                     ite->hostsWaiting + 1);
   ite->destination[ite->hostsWaiting - 1] = sender;
   change_pid_rc (sender, 1);
   /* again: new listener, flush seen list */
   resetSeen (ite);
-  ite->seenReplyWasUnique = NO;
-  return OK;
+  ite->seenReplyWasUnique = GNUNET_NO;
+  return GNUNET_OK;
 }
 
 /**
  * Find out, if this query is already pending. If the ttl of
  * the new query is higher than the ttl of an existing query,
- * NO is returned since we should re-send the query.<p>
+ * GNUNET_NO is returned since we should re-send the query.<p>
  *
- * If YES is returned, the slot is also marked as used by
+ * If GNUNET_YES is returned, the slot is also marked as used by
  * the query and the sender (HostId or socket) is added.<p>
  *
  * This method contains a heuristic that attempts to do its best to
@@ -1062,41 +1073,42 @@
  * of code than anyone on this planet would think is possible.
  *
  *
- * @param query the hash to look for
+ * @param query the GNUNET_hash to look for
  * @param ttl how long would the new query last
  * @param priority the priority of the query
  * @param sender which peer transmitted the query?
- * @param isRouted set to OK if we can route this
- *        query, SYSERR if we can not
- * @param doForward is set to OK if we should
- *        forward the query, SYSERR if not
+ * @param isRouted set to GNUNET_OK if we can route this
+ *        query, GNUNET_SYSERR if we can not
+ * @param doForward is set to GNUNET_OK if we should
+ *        forward the query, GNUNET_SYSERR if not
  * @return a case ID for debugging
  */
 static int
-needsForwarding (const HashCode512 * query,
+needsForwarding (const GNUNET_HashCode * query,
                  int ttl,
                  unsigned int priority,
                  PID_INDEX sender, int *isRouted, int *doForward)
 {
   IndirectionTableEntry *ite;
-  cron_t now;
-  cron_t new_ttl;
+  GNUNET_CronTime now;
+  GNUNET_CronTime new_ttl;
   int equal_to_pending;
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   ite = &ROUTING_indTable_[computeRoutingIndex (query)];
-  equal_to_pending = equalsHashCode512 (query, &ite->primaryKey);
+  equal_to_pending =
+    memcmp (query, &ite->primaryKey, sizeof (GNUNET_HashCode));
   if ((stats != NULL) && (equal_to_pending))
     stats->change (stat_routing_request_duplicates, 1);
 
   new_ttl = now + ttl;
   if ((ite->ttl < now) &&
-      (ite->ttl < now - (cron_t) (TTL_DECREMENT * 10L)) &&
+      (ite->ttl < now - (GNUNET_CronTime) (TTL_DECREMENT * 10L)) &&
       (ttl > -TTL_DECREMENT * 5))
     {
       addToSlot (ITE_REPLACE, ite, query, ttl, priority, sender);
-      *isRouted = YES;
-      *doForward = YES;
+      *isRouted = GNUNET_YES;
+      *doForward = GNUNET_YES;
       return 21;
     }
   if ((ttl < 0) && (equal_to_pending))
@@ -1104,20 +1116,21 @@
       /* if ttl is "expired" and we have
          the exact query pending, route
          replies but do NOT forward _again_! */
-      addToSlot (ITE_GROW, ite, query, ttl, priority, sender);
-      *isRouted = NO;
+      addToSlot (ITE_GNUNET_array_grow, ite, query, ttl, priority, sender);
+      *isRouted = GNUNET_NO;
       /* don't go again, we are not even going to reset the seen
          list, so why bother looking locally again, if we would find
          something, the seen list would block sending the reply anyway
          since we're not resetting that (ttl too small!)! */
-      *doForward = NO;
+      *doForward = GNUNET_NO;
       return 0;
     }
 
   if ((ite->ttl < new_ttl) &&
       (ite->ttl +
-       (cron_t) (TTL_DECREMENT * topology->estimateNetworkSize ()) < new_ttl)
-      && (ite->ttl + (cron_t) (TTL_DECREMENT * 10L) < new_ttl)
+       (GNUNET_CronTime) (TTL_DECREMENT * topology->estimateNetworkSize ()) <
+       new_ttl)
+      && (ite->ttl + (GNUNET_CronTime) (TTL_DECREMENT * 10L) < new_ttl)
       && (ite->ttl < now))
     {
       /* expired AND is significantly (!)
@@ -1125,19 +1138,20 @@
       /* previous entry relatively expired, start using the slot --
          and kill the old seen list! */
       resetSeen (ite);
-      ite->seenReplyWasUnique = NO;
+      ite->seenReplyWasUnique = GNUNET_NO;
       if ((equal_to_pending) &&
-          (YES == ite->successful_local_lookup_in_delay_loop))
+          (GNUNET_YES == ite->successful_local_lookup_in_delay_loop))
         {
-          *isRouted = NO;
-          *doForward = NO;
-          addToSlot (ITE_GROW, ite, query, ttl, priority, sender);
+          *isRouted = GNUNET_NO;
+          *doForward = GNUNET_NO;
+          addToSlot (ITE_GNUNET_array_grow, ite, query, ttl, priority,
+                     sender);
           return 1;
         }
       else
         {
-          *isRouted = YES;
-          *doForward = YES;
+          *isRouted = GNUNET_YES;
+          *doForward = GNUNET_YES;
           if ((stats != NULL) && (equal_to_pending))
             {
               stats->change (stat_routing_request_repeat, 1);
@@ -1156,22 +1170,22 @@
       if (ite->seenIndex == 0)
         {
           if ((ite->ttl < new_ttl) &&
-              (ite->ttl + (cron_t) TTL_DECREMENT < new_ttl))
+              (ite->ttl + (GNUNET_CronTime) TTL_DECREMENT < new_ttl))
             {
               /* ttl of new is SIGNIFICANTLY longer? */
               /* query again */
-              if (YES == ite->successful_local_lookup_in_delay_loop)
+              if (GNUNET_YES == ite->successful_local_lookup_in_delay_loop)
                 {
-                  *isRouted = NO;       /* don't go again, we are already
-                                           processing a local lookup! */
-                  *doForward = NO;
+                  *isRouted = GNUNET_NO;        /* don't go again, we are 
already
+                                                   processing a local lookup! 
*/
+                  *doForward = GNUNET_NO;
                   addToSlot (ITE_REPLACE, ite, query, ttl, priority, sender);
                   return 3;
                 }
               else
                 {
-                  *isRouted = YES;
-                  *doForward = YES;
+                  *isRouted = GNUNET_YES;
+                  *doForward = GNUNET_YES;
                   if (stats != NULL)
                     {
                       stats->change (stat_routing_request_repeat, 1);
@@ -1189,30 +1203,32 @@
             {
               /* 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 (GNUNET_OK ==
+                  addToSlot (ITE_GNUNET_array_grow, ite, query, ttl, priority,
+                             sender))
                 {
-                  if (YES == ite->successful_local_lookup_in_delay_loop)
+                  if (GNUNET_YES ==
+                      ite->successful_local_lookup_in_delay_loop)
                     {
-                      *isRouted = NO;
+                      *isRouted = GNUNET_NO;
                       /* don't go again, we are already processing a
                          local lookup! */
-                      *doForward = NO;
+                      *doForward = GNUNET_NO;
                       return 5;
                     }
                   else
                     {
-                      *isRouted = YES;
-                      *doForward = NO;
+                      *isRouted = GNUNET_YES;
+                      *doForward = GNUNET_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;
+                  *isRouted = GNUNET_NO;        /* same query with _higher_ 
TTL has already been
+                                                   processed FOR THE SAME 
recipient! Do NOT do
+                                                   the lookup *again*. */
+                  *doForward = GNUNET_NO;
                   return 7;
                 }
             }
@@ -1227,22 +1243,22 @@
             {                   /* ttl of new is longer? */
               /* go again */
               resetSeen (ite);
-              ite->seenReplyWasUnique = NO;
-              if (YES == ite->successful_local_lookup_in_delay_loop)
+              ite->seenReplyWasUnique = GNUNET_NO;
+              if (GNUNET_YES == ite->successful_local_lookup_in_delay_loop)
                 {
-                  *isRouted = NO;
+                  *isRouted = GNUNET_NO;
                   /* don't go again, we are already processing a local lookup! 
*/
-                  *doForward = NO;
+                  *doForward = GNUNET_NO;
                   addToSlot (ITE_REPLACE, ite, query, ttl, priority, sender);
                   return 8;
                 }
               else
                 {
-                  *isRouted = YES;
+                  *isRouted = GNUNET_YES;
                   /* only forward if new TTL is significantly higher */
                   if (ite->ttl + TTL_DECREMENT < new_ttl)
                     {
-                      *doForward = YES;
+                      *doForward = GNUNET_YES;
                       if (stats != NULL)
                         {
                           stats->change (stat_routing_request_repeat, 1);
@@ -1254,7 +1270,7 @@
                         }
                     }
                   else
-                    *doForward = NO;
+                    *doForward = GNUNET_NO;
                   addToSlot (ITE_REPLACE, ite, query, ttl, priority, sender);
                   return 9;
                 }
@@ -1263,26 +1279,28 @@
             {
               /* 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 (GNUNET_OK ==
+                  addToSlot (ITE_GNUNET_array_grow, ite, query, ttl, priority,
+                             sender))
                 {
-                  if (YES == ite->successful_local_lookup_in_delay_loop)
+                  if (GNUNET_YES ==
+                      ite->successful_local_lookup_in_delay_loop)
                     {
-                      *isRouted = NO;
-                      *doForward = NO;
+                      *isRouted = GNUNET_NO;
+                      *doForward = GNUNET_NO;
                       return 10;
                     }
                   else
                     {
-                      *isRouted = YES;
-                      *doForward = NO;
+                      *isRouted = GNUNET_YES;
+                      *doForward = GNUNET_NO;
                       return 11;
                     }
                 }
               else
                 {
-                  *isRouted = NO;
-                  *doForward = NO;
+                  *isRouted = GNUNET_NO;
+                  *doForward = GNUNET_NO;
                   return 12;
                 }
             }
@@ -1295,13 +1313,15 @@
              receiver */
           int isttlHigher;
           if (ite->ttl < new_ttl)
-            isttlHigher = NO;
+            isttlHigher = GNUNET_NO;
           else
-            isttlHigher = YES;
-          if (OK == addToSlot (ITE_GROW, ite, query, ttl, priority, sender))
+            isttlHigher = GNUNET_YES;
+          if (GNUNET_OK ==
+              addToSlot (ITE_GNUNET_array_grow, ite, query, ttl, priority,
+                         sender))
             {
-              *isRouted = YES;
-              *doForward = NO;
+              *isRouted = GNUNET_YES;
+              *doForward = GNUNET_NO;
               return 13;
             }
           else
@@ -1310,7 +1330,7 @@
               /* 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;
+              *doForward = GNUNET_NO;
               return 14;
             }
         }
@@ -1325,16 +1345,16 @@
     {
       /* we have seen the unique answer, get rid of it early */
       addToSlot (ITE_REPLACE, ite, query, ttl, priority, sender);
-      *isRouted = YES;
-      *doForward = YES;
+      *isRouted = GNUNET_YES;
+      *doForward = GNUNET_YES;
       return 15;
     }
   /* Another still valid query is using the slot.  Now we need a _really_
      good reason to discard it... */
   if (ttl < 0)
     {
-      *isRouted = NO;
-      *doForward = NO;
+      *isRouted = GNUNET_NO;
+      *doForward = GNUNET_NO;
       if (stats != NULL)
         stats->change (stat_routing_collisions, 1);
       return 16;                /* if new ttl is "expired", don't bother with 
priorities */
@@ -1354,21 +1374,21 @@
       (long long) 10 * (ttl * ite->priority))
     {
       addToSlot (ITE_REPLACE, ite, query, ttl, priority, sender);
-      *isRouted = YES;
-      *doForward = YES;
+      *isRouted = GNUNET_YES;
+      *doForward = GNUNET_YES;
       return 17;
     }
-  if (weak_randomi (TIE_BREAKER_CHANCE) == 0)
+  if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, TIE_BREAKER_CHANCE) == 0)
     {
       addToSlot (ITE_REPLACE, ite, query, ttl, priority, sender);
-      *isRouted = YES;
-      *doForward = YES;
+      *isRouted = GNUNET_YES;
+      *doForward = GNUNET_YES;
       return 20;
     }
   /* sadly, the slot is busy with something else; we can
      not even add ourselves to the reply set */
-  *isRouted = NO;
-  *doForward = NO;
+  *isRouted = GNUNET_NO;
+  *doForward = GNUNET_NO;
   if (stats != NULL)
     stats->change (stat_routing_collisions, 1);
 
@@ -1382,19 +1402,19 @@
  * @param msg the message to route
  */
 static void
-sendReply (IndirectionTableEntry * ite, const MESSAGE_HEADER * msg)
+sendReply (IndirectionTableEntry * ite, const GNUNET_MessageHeader * msg)
 {
   unsigned int j;
   unsigned int maxDelay;
-  cron_t now;
-  PeerIdentity recv;
+  GNUNET_CronTime now;
+  GNUNET_PeerIdentity recv;
 #if DEBUG_GAP
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   if (stats != NULL)
     stats->change (stat_routing_successes, 1);
-  now = get_time ();
+  now = GNUNET_get_time ();
   if (now < ite->ttl)
     maxDelay = ite->ttl - now;
   else
@@ -1406,7 +1426,7 @@
 #if DEBUG_GAP
       IF_GELOG (ectx,
                 GE_DEBUG | GE_REQUEST | GE_USER,
-                hash2enc (&recv.hashPubKey, &enc));
+                GNUNET_hash_to_enc (&recv.hashPubKey, &enc));
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "GAP sending reply to `%s'\n", &enc);
@@ -1421,7 +1441,7 @@
 {
   DataContainer **values;
   unsigned int valueCount;
-  HashCode512 query;
+  GNUNET_HashCode query;
 };
 
 /**
@@ -1437,7 +1457,7 @@
  *  the type ID).
  */
 static int
-queryLocalResultCallback (const HashCode512 * primaryKey,
+queryLocalResultCallback (const GNUNET_HashCode * primaryKey,
                           const DataContainer * value, void *closure)
 {
   struct qLRC *cls = closure;
@@ -1445,19 +1465,19 @@
 
 #if EXTRA_CHECKS
   /* verify data is valid */
-  uri (value, ANY_BLOCK, YES, primaryKey);
+  uri (value, ANY_BLOCK, GNUNET_YES, primaryKey);
 #endif
   /* check seen */
   if ((cls->valueCount > MAX_SEEN_VALUES) &&
-      (weak_randomi (cls->valueCount) > 8))
-    return OK;                  /* statistical drop, too many replies to keep 
in memory */
+      (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, cls->valueCount) > 8))
+    return GNUNET_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)))
-      return OK;                /* drop, duplicate entry in DB! */
-  GROW (cls->values, cls->valueCount, cls->valueCount + 1);
-  cls->values[cls->valueCount - 1] = MALLOC (ntohl (value->size));
+      return GNUNET_OK;         /* drop, duplicate entry in DB! */
+  GNUNET_array_grow (cls->values, cls->valueCount, cls->valueCount + 1);
+  cls->values[cls->valueCount - 1] = GNUNET_malloc (ntohl (value->size));
   memcpy (cls->values[cls->valueCount - 1], value, ntohl (value->size));
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1465,7 +1485,7 @@
  * the query is added to the routing table and the content is looked
  * for locally. If the content is available locally, a deferred
  * response is simulated with a cron job and the local content is
- * marked as valueable. The method returns OK if the query should
+ * marked as valueable. The method returns GNUNET_OK if the query should
  * subsequently be routed to other peers.
  *
  * @param sender next hop in routing of the reply, NULL for us
@@ -1473,13 +1493,13 @@
  * @param prio the effective priority of the query
  * @param ttl the relative ttl of the query
  * @param query the query itself
- * @return OK/YES if the query will be routed further,
- *         NO if we already found the one and only response,
- *         SYSERR if not (out of resources)
+ * @return GNUNET_OK/GNUNET_YES if the query will be routed further,
+ *         GNUNET_NO if we already found the one and only response,
+ *         GNUNET_SYSERR if not (out of resources)
  */
 static int
-execQuery (const PeerIdentity * sender,
-           const PeerIdentity * target,
+execQuery (const GNUNET_PeerIdentity * sender,
+           const GNUNET_PeerIdentity * target,
            unsigned int prio,
            QUERY_POLICY policy, int ttl, const P2P_gap_query_MESSAGE * query)
 {
@@ -1488,23 +1508,23 @@
   struct qLRC cls;
   int i;
   int max;
-  int *perm;
+  unsigned int *perm;
   int doForward;
   PID_INDEX senderID;
 #if DEBUG_GAP
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   /* Load above hard limit? */
   if (loadTooHigh ())
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (rhf == NULL)
-    return SYSERR;              /* not fully initialized */
+    return GNUNET_SYSERR;       /* not fully initialized */
 
   senderID = intern_pid (sender);
   GE_ASSERT (ectx, (senderID != 0) || (sender == NULL));
   ite = &ROUTING_indTable_[computeRoutingIndex (&query->queries[0])];
-  MUTEX_LOCK (lookup_exclusion);
+  GNUNET_mutex_lock (lookup_exclusion);
   i = -1;
   if (sender != NULL)
     {
@@ -1517,8 +1537,8 @@
         }
       else
         {
-          isRouted = NO;
-          doForward = NO;
+          isRouted = GNUNET_NO;
+          doForward = GNUNET_NO;
           if (stats != NULL)
             {
               if ((policy & QUERY_ANSWER) > 0)
@@ -1531,16 +1551,16 @@
   else
     {
       addReward (&query->queries[0], prio);
-      isRouted = YES;
-      doForward = YES;
+      isRouted = GNUNET_YES;
+      doForward = GNUNET_YES;
     }
   if ((policy & QUERY_FORWARD) == 0)
-    doForward = NO;
+    doForward = GNUNET_NO;
 
 #if DEBUG_GAP
   IF_GELOG (ectx,
             GE_DEBUG | GE_REQUEST | GE_USER,
-            hash2enc (&query->queries[0], &enc));
+            GNUNET_hash_to_enc (&query->queries[0], &enc));
   ((char *) &enc)[6] = '\0';
   GE_LOG (ectx,
           GE_INFO | GE_IMMEDIATE | GE_USER,
@@ -1553,21 +1573,25 @@
   cls.values = NULL;
   cls.valueCount = 0;
   cls.query = query->queries[0];
-  if ((isRouted == YES) &&      /* if we can't route, lookup useless! */
+  if ((isRouted == GNUNET_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);
+                    -
+                    sizeof (P2P_gap_query_MESSAGE)) /
+               sizeof (GNUNET_HashCode), &query->queries[0],
+               &queryLocalResultCallback, &cls);
     }
 
   if (cls.valueCount > 0)
     {
-      perm = permute (WEAK, cls.valueCount);
-      max = os_network_monitor_get_load (coreAPI->load_monitor, Download);
+      perm = GNUNET_permute (GNUNET_RANDOM_QUALITY_WEAK, cls.valueCount);
+      max =
+        GNUNET_network_monitor_get_load (coreAPI->load_monitor,
+                                         GNUNET_ND_DOWNLOAD);
       if (max > 100)
         max = 100;
       if (max == -1)
@@ -1581,34 +1605,35 @@
       for (i = 0; i < cls.valueCount; i++)
         {
           if ((i == 0) &&
-              (SYSERR == bs->put (bs->closure,
-                                  &query->queries[0],
-                                  cls.values[perm[i]], ite->priority)))
+              (GNUNET_SYSERR == bs->put (bs->closure,
+                                         &query->queries[0],
+                                         cls.values[perm[i]], ite->priority)))
             {
               GE_BREAK (NULL, 0);
-              FREE (cls.values[perm[i]]);
+              GNUNET_free (cls.values[perm[i]]);
               continue;
             }
           if ((i < max) &&
               (sender != NULL) &&
-              (YES == queueReply (sender,
-                                  &query->queries[0],
-                                  cls.values[perm[i]])) && (stats != NULL))
+              (GNUNET_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 */
-          if (uri (cls.values[perm[i]], ite->type, NO,  /* no need to verify 
local results! */
+          if (uri (cls.values[perm[i]], ite->type, GNUNET_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]]);
+            doForward = GNUNET_NO;      /* we have the one and only answer,
+                                           do not bother to forward... */
+          GNUNET_free (cls.values[perm[i]]);
         }
-      FREE (perm);
+      GNUNET_free (perm);
     }
-  GROW (cls.values, cls.valueCount, 0);
-  MUTEX_UNLOCK (lookup_exclusion);
+  GNUNET_array_grow (cls.values, cls.valueCount, 0);
+  GNUNET_mutex_unlock (lookup_exclusion);
   if (doForward)
     forwardQuery (query, target, sender);
   change_pid_rc (senderID, -1);
@@ -1630,11 +1655,12 @@
  *         priority of the original request)
  */
 static int
-useContent (const PeerIdentity * host, const MESSAGE_HEADER * pmsg)
+useContent (const GNUNET_PeerIdentity * host,
+            const GNUNET_MessageHeader * pmsg)
 {
   const P2P_gap_reply_MESSAGE *msg;
   unsigned int i;
-  HashCode512 contentHC;
+  GNUNET_HashCode contentHC;
   IndirectionTableEntry *ite;
   unsigned int size;
   int ret;
@@ -1643,21 +1669,21 @@
   double preference;
   PID_INDEX hostId;
 #if DEBUG_GAP
-  EncName enc;
-  EncName enc2;
+  GNUNET_EncName enc;
+  GNUNET_EncName enc2;
 #endif
 
   if (ntohs (pmsg->size) < sizeof (P2P_gap_reply_MESSAGE))
     {
       GE_BREAK_OP (ectx, 0);
-      return SYSERR;            /* invalid! */
+      return GNUNET_SYSERR;     /* invalid! */
     }
   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));
-  hash2enc (&msg->primaryKey, &enc2);
+            if (host != NULL) GNUNET_hash_to_enc (&host->hashPubKey, &enc));
+  GNUNET_hash_to_enc (&msg->primaryKey, &enc2);
   ((char *) &enc2)[6] = '\0';
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -1666,7 +1692,7 @@
 #endif
 
   ite = &ROUTING_indTable_[computeRoutingIndex (&msg->primaryKey)];
-  ite->successful_local_lookup_in_delay_loop = NO;
+  ite->successful_local_lookup_in_delay_loop = GNUNET_NO;
   size = ntohs (msg->header.size) - sizeof (P2P_gap_reply_MESSAGE);
   prio = 0;
 
@@ -1674,52 +1700,53 @@
     {
       if (stats != NULL)
         stats->change (stat_routing_reply_drops, 1);
-      return OK;                /* not fully initialized! */
+      return GNUNET_OK;         /* not fully initialized! */
     }
-  value = MALLOC (size + sizeof (DataContainer));
+  value = GNUNET_malloc (size + sizeof (DataContainer));
   value->size = htonl (size + sizeof (DataContainer));
   memcpy (&value[1], &msg[1], size);
   rhf (value, &contentHC);
 
   /* FIRST: check if valid */
   ret = bs->put (bs->closure, &msg->primaryKey, value, 0);
-  if (ret == SYSERR)
+  if (ret == GNUNET_SYSERR)
     {
-      EncName enc;
+      GNUNET_EncName enc;
 
       IF_GELOG (ectx,
                 GE_ERROR | GE_BULK | GE_USER,
-                if (host != NULL) hash2enc (&host->hashPubKey, &enc));
-      GE_LOG (ectx,
-              GE_ERROR | GE_BULK | GE_USER,
+                if (host != NULL) GNUNET_hash_to_enc (&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_BREAK_OP (ectx, 0);
-      FREE (value);
-      return SYSERR;            /* invalid */
+      GNUNET_free (value);
+      return GNUNET_SYSERR;     /* invalid */
     }
 
   /* SECOND: check if seen */
-  MUTEX_LOCK (lookup_exclusion);
+  GNUNET_mutex_lock (lookup_exclusion);
   for (i = 0; i < ite->seenIndex; i++)
     {
-      if (equalsHashCode512 (&contentHC, &ite->seen[i]))
+      if (0 == memcmp (&contentHC, &ite->seen[i], sizeof (GNUNET_HashCode)))
         {
-          MUTEX_UNLOCK (lookup_exclusion);
-          FREE (value);
+          GNUNET_mutex_unlock (lookup_exclusion);
+          GNUNET_free (value);
           if (stats != NULL)
             stats->change (stat_routing_reply_dups, 1);
           return 0;             /* seen before, useless */
         }
     }
-  MUTEX_UNLOCK (lookup_exclusion);
+  GNUNET_mutex_unlock (lookup_exclusion);
 
 
   /* THIRD: compute content priority/value and
      send remote reply (ITE processing) */
   hostId = intern_pid (host);
-  MUTEX_LOCK (lookup_exclusion);
-  if (equalsHashCode512 (&ite->primaryKey, &msg->primaryKey))
+  GNUNET_mutex_lock (lookup_exclusion);
+  if (0 ==
+      memcmp (&ite->primaryKey, &msg->primaryKey, sizeof (GNUNET_HashCode)))
     {
       prio = ite->priority;
       ite->priority = 0;
@@ -1736,23 +1763,24 @@
                     ite->destination[ite->hostsWaiting - 1];
                   if (stats != NULL)
                     stats->change (stat_memory_destinations, -1);
-                  GROW (ite->destination,
-                        ite->hostsWaiting, ite->hostsWaiting - 1);
+                  GNUNET_array_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);
+      GNUNET_array_grow (ite->seen, 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->seenReplyWasUnique = uri (value, ite->type, GNUNET_NO,   /* 
already verified */
                                          &ite->primaryKey);
         }
       else
         {
-          ite->seenReplyWasUnique = NO;
+          ite->seenReplyWasUnique = GNUNET_NO;
         }
       sendReply (ite, &msg->header);
       if (ite->seenIndex > MAX_SEEN_VALUES * 2)
@@ -1774,7 +1802,7 @@
       if (stats != NULL)
         stats->change (stat_routing_reply_drops, 1);
     }
-  MUTEX_UNLOCK (lookup_exclusion);
+  GNUNET_mutex_unlock (lookup_exclusion);
   prio += claimReward (&msg->primaryKey);
 
   /* FOURTH: update content priority in local datastore */
@@ -1784,13 +1812,13 @@
     }
 
   /* FIFTH: if unique reply, stop querying */
-  if (uri (value, ite->type, NO,        /* already verified */
+  if (uri (value, ite->type, GNUNET_NO, /* already verified */
            &ite->primaryKey))
     {
       /* unique reply, stop forwarding! */
       dequeueQuery (&ite->primaryKey);
     }
-  FREE (value);
+  GNUNET_free (value);
 
   /* SIXTH: adjust traffic preferences */
   if (host != NULL)
@@ -1804,7 +1832,7 @@
       coreAPI->preferTrafficFrom (host, preference);
     }
   change_pid_rc (hostId, -1);
-  return OK;
+  return GNUNET_OK;
 }
 
 /* ***************** GAP API implementation ***************** */
@@ -1813,7 +1841,7 @@
  * Start GAP.
  *
  * @param datastore the storage callbacks to use for storing data
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
 init (Blockstore * datastore, UniqueReplyIdentifier uid, ReplyHashFunction rh)
@@ -1821,12 +1849,12 @@
   if (bs != NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   bs = datastore;
   uri = uid;
   rhf = rh;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1842,27 +1870,29 @@
  * @param keys the keys to query for
  * @param timeout how long to wait until this operation should
  *        automatically time-out
- * @return OK if we will start to query, SYSERR if all of our
- *  buffers are full or other error, NO if we already
+ * @return GNUNET_OK if we will start to query, GNUNET_SYSERR if all of our
+ *  buffers are full or other error, GNUNET_NO if we already
  *  returned the one and only reply (local hit)
  */
 static int
-get_start (const PeerIdentity * target,
+get_start (const GNUNET_PeerIdentity * target,
            unsigned int type,
            unsigned int anonymityLevel,
            unsigned int keyCount,
-           const HashCode512 * keys, cron_t timeout, unsigned int prio)
+           const GNUNET_HashCode * keys, GNUNET_CronTime timeout,
+           unsigned int prio)
 {
   P2P_gap_query_MESSAGE *msg;
   unsigned int size;
   int ret;
 
   size =
-    sizeof (P2P_gap_query_MESSAGE) + (keyCount - 1) * sizeof (HashCode512);
-  if (size >= MAX_BUFFER_SIZE)
+    sizeof (P2P_gap_query_MESSAGE) + (keyCount -
+                                      1) * sizeof (GNUNET_HashCode);
+  if (size >= GNUNET_MAX_BUFFER_SIZE)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;            /* too many keys! */
+      return GNUNET_SYSERR;     /* too many keys! */
     }
 
   /* anonymity level considerations:
@@ -1881,16 +1911,17 @@
                   GE_ERROR | GE_BULK | GE_USER,
                   _
                   ("Cover traffic requested but traffic service not loaded.  
Rejecting request.\n"));
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      if (OK != traffic->get ((TTL_DECREMENT + timeout) / TRAFFIC_TIME_UNIT,
-                              P2P_PROTO_gap_QUERY,
-                              TC_RECEIVED, &count, &peers, &sizes, &timevect))
+      if (GNUNET_OK !=
+          traffic->get ((TTL_DECREMENT + timeout) / TRAFFIC_TIME_UNIT,
+                        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"));
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (anonymityLevel > 1000)
         {
@@ -1900,7 +1931,7 @@
                       GE_WARNING | GE_BULK | GE_USER,
                       _
                       ("Cannot satisfy desired level of anonymity, ignoring 
request.\n"));
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
           if (count < anonymityLevel % 1000)
             {
@@ -1908,7 +1939,7 @@
                       GE_WARNING | GE_BULK | GE_USER,
                       _
                       ("Cannot satisfy desired level of anonymity, ignoring 
request.\n"));
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
         }
       else
@@ -1919,26 +1950,26 @@
                       GE_WARNING | GE_BULK | GE_USER,
                       _
                       ("Cannot satisfy desired level of anonymity, ignoring 
request.\n"));
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
         }
     }
 
 
-  msg = MALLOC (size);
+  msg = GNUNET_malloc (size);
   msg->header.size = htons (size);
   msg->header.type = htons (P2P_PROTO_gap_QUERY);
   msg->type = htonl (type);
   msg->priority = htonl (prio);
-  msg->ttl = htonl (adjustTTL ((int) timeout - get_time (), prio));
-  memcpy (&msg->queries[0], keys, sizeof (HashCode512) * keyCount);
+  msg->ttl = htonl (adjustTTL ((int) timeout - GNUNET_get_time (), prio));
+  memcpy (&msg->queries[0], keys, sizeof (GNUNET_HashCode) * keyCount);
   msg->returnTo = *coreAPI->myIdentity;
   ret = execQuery (NULL,
                    target,
                    prio,
                    QUERY_ANSWER | QUERY_FORWARD | QUERY_INDIRECT,
-                   timeout - get_time (), msg);
-  FREE (msg);
+                   timeout - GNUNET_get_time (), msg);
+  GNUNET_free (msg);
   return ret;
 }
 
@@ -1948,10 +1979,11 @@
  * stop it earlier.
  */
 static int
-get_stop (unsigned int type, unsigned int keyCount, const HashCode512 * keys)
+get_stop (unsigned int type, unsigned int keyCount,
+          const GNUNET_HashCode * keys)
 {
   if (keyCount < 1)
-    return SYSERR;
+    return GNUNET_SYSERR;
   return dequeueQuery (&keys[0]);
 }
 
@@ -1966,7 +1998,7 @@
  */
 static unsigned int
 tryMigrate (const DataContainer * data,
-            const HashCode512 * primaryKey,
+            const GNUNET_HashCode * primaryKey,
             char *position, unsigned int padding)
 {
   P2P_gap_reply_MESSAGE *reply;
@@ -1975,7 +2007,7 @@
   size =
     sizeof (P2P_gap_reply_MESSAGE) + ntohl (data->size) -
     sizeof (DataContainer);
-  if ((size > padding) || (size >= MAX_BUFFER_SIZE))
+  if ((size > padding) || (size >= GNUNET_MAX_BUFFER_SIZE))
     return 0;
   reply = (P2P_gap_reply_MESSAGE *) position;
   reply->header.type = htons (P2P_PROTO_gap_RESULT);
@@ -1990,7 +2022,8 @@
  * lookup, forward or even indirect.
  */
 static int
-handleQuery (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+handleQuery (const GNUNET_PeerIdentity * sender,
+             const GNUNET_MessageHeader * msg)
 {
   QUERY_POLICY policy;
   P2P_gap_query_MESSAGE *qmsg;
@@ -1999,7 +2032,7 @@
   unsigned int prio;
   double preference;
 #if DEBUG_GAP
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   if (bs == NULL)
@@ -2015,30 +2048,31 @@
         {
           IF_GELOG (ectx,
                     GE_DEBUG | GE_REQUEST | GE_USER,
-                    hash2enc (&sender->hashPubKey, &enc));
+                    GNUNET_hash_to_enc (&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);
 #endif
-      return OK;
+      return GNUNET_OK;
     }
   queries = 1 + (ntohs (msg->size) - sizeof (P2P_gap_query_MESSAGE))
-    / sizeof (HashCode512);
+    / sizeof (GNUNET_HashCode);
   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 (GNUNET_HashCode)))
     {
       GE_BREAK_OP (ectx, 0);
-      return SYSERR;            /* malformed query */
+      return GNUNET_SYSERR;     /* malformed query */
     }
 
-  qmsg = MALLOC (ntohs (msg->size));
+  qmsg = GNUNET_malloc (ntohs (msg->size));
   memcpy (qmsg, msg, ntohs (msg->size));
-  if (equalsHashCode512 (&qmsg->returnTo.hashPubKey,
-                         &coreAPI->myIdentity->hashPubKey))
+  if (0 == memcmp (&qmsg->returnTo.hashPubKey,
+                   &coreAPI->myIdentity->hashPubKey,
+                   sizeof (GNUNET_HashCode)))
     {
       /* A to B, B sends to C without source rewriting,
          C sends back to A again without source rewriting;
@@ -2046,8 +2080,8 @@
          in this case, A must just drop; however, this
          should not happen (peers should check). */
       GE_BREAK_OP (ectx, 0);
-      FREE (qmsg);
-      return OK;
+      GNUNET_free (qmsg);
+      return GNUNET_OK;
     }
   if (stats != NULL)
     stats->change (stat_routing_totals, 1);
@@ -2056,25 +2090,29 @@
   ttl = ntohl (qmsg->ttl);
   if (ttl < 0)
     {
-      ttl = ttl - 2 * TTL_DECREMENT - weak_randomi (TTL_DECREMENT);
+      ttl =
+        ttl - 2 * TTL_DECREMENT -
+        GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, TTL_DECREMENT);
       if (ttl > 0)
         {                       /* integer underflow => drop (should be very 
rare)! */
-          FREE (qmsg);
+          GNUNET_free (qmsg);
           if (stats != NULL)
             stats->change (stat_routing_direct_drops, 1);
-          return OK;            /* just abort */
+          return GNUNET_OK;     /* just abort */
         }
     }
   else
     {
-      ttl = ttl - 2 * TTL_DECREMENT - weak_randomi (TTL_DECREMENT);
+      ttl =
+        ttl - 2 * TTL_DECREMENT -
+        GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, TTL_DECREMENT);
     }
   prio = ntohl (qmsg->priority);
   policy = evaluateQuery (sender, &prio);
 #if DEBUG_GAP
   IF_GELOG (ectx,
             GE_DEBUG | GE_REQUEST | GE_USER,
-            hash2enc (&qmsg->queries[0], &enc));
+            GNUNET_hash_to_enc (&qmsg->queries[0], &enc));
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Received GAP query `%s'.\n", &enc);
@@ -2083,12 +2121,12 @@
     {
       /* policy says no answer/forward/indirect => direct drop;
          this happens if the peer is too busy (netload-up >= 100%).  */
-      FREE (qmsg);
+      GNUNET_free (qmsg);
 #if DEBUG_GAP
       if (sender != NULL)
         {
           IF_GELOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-                    hash2enc (&sender->hashPubKey, &enc));
+                    GNUNET_hash_to_enc (&sender->hashPubKey, &enc));
         }
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
@@ -2097,7 +2135,7 @@
 #endif
       if (stats != NULL)
         stats->change (stat_routing_direct_drops, 1);
-      return OK;                /* straight drop. */
+      return GNUNET_OK;         /* straight drop. */
     }
   preference = (double) prio;
   if ((policy & QUERY_INDIRECT) > 0)
@@ -2122,8 +2160,8 @@
   if (ttl < 0)
     ttl = 0;
   execQuery (sender, NULL, prio, policy, ttl, qmsg);
-  FREE (qmsg);
-  return OK;
+  GNUNET_free (qmsg);
+  return GNUNET_OK;
 }
 
 static unsigned int
@@ -2168,8 +2206,8 @@
       || (-1 ==
           GC_get_configuration_value_number (cfg, "GAP", "TABLESIZE",
                                              MIN_INDIRECTION_TABLE_SIZE,
-                                             MAX_MALLOC_CHECKED /
-                                             sizeof (IndirectionTableEntry),
+                                             GNUNET_MAX_GNUNET_malloc_CHECKED
+                                             / sizeof (IndirectionTableEntry),
                                              MIN_INDIRECTION_TABLE_SIZE,
                                              &indirectionTableSize)))
     return NULL;
@@ -2231,7 +2269,7 @@
         stats->create (gettext_noop ("# gap response weights"));
     }
   init_pid_table (ectx, stats);
-  GROW (rewards, rewardSize, MAX_REWARD_TRACKS);
+  GNUNET_array_grow (rewards, rewardSize, MAX_REWARD_TRACKS);
 
 
   identity = coreAPI->requestService ("identity");
@@ -2245,15 +2283,15 @@
               _
               ("Traffic service failed to load; gap cannot ensure 
cover-traffic availability.\n"));
     }
-  random_qsel = weak_randomi (0xFFFF);
-  lookup_exclusion = MUTEX_CREATE (NO);
+  random_qsel = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 0xFFFF);
+  lookup_exclusion = GNUNET_mutex_create (GNUNET_NO);
   ROUTING_indTable_
-    = MALLOC (sizeof (IndirectionTableEntry) * indirectionTableSize);
+    = GNUNET_malloc (sizeof (IndirectionTableEntry) * indirectionTableSize);
   memset (ROUTING_indTable_,
           0, sizeof (IndirectionTableEntry) * indirectionTableSize);
   for (i = 0; i < indirectionTableSize; i++)
     {
-      ROUTING_indTable_[i].successful_local_lookup_in_delay_loop = NO;
+      ROUTING_indTable_[i].successful_local_lookup_in_delay_loop = GNUNET_NO;
     }
 
   for (i = 0; i < QUERY_RECORD_COUNT; i++)
@@ -2262,7 +2300,8 @@
       queries[i].msg = NULL;
     }
   lock = coreAPI->getConnectionModuleLock ();
-  cron_add_job (capi->cron, &ageRTD, 2 * cronMINUTES, 2 * cronMINUTES, NULL);
+  GNUNET_cron_add_job (capi->cron, &ageRTD, 2 * GNUNET_CRON_MINUTES,
+                       2 * GNUNET_CRON_MINUTES, NULL);
 
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -2294,17 +2333,17 @@
   coreAPI->unregisterSendCallback (sizeof (P2P_gap_query_MESSAGE),
                                    &fillInQuery);
 
-  cron_del_job (coreAPI->cron, &ageRTD, 2 * cronMINUTES, NULL);
+  GNUNET_cron_del_job (coreAPI->cron, &ageRTD, 2 * GNUNET_CRON_MINUTES, NULL);
 
   for (i = 0; i < indirectionTableSize; i++)
     {
       ite = &ROUTING_indTable_[i];
       resetSeen (ite);
-      ite->seenReplyWasUnique = NO;
+      ite->seenReplyWasUnique = GNUNET_NO;
       resetDestinations (ite);
     }
 
-  MUTEX_DESTROY (lookup_exclusion);
+  GNUNET_mutex_destroy (lookup_exclusion);
   lookup_exclusion = NULL;
   while (rtdList != NULL)
     {
@@ -2314,12 +2353,12 @@
         {
           rpos = pos->responseList;
           pos->responseList = rpos->next;
-          FREE (rpos);
+          GNUNET_free (rpos);
         }
-      FREE (pos);
+      GNUNET_free (pos);
     }
   for (i = 0; i < QUERY_RECORD_COUNT; i++)
-    FREENONNULL (queries[i].msg);
+    GNUNET_free_non_null (queries[i].msg);
 
   coreAPI->releaseService (identity);
   identity = NULL;
@@ -2330,8 +2369,8 @@
       coreAPI->releaseService (traffic);
       traffic = NULL;
     }
-  FREE (ROUTING_indTable_);
-  GROW (rewards, rewardSize, 0);
+  GNUNET_free (ROUTING_indTable_);
+  GNUNET_array_grow (rewards, rewardSize, 0);
   done_pid_table ();
   if (stats != NULL)
     {

Modified: GNUnet/src/applications/gap/gap.h
===================================================================
--- GNUnet/src/applications/gap/gap.h   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/gap/gap.h   2007-11-23 11:51:54 UTC (rev 5742)
@@ -37,7 +37,7 @@
 #include "gnunet_topology_service.h"
 #include "pid_table.h"
 
-#define DEBUG_GAP NO
+#define DEBUG_GAP GNUNET_NO
 
 #define EXTRA_CHECKS ALLOW_EXTRA_CHECKS
 
@@ -46,10 +46,10 @@
 
 /**
  * Until which load do we consider the peer idle and do not
- * charge at all? (should be larger than IDLE_LOAD_THRESHOLD used
+ * charge at all? (should be larger than GNUNET_IDLE_LOAD_THRESHOLD used
  * by the rest of the code)!
  */
-#define GAP_IDLE_LOAD_THRESHOLD ((100 + IDLE_LOAD_THRESHOLD) / 2)
+#define GAP_IDLE_LOAD_THRESHOLD ((100 + GNUNET_IDLE_LOAD_THRESHOLD) / 2)
 
 /**
  * For how many different hosts can we have a query pending (at most).
@@ -69,7 +69,7 @@
  * accordance to your network latency (above the time it'll take you
  * to send a packet and get a reply).
  */
-#define TTL_DECREMENT 5 * cronSECONDS
+#define TTL_DECREMENT 5 * GNUNET_CRON_SECONDS
 
 /**
  * Send answer if local files match
@@ -120,7 +120,7 @@
  * How much is a query worth 'in general' (even
  * if there is no trust relationship between
  * the peers!).  Multiplied by the number of queries
- * in the request.  20 is for '20 bytes / hash',
+ * in the request.  20 is for '20 bytes / GNUNET_hash',
  * so this is kind of the base unit.
  */
 #define BASE_QUERY_PRIORITY 20
@@ -168,7 +168,7 @@
  * the other peer will make that slot available.  This is the
  * probability that one will give in.  And yes, it's a hack.  It
  * may not be needed anymore once we add collision-resistance to
- * the routing hash table.
+ * the routing GNUNET_hash table.
  */
 #define TIE_BREAKER_CHANCE 4
 
@@ -189,7 +189,7 @@
  * ITE modes for addToSlot.
  */
 #define ITE_REPLACE 0
-#define ITE_GROW 1
+#define ITE_GNUNET_array_grow 1
 
 
 /* **************** Types ****************** */
@@ -205,7 +205,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Type of the query (block type).
@@ -218,20 +218,20 @@
   unsigned int priority;
 
   /**
-   * Relative time to live in cronMILLIS (network byte order)
+   * Relative time to live in GNUNET_CRON_MILLISECONDS (network byte order)
    */
   int ttl;
 
   /**
    * To whom to return results?
    */
-  PeerIdentity returnTo;
+  GNUNET_PeerIdentity returnTo;
 
   /**
    * Hashcodes of the file(s) we're looking for.
    * Details depend on the query type.
    */
-  HashCode512 queries[1];
+  GNUNET_HashCode queries[1];
 
 } P2P_gap_query_MESSAGE;
 
@@ -240,9 +240,9 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
-  HashCode512 primaryKey;
+  GNUNET_HashCode primaryKey;
 
 } P2P_gap_reply_MESSAGE;
 
@@ -284,7 +284,7 @@
   /**
    * When do we stop forwarding (!) this query?
    */
-  cron_t expires;
+  GNUNET_CronTime expires;
 
   /**
    * To which peer will we never send this message?
@@ -322,7 +322,7 @@
   /**
    * What are we waiting for?
    */
-  HashCode512 primaryKey;
+  GNUNET_HashCode primaryKey;
 
   /**
    * For what type of reply are we waiting?
@@ -332,7 +332,7 @@
   /**
    * How much is this query worth to us, that is, how much would
    * this node be willing to "pay" for an answer that matches the
-   * hash stored in this ITE? (This is NOT the inbound priority,
+   * GNUNET_hash stored in this ITE? (This is NOT the inbound priority,
    * it is the trust-adjusted inbound priority.)
    */
   unsigned int priority;
@@ -340,19 +340,19 @@
   /**
    * When can we forget about this entry?
    */
-  cron_t ttl;
+  GNUNET_CronTime ttl;
 
   /**
    * Which replies have we already seen?
    */
   unsigned int seenIndex;
 
-  int seenReplyWasUnique;       /* YES/NO, only valid if seenIndex == 1 */
+  int seenReplyWasUnique;       /* GNUNET_YES/GNUNET_NO, only valid if 
seenIndex == 1 */
 
   /**
    * Hashcodes of the encrypted (!) replies that we have forwarded so far
    */
-  HashCode512 *seen;
+  GNUNET_HashCode *seen;
 
   /**
    * Who are these hosts?
@@ -419,7 +419,7 @@
    * for this client.  Used to discard old entries
    * eventually.
    */
-  TIME_T lastReplyReceived;
+  GNUNET_Int32Time lastReplyReceived;
 } ReplyTrackData;
 
 /**
@@ -428,6 +428,6 @@
  */
 typedef struct
 {
-  HashCode512 query;
+  GNUNET_HashCode query;
   unsigned int prio;
 } RewardEntry;

Modified: GNUnet/src/applications/gap/gaptest.c
===================================================================
--- GNUnet/src/applications/gap/gaptest.c       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/gap/gaptest.c       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -41,13 +41,14 @@
 static int
 testTerminate (void *unused)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 
 static void
 uprogress (unsigned long long totalBytes,
-           unsigned long long completedBytes, cron_t eta, void *closure)
+           unsigned long long completedBytes, GNUNET_CronTime eta,
+           void *closure)
 {
   fprintf (stderr, totalBytes == completedBytes ? "\n" : ".");
 }
@@ -55,7 +56,7 @@
 static void
 dprogress (unsigned long long totalBytes,
            unsigned long long completedBytes,
-           cron_t eta,
+           GNUNET_CronTime eta,
            unsigned long long lastBlockOffset,
            const char *lastBlock, unsigned int lastBlockSize, void *closure)
 {
@@ -68,11 +69,11 @@
 {
   char *fn;
 
-  fn = MALLOC (strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14);
-  SNPRINTF (fn,
-            strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14,
-            "/tmp/gnunet-gaptest/GAPTEST%u", i);
-  disk_directory_create_for_file (NULL, fn);
+  fn = GNUNET_malloc (strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14,
+                   "/tmp/gnunet-gaptest/GAPTEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -87,21 +88,23 @@
   int i;
 
   name = makeName (size);
-  fd = disk_file_open (ectx, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
-  buf = MALLOC (size);
+  fd =
+    GNUNET_disk_file_open (ectx, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
+  buf = GNUNET_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]);
+  for (i = 0; i < (int) (size - 42 - sizeof (GNUNET_HashCode));
+       i += sizeof (GNUNET_HashCode))
+    GNUNET_hash (&buf[i + sizeof (GNUNET_HashCode)], 42,
+                 (GNUNET_HashCode *) & buf[i]);
   WRITE (fd, buf, size);
-  FREE (buf);
-  disk_file_close (ectx, name, fd);
-  ret = ECRS_uploadFile (ectx, cfg, name, YES,  /* index */
+  GNUNET_free (buf);
+  GNUNET_disk_file_close (ectx, name, fd);
+  ret = ECRS_uploadFile (ectx, cfg, name, GNUNET_YES,   /* index */
                          0,     /* anon */
                          0,     /* prio */
-                         get_time () + 10 * cronMINUTES,        /* expire */
+                         GNUNET_get_time () + 10 * GNUNET_CRON_MINUTES, /* 
expire */
                          &uprogress, NULL, &testTerminate, NULL, &uri);
-  if (ret != SYSERR)
+  if (ret != GNUNET_SYSERR)
     {
       struct ECRS_MetaData *meta;
       struct ECRS_URI *key;
@@ -112,12 +115,12 @@
 
       meta = ECRS_createMetaData ();
       key = ECRS_keywordsToUri (keywords);
-      ret = ECRS_addToKeyspace (ectx, cfg, key, 0, 0, get_time () + 10 * 
cronMINUTES,   /* expire */
+      ret = ECRS_addToKeyspace (ectx, cfg, key, 0, 0, GNUNET_get_time () + 10 
* GNUNET_CRON_MINUTES,    /* expire */
                                 uri, meta);
       ECRS_freeMetaData (meta);
       ECRS_freeUri (uri);
-      FREE (name);
-      if (ret == OK)
+      GNUNET_free (name);
+      if (ret == GNUNET_OK)
         {
           return key;
         }
@@ -129,14 +132,14 @@
     }
   else
     {
-      FREE (name);
+      GNUNET_free (name);
       return NULL;
     }
 }
 
 static int
 searchCB (const ECRS_FileInfo * fi,
-          const HashCode512 * key, int isRoot, void *closure)
+          const GNUNET_HashCode * key, int isRoot, void *closure)
 {
   struct ECRS_URI **my = closure;
   char *tmp;
@@ -144,15 +147,15 @@
   tmp = ECRS_uriToString (fi->uri);
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER, "Search found URI `%s'\n", tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   GE_ASSERT (ectx, NULL == *my);
   *my = ECRS_dupUri (fi->uri);
-  return SYSERR;                /* abort search */
+  return GNUNET_SYSERR;         /* abort search */
 }
 
 /**
  * @param *uri In: keyword URI, out: file URI
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 static int
 searchFile (struct ECRS_URI **uri)
@@ -165,14 +168,14 @@
                      cfg,
                      *uri,
                      0,
-                     15 * cronSECONDS,
+                     15 * GNUNET_CRON_SECONDS,
                      &searchCB, &myURI, &testTerminate, NULL);
   ECRS_freeUri (*uri);
   *uri = myURI;
-  if ((ret != SYSERR) && (myURI != NULL))
-    return OK;
+  if ((ret != GNUNET_SYSERR) && (myURI != NULL))
+    return GNUNET_OK;
   else
-    return SYSERR;
+    return GNUNET_SYSERR;
 }
 
 static int
@@ -190,33 +193,35 @@
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Starting download of `%s'\n", tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   tmpName = makeName (0);
-  ret = SYSERR;
-  if (OK == ECRS_downloadFile (ectx,
-                               cfg,
-                               uri,
-                               tmpName,
-                               0, &dprogress, NULL, &testTerminate, NULL))
+  ret = GNUNET_SYSERR;
+  if (GNUNET_OK == ECRS_downloadFile (ectx,
+                                      cfg,
+                                      uri,
+                                      tmpName,
+                                      0, &dprogress, NULL, &testTerminate,
+                                      NULL))
     {
 
-      fd = disk_file_open (ectx, tmpName, O_RDONLY);
-      buf = MALLOC (size);
-      in = MALLOC (size);
+      fd = GNUNET_disk_file_open (ectx, tmpName, O_RDONLY);
+      buf = GNUNET_malloc (size);
+      in = GNUNET_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]);
+      for (i = 0; i < (int) (size - 42 - sizeof (GNUNET_HashCode));
+           i += sizeof (GNUNET_HashCode))
+        GNUNET_hash (&buf[i + sizeof (GNUNET_HashCode)], 42,
+                     (GNUNET_HashCode *) & buf[i]);
       if (size != READ (fd, in, size))
-        ret = SYSERR;
+        ret = GNUNET_SYSERR;
       else if (0 == memcmp (buf, in, size))
-        ret = OK;
-      FREE (buf);
-      FREE (in);
-      disk_file_close (ectx, tmpName, fd);
+        ret = GNUNET_OK;
+      GNUNET_free (buf);
+      GNUNET_free (in);
+      GNUNET_disk_file_close (ectx, tmpName, fd);
     }
   UNLINK (tmpName);
-  FREE (tmpName);
+  GNUNET_free (tmpName);
   return ret;
 }
 
@@ -229,8 +234,8 @@
   name = makeName (size);
   ret = ECRS_unindexFile (ectx, cfg, name, NULL, NULL, &testTerminate, NULL);
   if (0 != UNLINK (name))
-    ret = SYSERR;
-  FREE (name);
+    ret = GNUNET_SYSERR;
+  GNUNET_free (name);
   return ret;
 }
 
@@ -245,19 +250,19 @@
 int
 main (int argc, char **argv)
 {
-  struct DaemonContext *peers;
+  struct GNUNET_TESTING_DaemonContext *peers;
   int ret;
   struct ECRS_URI *uri;
 
   ret = 0;
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_PEERS
-  peers = gnunet_testing_start_daemons ("tcp",
+  peers = GNUNET_TESTING_start_daemons ("tcp",
                                         "advertising topology fs stats",
                                         "/tmp/gnunet-gap-test",
                                         2087, 10000, 2);
@@ -268,9 +273,9 @@
       return -1;
     }
 #endif
-  if (OK != gnunet_testing_connect_daemons (2087, 12087))
+  if (GNUNET_OK != GNUNET_TESTING_connect_daemons (2087, 12087))
     {
-      gnunet_testing_stop_daemons (peers);
+      GNUNET_TESTING_stop_daemons (peers);
       fprintf (stderr, "Failed to connect the peers!\n");
       GC_free (cfg);
       return -1;
@@ -281,17 +286,17 @@
   GC_set_configuration_value_string (cfg,
                                      ectx,
                                      "NETWORK", "HOST", "localhost:12087");
-  CHECK (OK == searchFile (&uri));
-  CHECK (OK == downloadFile (12345, uri));
+  CHECK (GNUNET_OK == searchFile (&uri));
+  CHECK (GNUNET_OK == downloadFile (12345, uri));
   ECRS_freeUri (uri);
   GC_set_configuration_value_string (cfg,
                                      ectx,
                                      "NETWORK", "HOST", "localhost:2087");
-  CHECK (OK == unindexFile (12345));
+  CHECK (GNUNET_OK == unindexFile (12345));
 
 FAILURE:
 #if START_PEERS
-  gnunet_testing_stop_daemons (peers);
+  GNUNET_TESTING_stop_daemons (peers);
 #endif
 
   GC_free (cfg);

Modified: GNUnet/src/applications/gap/gaptest2.c
===================================================================
--- GNUnet/src/applications/gap/gaptest2.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/gap/gaptest2.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -48,12 +48,13 @@
 static int
 testTerminate (void *unused)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
 uprogress (unsigned long long totalBytes,
-           unsigned long long completedBytes, cron_t eta, void *closure)
+           unsigned long long completedBytes, GNUNET_CronTime eta,
+           void *closure)
 {
   fprintf (stderr, totalBytes == completedBytes ? "\n" : ".");
 }
@@ -61,7 +62,7 @@
 static void
 dprogress (unsigned long long totalBytes,
            unsigned long long completedBytes,
-           cron_t eta,
+           GNUNET_CronTime eta,
            unsigned long long lastBlockOffset,
            const char *lastBlock, unsigned int lastBlockSize, void *closure)
 {
@@ -73,11 +74,11 @@
 {
   char *fn;
 
-  fn = MALLOC (strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14);
-  SNPRINTF (fn,
-            strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14,
-            "/tmp/gnunet-gaptest/GAPTEST%u", i);
-  disk_directory_create_for_file (NULL, fn);
+  fn = GNUNET_malloc (strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14,
+                   "/tmp/gnunet-gaptest/GAPTEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -92,23 +93,24 @@
   int i;
 
   name = makeName (size);
-  fd = disk_file_open (ectx, 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)]);
+  fd =
+    GNUNET_disk_file_open (ectx, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
+  buf = GNUNET_malloc (size);
+  memset (buf, size / 253, sizeof (GNUNET_HashCode));
+  for (i = 0; i < size - sizeof (GNUNET_HashCode);
+       i += sizeof (GNUNET_HashCode))
+    GNUNET_hash (&buf[i], sizeof (GNUNET_HashCode),
+                 (GNUNET_HashCode *) & buf[i + sizeof (GNUNET_HashCode)]);
   WRITE (fd, buf, size);
-  FREE (buf);
-  disk_file_close (ectx, name, fd);
-  ret = ECRS_uploadFile (ectx, cfg, name, YES,  /* index */
+  GNUNET_free (buf);
+  GNUNET_disk_file_close (ectx, name, fd);
+  ret = ECRS_uploadFile (ectx, cfg, name, GNUNET_YES,   /* index */
                          1,     /* anon */
                          0,     /* prio */
-                         get_time () + 100 * cronMINUTES,       /* expire */
+                         GNUNET_get_time () + 100 * GNUNET_CRON_MINUTES,       
 /* expire */
                          &uprogress,    /* progress */
                          NULL, &testTerminate, NULL, &uri);
-  if (ret != SYSERR)
+  if (ret != GNUNET_SYSERR)
     {
       struct ECRS_MetaData *meta;
       struct ECRS_URI *key;
@@ -119,12 +121,12 @@
 
       meta = ECRS_createMetaData ();
       key = ECRS_keywordsToUri (keywords);
-      ret = ECRS_addToKeyspace (ectx, cfg, key, 0, 0, get_time () + 100 * 
cronMINUTES,  /* expire */
+      ret = ECRS_addToKeyspace (ectx, cfg, key, 0, 0, GNUNET_get_time () + 100 
* GNUNET_CRON_MINUTES,   /* expire */
                                 uri, meta);
       ECRS_freeMetaData (meta);
       ECRS_freeUri (uri);
-      FREE (name);
-      if (ret == OK)
+      GNUNET_free (name);
+      if (ret == GNUNET_OK)
         {
           return key;
         }
@@ -136,14 +138,14 @@
     }
   else
     {
-      FREE (name);
+      GNUNET_free (name);
       return NULL;
     }
 }
 
 static int
 searchCB (const ECRS_FileInfo * fi,
-          const HashCode512 * key, int isRoot, void *closure)
+          const GNUNET_HashCode * key, int isRoot, void *closure)
 {
   struct ECRS_URI **my = closure;
   char *tmp;
@@ -151,15 +153,15 @@
   tmp = ECRS_uriToString (fi->uri);
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "Search found URI `%s'\n", tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   GE_ASSERT (ectx, NULL == *my);
   *my = ECRS_dupUri (fi->uri);
-  return SYSERR;                /* abort search */
+  return GNUNET_SYSERR;         /* abort search */
 }
 
 /**
  * @param *uri In: keyword URI, out: file URI
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 static int
 searchFile (struct ECRS_URI **uri)
@@ -172,14 +174,14 @@
                      cfg,
                      *uri,
                      1,
-                     1450 * cronSECONDS,
+                     1450 * GNUNET_CRON_SECONDS,
                      &searchCB, &myURI, &testTerminate, NULL);
   ECRS_freeUri (*uri);
   *uri = myURI;
-  if ((ret != SYSERR) && (myURI != NULL))
-    return OK;
+  if ((ret != GNUNET_SYSERR) && (myURI != NULL))
+    return GNUNET_OK;
   else
-    return SYSERR;
+    return GNUNET_SYSERR;
 }
 
 static int
@@ -197,34 +199,35 @@
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Starting download of `%s'\n", tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   tmpName = makeName (0);
-  ret = SYSERR;
-  if (OK == ECRS_downloadFile (ectx,
-                               cfg,
-                               uri,
-                               tmpName,
-                               1, &dprogress, NULL, &testTerminate, NULL))
+  ret = GNUNET_SYSERR;
+  if (GNUNET_OK == ECRS_downloadFile (ectx,
+                                      cfg,
+                                      uri,
+                                      tmpName,
+                                      1, &dprogress, NULL, &testTerminate,
+                                      NULL))
     {
 
-      fd = disk_file_open (ectx, 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)]);
+      fd = GNUNET_disk_file_open (ectx, tmpName, O_RDONLY);
+      buf = GNUNET_malloc (size);
+      in = GNUNET_malloc (size);
+      memset (buf, size / 253, sizeof (GNUNET_HashCode));
+      for (i = 0; i < size - sizeof (GNUNET_HashCode);
+           i += sizeof (GNUNET_HashCode))
+        GNUNET_hash (&buf[i], sizeof (GNUNET_HashCode),
+                     (GNUNET_HashCode *) & buf[i + sizeof (GNUNET_HashCode)]);
       if (size != READ (fd, in, size))
-        ret = SYSERR;
+        ret = GNUNET_SYSERR;
       else if (0 == memcmp (buf, in, size))
-        ret = OK;
-      FREE (buf);
-      FREE (in);
-      disk_file_close (ectx, tmpName, fd);
+        ret = GNUNET_OK;
+      GNUNET_free (buf);
+      GNUNET_free (in);
+      GNUNET_disk_file_close (ectx, tmpName, fd);
     }
   UNLINK (tmpName);
-  FREE (tmpName);
+  GNUNET_free (tmpName);
   return ret;
 }
 
@@ -237,8 +240,8 @@
   name = makeName (size);
   ret = ECRS_unindexFile (ectx, cfg, name, NULL, NULL, &testTerminate, NULL);
   if (0 != UNLINK (name))
-    ret = SYSERR;
-  FREE (name);
+    ret = GNUNET_SYSERR;
+  GNUNET_free (name);
   return ret;
 }
 
@@ -251,22 +254,22 @@
 int
 main (int argc, char **argv)
 {
-  struct DaemonContext *peers;
+  struct GNUNET_TESTING_DaemonContext *peers;
   int ret;
   struct ECRS_URI *uri;
   int i;
   char buf[128];
-  cron_t start;
+  GNUNET_CronTime start;
 
   ret = 0;
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_PEERS
-  peers = gnunet_testing_start_daemons ("tcp",
+  peers = GNUNET_TESTING_start_daemons ("tcp",
                                         "advertising topology fs stats",
                                         "/tmp/gnunet-gap-test2",
                                         2087, 10, PEER_COUNT);
@@ -279,10 +282,10 @@
 #endif
   for (i = 1; i < PEER_COUNT; i++)
     {
-      if (OK != gnunet_testing_connect_daemons (2077 + (10 * i),
-                                                2087 + (10 * i)))
+      if (GNUNET_OK != GNUNET_TESTING_connect_daemons (2077 + (10 * i),
+                                                       2087 + (10 * i)))
         {
-          gnunet_testing_stop_daemons (peers);
+          GNUNET_TESTING_stop_daemons (peers);
           fprintf (stderr, "Failed to connect the peers!\n");
           GC_free (cfg);
           return -1;
@@ -292,24 +295,25 @@
   printf ("Uploading...\n");
   uri = uploadFile (SIZE);
   CHECK (NULL != uri);
-  SNPRINTF (buf, 128, "localhost:%u", 2077 + PEER_COUNT * 10);
+  GNUNET_snprintf (buf, 128, "localhost:%u", 2077 + PEER_COUNT * 10);
   GC_set_configuration_value_string (cfg, ectx, "NETWORK", "HOST", buf);
-  CHECK (OK == searchFile (&uri));
+  CHECK (GNUNET_OK == searchFile (&uri));
   printf ("Search successful!\n");
-  start = get_time ();
+  start = GNUNET_get_time ();
   printf ("Downloading...\n");
-  CHECK (OK == downloadFile (SIZE, uri));
+  CHECK (GNUNET_OK == downloadFile (SIZE, uri));
   printf ("Download successful at %llu kbps!\n",
-          (SIZE / 1024) / ((get_time () - start) / cronSECONDS));
+          (SIZE / 1024) / ((GNUNET_get_time () - start) /
+                           GNUNET_CRON_SECONDS));
   ECRS_freeUri (uri);
   GC_set_configuration_value_string (cfg,
                                      ectx,
                                      "NETWORK", "HOST", "localhost:2087");
-  CHECK (OK == unindexFile (SIZE));
+  CHECK (GNUNET_OK == unindexFile (SIZE));
 
 FAILURE:
 #if START_PEERS
-  gnunet_testing_stop_daemons (peers);
+  GNUNET_TESTING_stop_daemons (peers);
 #endif
 
   GC_free (cfg);

Modified: GNUnet/src/applications/gap/gaptest3.c
===================================================================
--- GNUnet/src/applications/gap/gaptest3.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/gap/gaptest3.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -48,12 +48,13 @@
 static int
 testTerminate (void *unused)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
 uprogress (unsigned long long totalBytes,
-           unsigned long long completedBytes, cron_t eta, void *closure)
+           unsigned long long completedBytes, GNUNET_CronTime eta,
+           void *closure)
 {
   fprintf (stderr, totalBytes == completedBytes ? "\n" : ".");
 }
@@ -61,7 +62,7 @@
 static void
 dprogress (unsigned long long totalBytes,
            unsigned long long completedBytes,
-           cron_t eta,
+           GNUNET_CronTime eta,
            unsigned long long lastBlockOffset,
            const char *lastBlock, unsigned int lastBlockSize, void *closure)
 {
@@ -73,11 +74,11 @@
 {
   char *fn;
 
-  fn = MALLOC (strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14);
-  SNPRINTF (fn,
-            strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14,
-            "/tmp/gnunet-gaptest/GAPTEST%u", i);
-  disk_directory_create_for_file (NULL, fn);
+  fn = GNUNET_malloc (strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14);
+  GNUNET_snprintf (fn,
+                   strlen ("/tmp/gnunet-gaptest/GAPTEST") + 14,
+                   "/tmp/gnunet-gaptest/GAPTEST%u", i);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
   return fn;
 }
 
@@ -92,22 +93,24 @@
   int i;
 
   name = makeName (size);
-  fd = disk_file_open (ectx, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
-  buf = MALLOC_LARGE (size);
+  fd =
+    GNUNET_disk_file_open (ectx, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
+  buf = GNUNET_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]);
+  for (i = 0; i < (int) (size - 42 - sizeof (GNUNET_HashCode));
+       i += sizeof (GNUNET_HashCode))
+    GNUNET_hash (&buf[i + sizeof (GNUNET_HashCode)], 42,
+                 (GNUNET_HashCode *) & buf[i]);
   WRITE (fd, buf, size);
-  FREE (buf);
-  disk_file_close (ectx, name, fd);
-  ret = ECRS_uploadFile (ectx, cfg, name, YES,  /* index */
+  GNUNET_free (buf);
+  GNUNET_disk_file_close (ectx, name, fd);
+  ret = ECRS_uploadFile (ectx, cfg, name, GNUNET_YES,   /* index */
                          1,     /* anon */
                          0,     /* prio */
-                         get_time () + 100 * cronMINUTES,       /* expire */
+                         GNUNET_get_time () + 100 * GNUNET_CRON_MINUTES,       
 /* expire */
                          &uprogress, NULL, &testTerminate, NULL, &uri);
-  FREE (name);
-  if (ret != SYSERR)
+  GNUNET_free (name);
+  if (ret != GNUNET_SYSERR)
     return uri;
   return NULL;
 }
@@ -127,64 +130,67 @@
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Starting download of `%s'\n", tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   tmpName = makeName (0);
-  ret = SYSERR;
-  if (OK == ECRS_downloadFile (ectx,
-                               cfg,
-                               uri,
-                               tmpName,
-                               1, &dprogress, NULL, &testTerminate, NULL))
+  ret = GNUNET_SYSERR;
+  if (GNUNET_OK == ECRS_downloadFile (ectx,
+                                      cfg,
+                                      uri,
+                                      tmpName,
+                                      1, &dprogress, NULL, &testTerminate,
+                                      NULL))
     {
 
-      fd = disk_file_open (ectx, tmpName, O_RDONLY);
-      buf = MALLOC (size);
-      in = MALLOC (size);
+      fd = GNUNET_disk_file_open (ectx, tmpName, O_RDONLY);
+      buf = GNUNET_malloc (size);
+      in = GNUNET_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]);
+      for (i = 0; i < (int) (size - 42 - sizeof (GNUNET_HashCode));
+           i += sizeof (GNUNET_HashCode))
+        GNUNET_hash (&buf[i + sizeof (GNUNET_HashCode)], 42,
+                     (GNUNET_HashCode *) & buf[i]);
       if (size != READ (fd, in, size))
-        ret = SYSERR;
+        ret = GNUNET_SYSERR;
       else if (0 == memcmp (buf, in, size))
-        ret = OK;
-      FREE (buf);
-      FREE (in);
-      disk_file_close (ectx, tmpName, fd);
+        ret = GNUNET_OK;
+      GNUNET_free (buf);
+      GNUNET_free (in);
+      GNUNET_disk_file_close (ectx, tmpName, fd);
     }
   UNLINK (tmpName);
-  FREE (tmpName);
+  GNUNET_free (tmpName);
   return ret;
 }
 
 #define CHECK(a) if (!(a)) { ret = 1; GE_BREAK(ectx, 0); goto FAILURE; }
 
-static PeerIdentity goodPeers[PEER_COUNT];
+static GNUNET_PeerIdentity goodPeers[PEER_COUNT];
 static unsigned int goodPeerPos;
 
 static int
 infoCallback (void *data,
-              const PeerIdentity * identity,
+              const GNUNET_PeerIdentity * identity,
               const void *address,
               unsigned int addr_len,
-              cron_t last_seen, unsigned int trust, unsigned int bpmFromPeer)
+              GNUNET_CronTime last_seen, unsigned int trust,
+              unsigned int bpmFromPeer)
 {
   int i;
   int good;
-  EncName enc;
+  GNUNET_EncName enc;
 
   good = 0;
   for (i = 0; i < goodPeerPos; i++)
-    if (0 == memcmp (&goodPeers[i], identity, sizeof (PeerIdentity)))
+    if (0 == memcmp (&goodPeers[i], identity, sizeof (GNUNET_PeerIdentity)))
       good = 1;
-  hash2enc (&identity->hashPubKey, &enc);
+  GNUNET_hash_to_enc (&identity->hashPubKey, &enc);
   if (good)
     printf ("Good peer `%8s' has trust %u and bandwidth %u\n",
             (const char *) &enc, trust, bpmFromPeer);
   else
     printf ("Poor peer `%8s' has trust %u and bandwidth %u\n",
             (const char *) &enc, trust, bpmFromPeer);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -194,25 +200,25 @@
 int
 main (int argc, char **argv)
 {
-  struct DaemonContext *peers;
+  struct GNUNET_TESTING_DaemonContext *peers;
   int ret;
   struct ECRS_URI *uri;
   int i;
   char buf[128];
-  P2P_hello_MESSAGE *hello;
-  struct ClientServerConnection *sock;
-  cron_t start;
-  EncName enc;
+  GNUNET_MessageHello *hello;
+  struct GNUNET_ClientServerConnection *sock;
+  GNUNET_CronTime start;
+  GNUNET_EncName enc;
 
   ret = 0;
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
       return -1;
     }
 #if START_PEERS
-  peers = gnunet_testing_start_daemons ("tcp",
+  peers = GNUNET_TESTING_start_daemons ("tcp",
                                         "advertising topology fs stats",
                                         "/tmp/gnunet-gap-test3",
                                         2087, 10, PEER_COUNT);
@@ -226,9 +232,9 @@
   /* connect as star-topology */
   for (i = 1; i < PEER_COUNT; i++)
     {
-      if (OK != gnunet_testing_connect_daemons (2087, 2087 + 10 * i))
+      if (GNUNET_OK != GNUNET_TESTING_connect_daemons (2087, 2087 + 10 * i))
         {
-          gnunet_testing_stop_daemons (peers);
+          GNUNET_TESTING_stop_daemons (peers);
           fprintf (stderr, "Failed to connect the peers!\n");
           GC_free (cfg);
           return -1;
@@ -239,44 +245,45 @@
   goodPeerPos = 0;
   for (i = 1; i < PEER_COUNT; i += 2)
     {
-      SNPRINTF (buf, 128, "localhost:%u", 2087 + i * 10);
+      GNUNET_snprintf (buf, 128, "localhost:%u", 2087 + i * 10);
       GC_set_configuration_value_string (cfg, ectx, "NETWORK", "HOST", buf);
-      sock = client_connection_create (NULL, cfg);
-      if (OK != gnunet_identity_get_self (sock, &hello))
+      sock = GNUNET_client_connection_create (NULL, cfg);
+      if (GNUNET_OK != GNUNET_IDENTITY_get_self (sock, &hello))
         {
-          connection_destroy (sock);
+          GNUNET_client_connection_destroy (sock);
           GE_BREAK (NULL, 0);
           break;
         }
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
       if (uri != NULL)
         ECRS_freeUri (uri);
-      hash2enc (&hello->senderIdentity.hashPubKey, &enc);
+      GNUNET_hash_to_enc (&hello->senderIdentity.hashPubKey, &enc);
       printf ("Uploading to peer `%8s'\n", (const char *) &enc);
       uri = uploadFile (SIZE);
       CHECK (NULL != uri);
 
       goodPeers[goodPeerPos++] = hello->senderIdentity;
-      FREE (hello);
+      GNUNET_free (hello);
 
     }
   GC_set_configuration_value_string (cfg,
                                      ectx,
                                      "NETWORK", "HOST", "localhost:2087");
   printf ("Downloading...\n");
-  start = get_time ();
-  CHECK (OK == downloadFile (SIZE, uri));
+  start = GNUNET_get_time ();
+  CHECK (GNUNET_OK == downloadFile (SIZE, uri));
   printf ("Download complete - %f kbps.\n",
-          SIZE / 1024 * 1.0 * cronSECONDS / (1 + get_time () - start));
+          SIZE / 1024 * 1.0 * GNUNET_CRON_SECONDS / (1 + GNUNET_get_time () -
+                                                     start));
   /* verify trust values have developed as expected */
 
-  sock = client_connection_create (NULL, cfg);
-  gnunet_identity_request_peer_infos (sock, &infoCallback, NULL);
-  connection_destroy (sock);
+  sock = GNUNET_client_connection_create (NULL, cfg);
+  GNUNET_IDENTITY_request_peer_infos (sock, &infoCallback, NULL);
+  GNUNET_client_connection_destroy (sock);
 
 FAILURE:
 #if START_PEERS
-  gnunet_testing_stop_daemons (peers);
+  GNUNET_TESTING_stop_daemons (peers);
 #endif
   GC_free (cfg);
   return ret;

Modified: GNUnet/src/applications/gap/pid_table.c
===================================================================
--- GNUnet/src/applications/gap/pid_table.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/gap/pid_table.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,7 +43,7 @@
   /**
    * the identifier itself
    */
-  HashCode512 id;
+  GNUNET_HashCode id;
 
   /**
    * reference counter
@@ -55,11 +55,11 @@
 
 static PID_Entry *table;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 
 PID_INDEX
-intern_pid (const PeerIdentity * pid)
+intern_pid (const GNUNET_PeerIdentity * pid)
 {
   PID_INDEX ret;
   PID_INDEX zero;
@@ -67,11 +67,11 @@
   if (pid == NULL)
     return 0;
   zero = size;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (ret = 1; ret < size; ret++)
     {
       if (0 == memcmp (&pid->hashPubKey,
-                       &table[ret].id, sizeof (HashCode512)))
+                       &table[ret].id, sizeof (GNUNET_HashCode)))
         {
           table[ret].rc++;
           if (stats != NULL)
@@ -80,7 +80,7 @@
               if (table[ret].rc == 1)
                 stats->change (stat_pid_entries, 1);
             }
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           return ret;
         }
       else if ((zero == size) && (table[ret].rc == 0))
@@ -91,14 +91,14 @@
   ret = zero;
   if (ret == size)
     {
-      GROW (table, size, size + 16);
+      GNUNET_array_grow (table, size, size + 16);
     }
   if (ret == 0)
     ret = 1;
   GE_ASSERT (ectx, ret < size);
   table[ret].id = pid->hashPubKey;
   table[ret].rc = 1;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   if (stats != NULL)
     {
       stats->change (stat_pid_rc, 1);
@@ -114,7 +114,7 @@
   PID_INDEX id;
   if (count == 0)
     return;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = count - 1; i >= 0; i--)
     {
       id = ids[i];
@@ -124,7 +124,7 @@
       if ((table[id].rc == 0) && (stats != NULL))
         stats->change (stat_pid_entries, -1);
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   if (stats != NULL)
     stats->change (stat_pid_rc, -count);
 }
@@ -134,7 +134,7 @@
 {
   if (id == 0)
     return;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   GE_ASSERT (ectx, id < size);
   GE_ASSERT (ectx, table[id].rc > 0);
   table[id].rc +=